BP_XProfile_Meta_Query::parse_query_vars( array $qv )
Constructs a meta query based on ‘meta_*’ query vars.
Description
Parameters
- $qv
-
(Required) The query variables.
Source
File: bp-xprofile/classes/class-bp-xprofile-meta-query.php
47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 | public function parse_query_vars( $qv ) { $meta_query = array (); /* * For orderby=meta_value to work correctly, simple query needs to be * first (so that its table join is against an unaliased meta table) and * needs to be its own clause (so it doesn't interfere with the logic of * the rest of the meta_query). */ $primary_meta_query = array (); foreach ( array ( 'key' , 'compare' , 'type' ) as $key ) { if ( ! empty ( $qv [ "meta_$key" ] ) ) { $primary_meta_query [ $key ] = $qv [ "meta_$key" ]; } } // WP_Query sets 'meta_value' = '' by default. if ( isset( $qv [ 'meta_value' ] ) && ( '' !== $qv [ 'meta_value' ] ) && ( ! is_array ( $qv [ 'meta_value' ] ) || $qv [ 'meta_value' ] ) ) { $primary_meta_query [ 'value' ] = $qv [ 'meta_value' ]; } // BP_XProfile_Query sets 'object_type' = '' by default. if ( isset( $qv [ 'object_type' ] ) && ( '' !== $qv [ 'object_type' ] ) && ( ! is_array ( $qv [ 'object_type' ] ) || $qv [ 'object_type' ] ) ) { $meta_query [0][ 'object' ] = $qv [ 'object_type' ]; } $existing_meta_query = isset( $qv [ 'meta_query' ] ) && is_array ( $qv [ 'meta_query' ] ) ? $qv [ 'meta_query' ] : array (); if ( ! empty ( $primary_meta_query ) && ! empty ( $existing_meta_query ) ) { $meta_query = array ( 'relation' => 'AND' , $primary_meta_query , $existing_meta_query , ); } elseif ( ! empty ( $primary_meta_query ) ) { $meta_query = array ( $primary_meta_query , ); } elseif ( ! empty ( $existing_meta_query ) ) { $meta_query = $existing_meta_query ; } $this ->__construct( $meta_query ); } |
Changelog
Version | Description |
---|---|
BuddyPress 2.3.0 | Introduced. |
Questions?
We're always happy to help with code or other questions you might have! Search our developer docs, contact support, or connect with our sales team.