diff --git a/src/bp-activity/classes/class-bp-activity-component.php b/src/bp-activity/classes/class-bp-activity-component.php
index 66005ebde..8daa46759 100644
a
|
b
|
class BP_Activity_Component extends BP_Component { |
51 | 51 | // Files to include. |
52 | 52 | $includes = array( |
53 | 53 | 'cssjs', |
54 | | 'actions', |
55 | | 'screens', |
56 | 54 | 'filters', |
57 | 55 | 'adminbar', |
58 | 56 | 'template', |
… |
… |
class BP_Activity_Component extends BP_Component { |
85 | 83 | parent::includes( $includes ); |
86 | 84 | } |
87 | 85 | |
| 86 | /** |
| 87 | * Load screen and action files only when viewing the activity component. |
| 88 | * |
| 89 | * @since 3.0.0 |
| 90 | */ |
| 91 | public function late_includes( $includes = array() ) { |
| 92 | if ( ! bp_is_activity_component() ) { |
| 93 | return; |
| 94 | } |
| 95 | |
| 96 | parent::late_includes( array( |
| 97 | 'actions', |
| 98 | 'screens', |
| 99 | ) ); |
| 100 | } |
| 101 | |
88 | 102 | /** |
89 | 103 | * Set up component global variables. |
90 | 104 | * |
diff --git a/src/bp-core/bp-core-actions.php b/src/bp-core/bp-core-actions.php
index 6e2ad3857..ba32e0828 100644
a
|
b
|
add_action( 'bp_register_taxonomies', 'bp_register_member_types' ); |
96 | 96 | * places. This won't always be this way, we promise. |
97 | 97 | * v---Load order |
98 | 98 | */ |
| 99 | add_action( 'bp_template_redirect', 'bp_late_includes', 0 ); |
99 | 100 | add_action( 'bp_template_redirect', 'bp_redirect_canonical', 2 ); |
100 | 101 | add_action( 'bp_template_redirect', 'bp_actions', 4 ); |
101 | 102 | add_action( 'bp_template_redirect', 'bp_screens', 6 ); |
diff --git a/src/bp-core/bp-core-dependency.php b/src/bp-core/bp-core-dependency.php
index f1791ecb8..bc824476e 100644
a
|
b
|
function bp_allowed_themes( $themes ) { |
666 | 666 | return apply_filters( 'bp_allowed_themes', $themes ); |
667 | 667 | } |
668 | 668 | |
| 669 | /** |
| 670 | * Fires the 'bp_late_includes' hook for including late-loading files. |
| 671 | * |
| 672 | * @since 3.0.0 |
| 673 | */ |
| 674 | function bp_late_includes() { |
| 675 | /** |
| 676 | * Fires just before BP runs its controller functions. |
| 677 | * |
| 678 | * @since 3.0.0 |
| 679 | */ |
| 680 | do_action( 'bp_late_includes' ); |
| 681 | } |
| 682 | |
669 | 683 | /** Requests ******************************************************************/ |
670 | 684 | |
671 | 685 | /** |
diff --git a/src/bp-core/classes/class-bp-component.php b/src/bp-core/classes/class-bp-component.php
index 137c8cb33..199735978 100644
a
|
b
|
class BP_Component { |
353 | 353 | * to be parsed and then included. |
354 | 354 | */ |
355 | 355 | public function includes( $includes = array() ) { |
356 | | |
357 | | // Bail if no files to include. |
358 | | if ( ! empty( $includes ) ) { |
359 | | $slashed_path = trailingslashit( $this->path ); |
360 | | |
361 | | // Loop through files to be included. |
362 | | foreach ( (array) $includes as $file ) { |
363 | | |
364 | | $paths = array( |
365 | | |
366 | | // Passed with no extension. |
367 | | 'bp-' . $this->id . '/bp-' . $this->id . '-' . $file . '.php', |
368 | | 'bp-' . $this->id . '-' . $file . '.php', |
369 | | 'bp-' . $this->id . '/' . $file . '.php', |
370 | | |
371 | | // Passed with extension. |
372 | | $file, |
373 | | 'bp-' . $this->id . '-' . $file, |
374 | | 'bp-' . $this->id . '/' . $file, |
375 | | ); |
376 | | |
377 | | foreach ( $paths as $path ) { |
378 | | if ( @is_file( $slashed_path . $path ) ) { |
379 | | require( $slashed_path . $path ); |
380 | | break; |
381 | | } |
382 | | } |
383 | | } |
384 | | } |
| 356 | $this->perform_includes( $includes ); |
385 | 357 | |
386 | 358 | /** |
387 | 359 | * Fires at the end of the includes method inside BP_Component. |
… |
… |
class BP_Component { |
393 | 365 | do_action( 'bp_' . $this->id . '_includes' ); |
394 | 366 | } |
395 | 367 | |
| 368 | /** |
| 369 | * Performs late includes. |
| 370 | * |
| 371 | * @since 3.0.0 |
| 372 | * |
| 373 | * @param array See BP_Component::includes(). |
| 374 | */ |
| 375 | public function late_includes( $includes = array() ) { |
| 376 | $this->perform_includes( $includes ); |
| 377 | } |
| 378 | |
396 | 379 | /** |
397 | 380 | * Set up the actions. |
398 | 381 | * |
… |
… |
class BP_Component { |
414 | 397 | // extending this base class. |
415 | 398 | add_action( 'bp_include', array( $this, 'includes' ), 8 ); |
416 | 399 | |
| 400 | // Use this hook to load files that only need to be present for screen/actions. |
| 401 | add_action( 'bp_late_includes', array( $this, 'late_includes' ) ); |
| 402 | |
417 | 403 | // Setup navigation. |
418 | 404 | add_action( 'bp_setup_nav', array( $this, 'setup_nav' ), 10 ); |
419 | 405 | |
… |
… |
class BP_Component { |
840 | 826 | */ |
841 | 827 | do_action( 'bp_' . $this->id . '_generate_rewrite_rules' ); |
842 | 828 | } |
| 829 | |
| 830 | protected function perform_includes( $includes = array() ) { |
| 831 | // Bail if no files to include. |
| 832 | if ( ! empty( $includes ) ) { |
| 833 | $slashed_path = trailingslashit( $this->path ); |
| 834 | |
| 835 | // Loop through files to be included. |
| 836 | foreach ( (array) $includes as $file ) { |
| 837 | |
| 838 | $paths = array( |
| 839 | |
| 840 | // Passed with no extension. |
| 841 | 'bp-' . $this->id . '/bp-' . $this->id . '-' . $file . '.php', |
| 842 | 'bp-' . $this->id . '-' . $file . '.php', |
| 843 | 'bp-' . $this->id . '/' . $file . '.php', |
| 844 | |
| 845 | // Passed with extension. |
| 846 | $file, |
| 847 | 'bp-' . $this->id . '-' . $file, |
| 848 | 'bp-' . $this->id . '/' . $file, |
| 849 | ); |
| 850 | |
| 851 | foreach ( $paths as $path ) { |
| 852 | if ( @is_file( $slashed_path . $path ) ) { |
| 853 | require( $slashed_path . $path ); |
| 854 | break; |
| 855 | } |
| 856 | } |
| 857 | } |
| 858 | } |
| 859 | } |
843 | 860 | } |
844 | 861 | endif; // BP_Component. |