apply_filters [ WordPress Function ]
| Parameters: |
|
| Returns: |
|
| Defined at: |
|
Call the functions added to a filter hook.
The callback functions attached to filter hook $tag are invoked by calling this function. This function can be used to create a new filter hook by simply calling this function with the name of the new hook specified using the $tag parameter.
The function allows for additional arguments to be added and passed to hooks.
function example_hook($string, $arg1, $arg2)
{
//Do stuff
return $string;
}
$value = apply_filters('example_filter', 'filter me', 'arg1', 'arg2');
Source
<?php
function apply_filters($tag, $value) {
global $wp_filter, $merged_filters, $wp_current_filter;
$args = array();
// Do 'all' actions first
if ( isset($wp_filter['all']) ) {
$wp_current_filter[] = $tag;
$args = func_get_args();
_wp_call_all_hook($args);
}
if ( !isset($wp_filter[$tag]) ) {
if ( isset($wp_filter['all']) )
array_pop($wp_current_filter);
return $value;
}
if ( !isset($wp_filter['all']) )
$wp_current_filter[] = $tag;
// Sort
if ( !isset( $merged_filters[ $tag ] ) ) {
ksort($wp_filter[$tag]);
$merged_filters[ $tag ] = true;
}
reset( $wp_filter[ $tag ] );
if ( empty($args) )
$args = func_get_args();
do {
foreach( (array) current($wp_filter[$tag]) as $the_ )
if ( !is_null($the_['function']) ){
$args[1] = $value;
$value = call_user_func_array($the_['function'], array_slice($args, 1, (int) $the_['accepted_args']));
}
} while ( next($wp_filter[$tag]) !== false );
array_pop( $wp_current_filter );
return $value;
}
?>
Examples [ wp-snippets.com ]
Google Arama Sonuçlarý
- apply_filters() - WordPress Codex
Description. Call the functions added to a filter hook. See the Plugin API for a list of filter hooks. The callback functions attached to filter hook $tag are invoked by ...
codex.wordpress.org - WordPress › Support » Tags — apply_filters()
(forgot?) Register · WordPress › Support » apply_filters() ...
wordpress.org - What does apply_filters(…) actually do in WordPress? - Stack Overflow
I'm trying to understand some of the function in WordPress, but I can't ... apply_filters($tag, $value) passes the 'value' argument to each of the ...
stackoverflow.com - apply filters - Explanation for apply_filters function and its variables ...
May 6, 2011 ... apply_filters('simplr-reg-instructions', __('Please fill out this form to sign up for this site', 'simplr-reg'));. Can you please explain what is happning ...
wordpress.stackexchange.com
Kullanýcý Tartýþmalarý [ wordpress.org ]
- flint_and_tinder on "Only display custom field if present and add content filters"
- flint_and_tinder on "Only display custom field if present and add content filters"
- keesiemeijer on "Only display custom field if present and add content filters"
- flint_and_tinder on "Only display custom field if present and add content filters"
- sharewidget on "[Plugin: Get The Image] how to apply filter on image output"
- miniCarl on "Content and Title filters, shortcodes"
- miniCarl on "Content and Title filters, shortcodes"
- miniCarl on "Content and Title filters, shortcodes"
- OM2 on "Problem with apply_filters function"
- brian914 on "Retrieving gallery image custom form field content"