WordPress.org

Make WordPress Core

Changeset 5587


Ignore:
Timestamp:
05/29/07 04:28:10 (7 years ago)
Author:
ryan
Message:

Post and page management filter additions from mdawaffe. see #3945

Location:
trunk
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-admin/edit-form-advanced.php

    r5543 r5587  
    117117 
    118118<?php  
    119 $authors = get_editable_authors( $current_user->id ); // TODO: ROLE SYSTEM 
     119$authors = get_editable_user_ids( $current_user->id ); // TODO: ROLE SYSTEM 
    120120if ( $authors && count( $authors ) > 1 ) : 
    121121?> 
     
    123123<h3 class="dbx-handle"><?php _e('Post Author'); ?></h3> 
    124124<div class="dbx-content"> 
    125 <select name="post_author_override" id="post_author_override"> 
    126 <?php 
    127 foreach ($authors as $o) : 
    128 $o = get_userdata( $o->ID ); 
    129 if ( $post->post_author == $o->ID || ( empty($post_ID) && $user_ID == $o->ID ) ) $selected = 'selected="selected"'; 
    130 else $selected = ''; 
    131 echo "<option value='" . (int) $o->ID . "' $selected>" . wp_specialchars( $o->display_name ) . "</option>"; 
    132 endforeach; 
    133 ?> 
    134 </select> 
     125<?php wp_dropdown_users( array('include' => $authors, 'name' => 'post_author_override', 'selected' => empty($post_ID) ? $user_ID : $post->post_author) ); ?> 
    135126</div> 
    136127</fieldset> 
  • trunk/wp-admin/edit-pages.php

    r5583 r5587  
    1414 
    1515$post_status_label = _c('Pages|manage pages header'); 
    16 $post_listing_pageable = true; 
    1716$post_status_q = ''; 
    1817if ( isset($_GET['post_status']) && in_array( $_GET['post_status'], array_keys($post_stati) ) ) { 
    1918    $post_status_label = $post_stati[$_GET['post_status']][1]; 
    20     $post_listing_pageable = false; 
    2119    $post_status_q = '&post_status=' . $_GET['post_status']; 
    22     if ( 'publish' == $_GET['post_status'] ); 
    23         $post_listing_pageable = true; 
    2420} 
    2521 
     
    3127// Use $_GET instead of is_ since they can override each other 
    3228$h2_search = isset($_GET['s']) && $_GET['s'] ? ' ' . sprintf(__('matching &#8220;%s&#8221;'), wp_specialchars( stripslashes( $_GET['s'] ) ) ) : ''; 
    33 printf( _c( '%1$s%2$s|manage pages header' ), $post_status_label, $h2_search ); 
     29$h2_author = ''; 
     30if ( isset($_GET['author']) && $_GET['author'] ) { 
     31    $author_user = get_userdata( (int) $_GET['author'] ); 
     32    $h2_author = ' ' . sprintf(__('by %s'), wp_specialchars( $author_user->display_name )); 
     33} 
     34printf( _c( '%1$s%2$s%3$s|manage pages header' ), $post_status_label, $h2_author, $h2_search ); 
    3435?></h2> 
    3536 
     
    5051        </select> 
    5152    </fieldset> 
     53 
     54<?php $editable_ids = get_editable_user_ids( $user_ID ); if ( $editable_ids && count( $editable_ids ) > 1 ) : ?> 
     55 
     56    <fieldset><legend><?php _e('Author&hellip;'); ?></legend> 
     57        <?php wp_dropdown_users( array('include' => $editable_ids, 'show_option_all' => __('Any'), 'name' => 'author', 'selected' => isset($_GET['author']) ? $_GET['author'] : 0) ); ?> 
     58    </fieldset> 
     59 
     60<?php endif; ?> 
    5261 
    5362    <input type="submit" id="post-query-submit" value="<?php _e('Filter &#187;'); ?>" class="button" /> 
  • trunk/wp-admin/edit.php

    r5583 r5587  
    1717 
    1818$post_status_q = ''; 
    19 $author_q = ''; 
    2019$post_status_label = _c('Posts|manage posts header'); 
    21 $post_listing_pageable = true; 
    2220if ( isset($_GET['post_status']) && in_array( $_GET['post_status'], array_keys($post_stati) ) ) { 
    2321    $post_status_label = $post_stati[$_GET['post_status']][1]; 
    24     $post_listing_pageable = false; 
    2522    $post_status_q = '&post_status=' . $_GET['post_status']; 
    26     if ( in_array( $_GET['post_status'], array('draft', 'private') ) ) 
    27         $author_q = "&author=$user_ID"; 
    28     elseif ( 'publish' == $_GET['post_status'] ); 
    29         $post_listing_pageable = true; 
    3023} 
    3124?> 
     
    3528<?php 
    3629 
    37 wp("what_to_show=posts$author_q$post_status_q&posts_per_page=15&posts_per_archive_page=-1"); 
     30wp("what_to_show=posts$post_status_q&posts_per_page=15"); 
    3831 
    3932do_action('restrict_manage_posts'); 
     
    6659        $h2_noun = $post_status_label; 
    6760    // Use $_GET instead of is_ since they can override each other 
     61    $h2_author = ''; 
     62    if ( isset($_GET['author']) && $_GET['author'] ) { 
     63        $author_user = get_userdata( get_query_var( 'author' ) ); 
     64        $h2_author = ' ' . sprintf(__('by %s'), wp_specialchars( $author_user->display_name )); 
     65    } 
    6866    $h2_search = isset($_GET['s'])   && $_GET['s']   ? ' ' . sprintf(__('matching &#8220;%s&#8221;'), wp_specialchars( get_search_query() ) ) : ''; 
    6967    $h2_cat    = isset($_GET['cat']) && $_GET['cat'] ? ' ' . sprintf( __('in &#8220;%s&#8221;'), single_cat_title('', false) ) : ''; 
    7068    $h2_month  = isset($_GET['m'])   && $_GET['m']   ? ' ' . sprintf( __('during %s'), single_month_title(' ', false) ) : ''; 
    71     printf( _c( '%1$s%2$s%3$s%4$s|manage posts header' ), $h2_noun, $h2_search, $h2_cat, $h2_month ); 
     69    printf( _c( '%1$s%2$s%3$s%4$s%5$s|manage posts header' ), $h2_noun, $h2_author, $h2_search, $h2_cat, $h2_month ); 
    7270} 
    7371?></h2> 
     
    8785    </fieldset> 
    8886 
     87<?php  
     88$editable_ids = get_editable_user_ids( $user_ID ); 
     89if ( $editable_ids && count( $editable_ids ) > 1 ) : 
     90?> 
     91    <fieldset><legend><?php _e('Author&hellip;'); ?></legend> 
     92        <?php wp_dropdown_users( array('include' => $editable_ids, 'show_option_all' => __('Any'), 'name' => 'author', 'selected' => isset($_GET['author']) ? $_GET['author'] : 0) ); ?> 
     93    </fieldset> 
     94 
    8995<?php 
    90  
     96endif; 
    9197 
    9298$arc_query = "SELECT DISTINCT YEAR(post_date) AS yyear, MONTH(post_date) AS mmonth FROM $wpdb->posts WHERE post_type = 'post' ORDER BY post_date DESC"; 
     
    130136<br style="clear:both;" /> 
    131137 
    132 <?php 
    133 if ( $post_status_q && ( false !== strpos($post_status_q, 'draft') || false !== strpos($post_status_q, 'private') ) ) { 
    134     echo '<h3>' . __('Your Posts') . "</h3>\n"; 
    135     include( 'edit-post-rows.php' ); 
    136  
    137     $editable_ids = get_editable_user_ids( $user_ID ); 
    138  
    139     if ( $editable_ids && count($editable_ids) > 1 ) { 
    140         $_editable_ids = join(',', array_diff($editable_ids, array($user_ID))); 
    141  
    142         $post_status_q = "&post_status=" . $_GET['post_status']; 
    143  
    144         unset($GLOBALS['day']); // setup_postdata does this 
    145         wp("what_to_show=posts&author=$_editable_ids$post_status_q&posts_per_page=-1&posts_per_archive_page=-1"); 
    146  
    147         if ( have_posts() ) { 
    148             echo '<h3>' . __("Others' Posts") . "</h3>\n"; 
    149             include( 'edit-post-rows.php' ); 
    150         } 
    151     } 
    152  
    153 } else { 
    154     include( 'edit-post-rows.php' ); 
    155 } 
    156 ?> 
     138<?php include( 'edit-post-rows.php' ); ?> 
    157139 
    158140<div id="ajax-response"></div> 
  • trunk/wp-admin/includes/upload.php

    r5542 r5587  
    285285 
    286286function wp_upload_tab_browse() { 
    287     global $wpdb, $action, $paged; 
     287    global $action, $paged; 
    288288    $old_vars = compact( 'paged' ); 
    289289 
     
    302302        if ( 'browse' == $tab && $post_id ) 
    303303            add_filter( 'posts_where', 'wp_upload_posts_where' ); 
    304         $attachments = query_posts("what_to_show=posts&posts_per_page=10&paged=$paged"); 
    305         $count_query = "SELECT COUNT(*) FROM $wpdb->posts WHERE post_type = 'attachment'"; 
    306         if ( $post_id ) 
    307             $count_query .= " AND post_parent = '$post_id'"; 
    308             $total =  $wpdb->get_var($count_query); 
     304        $attachments = query_posts("what_to_show=posts&post_status=any&posts_per_page=10&paged=$paged"); 
    309305 
    310306        echo "<ul id='upload-files'>\n"; 
  • trunk/wp-includes/user.php

    r5194 r5587  
    180180} 
    181181 
     182function wp_dropdown_users( $args = '' ) { 
     183    global $wpdb; 
     184    $defaults = array( 
     185        'show_option_all' => '', 'show_option_none' => '', 
     186        'orderby' => 'display_name', 'order' => 'ASC', 
     187        'include' => '', 'exclude' => '', 
     188        'show' => 'display_name', 'echo' => 1, 
     189        'selected' => 0, 'name' => 'user', 'class' => '' 
     190    ); 
     191     
     192    $defaults['selected'] = is_author() ? get_query_var( 'author' ) : 0; 
     193     
     194    $r = wp_parse_args( $args, $defaults ); 
     195    extract( $r ); 
     196 
     197    $query = "SELECT * FROM $wpdb->users"; 
     198 
     199    $query_where = array(); 
     200 
     201    if ( is_array($include) ) 
     202        $include = join(',', $include); 
     203    $include = preg_replace('/[^0-9,]/', '', $include); // (int) 
     204    if ( $include ) 
     205        $query_where[] = "ID IN ($include)"; 
     206 
     207    if ( is_array($exclude) ) 
     208        $exclude = join(',', $exclude); 
     209    $exclude = preg_replace('/[^0-9,]/', '', $exclude); // (int) 
     210    if ( $exclude ) 
     211        $query_where[] = "ID NOT IN ($exclude)"; 
     212 
     213    if ( $query_where ) 
     214        $query .= " WHERE " . join(' AND', $query_where); 
     215 
     216    $query .= " ORDER BY $orderby $order"; 
     217 
     218    $users = $wpdb->get_results( $query ); 
     219 
     220    $output = ''; 
     221    if ( !empty($users) ) { 
     222        $output = "<select name='$name' id='$name' class='$class'>\n"; 
     223 
     224        if ( $show_option_all ) 
     225            $output .= "\t<option value='0'>$show_option_all</option>\n"; 
     226 
     227        if ( $show_option_none ) 
     228            $output .= "\t<option value='-1'>$show_option_none</option>\n"; 
     229 
     230        foreach ( $users as $user ) { 
     231            $user->ID = (int) $user->ID; 
     232            $_selected = $user->ID == $selected ? " selected='selected'" : ''; 
     233            $output .= "\t<option value='$user->ID'$_selected>" . wp_specialchars($user->$show) . "</option>\n"; 
     234        } 
     235 
     236        $output .= "</select>"; 
     237    } 
     238 
     239    $output = apply_filters('wp_dropdown_users', $output); 
     240 
     241    if ( $echo ) 
     242        echo $output; 
     243 
     244    return $output; 
     245} 
     246 
    182247?> 
Note: See TracChangeset for help on using the changeset viewer.