add_filter [ WordPress Function ]
| Parameters: |
|
| Returns: |
|
| Defined at: |
|
Hooks a function or method to a specific filter action.
Filters are the hooks that WordPress launches to modify text of various types before adding it to the database or sending it to the browser screen. Plugins can specify that one or more of its PHP functions is executed to modify specific types of text at these times, using the Filter API.
To use the API, the following code should be used to bind a callback to the filter.
function example_hook($example) { echo $example; }
add_filter('example_filter', 'example_hook');
In WordPress 1.5.1+, hooked functions can take extra arguments that are set when the matching do_action() or apply_filters() call is run. The $accepted_args allow for calling functions only when the number of args match. Hooked functions can take extra arguments that are set when the matching do_action() or apply_filters() call is run. For example, the action comment_id_not_found will pass any functions that hook onto it the ID of the requested comment.
Note: the function will return true no matter if the function was hooked fails or not. There are no checks for whether the function exists beforehand and no checks to whether the $function_to_add is even a string. It is up to you to take care and this is done for optimization purposes, so everything is as quick as possible.
Source
<?php
function add_filter($tag, $function_to_add, $priority = 10, $accepted_args = 1) {
global $wp_filter, $merged_filters;
$idx = _wp_filter_build_unique_id($tag, $function_to_add, $priority);
$wp_filter[$tag][$priority][$idx] = array('function' => $function_to_add, 'accepted_args' => $accepted_args);
unset( $merged_filters[ $tag ] );
return true;
}
?>
Examples [ wp-snippets.com ]
Google Arama Sonuçlarý
- add_filter - WordPress Codex
Description. Hooks a function to a specific filter action. Filters are the hooks that WordPress launches to modify text of various types before adding it to the ...
codex.wordpress.org - Plugin API « WordPress Codex
Hook to the filter in WordPress, by calling add_filter(); Put your PHP function in a ... To do this, call add_filter() in the global execution space of your plugin file: ...
codex.wordpress.org - wordpress filters documentation? Trying to understand add_filter ...
I read over the documentation several times and have been having a ... add_filter () is a companion function to apply_filters() . Before apply_filters ...
stackoverflow.com - How to add wordpress like add_filter hooks in your PHP framework ...
Jul 17, 2009 ... I simply love wordpress mainly because of the architectural design it follows to deliver the good. Wordpress provide a hook or filter functionality ...
abhinavsingh.com
Kullanýcý Tartýþmalarý [ wordpress.org ]
- bcworkz on "add_filter('the_tags', 'myTags');"
- DenisCGN on "add_filter('the_tags', 'myTags');"
- bcworkz on "add_filter('the_tags', 'myTags');"
- DenisCGN on "add_filter('the_tags', 'myTags');"
- Jan Dembowski on "Change file on template trough plugin"
- JNestudi on "Change file on template trough plugin"
- Jan Dembowski on "Change file on template trough plugin"
- JNestudi on "Change file on template trough plugin"
- Jan Dembowski on "Change file on template trough plugin"
- JNestudi on "Change file on template trough plugin"