WordPress.org

Support

Support » Plugins and Hacks » [Resolved] [Plugin: Front-end Editor] Edit Select Widgets

[Resolved] [Plugin: Front-end Editor] Edit Select Widgets

  • This is quite possibly the best WordPress plugin I’ve ever come across (with kudos to Widget Logic):)

    I’ve seen examples where you can limit editing to select categories, etc. but is it possible to limit it to select widgets as well? Perhaps by widget title somehow?

    Great work!

Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Author scribu
    Member

    @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 );

    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
    Member

    @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;
Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘[Resolved] [Plugin: Front-end Editor] Edit Select Widgets’ is closed to new replies.