static function pre_user_query($query) { global $wpdb; $q =& $query->query_vars; P2P_Query::expand_shortcut_qv($q); if (isset($q['connected_items'])) { $item = $q['connected_items']; } else { $item = 'any'; } $r = P2P_Query::expand_connected_type($q, $item, 'user'); if (false === $r) { $query->query_where = " AND 1=0"; return; } // alter query $qv = P2P_Query::get_qv($q); if (!$qv) { return; } $map = array('fields' => 'query_fields', 'join' => 'query_from', 'where' => 'query_where', 'orderby' => 'query_orderby'); $clauses = array(); foreach ($map as $clause => $key) { $clauses[$clause] = $query->{$key}; } $clauses = P2P_Query::alter_clauses($clauses, $qv, "{$wpdb->users}.ID"); if (0 !== strpos($clauses['orderby'], 'ORDER BY ')) { $clauses['orderby'] = 'ORDER BY ' . $clauses['orderby']; } foreach ($map as $clause => $key) { $query->{$key} = $clauses[$clause]; } }
static function parse_query($wp_query) { $q =& $wp_query->query_vars; P2P_Query::expand_shortcut_qv($q); if (isset($q['connected_items'])) { $item = $q['connected_items']; } else { $item = isset($q['post_type']) ? $q['post_type'] : 'post'; } $r = P2P_Query::expand_connected_type($q, $item, 'post'); if (false === $r) { $q = array('year' => 2525); } elseif ($r) { $wp_query->is_home = false; $wp_query->is_archive = true; } }
function parse_query($wp_query) { $q =& $wp_query->query_vars; P2P_Query::expand_shortcut_qv($q); if (!isset($q['connected_items'])) { return; } if (!isset($q['connected_type'])) { return; } $r = self::expand_connected_type($q); if (false === $r) { $q = array('year' => 2525); } elseif ($r) { $wp_query->is_home = false; $wp_query->is_archive = true; } }