mirror of
https://github.com/gosticks/wordpress-develop.git
synced 2026-06-28 14:20:15 +00:00
Abstract the shortcode attribute parsing regex into its own function, update the JavaScript counterpart, and introduce a test to ensure they do not diverge again.
Fixes #34191 Props miqrogroove, johnbillion git-svn-id: https://develop.svn.wordpress.org/trunk@34933 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
@@ -450,6 +450,17 @@ function unescape_invalid_shortcodes( $content ) {
|
||||
return $content;
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve the shortcode attributes regex.
|
||||
*
|
||||
* @since 4.4.0
|
||||
*
|
||||
* @return string The shortcode attribute regular expression
|
||||
*/
|
||||
function get_shortcode_atts_regex() {
|
||||
return '/([\w-]+)\s*=\s*"([^"]*)"(?:\s|$)|([\w-]+)\s*=\s*\'([^\']*)\'(?:\s|$)|([\w-]+)\s*=\s*([^\s\'"]+)(?:\s|$)|"([^"]*)"(?:\s|$)|(\S+)(?:\s|$)/';
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve all attributes from the shortcodes tag.
|
||||
*
|
||||
@@ -467,7 +478,7 @@ function unescape_invalid_shortcodes( $content ) {
|
||||
*/
|
||||
function shortcode_parse_atts($text) {
|
||||
$atts = array();
|
||||
$pattern = '/([\w-]+)\s*=\s*"([^"]*)"(?:\s|$)|([\w-]+)\s*=\s*\'([^\']*)\'(?:\s|$)|([\w-]+)\s*=\s*([^\s\'"]+)(?:\s|$)|"([^"]*)"(?:\s|$)|(\S+)(?:\s|$)/';
|
||||
$pattern = get_shortcode_atts_regex();
|
||||
$text = preg_replace("/[\x{00a0}\x{200b}]+/u", " ", $text);
|
||||
if ( preg_match_all($pattern, $text, $match, PREG_SET_ORDER) ) {
|
||||
foreach ($match as $m) {
|
||||
|
||||
Reference in New Issue
Block a user