Edit File by line

Deprecated: str_replace(): Passing null to parameter #2 ($replace) of type array|string is deprecated in /home/sportsfever/public_html/filemanger/function.php on line 93

Warning: Undefined array key "page_file_edit_line" in /home/sportsfever/public_html/filemanger/edit_text_line.php on line 32
/home/sportsfe.../httpdocs/clone/wp-inclu...
File: class-wp-xmlrpc-server.php
* @since 1.5.0
[5000] Fix | Delete
*
[5001] Fix | Delete
* @param array $args {
[5002] Fix | Delete
* Method arguments. Note: arguments must be ordered as documented.
[5003] Fix | Delete
*
[5004] Fix | Delete
* @type string $0 App key (unused).
[5005] Fix | Delete
* @type int $1 Blog ID (unused).
[5006] Fix | Delete
* @type string $2 Username.
[5007] Fix | Delete
* @type string $3 Password.
[5008] Fix | Delete
* @type int $4 Optional. Number of posts.
[5009] Fix | Delete
* }
[5010] Fix | Delete
* @return array|IXR_Error
[5011] Fix | Delete
*/
[5012] Fix | Delete
public function blogger_getRecentPosts( $args ) {
[5013] Fix | Delete
[5014] Fix | Delete
$this->escape( $args );
[5015] Fix | Delete
[5016] Fix | Delete
// $args[0] = appkey - ignored.
[5017] Fix | Delete
$username = $args[2];
[5018] Fix | Delete
$password = $args[3];
[5019] Fix | Delete
if ( isset( $args[4] ) ) {
[5020] Fix | Delete
$query = array( 'numberposts' => absint( $args[4] ) );
[5021] Fix | Delete
} else {
[5022] Fix | Delete
$query = array();
[5023] Fix | Delete
}
[5024] Fix | Delete
[5025] Fix | Delete
$user = $this->login( $username, $password );
[5026] Fix | Delete
if ( ! $user ) {
[5027] Fix | Delete
return $this->error;
[5028] Fix | Delete
}
[5029] Fix | Delete
[5030] Fix | Delete
if ( ! current_user_can( 'edit_posts' ) ) {
[5031] Fix | Delete
return new IXR_Error( 401, __( 'Sorry, you are not allowed to edit posts.' ) );
[5032] Fix | Delete
}
[5033] Fix | Delete
[5034] Fix | Delete
/** This action is documented in wp-includes/class-wp-xmlrpc-server.php */
[5035] Fix | Delete
do_action( 'xmlrpc_call', 'blogger.getRecentPosts', $args, $this );
[5036] Fix | Delete
[5037] Fix | Delete
$posts_list = wp_get_recent_posts( $query );
[5038] Fix | Delete
[5039] Fix | Delete
if ( ! $posts_list ) {
[5040] Fix | Delete
$this->error = new IXR_Error( 500, __( 'Either there are no posts, or something went wrong.' ) );
[5041] Fix | Delete
return $this->error;
[5042] Fix | Delete
}
[5043] Fix | Delete
[5044] Fix | Delete
$recent_posts = array();
[5045] Fix | Delete
foreach ( $posts_list as $entry ) {
[5046] Fix | Delete
if ( ! current_user_can( 'edit_post', $entry['ID'] ) ) {
[5047] Fix | Delete
continue;
[5048] Fix | Delete
}
[5049] Fix | Delete
[5050] Fix | Delete
$post_date = $this->_convert_date( $entry['post_date'] );
[5051] Fix | Delete
$categories = implode( ',', wp_get_post_categories( $entry['ID'] ) );
[5052] Fix | Delete
[5053] Fix | Delete
$content = '<title>' . wp_unslash( $entry['post_title'] ) . '</title>';
[5054] Fix | Delete
$content .= '<category>' . $categories . '</category>';
[5055] Fix | Delete
$content .= wp_unslash( $entry['post_content'] );
[5056] Fix | Delete
[5057] Fix | Delete
$recent_posts[] = array(
[5058] Fix | Delete
'userid' => $entry['post_author'],
[5059] Fix | Delete
'dateCreated' => $post_date,
[5060] Fix | Delete
'content' => $content,
[5061] Fix | Delete
'postid' => (string) $entry['ID'],
[5062] Fix | Delete
);
[5063] Fix | Delete
}
[5064] Fix | Delete
[5065] Fix | Delete
return $recent_posts;
[5066] Fix | Delete
}
[5067] Fix | Delete
[5068] Fix | Delete
/**
[5069] Fix | Delete
* Deprecated.
[5070] Fix | Delete
*
[5071] Fix | Delete
* @since 1.5.0
[5072] Fix | Delete
* @deprecated 3.5.0
[5073] Fix | Delete
*
[5074] Fix | Delete
* @param array $args Unused.
[5075] Fix | Delete
* @return IXR_Error Error object.
[5076] Fix | Delete
*/
[5077] Fix | Delete
public function blogger_getTemplate( $args ) {
[5078] Fix | Delete
return new IXR_Error( 403, __( 'Sorry, this method is not supported.' ) );
[5079] Fix | Delete
}
[5080] Fix | Delete
[5081] Fix | Delete
/**
[5082] Fix | Delete
* Deprecated.
[5083] Fix | Delete
*
[5084] Fix | Delete
* @since 1.5.0
[5085] Fix | Delete
* @deprecated 3.5.0
[5086] Fix | Delete
*
[5087] Fix | Delete
* @param array $args Unused.
[5088] Fix | Delete
* @return IXR_Error Error object.
[5089] Fix | Delete
*/
[5090] Fix | Delete
public function blogger_setTemplate( $args ) {
[5091] Fix | Delete
return new IXR_Error( 403, __( 'Sorry, this method is not supported.' ) );
[5092] Fix | Delete
}
[5093] Fix | Delete
[5094] Fix | Delete
/**
[5095] Fix | Delete
* Creates a new post.
[5096] Fix | Delete
*
[5097] Fix | Delete
* @since 1.5.0
[5098] Fix | Delete
*
[5099] Fix | Delete
* @param array $args {
[5100] Fix | Delete
* Method arguments. Note: arguments must be ordered as documented.
[5101] Fix | Delete
*
[5102] Fix | Delete
* @type string $0 App key (unused).
[5103] Fix | Delete
* @type int $1 Blog ID (unused).
[5104] Fix | Delete
* @type string $2 Username.
[5105] Fix | Delete
* @type string $3 Password.
[5106] Fix | Delete
* @type string $4 Content.
[5107] Fix | Delete
* @type int $5 Publish flag. 0 for draft, 1 for publish.
[5108] Fix | Delete
* }
[5109] Fix | Delete
* @return int|IXR_Error
[5110] Fix | Delete
*/
[5111] Fix | Delete
public function blogger_newPost( $args ) {
[5112] Fix | Delete
$this->escape( $args );
[5113] Fix | Delete
[5114] Fix | Delete
$username = $args[2];
[5115] Fix | Delete
$password = $args[3];
[5116] Fix | Delete
$content = $args[4];
[5117] Fix | Delete
$publish = $args[5];
[5118] Fix | Delete
[5119] Fix | Delete
$user = $this->login( $username, $password );
[5120] Fix | Delete
if ( ! $user ) {
[5121] Fix | Delete
return $this->error;
[5122] Fix | Delete
}
[5123] Fix | Delete
[5124] Fix | Delete
/** This action is documented in wp-includes/class-wp-xmlrpc-server.php */
[5125] Fix | Delete
do_action( 'xmlrpc_call', 'blogger.newPost', $args, $this );
[5126] Fix | Delete
[5127] Fix | Delete
$cap = ( $publish ) ? 'publish_posts' : 'edit_posts';
[5128] Fix | Delete
if ( ! current_user_can( get_post_type_object( 'post' )->cap->create_posts ) || ! current_user_can( $cap ) ) {
[5129] Fix | Delete
return new IXR_Error( 401, __( 'Sorry, you are not allowed to post on this site.' ) );
[5130] Fix | Delete
}
[5131] Fix | Delete
[5132] Fix | Delete
$post_status = ( $publish ) ? 'publish' : 'draft';
[5133] Fix | Delete
[5134] Fix | Delete
$post_author = $user->ID;
[5135] Fix | Delete
[5136] Fix | Delete
$post_title = xmlrpc_getposttitle( $content );
[5137] Fix | Delete
$post_category = xmlrpc_getpostcategory( $content );
[5138] Fix | Delete
$post_content = xmlrpc_removepostdata( $content );
[5139] Fix | Delete
[5140] Fix | Delete
$post_date = current_time( 'mysql' );
[5141] Fix | Delete
$post_date_gmt = current_time( 'mysql', 1 );
[5142] Fix | Delete
[5143] Fix | Delete
$post_data = compact( 'post_author', 'post_date', 'post_date_gmt', 'post_content', 'post_title', 'post_category', 'post_status' );
[5144] Fix | Delete
[5145] Fix | Delete
$post_id = wp_insert_post( $post_data );
[5146] Fix | Delete
if ( is_wp_error( $post_id ) ) {
[5147] Fix | Delete
return new IXR_Error( 500, $post_id->get_error_message() );
[5148] Fix | Delete
}
[5149] Fix | Delete
[5150] Fix | Delete
if ( ! $post_id ) {
[5151] Fix | Delete
return new IXR_Error( 500, __( 'Sorry, the post could not be created.' ) );
[5152] Fix | Delete
}
[5153] Fix | Delete
[5154] Fix | Delete
$this->attach_uploads( $post_id, $post_content );
[5155] Fix | Delete
[5156] Fix | Delete
/**
[5157] Fix | Delete
* Fires after a new post has been successfully created via the XML-RPC Blogger API.
[5158] Fix | Delete
*
[5159] Fix | Delete
* @since 3.4.0
[5160] Fix | Delete
*
[5161] Fix | Delete
* @param int $post_id ID of the new post.
[5162] Fix | Delete
* @param array $args An array of new post arguments.
[5163] Fix | Delete
*/
[5164] Fix | Delete
do_action( 'xmlrpc_call_success_blogger_newPost', $post_id, $args ); // phpcs:ignore WordPress.NamingConventions.ValidHookName.NotLowercase
[5165] Fix | Delete
[5166] Fix | Delete
return $post_id;
[5167] Fix | Delete
}
[5168] Fix | Delete
[5169] Fix | Delete
/**
[5170] Fix | Delete
* Edits a post.
[5171] Fix | Delete
*
[5172] Fix | Delete
* @since 1.5.0
[5173] Fix | Delete
*
[5174] Fix | Delete
* @param array $args {
[5175] Fix | Delete
* Method arguments. Note: arguments must be ordered as documented.
[5176] Fix | Delete
*
[5177] Fix | Delete
* @type int $0 Blog ID (unused).
[5178] Fix | Delete
* @type int $1 Post ID.
[5179] Fix | Delete
* @type string $2 Username.
[5180] Fix | Delete
* @type string $3 Password.
[5181] Fix | Delete
* @type string $4 Content
[5182] Fix | Delete
* @type int $5 Publish flag. 0 for draft, 1 for publish.
[5183] Fix | Delete
* }
[5184] Fix | Delete
* @return true|IXR_Error true when done.
[5185] Fix | Delete
*/
[5186] Fix | Delete
public function blogger_editPost( $args ) {
[5187] Fix | Delete
[5188] Fix | Delete
$this->escape( $args );
[5189] Fix | Delete
[5190] Fix | Delete
$post_id = (int) $args[1];
[5191] Fix | Delete
$username = $args[2];
[5192] Fix | Delete
$password = $args[3];
[5193] Fix | Delete
$content = $args[4];
[5194] Fix | Delete
$publish = $args[5];
[5195] Fix | Delete
[5196] Fix | Delete
$user = $this->login( $username, $password );
[5197] Fix | Delete
if ( ! $user ) {
[5198] Fix | Delete
return $this->error;
[5199] Fix | Delete
}
[5200] Fix | Delete
[5201] Fix | Delete
/** This action is documented in wp-includes/class-wp-xmlrpc-server.php */
[5202] Fix | Delete
do_action( 'xmlrpc_call', 'blogger.editPost', $args, $this );
[5203] Fix | Delete
[5204] Fix | Delete
$actual_post = get_post( $post_id, ARRAY_A );
[5205] Fix | Delete
[5206] Fix | Delete
if ( ! $actual_post || 'post' !== $actual_post['post_type'] ) {
[5207] Fix | Delete
return new IXR_Error( 404, __( 'Sorry, no such post.' ) );
[5208] Fix | Delete
}
[5209] Fix | Delete
[5210] Fix | Delete
$this->escape( $actual_post );
[5211] Fix | Delete
[5212] Fix | Delete
if ( ! current_user_can( 'edit_post', $post_id ) ) {
[5213] Fix | Delete
return new IXR_Error( 401, __( 'Sorry, you are not allowed to edit this post.' ) );
[5214] Fix | Delete
}
[5215] Fix | Delete
if ( 'publish' === $actual_post['post_status'] && ! current_user_can( 'publish_posts' ) ) {
[5216] Fix | Delete
return new IXR_Error( 401, __( 'Sorry, you are not allowed to publish this post.' ) );
[5217] Fix | Delete
}
[5218] Fix | Delete
[5219] Fix | Delete
$postdata = array();
[5220] Fix | Delete
$postdata['ID'] = $actual_post['ID'];
[5221] Fix | Delete
$postdata['post_content'] = xmlrpc_removepostdata( $content );
[5222] Fix | Delete
$postdata['post_title'] = xmlrpc_getposttitle( $content );
[5223] Fix | Delete
$postdata['post_category'] = xmlrpc_getpostcategory( $content );
[5224] Fix | Delete
$postdata['post_status'] = $actual_post['post_status'];
[5225] Fix | Delete
$postdata['post_excerpt'] = $actual_post['post_excerpt'];
[5226] Fix | Delete
$postdata['post_status'] = $publish ? 'publish' : 'draft';
[5227] Fix | Delete
[5228] Fix | Delete
$result = wp_update_post( $postdata );
[5229] Fix | Delete
[5230] Fix | Delete
if ( ! $result ) {
[5231] Fix | Delete
return new IXR_Error( 500, __( 'Sorry, the post could not be updated.' ) );
[5232] Fix | Delete
}
[5233] Fix | Delete
$this->attach_uploads( $actual_post['ID'], $postdata['post_content'] );
[5234] Fix | Delete
[5235] Fix | Delete
/**
[5236] Fix | Delete
* Fires after a post has been successfully updated via the XML-RPC Blogger API.
[5237] Fix | Delete
*
[5238] Fix | Delete
* @since 3.4.0
[5239] Fix | Delete
*
[5240] Fix | Delete
* @param int $post_id ID of the updated post.
[5241] Fix | Delete
* @param array $args An array of arguments for the post to edit.
[5242] Fix | Delete
*/
[5243] Fix | Delete
do_action( 'xmlrpc_call_success_blogger_editPost', $post_id, $args ); // phpcs:ignore WordPress.NamingConventions.ValidHookName.NotLowercase
[5244] Fix | Delete
[5245] Fix | Delete
return true;
[5246] Fix | Delete
}
[5247] Fix | Delete
[5248] Fix | Delete
/**
[5249] Fix | Delete
* Deletes a post.
[5250] Fix | Delete
*
[5251] Fix | Delete
* @since 1.5.0
[5252] Fix | Delete
*
[5253] Fix | Delete
* @param array $args {
[5254] Fix | Delete
* Method arguments. Note: arguments must be ordered as documented.
[5255] Fix | Delete
*
[5256] Fix | Delete
* @type int $0 Blog ID (unused).
[5257] Fix | Delete
* @type int $1 Post ID.
[5258] Fix | Delete
* @type string $2 Username.
[5259] Fix | Delete
* @type string $3 Password.
[5260] Fix | Delete
* }
[5261] Fix | Delete
* @return true|IXR_Error True when post is deleted.
[5262] Fix | Delete
*/
[5263] Fix | Delete
public function blogger_deletePost( $args ) {
[5264] Fix | Delete
$this->escape( $args );
[5265] Fix | Delete
[5266] Fix | Delete
$post_id = (int) $args[1];
[5267] Fix | Delete
$username = $args[2];
[5268] Fix | Delete
$password = $args[3];
[5269] Fix | Delete
[5270] Fix | Delete
$user = $this->login( $username, $password );
[5271] Fix | Delete
if ( ! $user ) {
[5272] Fix | Delete
return $this->error;
[5273] Fix | Delete
}
[5274] Fix | Delete
[5275] Fix | Delete
/** This action is documented in wp-includes/class-wp-xmlrpc-server.php */
[5276] Fix | Delete
do_action( 'xmlrpc_call', 'blogger.deletePost', $args, $this );
[5277] Fix | Delete
[5278] Fix | Delete
$actual_post = get_post( $post_id, ARRAY_A );
[5279] Fix | Delete
[5280] Fix | Delete
if ( ! $actual_post || 'post' !== $actual_post['post_type'] ) {
[5281] Fix | Delete
return new IXR_Error( 404, __( 'Sorry, no such post.' ) );
[5282] Fix | Delete
}
[5283] Fix | Delete
[5284] Fix | Delete
if ( ! current_user_can( 'delete_post', $post_id ) ) {
[5285] Fix | Delete
return new IXR_Error( 401, __( 'Sorry, you are not allowed to delete this post.' ) );
[5286] Fix | Delete
}
[5287] Fix | Delete
[5288] Fix | Delete
$result = wp_delete_post( $post_id );
[5289] Fix | Delete
[5290] Fix | Delete
if ( ! $result ) {
[5291] Fix | Delete
return new IXR_Error( 500, __( 'Sorry, the post could not be deleted.' ) );
[5292] Fix | Delete
}
[5293] Fix | Delete
[5294] Fix | Delete
/**
[5295] Fix | Delete
* Fires after a post has been successfully deleted via the XML-RPC Blogger API.
[5296] Fix | Delete
*
[5297] Fix | Delete
* @since 3.4.0
[5298] Fix | Delete
*
[5299] Fix | Delete
* @param int $post_id ID of the deleted post.
[5300] Fix | Delete
* @param array $args An array of arguments to delete the post.
[5301] Fix | Delete
*/
[5302] Fix | Delete
do_action( 'xmlrpc_call_success_blogger_deletePost', $post_id, $args ); // phpcs:ignore WordPress.NamingConventions.ValidHookName.NotLowercase
[5303] Fix | Delete
[5304] Fix | Delete
return true;
[5305] Fix | Delete
}
[5306] Fix | Delete
[5307] Fix | Delete
/*
[5308] Fix | Delete
* MetaWeblog API functions.
[5309] Fix | Delete
* Specs on wherever Dave Winer wants them to be.
[5310] Fix | Delete
*/
[5311] Fix | Delete
[5312] Fix | Delete
/**
[5313] Fix | Delete
* Creates a new post.
[5314] Fix | Delete
*
[5315] Fix | Delete
* The 'content_struct' argument must contain:
[5316] Fix | Delete
* - title
[5317] Fix | Delete
* - description
[5318] Fix | Delete
* - mt_excerpt
[5319] Fix | Delete
* - mt_text_more
[5320] Fix | Delete
* - mt_keywords
[5321] Fix | Delete
* - mt_tb_ping_urls
[5322] Fix | Delete
* - categories
[5323] Fix | Delete
*
[5324] Fix | Delete
* Also, it can optionally contain:
[5325] Fix | Delete
* - wp_slug
[5326] Fix | Delete
* - wp_password
[5327] Fix | Delete
* - wp_page_parent_id
[5328] Fix | Delete
* - wp_page_order
[5329] Fix | Delete
* - wp_author_id
[5330] Fix | Delete
* - post_status | page_status - can be 'draft', 'private', 'publish', or 'pending'
[5331] Fix | Delete
* - mt_allow_comments - can be 'open' or 'closed'
[5332] Fix | Delete
* - mt_allow_pings - can be 'open' or 'closed'
[5333] Fix | Delete
* - date_created_gmt
[5334] Fix | Delete
* - dateCreated
[5335] Fix | Delete
* - wp_post_thumbnail
[5336] Fix | Delete
*
[5337] Fix | Delete
* @since 1.5.0
[5338] Fix | Delete
*
[5339] Fix | Delete
* @param array $args {
[5340] Fix | Delete
* Method arguments. Note: arguments must be ordered as documented.
[5341] Fix | Delete
*
[5342] Fix | Delete
* @type int $0 Blog ID (unused).
[5343] Fix | Delete
* @type string $1 Username.
[5344] Fix | Delete
* @type string $2 Password.
[5345] Fix | Delete
* @type array $3 Content structure.
[5346] Fix | Delete
* @type int $4 Optional. Publish flag. 0 for draft, 1 for publish. Default 0.
[5347] Fix | Delete
* }
[5348] Fix | Delete
* @return int|IXR_Error
[5349] Fix | Delete
*/
[5350] Fix | Delete
public function mw_newPost( $args ) {
[5351] Fix | Delete
$this->escape( $args );
[5352] Fix | Delete
[5353] Fix | Delete
$username = $args[1];
[5354] Fix | Delete
$password = $args[2];
[5355] Fix | Delete
$content_struct = $args[3];
[5356] Fix | Delete
$publish = isset( $args[4] ) ? $args[4] : 0;
[5357] Fix | Delete
[5358] Fix | Delete
$user = $this->login( $username, $password );
[5359] Fix | Delete
if ( ! $user ) {
[5360] Fix | Delete
return $this->error;
[5361] Fix | Delete
}
[5362] Fix | Delete
[5363] Fix | Delete
/** This action is documented in wp-includes/class-wp-xmlrpc-server.php */
[5364] Fix | Delete
do_action( 'xmlrpc_call', 'metaWeblog.newPost', $args, $this );
[5365] Fix | Delete
[5366] Fix | Delete
$page_template = '';
[5367] Fix | Delete
if ( ! empty( $content_struct['post_type'] ) ) {
[5368] Fix | Delete
if ( 'page' === $content_struct['post_type'] ) {
[5369] Fix | Delete
if ( $publish ) {
[5370] Fix | Delete
$cap = 'publish_pages';
[5371] Fix | Delete
} elseif ( isset( $content_struct['page_status'] ) && 'publish' === $content_struct['page_status'] ) {
[5372] Fix | Delete
$cap = 'publish_pages';
[5373] Fix | Delete
} else {
[5374] Fix | Delete
$cap = 'edit_pages';
[5375] Fix | Delete
}
[5376] Fix | Delete
$error_message = __( 'Sorry, you are not allowed to publish pages on this site.' );
[5377] Fix | Delete
$post_type = 'page';
[5378] Fix | Delete
if ( ! empty( $content_struct['wp_page_template'] ) ) {
[5379] Fix | Delete
$page_template = $content_struct['wp_page_template'];
[5380] Fix | Delete
}
[5381] Fix | Delete
} elseif ( 'post' === $content_struct['post_type'] ) {
[5382] Fix | Delete
if ( $publish ) {
[5383] Fix | Delete
$cap = 'publish_posts';
[5384] Fix | Delete
} elseif ( isset( $content_struct['post_status'] ) && 'publish' === $content_struct['post_status'] ) {
[5385] Fix | Delete
$cap = 'publish_posts';
[5386] Fix | Delete
} else {
[5387] Fix | Delete
$cap = 'edit_posts';
[5388] Fix | Delete
}
[5389] Fix | Delete
$error_message = __( 'Sorry, you are not allowed to publish posts on this site.' );
[5390] Fix | Delete
$post_type = 'post';
[5391] Fix | Delete
} else {
[5392] Fix | Delete
// No other 'post_type' values are allowed here.
[5393] Fix | Delete
return new IXR_Error( 401, __( 'Invalid post type.' ) );
[5394] Fix | Delete
}
[5395] Fix | Delete
} else {
[5396] Fix | Delete
if ( $publish ) {
[5397] Fix | Delete
$cap = 'publish_posts';
[5398] Fix | Delete
} elseif ( isset( $content_struct['post_status'] ) && 'publish' === $content_struct['post_status'] ) {
[5399] Fix | Delete
$cap = 'publish_posts';
[5400] Fix | Delete
} else {
[5401] Fix | Delete
$cap = 'edit_posts';
[5402] Fix | Delete
}
[5403] Fix | Delete
$error_message = __( 'Sorry, you are not allowed to publish posts on this site.' );
[5404] Fix | Delete
$post_type = 'post';
[5405] Fix | Delete
}
[5406] Fix | Delete
[5407] Fix | Delete
if ( ! current_user_can( get_post_type_object( $post_type )->cap->create_posts ) ) {
[5408] Fix | Delete
return new IXR_Error( 401, __( 'Sorry, you are not allowed to publish posts on this site.' ) );
[5409] Fix | Delete
}
[5410] Fix | Delete
if ( ! current_user_can( $cap ) ) {
[5411] Fix | Delete
return new IXR_Error( 401, $error_message );
[5412] Fix | Delete
}
[5413] Fix | Delete
[5414] Fix | Delete
// Check for a valid post format if one was given.
[5415] Fix | Delete
if ( isset( $content_struct['wp_post_format'] ) ) {
[5416] Fix | Delete
$content_struct['wp_post_format'] = sanitize_key( $content_struct['wp_post_format'] );
[5417] Fix | Delete
if ( ! array_key_exists( $content_struct['wp_post_format'], get_post_format_strings() ) ) {
[5418] Fix | Delete
return new IXR_Error( 404, __( 'Invalid post format.' ) );
[5419] Fix | Delete
}
[5420] Fix | Delete
}
[5421] Fix | Delete
[5422] Fix | Delete
// Let WordPress generate the 'post_name' (slug) unless
[5423] Fix | Delete
// one has been provided.
[5424] Fix | Delete
$post_name = null;
[5425] Fix | Delete
if ( isset( $content_struct['wp_slug'] ) ) {
[5426] Fix | Delete
$post_name = $content_struct['wp_slug'];
[5427] Fix | Delete
}
[5428] Fix | Delete
[5429] Fix | Delete
// Only use a password if one was given.
[5430] Fix | Delete
$post_password = '';
[5431] Fix | Delete
if ( isset( $content_struct['wp_password'] ) ) {
[5432] Fix | Delete
$post_password = $content_struct['wp_password'];
[5433] Fix | Delete
}
[5434] Fix | Delete
[5435] Fix | Delete
// Only set a post parent if one was given.
[5436] Fix | Delete
$post_parent = 0;
[5437] Fix | Delete
if ( isset( $content_struct['wp_page_parent_id'] ) ) {
[5438] Fix | Delete
$post_parent = $content_struct['wp_page_parent_id'];
[5439] Fix | Delete
}
[5440] Fix | Delete
[5441] Fix | Delete
// Only set the 'menu_order' if it was given.
[5442] Fix | Delete
$menu_order = 0;
[5443] Fix | Delete
if ( isset( $content_struct['wp_page_order'] ) ) {
[5444] Fix | Delete
$menu_order = $content_struct['wp_page_order'];
[5445] Fix | Delete
}
[5446] Fix | Delete
[5447] Fix | Delete
$post_author = $user->ID;
[5448] Fix | Delete
[5449] Fix | Delete
// If an author id was provided then use it instead.
[5450] Fix | Delete
if ( isset( $content_struct['wp_author_id'] ) && ( $user->ID != $content_struct['wp_author_id'] ) ) {
[5451] Fix | Delete
switch ( $post_type ) {
[5452] Fix | Delete
case 'post':
[5453] Fix | Delete
if ( ! current_user_can( 'edit_others_posts' ) ) {
[5454] Fix | Delete
return new IXR_Error( 401, __( 'Sorry, you are not allowed to create posts as this user.' ) );
[5455] Fix | Delete
}
[5456] Fix | Delete
break;
[5457] Fix | Delete
case 'page':
[5458] Fix | Delete
if ( ! current_user_can( 'edit_others_pages' ) ) {
[5459] Fix | Delete
return new IXR_Error( 401, __( 'Sorry, you are not allowed to create pages as this user.' ) );
[5460] Fix | Delete
}
[5461] Fix | Delete
break;
[5462] Fix | Delete
default:
[5463] Fix | Delete
return new IXR_Error( 401, __( 'Invalid post type.' ) );
[5464] Fix | Delete
}
[5465] Fix | Delete
$author = get_userdata( $content_struct['wp_author_id'] );
[5466] Fix | Delete
if ( ! $author ) {
[5467] Fix | Delete
return new IXR_Error( 404, __( 'Invalid author ID.' ) );
[5468] Fix | Delete
}
[5469] Fix | Delete
$post_author = $content_struct['wp_author_id'];
[5470] Fix | Delete
}
[5471] Fix | Delete
[5472] Fix | Delete
$post_title = isset( $content_struct['title'] ) ? $content_struct['title'] : '';
[5473] Fix | Delete
$post_content = isset( $content_struct['description'] ) ? $content_struct['description'] : '';
[5474] Fix | Delete
[5475] Fix | Delete
$post_status = $publish ? 'publish' : 'draft';
[5476] Fix | Delete
[5477] Fix | Delete
if ( isset( $content_struct[ "{$post_type}_status" ] ) ) {
[5478] Fix | Delete
switch ( $content_struct[ "{$post_type}_status" ] ) {
[5479] Fix | Delete
case 'draft':
[5480] Fix | Delete
case 'pending':
[5481] Fix | Delete
case 'private':
[5482] Fix | Delete
case 'publish':
[5483] Fix | Delete
$post_status = $content_struct[ "{$post_type}_status" ];
[5484] Fix | Delete
break;
[5485] Fix | Delete
default:
[5486] Fix | Delete
// Deliberably left empty.
[5487] Fix | Delete
break;
[5488] Fix | Delete
}
[5489] Fix | Delete
}
[5490] Fix | Delete
[5491] Fix | Delete
$post_excerpt = isset( $content_struct['mt_excerpt'] ) ? $content_struct['mt_excerpt'] : '';
[5492] Fix | Delete
$post_more = isset( $content_struct['mt_text_more'] ) ? $content_struct['mt_text_more'] : '';
[5493] Fix | Delete
[5494] Fix | Delete
$tags_input = isset( $content_struct['mt_keywords'] ) ? $content_struct['mt_keywords'] : array();
[5495] Fix | Delete
[5496] Fix | Delete
if ( isset( $content_struct['mt_allow_comments'] ) ) {
[5497] Fix | Delete
if ( ! is_numeric( $content_struct['mt_allow_comments'] ) ) {
[5498] Fix | Delete
switch ( $content_struct['mt_allow_comments'] ) {
[5499] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function