Skip to:
Content

BuddyPress.org


Ignore:
Timestamp:
04/01/2018 11:30:48 PM (8 years ago)
Author:
r-a-y
Message:

Groups: Conditionally load action and screen functions.

This commit conditionally loads action and screen function code for the
Groups 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 groups page. Now, we only load this code
when needed.

See #7218.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tests/phpunit/includes/loader.php

    r11885 r11923  
    1919
    2020/**
    21  * Load up activity action and screen code.
     21 * Load up component action and screen code.
    2222 *
    2323 * In BuddyPress, this is loaded conditionally, but PHPUnit needs all files
    2424 * loaded at the same time to prevent weird load order issues.
    2525 */
    26 add_action( 'bp_activity_includes', function() {
    27         $dirs = array(
    28                 buddypress()->plugin_dir . 'bp-activity/actions/',
    29                 buddypress()->plugin_dir . 'bp-activity/screens/',
    30         );
     26$components = array( 'activity', 'groups' );
     27foreach ( $components as $component ) {
     28        add_action( "bp_{$component}_includes", function() use ( $component ) {
     29                $dirs = array(
     30                        buddypress()->plugin_dir . 'bp-' . $component . '/actions/',
     31                        buddypress()->plugin_dir . 'bp-' . $component . '/screens/',
     32                );
    3133
    32         foreach ( $dirs as $dir ) {
    33                 foreach ( glob( $dir . "*.php" ) as $file ) {
    34                         require $file;
     34                foreach ( $dirs as $dir ) {
     35                        foreach ( glob( $dir . "*.php" ) as $file ) {
     36                                require $file;
     37                        }
    3538                }
    36         }
    37 } );
     39        } );
     40}
Note: See TracChangeset for help on using the changeset viewer.