Index: /trunk/wp-admin/admin-ajax.php
===================================================================
--- /trunk/wp-admin/admin-ajax.php (revision 6212)
+++ /trunk/wp-admin/admin-ajax.php (revision 6213)
@@ -5,5 +5,4 @@
define('DOING_AJAX', true);
-check_ajax_referer();
if ( !is_user_logged_in() )
die('-1');
@@ -12,21 +11,23 @@
add_action( 'shutdown', 'get_out_now', -1 );
-function wp_ajax_meta_row( $pid, $mid, $key, $value ) {
- $value = attribute_escape($value);
- $key_js = addslashes(wp_specialchars($key, 'double'));
- $key = attribute_escape($key);
- $r .= "
";
- $r .= "";
- $r .= " | | ";
- $r .= " ";
- $r .= " |
";
- return $r;
-}
-
$id = (int) $_POST['id'];
-switch ( $_POST['action'] ) :
+switch ( $action = $_POST['action'] ) :
+case 'add-post' :
+ check_ajax_referer( 'add-post' );
+ 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";' ) );
+ wp_edit_posts_query( '_POST' );
+ $posts_columns = wp_manage_posts_columns();
+ ob_start();
+ include( 'edit-post-rows.php' );
+ $data = ob_get_contents();
+ ob_end_clean();
+ if ( !preg_match('|(.+)|s', $data, $matches) )
+ my_dump($data);
+ $data = trim($matches[1]);
+ $x = new WP_Ajax_Response( array( 'what' => 'post', 'id' => $id, 'data' => $data ) );
+ $x->send();
+ break;
case 'delete-comment' :
+ check_ajax_referer( "delete-comment_$id" );
if ( !$comment = get_comment( $id ) )
die('0');
@@ -34,35 +35,31 @@
die('-1');
- if ( wp_delete_comment( $comment->comment_ID ) )
+ if ( isset($_POST['spam']) && 1 == $_POST['spam'] )
+ $r = wp_set_comment_status( $comment->comment_ID, 'spam' );
+ else
+ $r = wp_delete_comment( $comment->comment_ID );
+
+ die( $r ? '1' : '0' );
+ break;
+case 'delete-cat' :
+ check_ajax_referer( "delete-category_$id" );
+ if ( !current_user_can( 'manage_categories' ) )
+ die('-1');
+
+ if ( wp_delete_category( $id ) )
die('1');
else die('0');
break;
-case 'delete-comment-as-spam' :
- if ( !$comment = get_comment( $id ) )
- die('0');
- if ( !current_user_can( 'edit_post', $comment->comment_post_ID ) )
- die('-1');
-
- if ( wp_set_comment_status( $comment->comment_ID, 'spam' ) )
+case 'delete-link' :
+ check_ajax_referer( "delete-bookmark_$id" );
+ if ( !current_user_can( 'manage_links' ) )
+ die('-1');
+
+ if ( wp_delete_link( $id ) )
die('1');
else die('0');
break;
-case 'delete-cat' :
- if ( !current_user_can( 'manage_categories' ) )
- die('-1');
-
- if ( wp_delete_category( $id ) )
- die('1');
- else die('0');
- break;
-case 'delete-link' :
- if ( !current_user_can( 'manage_links' ) )
- die('-1');
-
- if ( wp_delete_link( $id ) )
- die('1');
- else die('0');
- break;
case 'delete-meta' :
+ check_ajax_referer( 'change_meta' );
if ( !$meta = get_post_meta_by_id( $id ) )
die('0');
@@ -74,4 +71,5 @@
break;
case 'delete-post' :
+ check_ajax_referer( "{$action}_$id" );
if ( !current_user_can( 'delete_post', $id ) )
die('-1');
@@ -79,7 +77,9 @@
if ( wp_delete_post( $id ) )
die('1');
- else die('0');
+ else
+ die('0');
break;
case 'delete-page' :
+ check_ajax_referer( "{$action}_$id" );
if ( !current_user_can( 'delete_page', $id ) )
die('-1');
@@ -98,7 +98,9 @@
if ( 'unapproved' == wp_get_comment_status($comment->comment_ID) ) {
+ check_ajax_referer( "approve-comment_$id" );
if ( wp_set_comment_status( $comment->comment_ID, 'approve' ) )
die('1');
} else {
+ check_ajax_referer( "unapprove-comment_$id" );
if ( wp_set_comment_status( $comment->comment_ID, 'hold' ) )
die('1');
@@ -107,4 +109,5 @@
break;
case 'add-category' : // On the Fly
+ check_ajax_referer( $action );
if ( !current_user_can( 'manage_categories' ) )
die('-1');
@@ -121,5 +124,6 @@
'what' => 'category',
'id' => $cat_id,
- 'data' => ""
+ 'data' => "",
+ 'position' => -1
) );
}
@@ -127,4 +131,5 @@
break;
case 'add-link-category' : // On the Fly
+ check_ajax_referer( $action );
if ( !current_user_can( 'manage_categories' ) )
die('-1');
@@ -137,11 +142,12 @@
if ( !$cat_id = is_term( $cat_name, 'link_category' ) ) {
$cat_id = wp_insert_term( $cat_name, 'link_category' );
- $cat_id = $cat_id['term_id'];
}
+ $cat_id = $cat_id['term_id'];
$cat_name = wp_specialchars(stripslashes($cat_name));
$x->add( array(
'what' => 'link-category',
'id' => $cat_id,
- 'data' => ""
+ 'data' => "",
+ 'position' => -1
) );
}
@@ -149,4 +155,5 @@
break;
case 'add-cat' : // From Manage->Categories
+ check_ajax_referer( 'add-category' );
if ( !current_user_can( 'manage_categories' ) )
die('-1');
@@ -156,9 +163,9 @@
die('0');
$level = 0;
- $cat_full_name = $cat->cat_name;
+ $cat_full_name = $cat->name;
$_cat = $cat;
- while ( $_cat->category_parent ) {
- $_cat = get_category( $_cat->category_parent );
- $cat_full_name = $_cat->cat_name . ' — ' . $cat_full_name;
+ while ( $_cat->parent ) {
+ $_cat = get_category( $_cat->parent );
+ $cat_full_name = $_cat->name . ' — ' . $cat_full_name;
$level++;
}
@@ -167,15 +174,16 @@
$x = new WP_Ajax_Response( array(
'what' => 'cat',
- 'id' => $cat->cat_ID,
+ 'id' => $cat->term_id,
'data' => _cat_row( $cat, $level, $cat_full_name ),
- 'supplemental' => array('name' => $cat_full_name, 'show-link' => sprintf(__( 'Category %s added' ), "cat-$cat->cat_ID", $cat_full_name))
+ 'supplemental' => array('name' => $cat_full_name, 'show-link' => sprintf(__( 'Category %s added' ), "cat-$cat->term_id", $cat_full_name))
) );
$x->send();
break;
case 'add-comment' :
+ check_ajax_referer( $action );
if ( !current_user_can( 'edit_post', $id ) )
die('-1');
$search = isset($_POST['s']) ? $_POST['s'] : false;
- $start = isset($_POST['page']) ? intval($_POST['page']) * 25 : 25;
+ $start = isset($_POST['page']) ? intval($_POST['page']) * 25 - 1: 24;
list($comments, $total) = _wp_get_comment_list( $search, $start, 1 );
@@ -199,56 +207,68 @@
break;
case 'add-meta' :
- if ( !current_user_can( 'edit_post', $id ) )
- die('-1');
- if ( $id < 0 ) {
- $now = current_time('timestamp', 1);
- if ( $pid = wp_insert_post( array(
- 'post_title' => sprintf('Draft created on %s at %s', date(get_option('date_format'), $now), date(get_option('time_format'), $now))
- ) ) ) {
- if ( is_wp_error( $pid ) )
- return $pid;
- $mid = add_meta( $pid );
+ check_ajax_referer( 'change_meta' );
+ $c = 0;
+ $pid = (int) $_POST['post_id'];
+ if ( isset($_POST['addmeta']) ) {
+ if ( !current_user_can( 'edit_post', $pid ) )
+ die('-1');
+ if ( $pid < 0 ) {
+ $now = current_time('timestamp', 1);
+ if ( $pid = wp_insert_post( array(
+ 'post_title' => sprintf('Draft created on %s at %s', date(get_option('date_format'), $now), date(get_option('time_format'), $now))
+ ) ) ) {
+ if ( is_wp_error( $pid ) ) {
+ $x = new WP_Ajax_Response( array(
+ 'what' => 'meta',
+ 'data' => $pid
+ ) );
+ $x->send();
+ }
+ $mid = add_meta( $pid );
+ } else {
+ die('0');
+ }
+ } else if ( !$mid = add_meta( $pid ) ) {
+ die('0');
}
- else
- die('0');
- } else if ( !$mid = add_meta( $id ) ) {
- die('0');
- }
-
- $meta = get_post_meta_by_id( $mid );
- $key = $meta->meta_key;
- $value = $meta->meta_value;
- $pid = (int) $meta->post_id;
-
- $x = new WP_Ajax_Response( array(
- 'what' => 'meta',
- 'id' => $mid,
- 'data' => wp_ajax_meta_row( $pid, $mid, $key, $value ),
- 'supplemental' => array('postid' => $pid)
- ) );
- $x->send();
- break;
-case 'update-meta' :
- $mid = (int) array_pop(array_keys($_POST['meta']));
- $key = $_POST['meta'][$mid]['key'];
- $value = $_POST['meta'][$mid]['value'];
- if ( !$meta = get_post_meta_by_id( $mid ) )
- die('0'); // if meta doesn't exist
- if ( !current_user_can( 'edit_post', $meta->post_id ) )
- die('-1');
- if ( $u = update_meta( $mid, $key, $value ) ) {
+
+ $meta = get_post_meta_by_id( $mid );
+ $pid = (int) $meta->post_id;
+ $meta = get_object_vars( $meta );
+ $x = new WP_Ajax_Response( array(
+ 'what' => 'meta',
+ 'id' => $mid,
+ 'data' => _list_meta_row( $meta, $c ),
+ 'position' => 1,
+ 'supplemental' => array('postid' => $pid)
+ ) );
+ } else {
+ $mid = (int) array_pop(array_keys($_POST['meta']));
+ $key = $_POST['meta'][$mid]['key'];
+ $value = $_POST['meta'][$mid]['value'];
+ if ( !$meta = get_post_meta_by_id( $mid ) )
+ die('0'); // if meta doesn't exist
+ if ( !current_user_can( 'edit_post', $meta->post_id ) )
+ die('-1');
+ if ( !$u = update_meta( $mid, $key, $value ) )
+ die('1'); // We know meta exists; we also know it's unchanged (or DB error, in which case there are bigger problems).
$key = stripslashes($key);
$value = stripslashes($value);
$x = new WP_Ajax_Response( array(
'what' => 'meta',
- 'id' => $mid,
- 'data' => wp_ajax_meta_row( $meta->post_id, $mid, $key, $value ),
+ 'id' => $mid, 'old_id' => $mid,
+ 'data' => _list_meta_row( array(
+ 'meta_key' => $key,
+ 'meta_value' => $value,
+ 'meta_id' => $mid
+ ), $c ),
+ 'position' => 0,
'supplemental' => array('postid' => $meta->post_id)
) );
- $x->send();
- }
- die('1'); // We know meta exists; we also know it's unchanged (or DB error, in which case there are bigger problems).
+ }
+ $x->send();
break;
case 'add-user' :
+ check_ajax_referer( $action );
if ( !current_user_can('edit_users') )
die('-1');
@@ -262,13 +282,18 @@
}
$user_object = new WP_User( $user_id );
+
$x = new WP_Ajax_Response( array(
'what' => 'user',
'id' => $user_id,
'data' => user_row( $user_object ),
- 'supplemental' => array('show-link' => sprintf(__( 'User %s added' ), "user-$user_id", $user_object->user_login))
+ 'supplemental' => array(
+ 'show-link' => sprintf(__( 'User %s added' ), "user-$user_id", $user_object->user_login),
+ 'role' => $user_object->roles[0]
+ )
) );
$x->send();
break;
case 'autosave' : // The name of this action is hardcoded in edit_post()
+ check_ajax_referer( $action );
$_POST['post_content'] = $_POST['content'];
$_POST['post_excerpt'] = $_POST['excerpt'];
@@ -301,4 +326,5 @@
break;
case 'autosave-generate-nonces' :
+ check_ajax_referer( $action );
$ID = (int) $_POST['post_ID'];
if($_POST['post_type'] == 'post') {
Index: /trunk/wp-admin/categories.php
===================================================================
--- /trunk/wp-admin/categories.php (revision 6212)
+++ /trunk/wp-admin/categories.php (revision 6213)
@@ -100,5 +100,5 @@
-
+
';
+ $form = '
Index: /trunk/wp-admin/edit-comments.php
===================================================================
--- /trunk/wp-admin/edit-comments.php (revision 6212)
+++ /trunk/wp-admin/edit-comments.php (revision 6213)
@@ -103,5 +103,5 @@
$start = " start='$offset'";
- echo "
\n"; $i = 0; foreach ( $comments as $comment ) { @@ -113,12 +113,16 @@ if ( $extra_comments ) : ?>' . __('Actions') . '
-';
+
+';
foreach ($comments as $comment) {
$post = get_post($comment->comment_post_ID);
@@ -160,5 +165,5 @@
comment_post_ID) ) { ?>
-
+
@@ -174,10 +179,12 @@
echo "" . __('Edit') . ""; } ?>
comment_post_ID) ) {
- echo "comment_post_ID."&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') . " ";
+ $url = clean_url( wp_nonce_url( "comment.php?action=deletecomment&p=$comment->comment_post_ID&c=$comment->comment_ID", "delete-comment_$comment->comment_ID" ) );
+ echo "" . __('Delete') . " ";
} ?>
+ ?>
+
-
-
+
+
-
-
Index: /trunk/wp-admin/edit-pages.php
===================================================================
--- /trunk/wp-admin/edit-pages.php (revision 6212)
+++ /trunk/wp-admin/edit-pages.php (revision 6213)
@@ -3,5 +3,5 @@
$title = __('Pages');
$parent_file = 'edit.php';
-wp_enqueue_script( 'listman' );
+wp_enqueue_script( 'wp-lists' );
require_once('admin-header.php');
@@ -21,7 +21,10 @@
?>
-
+
-
@@ -150,5 +154,6 @@'); return false } return confirm('')" /> '); return false } return confirm('')" />
Index: /trunk/wp-admin/edit-form-advanced.php =================================================================== --- /trunk/wp-admin/edit-form-advanced.php (revision 6212) +++ /trunk/wp-admin/edit-form-advanced.php (revision 6213) @@ -75,6 +75,6 @@Index: /trunk/wp-admin/edit-link-form.php =================================================================== --- /trunk/wp-admin/edit-link-form.php (revision 6212) +++ /trunk/wp-admin/edit-link-form.php (revision 6213) @@ -43,6 +43,6 @@
+ +
- + Index: /trunk/wp-admin/edit-post-rows.php =================================================================== --- /trunk/wp-admin/edit-post-rows.php (revision 6212) +++ /trunk/wp-admin/edit-post-rows.php (revision 6213) @@ -9,11 +9,14 @@ - + \n\t\n"; // Hack! +$class = ( $i_post > 15 || 'alternate' == $class) ? '' : 'alternate'; global $current_user; $post_owner = ( $current_user->ID == $post->post_author ? 'self' : 'other' ); @@ -91,5 +94,5 @@ case 'control_delete': ?> -ID) ) { echo "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') . ""; } ?>
+ ID) ) { echo "ID) . "' class='delete:the-list:post-$post->ID delete'>" . __('Delete') . ""; } ?>
array(__('Published'), __('Published posts')),
- 'future' => array(__('Scheduled'), __('Scheduled posts')),
- 'pending' => array(__('Pending Review'), __('Pending posts')),
- 'draft' => array(__('Draft'), _c('Drafts|manage posts header')),
- 'private' => array(__('Private'), __('Private posts'))
- );
-
-$avail_post_stati = $wpdb->get_col("SELECT DISTINCT post_status FROM $wpdb->posts WHERE post_type = 'post'");
-
-$post_status_q = '';
-$post_status_label = __('Posts');
-if ( isset($_GET['post_status']) && in_array( $_GET['post_status'], array_keys($post_stati) ) ) {
- $post_status_label = $post_stati[$_GET['post_status']][1];
- $post_status_q = '&post_status=' . $_GET['post_status'];
-}
+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";' ) );
+list($post_stati, $avail_post_stati) = wp_edit_posts_query();
+$wp_query->max_num_pages = ceil( $wp_query->found_posts / 15 ); // We grab 20 but only show 15 ( 5 more for ajax extra )
?>
@@ -31,38 +18,5 @@
'display name'
-$posts_columns = array();
-$posts_columns['id'] = '' . __('ID') . ' ';
-if ( 'draft' === $_GET['post_status'] )
- $posts_columns['modified'] = __('Modified');
-elseif ( 'pending' === $_GET['post_status'] )
- $posts_columns['modified'] = __('Submitted');
-else
- $posts_columns['date'] = __('When');
-$posts_columns['title'] = __('Title');
-$posts_columns['categories'] = __('Categories');
-if ( !in_array($_GET['post_status'], array('pending', 'draft', 'future')) )
- $posts_columns['comments'] = '' . __('Comments') . ' ';
-$posts_columns['author'] = __('Author');
-
-$posts_columns = apply_filters('manage_posts_columns', $posts_columns);
-
-// you can not edit these at the moment
-$posts_columns['control_view'] = '';
-$posts_columns['control_edit'] = '';
-$posts_columns['control_delete'] = '';
+$posts_columns = wp_manage_posts_columns();
?>
@@ -155,4 +109,6 @@
+
+
Index: /trunk/wp-admin/includes/post.php
===================================================================
--- /trunk/wp-admin/includes/post.php (revision 6212)
+++ /trunk/wp-admin/includes/post.php (revision 6213)
@@ -469,3 +469,40 @@
}
+function wp_edit_posts_query( $q = '_GET' ) {
+ global $wpdb;
+ $$q['m'] = (int) $$q['m'];
+ $$q['cat'] = (int) $$q['cat'];
+ $post_stati = array( // array( adj, noun )
+ 'draft' => array(__('Draft'), _c('Drafts|manage posts header')),
+ 'future' => array(__('Scheduled'), __('Scheduled posts')),
+ 'pending' => array(__('Pending Review'), __('Pending posts')),
+ 'private' => array(__('Private'), __('Private posts')),
+ 'publish' => array(__('Published'), __('Published posts'))
+ );
+
+ $avail_post_stati = $wpdb->get_col("SELECT DISTINCT post_status FROM $wpdb->posts WHERE post_type = 'post'");
+
+ $post_status_q = '';
+ $post_status_label = _c('Posts|manage posts header');
+ if ( isset($$q['post_status']) && in_array( $$q['post_status'], array_keys($post_stati) ) ) {
+ $post_status_label = $post_stati[$$q['post_status']][1];
+ $post_status_q = '&post_status=' . $$q['post_status'];
+ }
+
+ if ( 'pending' === $$q['post_status'] ) {
+ $order = 'ASC';
+ $orderby = 'modified';
+ } elseif ( 'draft' === $$q['post_status'] ) {
+ $order = 'DESC';
+ $orderby = 'modified';
+ } else {
+ $order = 'DESC';
+ $orderby = 'date';
+ }
+
+ wp("what_to_show=posts$post_status_q&posts_per_page=20&order=$order&orderby=$orderby");
+
+ return array($post_stati, $avail_post_stati);
+}
+
?>
Index: /trunk/wp-admin/includes/template.php
===================================================================
--- /trunk/wp-admin/includes/template.php (revision 6212)
+++ /trunk/wp-admin/includes/template.php (revision 6213)
@@ -42,5 +42,5 @@
if ( $category->term_id != $default_cat_id )
- $edit .= "term_id ) . "' onclick=\"return deleteSomething( 'cat', $category->term_id, '" . js_escape(sprintf( __("You are about to delete the category '%s'.\nAll posts that were only assigned to this category will be assigned to the '%s' category.\nAll links that were only assigned to this category will be assigned to the '%s' category.\n'OK' to delete, 'Cancel' to stop." ), $category->name, get_catname( $default_cat_id ), get_catname( $default_link_cat_id ) )) . "' );\" class='delete'>".__( 'Delete' )."";
+ $edit .= " term_id ) . "' class='delete:the-list:cat-$category->term_id delete'>".__( 'Delete' )."";
else
$edit .= " ".__( "Default" );
@@ -165,4 +165,29 @@
}
+// define the columns to display, the syntax is 'internal name' => 'display name'
+function wp_manage_posts_columns() {
+ $posts_columns = array();
+ $posts_columns['id'] = '' . __('ID') . ' ';
+ if ( 'draft' === $_GET['post_status'] )
+ $posts_columns['modified'] = __('Modified');
+ elseif ( 'pending' === $_GET['post_status'] )
+ $posts_columns['modified'] = __('Submitted');
+ else
+ $posts_columns['date'] = __('When');
+ $posts_columns['title'] = __('Title');
+ $posts_columns['categories'] = __('Categories');
+ if ( !in_array($_GET['post_status'], array('pending', 'draft', 'future')) )
+ $posts_columns['comments'] = '' . __('Comments') . ' ';
+ $posts_columns['author'] = __('Author');
+ $posts_columns = apply_filters('manage_posts_columns', $posts_columns);
+
+ // you can not edit these at the moment
+ $posts_columns['control_view'] = '';
+ $posts_columns['control_edit'] = '';
+ $posts_columns['control_delete'] = '';
+
+ return $posts_columns;
+}
+
function page_rows( $parent = 0, $level = 0, $pages = 0, $hierarchy = true ) {
global $wpdb, $class, $post;
@@ -191,7 +216,7 @@
post_modified ) _e('Unpublished'); else echo mysql2date( __('Y-m-d g:i a'), $post->post_modified ); ?>
-
+
" . __( 'Edit' ) . ""; } ?>
- " . __( 'Delete' ) . ""; } ?>
+ " . __( 'Delete' ) . ""; } ?>
@@ -263,17 +288,17 @@
function _wp_comment_list_item( $id, $alt = 0 ) {
global $authordata, $comment, $wpdb;
- $id = (int) $id;
$comment =& get_comment( $id );
+ $id = (int) $comment->comment_ID;
$class = '';
$post = get_post($comment->comment_post_ID);
$authordata = get_userdata($post->post_author);
- $comment_status = wp_get_comment_status($comment->comment_ID);
+ $comment_status = wp_get_comment_status($id);
if ( 'unapproved' == $comment_status )
$class .= ' unapproved';
if ( $alt % 2 )
$class .= ' alternate';
- echo "- ";
-?>
-
- ";
+?>
+
'; //TBODY needed for list-manipulation JS
+ echo ' '; //TBODY needed for list-manipulation JS
return;
}
@@ -337,41 +366,45 @@
-";
- foreach ( $meta as $entry ) {
- ++ $count;
- if ( $count % 2 )
- $style = 'alternate';
- else
- $style = '';
- if ('_' == $entry['meta_key'] { 0 } )
- $style .= ' hidden';
-
- if ( is_serialized( $entry['meta_value'] ) ) {
- if ( is_serialized_string( $entry['meta_value'] ) ) {
- // this is a serialized string, so we should display it
- $entry['meta_value'] = maybe_unserialize( $entry['meta_value'] );
- } else {
- // this is a serialized array/object so we should NOT display it
- --$count;
- continue;
- }
- }
-
- $key_js = js_escape( $entry['meta_key'] );
- $entry['meta_key'] = attribute_escape($entry['meta_key']);
- $entry['meta_value'] = attribute_escape($entry['meta_value']);
- $entry['meta_id'] = (int) $entry['meta_id'];
- $r .= "\n\t";
- $r .= "\n\t\t ";
- $r .= "\n\t\t ";
- $r .= "\n\t\t ";
- $r .= "\n\t ";
- }
- echo $r;
+
+";
+}
+
+function _list_meta_row( $entry, &$count ) {
+ $r = '';
+ ++ $count;
+ if ( $count % 2 )
+ $style = 'alternate';
+ else
+ $style = '';
+ if ('_' == $entry['meta_key'] { 0 } )
+ $style .= ' hidden';
+
+ if ( is_serialized( $entry['meta_value'] ) ) {
+ if ( is_serialized_string( $entry['meta_value'] ) ) {
+ // this is a serialized string, so we should display it
+ $entry['meta_value'] = maybe_unserialize( $entry['meta_value'] );
+ } else {
+ // this is a serialized array/object so we should NOT display it
+ --$count;
+ return;
+ }
+ }
+
+ $key_js = js_escape( $entry['meta_key'] );
+ $entry['meta_key'] = attribute_escape($entry['meta_key']);
+ $entry['meta_value'] = attribute_escape($entry['meta_value']);
+ $entry['meta_id'] = (int) $entry['meta_id'];
+ $r .= "\n\t";
+ $r .= "\n\t\t ";
+ $r .= "\n\t\t ";
+ $r .= "\n\t\t \n\t ";
+ return $r;
}
@@ -414,6 +447,9 @@
+
+
+
+
-
' + catL10n.how + '');
- $('newcat').onkeypress = function(e) { return killSubmit("catList.ajaxAdder('category','jaxcat');", e); };
- $('catadd').onclick = function() { catList.ajaxAdder('category', 'jaxcat'); };
-}
+jQuery( function($) {
+ $('#jaxcat').prepend('' + catL10n.how + '')
+ var a = $('#categorychecklist').wpList( { alt: '', response: 'cat-ajax-response' } );
+} );
Index: /trunk/wp-admin/js/categories.js
===================================================================
--- /trunk/wp-admin/js/categories.js (revision 6212)
+++ /trunk/wp-admin/js/categories.js (revision 6213)
@@ -1,16 +1,18 @@
-addLoadEvent(function() {
- if (!theList.theList) return false;
- document.forms.addcat.submit.onclick = function(e) {return killSubmit('theList.ajaxAdder("cat", "addcat");', e); };
- theList.addComplete = function(what, where, update, transport) {
- var name = getNodeValue(transport.responseXML, 'name').unescapeHTML();
- var id = transport.responseXML.getElementsByTagName(what)[0].getAttribute('id');
- var options = document.forms['addcat'].category_parent.options;
+jQuery(function($) {
+ var options = document.forms['addcat'].category_parent.options;
+
+ var addAfter = function( r, settings ) {
+ var name = $("" + $('name', r).text() + "").html();
+ var id = $('cat', r).attr('id');
options[options.length] = new Option(name, id);
- };
- theList.delComplete = function(what, id) {
- var options = document.forms['addcat'].category_parent.options;
+ }
+
+ var delAfter = function( r, settings ) {
+ var id = $('cat', r).attr('id');
for ( var o = 0; o < options.length; o++ )
if ( id == options[o].value )
options[o] = null;
- };
+ }
+
+ var a = $('#the-list').wpList( { addAfter: addAfter, delAfter: delAfter } );
});
Index: /trunk/wp-admin/js/custom-fields.js
===================================================================
--- /trunk/wp-admin/js/custom-fields.js (revision 6212)
+++ /trunk/wp-admin/js/custom-fields.js (revision 6213)
@@ -1,26 +1,33 @@
-function customFieldsOnComplete( what, where, update, transport ) {
- var pidEl = $('post_ID');
- pidEl.name = 'post_ID';
- pidEl.value = getNodeValue(transport.responseXML, 'postid');
- var aEl = $('hiddenaction')
- if ( aEl.value == 'post' ) aEl.value = 'postajaxpost';
-}
-addLoadEvent(customFieldsAddIn);
-function customFieldsAddIn() {
- theList.showLink=0;
- theList.addComplete = customFieldsOnComplete;
- if (!theList.theList) return false;
- inputs = theList.theList.getElementsByTagName('input');
- for ( var i=0; i < inputs.length; i++ ) {
- if ('text' == inputs[i].type) {
- inputs[i].setAttribute('autocomplete', 'off');
- inputs[i].onkeypress = function(e) {return killSubmit('theList.ajaxUpdater("meta", "meta-' + parseInt(this.name.slice(5),10) + '");', e); };
- }
- if ('updatemeta' == inputs[i].className) {
- inputs[i].onclick = function(e) {return killSubmit('theList.ajaxUpdater("meta", "meta-' + parseInt(this.parentNode.parentNode.id.slice(5),10) + '");', e); };
- }
+jQuery( function($) {
+ var before = function() {
+ var nonce = $('#newmeta [@name=_ajax_nonce]').val();
+ var postId = $('#post_ID').val();
+ if ( !nonce || !postId ) { return false; }
+ return [nonce,postId];
}
- $('metakeyinput').onkeypress = function(e) {return killSubmit('theList.inputData+="&id="+$("post_ID").value;theList.ajaxAdder("meta", "newmeta");', e); };
- $('updatemetasub').onclick = function(e) {return killSubmit('theList.inputData+="&id="+$("post_ID").value;theList.ajaxAdder("meta", "newmeta");', e); };
-}
+ var addBefore = function( s ) {
+ var b = before();
+ if ( !b ) { return false; }
+ s.data = s.data.replace(/_ajax_nonce=[a-f0-9]+/, '_ajax_nonce=' + b[0]) + '&post_id=' + b[1];
+ return s;
+ };
+
+ var addAfter = function( r, s ) {
+ var postId = $('postid', r).text();
+ if ( !postId ) { return; }
+ $('#post_ID').attr( 'name', 'post_ID' ).val( postId );
+ var h = $('#hiddenaction');
+ if ( 'post' == h.val() ) { h.val( 'postajaxpost' ); }
+ };
+
+ var delBefore = function( s ) {
+ var b = before(); if ( !b ) return false;
+ s.data._ajax_nonce = b[0]; s.data.post_id = b[1];
+ return s;
+ }
+
+ $('#the-list')
+ .wpList( { addBefore: addBefore, addAfter: addAfter, delBefore: delBefore } )
+ .find('.updatemeta, .deletemeta').attr( 'type', 'button' );
+} );
Index: /trunk/wp-admin/js/edit-comments.js
===================================================================
--- /trunk/wp-admin/js/edit-comments.js (revision 6212)
+++ /trunk/wp-admin/js/edit-comments.js (revision 6213)
@@ -1,59 +1,26 @@
-addLoadEvent(function() {
- theCommentList = new listMan('the-comment-list');
- if ( !theCommentList )
- return false;
+var list; var extra;
+jQuery(function($) {
- theExtraCommentList = new listMan('the-extra-comment-list');
- if ( theExtraCommentList ) {
- theExtraCommentList.showLink = 0;
- theExtraCommentList.altOffset = 1;
- if ( theExtraCommentList.theList && theExtraCommentList.theList.childNodes )
- var commentNum = $A(theExtraCommentList.theList.childNodes).findAll( function(i) { return Element.visible(i) } ).length;
- else
- var commentNum = 0;
- var urlQ = document.location.href.split('?');
- var params = urlQ[1] ? urlQ[1].toQueryParams() : [];
- var search = params['s'] ? params['s'] : '';
- var page = params['apage'] ? params['apage'] : 1;
+var dimAfter = function( r, settings ) {
+ var a = $('#awaitmod');
+ a.html( parseInt(a.html(),10) + ( $('#' + settings.element).is('.' + settings.dimClass) ? 1 : -1 ) );
+}
+
+var delAfter = function( r, settings ) {
+ var a = $('#awaitmod');
+ if ( $('#' + settings.element).is('.unapproved') && parseInt(a.html(),10) > 0 ) {
+ a.html( parseInt(a.html(),10) - 1 );
}
- theCommentList.dimComplete = function(what,id,dimClass) {
- var m = document.getElementById('awaitmod');
- if ( document.getElementById(what + '-' + id).className.match(dimClass) )
- m.innerHTML = parseInt(m.innerHTML,10) + 1;
- else
- m.innerHTML = parseInt(m.innerHTML,10) - 1;
+ if ( extra.size() == 0 || extra.children().size() == 0 ) {
+ return;
}
- theCommentList.delComplete = function(what,id) {
- var m = document.getElementById('awaitmod');
- what = what.split('-')[0];
- if ( document.getElementById(what + '-' + id).className.match('unapproved') )
- m.innerHTML = parseInt(m.innerHTML,10) - 1;
- if ( theExtraCommentList && commentNum ) {
- var theMover = theExtraCommentList.theList.childNodes[0];
- Element.removeClassName(theMover,'alternate');
- theCommentList.theList.appendChild(theMover);
- theExtraCommentList.inputData += '&page=' + page;
- if ( search )
- theExtraCommentList.inputData += '&s=' + search; // trust the URL not the search box
- theExtraCommentList.addComplete = function() {
- if ( theExtraCommentList.theList.childNodes )
- var commentNum = $A(theExtraCommentList.theList.childNodes).findAll( function(i) { return Element.visible(i) } ).length;
- else
- var commentNum = 0;
- }
- theExtraCommentList.ajaxAdder( 'comment', 'ajax-response' ); // Dummy Request
- }
- }
+ list[0].wpList.add( extra.children(':eq(0)').remove().clone() );
+ $('#get-extra-comments').submit();
+}
- if ( theList ) // the post list: edit.php
- theList.delComplete = function() {
- var comments = document.getElementById('comments');
- var commdel = encloseFunc(function(a){a.parentNode.removeChild(a);},comments);
- var listdel = encloseFunc(function(a){a.parentNode.removeChild(a);},theCommentList.theList);
- setTimeout(commdel,705);
- setTimeout(listdel,705);
- }
-});
+extra = $('#the-extra-comment-list').wpList( { alt: '', delColor: 'none', addColor: 'none' } );
+list = $('#the-comment-list').wpList( { dimAfter : dimAfter, delAfter : delAfter, addColor: 'none' } );
+} );
Index: /trunk/wp-admin/js/edit-posts.js
===================================================================
--- /trunk/wp-admin/js/edit-posts.js (revision 6213)
+++ /trunk/wp-admin/js/edit-posts.js (revision 6213)
@@ -0,0 +1,22 @@
+jQuery(function($) {
+var delAfter; var extra; var list;
+
+if ( document.location.href.match(/(\?|&)c=/) )
+ delAfter = function() { $('#comments, #the-comment-list').remove(); }
+else
+ delAfter = function() {
+ list[0].wpList.add( extra.children(':eq(0)').remove().clone() );
+ $('#get-extra-button').click();
+ }
+
+var addBefore = function ( settings ) {
+ var q = document.location.href.split('?');
+ if ( q[1] )
+ settings.data += '&' + q[1];
+ return settings;
+}
+
+extra = $('#the-extra-list').wpList( { alt: '', addBefore: addBefore, addColor: 'none', delColor: 'none' } );
+list = $('#the-list').wpList( { delAfter: delAfter, addColor: 'none' } );
+
+} );
Index: /trunk/wp-admin/js/link-cat.js
===================================================================
--- /trunk/wp-admin/js/link-cat.js (revision 6212)
+++ /trunk/wp-admin/js/link-cat.js (revision 6213)
@@ -1,10 +1,0 @@
-addLoadEvent(function(){linkcatList=new listMan('linkcategorychecklist');linkcatList.ajaxRespEl='jaxcat';linkcatList.topAdder=1;linkcatList.alt=0;linkcatList.showLink=0;});
-addLoadEvent(newLinkCatAddIn);
-function newLinkCatAddIn() {
- var jaxcat = $('jaxcat');
- if ( !jaxcat )
- return false;
- Element.update(jaxcat,'' + linkcatL10n.how + '');
- $('newcat').onkeypress = function(e) { return killSubmit("linkcatList.ajaxAdder('link-category','jaxcat');", e); };
- $('catadd').onclick = function() { linkcatList.ajaxAdder('link-category', 'jaxcat'); };
-}
Index: /trunk/wp-admin/js/users.js
===================================================================
--- /trunk/wp-admin/js/users.js (revision 6212)
+++ /trunk/wp-admin/js/users.js (revision 6213)
@@ -1,21 +1,22 @@
-addLoadEvent(function() {
- theListEls = document.getElementsByTagName('tbody');
- theUserLists = new Array();
- for ( var l = 0; l < theListEls.length; l++ ) {
- if ( theListEls[l].id )
- theUserLists[theListEls[l].id] = new listMan(theListEls[l].id);
- }
- addUserInputs = document.getElementById('adduser').getElementsByTagName('input');
- for ( var i = 0; i < addUserInputs.length; i++ ) {
- addUserInputs[i].onkeypress = function(e) { return killSubmit('addUserSubmit();', e); }
- }
- document.getElementById('addusersub').onclick = function(e) { return killSubmit('addUserSubmit();', e); }
-}
-);
+jQuery( function($) {
+ var userLists; var list; var addBefore; var addAfter;
-function addUserSubmit() {
- var roleEl = document.getElementById('role');
- var role = roleEl.options[roleEl.selectedIndex].value;
- if ( !theUserLists['role-' + role] ) return true;
- return theUserLists['role-' + role].ajaxAdder('user', 'adduser');
-}
+ addBefore = function( s ) {
+ if ( $( '#role-' + $('#role').val() ).size() )
+ return s;
+ return false;
+ };
+
+ addAfter = function( r, s ) {
+ var roleTable = $( '#role-' + $('role', r).text() );
+
+ var e = $('#user-' + $('user', r).attr('id') );
+ if ( !roleTable.size() ) { return; }
+ if ( !e.size() ) { return; }
+
+ roleTable[0].wpList.add(e.remove().clone());
+ };
+
+ userLists = $('.user-list').wpList();
+ list = $('#user-list').wpList( { addBefore: addBefore, addAfter: addAfter } );
+} );
Index: /trunk/wp-admin/link-add.php
===================================================================
--- /trunk/wp-admin/link-add.php (revision 6212)
+++ /trunk/wp-admin/link-add.php (revision 6213)
@@ -14,5 +14,5 @@
wp_enqueue_script( array('xfn', 'dbx-admin-key?pagenow=link.php') );
if ( current_user_can( 'manage_categories' ) )
- wp_enqueue_script( 'ajaxlinkcat' );
+ wp_enqueue_script( 'ajaxcat' );
require('admin-header.php');
?>
Index: /trunk/wp-admin/link-manager.php
===================================================================
--- /trunk/wp-admin/link-manager.php (revision 6212)
+++ /trunk/wp-admin/link-manager.php (revision 6213)
@@ -7,5 +7,5 @@
require_once ('admin.php');
-wp_enqueue_script( 'listman' );
+wp_enqueue_script( 'wp-lists' );
wp_reset_vars(array('action', 'cat_id', 'linkurl', 'name', 'image', 'description', 'visible', 'target', 'category', 'link_id', 'submit', 'order_by', 'links_show_cat_id', 'rating', 'rel', 'notes', 'linkcheck[]'));
@@ -47,5 +47,5 @@
?>
@@ -129,5 +132,5 @@
-
+
'.__('Edit').'';
- echo 'link_id , '".js_escape(sprintf(__("You are about to delete the '%s' link to %s.\n'Cancel' to stop, 'OK' to delete."), $link->link_name, $link->link_url )).'\' );" class="delete">'.__('Delete').' ';
+ echo "" . __('Edit') . ' ';
+ echo "link_id.'&action=delete', 'delete-bookmark_' . $link->link_id ) . "' class='delete:the-list:link-$link->link_id delete'>" . __('Delete') . ' ';
break;
default:
Index: /trunk/wp-admin/page.php
===================================================================
--- /trunk/wp-admin/page.php (revision 6212)
+++ /trunk/wp-admin/page.php (revision 6213)
@@ -108,8 +108,12 @@
if ($_POST['save']) {
$location = "page.php?action=edit&post=$page_ID";
- } elseif ($_POST['updatemeta']) {
- $location = wp_get_referer() . '&message=2#postcustom';
+ } elseif ($_POST['addemeta']) {
+ $location = add_query_arg( 'message', 2, wp_get_referer() );
+ $location = explode('#', $location);
+ $location = $location[0] . '#postcustom';
} elseif ($_POST['deletemeta']) {
- $location = wp_get_referer() . '&message=3#postcustom';
+ $location = add_query_arg( 'message', 3, wp_get_referer() );
+ $location = explode('#', $location);
+ $location = $location[0] . '#postcustom';
} elseif (!empty($_POST['referredby']) && $_POST['referredby'] != wp_get_referer()) {
$location = $_POST['referredby'];
Index: /trunk/wp-admin/post.php
===================================================================
--- /trunk/wp-admin/post.php (revision 6212)
+++ /trunk/wp-admin/post.php (revision 6213)
@@ -122,8 +122,12 @@
if ($_POST['save']) {
$location = "post.php?action=edit&post=$post_ID";
- } elseif ($_POST['updatemeta']) {
- $location = wp_get_referer() . '&message=2#postcustom';
+ } elseif ($_POST['addemeta']) {
+ $location = add_query_arg( 'message', 2, wp_get_referer() );
+ $location = explode('#', $location);
+ $location = $location[0] . '#postcustom';
} elseif ($_POST['deletemeta']) {
- $location = wp_get_referer() . '&message=3#postcustom';
+ $location = add_query_arg( 'message', 3, wp_get_referer() );
+ $location = explode('#', $location);
+ $location = $location[0] . '#postcustom';
} elseif (!empty($referredby) && $referredby != $referer) {
$location = $_POST['referredby'];
Index: /trunk/wp-admin/users.php
===================================================================
--- /trunk/wp-admin/users.php (revision 6212)
+++ /trunk/wp-admin/users.php (revision 6213)
@@ -394,5 +394,5 @@
-" class="list:user user-list">' . sprintf(__('Users cannot currently register themselves, but you can manually create users here.'), get_option('siteurl').'/wp-admin/options-general.php#users_can_register') . '';
?>
-
comment_author_email) { ?>| comment_author_url && 'http://' != $comment->comment_author_url) { ?> | |
+ echo "comment_author_email) { ?>| comment_author_url && 'http://' != $comment->comment_author_url) { ?> | |
@@ -282,11 +307,15 @@ comment_post_ID) ) { - echo " " . __('Edit') . ''; - echo ' | comment_author)) . "', theCommentList );\">" . __('Delete') . ' '; + echo " " . __('Edit') . ''; + $url = clean_url( wp_nonce_url( "comment.php?action=deletecomment&p=$comment->comment_post_ID&c=$id", "delete-comment_$id" ) ); + echo " | " . __('Delete') . ' '; if ( ('none' != $comment_status) && ( current_user_can('moderate_comments') ) ) { - echo ' | ' . __('Unapprove') . ' '; - echo ' | ' . __('Approve') . ' '; - } - echo " | comment_post_ID . "&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') . " "; + $url = clean_url( wp_nonce_url( "comment.php?action=unapprovecomment&p=$comment->comment_post_ID&c=$id", "unapprove-comment_$id" ) ); + echo " | " . __('Unapprove') . ' '; + $url = clean_url( wp_nonce_url( "comment.php?action=approvecomment&p=$comment->comment_post_ID&c=$id", "approve-comment_$id" ) ); + echo " | " . __('Approve') . ' '; + } + $url = clean_url( wp_nonce_url( "comment.php?action=deletecomment&dt=spam&p=$comment->comment_post_ID&c=$id", "delete-comment_$id" ) ); + echo " | " . __('Spam') . ' '; } $post = get_post($comment->comment_post_ID, OBJECT, 'display'); @@ -325,5 +354,5 @@ // Exit if no meta if (!$meta ) { - echo '"; - $r .= "\n\t\t
"; + $r .= "\n\t\t"; + $r .= ""; + $r .= "