Skip to:
Content

BuddyPress.org


Ignore:
Timestamp:
05/17/2023 11:14:06 AM (22 months ago)
Author:
imath
Message:

Deprecate BP Legacy widgets

Deprecate all classes, functions, JavaScripts and files related to Legacy Widgets. Legacy Widgets are now available from the BP Classic plugin.

See #8869
Closes https://github.com/buddypress/buddypress/pull/99

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/bp-messages/classes/class-bp-messages-sitewide-notices-widget.php

    r13108 r13481  
    66 * @subpackage MessagesClasses
    77 * @since 1.9.0
     8 * @deprecated 12.0.0
    89 */
    910
     
    1112defined( 'ABSPATH' ) || exit;
    1213
     14_deprecated_file( basename( __FILE__ ), '12.0.0', '', __( 'BuddyPress does not include Legacy Widgets anymore, you can restore it using the BP Classic plugin', 'buddypress' ) );
     15
    1316/**
    1417 * A widget that displays sitewide notices.
    1518 *
    1619 * @since 1.9.0
     20 * @deprecated 12.0.0
    1721 */
    1822class BP_Messages_Sitewide_Notices_Widget extends WP_Widget {
     
    2327     * @since 1.9.0
    2428     * @since 9.0.0 Adds the `show_instance_in_rest` property to Widget options.
     29     * @deprecated 12.0.0
    2530     */
    2631    public function __construct() {
    27         parent::__construct(
    28             'bp_messages_sitewide_notices_widget',
    29             __( '(BuddyPress) Sitewide Notices', 'buddypress' ),
    30             array(
    31                 'classname'                   => 'widget_bp_core_sitewide_messages buddypress widget',
    32                 'description'                 => __( 'Display Sitewide Notices posted by the site administrator', 'buddypress' ),
    33                 'customize_selective_refresh' => true,
    34                 'show_instance_in_rest'       => true,
    35             )
    36         );
     32        _deprecated_function( __METHOD__, '12.0.0' );
    3733    }
    3834
    3935    /**
    4036     * Render the widget.
     37     *
     38     * @deprecated 12.0.0
    4139     *
    4240     * @see WP_Widget::widget() for a description of parameters.
     
    4644     */
    4745    public function widget( $args, $instance ) {
    48 
    49         if ( ! is_user_logged_in() ) {
    50             return;
    51         }
    52 
    53         // Don't display the widget if there are no Notices to show.
    54         $notices = BP_Messages_Notice::get_active();
    55         if ( empty( $notices ) ) {
    56             return;
    57         }
    58 
    59         extract( $args );
    60 
    61         $title = ! empty( $instance['title'] ) ? $instance['title'] : '';
    62 
    63         /**
    64          * Filters the title of the Messages widget.
    65          *
    66          * @since 1.9.0
    67          * @since 2.3.0 Added 'instance' and 'id_base' to arguments passed to filter.
    68          *
    69          * @param string $title    The widget title.
    70          * @param array  $instance The settings for the particular instance of the widget.
    71          * @param string $id_base  Root ID for all widgets of this type.
    72          */
    73         $title = apply_filters( 'widget_title', $title, $instance, $this->id_base );
    74 
    75         echo $before_widget;
    76         echo $before_title . $title . $after_title; ?>
    77 
    78         <div class="bp-site-wide-message">
    79             <?php bp_message_get_notices(); ?>
    80         </div>
    81 
    82         <?php
    83 
    84         echo $after_widget;
     46        _deprecated_function( __METHOD__, '12.0.0' );
    8547    }
    8648
    8749    /**
    8850     * Process the saved settings for the widget.
     51     *
     52     * @deprecated 12.0.0
    8953     *
    9054     * @see WP_Widget::update() for a description of parameters and
     
    9660     */
    9761    public function update( $new_instance, $old_instance ) {
    98         $instance = $old_instance;
    99         $instance['title'] = strip_tags( $new_instance['title'] );
    100         return $instance;
     62        _deprecated_function( __METHOD__, '12.0.0' );
    10163    }
    10264
    10365    /**
    10466     * Render the settings form for Appearance > Widgets.
     67     *
     68     * @deprecated 12.0.0
    10569     *
    10670     * @see WP_Widget::form() for a description of parameters.
     
    10973     */
    11074    public function form( $instance ) {
    111         $instance = bp_parse_args(
    112             (array) $instance,
    113             array(
    114                 'title' => '',
    115             )
    116         );
    117 
    118         $title = strip_tags( $instance['title'] ); ?>
    119 
    120         <p>
    121             <label for="<?php echo $this->get_field_id( 'title' ); ?>"><?php _e( 'Title:', 'buddypress' ); ?></label>
    122             <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 ); ?>" />
    123         </p>
    124 
    125         <?php
     75        _deprecated_function( __METHOD__, '12.0.0' );
    12676    }
    12777}
Note: See TracChangeset for help on using the changeset viewer.