[ Index ] |
PHP Cross Reference of BuddyPress |
[Summary view] [Print] [Text view]
1 <?php 2 /** 3 * Activity component CSS/JS 4 * 5 * @package BuddyPress 6 * @subpackage ActivityScripts 7 * @since 1.0.0 8 */ 9 10 // Exit if accessed directly. 11 defined( 'ABSPATH' ) || exit; 12 13 /** 14 * Enqueue @mentions JS. 15 * 16 * @since 2.1.0 17 */ 18 function bp_activity_mentions_script() { 19 if ( ! bp_activity_maybe_load_mentions_scripts() ) { 20 return; 21 } 22 23 // Special handling for New/Edit screens in wp-admin. 24 if ( is_admin() ) { 25 $current_screen = null; 26 if ( function_exists( 'get_current_screen' ) ) { 27 $current_screen = get_current_screen(); 28 } 29 30 if ( 31 ! $current_screen || 32 ( isset( $current_screen->is_block_editor ) && $current_screen->is_block_editor ) || 33 ! in_array( $current_screen->base, array( 'page', 'post' ) ) || 34 ! post_type_supports( $current_screen->post_type, 'editor' ) ) { 35 return; 36 } 37 } 38 39 40 $min = bp_core_get_minified_asset_suffix(); 41 42 wp_enqueue_script( 'bp-mentions', buddypress()->plugin_url . "bp-activity/js/mentions{$min}.js", array( 'jquery', 'jquery-atwho' ), bp_get_version(), true ); 43 wp_enqueue_style( 'bp-mentions-css', buddypress()->plugin_url . "bp-activity/css/mentions{$min}.css", array(), bp_get_version() ); 44 45 wp_style_add_data( 'bp-mentions-css', 'rtl', 'replace' ); 46 if ( $min ) { 47 wp_style_add_data( 'bp-mentions-css', 'suffix', $min ); 48 } 49 50 // If the script has been enqueued, let's attach our mentions TinyMCE init callback. 51 add_filter( 'tiny_mce_before_init', 'bp_add_mentions_on_tinymce_init', 10, 2 ); 52 53 /** 54 * Fires at the end of the Activity Mentions script. 55 * 56 * This is the hook where BP components can add their own prefetched results 57 * friends to the page for quicker @mentions lookups. 58 * 59 * @since 2.1.0 60 */ 61 do_action( 'bp_activity_mentions_prime_results' ); 62 } 63 add_action( 'bp_enqueue_scripts', 'bp_activity_mentions_script' ); 64 add_action( 'bp_admin_enqueue_scripts', 'bp_activity_mentions_script' ); 65 66 /** 67 * Bind the mentions listener to a wp_editor instance when TinyMCE initializes. 68 * 69 * @since 2.3.3 70 * 71 * @param array $settings An array with TinyMCE config. 72 * @param string $editor_id Unique editor identifier, e.g. 'content'. 73 * @return array $mceInit An array with TinyMCE config. 74 */ 75 function bp_add_mentions_on_tinymce_init( $settings, $editor_id ) { 76 // We only apply the mentions init to the visual post editor in the WP dashboard. 77 if ( 'content' === $editor_id ) { 78 $settings['init_instance_callback'] = 'window.bp.mentions.tinyMCEinit'; 79 } 80 81 return $settings; 82 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
Generated: Thu Dec 26 01:01:04 2024 | Cross-referenced by PHPXref 0.7.1 |