wphooks.info - wp_creating_autosave

wp_creating_autosave

(trunk - 5.1-alpha-44286)

The hook occurs in the following 2 files

wp-includes/rest-api/endpoints/class-wp-rest-autosaves-controller.php:
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
			}

			if ( ! $autosave_is_different ) {
				wp_delete_post_revision( $old_autosave->ID );
				return new WP_Error( 'rest_autosave_no_changes', __( 'There is nothing to save. The autosave and the post content are the same.' ), array( 'status' => 400 ) );
			}

			/**
			 * This filter is documented in wp-admin/post.php.
			 */
			do_action( 'wp_creating_autosave', $new_autosave );

			// wp_update_post expects escaped array.
			return wp_update_post( wp_slash( $new_autosave ) );
		}

		// Create the new autosave as a special post revision.
		return _wp_put_post_revision( $post_data, true );
	}
wp-admin/includes/post.php:
1792
1793
1794
1795
1796
1797
1798
1799
1800
1801
1802
1803
1804
1805
1806
1807
1808
1809
1810
1811
			return 0;
		}

		/**
		 * Fires before an autosave is stored.
		 *
		 * @since 4.1.0
		 *
		 * @param array $new_autosave Post array - the autosave that is about to be saved.
		 */
		do_action( 'wp_creating_autosave', $new_autosave );

		return wp_update_post( $new_autosave );
	}

	// _wp_put_post_revision() expects unescaped.
	$post_data = wp_unslash( $post_data );

	// Otherwise create the new autosave as a special post revision
	return _wp_put_post_revision( $post_data, true );