[ Index ] |
PHP Cross Reference of BuddyPress |
[Summary view] [Print] [Text view]
1 <?php 2 /** 3 * BP Nouveau Messages 4 * 5 * @since 3.0.0 6 * @version 10.0.0 7 */ 8 9 // Exit if accessed directly. 10 defined( 'ABSPATH' ) || exit; 11 12 /** 13 * Messages Loader class 14 * 15 * @since 3.0.0 16 */ 17 class BP_Nouveau_Messages { 18 /** 19 * Constructor 20 * 21 * @since 3.0.0 22 */ 23 public function __construct() { 24 $this->setup_globals(); 25 $this->includes(); 26 $this->setup_actions(); 27 $this->setup_filters(); 28 } 29 30 /** 31 * Globals 32 * 33 * @since 3.0.0 34 */ 35 protected function setup_globals() { 36 $this->dir = trailingslashit( dirname( __FILE__ ) ); 37 } 38 39 /** 40 * Include needed files 41 * 42 * @since 3.0.0 43 */ 44 protected function includes() { 45 require $this->dir . 'functions.php'; 46 require $this->dir . 'template-tags.php'; 47 48 // Test suite requires the AJAX functions early. 49 if ( function_exists( 'tests_add_filter' ) ) { 50 require $this->dir . 'ajax.php'; 51 52 // Load AJAX code only on AJAX requests. 53 } else { 54 add_action( 'admin_init', function() { 55 if ( defined( 'DOING_AJAX' ) && true === DOING_AJAX && 0 === strpos( $_REQUEST['action'], 'messages_' ) ) { 56 require bp_nouveau()->messages->dir . 'ajax.php'; 57 } 58 } ); 59 } 60 } 61 62 /** 63 * Register do_action() hooks 64 * 65 * @since 3.0.0 66 */ 67 protected function setup_actions() { 68 // Notices 69 add_action( 'widgets_init', 'bp_nouveau_unregister_notices_widget' ); 70 add_action( 'bp_init', 'bp_nouveau_push_sitewide_notices', 99 ); 71 72 // Messages 73 add_action( 'bp_messages_setup_nav', 'bp_nouveau_messages_adjust_nav' ); 74 75 // Remove deprecated scripts 76 remove_action( 'bp_enqueue_scripts', 'messages_add_autocomplete_js' ); 77 78 // Enqueue the scripts for the new UI 79 add_action( 'bp_nouveau_enqueue_scripts', 'bp_nouveau_messages_enqueue_scripts' ); 80 81 // Register the Messages Notifications filters 82 add_action( 'bp_nouveau_notifications_init_filters', 'bp_nouveau_messages_notification_filters' ); 83 } 84 85 /** 86 * Register add_filter() hooks 87 * 88 * @since 3.0.0 89 */ 90 protected function setup_filters() { 91 // Enqueue specific styles. 92 add_filter( 'bp_nouveau_enqueue_styles', 'bp_nouveau_messages_enqueue_styles', 10, 1 ); 93 94 // Register messages scripts. 95 add_filter( 'bp_nouveau_register_scripts', 'bp_nouveau_messages_register_scripts', 10, 1 ); 96 97 // Localize Scripts. 98 add_filter( 'bp_core_get_js_strings', 'bp_nouveau_messages_localize_scripts', 10, 1 ); 99 100 // Notices. 101 add_filter( 'bp_core_get_notifications_for_user', 'bp_nouveau_add_notice_notification_for_user', 10, 2 ); 102 103 // Messages. 104 add_filter( 'bp_messages_admin_nav', 'bp_nouveau_messages_adjust_admin_nav', 10, 1 ); 105 } 106 } 107 108 /** 109 * Launch the Messages loader class. 110 * 111 * @since 3.0.0 112 */ 113 function bp_nouveau_messages( $bp_nouveau = null ) { 114 if ( is_null( $bp_nouveau ) ) { 115 return; 116 } 117 118 $bp_nouveau->messages = new BP_Nouveau_Messages(); 119 } 120 add_action( 'bp_nouveau_includes', 'bp_nouveau_messages', 10, 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 |