WordPress.org

Plugin Directory

Changeset 519129


Ignore:
Timestamp:
03/15/12 00:00:26 (2 years ago)
Author:
eddiemoya
Message:

version 2 update, added banner for plugin repo(screwed up the first checkin)

Location:
simple-hook-widget
Files:
3 added
1 edited

Legend:

Unmodified
Added
Removed
  • simple-hook-widget/trunk/readme.txt

    r475014 r519129  
    22Contributors: eddiemoya 
    33Donate link: http://eddiemoya.com 
    4 Tags: widget, sidebar, hook, custom hook 
    5 Requires at least: unknown 
    6 Tested up to: 3.2.1 
     4Tags: widget, sidebar, hook, custom hook, development 
     5Requires at least: 2.8 
     6Tested up to: 3.3.1 
    77Stable tag: trunk 
    88 
    9 Allows user to insert a custom hook with a name of their choosing into any sidebar. 
     9Allows 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. 
    1010 
    1111== Description == 
     
    1515The hook can be anything, an existing hook from the WordPress Core, a plugin, a theme, or something you've come up with on the fly. Once the hook exists, your plugins, your theme, or the WordPress Core to make something happen with that hook. 
    1616 
    17 This can be used in conjunction with other more complex plugins, to give the user control of then things occur (yes, that is intentionally vague). It can also serve as a quick alternative to making very simple widgets tied to code from a theme. Say you have a chunk of code which already exists on your site, you'd like to also have it placed in a sidebar, but don't want to make a widget out of it (since its entirely theme-centric). You could simply hook this chunk of code to a custom hook and use the Simple Hook Widget to place that custom hook in the sidebar. This is absolutely not an endorsement toward that strategy for widget development, but there may be times where such on option is useful to a developer in a pinch. 
     17This can be used in conjunction with other more complex plugins, to allow you to trigger a hook from the sidebar (yes, that is intentionally vague). It can also serve as a quick alternative to making very simple widgets tied to code from a theme. Say you have a chunk of code which already exists on your site, you'd like to also have it placed in a sidebar, but don't want to make a widget out of it (since its entirely theme-centric). You could simply hook this chunk of code to a custom hook and use the Simple Hook Widget to place that custom hook in the sidebar. This is absolutely not an endorsement toward that strategy for widget development, but there may be times where such on option is useful to a developer in a pinch. 
     18 
     19= Update 2.0 = 
     20* New filter which allows developers to specify what hooks are available to choose from. 
     21 
     22Warning: Use this plugin with care. If you are not a developer and don't know what 'hooks' are, this plugin is not for you. This plugin will allow you to enter _ANY_ hook, and will run it in the sidebar - that includes core WordPress loaded with actions that could result in problems for your site. 
    1823 
    1924== Installation == 
     25 
    2026 
    21271. Upload `plugin-name.php` to the `/wp-content/plugins/` directory 
    22281. Activate the plugin through the 'Plugins' menu in WordPress 
    23291. In the widgets interface, drag to desired location. 
    24 1. Enter desired hook name. 
     301. Enter desired hook name or select one from the drop down menu (if there is one). 
    25311. Enjoy cake. 
     32 
     33 
    2634 
    2735== Frequently Asked Questions == 
     
    4250== Upgrade Notice == 
    4351 
     52= 2.0 = 
     53New functionality! 
     54 
    4455= 1.1.1 = 
    4556Please upgrade to 1.1.1 - Fixes a problem that caused plugin to fail during activation. 
     
    4758== Changelog == 
    4859 
     60= 2.0 = 
     61* New 'simple-hook-list' filter which allows developers to specify what hooks are available to choose from in the widget panel. 
     62* New 'simple-hook-default' filter which allows developers to specify a default value for Simple Hook Widget. 
     63 
    4964= 1.1.1 = 
    50 Fixed a packaging problem which made plugin activation fail 
     65* Fixed a packaging problem which made plugin activation fail 
    5166 
    5267= 1.1 = 
    53 Changed the name of the update hook prefix from simplehook_ to simplehookupdate_  
     68* Changed the name of the update hook prefix from simplehook_ to simplehookupdate_  
    5469 
    5570= 1.0 = 
     71* Initial commit 
    5672 
    57 == Note to Developers == 
     73== Developer Notes == 
     74 
     75 
     76= IMPORTANT: =  
     77If 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. 
     78 
     79 
     80= Using the hooks = 
     81 
     82Here 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. 
     83 
     84Example #1: 
     85` 
     86function simple_hook_super_example() { 
     87    echo "This is my super simple hook widget"; 
     88} 
     89add_action('example-hook-name-one', 'simple_hook_super_example'); 
     90 
     91 
     92You 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. 
     93 
     94Example #2: 
     95` 
     96function simple_hook_awesome_example() { 
     97 
     98    //Do whatever you want your 'widget' to do, when the 'example-hook-name-two' hook is chosen. 
     99    echo "This is my awesome simple hook widget"; 
     100} 
     101add_action('example-hook-name-two', 'simple_hook_awesome_example'); 
     102` 
     103 
     104 
     105= Creating dropdown of Pre-determined hooks = 
     106 
     107= Filter: 'simple-hook-list' = 
     108Version 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. 
     109 
     110The 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.  
     111 
     112Example: 
     113` 
     114function simple_hook_example_filter($hooks){ 
     115    $hooks = array ( 
     116        'example-hook-name-one' => 'Awesome Widget', 
     117        'example-hook-name-two' => 'Simple Widget' 
     118    ); 
     119    return $hooks; 
     120} 
     121add_filter('simple-hook-list', 'simple_hook_example_filter'); 
     122` 
     123 
     124= 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. 
     125 
     126= Hook: simple-hook-default = 
     127 
     128This hook allows developers provide a default value for the Simple Hook widget. By default, the default value for the hook, is an empty string. 
     129Example: 
     130` 
     131function simple_hook_example_default($default_hook){ 
     132    return 'example-hook-name-two'; 
     133} 
     134` 
     135Note: 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. 
     136 
     137= Hook: simplehookupdate_ = 
    58138 
    59139This 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. 
     140 
     141Not sure how useful this is, but a friend suggested it, so here is it. 
     142 
Note: See TracChangeset for help on using the changeset viewer.