Просмотр исходного кода

Public Themes J, K, L: PHP Rector fixes (#7388)

Matthew Reishus 1 год назад
Родитель
Сommit
aa45821b15

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

@@ -92,7 +92,7 @@ function karuna_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( 'karuna_categories', $all_the_cool_cats );
 	}

+ 1 - 1
libre-2/inc/template-tags.php

@@ -97,7 +97,7 @@ function libre_2_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( 'libre_2_categories', $all_the_cool_cats );
 	}

+ 2 - 0
libretto/functions.php

@@ -344,6 +344,7 @@ function libretto_get_active_sidebars() {
  * You can pass a variable to request a particular type of information. Default is URL.
  */
 function libretto_get_header_image( $request = '' ) {
+	$libretto_header_image_height = null;
 	// If there's a featured image set for the post/page, use that
 	if ( libretto_has_post_thumbnail() && is_single() && libretto_jetpack_featured_image_display() ) :
 		$libretto_featured_image      = libretto_get_attachment_image_src( get_the_ID(), get_post_thumbnail_id( get_the_ID() ), 'libretto-fullpage' );
@@ -354,6 +355,7 @@ function libretto_get_header_image( $request = '' ) {
 	  $libretto_header_image        = $libretto_featured_image[0];
 	  $libretto_header_image_height = $libretto_featured_image[2];
 	  // Otherwise, use the header image
+	  // Otherwise, use the header image
   elseif ( get_header_image() ) :
 	  $libretto_header_image        = get_header_image();
 	  $libretto_header_image_height = get_custom_header()->height;

+ 3 - 1
libretto/inc/jetpack.php

@@ -43,7 +43,9 @@ add_action( 'after_setup_theme', 'libretto_jetpack_setup' );
 * If the social menu or the sidebar widgets are active, switch to click-to-scroll
 */
 function libretto_has_footer_widgets() {
-	if ( 0 !== count( libretto_get_active_sidebars() )  ) :
+	$l = libretto_get_active_sidebars();
+	$l_count = is_countable( $l ) ? count( $l ) : 0;
+	if ( 0 !== $l_count  ) :
 		return true;
 	else :
 		return false;

+ 2 - 1
libretto/inc/template-tags.php

@@ -152,6 +152,7 @@ if ( ! function_exists( 'the_archive_title' ) ) :
  * @param string $after  Optional. Content to append to the title. Default empty.
  */
 	function the_archive_title( $before = '', $after = '' ) {
+		$title = '';
 		if ( is_category() ) {
 			$title = sprintf( esc_html__( 'Category: %s', 'libretto' ), single_cat_title( '', false ) );
 		} elseif ( is_tag() ) {
@@ -251,7 +252,7 @@ function libretto_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( 'libretto_categories', $all_the_cool_cats );
 	}

+ 1 - 1
libretto/sidebar.php

@@ -8,7 +8,7 @@
 $active_sidebars = libretto_get_active_sidebars();
 
 // No sidebars? No content!
-if ( 0 === count( $active_sidebars )  ) {
+if ( ! is_countable( $active_sidebars ) || 0 === count( $active_sidebars )  ) {
 	return;
 }
 ?>

+ 1 - 1
livro/inc/gutenberg-dependency-check.php

@@ -11,7 +11,7 @@ function print_admin_message( $version ) {
 function show_admin_messages() {
 	$metadata = file_get_contents( get_stylesheet_directory() . '/style.css' );
 	preg_match( '/(?<=Requires Gutenberg:).+/', $metadata, $match );
-	if ( 0 === sizeof( $match ) ) {
+	if ( ! is_countable( $match ) || 0 === count( $match ) ) {
 		return; // Gutenberg is not required
 	}
 	$version = trim( $match[0] );

+ 1 - 0
lodestar/inc/jetpack.php

@@ -248,6 +248,7 @@ function lodestar_project_terms() {
 
 function lodestar_portfolio_data() {
 
+	$typeid = [];
 	$terms = get_the_terms( get_the_ID(), 'jetpack-portfolio-type' );
 	if ( empty( $terms) ) {
 		return;

+ 2 - 1
lodestar/inc/template-tags.php

@@ -133,6 +133,7 @@ endif;
  * layout with multiple posts/pages shown gets confusing.
  */
 function lodestar_edit_link( $id ) {
+	$type = null;
 	if ( is_page() ) :
 		$type = esc_html__( 'Page', 'lodestar' );
 	elseif ( get_post( $id ) ) :
@@ -217,7 +218,7 @@ function lodestar_categorized_blog() {
 			'number'     => 2,
 		) );
 		// Count the number of categories that are attached to the posts.
-		$category_count = count( $categories );
+		$category_count = is_countable( $categories ) ? count( $categories ) : 0;
 		set_transient( 'lodestar_categories', $category_count );
 	}
 	return $category_count > 1;