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
case 'closed':
[5500] Fix | Delete
$comment_status = 'closed';
[5501] Fix | Delete
break;
[5502] Fix | Delete
case 'open':
[5503] Fix | Delete
$comment_status = 'open';
[5504] Fix | Delete
break;
[5505] Fix | Delete
default:
[5506] Fix | Delete
$comment_status = get_default_comment_status( $post_type );
[5507] Fix | Delete
break;
[5508] Fix | Delete
}
[5509] Fix | Delete
} else {
[5510] Fix | Delete
switch ( (int) $content_struct['mt_allow_comments'] ) {
[5511] Fix | Delete
case 0:
[5512] Fix | Delete
case 2:
[5513] Fix | Delete
$comment_status = 'closed';
[5514] Fix | Delete
break;
[5515] Fix | Delete
case 1:
[5516] Fix | Delete
$comment_status = 'open';
[5517] Fix | Delete
break;
[5518] Fix | Delete
default:
[5519] Fix | Delete
$comment_status = get_default_comment_status( $post_type );
[5520] Fix | Delete
break;
[5521] Fix | Delete
}
[5522] Fix | Delete
}
[5523] Fix | Delete
} else {
[5524] Fix | Delete
$comment_status = get_default_comment_status( $post_type );
[5525] Fix | Delete
}
[5526] Fix | Delete
[5527] Fix | Delete
if ( isset( $content_struct['mt_allow_pings'] ) ) {
[5528] Fix | Delete
if ( ! is_numeric( $content_struct['mt_allow_pings'] ) ) {
[5529] Fix | Delete
switch ( $content_struct['mt_allow_pings'] ) {
[5530] Fix | Delete
case 'closed':
[5531] Fix | Delete
$ping_status = 'closed';
[5532] Fix | Delete
break;
[5533] Fix | Delete
case 'open':
[5534] Fix | Delete
$ping_status = 'open';
[5535] Fix | Delete
break;
[5536] Fix | Delete
default:
[5537] Fix | Delete
$ping_status = get_default_comment_status( $post_type, 'pingback' );
[5538] Fix | Delete
break;
[5539] Fix | Delete
}
[5540] Fix | Delete
} else {
[5541] Fix | Delete
switch ( (int) $content_struct['mt_allow_pings'] ) {
[5542] Fix | Delete
case 0:
[5543] Fix | Delete
$ping_status = 'closed';
[5544] Fix | Delete
break;
[5545] Fix | Delete
case 1:
[5546] Fix | Delete
$ping_status = 'open';
[5547] Fix | Delete
break;
[5548] Fix | Delete
default:
[5549] Fix | Delete
$ping_status = get_default_comment_status( $post_type, 'pingback' );
[5550] Fix | Delete
break;
[5551] Fix | Delete
}
[5552] Fix | Delete
}
[5553] Fix | Delete
} else {
[5554] Fix | Delete
$ping_status = get_default_comment_status( $post_type, 'pingback' );
[5555] Fix | Delete
}
[5556] Fix | Delete
[5557] Fix | Delete
if ( $post_more ) {
[5558] Fix | Delete
$post_content .= '<!--more-->' . $post_more;
[5559] Fix | Delete
}
[5560] Fix | Delete
[5561] Fix | Delete
$to_ping = '';
[5562] Fix | Delete
if ( isset( $content_struct['mt_tb_ping_urls'] ) ) {
[5563] Fix | Delete
$to_ping = $content_struct['mt_tb_ping_urls'];
[5564] Fix | Delete
if ( is_array( $to_ping ) ) {
[5565] Fix | Delete
$to_ping = implode( ' ', $to_ping );
[5566] Fix | Delete
}
[5567] Fix | Delete
}
[5568] Fix | Delete
[5569] Fix | Delete
// Do some timestamp voodoo.
[5570] Fix | Delete
if ( ! empty( $content_struct['date_created_gmt'] ) ) {
[5571] Fix | Delete
// We know this is supposed to be GMT, so we're going to slap that Z on there by force.
[5572] Fix | Delete
$dateCreated = rtrim( $content_struct['date_created_gmt']->getIso(), 'Z' ) . 'Z';
[5573] Fix | Delete
} elseif ( ! empty( $content_struct['dateCreated'] ) ) {
[5574] Fix | Delete
$dateCreated = $content_struct['dateCreated']->getIso();
[5575] Fix | Delete
}
[5576] Fix | Delete
[5577] Fix | Delete
$post_date = '';
[5578] Fix | Delete
$post_date_gmt = '';
[5579] Fix | Delete
if ( ! empty( $dateCreated ) ) {
[5580] Fix | Delete
$post_date = iso8601_to_datetime( $dateCreated );
[5581] Fix | Delete
$post_date_gmt = iso8601_to_datetime( $dateCreated, 'gmt' );
[5582] Fix | Delete
}
[5583] Fix | Delete
[5584] Fix | Delete
$post_category = array();
[5585] Fix | Delete
if ( isset( $content_struct['categories'] ) ) {
[5586] Fix | Delete
$catnames = $content_struct['categories'];
[5587] Fix | Delete
[5588] Fix | Delete
if ( is_array( $catnames ) ) {
[5589] Fix | Delete
foreach ( $catnames as $cat ) {
[5590] Fix | Delete
$post_category[] = get_cat_ID( $cat );
[5591] Fix | Delete
}
[5592] Fix | Delete
}
[5593] Fix | Delete
}
[5594] Fix | Delete
[5595] Fix | Delete
$postdata = compact( 'post_author', 'post_date', 'post_date_gmt', 'post_content', 'post_title', 'post_category', 'post_status', 'post_excerpt', 'comment_status', 'ping_status', 'to_ping', 'post_type', 'post_name', 'post_password', 'post_parent', 'menu_order', 'tags_input', 'page_template' );
[5596] Fix | Delete
[5597] Fix | Delete
$post_id = get_default_post_to_edit( $post_type, true )->ID;
[5598] Fix | Delete
$postdata['ID'] = $post_id;
[5599] Fix | Delete
[5600] Fix | Delete
// Only posts can be sticky.
[5601] Fix | Delete
if ( 'post' === $post_type && isset( $content_struct['sticky'] ) ) {
[5602] Fix | Delete
$data = $postdata;
[5603] Fix | Delete
$data['sticky'] = $content_struct['sticky'];
[5604] Fix | Delete
$error = $this->_toggle_sticky( $data );
[5605] Fix | Delete
if ( $error ) {
[5606] Fix | Delete
return $error;
[5607] Fix | Delete
}
[5608] Fix | Delete
}
[5609] Fix | Delete
[5610] Fix | Delete
if ( isset( $content_struct['custom_fields'] ) ) {
[5611] Fix | Delete
$this->set_custom_fields( $post_id, $content_struct['custom_fields'] );
[5612] Fix | Delete
}
[5613] Fix | Delete
[5614] Fix | Delete
if ( isset( $content_struct['wp_post_thumbnail'] ) ) {
[5615] Fix | Delete
if ( set_post_thumbnail( $post_id, $content_struct['wp_post_thumbnail'] ) === false ) {
[5616] Fix | Delete
return new IXR_Error( 404, __( 'Invalid attachment ID.' ) );
[5617] Fix | Delete
}
[5618] Fix | Delete
[5619] Fix | Delete
unset( $content_struct['wp_post_thumbnail'] );
[5620] Fix | Delete
}
[5621] Fix | Delete
[5622] Fix | Delete
// Handle enclosures.
[5623] Fix | Delete
$thisEnclosure = isset( $content_struct['enclosure'] ) ? $content_struct['enclosure'] : null;
[5624] Fix | Delete
$this->add_enclosure_if_new( $post_id, $thisEnclosure );
[5625] Fix | Delete
[5626] Fix | Delete
$this->attach_uploads( $post_id, $post_content );
[5627] Fix | Delete
[5628] Fix | Delete
/*
[5629] Fix | Delete
* Handle post formats if assigned, value is validated earlier
[5630] Fix | Delete
* in this function.
[5631] Fix | Delete
*/
[5632] Fix | Delete
if ( isset( $content_struct['wp_post_format'] ) ) {
[5633] Fix | Delete
set_post_format( $post_id, $content_struct['wp_post_format'] );
[5634] Fix | Delete
}
[5635] Fix | Delete
[5636] Fix | Delete
$post_id = wp_insert_post( $postdata, true );
[5637] Fix | Delete
if ( is_wp_error( $post_id ) ) {
[5638] Fix | Delete
return new IXR_Error( 500, $post_id->get_error_message() );
[5639] Fix | Delete
}
[5640] Fix | Delete
[5641] Fix | Delete
if ( ! $post_id ) {
[5642] Fix | Delete
return new IXR_Error( 500, __( 'Sorry, the post could not be created.' ) );
[5643] Fix | Delete
}
[5644] Fix | Delete
[5645] Fix | Delete
/**
[5646] Fix | Delete
* Fires after a new post has been successfully created via the XML-RPC MovableType API.
[5647] Fix | Delete
*
[5648] Fix | Delete
* @since 3.4.0
[5649] Fix | Delete
*
[5650] Fix | Delete
* @param int $post_id ID of the new post.
[5651] Fix | Delete
* @param array $args An array of arguments to create the new post.
[5652] Fix | Delete
*/
[5653] Fix | Delete
do_action( 'xmlrpc_call_success_mw_newPost', $post_id, $args ); // phpcs:ignore WordPress.NamingConventions.ValidHookName.NotLowercase
[5654] Fix | Delete
[5655] Fix | Delete
return (string) $post_id;
[5656] Fix | Delete
}
[5657] Fix | Delete
[5658] Fix | Delete
/**
[5659] Fix | Delete
* Adds an enclosure to a post if it's new.
[5660] Fix | Delete
*
[5661] Fix | Delete
* @since 2.8.0
[5662] Fix | Delete
*
[5663] Fix | Delete
* @param int $post_id Post ID.
[5664] Fix | Delete
* @param array $enclosure Enclosure data.
[5665] Fix | Delete
*/
[5666] Fix | Delete
public function add_enclosure_if_new( $post_id, $enclosure ) {
[5667] Fix | Delete
if ( is_array( $enclosure ) && isset( $enclosure['url'] ) && isset( $enclosure['length'] ) && isset( $enclosure['type'] ) ) {
[5668] Fix | Delete
$encstring = $enclosure['url'] . "\n" . $enclosure['length'] . "\n" . $enclosure['type'] . "\n";
[5669] Fix | Delete
$found = false;
[5670] Fix | Delete
$enclosures = get_post_meta( $post_id, 'enclosure' );
[5671] Fix | Delete
if ( $enclosures ) {
[5672] Fix | Delete
foreach ( $enclosures as $enc ) {
[5673] Fix | Delete
// This method used to omit the trailing new line. #23219
[5674] Fix | Delete
if ( rtrim( $enc, "\n" ) === rtrim( $encstring, "\n" ) ) {
[5675] Fix | Delete
$found = true;
[5676] Fix | Delete
break;
[5677] Fix | Delete
}
[5678] Fix | Delete
}
[5679] Fix | Delete
}
[5680] Fix | Delete
if ( ! $found ) {
[5681] Fix | Delete
add_post_meta( $post_id, 'enclosure', $encstring );
[5682] Fix | Delete
}
[5683] Fix | Delete
}
[5684] Fix | Delete
}
[5685] Fix | Delete
[5686] Fix | Delete
/**
[5687] Fix | Delete
* Attaches an upload to a post.
[5688] Fix | Delete
*
[5689] Fix | Delete
* @since 2.1.0
[5690] Fix | Delete
*
[5691] Fix | Delete
* @global wpdb $wpdb WordPress database abstraction object.
[5692] Fix | Delete
*
[5693] Fix | Delete
* @param int $post_id Post ID.
[5694] Fix | Delete
* @param string $post_content Post Content for attachment.
[5695] Fix | Delete
*/
[5696] Fix | Delete
public function attach_uploads( $post_id, $post_content ) {
[5697] Fix | Delete
global $wpdb;
[5698] Fix | Delete
[5699] Fix | Delete
// Find any unattached files.
[5700] Fix | Delete
$attachments = $wpdb->get_results( "SELECT ID, guid FROM {$wpdb->posts} WHERE post_parent = '0' AND post_type = 'attachment'" );
[5701] Fix | Delete
if ( is_array( $attachments ) ) {
[5702] Fix | Delete
foreach ( $attachments as $file ) {
[5703] Fix | Delete
if ( ! empty( $file->guid ) && str_contains( $post_content, $file->guid ) ) {
[5704] Fix | Delete
$wpdb->update( $wpdb->posts, array( 'post_parent' => $post_id ), array( 'ID' => $file->ID ) );
[5705] Fix | Delete
}
[5706] Fix | Delete
}
[5707] Fix | Delete
}
[5708] Fix | Delete
}
[5709] Fix | Delete
[5710] Fix | Delete
/**
[5711] Fix | Delete
* Edits a post.
[5712] Fix | Delete
*
[5713] Fix | Delete
* @since 1.5.0
[5714] Fix | Delete
*
[5715] Fix | Delete
* @param array $args {
[5716] Fix | Delete
* Method arguments. Note: arguments must be ordered as documented.
[5717] Fix | Delete
*
[5718] Fix | Delete
* @type int $0 Post ID.
[5719] Fix | Delete
* @type string $1 Username.
[5720] Fix | Delete
* @type string $2 Password.
[5721] Fix | Delete
* @type array $3 Content structure.
[5722] Fix | Delete
* @type int $4 Optional. Publish flag. 0 for draft, 1 for publish. Default 0.
[5723] Fix | Delete
* }
[5724] Fix | Delete
* @return true|IXR_Error True on success.
[5725] Fix | Delete
*/
[5726] Fix | Delete
public function mw_editPost( $args ) {
[5727] Fix | Delete
$this->escape( $args );
[5728] Fix | Delete
[5729] Fix | Delete
$post_id = (int) $args[0];
[5730] Fix | Delete
$username = $args[1];
[5731] Fix | Delete
$password = $args[2];
[5732] Fix | Delete
$content_struct = $args[3];
[5733] Fix | Delete
$publish = isset( $args[4] ) ? $args[4] : 0;
[5734] Fix | Delete
[5735] Fix | Delete
$user = $this->login( $username, $password );
[5736] Fix | Delete
if ( ! $user ) {
[5737] Fix | Delete
return $this->error;
[5738] Fix | Delete
}
[5739] Fix | Delete
[5740] Fix | Delete
/** This action is documented in wp-includes/class-wp-xmlrpc-server.php */
[5741] Fix | Delete
do_action( 'xmlrpc_call', 'metaWeblog.editPost', $args, $this );
[5742] Fix | Delete
[5743] Fix | Delete
$postdata = get_post( $post_id, ARRAY_A );
[5744] Fix | Delete
[5745] Fix | Delete
/*
[5746] Fix | Delete
* If there is no post data for the give post ID, stop now and return an error.
[5747] Fix | Delete
* Otherwise a new post will be created (which was the old behavior).
[5748] Fix | Delete
*/
[5749] Fix | Delete
if ( ! $postdata || empty( $postdata['ID'] ) ) {
[5750] Fix | Delete
return new IXR_Error( 404, __( 'Invalid post ID.' ) );
[5751] Fix | Delete
}
[5752] Fix | Delete
[5753] Fix | Delete
if ( ! current_user_can( 'edit_post', $post_id ) ) {
[5754] Fix | Delete
return new IXR_Error( 401, __( 'Sorry, you are not allowed to edit this post.' ) );
[5755] Fix | Delete
}
[5756] Fix | Delete
[5757] Fix | Delete
// Use wp.editPost to edit post types other than post and page.
[5758] Fix | Delete
if ( ! in_array( $postdata['post_type'], array( 'post', 'page' ), true ) ) {
[5759] Fix | Delete
return new IXR_Error( 401, __( 'Invalid post type.' ) );
[5760] Fix | Delete
}
[5761] Fix | Delete
[5762] Fix | Delete
// Thwart attempt to change the post type.
[5763] Fix | Delete
if ( ! empty( $content_struct['post_type'] ) && ( $content_struct['post_type'] != $postdata['post_type'] ) ) {
[5764] Fix | Delete
return new IXR_Error( 401, __( 'The post type may not be changed.' ) );
[5765] Fix | Delete
}
[5766] Fix | Delete
[5767] Fix | Delete
// Check for a valid post format if one was given.
[5768] Fix | Delete
if ( isset( $content_struct['wp_post_format'] ) ) {
[5769] Fix | Delete
$content_struct['wp_post_format'] = sanitize_key( $content_struct['wp_post_format'] );
[5770] Fix | Delete
if ( ! array_key_exists( $content_struct['wp_post_format'], get_post_format_strings() ) ) {
[5771] Fix | Delete
return new IXR_Error( 404, __( 'Invalid post format.' ) );
[5772] Fix | Delete
}
[5773] Fix | Delete
}
[5774] Fix | Delete
[5775] Fix | Delete
$this->escape( $postdata );
[5776] Fix | Delete
[5777] Fix | Delete
$ID = $postdata['ID'];
[5778] Fix | Delete
$post_content = $postdata['post_content'];
[5779] Fix | Delete
$post_title = $postdata['post_title'];
[5780] Fix | Delete
$post_excerpt = $postdata['post_excerpt'];
[5781] Fix | Delete
$post_password = $postdata['post_password'];
[5782] Fix | Delete
$post_parent = $postdata['post_parent'];
[5783] Fix | Delete
$post_type = $postdata['post_type'];
[5784] Fix | Delete
$menu_order = $postdata['menu_order'];
[5785] Fix | Delete
$ping_status = $postdata['ping_status'];
[5786] Fix | Delete
$comment_status = $postdata['comment_status'];
[5787] Fix | Delete
[5788] Fix | Delete
// Let WordPress manage slug if none was provided.
[5789] Fix | Delete
$post_name = $postdata['post_name'];
[5790] Fix | Delete
if ( isset( $content_struct['wp_slug'] ) ) {
[5791] Fix | Delete
$post_name = $content_struct['wp_slug'];
[5792] Fix | Delete
}
[5793] Fix | Delete
[5794] Fix | Delete
// Only use a password if one was given.
[5795] Fix | Delete
if ( isset( $content_struct['wp_password'] ) ) {
[5796] Fix | Delete
$post_password = $content_struct['wp_password'];
[5797] Fix | Delete
}
[5798] Fix | Delete
[5799] Fix | Delete
// Only set a post parent if one was given.
[5800] Fix | Delete
if ( isset( $content_struct['wp_page_parent_id'] ) ) {
[5801] Fix | Delete
$post_parent = $content_struct['wp_page_parent_id'];
[5802] Fix | Delete
}
[5803] Fix | Delete
[5804] Fix | Delete
// Only set the 'menu_order' if it was given.
[5805] Fix | Delete
if ( isset( $content_struct['wp_page_order'] ) ) {
[5806] Fix | Delete
$menu_order = $content_struct['wp_page_order'];
[5807] Fix | Delete
}
[5808] Fix | Delete
[5809] Fix | Delete
$page_template = '';
[5810] Fix | Delete
if ( ! empty( $content_struct['wp_page_template'] ) && 'page' === $post_type ) {
[5811] Fix | Delete
$page_template = $content_struct['wp_page_template'];
[5812] Fix | Delete
}
[5813] Fix | Delete
[5814] Fix | Delete
$post_author = $postdata['post_author'];
[5815] Fix | Delete
[5816] Fix | Delete
// If an author id was provided then use it instead.
[5817] Fix | Delete
if ( isset( $content_struct['wp_author_id'] ) ) {
[5818] Fix | Delete
// Check permissions if attempting to switch author to or from another user.
[5819] Fix | Delete
if ( $user->ID != $content_struct['wp_author_id'] || $user->ID != $post_author ) {
[5820] Fix | Delete
switch ( $post_type ) {
[5821] Fix | Delete
case 'post':
[5822] Fix | Delete
if ( ! current_user_can( 'edit_others_posts' ) ) {
[5823] Fix | Delete
return new IXR_Error( 401, __( 'Sorry, you are not allowed to change the post author as this user.' ) );
[5824] Fix | Delete
}
[5825] Fix | Delete
break;
[5826] Fix | Delete
case 'page':
[5827] Fix | Delete
if ( ! current_user_can( 'edit_others_pages' ) ) {
[5828] Fix | Delete
return new IXR_Error( 401, __( 'Sorry, you are not allowed to change the page author as this user.' ) );
[5829] Fix | Delete
}
[5830] Fix | Delete
break;
[5831] Fix | Delete
default:
[5832] Fix | Delete
return new IXR_Error( 401, __( 'Invalid post type.' ) );
[5833] Fix | Delete
}
[5834] Fix | Delete
$post_author = $content_struct['wp_author_id'];
[5835] Fix | Delete
}
[5836] Fix | Delete
}
[5837] Fix | Delete
[5838] Fix | Delete
if ( isset( $content_struct['mt_allow_comments'] ) ) {
[5839] Fix | Delete
if ( ! is_numeric( $content_struct['mt_allow_comments'] ) ) {
[5840] Fix | Delete
switch ( $content_struct['mt_allow_comments'] ) {
[5841] Fix | Delete
case 'closed':
[5842] Fix | Delete
$comment_status = 'closed';
[5843] Fix | Delete
break;
[5844] Fix | Delete
case 'open':
[5845] Fix | Delete
$comment_status = 'open';
[5846] Fix | Delete
break;
[5847] Fix | Delete
default:
[5848] Fix | Delete
$comment_status = get_default_comment_status( $post_type );
[5849] Fix | Delete
break;
[5850] Fix | Delete
}
[5851] Fix | Delete
} else {
[5852] Fix | Delete
switch ( (int) $content_struct['mt_allow_comments'] ) {
[5853] Fix | Delete
case 0:
[5854] Fix | Delete
case 2:
[5855] Fix | Delete
$comment_status = 'closed';
[5856] Fix | Delete
break;
[5857] Fix | Delete
case 1:
[5858] Fix | Delete
$comment_status = 'open';
[5859] Fix | Delete
break;
[5860] Fix | Delete
default:
[5861] Fix | Delete
$comment_status = get_default_comment_status( $post_type );
[5862] Fix | Delete
break;
[5863] Fix | Delete
}
[5864] Fix | Delete
}
[5865] Fix | Delete
}
[5866] Fix | Delete
[5867] Fix | Delete
if ( isset( $content_struct['mt_allow_pings'] ) ) {
[5868] Fix | Delete
if ( ! is_numeric( $content_struct['mt_allow_pings'] ) ) {
[5869] Fix | Delete
switch ( $content_struct['mt_allow_pings'] ) {
[5870] Fix | Delete
case 'closed':
[5871] Fix | Delete
$ping_status = 'closed';
[5872] Fix | Delete
break;
[5873] Fix | Delete
case 'open':
[5874] Fix | Delete
$ping_status = 'open';
[5875] Fix | Delete
break;
[5876] Fix | Delete
default:
[5877] Fix | Delete
$ping_status = get_default_comment_status( $post_type, 'pingback' );
[5878] Fix | Delete
break;
[5879] Fix | Delete
}
[5880] Fix | Delete
} else {
[5881] Fix | Delete
switch ( (int) $content_struct['mt_allow_pings'] ) {
[5882] Fix | Delete
case 0:
[5883] Fix | Delete
$ping_status = 'closed';
[5884] Fix | Delete
break;
[5885] Fix | Delete
case 1:
[5886] Fix | Delete
$ping_status = 'open';
[5887] Fix | Delete
break;
[5888] Fix | Delete
default:
[5889] Fix | Delete
$ping_status = get_default_comment_status( $post_type, 'pingback' );
[5890] Fix | Delete
break;
[5891] Fix | Delete
}
[5892] Fix | Delete
}
[5893] Fix | Delete
}
[5894] Fix | Delete
[5895] Fix | Delete
if ( isset( $content_struct['title'] ) ) {
[5896] Fix | Delete
$post_title = $content_struct['title'];
[5897] Fix | Delete
}
[5898] Fix | Delete
[5899] Fix | Delete
if ( isset( $content_struct['description'] ) ) {
[5900] Fix | Delete
$post_content = $content_struct['description'];
[5901] Fix | Delete
}
[5902] Fix | Delete
[5903] Fix | Delete
$post_category = array();
[5904] Fix | Delete
if ( isset( $content_struct['categories'] ) ) {
[5905] Fix | Delete
$catnames = $content_struct['categories'];
[5906] Fix | Delete
if ( is_array( $catnames ) ) {
[5907] Fix | Delete
foreach ( $catnames as $cat ) {
[5908] Fix | Delete
$post_category[] = get_cat_ID( $cat );
[5909] Fix | Delete
}
[5910] Fix | Delete
}
[5911] Fix | Delete
}
[5912] Fix | Delete
[5913] Fix | Delete
if ( isset( $content_struct['mt_excerpt'] ) ) {
[5914] Fix | Delete
$post_excerpt = $content_struct['mt_excerpt'];
[5915] Fix | Delete
}
[5916] Fix | Delete
[5917] Fix | Delete
$post_more = isset( $content_struct['mt_text_more'] ) ? $content_struct['mt_text_more'] : '';
[5918] Fix | Delete
[5919] Fix | Delete
$post_status = $publish ? 'publish' : 'draft';
[5920] Fix | Delete
if ( isset( $content_struct[ "{$post_type}_status" ] ) ) {
[5921] Fix | Delete
switch ( $content_struct[ "{$post_type}_status" ] ) {
[5922] Fix | Delete
case 'draft':
[5923] Fix | Delete
case 'pending':
[5924] Fix | Delete
case 'private':
[5925] Fix | Delete
case 'publish':
[5926] Fix | Delete
$post_status = $content_struct[ "{$post_type}_status" ];
[5927] Fix | Delete
break;
[5928] Fix | Delete
default:
[5929] Fix | Delete
$post_status = $publish ? 'publish' : 'draft';
[5930] Fix | Delete
break;
[5931] Fix | Delete
}
[5932] Fix | Delete
}
[5933] Fix | Delete
[5934] Fix | Delete
$tags_input = isset( $content_struct['mt_keywords'] ) ? $content_struct['mt_keywords'] : array();
[5935] Fix | Delete
[5936] Fix | Delete
if ( 'publish' === $post_status || 'private' === $post_status ) {
[5937] Fix | Delete
if ( 'page' === $post_type && ! current_user_can( 'publish_pages' ) ) {
[5938] Fix | Delete
return new IXR_Error( 401, __( 'Sorry, you are not allowed to publish this page.' ) );
[5939] Fix | Delete
} elseif ( ! current_user_can( 'publish_posts' ) ) {
[5940] Fix | Delete
return new IXR_Error( 401, __( 'Sorry, you are not allowed to publish this post.' ) );
[5941] Fix | Delete
}
[5942] Fix | Delete
}
[5943] Fix | Delete
[5944] Fix | Delete
if ( $post_more ) {
[5945] Fix | Delete
$post_content = $post_content . '<!--more-->' . $post_more;
[5946] Fix | Delete
}
[5947] Fix | Delete
[5948] Fix | Delete
$to_ping = '';
[5949] Fix | Delete
if ( isset( $content_struct['mt_tb_ping_urls'] ) ) {
[5950] Fix | Delete
$to_ping = $content_struct['mt_tb_ping_urls'];
[5951] Fix | Delete
if ( is_array( $to_ping ) ) {
[5952] Fix | Delete
$to_ping = implode( ' ', $to_ping );
[5953] Fix | Delete
}
[5954] Fix | Delete
}
[5955] Fix | Delete
[5956] Fix | Delete
// Do some timestamp voodoo.
[5957] Fix | Delete
if ( ! empty( $content_struct['date_created_gmt'] ) ) {
[5958] Fix | Delete
// We know this is supposed to be GMT, so we're going to slap that Z on there by force.
[5959] Fix | Delete
$dateCreated = rtrim( $content_struct['date_created_gmt']->getIso(), 'Z' ) . 'Z';
[5960] Fix | Delete
} elseif ( ! empty( $content_struct['dateCreated'] ) ) {
[5961] Fix | Delete
$dateCreated = $content_struct['dateCreated']->getIso();
[5962] Fix | Delete
}
[5963] Fix | Delete
[5964] Fix | Delete
// Default to not flagging the post date to be edited unless it's intentional.
[5965] Fix | Delete
$edit_date = false;
[5966] Fix | Delete
[5967] Fix | Delete
if ( ! empty( $dateCreated ) ) {
[5968] Fix | Delete
$post_date = iso8601_to_datetime( $dateCreated );
[5969] Fix | Delete
$post_date_gmt = iso8601_to_datetime( $dateCreated, 'gmt' );
[5970] Fix | Delete
[5971] Fix | Delete
// Flag the post date to be edited.
[5972] Fix | Delete
$edit_date = true;
[5973] Fix | Delete
} else {
[5974] Fix | Delete
$post_date = $postdata['post_date'];
[5975] Fix | Delete
$post_date_gmt = $postdata['post_date_gmt'];
[5976] Fix | Delete
}
[5977] Fix | Delete
[5978] Fix | Delete
// We've got all the data -- post it.
[5979] Fix | Delete
$newpost = compact( 'ID', 'post_content', 'post_title', 'post_category', 'post_status', 'post_excerpt', 'comment_status', 'ping_status', 'edit_date', 'post_date', 'post_date_gmt', 'to_ping', 'post_name', 'post_password', 'post_parent', 'menu_order', 'post_author', 'tags_input', 'page_template' );
[5980] Fix | Delete
[5981] Fix | Delete
$result = wp_update_post( $newpost, true );
[5982] Fix | Delete
if ( is_wp_error( $result ) ) {
[5983] Fix | Delete
return new IXR_Error( 500, $result->get_error_message() );
[5984] Fix | Delete
}
[5985] Fix | Delete
[5986] Fix | Delete
if ( ! $result ) {
[5987] Fix | Delete
return new IXR_Error( 500, __( 'Sorry, the post could not be updated.' ) );
[5988] Fix | Delete
}
[5989] Fix | Delete
[5990] Fix | Delete
// Only posts can be sticky.
[5991] Fix | Delete
if ( 'post' === $post_type && isset( $content_struct['sticky'] ) ) {
[5992] Fix | Delete
$data = $newpost;
[5993] Fix | Delete
$data['sticky'] = $content_struct['sticky'];
[5994] Fix | Delete
$data['post_type'] = 'post';
[5995] Fix | Delete
$error = $this->_toggle_sticky( $data, true );
[5996] Fix | Delete
if ( $error ) {
[5997] Fix | Delete
return $error;
[5998] Fix | Delete
}
[5999] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function