ordPress Hooks(Actions, Filters)Sanam Maharjan   (Nhuja Concepts)
What is hook?
The Proliferation of Hooks over Time
Action Hooks • Used to stick a new function • Add or remove elements • Launches when specific events occur such as   publi...
Different Functions for HooksAction Hooks              Filter Hooks do_action()              apply_filters() add_action...
Using Action Hooks• do_action( hook_name‘, [$arg] );• add_action (  hook_name, your_function_name, [pri  ority], [accepted...
Using Filter Hooks• apply_filters( hook_name’, $value, [$v  ar ...] );• add_filter( hook_name’, ’function_to_  add’, [$pri...
References• http://codex.wordpress.org/Plugin_API• http://adambrown.info/p/wp_hooks• http://wpcandy.com/teaches/how-to-use...
Thank you
Wordpress hooks
Upcoming SlideShare
Loading in …5
×

Wordpress hooks

836 views

Published on

Published in: Technology, Business
0 Comments
1 Like
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total views
836
On SlideShare
0
From Embeds
0
Number of Embeds
3
Actions
Shares
0
Downloads
13
Comments
0
Likes
1
Embeds 0
No embeds

No notes for slide
  • Arguably the base of WordPress development, forming a large part of the core functionalityA “hook” is just place holders or a certain location in the WordPress code which allows you to attach or run your own code and execute your own functions.No change in core WordPress code.Changes will not be lost on WordPress update.
  • Wordpress hooks

    1. 1. ordPress Hooks(Actions, Filters)Sanam Maharjan (Nhuja Concepts)
    2. 2. What is hook?
    3. 3. The Proliferation of Hooks over Time
    4. 4. Action Hooks • Used to stick a new function • Add or remove elements • Launches when specific events occur such as publishing a post, changing themes, or displaying a page of the admin panel. • do_action( "hook_name" )Filter Hooks• Replaces or changes an existing function• Change how elements are presented• Launches to modify text of various types before adding it to the database or sending it to the browser screen.• apply_filters( "hook_name", "what_to_filter" )
    5. 5. Different Functions for HooksAction Hooks Filter Hooks do_action()  apply_filters() add_action()  add_filter() remove_action()  remove_filter() has_action()  has_filter() do_action_ref_array()  current_filter() did_action()  merge_filters() remove_all_actions()  remove_all_filters()
    6. 6. Using Action Hooks• do_action( hook_name‘, [$arg] );• add_action ( hook_name, your_function_name, [pri ority], [accepted_args] );• remove_action( hook_name‘, your_fun ction_name, [$priority], [$accepted_arg s]);
    7. 7. Using Filter Hooks• apply_filters( hook_name’, $value, [$v ar ...] );• add_filter( hook_name’, ’function_to_ add’, [$priority], [$accepted_args] );• remove_filter( hook_name’, ’function_ to_remove’, [$priority], [$accepted_args ] );
    8. 8. References• http://codex.wordpress.org/Plugin_API• http://adambrown.info/p/wp_hooks• http://wpcandy.com/teaches/how-to-use- wordpress-hooks
    9. 9. Thank you

    ×