You appear to be a bot. Output may be restricted
Description
Create an attachment fixture.
Usage
$int|WP_Error = WP_UnitTest_Factory_For_Attachment::create_object( $args, $legacy_parent, $legacy_args );
Parameters
- $args
- ( array ) required – { Array of arguments. Accepts all arguments that can be passed to wp_insert_attachment(), in addition to the following:
- $post_parent
- ( int ) required – ID of the post to which the attachment belongs.
- $file
- ( string ) required – Path of the attached file. }
- $legacy_parent
- ( int ) optional – Deprecated.
- $legacy_args
- ( array ) optional – Deprecated.
Returns
int|WP_Error The attachment ID on success. The value 0 or WP_Error on failure.
Source
File name: wordpress-develop-tests/phpunit/includes/factory/class-wp-unittest-factory-for-attachment.php
Lines:
1 to 19 of 19
public function create_object( $args, $legacy_parent = 0, $legacy_args = array() ) { // Backward compatibility for legacy argument format. if ( is_string( $args ) ) { $file = $args; $args = $legacy_args; $args['post_parent'] = $legacy_parent; $args['file'] = $file; } $r = array_merge( array( 'file' => '', 'post_parent' => 0, ), $args ); return wp_insert_attachment( $r, $r['file'], $r['post_parent'] ); }