Skip to content

Commit cd773ae

Browse files
committed
Almost level 8
1 parent 99de66c commit cd773ae

File tree

3 files changed

+14
-4
lines changed

3 files changed

+14
-4
lines changed

src/Comment_Command.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -673,6 +673,9 @@ public function count( $args, $assoc_args ) {
673673
public function recount( $args ) {
674674
foreach ( $args as $id ) {
675675
if ( wp_update_comment_count( $id ) ) {
676+
/**
677+
* @var \WP_Post $post
678+
*/
676679
$post = get_post( $id );
677680
WP_CLI::log( "Updated post {$post->ID} comment count to {$post->comment_count}." );
678681
} else {

src/Menu_Item_Command.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -423,6 +423,10 @@ private function add_or_update_item( $method, $type, $args, $assoc_args ) {
423423

424424
$menu_item_obj = get_post( $menu_item_db_id );
425425

426+
if ( ! $menu_item_obj ) {
427+
WP_CLI::error( 'Invalid menu.' );
428+
}
429+
426430
/**
427431
* @var object{title: string, url: string, description: string, object: string, object_id: int, menu_item_parent: int, attr_title: string, target: string, classes: string[], xfn: string, post_status: string, menu_order: int} $menu_item_obj
428432
*/

src/Post_Command.php

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -806,11 +806,14 @@ public function generate( $args, $assoc_args ) {
806806
// Get the total number of posts.
807807
$total = $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(*) FROM $wpdb->posts WHERE post_type = %s", $post_data['post_type'] ) );
808808

809+
/**
810+
* @var \WP_Post_Type $post_type
811+
*/
812+
$post_type = get_post_type_object( $post_data['post_type'] );
813+
809814
$label = ! empty( $post_data['post_title'] )
810815
? $post_data['post_title']
811-
: get_post_type_object( $post_data['post_type'] )->labels->singular_name;
812-
813-
$hierarchical = get_post_type_object( $post_data['post_type'] )->hierarchical;
816+
: $post_type->labels->singular_name;
814817

815818
$limit = $post_data['count'] + $total;
816819

@@ -827,7 +830,7 @@ public function generate( $args, $assoc_args ) {
827830

828831
for ( $index = $total; $index < $limit; $index++ ) {
829832

830-
if ( $hierarchical ) {
833+
if ( $post_type->hierarchical ) {
831834

832835
if ( $this->maybe_make_child() && $current_depth < $post_data['max_depth'] ) {
833836

0 commit comments

Comments
 (0)