Skip to content

Commit a3dc705

Browse files
swissspidyCopilot
andauthored
Potential fix for pull request finding
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
1 parent f26bdbd commit a3dc705

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

src/Menu_Item_Command.php

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -379,10 +379,16 @@ public function add_post_type_archive( $args, $assoc_args ) {
379379
$assoc_args['object'] = $args[1];
380380
unset( $args[1] );
381381

382-
if ( ! get_post_type_object( $assoc_args['object'] ) ) {
382+
$post_type = $assoc_args['object'];
383+
384+
if ( ! get_post_type_object( $post_type ) ) {
383385
WP_CLI::error( 'Invalid post type.' );
384386
}
385387

388+
if ( false === get_post_type_archive_link( $post_type ) ) {
389+
WP_CLI::error( 'Post type does not have an archive.' );
390+
}
391+
386392
$this->add_or_update_item( 'add', 'post_type_archive', $args, $assoc_args );
387393
}
388394

0 commit comments

Comments
 (0)