BP_Activity_Template:: __construct (数组args美元)
构造函数方法。
描述
传递给这个类构造函数的参数的格式与BP_Activity_Activity: get ().
另请参阅
- BP_Activity_Activity: get ():用于参数结构的描述,以及默认值。
参数
- args美元
-
(数组)(必需)数组的参数。支持所有的论点BP_Activity_Activity: get (),以及'page_arg'和'include'。'per_page'和'display_comments'的默认值与原始函数不同,如下所述。
- “page_arg”
(字符串)在分页链接中用作查询参数的字符串。默认值:“acpage”。 - “包括”
(数组| bool)传递一个活动id数组以仅检索这些项目,或false以noop 'include'参数。“include”与“in”的区别在于,“in”形成了一个in子句,与传递给函数的其他过滤器一起工作,而“include”被解释为要检索的项的精确列表,这跳过了所有其他与过滤器相关的参数。默认值:false。 - “per_page”
(int | bool)默认值:20。 - “display_comments”
(字符串| bool)默认值:“线程”。
- “page_arg”
源
文件:bp-activity /类/ class-bp-activity-template.php
Public function __construct($args) {$bp = buddypress();//与旧的参数传递方法向后兼容。if (!is_array($args) || func_num_args() > 1) {_depreccated_argument (__METHOD__, '1.6', sprintf(__('传递给%1$s的参数应该在一个关联数组中。有关更多细节,请参阅%2$s的内联文档。', 'buddyboss'), __METHOD__, __FILE__));$ old_args_keys =阵列(0 = >“页”,1 = > ' per_page ', 2 = >‘麦克斯’,3 = >“包括”,4 = >“排序”,5 = >“过滤器”,6 = > ' search_term ', 7 = > ' display_comments ', 8 = > ' show_hidden ', 9 = >“排除”,10 = > '在',11 = >“垃圾邮件”,12 = > ' page_arg ');$args = bp_core_parse_args_array($old_args_keys, func_get_args());} $违约=阵列(“页面”= > 1,' per_page ' = > 20日“page_arg”= >“acpage”,“马克斯”= > false, '字段' = > '所有',' count_total ' = >假,“排序”= > false,“包括”= > false,“排除”= > false,”“= >假,“过滤器”= > false,“范围”= > false, search_term = > false,隐私' = > false, meta_query = > false, date_query = > false,'filter_query' => false, 'display_comments' => 'thread ', 'show_hidden' => false, 'spam' => 'ham_only', 'update_meta_cache' => true,);$r = wp_parse_args($args, $defaults);提取($ r); $this->pag_arg = sanitize_key( $r['page_arg'] ); $this->pag_page = bp_sanitize_pagination_arg( $this->pag_arg, $r['page'] ); $this->pag_num = bp_sanitize_pagination_arg( 'num', $r['per_page'] ); // Check if post/comment replies are disabled. $this->disable_blogforum_replies = (bool) bp_core_get_root_option( 'bp-disable-blogforum-comments' ); // Get an array of the logged in user's favorite activities. $this->my_favs = bp_get_user_meta( bp_loggedin_user_id(), 'bp_favorite_activities', true ); // Fetch specific activity items based on ID's. if ( !empty( $include ) ) { $this->activities = bp_activity_get_specific( array( 'activity_ids' => explode( ',', $include ), 'max' => $max, 'count_total' => $count_total, 'page' => $this->pag_page, 'per_page' => $this->pag_num, 'sort' => $sort, 'display_comments' => $display_comments, 'show_hidden' => $show_hidden, 'spam' => $spam, 'update_meta_cache' => $update_meta_cache, ) ); // Fetch all activity items. } else { $this->activities = bp_activity_get( array( 'display_comments' => $display_comments, 'max' => $max, 'count_total' => $count_total, 'per_page' => $this->pag_num, 'page' => $this->pag_page, 'sort' => $sort, 'search_terms' => $search_terms, 'privacy' => $privacy, 'meta_query' => $meta_query, 'date_query' => $date_query, 'filter_query' => $filter_query, 'filter' => $filter, 'scope' => $scope, 'show_hidden' => $show_hidden, 'exclude' => $exclude, 'in' => $in, 'spam' => $spam, 'update_meta_cache' => $update_meta_cache, ) ); } // The total_activity_count property will be set only if a // 'count_total' query has taken place. if ( ! is_null( $this->activities['total'] ) ) { if ( ! $max || $max >= (int) $this->activities['total'] ) { $this->total_activity_count = (int) $this->activities['total']; } else { $this->total_activity_count = (int) $max; } } $this->has_more_items = $this->activities['has_more_items']; $this->activities = $this->activities['activities']; if ( $max ) { if ( $max >= count($this->activities) ) { $this->activity_count = count( $this->activities ); } else { $this->activity_count = (int) $max; } } else { $this->activity_count = count( $this->activities ); } $this->full_name = bp_get_displayed_user_fullname(); // Fetch parent content for activity comments so we do not have to query in the loop. foreach ( (array) $this->activities as $activity ) { if ( 'activity_comment' != $activity->type ) { continue; } $parent_ids[] = $activity->item_id; } if ( !empty( $parent_ids ) ) { $activity_parents = bp_activity_get_specific( array( 'activity_ids' => $parent_ids ) ); } if ( !empty( $activity_parents['activities'] ) ) { foreach( $activity_parents['activities'] as $parent ) { $this->activity_parents[$parent->id] = $parent; } unset( $activity_parents ); } if ( (int) $this->total_activity_count && (int) $this->pag_num ) { $this->pag_links = paginate_links( array( 'base' => add_query_arg( $this->pag_arg, '%#%' ), 'format' => '', 'total' => ceil( (int) $this->total_activity_count / (int) $this->pag_num ), 'current' => (int) $this->pag_page, 'prev_text' => __( '←', 'buddyboss' ), 'next_text' => __( '→', 'buddyboss' ), 'mid_size' => 1, 'add_args' => array(), ) ); } }
更新日志
版本 | 描述 |
---|---|
BuddyPress 1.5.0 | 介绍了。 |