PluginProbe
WPSSO Core – Complete Schema Markup and Meta Tags / 22.7.0
WPSSO Core – Complete Schema Markup and Meta Tags v22.7.0
22.7.0 22.6.1 22.6.0 22.5.3 22.5.2 22.5.1 22.4.0 22.3.0 22.2.1 22.2.0 22.1.3 22.1.2 22.1.1 22.1.0 22.0.0 21.13.3 21.13.2 trunk 21.13.1
← All changes | lib/theme-compat/embed-content.php +169 -0 21.13.222.7.0 View file →
@@ -1,0 +1,169 @@
1 +<?php
2 +/*
3 + * License: GPLv3
4 + * License URI: https://www.gnu.org/licenses/gpl.txt
5 + * Copyright 2012-2026 Jean-Sebastien Morisset (https://wpsso.com/)
6 + *
7 + * When an existing post is embedded in an iframe, this template is used to create the content output.
8 + *
9 + * Required by the WpssoOembed->template_part_embed() method.
10 + *
11 + * See wordpress/wp-includes/theme-compat/embed-content.php.
12 + */
13 +
14 +$embed_class = esc_attr( implode( ' ', get_post_class( 'wpsso-embed wp-embed' ) ) );
15 +$thumbnail_url = apply_filters( 'embed_thumbnail_url', '' );
16 +$thumbnail_id = 0;
17 +$thumbnail_shape = 'rectangular';
18 +$thumbnail_img = '';
19 +$permalink = get_permalink();
20 +
21 +if ( $thumbnail_url ) {
22 +
23 + $thumbnail_shape = apply_filters( 'embed_thumbnail_url_image_shape', $thumbnail_shape, $thumbnail_url );
24 +
25 +} else {
26 +
27 + if ( has_post_thumbnail() ) {
28 +
29 + $thumbnail_id = get_post_thumbnail_id();
30 + }
31 +
32 + if ( 'attachment' === get_post_type() && wp_attachment_is( 'image' ) ) {
33 +
34 + $thumbnail_id = get_the_ID();
35 + }
36 +
37 + /*
38 + * Filters the thumbnail image ID for use in the embed template.
39 + *
40 + * @since 4.9.0
41 + *
42 + * @param int $thumbnail_id Attachment ID.
43 + */
44 + $thumbnail_id = apply_filters( 'embed_thumbnail_id', $thumbnail_id );
45 +
46 + if ( $thumbnail_id ) {
47 +
48 + $aspect_ratio = 1;
49 + $measurements = array( 1, 1 );
50 + $image_size = 'full'; // Fallback.
51 + $img_meta = wp_get_attachment_metadata( $thumbnail_id ); // Returns a WP_Error object on failure.
52 +
53 + if ( is_array( $img_meta ) ) {
54 +
55 + if ( ! empty( $img_meta[ 'sizes' ] ) ) {
56 +
57 + foreach ( $img_meta[ 'sizes' ] as $size => $data ) {
58 +
59 + if ( $data[ 'height' ] > 0 && $data[ 'width' ] / $data[ 'height' ] > $aspect_ratio ) {
60 +
61 + $aspect_ratio = $data[ 'width' ] / $data[ 'height' ];
62 + $measurements = array( $data[ 'width' ], $data[ 'height' ] );
63 + $image_size = $size;
64 + }
65 + }
66 + }
67 + }
68 +
69 + /*
70 + * Filters the thumbnail image size for use in the embed template.
71 + *
72 + * @since 4.4.0
73 + * @since 4.5.0 Added `$thumbnail_id` parameter.
74 + *
75 + * @param string $image_size Thumbnail image size.
76 + * @param int $thumbnail_id Attachment ID.
77 + */
78 + $image_size = apply_filters( 'embed_thumbnail_image_size', $image_size, $thumbnail_id );
79 +
80 + $thumbnail_shape = $measurements[ 0 ] / $measurements[ 1 ] >= 1.75 ? 'rectangular' : 'square';
81 +
82 + /*
83 + * Filters the thumbnail shape for use in the embed template.
84 + *
85 + * Rectangular images are shown above the title while square images
86 + * are shown next to the content.
87 + *
88 + * @since 4.4.0
89 + * @since 4.5.0 Added `$thumbnail_id` parameter.
90 + *
91 + * @param string $thumbnail_shape Thumbnail image shape. Either 'rectangular' or 'square'.
92 + * @param int $thumbnail_id Attachment ID.
93 + */
94 + $thumbnail_shape = apply_filters( 'embed_thumbnail_image_shape', $thumbnail_shape, $thumbnail_id );
95 + }
96 +}
97 +
98 +if ( $thumbnail_url ) {
99 +
100 + $loading = wp_lazy_loading_enabled( 'img', 'wp_get_attachment_image' ) ? 'loading="lazy"' : '';
101 +
102 + $thumbnail_img = '<img src="' . $thumbnail_url . '" ' . $loading . '>' ;
103 +
104 +} elseif ( $thumbnail_id ) {
105 +
106 + $thumbnail_img = wp_get_attachment_image( $thumbnail_id, $image_size );
107 +}
108 +
109 +echo '<div class="' . $embed_class . '">' . "\n";
110 +
111 +if ( $thumbnail_img && 'rectangular' === $thumbnail_shape ) {
112 +
113 + echo '<div class="wp-embed-featured-image rectangular">';
114 +
115 + echo '<a href="' . $permalink . '" target="_top">' . $thumbnail_img . '</a>';
116 +
117 + echo '</div><!-- .wp-embed-featured-image.rectangular -->' . "\n";
118 +}
119 +
120 +echo '<p class="wp-embed-heading">';
121 +
122 +echo '<a href="' . $permalink . '" target="_top">';
123 +
124 +the_title();
125 +
126 +echo ' </a>';
127 +
128 +echo '</p><!-- .wp-embed-heading -->' . "\n";
129 +
130 +if ( $thumbnail_img && 'square' === $thumbnail_shape ) {
131 +
132 + echo '<div class="wp-embed-featured-image square">';
133 +
134 + echo '<a href="' . $permalink . '" target="_top">' . $thumbnail_img . '</a>';
135 +
136 + echo '</div><!-- .wp-embed-featured-image.square -->' . "\n";
137 +}
138 +
139 +echo '<div class="wp-embed-excerpt">';
140 +
141 +the_excerpt_embed();
142 +
143 +echo '</div><!-- wp-embed-excerpt -->' . "\n";
144 +
145 +/*
146 + * Prints additional content after the embed excerpt.
147 + *
148 + * @since 4.4.0
149 + */
150 +do_action( 'embed_content' );
151 +
152 +echo '<div class="wp-embed-footer">';
153 +
154 +the_embed_site_title();
155 +
156 +echo '<div class="wp-embed-meta">';
157 +
158 +/*
159 + * Prints additional meta content in the embed template.
160 + *
161 + * @since 4.4.0
162 + */
163 +do_action( 'embed_content_meta' );
164 +
165 +echo '</div><!-- .wp-embed-meta -->' . "\n";
166 +
167 +echo '</div><!-- .wp-embed-footer -->' . "\n";
168 +
169 +echo '</div><!-- .wpsso-embed .wp-embed -->' . "\n";