Skip to:
Content

BuddyPress.org


Ignore:
Timestamp:
05/17/2023 11:14:06 AM (4 years 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-templates/bp-nouveau/includes/classes/class-bp-nouveau-object-nav-widget.php

    r13153 r13481  
    55 * @since 3.0.0
    66 * @version 10.0.0
     7 * @deprecated 12.0.0
    78 */
    89
    … …  
    1011defined( 'ABSPATH' ) || exit;
    1112
    12 /**
    13  * BP Sidebar Item Nav_Widget.
    14  *
    15  * Adds a widget to move avatar/item nav into the sidebar.
    16  *
    17  * @since 3.0.0
    18  */
    19 class BP_Nouveau_Object_Nav_Widget extends WP_Widget {
    20         /**
    21          * Constructor
    22          *
    23          * @since 3.0.0
    24          * @since 9.0.0 Adds the `show_instance_in_rest` property to Widget options.
    25          */
    26         public function __construct() {
    27                 $widget_ops = array(
    28                         'description'           => __( 'Displays BuddyPress primary nav in the sidebar of your site. Make sure to use it as the first widget of the sidebar and only once.', 'buddypress' ),
    29                         'classname'             => 'widget_nav_menu buddypress_object_nav',
    30                         'show_instance_in_rest' => true,
    31                 );
    32 
    33                 parent::__construct(
    34                         'bp_nouveau_sidebar_object_nav_widget',
    35                         __( '(BuddyPress) Primary navigation', 'buddypress' ),
    36                         $widget_ops
    37                 );
    38         }
    39 
    40         /**
    41          * Register the widget
    42          *
    43          * @since 3.0.0
    44          */
    45         public static function register_widget() {
    46                 register_widget( 'BP_Nouveau_Object_Nav_Widget' );
    47         }
    48 
    49         /**
    50          * Displays the output, the button to post new support topics
    51          *
    52          * @since 3.0.0
    53          *
    54          * @param mixed   $args     Arguments
    55          * @param unknown $instance
    56          */
    57         public function widget( $args, $instance ) {
    58                 if ( ! is_buddypress() || bp_is_group_create() ) {
    59                         return;
    60                 }
    61 
    62                 /**
    63                  * Filters the nav widget args for the BP_Nouveau_Object_Nav_Widget widget.
    64                  *
    65                  * @since 3.0.0
    66                  *
    67                  * @param array $value Array of arguments {
    68                  *     @param bool $bp_nouveau_widget_title Whether or not to assign a title for the widget.
    69                  * }
    70                  */
    71                 $item_nav_args = bp_parse_args(
    72                         $instance,
    73                         apply_filters(
    74                                 'bp_nouveau_object_nav_widget_args',
    75                                 array( 'bp_nouveau_widget_title' => true )
    76                         ),
    77                         'widget_object_nav'
    78                 );
    79 
    80                 $title = '';
    81 
    82                 if ( ! empty( $item_nav_args['bp_nouveau_widget_title'] ) ) {
    83                         if ( bp_is_group() ) {
    84                                 $title = bp_get_current_group_name();
    85                         } elseif ( bp_is_user() ) {
    86                                 $title = bp_get_displayed_user_fullname();
    87                         } elseif ( bp_get_directory_title( bp_current_component() ) ) {
    88                                 $title = bp_get_directory_title( bp_current_component() );
    89                         }
    90                 }
    91 
    92                 /**
    93                  * Filters the BP_Nouveau_Object_Nav_Widget widget title.
    94                  *
    95                  * @since 3.0.0
    96                  *
    97                  * @param string $title    The widget title.
    98                  * @param array  $instance The settings for the particular instance of the widget.
    99                  * @param string $id_base  Root ID for all widgets of this type.
    100                  */
    101                 $title = apply_filters( 'widget_title', $title, $instance, $this->id_base );
    102 
    103                 echo $args['before_widget'];
    104 
    105                 if ( ! empty( $title ) ) {
    106                         echo $args['before_title'] . $title . $args['after_title'];
    107                 }
    108 
    109                 if ( bp_is_user() ) {
    110                         bp_get_template_part( 'members/single/parts/item-nav' );
    111                 } elseif ( bp_is_group() ) {
    112                         bp_get_template_part( 'groups/single/parts/item-nav' );
    113                 } elseif ( bp_is_directory() ) {
    114                         bp_get_template_part( 'common/nav/directory-nav' );
    115                 }
    116 
    117                 echo $args['after_widget'];
    118         }
    119 
    120         /**
    121          * Update the new support topic widget options (title)
    122          *
    123          * @since 3.0.0
    124          *
    125          * @param array $new_instance The new instance options
    126          * @param array $old_instance The old instance options
    127          *
    128          * @return array the instance
    129          */
    130         public function update( $new_instance, $old_instance ) {
    131                 $instance                            = $old_instance;
    132                 $instance['bp_nouveau_widget_title'] = (bool) $new_instance['bp_nouveau_widget_title'];
    133 
    134                 return $instance;
    135         }
    136 
    137         /**
    138          * Output the new support topic widget options form
    139          *
    140          * @since 3.0.0
    141          *
    142          * @param $instance Instance
    143          *
    144          * @return string HTML Output
    145          */
    146         public function form( $instance ) {
    147                 $defaults = array(
    148                         'bp_nouveau_widget_title' => true,
    149                 );
    150 
    151                 $instance = bp_parse_args(
    152                         (array) $instance,
    153                         $defaults,
    154                         'widget_object_nav_form'
    155                 );
    156 
    157                 $bp_nouveau_widget_title = (bool) $instance['bp_nouveau_widget_title'];
    158                 ?>
    159 
    160                 <p>
    161                         <input class="checkbox" type="checkbox" <?php checked( $bp_nouveau_widget_title, true ); ?> id="<?php echo $this->get_field_id( 'bp_nouveau_widget_title' ); ?>" name="<?php echo $this->get_field_name( 'bp_nouveau_widget_title' ); ?>" />
    162                         <label for="<?php echo $this->get_field_id( 'bp_nouveau_widget_title' ); ?>"><?php esc_html_e( 'Include navigation title', 'buddypress' ); ?></label>
    163                 </p>
    164 
    165                 <?php
    166         }
    167 }
     13_deprecated_file( basename( __FILE__ ), '12.0.0', '', __( 'BuddyPress does not include Legacy Widgets anymore, you can restore it using the BP Classic plugin', 'buddypress' ) );
Note: See TracChangeset for help on using the changeset viewer.