Changeset 49172 for trunk/src/wp-includes/post.php
- Timestamp:
- 10/16/2020 03:32:11 AM (4 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/post.php
r49141 r49172 3646 3646 * @type array $meta_input Array of post meta values keyed by their post meta key. Default empty. 3647 3647 * } 3648 * @param bool $wp_error Optional. Whether to return a WP_Error on failure. Default false. 3648 * @param bool $wp_error Optional. Whether to return a WP_Error on failure. Default false. 3649 * @param bool $fire_after_hooks Whether to fire the after insert hooks. Default true. 3649 3650 * @return int|WP_Error The post ID on success. The value 0 or WP_Error on failure. 3650 3651 */ 3651 function wp_insert_post( $postarr, $wp_error = false ) {3652 function wp_insert_post( $postarr, $wp_error = false, $fire_after_hooks = true ) { 3652 3653 global $wpdb; 3653 3654 … … 4311 4312 do_action( 'wp_insert_post', $post_ID, $post, $update ); 4312 4313 4314 if ( $fire_after_hooks ) { 4315 wp_after_insert_post( $post, $update ); 4316 } 4317 4313 4318 return $post_ID; 4314 4319 } … … 4322 4327 * @since 1.0.0 4323 4328 * 4324 * @param array|object $postarr Optional. Post data. Arrays are expected to be escaped, 4325 * objects are not. Default array. 4326 * @param bool $wp_error Optional. Allow return of WP_Error on failure. Default false. 4329 * @param array|object $postarr Optional. Post data. Arrays are expected to be escaped, 4330 * objects are not. Default array. 4331 * @param bool $wp_error Optional. Allow return of WP_Error on failure. Default false. 4332 * @param bool $fire_after_hooks Whether to fire the after insert hooks. Default true. 4327 4333 * @return int|WP_Error The post ID on success. The value 0 or WP_Error on failure. 4328 4334 */ 4329 function wp_update_post( $postarr = array(), $wp_error = false ) {4335 function wp_update_post( $postarr = array(), $wp_error = false, $fire_after_hooks = true ) { 4330 4336 if ( is_object( $postarr ) ) { 4331 4337 // Non-escaped post was passed. … … 4392 4398 } 4393 4399 4394 return wp_insert_post( $postarr, $wp_error );4400 return wp_insert_post( $postarr, $wp_error, $fire_after_hooks ); 4395 4401 } 4396 4402 … … 4468 4474 /** This action is documented in wp-includes/post.php */ 4469 4475 do_action( 'wp_insert_post', $post->ID, $post, true ); 4476 4477 wp_after_insert_post( $post, true ); 4470 4478 } 4471 4479 … … 4915 4923 */ 4916 4924 do_action( "{$new_status}_{$post->post_type}", $post->ID, $post ); 4925 } 4926 4927 /** 4928 * Fires actions after a post, its terms and meta data has been saved. 4929 * 4930 * @since 5.6.0 4931 * 4932 * @param int|WP_Post $post The post ID or object that has been saved. 4933 * @param bool $update Whether this is an existing post being updated. 4934 */ 4935 function wp_after_insert_post( $post, $update ) { 4936 $post = get_post( $post ); 4937 if ( ! $post ) { 4938 return; 4939 } 4940 4941 $post_id = $post->ID; 4942 4943 /** 4944 * Fires once a post, its terms and meta data has been saved. 4945 * 4946 * @since 5.6.0 4947 * 4948 * @param int $post_id Post ID. 4949 * @param WP_Post $post Post object. 4950 * @param bool $update Whether this is an existing post being updated. 4951 */ 4952 do_action( 'wp_after_insert_post', $post_id, $post, $update ); 4917 4953 } 4918 4954 … … 5790 5826 * @see wp_insert_post() 5791 5827 * 5792 * @param string|array $args Arguments for inserting an attachment. 5793 * @param string $file Optional. Filename. 5794 * @param int $parent Optional. Parent post ID. 5795 * @param bool $wp_error Optional. Whether to return a WP_Error on failure. Default false. 5828 * @param string|array $args Arguments for inserting an attachment. 5829 * @param string $file Optional. Filename. 5830 * @param int $parent Optional. Parent post ID. 5831 * @param bool $wp_error Optional. Whether to return a WP_Error on failure. Default false. 5832 * @param bool $fire_after_hooks Whether to fire the after insert hooks. Default true. 5796 5833 * @return int|WP_Error The attachment ID on success. The value 0 or WP_Error on failure. 5797 5834 */ 5798 function wp_insert_attachment( $args, $file = false, $parent = 0, $wp_error = false ) {5835 function wp_insert_attachment( $args, $file = false, $parent = 0, $wp_error = false, $fire_after_hooks = true ) { 5799 5836 $defaults = array( 5800 5837 'file' => $file, … … 5810 5847 $data['post_type'] = 'attachment'; 5811 5848 5812 return wp_insert_post( $data, $wp_error );5849 return wp_insert_post( $data, $wp_error, $fire_after_hooks ); 5813 5850 } 5814 5851
Note: See TracChangeset
for help on using the changeset viewer.