Skip to:
Content

bbPress.org

Changeset 5186


Ignore:
Timestamp:
11/25/2013 02:55:13 AM (8 years ago)
Author:
johnjamesjacoby
Message:

Check the $located variable to avoid trying to enqueue a style or script that was not found.

File:
1 edited

Legend:

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

    r5181 r5186  
    130130function bbp_enqueue_style( $handle = '', $file = '', $dependencies = array(), $version = false, $media = 'all' ) {
    131131
     132    // No file found yet
     133    $located = false;
     134
    132135    // Trim off any slashes from the template name
    133136    $file = ltrim( $file, '/' );
     
    153156    }
    154157
    155     // Make path to file relative to site URL
    156     $located = trailingslashit( site_url() ) . str_replace( ABSPATH, '', $located );
    157 
    158     // Enqueue the style
    159     wp_enqueue_style( $handle, $located, $dependencies, $version, $media );
     158    // Enqueue if located
     159    if ( !empty( $located ) ) {
     160
     161        // Make path to file relative to site URL
     162        $located = trailingslashit( site_url() ) . str_replace( ABSPATH, '', $located );
     163
     164        // Enqueue the style
     165        wp_enqueue_style( $handle, $located, $dependencies, $version, $media );
     166    }
    160167
    161168    return $located;
     
    182189function bbp_enqueue_script( $handle = '', $file = '', $dependencies = array(), $version = false, $in_footer = 'all' ) {
    183190
     191    // No file found yet
     192    $located = false;
     193
    184194    // Trim off any slashes from the template name
    185195    $file = ltrim( $file, '/' );
     
    205215    }
    206216
    207     // Make path to file relative to site URL
    208     $located = trailingslashit( site_url() ) . str_replace( ABSPATH, '', $located );
    209 
    210     // Enqueue the style
    211     wp_enqueue_script( $handle, $located, $dependencies, $version, $in_footer );
     217    // Enqueue if located
     218    if ( !empty( $located ) ) {
     219
     220        // Make path to file relative to site URL
     221        $located = trailingslashit( site_url() ) . str_replace( ABSPATH, '', $located );
     222
     223        // Enqueue the style
     224        wp_enqueue_script( $handle, $located, $dependencies, $version, $in_footer );
     225    }
    212226
    213227    return $located;
Note: See TracChangeset for help on using the changeset viewer.