Shortcodes: Revert recent `apply_shortcodes` and `do_shortcode` changes.

[54248] reversed the wrapping of `do_shortcode` and `apply_shortcodes` and updated all direct internal calls of `do_shortcode` to `apply_shortcodes` after [47004].  After further consideration, the long history of `do_shortcodes` should be favored over any subjective semantic improvements.  This change reverts the remaining changes from #55883 not already reverted in [54278].

Follow-up to [47004], [54248], and [54278].

Props azaozz, jorbin.
See #55883.
Built from https://develop.svn.wordpress.org/trunk@54319


git-svn-id: http://core.svn.wordpress.org/trunk@53878 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
davidbaumwald 2022-09-26 22:43:10 +00:00
parent 2eabdd1490
commit b266a2d535
7 changed files with 36 additions and 36 deletions

View File

@ -3788,7 +3788,7 @@ function wp_ajax_parse_embed() {
$styles .= sprintf( '<link rel="stylesheet" href="%s" />', $style );
}
$html = apply_shortcodes( $parsed );
$html = do_shortcode( $parsed );
global $wp_scripts;
@ -3861,7 +3861,7 @@ function wp_ajax_parse_media_shortcode() {
setup_postdata( $post );
}
$parsed = apply_shortcodes( $shortcode );
$parsed = do_shortcode( $shortcode );
if ( empty( $parsed ) ) {
wp_send_json_error(

View File

@ -242,7 +242,7 @@ function get_the_block_template_html() {
$content = convert_smilies( $content );
$content = shortcode_unautop( $content );
$content = wp_filter_content_tags( $content );
$content = apply_shortcodes( $content );
$content = do_shortcode( $content );
$content = str_replace( ']]>', ']]&gt;', $content );
// Wrap block template in .wp-site-blocks to allow for specific descendant styles

View File

@ -52,7 +52,7 @@ class WP_Embed {
*
* Since the [embed] shortcode needs to be run earlier than other shortcodes,
* this function removes all existing shortcodes, registers the [embed] shortcode,
* calls apply_shortcodes(), and then re-registers the old shortcodes.
* calls do_shortcode(), and then re-registers the old shortcodes.
*
* @global array $shortcode_tags
*
@ -69,7 +69,7 @@ class WP_Embed {
add_shortcode( 'embed', array( $this, 'shortcode' ) );
// Do the shortcode (only the [embed] one is registered).
$content = apply_shortcodes( $content, true );
$content = do_shortcode( $content, true );
// Put the original shortcodes back.
$shortcode_tags = $orig_shortcode_tags;
@ -177,7 +177,7 @@ class WP_Embed {
}
/**
* The apply_shortcodes() callback function.
* The do_shortcode() callback function.
*
* Attempts to convert a URL into embed HTML. Starts by checking the URL against the regex of
* the registered embed handlers. If none of the regex matches and it's enabled, then the URL

View File

@ -2296,7 +2296,7 @@ function img_caption_shortcode( $attr, $content = '' ) {
$describedby,
$style,
esc_attr( $class ),
apply_shortcodes( $content ),
do_shortcode( $content ),
sprintf(
'<figcaption %sclass="wp-caption-text">%s</figcaption>',
$caption_id,
@ -2309,7 +2309,7 @@ function img_caption_shortcode( $attr, $content = '' ) {
$id,
$style,
esc_attr( $class ),
str_replace( '<img ', '<img ' . $describedby, apply_shortcodes( $content ) ),
str_replace( '<img ', '<img ' . $describedby, do_shortcode( $content ) ),
sprintf(
'<p %sclass="wp-caption-text">%s</p>',
$caption_id,

View File

@ -21,7 +21,7 @@
*
* To apply shortcode tags to content:
*
* $out = apply_shortcodes( $content );
* $out = do_shortcode( $content );
*
* @link https://developer.wordpress.org/plugins/shortcodes/
*
@ -168,6 +168,24 @@ function has_shortcode( $content, $tag ) {
return false;
}
/**
* Searches content for shortcodes and filter shortcodes through their hooks.
*
* This function is an alias for do_shortcode().
*
* @since 5.4.0
*
* @see do_shortcode()
*
* @param string $content Content to search for shortcodes.
* @param bool $ignore_html When true, shortcodes inside HTML elements will be skipped.
* Default false.
* @return string Content with shortcodes filtered out.
*/
function apply_shortcodes( $content, $ignore_html = false ) {
return do_shortcode( $content, $ignore_html );
}
/**
* Searches content for shortcodes and filter shortcodes through their hooks.
*
@ -175,7 +193,7 @@ function has_shortcode( $content, $tag ) {
* without any filtering. This might cause issues when plugins are disabled but
* the shortcode will still show up in the post or content.
*
* @since 5.4.0
* @since 2.5.0
*
* @global array $shortcode_tags List of shortcode tags and their callback hooks.
*
@ -184,7 +202,7 @@ function has_shortcode( $content, $tag ) {
* Default false.
* @return string Content with shortcodes filtered out.
*/
function apply_shortcodes( $content, $ignore_html = false ) {
function do_shortcode( $content, $ignore_html = false ) {
global $shortcode_tags;
if ( false === strpos( $content, '[' ) ) {
@ -214,24 +232,6 @@ function apply_shortcodes( $content, $ignore_html = false ) {
return $content;
}
/**
* Searches content for shortcodes and filter shortcodes through their hooks.
*
* This function is an alias for apply_shortcodes().
*
* @since 2.5.0
*
* @see apply_shortcodes()
*
* @param string $content Content to search for shortcodes.
* @param bool $ignore_html When true, shortcodes inside HTML elements will be skipped.
* Default false.
* @return string Content with shortcodes filtered out.
*/
function do_shortcode( $content, $ignore_html = false ) {
return apply_shortcodes( $content, $ignore_html );
}
/**
* Retrieves the shortcode regular expression for searching.
*
@ -299,7 +299,7 @@ function get_shortcode_regex( $tagnames = null ) {
}
/**
* Regular Expression callable for apply_shortcodes() for calling shortcode hook.
* Regular Expression callable for do_shortcode() for calling shortcode hook.
*
* @see get_shortcode_regex() for details of the match array contents.
*

View File

@ -16,7 +16,7 @@
*
* @global string $wp_version
*/
$wp_version = '6.1-beta1-54318';
$wp_version = '6.1-beta1-54319';
/**
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.

View File

@ -244,9 +244,9 @@ class WP_Widget_Text extends WP_Widget {
/*
* Suspend legacy plugin-supplied do_shortcode() for 'widget_text' filter for the visual Text widget to prevent
* shortcodes being processed twice. Now apply_shortcodes() is added to the 'widget_text_content' filter in core itself
* shortcodes being processed twice. Now do_shortcode() is added to the 'widget_text_content' filter in core itself
* and it applies after wpautop() to prevent corrupting HTML output added by the shortcode. When do_shortcode() is
* added to 'widget_text_content' then apply_shortcodes() will be manually called when in legacy mode as well.
* added to 'widget_text_content' then do_shortcode() will be manually called when in legacy mode as well.
*/
$widget_text_do_shortcode_priority = has_filter( 'widget_text', 'do_shortcode' );
$should_suspend_legacy_shortcode_support = ( $is_visual_text_widget && false !== $widget_text_do_shortcode_priority );
@ -302,9 +302,9 @@ class WP_Widget_Text extends WP_Widget {
/*
* Manually do shortcodes on the content when the core-added filter is present. It is added by default
* in core by adding apply_shortcodes() to the 'widget_text_content' filter to apply after wpautop().
* in core by adding do_shortcode() to the 'widget_text_content' filter to apply after wpautop().
* Since the legacy Text widget runs wpautop() after 'widget_text' filters are applied, the widget in
* legacy mode here manually applies apply_shortcodes() on the content unless the default
* legacy mode here manually applies do_shortcode() on the content unless the default
* core filter for 'widget_text_content' has been removed, or if do_shortcode() has already
* been applied via a plugin adding do_shortcode() to 'widget_text' filters.
*/
@ -312,7 +312,7 @@ class WP_Widget_Text extends WP_Widget {
if ( ! empty( $instance['filter'] ) ) {
$text = shortcode_unautop( $text );
}
$text = apply_shortcodes( $text );
$text = do_shortcode( $text );
}
}