Changeset 55021
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/post.php
r54961 r55021 6328 6328 * @param string|array $args Arguments for inserting an attachment. 6329 6329 * @param string|false $file Optional. Filename. 6330 * @param int $parent_post 6330 * @param int $parent_post_id Optional. Parent post ID. 6331 6331 * @param bool $wp_error Optional. Whether to return a WP_Error on failure. Default false. 6332 6332 * @param bool $fire_after_hooks Optional. Whether to fire the after insert hooks. Default true. 6333 6333 * @return int|WP_Error The attachment ID on success. The value 0 or WP_Error on failure. 6334 6334 */ 6335 function wp_insert_attachment( $args, $file = false, $parent_post = 0, $wp_error = false, $fire_after_hooks = true ) {6335 function wp_insert_attachment( $args, $file = false, $parent_post_id = 0, $wp_error = false, $fire_after_hooks = true ) { 6336 6336 $defaults = array( 6337 6337 'file' => $file, … … 6341 6341 $data = wp_parse_args( $args, $defaults ); 6342 6342 6343 if ( ! empty( $parent_post ) ) {6344 $data['post_parent'] = $parent_post ;6343 if ( ! empty( $parent_post_id ) ) { 6344 $data['post_parent'] = $parent_post_id; 6345 6345 } 6346 6346 -
trunk/src/wp-includes/rest-api/endpoints/class-wp-rest-revisions-controller.php
r54970 r55021 135 135 * @since 4.7.2 136 136 * 137 * @param int $parent_post Supplied ID.137 * @param int $parent_post_id Supplied ID. 138 138 * @return WP_Post|WP_Error Post object if ID is valid, WP_Error otherwise. 139 139 */ 140 protected function get_parent( $parent_post ) {140 protected function get_parent( $parent_post_id ) { 141 141 $error = new WP_Error( 142 142 'rest_post_invalid_parent', … … 145 145 ); 146 146 147 if ( (int) $parent_post <= 0 ) {147 if ( (int) $parent_post_id <= 0 ) { 148 148 return $error; 149 149 } 150 150 151 $parent_post = get_post( (int) $parent_post );151 $parent_post = get_post( (int) $parent_post_id ); 152 152 153 153 if ( empty( $parent_post ) || empty( $parent_post->ID ) -
trunk/tests/phpunit/includes/factory/class-wp-unittest-factory-for-attachment.php
r55019 r55021 56 56 * @since 6.2.0 Returns a WP_Error object on failure. 57 57 * 58 * @param string $file The file name to create attachment object for.59 * @param int $parent ID of the post to attach the file to.58 * @param string $file The file name to create attachment object for. 59 * @param int $parent_post_id ID of the post to attach the file to. 60 60 * 61 61 * @return int|WP_Error The attachment ID on success, WP_Error object on failure. 62 62 */ 63 public function create_upload_object( $file, $parent = 0 ) {63 public function create_upload_object( $file, $parent_post_id = 0 ) { 64 64 $contents = file_get_contents( $file ); 65 65 $upload = wp_upload_bits( wp_basename( $file ), null, $contents ); … … 79 79 'post_content' => '', 80 80 'post_type' => 'attachment', 81 'post_parent' => $parent ,81 'post_parent' => $parent_post_id, 82 82 'post_mime_type' => $type, 83 83 'guid' => $upload['url'], … … 85 85 86 86 // Save the data. 87 $attachment_id = wp_insert_attachment( $attachment, $upload['file'], $parent , true );87 $attachment_id = wp_insert_attachment( $attachment, $upload['file'], $parent_post_id, true ); 88 88 89 89 if ( is_wp_error( $attachment_id ) ) {
Note: See TracChangeset
for help on using the changeset viewer.