Make WordPress Core

Ticket #6815: manageable.patch

File manageable.patch, 27.9 KB (added by aaron_guitar, 17 years ago)

Initial integration of Manageable. Saving not yet implemented.

  • 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

     
    715715        $slug = isset($_POST['new_slug'])? $_POST['new_slug'] : '';
    716716        die(get_sample_permalink_html($post_id, $title, $slug));
    717717break;
     718case 'inline-data':
     719        if( !isset( $_POST['posts'] ) )
     720                break;
     721        get_edit_data( explode(',', $_POST['posts']) );
     722        die();
     723break;
     724case 'inline-save':
     725        die('1');
     726break;
    718727case 'meta-box-order':
    719728        check_ajax_referer( 'meta-box-order' );
    720729        update_user_option( $GLOBALS['current_user']->ID, "meta-box-order_$_POST[page]", $_POST['order'] );
  • wp-admin/wp-admin.css

     
    20852085.metabox-prefs label input {
    20862086        margin: 0 5px 0 2px;
    20872087}
     2088
     2089
     2090/* Inline Editor */
     2091
     2092.edit-column {
     2093        text-align: center;
     2094}
     2095
     2096.inline {
     2097        font-size: 10px;
     2098}
     2099
     2100.inline td {
     2101        padding-right: 4px;
     2102        padding-left: 7px;
     2103}
     2104
     2105.inline input, .inline select, .inline textarea {
     2106        font-size: 10px !important;
     2107        padding: 2px;
     2108        border: 1px solid #ddd;
     2109}
     2110
     2111.inline td.date {
     2112        width: 87px;
     2113}
     2114
     2115.inline td.page-title {
     2116        width: 495px;
     2117}
     2118
     2119.inline td.post-title input.title {
     2120        width: 250px;
     2121}
     2122
     2123.inline td.post-title input.slug {
     2124        width: 222px;
     2125        float: right;
     2126}
     2127
     2128.inline div.title {
     2129        float: left;
     2130}
     2131
     2132.inline div.title input.title {
     2133        font-size: 12px !important;
     2134}
     2135
     2136.inline div.title label {
     2137        float: left;
     2138        margin-top: 4px;
     2139}
     2140
     2141.inline td.page-title input.slug {
     2142        width: 123px;
     2143        float: right;
     2144}
     2145
     2146.inline div.other, .inline div.more {
     2147        width: 190px;
     2148        float: left;
     2149        padding-left: 5px;
     2150}
     2151
     2152.inline div.other label, .inline div.more label {
     2153        display: block; float: left;
     2154        width: 54px;
     2155        margin-top: 4px;
     2156}
     2157
     2158.inline div.other select {
     2159        width: 133px;
     2160}
     2161
     2162.inline div.more {
     2163        width: 125px;
     2164}
     2165
     2166.inline div.more input {
     2167        width: 60px;
     2168}
     2169
     2170.inline td.author select {
     2171        width: 110px;
     2172}
     2173
     2174.inline ul.categories {
     2175        list-style: none;
     2176        padding: 0; margin: 0;
     2177        height: 65px;
     2178        overflow: auto;
     2179        font-size: 10px;
     2180}
     2181
     2182.inline ul.categories ul.children {
     2183        list-style: none;
     2184        padding-left: 15px;
     2185}
     2186
     2187.inline ul.categories li {
     2188        margin-bottom: 2px;
     2189}
     2190
     2191.inline ul.categories input {
     2192        vertical-align: middle;
     2193        padding: 0; border: 0;
     2194}
     2195
     2196.inline td.tags textarea {
     2197        height: 58px; width: 100%;
     2198}
     2199
     2200.inline td.comments {
     2201        padding-left: 0;
     2202}
     2203
     2204.inline td.status select {
     2205        width: 98px;
     2206}
     2207
     2208.inline td.status input {
     2209        vertical-align: middle;
     2210}
     2211 No newline at end of file
  • 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 display_edit_row() {
     410        global $pagenow, $current_user;
     411 
     412        if($pagenow == 'edit.php')
     413                $type = 'post';
     414        elseif($pagenow == 'edit-pages.php')
     415                $type = 'page';
     416        else
     417                return false;
     418 
     419        echo '<tr id="inline-edit" style="display: none">';
     420
     421        $columns = $type == 'post' ? wp_manage_posts_columns() : wp_manage_pages_columns();
     422        foreach($columns as $column_name=>$column_display_name) {
     423
     424                switch($column_name) {
     425
     426                case 'cb': ?>
     427                  <td></td>
     428                  <?php
     429                  break;
     430
     431                case 'modified':
     432                case 'date': ?>
     433                        <td class="date">
     434                                <?php touch_time(1, 1, 4, 1); ?>
     435                        </td>
     436                        <?php
     437                        break;
     438
     439                case 'title': ?>
     440                        <td class="<?php echo $type ?>-title">
     441                                <div class="title">
     442                                        <input type="text" class="title" value="" /><br />
     443                                        <label><?php _e('Slug'); ?></label><input type="text" value="" class="slug" />
     444                                </div>
     445                                <?php if($type == 'page'): ?>
     446                                <div class="other">
     447                                        <label><?php _e('Parent'); ?></label>
     448                                        <select class="parent">
     449                                                <option value="0"><?php _e('Main Page (no parent)'); ?></option>
     450                                                <?php parent_dropdown(); ?>
     451                                        </select><br />
     452                                        <label><?php _e('Template'); ?></label>
     453                                        <select class="template">
     454                                                <option value='default'><?php _e('Default Template'); ?></option>
     455                                                <?php page_template_dropdown() ?>
     456                                        </select>
     457                                </div>
     458                                <div class="more">
     459                                        <label><?php _e('Order'); ?></label><input type="text" class="order" value="<?php echo $post->menu_order ?>" />
     460                                        <label><?php _e('Password'); ?></label><input type="text" class="password" value="<?php echo $post->post_password ?>" />     
     461                                </div>
     462                                <?php endif; ?>
     463                                <div class="clear"></div>
     464                                <?php
     465                                $actions = array();
     466                                $actions['save'] = '<a href="#">' . __('Save') . '</a>';
     467                                $actions['cancel'] = '<a href="#">' . __('Cancel') . '</a>';
     468                                $action_count = count($actions);
     469                                $i = 0;
     470                                foreach ( $actions as $action => $link ) {
     471                                        ++$i;
     472                                        ( $i == $action_count ) ? $sep = '' : $sep = ' | ';
     473                                        echo "<span class='$action'>$link$sep</span>";
     474                                }
     475                                ?>
     476                        </td>
     477                        <?php
     478                        break;
     479
     480                case 'categories': ?>
     481                        <td class="categories">
     482                                <ul class="categories">
     483                                        <?php wp_category_checklist() ?>
     484                                </ul>
     485                        </td>
     486                        <?php
     487                        break;
     488
     489                case 'tags': ?>
     490                        <td class="tags">
     491                                <textarea class="tags"></textarea>
     492                        </td>
     493                        <?php
     494                        break;
     495
     496                case 'comments': ?>
     497                        <td class="comments num">
     498                                <input title="Allow Comments" type="checkbox" class="comment" value="open" /><br />
     499                                <input title="Allow Pings" type="checkbox" class="ping" value="open" />
     500                        </td>
     501                        <?php
     502                        break;
     503
     504                case 'author': ?>
     505                        <td class="author">
     506                                <?php
     507                                $authors = get_editable_user_ids( $current_user->id ); // TODO: ROLE SYSTEM
     508                                if ( $authors && count( $authors ) > 1 ) {
     509                                        wp_dropdown_users( array('include' => $authors, 'name' => 'author-'.$post->ID, 'class'=> 'author', 'selected' => $post->post_author) );
     510                                } else {
     511                                        echo $current_user->user_nicename.'<input type="hidden" value="'.$post->post_author.'" class="author" />';
     512                                }
     513                                ?>
     514                        </td>
     515                        <?php
     516                        break;
     517
     518                case 'status': ?>
     519                        <td class="status">
     520                                <select class="status">
     521                                        <?php if ( current_user_can('publish_posts') ) : // Contributors only get "Unpublished" and "Pending Review" ?>
     522                                        <option value='publish'><?php _e('Published') ?></option>
     523                                        <option value='future'><?php _e('Scheduled') ?></option>
     524                                        <?php endif; ?>
     525                                        <option value='pending'><?php _e('Pending Review') ?></option>
     526                                        <option value='draft'><?php _e('Unpublished') ?></option>
     527                                </select>
     528                                <?php if($type == 'page'): ?>
     529                                <br /><label><input class="private" type="checkbox" value="private" <?php checked($post->post_status, 'private'); ?> /> <?php _e('Private') ?></label></p>
     530                                <?php endif; ?>
     531                        </td>
     532                        <?php
     533                        break;
     534
     535                case 'control_view': ?>
     536                        <td><a href="<?php the_permalink(); ?>" rel="permalink" class="view"><?php _e('View'); ?></a></td>
     537                        <?php
     538                        break;
     539
     540                case 'control_edit': ?>
     541                        <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>
     542                        <?php
     543                        break;
     544
     545                case 'control_delete': ?>
     546                        <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>
     547                        <?php
     548                        break;
     549
     550                default: ?>
     551                        <td><?php do_action('manage_posts_custom_column', $column_name, $post->ID); ?></td>
     552                        <?php
     553                        break;
     554                }
     555        }
     556
     557        echo '</tr>';
     558}
     559
     560// outputs XML of the post/page data ready for use in the inline editor
     561// accepts array of post IDs
     562function get_edit_data($posts) {
     563        global $post;
     564
     565        header('Content-Type: text/xml; charset=' . get_option('blog_charset'), true);
     566        echo "<?xml version='1.0' ?>\n";
     567        echo "<posts>\n";
     568
     569        foreach($posts as $ID) {
     570                $GLOBALS['post'] = get_post($ID);
     571                $GLOBALS['post_ID'] = $ID;
     572
     573                if( ($post->post_type == 'post' && !current_user_can('edit_post', $ID)) ||
     574                                ($post->post_type == 'page' && !current_user_can('edit_page', $ID)) ||
     575                                ($post->post_type != 'post' && $post->post_type != 'page'))
     576                        continue;
     577
     578                echo "  <post id='$ID'>\n";
     579                echo "    <title>" . wp_specialchars($post->post_title, 1) . "</title>\n";
     580                echo "    <slug>$post->post_name</slug>\n";
     581                echo "    <author>$post->post_author</author>\n";
     582                echo "    <comments>$post->comment_status</comments>\n";
     583                echo "    <ping>$post->ping_status</ping>\n";
     584                echo "    <status>$post->post_status</status>\n";
     585                echo "    <jj>" . mysql2date( 'd', $post->post_date ) . "</jj>\n";
     586                echo "    <mm>" . mysql2date( 'm', $post->post_date ) . "</mm>\n";
     587                echo "    <aa>" . mysql2date( 'Y', $post->post_date ) . "</aa>\n";
     588                echo "    <hh>" . mysql2date( 'H', $post->post_date ) . "</hh>\n";
     589                echo "    <mn>" . mysql2date( 'i', $post->post_date ) . "</mn>\n";
     590                if( $post->post_type == 'post' ) {
     591                        echo '    <tags>' . wp_specialchars(get_tags_to_edit( $post->ID ), 1) . "</tags>\n";
     592                        echo '    <categories>' . implode( ',', wp_get_post_categories( $post->ID ) ) . "</categories>\n";
     593                }
     594                if( $post->post_type == 'page' ) {
     595                        echo "    <parent>$post->post_parent</parent>\n";
     596                        echo '    <template>' . wp_specialchars(get_post_meta( $post->ID, '_wp_page_template', true ), 1) . "</template>\n";
     597                        echo "    <password>" . wp_specialchars($post->post_password, 1) . "</password>\n";
     598                        echo "    <order>$post->menu_order</order>\n";
     599                }
     600                echo "  </post>\n";
     601        }
     602
     603        echo '</posts>';
     604}
     605
    409606function post_rows() {
    410607        global $wp_query, $post, $mode;
    411608
     
    483680                        }
    484681
    485682                        if ( 'excerpt' == $mode ) { ?>
    486                 <td><?php echo apply_filters('post_date_column_time', $t_time, $post, $column_name, $mode) ?></td>
     683                <td class="date"><?php echo apply_filters('post_date_column_time', $t_time, $post, $column_name, $mode) ?></td>
    487684                <?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>
     685                <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>
    489686                <?php }
    490687                break;
    491688
     
    500697
    501698                        $actions = array();
    502699                        $actions['edit'] = '<a href="post.php?action=edit&amp;post=' . $post->ID . '">' . __('Edit') . '</a>';
     700                        $actions['inline'] = '<a href="#" class="editinline">' . __('Quick Edit') . '</a>';
    503701                        $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>";
    504702                        $action_count = count($actions);
    505703                        $i = 0;
     
    515713
    516714                case 'categories':
    517715                ?>
    518                 <td><?php
     716                <td class="categories"><?php
    519717                        $categories = get_the_category();
    520718                        if ( !empty( $categories ) ) {
    521719                                $out = array();
     
    531729
    532730                case 'tags':
    533731                ?>
    534                 <td><?php
     732                <td class="tags"><?php
    535733                        $tags = get_the_tags();
    536734                        if ( !empty( $tags ) ) {
    537735                                $out = array();
     
    547745
    548746                case 'comments':
    549747                ?>
    550                 <td class="num"><div class="post-com-count-wrapper">
     748                <td class="comments num"><div class="post-com-count-wrapper">
    551749                <?php
    552750                        $pending_phrase = sprintf( __('%s pending'), number_format( $pending_comments ) );
    553751                        if ( $pending_comments )
     
    562760
    563761                case 'author':
    564762                ?>
    565                 <td><a href="edit.php?author=<?php the_author_ID(); ?>"><?php the_author() ?></a></td>
     763                <td class="author"><a href="edit.php?author=<?php the_author_ID(); ?>"><?php the_author() ?></a></td>
    566764                <?php
    567765                break;
    568766
    569767                case 'status':
    570768                ?>
    571                 <td>
     769                <td class="status">
    572770                <a href="<?php the_permalink(); ?>" title="<?php echo attribute_escape(sprintf(__('View "%s"'), $title)); ?>" rel="permalink">
    573771                <?php
    574772                        switch ( $post->post_status ) {
     
    654852
    655853        case 'cb':
    656854                ?>
    657                 <th scope="row" class="check-column"><input type="checkbox" name="delete[]" value="<?php the_ID(); ?>" /></th>
     855                <th scope="row" class="check-column"><input type="checkbox" name="post[]" value="<?php the_ID(); ?>" /></th>
    658856                <?php
    659857                break;
    660858        case 'modified':
     
    681879                        }
    682880                }
    683881                ?>
    684                 <td><abbr title="<?php echo $t_time ?>"><?php echo $h_time ?></abbr></td>
     882                <td class="date"><abbr title="<?php echo $t_time ?>"><?php echo $h_time ?></abbr></td>
    685883                <?php
    686884                break;
    687885        case 'title':
     
    696894
    697895                $actions = array();
    698896                $actions['edit'] = '<a href="' . $edit_link . '">' . __('Edit') . '</a>';
     897                $actions['inline'] = '<a href="#" class="editinline">' . __('Quick Edit') . '</a>';
    699898                $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>";
    700899                $action_count = count($actions);
    701900                $i = 0;
     
    711910
    712911        case 'comments':
    713912                ?>
    714                 <td class="num"><div class="post-com-count-wrapper">
     913                <td class="comments num"><div class="post-com-count-wrapper">
    715914                <?php
    716915                $left = get_pending_comments_num( $page->ID );
    717916                $pending_phrase = sprintf( __('%s pending'), number_format( $left ) );
     
    727926
    728927        case 'author':
    729928                ?>
    730                 <td><a href="edit-pages.php?author=<?php the_author_ID(); ?>"><?php the_author() ?></a></td>
     929                <td class="author"><a href="edit-pages.php?author=<?php the_author_ID(); ?>"><?php the_author() ?></a></td>
    731930                <?php
    732931                break;
    733932
    734933        case 'status':
    735934                ?>
    736                 <td>
     935                <td class="status">
    737936                <a href="<?php the_permalink(); ?>" title="<?php echo attribute_escape(sprintf(__('View "%s"'), $title)); ?>" rel="permalink">
    738937                <?php
    739938                switch ( $page->post_status ) {
     
    12401439
    12411440}
    12421441
    1243 function touch_time( $edit = 1, $for_post = 1, $tab_index = 0 ) {
     1442function touch_time( $edit = 1, $for_post = 1, $tab_index = 0, $multi = 0 ) {
    12441443        global $wp_locale, $post, $comment;
    12451444
    12461445        if ( $for_post )
     
    12501449        if ( (int) $tab_index > 0 )
    12511450                $tab_index_attribute = " tabindex=\"$tab_index\"";
    12521451
     1452  $identifier = $multi ? 'class' : 'id';
     1453
    12531454        // echo '<label for="timestamp" style="display: block;"><input type="checkbox" class="checkbox" name="edit_date" value="1" id="timestamp"'.$tab_index_attribute.' /> '.__( 'Edit timestamp' ).'</label><br />';
    12541455
    12551456        $time_adj = time() + (get_option( 'gmt_offset' ) * 3600 );
     
    12611462        $mn = ($edit) ? mysql2date( 'i', $post_date ) : gmdate( 'i', $time_adj );
    12621463        $ss = ($edit) ? mysql2date( 's', $post_date ) : gmdate( 's', $time_adj );
    12631464
    1264         $month = "<select id=\"mm\" name=\"mm\"$tab_index_attribute>\n";
     1465        $month = "<select $identifier=\"mm\" name=\"mm\"$tab_index_attribute>\n";
    12651466        for ( $i = 1; $i < 13; $i = $i +1 ) {
    12661467                $month .= "\t\t\t" . '<option value="' . zeroise($i, 2) . '"';
    12671468                if ( $i == $mm )
     
    12701471        }
    12711472        $month .= '</select>';
    12721473
    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"  />';
     1474        $day = '<input type="text" ' . $identifier . '="jj" name="jj" value="' . $jj . '" size="2" maxlength="2"' . $tab_index_attribute . ' autocomplete="off"  />';
     1475        $year = '<input type="text" ' . $identifier . '="aa" name="aa" value="' . $aa . '" size="4" maxlength="5"' . $tab_index_attribute . ' autocomplete="off"  />';
     1476        $hour = '<input type="text" ' . $identifier . '="hh" name="hh" value="' . $hh . '" size="2" maxlength="2"' . $tab_index_attribute . ' autocomplete="off"  />';
     1477        $minute = '<input type="text" ' . $identifier . '="mn" name="mn" value="' . $mn . '" size="2" maxlength="2"' . $tab_index_attribute . ' autocomplete="off"  />';
    12771478        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);
     1479
     1480        if ( $multi ) return;
     1481       
    12781482        echo "\n\n";
    12791483        foreach ( array('mm', 'jj', 'aa', 'hh', 'mn') as $timeunit )
    1280                 echo '<input type="hidden" id="hidden_' . $timeunit . '" name="hidden_' . $timeunit . '" value="' . $$timeunit . '" />' . "\n";
     1484                echo '<input type="hidden" ' . $identifier . '="hidden_' . $timeunit . '" name="hidden_' . $timeunit . '" value="' . $$timeunit . '" />' . "\n";
    12811485?>
    12821486
    1283 <input type="hidden" id="ss" name="ss" value="<?php echo $ss ?>" size="2" maxlength="2" />
     1487<input type="hidden" <?php echo $identifier ?>="ss" name="ss" value="<?php echo $ss ?>" size="2" maxlength="2" />
    12841488
    12851489<a href="#edit_timestamp" class="save-timestamp hide-if-no-js button"><?php _e('OK'); ?></a>
    12861490<a href="#edit_timestamp" class="edit-timestamp hide-if-no-js"><?php _e('Cancel'); ?></a>
  • 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 = '';
     2var multiKey = false;
     3var postsXml = '';
     4
     5// keep track of the shift key
     6jQuery(document).keydown(function(e) { if(e.which == 16) multiKey = true; } );
     7jQuery(document).keyup(function(e) { if(e.which == 16)   multiKey = false; } );
     8
     9jQuery(function() {
     10        postType = window.location.href.indexOf('edit.php') != -1 ? 'post' : 'page';
     11
     12        // handle edit action
     13        jQuery('#posts-filter input[name="doaction"]').click(function() {
     14                if(jQuery('#posts-filter select[name="action"]').val() == 'edit') {
     15                        editRow(selectedRows());
     16                        return false;       
     17                }
     18                return true;
     19        });
     20
     21        // get IDs of all editable rows
     22        var rows = jQuery('table.widefat .check-column :checkbox');
     23        var editable = [];
     24        rows.each(function(i) { editable[i] = this.value; });
     25
     26        // prepare the edit row
     27        var blankRow = jQuery('#inline-edit');
     28        jQuery('ul.categories *', blankRow).removeAttr('id');
     29        jQuery('ul.categories label', blankRow).removeAttr('for');
     30        jQuery('ul.categories :checkbox').each(function() {
     31                jQuery(this).addClass('category-'+this.value);
     32        });
     33        blankRow.attr('title', 'Double-click to cancel')
     34                .dblclick(function() { toggleRow(this); })
     35                .keypress(function(event) { if(event.which == 13) return saveRow(this); });
     36        jQuery('span.cancel a', blankRow).click(function() { return revertRow(this); });
     37        jQuery('span.save a', blankRow).click(function() { return saveRow(this); });
     38
     39        // add events for shift-change functionality
     40        jQuery('ul.categories input[type="checkbox"], td.comments input[type="checkbox"], input.private', blankRow).click(changeAll);
     41        jQuery('select.author, select.status, select.mm, select.parent, select.template', blankRow).change(changeAll);
     42        jQuery('input.password, input.jj, input.aa, input.hh, input.mn, textarea.tags, input.title', blankRow).blur(changeAll);
     43
     44        // add events to links and make rows double-clickable
     45        rows.each(function() {
     46                var row = jQuery('#'+postType+'-'+this.value);
     47                jQuery('a.editinline', row).click(function() { editRow(this); return false; });
     48                row.dblclick(function() { toggleRow(this); });
     49                row.attr('title', 'Double-click to edit');
     50        });
     51
     52        // get data for posts
     53        jQuery.post('admin-ajax.php', { action: 'inline-data', posts: editable.join(',') }, function(xml) { postsXml = xml; }, 'xml');
     54});
     55
     56function toggleRow(el) {
     57        jQuery('#'+postType+'-'+getRowId(el)).css('display') == 'none' ? revertRow(el) : editRow(el);
     58}
     59
     60// ID can be either the row object or a comma separated list of IDs
     61function editRow(id) {
     62        if(typeof(id) == 'object')
     63                id = getRowId(id);
     64
     65        var blankRow = jQuery('#inline-edit');
     66
     67        var ids = id.split(',');
     68        var fields = ['title', 'slug', 'author', 'status', 'jj', 'mm', 'aa', 'hh', 'mn'];
     69        if(postType == 'page') fields.push('parent', 'order', 'template', 'password');
     70        if(postType == 'post') fields.push('tags');
     71
     72        // iterate through the rows
     73        for(var i = 0; i < ids.length; i++) {
     74                id = ids[i];
     75               
     76                // add the new blank row
     77                var editRow = blankRow.clone(true);
     78                jQuery(editRow).attr('id', 'edit-'+id).addClass('inline').show();
     79                if(jQuery('#'+postType+'-'+id).hasClass('alternate'))
     80                        jQuery(editRow).addClass('alternate');
     81                jQuery('#'+postType+'-'+id).hide().after(editRow);
     82               
     83                // populate the data
     84                var rowData = jQuery(postsXml).find('post[id="'+id+'"]');
     85                for(var f = 0; f < fields.length; f++) {
     86                        jQuery(':input.'+fields[f], editRow).val(jQuery(fields[f], rowData).text());
     87                }
     88               
     89                // ping, comments, and privacy
     90                if(jQuery('comments', rowData).text() == 'open')
     91                        jQuery('input.comment', editRow).select();
     92                if(jQuery('ping', rowData).text() == 'open')
     93                        jQuery('input.ping', editRow).select();
     94               
     95                // categories
     96                var categories = jQuery('categories', rowData).text().split(',');
     97                jQuery(categories).each(function() {
     98                        jQuery('ul.categories :checkbox[value="'+this+'"]', editRow).select();
     99                });
     100               
     101                // handle the post status
     102                var status = jQuery('status', rowData).text();
     103                if(status != 'future') jQuery('select.status option[value="future"]', editRow).remove();
     104                if(status == 'private') jQuery('input.private', editRow).select();
     105               
     106                // remove the current page from the parent dropdown
     107                jQuery('select.parent option[value="'+id+'"]', editRow).remove();
     108                // NEED TO REMOVE CHILD PAGES TOO
     109        }
     110
     111        // enable autocomplete for tags
     112        if(postType == 'post') {
     113                jQuery('tr.inline textarea.tags').suggest( 'admin-ajax.php?action=ajax-tag-search', { delay: 500, minchars: 2, multiple: true, multipleSep: ", " } );
     114        }
     115
     116        return false;
     117}
     118
     119function saveRow(id) {
     120        if(typeof(id) == 'object')
     121          id = getRowId(id);
     122        if(multiKey)
     123          id = openRows();
     124
     125        var rows = jQuery('table.widefat tr.inline');
     126
     127        alert('Saving is not yet implemented.');
     128        return false;
     129
     130        // add names to all the fields
     131        var idArray = id.split(',');
     132        jQuery(idArray).each(function(i) {
     133                jQuery('input[type!="button"], select, textarea', jQuery('tr#'+postType+'-'+id)).each(function() {
     134                        jQuery(this).attr('name', this.className+'-'+idArray[i]);
     135                });
     136        });
     137 
     138        var params = 'action=save&post_type='+postType+'&id='+id+'&';
     139        params += jQuery('input[type!="button"], select, textarea', rows).fieldSerialize();
     140
     141        // make ajax request
     142        jQuery.post('admin-ajax.php', params,
     143                function(html) {
     144                        //updateRow(id, 'get', html);
     145                        //var row = jQuery(rowId);
     146                }
     147        ); 
     148        return false;
     149}
     150
     151function revertRow(id) {
     152        if(typeof(id) == 'object') id = getRowId(id);
     153        if(multiKey) id = openRows();
     154        id = id.split(',');
     155
     156        jQuery(id).each(function() {
     157                jQuery('#edit-'+this).remove();
     158                jQuery('#'+postType+'-'+this).show();
     159        });
     160
     161        return false;
     162}
     163
     164function changeAll(event) {
     165        if(!multiKey) return;
     166
     167        switch(this.type) {
     168                case 'checkbox':
     169                        var checked = this.checked ? true : false;
     170                        jQuery('tr.inline input.'+this.className+'[type="checkbox"]').select(checked);
     171                        break;
     172                case 'select':
     173                case 'select-one':
     174                        jQuery('tr.inline select.'+this.className).val(this.value);
     175                        break;
     176                case 'text':
     177                        jQuery('tr.inline input.'+this.className).val(this.value);
     178                        break;
     179                case 'textarea':
     180                        jQuery('tr.inline textarea.tags').val(this.value);
     181                        break;
     182        }
     183}
     184
     185function openRows() {
     186        var ids = [];
     187        jQuery('table.widefat tr.inline').each(function(i) {
     188          ids[i] = this.id.split('-')[1];
     189        });
     190        return ids.join(',');
     191}
     192
     193function selectedRows() {
     194        var ids = [];
     195        jQuery('table.widefat .check-column :checked').each(function(i) { ids[i] = this.value; });
     196        return ids.join(',');
     197}
     198
     199function getRowId(obj) {
     200        var id = obj.tagName == 'TR' ? obj.id : jQuery(obj).parents('tr').attr('id');
     201        var parts = id.split('-');
     202        return parts[parts.length - 1];
     203}
     204 No newline at end of file
  • wp-admin/edit-post-rows.php

     
    2727        </tr>
    2828        </thead>
    2929        <tbody>
     30         
     31<?php display_edit_row() ?>       
     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() ) {
     
    168170<div class="alignleft">
    169171<select name="action">
    170172<option value="" selected><?php _e('Actions'); ?></option>
     173<option value="edit"><?php _e('Edit'); ?></option>
    171174<option value="delete"><?php _e('Delete'); ?></option>
    172 <option value="edit"><?php _e('Edit'); ?></option>
    173175</select>
    174176<input type="submit" value="<?php _e('Apply'); ?>" name="doaction" class="button-secondary action" />
    175177<?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 display_edit_row() ?>
    190193  <?php page_rows($posts, $pagenum, $per_page); ?>
    191194  </tbody>
    192195</table>