Skip to content

Commit

Permalink
Fix summarizing error sources both parent theme and child theme
Browse files Browse the repository at this point in the history
  • Loading branch information
westonruter committed Nov 11, 2019
1 parent e9afd58 commit 05bd040
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 7 deletions.
8 changes: 2 additions & 6 deletions includes/validation/class-amp-validated-url-post-type.php
Original file line number Diff line number Diff line change
Expand Up @@ -1097,19 +1097,15 @@ public static function render_sources_column( $error_summary, $post_id ) {
}
}
if ( isset( $sources['theme'] ) && empty( $sources['embed'] ) ) {
$output[] = '<div class="source">';
$output[] = '<span class="dashicons dashicons-admin-appearance"></span>';
$themes = array_unique( $sources['theme'] );
foreach ( $themes as $theme_slug ) {
foreach ( array_unique( $sources['theme'] ) as $theme_slug ) {
$theme_obj = wp_get_theme( $theme_slug );
if ( ! $theme_obj->errors() ) {
$theme_name = $theme_obj->get( 'Name' );
} else {
$theme_name = $theme_slug;
}
$output[] = sprintf( '<strong>%s</strong>', esc_html( $theme_name ) );
$output[] = sprintf( '<strong class="source"><span class="dashicons dashicons-admin-appearance"></span>%s</strong>', esc_html( $theme_name ) );
}
$output[] = '</div>';
}
if ( isset( $sources['core'] ) ) {
$core_sources = array_unique( $sources['core'] );
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -670,7 +670,7 @@ public function test_render_sources_column() {
// If there is no embed source, but there is a theme, this should output the theme icon.
unset( $error_summary['sources_with_invalid_output']['embed'] );
$sources_column = get_echo( [ 'AMP_Validated_URL_Post_Type', 'render_sources_column' ], [ $error_summary, $post_id ] );
$expected_theme_icon = '<div class="source"><span class="dashicons dashicons-admin-appearance"></span><strong>' . $theme_name . '</strong></div>';
$expected_theme_icon = '<strong class="source"><span class="dashicons dashicons-admin-appearance"></span>' . $theme_name . '</strong>';
$this->assertEquals( $expected_theme_icon, $sources_column );

// If there is a plugin and theme source, this should output icons for both of them.
Expand Down

0 comments on commit 05bd040

Please sign in to comment.