<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[56850] branches/4.1/src: Grouped backports to the 4.1 branch.</title>
</head>
<body>

<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt;  }
#msg dl a { font-weight: bold}
#msg dl a:link    { color:#fc3; }
#msg dl a:active  { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { white-space: pre-line; overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff  {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta" style="font-size: 105%">
<dt style="float: left; width: 6em; font-weight: bold">Revision</dt> <dd><a style="font-weight: bold" href="https://core.trac.wordpress.org/changeset/56850">56850</a><script type="application/ld+json">{"@context":"http://schema.org","@type":"EmailMessage","description":"Review this Commit","action":{"@type":"ViewAction","url":"https://core.trac.wordpress.org/changeset/56850","name":"Review Commit"}}</script></dd>
<dt style="float: left; width: 6em; font-weight: bold">Author</dt> <dd>davidbaumwald</dd>
<dt style="float: left; width: 6em; font-weight: bold">Date</dt> <dd>2023-10-12 14:21:47 +0000 (Thu, 12 Oct 2023)</dd>
</dl>

<pre style='padding-left: 1em; margin: 2em 0; border-left: 2px solid #ccc; line-height: 1.25; font-size: 105%; font-family: sans-serif'>Grouped backports to the 4.1 branch.
- Comments: Prevent users who can not see a post from seeing comments on it.
- Shortcodes: Restrict ajax handler for media shortcode.
- Prevent unintended behavior when certain objects are unserialized.

Merges <a href="https://core.trac.wordpress.org/changeset/56835">[56835]</a>, <a href="https://core.trac.wordpress.org/changeset/56836">[56836]</a>, and <a href="https://core.trac.wordpress.org/changeset/56838">[56838]</a> to the 4.1 branch.
Props xknown, jorbin, joehoyle, peterwilsoncc, ehtis, tykoted, antpb.</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#branches41srcwpadminincludesajaxactionsphp">branches/4.1/src/wp-admin/includes/ajax-actions.php</a></li>
<li><a href="#branches41srcwpadminincludesclasswpcommentslisttablephp">branches/4.1/src/wp-admin/includes/class-wp-comments-list-table.php</a></li>
<li><a href="#branches41srcwpadminincludesclasswplisttablephp">branches/4.1/src/wp-admin/includes/class-wp-list-table.php</a></li>
<li><a href="#branches41srcwpadminincludesdashboardphp">branches/4.1/src/wp-admin/includes/dashboard.php</a></li>
<li><a href="#branches41srcwpincludesclasswpthemephp">branches/4.1/src/wp-includes/class-wp-theme.php</a></li>
<li><a href="#branches41srcwpincludesmediaphp">branches/4.1/src/wp-includes/media.php</a></li>
<li><a href="#branches41srcwpincludesshortcodesphp">branches/4.1/src/wp-includes/shortcodes.php</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="branches41srcwpadminincludesajaxactionsphp"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: branches/4.1/src/wp-admin/includes/ajax-actions.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- branches/4.1/src/wp-admin/includes/ajax-actions.php       2023-10-12 13:55:27 UTC (rev 56849)
+++ branches/4.1/src/wp-admin/includes/ajax-actions.php 2023-10-12 14:21:47 UTC (rev 56850)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -828,7 +828,7 @@
</span><span class="cx" style="display: block; padding: 0 10px">        if ( ! $tax ) {
</span><span class="cx" style="display: block; padding: 0 10px">                wp_die( 0 );
</span><span class="cx" style="display: block; padding: 0 10px">        }
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-        
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
</ins><span class="cx" style="display: block; padding: 0 10px">         if ( ! current_user_can( $tax->cap->assign_terms ) ) {
</span><span class="cx" style="display: block; padding: 0 10px">                wp_die( -1 );
</span><span class="cx" style="display: block; padding: 0 10px">        }
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -2767,9 +2767,37 @@
</span><span class="cx" style="display: block; padding: 0 10px">                wp_send_json_error();
</span><span class="cx" style="display: block; padding: 0 10px">        }
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-        setup_postdata( $post );
-       $shortcode = do_shortcode( wp_unslash( $_POST['shortcode'] ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $shortcode = wp_unslash( $_POST['shortcode'] );
</ins><span class="cx" style="display: block; padding: 0 10px"> 
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+        // Only process previews for media related shortcodes:
+       $found_shortcodes = get_shortcode_tags_in_content( $shortcode );
+       $media_shortcodes = array(
+               'audio',
+               'embed',
+               'playlist',
+               'video',
+               'gallery',
+       );
+
+       $other_shortcodes = array_diff( $found_shortcodes, $media_shortcodes );
+
+       if ( ! empty( $other_shortcodes ) ) {
+               wp_send_json_error();
+       }
+
+       if ( ! empty( $_POST['post_ID'] ) ) {
+               $post = get_post( (int) $_POST['post_ID'] );
+       }
+
+       // the embed shortcode requires a post
+       if ( ! $post || ! current_user_can( 'edit_post', $post->ID ) ) {
+               if ( in_array( 'embed', $found_shortcodes, true ) ) {
+                       wp_send_json_error();
+               }
+       } else {
+               setup_postdata( $post );
+       }
+
</ins><span class="cx" style="display: block; padding: 0 10px">         if ( empty( $shortcode ) ) {
</span><span class="cx" style="display: block; padding: 0 10px">                wp_send_json_error( array(
</span><span class="cx" style="display: block; padding: 0 10px">                        'type' => 'no-items',
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -2835,7 +2863,7 @@
</span><span class="cx" style="display: block; padding: 0 10px">                $message = __( 'You are now logged out everywhere else.' );
</span><span class="cx" style="display: block; padding: 0 10px">        } else {
</span><span class="cx" style="display: block; padding: 0 10px">                $sessions->destroy_all();
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                /* translators: 1: User's display name. */ 
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+         /* translators: 1: User's display name. */
</ins><span class="cx" style="display: block; padding: 0 10px">                 $message = sprintf( __( '%s has been logged out.' ), $user->display_name );
</span><span class="cx" style="display: block; padding: 0 10px">        }
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span></span></pre></div>
<a id="branches41srcwpadminincludesclasswpcommentslisttablephp"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: branches/4.1/src/wp-admin/includes/class-wp-comments-list-table.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- branches/4.1/src/wp-admin/includes/class-wp-comments-list-table.php       2023-10-12 13:55:27 UTC (rev 56849)
+++ branches/4.1/src/wp-admin/includes/class-wp-comments-list-table.php 2023-10-12 14:21:47 UTC (rev 56850)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -362,6 +362,19 @@
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><span class="cx" style="display: block; padding: 0 10px">                $this->user_can = current_user_can( 'edit_comment', $comment->comment_ID );
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+                $edit_post_cap = $post ? 'edit_post' : 'edit_posts';
+               if (
+                       current_user_can( $edit_post_cap, $comment->comment_post_ID ) ||
+                       (
+                               empty( $post->post_password ) &&
+                               current_user_can( 'read_post', $comment->comment_post_ID )
+                       )
+               ) {
+                       // The user has access to the post
+               } else {
+                       return false;
+               }
+
</ins><span class="cx" style="display: block; padding: 0 10px">                 echo "<tr id='comment-$comment->comment_ID' class='$the_comment_class'>";
</span><span class="cx" style="display: block; padding: 0 10px">                $this->single_row_columns( $comment );
</span><span class="cx" style="display: block; padding: 0 10px">                echo "</tr>\n";
</span></span></pre></div>
<a id="branches41srcwpadminincludesclasswplisttablephp"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: branches/4.1/src/wp-admin/includes/class-wp-list-table.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- branches/4.1/src/wp-admin/includes/class-wp-list-table.php        2023-10-12 13:55:27 UTC (rev 56849)
+++ branches/4.1/src/wp-admin/includes/class-wp-list-table.php  2023-10-12 14:21:47 UTC (rev 56850)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -573,6 +573,20 @@
</span><span class="cx" style="display: block; padding: 0 10px">        protected function comments_bubble( $post_id, $pending_comments ) {
</span><span class="cx" style="display: block; padding: 0 10px">                $pending_phrase = sprintf( __( '%s pending' ), number_format( $pending_comments ) );
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+                $post_object   = get_post( $post_id );
+               $edit_post_cap = $post_object ? 'edit_post' : 'edit_posts';
+               if (
+                       current_user_can( $edit_post_cap, $post_id ) ||
+                       (
+                               empty( $post_object->post_password ) &&
+                               current_user_can( 'read_post', $post_id )
+                       )
+               ) {
+                       // The user has access to the post and thus can see comments
+               } else {
+                       return false;
+               }
+
</ins><span class="cx" style="display: block; padding: 0 10px">                 if ( $pending_comments )
</span><span class="cx" style="display: block; padding: 0 10px">                        echo '<strong>';
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span></span></pre></div>
<a id="branches41srcwpadminincludesdashboardphp"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: branches/4.1/src/wp-admin/includes/dashboard.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- branches/4.1/src/wp-admin/includes/dashboard.php  2023-10-12 13:55:27 UTC (rev 56849)
+++ branches/4.1/src/wp-admin/includes/dashboard.php    2023-10-12 14:21:47 UTC (rev 56850)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -778,8 +778,18 @@
</span><span class="cx" style="display: block; padding: 0 10px">                echo '<h4>' . __( 'Comments' ) . '</h4>';
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><span class="cx" style="display: block; padding: 0 10px">                echo '<div id="the-comment-list" data-wp-lists="list:comment">';
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                foreach ( $comments as $comment )
-                       _wp_dashboard_recent_comments_row( $comment );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+         foreach ( $comments as $comment ) {
+                       $comment_post = get_post( $comment->comment_post_ID );
+                       if (
+                               current_user_can( 'edit_post', $comment->comment_post_ID ) ||
+                               (
+                                       empty( $comment_post->post_password ) &&
+                                       current_user_can( 'read_post', $comment->comment_post_ID )
+                               )
+                       ) {
+                               _wp_dashboard_recent_comments_row( $comment );
+                       }
+               }
</ins><span class="cx" style="display: block; padding: 0 10px">                 echo '</div>';
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><span class="cx" style="display: block; padding: 0 10px">                if ( current_user_can('edit_posts') )
</span></span></pre></div>
<a id="branches41srcwpincludesclasswpthemephp"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: branches/4.1/src/wp-includes/class-wp-theme.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- branches/4.1/src/wp-includes/class-wp-theme.php   2023-10-12 13:55:27 UTC (rev 56849)
+++ branches/4.1/src/wp-includes/class-wp-theme.php     2023-10-12 14:21:47 UTC (rev 56850)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -477,6 +477,28 @@
</span><span class="cx" style="display: block; padding: 0 10px">        }
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><span class="cx" style="display: block; padding: 0 10px">        /**
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+         * Perform reinitialization tasks.
+        *
+        * Prevents a callback from being injected during unserialization of an object.
+        *
+        * @return void
+        */
+       public function __wakeup() {
+               if ( $this->parent && ! $this->parent instanceof self ) {
+                       throw new UnexpectedValueException();
+               }
+               if ( $this->headers && ! is_array( $this->headers ) ) {
+                       throw new UnexpectedValueException();
+               }
+               foreach ( $this->headers as $value ) {
+                       if ( ! is_string( $value ) ) {
+                               throw new UnexpectedValueException();
+                       }
+               }
+               $this->headers_sanitized = array();
+       }
+
+       /**
</ins><span class="cx" style="display: block; padding: 0 10px">          * Adds theme data to cache.
</span><span class="cx" style="display: block; padding: 0 10px">         *
</span><span class="cx" style="display: block; padding: 0 10px">         * Cache entries keyed by the theme and the type of data.
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1232,4 +1254,16 @@
</span><span class="cx" style="display: block; padding: 0 10px">                // Don't mark up; Do translate.
</span><span class="cx" style="display: block; padding: 0 10px">                return strnatcasecmp( $a->display( 'Name', false, true ), $b->display( 'Name', false, true ) );
</span><span class="cx" style="display: block; padding: 0 10px">        }
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
+       private static function _check_headers_property_has_correct_type( $headers ) {
+               if ( ! is_array( $headers ) ) {
+                       return false;
+               }
+               foreach ( $headers as $key => $value ) {
+                       if ( ! is_string( $key ) || ! is_string( $value ) ) {
+                               return false;
+                       }
+               }
+               return true;
+       }
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span></span></pre></div>
<a id="branches41srcwpincludesmediaphp"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: branches/4.1/src/wp-includes/media.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- branches/4.1/src/wp-includes/media.php    2023-10-12 13:55:27 UTC (rev 56849)
+++ branches/4.1/src/wp-includes/media.php      2023-10-12 14:21:47 UTC (rev 56850)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -974,11 +974,24 @@
</span><span class="cx" style="display: block; padding: 0 10px">                        $attachments[$val->ID] = $_attachments[$key];
</span><span class="cx" style="display: block; padding: 0 10px">                }
</span><span class="cx" style="display: block; padding: 0 10px">        } elseif ( ! empty( $atts['exclude'] ) ) {
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+                $post_parent_id = $id;
</ins><span class="cx" style="display: block; padding: 0 10px">                 $attachments = get_children( array( 'post_parent' => $id, 'exclude' => $atts['exclude'], 'post_status' => 'inherit', 'post_type' => 'attachment', 'post_mime_type' => 'image', 'order' => $atts['order'], 'orderby' => $atts['orderby'] ) );
</span><span class="cx" style="display: block; padding: 0 10px">        } else {
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+                $post_parent_id = $id;
</ins><span class="cx" style="display: block; padding: 0 10px">                 $attachments = get_children( array( 'post_parent' => $id, 'post_status' => 'inherit', 'post_type' => 'attachment', 'post_mime_type' => 'image', 'order' => $atts['order'], 'orderby' => $atts['orderby'] ) );
</span><span class="cx" style="display: block; padding: 0 10px">        }
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+        if ( ! empty( $post_parent_id ) ) {
+               $post_parent = get_post( $post_parent_id );
+
+               // terminate the shortcode execution if user cannot read the post or password-protected
+               if (
+               ( ! is_post_publicly_viewable( $post_parent->ID ) && ! current_user_can( 'read_post', $post_parent->ID ) )
+               || post_password_required( $post_parent ) ) {
+                       return '';
+               }
+       }
+
</ins><span class="cx" style="display: block; padding: 0 10px">         if ( empty( $attachments ) ) {
</span><span class="cx" style="display: block; padding: 0 10px">                return '';
</span><span class="cx" style="display: block; padding: 0 10px">        }
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1268,6 +1281,15 @@
</span><span class="cx" style="display: block; padding: 0 10px">                $attachments = get_children( $args );
</span><span class="cx" style="display: block; padding: 0 10px">        }
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+        if ( ! empty( $args['post_parent'] ) ) {
+               $post_parent = get_post( $id );
+
+               // terminate the shortcode execution if user cannot read the post or password-protected
+               if ( ! current_user_can( 'read_post', $post_parent->ID ) || post_password_required( $post_parent ) ) {
+                       return '';
+               }
+       }
+
</ins><span class="cx" style="display: block; padding: 0 10px">         if ( empty( $attachments ) ) {
</span><span class="cx" style="display: block; padding: 0 10px">                return '';
</span><span class="cx" style="display: block; padding: 0 10px">        }
</span></span></pre></div>
<a id="branches41srcwpincludesshortcodesphp"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: branches/4.1/src/wp-includes/shortcodes.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- branches/4.1/src/wp-includes/shortcodes.php       2023-10-12 13:55:27 UTC (rev 56849)
+++ branches/4.1/src/wp-includes/shortcodes.php 2023-10-12 14:21:47 UTC (rev 56850)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -170,8 +170,46 @@
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * Search content for shortcodes and filter shortcodes through their hooks.
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * Returns a list of registered shortcode names found in the given content.
</ins><span class="cx" style="display: block; padding: 0 10px">  *
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * Example usage:
+ *
+ *     get_shortcode_tags_in_content( '[audio src="file.mp3"][/audio] [foo] [gallery ids="1,2,3"]' );
+ *     // array( 'audio', 'gallery' )
+ *
+ * @since 6.3.2
+ *
+ * @param string $content The content to check.
+ * @return string[] An array of registered shortcode names found in the content.
+ */
+function get_shortcode_tags_in_content( $content ) {
+       if ( false === strpos( $content, '[' ) ) {
+               return array();
+       }
+
+       preg_match_all( '/' . get_shortcode_regex() . '/', $content, $matches, PREG_SET_ORDER );
+       if ( empty( $matches ) ) {
+               return array();
+       }
+
+       $tags = array();
+       foreach ( $matches as $shortcode ) {
+               $tags[] = $shortcode[2];
+
+               if ( ! empty( $shortcode[5] ) ) {
+                       $deep_tags = get_shortcode_tags_in_content( $shortcode[5] );
+                       if ( ! empty( $deep_tags ) ) {
+                               $tags = array_merge( $tags, $deep_tags );
+                       }
+               }
+       }
+
+       return $tags;
+}
+
+/**
+ * Searches content for shortcodes and filter shortcodes through their hooks.
+ *
</ins><span class="cx" style="display: block; padding: 0 10px">  * If there are no shortcode tags defined, then the content will be returned
</span><span class="cx" style="display: block; padding: 0 10px">  * without any filtering. This might cause issues when plugins are disabled but
</span><span class="cx" style="display: block; padding: 0 10px">  * the shortcode will still show up in the post or content.
</span></span></pre>
</div>
</div>

</body>
</html>