Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Switched arrangement of deprecated filters array.
Props @shadyvb for the suggestion.
- Loading branch information
Luke Carbis
committed
Apr 13, 2014
1 parent
4dc0ca9
commit 172b879
Showing
1 changed file
with
9 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,42 +7,38 @@ | |
global $wp_stream_deprecated_filters; | ||
|
||
$wp_stream_deprecated_filters = array( | ||
'wp_stream_query_args' => array( | ||
'old' => 'stream_query_args', | ||
'stream_query_args' => array( | ||
'new' => 'wp_stream_query_args', | ||
'version' => '3.0.1', | ||
), | ||
); | ||
|
||
foreach ( $wp_stream_deprecated_filters as $new => $old ) { | ||
add_filter( $new, 'wp_stream_deprecated_filter_mapping' ); | ||
foreach ( $wp_stream_deprecated_filters as $old => $new ) { | ||
add_filter( $old, 'wp_stream_deprecated_filter_mapping' ); | ||
} | ||
|
||
function wp_stream_deprecated_filter_mapping( $data ) { | ||
This comment has been minimized.
Sorry, something went wrong. |
||
global $wp_stream_deprecated_filters; | ||
|
||
$filter = current_filter(); | ||
|
||
if ( ! isset( $wp_stream_deprecated_filters[ $filter ][ 'old' ] ) ) { | ||
return $data; | ||
} | ||
|
||
if ( ! has_filter( $wp_stream_deprecated_filters[ $filter ][ 'old' ] ) ) { | ||
if ( ! has_filter( $filter ) ) { | ||
This comment has been minimized.
Sorry, something went wrong.
shadyvb
Contributor
|
||
return $data; | ||
} | ||
|
||
$filter_args = array_merge( | ||
array( | ||
$wp_stream_deprecated_filters[ $filter ][ 'old' ], | ||
$wp_stream_deprecated_filters[ $filter ]['new'], | ||
), | ||
func_get_args() | ||
); | ||
|
||
$data = call_user_func_array( 'apply_filters', $filter_args ); | ||
|
||
_deprecated_function( | ||
sprintf( __( 'The %s filter', 'stream' ), $wp_stream_deprecated_filters[ $filter ][ 'old' ] ), | ||
$wp_stream_deprecated_filters[ $filter ][ 'version' ], | ||
$filter | ||
sprintf( __( 'The %s filter', 'stream' ), $filter ), | ||
$wp_stream_deprecated_filters[ $filter ]['version'], | ||
$wp_stream_deprecated_filters[ $filter ]['new'] | ||
); | ||
|
||
return $data; | ||
|
$data
here won't be needed, since we're dealing with a dynamic number of arguments.