Use static strings. Props niallkennedy. fixes #17169
git-svn-id: http://svn.automattic.com/wordpress/trunk@17823 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
c39f85038e
commit
a972403a40
|
@ -475,7 +475,7 @@ class wp_xmlrpc_server extends IXR_Server {
|
||||||
$page = get_page($page_id);
|
$page = get_page($page_id);
|
||||||
|
|
||||||
// If we found the page then format the data.
|
// If we found the page then format the data.
|
||||||
if ( $page->ID && ($page->post_type == "page") ) {
|
if ( $page->ID && ($page->post_type == 'page') ) {
|
||||||
// Get all of the page content and link.
|
// Get all of the page content and link.
|
||||||
$full_page = get_extended($page->post_content);
|
$full_page = get_extended($page->post_content);
|
||||||
$link = post_permalink($page->ID);
|
$link = post_permalink($page->ID);
|
||||||
|
@ -492,8 +492,8 @@ class wp_xmlrpc_server extends IXR_Server {
|
||||||
$allow_pings = pings_open($page->ID) ? 1 : 0;
|
$allow_pings = pings_open($page->ID) ? 1 : 0;
|
||||||
|
|
||||||
// Format page date.
|
// Format page date.
|
||||||
$page_date = mysql2date("Ymd\TH:i:s", $page->post_date, false);
|
$page_date = mysql2date('Ymd\TH:i:s', $page->post_date, false);
|
||||||
$page_date_gmt = mysql2date("Ymd\TH:i:s", $page->post_date_gmt, false);
|
$page_date_gmt = mysql2date('Ymd\TH:i:s', $page->post_date_gmt, false);
|
||||||
|
|
||||||
// For drafts use the GMT version of the date
|
// For drafts use the GMT version of the date
|
||||||
if ( $page->post_status == 'draft' )
|
if ( $page->post_status == 'draft' )
|
||||||
|
@ -513,37 +513,37 @@ class wp_xmlrpc_server extends IXR_Server {
|
||||||
$page_template = 'default';
|
$page_template = 'default';
|
||||||
|
|
||||||
$page_struct = array(
|
$page_struct = array(
|
||||||
"dateCreated" => new IXR_Date($page_date),
|
'dateCreated' => new IXR_Date($page_date),
|
||||||
"userid" => $page->post_author,
|
'userid' => $page->post_author,
|
||||||
"page_id" => $page->ID,
|
'page_id' => $page->ID,
|
||||||
"page_status" => $page->post_status,
|
'page_status' => $page->post_status,
|
||||||
"description" => $full_page["main"],
|
'description' => $full_page['main'],
|
||||||
"title" => $page->post_title,
|
'title' => $page->post_title,
|
||||||
"link" => $link,
|
'link' => $link,
|
||||||
"permaLink" => $link,
|
'permaLink' => $link,
|
||||||
"categories" => $categories,
|
'categories' => $categories,
|
||||||
"excerpt" => $page->post_excerpt,
|
'excerpt' => $page->post_excerpt,
|
||||||
"text_more" => $full_page["extended"],
|
'text_more' => $full_page['extended'],
|
||||||
"mt_allow_comments" => $allow_comments,
|
'mt_allow_comments' => $allow_comments,
|
||||||
"mt_allow_pings" => $allow_pings,
|
'mt_allow_pings' => $allow_pings,
|
||||||
"wp_slug" => $page->post_name,
|
'wp_slug' => $page->post_name,
|
||||||
"wp_password" => $page->post_password,
|
'wp_password' => $page->post_password,
|
||||||
"wp_author" => $author->display_name,
|
'wp_author' => $author->display_name,
|
||||||
"wp_page_parent_id" => $page->post_parent,
|
'wp_page_parent_id' => $page->post_parent,
|
||||||
"wp_page_parent_title" => $parent_title,
|
'wp_page_parent_title' => $parent_title,
|
||||||
"wp_page_order" => $page->menu_order,
|
'wp_page_order' => $page->menu_order,
|
||||||
"wp_author_id" => $author->ID,
|
'wp_author_id' => $author->ID,
|
||||||
"wp_author_display_name" => $author->display_name,
|
'wp_author_display_name' => $author->display_name,
|
||||||
"date_created_gmt" => new IXR_Date($page_date_gmt),
|
'date_created_gmt' => new IXR_Date($page_date_gmt),
|
||||||
"custom_fields" => $this->get_custom_fields($page_id),
|
'custom_fields' => $this->get_custom_fields($page_id),
|
||||||
"wp_page_template" => $page_template
|
'wp_page_template' => $page_template
|
||||||
);
|
);
|
||||||
|
|
||||||
return($page_struct);
|
return($page_struct);
|
||||||
}
|
}
|
||||||
// If the page doesn't exist indicate that.
|
// If the page doesn't exist indicate that.
|
||||||
else {
|
else {
|
||||||
return(new IXR_Error(404, __("Sorry, no such page.")));
|
return(new IXR_Error(404, __('Sorry, no such page.')));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -618,11 +618,11 @@ class wp_xmlrpc_server extends IXR_Server {
|
||||||
do_action('xmlrpc_call', 'wp.newPage');
|
do_action('xmlrpc_call', 'wp.newPage');
|
||||||
|
|
||||||
// Make sure the user is allowed to add new pages.
|
// Make sure the user is allowed to add new pages.
|
||||||
if ( !current_user_can("publish_pages") )
|
if ( !current_user_can('publish_pages') )
|
||||||
return(new IXR_Error(401, __("Sorry, you cannot add new pages.")));
|
return(new IXR_Error(401, __('Sorry, you cannot add new pages.')));
|
||||||
|
|
||||||
// Mark this as content for a page.
|
// Mark this as content for a page.
|
||||||
$args[3]["post_type"] = "page";
|
$args[3]["post_type"] = 'page';
|
||||||
|
|
||||||
// Let mw_newPost do all of the heavy lifting.
|
// Let mw_newPost do all of the heavy lifting.
|
||||||
return($this->mw_newPost($args));
|
return($this->mw_newPost($args));
|
||||||
|
@ -652,17 +652,17 @@ class wp_xmlrpc_server extends IXR_Server {
|
||||||
// Get the current page based on the page_id and
|
// Get the current page based on the page_id and
|
||||||
// make sure it is a page and not a post.
|
// make sure it is a page and not a post.
|
||||||
$actual_page = wp_get_single_post($page_id, ARRAY_A);
|
$actual_page = wp_get_single_post($page_id, ARRAY_A);
|
||||||
if ( !$actual_page || ($actual_page["post_type"] != "page") )
|
if ( !$actual_page || ($actual_page['post_type'] != 'page') )
|
||||||
return(new IXR_Error(404, __("Sorry, no such page.")));
|
return(new IXR_Error(404, __('Sorry, no such page.')));
|
||||||
|
|
||||||
// Make sure the user can delete pages.
|
// Make sure the user can delete pages.
|
||||||
if ( !current_user_can("delete_page", $page_id) )
|
if ( !current_user_can('delete_page', $page_id) )
|
||||||
return(new IXR_Error(401, __("Sorry, you do not have the right to delete this page.")));
|
return(new IXR_Error(401, __('Sorry, you do not have the right to delete this page.')));
|
||||||
|
|
||||||
// Attempt to delete the page.
|
// Attempt to delete the page.
|
||||||
$result = wp_delete_post($page_id);
|
$result = wp_delete_post($page_id);
|
||||||
if ( !$result )
|
if ( !$result )
|
||||||
return(new IXR_Error(500, __("Failed to delete the page.")));
|
return(new IXR_Error(500, __('Failed to delete the page.')));
|
||||||
|
|
||||||
return(true);
|
return(true);
|
||||||
}
|
}
|
||||||
|
@ -691,15 +691,15 @@ class wp_xmlrpc_server extends IXR_Server {
|
||||||
|
|
||||||
// Get the page data and make sure it is a page.
|
// Get the page data and make sure it is a page.
|
||||||
$actual_page = wp_get_single_post($page_id, ARRAY_A);
|
$actual_page = wp_get_single_post($page_id, ARRAY_A);
|
||||||
if ( !$actual_page || ($actual_page["post_type"] != "page") )
|
if ( !$actual_page || ($actual_page['post_type'] != 'page') )
|
||||||
return(new IXR_Error(404, __("Sorry, no such page.")));
|
return(new IXR_Error(404, __('Sorry, no such page.')));
|
||||||
|
|
||||||
// Make sure the user is allowed to edit pages.
|
// Make sure the user is allowed to edit pages.
|
||||||
if ( !current_user_can("edit_page", $page_id) )
|
if ( !current_user_can('edit_page', $page_id) )
|
||||||
return(new IXR_Error(401, __("Sorry, you do not have the right to edit this page.")));
|
return(new IXR_Error(401, __('Sorry, you do not have the right to edit this page.')));
|
||||||
|
|
||||||
// Mark this as content for a page.
|
// Mark this as content for a page.
|
||||||
$content["post_type"] = "page";
|
$content['post_type'] = 'page';
|
||||||
|
|
||||||
// Arrange args in the way mw_editPost understands.
|
// Arrange args in the way mw_editPost understands.
|
||||||
$args = array(
|
$args = array(
|
||||||
|
@ -755,8 +755,8 @@ class wp_xmlrpc_server extends IXR_Server {
|
||||||
// The date needs to be formated properly.
|
// The date needs to be formated properly.
|
||||||
$num_pages = count($page_list);
|
$num_pages = count($page_list);
|
||||||
for ( $i = 0; $i < $num_pages; $i++ ) {
|
for ( $i = 0; $i < $num_pages; $i++ ) {
|
||||||
$post_date = mysql2date("Ymd\TH:i:s", $page_list[$i]->post_date, false);
|
$post_date = mysql2date('Ymd\TH:i:s', $page_list[$i]->post_date, false);
|
||||||
$post_date_gmt = mysql2date("Ymd\TH:i:s", $page_list[$i]->post_date_gmt, false);
|
$post_date_gmt = mysql2date('Ymd\TH:i:s', $page_list[$i]->post_date_gmt, false);
|
||||||
|
|
||||||
$page_list[$i]->dateCreated = new IXR_Date($post_date);
|
$page_list[$i]->dateCreated = new IXR_Date($post_date);
|
||||||
$page_list[$i]->date_created_gmt = new IXR_Date($post_date_gmt);
|
$page_list[$i]->date_created_gmt = new IXR_Date($post_date_gmt);
|
||||||
|
@ -794,17 +794,17 @@ class wp_xmlrpc_server extends IXR_Server {
|
||||||
if ( !$user = $this->login($username, $password) )
|
if ( !$user = $this->login($username, $password) )
|
||||||
return $this->error;
|
return $this->error;
|
||||||
|
|
||||||
if ( !current_user_can("edit_posts") )
|
if ( !current_user_can('edit_posts') )
|
||||||
return(new IXR_Error(401, __("Sorry, you cannot edit posts on this site.")));
|
return(new IXR_Error(401, __('Sorry, you cannot edit posts on this site.')));
|
||||||
|
|
||||||
do_action('xmlrpc_call', 'wp.getAuthors');
|
do_action('xmlrpc_call', 'wp.getAuthors');
|
||||||
|
|
||||||
$authors = array();
|
$authors = array();
|
||||||
foreach ( get_users( array( 'fields' => array('ID','user_login','display_name') ) ) as $user ) {
|
foreach ( get_users( array( 'fields' => array('ID','user_login','display_name') ) ) as $user ) {
|
||||||
$authors[] = array(
|
$authors[] = array(
|
||||||
"user_id" => $user->ID,
|
'user_id' => $user->ID,
|
||||||
"user_login" => $user->user_login,
|
'user_login' => $user->user_login,
|
||||||
"display_name" => $user->display_name
|
'display_name' => $user->display_name
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -874,28 +874,28 @@ class wp_xmlrpc_server extends IXR_Server {
|
||||||
do_action('xmlrpc_call', 'wp.newCategory');
|
do_action('xmlrpc_call', 'wp.newCategory');
|
||||||
|
|
||||||
// Make sure the user is allowed to add a category.
|
// Make sure the user is allowed to add a category.
|
||||||
if ( !current_user_can("manage_categories") )
|
if ( !current_user_can('manage_categories') )
|
||||||
return(new IXR_Error(401, __("Sorry, you do not have the right to add a category.")));
|
return(new IXR_Error(401, __('Sorry, you do not have the right to add a category.')));
|
||||||
|
|
||||||
// If no slug was provided make it empty so that
|
// If no slug was provided make it empty so that
|
||||||
// WordPress will generate one.
|
// WordPress will generate one.
|
||||||
if ( empty($category["slug"]) )
|
if ( empty($category['slug']) )
|
||||||
$category["slug"] = "";
|
$category['slug'] = '';
|
||||||
|
|
||||||
// If no parent_id was provided make it empty
|
// If no parent_id was provided make it empty
|
||||||
// so that it will be a top level page (no parent).
|
// so that it will be a top level page (no parent).
|
||||||
if ( !isset($category["parent_id"]) )
|
if ( !isset($category['parent_id']) )
|
||||||
$category["parent_id"] = "";
|
$category['parent_id'] = '';
|
||||||
|
|
||||||
// If no description was provided make it empty.
|
// If no description was provided make it empty.
|
||||||
if ( empty($category["description"]) )
|
if ( empty($category["description"]) )
|
||||||
$category["description"] = "";
|
$category["description"] = "";
|
||||||
|
|
||||||
$new_category = array(
|
$new_category = array(
|
||||||
"cat_name" => $category["name"],
|
'cat_name' => $category['name'],
|
||||||
"category_nicename" => $category["slug"],
|
'category_nicename' => $category['slug'],
|
||||||
"category_parent" => $category["parent_id"],
|
'category_parent' => $category['parent_id'],
|
||||||
"category_description" => $category["description"]
|
'category_description' => $category['description']
|
||||||
);
|
);
|
||||||
|
|
||||||
$cat_id = wp_insert_category($new_category, true);
|
$cat_id = wp_insert_category($new_category, true);
|
||||||
|
@ -903,9 +903,9 @@ class wp_xmlrpc_server extends IXR_Server {
|
||||||
if ( 'term_exists' == $cat_id->get_error_code() )
|
if ( 'term_exists' == $cat_id->get_error_code() )
|
||||||
return (int) $cat_id->get_error_data();
|
return (int) $cat_id->get_error_data();
|
||||||
else
|
else
|
||||||
return(new IXR_Error(500, __("Sorry, the new category failed.")));
|
return(new IXR_Error(500, __('Sorry, the new category failed.')));
|
||||||
} elseif ( ! $cat_id ) {
|
} elseif ( ! $cat_id ) {
|
||||||
return(new IXR_Error(500, __("Sorry, the new category failed.")));
|
return(new IXR_Error(500, __('Sorry, the new category failed.')));
|
||||||
}
|
}
|
||||||
|
|
||||||
return($cat_id);
|
return($cat_id);
|
||||||
|
@ -932,8 +932,8 @@ class wp_xmlrpc_server extends IXR_Server {
|
||||||
|
|
||||||
do_action('xmlrpc_call', 'wp.deleteCategory');
|
do_action('xmlrpc_call', 'wp.deleteCategory');
|
||||||
|
|
||||||
if ( !current_user_can("manage_categories") )
|
if ( !current_user_can('manage_categories') )
|
||||||
return new IXR_Error( 401, __( "Sorry, you do not have the right to delete a category." ) );
|
return new IXR_Error( 401, __( 'Sorry, you do not have the right to delete a category.' ) );
|
||||||
|
|
||||||
return wp_delete_term( $category_id, 'category' );
|
return wp_delete_term( $category_id, 'category' );
|
||||||
}
|
}
|
||||||
|
@ -967,8 +967,8 @@ class wp_xmlrpc_server extends IXR_Server {
|
||||||
$args = array('get' => 'all', 'number' => $max_results, 'name__like' => $category);
|
$args = array('get' => 'all', 'number' => $max_results, 'name__like' => $category);
|
||||||
foreach ( (array) get_categories($args) as $cat ) {
|
foreach ( (array) get_categories($args) as $cat ) {
|
||||||
$category_suggestions[] = array(
|
$category_suggestions[] = array(
|
||||||
"category_id" => $cat->term_id,
|
'category_id' => $cat->term_id,
|
||||||
"category_name" => $cat->name
|
'category_name' => $cat->name
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1003,8 +1003,8 @@ class wp_xmlrpc_server extends IXR_Server {
|
||||||
return new IXR_Error( 404, __( 'Invalid comment ID.' ) );
|
return new IXR_Error( 404, __( 'Invalid comment ID.' ) );
|
||||||
|
|
||||||
// Format page date.
|
// Format page date.
|
||||||
$comment_date = mysql2date("Ymd\TH:i:s", $comment->comment_date, false);
|
$comment_date = mysql2date('Ymd\TH:i:s', $comment->comment_date, false);
|
||||||
$comment_date_gmt = mysql2date("Ymd\TH:i:s", $comment->comment_date_gmt, false);
|
$comment_date_gmt = mysql2date('Ymd\TH:i:s', $comment->comment_date_gmt, false);
|
||||||
|
|
||||||
if ( '0' == $comment->comment_approved )
|
if ( '0' == $comment->comment_approved )
|
||||||
$comment_status = 'hold';
|
$comment_status = 'hold';
|
||||||
|
@ -1018,20 +1018,20 @@ class wp_xmlrpc_server extends IXR_Server {
|
||||||
$link = get_comment_link($comment);
|
$link = get_comment_link($comment);
|
||||||
|
|
||||||
$comment_struct = array(
|
$comment_struct = array(
|
||||||
"date_created_gmt" => new IXR_Date($comment_date_gmt),
|
'date_created_gmt' => new IXR_Date($comment_date_gmt),
|
||||||
"user_id" => $comment->user_id,
|
'user_id' => $comment->user_id,
|
||||||
"comment_id" => $comment->comment_ID,
|
'comment_id' => $comment->comment_ID,
|
||||||
"parent" => $comment->comment_parent,
|
'parent' => $comment->comment_parent,
|
||||||
"status" => $comment_status,
|
'status' => $comment_status,
|
||||||
"content" => $comment->comment_content,
|
'content' => $comment->comment_content,
|
||||||
"link" => $link,
|
'link' => $link,
|
||||||
"post_id" => $comment->comment_post_ID,
|
'post_id' => $comment->comment_post_ID,
|
||||||
"post_title" => get_the_title($comment->comment_post_ID),
|
'post_title' => get_the_title($comment->comment_post_ID),
|
||||||
"author" => $comment->comment_author,
|
'author' => $comment->comment_author,
|
||||||
"author_url" => $comment->comment_author_url,
|
'author_url' => $comment->comment_author_url,
|
||||||
"author_email" => $comment->comment_author_email,
|
'author_email' => $comment->comment_author_email,
|
||||||
"author_ip" => $comment->comment_author_IP,
|
'author_ip' => $comment->comment_author_IP,
|
||||||
"type" => $comment->comment_type,
|
'type' => $comment->comment_type,
|
||||||
);
|
);
|
||||||
|
|
||||||
return $comment_struct;
|
return $comment_struct;
|
||||||
|
@ -1373,10 +1373,10 @@ class wp_xmlrpc_server extends IXR_Server {
|
||||||
|
|
||||||
$count = wp_count_comments( $post_id );
|
$count = wp_count_comments( $post_id );
|
||||||
return array(
|
return array(
|
||||||
"approved" => $count->approved,
|
'approved' => $count->approved,
|
||||||
"awaiting_moderation" => $count->moderated,
|
'awaiting_moderation' => $count->moderated,
|
||||||
"spam" => $count->spam,
|
'spam' => $count->spam,
|
||||||
"total_comments" => $count->total_comments
|
'total_comments' => $count->total_comments
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1586,21 +1586,21 @@ class wp_xmlrpc_server extends IXR_Server {
|
||||||
return new IXR_Error( 404, __( 'Invalid attachment ID.' ) );
|
return new IXR_Error( 404, __( 'Invalid attachment ID.' ) );
|
||||||
|
|
||||||
// Format page date.
|
// Format page date.
|
||||||
$attachment_date = mysql2date("Ymd\TH:i:s", $attachment->post_date, false);
|
$attachment_date = mysql2date('Ymd\TH:i:s', $attachment->post_date, false);
|
||||||
$attachment_date_gmt = mysql2date("Ymd\TH:i:s", $attachment->post_date_gmt, false);
|
$attachment_date_gmt = mysql2date('Ymd\TH:i:s', $attachment->post_date_gmt, false);
|
||||||
|
|
||||||
$link = wp_get_attachment_url($attachment->ID);
|
$link = wp_get_attachment_url($attachment->ID);
|
||||||
$thumbnail_link = wp_get_attachment_thumb_url($attachment->ID);
|
$thumbnail_link = wp_get_attachment_thumb_url($attachment->ID);
|
||||||
|
|
||||||
$attachment_struct = array(
|
$attachment_struct = array(
|
||||||
"date_created_gmt" => new IXR_Date($attachment_date_gmt),
|
'date_created_gmt' => new IXR_Date($attachment_date_gmt),
|
||||||
"parent" => $attachment->post_parent,
|
'parent' => $attachment->post_parent,
|
||||||
"link" => $link,
|
'link' => $link,
|
||||||
"thumbnail" => $thumbnail_link,
|
'thumbnail' => $thumbnail_link,
|
||||||
"title" => $attachment->post_title,
|
'title' => $attachment->post_title,
|
||||||
"caption" => $attachment->post_excerpt,
|
'caption' => $attachment->post_excerpt,
|
||||||
"description" => $attachment->post_content,
|
'description' => $attachment->post_content,
|
||||||
"metadata" => wp_get_attachment_metadata($attachment->ID),
|
'metadata' => wp_get_attachment_metadata($attachment->ID),
|
||||||
);
|
);
|
||||||
|
|
||||||
return $attachment_struct;
|
return $attachment_struct;
|
||||||
|
@ -2243,39 +2243,39 @@ class wp_xmlrpc_server extends IXR_Server {
|
||||||
// Let WordPress generate the post_name (slug) unless
|
// Let WordPress generate the post_name (slug) unless
|
||||||
// one has been provided.
|
// one has been provided.
|
||||||
$post_name = "";
|
$post_name = "";
|
||||||
if ( isset($content_struct["wp_slug"]) )
|
if ( isset($content_struct['wp_slug']) )
|
||||||
$post_name = $content_struct["wp_slug"];
|
$post_name = $content_struct['wp_slug'];
|
||||||
|
|
||||||
// Only use a password if one was given.
|
// Only use a password if one was given.
|
||||||
if ( isset($content_struct["wp_password"]) )
|
if ( isset($content_struct['wp_password']) )
|
||||||
$post_password = $content_struct["wp_password"];
|
$post_password = $content_struct['wp_password'];
|
||||||
|
|
||||||
// Only set a post parent if one was provided.
|
// Only set a post parent if one was provided.
|
||||||
if ( isset($content_struct["wp_page_parent_id"]) )
|
if ( isset($content_struct['wp_page_parent_id']) )
|
||||||
$post_parent = $content_struct["wp_page_parent_id"];
|
$post_parent = $content_struct['wp_page_parent_id'];
|
||||||
|
|
||||||
// Only set the menu_order if it was provided.
|
// Only set the menu_order if it was provided.
|
||||||
if ( isset($content_struct["wp_page_order"]) )
|
if ( isset($content_struct['wp_page_order']) )
|
||||||
$menu_order = $content_struct["wp_page_order"];
|
$menu_order = $content_struct['wp_page_order'];
|
||||||
|
|
||||||
$post_author = $user->ID;
|
$post_author = $user->ID;
|
||||||
|
|
||||||
// If an author id was provided then use it instead.
|
// If an author id was provided then use it instead.
|
||||||
if ( isset($content_struct["wp_author_id"]) && ($user->ID != $content_struct["wp_author_id"]) ) {
|
if ( isset($content_struct['wp_author_id']) && ($user->ID != $content_struct['wp_author_id']) ) {
|
||||||
switch ( $post_type ) {
|
switch ( $post_type ) {
|
||||||
case "post":
|
case "post":
|
||||||
if ( !current_user_can("edit_others_posts") )
|
if ( !current_user_can('edit_others_posts') )
|
||||||
return(new IXR_Error(401, __("You are not allowed to post as this user")));
|
return(new IXR_Error(401, __('You are not allowed to post as this user')));
|
||||||
break;
|
break;
|
||||||
case "page":
|
case "page":
|
||||||
if ( !current_user_can("edit_others_pages") )
|
if ( !current_user_can('edit_others_pages') )
|
||||||
return(new IXR_Error(401, __("You are not allowed to create pages as this user")));
|
return(new IXR_Error(401, __('You are not allowed to create pages as this user')));
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
return(new IXR_Error(401, __("Invalid post type.")));
|
return(new IXR_Error(401, __('Invalid post type.')));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
$post_author = $content_struct["wp_author_id"];
|
$post_author = $content_struct['wp_author_id'];
|
||||||
}
|
}
|
||||||
|
|
||||||
$post_title = isset( $content_struct['title'] ) ? $content_struct['title'] : null;
|
$post_title = isset( $content_struct['title'] ) ? $content_struct['title'] : null;
|
||||||
|
@ -2302,69 +2302,69 @@ class wp_xmlrpc_server extends IXR_Server {
|
||||||
|
|
||||||
$tags_input = isset($content_struct['mt_keywords']) ? $content_struct['mt_keywords'] : null;
|
$tags_input = isset($content_struct['mt_keywords']) ? $content_struct['mt_keywords'] : null;
|
||||||
|
|
||||||
if ( isset($content_struct["mt_allow_comments"]) ) {
|
if ( isset($content_struct['mt_allow_comments']) ) {
|
||||||
if ( !is_numeric($content_struct["mt_allow_comments"]) ) {
|
if ( !is_numeric($content_struct['mt_allow_comments']) ) {
|
||||||
switch ( $content_struct["mt_allow_comments"] ) {
|
switch ( $content_struct['mt_allow_comments'] ) {
|
||||||
case "closed":
|
case 'closed':
|
||||||
$comment_status = "closed";
|
$comment_status = 'closed';
|
||||||
break;
|
break;
|
||||||
case "open":
|
case 'open':
|
||||||
$comment_status = "open";
|
$comment_status = 'open';
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
$comment_status = get_option("default_comment_status");
|
$comment_status = get_option('default_comment_status');
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
switch ( (int) $content_struct["mt_allow_comments"] ) {
|
switch ( (int) $content_struct['mt_allow_comments'] ) {
|
||||||
case 0:
|
case 0:
|
||||||
case 2:
|
case 2:
|
||||||
$comment_status = "closed";
|
$comment_status = 'closed';
|
||||||
break;
|
break;
|
||||||
case 1:
|
case 1:
|
||||||
$comment_status = "open";
|
$comment_status = 'open';
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
$comment_status = get_option("default_comment_status");
|
$comment_status = get_option('default_comment_status');
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
$comment_status = get_option("default_comment_status");
|
$comment_status = get_option('default_comment_status');
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( isset($content_struct["mt_allow_pings"]) ) {
|
if ( isset($content_struct['mt_allow_pings']) ) {
|
||||||
if ( !is_numeric($content_struct["mt_allow_pings"]) ) {
|
if ( !is_numeric($content_struct['mt_allow_pings']) ) {
|
||||||
switch ( $content_struct['mt_allow_pings'] ) {
|
switch ( $content_struct['mt_allow_pings'] ) {
|
||||||
case "closed":
|
case 'closed':
|
||||||
$ping_status = "closed";
|
$ping_status = 'closed';
|
||||||
break;
|
break;
|
||||||
case "open":
|
case 'open':
|
||||||
$ping_status = "open";
|
$ping_status = 'open';
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
$ping_status = get_option("default_ping_status");
|
$ping_status = get_option('default_ping_status');
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
switch ( (int) $content_struct["mt_allow_pings"] ) {
|
switch ( (int) $content_struct['mt_allow_pings'] ) {
|
||||||
case 0:
|
case 0:
|
||||||
$ping_status = "closed";
|
$ping_status = 'closed';
|
||||||
break;
|
break;
|
||||||
case 1:
|
case 1:
|
||||||
$ping_status = "open";
|
$ping_status = 'open';
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
$ping_status = get_option("default_ping_status");
|
$ping_status = get_option('default_ping_status');
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
$ping_status = get_option("default_ping_status");
|
$ping_status = get_option('default_ping_status');
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( $post_more )
|
if ( $post_more )
|
||||||
$post_content = $post_content . "<!--more-->" . $post_more;
|
$post_content = $post_content . '<!--more-->' . $post_more;
|
||||||
|
|
||||||
$to_ping = null;
|
$to_ping = null;
|
||||||
if ( isset( $content_struct['mt_tb_ping_urls'] ) ) {
|
if ( isset( $content_struct['mt_tb_ping_urls'] ) ) {
|
||||||
|
@ -2551,7 +2551,7 @@ class wp_xmlrpc_server extends IXR_Server {
|
||||||
// now and return an error. Other wise a new post will be
|
// now and return an error. Other wise a new post will be
|
||||||
// created (which was the old behavior).
|
// created (which was the old behavior).
|
||||||
if ( empty($postdata["ID"]) )
|
if ( empty($postdata["ID"]) )
|
||||||
return(new IXR_Error(404, __("Invalid post ID.")));
|
return(new IXR_Error(404, __('Invalid post ID.')));
|
||||||
|
|
||||||
$this->escape($postdata);
|
$this->escape($postdata);
|
||||||
extract($postdata, EXTR_SKIP);
|
extract($postdata, EXTR_SKIP);
|
||||||
|
@ -2559,93 +2559,93 @@ class wp_xmlrpc_server extends IXR_Server {
|
||||||
// Let WordPress manage slug if none was provided.
|
// Let WordPress manage slug if none was provided.
|
||||||
$post_name = "";
|
$post_name = "";
|
||||||
$post_name = $postdata['post_name'];
|
$post_name = $postdata['post_name'];
|
||||||
if ( isset($content_struct["wp_slug"]) )
|
if ( isset($content_struct['wp_slug']) )
|
||||||
$post_name = $content_struct["wp_slug"];
|
$post_name = $content_struct['wp_slug'];
|
||||||
|
|
||||||
// Only use a password if one was given.
|
// Only use a password if one was given.
|
||||||
if ( isset($content_struct["wp_password"]) )
|
if ( isset($content_struct['wp_password']) )
|
||||||
$post_password = $content_struct["wp_password"];
|
$post_password = $content_struct['wp_password'];
|
||||||
|
|
||||||
// Only set a post parent if one was given.
|
// Only set a post parent if one was given.
|
||||||
if ( isset($content_struct["wp_page_parent_id"]) )
|
if ( isset($content_struct['wp_page_parent_id']) )
|
||||||
$post_parent = $content_struct["wp_page_parent_id"];
|
$post_parent = $content_struct['wp_page_parent_id'];
|
||||||
|
|
||||||
// Only set the menu_order if it was given.
|
// Only set the menu_order if it was given.
|
||||||
if ( isset($content_struct["wp_page_order"]) )
|
if ( isset($content_struct['wp_page_order']) )
|
||||||
$menu_order = $content_struct["wp_page_order"];
|
$menu_order = $content_struct['wp_page_order'];
|
||||||
|
|
||||||
$post_author = $postdata["post_author"];
|
$post_author = $postdata['post_author'];
|
||||||
|
|
||||||
// Only set the post_author if one is set.
|
// Only set the post_author if one is set.
|
||||||
if ( isset($content_struct["wp_author_id"]) && ($user->ID != $content_struct["wp_author_id"]) ) {
|
if ( isset($content_struct['wp_author_id']) && ($user->ID != $content_struct['wp_author_id']) ) {
|
||||||
switch ( $post_type ) {
|
switch ( $post_type ) {
|
||||||
case "post":
|
case 'post':
|
||||||
if ( !current_user_can("edit_others_posts") )
|
if ( !current_user_can('edit_others_posts') )
|
||||||
return(new IXR_Error(401, __("You are not allowed to change the post author as this user.")));
|
return(new IXR_Error(401, __('You are not allowed to change the post author as this user.')));
|
||||||
break;
|
break;
|
||||||
case "page":
|
case 'page':
|
||||||
if ( !current_user_can("edit_others_pages") )
|
if ( !current_user_can('edit_others_pages') )
|
||||||
return(new IXR_Error(401, __("You are not allowed to change the page author as this user.")));
|
return(new IXR_Error(401, __('You are not allowed to change the page author as this user.')));
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
return(new IXR_Error(401, __("Invalid post type.")));
|
return(new IXR_Error(401, __('Invalid post type.')));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
$post_author = $content_struct["wp_author_id"];
|
$post_author = $content_struct['wp_author_id'];
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( isset($content_struct["mt_allow_comments"]) ) {
|
if ( isset($content_struct['mt_allow_comments']) ) {
|
||||||
if ( !is_numeric($content_struct["mt_allow_comments"]) ) {
|
if ( !is_numeric($content_struct['mt_allow_comments']) ) {
|
||||||
switch ( $content_struct["mt_allow_comments"] ) {
|
switch ( $content_struct['mt_allow_comments'] ) {
|
||||||
case "closed":
|
case 'closed':
|
||||||
$comment_status = "closed";
|
$comment_status = 'closed';
|
||||||
break;
|
break;
|
||||||
case "open":
|
case 'open':
|
||||||
$comment_status = "open";
|
$comment_status = 'open';
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
$comment_status = get_option("default_comment_status");
|
$comment_status = get_option('default_comment_status');
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
switch ( (int) $content_struct["mt_allow_comments"] ) {
|
switch ( (int) $content_struct['mt_allow_comments'] ) {
|
||||||
case 0:
|
case 0:
|
||||||
case 2:
|
case 2:
|
||||||
$comment_status = "closed";
|
$comment_status = 'closed';
|
||||||
break;
|
break;
|
||||||
case 1:
|
case 1:
|
||||||
$comment_status = "open";
|
$comment_status = 'open';
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
$comment_status = get_option("default_comment_status");
|
$comment_status = get_option('default_comment_status');
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( isset($content_struct["mt_allow_pings"]) ) {
|
if ( isset($content_struct['mt_allow_pings']) ) {
|
||||||
if ( !is_numeric($content_struct["mt_allow_pings"]) ) {
|
if ( !is_numeric($content_struct['mt_allow_pings']) ) {
|
||||||
switch ( $content_struct["mt_allow_pings"] ) {
|
switch ( $content_struct['mt_allow_pings'] ) {
|
||||||
case "closed":
|
case 'closed':
|
||||||
$ping_status = "closed";
|
$ping_status = 'closed';
|
||||||
break;
|
break;
|
||||||
case "open":
|
case 'open':
|
||||||
$ping_status = "open";
|
$ping_status = 'open';
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
$ping_status = get_option("default_ping_status");
|
$ping_status = get_option('default_ping_status');
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
switch ( (int) $content_struct["mt_allow_pings"] ) {
|
switch ( (int) $content_struct["mt_allow_pings"] ) {
|
||||||
case 0:
|
case 0:
|
||||||
$ping_status = "closed";
|
$ping_status = 'closed';
|
||||||
break;
|
break;
|
||||||
case 1:
|
case 1:
|
||||||
$ping_status = "open";
|
$ping_status = 'open';
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
$ping_status = get_option("default_ping_status");
|
$ping_status = get_option('default_ping_status');
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -3062,10 +3062,10 @@ class wp_xmlrpc_server extends IXR_Server {
|
||||||
return $this->error;
|
return $this->error;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( $upload_err = apply_filters( "pre_upload_error", false ) )
|
if ( $upload_err = apply_filters( 'pre_upload_error', false ) )
|
||||||
return new IXR_Error(500, $upload_err);
|
return new IXR_Error(500, $upload_err);
|
||||||
|
|
||||||
if ( !empty($data["overwrite"]) && ($data["overwrite"] == true) ) {
|
if ( !empty($data['overwrite']) && ($data['overwrite'] == true) ) {
|
||||||
// Get postmeta info on the object.
|
// Get postmeta info on the object.
|
||||||
$old_file = $wpdb->get_row("
|
$old_file = $wpdb->get_row("
|
||||||
SELECT ID
|
SELECT ID
|
||||||
|
@ -3079,7 +3079,7 @@ class wp_xmlrpc_server extends IXR_Server {
|
||||||
|
|
||||||
// Make sure the new name is different by pre-pending the
|
// Make sure the new name is different by pre-pending the
|
||||||
// previous post id.
|
// previous post id.
|
||||||
$filename = preg_replace("/^wpid\d+-/", "", $name);
|
$filename = preg_replace('/^wpid\d+-/', '', $name);
|
||||||
$name = "wpid{$old_file->ID}-{$filename}";
|
$name = "wpid{$old_file->ID}-{$filename}";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue