/** * Meta Options build. */ import { useState } from 'react'; import { PluginSidebar, PluginSidebarMoreMenuItem } from '@wordpress/edit-post'; import { compose } from '@wordpress/compose'; import { withSelect, withDispatch } from '@wordpress/data'; import AstCheckboxControl from './ast-checkbox.js'; import AstRadioImageControl from './ast-radio-image.js'; import AstSelectorControl from './ast-selector.js'; import svgIcons from '../../../../assets/svg/svgs.json'; import { SelectControl, PanelBody, Modal } from '@wordpress/components'; import parse from 'html-react-parser'; const { __ } = wp.i18n; const MetaSettings = props => { const modalIcon = parse( svgIcons['meta-popup-icon'] ); const brandIcon = astMetaParams.isWhiteLabelled ? '' : parse( svgIcons['astra-brand-icon'] ); const [ isOpen, setOpen ] = useState( false ); const openModal = () => setOpen( true ); const closeModal = () => setOpen( false ); // Adjust spacing & borders for table. const topTableSpacing = ; const bottomTableSpacing = ; const icon = parse( svgIcons['astra-meta-settings'] ); const sidebarOptions = Object.entries( astMetaParams.sidebar_options ).map( ( [ key, name ] ) => { return ( { label: name, value: key } ); } ); const contentLayoutOptions = Object.entries( astMetaParams.content_layout ).map( ( [ key, name ] ) => { return ( { label: name, value: key } ); } ); // Taransparent and Sticky Header Options. const headerOptions = Object.entries( astMetaParams.header_options ).map( ( [ key, name ] ) => { return ( { label: name, value: key } ); } ); // Page header optins. const pageHeaderOptions = Object.entries( astMetaParams.page_header_options ).map( ( [ key, name ] ) => { return ( { label: name, value: key } ); } ); // Checkbox control const disableSections = Object.entries( astMetaParams.disable_sections ).map( ( [ key, value ] ) => { let sectionValue = ( 'disabled' === props.meta[value['key']] ) ? true : false; return ( { props.setMetaFieldValue( val, value['key'] ); } } />); }); const headers_meta_options = Object.entries( astMetaParams.headers_meta_options ).map( ( [ key, value ] ) => { let sectionValue = ( 'disabled' === props.meta[value['key']] ) ? true : false; return ( { props.setMetaFieldValue( val, value['key'] ); } } />); }); // Checkbox control const stickyHeadderOptions = Object.entries( astMetaParams.sticky_header_options ).map( ( [ key, value ] ) => { let stickyValue = ( 'disabled' === props.meta[value['key']] ) ? true : false; return ( { props.setMetaFieldValue( val, value['key'] ); } } />); }); return ( <> {/* Meta settings icon */} { astMetaParams.title } {/* Meta seetings popup area */}
{/* Content Layout Setting */}
{ props.setMetaFieldValue( val, 'site-content-layout' ); } } />
{/* Sidebar Setting */}
{ props.setMetaFieldValue( val, 'site-sidebar-layout' ); } } />
{/* Disable Section Setting */}
{ disableSections }
{ ( undefined !== props.meta['ast-global-header-display'] && 'disabled' !== props.meta['ast-global-header-display'] ) &&

} {/* Header related all settings */} { isOpen && (
{ topTableSpacing } { bottomTableSpacing } { topTableSpacing } { bottomTableSpacing } {/* Sticky Header Setting */} { 'disabled' !== props.meta['ast-main-header-display'] && astMetaParams.is_addon_activated && astMetaParams.sticky_addon_enabled && <> { topTableSpacing } { topTableSpacing } } { astMetaParams.is_addon_activated && astMetaParams.sticky_addon_enabled && 'enabled' == props.meta['stick-header-meta'] && <> { topTableSpacing } }
{/* Individual header settings. */} { headers_meta_options }
{/* Transparent Header Setting */}
{ props.setMetaFieldValue( val, 'theme-transparent-header-meta' ); } } />
{ props.setMetaFieldValue( val, 'stick-header-meta' ); } } />
{stickyHeadderOptions}
{ __( 'Make sure to update your post for changes to take effect.', 'astra' ) }
) } {/* Page Header Setting */} { ( astMetaParams.is_bb_themer_layout && astMetaParams.is_addon_activated && astMetaParams.page_header_availability ) &&
{ props.setMetaFieldValue( val, 'adv-header-id-meta' ); } } />

{ __( 'If you would like to apply custom header for this page, select the one from the list above. Page headers can be created and customized from ', 'astra' ) } { __( 'here.', 'astra' ) }

}
); } export default compose( withSelect( ( select ) => { const postMeta = select( 'core/editor' ).getEditedPostAttribute( 'meta' ); const oldPostMeta = select( 'core/editor' ).getCurrentPostAttribute( 'meta' ); return { meta: { ...oldPostMeta, ...postMeta }, oldMeta: oldPostMeta, }; } ), withDispatch( ( dispatch ) => ( { setMetaFieldValue: ( value, field ) => dispatch( 'core/editor' ).editPost( { meta: { [ field ]: value } } ), } ) ), )( MetaSettings );