# leadin/11.0.52/scripts/utils/withMetaData.ts

HubSpot All-In-One Marketing – Forms, Popups, Live Chat, version 11.0.52. 26 lines.

- Page: https://pluginprobe.com/plugins/leadin/11.0.52/code/scripts/utils/withMetaData.ts
- Raw: https://pluginprobe.com/plugins/leadin/11.0.52/raw/scripts/utils/withMetaData.ts
- Modified: 2024-04-11T14:35:44+00:00

Line numbers below start at 1. Link to a line or a range by appending a fragment to the
page URL, for example `https://pluginprobe.com/plugins/leadin/11.0.52/code/scripts/utils/withMetaData.ts#L10-L20`.

```typescript
import { withSelect, withDispatch } from '@wordpress/data';

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;

```
