wp_admin_css
函数
wp_admin_css ( $file = 'wp-admin', $force_echo = false )
- 参数
-
-
(string)
$file
Optional. Style handle name or file name (without “.css” extension) relative to wp-admin/. Defaults to ‘wp-admin’.- Required: 否
- Default: ‘wp-admin’
-
(bool)
$force_echo
Optional. Force the stylesheet link to be printed rather than enqueued.- Required: 否
- Default: false
-
(string)
- 定义位置
-
-
wp-includes/general-template.php
, line 4865
-
wp-includes/general-template.php
- 引入
- 2.3.0
- 弃用
- –
Enqueues or directly prints a stylesheet link to the specified CSS file.
“Intelligently” decides to enqueue or to print the CSS file. If the
{@see ‘wp_print_styles’} action has *not* yet been called, the CSS file will be
enqueued. If the {@see ‘wp_print_styles’} action has been called, the CSS link will
be printed. Printing may be forced by passing true as the $force_echo
(second) parameter.
For backward compatibility with WordPress 2.3 calling method: If the $file
(first) parameter does not correspond to a registered CSS file, we assume
$file is a file relative to wp-admin/ without its “.css” extension. A
stylesheet link to that generated URL is printed.
function wp_admin_css( $file = 'wp-admin', $force_echo = false ) {
// For backward compatibility.
$handle = 0 === strpos( $file, 'css/' ) ? substr( $file, 4 ) : $file;
if ( wp_styles()->query( $handle ) ) {
if ( $force_echo || did_action( 'wp_print_styles' ) ) {
// We already printed the style queue. Print this one immediately.
wp_print_styles( $handle );
} else {
// Add to style queue.
wp_enqueue_style( $handle );
}
return;
}
$stylesheet_link = sprintf(
"n",
esc_url( wp_admin_css_uri( $file ) )
);
/**
* Filters the stylesheet link to the specified CSS file.
*
* If the site is set to display right-to-left, the RTL stylesheet link
* will be used instead.
*
* @since 2.3.0
* @param string $stylesheet_link HTML link element for the stylesheet.
* @param string $file Style handle name or filename (without ".css" extension)
* relative to wp-admin/. Defaults to 'wp-admin'.
*/
echo apply_filters( 'wp_admin_css', $stylesheet_link, $file );
if ( function_exists( 'is_rtl' ) && is_rtl() ) {
$rtl_stylesheet_link = sprintf(
"n",
esc_url( wp_admin_css_uri( "$file-rtl" ) )
);
/** This filter is documented in wp-includes/general-template.php */
echo apply_filters( 'wp_admin_css', $rtl_stylesheet_link, "$file-rtl" );
}
}
声明:本站所有文章,如无特殊说明或标注,均为本站原创发布。任何个人或组织,在未征得本站同意时,禁止复制、盗用、采集、发布本站内容到任何网站、书籍等各类媒体平台。如若本站内容侵犯了原著者的合法权益,可联系我们进行处理。


