diff --git a/wp-admin/admin-ajax.php b/wp-admin/admin-ajax.php
index 06df8afb45..a11b542699 100644
--- a/wp-admin/admin-ajax.php
+++ b/wp-admin/admin-ajax.php
@@ -12,6 +12,7 @@
* @since unknown
*/
define('DOING_AJAX', true);
+define('WP_ADMIN', true);
require_once('../wp-load.php');
require_once('includes/admin.php');
@@ -715,6 +716,24 @@ case 'sample-permalink':
$slug = isset($_POST['new_slug'])? $_POST['new_slug'] : '';
die(get_sample_permalink_html($post_id, $title, $slug));
break;
+case 'inline-data':
+ get_inline_data( explode(',', $_POST['posts']) );
+ die();
+break;
+case 'inline-save':
+ inline_save_row( $_POST );
+ if ( 'page' == $_POST['post_type'] ) {
+ $post = array();
+ $post[] = get_post($_POST['post_ID']);
+ page_rows( $post );
+ } elseif ( 'post' == $_POST['post_type'] ) {
+ $mode = $_POST['post_view'];
+ $post = array();
+ $post[] = get_post($_POST['post_ID']);
+ post_rows($post);
+ }
+ die();
+break;
case 'meta-box-order':
check_ajax_referer( 'meta-box-order' );
update_user_option( $GLOBALS['current_user']->ID, "meta-box-order_$_POST[page]", $_POST['order'] );
diff --git a/wp-admin/edit-pages.php b/wp-admin/edit-pages.php
index 989cd69a27..becbd3f283 100644
--- a/wp-admin/edit-pages.php
+++ b/wp-admin/edit-pages.php
@@ -44,6 +44,7 @@ if ( isset($_GET['action']) && isset($_GET['delete']) ) {
$title = __('Pages');
$parent_file = 'edit.php';
wp_enqueue_script('admin-forms');
+wp_enqueue_script('inline-edit');
$post_stati = array( // array( adj, noun )
'publish' => array(__('Published'), __('Published pages'), __ngettext_noop('Published (%s)', 'Published (%s)')),
@@ -153,6 +154,7 @@ if ( $page_links )
@@ -187,6 +189,7 @@ if ($posts) {
+
diff --git a/wp-admin/edit-post-rows.php b/wp-admin/edit-post-rows.php
index c6fcd3cb1f..2319c760c3 100644
--- a/wp-admin/edit-post-rows.php
+++ b/wp-admin/edit-post-rows.php
@@ -27,6 +27,9 @@ if ( ! defined('ABSPATH') ) die();
+
+
+
diff --git a/wp-admin/includes/post.php b/wp-admin/includes/post.php
index 4e83a1a6c6..6b638c2974 100644
--- a/wp-admin/includes/post.php
+++ b/wp-admin/includes/post.php
@@ -9,29 +9,34 @@
* @since 2.6
*
* @param bool $update Are we updating a pre-existing post?
+ * @param post_data array Array of post data. Defaults to the contents of $_POST
* @return object|bool WP_Error on failure, true on success.
*/
-function _wp_translate_postdata( $update = false ) {
- if ( $update )
- $_POST['ID'] = (int) $_POST['post_ID'];
- $_POST['post_content'] = $_POST['content'];
- $_POST['post_excerpt'] = $_POST['excerpt'];
- $_POST['post_parent'] = isset($_POST['parent_id'])? $_POST['parent_id'] : '';
- if ( isset($_POST['trackback_url']) )
- $_POST['to_ping'] = $_POST['trackback_url'];
+function _wp_translate_postdata( $update = false, &$post_data = null ) {
- if (!empty ( $_POST['post_author_override'] ) ) {
- $_POST['post_author'] = (int) $_POST['post_author_override'];
+ if ( empty($post_data) )
+ $post_data = &$_POST;
+
+ if ( $update )
+ $post_data['ID'] = (int) $post_data['post_ID'];
+ $post_data['post_content'] = $post_data['content'];
+ $post_data['post_excerpt'] = $post_data['excerpt'];
+ $post_data['post_parent'] = isset($post_data['parent_id'])? $post_data['parent_id'] : '';
+ if ( isset($post_data['trackback_url']) )
+ $post_data['to_ping'] = $post_data['trackback_url'];
+
+ if (!empty ( $post_data['post_author_override'] ) ) {
+ $post_data['post_author'] = (int) $post_data['post_author_override'];
} else {
- if (!empty ( $_POST['post_author'] ) ) {
- $_POST['post_author'] = (int) $_POST['post_author'];
+ if (!empty ( $post_data['post_author'] ) ) {
+ $post_data['post_author'] = (int) $post_data['post_author'];
} else {
- $_POST['post_author'] = (int) $_POST['user_ID'];
+ $post_data['post_author'] = (int) $post_data['user_ID'];
}
}
- if ( isset($_POST['user_ID']) && ($_POST['post_author'] != $_POST['user_ID']) ) {
- if ( 'page' == $_POST['post_type'] ) {
+ if ( isset($post_data['user_ID']) && ($post_data['post_author'] != $post_data['user_ID']) ) {
+ if ( 'page' == $post_data['post_type'] ) {
if ( !current_user_can( 'edit_others_pages' ) ) {
return new WP_Error( 'edit_others_pages', $update ?
__( 'You are not allowed to edit pages as this user.' ) :
@@ -49,51 +54,51 @@ function _wp_translate_postdata( $update = false ) {
}
// What to do based on which button they pressed
- if ( isset($_POST['saveasdraft']) && '' != $_POST['saveasdraft'] )
- $_POST['post_status'] = 'draft';
- if ( isset($_POST['saveasprivate']) && '' != $_POST['saveasprivate'] )
- $_POST['post_status'] = 'private';
- if ( isset($_POST['publish']) && ( '' != $_POST['publish'] ) && ( $_POST['post_status'] != 'private' ) )
- $_POST['post_status'] = 'publish';
- if ( isset($_POST['advanced']) && '' != $_POST['advanced'] )
- $_POST['post_status'] = 'draft';
+ if ( isset($post_data['saveasdraft']) && '' != $post_data['saveasdraft'] )
+ $post_data['post_status'] = 'draft';
+ if ( isset($post_data['saveasprivate']) && '' != $post_data['saveasprivate'] )
+ $post_data['post_status'] = 'private';
+ if ( isset($post_data['publish']) && ( '' != $post_data['publish'] ) && ( $post_data['post_status'] != 'private' ) )
+ $post_data['post_status'] = 'publish';
+ if ( isset($post_data['advanced']) && '' != $post_data['advanced'] )
+ $post_data['post_status'] = 'draft';
- $previous_status = get_post_field('post_status', $_POST['ID']);
+ $previous_status = get_post_field('post_status', $post_data['ID']);
// Posts 'submitted for approval' present are submitted to $_POST the same as if they were being published.
// Change status from 'publish' to 'pending' if user lacks permissions to publish or to resave published posts.
- if ( 'page' == $_POST['post_type'] ) {
- if ( 'publish' == $_POST['post_status'] && !current_user_can( 'publish_pages' ) )
+ if ( 'page' == $post_data['post_type'] ) {
+ if ( 'publish' == $post_data['post_status'] && !current_user_can( 'publish_pages' ) )
if ( $previous_status != 'publish' OR !current_user_can( 'edit_published_pages') )
- $_POST['post_status'] = 'pending';
+ $post_data['post_status'] = 'pending';
} else {
- if ( isset($_POST['post_status']) && ('publish' == $_POST['post_status'] && !current_user_can( 'publish_posts' )) ) :
+ if ( isset($post_data['post_status']) && ('publish' == $post_data['post_status'] && !current_user_can( 'publish_posts' )) ) :
// Stop attempts to publish new posts, but allow already published posts to be saved if appropriate.
if ( $previous_status != 'publish' OR !current_user_can( 'edit_published_posts') )
- $_POST['post_status'] = 'pending';
+ $post_data['post_status'] = 'pending';
endif;
}
- if (!isset( $_POST['comment_status'] ))
- $_POST['comment_status'] = 'closed';
+ if (!isset( $post_data['comment_status'] ))
+ $post_data['comment_status'] = 'closed';
- if (!isset( $_POST['ping_status'] ))
- $_POST['ping_status'] = 'closed';
+ if (!isset( $post_data['ping_status'] ))
+ $post_data['ping_status'] = 'closed';
foreach ( array('aa', 'mm', 'jj', 'hh', 'mn') as $timeunit ) {
- if ( !empty( $_POST['hidden_' . $timeunit] ) && $_POST['hidden_' . $timeunit] != $_POST[$timeunit] ) {
- $_POST['edit_date'] = '1';
+ if ( !empty( $post_data['hidden_' . $timeunit] ) && $post_data['hidden_' . $timeunit] != $post_data[$timeunit] ) {
+ $post_data['edit_date'] = '1';
break;
}
}
- if ( !empty( $_POST['edit_date'] ) ) {
- $aa = $_POST['aa'];
- $mm = $_POST['mm'];
- $jj = $_POST['jj'];
- $hh = $_POST['hh'];
- $mn = $_POST['mn'];
- $ss = $_POST['ss'];
+ if ( !empty( $post_data['edit_date'] ) ) {
+ $aa = $post_data['aa'];
+ $mm = $post_data['mm'];
+ $jj = $post_data['jj'];
+ $hh = $post_data['hh'];
+ $mn = $post_data['mn'];
+ $ss = $post_data['ss'];
$aa = ($aa <= 0 ) ? date('Y') : $aa;
$mm = ($mm <= 0 ) ? date('n') : $mm;
$jj = ($jj > 31 ) ? 31 : $jj;
@@ -101,8 +106,8 @@ function _wp_translate_postdata( $update = false ) {
$hh = ($hh > 23 ) ? $hh -24 : $hh;
$mn = ($mn > 59 ) ? $mn -60 : $mn;
$ss = ($ss > 59 ) ? $ss -60 : $ss;
- $_POST['post_date'] = sprintf( "%04d-%02d-%02d %02d:%02d:%02d", $aa, $mm, $jj, $hh, $mn, $ss );
- $_POST['post_date_gmt'] = get_gmt_from_date( $_POST['post_date'] );
+ $post_data['post_date'] = sprintf( "%04d-%02d-%02d %02d:%02d:%02d", $aa, $mm, $jj, $hh, $mn, $ss );
+ $post_data['post_date_gmt'] = get_gmt_from_date( $post_data['post_date'] );
}
return true;
@@ -110,11 +115,14 @@ function _wp_translate_postdata( $update = false ) {
// Update an existing post with values provided in $_POST.
-function edit_post() {
+function edit_post( $post_data = null ) {
- $post_ID = (int) $_POST['post_ID'];
+ if ( empty($post_data) )
+ $post_data = &$_POST;
- if ( 'page' == $_POST['post_type'] ) {
+ $post_ID = (int) $post_data['post_ID'];
+
+ if ( 'page' == $post_data['post_type'] ) {
if ( !current_user_can( 'edit_page', $post_ID ) )
wp_die( __('You are not allowed to edit this page.' ));
} else {
@@ -123,7 +131,7 @@ function edit_post() {
}
// Autosave shouldn't save too soon after a real save
- if ( 'autosave' == $_POST['action'] ) {
+ if ( 'autosave' == $post_data['action'] ) {
$post =& get_post( $post_ID );
$now = time();
$then = strtotime($post->post_date_gmt . ' +0000');
@@ -132,24 +140,24 @@ function edit_post() {
return $post_ID;
}
- $translated = _wp_translate_postdata( true );
+ $translated = _wp_translate_postdata( true, $post_data );
if ( is_wp_error($translated) )
wp_die( $translated->get_error_message() );
// Meta Stuff
- if ( isset($_POST['meta']) && $_POST['meta'] ) {
- foreach ( $_POST['meta'] as $key => $value )
+ if ( isset($post_data['meta']) && $post_data['meta'] ) {
+ foreach ( $post_data['meta'] as $key => $value )
update_meta( $key, $value['key'], $value['value'] );
}
- if ( isset($_POST['deletemeta']) && $_POST['deletemeta'] ) {
- foreach ( $_POST['deletemeta'] as $key => $value )
+ if ( isset($post_data['deletemeta']) && $post_data['deletemeta'] ) {
+ foreach ( $post_data['deletemeta'] as $key => $value )
delete_meta( $key );
}
add_meta( $post_ID );
- wp_update_post( $_POST );
+ wp_update_post( $post_data );
// Reunite any orphaned attachments with their parent
if ( !$draft_ids = get_user_option( 'autosave_draft_ids' ) )
@@ -163,7 +171,7 @@ function edit_post() {
wp_set_post_lock( $post_ID, $GLOBALS['current_user']->ID );
if ( current_user_can( 'edit_others_posts' ) ) {
- if ( !empty($_POST['sticky']) )
+ if ( !empty($post_data['sticky']) )
stick_post($post_ID);
else
unstick_post($post_ID);
diff --git a/wp-admin/includes/template.php b/wp-admin/includes/template.php
index c599cd76cc..d4cfd977e6 100644
--- a/wp-admin/includes/template.php
+++ b/wp-admin/includes/template.php
@@ -350,7 +350,7 @@ function wp_manage_posts_columns() {
$posts_columns['modified'] = __('Submitted');
else
$posts_columns['date'] = __('Date');
- //$posts_columns['author'] = __('Author');
+ $posts_columns['author'] = __('Author');
$posts_columns['categories'] = __('Categories');
$posts_columns['tags'] = __('Tags');
if ( !isset($_GET['post_status']) || !in_array($_GET['post_status'], array('pending', 'draft', 'future')) )
@@ -406,23 +406,248 @@ function wp_manage_pages_columns() {
return $posts_columns;
}
-function post_rows() {
+function inline_edit_row( $type ) {
+ global $current_user;
+
+ if ( 'post' == $type )
+ $post = get_default_post_to_edit();
+ else
+ $post = get_default_page_to_edit();
+
+ echo '';
+ $columns = $type == 'post' ? wp_manage_posts_columns() : wp_manage_pages_columns();
+ foreach($columns as $column_name=>$column_display_name) {
+
+ switch($column_name) {
+
+ case 'cb': ?>
+ |
+
+
+
+ |
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ ' . __('Save') . '';
+ $actions['cancel'] = '' . __('Cancel') . '';
+ $action_count = count($actions);
+ $i = 0;
+ foreach ( $actions as $action => $link ) {
+ ++$i;
+ ( $i == $action_count ) ? $sep = '' : $sep = ' | ';
+ echo "$link$sep";
+ }
+ ?>
+ |
+
+
+
+ |
+
+
+
+ |
+
+
+
+
+ id ); // TODO: ROLE SYSTEM
+ if ( $authors && count( $authors ) > 1 ) {
+ wp_dropdown_users( array('include' => $authors, 'name' => 'post_author', 'class'=> 'author', 'selected' => $post->post_author) );
+ } else {
+ echo $current_user->user_nicename.'';
+ }
+ ?>
+ |
+
+
+
+
+
+
+
+
+
+
+ |
+
+ |
+
+ ID) ) { echo "" . __('Edit') . ""; } ?> |
+
+ ID) ) { echo "ID) . "' class='delete'>" . __('Delete') . ""; } ?> |
+
+ ID); ?> |
+ ';
+}
+
+function inline_save_row( $data ) {
+ // get the original post content
+ $post = get_post( $data['post_ID'], ARRAY_A );
+ $data['content'] = $post['post_content'];
+
+ // statuses
+ if ( 'page' == $data['post_type'] && 'private' == $data['page_private'] )
+ $data['post_status'] = 'private';
+ if ( empty($data['comment_status']) )
+ $data['comment_status'] = 'closed';
+ if ( empty($data['ping_status']) )
+ $data['ping_status'] = 'closed';
+
+ // rename
+ $data['user_ID'] = $GLOBALS['user_ID'];
+ $data['excerpt'] = $data['post_excerpt'];
+ $data['trackback_url'] = $data['to_ping'];
+ $data['parent_id'] = $data['post_parent'];
+
+ // update the post
+ $_POST = $data;
+ edit_post();
+}
+
+// outputs XML of the post/page data ready for use in the inline editor
+// accepts array of post IDs
+function get_inline_data($posts) {
+ global $post;
+
+ header('Content-Type: text/xml; charset=' . get_option('blog_charset'), true);
+ echo "\n";
+ echo "\n";
+
+ foreach ($posts as $ID) {
+ $GLOBALS['post'] = get_post($ID);
+ $GLOBALS['post_ID'] = $ID;
+
+ if ( ($post->post_type == 'post' && !current_user_can('edit_post', $ID)) ||
+ ($post->post_type == 'page' && !current_user_can('edit_page', $ID)) ||
+ ($post->post_type != 'post' && $post->post_type != 'page'))
+ continue;
+
+ echo " \n";
+ echo " " . wp_specialchars($post->post_title, 1) . "\n";
+ echo " $post->post_name\n";
+ echo " $post->post_author\n";
+ echo " $post->comment_status\n";
+ echo " $post->ping_status\n";
+ echo " $post->post_status\n";
+ echo " " . mysql2date( 'd', $post->post_date ) . "\n";
+ echo " " . mysql2date( 'm', $post->post_date ) . "\n";
+ echo " " . mysql2date( 'Y', $post->post_date ) . "\n";
+ echo " " . mysql2date( 'H', $post->post_date ) . "\n";
+ echo " " . mysql2date( 'i', $post->post_date ) . "\n";
+ if( $post->post_type == 'post' ) {
+ echo ' ' . wp_specialchars(get_tags_to_edit( $post->ID ), 1) . "\n";
+ echo ' ' . implode( ',', wp_get_post_categories( $post->ID ) ) . "\n";
+ echo ' ' . (is_sticky($post->ID) ? 'sticky' : '') . "\n";
+ }
+ if( $post->post_type == 'page' ) {
+ echo " $post->post_parent\n";
+ echo ' ' . wp_specialchars(get_post_meta( $post->ID, '_wp_page_template', true ), 1) . "\n";
+ echo " " . wp_specialchars($post->post_password, 1) . "\n";
+ echo " $post->menu_order\n";
+ }
+ echo " \n";
+ }
+
+ echo '';
+}
+
+function post_rows( $posts = array() ) {
global $wp_query, $post, $mode;
add_filter('the_title','wp_specialchars');
// Create array of post IDs.
$post_ids = array();
- foreach ( $wp_query->posts as $a_post )
+
+ if ( empty($posts) )
+ $posts = &$wp_query->posts;
+
+ foreach ( $posts as $a_post )
$post_ids[] = $a_post->ID;
$comment_pending_count = get_pending_comments_num($post_ids);
- if ( empty($comment_pending_count[$post->ID]) )
+ if ( empty($comment_pending_count) )
$comment_pending_count = array();
- while ( have_posts() ) {
- the_post();
-
+ foreach ( $posts as $post ) {
if ( empty($comment_pending_count[$post->ID]) )
$comment_pending_count[$post->ID] = 0;
@@ -436,6 +661,7 @@ function _post_row($a_post, $pending_comments, $mode) {
$global_post = $post;
$post = $a_post;
+ setup_postdata($post);
$class = 'alternate' == $class ? '' : 'alternate';
global $current_user;
@@ -483,9 +709,9 @@ function _post_row($a_post, $pending_comments, $mode) {
}
if ( 'excerpt' == $mode ) { ?>
- |
+ |
- |
+ |
ID . '">' . __('Edit') . '';
+ $actions['inline'] = '' . __('Quick Edit') . '';
$actions['delete'] = "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') . "";
$action_count = count($actions);
$i = 0;
@@ -515,7 +742,7 @@ function _post_row($a_post, $pending_comments, $mode) {
case 'categories':
?>
-
- |
- |
+ |