HEX
Server: LiteSpeed
System: Linux neo.webimonline.com 5.14.0-687.12.1.el9_8.x86_64 #1 SMP PREEMPT_DYNAMIC Sun Jun 7 14:39:27 EDT 2026 x86_64
User: smarimaki (1290)
PHP: 7.4.33
Disabled: mail
Upload Files
File: /home/smarimaki/public_html/wp-content/plugins/leadin/scripts/utils/withMetaData.ts
import { withSelect, withDispatch, select } from '@wordpress/data';

// from answer here: https://github.com/WordPress/gutenberg/issues/44477#issuecomment-1263026599
export const isFullSiteEditor = () => {
  return select && !!select('core/edit-site');
};

const applyWithSelect = withSelect((select: Function, props: any): any => {
  return {
    metaValue: select('core/editor').getEditedPostAttribute('meta')[
      props.metaKey
    ],
  };
});

const applyWithDispatch = withDispatch(
  (dispatch: Function, props: any): any => {
    return {
      setMetaValue(value: string) {
        dispatch('core/editor').editPost({ meta: { [props.metaKey]: value } });
      },
    };
  }
);

function apply<T>(el: T): T {
  return applyWithSelect(applyWithDispatch(el));
}

export default apply;