Archived
Updates
This commit is contained in:
1 parent
70d2335bba
commit
7428b67da5
1086 files changed
+94145
-59082
No files matched your search
+42
-55
@@ -11,7 +11,7 @@
|
||||
* {@link http://us2.php.net/manual/en/language.pseudo-types.php#language.types.callback 'callback'}
|
||||
* type are valid.
|
||||
*
|
||||
* Also see the {@link http://codex.wordpress.org/Plugin_API Plugin API} for
|
||||
* Also see the {@link https://codex.wordpress.org/Plugin_API Plugin API} for
|
||||
* more information and examples on how to use a lot of these functions.
|
||||
*
|
||||
* @package WordPress
|
||||
@@ -45,22 +45,21 @@ if ( ! isset( $wp_current_filter ) )
|
||||
* 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:
|
||||
*
|
||||
* <code>
|
||||
* function example_callback( $example ) {
|
||||
* // Maybe modify $example in some way
|
||||
* return $example;
|
||||
* }
|
||||
* add_filter( 'example_filter', 'example_callback' );
|
||||
* </code>
|
||||
* Note that `$example` is passed to the callback, (maybe) modified, then returned:
|
||||
*
|
||||
* function example_callback( $example ) {
|
||||
* // Maybe modify $example in some way.
|
||||
* return $example;
|
||||
* }
|
||||
* add_filter( 'example_filter', 'example_callback' );
|
||||
*
|
||||
* Since WordPress 1.5.1, bound callbacks can take as many arguments as are
|
||||
* passed as parameters in the corresponding apply_filters() call. The $accepted_args
|
||||
* passed as parameters in the corresponding apply_filters() call. The `$accepted_args`
|
||||
* parameter allows for calling functions only when the number of args match.
|
||||
*
|
||||
* <strong>Note:</strong> the function will return true whether or not the callback
|
||||
* is valid. It is up to you to take care. This is done for optimization purposes,
|
||||
* *Note:* the function will return true whether or not the callback is valid.
|
||||
* It is up to you to take care. This is done for optimization purposes,
|
||||
* so everything is as quick as possible.
|
||||
*
|
||||
* @since 0.71
|
||||
@@ -148,21 +147,21 @@ function has_filter($tag, $function_to_check = false) {
|
||||
* the $tag parameter.
|
||||
*
|
||||
* The function allows for additional arguments to be added and passed to hooks.
|
||||
* <code>
|
||||
* // Our filter callback function
|
||||
* function example_callback( $string, $arg1, $arg2 ) {
|
||||
* // (maybe) modify $string
|
||||
* return $string;
|
||||
* }
|
||||
* add_filter( 'example_filter', 'example_callback', 10, 3 );
|
||||
*
|
||||
* // Apply the filters by calling the 'example_callback' function we
|
||||
* // "hooked" to 'example_filter' using the add_filter() function above.
|
||||
* // - 'example_filter' is the filter hook $tag
|
||||
* // - 'filter me' is the value being filtered
|
||||
* // - $arg1 and $arg2 are the additional arguments passed to the callback.
|
||||
* $value = apply_filters( 'example_filter', 'filter me', $arg1, $arg2 );
|
||||
* </code>
|
||||
* // Our filter callback function
|
||||
* function example_callback( $string, $arg1, $arg2 ) {
|
||||
* // (maybe) modify $string
|
||||
* return $string;
|
||||
* }
|
||||
* add_filter( 'example_filter', 'example_callback', 10, 3 );
|
||||
*
|
||||
* /*
|
||||
* * Apply the filters by calling the 'example_callback' function we
|
||||
* * "hooked" to 'example_filter' using the add_filter() function above.
|
||||
* * - 'example_filter' is the filter hook $tag
|
||||
* * - 'filter me' is the value being filtered
|
||||
* * - $arg1 and $arg2 are the additional arguments passed to the callback.
|
||||
* $value = apply_filters( 'example_filter', 'filter me', $arg1, $arg2 );
|
||||
*
|
||||
* @since 0.71
|
||||
*
|
||||
@@ -171,8 +170,8 @@ function has_filter($tag, $function_to_check = false) {
|
||||
* @global array $wp_current_filter Stores the list of current filters with the current one last.
|
||||
*
|
||||
* @param string $tag The name of the filter hook.
|
||||
* @param mixed $value The value on which the filters hooked to <tt>$tag</tt> are applied on.
|
||||
* @param mixed $var Additional variables passed to the functions hooked to <tt>$tag</tt>.
|
||||
* @param mixed $value The value on which the filters hooked to `$tag` are applied on.
|
||||
* @param mixed $var Additional variables passed to the functions hooked to `$tag`.
|
||||
* @return mixed The filtered value after all hooked functions are applied to it.
|
||||
*/
|
||||
function apply_filters( $tag, $value ) {
|
||||
@@ -224,10 +223,10 @@ function apply_filters( $tag, $value ) {
|
||||
/**
|
||||
* Execute functions hooked on a specific filter hook, specifying arguments in an array.
|
||||
*
|
||||
* @see apply_filters() This function is identical, but the arguments passed to the
|
||||
* functions hooked to <tt>$tag</tt> are supplied using an array.
|
||||
* @see 3.0.0
|
||||
*
|
||||
* @since 3.0.0
|
||||
* @see apply_filters() This function is identical, but the arguments passed to the
|
||||
* functions hooked to `$tag` are supplied using an array.
|
||||
*
|
||||
* @global array $wp_filter Stores all of the filters
|
||||
* @global array $merged_filters Merges the filter hooks using this function.
|
||||
@@ -326,10 +325,10 @@ function remove_all_filters( $tag, $priority = false ) {
|
||||
global $wp_filter, $merged_filters;
|
||||
|
||||
if ( isset( $wp_filter[ $tag ]) ) {
|
||||
if ( false !== $priority && isset( $wp_filter[ $tag ][ $priority ] ) ) {
|
||||
$wp_filter[ $tag ][ $priority ] = array();
|
||||
} else {
|
||||
if ( false === $priority ) {
|
||||
$wp_filter[ $tag ] = array();
|
||||
} elseif ( isset( $wp_filter[ $tag ][ $priority ] ) ) {
|
||||
$wp_filter[ $tag ][ $priority ] = array();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -357,8 +356,6 @@ function current_filter() {
|
||||
*
|
||||
* @since 3.9.0
|
||||
*
|
||||
* @uses current_filter()
|
||||
*
|
||||
* @return string Hook name of the current action.
|
||||
*/
|
||||
function current_action() {
|
||||
@@ -401,8 +398,6 @@ function doing_filter( $filter = null ) {
|
||||
*
|
||||
* @since 3.9.0
|
||||
*
|
||||
* @uses doing_filter()
|
||||
*
|
||||
* @param string|null $action Optional. Action to check. Defaults to null, which checks
|
||||
* if any action is currently being run.
|
||||
* @return bool Whether the action is currently in the stack.
|
||||
@@ -421,8 +416,6 @@ function doing_action( $action = null ) {
|
||||
*
|
||||
* @since 1.2.0
|
||||
*
|
||||
* @uses add_filter() Adds an action. Parameter list and functionality are the same.
|
||||
*
|
||||
* @param string $tag The name of the action to which the $function_to_add is hooked.
|
||||
* @param callback $function_to_add The name of the function you wish to be called.
|
||||
* @param int $priority Optional. Used to specify the order in which the functions
|
||||
@@ -440,17 +433,15 @@ function add_action($tag, $function_to_add, $priority = 10, $accepted_args = 1)
|
||||
/**
|
||||
* Execute functions hooked on a specific action hook.
|
||||
*
|
||||
* This function invokes all functions attached to action hook $tag. It is
|
||||
* This function invokes all functions attached to action hook `$tag`. It is
|
||||
* possible to create new action hooks by simply calling this function,
|
||||
* specifying the name of the new hook using the <tt>$tag</tt> parameter.
|
||||
* specifying the name of the new hook using the `$tag` parameter.
|
||||
*
|
||||
* You can pass extra arguments to the hooks, much like you can with
|
||||
* apply_filters().
|
||||
* {@see apply_filters()}.
|
||||
*
|
||||
* @since 1.2.0
|
||||
*
|
||||
* @see apply_filters() This function works similar with the exception that nothing
|
||||
* is returned and only the functions or methods are called.
|
||||
* @global array $wp_filter Stores all of the filters
|
||||
* @global array $wp_actions Increments the amount of times action was triggered.
|
||||
*
|
||||
@@ -488,7 +479,7 @@ function do_action($tag, $arg = '') {
|
||||
$args[] =& $arg[0];
|
||||
else
|
||||
$args[] = $arg;
|
||||
for ( $a = 2; $a < func_num_args(); $a++ )
|
||||
for ( $a = 2, $num = func_num_args(); $a < $num; $a++ )
|
||||
$args[] = func_get_arg($a);
|
||||
|
||||
// Sort
|
||||
@@ -539,8 +530,8 @@ function did_action($tag) {
|
||||
* @global array $wp_actions Increments the amount of times action was triggered.
|
||||
*
|
||||
* @param string $tag The name of the action to be executed.
|
||||
* @param array $args The arguments supplied to the functions hooked to <tt>$tag</tt>
|
||||
* @return null Will return null if $tag does not exist in $wp_filter array
|
||||
* @param array $args The arguments supplied to the functions hooked to `$tag`.
|
||||
* @return null Will return null if `$tag` does not exist in `$wp_filter` array.
|
||||
*/
|
||||
function do_action_ref_array($tag, $args) {
|
||||
global $wp_filter, $wp_actions, $merged_filters, $wp_current_filter;
|
||||
@@ -646,8 +637,6 @@ function remove_all_actions($tag, $priority = false) {
|
||||
*
|
||||
* @since 1.5.0
|
||||
*
|
||||
* @uses WP_PLUGIN_DIR, WPMU_PLUGIN_DIR
|
||||
*
|
||||
* @param string $file The filename of plugin.
|
||||
* @return string The name of a plugin.
|
||||
*/
|
||||
@@ -832,8 +821,6 @@ function register_uninstall_hook( $file, $callback ) {
|
||||
* @since 2.5.0
|
||||
* @access private
|
||||
*
|
||||
* @uses $wp_filter Used to process all of the functions in the 'all' hook.
|
||||
*
|
||||
* @param array $args The collected parameters from the hook that was called.
|
||||
*/
|
||||
function _wp_call_all_hook($args) {
|
||||
@@ -852,7 +839,7 @@ function _wp_call_all_hook($args) {
|
||||
* Build Unique ID for storage and retrieval.
|
||||
*
|
||||
* The old way to serialize the callback caused issues and this function is the
|
||||
* solution. It works by checking for objects and creating an a new property in
|
||||
* solution. It works by checking for objects and creating a new property in
|
||||
* the class to keep track of the object and new objects of the same class that
|
||||
* need to be added.
|
||||
*
|
||||
@@ -865,7 +852,7 @@ function _wp_call_all_hook($args) {
|
||||
* Functions and static method callbacks are just returned as strings and
|
||||
* shouldn't have any speed penalty.
|
||||
*
|
||||
* @link http://trac.wordpress.org/ticket/3875
|
||||
* @link https://core.trac.wordpress.org/ticket/3875
|
||||
*
|
||||
* @since 2.2.3
|
||||
* @access private
|
||||
@@ -913,7 +900,7 @@ function _wp_filter_build_unique_id($tag, $function, $priority) {
|
||||
|
||||
return $obj_idx;
|
||||
}
|
||||
} else if ( is_string($function[0]) ) {
|
||||
} elseif ( is_string( $function[0] ) ) {
|
||||
// Static Calling
|
||||
return $function[0] . '::' . $function[1];
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user