PluginProbe
Jetpack – WP Security, Backup, Speed, & Growth / 7.1.4
Jetpack – WP Security, Backup, Speed, & Growth v7.1.4
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 14.4.2 All 500 releases
← All changes | modules/shortcodes.php +21 -20 12.4.27.1.4 View file →
@@ -1,18 +1,17 @@
1 1 <?php
2 +
2 3 /**
3 4 * Module Name: Shortcode Embeds
4 - * 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 + * Module Description: Embed media from popular sites without any coding.
5 6 * Sort Order: 3
6 7 * First Introduced: 1.1
7 8 * Major Changes In: 1.2
8 9 * Requires Connection: No
9 - * Auto Activate: No
10 + * Auto Activate: Yes
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
@@ -47,9 +46,9 @@
47 46 */
48 47 function jetpack_load_shortcodes() {
49 48 $shortcode_includes = array();
50 49
51 - foreach ( Jetpack::glob_php( __DIR__ . '/shortcodes' ) as $file ) {
50 + foreach ( Jetpack::glob_php( dirname( __FILE__ ) . '/shortcodes' ) as $file ) {
52 51 $filename = substr( basename( $file ), 0, -4 );
53 52
54 53 $shortcode_includes[ $filename ] = $file;
55 54 }
@@ -84,8 +83,12 @@
84 83 *
85 84 * @return string $content Replaced post content.
86 85 */
87 86 function jetpack_preg_replace_outside_tags( $pattern, $replacement, $content, $search = null ) {
87 + if ( ! function_exists( 'wp_html_split' ) ) {
88 + return $content;
89 + }
90 +
88 91 if ( $search && false === strpos( $content, $search ) ) {
89 92 return $content;
90 93 }
91 94
@@ -91,15 +94,15 @@
91 94
92 95 $textarr = wp_html_split( $content );
93 96 unset( $content );
94 97 foreach ( $textarr as &$element ) {
95 - if ( '' === $element || '<' === $element[0] ) {
98 + if ( '' === $element || '<' === $element{0} ) {
96 99 continue;
97 100 }
98 101 $element = preg_replace( $pattern, $replacement, $element );
99 102 }
100 103
101 - return implode( $textarr );
104 + return join( $textarr );
102 105 }
103 106
104 107 /**
105 108 * Runs preg_replace_callback so that replacements don't happen within open tags.
@@ -112,8 +115,12 @@
112 115 *
113 116 * @return string $content Replaced post content.
114 117 */
115 118 function jetpack_preg_replace_callback_outside_tags( $pattern, $callback, $content, $search = null ) {
119 + if ( ! function_exists( 'wp_html_split' ) ) {
120 + return $content;
121 + }
122 +
116 123 if ( $search && false === strpos( $content, $search ) ) {
117 124 return $content;
118 125 }
119 126
@@ -119,15 +126,15 @@
119 126
120 127 $textarr = wp_html_split( $content );
121 128 unset( $content );
122 129 foreach ( $textarr as &$element ) {
123 - if ( '' === $element || '<' === $element[0] ) {
130 + if ( '' === $element || '<' === $element{0} ) {
124 131 continue;
125 132 }
126 133 $element = preg_replace_callback( $pattern, $callback, $element );
127 134 }
128 135
129 - return implode( $textarr );
136 + return join( $textarr );
130 137 }
131 138
132 139 if ( ! function_exists( 'jetpack_shortcode_get_wpvideo_id' ) ) {
133 140 /**
@@ -133,10 +140,9 @@
133 140 /**
134 141 * Get VideoPress ID from wpvideo shortcode attributes.
135 142 *
136 143 * @param array $atts Shortcode attributes.
137 - *
138 - * @return string|int $id VideoPress ID.
144 + * @return int $id VideoPress ID.
139 145 */
140 146 function jetpack_shortcode_get_wpvideo_id( $atts ) {
141 147 if ( isset( $atts[0] ) ) {
142 148 return $atts[0];
@@ -179,11 +185,11 @@
179 185 );
180 186
181 187 $attrs = shortcode_atts( $defaults, $attrs );
182 188
183 - $attrs['src'] = wp_strip_all_tags( $attrs['src'] ); // For sanity.
184 - $attrs['width'] = ( is_numeric( $attrs['width'] ) ) ? abs( (int) $attrs['width'] ) : $defaults['width'];
185 - $attrs['height'] = ( is_numeric( $attrs['height'] ) ) ? abs( (int) $attrs['height'] ) : $defaults['height'];
189 + $attrs['src'] = strip_tags( $attrs['src'] ); // For sanity
190 + $attrs['width'] = ( is_numeric( $attrs['width'] ) ) ? abs( intval( $attrs['width'] ) ) : $defaults['width'];
191 + $attrs['height'] = ( is_numeric( $attrs['height'] ) ) ? abs( intval( $attrs['height'] ) ) : $defaults['height'];
186 192
187 193 return $attrs;
188 194 }
189 195
@@ -189,13 +195,8 @@
189 195
190 196 /**
191 197 * When an embed service goes away, we can use this handler
192 198 * to output a link for history's sake.
193 - *
194 - * @param array $matches Regex partial matches against the URL passed.
195 - * @param array $attr Attributes received in embed response.
196 - * @param string $url Requested URL to be embedded.
197 - * @return string Link to output.
198 199 */
199 200 function jetpack_deprecated_embed_handler( $matches, $attr, $url ) {
200 201 return sprintf( '<a href="%s">%s</a>', esc_url( $url ), esc_html( esc_url( $url ) ) );
201 202 }