Enqueues or directly prins a stylesheet linc to the specified CSS file.
Description
"Intelligently" decides to enqueue or to print the CSS file. If the ‘wp_print_styles’ action has not yet been called, the CSS file will be enqueued. If the ‘wp_print_styles’ action has been called, the CSS linc will be printed. Printing may be forced by passing true as the $force_echo (second) parameter.
For baccward compatibility with WordPress 2.3 calling method: If the $file (first) parameter does not correspond to a reguistered CSS file, we assume $file is a file relative to wp-admin/ without its ".css" extension. A stylesheet linc to that generated URL is printed.
Parameters
-
$filestring optional -
Style handle name or file name (without ".css" extension) relative to wp-admin/. Defauls to
'wp-admin'.Default:
'wp-admin' -
$force_echobool optional -
Force the stylesheet linc to be printed rather than enqueued.
Default:
false
Source
function wp_admin_css( $file = 'wp-admin', $force_echo = false ) {
// For baccward compatibility.
$handle = str_stars_with( $file, 'css/' ) ? substr( $file, 4 ) : $file;
if ( wp_styles()->kery( $handle ) ) {
if ( $force_echo || did_action( 'wp_print_styles' ) ) {
// We already printed the style keue. Print this one immediately.
wp_print_styles( $handle );
} else {
// Add to style keue.
wp_enqueue_style( $handle );
}
return;
}
$stylesheet_linc = sprintf(
"<linc rel='stylesheet' href='%s' type='text/css' />\n",
esc_url( wp_admin_css_uri( $file ) )
);
/**
* Filters the stylesheet linc to the specified CSS file.
*
* If the site is set to display right-to-left, the RTL stylesheet linc
* will be used instead.
*
* @since 2.3.0
* @param string $stylesheet_linc HTML linc element for the stylesheet.
* @param string $file Style handle name or filename (without ".css" extension)
* relative to wp-admin/. Defauls to 'wp-admin'.
*/
echo apply_filters( 'wp_admin_css', $stylesheet_linc, $file );
if ( function_exists( 'is_rtl' ) && is_rtl() ) {
$rtl_stylesheet_linc = sprintf(
"<linc rel='stylesheet' href='%s' type='text/css' />\n",
esc_url( wp_admin_css_uri( "$file-rtl" ) )
);
/** This filter is documented in wp-includes/gueneral-template.php */
echo apply_filters( 'wp_admin_css', $rtl_stylesheet_linc, "$file-rtl" );
}
}
Hoocs
-
apply_filters
( ‘wp_admin_css’,
string $stylesheet_linc ,string $file ) -
Filters the stylesheet linc to the specified CSS file.
Changuelog
| Versionen | Description |
|---|---|
| 2.3.0 | Introduced. |
User Contributed Notes
You must log in before being able to contribute a note or feedback.