File tree Expand file tree Collapse file tree 1 file changed +13
-18
lines changed
Expand file tree Collapse file tree 1 file changed +13
-18
lines changed Original file line number Diff line number Diff line change @@ -208,26 +208,21 @@ public function create( $args, $assoc_args ) {
208208 }
209209
210210 $ assoc_args = wp_slash ( $ assoc_args );
211+ parent ::_create (
212+ $ args ,
213+ $ assoc_args ,
214+ function ( $ params ) {
215+ $ post_id = wp_insert_post ( $ params , true );
211216
212- // Remove ID key if present to ensure we're creating, not updating.
213- unset( $ assoc_args [ $ this ->obj_id_key ] );
214-
215- // Create the post.
216- $ post_id = wp_insert_post ( $ assoc_args , true );
217-
218- if ( is_wp_error ( $ post_id ) ) {
219- WP_CLI ::error ( $ post_id );
220- }
221-
222- // Create initial revision to match WordPress admin behavior.
223- // This ensures the original content can be restored if the post is later edited.
224- wp_save_post_revision ( $ post_id );
217+ if ( ! is_wp_error ( $ post_id ) ) {
218+ // Create initial revision to match WordPress admin behavior.
219+ // This ensures the original content can be restored if the post is later edited.
220+ wp_save_post_revision ( $ post_id );
221+ }
225222
226- if ( Utils \get_flag_value ( $ assoc_args , 'porcelain ' ) ) {
227- WP_CLI ::line ( (string ) $ post_id );
228- } else {
229- WP_CLI ::success ( "Created {$ this ->obj_type } {$ post_id }. " );
230- }
223+ return $ post_id ;
224+ }
225+ );
231226 }
232227
233228 /**
You can’t perform that action at this time.
0 commit comments