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-blogs/classes/class-bp-blogs-recent-posts-widget.php

    r13436 r13481  
    66 * @subpackage BlogsWidgets
    77 * @since 1.0.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 * The Recent Networkwide Posts widget.
    1518 *
    1619 * @since 1.0.0
     20 * @deprecated 12.0.0
    1721 */
    18 class BP_Blogs_Recent_Posts_Widget extends WP_Widget {
     22class BP_Blogs_Recent_Posts_Widget {
    1923
    2024    /**
     
    2327     * @since 1.5.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         $widget_ops = array(
    28             'description'                 => __( 'A list of recently published posts from across your network.', 'buddypress' ),
    29             'classname'                   => 'widget_bp_blogs_widget buddypress widget',
    30             'customize_selective_refresh' => true,
    31             'show_instance_in_rest'       => true,
    32         );
    33         parent::__construct( false, $name = _x( '(BuddyPress) Recent Networkwide Posts', 'widget name', 'buddypress' ), $widget_ops );
     32        _deprecated_function( __METHOD__, '12.0.0' );
    3433    }
    3534
     
    3938     * @see WP_Widget::widget() for description of parameters.
    4039     *
     40     * @deprecated 12.0.0
     41     *
    4142     * @param array $args     Widget arguments.
    4243     * @param array $instance Widget settings, as saved by the user.
    4344     */
    4445    public function widget( $args, $instance ) {
    45         global $activities_template;
    46 
    47         $title = ! empty( $instance['title'] )
    48             ? esc_html( $instance['title'] )
    49             : __( 'Recent Networkwide Posts', 'buddypress' );
    50 
    51         if ( ! empty( $instance['link_title'] ) ) {
    52             $title = '<a href="' . bp_get_blogs_directory_url() . '">' . esc_html( $title ) . '</a>';
    53         }
    54 
    55         /**
    56          * Filters the Blogs Recent Posts widget title.
    57          *
    58          * @since 2.2.0
    59          * @since 2.3.0 Added 'instance' and 'id_base' to arguments passed to filter.
    60          *
    61          * @param string $title    The widget title.
    62          * @param array  $instance The settings for the particular instance of the widget.
    63          * @param string $id_base  Root ID for all widgets of this type.
    64          */
    65         $title = apply_filters( 'widget_title', $title, $instance, $this->id_base );
    66 
    67         echo $args['before_widget'];
    68         echo $args['before_title'] . $title . $args['after_title'];
    69 
    70         $max_limit = bp_get_widget_max_count_limit( __CLASS__ );
    71         if ( empty( $instance['max_posts'] ) || $instance['max_posts'] > $max_limit ) {
    72             $instance['max_posts'] = 10;
    73         }
    74 
    75         $after_widget = $args['after_widget'];
    76 
    77         // Override some of the contextually set parameters for bp_has_activities().
    78         $args = array(
    79             'action'     => 'new_blog_post',
    80             'max'        => $instance['max_posts'],
    81             'per_page'   => $instance['max_posts'],
    82             'user_id'    => 0,
    83             'scope'      => false,
    84             'object'     => false,
    85             'primary_id' => false
    86         );
    87 
    88         // Back up global.
    89         $old_activities_template = $activities_template;
    90 
    91         ?>
    92 
    93         <?php if ( bp_has_activities( $args ) ) : ?>
    94 
    95             <ul id="blog-post-list" class="activity-list item-list">
    96 
    97                 <?php while ( bp_activities() ) : bp_the_activity(); ?>
    98 
    99                     <li>
    100                         <div class="activity-content" style="margin: 0">
    101                             <div class="activity-header"><?php bp_activity_action(); ?></div>
    102 
    103                             <?php if ( bp_get_activity_content_body() ) : ?>
    104 
    105                                 <div class="activity-inner"><?php bp_activity_content_body(); ?></div>
    106 
    107                             <?php endif; ?>
    108 
    109                         </div>
    110                     </li>
    111 
    112                 <?php endwhile; ?>
    113 
    114             </ul>
    115 
    116         <?php else : ?>
    117 
    118             <div id="message" class="info">
    119                 <p><?php _e( 'Sorry, there were no posts found. Why not write one?', 'buddypress' ); ?></p>
    120             </div>
    121 
    122         <?php endif; ?>
    123 
    124         <?php echo $after_widget;
    125 
    126         // Restore the global.
    127         $activities_template = $old_activities_template;
     46        _deprecated_function( __METHOD__, '12.0.0' );
    12847    }
    12948
    13049    /**
    13150     * Update the networkwide posts widget options.
     51     *
     52     * @deprecated 12.0.0
    13253     *
    13354     * @param array $new_instance The new instance options.
     
    13657     */
    13758    public function update( $new_instance, $old_instance ) {
    138         $instance = $old_instance;
    139 
    140         $max_limit = bp_get_widget_max_count_limit( __CLASS__ );
    141 
    142         $instance['title']      = strip_tags( $new_instance['title'] );
    143         $instance['max_posts']  = $new_instance['max_posts'] > $max_limit ? $max_limit : intval( $new_instance['max_posts'] );
    144         $instance['link_title'] = ! empty( $new_instance['link_title'] );
    145 
    146         return $instance;
     59        _deprecated_function( __METHOD__, '12.0.0' );
    14760    }
    14861
     
    15063     * Output the networkwide posts widget options form.
    15164     *
     65     * @deprecated 12.0.0
     66     *
    15267     * @param array $instance Settings for this widget.
    15368     */
    15469    public function form( $instance ) {
    155         $instance = bp_parse_args(
    156             (array) $instance,
    157             array(
    158                 'title'      => __( 'Recent Networkwide Posts', 'buddypress' ),
    159                 'max_posts'  => 10,
    160                 'link_title' => false,
    161             )
    162         );
    163 
    164         $max_limit = bp_get_widget_max_count_limit( __CLASS__ );
    165 
    166         $title      = strip_tags( $instance['title'] );
    167         $max_posts  = $instance['max_posts'] > $max_limit ? $max_limit : intval( $instance['max_posts'] );
    168         $link_title = (bool) $instance['link_title'];
    169 
    170         ?>
    171 
    172         <p><label for="<?php echo $this->get_field_id( 'title' ); ?>"><?php _ex( 'Title:', 'Label for the Title field of the Recent Networkwide Posts widget', 'buddypress' ); ?> <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 ); ?>" style="width: 100%;" /></label></p>
    173         <p><label for="<?php echo $this->get_field_id( 'link_title' ); ?>"><input type="checkbox" name="<?php echo $this->get_field_name( 'link_title' ); ?>" value="1" <?php checked( $link_title ); ?> /> <?php _e( 'Link widget title to Blogs directory', 'buddypress' ); ?></label></p>
    174         <p><label for="<?php echo $this->get_field_id( 'max_posts' ); ?>"><?php _e( 'Max posts to show:', 'buddypress' ); ?> <input class="widefat" id="<?php echo $this->get_field_id( 'max_posts' ); ?>" name="<?php echo $this->get_field_name( 'max_posts' ); ?>" type="number" min="1" max="<?php echo esc_attr( $max_limit ); ?>" value="<?php echo esc_attr( $max_posts ); ?>" style="width: 30%" /></label></p>
    175         <?php
     70        _deprecated_function( __METHOD__, '12.0.0' );
    17671    }
    17772}
Note: See TracChangeset for help on using the changeset viewer.