[ Index ] |
PHP Cross Reference of BuddyPress |
[Summary view] [Print] [Text view]
1 <?php 2 /** 3 * BuddyPress Messages Sitewide Notices Widget. 4 * 5 * @package BuddyPress 6 * @subpackage Messages 7 * @since 1.9.0 8 */ 9 10 // Exit if accessed directly. 11 defined( 'ABSPATH' ) || exit; 12 13 /** 14 * A widget that displays sitewide notices. 15 * 16 * @since 1.9.0 17 */ 18 class BP_Messages_Sitewide_Notices_Widget extends WP_Widget { 19 20 /** 21 * Constructor method. 22 */ 23 function __construct() { 24 parent::__construct( 25 'bp_messages_sitewide_notices_widget', 26 __( '(BuddyPress) Sitewide Notices', 'buddypress' ), 27 array( 28 'classname' => 'widget_bp_core_sitewide_messages buddypress widget', 29 'description' => __( 'Display Sitewide Notices posted by the site administrator', 'buddypress' ), 30 'customize_selective_refresh' => true, 31 ) 32 ); 33 } 34 35 /** 36 * Render the widget. 37 * 38 * @see WP_Widget::widget() for a description of parameters. 39 * 40 * @param array $args See {@WP_Widget::widget()}. 41 * @param array $instance See {@WP_Widget::widget()}. 42 */ 43 public function widget( $args, $instance ) { 44 45 if ( ! is_user_logged_in() ) { 46 return; 47 } 48 49 // Don't display the widget if there are no Notices to show. 50 $notices = BP_Messages_Notice::get_active(); 51 if ( empty( $notices ) ) { 52 return; 53 } 54 55 extract( $args ); 56 57 $title = ! empty( $instance['title'] ) ? $instance['title'] : ''; 58 59 /** 60 * Filters the title of the Messages widget. 61 * 62 * @since 1.9.0 63 * @since 2.3.0 Added 'instance' and 'id_base' to arguments passed to filter. 64 * 65 * @param string $title The widget title. 66 * @param array $instance The settings for the particular instance of the widget. 67 * @param string $id_base Root ID for all widgets of this type. 68 */ 69 $title = apply_filters( 'widget_title', $title, $instance, $this->id_base ); 70 71 echo $before_widget; 72 echo $before_title . $title . $after_title; ?> 73 74 <div class="bp-site-wide-message"> 75 <?php bp_message_get_notices(); ?> 76 </div> 77 78 <?php 79 80 echo $after_widget; 81 } 82 83 /** 84 * Process the saved settings for the widget. 85 * 86 * @see WP_Widget::update() for a description of parameters and 87 * return values. 88 * 89 * @param array $new_instance See {@WP_Widget::update()}. 90 * @param array $old_instance See {@WP_Widget::update()}. 91 * @return array $instance See {@WP_Widget::update()}. 92 */ 93 public function update( $new_instance, $old_instance ) { 94 $instance = $old_instance; 95 $instance['title'] = strip_tags( $new_instance['title'] ); 96 return $instance; 97 } 98 99 /** 100 * Render the settings form for Appearance > Widgets. 101 * 102 * @see WP_Widget::form() for a description of parameters. 103 * 104 * @param array $instance See {@WP_Widget::form()}. 105 * 106 * @return string|null Widget form output. 107 */ 108 public function form( $instance ) { 109 $instance = wp_parse_args( (array) $instance, array( 110 'title' => '', 111 ) ); 112 113 $title = strip_tags( $instance['title'] ); ?> 114 115 <p> 116 <label for="<?php echo $this->get_field_id( 'title' ); ?>"><?php _e( 'Title:', 'buddypress' ); ?></label> 117 <input class="widefat" id="<?php echo $this->get_field_id( 'title' ); ?>" name="<?php echo $this->get_field_name( 'title' ); ?>" type="text" value="<?php echo esc_attr( $title ); ?>" /> 118 </p> 119 120 <?php 121 } 122 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
Generated: Tue Jan 26 01:01:37 2021 | Cross-referenced by PHPXref 0.7.1 |