Skip to:
Content

BuddyPress.org


Ignore:
Timestamp:
08/07/2014 02:11:24 PM (10 years ago)
Author:
johnjamesjacoby
Message:

Separate out registering and enqueing of bp-admin-bar styling.

This allows theme and plugin authors more flexibility in how they override BuddyPress's default behaviour, and also more closely follows our existing conventions for other scripts and styles.

File:
1 edited

Legend:

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

    r8568 r8764  
    9191
    9292/**
    93  * Handle the Toolbar CSS.
     93 * Handle the enqueuing of toolbar CSS.
     94 *
     95 * This function exists mostly for backwards compatibility reasons, so anyone
     96 * previously unhooking this function can continue to do so. It's hooked to
     97 * the `bp_init` action in `bp-core-actions.php`.
    9498 *
    9599 * @since BuddyPress (1.5.0)
    96100 */
    97101function bp_core_load_admin_bar_css() {
    98     global $wp_styles;
     102    add_action( 'bp_enqueue_scripts',       'bp_core_enqueue_admin_bar_css', 1 );
     103    add_action( 'bp_admin_enqueue_scripts', 'bp_core_enqueue_admin_bar_css', 1 );
     104}
    99105
    100     if ( ! bp_use_wp_admin_bar() || ! is_admin_bar_showing() )
     106/**
     107 * Enqueue supplemental WordPress Toolbar styling
     108 *
     109 * @since BuddyPress (2.1.0)
     110 *
     111 * @see bp_core_register_common_styles()
     112 * @see bp_core_load_admin_bar_css()
     113 */
     114function bp_core_enqueue_admin_bar_css() {
     115
     116    // Bail if not using WordPress's admin bar or it's not showing on this
     117    // page request.
     118    if ( ! bp_use_wp_admin_bar() || ! is_admin_bar_showing() ) {
    101119        return;
     120    }
    102121
    103     $min = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min';
    104 
    105     // Toolbar styles
    106     $stylesheet = buddypress()->plugin_url . "bp-core/css/admin-bar{$min}.css";
    107 
    108     wp_enqueue_style( 'bp-admin-bar', apply_filters( 'bp_core_admin_bar_css', $stylesheet ), array( 'admin-bar' ), bp_get_version() );
    109     $wp_styles->add_data( 'bp-admin-bar', 'rtl', true );
    110     if ( $min )
    111         $wp_styles->add_data( 'bp-admin-bar', 'suffix', $min );
     122    // Enqueue the additional adminbar css
     123    wp_enqueue_style( 'bp-admin-bar' );
    112124}
Note: See TracChangeset for help on using the changeset viewer.