-
Notifications
You must be signed in to change notification settings - Fork 10
Open
Description
/**
* New v2.2 fields method should account for.
*
* - Id
* - Tab
* - Section/panel
* - Priority
* - Component/Slot
* - Component props
*
* Tab & section sorting default to order of registration.
* - Add filter to allow custom sorting.
*
* Should allow passing fields, props, and an options object through the filter.
* - Fields should be an array of objects.
* - Props should be an object containing settings, updateSettings.
* - Options should be an object containing additional info such as:
* - Shared instanceId.
* - fieldIsVisible method
* - tabIsVisible method
* - sectionIsVisible method
* - Should return an array of objects.
*
* New helper methods should account for:
* - getFields should be modified to accept tab & section filters.
* - Sort fields by priority after filtering.
* - sortFields should sort by tab (priority) => section (priority) => field (priority)
* - tabIsVisible
* - sectionIsVisible
*/
addFilter(
'contentControl.restrictionEditor.fields',
'content-control',
( fields, { settings, updateSettings }, options ) => {
return [
...fields,
{
id: 'protectionMethod',
tab: 'protection',
section: 'general',
priority: 1,
component: (
<RadioButtonControl
label={ __(
'How do you want to protect your content?',
'content-control'
) }
value={ settings.protectionMethod }
onChange={ ( protectionMethod ) =>
updateSettings( { protectionMethod } )
}
options={ ( () =>
applyFilters(
'contentControl.restrictionEditor.protectionMethodOptions',
protectionMethodOptions
) as typeof protectionMethodOptions )() }
/>
),
},
{
id: 'protectionFieldsSlot',
tab: 'protection',
section: '',
priority: 2,
component: <ProtectionFieldsSlot />,
},
];
}
);
Metadata
Metadata
Assignees
Labels
No labels