Ticket #35357: 35357.5.patch
| File 35357.5.patch, 2.0 KB (added by , 5 years ago) |
|---|
-
src/wp-includes/plugin.php
30 30 /** @var int[] $wp_actions */ 31 31 global $wp_actions; 32 32 33 /** @var int[] $wp_filters */ 34 global $wp_filters; 35 33 36 /** @var string[] $wp_current_filter */ 34 37 global $wp_current_filter; 35 38 … … 43 46 $wp_actions = array(); 44 47 } 45 48 49 if ( ! isset( $wp_filters ) ) { 50 $wp_filters = array(); 51 } 52 46 53 if ( ! isset( $wp_current_filter ) ) { 47 54 $wp_current_filter = array(); 48 55 } … … 161 168 * @return mixed The filtered value after all hooked functions are applied to it. 162 169 */ 163 170 function apply_filters( $hook_name, $value ) { 164 global $wp_filter, $wp_current_filter ;171 global $wp_filter, $wp_current_filter, $wp_filters; 165 172 173 if ( ! isset( $wp_filters[ $tag ] ) ) { 174 $wp_filters[ $tag ] = 1; 175 } else { 176 ++$wp_filters[ $tag ]; 177 } 178 166 179 $args = func_get_args(); 167 180 168 181 // Do 'all' actions first. … … 209 222 * @return mixed The filtered value after all hooked functions are applied to it. 210 223 */ 211 224 function apply_filters_ref_array( $hook_name, $args ) { 212 global $wp_filter, $wp_current_filter ;225 global $wp_filter, $wp_current_filter, $wp_filters; 213 226 227 if ( ! isset( $wp_filters[ $tag ] ) ) { 228 $wp_filters[ $tag ] = 1; 229 } else { 230 ++$wp_filters[ $tag ]; 231 } 232 214 233 // Do 'all' actions first. 215 234 if ( isset( $wp_filter['all'] ) ) { 216 235 $wp_current_filter[] = $hook_name; … … 238 257 } 239 258 240 259 /** 260 * Retrieve the number of times a filter has been fired. 261 * 262 * @param string $tag The name of the filter hook. 263 * @return int The number of times filter hook $tag is fired. 264 * 265 * @global int[] $wp_filters Stores the number of times each filter was triggered. 266 * 267 */ 268 function did_filter( $tag ) { 269 global $wp_filters; 270 271 if ( ! isset( $wp_filters[ $tag ] ) ) { 272 return 0; 273 } 274 275 return $wp_filters[ $tag ]; 276 } 277 278 /** 241 279 * Checks if any filter has been registered for a hook. 242 280 * 243 281 * When using the `$callback` argument, this function may return a non-boolean value