bp_activity_mentions_script()

Enqueue @mentions JS.

Description

Source

File: bp-activity/bp-activity-cssjs.php

17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
function bp_activity_mentions_script() {
    if ( ! bp_activity_maybe_load_mentions_scripts() ) {
        return;
    }
 
    // Special handling for New/Edit screens in wp-admin.
    if ( is_admin() ) {
        if (
            ! get_current_screen() ||
            ! in_array( get_current_screen()->base, array( 'page', 'post' ) ) ||
            ! post_type_supports( get_current_screen()->post_type, 'editor' ) ) {
            return;
        }
    }
 
 
    $min = bp_core_get_minified_asset_suffix();
 
    wp_enqueue_script( 'bp-mentions', buddypress()->plugin_url . "bp-activity/js/mentions{$min}.js", array( 'jquery', 'jquery-atwho' ), bp_get_version(), true );
    wp_enqueue_style( 'bp-mentions-css', buddypress()->plugin_url . "bp-activity/css/mentions{$min}.css", array(), bp_get_version() );
 
    wp_style_add_data( 'bp-mentions-css', 'rtl', true );
    if ( $min ) {
        wp_style_add_data( 'bp-mentions-css', 'suffix', $min );
    }
 
    wp_localize_script( 'bp-mentions', 'BP_Mentions_Options', bp_at_mention_default_options() );
 
    // If the script has been enqueued, let's attach our mentions TinyMCE init callback.
    add_filter( 'tiny_mce_before_init', 'bp_add_mentions_on_tinymce_init', 10, 2 );
 
    /**
     * Fires at the end of the Activity Mentions script.
     *
     * This is the hook where BP components can add their own prefetched results
     * friends to the page for quicker @mentions lookups.
     *
     * @since BuddyPress 2.1.0
     */
    do_action( 'bp_activity_mentions_prime_results' );
}

Changelog

Changelog
Version Description
BuddyPress 2.1.0 Introduced.

Questions?

We're always happy to help with code or other questions you might have! Search our developer docs, contact support, or connect with our sales team.