Skip to content

Commit 943fa44

Browse files
Shortcodes: Revert [46369] for now to allow more time to investigate and prepare for backward compatibility changes.
Also reverts follow-up changes in [46370] and [46465]. See #47863. git-svn-id: https://develop.svn.wordpress.org/trunk@46554 602fd350-edb4-49c9-b593-d223f7449a82
1 parent d5f11a9 commit 943fa44

File tree

2 files changed

+3
-142
lines changed

2 files changed

+3
-142
lines changed

src/wp-includes/shortcodes.php

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -488,9 +488,8 @@ function get_shortcode_atts_regex() {
488488
* retrieval of the attributes, since all attributes have to be known.
489489
*
490490
* @since 2.5.0
491-
* @since 5.3.0 Added support of a full shortcode input.
492491
*
493-
* @param string $text Any single shortcode of any format or key/value pair string.
492+
* @param string $text
494493
* @return array|string List of attribute values.
495494
* Returns empty array if trim( $text ) == '""'.
496495
* Returns empty string if trim( $text ) == ''.
@@ -499,13 +498,7 @@ function get_shortcode_atts_regex() {
499498
function shortcode_parse_atts( $text ) {
500499
$atts = array();
501500
$pattern = get_shortcode_atts_regex();
502-
$text = trim( preg_replace( "/[\x{00a0}\x{200b}]+/u", ' ', $text ) );
503-
504-
// Remove everything but attributes from shortcode.
505-
if ( preg_match( '#^\[[\w-]+([^\]]*?)\/?\]#', $text, $matches ) ) {
506-
$text = $matches[1];
507-
}
508-
501+
$text = preg_replace( "/[\x{00a0}\x{200b}]+/u", ' ', $text );
509502
if ( preg_match_all( $pattern, $text, $match, PREG_SET_ORDER ) ) {
510503
foreach ( $match as $m ) {
511504
if ( ! empty( $m[1] ) ) {

tests/phpunit/tests/shortcode.php

Lines changed: 1 addition & 133 deletions
Original file line numberDiff line numberDiff line change
@@ -740,7 +740,7 @@ function test_pcre_performance( $input ) {
740740
}
741741

742742
function data_whole_posts() {
743-
require_once DIR_TESTDATA . '/formatting/whole-posts.php';
743+
require_once( DIR_TESTDATA . '/formatting/whole-posts.php' );
744744
return data_whole_posts();
745745
}
746746

@@ -972,136 +972,4 @@ function test_positional_atts_mixed_quotes() {
972972
);
973973
$this->assertEquals( 'test-shortcode-tag', $this->tagname );
974974
}
975-
976-
/**
977-
* Testing the `shortcode_parse_atts()` function.
978-
*
979-
* @ticket 47863
980-
*
981-
* @covers ::shortcode_parse_atts
982-
* @dataProvider data_shortcode_parse_atts
983-
*
984-
* @param string $text A single shortcode format or key/value pair string.
985-
* @param string|array $expected Expected results.
986-
*/
987-
public function test_shortcode_parse_atts( $text, $expected ) {
988-
$actual = shortcode_parse_atts( $text );
989-
$this->assertSame( $expected, $actual );
990-
}
991-
992-
/**
993-
* Data provider for `test_shortcode_parse_atts()`.
994-
*
995-
* @return array {
996-
* @type array {
997-
* @type string $text A single shortcode format or key/value pair string.
998-
* @type string|array $expected The expected result.
999-
* }
1000-
* }
1001-
*/
1002-
public function data_shortcode_parse_atts() {
1003-
1004-
return array(
1005-
array(
1006-
'',
1007-
'',
1008-
),
1009-
array(
1010-
' ',
1011-
'',
1012-
),
1013-
array(
1014-
'""',
1015-
array(),
1016-
),
1017-
array(
1018-
'\'\'',
1019-
array(),
1020-
),
1021-
array(
1022-
'[unittest]',
1023-
'',
1024-
),
1025-
array(
1026-
'[unitest]Unit Test[/unittest]',
1027-
'',
1028-
),
1029-
array(
1030-
'[unittest title="unittest" link="https://unit.test/"]',
1031-
array(
1032-
'title' => 'unittest',
1033-
'link' => 'https://unit.test/',
1034-
),
1035-
),
1036-
array(
1037-
'[unittest title="unittest" link="https://unit.test/"/]',
1038-
array(
1039-
'title' => 'unittest',
1040-
'link' => 'https://unit.test/',
1041-
),
1042-
),
1043-
array(
1044-
'[unit_test title="unittest" link="https://unit.test/"/]',
1045-
array(
1046-
'title' => 'unittest',
1047-
'link' => 'https://unit.test/',
1048-
),
1049-
),
1050-
array(
1051-
'[unit-test title="unittest" link="https://unit.test/"/]',
1052-
array(
1053-
'title' => 'unittest',
1054-
'link' => 'https://unit.test/',
1055-
),
1056-
),
1057-
array(
1058-
'[unittest link=https://unit.test/ /]',
1059-
array(
1060-
'link' => 'https://unit.test/',
1061-
),
1062-
),
1063-
array(
1064-
'[unittest link=https://unit.test/ ]',
1065-
array(
1066-
'link' => 'https://unit.test/',
1067-
),
1068-
),
1069-
array(
1070-
'[unittest link=https://unit.test/]',
1071-
array(
1072-
'link' => 'https://unit.test',
1073-
),
1074-
),
1075-
array(
1076-
'[unittest link https://unit.test/ /]',
1077-
array(
1078-
'link',
1079-
'https://unit.test/',
1080-
),
1081-
),
1082-
array(
1083-
'[unittest title="unittest" link="https://unit.test/"]Unit Test[/unittest]',
1084-
array(
1085-
'title' => 'unittest',
1086-
'link' => 'https://unit.test/',
1087-
),
1088-
),
1089-
array(
1090-
'[unittest title="unittest" link="https://unit.test/"][unit_test foo="bar" bar="foo"][/unittest]',
1091-
array(
1092-
'title' => 'unittest',
1093-
'link' => 'https://unit.test/',
1094-
),
1095-
),
1096-
array(
1097-
'title="unittest" link="https://unit.test/"',
1098-
array(
1099-
'title' => 'unittest',
1100-
'link' => 'https://unit.test/',
1101-
),
1102-
),
1103-
);
1104-
1105-
}
1106-
1107975
}

0 commit comments

Comments
 (0)