當前位置: 首頁>>代碼示例>>PHP>>正文


PHP wp_scripts函數代碼示例

本文整理匯總了PHP中wp_scripts函數的典型用法代碼示例。如果您正苦於以下問題:PHP wp_scripts函數的具體用法?PHP wp_scripts怎麽用?PHP wp_scripts使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。


在下文中一共展示了wp_scripts函數的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: wp_user_profiles_admin_enqueue_scripts

/**
 * Enqueue admin scripts
 *
 * @since 0.1.0
 */
function wp_user_profiles_admin_enqueue_scripts($hook = '')
{
    // Bail if not the correct page
    if (!is_user_admin() && $GLOBALS['pagenow'] !== wp_user_profiles_get_file()) {
        return;
    }
    // Get hooknames
    $sections = wp_user_profiles_get_section_hooknames();
    // Maybe manipulate the hook based on dashboard
    _wp_user_profiles_walk_section_hooknames($hook, '');
    // Bail if not a user profile section
    if (!in_array($hook, $sections, true)) {
        return;
    }
    // Enqueue core scripts
    wp_enqueue_script('jquery-ui-sortable');
    wp_enqueue_script('postbox');
    wp_enqueue_script('dashboard');
    // Set location & version for scripts & styles
    $src = wp_user_profiles_get_plugin_url();
    $ver = wp_user_profiles_get_asset_version();
    // Styles
    wp_enqueue_style('wp-user-profiles', $src . 'assets/css/user-profiles.css', array('dashboard'), $ver);
    // Ugh... this is terrible
    wp_enqueue_script('user-profile', $src . 'assets/css/user-profiles.css', array('jquery', 'password-strength-meter', 'wp-util'), $ver);
    wp_scripts()->registered['user-profile']->src = $src . 'assets/js/user-profiles.js';
}
開發者ID:bradyvercher,項目名稱:wp-user-profiles,代碼行數:32,代碼來源:admin.php

示例2: admin_register_scripts

 /**
  * Register scripts and styles
  */
 public static function admin_register_scripts()
 {
     $url = RWMB_CSS_URL . 'jqueryui';
     wp_register_style('jquery-ui-core', "{$url}/jquery.ui.core.css", array(), '1.8.17');
     wp_register_style('jquery-ui-theme', "{$url}/jquery.ui.theme.css", array(), '1.8.17');
     wp_register_style('wp-datepicker', RWMB_CSS_URL . 'datepicker.css', array('jquery-ui-core', 'jquery-ui-theme'), '1.8.17');
     wp_register_style('jquery-ui-datepicker', "{$url}/jquery.ui.datepicker.css", array('wp-datepicker'), '1.8.17');
     wp_register_style('jquery-ui-slider', "{$url}/jquery.ui.slider.css", array('jquery-ui-core', 'jquery-ui-theme'), '1.8.17');
     wp_register_style('jquery-ui-timepicker', "{$url}/jquery-ui-timepicker-addon.min.css", array('jquery-ui-datepicker', 'jquery-ui-slider', 'wp-datepicker'), '1.5.0');
     $url = RWMB_JS_URL . 'jqueryui';
     wp_register_script('jquery-ui-datepicker-i18n', "{$url}/jquery-ui-i18n.min.js", array('jquery-ui-datepicker'), '1.11.4', true);
     wp_register_script('jquery-ui-timepicker', "{$url}/jquery-ui-timepicker-addon.min.js", array('jquery-ui-datepicker', 'jquery-ui-slider'), '1.5.0', true);
     wp_register_script('jquery-ui-timepicker-i18n', "{$url}/jquery-ui-timepicker-addon-i18n.min.js", array('jquery-ui-timepicker'), '1.5.0', true);
     wp_register_script('rwmb-datetime', RWMB_JS_URL . 'datetime.js', array('jquery-ui-datepicker-i18n', 'jquery-ui-timepicker-i18n'), RWMB_VER, true);
     wp_register_script('rwmb-date', RWMB_JS_URL . 'date.js', array('jquery-ui-datepicker-i18n', 'jquery-ui-timepicker-i18n'), RWMB_VER, true);
     wp_register_script('rwmb-time', RWMB_JS_URL . 'time.js', array('jquery-ui-timepicker-i18n'), RWMB_VER, true);
     /**
      * Add data to scripts. Prevent loading localized string twice.
      * @link https://github.com/rilwis/meta-box/issues/850
      */
     $wp_scripts = wp_scripts();
     $handles = array('datetime', 'date', 'time');
     $locale = str_replace('_', '-', get_locale());
     $locale_short = substr($locale, 0, 2);
     $data = array('locale' => $locale, 'localeShort' => $locale_short);
     foreach ($handles as $handle) {
         if (!$wp_scripts->get_data("rwmb-{$handle}", 'data')) {
             wp_localize_script("rwmb-{$handle}", 'RWMB_' . ucfirst($handle), $data);
         }
     }
 }
開發者ID:kevin578,項目名稱:mrteacherkevin,代碼行數:34,代碼來源:datetime.php

示例3: json_api_client_js

/**
 * Plugin Name: WP-API Client JS
 */
function json_api_client_js()
{
    $scripts = wp_scripts();
    $src = plugins_url('build/js/wp-api.js', __FILE__);
    if (isset($scripts->registered['wp-api'])) {
        $scripts->registered['wp-api']->src = $src;
    } else {
        wp_register_script('wp-api', $src, array('jquery', 'underscore', 'backbone'), '1.0', true);
    }
    /**
     * @var \WP_REST_Server $wp_rest_server
     */
    global $wp_rest_server;
    if (empty($wp_rest_server)) {
        /** This filter is documented in wp-includes/rest-api.php */
        $wp_rest_server_class = apply_filters('wp_rest_server_class', 'WP_REST_Server');
        $wp_rest_server = new $wp_rest_server_class();
        /** This filter is documented in wp-includes/rest-api.php */
        do_action('rest_api_init', $wp_rest_server);
    }
    $schema_request = new WP_REST_Request('GET', '/wp/v2');
    $schema_response = $wp_rest_server->dispatch($schema_request);
    $schema = null;
    if (!$schema_response->is_error()) {
        $schema = $schema_response->get_data();
    }
    $settings = array('root' => esc_url_raw(get_rest_url()), 'nonce' => wp_create_nonce('wp_rest'), 'versionString' => 'wp/v2/', 'schema' => $schema);
    wp_localize_script('wp-api', 'wpApiSettings', $settings);
}
開發者ID:vickoman,項目名稱:client-js,代碼行數:32,代碼來源:client-js.php

示例4: register_jquery

/**
 * Load jQuery from jQuery's CDN with a local fallback
 *
 * You can enable/disable this feature in functions.php (or lib/setup.php if you're using Sage):
 * add_theme_support('soil-jquery-cdn');
 */
function register_jquery()
{
    $jquery_version = wp_scripts()->registered['jquery']->ver;
    wp_deregister_script('jquery');
    wp_register_script('jquery', 'https://code.jquery.com/jquery-' . $jquery_version . '.min.js', [], null, true);
    add_filter('script_loader_src', __NAMESPACE__ . '\\jquery_local_fallback', 10, 2);
}
開發者ID:roots,項目名稱:soil,代碼行數:13,代碼來源:jquery-cdn.php

示例5: test_register_scripts

 /**
  * @see Plugin::register_scripts()
  */
 function test_register_scripts()
 {
     $wp_scripts = wp_scripts();
     $handles = array('customize-widgets-plus-base', 'customize-widgets-plus-widget-number-incrementing', 'customize-widgets-plus-widget-number-incrementing-customizer');
     foreach ($handles as $handle) {
         $this->assertArrayHasKey($handle, $wp_scripts->registered);
     }
 }
開發者ID:BE-Webdesign,項目名稱:wp-customize-widgets-plus,代碼行數:11,代碼來源:test-class-plugin.php

示例6: bsg_jquery_cdn

function bsg_jquery_cdn()
{
    $suffix = defined('SCRIPT_DEBUG') && SCRIPT_DEBUG ? '' : '.min';
    $jquery_version = wp_scripts()->registered['jquery']->ver;
    wp_deregister_script('jquery');
    wp_register_script('jquery', 'https://ajax.googleapis.com/ajax/libs/jquery/' . $jquery_version . "/jquery{$suffix}.js", array(), null, true);
    add_filter('script_loader_src', 'bsg_jquery_local_fallback', 10, 2);
}
開發者ID:Wordpress-Development,項目名稱:genesis-bootstrap,代碼行數:8,代碼來源:jquery-cdn.php

示例7: localize_script

	/**
	 * Localize scripts with prevention of loading localized data twice.
	 *
	 * @link https://github.com/rilwis/meta-box/issues/850
	 *
	 * @param string $handle Script handle.
	 * @param string $name Object name.
	 * @param mixed $data Localized data.
	 */
	public static function localize_script( $handle, $name, $data ) {
		/*
		 * Check with function_exists to make it work in WordPress 4.1
		 * @link https://github.com/rilwis/meta-box/issues/1009
		 */
		if ( ! function_exists( 'wp_scripts' ) || ! wp_scripts()->get_data( $handle, 'data' ) ) {
			wp_localize_script( $handle, $name, $data );
		}
	}
開發者ID:rilwis,項目名稱:meta-box,代碼行數:18,代碼來源:field.php

示例8: get_scripts

 public function get_scripts()
 {
     $wp_scripts = wp_scripts();
     $this->scripts = array();
     add_filter('script_loader_tag', array($this, 'catch_script_tags'), 99, 3);
     ob_start();
     $wp_scripts->do_items($this->script_handles);
     ob_get_clean();
     return $this->scripts;
 }
開發者ID:nayabbukhari,項目名稱:circulocristiano,代碼行數:10,代碼來源:class-enqueue-extractor.php

示例9: boot_gen_move_js_to_footer

function boot_gen_move_js_to_footer()
{
    $scripts = wp_scripts();
    foreach ($scripts->registered as $script) {
        if ('html5shiv' == $script->handle || 'respond' == $script->handle) {
            wp_script_add_data($script->handle, 'group', 0);
        } else {
            wp_script_add_data($script->handle, 'group', 1);
        }
    }
}
開發者ID:Wordpress-Development,項目名稱:genesis-bootstrap,代碼行數:11,代碼來源:scripts-to-footer.php

示例10: load

 public function load(ActiveTheme $theme)
 {
     if (!is_admin()) {
         $scripts = wp_scripts();
         // Add fallback to local jQuery
         if (isset($scripts->registered['jquery-core'])) {
             $this->localUrl = get_site_url(null, $scripts->registered['jquery-core']->src);
             add_action('wp_footer', array($this, 'renderFallbackScript'), 1, -999);
         }
         add_action('wp_enqueue_scripts', array($this, 'enqueue'), 9999);
     }
 }
開發者ID:wells5609,項目名稱:wp-app,代碼行數:12,代碼來源:JqueryCdn.php

示例11: localize_script

 /**
  * ELocalize scripts
  */
 public static function localize_script($handle, $name, $data)
 {
     /**
      * Prevent loading localized string twice.
      *
      * @link https://github.com/rilwis/meta-box/issues/850
      */
     $wp_scripts = wp_scripts();
     if (!$wp_scripts->get_data($handle, 'data')) {
         wp_localize_script($handle, $name, $data);
     }
 }
開發者ID:CityOfPhiladelphia,項目名稱:business.phila.gov,代碼行數:15,代碼來源:field.php

示例12: admin_enqueue_scripts

 /**
  * Enqueue scripts and styles
  */
 public static function admin_enqueue_scripts()
 {
     wp_enqueue_style('rwmb-file', RWMB_CSS_URL . 'file.css', array(), RWMB_VER);
     wp_enqueue_script('rwmb-file', RWMB_JS_URL . 'file.js', array('jquery'), RWMB_VER, true);
     /**
      * Prevent loading localized string twice.
      * @link https://github.com/rilwis/meta-box/issues/850
      */
     $wp_scripts = wp_scripts();
     if (!$wp_scripts->get_data('rwmb-file', 'data')) {
         wp_localize_script('rwmb-file', 'rwmbFile', array('maxFileUploadsSingle' => __('You may only upload maximum %d file', 'meta-box'), 'maxFileUploadsPlural' => __('You may only upload maximum %d files', 'meta-box')));
     }
 }
開發者ID:jesusmarket,項目名稱:jesusmarket,代碼行數:16,代碼來源:file.php

示例13: enqueueInclude

 public function enqueueInclude(FrontInclude $script)
 {
     if (defined('WP_DEBUG') && WP_DEBUG) {
         $dependencies = $script->getDependency();
         $scripts = wp_scripts()->registered;
         foreach ($dependencies as $dependency) {
             if (!isset($scripts[$dependency])) {
                 trigger_error(sprintf('Dependency failed for %s, No script with handle %s is registered', $script->getHandle(), $dependency), E_USER_WARNING);
             }
         }
     }
     wp_enqueue_script($script->getHandle(), $script->getSrc(), $script->getDependency(), $script->getVersion(), $script->loadInFooter());
 }
開發者ID:ArtOfWP,項目名稱:CloudLess,代碼行數:13,代碼來源:WpScriptIncludes.php

示例14: admin_enqueue_scripts

 /**
  * Enqueue scripts and styles
  *
  * @return void
  */
 static function admin_enqueue_scripts()
 {
     wp_enqueue_media();
     wp_enqueue_script('rwmb-file-input', RWMB_JS_URL . 'file-input.js', array('jquery'), RWMB_VER, true);
     /**
      * Prevent loading localized string twice.
      * @link https://github.com/rilwis/meta-box/issues/850
      */
     $wp_scripts = wp_scripts();
     if (!$wp_scripts->get_data('rwmb-file-input', 'data')) {
         wp_localize_script('rwmb-file-input', 'rwmbFileInput', array('frameTitle' => __('Select File', 'meta-box')));
     }
 }
開發者ID:jesusmarket,項目名稱:jesusmarket,代碼行數:18,代碼來源:file-input.php

示例15: admin_enqueue_scripts

 /**
  * Enqueue scripts and styles.
  */
 static function admin_enqueue_scripts()
 {
     wp_enqueue_style('rwmb-autocomplete', RWMB_CSS_URL . 'autocomplete.css', array('wp-admin'), RWMB_VER);
     wp_enqueue_script('rwmb-autocomplete', RWMB_JS_URL . 'autocomplete.js', array('jquery-ui-autocomplete'), RWMB_VER, true);
     /**
      * Prevent loading localized string twice.
      * @link https://github.com/rilwis/meta-box/issues/850
      */
     $wp_scripts = wp_scripts();
     if (!$wp_scripts->get_data('rwmb-autocomplete', 'data')) {
         wp_localize_script('rwmb-autocomplete', 'RWMB_Autocomplete', array('delete' => __('Delete', 'meta-box')));
     }
 }
開發者ID:jesusmarket,項目名稱:jesusmarket,代碼行數:16,代碼來源:autocomplete.php


注:本文中的wp_scripts函數示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。