Ticket #40280: 40280.diff
File 40280.diff, 4.8 KB (added by , 7 years ago) |
---|
-
src/wp-includes/class-wp-short-circuit-result.php
1 <?php 2 /** 3 * Plugin API: WP_Short_Circuit_Result class 4 * 5 * @package WordPress 6 * @since 4.8.0 7 */ 8 9 /** 10 * Core class to store a short-circuit result. 11 * 12 * @since 4.8.0 13 */ 14 class WP_Short_Circuit_Result { 15 16 /** 17 * Whether the current process should be short-circuited. 18 * 19 * @since 4.8.0 20 * @access private 21 * @var bool 22 */ 23 private $short_circuit = false; 24 25 /** 26 * Value of the short-circuit. 27 * 28 * @since 4.8.0 29 * @access private 30 * @var mixed 31 */ 32 private $value = null; 33 34 /** 35 * Toggles or retrieves whether the current process should be short-circuited. 36 * 37 * @since 4.8.0 38 * @access public 39 * 40 * @param bool $set Optional. Whether to short-circuit the current process. If this is 41 * omitted, the current value is retrieved. Default null. 42 * @return bool The previous value of the short-circuit flag if $set was passed, or the 43 * current value of the flag otherwise. 44 */ 45 public function short_circuit( $set = null ) { 46 $current = $this->short_circuit; 47 48 if ( func_num_args() > 0 ) { 49 $this->short_circuit = (bool) $set; 50 } 51 52 return $current; 53 } 54 55 /** 56 * Sets or retrieves the result value of the short-circuit. 57 * 58 * @since 4.8.0 59 * @access public 60 * 61 * @param bool $set Optional. Result value of the short-circuit. If this is 62 * omitted, the current value is retrieved. Default null. 63 * @return bool The previous short-circuit result value if $set was passed, or the 64 * current result value otherwise. 65 */ 66 public function value( $set = null ) { 67 $current = $this->value; 68 69 if ( func_num_args() > 0 ) { 70 $this->value = $set; 71 } 72 73 return $current; 74 } 75 } -
src/wp-includes/plugin.php
622 622 do_action_ref_array( $tag, $args ); 623 623 } 624 624 625 /** 626 * Checks whether a specific filter hook should be used to short-circuit a process. 627 * 628 * @since 4.8.0 629 * 630 * @param string $tag The name of the filter hook. 631 * @param mixed &$value Value to be filled with the short-circuit result. Passed by reference. 632 * @param array $args Additional arguments for the filter hook. 633 * @return bool True if the process should be short-circuited, false otherwise. 634 */ 635 function wp_short_circuit_filter( $tag, &$value, $args = array() ) { 636 array_unshift( $args, new WP_Short_Circuit_Result() ); 637 638 /** 639 * Filters whether a specific filter hook should be used to short-circuit a process. 640 * 641 * The dynamic portion of the hook name, `$tag`, refers to the hook name. 642 * 643 * @since 4.8.0 644 * 645 * @param WP_Short_Circuit_Result $result Short-circuit object to modify. 646 * @param mixed $args,... Arguments for the filter. 647 */ 648 $result = apply_filters_ref_array( "wp_short_circuit_filter_{$tag}", $args ); 649 650 if ( is_a( $result, 'WP_Short_Circuit_Result' ) && $result->short_circuit() ) { 651 $value = $result->value(); 652 653 return true; 654 } 655 656 return false; 657 } 658 659 /** 660 * Checks whether a specific action hook should be used to short-circuit a process. 661 * 662 * @since 4.8.0 663 * 664 * @param string $tag The name of the action hook. 665 * @param array $args Additional arguments for the action hook. 666 * @return bool True if the process should be short-circuited, false otherwise. 667 */ 668 function wp_short_circuit_action( $tag, $args = array() ) { 669 array_unshift( $args, new WP_Short_Circuit_Result() ); 670 671 /** 672 * Filters whether a specific action hook should be used to short-circuit a process. 673 * 674 * The dynamic portion of the hook name, `$tag`, refers to the hook name. 675 * 676 * @since 4.8.0 677 * 678 * @param WP_Short_Circuit_Result $result Short-circuit object to modify. 679 * @param mixed $args,... Arguments for the action. 680 */ 681 $result = apply_filters_ref_array( "wp_short_circuit_action_{$tag}", $args ); 682 683 if ( is_a( $result, 'WP_Short_Circuit_Result' ) && $result->short_circuit() ) { 684 return true; 685 } 686 687 return false; 688 } 689 625 690 // 626 691 // Functions for handling plugins. 627 692 // -
src/wp-settings.php
18 18 // Include files required for initialization. 19 19 require( ABSPATH . WPINC . '/load.php' ); 20 20 require( ABSPATH . WPINC . '/default-constants.php' ); 21 require_once( ABSPATH . WPINC . '/class-wp-short-circuit-result.php' ); 21 22 require_once( ABSPATH . WPINC . '/plugin.php' ); 22 23 23 24 /*