BBP_Admin::enqueue_scripts()

Enqueue any admin scripts we might need

Description

Source

File: bp-forums/admin/admin.php

484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
public function enqueue_scripts() {
    wp_enqueue_script( 'suggest' );
 
    // Get the version to use for JS
    $version = bbp_get_version();
 
    // Post type checker (only topics and replies)
    if ( 'post' === get_current_screen()->base ) {
        switch( get_current_screen()->post_type ) {
            case bbp_get_reply_post_type() :
            case bbp_get_topic_post_type() :
 
                // Enqueue the common JS
                wp_enqueue_script( 'bbp-admin-common-js', $this->js_url . 'common.js', array( 'jquery' ), $version );
 
                // Topics admin
                if ( bbp_get_topic_post_type() === get_current_screen()->post_type ) {
                    wp_enqueue_script( 'bbp-admin-topics-js', $this->js_url . 'topics.js', array( 'jquery' ), $version );
 
                // Replies admin
                } elseif ( bbp_get_reply_post_type() === get_current_screen()->post_type ) {
                    wp_enqueue_script( 'bbp-admin-replies-js', $this->js_url . 'replies.js', array( 'jquery' ), $version );
                    $localize_array = array(
                        'loading_text' => __( 'Loading', 'buddyboss' ),
                    );
                    wp_localize_script( 'bbp-admin-replies-js', 'replies_data', $localize_array );
                }
 
                break;
        }
    }
}

Changelog

Changelog
Version Description
bbPress (r4260) 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.