| | 197 | |
| | 198 | /** |
| | 199 | * Registered shortcodes shouldn't have their content texturized; developers should texturize |
| | 200 | * shortcode content within their handler manually. |
| | 201 | * |
| | 202 | * @ticket 6969 |
| | 203 | */ |
| | 204 | function test_shortcode_exclusion() { |
| | 205 | // The only core shortcode that wraps content is [caption]. Other core shortcodes use parameters rather than a wrap. |
| | 206 | $unfiltered_content = array ( |
| | 207 | 'caption' => '[caption]<img src="http://localhost/Great_Wave.jpg" alt="Great Wave" title="Great Wave" width="300" height="205" /> The Great Wave[/caption]', |
| | 208 | 'code' => '[code lang="php"]$foo = \'bar\';[/code]', // [code] isn't a core shortcode, but was used as an example in the original Trac ticket. |
| | 209 | 'foobar' => '[foobar]This is how you "quote" things.[/foobar]', // [foobar] was used as an example in a documented workaround (written by @viper007bond) |
| | 210 | ); |
| | 211 | |
| | 212 | // Register our foobar and code shortcodes so they exist |
| | 213 | add_shortcode( 'code', array( $this, '_dummy_shortcode' ) ); |
| | 214 | add_shortcode( 'foobar', array( $this, '_dummy_shortcode' ) ); |
| | 215 | |
| | 216 | // Act |
| | 217 | |
| | 218 | $texturized_content = array(); |
| | 219 | foreach( $unfiltered_content as $key => $value ) { |
| | 220 | $texturized_content[ $key ] = wptexturize( $value ); |
| | 221 | } |
| | 222 | |
| | 223 | // Verify |
| | 224 | foreach( $unfiltered_content as $key => $value ) { |
| | 225 | // Shortcodes should be entirely untouched by wptexturize() |
| | 226 | $this->assertEquals( $value, $texturized_content[ $key ] ); |
| | 227 | } |
| | 228 | } |
| | 229 | |
| | 230 | function _dummy_shortcode( $atts, $content = '' ) { |
| | 231 | return $content; |
| | 232 | } |