• Resolved profilpr

    (@profilpr)


    Hi, is there a plugin function I could use to check for widgets to be allowed for a page?

    I currently use the wordpress function “is_active_sidebar” which returns true if widgets are assigned to it. But it misses the fact that the widgets might be disallowed via the dynamic widgets plugin.

Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Contributor Qurl

    (@qurl)

    You can check if the widget is (going to be) removed in the $DW->removelist array

    Thread Starter profilpr

    (@profilpr)

    Hi thanks for your reply. That did the trick!

    I am using the following in my themes functions.php:

    function sidebar_has_active_widgets($sidebar) {
      include_once( ABSPATH . 'wp-admin/includes/plugin.php' );
      if ( is_plugin_active('dynamic-widgets/dynamic-widgets.php') ) {
        $DW = &$GLOBALS['DW'];
        if (!empty($sidebar) && is_array($DW->removelist) && array_key_exists($sidebar, $DW->removelist)) {
          return false;
        }
      }
      return true;
    }
Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Function to check for visibility’ is closed to new replies.