BP_Activity_Activity:: get_scope_query_sql (混合美元的范围=假,数组$ r=数组())
获取' scope '参数的SQLBP_Activity_Activity: get ().
描述
范围是一组预先确定的活动参数。此方法用于获取这些活动参数,并在需要时覆盖任何现有参数。
可以处理多个作用域。
参数
- 美元的范围
-
(混合)(可选)活动范围。接受范围的字符串或数组。
默认值:假
- $ r
-
(数组)(可选)当前活动的观点。和BP_Activity_Activity: get (),但与默认值合并。
默认值:数组()
返回
(假|数组)'sql' WHERE sql字符串和'override'活动参数。
源
文件:bp-activity /类/ class-bp-activity-activity.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 activity arguments for custom scopes. * * This is a dynamic filter based on the activity scope. eg: * - 'bp_activity_set_groups_scope_args' * - 'bp_activity_set_friends_scope_args' * * To see how this filter is used, plugin devs should check out: * - bp_groups_filter_activity_scope() - used for 'groups' scope * - bp_friends_filter_activity_scope() - used for 'friends' scope * * @since BuddyPress 2.2.0 * * @param array { * Activity query clauses. * @type array { * Activity arguments for your custom scope. * See {@link BP_Activity_Query::_construct()} for more details. * } * @type array $override Optional. Override existing activity arguments passed by $r. * } * } * @param array $r Current activity arguments passed in BP_Activity_Activity::get(). */ $scope_args = apply_filters( "bp_activity_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_Activity_Query( $query_args ); $sql = $query->get_sql(); if ( ! empty( $sql ) ) { $retval['sql'] = $sql; } } if ( ! empty( $override ) ) { $retval['override'] = $override; } return $retval; }
更新日志
版本 | 描述 |
---|---|
BuddyPress 2.2.0 | 介绍了。 |