BP_Document:: get_scope_query_sql (混合美元的范围=假,数组$ r=数组())
获取' scope '参数的SQLBP_Document: get ().
描述
范围是一组预先确定的文档参数。此方法用于获取这些文档参数并在需要时覆盖任何现有参数。可以处理多个作用域。
参数
- 美元的范围
-
(混合)(可选)文档的范围。接受范围的字符串或数组。
默认值:假
- $ r
-
(数组)(可选)当前活动的观点。和BP_document: get (),但与默认值合并。
默认值:数组()
返回
(假|数组)'sql' WHERE sql字符串和'override'文档参数。
源
文件:bp-document /类/ class-bp-document.php
public static function get_scope_query_sql($scope = false, $r = array()){//定义数组以备将来使用。数组$ query_args = ();$覆盖=数组();数组$ retval = ();//检查作用域数组。如果(is_array($scope)) {$scope = $scope;//爆炸一个逗号分隔的范围字符串。} elseif (is_string($scope)) {$scope =爆炸(',',$scope);} //如果没有范围通过,保释。If (empty($scopes)){返回false; } // Helper to easily grab the 'user_id'. if ( ! empty( $r['filter']['user_id'] ) ) { $r['user_id'] = $r['filter']['user_id']; } // Parse each scope; yes! we handle multiples! foreach ( $scopes as $scope ) { $scope_args = array(); /** * Plugins can hook here to set their document arguments for custom scopes. * This is a dynamic filter based on the document scope. eg: * - 'bp_document_set_groups_scope_args' * - 'bp_document_set_friends_scope_args' * To see how this filter is used, plugin devs should check out: * - bp_groups_filter_document_scope() - used for 'groups' scope * - bp_friends_filter_document_scope() - used for 'friends' scope * * @param array { * Document query clauses. * * @type array { * Document arguments for your custom scope. * See {@link BP_Document_Query::_construct()} for more details. * } * @type array $override Optional. Override existing document arguments passed by $r. * } * } * * @param array $r Current activity arguments passed in BP_Document::get(). * * @since BuddyBoss 1.4.0 */ $scope_args = apply_filters( "bp_document_set_{$scope}_scope_args", array(), $r ); if ( ! empty( $scope_args ) ) { // Merge override properties from other scopes // this might be a problem... if ( ! empty( $scope_args['override'] ) ) { $override = array_merge( $override, $scope_args['override'] ); unset( $scope_args['override'] ); } // Save scope args. if ( ! empty( $scope_args ) ) { $query_args[] = $scope_args; } } } if ( ! empty( $query_args ) ) { // Set relation to OR. $query_args['relation'] = 'OR'; $query = new BP_Document_Query( $query_args ); $sql = $query->get_sql(); if ( ! empty( $sql ) ) { $retval['sql'] = $sql; } } if ( ! empty( $override ) ) { $retval['override'] = $override; } return $retval; }
更新日志
版本 | 描述 |
---|---|
BuddyBoss 1.4.0 | 介绍了。 |