example_filter

FILTER wp-includes\plugin.php (ligne 158) github
Adds a callback function to a filter hook. WordPress offers filter hooks to allow plugins to modify various types of internal data at runtime. A plugin can modify data by binding a callback to a filter hook. When the filter is later applied, each bound callback is run in order of priority, and given the opportunity to modify a value by returning a new value. The following example shows how a callback function is bound to a filter hook. Note that `$example` is passed to the callback, (maybe) modified, then returned:

Paramètres

Entrée :
'filter me', $arg1, $arg2
Sortie :
@param string   $hook_name     The name of the filter to add the callback to.
@param callable $callback      The callback to be run when the filter is applied.
@param int      $priority      Optional. Used to specify the order in which the functions
@param int      $accepted_args Optional. The number of arguments the function accepts. Default 1.
@return true Always returns true.

Utilisation

// Modifier la valeur avec le filtre 'example_filter'
add_filter('example_filter', 'ma_fonction_filtre', 10, 1);

function ma_fonction_filtre('filter me') {
    // Modifier la valeur
    return 'filter me';
}

Actualités

Chargement des actualités...