本文整理汇总了PHP中wp_styles函数的典型用法代码示例。如果您正苦于以下问题:PHP wp_styles函数的具体用法?PHP wp_styles怎么用?PHP wp_styles使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了wp_styles函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: zerowp_customizer_enqueue_font
function zerowp_customizer_enqueue_font($option)
{
$font_name = get_theme_mod($option);
if (empty($font_name)) {
$font_name = 'Arial';
}
if (!in_array($font_name, zerowp_customizer_standard_fonts())) {
$font_weight = get_theme_mod($option . '_weight', 400);
$font_weight = !empty($font_weight) ? $font_weight : 400;
$font_weight_in_url = !in_array(absint($font_weight), array(400, 700)) ? '400,700,' . $font_weight : '400,700';
$font_name = trim($font_name);
$handle = 'google_font_' . str_ireplace(' ', '_', $font_name);
if (!wp_style_is($handle, 'enqueued')) {
wp_register_style($handle, "//fonts.googleapis.com/css?family=" . str_ireplace(' ', '+', $font_name) . ":" . $font_weight_in_url);
wp_enqueue_style($handle);
} else {
$registered_link = wp_styles()->query($handle)->src;
if (strpos($registered_link, (string) $font_weight) === false) {
wp_deregister_style($handle);
wp_register_style($handle, $registered_link . ',' . $font_weight);
wp_enqueue_style($handle);
}
}
}
}
示例2: replace_admin_bar_style
public function replace_admin_bar_style()
{
global $wp_styles;
$wp_styles = wp_styles();
if (!isset($wp_styles->registered['admin-bar'])) {
return;
}
$this->replace_css('admin-bar', 'admin-bar.css', '');
}
示例3: enqueueInclude
public function enqueueInclude(FrontInclude $style)
{
if (defined('WP_DEBUG') && WP_DEBUG) {
$dependencies = $style->getDependency();
$scripts = wp_styles()->registered;
foreach ($dependencies as $dependency) {
if (!isset($scripts[$dependency])) {
trigger_error(sprintf('Dependency failed for %s, No style with handle %s is registered', $style->getHandle(), $dependency), E_USER_WARNING);
}
}
}
wp_enqueue_style($style->getHandle(), $style->getSrc(), $style->getDependency(), $style->getVersion(), $style->loadInFooter());
}
示例4: enqueue_scripts
function enqueue_scripts()
{
$GLOBALS['is_IE'] = false;
$wp_styles = wp_styles();
$wp_scripts = wp_scripts();
$this->plugin->enqueue_scripts();
$this->assertContains('font-awesome', $wp_styles->queue);
$this->assertContains('wpcw-admin', $wp_styles->queue);
$this->assertContains('wpcw-admin', $wp_scripts->queue);
$this->assertNotContains('wpcw-admin-ie', $wp_scripts->queue);
$GLOBALS['is_IE'] = true;
$this->plugin->enqueue_scripts();
$this->assertContains('wpcw-admin-ie', $wp_scripts->queue);
}
示例5: test_widget
function test_widget()
{
$instance = ['title' => 'test', 'labels' => ['value' => 'yes']];
$args = ['before_widget' => '<div class="widget wpcw-widget-social"><div class="widget-content">', 'after_widget' => '</div><div class="clear"></div></div>', 'before_title' => '<h3 class="widget-title">', 'after_title' => '</h3>'];
$this->expectOutputRegex('/<div class="widget wpcw-widget-social"><div class="widget-content">/');
$this->expectOutputRegex('/<h3 class="widget-title">/');
$this->plugin->widget($args, $instance);
// Tests that script & styles are enqueued enqueued
do_action('wp_enqueue_scripts');
$wp_styles = wp_styles();
// Make sure the JS file is enqueued
$this->assertContains('font-awesome', $wp_styles->queue);
$this->assertContains('wpcw', $wp_styles->queue);
}
示例6: test_widget
function test_widget()
{
$instance = ['title' => 'test', 'labels' => ['value' => 'yes'], 'map' => ['value' => 'yes'], 'address' => ['value' => '<br>123 Santa Monica<br>']];
$args = ['before_widget' => '<div class="widget wpcw-widget-contact"><div class="widget-content">', 'after_widget' => '</div><div class="clear"></div></div>', 'before_title' => '<h3 class="widget-title">', 'after_title' => '</h3>'];
$this->expectOutputRegex('/<div class="widget wpcw-widget-contact"><div class="widget-content">/');
$this->expectOutputRegex('/<h3 class="widget-title">/');
// Check that we sprint the right google url
$this->expectOutputRegex('~//www\\.google\\.com/maps\\?q=123\\+Santa\\+Monica&output=embed~');
$this->plugin->widget($args, $instance);
// Tests that script & styles are enqueued enqueued
do_action('wp_enqueue_scripts');
$wp_styles = wp_styles();
$this->assertContains('wpcw', $wp_styles->queue);
}
示例7: __construct
/**
* Init
*/
protected function __construct()
{
// init properties
$this->wp_styles = wp_styles();
$this->handles_loaded_async = get_option('bcd-css-handles', array());
$this->critical_css = get_option('bcd-critical-css', '');
// add wp hooks
add_action('wp_print_styles', array($this, 'loadCSS'));
add_filter('style_loader_tag', array($this, 'style_loader_tag'), 10, 3);
if (strlen($this->critical_css)) {
add_action('wp_print_styles', array($this, 'print_critical_css'));
}
// conditionally print debug information in the foot
if (true === filter_input(INPUT_GET, 'debugBCD', FILTER_VALIDATE_BOOLEAN)) {
add_action('wp_footer', array($this, 'footer_debug'), 9999);
}
}
示例8: register_assets
/**
* Register assets
*
* @since 0.1.0
* @wp_hook action icon_picker_loader_init
*
* @param Icon_Picker_Loader $loader Icon_Picker_Loader instance.
*
* @return void
*/
public function register_assets(Icon_Picker_Loader $loader)
{
if (empty($this->stylesheet_uri)) {
return;
}
$register = true;
$deps = false;
$styles = wp_styles();
if ($styles->query($this->stylesheet_id, 'registered')) {
$object = $styles->registered[$this->stylesheet_id];
if (version_compare($object->ver, $this->version, '<')) {
$deps = $object->deps;
wp_deregister_style($this->stylesheet_id);
} else {
$register = false;
}
}
if ($register) {
wp_register_style($this->stylesheet_id, $this->stylesheet_uri, $deps, $this->version);
}
$loader->add_style($this->stylesheet_id);
}
示例9: enqueue_preview_scripts
/**
* Enqueue preview scripts.
*
* @since 4.5.0
* @access public
*/
public function enqueue_preview_scripts()
{
wp_enqueue_script('customize-partial-refresh-preview');
$wp_scripts = wp_scripts();
$wp_styles = wp_styles();
/*
* Core does not rebuild MediaElement.js audio and video players when DOM subtrees change.
* The Jetpack Infinite Scroll handles this when a post-load event is triggered.
* Ideally this should be incorporated into Core.
*
* Hard-coded reference to a Jetpack module's event is not relevant for #coremerge.
*/
if (class_exists('Jetpack')) {
$exports = array();
$handle = 'customize-partial-jetpack-support';
$src = $this->dir_url . 'js/plugin-support/jetpack.js';
$deps = array('customize-partial-refresh-preview');
$in_footer = true;
wp_enqueue_script($handle, $src, $deps, $this->get_version(), $in_footer);
if (Jetpack::is_module_active('infinite-scroll')) {
$exports['infiniteScroll'] = array('themeSupport' => current_theme_supports('infinite-scroll'));
}
if (Jetpack::is_module('widgets')) {
$exports['widgets'] = array('scripts' => array('google-maps' => array('src' => 'https://maps.googleapis.com/maps/api/js?sensor=false'), 'contact-info-map-js' => array('src' => plugins_url('modules/widgets/contact-info/contact-info-map.js', JETPACK__PLUGIN_FILE), 'deps' => array('jquery', 'google-maps'))), 'styles' => array('contact-info-map-css' => array('src' => plugins_url('modules/widgets/contact-info/contact-info-map.css', JETPACK__PLUGIN_FILE))));
}
wp_scripts()->add_data($handle, 'data', sprintf('var _customizeSelectiveRefreshJetpackExports = %s;', wp_json_encode($exports)));
}
add_action('wp_footer', array($this, 'export_preview_data'), 1000);
}
开发者ID:rheinardkorf,项目名称:wp-customize-partial-refresh,代码行数:35,代码来源:class-wp-customize-selective-refresh.php
示例10: wp_style_is
/**
* Check whether a CSS stylesheet has been added to the queue.
*
* @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')
{
_wp_scripts_maybe_doing_it_wrong(__FUNCTION__);
return (bool) wp_styles()->query($handle, $list);
}
示例11: test_enqueue_frontend_scripts
/**
* Test enqueue frontend scripts.
*
* @see Customize_Snapshot_Manager::enqueue_frontend_scripts()
*/
function test_enqueue_frontend_scripts()
{
$this->plugin->register_scripts(wp_scripts());
$this->plugin->register_styles(wp_styles());
$manager = new Customize_Snapshot_Manager($this->plugin);
$manager->init();
$this->assertFalse(wp_script_is('customize-snapshots-frontend', 'enqueued'));
$manager->enqueue_frontend_scripts();
$this->assertFalse(wp_script_is('customize-snapshots-frontend', 'enqueued'));
$_REQUEST['customize_snapshot_uuid'] = self::UUID;
$manager = new Customize_Snapshot_Manager($this->plugin);
$manager->init();
$this->assertFalse(wp_script_is('customize-snapshots-frontend', 'enqueued'));
$manager->enqueue_frontend_scripts();
$this->assertTrue(wp_script_is('customize-snapshots-frontend', 'enqueued'));
}
示例12: register_assets
/**
* Register assets
*
* @since 0.1.0
* @wp_hook action icon_picker_loader_init
*
* @param Icon_Picker_Loader $loader Icon_Picker_Loader instance.
*
* @return void
*/
public function register_assets(Icon_Picker_Loader $loader)
{
if (empty($this->stylesheet_uri)) {
return;
}
$register = true;
$deps = false;
$styles = wp_styles();
/**
* When the stylesheet ID of an icon type is already registered,
* we'll compare its version with ours. If our stylesheet has greater
* version number, we'll deregister the other stylesheet.
*/
if ($styles->query($this->stylesheet_id, 'registered')) {
$object = $styles->registered[$this->stylesheet_id];
if (version_compare($object->ver, $this->version, '<')) {
$deps = $object->deps;
wp_deregister_style($this->stylesheet_id);
} else {
$register = false;
}
}
if ($register) {
wp_register_style($this->stylesheet_id, $this->stylesheet_uri, $deps, $this->version);
}
$loader->add_style($this->stylesheet_id);
}
示例13: cacsp_asset_enqueue_handler
/**
* Asset enqueue handler on single social paper pages.
*
* Removes all styles except the most pertinent ones.
*
* @todo maybe do the same for scripts?
*/
function cacsp_asset_enqueue_handler()
{
if (!cacsp_is_page() || is_404()) {
return;
}
$styles = wp_styles();
// wipe out all styles and only enqueue the ones we need
$styles->queue = array('social-paper-single', 'side-comments-style', 'side-comments-theme', 'incom-style', 'media-views', 'wp-core-ui-colors', 'buttons', 'wp-auth-check', 'fee-modal', 'fee-link-modal', 'tinymce-core', 'tinymce-view', 'fee', 'dashicons', 'admin-bar', 'fee-adminbar');
// enqueue our styles
wp_enqueue_style('social-paper-single', Social_Paper::$URL . '/assets/css/single.css');
wp_enqueue_style('social-paper-single-print', Social_Paper::$URL . '/assets/css/print.css', array('social-paper-single'), '0.1', 'print');
if (function_exists('bp_is_active') && bp_is_active('groups')) {
$select2_css_url = set_url_scheme('http://cdnjs.cloudflare.com/ajax/libs/select2/4.0.0/css/select2.min.css');
wp_enqueue_style('social-paper-select2', $select2_css_url);
}
// Register scripts.
$sp_js_deps = array('jquery');
if (function_exists('bp_is_active') && bp_is_active('groups')) {
$select2_js_url = set_url_scheme('http://cdnjs.cloudflare.com/ajax/libs/select2/4.0.0/js/select2.js');
wp_register_script('social-paper-select2', $select2_js_url, array('jquery'));
$sp_js_deps[] = 'social-paper-select2';
}
wp_enqueue_script('social-paper-single', Social_Paper::$URL . '/assets/js/single.js', $sp_js_deps);
wp_localize_script('social-paper-single', 'SocialPaperL18n', array('group_placeholder' => __('Enter a group name', 'social-paper'), 'reader_placeholder' => __('Enter a user name', 'social-paper')));
}
示例14: get_include_style
/**
* Get Style List
*
* @since 4.0.0
*/
private function get_include_style()
{
return $this->add_suffix('.css', wp_styles()->queue);
}
示例15: test_customize_controls_enqueue_scripts
/**
* @see Customize_Concurrency::customize_controls_enqueue_scripts()
*/
function test_customize_controls_enqueue_scripts()
{
$this->plugin->register_scripts(wp_scripts());
$this->plugin->register_styles(wp_styles());
$instance = new Customize_Concurrency($this->plugin);
$instance->customize_controls_enqueue_scripts();
$this->assertTrue(wp_script_is($this->plugin->slug, 'enqueued'));
$this->assertTrue(wp_style_is($this->plugin->slug, 'enqueued'));
$this->assertEquals(1, has_action('customize_controls_print_footer_scripts', array($instance, 'export_js_data')));
}