BBP_Default::enqueue_scripts()
Enqueue the required Javascript files
Description
Source
File: bp-forums/templates/default/bbpress-functions.php
138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 | public function enqueue_scripts() { // Setup scripts array $scripts = array (); // Tag Input if ( bbp_allow_topic_tags() && current_user_can( 'assign_topic_tags' ) ) { wp_enqueue_script( 'bp-tagify' ); } // Always pull in jQuery for TinyMCE shortcode usage if ( bbp_use_wp_editor() ) { $scripts [ 'bbpress-editor' ] = array ( 'file' => 'js/editor.js' , 'dependencies' => array ( 'jquery' ) ); wp_enqueue_script( 'bp-medium-editor' ); wp_enqueue_style( 'bp-medium-editor' ); wp_enqueue_style( 'bp-medium-editor-beagle' ); } // Forum-specific scripts if ( bbp_is_single_forum() ) { $scripts [ 'bbpress-forum' ] = array ( 'file' => 'js/forum.js' , 'dependencies' => array ( 'jquery' ) ); } // Topic-specific scripts if ( bbp_is_single_topic() ) { // Topic favorite/unsubscribe $scripts [ 'bbpress-topic' ] = array ( 'file' => 'js/topic.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() ) { $scripts [ 'bbpress-user' ] = array ( 'file' => 'js/user.js' , 'dependencies' => array ( 'user-query' ) ); } $scripts [ 'bbpress-common' ] = array ( 'file' => 'js/common.js' , 'dependencies' => array ( 'jquery' ) ); // 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, 'screen' ); } } |
Changelog
Version | Description |
---|---|
bbPress (r3732) | 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.