Plugin Author
scribu
(@scribu)
You can restrict widgets by widget type, widget number, sidebar id or any combination thereof:
function restrict_widget_editing( $allow, $params ) {
extract( $params ); // populates $widget_id and $sidebar_id
$widget_type = explode( '-', $widget_id );
$widget_nr = array_pop( $widget_type );
$widget_type = implode( '-', $widget_type );
if ( 'categories' == $widget_type )
return false;
return $allow;
}
add_filter( 'front_end_editor_allow_widget', 'restrict_widget_editing', 10, 2 );
Thread Starter
Scotm
(@scotm)
scribu
Awesome…but if I understand you widgets can’t be excluded by the title you give them? I’m looking for the ability to exclude editing on some instances of Text widgets versus all Text widgets (type), though failing that I guess I could limit it to the sidebar ID where they appear.
If I was using the above code, how would I exclude “footer-1” as an example of a widget area to exclude or “Text” as an example of excluding Text widgets or “Primary Sidebar” as an example of a sidebar to exclude.
This is a great feature btw…
Thx
Plugin Author
scribu
(@scribu)
If I was using the above code, how would I exclude “footer-1” as an example of a widget area to exclude or “Text” as an example of excluding Text widgets or “Primary Sidebar” as an example of a sidebar to exclude.
I don’t understand what you mean by “widget area”.
I already explained the information you can use. Beyond that, it’s just basic PHP knowledge. One final example:
To disable editing of all text widgets in the ‘primary’ sidebar, in the first example, you would replace this:
if ( 'categories' == $widget_type )
return false;
with this:
if ( 'text' == $widget_type && 'primary' == $sidebar_id )
return false;