Skip to:
Content

BuddyPress.org

Ticket #4794: 4794.02.patch

File 4794.02.patch, 3.3 KB (added by r-a-y, 12 years ago)

Switch out is_object() for screen function checks and use is_callable()

  • bp-core/bp-core-buddybar.php

    function bp_core_new_nav_item( $args = '' ) { 
    8181                if ( !empty( $default_subnav_slug ) && bp_is_current_action( $default_subnav_slug ) && !bp_action_variable( 0 ) ) {
    8282                        unset( $bp->canonical_stack['action'] );
    8383                } elseif ( ! bp_current_action() ) {
    84                         $func = is_object( $screen_function[0] ) ? array( &$screen_function[0], $screen_function[1] ) : $screen_function;
    85                         add_action( 'bp_screens', $func, 3 );
     84
     85                        // Add our screen hook if screen function is callable
     86                        if ( is_callable( $screen_function ) ) {
     87                                add_action( 'bp_screens', $screen_function, 3 );
     88                        }
    8689
    8790                        if ( !empty( $default_subnav_slug ) ) {
    8891                                $bp->current_action = apply_filters( 'bp_default_component_subnav', $default_subnav_slug, $r );
    function bp_core_new_nav_default( $args = '' ) { 
    112115        extract( $r, EXTR_SKIP );
    113116
    114117        if ( $function = $bp->bp_nav[$parent_slug]['screen_function'] ) {
    115                 if ( is_object( $function[0] ) ) {
    116                         remove_action( 'bp_screens', array( &$function[0], $function[1] ), 3 );
    117                 } else {
     118                // Remove our screen hook if screen function is callable
     119                if ( is_callable( $function ) ) {
    118120                        remove_action( 'bp_screens', $function, 3 );
    119121                }
    120122        }
    function bp_core_new_nav_default( $args = '' ) { 
    136138                // No subnav item has been requested in the URL, so set a new nav default
    137139                if ( empty( $unfiltered_action ) ) {
    138140                        if ( !bp_is_current_action( $subnav_slug ) ) {
    139                                 if ( is_object( $screen_function[0] ) ) {
    140                                         add_action( 'bp_screens', array( &$screen_function[0], $screen_function[1] ), 3 );
    141                                 } else {
     141                                if ( is_callable( $screen_function ) ) {
    142142                                        add_action( 'bp_screens', $screen_function, 3 );
    143143                                }
    144144
    function bp_core_new_subnav_item( $args = '' ) { 
    278278
    279279                // Before hooking the screen function, check user access
    280280                if ( !empty( $user_has_access ) ) {
    281                         if ( is_object( $screen_function[0] ) ) {
    282                                 add_action( 'bp_screens', array( &$screen_function[0], $screen_function[1] ), 3 );
    283                         } else {
     281                        // Add our screen hook if screen function is callable
     282                        if ( is_callable( $screen_function ) ) {
    284283                                add_action( 'bp_screens', $screen_function, 3 );
    285284                        }
    286285                } else {
    function bp_core_remove_nav_item( $parent_id ) { 
    390389                return false;
    391390
    392391        if ( $function = $bp->bp_nav[$parent_id]['screen_function'] ) {
    393                 if ( is_object( $function[0] ) ) {
    394                         remove_action( 'bp_screens', array( &$function[0], $function[1] ), 3 );
    395                 } else {
     392                // Remove our screen hook if screen function is callable
     393                if ( is_callable( $function ) ) {
    396394                        remove_action( 'bp_screens', $function, 3 );
    397395                }
    398396        }
    function bp_core_remove_subnav_item( $parent_id, $slug ) { 
    412410
    413411        $screen_function = isset( $bp->bp_options_nav[$parent_id][$slug]['screen_function'] ) ? $bp->bp_options_nav[$parent_id][$slug]['screen_function'] : false;
    414412
    415         if ( !empty( $screen_function ) ) {
    416                 if ( is_object( $screen_function[0] ) ) {
    417                         remove_action( 'bp_screens', array( &$screen_function[0], $screen_function[1] ), 3 );
    418                 } else {
     413        if ( ! empty( $screen_function ) ) {
     414                // Remove our screen hook if screen function is callable
     415                if ( is_callable( $screen_function ) ) {
    419416                        remove_action( 'bp_screens', $screen_function, 3 );
    420417                }
    421418        }