| 1 | <?php |
|---|
| 2 | /** |
|---|
| 3 | * Marks an action/filter hook as deprecated and informs when it has been used. |
|---|
| 4 | * |
|---|
| 5 | * @access private |
|---|
| 6 | * |
|---|
| 7 | * @param string $tag The hook that was used |
|---|
| 8 | * @param string $version The version of WordPress that deprecated the hook |
|---|
| 9 | * @param string $replacement Optional. The hook that should have been used |
|---|
| 10 | */ |
|---|
| 11 | function _deprecated_hook( $tag, $version, $replacement = null ) { |
|---|
| 12 | if ( WP_DEBUG && apply_filters( 'deprecated_hook_trigger_error', true ) ) { |
|---|
| 13 | if ( ! is_null( $replacement ) ) |
|---|
| 14 | trigger_error( sprintf( __('The %1$s hook is <strong>deprecated</strong>! Use %3$s instead.'), $tag, $version, $replacement ) ); |
|---|
| 15 | else |
|---|
| 16 | trigger_error( sprintf( __('The %1$s hook is <strong>deprecated</strong> since version %2$s with no alternative available.'), $tag, $version ) ); |
|---|
| 17 | } |
|---|
| 18 | } |
|---|
| 19 | |
|---|
| 20 | /** |
|---|
| 21 | * Call the functions hooked to a deprecated filter hook |
|---|
| 22 | * |
|---|
| 23 | * This function invokes do_filter() but first issues a warning that |
|---|
| 24 | * a deprecated hook is being used |
|---|
| 25 | * |
|---|
| 26 | * @access private |
|---|
| 27 | * |
|---|
| 28 | * @param string $tag The name of the deprecated action to be executed. |
|---|
| 29 | * @param mixed $value The value on which the filters hooked to <tt>$tag</tt> are applied on. |
|---|
| 30 | * @param string $version The version of WordPress that deprecated the action |
|---|
| 31 | * @param string $replacement The recommended hook to be used instead |
|---|
| 32 | * @param mixed $var,... Additional variables, see apply_filters() |
|---|
| 33 | * @return null Will return null if $tag does not exist in $wp_filter array |
|---|
| 34 | */ |
|---|
| 35 | function _apply_deprecated_filters( $tag, $value, $version, $replacement = null ) { |
|---|
| 36 | if ( isset( $GLOBALS['wp_filter'][$tag] ) ) |
|---|
| 37 | _deprecated_hook( $tag, $version, $replacement ); |
|---|
| 38 | |
|---|
| 39 | $args = array( $tag, $value ); |
|---|
| 40 | for ( $a = 4, $n = func_num_args() ; $a < $n; $a++ ) |
|---|
| 41 | $args[] = func_get_arg( $a ); |
|---|
| 42 | |
|---|
| 43 | call_user_func_array( 'apply_filters', $args ); |
|---|
| 44 | } |
|---|
| 45 | |
|---|
| 46 | /** |
|---|
| 47 | * Execute functions hooked on a deprecated action hook |
|---|
| 48 | * |
|---|
| 49 | * This function invokes do_action() but first issues a warning that |
|---|
| 50 | * a deprecated hook is being used |
|---|
| 51 | * |
|---|
| 52 | * @access private |
|---|
| 53 | * |
|---|
| 54 | * @param string $tag The name of the deprecated action to be executed. |
|---|
| 55 | * @param string $version The version of WordPress that deprecated the action |
|---|
| 56 | * @param string $replacement The recommended hook to be used instead |
|---|
| 57 | * @param mixed $arg Optional additional arguments, if multiple then must be an array |
|---|
| 58 | */ |
|---|
| 59 | function _do_deprecated_action( $tag, $version, $replacement = null, $arg = '' ) { |
|---|
| 60 | if ( isset( $GLOBALS['wp_filter'][$tag] ) ) |
|---|
| 61 | _deprecated_hook( $tag, $version, $replacement ); |
|---|
| 62 | |
|---|
| 63 | do_action( $tag, $arg ); |
|---|
| 64 | } |
|---|
| 65 | ?> |
|---|