Skip to:
Content

BuddyPress.org

Changeset 8764


Ignore:
Timestamp:
08/07/2014 02:11:24 PM (5 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.

Location:
trunk/src/bp-core
Files:
2 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}
  • trunk/src/bp-core/bp-core-cssjs.php

    r8754 r8764  
    3939
    4040/**
     41 * Register styles commonly used by BuddyPress.
     42 *
     43 * @since BuddyPress (2.1.0)
     44 */
     45function bp_core_register_common_styles() {
     46    $ext = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '.css' : '.min.css';
     47    $url = buddypress()->plugin_url . 'bp-core/css/';
     48
     49    $styles = apply_filters( 'bp_core_register_common_styles', array(
     50        'bp-admin-bar' => array(
     51            'file'         => apply_filters( 'bp_core_admin_bar_css', "{$url}admin-bar{$ext}" ),
     52            'dependencies' => array( 'admin-bar' )
     53        )
     54    ) );
     55
     56    $version = bp_get_version();
     57    foreach ( $styles as $id => $style ) {
     58        wp_register_style( $id, $style['file'], $style['dependencies'], $version );
     59    }
     60}
     61add_action( 'bp_enqueue_scripts',       'bp_core_register_common_styles', 1 );
     62add_action( 'bp_admin_enqueue_scripts', 'bp_core_register_common_styles', 1 );
     63
     64/**
    4165 * Load the JS for "Are you sure?" .confirm links.
    4266 */
Note: See TracChangeset for help on using the changeset viewer.