import React from 'react'; import { registerPlugin } from '@wordpress/plugins'; import { PluginSidebar } from '@wordpress/edit-post'; import { PanelBody, Icon } from '@wordpress/components'; import { withSelect } from '@wordpress/data'; import UISidebarSelectControl from '../UIComponents/UISidebarSelectControl'; import SidebarSprocketIcon from '../Common/SidebarSprocketIcon'; import styled from 'styled-components'; import { __ } from '@wordpress/i18n'; export function registerHubspotSidebar() { const ContentTypeLabelStyle = styled.div` white-space: normal; text-transform: none; `; const ContentTypeLabel = ( {__( 'Select the content type HubSpot Analytics uses to track this page.', 'leadin' )} ); const LeadinPluginSidebar = ({ postType }: { postType: string }) => postType ? ( } > ) : null; const LeadinPluginSidebarWrapper = withSelect((select: Function) => { const data = select('core/editor'); return { postType: data && data.getCurrentPostType() && data.getEditedPostAttribute('meta'), }; })(LeadinPluginSidebar); registerPlugin('leadin', { render: LeadinPluginSidebarWrapper, icon: SidebarSprocketIcon, }); }