Make WordPress Core


Ignore:
Timestamp:
10/12/2023 02:54:10 PM (16 months ago)
Author:
joemcgill
Message:

Grouped backports to the 6.1 branch.

  • REST API: Limit search_columns for users without list_users.
  • Comments: Prevent users who can not see a post from seeing comments on it.
  • Application Passwords: Prevent the use of some pseudo protocols in application passwords.
  • Restrict media shortcode ajax to certain type
  • REST API: Ensure no-cache headers are sent when methods are overriden.
  • Prevent unintended behavior when certain objects are unserialized.

Merges [56833], [56834], [56835], [56836], [56837], and [56838] to the 6.1 branch.
Props xknown, jorbin, Vortfu, joehoyle, timothyblynjacobs, peterwilsoncc, ehtis, tykoted, martinkrcho, paulkevan, dd32, antpb, rmccue.

Location:
branches/6.1
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/6.1

  • branches/6.1/src/wp-includes/shortcodes.php

    r54319 r56867  
    167167    }
    168168    return false;
     169}
     170
     171/**
     172 * Returns a list of registered shortcode names found in the given content.
     173 *
     174 * Example usage:
     175 *
     176 *     get_shortcode_tags_in_content( '[audio src="file.mp3"][/audio] [foo] [gallery ids="1,2,3"]' );
     177 *     // array( 'audio', 'gallery' )
     178 *
     179 * @since 6.3.2
     180 *
     181 * @param string $content The content to check.
     182 * @return string[] An array of registered shortcode names found in the content.
     183 */
     184function get_shortcode_tags_in_content( $content ) {
     185    if ( false === strpos( $content, '[' ) ) {
     186        return array();
     187    }
     188
     189    preg_match_all( '/' . get_shortcode_regex() . '/', $content, $matches, PREG_SET_ORDER );
     190    if ( empty( $matches ) ) {
     191        return array();
     192    }
     193
     194    $tags = array();
     195    foreach ( $matches as $shortcode ) {
     196        $tags[] = $shortcode[2];
     197
     198        if ( ! empty( $shortcode[5] ) ) {
     199            $deep_tags = get_shortcode_tags_in_content( $shortcode[5] );
     200            if ( ! empty( $deep_tags ) ) {
     201                $tags = array_merge( $tags, $deep_tags );
     202            }
     203        }
     204    }
     205
     206    return $tags;
    169207}
    170208
Note: See TracChangeset for help on using the changeset viewer.