Changeset 53803 for trunk/src/wp-includes/plugin.php
- Timestamp:
- 07/31/2022 02:18:36 PM (2 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/plugin.php
r53770 r53803 30 30 /** @var int[] $wp_actions */ 31 31 global $wp_actions; 32 33 /** @var int[] $wp_filters */ 34 global $wp_filters; 32 35 33 36 /** @var string[] $wp_current_filter */ … … 42 45 if ( ! isset( $wp_actions ) ) { 43 46 $wp_actions = array(); 47 } 48 49 if ( ! isset( $wp_filters ) ) { 50 $wp_filters = array(); 44 51 } 45 52 … … 156 163 * 157 164 * @global WP_Hook[] $wp_filter Stores all of the filters and actions. 165 * @global int[] $wp_filters Stores the number of times each filter was triggered. 158 166 * @global string[] $wp_current_filter Stores the list of current filters with the current one last. 159 167 * … … 164 172 */ 165 173 function apply_filters( $hook_name, $value, ...$args ) { 166 global $wp_filter, $wp_current_filter; 174 global $wp_filter, $wp_filters, $wp_current_filter; 175 176 if ( ! isset( $wp_filters[ $hook_name ] ) ) { 177 $wp_filters[ $hook_name ] = 1; 178 } else { 179 ++$wp_filters[ $hook_name ]; 180 } 167 181 168 182 // Do 'all' actions first. … … 205 219 * 206 220 * @global WP_Hook[] $wp_filter Stores all of the filters and actions. 221 * @global int[] $wp_filters Stores the number of times each filter was triggered. 207 222 * @global string[] $wp_current_filter Stores the list of current filters with the current one last. 208 223 * … … 212 227 */ 213 228 function apply_filters_ref_array( $hook_name, $args ) { 214 global $wp_filter, $wp_current_filter; 229 global $wp_filter, $wp_filters, $wp_current_filter; 230 231 if ( ! isset( $wp_filters[ $hook_name ] ) ) { 232 $wp_filters[ $hook_name ] = 1; 233 } else { 234 ++$wp_filters[ $hook_name ]; 235 } 215 236 216 237 // Do 'all' actions first. … … 376 397 377 398 return in_array( $hook_name, $wp_current_filter, true ); 399 } 400 401 /** 402 * Retrieves the number of times a filter has been applied during the current request. 403 * 404 * @since 6.1.0 405 * 406 * @global int[] $wp_filters Stores the number of times each filter was triggered. 407 * 408 * @param string $hook_name The name of the filter hook. 409 * @return int The number of times the filter hook has been applied. 410 */ 411 function did_filter( $hook_name ) { 412 global $wp_filters; 413 414 if ( ! isset( $wp_filters[ $hook_name ] ) ) { 415 return 0; 416 } 417 418 return $wp_filters[ $hook_name ]; 378 419 } 379 420
Note: See TracChangeset
for help on using the changeset viewer.