2024-11-20 17:21:09 +01:00
|
|
|
import { createReduxStore, register } from '@wordpress/data';
|
|
|
|
|
|
|
|
import { STORE_NAME } from './constants';
|
2024-11-18 18:58:54 +01:00
|
|
|
import reducer from './reducer';
|
|
|
|
import * as selectors from './selectors';
|
|
|
|
import * as actions from './actions';
|
2025-02-06 13:48:21 +01:00
|
|
|
import * as thunkActions from './actions-thunk';
|
2024-11-20 17:21:09 +01:00
|
|
|
import * as hooks from './hooks';
|
2025-02-06 14:20:22 +01:00
|
|
|
import * as resolvers from './resolvers';
|
2024-11-18 18:58:54 +01:00
|
|
|
|
2025-01-21 13:32:03 +01:00
|
|
|
/**
|
|
|
|
* 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.
|
|
|
|
*/
|
2024-11-20 17:21:09 +01:00
|
|
|
export const initStore = () => {
|
|
|
|
const store = createReduxStore( STORE_NAME, {
|
|
|
|
reducer,
|
2025-02-06 13:48:21 +01:00
|
|
|
actions: { ...actions, ...thunkActions },
|
2024-11-20 17:21:09 +01:00
|
|
|
selectors,
|
|
|
|
resolvers,
|
|
|
|
} );
|
|
|
|
|
|
|
|
register( store );
|
2025-01-21 13:32:03 +01:00
|
|
|
|
|
|
|
return Boolean( wp.data.select( STORE_NAME ) );
|
2024-11-20 17:21:09 +01:00
|
|
|
};
|
|
|
|
|
2024-11-20 18:37:28 +01:00
|
|
|
export { hooks, selectors, STORE_NAME };
|