[wp-trac] [WordPress Trac] #53552: Inactive Widgets prevent placement of new widget if `multiple` is false
WordPress Trac
noreply at wordpress.org
Tue Jun 29 20:50:31 UTC 2021
#53552: Inactive Widgets prevent placement of new widget if `multiple` is false
---------------------------+-----------------------------
Reporter: MattyRob | Owner: (none)
Type: defect (bug) | Status: new
Priority: normal | Milestone: 5.8.1
Component: Widgets | Version: trunk
Severity: normal | Resolution:
Keywords: needs-testing | Focuses: administration
---------------------------+-----------------------------
Comment (by MattyRob):
@desrosj
You can use the example code below, then in the current development code:
1/ Navigate to the new Widget Editor
2/ Paste the code below into the browser console
3/ Place this Widget in your Sidebar
4/ Move the widget to 'Inactive'
5/ Try placing a new copy of the Widget in the Active sidebar - note that
you can't do this until the Inactive instance is deleted.
I probably agree that's it's not a blocker but it is likely to create core
and plugin support requests while users get used to the new Widget screen
and realise they have to tidy up the Inactive Widget lists to add new
Widgets that are only allowed a single active instance.
{{{#!php
( function( blocks, element, components, editor ) {
var el = element.createElement,
Fragment = element.Fragment,
PanelBody = components.PanelBody,
PanelRow = components.PanelRow,
TextControl = components.TextControl;
blocks.registerBlockType(
'gutenberg/widget',
{
title: 'No Multiple Widget',
icon: 'hammer',
category: 'widgets',
supports: {
multiple: false
},
edit: function( props ) {
var title = props.attributes.title
|| 'Title'
return el(
Fragment,
{},
el(
editor.InspectorControls,
{ key: 'gutenberg/widget'
},
el(
PanelBody,
{
title:
'Title',
initialOpen: true
},
el(
PanelRow,
{},
el(
TextControl,
{
type: 'string',
label: 'Title',
value: title,
}
)
)
)
),
el(
element.RawHTML,
null,
'Foobar'
)
);
}
}
);
} )(
window.wp.blocks,
window.wp.element,
window.wp.components,
window.wp.blockEditor
);
}}}
--
Ticket URL: <https://core.trac.wordpress.org/ticket/53552#comment:2>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list