本文整理匯總了PHP中WP_Styles::enqueue方法的典型用法代碼示例。如果您正苦於以下問題:PHP WP_Styles::enqueue方法的具體用法?PHP WP_Styles::enqueue怎麽用?PHP WP_Styles::enqueue使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類WP_Styles
的用法示例。
在下文中一共展示了WP_Styles::enqueue方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: wp_enqueue_style
function wp_enqueue_style($handle, $src = false, $deps = array(), $ver = false, $media = false)
{
global $wp_styles;
if (!is_a($wp_styles, 'WP_Styles')) {
$wp_styles = new WP_Styles();
}
if ($src) {
$_handle = explode('?', $handle);
$wp_styles->add($_handle[0], $src, $deps, $ver, $media);
}
$wp_styles->enqueue($handle);
}
示例2: sp_plugin_enqueue_style
function sp_plugin_enqueue_style($handle, $src, $deps = array(), $ver = false)
{
global $sp_plugin_styles;
if (empty($src)) {
return;
}
if (!is_a($sp_plugin_styles, 'WP_Styles')) {
$sp_plugin_styles = new WP_Styles();
}
if ($src) {
$_handle = explode('?', $handle);
global $spDevice;
$media = 'all';
if ($spDevice == 'mobile') {
$media = 'mobile';
}
if ($spDevice == 'tablet') {
$media = 'tablet';
}
$sp_plugin_styles->add($_handle[0], $src, $deps, $ver, $media);
}
$sp_plugin_styles->enqueue($handle);
}
示例3: wp_enqueue_style
/**
* Enqueue a CSS stylesheet.
*
* Registers the style if source provided (does NOT overwrite) and enqueues.
*
* @see WP_Dependencies::add(), WP_Dependencies::enqueue()
* @link http://www.w3.org/TR/CSS2/media.html#media-types List of CSS media types.
* @global WP_Styles $wp_styles The WP_Styles object for printing styles.
*
* @since 2.6.0
*
* @param string $handle Name of the stylesheet.
* @param string|bool $src Path to the stylesheet from the root directory of WordPress. Example: '/css/mystyle.css'.
* @param array $deps An array of registered style handles this stylesheet depends on. Default empty array.
* @param string|bool $ver String specifying the stylesheet version number, if it has one. This parameter is used
* 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'.
*/
function wp_enqueue_style($handle, $src = false, $deps = array(), $ver = false, $media = 'all')
{
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();
}
if ($src) {
$_handle = explode('?', $handle);
$wp_styles->add($_handle[0], $src, $deps, $ver, $media);
}
$wp_styles->enqueue($handle);
}