| @@ -1,8 +1,9 @@ | ||
| 1 | 1 | <?php |
| 2 | + | |
| 2 | 3 | /** |
| 3 | 4 | * Module Name: Shortcode Embeds |
| 4 | - * Module Description: Easily embed rich media like YouTube videos and tweets using simple shortcodes. | |
| 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 |
| 6 | 7 | * First Introduced: 1.1 |
| 7 | 8 | * Major Changes In: 1.2 |
| 8 | 9 | * Requires Connection: No |
| @@ -8,20 +9,11 @@ | ||
| 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 | -if ( ! defined( 'ABSPATH' ) ) { | |
| 18 | - exit( 0 ); | |
| 19 | -} | |
| 20 | - | |
| 21 | -// Load shortcode utils. | |
| 22 | -require_once __DIR__ . '/shortcodes/shortcode-utils.php'; | |
| 23 | - | |
| 24 | 16 | /** |
| 25 | 17 | * Transforms the $atts array into a string that the old functions expected |
| 26 | 18 | * |
| 27 | 19 | * The old way was: |
| @@ -52,29 +44,20 @@ | ||
| 52 | 44 | /** |
| 53 | 45 | * Load all available Jetpack shortcode files. |
| 54 | 46 | */ |
| 55 | 47 | function jetpack_load_shortcodes() { |
| 56 | - // Prevent third-party shortcode plugins when loading shortcode files. | |
| 57 | - // Format: shortcode => condition_when_to_skip | |
| 58 | - $shortcode_skips = array( | |
| 59 | - 'shortcode-utils' => true, // Utils aren't shortcodes. | |
| 60 | - 'soundcloud' => function_exists( 'soundcloud_shortcode' ), // SoundCloud Shortcodes plugin | |
| 61 | - ); | |
| 62 | - | |
| 63 | 48 | $shortcode_includes = array(); |
| 64 | 49 | |
| 65 | - foreach ( Jetpack::glob_php( __DIR__ . '/shortcodes' ) as $file ) { | |
| 50 | + foreach ( Jetpack::glob_php( dirname( __FILE__ ) . '/shortcodes' ) as $file ) { | |
| 66 | 51 | $filename = substr( basename( $file ), 0, -4 ); |
| 67 | 52 | |
| 68 | - if ( empty( $shortcode_skips[ $filename ] ) ) { | |
| 69 | - $shortcode_includes[ $filename ] = $file; | |
| 70 | - } | |
| 53 | + $shortcode_includes[ $filename ] = $file; | |
| 71 | 54 | } |
| 72 | 55 | |
| 73 | 56 | /** |
| 74 | 57 | * This filter allows other plugins to override which shortcodes Jetpack loads. |
| 75 | 58 | * |
| 76 | - * 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. | |
| 77 | 60 | * |
| 78 | 61 | * @module shortcodes |
| 79 | 62 | * |
| 80 | 63 | * @since 2.2.1 |
| @@ -100,9 +83,9 @@ | ||
| 100 | 83 | * |
| 101 | 84 | * @return string $content Replaced post content. |
| 102 | 85 | */ |
| 103 | 86 | function jetpack_preg_replace_outside_tags( $pattern, $replacement, $content, $search = null ) { |
| 104 | - if ( $search && ! str_contains( $content, $search ) ) { | |
| 87 | + if ( $search && false === strpos( $content, $search ) ) { | |
| 105 | 88 | return $content; |
| 106 | 89 | } |
| 107 | 90 | |
| 108 | 91 | $textarr = wp_html_split( $content ); |
| @@ -113,9 +96,9 @@ | ||
| 113 | 96 | } |
| 114 | 97 | $element = preg_replace( $pattern, $replacement, $element ); |
| 115 | 98 | } |
| 116 | 99 | |
| 117 | - return implode( $textarr ); | |
| 100 | + return join( $textarr ); | |
| 118 | 101 | } |
| 119 | 102 | |
| 120 | 103 | /** |
| 121 | 104 | * Runs preg_replace_callback so that replacements don't happen within open tags. |
| @@ -128,9 +111,9 @@ | ||
| 128 | 111 | * |
| 129 | 112 | * @return string $content Replaced post content. |
| 130 | 113 | */ |
| 131 | 114 | function jetpack_preg_replace_callback_outside_tags( $pattern, $callback, $content, $search = null ) { |
| 132 | - if ( $search && ! str_contains( $content, $search ) ) { | |
| 115 | + if ( $search && false === strpos( $content, $search ) ) { | |
| 133 | 116 | return $content; |
| 134 | 117 | } |
| 135 | 118 | |
| 136 | 119 | $textarr = wp_html_split( $content ); |
| @@ -141,9 +124,9 @@ | ||
| 141 | 124 | } |
| 142 | 125 | $element = preg_replace_callback( $pattern, $callback, $element ); |
| 143 | 126 | } |
| 144 | 127 | |
| 145 | - return implode( $textarr ); | |
| 128 | + return join( $textarr ); | |
| 146 | 129 | } |
| 147 | 130 | |
| 148 | 131 | if ( ! function_exists( 'jetpack_shortcode_get_wpvideo_id' ) ) { |
| 149 | 132 | /** |
| @@ -149,10 +132,9 @@ | ||
| 149 | 132 | /** |
| 150 | 133 | * Get VideoPress ID from wpvideo shortcode attributes. |
| 151 | 134 | * |
| 152 | 135 | * @param array $atts Shortcode attributes. |
| 153 | - * | |
| 154 | - * @return string|int $id VideoPress ID. | |
| 136 | + * @return int $id VideoPress ID. | |
| 155 | 137 | */ |
| 156 | 138 | function jetpack_shortcode_get_wpvideo_id( $atts ) { |
| 157 | 139 | if ( isset( $atts[0] ) ) { |
| 158 | 140 | return $atts[0]; |
| @@ -195,9 +177,9 @@ | ||
| 195 | 177 | ); |
| 196 | 178 | |
| 197 | 179 | $attrs = shortcode_atts( $defaults, $attrs ); |
| 198 | 180 | |
| 199 | - $attrs['src'] = wp_strip_all_tags( $attrs['src'] ); // For sanity. | |
| 181 | + $attrs['src'] = strip_tags( $attrs['src'] ); // For sanity | |
| 200 | 182 | $attrs['width'] = ( is_numeric( $attrs['width'] ) ) ? abs( (int) $attrs['width'] ) : $defaults['width']; |
| 201 | 183 | $attrs['height'] = ( is_numeric( $attrs['height'] ) ) ? abs( (int) $attrs['height'] ) : $defaults['height']; |
| 202 | 184 | |
| 203 | 185 | return $attrs; |
| @@ -205,13 +187,8 @@ | ||
| 205 | 187 | |
| 206 | 188 | /** |
| 207 | 189 | * When an embed service goes away, we can use this handler |
| 208 | 190 | * to output a link for history's sake. |
| 209 | - * | |
| 210 | - * @param array $matches Regex partial matches against the URL passed. | |
| 211 | - * @param array $attr Attributes received in embed response. | |
| 212 | - * @param string $url Requested URL to be embedded. | |
| 213 | - * @return string Link to output. | |
| 214 | 191 | */ |
| 215 | 192 | function jetpack_deprecated_embed_handler( $matches, $attr, $url ) { |
| 216 | 193 | return sprintf( '<a href="%s">%s</a>', esc_url( $url ), esc_html( esc_url( $url ) ) ); |
| 217 | 194 | } |