| 1 |
/** |
| 2 |
* WordPress dependencies |
| 3 |
*/ |
| 4 |
import { register, select } from '@wordpress/data'; |
| 5 |
|
| 6 |
/** |
| 7 |
* Internal dependencies |
| 8 |
*/ |
| 9 |
import { SettingsStore, STORE_NAME } from './store'; |
| 10 |
|
| 11 |
/** |
| 12 |
* Exports |
| 13 |
*/ |
| 14 |
export { SettingsProvider, useSettings } from './provider'; |
| 15 |
// Export all the settings types. |
| 16 |
export * from './types'; |
| 17 |
|
| 18 |
/** |
| 19 |
* Initializes the settings store. |
| 20 |
* |
| 21 |
* @since 3.14.0 |
| 22 |
*/ |
| 23 |
function initSettings() { |
| 24 |
// Check if the store is already registered. |
| 25 |
const isStoreRegistered = select( STORE_NAME ) !== undefined; |
| 26 |
|
| 27 |
// Register the store if it's not already registered. |
| 28 |
if ( ! isStoreRegistered ) { |
| 29 |
register( SettingsStore ); |
| 30 |
} |
| 31 |
} |
| 32 |
|
| 33 |
// Initialize the settings store. |
| 34 |
initSettings(); |
| 35 |
|
| 36 |
|