bpbbpst_enqueue_scripts

Hooks wp_enqueue_scripts to load needed js or css.

Description

bpbbpst_enqueue_scripts(); 

It only loads the scripts or stylesheets only on the template where we need it (not on all page of the blog!)


Usage

  1. if ( !function_exists( 'bpbbpst_enqueue_scripts' ) ) { 
  2. require_once ABSPATH . PLUGINDIR . 'buddy-bbpress-support-topic/includes/functions.php'; 
  3.  
  4.  
  5. // NOTICE! Understand what this does before running. 
  6. $result = bpbbpst_enqueue_scripts(); 
  7.  

Defined (1)

The function is defined in the following location(s).

/includes/functions.php  
  1. function bpbbpst_enqueue_scripts() { 
  2.  
  3. /** 
  4. With BuddyPress activated, bbp_is_single_topic() is becoming true too late :( 
  5. so we need to check for bp_is_group_forum_topic(), if this function exists ;) 
  6. */ 
  7. $bbpress_load_scripts = false; 
  8.  
  9. if ( bbp_is_single_topic() ) { 
  10. $bbpress_load_scripts = true; 
  11. } else if ( function_exists( 'bp_is_group_forum_topic' ) && bp_is_group_forum_topic() ) { 
  12. $bbpress_load_scripts = true; 
  13.  
  14. if ( $bbpress_load_scripts ) { 
  15. wp_enqueue_script( 'bpbbpst-topic-js', bpbbpst_get_plugin_url( 'js' ) . 'bpbbpst-topic.js', array( 'jquery' ), bpbbpst_get_plugin_version(), true ); 
  16. wp_localize_script( 'bpbbpst-topic-js', 'bpbbpstbbp_vars', array( 
  17. 'securitycheck' => __( 'Security check failed', 'buddy-bbpress-support-topic' ),  
  18. 'loading' => __( 'loading', 'buddy-bbpress-support-topic' ) 
  19. ) );