BBP_Default::enqueue_scripts()
Enqueue the required JavaScript files
Description Description
Source Source
File: templates/default/bbpress-functions.php
public function enqueue_scripts() {
// Setup scripts array
$scripts = array();
// Editor scripts
// @see https://bbpress.trac.wordpress.org/ticket/2930
if ( bbp_use_wp_editor() && is_bbpress() ) {
$scripts['bbpress-editor'] = array(
'file' => 'js/editor.js',
'dependencies' => array( 'jquery' )
);
}
// Forum-specific scripts
if ( bbp_is_single_forum() ) {
$scripts['bbpress-engagements'] = array(
'file' => 'js/engagements.js',
'dependencies' => array( 'jquery' )
);
}
// Topic-specific scripts
if ( bbp_is_single_topic() || bbp_is_topic_edit() ) {
// Engagements
$scripts['bbpress-engagements'] = array(
'file' => 'js/engagements.js',
'dependencies' => array( 'jquery' )
);
// Hierarchical replies
if ( bbp_thread_replies() ) {
$scripts['bbpress-reply'] = array(
'file' => 'js/reply.js',
'dependencies' => array( 'jquery' )
);
}
}
// User Profile edit
if ( bbp_is_single_user_edit() ) {
wp_enqueue_script( 'user-profile' );
}
// Filter the scripts
$scripts = apply_filters( 'bbp_default_scripts', $scripts );
// Enqueue the scripts
foreach ( $scripts as $handle => $attributes ) {
bbp_enqueue_script( $handle, $attributes['file'], $attributes['dependencies'], $this->version, true );
}
}
Changelog Changelog
| Version | Description |
|---|---|
| 2.1.0 | Introduced. |