Skip to:
Content

BuddyPress.org

Changeset 11884


Ignore:
Timestamp:
03/04/2018 11:17:29 PM (21 months ago)
Author:
r-a-y
Message:

Core: Introduce hook, 'bp_late_include'.

This hook is meant to be used to load conditional files on certain pages
so we are not always loading code unnecessarily.

This fires on the 'bp_setup_canonical_stack' at priority 20 when we
have ensured that the canonical stack is set up and before we register
navigation items that do checks for screen functions.

We'll be using this hook across all components to offshore code until it
is required.

See #7218.

Location:
trunk/src/bp-core
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/bp-core/bp-core-actions.php

    r11589 r11884  
    8787
    8888/**
     89 * Late includes.
     90 *
     91 * Run after the canonical stack is setup to allow for conditional includes
     92 * on certain pages.
     93 */
     94add_action( 'bp_setup_canonical_stack', 'bp_late_include', 20 );
     95
     96/**
    8997 * The bp_template_redirect hook - Attached to 'template_redirect' above.
    9098 *
  • trunk/src/bp-core/bp-core-dependency.php

    r11364 r11884  
    3232     */
    3333    do_action( 'bp_include' );
     34}
     35
     36/**
     37 * Fire the 'bp_late_include' action for loading conditional files.
     38 *
     39 * @since 3.0.0
     40 */
     41function bp_late_include() {
     42
     43    /**
     44     * Fires the 'bp_late_include' action.
     45     *
     46     * Allow for conditional includes on certain pages.
     47     *
     48     * @since 3.0.0
     49     */
     50    do_action( 'bp_late_include' );
    3451}
    3552
  • trunk/src/bp-core/classes/class-bp-component.php

    r10825 r11884  
    395395
    396396    /**
     397     * Late includes method.
     398     *
     399     * Components should include files here only on specific pages using
     400     * conditionals such as {@link bp_is_current_component()}. Intentionally left
     401     * empty.
     402     *
     403     * @since 3.0.0
     404     */
     405    public function late_includes() {}
     406
     407    /**
    397408     * Set up the actions.
    398409     *
     
    414425        // extending this base class.
    415426        add_action( 'bp_include',                array( $this, 'includes'               ), 8 );
     427
     428        // Load files conditionally, based on certain pages.
     429        add_action( 'bp_late_include',           array( $this, 'late_includes'          ) );
    416430
    417431        // Setup navigation.
Note: See TracChangeset for help on using the changeset viewer.