WordPress.org

Make WordPress Core

Ticket #47678: 47678-WP_Hook-apply_filters.patch

File 47678-WP_Hook-apply_filters.patch, 1.3 KB (added by jrf, 7 months ago)

Minor simplification of WP_Hook::apply_filters()

  • src/wp-includes/class-wp-hook.php

    From eb3730738bbc6e2ed33a8ba50ffea95ec3c18da4 Mon Sep 17 00:00:00 2001
    From: jrfnl <jrfnl@users.noreply.github.com>
    Date: Fri, 19 Jul 2019 23:49:52 +0200
    Subject: [PATCH] Minor simplification of WP_Hook::apply_filters()
    
    ---
     src/wp-includes/class-wp-hook.php | 3 ++-
     1 file changed, 2 insertions(+), 1 deletion(-)
    
    diff --git a/src/wp-includes/class-wp-hook.php b/src/wp-includes/class-wp-hook.php
    index 6620e3f377..deac4ceb5d 100644
    a b final class WP_Hook implements Iterator, ArrayAccess { 
    259259         *
    260260         * @param mixed $value The value to filter.
    261261         * @param array $args  Additional parameters to pass to the callback functions.
     262         *                     This array is expected to include $value at index 0.
    262263         * @return mixed The filtered value after all hooked functions are applied to it.
    263264         */
    264265        public function apply_filters( $value, $args ) {
    final class WP_Hook implements Iterator, ArrayAccess { 
    282283
    283284                                // Avoid the array_slice if possible.
    284285                                if ( $the_['accepted_args'] == 0 ) {
    285                                         $value = call_user_func_array( $the_['function'], array() );
     286                                        $value = call_user_func( $the_['function'] );
    286287                                } elseif ( $the_['accepted_args'] >= $num_args ) {
    287288                                        $value = call_user_func_array( $the_['function'], $args );
    288289                                } else {