diff options
Diffstat (limited to 'plugins/jetpack/class.json-api-endpoints.php')
-rw-r--r-- | plugins/jetpack/class.json-api-endpoints.php | 21 |
1 files changed, 17 insertions, 4 deletions
diff --git a/plugins/jetpack/class.json-api-endpoints.php b/plugins/jetpack/class.json-api-endpoints.php index 69f457dd..8eb14952 100644 --- a/plugins/jetpack/class.json-api-endpoints.php +++ b/plugins/jetpack/class.json-api-endpoints.php @@ -1475,17 +1475,30 @@ abstract class WPCOM_JSON_API_Endpoint { function copy_hooks( $from_hook, $to_hook, $base_paths ) { global $wp_filter; foreach ( $wp_filter as $hook => $actions ) { - if ( $from_hook <> $hook ) + + if ( $from_hook != $hook ) { continue; + } + foreach ( (array) $actions as $priority => $callbacks ) { foreach( $callbacks as $callback_key => $callback_data ) { $callback = $callback_data['function']; - $reflection = $this->get_reflection( $callback ); // use reflection api to determine filename where function is defined + + // use reflection api to determine filename where function is defined + $reflection = $this->get_reflection( $callback ); + if ( false !== $reflection ) { $file_name = $reflection->getFileName(); foreach( $base_paths as $base_path ) { - if ( 0 === strpos( $file_name, $base_path ) ) { // only copy hooks with functions which are part of the specified files - $wp_filter[ $to_hook ][ $priority ][ 'cph' . $callback_key ] = $callback_data; + + // only copy hooks with functions which are part of the specified files + if ( 0 === strpos( $file_name, $base_path ) ) { + add_action( + $to_hook, + $callback_data['function'], + $priority, + $callback_data['accepted_args'] + ); } } } |