BP_Media:: get_scope_query_sql (混合美元的范围数组$ r数组()

获取' scope '参数的SQLBP_Media: get ()

描述

范围是一组预先确定的媒体参数。此方法用于获取这些媒体参数,并在需要时覆盖任何现有参数。

可以处理多个作用域。

参数

美元的范围

混合(可选)媒体的范围。接受范围的字符串或数组。

默认值:假

$ r

数组(可选)当前活动的观点。和BP_Media: get (),但与默认值合并。

默认值:数组()

返回

(假|数组)'sql' WHERE sql字符串和'override'媒体参数。

文件:bp-media /类/ class-bp-media.php

public static function get_scope_query_sql($scope = false, $r = array()){//定义数组以备将来使用。数组$ query_args = ();$覆盖=数组();数组$ retval = ();//检查数组的作用域。If (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 media arguments for custom scopes. * * This is a dynamic filter based on the media scope. eg: * - 'bp_media_set_groups_scope_args' * - 'bp_media_set_friends_scope_args' * * To see how this filter is used, plugin devs should check out: * - bp_groups_filter_media_scope() - used for 'groups' scope * - bp_friends_filter_media_scope() - used for 'friends' scope * * @since BuddyBoss 1.1.9 * * @param array { * Media query clauses. * @type array { * Media arguments for your custom scope. * See {@link BP_Media_Query::_construct()} for more details. * } * @type array $override Optional. Override existing media arguments passed by $r. * } * } * @param array $r Current activity arguments passed in BP_Media::get(). */ $scope_args = apply_filters( "bp_media_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 ) ) { if ( count( $scopes ) > 1 ) { // Set relation to OR. $query_args['relation'] = 'OR'; } else { // Set relation to OR. $query_args['relation'] = 'AND'; } $query = new BP_Media_Query( $query_args ); $sql = $query->get_sql(); if ( ! empty( $sql ) ) { $retval['sql'] = $sql; } } if ( ! empty( $override ) ) { $retval['override'] = $override; } return $retval; }

更新日志

更新日志
版本 描述
BuddyBoss 1.1.9 介绍了。

问题吗?

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