Ticket #15871: 15871.3.diff
File 15871.3.diff, 5.5 KB (added by , 14 years ago) |
---|
-
wp-includes/user.php
481 481 $this->query_where .= $this->get_search_sql( $search, $search_columns, $wild ); 482 482 } 483 483 484 $blog_id = absint( $qv['blog_id'] ); 485 486 // @todo This should use get_meta_sql() once it handles 0 as a meta_value. See #15871 487 if ( 'authors' == $qv['who'] && $blog_id ) { 488 $qv['meta_key'] = $wpdb->get_blog_prefix( $blog_id ) . 'user_level'; 489 $qv['meta_value'] = '_wp_zero_value'; // Hack to pass '0' 490 $qv['meta_compare'] = '!='; 491 $qv['blog_id'] = $blog_id = 0; // Prevent extra meta query 492 } 493 484 494 _parse_meta_query( $qv ); 485 495 486 496 $role = trim( $qv['role'] ); 487 $blog_id = absint( $qv['blog_id'] );488 497 489 498 if ( $blog_id && ( $role || is_multisite() ) ) { 490 499 $cap_meta_query = array(); … … 949 958 * <ol> 950 959 * <li>show_option_all - Text to show all and whether HTML option exists.</li> 951 960 * <li>show_option_none - Text for show none and whether HTML option exists.</li> 961 * <li>show_option_gt_one - Generate the dropdown only if more than one user is listed.</li> 952 962 * <li>orderby - SQL order by clause for what order the users appear. Default is 'display_name'.</li> 953 963 * <li>order - Default is 'ASC'. Can also be 'DESC'.</li> 954 964 * <li>include - User IDs to include.</li> … … 961 971 * <li>id - Default is the value of the 'name' parameter. ID attribute of select element.</li> 962 972 * <li>class - Class attribute of select element.</li> 963 973 * <li>blog_id - ID of blog (Multisite only). Defaults to ID of current blog.</li> 974 * <li>who - Which users to query. Currently only 'authors' is supported. Default is all users.</li> 964 975 * </ol> 965 976 * 966 977 * @since 2.3.0 … … 970 981 * @return string|null Null on display. String of HTML content on retrieve. 971 982 */ 972 983 function wp_dropdown_users( $args = '' ) { 973 global $wpdb;974 984 $defaults = array( 975 'show_option_all' => '', 'show_option_none' => '', 985 'show_option_all' => '', 'show_option_none' => '', 'show_option_gt_one' => '', 976 986 'orderby' => 'display_name', 'order' => 'ASC', 977 987 'include' => '', 'exclude' => '', 'multi' => 0, 978 988 'show' => 'display_name', 'echo' => 1, 979 'selected' => 0, 'name' => 'user', 'class' => '', ' blog_id' => $GLOBALS['blog_id'],980 ' id' => '',989 'selected' => 0, 'name' => 'user', 'class' => '', 'id' => '', 990 'blog_id' => $GLOBALS['blog_id'], 'who' => '' 981 991 ); 982 992 983 993 $defaults['selected'] = is_author() ? get_query_var( 'author' ) : 0; … … 985 995 $r = wp_parse_args( $args, $defaults ); 986 996 extract( $r, EXTR_SKIP ); 987 997 988 $query_args = wp_array_slice_assoc( $r, array( 'blog_id', 'include', 'exclude', 'orderby', 'order' ) );998 $query_args = wp_array_slice_assoc( $r, array( 'blog_id', 'include', 'exclude', 'orderby', 'order', 'who' ) ); 989 999 $query_args['fields'] = array( 'ID', $show ); 990 991 1000 $users = get_users( $query_args ); 992 1001 993 1002 $output = ''; 994 if ( !empty($users) ) {1003 if ( !empty($users) && ( empty($show_option_gt_one) || count($users) > 1 ) ) { 995 1004 $name = esc_attr( $name ); 996 1005 if ( $multi && ! $id ) 997 1006 $id = ''; -
wp-includes/meta.php
433 433 } else { 434 434 $meta_compare_string = '%s'; 435 435 } 436 437 // @todo Temporary hack to support empty values. Do not use outside of core. 438 if ( '_wp_zero_value' == $meta_value ) 439 $meta_value = 0; 440 436 441 $where .= $wpdb->prepare( " AND CAST($alias.meta_value AS {$meta_type}) {$meta_compare} {$meta_compare_string}", $meta_value ); 437 442 } 438 443 -
wp-admin/includes/class-wp-posts-list-table.php
757 757 <?php touch_time( 1, 1, 4, 1 ); ?> 758 758 </div> 759 759 <br class="clear" /> 760 761 760 <?php endif; // $bulk 762 761 763 762 if ( post_type_supports( $screen->post_type, 'author' ) ) : … … 765 764 766 765 if ( is_super_admin() || current_user_can( $post_type_object->cap->edit_others_posts ) ) : 767 766 $users_opt = array( 767 'show_option_gt_one' => true, 768 'who' => 'authors', 768 769 'name' => 'post_author', 769 770 'class'=> 'authors', 770 771 'multi' => 1, … … 772 773 ); 773 774 if ( $bulk ) 774 775 $users_opt['show_option_none'] = __( '— No Change —' ); 775 $authors_dropdown = '<label>'; 776 $authors_dropdown .= '<span class="title">' . __( 'Author' ) . '</span>'; 777 $authors_dropdown .= wp_dropdown_users( $users_opt ); 778 $authors_dropdown .= '</label>'; 776 777 if ( $authors = wp_dropdown_users( $users_opt ) ) : 778 $authors_dropdown = '<label>'; 779 $authors_dropdown .= '<span class="title">' . __( 'Author' ) . '</span>'; 780 $authors_dropdown .= $authors; 781 $authors_dropdown .= '</label>'; 782 endif; 779 783 endif; // authors 780 784 ?> 781 785 -
wp-admin/includes/meta-boxes.php
530 530 */ 531 531 function post_author_meta_box($post) { 532 532 global $user_ID; 533 534 533 ?> 535 534 <label class="screen-reader-text" for="post_author_override"><?php _e('Author'); ?></label> 536 535 <?php 537 536 wp_dropdown_users( array( 537 'who' => 'authors', 538 538 'name' => 'post_author_override', 539 539 'selected' => empty($post->ID) ? $user_ID : $post->post_author 540 540 ) );