Skip to:
Content

BuddyPress.org


Ignore:
Timestamp:
03/05/2018 12:00:25 AM (7 years ago)
Author:
r-a-y
Message:

Activity: Conditionally load action and screen functions.

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

A special case is required for PHPUnit as PHPUnit doesn't like conditional-
included files when running multiple unit tests. So for PHPUnit, we
include all action and screen code at once, just like before.

See #7218.

File:
1 edited

Legend:

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

    r11882 r11885  
    1717}
    1818tests_add_filter( 'bp_send_email_delivery_class', '_bp_mock_mailer' );
     19
     20/**
     21 * Load up activity action and screen code.
     22 *
     23 * In BuddyPress, this is loaded conditionally, but PHPUnit needs all files
     24 * loaded at the same time to prevent weird load order issues.
     25 */
     26add_action( 'bp_activity_includes', function() {
     27    $dirs = array(
     28        buddypress()->plugin_dir . 'bp-activity/actions/',
     29        buddypress()->plugin_dir . 'bp-activity/screens/',
     30    );
     31
     32    foreach ( $dirs as $dir ) {
     33        foreach ( glob( $dir . "*.php" ) as $file ) {
     34            require $file;
     35        }
     36    }
     37} );
Note: See TracChangeset for help on using the changeset viewer.