本文整理汇总了PHP中WP_Styles::query方法的典型用法代码示例。如果您正苦于以下问题:PHP WP_Styles::query方法的具体用法?PHP WP_Styles::query怎么用?PHP WP_Styles::query使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类WP_Styles
的用法示例。
在下文中一共展示了WP_Styles::query方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1:
function wp_style_is($handle, $list = 'queue')
{
global $wp_styles;
if (!is_a($wp_styles, 'WP_Scripts')) {
$wp_styles = new WP_Styles();
}
$query = $wp_styles->query($handle, $list);
if (is_object($query)) {
return true;
}
return $query;
}
示例2: wp_admin_css
/**
* Enqueues or directly prints a stylesheet link to the specified CSS file.
*
* "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 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.
*
* @since 2.3.0
* @uses $wp_styles WordPress Styles Object
*
* @param string $file Optional. Style handle name or file name (without ".css" extension) relative
* to wp-admin/. Defaults to 'wp-admin'.
* @param bool $force_echo Optional. Force the stylesheet link to be printed rather than enqueued.
*/
function wp_admin_css($file = 'wp-admin', $force_echo = false)
{
global $wp_styles;
if (!$wp_styles instanceof WP_Styles) {
$wp_styles = new WP_Styles();
}
// 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;
}
/**
* Filter 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 $file Style handle name or filename (without ".css" extension)
* relative to wp-admin/. Defaults to 'wp-admin'.
*/
echo apply_filters('wp_admin_css', "<link rel='stylesheet' href='" . esc_url(wp_admin_css_uri($file)) . "' type='text/css' />\n", $file);
if (function_exists('is_rtl') && is_rtl()) {
/** This filter is documented in wp-includes/general-template.php */
echo apply_filters('wp_admin_css', "<link rel='stylesheet' href='" . esc_url(wp_admin_css_uri("{$file}-rtl")) . "' type='text/css' />\n", "{$file}-rtl");
}
}
示例3: wp_admin_css
/**
* Enqueues or directly prints a stylesheet link to the specified CSS file.
*
* "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 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.
*
* @package WordPress
* @since 2.3.0
* @uses $wp_styles WordPress Styles Object
*
* @param string $file Optional. Style handle name or file name (without ".css" extension) relative
* to wp-admin/. Defaults to 'wp-admin'.
* @param bool $force_echo Optional. Force the stylesheet link to be printed rather than enqueued.
*/
function wp_admin_css($file = 'wp-admin', $force_echo = false)
{
global $wp_styles;
if (!is_a($wp_styles, 'WP_Styles')) {
$wp_styles = new WP_Styles();
}
// 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;
}
echo apply_filters('wp_admin_css', "<link rel='stylesheet' href='" . esc_url(wp_admin_css_uri($file)) . "' type='text/css' />\n", $file);
if (function_exists('is_rtl') && is_rtl()) {
echo apply_filters('wp_admin_css', "<link rel='stylesheet' href='" . esc_url(wp_admin_css_uri("{$file}-rtl")) . "' type='text/css' />\n", "{$file}-rtl");
}
}
示例4: wp_style_is
/**
* Check whether a CSS stylesheet has been added to the queue.
*
* @global WP_Styles $wp_styles The WP_Styles object for printing styles.
*
* @since 2.8.0
*
* @param string $handle Name of the stylesheet.
* @param string $list Optional. Status of the stylesheet to check. Default 'enqueued'.
* Accepts 'enqueued', 'registered', 'queue', 'to_do', and 'done'.
* @return bool Whether style is queued.
*/
function wp_style_is($handle, $list = 'enqueued')
{
global $wp_styles;
if (!is_a($wp_styles, 'WP_Styles')) {
if (!did_action('init')) {
_doing_it_wrong(__FUNCTION__, sprintf(__('Scripts and styles should not be registered or enqueued until the %1$s, %2$s, or %3$s hooks.'), '<code>wp_enqueue_scripts</code>', '<code>admin_enqueue_scripts</code>', '<code>login_enqueue_scripts</code>'), '3.3');
}
$wp_styles = new WP_Styles();
}
return (bool) $wp_styles->query($handle, $list);
}
示例5: wp_admin_css
/**
* Enqueues or directly prints a stylesheet link to the specified CSS file.
*
* "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 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.
*
* @package WordPress
* @since 2.3.0
* @uses $wp_styles WordPress Styles Object
*
* @param string $file Style handle name or file name (without ".css" extension) relative to wp-admin/
* @param bool $force_echo Optional. Force the stylesheet link to be printed rather than enqueued.
*/
function wp_admin_css( $file = 'wp-admin', $force_echo = false ) {
global $wp_styles;
if ( !is_a($wp_styles, 'WP_Styles') )
$wp_styles = new WP_Styles();
// 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;
}
echo apply_filters( 'wp_admin_css', "<link rel='stylesheet' href='" . clean_url( wp_admin_css_uri( $file ) ) . "' type='text/css' />\n", $file );
if ( 'rtl' == get_bloginfo( 'text_direction' ) )
echo apply_filters( 'wp_admin_css', "<link rel='stylesheet' href='" . clean_url( wp_admin_css_uri( "$file-rtl" ) ) . "' type='text/css' />\n", "$file-rtl" );
}
示例6: wp_style_is
/**
* Check whether style has been added to WordPress Styles.
*
* The values for list defaults to 'queue', which is the same as wp_enqueue_style().
*
* @since WP unknown; BP unknown
* @global object $wp_styles The WP_Styles object for printing styles.
*
* @param string $handle Name of the stylesheet.
* @param string $list Values are 'registered', 'done', 'queue' and 'to_do'.
* @return bool True on success, false on failure.
*/
function wp_style_is( $handle, $list = 'queue' ) {
global $wp_styles;
if ( ! is_a( $wp_styles, 'WP_Styles' ) ) {
if ( ! did_action( 'init' ) )
_doing_it_wrong( __FUNCTION__, sprintf( __( 'Scripts and styles should not be registered or enqueued until the %1$s, %2$s, or %3$s hooks.' ),
'<code>wp_enqueue_scripts</code>', '<code>admin_enqueue_scripts</code>', '<code>init</code>' ), '3.3' );
$wp_styles = new WP_Styles();
}
$query = $wp_styles->query( $handle, $list );
if ( is_object( $query ) )
return true;
return $query;
}