Make WordPress Core

Ticket #6815: 6815.2.diff

File 6815.2.diff, 28.7 KB (added by aaron_guitar, 18 years ago)

Integration of manageable with saving

  • wp-includes/script-loader.php

     
    241241                ));
    242242
    243243                $scripts->add( 'theme-preview', '/wp-admin/js/theme-preview.js', array( 'thickbox', 'jquery' ), '20080625' );
     244               
     245                $scripts->add( 'inline-edit', '/wp-admin/js/inline-edit.js', array( 'jquery', 'jquery-form', 'suggest' ), '20080812' );
    244246
    245247                $scripts->add( 'plugin-install', '/wp-admin/js/plugin-install.js', array( 'thickbox', 'jquery' ), '20080803' );
    246248                $scripts->localize( 'plugin-install', 'plugininstallL10n', array(
  • wp-admin/admin-ajax.php

     
    1212 * @since unknown
    1313 */
    1414define('DOING_AJAX', true);
     15define('WP_ADMIN', true);
    1516
    1617require_once('../wp-load.php');
    1718require_once('includes/admin.php');
     
    715716        $slug = isset($_POST['new_slug'])? $_POST['new_slug'] : '';
    716717        die(get_sample_permalink_html($post_id, $title, $slug));
    717718break;
     719case 'inline-data':
     720        get_inline_data( explode(',', $_POST['posts']) );
     721        die();
     722break;
     723case 'inline-save':
     724        inline_save_row( $_POST );
     725        if( 'page' == $_POST['post_type'] ) {
     726                $post = query_posts( 'page_id=' . $_POST['post_ID'] );
     727                page_rows( $post );
     728  }
     729        if( 'post' == $_POST['post_type'] ) {
     730                $mode = $_POST['post_view'];
     731                $post = query_posts( 'p=' . $_POST['post_ID'] );
     732                post_rows();
     733        }
     734        die();
     735break;
    718736case 'meta-box-order':
    719737        check_ajax_referer( 'meta-box-order' );
    720738        update_user_option( $GLOBALS['current_user']->ID, "meta-box-order_$_POST[page]", $_POST['order'] );
  • wp-admin/wp-admin.css

     
    21392139.metabox-prefs label input {
    21402140        margin: 0 5px 0 2px;
    21412141}
     2142
     2143
     2144/* Inline Editor */
     2145
     2146.inline {
     2147        font-size: 10px;
     2148}
     2149
     2150.inline td {
     2151        padding-right: 4px;
     2152        padding-left: 7px;
     2153}
     2154
     2155.inline input, .inline select, .inline textarea {
     2156        font-size: 10px !important;
     2157        padding: 2px;
     2158        border: 1px solid #ddd;
     2159}
     2160
     2161.inline td.date {
     2162        width: 87px;
     2163}
     2164
     2165.inline td.page-title {
     2166        width: 495px;
     2167}
     2168
     2169.inline td.post-title input.title {
     2170        width: 250px;
     2171}
     2172
     2173.inline td.post-title input.slug {
     2174        width: 222px;
     2175        float: right;
     2176}
     2177
     2178.inline div.title {
     2179        float: left;
     2180}
     2181
     2182.inline div.title input.title {
     2183        font-size: 12px !important;
     2184}
     2185
     2186.inline div.title label {
     2187        float: left;
     2188        margin-top: 4px;
     2189}
     2190
     2191.inline td.page-title input.slug {
     2192        width: 123px;
     2193        float: right;
     2194}
     2195
     2196.inline div.other, .inline div.more {
     2197        width: 190px;
     2198        float: left;
     2199        padding-left: 5px;
     2200}
     2201
     2202.inline div.other label, .inline div.more label {
     2203        display: block; float: left;
     2204        width: 54px;
     2205        margin-top: 4px;
     2206}
     2207
     2208.inline div.other select {
     2209        width: 133px;
     2210}
     2211
     2212.inline div.more {
     2213        width: 125px;
     2214}
     2215
     2216.inline div.more input {
     2217        width: 60px;
     2218}
     2219
     2220.inline td.author select {
     2221        width: 110px;
     2222}
     2223
     2224.inline ul.categories {
     2225        list-style: none;
     2226        padding: 0; margin: 0;
     2227        height: 65px;
     2228        overflow: auto;
     2229        font-size: 10px;
     2230}
     2231
     2232.inline ul.categories ul.children {
     2233        list-style: none;
     2234        padding-left: 15px;
     2235}
     2236
     2237.inline ul.categories li {
     2238        margin-bottom: 2px;
     2239}
     2240
     2241.inline ul.categories input {
     2242        vertical-align: middle;
     2243        padding: 0; border: 0;
     2244}
     2245
     2246.inline td.tags textarea {
     2247        height: 58px; width: 100%;
     2248}
     2249
     2250.inline td.comments {
     2251        padding-left: 0;
     2252}
     2253
     2254.inline td.status select {
     2255        width: 98px;
     2256}
     2257
     2258.inline td.status input {
     2259        vertical-align: middle;
     2260}
     2261 No newline at end of file
  • wp-admin/includes/taxonomy.php

     
    133133
    134134        foreach ( $tags as $tag )
    135135                $tag_names[] = $tag->name;
    136         $tags_to_edit = join( ',', $tag_names );
     136        $tags_to_edit = join( ', ', $tag_names );
    137137        $tags_to_edit = attribute_escape( $tags_to_edit );
    138138        $tags_to_edit = apply_filters( 'tags_to_edit', $tags_to_edit );
    139139        return $tags_to_edit;
  • wp-admin/includes/template.php

     
    350350                $posts_columns['modified'] = __('Submitted');
    351351        else
    352352                $posts_columns['date'] = __('Date');
    353         //$posts_columns['author'] = __('Author');
     353        $posts_columns['author'] = __('Author');
    354354        $posts_columns['categories'] = __('Categories');
    355355        $posts_columns['tags'] = __('Tags');
    356356        if ( !isset($_GET['post_status']) || !in_array($_GET['post_status'], array('pending', 'draft', 'future')) )
     
    406406        return $posts_columns;
    407407}
    408408
     409function inline_edit_row( $type ) {
     410        global $current_user;
     411
     412        if ( 'post' == $type )
     413                $post = get_default_post_to_edit();
     414        else
     415                $post = get_default_page_to_edit(); 
     416
     417        echo '<tr id="inline-edit" style="display: none">';
     418        $columns = $type == 'post' ? wp_manage_posts_columns() : wp_manage_pages_columns();
     419        foreach($columns as $column_name=>$column_display_name) {
     420
     421                switch($column_name) {
     422
     423                        case 'cb': ?>
     424                          <th class="check-column"></th>
     425                          <?php
     426                          break;
     427
     428                        case 'modified':
     429                        case 'date': ?>
     430                                <td class="date">
     431                                        <?php touch_time(1, 1, 4, 1); ?>
     432                                </td>
     433                                <?php
     434                                break;
     435
     436                        case 'title': ?>
     437                                <td class="<?php echo $type ?>-title">
     438                                        <div class="title">
     439                                                <input type="text" name="post_title" class="title" value="" /><br />
     440                                                <label><?php _e('Slug'); ?></label><input type="text" name="post_name" value="" class="slug" />
     441                                        </div>
     442                                        <?php if($type == 'page'): ?>
     443                                        <div class="other">
     444                                                <label><?php _e('Parent'); ?></label>
     445                                                <select name="post_parent">
     446                                                        <option value="0"><?php _e('Main Page (no parent)'); ?></option>
     447                                                        <?php parent_dropdown(); ?>
     448                                                </select><br />
     449                                                <label><?php _e('Template'); ?></label>
     450                                                <select name="page_template">
     451                                                        <option value='default'><?php _e('Default Template'); ?></option>
     452                                                        <?php page_template_dropdown() ?>
     453                                                </select>
     454                                        </div>
     455                                        <div class="more">
     456                                                <label><?php _e('Order'); ?></label><input type="text" name="menu_order" value="<?php echo $post->menu_order ?>" />
     457                                                <label><?php _e('Password'); ?></label><input type="text" name="post_password" value="<?php echo $post->post_password ?>" />     
     458                                        </div>
     459                                        <?php endif; ?>
     460                                        <div class="clear"></div>
     461                                        <?php
     462                                        $actions = array();
     463                                        $actions['save'] = '<a href="#">' . __('Save') . '</a>';
     464                                        $actions['cancel'] = '<a href="#">' . __('Cancel') . '</a>';
     465                                        $action_count = count($actions);
     466                                        $i = 0;
     467                                        foreach ( $actions as $action => $link ) {
     468                                                ++$i;
     469                                                ( $i == $action_count ) ? $sep = '' : $sep = ' | ';
     470                                                echo "<span class='$action'>$link$sep</span>";
     471                                        }
     472                                        ?>
     473                                </td>
     474                                <?php
     475                                break;
     476
     477                        case 'categories': ?>
     478                                <td class="categories">
     479                                        <ul class="categories">
     480                                                <?php wp_category_checklist() ?>
     481                                        </ul>
     482                                </td>
     483                                <?php
     484                                break;
     485
     486                        case 'tags': ?>
     487                                <td class="tags">
     488                                        <textarea name="tags_input"></textarea>
     489                                </td>
     490                                <?php
     491                                break;
     492
     493                        case 'comments': ?>
     494                                <td class="comments num">
     495                                        <input title="Allow Comments" type="checkbox" name="comment_status" value="open" /><br />
     496                                        <input title="Allow Pings" type="checkbox" name="ping_status" value="open" />
     497                                </td>
     498                                <?php
     499                                break;
     500
     501                        case 'author': ?>
     502                                <td class="author">
     503                                        <?php
     504                                        $authors = get_editable_user_ids( $current_user->id ); // TODO: ROLE SYSTEM
     505                                        if ( $authors && count( $authors ) > 1 ) {
     506                                                wp_dropdown_users( array('include' => $authors, 'name' => 'post_author', 'class'=> 'author', 'selected' => $post->post_author) );
     507                                        } else {
     508                                                echo $current_user->user_nicename.'<input type="hidden" value="'.$post->post_author.'" class="author" />';
     509                                        }
     510                                        ?>
     511                                </td>
     512                                <?php
     513                                break;
     514
     515                        case 'status': ?>
     516                                <td class="status">
     517                                        <select name="post_status">
     518                                                <?php if ( current_user_can('publish_posts') ) : // Contributors only get "Unpublished" and "Pending Review" ?>
     519                                                <option value='publish'><?php _e('Published') ?></option>
     520                                                <option value='future'><?php _e('Scheduled') ?></option>
     521                                                <?php endif; ?>
     522                                                <option value='pending'><?php _e('Pending Review') ?></option>
     523                                                <option value='draft'><?php _e('Unpublished') ?></option>
     524                                        </select>
     525                                        <?php if($type == 'page'): ?>
     526                                        <br /><label><input type="checkbox" name="page_private" value="private" <?php checked($post->post_status, 'private'); ?> /> <?php _e('Private') ?></label></p>
     527                                        <?php else: ?>
     528                                        <?php if ( current_user_can( 'edit_others_posts' ) ) : ?>
     529                                        <br /><label><input type="checkbox" name="sticky" value="sticky" /> <?php _e('Sticky') ?></label></p>
     530                                        <?php endif; ?>
     531                                        <?php endif; ?>
     532                                </td>
     533                                <?php
     534                                break;
     535
     536                        case 'control_view': ?>
     537                                <td><a href="<?php the_permalink(); ?>" rel="permalink" class="view"><?php _e('View'); ?></a></td>
     538                                <?php
     539                                break;
     540
     541                        case 'control_edit': ?>
     542                                <td><?php if ( current_user_can('edit_post',$post->ID) ) { echo "<a href='post.php?action=edit&amp;post=$id' class='edit'>" . __('Edit') . "</a>"; } ?></td>
     543                                <?php
     544                                break;
     545
     546                        case 'control_delete': ?>
     547                                <td><?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>"; } ?></td>
     548                                <?php
     549                                break;
     550
     551                        default: ?>
     552                                <td><?php do_action('manage_posts_custom_column', $column_name, $post->ID); ?></td>
     553                                <?php
     554                                break;
     555                }
     556        }
     557
     558        echo '</tr>';
     559}
     560
     561function inline_save_row( $data ) { 
     562        // get the original post content
     563        $post = get_post( $data['post_ID'], ARRAY_A );
     564        $data['content'] = $post['post_content'];
     565
     566        // statuses
     567        if( 'page' == $data['post_type'] && 'private' == $data['page_private'] )
     568                $data['post_status'] = 'private';
     569        if( empty($data['comment_status']) )
     570                $data['comment_status'] = 'closed';
     571        if( empty($data['ping_status']) )
     572                $data['ping_status'] = 'closed';
     573
     574        // rename
     575        $data['user_ID'] = $GLOBALS['user_ID'];
     576        $data['excerpt'] = $data['post_excerpt'];
     577        $data['trackback_url'] = $data['to_ping'];
     578        $data['parent_id'] = $data['post_parent'];
     579
     580        // update the post
     581        $_POST = $data;
     582        edit_post();
     583}
     584
     585// outputs XML of the post/page data ready for use in the inline editor
     586// accepts array of post IDs
     587function get_inline_data($posts) {
     588        global $post;
     589
     590        header('Content-Type: text/xml; charset=' . get_option('blog_charset'), true);
     591        echo "<?xml version='1.0' ?>\n";
     592        echo "<posts>\n";
     593
     594        foreach($posts as $ID) {
     595                $GLOBALS['post'] = get_post($ID);
     596                $GLOBALS['post_ID'] = $ID;
     597
     598                if( ($post->post_type == 'post' && !current_user_can('edit_post', $ID)) ||
     599                                ($post->post_type == 'page' && !current_user_can('edit_page', $ID)) ||
     600                                ($post->post_type != 'post' && $post->post_type != 'page'))
     601                        continue;
     602
     603                echo "  <post id='$ID'>\n";
     604                echo "    <post_title>" . wp_specialchars($post->post_title, 1) . "</post_title>\n";
     605                echo "    <post_name>$post->post_name</post_name>\n";
     606                echo "    <post_author>$post->post_author</post_author>\n";
     607                echo "    <comment_status>$post->comment_status</comment_status>\n";
     608                echo "    <ping_status>$post->ping_status</ping_status>\n";
     609                echo "    <post_status>$post->post_status</post_status>\n";
     610                echo "    <jj>" . mysql2date( 'd', $post->post_date ) . "</jj>\n";
     611                echo "    <mm>" . mysql2date( 'm', $post->post_date ) . "</mm>\n";
     612                echo "    <aa>" . mysql2date( 'Y', $post->post_date ) . "</aa>\n";
     613                echo "    <hh>" . mysql2date( 'H', $post->post_date ) . "</hh>\n";
     614                echo "    <mn>" . mysql2date( 'i', $post->post_date ) . "</mn>\n";
     615                if( $post->post_type == 'post' ) {
     616                        echo '    <tags_input>' . wp_specialchars(get_tags_to_edit( $post->ID ), 1) . "</tags_input>\n";
     617                        echo '    <post_category>' . implode( ',', wp_get_post_categories( $post->ID ) ) . "</post_category>\n";
     618                        echo '    <sticky>' . (is_sticky($post->ID) ? 'sticky' : '') . "</sticky>\n";
     619                }
     620                if( $post->post_type == 'page' ) {
     621                        echo "    <post_parent>$post->post_parent</post_parent>\n";
     622                        echo '    <page_template>' . wp_specialchars(get_post_meta( $post->ID, '_wp_page_template', true ), 1) . "</page_template>\n";
     623                        echo "    <post_password>" . wp_specialchars($post->post_password, 1) . "</post_password>\n";
     624                        echo "    <menu_order>$post->menu_order</menu_order>\n";
     625                }
     626                echo "  </post>\n";
     627        }
     628
     629        echo '</posts>';
     630}
     631
    409632function post_rows() {
    410633        global $wp_query, $post, $mode;
    411634
     
    483706                        }
    484707
    485708                        if ( 'excerpt' == $mode ) { ?>
    486                 <td><?php echo apply_filters('post_date_column_time', $t_time, $post, $column_name, $mode) ?></td>
     709                <td class="date"><?php echo apply_filters('post_date_column_time', $t_time, $post, $column_name, $mode) ?></td>
    487710                <?php } else { ?>
    488                 <td><abbr title="<?php echo $t_time ?>"><?php echo apply_filters('post_date_column_time', $h_time, $post, $column_name, $mode) ?></abbr></td>
     711                <td class="date"><abbr title="<?php echo $t_time ?>"><?php echo apply_filters('post_date_column_time', $h_time, $post, $column_name, $mode) ?></abbr></td>
    489712                <?php }
    490713                break;
    491714
     
    500723
    501724                        $actions = array();
    502725                        $actions['edit'] = '<a href="post.php?action=edit&amp;post=' . $post->ID . '">' . __('Edit') . '</a>';
     726                        $actions['inline'] = '<a href="#" class="editinline">' . __('Quick Edit') . '</a>';
    503727                        $actions['delete'] = "<a class='submitdelete' href='" . wp_nonce_url("post.php?action=delete&amp;post=$post->ID", 'delete-post_' . $post->ID) . "' onclick=\"if ( confirm('" . js_escape(sprintf( ('draft' == $post->post_status) ? __("You are about to delete this draft '%s'\n  'Cancel' to stop, 'OK' to delete.") : __("You are about to delete this post '%s'\n  'Cancel' to stop, 'OK' to delete."), $post->post_title )) . "') ) { return true;}return false;\">" . __('Delete') . "</a>";
    504728                        $action_count = count($actions);
    505729                        $i = 0;
     
    515739
    516740                case 'categories':
    517741                ?>
    518                 <td><?php
     742                <td class="categories"><?php
    519743                        $categories = get_the_category();
    520744                        if ( !empty( $categories ) ) {
    521745                                $out = array();
     
    531755
    532756                case 'tags':
    533757                ?>
    534                 <td><?php
     758                <td class="tags"><?php
    535759                        $tags = get_the_tags();
    536760                        if ( !empty( $tags ) ) {
    537761                                $out = array();
     
    547771
    548772                case 'comments':
    549773                ?>
    550                 <td class="num"><div class="post-com-count-wrapper">
     774                <td class="comments num"><div class="post-com-count-wrapper">
    551775                <?php
    552776                        $pending_phrase = sprintf( __('%s pending'), number_format( $pending_comments ) );
    553777                        if ( $pending_comments )
     
    562786
    563787                case 'author':
    564788                ?>
    565                 <td><a href="edit.php?author=<?php the_author_ID(); ?>"><?php the_author() ?></a></td>
     789                <td class="author"><a href="edit.php?author=<?php the_author_ID(); ?>"><?php the_author() ?></a></td>
    566790                <?php
    567791                break;
    568792
    569793                case 'status':
    570794                ?>
    571                 <td>
     795                <td class="status">
    572796                <a href="<?php the_permalink(); ?>" title="<?php echo attribute_escape(sprintf(__('View "%s"'), $title)); ?>" rel="permalink">
    573797                <?php
    574798                        switch ( $post->post_status ) {
     
    654878
    655879        case 'cb':
    656880                ?>
    657                 <th scope="row" class="check-column"><input type="checkbox" name="delete[]" value="<?php the_ID(); ?>" /></th>
     881                <th scope="row" class="check-column"><input type="checkbox" name="post[]" value="<?php the_ID(); ?>" /></th>
    658882                <?php
    659883                break;
    660884        case 'modified':
     
    681905                        }
    682906                }
    683907                ?>
    684                 <td><abbr title="<?php echo $t_time ?>"><?php echo $h_time ?></abbr></td>
     908                <td class="date"><abbr title="<?php echo $t_time ?>"><?php echo $h_time ?></abbr></td>
    685909                <?php
    686910                break;
    687911        case 'title':
     
    696920
    697921                $actions = array();
    698922                $actions['edit'] = '<a href="' . $edit_link . '">' . __('Edit') . '</a>';
     923                $actions['inline'] = '<a href="#" class="editinline">' . __('Quick Edit') . '</a>';
    699924                $actions['delete'] = "<a class='submitdelete' href='" . wp_nonce_url("page.php?action=delete&amp;post=$page->ID", 'delete-page_' . $page->ID) . "' onclick=\"if ( confirm('" . js_escape(sprintf( ('draft' == $page->post_status) ? __("You are about to delete this draft '%s'\n  'Cancel' to stop, 'OK' to delete.") : __("You are about to delete this page '%s'\n  'Cancel' to stop, 'OK' to delete."), $page->post_title )) . "') ) { return true;}return false;\">" . __('Delete') . "</a>";
    700925                $action_count = count($actions);
    701926                $i = 0;
     
    711936
    712937        case 'comments':
    713938                ?>
    714                 <td class="num"><div class="post-com-count-wrapper">
     939                <td class="comments num"><div class="post-com-count-wrapper">
    715940                <?php
    716941                $left = get_pending_comments_num( $page->ID );
    717942                $pending_phrase = sprintf( __('%s pending'), number_format( $left ) );
     
    727952
    728953        case 'author':
    729954                ?>
    730                 <td><a href="edit-pages.php?author=<?php the_author_ID(); ?>"><?php the_author() ?></a></td>
     955                <td class="author"><a href="edit-pages.php?author=<?php the_author_ID(); ?>"><?php the_author() ?></a></td>
    731956                <?php
    732957                break;
    733958
    734959        case 'status':
    735960                ?>
    736                 <td>
     961                <td class="status">
    737962                <a href="<?php the_permalink(); ?>" title="<?php echo attribute_escape(sprintf(__('View "%s"'), $title)); ?>" rel="permalink">
    738963                <?php
    739964                switch ( $page->post_status ) {
     
    12401465
    12411466}
    12421467
    1243 function touch_time( $edit = 1, $for_post = 1, $tab_index = 0 ) {
     1468function touch_time( $edit = 1, $for_post = 1, $tab_index = 0, $multi = 0 ) {
    12441469        global $wp_locale, $post, $comment;
    12451470
    12461471        if ( $for_post )
     
    12611486        $mn = ($edit) ? mysql2date( 'i', $post_date ) : gmdate( 'i', $time_adj );
    12621487        $ss = ($edit) ? mysql2date( 's', $post_date ) : gmdate( 's', $time_adj );
    12631488
    1264         $month = "<select id=\"mm\" name=\"mm\"$tab_index_attribute>\n";
     1489        $month = "<select " . ( $multi ? '' : 'id="mm" ' ) . "name=\"mm\"$tab_index_attribute>\n";
    12651490        for ( $i = 1; $i < 13; $i = $i +1 ) {
    12661491                $month .= "\t\t\t" . '<option value="' . zeroise($i, 2) . '"';
    12671492                if ( $i == $mm )
     
    12701495        }
    12711496        $month .= '</select>';
    12721497
    1273         $day = '<input type="text" id="jj" name="jj" value="' . $jj . '" size="2" maxlength="2"' . $tab_index_attribute . ' autocomplete="off"  />';
    1274         $year = '<input type="text" id="aa" name="aa" value="' . $aa . '" size="4" maxlength="5"' . $tab_index_attribute . ' autocomplete="off"  />';
    1275         $hour = '<input type="text" id="hh" name="hh" value="' . $hh . '" size="2" maxlength="2"' . $tab_index_attribute . ' autocomplete="off"  />';
    1276         $minute = '<input type="text" id="mn" name="mn" value="' . $mn . '" size="2" maxlength="2"' . $tab_index_attribute . ' autocomplete="off"  />';
     1498        $day = '<input type="text" ' . ( $multi ? '' : 'id="jj" ' ) . 'name="jj" value="' . $jj . '" size="2" maxlength="2"' . $tab_index_attribute . ' autocomplete="off"  />';
     1499        $year = '<input type="text" ' . ( $multi ? '' : 'id="aa" ' ) . 'name="aa" value="' . $aa . '" size="4" maxlength="5"' . $tab_index_attribute . ' autocomplete="off"  />';
     1500        $hour = '<input type="text" ' . ( $multi ? '' : 'id="hh" ' ) . 'name="hh" value="' . $hh . '" size="2" maxlength="2"' . $tab_index_attribute . ' autocomplete="off"  />';
     1501        $minute = '<input type="text" ' . ( $multi ? '' : 'id="mn" ' ) . 'name="mn" value="' . $mn . '" size="2" maxlength="2"' . $tab_index_attribute . ' autocomplete="off"  />';
    12771502        printf(_c('%1$s%2$s, %3$s @ %4$s : %5$s|1: month input, 2: day input, 3: year input, 4: hour input, 5: minute input'), $month, $day, $year, $hour, $minute);
     1503
     1504        if ( $multi ) return;
     1505       
    12781506        echo "\n\n";
    12791507        foreach ( array('mm', 'jj', 'aa', 'hh', 'mn') as $timeunit )
    12801508                echo '<input type="hidden" id="hidden_' . $timeunit . '" name="hidden_' . $timeunit . '" value="' . $$timeunit . '" />' . "\n";
     
    13171545                        else
    13181546                                $current = '';
    13191547
    1320                         echo "\n\t<option value='$item->ID'$current>$pad " . wp_specialchars($item->post_title) . "</option>";
     1548                        echo "\n\t<option class='level-$level' value='$item->ID'$current>$pad " . wp_specialchars($item->post_title) . "</option>";
    13211549                        parent_dropdown( $default, $item->ID, $level +1 );
    13221550                }
    13231551        } else {
  • wp-admin/js/forms.js

     
    11function checkAll(jQ) { // use attr( checked, fn )
    2         jQuery(jQ).find( 'tbody:visible :checkbox' ).attr( 'checked', function() {
     2        jQuery(jQ).find( 'tbody:visible .check-column :checkbox' ).attr( 'checked', function() {
    33                return jQuery(this).attr( 'checked' ) ? '' : 'checked';
    44        } );
    55}
    66
    77jQuery( function($) {
    88        var lastClicked = false;
    9         $( 'tbody :checkbox' ).click( function(e) {
     9        $( 'tbody .check-column :checkbox' ).click( function(e) {
    1010                if ( 'undefined' == e.shiftKey ) { return true; }
    1111                if ( e.shiftKey ) {
    1212                        if ( !lastClicked ) { return true; }
  • wp-admin/js/inline-edit.js

     
     1var postType   = null;
     2var postView   = null;
     3var postsXml   = null;
     4var inlineRows = null;
     5
     6jQuery(document).ready(function() {
     7        postType = window.location.href.indexOf('edit.php') == -1 ? 'page' : 'post';
     8        postView = window.location.href.indexOf('mode=excerpt') == -1 ? 'list' : 'excerpt';
     9
     10        // get IDs of all editable rows
     11        inlineRows = jQuery('table.widefat .check-column :checkbox[name="post[]"]').parents('tr');
     12
     13        // prepare the edit row
     14        var blankRow = jQuery('#inline-edit');
     15        jQuery('ul.categories *', blankRow).removeAttr('id');
     16        jQuery('ul.categories label', blankRow).removeAttr('for');
     17        blankRow.attr('title', 'Double-click to cancel')
     18                .dblclick(function() { toggleRow(this); })
     19                .keypress(function(event) { if(event.which == 13) return saveRow(this); });
     20        jQuery('span.cancel a', blankRow).click(function() { return revertRow(this); });
     21        jQuery('span.save a', blankRow).click(function() { return saveRow(this); });
     22
     23        // add events and get data
     24        inlineRows.dblclick(function() { toggleRow(this); });
     25        addEvents(inlineRows);
     26
     27        // get data
     28        getInlineData('all');
     29});
     30
     31function toggleRow(el) {
     32        jQuery('#'+postType+'-'+getRowId(el)).css('display') == 'none' ? revertRow(el) : editRow(el);
     33}
     34
     35// add events to links and make rows double-clickable
     36function addEvents(rows) {
     37        rows.each(function() {
     38                var row = jQuery(this);
     39                jQuery('a.editinline', row).click(function() { editRow(this); return false; });
     40                row.attr('title', 'Double-click to edit');
     41        });
     42}
     43
     44function getInlineData(id) {   
     45        if(id == 'all') {
     46                var editable = [];
     47                inlineRows.each(function(i) { editable[i] = getRowId(this); });
     48                id = editable.join(',');
     49        }
     50
     51        if(id == '')
     52                return false;
     53       
     54        jQuery.post('admin-ajax.php',
     55                {
     56                        action: 'inline-data',
     57                        posts: id
     58                },
     59                function(xml) {
     60                        if(id.indexOf(',') == -1) {
     61                                var newData = jQuery(xml).find('post[id="'+id+'"]');
     62                                jQuery(postsXml).find('post[id="'+id+'"]').replaceWith(newData);
     63                        } else {
     64                                postsXml = xml;
     65                        }
     66                }, 'xml'
     67        );
     68}
     69
     70function editRow(id) {
     71        if(typeof(id) == 'object')
     72                id = getRowId(id);
     73
     74        var blankRow = jQuery('#inline-edit');
     75
     76        var fields = ['post_title', 'post_name', 'post_author', 'post_status', 'jj', 'mm', 'aa', 'hh', 'mn'];
     77        if(postType == 'page') fields.push('post_parent', 'menu_order', 'page_template', 'post_password');
     78        if(postType == 'post') fields.push('tags_input');
     79
     80        // add the new blank row
     81        var editRow = blankRow.clone(true);
     82        jQuery(editRow).attr('id', 'edit-'+id).addClass('inline').show();
     83        if(jQuery('#'+postType+'-'+id).hasClass('alternate'))
     84                jQuery(editRow).addClass('alternate');
     85        jQuery('#'+postType+'-'+id).hide().after(editRow);
     86       
     87        // populate the data
     88        var rowData = jQuery(postsXml).find('post[id="'+id+'"]');
     89        for(var f = 0; f < fields.length; f++) {
     90                jQuery(':input[name="'+fields[f]+'"]', editRow).val(jQuery(fields[f], rowData).text());
     91        }
     92       
     93        // ping, comments, and privacy
     94        if(jQuery('comment_status', rowData).text() == 'open')
     95                jQuery('input[name="comment_status"]', editRow).select();
     96        if(jQuery('ping_status', rowData).text() == 'open')
     97                jQuery('input[name="ping_status"]', editRow).select();
     98        if(jQuery('sticky', rowData).text() == 'sticky')
     99                jQuery('input[name="sticky"]', editRow).select();
     100       
     101        // categories
     102        var categories = jQuery('post_category', rowData).text().split(',');
     103        jQuery(categories).each(function() {
     104                jQuery('ul.categories :checkbox[value="'+this+'"]', editRow).select();
     105        });
     106       
     107        // handle the post status
     108        var status = jQuery('post_status', rowData).text();
     109        if(status != 'future') jQuery('select[name="post_status"] option[value="future"]', editRow).remove();
     110        if(status == 'private') jQuery('input[name="page_private"]', editRow).select();
     111       
     112        // enable autocomplete for tags
     113        if(postType == 'post') {
     114                jQuery('tr.inline textarea[name="tags_input"]').suggest( 'admin-ajax.php?action=ajax-tag-search', { delay: 500, minchars: 2, multiple: true, multipleSep: ", " } );
     115        }
     116       
     117        // remove the current page and children from the parent dropdown
     118        var pageOpt = jQuery('select[name="post_parent"] option[value="'+id+'"]', editRow);
     119        if(pageOpt.length > 0) {
     120                var pageLevel = pageOpt[0].className.split('-')[1];
     121                var nextPage = pageOpt; var pageLoop = true;
     122                while(pageLoop) {
     123                        var nextPage  = nextPage.next('option');
     124                        var nextLevel = nextPage[0].className.split('-')[1];
     125                        if(nextLevel <= pageLevel)
     126                                pageLoop = false;
     127                        else {
     128                                nextPage.remove();
     129                                nextPage = pageOpt;
     130                        }
     131                }
     132                pageOpt.remove();
     133        }
     134
     135        return false;
     136}
     137
     138function saveRow(id) {
     139        if(typeof(id) == 'object')
     140          id = getRowId(id);
     141
     142        jQuery('#edit-'+id+' .check-column').html('<img src="images/loading.gif" alt="Saving..." />');
     143
     144        var params = {
     145                action:    'inline-save',
     146                post_type: postType,
     147                post_ID:   id,
     148                edit_date: 'true',
     149                post_view: postView
     150        };
     151
     152        var fields = jQuery('#edit-'+id+' :input').fieldSerialize();
     153        params = fields + '&' + jQuery.param(params);
     154   
     155        // make ajax request
     156        jQuery.post('admin-ajax.php', params,
     157                function(html) {
     158                        var row = jQuery('#'+postType+'-'+id);
     159                        jQuery('#edit-'+id).hide();
     160                        html = jQuery(html).html();
     161                        row.html(html).show();
     162                        row.animate( { backgroundColor: '#FFFBCC' }, 200)
     163                                 .animate( { backgroundColor: row.css('background-color') }, 500);
     164                        getInlineData(id);
     165                        addEvents(row);
     166                }
     167        );
     168
     169        return false;
     170}
     171
     172function revertRow(id) {
     173        if(typeof(id) == 'object')
     174                id = getRowId(id);
     175
     176        jQuery('#edit-'+id).remove();
     177        jQuery('#'+postType+'-'+id).show();
     178
     179        return false;
     180}
     181
     182function getRowId(obj) {
     183        var id = obj.tagName == 'TR' ? obj.id : jQuery(obj).parents('tr').attr('id');
     184        var parts = id.split('-');
     185        return parts[parts.length - 1];
     186}
     187 No newline at end of file
  • wp-admin/edit-post-rows.php

     
    2727        </tr>
    2828        </thead>
    2929        <tbody>
     30         
     31<?php inline_edit_row( 'post' ) ?>       
     32
    3033<?php
    3134if ( have_posts() ) {
    3235        post_rows();
  • wp-admin/edit.php

     
    5050$title = __('Posts');
    5151$parent_file = 'edit.php';
    5252wp_enqueue_script('admin-forms');
     53wp_enqueue_script('inline-edit');
    5354
     55
    5456list($post_stati, $avail_post_stati) = wp_edit_posts_query();
    5557
    5658if ( 1 == count($posts) && is_singular() ) {
     
    169171<div class="alignleft">
    170172<select name="action">
    171173<option value="" selected><?php _e('Actions'); ?></option>
     174<option value="edit"><?php _e('Edit'); ?></option>
    172175<option value="delete"><?php _e('Delete'); ?></option>
    173 <option value="edit"><?php _e('Edit'); ?></option>
    174176</select>
    175177<input type="submit" value="<?php _e('Apply'); ?>" name="doaction" class="button-secondary action" />
    176178<?php wp_nonce_field('bulk-posts'); ?>
  • wp-admin/edit-pages.php

     
    4444$title = __('Pages');
    4545$parent_file = 'edit.php';
    4646wp_enqueue_script('admin-forms');
     47wp_enqueue_script('inline-edit');
    4748
    4849$post_stati  = array(   //      array( adj, noun )
    4950                'publish' => array(__('Published'), __('Published pages'), __ngettext_noop('Published (%s)', 'Published (%s)')),
     
    153154<div class="alignleft">
    154155<select name="action">
    155156<option value="" selected><?php _e('Actions'); ?></option>
     157<option value="edit"><?php _e('Edit'); ?></option>
    156158<option value="delete"><?php _e('Delete'); ?></option>
    157159</select>
    158160<input type="submit" value="<?php _e('Apply'); ?>" name="doaction" class="button-secondary action" />
     
    187189  </tr>
    188190  </thead>
    189191  <tbody>
     192  <?php inline_edit_row( 'page' ) ?>
    190193  <?php page_rows($posts, $pagenum, $per_page); ?>
    191194  </tbody>
    192195</table>