2025-01-17 13:59:17 +01:00
|
|
|
/**
|
|
|
|
* Store Configuration: Defines and registers the settings data store.
|
|
|
|
*
|
|
|
|
* Creates a Redux-style store with WordPress data layer integration.
|
|
|
|
* Combines reducers, actions, selectors and controls into a unified store.
|
|
|
|
*
|
|
|
|
* @file
|
|
|
|
*/
|
|
|
|
|
|
|
|
import { createReduxStore, register } from '@wordpress/data';
|
|
|
|
import { controls as wpControls } from '@wordpress/data-controls';
|
2025-01-21 13:19:59 +01:00
|
|
|
|
2025-01-17 13:59:17 +01:00
|
|
|
import { STORE_NAME } from './constants';
|
|
|
|
import reducer from './reducer';
|
|
|
|
import * as selectors from './selectors';
|
|
|
|
import * as actions from './actions';
|
|
|
|
import * as hooks from './hooks';
|
|
|
|
import { resolvers } from './resolvers';
|
|
|
|
import { controls } from './controls';
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Initializes and registers the settings store with WordPress data layer.
|
|
|
|
* Combines custom controls with WordPress data controls.
|
|
|
|
*
|
|
|
|
* @return {boolean} True if initialization succeeded, false otherwise.
|
|
|
|
*/
|
|
|
|
export const initStore = () => {
|
2025-01-21 13:32:03 +01:00
|
|
|
const store = createReduxStore( STORE_NAME, {
|
|
|
|
reducer,
|
|
|
|
controls: { ...wpControls, ...controls },
|
|
|
|
actions,
|
|
|
|
selectors,
|
|
|
|
resolvers,
|
|
|
|
} );
|
|
|
|
register( store );
|
2025-01-17 13:59:17 +01:00
|
|
|
|
2025-01-21 13:32:03 +01:00
|
|
|
return Boolean( wp.data.select( STORE_NAME ) );
|
2025-01-17 13:59:17 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
export { hooks, selectors, STORE_NAME };
|