Skip to content

Commit

Permalink
Switched arrangement of deprecated filters array.
Browse files Browse the repository at this point in the history
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.
22 changes: 9 additions & 13 deletions includes/deprecated.php
Expand Up @@ -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.

Copy link
@shadyvb

shadyvb Apr 13, 2014

Contributor

$data here won't be needed, since we're dealing with a dynamic number of arguments.

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.

Copy link
@shadyvb

shadyvb Apr 13, 2014

Contributor

@lukecarbis Not sure why we're doing this, since the filter has already been triggered, hence the execution of the function. Care to explain ?

This comment has been minimized.

Copy link
@lukecarbis

lukecarbis Apr 13, 2014

Contributor

Ah, I think this change broke things. I'm starting to see why I originally did it the way I did it. Stand by.

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;
Expand Down

0 comments on commit 172b879

Please sign in to comment.