Quantcast
Channel: KWS Blog » Code
Viewing all articles
Browse latest Browse all 10

How to Tell if Your WordPress Widget is Active

$
0
0

Check your  widget activation & settings

Also, How to Check Plugin Status

Ever wonder if your widget is activated on an external site?

Here’s how to find out.

When you register a sidebar widget, you use code like this:

register_sidebar_widget(array('Name of Widget', 'class-of-widget'), 'widget_function');

If you want to check whether the widget is activated (you may want to for a variety of reasons), you can do it like this (the “class-of-widget” value from above will be used in the code below): if(isset($_REQUEST['check_status'])) {
if(is_active_widget('class-of-widget')) {
echo 'Active';
} else {
echo 'Inactive';
} // End if 'is_active_widget'
} // End if 'check_status'

Now, simply browse to your widget’s location and add the variable “check_status” at the end: (wp-content/plugins/your-plugin/widget.php?check_status). You will then see the plugin/widget is “Active” or “Inactive.”

I hope someone finds this useful; if you’re in plugin or widget development for WordPress, try the code out!

The post How to Tell if Your WordPress Widget is Active appeared first on KWS Blog.


Viewing all articles
Browse latest Browse all 10

Latest Images

Trending Articles





Latest Images