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 | modules/shortcodes/recipe.php +26 -27 12.0.3 → 16.3-a.1 View file →
@@ -1,8 +1,12 @@
1 1 <?php //phpcs:ignore WordPress.Files.FileName.InvalidClassFileName
2 2
3 3 use Automattic\Jetpack\Assets;
4 4
5 +if ( ! defined( 'ABSPATH' ) ) {
6 + exit( 0 );
7 +}
8 +
5 9 /**
6 10 * Embed recipe 'cards' in post, with basic styling and print functionality
7 11 *
8 12 * To Do
@@ -15,8 +19,10 @@
15 19 */
16 20
17 21 /**
18 22 * Register and display Recipes in posts.
23 + *
24 + * @phan-constructor-used-for-side-effects
19 25 */
20 26 class Jetpack_Recipes {
21 27
22 28 /**
@@ -110,20 +116,20 @@
110 116 if ( class_exists( 'Jetpack_AMP_Support' ) && Jetpack_AMP_Support::is_amp_request() ) {
111 117 return;
112 118 }
113 119
114 - wp_enqueue_script(
115 - 'jetpack-recipes-printthis',
116 - Assets::get_file_url_for_environment( '_inc/build/shortcodes/js/recipes-printthis.min.js', 'modules/shortcodes/js/recipes-printthis.js' ),
120 + wp_register_script(
121 + 'jetpack-shortcode-deps',
122 + plugins_url( '_inc/build/shortcodes/js/dependencies.min.js', JETPACK__PLUGIN_FILE ),
117 123 array( 'jquery' ),
118 - '20170202',
119 - false
124 + '20250905',
125 + true
120 126 );
121 127
122 128 wp_enqueue_script(
123 129 'jetpack-recipes-js',
124 130 Assets::get_file_url_for_environment( '_inc/build/shortcodes/js/recipes.min.js', 'modules/shortcodes/js/recipes.js' ),
125 - array( 'jquery', 'jetpack-recipes-printthis' ),
131 + array( 'jquery', 'jetpack-shortcode-deps' ),
126 132 '20131230',
127 133 false
128 134 );
129 135
@@ -477,13 +483,8 @@
477 483 $list_item_replacement = '<li class="jetpack-recipe-nutrition">${1}</li>';
478 484 $itemprop = ' itemprop="nutrition"';
479 485 $listtype = 'ul';
480 486 break;
481 - case 'nutrition':
482 - $list_item_replacement = '<li class="jetpack-recipe-nutrition nutrition">${1}</li>';
483 - $itemprop = ' itemprop="nutrition"';
484 - $listtype = 'ul';
485 - break;
486 487 default:
487 488 $list_item_replacement = '<li class="jetpack-recipe-notes">${1}</li>';
488 489 $itemprop = '';
489 490 $listtype = 'ul';
@@ -490,15 +491,15 @@
490 491 }
491 492
492 493 // Check to see if the user is trying to use shortened formatting.
493 494 if (
494 - strpos( $content, '&#8211;' ) !== false ||
495 - strpos( $content, '&#8212;' ) !== false ||
496 - strpos( $content, '-' ) !== false ||
497 - strpos( $content, '*' ) !== false ||
498 - strpos( $content, '#' ) !== false ||
499 - strpos( $content, '–' ) !== false || // ndash.
500 - strpos( $content, '—' ) !== false || // mdash.
495 + str_contains( $content, '&#8211;' ) ||
496 + str_contains( $content, '&#8212;' ) ||
497 + str_contains( $content, '-' ) ||
498 + str_contains( $content, '*' ) ||
499 + str_contains( $content, '#' ) ||
500 + str_contains( $content, '–' ) || // ndash.
501 + str_contains( $content, '—' ) || // mdash.
501 502 preg_match( '/\d+\.\s/', $content )
502 503 ) {
503 504 // Remove breaks and extra whitespace.
504 505 $content = str_replace( "<br />\n", "\n", $content );
@@ -509,11 +510,11 @@
509 510
510 511 preg_match_all( $ul_pattern, $content, $ul_matches );
511 512 preg_match_all( $ol_pattern, $content, $ol_matches );
512 513
513 - if ( 0 !== count( $ul_matches[0] ) || 0 !== count( $ol_matches[0] ) ) {
514 + if ( ( is_countable( $ul_matches[0] ) && count( $ul_matches[0] ) > 0 ) || ( is_countable( $ol_matches[0] ) && count( $ol_matches[0] ) > 0 ) ) {
514 515
515 - if ( 0 !== count( $ol_matches[0] ) ) {
516 + if ( is_countable( $ol_matches[0] ) && count( $ol_matches[0] ) > 0 ) {
516 517 $listtype = 'ol';
517 518 $list_item_pattern = $ol_pattern;
518 519 } else {
519 520 $listtype = 'ul';
@@ -634,12 +635,9 @@
634 635 'class' => 'jetpack-recipe-image u-photo photo',
635 636 'itemprop' => 'image',
636 637 );
637 638
638 - if (
639 - function_exists( 'wp_lazy_loading_enabled' )
640 - && wp_lazy_loading_enabled( 'img', 'wp_get_attachment_image' )
641 - ) {
639 + if ( wp_lazy_loading_enabled( 'img', 'wp_get_attachment_image' ) ) {
642 640 $image_attrs['loading'] = 'lazy';
643 641 }
644 642
645 643 // If it's numeric, this may be an attachment.
@@ -653,9 +651,9 @@
653 651 }
654 652
655 653 // Check if it's an absolute or relative URL, and return if not.
656 654 if (
657 - 0 !== strpos( $src, '/' )
655 + ! str_starts_with( $src, '/' )
658 656 && false === filter_var( $src, FILTER_VALIDATE_URL )
659 657 ) {
660 658 return '';
661 659 }
@@ -685,15 +683,16 @@
685 683 public function themecolor_styles() {
686 684 global $themecolors;
687 685 $style = '';
688 686
689 - if ( isset( $themecolors ) ) {
687 + if ( isset( $themecolors['border'] ) ) {
690 688 $style .= '.jetpack-recipe { border-color: #' . esc_attr( $themecolors['border'] ) . '; }';
689 + }
690 + if ( isset( $themecolors['link'] ) ) {
691 691 $style .= '.jetpack-recipe-title { border-bottom-color: #' . esc_attr( $themecolors['link'] ) . '; }';
692 692 }
693 693
694 694 return $style;
695 695 }
696 -
697 696 }
698 697
699 698 new Jetpack_Recipes();