Skip to:
Content

BuddyPress.org


Ignore:
Timestamp:
08/09/2014 04:30:44 PM (10 years ago)
Author:
djpaul
Message:

Activity: Combine the @mentions enqueuing function.

Previously, there was a function for loading in both admin and frontend contexts.
I've combined the loading into one function which removes a bunch of duplicated logic, probably left over from an early approach at building the suggestions feature.

See #3278

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/bp-activity/bp-activity-cssjs.php

    r8770 r8773  
    2121    }
    2222
     23    // Special handling for New/Edit screens in wp-admin
     24    if ( is_admin() ) {
     25        if (
     26            ! get_current_screen() ||
     27            ! in_array( get_current_screen()->base, array( 'page', 'post' ) ) ||
     28            ! post_type_supports( get_current_screen()->post_type, 'editor' ) ) {
     29            return;
     30        }
     31    }
     32
     33
    2334    $min = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min';
    2435
     
    3546}
    3647add_action( 'bp_enqueue_scripts', 'bp_activity_mentions_script' );
    37 
    38 /**
    39  * Enqueue @mentions JS in wp-admin.
    40  *
    41  * @since BuddyPress (2.1)
    42  */
    43 function bp_activity_mentions_dashboard_script() {
    44     if ( ! bp_activity_maybe_load_mentions_scripts() ) {
    45         return;
    46     }
    47 
    48     // Special handling for New/Edit screens in wp-admin
    49     if (
    50         ! get_current_screen() ||
    51         ! in_array( get_current_screen()->base, array( 'page', 'post' ) ) ||
    52         ! post_type_supports( get_current_screen()->post_type, 'editor' ) ) {
    53         return;
    54     }
    55 
    56     $min = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min';
    57 
    58     wp_enqueue_script( 'bp-mentions', buddypress()->plugin_url . "bp-activity/js/mentions{$min}.js", array( 'jquery', 'jquery-atwho' ), bp_get_version(), true );
    59     wp_enqueue_style( 'bp-mentions-css', buddypress()->plugin_url . "bp-activity/css/mentions{$min}.css", array(), bp_get_version() );
    60 
    61     wp_style_add_data( 'bp-mentions-css', 'rtl', true );
    62     if ( $min ) {
    63         wp_style_add_data( 'bp-mentions-css', 'suffix', $min );
    64     }
    65 
    66     // Print a list of the current user's friends to the page for quicker @mentions lookups.
    67     do_action( 'bp_activity_mentions_prime_results' );
    68 }
    69 add_action( 'bp_admin_enqueue_scripts', 'bp_activity_mentions_dashboard_script' );
     48add_action( 'bp_admin_enqueue_scripts', 'bp_activity_mentions_script' );
Note: See TracChangeset for help on using the changeset viewer.