diff --git a/modules/theme-tools/site-logo/inc/functions.php b/modules/theme-tools/site-logo/inc/functions.php index 3b27b32fb75d8..f22829d226a45 100644 --- a/modules/theme-tools/site-logo/inc/functions.php +++ b/modules/theme-tools/site-logo/inc/functions.php @@ -101,41 +101,45 @@ function jetpack_has_site_logo() { * @since 1.0 */ function jetpack_the_site_logo() { - $logo = site_logo()->logo; - $logo_id = get_theme_mod( 'custom_logo' ); // Check for WP 4.5 Site Logo - $logo_id = $logo_id ? $logo_id : $logo['id']; // Use WP Core logo if present, otherwise use Jetpack's. - $size = site_logo()->theme_size(); - $html = ''; + $size = site_logo()->theme_size(); // If no logo is set, but we're in the Customizer, leave a placeholder (needed for the live preview). - if ( ! jetpack_has_site_logo() ) { - if ( jetpack_is_customize_preview() ) { - $html = sprintf( + if ( + ! jetpack_has_site_logo() + && jetpack_is_customize_preview() + ) { + /* + * Reason: the output is escaped in the sprintf. + * phpcs:disable WordPress.Security.EscapeOutput + */ + /** This filter is documented in modules/theme-tools/site-logo/inc/functions.php */ + echo apply_filters( + 'jetpack_the_site_logo', + sprintf( '', esc_url( home_url( '/' ) ), esc_attr( $size ) - ); - } + ), + array(), + $size + ); + /* phpcs:enable WordPress.Security.EscapeOutput */ + return; } - // We have a logo. Logo is go. - else { - $html = sprintf( - '', - esc_url( home_url( '/' ) ), - wp_get_attachment_image( - $logo_id, - $size, - false, - array( - 'class' => "site-logo attachment-$size", - 'data-size' => $size, - 'itemprop' => 'logo', - ) - ) - ); + // Check for WP 4.5 Site Logo and Jetpack logo. + $logo_id = get_theme_mod( 'custom_logo' ); + $jetpack_logo = site_logo()->logo; + + // Use WP Core logo if present, otherwise use Jetpack's. + if ( ! $logo_id && isset( $jetpack_logo['id'] ) ) { + $logo_id = $jetpack_logo['id']; } + /* + * Reason: the output is escaped in the sprintf. + * phpcs:disable WordPress.Security.EscapeOutput + */ /** * Filter the Site Logo output. * @@ -144,10 +148,29 @@ function jetpack_the_site_logo() { * @since 3.2.0 * * @param string $html Site Logo HTML output. - * @param array $logo Array of Site Logo details. + * @param array $jetpack_logo Array of Site Logo details. * @param string $size Size specified in add_theme_support declaration, or 'thumbnail' default. */ - echo apply_filters( 'jetpack_the_site_logo', $html, $logo, $size ); + echo apply_filters( + 'jetpack_the_site_logo', + sprintf( + '', + esc_url( home_url( '/' ) ), + wp_get_attachment_image( + $logo_id, + $size, + false, + array( + 'class' => "site-logo attachment-$size", + 'data-size' => $size, + 'itemprop' => 'logo', + ) + ) + ), + $jetpack_logo, + $size + ); + /* phpcs:enable WordPress.Security.EscapeOutput */ } /**