mirror of
https://github.com/gosticks/wordpress-develop.git
synced 2026-10-06 07:36:58 +00:00
Shortcodes: Allow using single quotes for empty value attributes.
Props enrico.sorcinelli. Fixes #37304. git-svn-id: https://develop.svn.wordpress.org/trunk@41026 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
@@ -134,8 +134,9 @@ window.wp = window.wp || {};
|
||||
// 5. An attribute name, that corresponds to...
|
||||
// 6. an unquoted value.
|
||||
// 7. A numeric attribute in double quotes.
|
||||
// 8. An unquoted numeric attribute.
|
||||
pattern = /([\w-]+)\s*=\s*"([^"]*)"(?:\s|$)|([\w-]+)\s*=\s*'([^']*)'(?:\s|$)|([\w-]+)\s*=\s*([^\s'"]+)(?:\s|$)|"([^"]*)"(?:\s|$)|(\S+)(?:\s|$)/g;
|
||||
// 8. A numeric attribute in single quotes.
|
||||
// 9. An unquoted numeric attribute.
|
||||
pattern = /([\w-]+)\s*=\s*"([^"]*)"(?:\s|$)|([\w-]+)\s*=\s*'([^']*)'(?:\s|$)|([\w-]+)\s*=\s*([^\s'"]+)(?:\s|$)|"([^"]*)"(?:\s|$)|'([^']*)'(?:\s|$)|(\S+)(?:\s|$)/g;
|
||||
|
||||
// Map zero-width spaces to actual spaces.
|
||||
text = text.replace( /[\u00a0\u200b]/g, ' ' );
|
||||
@@ -152,6 +153,8 @@ window.wp = window.wp || {};
|
||||
numeric.push( match[7] );
|
||||
} else if ( match[8] ) {
|
||||
numeric.push( match[8] );
|
||||
} else if ( match[9] ) {
|
||||
numeric.push( match[9] );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -487,7 +487,7 @@ function unescape_invalid_shortcodes( $content ) {
|
||||
* @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|$)/';
|
||||
return '/([\w-]+)\s*=\s*"([^"]*)"(?:\s|$)|([\w-]+)\s*=\s*\'([^\']*)\'(?:\s|$)|([\w-]+)\s*=\s*([^\s\'"]+)(?:\s|$)|"([^"]*)"(?:\s|$)|\'([^\']*)\'(?:\s|$)|(\S+)(?:\s|$)/';
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -519,8 +519,10 @@ function shortcode_parse_atts($text) {
|
||||
$atts[strtolower($m[5])] = stripcslashes($m[6]);
|
||||
elseif (isset($m[7]) && strlen($m[7]))
|
||||
$atts[] = stripcslashes($m[7]);
|
||||
elseif (isset($m[8]))
|
||||
elseif (isset($m[8]) && strlen($m[8]))
|
||||
$atts[] = stripcslashes($m[8]);
|
||||
elseif (isset($m[9]))
|
||||
$atts[] = stripcslashes($m[9]);
|
||||
}
|
||||
|
||||
// Reject any unclosed HTML elements
|
||||
|
||||
Reference in New Issue
Block a user