Skip to content

Commit

Permalink
Update post.php
Browse files Browse the repository at this point in the history
  • Loading branch information
wprashed committed Jan 11, 2025
1 parent 488e4bc commit f83ec0f
Showing 1 changed file with 39 additions and 1 deletion.
40 changes: 39 additions & 1 deletion src/wp-includes/post.php
Original file line number Diff line number Diff line change
Expand Up @@ -8473,4 +8473,42 @@ function wp_create_initial_post_meta() {
* are tracked as revisions, allowing users to revert changes if needed.
*
* @param array $post_data An array of sanitized post data.
*/
*/

function edit_post($post_data) {
// Verify post ID exists.
if (empty($post_data['ID'])) {
return new WP_Error('missing_post_id', __('Post ID is missing.', 'dpb'));
}

// Retrieve the post to ensure it exists and can be updated.
$post = get_post($post_data['ID']);
if (!$post) {
return new WP_Error('invalid_post_id', __('Invalid post ID.', 'dpb'));
}

// Check if the post type supports revisions.
if (post_type_supports($post->post_type, 'revisions')) {
/**
* Check if the request was triggered by Quick Edit.
* The '_inline_edit' field in the $_POST data indicates Quick Edit usage.
*/
if (isset($_POST['_inline_edit'])) {
// Save a new revision for the post being updated.
wp_save_post_revision($post_data['ID']);
}
}

// Continue with existing logic to update the post (simplified for illustration).
$updated = wp_update_post($post_data, true);

// Return an error if the update failed.
if (is_wp_error($updated)) {
return $updated;
}

// Perform any additional actions after the post is updated.
do_action('post_updated', $post_data['ID'], $post_data);

return $updated;
}

0 comments on commit f83ec0f

Please sign in to comment.