You appear to be a bot. Output may be restricted
Description
Usage
WP_UnitTestCase::_make_attachment( $upload, $parent_post_id );
Parameters
- $upload
- ( mixed ) required –
- $parent_post_id
- ( mixed ) optional –
Returns
voidSource
File name: oik-batch/tests/testcase.phpLines:
1 to 24 of 24
function _make_attachment($upload, $parent_post_id = 0) { $type = ''; if ( !empty($upload['type']) ) { $type = $upload['type']; } else { $mime = wp_check_filetype( $upload['file'] ); if ($mime) $type = $mime['type']; } $attachment = array( 'post_title' => basename( $upload['file'] ), 'post_content' => '', 'post_type' => 'attachment', 'post_parent' => $parent_post_id, 'post_mime_type' => $type, 'guid' => $upload[ 'url' ], ); // Save the data $id = wp_insert_attachment( $attachment, $upload[ 'file' ], $parent_post_id ); wp_update_attachment_metadata( $id, wp_generate_attachment_metadata( $id, $upload['file'] ) ); return $id; }View on GitHub