Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
…d852eb0e9c85aa5776e6b7377e from refs/tags/v1.0.18-beta
  • Loading branch information
prcdevgitbot committed Oct 9, 2024
1 parent 0d35f3b commit cd9c75d
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ public function init($loader = null) {
/**
* @uses prc_platform_on_incremental_save
*/
$loader->add_action( 'save_post', $this, 'post_incremental_save_hook', 10, 3 );
$loader->add_action( 'save_post', $this, 'restful_post_incremental_save_hook', 10, 3 );
/**
* @uses prc_platform_on_post_init
*/
Expand Down Expand Up @@ -314,15 +314,15 @@ public function apply_extra_wp_post_object_fields( $ref_post ) {
* @param mixed $update
* @return void
*/
public function post_incremental_save_hook( $post_id, $post, $update ) {
public function restful_post_incremental_save_hook( $post_id, $post, $update ) {
if ( true === $this->is_cli ) {
return;
}
if ( true !== $update ) {
return;
}
// This will make sure this doesnt run twice on Gutenberg editor.
if ( defined( 'REST_REQUEST' ) && true === REST_REQUEST ) {
if ( !defined( 'REST_REQUEST' ) || true !== REST_REQUEST ) {
return;
}
if ( ! in_array( $post->post_status, array( 'draft', 'publish' ) ) ) {
Expand All @@ -340,7 +340,7 @@ public function post_incremental_save_hook( $post_id, $post, $update ) {
if ( wp_is_post_revision( $post_id ) || wp_is_post_autosave( $post_id ) ) {
return;
}
if ( doing_action( 'prc_platform_on_incremental_save' ) ) {
if ( doing_action( 'prc_platform_on_incremental_save' ) || doing_action( 'prc_platform_on_rest_publish' ) || doing_action( 'prc_platform_on_rest_update' )) {
return;
}

Expand Down
8 changes: 4 additions & 4 deletions includes/post-report-package/class-post-report-package.php
Original file line number Diff line number Diff line change
Expand Up @@ -332,12 +332,12 @@ public function update_children( $post ) {
}

if ( is_wp_error( $child_updated ) ) {
$errors[] = new WP_Error( '409', 'Failed to update child post state.', $child_updated );
$errors[] = new WP_Error( 'post-report-package::failed-to-update-child-post-state', 'Failed to update child post state.', $child_updated );
} else {
$success[] = $child_updated;
}
if ( is_wp_error( $terms_updated ) ) {
$errors[] = new WP_Error( '409', 'Failed to update child post terms.', $terms_updated );
$errors[] = new WP_Error( 'post-report-package::failed-to-update-child-post-terms', 'Failed to update child post terms.', $terms_updated );
}
}

Expand All @@ -355,7 +355,7 @@ public function assign_child_to_parent($child_post_id, $parent_post_id) {
'post_parent' => $parent_post_id,
), true );
if ( is_wp_error( $updated ) ) {
return new WP_Error( '412', 'Failed to assign child post to parent.', $updated );
return new WP_Error( 'post-report-package::failed-to-assign-child', 'Failed to assign child post to parent.', $updated );
}
return $updated;
}
Expand Down Expand Up @@ -900,7 +900,7 @@ public function register_rest_endpoint($endpoints) {
public function restfully_regenerate_toc(\WP_REST_Request $request) {
$post_id = $request->get_param('post_id');
if ( empty($post_id) ) {
return new WP_Error('400', 'Missing post_id parameter.');
return new WP_Error('post-report-package::missing-post-id', 'Missing post_id parameter.');
}
return $this->construct_toc( $post_id );
}
Expand Down

0 comments on commit cd9c75d

Please sign in to comment.