Ticket #5232: wp-current-filter-revised-r6317.patch
| File wp-current-filter-revised-r6317.patch, 2.3 KB (added by tellyworth, 5 years ago) |
|---|
-
wordpress/wp-includes/plugin.php
107 107 * @return string The text in <tt>$string</tt> after all hooked functions are applied to it. 108 108 */ 109 109 function apply_filters($tag, $value) { 110 global $wp_filter, $merged_filters ;110 global $wp_filter, $merged_filters, $wp_current_filter; 111 111 112 @$wp_current_filter[] = $tag; 113 112 114 // Do 'all' actions first 113 115 if ( isset($wp_filter['all']) ) { 114 116 reset( $wp_filter['all'] ); … … 120 122 } while ( next($wp_filter['all']) !== false ); 121 123 } 122 124 123 if ( !isset($wp_filter[$tag]) ) 125 if ( !isset($wp_filter[$tag]) ) { 126 array_pop($wp_current_filter); 124 127 return $value; 128 } 125 129 126 130 // Sort 127 131 if ( !isset( $merged_filters[ $tag ] ) ) { … … 142 146 } 143 147 144 148 } while ( next($wp_filter[$tag]) !== false ); 149 150 array_pop( $wp_current_filter ); 145 151 146 152 return $value; 147 153 } … … 182 188 183 189 184 190 /** 191 * Return the name of the current filter or action. 192 */ 193 function current_filter() { 194 global $wp_current_filter; 195 return end( $wp_current_filter ); 196 } 197 198 199 /** 185 200 * Hooks a function on to a specific action. 186 201 * 187 202 * Actions are the hooks that the WordPress core launches at specific points … … 233 248 * @return null Will return null if $tag does not exist in $wp_filter array 234 249 */ 235 250 function do_action($tag, $arg = '') { 236 global $wp_action, $wp_actions ;251 global $wp_action, $wp_actions, $wp_current_filter; 237 252 238 253 if ( is_array($wp_actions) ) 239 254 $wp_actions[] = $tag; … … 248 263 for ( $a = 2; $a < func_num_args(); $a++ ) 249 264 $args[] = func_get_arg($a); 250 265 266 @$wp_current_filter[] = $tag; 267 251 268 // Do 'all' actions first 252 269 if ( isset($wp_action['all']) ) { 253 270 do { … … 258 275 } while ( next($wp_action['all']) !== false ); 259 276 } 260 277 261 if ( !isset($wp_action[$tag]) ) 278 if ( !isset($wp_action[$tag]) ) { 279 array_pop($wp_current_filter); 262 280 return; 263 281 } 282 264 283 // Sort 265 284 if ( !isset( $merged_actions[ $tag ] ) ) { 266 285 reset($wp_action[$tag]); … … 277 296 278 297 } while ( next($wp_action[$tag]) !== false ); 279 298 299 array_pop($wp_current_filter); 280 300 } 281 301 282 302 /** … … 524 544 return $function[0].$function[1]; 525 545 } 526 546 527 ?> 528 No newline at end of file 547 ?>
