__( 'A list of recently published posts from across your network.', 'buddypress' ), 'classname' => 'widget_bp_blogs_widget buddypress widget', 'customize_selective_refresh' => true, 'show_instance_in_rest' => true, ); parent::__construct( false, $name = _x( '(BuddyPress) Recent Networkwide Posts', 'widget name', 'buddypress' ), $widget_ops ); } /** * Display the networkwide posts widget. * * @see WP_Widget::widget() for description of parameters. * * @param array $args Widget arguments. * @param array $instance Widget settings, as saved by the user. */ public function widget( $args, $instance ) { global $activities_template; $title = ! empty( $instance['title'] ) ? esc_html( $instance['title'] ) : __( 'Recent Networkwide Posts', 'buddypress' ); if ( ! empty( $instance['link_title'] ) ) { $title = '' . esc_html( $title ) . ''; } /** * Filters the Blogs Recent Posts widget title. * * @since 2.2.0 * @since 2.3.0 Added 'instance' and 'id_base' to arguments passed to filter. * * @param string $title The widget title. * @param array $instance The settings for the particular instance of the widget. * @param string $id_base Root ID for all widgets of this type. */ $title = apply_filters( 'widget_title', $title, $instance, $this->id_base ); echo $args['before_widget']; echo $args['before_title'] . $title . $args['after_title']; $max_limit = bp_get_widget_max_count_limit( __CLASS__ ); if ( empty( $instance['max_posts'] ) || $instance['max_posts'] > $max_limit ) { $instance['max_posts'] = 10; } $after_widget = $args['after_widget']; // Override some of the contextually set parameters for bp_has_activities(). $args = array( 'action' => 'new_blog_post', 'max' => $instance['max_posts'], 'per_page' => $instance['max_posts'], 'user_id' => 0, 'scope' => false, 'object' => false, 'primary_id' => false ); // Back up global. $old_activities_template = $activities_template; ?>

$max_limit ? $max_limit : intval( $new_instance['max_posts'] ); $instance['link_title'] = ! empty( $new_instance['link_title'] ); return $instance; } /** * Output the networkwide posts widget options form. * * @param array $instance Settings for this widget. */ public function form( $instance ) { $instance = bp_parse_args( (array) $instance, array( 'title' => __( 'Recent Networkwide Posts', 'buddypress' ), 'max_posts' => 10, 'link_title' => false, ) ); $max_limit = bp_get_widget_max_count_limit( __CLASS__ ); $title = strip_tags( $instance['title'] ); $max_posts = $instance['max_posts'] > $max_limit ? $max_limit : intval( $instance['max_posts'] ); $link_title = (bool) $instance['link_title']; ?>