in_widget_form detect sidebar id

I have extensively looked for this and can’t find a php answer, only js or css.

In my widget class dynamic_sidebar_params I have this to only output css classes on that instance:

if ( 'sidebar' === $params[0][ 'id' ] || 'after-entry' === $params[0][ 'id' ] ) :

   // Add the classes added in the Widget Style Field
    if ( ! empty( $instance[ 'prefix_select_class' ] ) ) :

         $class = $instance[ 'prefix_select_class' ];

         $params[0]['before_widget'] = preg_replace('/class="/', 'class="'. $class . ' ',  $params[0]['before_widget'], 1 );

     endif; // cherish_select_class not empty

endif; //specific widgets

But on the in_widget_form I can’t get the $params, no clue how, is there a way to not show certain fields based on the sidebar id?

Read more here: in_widget_form detect sidebar id

Leave a Reply

Your email address will not be published. Required fields are marked *