HEX
Server: Apache
System: Linux ecngx285.inmotionhosting.com 4.18.0-553.79.1.lve.el8.x86_64 #1 SMP Wed Oct 15 17:59:35 UTC 2025 x86_64
User: zeusxp5 (3862)
PHP: 8.3.28
Disabled: NONE
Upload Files
File: /home/zeusxp5/lrliberia.com/wp-content/themes/lifttruck/resources/js/metabox-fields.js
(function() { 'use strict';

  const { registerPlugin } = wp.plugins;
  const { PluginSidebar, PluginSidebarMoreMenuItem } = wp.editPost;
  const { __ } = wp.i18n;
  const { PanelBody, TextControl, ToggleControl, SelectControl  } = wp.components;
  const { withSelect, withDispatch } = wp.data;
  const { compose } = wp.compose;

  //------- Meta box Fields --------
  const PageMetaFields = ({ postType, postMeta, setPostMeta }) => {
    if ('page' !== postType) return null;
    return (
      <>
        <PanelBody
          title={__('Header Options', 'lifttruck')}
          icon=""
          initialOpen={true}
        >
          <SelectControl
            label="Header Settings"
            value={postMeta.wd_custom_header_options}
            options={[
              { label: 'Use Default', value: 'default' },
              { label: 'Use Custom', value: 'custom' }
            ]}
            onChange={(value) => setPostMeta({ wd_custom_header_options: value })}
            __nextHasNoMarginBottom
          />
          
          { postMeta.wd_custom_header_options == 'custom' && (
              <ToggleControl
                label={__('Enable Sticky Header', 'lifttruck')}
                onChange={(value) => setPostMeta({ wd_sticky_header: value })}
                checked={postMeta.wd_sticky_header}
              />)
            } 

          { postMeta.wd_custom_header_options == 'custom' && (
              <ToggleControl
              label={__('Enable Transparent Header', 'lifttruck')}
              onChange={(value) => setPostMeta({ wd_transparent_header: value })}
              checked={postMeta.wd_transparent_header}
            />)
            }

          { (postMeta.wd_custom_header_options == 'custom' && postMeta.wd_transparent_header) && (
              <ToggleControl
              label={__('Enable Header Cap', 'lifttruck')}
              onChange={(value) => setPostMeta({ wd_header_cap: value })}
              checked={postMeta.wd_header_cap}
            />)
            }

        </PanelBody>
      </>
    );
  }
  //---- compose / save metabox ----------
  const EnhancedPageMetaFields = compose(
    withSelect((select) => {
      return {
        postMeta: select('core/editor').getEditedPostAttribute('meta'),
        postType: select('core/editor').getCurrentPostType(),
      };
    }),
    withDispatch((dispatch) => {
      return {
        setPostMeta(newMeta) {
          dispatch('core/editor').editPost({ meta: newMeta });
        }
      };
    })
  )(PageMetaFields);

  //--------- register plugin ---
  registerPlugin('lifttruck-page-sidebar', {
    icon: 'admin-post',
    render: () => (
      <>
        <PluginSidebarMoreMenuItem target="lifttruck-page-sidebar">
          {__('LiftTruck Page Options', 'lifttruck')}
        </PluginSidebarMoreMenuItem>
        <PluginSidebar name="lifttruck-page-sidebar" title={__('Page Options', 'lifttruck')}>
          <EnhancedPageMetaFields />
        </PluginSidebar>
      </>
    ),
  });

} )();