Skip to:
Content

bbPress.org


Ignore:
Timestamp:
04/23/2018 07:35:53 AM (8 years ago)
Author:
johnjamesjacoby
Message:

Intercept: return default value if an invalid number of args is parsed.

Also pass a $user_id into favorites & subscriptions links functions.

These changes together will prevent notices & errors in certain intercept conditions.

File:
1 edited

Legend:

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

    r6803 r6816  
    434434
    435435    // Backwards compatibility juggle
    436     $hook     = ( false === strpos( $action, 'pre_' ) )
     436    $hook = ( false === strpos( $action, 'pre_' ) )
    437437        ? "pre_{$action}"
    438438        : $action;
    439439
     440    // Default value
     441    $default = bbp_default_intercept();
     442
    440443    // Parse args
    441     $r        = bbp_parse_args( (array) $args, array(), 'maybe_intercept' );
    442     $retval   = reset( $r );
     444    $r = bbp_parse_args( (array) $args, array(), 'maybe_intercept' );
     445
     446    // Bail if no args
     447    if ( empty( $r ) ) {
     448        return $default;
     449    }
    443450
    444451    // Filter
     
    447454
    448455    // Return filtered value, or default if not intercepted
    449     return ( $filtered === $retval )
    450         ? bbp_default_intercept()
     456    return ( $filtered === reset( $r ) )
     457        ? $default
    451458        : $filtered;
    452459}
Note: See TracChangeset for help on using the changeset viewer.