bp_latest_activities.

窗口小部件显示您的社区的最新活动!

描述

来源

文件:BP-templates / bp-nouveau /包括/活动/ widgets.php

bp_latest_activities类扩展wp_widget {/ ** *构造窗口小部件。* * * @since buddypress 3.0.0 * / public function __construct(){/ ** *过滤bp_latest_activities小部件的窗口小部件选项。* * @since buddypress 3.0.0 * * * @param数组$ value数组的小部件选项。* / $ widget_ops = apply_filters('bp_latest_activitive',array('classname'=>'bp-lasture-visutions buddypress','description'=> __('选择以按类型显示最新的活动更新,在您的社区中发布。','buddyboss'),'customize_selective_refresh'=> true,));父母:: __构造(false,__('(bb),'buddyboss'),$ widget_ops);} / ** *注册小部件。* * @since buddypress 3.0.0 * / public static functive register_widget(){register_widget('bp_latest_activitivities');} / ** *显示小部件内容。* * @since buddypress 3.0.0 * * * @param数组$ args窗口小部件参数。* @param数组$ siforation widget设置,由用户保存。 */ public function widget( $args, $instance ) { // Default values $title = __( 'Latest updates', 'buddyboss' ); $type = array( 'activity_update' ); $max = 5; $bp_nouveau = bp_nouveau(); // Check instance for a custom title if ( ! empty( $instance['title'] ) ) { $title = $instance['title']; } /** * Filters the BP_Latest_Activities widget title. * * @since BuddyPress 3.0.0 * * @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 ); // Check instance for custom max number of activities to display if ( ! empty( $instance['max'] ) ) { $max = (int) $instance['max']; } // Check instance for custom activity types if ( ! empty( $instance['type'] ) ) { $type = maybe_unserialize( $instance['type'] ); $classes = array_map( 'sanitize_html_class', array_merge( $type, array( 'bp-latest-activities' ) ) ); // Add classes to the container $args['before_widget'] = str_replace( 'bp-latest-activities', join( ' ', $classes ), $args['before_widget'] ); } echo $args['before_widget']; if ( $title ) { echo $args['before_title'] . $title . $args['after_title']; } $reset_activities_template = null; if ( ! empty( $GLOBALS['activities_template'] ) ) { $reset_activities_template = $GLOBALS['activities_template']; } /** * Globalize the activity widget arguments. * @see bp_nouveau_activity_widget_query() to override */ $bp_nouveau->activity->widget_args = array( 'max' => $max, 'scope' => 'all', 'user_id' => 0, 'object' => false, 'action' => join( ',', $type ), 'primary_id' => 0, 'secondary_id' => 0, ); bp_get_template_part( 'activity/widget' ); // Reset the globals $GLOBALS['activities_template'] = $reset_activities_template; $bp_nouveau->activity->widget_args = array(); echo $args['after_widget']; } /** * Update the widget settings. * * @since BuddyPress 3.0.0 * * @param array $new_instance The new instance settings. * @param array $old_instance The old instance settings. * * @return array The widget settings. */ public function update( $new_instance, $old_instance ) { $instance = $old_instance; $instance['title'] = strip_tags( $new_instance['title'] ); $instance['max'] = 5; if ( ! empty( $new_instance['max'] ) ) { $instance['max'] = $new_instance['max']; } $instance['type'] = maybe_serialize( array( 'activity_update' ) ); if ( ! empty( $new_instance['type'] ) ) { $instance['type'] = maybe_serialize( $new_instance['type'] ); } return $instance; } /** * Display the form to set the widget settings. * * @since BuddyPress 3.0.0 * * @param array $instance Settings for this widget. * * @return string HTML output. */ public function form( $instance ) { $instance = wp_parse_args( (array) $instance, array( 'title' => __( 'Latest updates', 'buddyboss' ), 'max' => 5, 'type' => '', ) ); $title = esc_attr( $instance['title'] ); $max = (int) $instance['max']; $type = array( 'activity_update' ); if ( ! empty( $instance['type'] ) ) { $type = maybe_unserialize( $instance['type'] ); } ?> 

更新日志

更新日志
版本 描述
BuddyPress 3.0.0 介绍。

方法

问题?

我们总是很乐意帮助您可能拥有的代码或其他问题!搜索我们开发人员文档联系支持,或与我们联系销售团队