bp_has_document (数组|字符串args美元''

初始化文档循环。

描述

根据$ args通过,bp_has_document ()填充$ Document_Template全局,使使用BuddyPress模板和模板函数来显示文档项列表。

参数

args美元

数组|字符串(可选的)限制文档循环内容的参数。大多数参数的格式相同BP_Document: get ().但是,因为这里接受的参数的格式在许多方面不同,而且因为bp_has_document ()以动态方式确定一些默认参数,我们也列出了这里的所有接受的参数。参数可以作为关联数组传递,也可以作为URL querystring(例如,'user_id = 4&fields =全部')。

  • '页'
    (int)获取结果的哪一页。使用page=1而不使用per_page将不会导致分页。默认值:1。
  • '每页'
    (int | bool)每页的结果数。默认值:20。
  • “page_arg”
    (字符串)在分页链接中用作查询参数的字符串。默认值:“acpage”。
  • “马克斯”
    (int | bool)返回的最大结果数。默认值:false(无限)。
  • '田野'
    (字符串)要检索的文档字段。'all'获取整个文档对象,'ids'仅获取文档id。默认的“所有”。
  • “count_total”
    (字符串| bool)如果为true,则运行一个额外的DB查询来计算查询的文档项总数。默认值:false。
  • '种类'
    (字符串)'asc'或'desc'。默认值:'desc'。
  • “排除”
    (数组| bool)要排除的文档id数组。默认值:false。
  • '包括'
    (数组| bool)要查询的精确文档id数组。提供一个'include'数组将覆盖参数数组中传递的所有其他过滤器。当查看单个文档项的永久链接页面时,此值默认为该项的ID。否则默认值为false。
  • “search_term”
    (字符串)按照搜索项限制结果。默认值:false。
  • “范围”
    (字符串)使用BuddyPress预构建过滤器。- 'friends'检索属于用户朋友的物品。- 'groups'检索属于用户所属组的项目。默认值为false。
  • '用户身份'
    (int数组| | bool)应获取其文档的用户的ID(s)。传递单个ID或ID数组。查看用户个人资料页面时,“user_id”默认为显示用户的ID。否则默认值为false。
  • “folder_id”
    (int数组| | bool)应获取其文档的文件夹的ID。传递单个ID或ID数组。当查看单个文件夹页面时,'folder_id'默认为所显示文件夹的ID。否则默认值为false。
  • “group_id”
    (int数组| | bool)应获取其文档的组的ID。传递单个ID或ID数组。当查看单个组页面时,'group_id'默认为显示组的ID。否则默认值为false。
  • '隐私'
    (数组)通过隐私限制结果。默认值:public | grouponly。

默认值:“

返回

(BOOL)当找到文档时返回true,否则返回false。

文件:bp-document / bp-document-template.php

功能bp_has_document($ args =''){global $ document_template,$ bp;$ args = bp_parse_args($ args);/ * *智能默认值。* / $ search_terms_default = false;$ search_query_arg = bp_core_get_component_search_query_arg('document');如果(!空($ _request [$ search_query_arg]))){$ search_terms_default = stripslashes($ _request [$ search_query_arg]);$ privacy = false;//文件夹过滤。$ folder_id = 0;if(!isset($ args ['folder_id'])&&空($ args ['include'])){$ folder_id = bp_is_single_folder()? (int) bp_action_variable( 0 ) : false; if ( bp_is_group_single() && bp_is_group_folders() ) { $folder_id = (int) bp_action_variable( 1 ); } } elseif ( ! empty( $args['folder_id'] ) ) { $folder_id = $args['folder_id']; } $group_id = false; // The default scope should recognize custom slugs. $scope = ( isset( $_REQUEST['scope'] ) ? $_REQUEST['scope'] : 'all' ); $scope = bp_document_default_scope( $scope ); /* * Parse Args. */ // Note: any params used for filtering can be a single value, or multiple // values comma separated. $r = bp_parse_args( $args, array( 'include' => false, // Pass an document_id or string of IDs comma-separated. 'exclude' => false, // Pass an activity_id or string of IDs comma-separated. 'sort' => 'ASC', // Sort DESC or ASC. 'order_by' => false, // Order by. Default: title. 'page' => 1, // Which page to load. 'per_page' => 20, // Number of items per page. 'page_arg' => 'acpage', // See https://buddypress.trac.wordpress.org/ticket/3679. 'max' => false, // Max number to return. 'fields' => 'all', 'count_total' => false, // Scope - pre-built document filters for a user (friends/groups). 'scope' => $scope, // Filtering. 'user_id' => false, // user_id to filter on. 'folder_id' => $folder_id, // folder_id to filter on. 'group_id' => $group_id, // group_id to filter on. 'privacy' => $privacy, // privacy to filter on - public, onlyme, loggedin, friends, grouponly, message. 'folder' => true, // privacy to filter on - public, onlyme, loggedin, friends, grouponly, message. 'user_directory' => true, // privacy to filter on - public, onlyme, loggedin, friends, grouponly, message. 'meta_query_document' => false, 'meta_query_folder' => false, 'meta_query' => false, // Searching. 'search_terms' => $search_terms_default, ), 'has_document' ); /* * Smart Overrides. */ // Search terms. if ( ! empty( $_REQUEST['s'] ) && empty( $r['search_terms'] ) ) { $r['search_terms'] = $_REQUEST['s']; } if ( ! empty( $_REQUEST['sort'] ) ) { $r['sort'] = $_REQUEST['sort']; } if ( isset( $_POST['extras'] ) && ! empty( $_POST['extras']['orderby'] ) && ! empty( $_POST['extras']['sort'] ) ) { $r['order_by'] = $_POST['extras']['orderby']; $r['sort'] = $_POST['extras']['sort']; } if ( ! empty( $_REQUEST['order_by'] ) ) { $r['order_by'] = $_REQUEST['order_by']; } // Do not exceed the maximum per page. if ( ! empty( $r['max'] ) && ( (int) $r['per_page'] > (int) $r['max'] ) ) { $r['per_page'] = $r['max']; } /* * Query */ $document_template = new BP_Document_Template( $r ); /** * Filters whether or not there are document items to display. * * @since BuddyBoss 1.4.0 * * @param bool $value Whether or not there are document items to display. * @param string $document_template Current document template being used. * @param array $r Array of arguments passed into the BP_Document_Template class. */ return apply_filters( 'bp_has_document', $document_template->has_document(), $document_template, $r ); }

变更乐

变更乐
版本 描述
BuddyBoss 1.4.0 介绍了。

问题吗?

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