Changeset 54248
- Timestamp:
- 09/20/2022 10:29:55 AM (2 years ago)
- Location:
- trunk/src
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-admin/includes/ajax-actions.php
r53885 r54248 3789 3789 } 3790 3790 3791 $html = do_shortcode( $parsed );3791 $html = apply_shortcodes( $parsed ); 3792 3792 3793 3793 global $wp_scripts; … … 3862 3862 } 3863 3863 3864 $parsed = do_shortcode( $shortcode );3864 $parsed = apply_shortcodes( $shortcode ); 3865 3865 3866 3866 if ( empty( $parsed ) ) { -
trunk/src/wp-includes/block-template.php
r53728 r54248 243 243 $content = shortcode_unautop( $content ); 244 244 $content = wp_filter_content_tags( $content ); 245 $content = do_shortcode( $content );245 $content = apply_shortcodes( $content ); 246 246 $content = str_replace( ']]>', ']]>', $content ); 247 247 -
trunk/src/wp-includes/class-wp-embed.php
r54133 r54248 53 53 * Since the [embed] shortcode needs to be run earlier than other shortcodes, 54 54 * this function removes all existing shortcodes, registers the [embed] shortcode, 55 * calls do_shortcode(), and then re-registers the old shortcodes.55 * calls apply_shortcodes(), and then re-registers the old shortcodes. 56 56 * 57 57 * @global array $shortcode_tags … … 70 70 71 71 // Do the shortcode (only the [embed] one is registered). 72 $content = do_shortcode( $content, true );72 $content = apply_shortcodes( $content, true ); 73 73 74 74 // Put the original shortcodes back. … … 178 178 179 179 /** 180 * The do_shortcode() callback function.180 * The apply_shortcodes() callback function. 181 181 * 182 182 * Attempts to convert a URL into embed HTML. Starts by checking the URL against the regex of -
trunk/src/wp-includes/default-filters.php
r54226 r54248 229 229 add_filter( 'widget_block_content', 'do_blocks', 9 ); 230 230 add_filter( 'widget_block_content', 'wp_filter_content_tags' ); 231 add_filter( 'widget_block_content', ' do_shortcode', 11 );231 add_filter( 'widget_block_content', 'apply_shortcodes', 11 ); 232 232 233 233 add_filter( 'block_type_metadata', 'wp_migrate_old_typography_shape' ); … … 606 606 607 607 // Shortcodes. 608 add_filter( 'the_content', ' do_shortcode', 11 ); // AFTER wpautop().608 add_filter( 'the_content', 'apply_shortcodes', 11 ); // AFTER wpautop(). 609 609 610 610 // Media. -
trunk/src/wp-includes/media.php
r54226 r54248 2297 2297 $style, 2298 2298 esc_attr( $class ), 2299 do_shortcode( $content ),2299 apply_shortcodes( $content ), 2300 2300 sprintf( 2301 2301 '<figcaption %sclass="wp-caption-text">%s</figcaption>', … … 2310 2310 $style, 2311 2311 esc_attr( $class ), 2312 str_replace( '<img ', '<img ' . $describedby, do_shortcode( $content ) ),2312 str_replace( '<img ', '<img ' . $describedby, apply_shortcodes( $content ) ), 2313 2313 sprintf( 2314 2314 '<p %sclass="wp-caption-text">%s</p>', -
trunk/src/wp-includes/shortcodes.php
r53585 r54248 22 22 * To apply shortcode tags to content: 23 23 * 24 * $out = do_shortcode( $content );24 * $out = apply_shortcodes( $content ); 25 25 * 26 26 * @link https://developer.wordpress.org/plugins/shortcodes/ … … 172 172 * Searches content for shortcodes and filter shortcodes through their hooks. 173 173 * 174 * This function is an alias for do_shortcode(). 174 * If there are no shortcode tags defined, then the content will be returned 175 * without any filtering. This might cause issues when plugins are disabled but 176 * the shortcode will still show up in the post or content. 175 177 * 176 178 * @since 5.4.0 177 179 * 178 * @ see do_shortcode()180 * @global array $shortcode_tags List of shortcode tags and their callback hooks. 179 181 * 180 182 * @param string $content Content to search for shortcodes. … … 184 186 */ 185 187 function apply_shortcodes( $content, $ignore_html = false ) { 186 return do_shortcode( $content, $ignore_html ); 188 global $shortcode_tags; 189 190 if ( false === strpos( $content, '[' ) ) { 191 return $content; 192 } 193 194 if ( empty( $shortcode_tags ) || ! is_array( $shortcode_tags ) ) { 195 return $content; 196 } 197 198 // Find all registered tag names in $content. 199 preg_match_all( '@\[([^<>&/\[\]\x00-\x20=]++)@', $content, $matches ); 200 $tagnames = array_intersect( array_keys( $shortcode_tags ), $matches[1] ); 201 202 if ( empty( $tagnames ) ) { 203 return $content; 204 } 205 206 $content = do_shortcodes_in_html_tags( $content, $ignore_html, $tagnames ); 207 208 $pattern = get_shortcode_regex( $tagnames ); 209 $content = preg_replace_callback( "/$pattern/", 'do_shortcode_tag', $content ); 210 211 // Always restore square braces so we don't break things like <!--[if IE ]>. 212 $content = unescape_invalid_shortcodes( $content ); 213 214 return $content; 187 215 } 188 216 … … 190 218 * Searches content for shortcodes and filter shortcodes through their hooks. 191 219 * 192 * If there are no shortcode tags defined, then the content will be returned 193 * without any filtering. This might cause issues when plugins are disabled but 194 * the shortcode will still show up in the post or content. 195 * 196 * @since 2.5.0 197 * 198 * @global array $shortcode_tags List of shortcode tags and their callback hooks. 220 * This function is an alias for apply_shortcodes(). 221 * 222 * @since 2.5.0 223 * 224 * @see apply_shortcodes() 199 225 * 200 226 * @param string $content Content to search for shortcodes. … … 204 230 */ 205 231 function do_shortcode( $content, $ignore_html = false ) { 206 global $shortcode_tags; 207 208 if ( false === strpos( $content, '[' ) ) { 209 return $content; 210 } 211 212 if ( empty( $shortcode_tags ) || ! is_array( $shortcode_tags ) ) { 213 return $content; 214 } 215 216 // Find all registered tag names in $content. 217 preg_match_all( '@\[([^<>&/\[\]\x00-\x20=]++)@', $content, $matches ); 218 $tagnames = array_intersect( array_keys( $shortcode_tags ), $matches[1] ); 219 220 if ( empty( $tagnames ) ) { 221 return $content; 222 } 223 224 $content = do_shortcodes_in_html_tags( $content, $ignore_html, $tagnames ); 225 226 $pattern = get_shortcode_regex( $tagnames ); 227 $content = preg_replace_callback( "/$pattern/", 'do_shortcode_tag', $content ); 228 229 // Always restore square braces so we don't break things like <!--[if IE ]>. 230 $content = unescape_invalid_shortcodes( $content ); 231 232 return $content; 232 return apply_shortcodes( $content, $ignore_html ); 233 233 } 234 234 … … 300 300 301 301 /** 302 * Regular Expression callable for do_shortcode() for calling shortcode hook.302 * Regular Expression callable for apply_shortcodes() for calling shortcode hook. 303 303 * 304 304 * @see get_shortcode_regex() for details of the match array contents. -
trunk/src/wp-includes/widgets/class-wp-widget-text.php
r52978 r54248 245 245 /* 246 246 * Suspend legacy plugin-supplied do_shortcode() for 'widget_text' filter for the visual Text widget to prevent 247 * shortcodes being processed twice. Now do_shortcode() is added to the 'widget_text_content' filter in core itself247 * shortcodes being processed twice. Now apply_shortcodes() is added to the 'widget_text_content' filter in core itself 248 248 * and it applies after wpautop() to prevent corrupting HTML output added by the shortcode. When do_shortcode() is 249 * added to 'widget_text_content' then do_shortcode() will be manually called when in legacy mode as well.249 * added to 'widget_text_content' then apply_shortcodes() will be manually called when in legacy mode as well. 250 250 */ 251 251 $widget_text_do_shortcode_priority = has_filter( 'widget_text', 'do_shortcode' ); … … 303 303 /* 304 304 * Manually do shortcodes on the content when the core-added filter is present. It is added by default 305 * in core by adding do_shortcode() to the 'widget_text_content' filter to apply after wpautop().305 * in core by adding apply_shortcodes() to the 'widget_text_content' filter to apply after wpautop(). 306 306 * Since the legacy Text widget runs wpautop() after 'widget_text' filters are applied, the widget in 307 * legacy mode here manually applies do_shortcode() on the content unless the default307 * legacy mode here manually applies apply_shortcodes() on the content unless the default 308 308 * core filter for 'widget_text_content' has been removed, or if do_shortcode() has already 309 309 * been applied via a plugin adding do_shortcode() to 'widget_text' filters. … … 313 313 $text = shortcode_unautop( $text ); 314 314 } 315 $text = do_shortcode( $text );315 $text = apply_shortcodes( $text ); 316 316 } 317 317 }
Note: See TracChangeset
for help on using the changeset viewer.