PluginProbe
Jetpack – WP Security, Backup, Speed, & Growth / 16.3-a.7
Jetpack – WP Security, Backup, Speed, & Growth v16.3-a.7
16.3-a.5 16.3-a.7 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 All 506 releases
← All changes | extensions/blocks/pinterest/pinterest.php +14 -4 13.0.2 → 16.3-a.7 View file →
@@ -1,8 +1,12 @@
1 1 <?php
2 2 /**
3 3 * Pinterest Block.
4 4 *
5 + * Note: this block is no longer available to be added to new posts.
6 + * It is only kept available for existing posts with Pinterest blocks.
7 + * You can still embed Pinterest content using the embed method provided by WordPress itself.
8 + *
5 9 * @since 8.0.0
6 10 *
7 11 * @package automattic/jetpack
8 12 */
@@ -9,10 +13,15 @@
9 13
10 14 namespace Automattic\Jetpack\Extensions\Pinterest;
11 15
12 16 use Automattic\Jetpack\Blocks;
17 +use Automattic\Jetpack\Status\Request;
13 18 use WP_Error;
14 19
20 +if ( ! defined( 'ABSPATH' ) ) {
21 + exit( 0 );
22 +}
23 +
15 24 const URL_PATTERN = '#^https?://(?:www\.)?(?:[a-z]{2}\.)?pinterest\.[a-z.]+/pin/(?P<pin_id>[^/]+)/?#i'; // Taken from AMP plugin, originally from Jetpack.
16 25 // This is the validate Pinterest URLs, converted from URL_REGEX in extensions/blocks/pinterest/index.js.
17 26 const PINTEREST_URL_REGEX = '/^https?:\/\/(?:www\.)?(?:[a-z]{2}\.)?(?:pinterest\.[a-z.]+|pin\.it)\/([^\/]+)(\/[^\/]+)?/i';
18 27 // This looks for matches in /foo/ of https://www.pinterest.ca/foo/.
@@ -23,9 +32,9 @@
23 32 /**
24 33 * Determines the Pinterest embed type from the URL.
25 34 *
26 35 * @param string $url the URL to check.
27 - * @returns {string} The pin type. Empty string if it isn't a valid Pinterest URL.
36 + * @return string The pin type. Empty string if it isn't a valid Pinterest URL.
28 37 */
29 38 function pin_type( $url ) {
30 39 if ( null === $url || ! preg_match( PINTEREST_URL_REGEX, $url ) ) {
31 40 return '';
@@ -137,10 +146,10 @@
137 146 }
138 147
139 148 if ( is_array( $info ) ) {
140 149 $image = $info['images']['237x'];
141 - $title = isset( $info['rich_metadata']['title'] ) ? $info['rich_metadata']['title'] : null;
142 - $description = isset( $info['rich_metadata']['description'] ) ? $info['rich_metadata']['description'] : null;
150 + $title = $info['rich_metadata']['title'] ?? null;
151 + $description = $info['rich_metadata']['description'] ?? null;
143 152
144 153 // This placeholder will appear while waiting for the amp-pinterest component to initialize (or if it fails to initialize due to JS being disabled).
145 154 $placeholder = sprintf(
146 155 // The AMP_Img_Sanitizer will convert his to <amp-img> while also supplying `noscript > img` as fallback when JS is disabled.
@@ -215,11 +224,12 @@
215 224 *
216 225 * @return string
217 226 */
218 227 function load_assets( $attr, $content ) {
219 - if ( ! jetpack_is_frontend() ) {
228 + if ( ! Request::is_frontend() ) {
220 229 return $content;
221 230 }
231 + $attr['url'] ??= '';
222 232 if ( Blocks::is_amp_request() ) {
223 233 return render_amp_pin( $attr );
224 234 } else {
225 235 $url = $attr['url'];