[ Index ] |
PHP Cross Reference of BuddyPress |
[Summary view] [Print] [Text view]
1 <?php 2 3 function bb_default_scripts( &$scripts ) { 4 $scripts->base_url = bb_get_uri( BB_INC, null, BB_URI_CONTEXT_SCRIPT_SRC ); 5 $scripts->base_url_admin = bb_get_uri( 'bb-admin/', null, BB_URI_CONTEXT_SCRIPT_SRC + BB_URI_CONTEXT_BB_ADMIN ); 6 $scripts->content_url = ''; // May not work - might need to specify plugin and theme urls 7 $scripts->default_version = bb_get_option( 'version' ); 8 $scripts->default_dirs = array( '/bb-admin/js/', '/bb-includes/js/' ); 9 10 // These are our enqueued scripts 11 $scripts->add( 'topic', $scripts->base_url . 'js/topic.js', array('wp-lists'), '20090602' ); 12 $scripts->add( 'profile-edit', $scripts->base_url . 'js/profile-edit.js', array('password-strength-meter'), '20080721' ); 13 $scripts->add( 'admin-forums', $scripts->base_url_admin . 'js/admin-forums.js', array('wp-lists', 'interface'), '20090320' ); 14 $scripts->add( 'utils', $scripts->base_url_admin . 'js/utils.js', false, '20090102' ); 15 $scripts->add( 'common', $scripts->base_url_admin . 'js/common.js', array('jquery', 'hoverIntent', 'utils'), '20090517' ); 16 $scripts->add_data( 'common', 'group', 1 ); 17 $scripts->localize( 'common', 'commonL10n', array( 18 'warnDelete' => __( "You are about to delete the selected items.\n 'Cancel' to stop, 'OK' to delete." ), 19 'l10n_print_after' => 'try{convertEntities(commonL10n);}catch(e){};' 20 ) ); 21 $scripts->localize( 'admin-forums', 'bbSortForumsL10n', array( 22 'handleText' => __('drag'), 23 'saveText' => __('Save Forum Order'), 24 'editText' => __('Edit Forum Order') 25 )); 26 27 // These are non-3rd-party libraries 28 $scripts->add( 'wp-lists', $scripts->base_url . 'js/wp-lists.js', array('wp-ajax-response','jquery-color'), '20080826' ); 29 $scripts->localize( 'wp-lists', 'wpListL10n', array( 30 'url' => $scripts->base_url_admin . 'admin-ajax.php' 31 ) ); 32 $scripts->add( 'wp-ajax-response', $scripts->base_url . 'js/wp-ajax-response.js', array('jquery'), '20080316' ); 33 $scripts->localize( 'wp-ajax-response', 'wpAjax', array( 34 'noPerm' => __('You do not have permission to do that.'), 35 'broken' => __('An unidentified error has occurred.') 36 ) ); 37 38 // jQuery and friends 39 $scripts->add( 'jquery', $scripts->base_url . 'js/jquery/jquery.js', false, '1.4.2' ); 40 $scripts->add( 'jquery-color', $scripts->base_url . 'js/jquery/jquery.color.js', array('jquery'), '2.0-4561' ); 41 $scripts->add( 'interface', $scripts->base_url . 'js/jquery/interface.js', array('jquery'), '1.2.3' ); 42 $scripts->add( 'password-strength-meter', $scripts->base_url . 'js/jquery/password-strength-meter.js', array('jquery'), '20070405' ); 43 $scripts->localize( 'password-strength-meter', 'pwsL10n', array( 44 'short' => __('Too short'), 45 'bad' => __('Bad'), 46 'good' => __('Good'), 47 'strong' => __('Strong') 48 )); 49 $scripts->add( 'hoverIntent', $scripts->base_url . 'js/jquery/hoverIntent.js', array('jquery'), '20090102' ); 50 $scripts->add_data( 'hoverIntent', 'group', 1 ); 51 } 52 53 /** 54 * Reorder JavaScript scripts array to place prototype before jQuery. 55 * 56 * @param array $js_array JavaScript scripst array 57 * @return array Reordered array, if needed. 58 */ 59 function bb_prototype_before_jquery( $js_array ) { 60 if ( false === $jquery = array_search( 'jquery', $js_array, true ) ) 61 return $js_array; 62 63 if ( false === $prototype = array_search( 'prototype', $js_array, true ) ) 64 return $js_array; 65 66 if ( $prototype < $jquery ) 67 return $js_array; 68 69 unset($js_array[$prototype]); 70 71 array_splice( $js_array, $jquery, 0, 'prototype' ); 72 73 return $js_array; 74 } 75 76 /** 77 * Load localized script just in time for MCE. 78 * 79 * These localizations require information that may not be loaded even by init. 80 */ 81 function bb_just_in_time_script_localization() { 82 wp_localize_script( 'topic', 'bbTopicJS', array( 83 'currentUserId' => bb_get_current_user_info( 'id' ), 84 'topicId' => get_topic_id(), 85 'favoritesLink' => get_favorites_link(), 86 'isFav' => (int) is_user_favorite( bb_get_current_user_info( 'id' ) ), 87 'confirmPostDelete' => __("Are you sure you want to delete this post?"), 88 'confirmPostUnDelete' => __("Are you sure you want to undelete this post?"), 89 'favLinkYes' => __( 'favorites' ), 90 'favLinkNo' => __( '?' ), 91 'favYes' => __( 'This topic is one of your %favLinkYes% [%favDel%]' ), 92 'favNo' => __( '%favAdd% (%favLinkNo%)' ), 93 'favDel' => __( '×' ), 94 'favAdd' => __( 'Add this topic to your favorites' ) 95 )); 96 } 97 98 add_action( 'wp_default_scripts', 'bb_default_scripts' ); 99 add_filter( 'wp_print_scripts', 'bb_just_in_time_script_localization' ); 100 add_filter( 'print_scripts_array', 'bb_prototype_before_jquery' );
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
Generated: Thu Dec 7 01:01:35 2017 | Cross-referenced by PHPXref 0.7.1 |