Changeset 55021 for trunk/tests/phpunit/includes/factory/class-wp-unittest-factory-for-attachment.php
- Timestamp:
- 12/30/2022 02:36:03 AM (21 months ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
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.