Plugin Directory

Changeset 1589970


Ignore:
Timestamp:
02/06/2017 01:41:59 PM (9 years ago)
Author:
jozik
Message:

comp-2319 Fixed Activity redirections

File:
1 edited

Legend:

Unmodified
Added
Removed
  • buddypress-multilingual/trunk/includes/class.filters.php

    r1558084 r1589970  
    170170    }
    171171
    172     public function wpml_fix_activity_redirection( $q ){
    173         if ( !bp_is_blog_page()
    174             && (bool) $q->get( 'page_id' ) === false
    175             && (bool) $q->get( 'pagename' ) === true ) {
    176             if ( is_null( $this->bp_current_page_id ) ) {
    177                 $bp_pages = bp_core_get_directory_pages();
    178                 $bp_current_component = bp_current_component();
    179                 if ( isset( $bp_pages->members->id ) ) {
    180                     $this->bp_current_page_id = $bp_pages->members->id;
    181                 } else if ( isset( $bp_pages->{$bp_current_component}->id ) ) {
    182                     $this->bp_current_page_id = $bp_pages->{$bp_current_component}->id;
    183                 } else {
    184                     // Failed - add BuddyPress main page(s)
    185                     $this->bp_current_page_id = 0;
    186                 }
    187             }
    188             $q->set( 'page_id', $this->bp_current_page_id ) ;
    189         }
    190         return $q;
    191     }
     172    /**
     173     * Fixes redirection to root Activity page.
     174     * WPML_Name_Query_Filter_Translated::select_best_match()
     175     *
     176     * Affected views:
     177     * 1. Single activity /activity/p/6/
     178     * 2. Activity by member /members/admin/activity/ (Profile > Activity)
     179     *
     180     * @param $q WP_Query
     181     *
     182     * @return object WP_Query
     183     */
     184    public function wpml_fix_activity_redirection( $q ){
     185        if ( !defined( 'DOING_AJAX' ) && !bp_is_blog_page()
     186             && (bool) $q->get( 'page_id' ) === false
     187             && (bool) $q->get( 'pagename' ) === true ) {
     188
     189            $bp_current_component = bp_current_component();
     190            $bp_current_action    = bp_current_action();
     191
     192            if ( ( $bp_current_component == 'activity'
     193                   && ( $bp_current_action == 'p'
     194                        || is_numeric( $bp_current_action )
     195                        || $bp_current_action == 'just-me')
     196            ) ) {
     197
     198                if ( is_null( $this->bp_current_page_id ) ) {
     199                    $bp_pages = bp_core_get_directory_pages();
     200                    if ( isset( $bp_pages->members->id ) ) {
     201                        $this->bp_current_page_id = $bp_pages->members->id;
     202                    } else if ( isset( $bp_pages->{$bp_current_component}->id ) ) {
     203                        $this->bp_current_page_id = $bp_pages->{$bp_current_component}->id;
     204                    } else {
     205                        // Failed - add BuddyPress main page(s)
     206                        $this->bp_current_page_id = 0;
     207                    }
     208                }
     209                $q->set( 'page_id', $this->bp_current_page_id );
     210            }
     211        }
     212        return $q;
     213    }
    192214
    193215}
Note: See TracChangeset for help on using the changeset viewer.