Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Site Health test to warn sites when fallback publisher logo will be used for Schema.org metadata #5120

Closed
westonruter opened this issue Jul 28, 2020 · 0 comments · Fixed by #7124
Labels
Changelogged Whether the issue/PR has been added to release notes. Groomed Needs sizing P2 Low priority Punted Schema.org Metadata Site Health WS:Core Work stream for Plugin core
Milestone

Comments

@westonruter
Copy link
Member

Feature description

Users often reported structured data errors related to publisher.logo.url being empty. For this reason, we provide a fallback image amp-page-fallback-wordpress-publisher-logo.png. Nevertheless, this is not ideal.

There should be a Site Health test that warns administrators when amp_get_publisher_logo() returns an image other than the fallback of amp-page-fallback-wordpress-publisher-logo.png.

This field is empty for sites that do not have a Custom Logo or Site Icon set in the Customizer, or a custom amp_site_icon_url filter was not used. See logic here:

function amp_get_publisher_logo() {
$logo_image_url = null;
/*
* This should be 60x600px rectangle. It *can* be larger than this, contrary to the current documentation.
* Only minimum size and ratio matters. So height should be at least 60px and width a minimum of 200px.
* An aspect ratio between 200/60 (10/3) and 600:60 (10/1) should be used. A square image still be used,
* but it is not preferred; a landscape logo should be provided if possible.
*/
$logo_width = 600;
$logo_height = 60;
// Use the Custom Logo if set.
$custom_logo_id = get_theme_mod( 'custom_logo' );
if ( has_custom_logo() && $custom_logo_id ) {
$custom_logo_img = wp_get_attachment_image_src( $custom_logo_id, [ $logo_width, $logo_height ], false );
if ( ! empty( $custom_logo_img[0] ) ) {
$logo_image_url = $custom_logo_img[0];
}
}
// Try Site Icon if a custom logo is not set.
$site_icon_id = get_option( 'site_icon' );
if ( empty( $logo_image_url ) && $site_icon_id ) {
$site_icon_src = wp_get_attachment_image_src( $site_icon_id, [ $logo_width, $logo_height ], false );
if ( ! empty( $site_icon_src ) ) {
$logo_image_url = $site_icon_src[0];
}
}
/**
* Filters the publisher logo URL in the schema.org data.
*
* Previously, this only filtered the Site Icon, as that was the only possible schema.org publisher logo.
* But the Custom Logo is now the preferred publisher logo, if it exists and its dimensions aren't too big.
*
* @since 0.3
*
* @param string $schema_img_url URL of the publisher logo, either the Custom Logo or the Site Icon.
*/
$logo_image_url = apply_filters( 'amp_site_icon_url', $logo_image_url );
// Fallback to serving the WordPress logo.
if ( empty( $logo_image_url ) ) {
$logo_image_url = amp_get_asset_url( 'images/amp-page-fallback-wordpress-publisher-logo.png' );
}
return $logo_image_url;
}

The amp_get_publisher_logo() should perhaps take a $default arg that is set to amp-page-fallback-wordpress-publisher-logo.png when null. Then we can use this in the Site Health test by passing false to determine if a publisher logo is defined.


Do not alter or remove anything below. The following sections will be managed by moderators only.

Acceptance criteria

Implementation brief

QA testing instructions

Demo

Changelog entry

@westonruter westonruter added this to the v2.1 milestone Jul 28, 2020
@westonruter westonruter changed the title Add Site Health test to warn sites when publisher logo will be empty Add Site Health test to warn sites when fallback publisher logo will be used for Schema.org metadata Jul 28, 2020
@kmyram kmyram added the WS:Core Work stream for Plugin core label Aug 5, 2020
@westonruter westonruter modified the milestones: v2.1, v2.2 Feb 11, 2021
@westonruter westonruter added the P2 Low priority label Oct 25, 2021
@westonruter westonruter modified the milestones: v2.2, v2.3 Nov 30, 2021
@westonruter westonruter modified the milestones: v2.3, v2.4 Dec 23, 2021
@dhaval-parekh dhaval-parekh self-assigned this May 25, 2022
@westonruter westonruter modified the milestones: v2.4, v2.3 Jun 13, 2022
@westonruter westonruter added the Changelogged Whether the issue/PR has been added to release notes. label Jun 14, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Changelogged Whether the issue/PR has been added to release notes. Groomed Needs sizing P2 Low priority Punted Schema.org Metadata Site Health WS:Core Work stream for Plugin core
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants