PluginProbe
Jetpack – WP Security, Backup, Speed, & Growth / 16.3-a.1
Jetpack – WP Security, Backup, Speed, & Growth v16.3-a.1
16.3-a.3 16.3-a.1 16.2 16.2-beta 12.0.3 12.1.3 12.2.3 12.3.2 12.4.2 12.5.2 12.6.4 12.7.3 12.8.3 12.9.5 13.0.2 13.1.5 13.2.4 13.3.3 13.4.5 13.5.2 13.6.2 13.7.2 13.8.3 13.9.2 14.0.1 All 504 releases
← All changes | enhanced-open-graph.php +52 -8 13.6.216.3-a.1 View file →
@@ -4,8 +4,14 @@
4 4 *
5 5 * @package automattic/jetpack
6 6 */
7 7
8 +use Automattic\Jetpack\Post_Media\Images;
9 +
10 +if ( ! defined( 'ABSPATH' ) ) {
11 + exit( 0 );
12 +}
13 +
8 14 if ( ! class_exists( 'Jetpack_Media_Summary' ) ) {
9 15 require_once JETPACK__PLUGIN_DIR . '_inc/lib/class.media-summary.php';
10 16 }
11 17
@@ -25,14 +31,26 @@
25 31 if ( ! $post instanceof WP_Post ) {
26 32 return $tags;
27 33 }
28 34
35 + // A gated body's embedded media is withheld along with the body.
36 + if ( \Automattic\Jetpack\SEO\Content_Gate::is_gated( $post ) ) {
37 + return $tags;
38 + }
39 +
29 40 // Always favor featured images.
30 41 if ( enhanced_og_has_featured_image( $post->ID ) ) {
31 42 return $tags;
32 43 }
33 44
34 - $summary = Jetpack_Media_Summary::get( $post->ID );
45 + $summary = Jetpack_Media_Summary::get(
46 + $post->ID,
47 + 0,
48 + array(
49 + 'include_excerpt' => false,
50 + 'include_count' => false,
51 + )
52 + );
35 53
36 54 if ( 'image' !== $summary['type'] ) {
37 55 return $tags;
38 56 }
@@ -60,14 +78,26 @@
60 78 if ( ! $post instanceof WP_Post ) {
61 79 return $tags;
62 80 }
63 81
82 + // A gated body's embedded media is withheld along with the body.
83 + if ( \Automattic\Jetpack\SEO\Content_Gate::is_gated( $post ) ) {
84 + return $tags;
85 + }
86 +
64 87 // Always favor featured images.
65 88 if ( enhanced_og_has_featured_image( $post->ID ) ) {
66 89 return $tags;
67 90 }
68 91
69 - $summary = Jetpack_Media_Summary::get( $post->ID );
92 + $summary = Jetpack_Media_Summary::get(
93 + $post->ID,
94 + 0,
95 + array(
96 + 'include_excerpt' => false,
97 + 'include_count' => false,
98 + )
99 + );
70 100
71 101 if ( 'gallery' !== $summary['type'] ) {
72 102 return $tags;
73 103 }
@@ -107,14 +137,26 @@
107 137 if ( ! $post instanceof WP_Post ) {
108 138 return $tags;
109 139 }
110 140
141 + // A gated body's embedded media is withheld along with the body.
142 + if ( \Automattic\Jetpack\SEO\Content_Gate::is_gated( $post ) ) {
143 + return $tags;
144 + }
145 +
111 146 // Always favor featured images.
112 147 if ( enhanced_og_has_featured_image( $post->ID ) ) {
113 148 return $tags;
114 149 }
115 150
116 - $summary = Jetpack_Media_Summary::get( $post->ID );
151 + $summary = Jetpack_Media_Summary::get(
152 + $post->ID,
153 + 0,
154 + array(
155 + 'include_excerpt' => false,
156 + 'include_count' => false,
157 + )
158 + );
117 159
118 160 if ( 'video' !== $summary['type'] ) {
119 161 if ( $summary['count']['video'] > 0 && $summary['count']['image'] < 1 ) {
120 162 $tags['og:image'] = $summary['image'];
@@ -126,9 +168,9 @@
126 168 $tags['og:image'] = $summary['image'];
127 169 $tags['og:image:secure_url'] = $summary['secure']['image'];
128 170
129 171 // This should be html by default for youtube/vimeo, since we're linking to HTML pages.
130 - $tags['og:video:type'] = isset( $summary['video_type'] ) ? $summary['video_type'] : 'text/html';
172 + $tags['og:video:type'] = $summary['video_type'] ?? 'text/html';
131 173
132 174 $video_url = $summary['video'];
133 175 $secure_video_url = $summary['secure']['video'];
134 176
@@ -138,11 +180,13 @@
138 180 $video_url = 'http://www.youtube.com/embed/' . $id;
139 181 $secure_video_url = 'https://www.youtube.com/embed/' . $id;
140 182 } elseif ( strstr( $video_url, 'vimeo' ) ) {
141 183 preg_match( '|vimeo\.com/(\d+)/?$|i', $video_url, $match );
142 - $id = (int) $match[1];
143 - $video_url = 'http://vimeo.com/moogaloop.swf?clip_id=' . $id;
144 - $secure_video_url = 'https://vimeo.com/moogaloop.swf?clip_id=' . $id;
184 + if ( isset( $match[1] ) ) {
185 + $id = (int) $match[1];
186 + $video_url = 'http://vimeo.com/moogaloop.swf?clip_id=' . $id;
187 + $secure_video_url = 'https://vimeo.com/moogaloop.swf?clip_id=' . $id;
188 + }
145 189 }
146 190 }
147 191
148 192 $tags['og:video'] = $video_url;
@@ -163,6 +207,6 @@
163 207 * @param int $post_id The post ID to check.
164 208 * @return bool True if the post has a suitable featured image, false otherwise.
165 209 */
166 210 function enhanced_og_has_featured_image( $post_id ) {
167 - return ! empty( Jetpack_PostImages::from_thumbnail( $post_id ) );
211 + return ! empty( Images::from_thumbnail( $post_id ) );
168 212 }