Make WordPress Core


Ignore:
Timestamp:
09/25/2008 01:42:34 PM (18 years ago)
Author:
azaozz
Message:

Batch editing, first cut, see #6815

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-admin/includes/template.php

    r8967 r8973  
    623623        $col_count = count($columns) - $hidden_count;
    624624        $m = ( isset($mode) && 'excerpt' == $mode ) ? 'excerpt' : 'list';
    625         ?>
    626         <tr title="<?php _e('Double-click to cancel'); ?>" id="inline-edit" style="display: none"><td colspan="<?php echo $col_count; ?>">
     625        $can_publish = current_user_can('publish_posts'); ?>
     626
     627<form method="get" action=""><table style="display: none"><tbody id="inlineedit">
     628        <?php
     629        $bulk = 0;
     630        while ( $bulk < 2 ) { ?>
     631       
     632        <tr title="<?php _e('Double-click to cancel'); ?>" id="<?php echo $bulk ? 'bulk-edit' : 'inline-edit'; ?>" style="display: none"><td colspan="<?php echo $col_count; ?>">
    627633        <?php
    628634        foreach($columns as $column_name=>$column_display_name) {
    … …  
    641647                        case 'modified':
    642648                        case 'date':
    643                         ?>
     649                                if ( ! $bulk ) { ?>
    644650                                <div <?php echo $attributes; ?> title="<?php _e('Timestamp'); ?>">
    645651                                        <div class="title"><?php _e('Timestamp'); ?></div>
    … …  
    649655                                </div>
    650656                                <?php
     657                                }
    651658                                break;
    652659
    653660                        case 'title':
    654661                                $attributes = "class=\"$type-title column-title quick-edit-div\"" . $style; ?>
     662                                <?php if ( $bulk ) { ?>
     663                                <div <?php echo $attributes; ?> id="bulk-title-div" title="<?php $is_page ? _e('Selected pages') : _e('Selected posts'); ?>">
     664                                        <div class="title"><?php $is_page ? _e('Selected pages') : _e('Selected posts'); ?></div>
     665                                        <div class="in">
     666                                        <div id="bulk-titles"></div>
     667                                        </div>
     668                                </div>
     669                                <?php } else { ?>
    655670                                <div <?php echo $attributes ?>>
    656671                                        <div class="title"><?php _e('Title'); ?></div>
    … …  
    661676                                        </div>
    662677                                </div>
     678                                <?php } ?>
     679
    663680                                <?php if ( $is_page ) { ?>
    664681                                <div class="parent quick-edit-div" title="<?php _e('Page Parent'); ?>">
    … …  
    666683                                        <div class="in">
    667684                                        <select name="post_parent">
     685                                                <?php if ( $bulk ) { ?>
     686                                                <option value=""><?php _e('- No Change -'); ?></option>
     687                                                <?php } ?>
    668688                                                <option value="0"><?php _e('Main Page (no parent)'); ?></option>
    669689                                                <?php parent_dropdown(); ?>
    … …  
    671691                                        </div>
    672692                                </div>
     693
    673694                                <div class="template quick-edit-div" title="<?php _e('Page Template'); ?>">
    674695                                        <div class="title"><?php _e('Page Template'); ?></div>
    675696                                        <div class="in">
    676697                                        <select name="page_template">
    677                                                 <option value='default'><?php _e('Default Template'); ?></option>
     698                                                <?php if ( $bulk ) { ?>
     699                                                <option value=""><?php _e('- No Change -'); ?></option>
     700                                                <?php } ?>
     701                                                <option value="default"><?php _e('Default Template'); ?></option>
    678702                                                <?php page_template_dropdown() ?>
    679703                                        </select>
    680704                                        </div>
    681705                                </div>
     706
     707                                <?php if ( ! $bulk ) { ?>
    682708                                <div class="order quick-edit-div" title="<?php _e('Page Order'); ?>">
    683709                                        <div class="title"><?php _e('Page Order'); ?></div>
    … …  
    687713                                </div>
    688714                                <?php }
     715                                }
    689716
    690717                                break;
    691718
    692719                        case 'categories': ?>
     720                                <?php if ( ! $bulk ) { ?>
    693721                                <div <?php echo $attributes ?> title="<?php _e('Categories'); ?>">
    694722                                        <div class="title"><?php _e('Categories'); ?>
    … …  
    699727                                        </ul>
    700728                                </div>
    701                                 <?php
     729                                <?php }
    702730                                break;
    703731
    704732                        case 'tags': ?>
     733                                <?php if ( ! $bulk ) { ?>
    705734                                <div <?php echo $attributes ?> title="<?php _e('Tags'); ?>">
    706735                                        <div class="title"><?php _e('Tags'); ?></div>
    … …  
    709738                                        </div>
    710739                                </div>
    711                                 <?php
     740                                <?php }
    712741                                break;
    713742
    714743                        case 'comments':
    715                                 $attributes = 'class="comments column-comments num quick-edit-div"' . $style; ?>
     744                                ?>
    716745                                <div <?php echo $attributes ?> title="<?php _e('Comments and Pings'); ?>">
    717746                                        <div class="title"><?php _e('Comments and Pings'); ?></div>
    718747                                        <div class="in">
     748                                        <?php if ( $bulk ) { ?>
     749                                        <select name="comment_status">
     750                                                <option value=""><?php _e('- No Change -'); ?></option>
     751                                                <option value="open"><?php _e('Allow Comments'); ?></option>
     752                                                <option value="closed"><?php _e('Disallow Comments'); ?></option>
     753                                        </select>
     754                                        <select name="ping_status">
     755                                                <option value=""><?php _e('- No Change -'); ?></option>
     756                                                <option value="open"><?php _e('Allow Pings'); ?></option>
     757                                                <option value="closed"><?php _e('Disallow Pings'); ?></option>
     758                                        </select>
     759                                        <?php } else { ?>
    719760                                        <label><input type="checkbox" name="comment_status" value="open" />
    720761                                        <?php _e('Allow Comments'); ?></label><br />
    721762                                        <label><input type="checkbox" name="ping_status" value="open" />
    722763                                        <?php _e('Allow Pings'); ?></label>
     764                                        <?php } ?>
    723765                                        </div>
    724766                                </div>
    … …  
    732774                                        <div class="title"><?php _e('Author'); ?></div>
    733775                                        <div class="in">
    734                                         <?php wp_dropdown_users( array('include' => $authors, 'name' => 'post_author', 'class'=> 'authors', 'selected' => $post->post_author) ); ?>
     776                                        <?php
     777                                        $users_opt = array('include' => $authors, 'name' => 'post_author', 'class'=> 'authors');
     778                                        if ( $bulk ) $users_opt['show_option_none'] = __('- No Change -');
     779                                        wp_dropdown_users( $users_opt ); ?>
    735780                                        </div>
    736781                                </div>
    737782                                <?php } ?>
    738783
     784                                <?php if ( ! $bulk ) { ?>
    739785                                <div class="password quick-edit-div" title="<?php _e('Password'); ?>">
    740786                                        <div class="title"><?php _e('Password'); ?></div>
    741787                                        <div class="in">
    742                                         <input type="text" name="post_password" value="<?php the_post_password(); ?>" />
     788                                        <input type="text" name="post_password" value="" />
    743789                                        <label title="<?php _e('Privacy'); ?>">
    744790                                        <input type="checkbox" name="keep_private" value="private" <?php checked($post->post_status, 'private'); ?> /> <?php echo $is_page ? __('Keep this page private') : __('Keep this post private'); ?></label>
    745791                                        </div>
    746792                                </div>
    747                                 <?php
     793                                <?php }
    748794                                break;
    749795
    … …  
    753799                                        <div class="in">
    754800                                        <select name="_status">
    755                                                 <?php if ( current_user_can('publish_posts') ) { // Contributors only get "Unpublished" and "Pending Review" ?>
    756                                                 <option value='publish'><?php _e('Published') ?></option>
    757                                                 <option value='future'><?php _e('Scheduled') ?></option>
     801                                                <?php if ( $bulk ) { ?>
     802                                                <option value=""><?php _e('- No Change -'); ?></option>
     803                                                        <?php if ( $can_publish ) { ?>
     804                                                        <option value="private"><?php _e('Private') ?></option>
     805                                                        <?php } ?>
    758806                                                <?php } ?>
    759                                                 <option value='pending'><?php _e('Pending Review') ?></option>
    760                                                 <option value='draft'><?php _e('Unpublished') ?></option>
     807                                                <?php if ( $can_publish ) { // Contributors only get "Unpublished" and "Pending Review" ?>
     808                                                <option value="publish"><?php _e('Published') ?></option>
     809                                                <option value="future"><?php _e('Scheduled') ?></option>
     810                                                <?php } ?>
     811                                                <option value="pending"><?php _e('Pending Review') ?></option>
     812                                                <option value="draft"><?php _e('Unpublished') ?></option>
    761813                                        </select>
    762814                                        </div>
    763815                                </div>
    764816
    765                                 <?php if ( current_user_can( 'edit_others_posts' ) && ! $is_page ) { ?>
     817                                <?php if ( ! $is_page && ! $bulk && current_user_can( 'edit_others_posts' ) ) { ?>
    766818                                <div class="sticky quick-edit-div" <?php echo $style; ?> title="<?php _e('Sticky') ?>">
    767819                                        <div class="title"><?php _e('Sticky'); ?></div>
    … …  
    774826                                break;
    775827
    776                         case 'control_view': ?>
    777                                 <div><a href="<?php the_permalink(); ?>" rel="permalink" class="view"><?php _e('View'); ?></a></div>
    778                                 <?php
    779                                 break;
    780 
    781                         case 'control_edit': ?>
    782                                 <div><?php if ( current_user_can('edit_post',$post->ID) ) { echo "<a href='post.php?action=edit&amp;post=$id' class='edit'>" . __('Edit') . "</a>"; } ?></div>
    783                                 <?php
    784                                 break;
    785 
    786                         case 'control_delete': ?>
    787                                 <div><?php if ( current_user_can('delete_post',$post->ID) ) { echo "<a href='" . wp_nonce_url("post.php?action=delete&amp;post=$id", 'delete-post_' . $post->ID) . "' class='delete'>" . __('Delete') . "</a>"; } ?></div>
    788                                 <?php
    789                                 break;
    790 
    791                         default: ?>
    792                                 <div><?php do_action('manage_posts_custom_column', $column_name, $post->ID); ?></div>
    793                                 <?php
     828                        default:
     829                                if ( $bulk )
     830                                        do_action('bulk_edit_custom_box', $column_name, $type);
     831                                else
     832                                        do_action('quick_edit_custom_box', $column_name, $type);
     833
    794834                                break;
    795835                }
    … …  
    800840                <a accesskey="c" href="#inline-edit" title="<?php _e('Cancel'); ?>" class="button-secondary cancel"><?php _e('Cancel'); ?></a>
    801841                <a accesskey="s" href="#inline-edit" title="<?php _e('Save'); ?>" class="button-secondary save"><?php _e('Save'); ?></a>
    802                 <?php wp_nonce_field( 'inlineeditnonce', '_inline_edit', false ) ?>
     842                <?php if ( ! $bulk ) wp_nonce_field( 'inlineeditnonce', '_inline_edit', false ); ?>
    803843                <input type="hidden" name="post_view" value="<?php echo $m; ?>" />
    804844        </div>
    805845        </td></tr>
     846<?php
     847        $bulk++;
     848        } ?>
     849        </tbody></table></form>
    806850<?php
    807851}
    … …  
    845889
    846890        echo '
    847 <div id="inline_' . $post->ID . '">
    848         <input type="hidden" name="" class="post_title" value="' . $title . '" />
    849         <input type="hidden" name="" class="post_name" value="' . $post->post_name . '" />
    850         <input type="hidden" name="" class="post_author" value="' . $post->post_author . '" />
    851         <input type="hidden" name="" class="comment_status" value="' . $post->comment_status . '" />
    852         <input type="hidden" name="" class="ping_status" value="' . $post->ping_status . '" />
    853         <input type="hidden" name="" class="_status" value="' . $post->post_status . '" />
    854         <input type="hidden" name="" class="jj" value="' . mysql2date( 'd', $post->post_date ) . '" />
    855         <input type="hidden" name="" class="mm" value="' . mysql2date( 'm', $post->post_date ) . '" />
    856         <input type="hidden" name="" class="aa" value="' . mysql2date( 'Y', $post->post_date ) . '" />
    857         <input type="hidden" name="" class="hh" value="' . mysql2date( 'H', $post->post_date ) . '" />
    858         <input type="hidden" name="" class="mn" value="' . mysql2date( 'i', $post->post_date ) . '" />
    859         <input type="hidden" name="" class="post_password" value="' . wp_specialchars($post->post_password, 1) . '" />';
     891<div class="hidden" id="inline_' . $post->ID . '">
     892        <div class="post_title">' . $title . '</div>
     893        <div class="post_name">' . $post->post_name . '</div>
     894        <div class="post_author">' . $post->post_author . '</div>
     895        <div class="comment_status">' . $post->comment_status . '</div>
     896        <div class="ping_status">' . $post->ping_status . '</div>
     897        <div class="_status">' . $post->post_status . '</div>
     898        <div class="jj">' . mysql2date( 'd', $post->post_date ) . '</div>
     899        <div class="mm">' . mysql2date( 'm', $post->post_date ) . '</div>
     900        <div class="aa">' . mysql2date( 'Y', $post->post_date ) . '</div>
     901        <div class="hh">' . mysql2date( 'H', $post->post_date ) . '</div>
     902        <div class="mn">' . mysql2date( 'i', $post->post_date ) . '</div>
     903        <div class="post_password">' . wp_specialchars($post->post_password, 1) . '</div>';
    860904
    861905        if( $post->post_type == 'page' )
    862906                echo '
    863         <input type="hidden" name="" class="post_parent" value="' . $post->post_parent . '" />
    864         <input type="hidden" name="" class="page_template" value="' . wp_specialchars(get_post_meta( $post->ID, '_wp_page_template', true ), 1) . '" />
    865         <input type="hidden" name="" class="menu_order" value="' . $post->menu_order . '" />';
     907        <div class="post_parent">' . $post->post_parent . '</div>
     908        <div class="page_template">' . wp_specialchars(get_post_meta( $post->ID, '_wp_page_template', true ), 1) . '</div>
     909        <div class="menu_order">' . $post->menu_order . '</div>';
    866910       
    867911        if( $post->post_type == 'post' )
    868912                echo '
    869         <input type="hidden" name="" class="tags_input" value="' . wp_specialchars( str_replace( ',', ', ', get_tags_to_edit($post->ID) ), 1) . '" />
    870         <input type="hidden" name="" class="post_category" value="' . implode( ',', wp_get_post_categories( $post->ID ) ) . '" />
    871         <input type="hidden" name="" class="sticky" value="' . (is_sticky($post->ID) ? 'sticky' : '') . '" />';
     913        <div class="tags_input">' . wp_specialchars( str_replace( ',', ', ', get_tags_to_edit($post->ID) ), 1) . '</div>
     914        <div class="post_category">' . implode( ',', wp_get_post_categories( $post->ID ) ) . '</div>
     915        <div class="sticky">' . (is_sticky($post->ID) ? 'sticky' : '') . '</div>';
    872916               
    873917        echo '</div>';
    … …  
    10361080
    10371081                case 'comments':
    1038                         $attributes = 'class="comments column-comments num"' . $style;
    10391082                ?>
    10401083                <td <?php echo $attributes ?>><div class="post-com-count-wrapper">
    … …  
    12111254
    12121255        case 'comments':
    1213                 $attributes = 'class="comments column-comments num"' . $style;
    12141256                ?>
    12151257                <td <?php echo $attributes ?>><div class="post-com-count-wrapper">
Note: See TracChangeset for help on using the changeset viewer.