Created
January 18, 2019 17:05
-
-
Save mcaskill/f97201f1b5ffed9129da57144e0c254d to your computer and use it in GitHub Desktop.
WordPress \ Hooks : Hook a function or method to an array of actions or filters.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Hook a function or method to an array of actions. | |
* | |
* @param string[] $tags Array of names of filters to hook the $function callback to. | |
* @param callable $function_to_add The callback to be run when the filter is applied. | |
* @param int $priority Optional. Used to specify the order in which the functions | |
* associated with a particular action are executed. Default 10. | |
* @param int $accepted_args Optional. The number of arguments the function accepts. Default 1. | |
* @return true | |
*/ | |
function add_actions( $tags, $function, $priority = 10, $accepted_args = 1 ) | |
{ | |
return add_filters( $tags, $function, $priority, $accepted_args ); | |
} | |
/** | |
* Hook a function or method to an array of filters. | |
* | |
* @param string[] $tags Array of names of filters to hook the $function callback to. | |
* @param callable $function_to_add The callback to be run when the filter is applied. | |
* @param int $priority Optional. Used to specify the order in which the functions | |
* associated with a particular action are executed. Default 10. | |
* @param int $accepted_args Optional. The number of arguments the function accepts. Default 1. | |
* @return true | |
*/ | |
function add_filters( $tags, $function, $priority = 10, $accepted_args = 1 ) | |
{ | |
foreach ((array) $tags as $tag ) { | |
add_filter( $tag, $function, $priority, $accepted_args ); | |
} | |
return true; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment