mirror of
https://github.com/gosticks/wordpress-develop.git
synced 2025-10-16 12:05:38 +00:00
The whole string is escaped with `esc_html()` anyway, so we don't need to `wp_kses_post()`. This is a better experience for users who want to use angle brackets in their site title or description. Does not allow any HTML, adds unit tests. props BandonRandon, pauldewouters. fixes #27942. git-svn-id: https://develop.svn.wordpress.org/trunk@35788 602fd350-edb4-49c9-b593-d223f7449a82
74 lines
1.9 KiB
PHP
74 lines
1.9 KiB
PHP
<?php
|
|
|
|
/**
|
|
* @group formatting
|
|
*/
|
|
class Tests_Formatting_BlogInfo extends WP_UnitTestCase {
|
|
|
|
/**
|
|
* @dataProvider locales
|
|
* @ticket 28303
|
|
*/
|
|
function test_get_bloginfo_language( $test_locale, $expected ) {
|
|
global $locale;
|
|
|
|
$old_locale = $locale;
|
|
|
|
$locale = $test_locale;
|
|
$this->assertEquals( $expected, get_bloginfo( 'language' ) );
|
|
|
|
$locale = $old_locale;
|
|
}
|
|
|
|
function locales() {
|
|
return array(
|
|
// Locale Language code
|
|
array( 'en_US', 'en-US' ),
|
|
array( 'ar', 'ar' ),
|
|
array( 'de_DE', 'de-DE' ),
|
|
array( 'de_DE_formal', 'de-DE-formal' ),
|
|
array( 'oci', 'oci' ),
|
|
array( 'pt_PT_ao1990', 'pt-PT-ao1990' ),
|
|
);
|
|
}
|
|
|
|
/**
|
|
* @ticket 27942
|
|
*/
|
|
function test_bloginfo_sanitize_option() {
|
|
$old_values = array(
|
|
'blogname' => get_option( 'blogname' ),
|
|
'blogdescription' => get_option( 'blogdescription' ),
|
|
);
|
|
|
|
$values = array(
|
|
'foo' => 'foo',
|
|
'<em>foo</em>' => '<em>foo</em>',
|
|
'<script>foo</script>' => '<script>foo</script>',
|
|
'<foo>' => '<foo>',
|
|
'<foo' => '<foo',
|
|
);
|
|
|
|
foreach ( $values as $value => $expected ) {
|
|
$sanitized_value = sanitize_option( 'blogname', $value );
|
|
update_option( 'blogname', $sanitized_value );
|
|
|
|
$this->assertEquals( $expected, $sanitized_value );
|
|
$this->assertEquals( $expected, get_bloginfo( 'name' ) );
|
|
$this->assertEquals( $expected, get_bloginfo( 'name', 'display' ) );
|
|
|
|
$sanitized_value = sanitize_option( 'blogdescription', $value );
|
|
update_option( 'blogdescription', $sanitized_value );
|
|
|
|
$this->assertEquals( $expected, $sanitized_value );
|
|
$this->assertEquals( $expected, get_bloginfo( 'description' ) );
|
|
$this->assertEquals( $expected, get_bloginfo( 'description', 'display' ) );
|
|
}
|
|
|
|
// Restore old values.
|
|
foreach ( $old_values as $option_name => $value ) {
|
|
update_option( $option_name, $value );
|
|
}
|
|
}
|
|
}
|