Make WordPress Core

Ticket #53296: 53296.patch

File 53296.patch, 1.2 KB (added by xmic, 3 years ago)

Add trim to add_filter() function param 1

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

    diff --git a/src/wp-includes/class-wp-hook.php b/src/wp-includes/class-wp-hook.php
    index 432a01600f..03119724f1 100644
    a b final class WP_Hook implements Iterator, ArrayAccess { 
    7171        * @param int      $accepted_args The number of arguments the function accepts.
    7272        */
    7373       public function add_filter( $hook_name, $callback, $priority, $accepted_args ) {
     74
     75               $hook_name = trim( $hook_name );
     76
    7477               $idx = _wp_filter_build_unique_id( $hook_name, $callback, $priority );
    7578
    7679               $priority_existed = isset( $this->callbacks[ $priority ] );
  • src/wp-includes/plugin.php

    diff --git a/src/wp-includes/plugin.php b/src/wp-includes/plugin.php
    index 5f4fa15986..4f6988be74 100644
    a b if ( ! isset( $wp_current_filter ) ) { 
    114114function add_filter( $hook_name, $callback, $priority = 10, $accepted_args = 1 ) {
    115115       global $wp_filter;
    116116
     117       $hook_name = trim( $hook_name );
     118
    117119       if ( ! isset( $wp_filter[ $hook_name ] ) ) {
    118120               $wp_filter[ $hook_name ] = new WP_Hook();
    119121       }