WordPress.org

Make WordPress Core

Ticket #47678: 47678- code-simplification-apply_filters.patch

File 47678- code-simplification-apply_filters.patch, 1.2 KB (added by jrf, 9 months ago)

Code simplification apply_filters()

  • src/wp-includes/plugin.php

    From 4a326547bbff15c74fe6750299ec08a00a6dc80d Mon Sep 17 00:00:00 2001
    From: jrfnl <jrfnl@users.noreply.github.com>
    Date: Thu, 18 Jul 2019 06:27:32 +0200
    Subject: [PATCH] Code simplification apply_filters()
    
    ---
     src/wp-includes/plugin.php | 9 ++-------
     1 file changed, 2 insertions(+), 7 deletions(-)
    
    diff --git a/src/wp-includes/plugin.php b/src/wp-includes/plugin.php
    index 7c40389f90..a89c61be9e 100644
    a b function has_filter( $tag, $function_to_check = false ) { 
    181181function apply_filters( $tag, $value ) {
    182182        global $wp_filter, $wp_current_filter;
    183183
    184         $args = array();
     184        $args = func_get_args();
    185185
    186186        // Do 'all' actions first.
    187187        if ( isset( $wp_filter['all'] ) ) {
    188188                $wp_current_filter[] = $tag;
    189                 $args                = func_get_args();
    190189                _wp_call_all_hook( $args );
    191190        }
    192191
    function apply_filters( $tag, $value ) { 
    201200                $wp_current_filter[] = $tag;
    202201        }
    203202
    204         if ( empty( $args ) ) {
    205                 $args = func_get_args();
    206         }
    207 
    208         // don't pass the tag name to WP_Hook
     203        // Don't pass the tag name to WP_Hook.
    209204        array_shift( $args );
    210205
    211206        $filtered = $wp_filter[ $tag ]->apply_filters( $value, $args );