Browse Source

Public Themes T1: PHP Rector fixes (#7396)

Matthew Reishus 1 year ago
parent
commit
db84854898

+ 3 - 2
textbook/components/features/featured-content/display-featured.php

@@ -59,7 +59,8 @@ if ( empty( $featured_page_description ) && ! empty( $featured_options[ 'tag-des
 
 				if ( $i <= 3 ) {
 
-					if ( 1 !== count( $featured_content ) ) {
+					$f_count = is_countable( $featured_content ) ? count( $featured_content ) : 0;
+					if ( 1 !== $f_count ) {
 						// Include the standard featured content template.
 						get_template_part( 'components/features/featured-content/content', 'featured' );
 					} else {
@@ -78,4 +79,4 @@ if ( empty( $featured_page_description ) && ! empty( $featured_options[ 'tag-des
 	</div>
 	<?php } ?>
 </div>
-<?php } ?>
+<?php } ?>

+ 2 - 2
textbook/components/post/content-card.php

@@ -15,7 +15,7 @@
 			if ( 'post' === get_post_type() ) { ?>
 		<div class="entry-meta">
 			<?php $category = get_the_category();
-				$category_count = ( count( $category ) );
+				$category_count = is_countable( $category ) ? count( $category ) : 0;
 
 				if ( $category && $category_count >= 2 ) {
 					$cat_links =  '<a href="' . esc_url( get_permalink() ) . '">' . $category[0]->name.'&hellip;</a>';
@@ -80,4 +80,4 @@
 		</g></g>
 	</svg>
 	<?php } ?>
-</article><!-- #post-## -->
+</article><!-- #post-## -->

+ 1 - 1
textbook/inc/template-tags.php

@@ -117,7 +117,7 @@ function textbook_categorized_blog() {
 		) );
 
 		// Count the number of categories that are attached to the posts.
-		$all_the_cool_cats = count( $all_the_cool_cats );
+		$all_the_cool_cats = is_countable( $all_the_cool_cats ) ? count( $all_the_cool_cats ) : 0;
 
 		set_transient( 'textbook_categories', $all_the_cool_cats );
 	}

+ 1 - 1
toujours/inc/template-tags.php

@@ -126,7 +126,7 @@ function toujours_categorized_blog() {
 		) );
 
 		// Count the number of categories that are attached to the posts.
-		$all_the_cool_cats = count( $all_the_cool_cats );
+		$all_the_cool_cats = is_countable( $all_the_cool_cats ) ? count( $all_the_cool_cats ) : 0;
 
 		set_transient( 'toujours_categories', $all_the_cool_cats );
 	}