WordPress.org

Ready to get started?Download WordPress

Plugin Directory

!This plugin hasn't been updated in over 2 years. It may no longer be maintained or supported and may have compatibility issues when used with more recent versions of WordPress.

Simple Hook Widget

Allows developers to create a drop down of hooks to be selected from a widget, for on-the-fly widgets without the fuss, or just easily test hooks.

Developer Notes

IMPORTANT:

If the 'simple-hook-list' is not filtered, the Simple Hook Widget will not show a drop down in the widget interface, but instead it will provide an empty text field allowing a user to enter ANY hook they like.

Using the hooks

Here is a simple example of how to use a hook used in the Simple Hook Widget. Its just like using any other hook in WordPress. Remember, you can do whatever you want here, you just need to make sure the hook used in the add_action() is the same as the hook name selected in a particular widget.

Example #1:

function simple_hook_super_example() {
    echo "This is my super simple hook widget";
}
add_action('example-hook-name-one', 'simple_hook_super_example');

You can create any number of different widgets by simply writing a function, and adding it as an action to a hook. Here is a similar one as the first, but this is here to illustrate the point.

Example #2:

function simple_hook_awesome_example() {

//Do whatever you want your 'widget' to do, when the 'example-hook-name-two' hook is chosen.
echo "This is my awesome simple hook widget";

} add_action('example-hook-name-two', 'simple_hook_awesome_example');

<h4>Creating dropdown of Pre-determined hooks</h4>
<h4>Filter: 'simple-hook-list'</h4>
Version 2.0 of the Simple Hook Widget includes the 'simple-hook-list' filter which allows developers to specify a set of hooks which can be selected from the widgets admin panel.

The function you create should return an associative array where the index is the actual hook's name, and the value is the text that will represent it in the drop down on the widgets panel. 

Example:

function simple_hook_example_filter($hooks){ $hooks = array ( 'example-hook-name-one' => 'Awesome Widget', 'example-hook-name-two' => 'Simple Widget' ); return $hooks; } add_filter('simple-hook-list', 'simple_hook_example_filter');

<h4>IMPORTANT:</h4> If the 'simple-hook-list' is not filtered, the Simple Hook Widget will not show a drop down in the widget interface, but instead it will provide an empty text field allowing a user to enter _ANY_ hook they like.
<h4>Hook: simple-hook-default</h4>

This hook allows developers provide a default value for the Simple Hook widget. By default, the default value for the hook, is an empty string.
Example:

function simple_hook_example_default($default_hook){ return 'example-hook-name-two'; } ` Note: If filtering 'simple-hook-list' to create a drop down, the default value must match one of the keys in the array passed to the filter - otherwise this default will do nothing.

Hook: simplehookupdate_

This widget also contains an internal hook, which will be your hook, prefixed with simplehookupdate_. So if you use this plugin to create a hook name 'testhook', the widget, aside from creating the 'testhook' in the chosen sidebar location, will also create a hook called 'simplehookupdate_testhook'. This hook occurs within the update method of the WP_Widget class, immediately before $instance is returned.

Not sure how useful this is, but a friend suggested it, so here is it.

Requires: 2.8 or higher
Compatible up to: 3.3.2
Last Updated: 2012-3-15
Downloads: 1,669

Ratings

3 stars
3 out of 5 stars

Support

Got something to say? Need help?

Compatibility

+
=
Not enough data

0 people say it works.
0 people say it's broken.

100,1,1 100,1,1
100,1,1
100,1,1
100,1,1
50,2,1 100,1,1
100,1,1