2024-02-28 21:00:52 +00:00
|
|
|
/**
|
|
|
|
* External dependencies
|
|
|
|
*/
|
2024-08-02 06:53:49 +00:00
|
|
|
import { createRoot } from '@wordpress/element';
|
2024-02-28 21:00:52 +00:00
|
|
|
import { createSlotFill, SlotFillProvider } from '@wordpress/components';
|
|
|
|
import { PluginArea } from '@wordpress/plugins';
|
|
|
|
|
|
|
|
export const SETTINGS_SLOT_FILL_CONSTANT =
|
|
|
|
'__EXPERIMENTAL__WcAdminSettingsSlots';
|
|
|
|
|
|
|
|
const { Slot } = createSlotFill( SETTINGS_SLOT_FILL_CONSTANT );
|
|
|
|
|
|
|
|
export const possiblyRenderSettingsSlots = () => {
|
|
|
|
const slots = [
|
|
|
|
{
|
|
|
|
id: 'wc_payments_settings_slotfill',
|
|
|
|
scope: 'woocommerce-payments-settings',
|
|
|
|
},
|
|
|
|
{ id: 'wc_tax_settings_slotfill', scope: 'woocommerce-tax-settings' },
|
|
|
|
{ id: 'wc_settings_slotfill', scope: 'woocommerce-settings' },
|
2024-03-08 04:11:52 +00:00
|
|
|
{
|
2024-04-04 21:28:58 +00:00
|
|
|
id: 'wc_settings_site_visibility_slotfill',
|
|
|
|
scope: 'woocommerce-site-visibility-settings',
|
2024-03-08 04:11:52 +00:00
|
|
|
},
|
2024-08-12 23:33:05 +00:00
|
|
|
{
|
|
|
|
id: 'wc_settings_blueprint_slotfill',
|
|
|
|
scope: 'woocommerce-blueprint-settings',
|
|
|
|
},
|
2024-02-28 21:00:52 +00:00
|
|
|
];
|
|
|
|
|
|
|
|
slots.forEach( ( slot ) => {
|
|
|
|
const slotDomElement = document.getElementById( slot.id );
|
|
|
|
|
|
|
|
if ( slotDomElement ) {
|
2024-08-02 06:53:49 +00:00
|
|
|
createRoot( slotDomElement ).render(
|
2024-02-28 21:00:52 +00:00
|
|
|
<>
|
|
|
|
<SlotFillProvider>
|
|
|
|
<Slot />
|
|
|
|
<PluginArea scope={ slot.scope } />
|
|
|
|
</SlotFillProvider>
|
2024-08-02 06:53:49 +00:00
|
|
|
</>
|
2024-02-28 21:00:52 +00:00
|
|
|
);
|
|
|
|
}
|
|
|
|
} );
|
|
|
|
};
|