Skip to:
Content

bbPress.org


Ignore:
Timestamp:
08/04/2017 01:08:43 AM (9 years ago)
Author:
johnjamesjacoby
Message:

Scripts: Do not enqueue if not is_bbpress().

This reduces the number of external scripts that are enqueued on non-bbPress pages. Put another way, it makes sure that bbPress styles & scripts are only loaded on pages where bbPress content is known to exist.

Fibes #3138. Props DJPaul.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/includes/core/template-functions.php

    r6583 r6641  
    113113 *
    114114 * @since 2.5.0 bbPress (r5180)
     115 * @since 2.6.0 bbPress (r6640) Bail early if not a bbPress page/shortcode
    115116 *
    116117 * @param string      $handle Name of the stylesheet.
     
    128129function bbp_enqueue_style( $handle = '', $file = '', $deps = array(), $ver = false, $media = 'all' ) {
    129130
     131    // Bail if not on a bbPress page or shortcode
     132    if ( ! is_bbpress() ) {
     133        return;
     134    }
     135
    130136    // No file found yet
    131137    $located = false;
     
    185191 *
    186192 * @since 2.5.0 bbPress (r5180)
     193 * @since 2.6.0 bbPress (r6640) Bail early if not a bbPress page/shortcode
    187194 *
    188195 * @param string      $handle    Name of the script.
     
    199206function bbp_enqueue_script( $handle = '', $file = '', $deps = array(), $ver = false, $in_footer = false ) {
    200207
     208    // Bail if not on a bbPress page or shortcode
     209    if ( ! is_bbpress() ) {
     210        return;
     211    }
     212
    201213    // No file found yet
    202214    $located = false;
Note: See TracChangeset for help on using the changeset viewer.