Allow shortcode parameter names (attributes) to contain dashes.

Props aaroncampbell, tyxla, izem
Fixes #9405


git-svn-id: https://develop.svn.wordpress.org/trunk@33118 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
John Blackbourn
2015-07-07 23:58:49 +00:00
parent 41705c3e7c
commit 063637755b
2 changed files with 19 additions and 1 deletions

View File

@@ -119,6 +119,24 @@ class Tests_Shortcode extends WP_UnitTestCase {
$this->assertEquals( '[hyphen-foo-bar-baz]', do_shortcode( '[hyphen-foo-bar-baz]' ) );
}
/**
* @ticket 9405
*/
function test_attr_hyphen() {
do_shortcode('[test-shortcode-tag foo="foo" foo-bar="foo-bar" foo-bar-="foo-bar-" -foo-bar="-foo-bar" -foo-bar-="-foo-bar-" foo-bar-baz="foo-bar-baz" -foo-bar-baz="-foo-bar-baz" foo--bar="foo--bar" /]');
$expected_attrs = array(
'foo' => 'foo',
'foo-bar' => 'foo-bar',
'foo-bar-' => 'foo-bar-',
'-foo-bar' => '-foo-bar',
'-foo-bar-' => '-foo-bar-',
'foo-bar-baz' => 'foo-bar-baz',
'-foo-bar-baz' => '-foo-bar-baz',
'foo--bar' => 'foo--bar',
);
$this->assertEquals( $expected_attrs, $this->atts );
}
function test_two_atts() {
do_shortcode('[test-shortcode-tag foo="asdf" bar="bing" /]');
$this->assertEquals( array('foo' => 'asdf', 'bar' => 'bing'), $this->atts );