[ Index ] |
PHP Cross Reference of BuddyPress |
[Summary view] [Print] [Text view]
1 <?php 2 /** 3 * BuddyPress Messages CSS and JS. 4 * 5 * @package BuddyPress 6 * @subpackage MessagesScripts 7 * @since 1.0.0 8 */ 9 10 // Exit if accessed directly. 11 defined( 'ABSPATH' ) || exit; 12 13 /** 14 * Enqueue the JS for messages autocomplete. 15 */ 16 function messages_add_autocomplete_js() { 17 18 // Include the autocomplete JS for composing a message. 19 if ( bp_is_messages_component() && bp_is_current_action( 'compose' ) ) { 20 add_action( 'wp_head', 'messages_autocomplete_init_jsblock' ); 21 22 $min = bp_core_get_minified_asset_suffix(); 23 $url = buddypress()->plugin_url . 'bp-messages/js/'; 24 25 wp_enqueue_script( 'bp-jquery-autocomplete', "{$url}autocomplete/jquery.autocomplete{$min}.js", array( 'jquery' ), bp_get_version() ); 26 wp_enqueue_script( 'bp-jquery-autocomplete-fb', "{$url}autocomplete/jquery.autocompletefb{$min}.js", array( 'jquery' ), bp_get_version() ); 27 wp_enqueue_script( 'bp-jquery-bgiframe', "{$url}autocomplete/jquery.bgiframe{$min}.js", array( 'jquery' ), bp_get_version() ); 28 wp_enqueue_script( 'bp-jquery-dimensions', "{$url}autocomplete/jquery.dimensions{$min}.js", array( 'jquery' ), bp_get_version() ); 29 } 30 } 31 add_action( 'bp_enqueue_scripts', 'messages_add_autocomplete_js' ); 32 33 /** 34 * Enqueue the CSS for messages autocomplete. 35 * 36 * @todo Why do we call wp_print_styles()? 37 */ 38 function messages_add_autocomplete_css() { 39 if ( bp_is_messages_component() && bp_is_current_action( 'compose' ) ) { 40 $min = bp_core_get_minified_asset_suffix(); 41 $url = buddypress()->plugin_url . 'bp-messages/css/'; 42 43 wp_enqueue_style( 'bp-messages-autocomplete', "{$url}autocomplete/jquery.autocompletefb{$min}.css", array(), bp_get_version() ); 44 45 wp_style_add_data( 'bp-messages-autocomplete', 'rtl', 'replace' ); 46 if ( $min ) { 47 wp_style_add_data( 'bp-messages-autocomplete', 'suffix', $min ); 48 } 49 50 wp_print_styles(); 51 } 52 } 53 add_action( 'wp_head', 'messages_add_autocomplete_css' ); 54 55 /** 56 * Print inline JS for initializing the messages autocomplete. 57 * 58 * @todo Why is this here and not in a properly enqueued file? 59 */ 60 function messages_autocomplete_init_jsblock() { 61 ?> 62 63 <script type="text/javascript"> 64 jQuery(document).ready(function() { 65 var acfb = jQuery("ul.first").autoCompletefb({urlLookup: ajaxurl}); 66 67 jQuery('#send_message_form').submit( function() { 68 var users = document.getElementById('send-to-usernames').className; 69 document.getElementById('send-to-usernames').value = String(users); 70 }); 71 }); 72 </script> 73 74 <?php 75 } 76 77 /** 78 * Registers a new script to manage the dismissal action for the Sitewide notice widget/block. 79 * 80 * @since 9.0.0 81 * 82 * @param array $scripts Data about the scripts to register. 83 * @return array Data about the scripts to register. 84 */ 85 function bp_messages_register_scripts( $scripts = array() ) { 86 $scripts['bp-sitewide-notices-script'] = array( 87 'file' => plugins_url( 'js/sitewide-notices.js', __FILE__ ), 88 'dependencies' => array(), 89 'footer' => true, 90 ); 91 92 return $scripts; 93 } 94 add_filter( 'bp_core_register_common_scripts', 'bp_messages_register_scripts', 9, 1 );
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
Generated: Thu Nov 21 01:00:57 2024 | Cross-referenced by PHPXref 0.7.1 |