Plugin Directory


Ignore:
Timestamp:
09/27/2026 08:41:32 AM (5 weeks ago)
Author:
eskapism
Message:

Update to version 1.2.0 from GitHub

File:
1 edited

Legend:

Unmodified
Added
Removed
  • simple-seo/trunk/src/link-previews.php

    r3714305 r3715169  
    4343        }
    4444
    45         $title = get_bloginfo( 'name' );
    46         $url   = home_url( '/' );
    47         $image = null;
     45        $title       = get_bloginfo( 'name' );
     46        $description = current_description();
     47        $url         = home_url( '/' );
     48        $image       = null;
    4849
    4950        if ( $post_id ) {
    … …  
    5253                $url   = (string) get_permalink( $post_id );
    5354                $image = featured_image( $post_id );
     55
     56                // No meta description: the excerpt, if someone wrote one. Not an automatic excerpt from the
     57                // content, which is usually a worse summary than the apps' own.
     58                if ( '' === $description ) {
     59                        $description = trim( (string) preg_replace( '/\s+/', ' ', wp_strip_all_tags( (string) get_post_field( 'post_excerpt', $post_id ) ) ) );
     60                }
    5461        }
    5562
    … …  
    7279                'og:site_name'    => get_bloginfo( 'name' ),
    7380                'og:title'        => $title,
    74                 'og:description'  => current_description(),
     81                'og:description'  => $description,
    7582                'og:url'          => $url,
    7683                'og:image'        => $image['url'] ?? '',
    … …  
    7986                'og:image:alt'    => $image['alt'] ?? '',
    8087                // Apps that read twitter:card take everything else from the og: tags.
    81                 'twitter:card'    => $image ? 'summary_large_image' : 'summary',
     88                'twitter:card'    => $image && is_wide( $image ) ? 'summary_large_image' : 'summary',
    8289        ];
    8390
    … …  
    106113
    107114/**
     115 * Whether an image suits a large, wide preview card: at least 600 px wide and wider than tall.
     116 * A small or square image, like a site icon, gets the small card instead of being cropped or blurred.
     117 * An image without a known size (from the filter) counts as wide.
     118 *
     119 * @param array{url: string, width?: int, height?: int} $image The image.
     120 */
     121function is_wide( array $image ): bool {
     122        $width  = (int) ( $image['width'] ?? 0 );
     123        $height = (int) ( $image['height'] ?? 0 );
     124
     125        return ! $width || ( $width >= 600 && $width > $height );
     126}
     127
     128/**
    108129 * The post's featured image at full size, or null.
    109130 *
Note: See TracChangeset for help on using the changeset viewer.