Ticket #31383: User WP_Tax_Query support.patch
File User WP_Tax_Query support.patch, 3.4 KB (added by , 9 years ago) |
---|
-
wp-includes/user.php
455 455 */ 456 456 public $query_vars = array(); 457 457 458 public $tax_query = array(); 459 458 460 /** 459 461 * List of found user ids 460 462 * … … 569 571 'meta_key' => '', 570 572 'meta_value' => '', 571 573 'meta_compare' => '', 574 'tax_query' => '', 572 575 'include' => array(), 573 576 'exclude' => array(), 574 577 'search' => '', … … 619 622 $this->query_from = "FROM $wpdb->users"; 620 623 $this->query_where = "WHERE 1=1"; 621 624 625 //Handle taxonomy queries 626 $this->parse_tax_query( $qv ); 627 628 $clauses = $this->tax_query->get_sql( $wpdb->users, 'ID' ); 629 630 $this->query_from .= $clauses['join']; 631 $this->query_where .= $clauses['where']; 632 622 633 // Parse and sanitize 'include', for use by 'orderby' as well as 'include' below. 623 634 if ( ! empty( $qv['include'] ) ) { 624 635 $include = wp_parse_id_list( $qv['include'] ); … … 812 823 do_action_ref_array( 'pre_user_query', array( &$this ) ); 813 824 } 814 825 826 public function parse_tax_query( &$q ) { 827 828 if ( ! empty( $q['tax_query'] ) && is_array( $q['tax_query'] ) ) { 829 $tax_query = $q['tax_query']; 830 } else { 831 $tax_query = array(); 832 } 833 834 if ( ! empty( $q['taxonomy'] ) && ! empty( $q['term'] ) ) { 835 $tax_query[] = array( 836 'taxonomy' => $q['taxonomy'], 837 'terms' => array( $q['term'] ), 838 'field' => 'slug', 839 ); 840 } 841 842 foreach ( get_taxonomies( array() , 'objects' ) as $taxonomy => $t ) { 843 if ( $t->query_var && ! empty( $q[ $t->query_var ] ) ) { 844 $tax_query_defaults = array( 845 'taxonomy' => $taxonomy, 846 'field' => 'slug', 847 ); 848 849 if ( isset( $t->rewrite['hierarchical'] ) && $t->rewrite['hierarchical'] ) { 850 $q[ $t->query_var ] = wp_basename( $q[ $t->query_var ] ); 851 } 852 853 $term = $q[ $t->query_var ]; 854 855 if ( strpos( $term, '+' ) !== false ) { 856 $terms = preg_split( '/[+]+/', $term ); 857 foreach ( $terms as $term ) { 858 $tax_query[] = array_merge( $tax_query_defaults, array( 859 'terms' => array( $term ) 860 ) ); 861 } 862 } else { 863 $tax_query[] = array_merge( $tax_query_defaults, array( 864 'terms' => preg_split( '/[,]+/', $term ) 865 ) ); 866 } 867 } 868 } 869 870 $this->tax_query = new WP_Tax_Query( $tax_query ); 871 872 /** 873 * Fires after taxonomy-related query vars have been parsed. 874 * 875 * @since 876 * 877 * @param WP_Query $this The WP_Query instance. 878 */ 879 do_action( 'parse_user_tax_query', $this ); 880 } 881 815 882 /** 816 883 * Execute the query, with the current variables. 817 884 * -
wp-admin/menu.php
213 213 } 214 214 215 215 $submenu['users.php'][15] = array(__('Your Profile'), 'read', 'profile.php'); 216 217 foreach ( get_taxonomies( array(), 'objects' ) as $tax ) { 218 if ( ! $tax->show_ui || ! $tax->show_in_menu || ! in_array( 'user', (array) $tax->object_type, true ) ) { 219 continue; 220 } 221 222 $i = 20; 223 224 $submenu['users.php'][ $i++ ] = array( esc_attr( $tax->labels->menu_name ), $tax->cap->manage_terms, 'edit-tags.php?taxonomy=' . $tax->name ); 225 } 226 unset( $tax ); 216 227 } else { 217 228 $_wp_real_parent_file['users.php'] = 'profile.php'; 218 229 $submenu['profile.php'][5] = array(__('Your Profile'), 'read', 'profile.php');