Changeset 1139 for trunk/wp-admin

Show
Ignore:
Timestamp:
10/30/07 16:49:38 (1 year ago)
Author:
donncha
Message:

Merge with WordPress? 2.3.1

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/wp-admin/admin-ajax.php

    r1130 r1139  
    55define('DOING_AJAX', true); 
    66 
     7check_ajax_referer(); 
    78if ( !is_user_logged_in() ) 
    89        die('-1'); 
     
    1112add_action( 'shutdown', 'get_out_now', -1 ); 
    1213 
     14function wp_ajax_meta_row( $pid, $mid, $key, $value ) { 
     15        $value = attribute_escape($value); 
     16        $key_js = addslashes(wp_specialchars($key, 'double')); 
     17        $key = attribute_escape($key); 
     18        $r .= "<tr id='meta-$mid'><td valign='top'>"; 
     19        $r .= "<input name='meta[$mid][key]' tabindex='6' onkeypress='return killSubmit(\"theList.ajaxUpdater(&#039;meta&#039;,&#039;meta-$mid&#039;);\",event);' type='text' size='20' value='$key' />"; 
     20        $r .= "</td><td><textarea name='meta[$mid][value]' tabindex='6' rows='2' cols='30'>$value</textarea></td><td align='center'>"; 
     21        $r .= "<input name='updatemeta' type='button' class='updatemeta' tabindex='6' value='".attribute_escape(__('Update'))."' onclick='return theList.ajaxUpdater(&#039;meta&#039;,&#039;meta-$mid&#039;);' /><br />"; 
     22        $r .= "<input name='deletemeta[$mid]' type='submit' onclick=\"return deleteSomething( 'meta', $mid, '"; 
     23        $r .= js_escape(sprintf(__("You are about to delete the '%s' custom field on this post.\n'OK' to delete, 'Cancel' to stop."), $key_js)); 
     24        $r .= "' );\" class='deletemeta' tabindex='6' value='".attribute_escape(__('Delete'))."' /></td></tr>"; 
     25        return $r; 
     26} 
     27 
    1328$id = (int) $_POST['id']; 
    14 switch ( $action = $_POST['action'] ) : 
    15 case 'add-post' : 
    16         check_ajax_referer( 'add-post' ); 
    17         add_filter( 'post_limits', $limit_filter = create_function( '$a', '$b = split(" ",$a); if ( !isset($b[2]) ) return $a; $start = intval(trim($b[1])) / 20 * 15; if ( !is_int($start) ) return $a; $start += intval(trim($b[2])) - 1; return "LIMIT $start, 1";' ) ); 
    18         wp_edit_posts_query( $_POST ); 
    19         if ( !have_posts() ) 
    20                 die('1'); 
    21         $posts_columns = wp_manage_posts_columns(); 
    22         ob_start(); 
    23                 include( 'edit-post-rows.php' ); 
    24                 $data = ob_get_contents(); 
    25         ob_end_clean(); 
    26         if ( !preg_match('|<tbody.+?>(.+)</tbody>|s', $data, $matches) ) 
    27                 my_dump($data); 
    28         $data = trim($matches[1]); 
    29         $x = new WP_Ajax_Response( array( 'what' => 'post', 'id' => $id, 'data' => $data ) ); 
    30         $x->send(); 
    31         break; 
     29switch ( $_POST['action'] ) : 
    3230case 'delete-comment' : 
    33         check_ajax_referer( "delete-comment_$id" ); 
    3431        if ( !$comment = get_comment( $id ) ) 
    3532                die('0'); 
     
    3734                die('-1'); 
    3835 
    39         if ( isset($_POST['spam']) && 1 == $_POST['spam'] ) 
    40                 $r = wp_set_comment_status( $comment->comment_ID, 'spam' ); 
    41         else 
    42                 $r = wp_delete_comment( $comment->comment_ID ); 
    43  
    44         die( $r ? '1' : '0' ); 
     36        if ( wp_delete_comment( $comment->comment_ID ) ) 
     37                die('1'); 
     38        else    die('0'); 
     39        break; 
     40case 'delete-comment-as-spam' : 
     41        if ( !$comment = get_comment( $id ) ) 
     42                die('0'); 
     43        if ( !current_user_can( 'edit_post', $comment->comment_post_ID ) ) 
     44                die('-1'); 
     45 
     46        if ( wp_set_comment_status( $comment->comment_ID, 'spam' ) ) 
     47                die('1'); 
     48        else    die('0'); 
    4549        break; 
    4650case 'delete-cat' : 
    47         check_ajax_referer( "delete-category_$id" ); 
    4851        if ( !current_user_can( 'manage_categories' ) ) 
    4952                die('-1'); 
     
    5457        break; 
    5558case 'delete-link' : 
    56         check_ajax_referer( "delete-bookmark_$id" ); 
    5759        if ( !current_user_can( 'manage_links' ) ) 
    5860                die('-1'); 
     
    6365        break; 
    6466case 'delete-meta' : 
    65         check_ajax_referer( 'change_meta' ); 
    6667        if ( !$meta = get_post_meta_by_id( $id ) ) 
    6768                die('0'); 
     
    7374        break; 
    7475case 'delete-post' : 
    75         check_ajax_referer( "{$action}_$id" ); 
    7676        if ( !current_user_can( 'delete_post', $id ) ) 
    7777                die('-1'); 
     
    7979        if ( wp_delete_post( $id ) ) 
    8080                die('1'); 
    81         else 
    82                 die('0'); 
     81        else    die('0'); 
    8382        break; 
    8483case 'delete-page' : 
    85         check_ajax_referer( "{$action}_$id" ); 
    8684        if ( !current_user_can( 'delete_page', $id ) ) 
    8785                die('-1'); 
     
    10098 
    10199        if ( 'unapproved' == wp_get_comment_status($comment->comment_ID) ) { 
    102                 check_ajax_referer( "approve-comment_$id" ); 
    103100                if ( wp_set_comment_status( $comment->comment_ID, 'approve' ) ) 
    104101                        die('1'); 
    105102        } else { 
    106                 check_ajax_referer( "unapprove-comment_$id" ); 
    107103                if ( wp_set_comment_status( $comment->comment_ID, 'hold' ) ) 
    108104                        die('1'); 
     
    111107        break; 
    112108case 'add-category' : // On the Fly 
    113         check_ajax_referer( $action ); 
    114109        if ( !current_user_can( 'manage_categories' ) ) 
    115110                die('-1'); 
     
    126121                        'what' => 'category', 
    127122                        'id' => $cat_id, 
    128                         'data' => "<li id='category-$cat_id'><label for='in-category-$cat_id' class='selectit'><input value='$cat_id' type='checkbox' checked='checked' name='post_category[]' id='in-category-$cat_id'/> $cat_name</label></li>", 
    129                         'position' => -1 
     123                        'data' => "<li id='category-$cat_id'><label for='in-category-$cat_id' class='selectit'><input value='$cat_id' type='checkbox' checked='checked' name='post_category[]' id='in-category-$cat_id'/> $cat_name</label></li>" 
    130124                ) ); 
    131125        } 
     
    133127        break; 
    134128case 'add-link-category' : // On the Fly 
    135         check_ajax_referer( $action ); 
    136129        if ( !current_user_can( 'manage_categories' ) ) 
    137130                die('-1'); 
     
    144137                if ( !$cat_id = is_term( $cat_name, 'link_category' ) ) { 
    145138                        $cat_id = wp_insert_term( $cat_name, 'link_category' ); 
     139                        $cat_id = $cat_id['term_id']; 
    146140                } 
    147                 $cat_id = $cat_id['term_id']; 
    148141                $cat_name = wp_specialchars(stripslashes($cat_name)); 
    149142                $x->add( array( 
    150143                        'what' => 'link-category', 
    151144                        'id' => $cat_id, 
    152                         'data' => "<li id='link-category-$cat_id'><label for='in-link-category-$cat_id' class='selectit'><input value='$cat_id' type='checkbox' checked='checked' name='link_category[]' id='in-link-category-$cat_id'/> $cat_name</label></li>", 
    153                         'position' => -1 
     145                        'data' => "<li id='link-category-$cat_id'><label for='in-link-category-$cat_id' class='selectit'><input value='$cat_id' type='checkbox' checked='checked' name='link_category[]' id='in-link-category-$cat_id'/> $cat_name</label></li>" 
    154146                ) ); 
    155147        } 
     
    157149        break; 
    158150case 'add-cat' : // From Manage->Categories 
    159         check_ajax_referer( 'add-category' ); 
    160151        if ( !current_user_can( 'manage_categories' ) ) 
    161152                die('-1'); 
     
    165156                die('0'); 
    166157        $level = 0; 
    167         $cat_full_name = $cat->name; 
     158        $cat_full_name = $cat->cat_name; 
    168159        $_cat = $cat; 
    169         while ( $_cat->parent ) { 
    170                 $_cat = get_category( $_cat->parent ); 
    171                 $cat_full_name = $_cat->name . ' &#8212; ' . $cat_full_name; 
     160        while ( $_cat->category_parent ) { 
     161                $_cat = get_category( $_cat->category_parent ); 
     162                $cat_full_name = $_cat->cat_name . ' &#8212; ' . $cat_full_name; 
    172163                $level++; 
    173164        } 
     
    176167        $x = new WP_Ajax_Response( array( 
    177168                'what' => 'cat', 
    178                 'id' => $cat->term_id
     169                'id' => $cat->cat_ID
    179170                'data' => _cat_row( $cat, $level, $cat_full_name ), 
    180                 'supplemental' => array('name' => $cat_full_name, 'show-link' => sprintf(__( 'Category <a href="#%s">%s</a> added' ), "cat-$cat->term_id", $cat_full_name)) 
     171                'supplemental' => array('name' => $cat_full_name, 'show-link' => sprintf(__( 'Category <a href="#%s">%s</a> added' ), "cat-$cat->cat_ID", $cat_full_name)) 
    181172        ) ); 
    182173        $x->send(); 
    183174        break; 
    184175case 'add-comment' : 
    185         check_ajax_referer( $action ); 
    186176        if ( !current_user_can( 'edit_post', $id ) ) 
    187177                die('-1'); 
    188178        $search = isset($_POST['s']) ? $_POST['s'] : false; 
    189         $start = isset($_POST['page']) ? intval($_POST['page']) * 25 - 1: 24
     179        $start = isset($_POST['page']) ? intval($_POST['page']) * 25 : 25
    190180 
    191181        list($comments, $total) = _wp_get_comment_list( $search, $start, 1 ); 
     
    209199        break; 
    210200case 'add-meta' : 
    211         check_ajax_referer( 'change_meta' ); 
    212         $c = 0; 
    213         $pid = (int) $_POST['post_id']; 
    214         if ( isset($_POST['addmeta']) ) { 
    215                 if ( !current_user_can( 'edit_post', $pid ) ) 
    216                         die('-1'); 
    217                 if ( $pid < 0 ) { 
    218                         $now = current_time('timestamp', 1); 
    219                         if ( $pid = wp_insert_post( array( 
    220                                 'post_title' => sprintf('Draft created on %s at %s', date(get_option('date_format'), $now), date(get_option('time_format'), $now)) 
    221                         ) ) ) { 
    222                                 if ( is_wp_error( $pid ) ) { 
    223                                         $x = new WP_Ajax_Response( array( 
    224                                                 'what' => 'meta', 
    225                                                 'data' => $pid 
    226                                         ) ); 
    227                                         $x->send(); 
    228                                 } 
    229                                 $mid = add_meta( $pid ); 
    230                         } else { 
    231                                 die('0'); 
    232                         } 
    233                 } else if ( !$mid = add_meta( $pid ) ) { 
     201        if ( !current_user_can( 'edit_post', $id ) ) 
     202                die('-1'); 
     203        if ( $id < 0 ) { 
     204                $now = current_time('timestamp', 1); 
     205                if ( $pid = wp_insert_post( array( 
     206                        'post_title' => sprintf('Draft created on %s at %s', date(get_option('date_format'), $now), date(get_option('time_format'), $now)) 
     207                ) ) ) { 
     208                        if ( is_wp_error( $pid ) ) 
     209                                return $pid; 
     210                        $mid = add_meta( $pid ); 
     211                } 
     212                else 
    234213                        die('0'); 
    235                 } 
    236  
    237                 $meta = get_post_meta_by_id( $mid ); 
    238                 $pid = (int) $meta->post_id; 
    239                 $meta = get_object_vars( $meta ); 
    240                 $x = new WP_Ajax_Response( array( 
    241                         'what' => 'meta', 
    242                         'id' => $mid, 
    243                         'data' => _list_meta_row( $meta, $c ), 
    244                         'position' => 1, 
    245                         'supplemental' => array('postid' => $pid) 
    246                 ) ); 
    247         } else { 
    248                 $mid = (int) array_pop(array_keys($_POST['meta'])); 
    249                 $key = $_POST['meta'][$mid]['key']; 
    250                 $value = $_POST['meta'][$mid]['value']; 
    251                 if ( !$meta = get_post_meta_by_id( $mid ) ) 
    252                         die('0'); // if meta doesn't exist 
    253                 if ( !current_user_can( 'edit_post', $meta->post_id ) ) 
    254                         die('-1'); 
    255                 if ( !$u = update_meta( $mid, $key, $value ) ) 
    256                         die('1'); // We know meta exists; we also know it's unchanged (or DB error, in which case there are bigger problems). 
     214        } else if ( !$mid = add_meta( $id ) ) { 
     215                die('0'); 
     216        } 
     217 
     218        $meta = get_post_meta_by_id( $mid ); 
     219        $key = $meta->meta_key; 
     220        $value = $meta->meta_value; 
     221        $pid = (int) $meta->post_id; 
     222 
     223        $x = new WP_Ajax_Response( array( 
     224                'what' => 'meta', 
     225                'id' => $mid, 
     226                'data' => wp_ajax_meta_row( $pid, $mid, $key, $value ), 
     227                'supplemental' => array('postid' => $pid) 
     228        ) ); 
     229        $x->send(); 
     230        break; 
     231case 'update-meta' : 
     232        $mid = (int) array_pop(array_keys($_POST['meta'])); 
     233        $key = $_POST['meta'][$mid]['key']; 
     234        $value = $_POST['meta'][$mid]['value']; 
     235        if ( !$meta = get_post_meta_by_id( $mid ) ) 
     236                die('0'); // if meta doesn't exist 
     237        if ( !current_user_can( 'edit_post', $meta->post_id ) ) 
     238                die('-1'); 
     239        if ( $u = update_meta( $mid, $key, $value ) ) { 
    257240                $key = stripslashes($key); 
    258241                $value = stripslashes($value); 
    259242                $x = new WP_Ajax_Response( array( 
    260243                        'what' => 'meta', 
    261                         'id' => $mid, 'old_id' => $mid, 
    262                         'data' => _list_meta_row( array( 
    263                                 'meta_key' => $key, 
    264                                 'meta_value' => $value, 
    265                                 'meta_id' => $mid 
    266                         ), $c ), 
    267                         'position' => 0, 
     244                        'id' => $mid, 
     245                        'data' => wp_ajax_meta_row( $meta->post_id, $mid, $key, $value ), 
    268246                        'supplemental' => array('postid' => $meta->post_id) 
    269247                ) ); 
    270         } 
    271         $x->send(); 
     248                $x->send(); 
     249        } 
     250        die('1'); // We know meta exists; we also know it's unchanged (or DB error, in which case there are bigger problems). 
    272251        break; 
    273252case 'add-user' : 
    274         check_ajax_referer( $action ); 
    275253        if ( !current_user_can('edit_users') ) 
    276254                die('-1'); 
     
    284262        } 
    285263        $user_object = new WP_User( $user_id ); 
    286  
    287264        $x = new WP_Ajax_Response( array( 
    288265                'what' => 'user', 
    289266                'id' => $user_id, 
    290267                'data' => user_row( $user_object ), 
    291                 'supplemental' => array( 
    292                         'show-link' => sprintf(__( 'User <a href="#%s">%s</a> added' ), "user-$user_id", $user_object->user_login), 
    293                         'role' => $user_object->roles[0] 
    294                 ) 
     268                'supplemental' => array('show-link' => sprintf(__( 'User <a href="#%s">%s</a> added' ), "user-$user_id", $user_object->user_login)) 
    295269        ) ); 
    296270        $x->send(); 
    297271        break; 
    298272case 'autosave' : // The name of this action is hardcoded in edit_post() 
    299         check_ajax_referer( $action ); 
    300273        $_POST['post_content'] = $_POST['content']; 
    301274        $_POST['post_excerpt'] = $_POST['excerpt']; 
     
    328301break; 
    329302case 'autosave-generate-nonces' : 
    330         check_ajax_referer( $action ); 
    331303        $ID = (int) $_POST['post_ID']; 
    332304        if($_POST['post_type'] == 'post') { 
  • trunk/wp-admin/categories.php

    r1125 r1139  
    103103        </tr> 
    104104        </thead> 
    105         <tbody id="the-list" class="list:cat"
     105        <tbody id="the-list"
    106106<?php 
    107107cat_rows(); 
  • trunk/wp-admin/edit-category-form.php

    r1131 r1139  
    1010        $heading = __('Add Category'); 
    1111        $submit_text = __('Add Category &raquo;'); 
    12         $form = '<form name="addcat" id="addcat" method="post" action="categories.php" class="add:the-list:">'; 
     12        $form = '<form name="addcat" id="addcat" method="post" action="categories.php">'; 
    1313        $action = 'addcat'; 
    1414        $nonce_action = 'add-category'; 
  • trunk/wp-admin/edit-comments.php

    r1125 r1139  
    103103                $start = " start='$offset'"; 
    104104 
    105                 echo "<ol id='the-comment-list' class='list:comment commentlist' $start>\n"; 
     105                echo "<ol id='the-comment-list' class='commentlist' $start>\n"; 
    106106                $i = 0; 
    107107                foreach ( $comments as $comment ) { 
     108                        get_comment( $comment ); // Cache it 
    108109                        _wp_comment_list_item( $comment->comment_ID, ++$i ); 
    109110                } 
     
    112113if ( $extra_comments ) : ?> 
    113114<div id="extra-comments" style="display:none"> 
    114 <ol id="the-extra-comment-list" class="list:comment commentlist" style="color:red"> 
     115<ul id="the-extra-comment-list" class="commentlist"> 
    115116<?php 
    116117        foreach ( $extra_comments as $comment ) { 
    117118                get_comment( $comment ); // Cache it 
    118                 _wp_comment_list_item( $comment->comment_ID, 0 ); 
    119         } 
    120 ?> 
    121 </ol> 
    122 <form action="" method="get" id="get-extra-comments" class="add:the-extra-comment-list:"> 
    123 <input type="hidden" name="page" value="<?php echo $page; ?>" /> 
    124 <input type="hidden" name="s" value="<?php echo attribute_escape(@$_GET['s']); ?>" /> 
    125 <?php wp_nonce_field( 'add-comment', '_ajax_nonce', false ); ?> 
     119                _wp_comment_list_item( $comment->comment_ID, ++$i ); 
     120        } 
     121?> 
     122</ul> 
    126123</div> 
    127124<?php endif; // $extra_comments ?> 
     
    153150        <th scope="col" colspan="3" style="text-align: center">' .  __('Actions') . '</th> 
    154151  </tr> 
    155 </thead> 
    156 <tbody id="the-comment-list" class="list:comment">'; 
     152</thead>'; 
    157153                foreach ($comments as $comment) { 
    158154                $post = get_post($comment->comment_post_ID); 
     
    164160  <tr id="comment-<?php echo $comment->comment_ID; ?>" class='<?php echo $class; ?>'> 
    165161    <td style="text-align: center"><?php if ( current_user_can('edit_post', $comment->comment_post_ID) ) { ?><input type="checkbox" name="delete_comments[]" value="<?php echo $comment->comment_ID; ?>" /><?php } ?></td> 
    166     <td class="comment-author"><?php comment_author_link() ?></td> 
     162    <td><?php comment_author_link() ?></td> 
    167163    <td><?php comment_author_email_link() ?></td> 
    168164    <td><a href="edit-comments.php?s=<?php comment_author_IP() ?>&amp;mode=edit"><?php comment_author_IP() ?></a></td> 
     
    178174        echo "<a href='comment.php?action=editcomment&amp;c=$comment->comment_ID' class='edit'>" .  __('Edit') . "</a>"; } ?></td> 
    179175    <td><?php if ( current_user_can('edit_post', $comment->comment_post_ID) ) { 
    180                 $url = clean_url( wp_nonce_url( "comment.php?action=deletecomment&p=$comment->comment_post_ID&c=$comment->comment_ID", "delete-comment_$comment->comment_ID" ) ); 
    181                 echo "<a href='$url' class='delete:the-comment-list:comment-$comment->comment_ID delete'>" . __('Delete') . "</a> "; 
     176                echo "<a href=\"comment.php?action=deletecomment&amp;p=".$comment->comment_post_ID."&amp;c=".$comment->comment_ID."\" onclick=\"return deleteSomething( 'comment', $comment->comment_ID, '" . js_escape(sprintf(__("You are about to delete this comment by '%s'. \n  'Cancel' to stop, 'OK' to delete."), $comment->comment_author ))  . "', theCommentList );\" class='delete'>" . __('Delete') . "</a> "; 
    182177                } ?></td> 
    183178  </tr> 
    184179                <?php 
    185180                } // end foreach 
    186         ?></tbody> 
    187 </table> 
     181        ?></table> 
    188182<p class="submit"><input type="submit" name="delete_button" class="delete" value="<?php _e('Delete Checked Comments &raquo;') ?>" onclick="var numchecked = getNumChecked(document.getElementById('deletecomments')); if(numchecked < 1) { alert('<?php echo js_escape(__("Please select some comments to delete")); ?>'); return false } return confirm('<?php echo sprintf(js_escape(__("You are about to delete %s comments permanently \n  'Cancel' to stop, 'OK' to delete.")), "' + numchecked + '"); ?>')" /> 
    189183                        <input type="submit" name="spam_button" value="<?php _e('Mark Checked Comments as Spam &raquo;') ?>" onclick="var numchecked = getNumChecked(document.getElementById('deletecomments')); if(numchecked < 1) { alert('<?php echo js_escape(__("Please select some comments to mark as spam")); ?>'); return false } return confirm('<?php echo sprintf(js_escape(__("You are about to mark %s comments as spam \n  'Cancel' to stop, 'OK' to mark as spam.")), "' + numchecked + '"); ?>')" /></p> 
  • trunk/wp-admin/edit-form-advanced.php

    r1125 r1139  
    7575<h3 class="dbx-handle"><?php _e('Categories') ?></h3> 
    7676<div class="dbx-content"> 
    77 <p id="jaxcat"><?php wp_nonce_field( 'add-category', '_ajax_nonce', false ); ?></p> 
    78 <ul id="categorychecklist" class="list:category"><?php dropdown_categories(); ?></ul></div> 
     77<p id="jaxcat"></p> 
     78<ul id="categorychecklist"><?php dropdown_categories(); ?></ul></div> 
    7979</fieldset> 
    8080 
  • trunk/wp-admin/edit-link-form.php

    r1125 r1139  
    4343<h3 class="dbx-handle"><?php _e('Categories') ?></h3> 
    4444<div class="dbx-content"> 
    45 <p id="jaxcat"><?php wp_nonce_field( 'add-link-category', '_ajax_nonce', false ); ?></p> 
    46 <ul id="categorychecklist" class="list:link-category"><?php dropdown_link_categories(get_option('default_link_category')); ?></ul> 
     45<p id="jaxcat"></p> 
     46<ul id="linkcategorychecklist"><?php dropdown_link_categories(get_option('default_link_category')); ?></ul> 
    4747</div> 
    4848</fieldset> 
  • trunk/wp-admin/edit-pages.php

    r1125 r1139  
    33$title = __('Pages'); 
    44$parent_file = 'edit.php'; 
    5 wp_enqueue_script( 'wp-lists' ); 
     5wp_enqueue_script( 'listman' ); 
    66require_once('admin-header.php'); 
    77 
     
    2121 
    2222?> 
    23 <script> 
    24 /* <![CDATA[ */ 
    25 jQuery(function($){$('#the-list').wpList();}); 
    26 /* ]]> */ 
    27 </script> 
     23 
    2824<div class="wrap"> 
     25 
    2926<h2><?php 
    3027// Use $_GET instead of is_ since they can override each other 
     
    8582  </tr> 
    8683  </thead> 
    87   <tbody id="the-list" class="list:page"
     84  <tbody id="the-list"
    8885<?php page_rows(0, 0, $posts, $all); ?> 
    8986  </tbody> 
  • trunk/wp-admin/edit-post-rows.php

    r1125 r1139  
    1010        </tr> 
    1111        </thead> 
    12         <tbody id="the-list" class="list:post"
     12        <tbody id="the-list"
    1313<?php 
    14 $i_post = 0; 
    1514if ( have_posts() ) { 
    1615$bgcolor = ''; 
    1716add_filter('the_title','wp_specialchars'); 
    18 while (have_posts()) : the_post(); $i_post++; 
    19 if ( 16 == $i_post ) 
    20         echo "\t</tbody>\n\t<tbody id='the-extra-list' class='list:post' style='display: none'>\n"; // Hack! 
    21 $class = ( $i_post > 15 || 'alternate' == $class) ? '' : 'alternate'; 
     17while (have_posts()) : the_post(); 
     18$class = ('alternate' == $class) ? '' : 'alternate'; 
    2219global $current_user; 
    2320$post_owner = ( $current_user->ID == $post->post_author ? 'self' : 'other' ); 
     
    9592        case 'control_delete': 
    9693                ?> 
    97                 <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:the-list:post-$post->ID delete'>" . __('Delete') . "</a>"; } ?></td> 
     94                <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' onclick=\"return deleteSomething( 'post', " . $id . ", '" . js_escape(sprintf(__("You are about to delete this post '%s'.\n'OK' to delete, 'Cancel' to stop."), get_the_title())) . "' );\">" . __('Delete') . "</a>"; } ?></td> 
    9895                <?php 
    9996                break; 
  • trunk/wp-admin/edit.php

    r1130 r1139  
    44$title = __('Posts'); 
    55$parent_file = 'edit.php'; 
    6 wp_enqueue_script( 'admin-posts' ); 
    7 if ( 1 == $_GET['c'] ) 
    8         wp_enqueue_script( 'admin-comments' ); 
     6wp_enqueue_script( 1 == $_GET['c'] ? 'admin-comments' : 'listman' ); 
    97require_once('admin-header.php'); 
    108 
    11 add_filter( 'post_limits', $limit_filter = create_function( '$a', '$b = split(" ",$a); if ( !isset($b[2]) ) return $a; $start = intval(trim($b[1])) / 20 * 15; if ( !is_int($start) ) return $a; return "LIMIT $start, 20";' ) ); 
    12 list($post_stati, $avail_post_stati) = wp_edit_posts_query(); 
    13 $wp_query->max_num_pages = ceil( $wp_query->found_posts / 15 ); // We grab 20 but only show 15 ( 5 more for ajax extra ) 
     9$_GET['m']   = (int) $_GET['m']; 
     10$_GET['cat'] = (int) $_GET['cat']; 
     11$post_stati  = array(   //      array( adj, noun ) 
     12                        'publish' => array(__('Published'), __('Published posts')), 
     13                        'future' => array(__('Scheduled'), __('Scheduled posts')), 
     14                        'pending' => array(__('Pending Review'), __('Pending posts')), 
     15                        'draft' => array(__('Draft'), _c('Drafts|manage posts header')), 
     16                        'private' => array(__('Private'), __('Private posts')) 
     17                ); 
     18 
     19$avail_post_stati = $wpdb->get_col("SELECT DISTINCT post_status FROM $wpdb->posts WHERE post_type = 'post'"); 
     20 
     21$post_status_q = ''; 
     22$post_status_label = __('Posts'); 
     23if ( isset($_GET['post_status']) && in_array( $_GET['post_status'], array_keys($post_stati) ) ) { 
     24        $post_status_label = $post_stati[$_GET['post_status']][1]; 
     25        $post_status_q = '&post_status=' . $_GET['post_status']; 
     26
    1427?> 
    1528 
     
    1831<?php 
    1932 
    20 $posts_columns = wp_manage_posts_columns(); 
     33if ( 'pending' === $_GET['post_status'] ) { 
     34        $order = 'ASC'; 
     35        $orderby = 'modified'; 
     36} elseif ( 'draft' === $_GET['post_status'] ) { 
     37        $order = 'DESC'; 
     38        $orderby = 'modified'; 
     39} else { 
     40        $order = 'DESC'; 
     41        $orderby = 'date'; 
     42
     43 
     44wp("what_to_show=posts$post_status_q&posts_per_page=15&order=$order&orderby=$orderby"); 
     45 
     46// define the columns to display, the syntax is 'internal name' => 'display name' 
     47$posts_columns = array(); 
     48$posts_columns['id'] = '<div style="text-align: center">' . __('ID') . '</div>'; 
     49if ( 'draft' === $_GET['post_status'] ) 
     50        $posts_columns['modified'] = __('Modified'); 
     51elseif ( 'pending' === $_GET['post_status'] ) 
     52        $posts_columns['modified'] = __('Submitted'); 
     53else 
     54        $posts_columns['date'] = __('When'); 
     55$posts_columns['title'] = __('Title'); 
     56$posts_columns['categories'] = __('Categories'); 
     57if ( !in_array($_GET['post_status'], array('pending', 'draft', 'future')) ) 
     58        $posts_columns['comments'] = '<div style="text-align: center">' . __('Comments') . '</div>'; 
     59$posts_columns['author'] = __('Author'); 
     60 
     61$posts_columns = apply_filters('manage_posts_columns', $posts_columns); 
     62 
     63// you can not edit these at the moment 
     64$posts_columns['control_view']   = ''; 
     65$posts_columns['control_edit']   = ''; 
     66$posts_columns['control_delete'] = ''; 
    2167 
    2268?> 
     
    117163<?php include( 'edit-post-rows.php' ); ?> 
    118164 
    119 <form action="" method="post" id="get-extra-posts" class="add:the-extra-list:" style="display:none"> 
    120         <?php wp_nonce_field( 'add-post', '_ajax_nonce', false ); ?> 
    121 </form> 
    122  
    123165<div id="ajax-response"></div> 
    124166 
     
    134176        $comments = $wpdb->get_results("SELECT * FROM $wpdb->comments WHERE comment_post_ID = $id AND comment_approved != 'spam' ORDER BY comment_date"); 
    135177        if ($comments) { 
    136                 // Make sure comments, post, and post_author are cached 
    137178                update_comment_cache($comments); 
    138                 $post = get_post($id); 
    139                 $authordata = get_userdata($post->post_author); 
    140179        ?> 
    141180<h3 id="comments"><?php _e('Comments') ?></h3> 
    142 <ol id="the-comment-list" class="list:comment commentlist"> 
    143 <?php 
    144                 $i = 0; 
    145                 foreach ( $comments as $comment ) { 
    146                         _wp_comment_list_item( $comment->comment_ID, ++$i ); 
    147                 } 
     181<ol id="the-comment-list" class="commentlist"> 
     182<?php 
     183$i = 0; 
     184foreach ($comments as $comment) { 
     185 
     186                ++$i; $class = ''; 
     187                $post = get_post($comment->comment_post_ID); 
     188                $authordata = get_userdata($post->post_author); 
     189                        $comment_status = wp_get_comment_status($comment->comment_ID); 
     190                        if ('unapproved' == $comment_status) 
     191                                $class .= ' unapproved'; 
     192                        if ($i % 2) 
     193                                $class .= ' alternate'; 
     194                        echo "<li id='comment-$comment->comment_ID' class='$class'>"; 
     195?> 
     196<p><strong><?php comment_author() ?></strong> <?php if ($comment->comment_author_email) { ?>| <?php comment_author_email_link() ?> <?php } if ($comment->comment_author_url && 'http://' != $comment->comment_author_url) { ?> | <?php comment_author_url_link() ?> <?php } ?>| <?php _e('IP:') ?> <a href="edit-comments.php?s=<?php comment_author_IP() ?>&amp;mode=edit"><?php comment_author_IP() ?></a></p> 
     197 
     198<?php comment_text() ?> 
     199 
     200<p><?php comment_date(__('M j, g:i A')); ?> &#8212; [ 
     201<?php 
     202if ( current_user_can('edit_post', $comment->comment_post_ID) ) { 
     203        echo " <a href='comment.php?action=editcomment&amp;c=".$comment->comment_ID."'>" . __('Edit') . '</a>'; 
     204        echo ' | <a href="' . wp_nonce_url('comment.php?action=deletecomment&amp;p=' . $comment->comment_post_ID . '&amp;c=' . $comment->comment_ID, 'delete-comment_' . $comment->comment_ID) . '" onclick="return deleteSomething( \'comment\', ' . $comment->comment_ID . ', \'' . js_escape(sprintf(__("You are about to delete this comment by '%s'.\n'Cancel' to stop, 'OK' to delete."), $comment->comment_author)) . "', theCommentList );\">" . __('Delete') . '</a> '; 
     205        if ( ('none' != $comment_status) && ( current_user_can('moderate_comments') ) ) { 
     206                echo '<span class="unapprove"> | <a href="' . wp_nonce_url('comment.php?action=unapprovecomment&amp;p=' . $comment->comment_post_ID . '&amp;c=' . $comment->comment_ID, 'unapprove-comment_' . $comment->comment_ID) . '" onclick="return dimSomething( \'comment\', ' . $comment->comment_ID . ', \'unapproved\', theCommentList );">' . __('Unapprove') . '</a> </span>'; 
     207                echo '<span class="approve"> | <a href="' . wp_nonce_url('comment.php?action=approvecomment&amp;p=' . $comment->comment_post_ID . '&amp;c=' . $comment->comment_ID, 'approve-comment_' . $comment->comment_ID) . '" onclick="return dimSomething( \'comment\', ' . $comment->comment_ID . ', \'unapproved\', theCommentList );">' . __('Approve') . '</a> </span>'; 
     208        } 
     209        echo " | <a href=\"" . wp_nonce_url("comment.php?action=deletecomment&amp;dt=spam&amp;p=" . $comment->comment_post_ID . "&amp;c=" . $comment->comment_ID, 'delete-comment_' . $comment->comment_ID) . "\" onclick=\"return deleteSomething( 'comment-as-spam', $comment->comment_ID, '" . js_escape(sprintf(__("You are about to mark as spam this comment by '%s'.\n'Cancel' to stop, 'OK' to mark as spam."), $comment->comment_author)) . "', theCommentList );\">" . __('Spam') . "</a> "; 
     210
     211?> ] 
     212</p> 
     213                </li> 
     214 
     215<?php //end of the loop, don't delete 
     216                } // end foreach 
    148217        echo '</ol>'; 
    149         } // end if comments 
    150 ?> 
     218        }//end if comments 
     219       ?> 
    151220<?php } ?> 
    152221</div> 
  • trunk/wp-admin/export.php

    r1125 r1139  
    183183<!--    contained in this file into your blog --> 
    184184 
    185 <?php the_generator('export');?
     185<!-- generator="wordpress/<?php bloginfo_rss('version') ?>" created="<?php echo date('Y-m-d H:i'); ?>"--
    186186<rss version="2.0" 
    187187        xmlns:content="http://purl.org/rss/1.0/modules/content/" 
  • trunk/wp-admin/import/mt.php

    r1069 r1139  
    139139                foreach ($authors as $author) { 
    140140                        ++ $j; 
    141                         echo '<li><i>'.$author.'</i><br />'.'<input type="text" value="'.$author.'" name="'.'user[]'.'" maxlength="30">'; 
     141                        echo '<li>'.__('Current author:').' <strong>'.$author.'</strong><br />'.'<input type="text" value="'.$author.'" name="'.'user[]'.'" maxlength="30">'; 
    142142                        $this->users_form($j); 
    143143                        echo '</li>'; 
  • trunk/wp-admin/includes/plugin.php

    r1125 r1139  
    8787} 
    8888 
    89 function activate_plugin($plugin) { 
    90                 $current = get_option('active_plugins'); 
    91                 $plugin = trim($plugin); 
    92  
    93                 if ( validate_file($plugin) ) 
    94                         return new WP_Error('plugin_invalid', __('Invalid plugin.')); 
    95                 if ( ! file_exists(ABSPATH . PLUGINDIR . '/' . $plugin) ) 
    96                         return new WP_Error('plugin_not_found', __('Plugin file does not exist.')); 
    97  
    98                 if (!in_array($plugin, $current)) { 
    99                         wp_redirect(add_query_arg('_error_nonce', wp_create_nonce('plugin-activation-error_' . $plugin), 'plugins.php?error=true&plugin=' . $plugin)); // we'll override this later if the plugin can be included without fatal error 
    100                         ob_start(); 
    101                         @include(ABSPATH . PLUGINDIR . '/' . $plugin); 
    102                         $current[] = $plugin; 
    103                         sort($current); 
    104                         update_option('active_plugins', $current); 
    105                         do_action('activate_' . $plugin); 
    106                         ob_end_clean(); 
    107                 } 
    108  
    109                 return null; 
    110 } 
    111  
    112 function deactivate_plugins($plugins) { 
    113         $current = get_option('active_plugins'); 
    114  
    115         if(!is_array($plugins)) 
    116                 $plugins = array($plugins); 
    117  
    118         foreach($plugins as $plugin) { 
    119                 array_splice($current, array_search( $plugin, $current), 1 ); // Array-fu! 
    120                 do_action('deactivate_' . trim( $plugin )); 
    121         } 
    122  
    123         update_option('active_plugins', $current); 
    124 } 
    125  
    126 function deactivate_all_plugins() { 
    127         $current = get_option('active_plugins'); 
    128         deactivate_plugins($current); 
    129 } 
    130  
    13189// 
    13290// Menu 
  • trunk/wp-admin/includes/post.php

    r1130 r1139  
    349349                        return false; 
    350350 
    351                 wp_cache_delete($post_ID, 'post_meta'); 
    352  
    353351                $result = $wpdb->query( " 
    354352                                                INSERT INTO $wpdb->postmeta 
     
    365363        $mid = (int) $mid; 
    366364 
    367         $post_id = $wpdb->get_var("SELECT post_id FROM $wpdb->postmeta WHERE meta_id = '$mid'"); 
    368         wp_cache_delete($post_id, 'post_meta'); 
    369  
    370365        return $wpdb->query( "DELETE FROM $wpdb->postmeta WHERE meta_id = '$mid'" ); 
    371366} 
     
    413408        if ( in_array($mkey, $protected) ) 
    414409                return false; 
    415  
    416         $post_id = $wpdb->get_var("SELECT post_id FROM $wpdb->postmeta WHERE meta_id = '$mid'"); 
    417         wp_cache_delete($post_id, 'post_meta'); 
    418410 
    419411        $mvalue = maybe_serialize( stripslashes( $mvalue )); 
     
    477469} 
    478470 
    479 function wp_edit_posts_query( $q = false ) { 
    480         global $wpdb; 
    481         if ( false === $q ) 
    482                 $q = $_GET; 
    483         $q['m']   = (int) $q['m']; 
    484         $q['cat'] = (int) $q['cat']; 
    485         $post_stati  = array(   //      array( adj, noun ) 
    486                                 'draft' => array(__('Draft'), _c('Drafts|manage posts header')), 
    487                                 'future' => array(__('Scheduled'), __('Scheduled posts')), 
    488                                 'pending' => array(__('Pending Review'), __('Pending posts')), 
    489                                 'private' => array(__('Private'), __('Private posts')), 
    490                                 'publish' => array(__('Published'), __('Published posts')) 
    491                         ); 
    492  
    493         $avail_post_stati = $wpdb->get_col("SELECT DISTINCT post_status FROM $wpdb->posts WHERE post_type = 'post'"); 
    494  
    495         $post_status_q = ''; 
    496         $post_status_label = _c('Posts|manage posts header'); 
    497         if ( isset($q['post_status']) && in_array( $q['post_status'], array_keys($post_stati) ) ) { 
    498                 $post_status_label = $post_stati[$q['post_status']][1]; 
    499                 $post_status_q = '&post_status=' . $q['post_status']; 
    500         } 
    501  
    502         if ( 'pending' === $q['post_status'] ) { 
    503                 $order = 'ASC'; 
    504                 $orderby = 'modified'; 
    505         } elseif ( 'draft' === $q['post_status'] ) { 
    506                 $order = 'DESC'; 
    507                 $orderby = 'modified'; 
    508         } else { 
    509                 $order = 'DESC'; 
    510