Styles: Clarify the allowed values for the $media
parameter of wp_register_style()
/wp_enqueue_style()
.
Adds unit test. Fixes #35921. git-svn-id: https://develop.svn.wordpress.org/trunk@36649 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
parent
3039740a3a
commit
3a836ea224
@ -106,8 +106,9 @@ function wp_add_inline_style( $handle, $data ) {
|
||||
* @param string|bool $ver String specifying the stylesheet version number. Used to ensure that the correct version
|
||||
* is sent to the client regardless of caching. Default 'false'. Accepts 'false', 'null', or 'string'.
|
||||
* @param string $media Optional. The media for which this stylesheet has been defined.
|
||||
* Default 'all'. Accepts 'all', 'aural', 'braille', 'handheld', 'projection', 'print',
|
||||
* 'screen', 'tty', or 'tv'.
|
||||
* Default 'all'. Accepts media types like 'all', 'print' and 'screen', or media queries like
|
||||
* '(orientation: portrait)' and '(max-width: 640px)'.
|
||||
*
|
||||
* @return bool Whether the style has been registered. True on success, false on failure.
|
||||
*/
|
||||
function wp_register_style( $handle, $src, $deps = array(), $ver = false, $media = 'all' ) {
|
||||
@ -149,8 +150,8 @@ function wp_deregister_style( $handle ) {
|
||||
* to ensure that the correct version is sent to the client regardless of caching, and so
|
||||
* should be included if a version number is available and makes sense for the stylesheet.
|
||||
* @param string $media Optional. The media for which this stylesheet has been defined.
|
||||
* Default 'all'. Accepts 'all', 'aural', 'braille', 'handheld', 'projection', 'print',
|
||||
* 'screen', 'tty', or 'tv'.
|
||||
* Default 'all'. Accepts media types like 'all', 'print' and 'screen', or media queries like
|
||||
* '(orientation: portrait)' and '(max-width: 640px)'.
|
||||
*/
|
||||
function wp_enqueue_style( $handle, $src = false, $deps = array(), $ver = false, $media = 'all' ) {
|
||||
_wp_scripts_maybe_doing_it_wrong( __FUNCTION__ );
|
||||
|
@ -261,4 +261,41 @@ CSS;
|
||||
$this->assertEquals( $expected, get_echo( 'wp_print_styles' ) );
|
||||
}
|
||||
|
||||
/**
|
||||
* @ticket 35921
|
||||
* @dataProvider data_styles_with_media
|
||||
*/
|
||||
function test_wp_enqueue_style_with_media( $expected, $media ) {
|
||||
wp_enqueue_style( 'handle', 'http://example.com', array(), 1, $media );
|
||||
$this->assertContains( $expected, get_echo( 'wp_print_styles' ) );
|
||||
}
|
||||
|
||||
function data_styles_with_media() {
|
||||
return array(
|
||||
array(
|
||||
"media='all'",
|
||||
'all'
|
||||
),
|
||||
array(
|
||||
"media='(orientation: portrait)'",
|
||||
'(orientation: portrait)'
|
||||
),
|
||||
array(
|
||||
"media='(max-width: 640px)'",
|
||||
'(max-width: 640px)'
|
||||
),
|
||||
array(
|
||||
"media='print and (min-width: 25cm)'",
|
||||
'print and (min-width: 25cm)'
|
||||
),
|
||||
array(
|
||||
"media='screen and (color), projection and (color)'",
|
||||
'screen and (color), projection and (color)'
|
||||
),
|
||||
array(
|
||||
"media='not screen and (color)'",
|
||||
'not screen and (color)'
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user