--- a/wp/wp-includes/plugin.php Mon Oct 14 18:06:33 2019 +0200
+++ b/wp/wp-includes/plugin.php Mon Oct 14 18:28:13 2019 +0200
@@ -33,11 +33,13 @@
$wp_filter = array();
}
-if ( ! isset( $wp_actions ) )
+if ( ! isset( $wp_actions ) ) {
$wp_actions = array();
+}
-if ( ! isset( $wp_current_filter ) )
+if ( ! isset( $wp_current_filter ) ) {
$wp_current_filter = array();
+}
/**
* Hook a function or method to a specific filter action.
@@ -128,7 +130,7 @@
* that evaluates to false (e.g.) 0, so use the === operator for testing the
* return value.
*/
-function has_filter($tag, $function_to_check = false) {
+function has_filter( $tag, $function_to_check = false ) {
global $wp_filter;
if ( ! isset( $wp_filter[ $tag ] ) ) {
@@ -179,23 +181,26 @@
$args = array();
// Do 'all' actions first.
- if ( isset($wp_filter['all']) ) {
+ if ( isset( $wp_filter['all'] ) ) {
$wp_current_filter[] = $tag;
- $args = func_get_args();
- _wp_call_all_hook($args);
+ $args = func_get_args();
+ _wp_call_all_hook( $args );
}
- if ( !isset($wp_filter[$tag]) ) {
- if ( isset($wp_filter['all']) )
- array_pop($wp_current_filter);
+ if ( ! isset( $wp_filter[ $tag ] ) ) {
+ if ( isset( $wp_filter['all'] ) ) {
+ array_pop( $wp_current_filter );
+ }
return $value;
}
- if ( !isset($wp_filter['all']) )
+ if ( ! isset( $wp_filter['all'] ) ) {
$wp_current_filter[] = $tag;
+ }
- if ( empty($args) )
+ if ( empty( $args ) ) {
$args = func_get_args();
+ }
// don't pass the tag name to WP_Hook
array_shift( $args );
@@ -222,24 +227,26 @@
* @param array $args The arguments supplied to the functions hooked to $tag.
* @return mixed The filtered value after all hooked functions are applied to it.
*/
-function apply_filters_ref_array($tag, $args) {
+function apply_filters_ref_array( $tag, $args ) {
global $wp_filter, $wp_current_filter;
// Do 'all' actions first
- if ( isset($wp_filter['all']) ) {
+ if ( isset( $wp_filter['all'] ) ) {
$wp_current_filter[] = $tag;
- $all_args = func_get_args();
- _wp_call_all_hook($all_args);
+ $all_args = func_get_args();
+ _wp_call_all_hook( $all_args );
}
- if ( !isset($wp_filter[$tag]) ) {
- if ( isset($wp_filter['all']) )
- array_pop($wp_current_filter);
+ if ( ! isset( $wp_filter[ $tag ] ) ) {
+ if ( isset( $wp_filter['all'] ) ) {
+ array_pop( $wp_current_filter );
+ }
return $args[0];
}
- if ( !isset($wp_filter['all']) )
+ if ( ! isset( $wp_filter['all'] ) ) {
$wp_current_filter[] = $tag;
+ }
$filtered = $wp_filter[ $tag ]->apply_filters( $args[0], $args );
@@ -296,7 +303,7 @@
function remove_all_filters( $tag, $priority = false ) {
global $wp_filter;
- if ( isset( $wp_filter[ $tag ]) ) {
+ if ( isset( $wp_filter[ $tag ] ) ) {
$wp_filter[ $tag ]->remove_all_filters( $priority );
if ( ! $wp_filter[ $tag ]->has_filters() ) {
unset( $wp_filter[ $tag ] );
@@ -395,8 +402,8 @@
* @param int $accepted_args Optional. The number of arguments the function accepts. Default 1.
* @return true Will always return true.
*/
-function add_action($tag, $function_to_add, $priority = 10, $accepted_args = 1) {
- return add_filter($tag, $function_to_add, $priority, $accepted_args);
+function add_action( $tag, $function_to_add, $priority = 10, $accepted_args = 1 ) {
+ return add_filter( $tag, $function_to_add, $priority, $accepted_args );
}
/**
@@ -418,41 +425,46 @@
* @param mixed $arg,... Optional. Additional arguments which are passed on to the
* functions hooked to the action. Default empty.
*/
-function do_action($tag, $arg = '') {
+function do_action( $tag, $arg = '' ) {
global $wp_filter, $wp_actions, $wp_current_filter;
- if ( ! isset($wp_actions[$tag]) )
- $wp_actions[$tag] = 1;
- else
- ++$wp_actions[$tag];
+ if ( ! isset( $wp_actions[ $tag ] ) ) {
+ $wp_actions[ $tag ] = 1;
+ } else {
+ ++$wp_actions[ $tag ];
+ }
// Do 'all' actions first
- if ( isset($wp_filter['all']) ) {
+ if ( isset( $wp_filter['all'] ) ) {
$wp_current_filter[] = $tag;
- $all_args = func_get_args();
- _wp_call_all_hook($all_args);
+ $all_args = func_get_args();
+ _wp_call_all_hook( $all_args );
}
- if ( !isset($wp_filter[$tag]) ) {
- if ( isset($wp_filter['all']) )
- array_pop($wp_current_filter);
+ if ( ! isset( $wp_filter[ $tag ] ) ) {
+ if ( isset( $wp_filter['all'] ) ) {
+ array_pop( $wp_current_filter );
+ }
return;
}
- if ( !isset($wp_filter['all']) )
+ if ( ! isset( $wp_filter['all'] ) ) {
$wp_current_filter[] = $tag;
+ }
$args = array();
- if ( is_array($arg) && 1 == count($arg) && isset($arg[0]) && is_object($arg[0]) ) // array(&$this)
+ if ( is_array( $arg ) && 1 == count( $arg ) && isset( $arg[0] ) && is_object( $arg[0] ) ) { // array(&$this)
$args[] =& $arg[0];
- else
+ } else {
$args[] = $arg;
- for ( $a = 2, $num = func_num_args(); $a < $num; $a++ )
- $args[] = func_get_arg($a);
+ }
+ for ( $a = 2, $num = func_num_args(); $a < $num; $a++ ) {
+ $args[] = func_get_arg( $a );
+ }
$wp_filter[ $tag ]->do_action( $args );
- array_pop($wp_current_filter);
+ array_pop( $wp_current_filter );
}
/**
@@ -465,13 +477,14 @@
* @param string $tag The name of the action hook.
* @return int The number of times action hook $tag is fired.
*/
-function did_action($tag) {
+function did_action( $tag ) {
global $wp_actions;
- if ( ! isset( $wp_actions[ $tag ] ) )
+ if ( ! isset( $wp_actions[ $tag ] ) ) {
return 0;
+ }
- return $wp_actions[$tag];
+ return $wp_actions[ $tag ];
}
/**
@@ -488,33 +501,36 @@
* @param string $tag The name of the action to be executed.
* @param array $args The arguments supplied to the functions hooked to `$tag`.
*/
-function do_action_ref_array($tag, $args) {
+function do_action_ref_array( $tag, $args ) {
global $wp_filter, $wp_actions, $wp_current_filter;
- if ( ! isset($wp_actions[$tag]) )
- $wp_actions[$tag] = 1;
- else
- ++$wp_actions[$tag];
+ if ( ! isset( $wp_actions[ $tag ] ) ) {
+ $wp_actions[ $tag ] = 1;
+ } else {
+ ++$wp_actions[ $tag ];
+ }
// Do 'all' actions first
- if ( isset($wp_filter['all']) ) {
+ if ( isset( $wp_filter['all'] ) ) {
$wp_current_filter[] = $tag;
- $all_args = func_get_args();
- _wp_call_all_hook($all_args);
+ $all_args = func_get_args();
+ _wp_call_all_hook( $all_args );
}
- if ( !isset($wp_filter[$tag]) ) {
- if ( isset($wp_filter['all']) )
- array_pop($wp_current_filter);
+ if ( ! isset( $wp_filter[ $tag ] ) ) {
+ if ( isset( $wp_filter['all'] ) ) {
+ array_pop( $wp_current_filter );
+ }
return;
}
- if ( !isset($wp_filter['all']) )
+ if ( ! isset( $wp_filter['all'] ) ) {
$wp_current_filter[] = $tag;
+ }
$wp_filter[ $tag ]->do_action( $args );
- array_pop($wp_current_filter);
+ array_pop( $wp_current_filter );
}
/**
@@ -533,8 +549,8 @@
* that evaluates to false (e.g.) 0, so use the === operator for testing the
* return value.
*/
-function has_action($tag, $function_to_check = false) {
- return has_filter($tag, $function_to_check);
+function has_action( $tag, $function_to_check = false ) {
+ return has_filter( $tag, $function_to_check );
}
/**
@@ -564,8 +580,8 @@
* @param int|bool $priority The priority number to remove them from. Default false.
* @return true True when finished.
*/
-function remove_all_actions($tag, $priority = false) {
- return remove_all_filters($tag, $priority);
+function remove_all_actions( $tag, $priority = false ) {
+ return remove_all_filters( $tag, $priority );
}
/**
@@ -660,11 +676,11 @@
}
}
- $plugin_dir = wp_normalize_path( WP_PLUGIN_DIR );
+ $plugin_dir = wp_normalize_path( WP_PLUGIN_DIR );
$mu_plugin_dir = wp_normalize_path( WPMU_PLUGIN_DIR );
- $file = preg_replace('#^' . preg_quote($plugin_dir, '#') . '/|^' . preg_quote($mu_plugin_dir, '#') . '/#','',$file); // get relative path from plugins dir
- $file = trim($file, '/');
+ $file = preg_replace( '#^' . preg_quote( $plugin_dir, '#' ) . '/|^' . preg_quote( $mu_plugin_dir, '#' ) . '/#', '', $file ); // get relative path from plugins dir
+ $file = trim( $file, '/' );
return $file;
}
@@ -691,11 +707,11 @@
// Normalize, but store as static to avoid recalculation of a constant value
static $wp_plugin_path = null, $wpmu_plugin_path = null;
if ( ! isset( $wp_plugin_path ) ) {
- $wp_plugin_path = wp_normalize_path( WP_PLUGIN_DIR );
+ $wp_plugin_path = wp_normalize_path( WP_PLUGIN_DIR );
$wpmu_plugin_path = wp_normalize_path( WPMU_PLUGIN_DIR );
}
- $plugin_path = wp_normalize_path( dirname( $file ) );
+ $plugin_path = wp_normalize_path( dirname( $file ) );
$plugin_realpath = wp_normalize_path( dirname( realpath( $file ) ) );
if ( $plugin_path === $wp_plugin_path || $plugin_path === $wpmu_plugin_path ) {
@@ -751,9 +767,9 @@
* @param string $file The filename of the plugin including the path.
* @param callable $function The function hooked to the 'activate_PLUGIN' action.
*/
-function register_activation_hook($file, $function) {
- $file = plugin_basename($file);
- add_action('activate_' . $file, $function);
+function register_activation_hook( $file, $function ) {
+ $file = plugin_basename( $file );
+ add_action( 'activate_' . $file, $function );
}
/**
@@ -774,9 +790,9 @@
* @param string $file The filename of the plugin including the path.
* @param callable $function The function hooked to the 'deactivate_PLUGIN' action.
*/
-function register_deactivation_hook($file, $function) {
- $file = plugin_basename($file);
- add_action('deactivate_' . $file, $function);
+function register_deactivation_hook( $file, $function ) {
+ $file = plugin_basename( $file );
+ add_action( 'deactivate_' . $file, $function );
}
/**
@@ -816,10 +832,10 @@
* cases. Emphasis should be put on using the 'uninstall.php' way of
* uninstalling the plugin.
*/
- $uninstallable_plugins = (array) get_option('uninstall_plugins');
- $uninstallable_plugins[plugin_basename($file)] = $callback;
+ $uninstallable_plugins = (array) get_option( 'uninstall_plugins' );
+ $uninstallable_plugins[ plugin_basename( $file ) ] = $callback;
- update_option('uninstall_plugins', $uninstallable_plugins);
+ update_option( 'uninstall_plugins', $uninstallable_plugins );
}
/**
@@ -840,7 +856,7 @@
*
* @param array $args The collected parameters from the hook that was called.
*/
-function _wp_call_all_hook($args) {
+function _wp_call_all_hook( $args ) {
global $wp_filter;
$wp_filter['all']->do_all_hook( $args );
@@ -880,30 +896,32 @@
* and $function is an object reference, and it does not already have
* a unique id.
*/
-function _wp_filter_build_unique_id($tag, $function, $priority) {
+function _wp_filter_build_unique_id( $tag, $function, $priority ) {
global $wp_filter;
static $filter_id_count = 0;
- if ( is_string($function) )
+ if ( is_string( $function ) ) {
return $function;
+ }
- if ( is_object($function) ) {
+ if ( is_object( $function ) ) {
// Closures are currently implemented as objects
$function = array( $function, '' );
} else {
$function = (array) $function;
}
- if (is_object($function[0]) ) {
+ if ( is_object( $function[0] ) ) {
// Object Class Calling
- if ( function_exists('spl_object_hash') ) {
- return spl_object_hash($function[0]) . $function[1];
+ if ( function_exists( 'spl_object_hash' ) ) {
+ return spl_object_hash( $function[0] ) . $function[1];
} else {
- $obj_idx = get_class($function[0]).$function[1];
- if ( !isset($function[0]->wp_filter_id) ) {
- if ( false === $priority )
+ $obj_idx = get_class( $function[0] ) . $function[1];
+ if ( ! isset( $function[0]->wp_filter_id ) ) {
+ if ( false === $priority ) {
return false;
- $obj_idx .= isset($wp_filter[$tag][$priority]) ? count((array)$wp_filter[$tag][$priority]) : $filter_id_count;
+ }
+ $obj_idx .= isset( $wp_filter[ $tag ][ $priority ] ) ? count( (array) $wp_filter[ $tag ][ $priority ] ) : $filter_id_count;
$function[0]->wp_filter_id = $filter_id_count;
++$filter_id_count;
} else {