Changeset 38504
- Timestamp:
- 09/01/2016 11:59:59 PM (8 years ago)
- Location:
- trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/functions.php
r38470 r38504 3343 3343 } 3344 3344 3345 /** 3346 * Filter all the smilies. 3347 * 3348 * This filter must be added before `smilies_init` is run, as 3349 * it is normally only run once to setup the smilies regex. 3350 * 3351 * @since 4.6.0 3352 * 3353 * @param array $wpsmiliestrans List of the smilies. 3354 */ 3355 $wpsmiliestrans = apply_filters('smilies', $wpsmiliestrans); 3356 3345 3357 if (count($wpsmiliestrans) == 0) { 3346 3358 return; -
trunk/tests/phpunit/tests/formatting/Smilies.php
r37296 r38504 313 313 update_option( 'use_smilies', 0 ); 314 314 } 315 316 /** 317 * Test to ensure smilies can be removed with a filter 318 * 319 * @ticket 35905 320 */ 321 public function test_smilies_filter_removes_smilies() { 322 add_filter( 'smilies', array( $this, '_filter_remove_smilies' ) ); 323 smilies_init(); 324 remove_filter( 'smilies', array( $this, '_filter_remove_smilies' ) ); 325 326 $txt = ':oops: I did it again'; 327 328 $this->assertEquals( $txt, convert_smilies( $txt ) ); 329 } 330 331 /** 332 * Test to ensure smilies can be added with a filter 333 * 334 * @ticket 35905 335 */ 336 public function test_smilies_filter_adds_smilies() { 337 add_filter( 'smilies', array( $this, '_filter_add_smilies' ) ); 338 smilies_init(); 339 remove_filter( 'smilies', array( $this, '_filter_add_smilies' ) ); 340 341 $txt = 'You played with my <3'; 342 $expected_txt = 'You played with my \xe2\x9d\xa4'; 343 344 $this->assertEquals( $expected_txt, convert_smilies( $txt ) ); 345 } 346 347 348 public function _filter_remove_smilies( $wpsmiliestrans ) { 349 unset( $wpsmiliestrans[':oops:'] ); 350 return $wpsmiliestrans; 351 } 352 353 public function _filter_add_smilies( $wpsmiliestrans ) { 354 $wpsmiliestrans['<3'] = '\xe2\x9d\xa4'; 355 return $wpsmiliestrans; 356 } 315 357 }
Note: See TracChangeset
for help on using the changeset viewer.