Skip to:
Content

bbPress.org


Ignore:
Timestamp:
04/22/2018 10:34:54 PM (7 years ago)
Author:
johnjamesjacoby
Message:

Intercept: updates to bbp_maybe_intercept():

  • Use bbp_parse_args() internally
  • Compare against known default return value
  • Use call_user_func_array() to avoid using extract()

This change allows the intercept API to work a bit more smoothly with filters that have multiple arguments passed into them. Previous to this, those filters may have dropped their arguments, or otherwise not passed the proper arguments into their filter call.

This fixes a regression related to BuddyPress profile URL overrides.

See #3814.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/includes/core/abstraction.php

    r6785 r6803  
    434434
    435435    // Backwards compatibility juggle
    436     $hook      = ( false === strpos( $action, 'pre_' ) )
     436    $hook     = ( false === strpos( $action, 'pre_' ) )
    437437        ? "pre_{$action}"
    438438        : $action;
    439439
    440     // Sanitize the hook same
    441     $key       = sanitize_key( $hook );
    442 
    443     // Default return value
    444     $default   = bbp_default_intercept();
    445 
    446     // Filter and return
    447     return apply_filters( $key, $default, extract( (array) $args ) );
     440    // Parse args
     441    $r        = bbp_parse_args( (array) $args, array(), 'maybe_intercept' );
     442    $retval   = reset( $r );
     443
     444    // Filter
     445    $args     = array_merge( array( $hook ), $r );
     446    $filtered = call_user_func_array( 'apply_filters', $args );
     447
     448    // Return filtered value, or default if not intercepted
     449    return ( $filtered === $retval )
     450        ? bbp_default_intercept()
     451        : $filtered;
    448452}
    449453
Note: See TracChangeset for help on using the changeset viewer.