BP_Messages_Box_Template:: __construct (数组args美元数组()

构造函数方法。

描述

参数

args美元

数组(可选)数组的参数。看到bp_has_message_threads ()充分的描述。

默认值:数组()

文件:bp-messages /类/ class-bp-messages-box-template.php

public function __construct($args = array()){//与传递参数的旧方法向后兼容。如果(!is_array($args) || func_num_args() > 1) {_depreccated_argument (__METHOD__, '2.2.0', sprintf(__('传递给%1$s的参数应该在一个关联数组中。有关更多细节,请参阅%2$s的内联文档。', 'buddyboss'), __METHOD__, __FILE__));$ old_args_keys =阵列(0 = > ' user_id ', 1 = >“盒子”,2 = > ' per_page ', 3 = >‘麦克斯’,4 = > '类型',5 = > ' search_term ', 6 = > ' page_arg ');$args = bp_core_parse_args_array($old_args_keys, func_get_args());} $ r = wp_parse_args (args美元,阵列(“页面”= > 1,' per_page ' = > 10,“page_arg”= >“mpage”,“盒子”= >“收件箱”,'类型' = > '所有',' user_id ' = > bp_loggedin_user_id(),“马克斯”= > false, search_term ' => '', ' 包括“= > false, meta_query = >阵列()));$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']); / /分页 $this->user_id = $r['user_id']; $this->box = $r['box']; $this->type = $r['type']; $this->search_terms = $r['search_terms']; $this->include = $r['include']; if ( 'notices' === $this->box ) { $this->threads = BP_Messages_Notice::get_notices( array( 'pag_num' => $this->pag_num, 'pag_page' => $this->pag_page ) ); } else { $threads = BP_Messages_Thread::get_current_threads_for_user( array( 'user_id' => $this->user_id, 'box' => $this->box, 'type' => $this->type, 'limit' => $this->pag_num, 'page' => $this->pag_page, 'search_terms' => $this->search_terms, 'include' => $this->include, 'meta_query' => $r['meta_query'], ) ); $this->threads = $threads['threads']; $this->total_thread_count = $threads['total']; } if ( !$this->threads ) { $this->thread_count = 0; $this->total_thread_count = 0; } else { $total_notice_count = BP_Messages_Notice::get_total_notice_count(); if ( empty( $r['max'] ) || ( (int) $r['max'] >= (int) $total_notice_count ) ) { if ( 'notices' === $this->box ) { $this->total_thread_count = (int) $total_notice_count; } } else { $this->total_thread_count = (int) $r['max']; } if ( ! empty( $r['max'] ) ) { if ( (int) $r['max'] >= count( $this->threads ) ) { $this->thread_count = count( $this->threads ); } else { $this->thread_count = (int) $r['max']; } } else { $this->thread_count = count( $this->threads ); } } if ( (int) $this->total_thread_count && (int) $this->pag_num ) { $pag_args = array( $r['page_arg'] => '%#%', ); if ( defined( 'DOING_AJAX' ) && true === (bool) DOING_AJAX ) { $base = remove_query_arg( 's', wp_get_referer() ); } else { $base = ''; } $add_args = array(); if ( ! empty( $this->search_terms ) ) { $add_args['s'] = $this->search_terms; } $this->pag_links = paginate_links( array( 'base' => add_query_arg( $pag_args, $base ), 'format' => '', 'total' => ceil( (int) $this->total_thread_count / (int) $this->pag_num ), 'current' => $this->pag_page, 'prev_text' => __( '←', 'buddyboss' ), 'next_text' => __( '→', 'buddyboss' ), 'mid_size' => 1, 'add_args' => $add_args, ) ); } }

问题吗?

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