diff --git a/includes/SiteGen/SiteGen.php b/includes/SiteGen/SiteGen.php index fe70da3..4c3afc0 100644 --- a/includes/SiteGen/SiteGen.php +++ b/includes/SiteGen/SiteGen.php @@ -424,7 +424,7 @@ public static function get_home_pages( $site_description, $content_style, $targe $generated_content_structures = $parsed_response['contentStructures']; $generated_patterns = $parsed_response['generatedPatterns']; $generated_homepages = $parsed_response['pages']; - if ( array_key_exists( "generatedImages", $parsed_response ) ) { + if ( array_key_exists( 'generatedImages', $parsed_response ) ) { $generated_images = $parsed_response['generatedImages']; self::cache_sitegen_response( 'generatedImages', $generated_images ); } @@ -437,30 +437,29 @@ public static function get_home_pages( $site_description, $content_style, $targe $generated_homepages = array(); $generated_patterns = self::get_sitegen_from_cache( 'generatedPatterns' ); - $categories_to_separate = array('header', 'footer'); + $categories_to_separate = array( 'header', 'footer' ); // Choose random categories for the generated patterns and return foreach ( $random_homepages as $homepage_index => $slug ) { $generated_homepages[ $slug ] = array(); - $homepage_patterns = array(); + $homepage_patterns = array(); foreach ( $generated_content_structures[ $slug ] as $pattern_category ) { if ( empty( $generated_patterns[ $pattern_category ] ) ) { continue; } // Get a random pattern for the category when regenerating otherwise pick in sequence // so that the 3 previews are as different as much as possible. - $pattern_index = ( $regenerate ) ? array_rand( $generated_patterns[ $pattern_category ] ) : $homepage_index; + $pattern_index = ( $regenerate ) ? array_rand( $generated_patterns[ $pattern_category ] ) : $homepage_index; $random_pattern = $generated_patterns[ $pattern_category ][ $pattern_index ]; - if( in_array( $pattern_category, $categories_to_separate ) ) { + if ( in_array( $pattern_category, $categories_to_separate, true ) ) { $homepage_patterns[ $pattern_category ] = $random_pattern; } else { - $homepage_patterns[ 'content' ] = $random_pattern; + $homepage_patterns['content'] = $random_pattern; } - } $generated_homepages[ $slug ] = $homepage_patterns; } - + $generated_homepages['generatedImages'] = $generated_images; self::cache_sitegen_response( 'homepages', $generated_homepages ); return $generated_homepages; @@ -529,7 +528,7 @@ public static function get_content_for_page( } } $parsed_response = json_decode( wp_remote_retrieve_body( $response ), true ); - if( ! array_key_exists( 'error', $parsed_response['content'] ) ) { + if ( ! array_key_exists( 'error', $parsed_response['content'] ) ) { $parsed_response['content'] = implode( '', $parsed_response['content'] ); } return $parsed_response['content']; @@ -572,6 +571,10 @@ public static function get_pages( $page = $site_menu_options['slug']; $keywords = $site_menu_options['keywords']; + if ( strcmp( $site_menu_options['slug'], 'home' ) === 0 ) { + continue; + } + $response = self::get_content_for_page( $site_description, $content_style,