PluginProbe
Jetpack – WP Security, Backup, Speed, & Growth / 9.2
Jetpack – WP Security, Backup, Speed, & Growth v9.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 14.1.1 14.2.2 14.3.1 All 501 releases
← All changes | modules/shortcodes.php +11 -26 14.2.29.2 View file →
@@ -1,5 +1,6 @@
1 1 <?php
2 +
2 3 /**
3 4 * Module Name: Shortcode Embeds
4 5 * Module Description: Shortcodes are WordPress-specific markup that let you add media from popular sites. This feature is no longer necessary as the editor now handles media embeds rather gracefully.
5 6 * Sort Order: 3
@@ -8,11 +9,9 @@
8 9 * Requires Connection: No
9 10 * Auto Activate: No
10 11 * Module Tags: Photos and Videos, Social, Writing, Appearance
11 12 * Feature: Writing
12 - * Additional Search Queries: shortcodes, shortcode, embeds, media, bandcamp, dailymotion, facebook, flickr, google calendars, google maps, polldaddy, recipe, recipes, scribd, slideshare, slideshow, slideshows, soundcloud, ted, twitter, vimeo, vine, youtube
13 - *
14 - * @package automattic/jetpack
13 + * Additional Search Queries: shortcodes, shortcode, embeds, media, bandcamp, dailymotion, facebook, flickr, google calendars, google maps, google+, polldaddy, recipe, recipes, scribd, slideshare, slideshow, slideshows, soundcloud, ted, twitter, vimeo, vine, youtube
15 14 */
16 15
17 16 /**
18 17 * Transforms the $atts array into a string that the old functions expected
@@ -45,28 +44,20 @@
45 44 /**
46 45 * Load all available Jetpack shortcode files.
47 46 */
48 47 function jetpack_load_shortcodes() {
49 - // Prevent third-party shortcode plugins when loading shortcode files.
50 - // Format: shortcode => condition_when_to_skip
51 - $shortcode_skips = array(
52 - 'soundcloud' => function_exists( 'soundcloud_shortcode' ), // SoundCloud Shortcodes plugin
53 - );
54 -
55 48 $shortcode_includes = array();
56 49
57 - foreach ( Jetpack::glob_php( __DIR__ . '/shortcodes' ) as $file ) {
50 + foreach ( Jetpack::glob_php( dirname( __FILE__ ) . '/shortcodes' ) as $file ) {
58 51 $filename = substr( basename( $file ), 0, -4 );
59 52
60 - if ( empty( $shortcode_skips[ $filename ] ) ) {
61 - $shortcode_includes[ $filename ] = $file;
62 - }
53 + $shortcode_includes[ $filename ] = $file;
63 54 }
64 55
65 56 /**
66 57 * This filter allows other plugins to override which shortcodes Jetpack loads.
67 58 *
68 - * Fires as part of the `after_setup_theme` WP hook, so modifying code needs to be in a plugin, not in a theme's functions.php.
59 + * Fires as part of the `plugins_loaded` WP hook, so modifying code needs to be in a plugin, not in a theme's functions.php.
69 60 *
70 61 * @module shortcodes
71 62 *
72 63 * @since 2.2.1
@@ -92,9 +83,9 @@
92 83 *
93 84 * @return string $content Replaced post content.
94 85 */
95 86 function jetpack_preg_replace_outside_tags( $pattern, $replacement, $content, $search = null ) {
96 - if ( $search && ! str_contains( $content, $search ) ) {
87 + if ( $search && false === strpos( $content, $search ) ) {
97 88 return $content;
98 89 }
99 90
100 91 $textarr = wp_html_split( $content );
@@ -105,9 +96,9 @@
105 96 }
106 97 $element = preg_replace( $pattern, $replacement, $element );
107 98 }
108 99
109 - return implode( $textarr );
100 + return join( $textarr );
110 101 }
111 102
112 103 /**
113 104 * Runs preg_replace_callback so that replacements don't happen within open tags.
@@ -120,9 +111,9 @@
120 111 *
121 112 * @return string $content Replaced post content.
122 113 */
123 114 function jetpack_preg_replace_callback_outside_tags( $pattern, $callback, $content, $search = null ) {
124 - if ( $search && ! str_contains( $content, $search ) ) {
115 + if ( $search && false === strpos( $content, $search ) ) {
125 116 return $content;
126 117 }
127 118
128 119 $textarr = wp_html_split( $content );
@@ -133,9 +124,9 @@
133 124 }
134 125 $element = preg_replace_callback( $pattern, $callback, $element );
135 126 }
136 127
137 - return implode( $textarr );
128 + return join( $textarr );
138 129 }
139 130
140 131 if ( ! function_exists( 'jetpack_shortcode_get_wpvideo_id' ) ) {
141 132 /**
@@ -141,10 +132,9 @@
141 132 /**
142 133 * Get VideoPress ID from wpvideo shortcode attributes.
143 134 *
144 135 * @param array $atts Shortcode attributes.
145 - *
146 - * @return string|int $id VideoPress ID.
136 + * @return int $id VideoPress ID.
147 137 */
148 138 function jetpack_shortcode_get_wpvideo_id( $atts ) {
149 139 if ( isset( $atts[0] ) ) {
150 140 return $atts[0];
@@ -187,9 +177,9 @@
187 177 );
188 178
189 179 $attrs = shortcode_atts( $defaults, $attrs );
190 180
191 - $attrs['src'] = wp_strip_all_tags( $attrs['src'] ); // For sanity.
181 + $attrs['src'] = strip_tags( $attrs['src'] ); // For sanity
192 182 $attrs['width'] = ( is_numeric( $attrs['width'] ) ) ? abs( (int) $attrs['width'] ) : $defaults['width'];
193 183 $attrs['height'] = ( is_numeric( $attrs['height'] ) ) ? abs( (int) $attrs['height'] ) : $defaults['height'];
194 184
195 185 return $attrs;
@@ -197,13 +187,8 @@
197 187
198 188 /**
199 189 * When an embed service goes away, we can use this handler
200 190 * to output a link for history's sake.
201 - *
202 - * @param array $matches Regex partial matches against the URL passed.
203 - * @param array $attr Attributes received in embed response.
204 - * @param string $url Requested URL to be embedded.
205 - * @return string Link to output.
206 191 */
207 192 function jetpack_deprecated_embed_handler( $matches, $attr, $url ) {
208 193 return sprintf( '<a href="%s">%s</a>', esc_url( $url ), esc_html( esc_url( $url ) ) );
209 194 }