Skip to:
Content

BuddyPress.org


Ignore:
Timestamp:
04/02/2018 03:51:24 AM (7 years ago)
Author:
r-a-y
Message:

Members: Conditionally load action and screen functions.

This commit conditionally loads action and screen function code for the
Members component, utilizing the 'bp_late_include' hook introduced in
r11884.

Previously, we loaded these functions at all times, which is unnecessary
when a user is not on a BuddyPress members page. Now, we only load this
code when needed.

See #7218.

Location:
trunk/src/bp-members/screens
Files:
1 added
1 moved

Legend:

Unmodified
Added
Removed
  • trunk/src/bp-members/screens/register.php

    r11926 r11927  
    11<?php
    22/**
    3  * BuddyPress Member Screens.
    4  *
    5  * Handlers for member screens that aren't handled elsewhere.
     3 * Members: Register screen handler
    64 *
    75 * @package BuddyPress
    86 * @subpackage MembersScreens
    9  * @since 1.5.0
     7 * @since 3.0.0
    108 */
    11 
    12 // Exit if accessed directly.
    13 defined( 'ABSPATH' ) || exit;
    14 
    15 /**
    16  * Handle the display of the profile page by loading the correct template file.
    17  *
    18  * @since 1.5.0
    19  */
    20 function bp_members_screen_display_profile() {
    21 
    22     /**
    23      * Fires right before the loading of the Member profile screen template file.
    24      *
    25      * @since 1.5.0
    26      */
    27     do_action( 'bp_members_screen_display_profile' );
    28 
    29     /**
    30      * Filters the template to load for the Member profile page screen.
    31      *
    32      * @since 1.5.0
    33      *
    34      * @param string $template Path to the Member template to load.
    35      */
    36     bp_core_load_template( apply_filters( 'bp_members_screen_display_profile', 'members/single/home' ) );
    37 }
    38 
    39 /**
    40  * Handle the display of the members directory index.
    41  *
    42  * @since 1.5.0
    43  */
    44 function bp_members_screen_index() {
    45     if ( bp_is_members_directory() ) {
    46         bp_update_is_directory( true, 'members' );
    47 
    48         /**
    49          * Fires right before the loading of the Member directory index screen template file.
    50          *
    51          * @since 1.5.0
    52          */
    53         do_action( 'bp_members_screen_index' );
    54 
    55         /**
    56          * Filters the template to load for the Member directory page screen.
    57          *
    58          * @since 1.5.0
    59          *
    60          * @param string $value Path to the member directory template to load.
    61          */
    62         bp_core_load_template( apply_filters( 'bp_members_screen_index', 'members/index' ) );
    63     }
    64 }
    65 add_action( 'bp_screens', 'bp_members_screen_index' );
    669
    6710/**
     
    287230}
    288231add_action( 'bp_screens', 'bp_core_screen_signup' );
    289 
    290 /**
    291  * Handle the loading of the Activate screen.
    292  *
    293  * @since 1.1.0
    294  */
    295 function bp_core_screen_activation() {
    296 
    297     // Bail if not viewing the activation page.
    298     if ( ! bp_is_current_component( 'activate' ) ) {
    299         return false;
    300     }
    301 
    302     // If the user is already logged in, redirect away from here.
    303     if ( is_user_logged_in() ) {
    304 
    305         // If activation page is also front page, set to members directory to
    306         // avoid an infinite loop. Otherwise, set to root domain.
    307         $redirect_to = bp_is_component_front_page( 'activate' )
    308             ? bp_get_members_directory_permalink()
    309             : bp_get_root_domain();
    310 
    311         // Trailing slash it, as we expect these URL's to be.
    312         $redirect_to = trailingslashit( $redirect_to );
    313 
    314         /**
    315          * Filters the URL to redirect logged in users to when visiting activation page.
    316          *
    317          * @since 1.9.0
    318          *
    319          * @param string $redirect_to URL to redirect user to.
    320          */
    321         $redirect_to = apply_filters( 'bp_loggedin_activate_page_redirect_to', $redirect_to );
    322 
    323         // Redirect away from the activation page.
    324         bp_core_redirect( $redirect_to );
    325     }
    326 
    327     // Get BuddyPress.
    328     $bp = buddypress();
    329 
    330     /**
    331      * Filters the template to load for the Member activation page screen.
    332      *
    333      * @since 1.1.1
    334      *
    335      * @param string $value Path to the Member activation template to load.
    336      */
    337     bp_core_load_template( apply_filters( 'bp_core_template_activate', array( 'activate', 'registration/activate' ) ) );
    338 }
    339 add_action( 'bp_screens', 'bp_core_screen_activation' );
    340 
    341 /** Theme Compatibility *******************************************************/
    342 
    343 new BP_Members_Theme_Compat();
    344 new BP_Registration_Theme_Compat();
Note: See TracChangeset for help on using the changeset viewer.