bp_dtheme_enqueue_scripts

Enqueue theme javascript safely.

Description

bp_dtheme_enqueue_scripts(); 

Usage

  1. if ( !function_exists( 'bp_dtheme_enqueue_scripts' ) ) { 
  2. require_once ABSPATH . PLUGINDIR . 'buddypress/bp-themes/bp-default/functions.php'; 
  3.  
  4.  
  5. // NOTICE! Understand what this does before running. 
  6. $result = bp_dtheme_enqueue_scripts(); 
  7.  

Defined (1)

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

/bp-themes/bp-default/functions.php  
  1. function bp_dtheme_enqueue_scripts() { 
  2.  
  3. // Enqueue various scripts 
  4. wp_enqueue_script( 'bp-jquery-query' ); 
  5. wp_enqueue_script( 'bp-jquery-cookie' ); 
  6.  
  7. // Enqueue scrollTo only on activity pages 
  8. wp_enqueue_script( 'bp-jquery-scroll-to' ); 
  9.  
  10. // A similar check is done in BP_Core_Members_Widget, but due to a load order 
  11. // issue, we do it again here 
  12. if ( is_active_widget( false, false, bp_core_members_widget ) && ! is_admin() && ! is_network_admin() ) { 
  13. wp_enqueue_script( 'bp-widget-members' ); 
  14.  
  15. // Enqueue the global JS - Ajax will not work without it 
  16. wp_enqueue_script( 'dtheme-ajax-js', get_template_directory_uri() . '/_inc/global.js', array( 'jquery' ), bp_get_version() ); 
  17.  
  18. // Add words that we need to use in JS to the end of the page so they can be translated and still used. 
  19. $params = array( 
  20. 'my_favs' => __( 'My Favorites', buddypress ),  
  21. 'accepted' => __( 'Accepted', buddypress ),  
  22. 'rejected' => __( 'Rejected', buddypress ),  
  23. 'show_all_comments' => __( 'Show all comments for this thread', buddypress ),  
  24. 'show_x_comments' => __( 'Show all %d comments', buddypress ),  
  25. 'show_all' => __( 'Show all', buddypress ),  
  26. 'comments' => __( 'comments', buddypress ),  
  27. 'close' => __( 'Close', buddypress ),  
  28. 'view' => __( 'View', buddypress ),  
  29. 'mark_as_fav' => __( 'Favorite', buddypress ),  
  30. 'remove_fav' => __( 'Remove Favorite', buddypress ),  
  31. 'unsaved_changes' => __( 'Your profile has unsaved changes. If you leave the page, the changes will be lost.', buddypress ),  
  32. ); 
  33. wp_localize_script( 'dtheme-ajax-js', 'BP_DTheme', $params ); 
  34.  
  35. // Maybe enqueue comment reply JS 
  36. if ( is_singular() && bp_is_blog_page() && get_option( 'thread_comments' ) ) 
  37. wp_enqueue_script( 'comment-reply' );