当前位置: 首页>>代码示例>>PHP>>正文


PHP WP_Scripts::add方法代码示例

本文整理汇总了PHP中WP_Scripts::add方法的典型用法代码示例。如果您正苦于以下问题:PHP WP_Scripts::add方法的具体用法?PHP WP_Scripts::add怎么用?PHP WP_Scripts::add使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在WP_Scripts的用法示例。


在下文中一共展示了WP_Scripts::add方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: register_scripts

 /**
  * Register scripts.
  *
  * @action wp_default_scripts, 11
  *
  * @param \WP_Scripts $wp_scripts Instance of \WP_Scripts.
  */
 public function register_scripts(\WP_Scripts $wp_scripts)
 {
     $min = SCRIPT_DEBUG ? '' : '.min';
     $handle = 'customize-snapshots';
     $src = $this->dir_url . 'js/customize-snapshots' . $min . '.js';
     $deps = array('jquery', 'jquery-ui-dialog', 'wp-util', 'customize-controls');
     $wp_scripts->add($handle, $src, $deps);
     $handle = 'customize-snapshots-preview';
     $src = $this->dir_url . 'js/customize-snapshots-preview' . $min . '.js';
     $deps = array('customize-preview');
     $wp_scripts->add($handle, $src, $deps);
     $handle = 'customize-snapshots-frontend';
     $src = $this->dir_url . 'js/customize-snapshots-frontend' . $min . '.js';
     $deps = array('jquery', 'underscore');
     $wp_scripts->add($handle, $src, $deps);
 }
开发者ID:xwp,项目名称:wp-customize-snapshots,代码行数:23,代码来源:class-plugin.php

示例2: array

 /**
  * Register scripts.
  *
  * @param \WP_Scripts $wp_scripts Instance of \WP_Scripts.
  * @action wp_default_scripts
  */
 function register_scripts(\WP_Scripts $wp_scripts)
 {
     $src = $this->dir_url . 'js/customize-concurrency.js';
     $deps = array('heartbeat', 'customize-widgets', 'underscore');
     $wp_scripts->add($this->slug, $src, $deps);
     $wp_scripts->add_data($this->slug, 'group', 1);
     // 1 = in_footer.
 }
开发者ID:xwp,项目名称:wp-customize-concurrency,代码行数:14,代码来源:class-plugin.php

示例3: array

 /**
  * @param WP_Scripts $wp_scripts
  * @action wp_default_scripts
  */
 function register_scripts($wp_scripts)
 {
     $handle = 'customize-partial-refresh-base';
     $src = $this->get_dir_url('js/customize-partial-refresh-base.js');
     $deps = array('customize-base');
     $wp_scripts->add($handle, $src, $deps, $this->get_version());
     $this->script_handles['base'] = $handle;
     $handle = 'customize-partial-refresh-widgets-preview';
     $src = $this->get_dir_url('js/customize-partial-refresh-widgets-preview.js');
     $deps = array('jquery', 'wp-util', 'customize-preview', 'customize-preview-widgets', $this->script_handles['base']);
     $in_footer = true;
     $wp_scripts->add($handle, $src, $deps, $this->get_version(), $in_footer);
     $this->script_handles['widgets-preview'] = $handle;
     $handle = 'customize-partial-refresh-widgets-pane';
     $src = $this->get_dir_url('js/customize-partial-refresh-widgets-pane.js');
     $deps = array('jquery', 'wp-util', 'customize-controls', 'customize-widgets', $this->script_handles['base']);
     $in_footer = true;
     $wp_scripts->add($handle, $src, $deps, $this->get_version(), $in_footer);
     $this->script_handles['widgets-pane'] = $handle;
 }
开发者ID:AshiqKiron,项目名称:wp-customize-partial-refresh,代码行数:24,代码来源:class-wp-customize-partial-refresh-plugin.php

示例4: wp_enqueue_script

/**
 * Equeues script
 *
 * Registers the script if src provided (does NOT overwrite) and enqueues.
 *
 * @see WP_Script::add(), WP_Script::enqueue()
*/
function wp_enqueue_script($handle, $src = false, $deps = array(), $ver = false)
{
    global $wp_scripts;
    if (!is_a($wp_scripts, 'WP_Scripts')) {
        $wp_scripts = new WP_Scripts();
    }
    if ($src) {
        $_handle = explode('?', $handle);
        $wp_scripts->add($_handle[0], $src, $deps, $ver);
    }
    $wp_scripts->enqueue($handle);
}
开发者ID:nurpax,项目名称:saastafi,代码行数:19,代码来源:functions.wp-scripts.php

示例5: array

 /**
  * Test placing of jQuery in footer.
  *
  * @ticket 25247
  */
 function test_jquery_in_footer()
 {
     $scripts = new WP_Scripts();
     $scripts->add('jquery', false, array('jquery-core', 'jquery-migrate'));
     $scripts->add('jquery-core', '/jquery.js', array());
     $scripts->add('jquery-migrate', '/jquery-migrate.js', array());
     $scripts->enqueue('jquery');
     $jquery = $scripts->query('jquery');
     $jquery->add_data('group', 1);
     foreach ($jquery->deps as $dep) {
         $scripts->add_data($dep, 'group', 1);
     }
     $this->expectOutputRegex('/^(?:<script[^>]+><\\/script>\\n){2}$/');
     $scripts->do_items(false, 0);
     $this->assertNotContains('jquery', $scripts->done);
     $this->assertNotContains('jquery-core', $scripts->done, 'jquery-core should be in footer but is in head');
     $this->assertNotContains('jquery-migrate', $scripts->done, 'jquery-migrate should be in footer but is in head');
     $scripts->do_items(false, 1);
     $this->assertContains('jquery', $scripts->done);
     $this->assertContains('jquery-core', $scripts->done, 'jquery-core in footer');
     $this->assertContains('jquery-migrate', $scripts->done, 'jquery-migrate in footer');
 }
开发者ID:atimmer,项目名称:wordpress-develop-mirror,代码行数:27,代码来源:jquery.php

示例6: gp_scripts_default

/**
 * Register the GlotPress scripts
 *
 * @param WP_Scripts $scripts
 */
function gp_scripts_default(&$scripts)
{
    $url = gp_plugin_url('assets/js');
    $scripts->add('tablesorter', $url . '/jquery.tablesorter.min.js', array('jquery'), '1.10.4');
    $scripts->add('gp-common', $url . '/common.js', array('jquery'), '20150430');
    $scripts->add('gp-editor', $url . '/editor.js', array('gp-common', 'jquery-ui-tooltip'), '20160329');
    $scripts->add('gp-glossary', $url . '/glossary.js', array('gp-common'), '20160329');
    $scripts->add('gp-translations-page', $url . '/translations-page.js', array('gp-common'), '20150430');
    $scripts->add('mass-create-sets-page', $url . '/mass-create-sets-page.js', array('gp-common'), '20150430');
}
开发者ID:ramiy,项目名称:GlotPress-WP,代码行数:15,代码来源:assets-loader.php

示例7: test_group_mismatch_in_deps

 /**
  * Test mismatch of groups in dependencies outputs all scripts in right order.
  *
  * @ticket 35873
  */
 public function test_group_mismatch_in_deps()
 {
     $scripts = new WP_Scripts();
     $scripts->add('one', 'one', array(), 'v1', 1);
     $scripts->add('two', 'two', array('one'));
     $scripts->add('three', 'three', array('two'), 'v1', 1);
     $scripts->enqueue(array('three'));
     $this->expectOutputRegex('/^(?:<script[^>]+><\\/script>\\n){7}$/');
     $scripts->do_items(false, 0);
     $this->assertContains('one', $scripts->done);
     $this->assertContains('two', $scripts->done);
     $this->assertNotContains('three', $scripts->done);
     $scripts->do_items(false, 1);
     $this->assertContains('one', $scripts->done);
     $this->assertContains('two', $scripts->done);
     $this->assertContains('three', $scripts->done);
     $scripts = new WP_Scripts();
     $scripts->add('one', 'one', array(), 'v1', 1);
     $scripts->add('two', 'two', array('one'), 'v1', 1);
     $scripts->add('three', 'three', array('one'));
     $scripts->add('four', 'four', array('two', 'three'), 'v1', 1);
     $scripts->enqueue(array('four'));
     $scripts->do_items(false, 0);
     $this->assertContains('one', $scripts->done);
     $this->assertNotContains('two', $scripts->done);
     $this->assertContains('three', $scripts->done);
     $this->assertNotContains('four', $scripts->done);
     $scripts->do_items(false, 1);
     $this->assertContains('one', $scripts->done);
     $this->assertContains('two', $scripts->done);
     $this->assertContains('three', $scripts->done);
     $this->assertContains('four', $scripts->done);
 }
开发者ID:jaspermdegroot,项目名称:develop.wordpress,代码行数:38,代码来源:scripts.php

示例8: wp_enqueue_script

/**
 * Enqueues script.
 *
 * Registers the script if src provided (does NOT overwrite) and enqueues.
 *
 * @since r16
 * @see wp_register_script() For parameter information.
 */
function wp_enqueue_script($handle, $src = false, $deps = array(), $ver = false, $in_footer = false)
{
    global $wp_scripts;
    if (!is_a($wp_scripts, 'WP_Scripts')) {
        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_scripts = new WP_Scripts();
    }
    if ($src) {
        $_handle = explode('?', $handle);
        $wp_scripts->add($_handle[0], $src, $deps, $ver);
        if ($in_footer) {
            $wp_scripts->add_data($_handle[0], 'group', 1);
        }
    }
    $wp_scripts->enqueue($handle);
}
开发者ID:adisonc,项目名称:MaineLearning,代码行数:26,代码来源:functions.wp-scripts.php

示例9: add

 public function add($handle, $src, $deps = array(), $ver = false, $args = null)
 {
     $debug = defined('SCRIPT_DEBUG') && SCRIPT_DEBUG;
     // Determine if we are debugging the scripts
     if (isset($_GET['debug']) && 1 == $_GET['debug']) {
         $debug = true;
     }
     $extension = '.js';
     // Use .js extension for script files
     $suffix = '.min';
     // Use .min for suffix
     $minsrc = str_replace($extension, $suffix . $extension, $src);
     // Add the suffix when not debugging and the suffix isn't already used (the file is not available unminified)
     if (!$debug && false === strpos($src, $suffix . $extension) && file_exists(ShoppLoader::basepath() . $minsrc)) {
         $src = $minsrc;
     }
     return parent::add($handle, $src, $deps, $ver, $args);
 }
开发者ID:BlessySoftwares,项目名称:anvelocom,代码行数:18,代码来源:Scripts.php

示例10: filter_wp_default_scripts

/**
 * Filter wp_default_scripts
 *
 * Removes an extra jQuery Script
 *
 * @since 5.0.0
 *
 * @param \WP_Scripts $scripts The Default WordPress scripts.
 *
 * @return void
 */
function filter_wp_default_scripts($scripts)
{
    if (!is_admin()) {
        $scripts->remove('jquery');
        $scripts->add('jquery', false, array('jquery-core'), '1.12.3');
    }
}
开发者ID:ChrisWiegman,项目名称:chriswiegman-theme,代码行数:18,代码来源:core.php

示例11: register_ui_scripts

 /**
  * Register additional jQuery UI scripts
  *
  * Never call this manually unless you really know what you are doing!
  *
  * @internal
  */
 public function register_ui_scripts()
 {
     global $wp_scripts;
     if (!$wp_scripts instanceof WP_Scripts) {
         $wp_scripts = new WP_Scripts();
     }
     $deps_c = array('jquery-ui-core');
     $deps_cw = array_merge($deps_c, array('jquery-ui-widget'));
     $deps_cwm = array_merge($deps_cw, array('jquery-ui-mouse'));
     $deps_cwp = array_merge($deps_cw, array('jquery-ui-position'));
     $jui = array('jquery-ui-accordion' => array('src' => 'jquery.ui.accordion.min.js', 'deps' => $deps_cw), 'jquery-ui-autocomplete' => array('src' => 'jquery.ui.autocomplete.min.js', 'deps' => $deps_cwp), 'jquery-ui-datepicker' => array('src' => 'jquery.ui.datepicker.min.js', 'deps' => $deps_c), 'jquery-ui-progressbar' => array('src' => 'jquery.ui.progressbar.min.js', 'deps' => $deps_cw), 'jquery-ui-slider' => array('src' => 'jquery.ui.slider.min.js', 'deps' => $deps_cwm));
     // register more scripts
     foreach ($jui as $handle => $cfg) {
         // make sure not registered already
         if (!$wp_scripts->query($handle)) {
             // register it
             $wp_scripts->add($handle, ICE_JS_URL . '/' . $cfg['src'], $cfg['deps'], '1.8.12');
             // put in footer group
             $wp_scripts->add_data($handle, 'group', 1);
         }
     }
 }
开发者ID:nathan929,项目名称:infinity,代码行数:29,代码来源:enqueue.php

示例12: register_scripts

 /**
  * Register scripts.
  *
  * @param \WP_Scripts $wp_scripts Instance of \WP_Scripts.
  * @action wp_default_scripts
  */
 public function register_scripts(\WP_Scripts $wp_scripts)
 {
     $handle = 'customize-rest-resources-namespace';
     $src = $this->dir_url . 'js/namespace.js';
     $deps = array();
     $wp_scripts->add($handle, $src, $deps, $this->version);
     $handle = 'customize-rest-resources-manager';
     $src = $this->dir_url . 'js/rest-resources-manager.js';
     $deps = array('customize-rest-resources-namespace', 'wp-api', 'backbone');
     $wp_scripts->add($handle, $src, $deps, $this->version);
     $handle = 'customize-rest-resources-pane-manager';
     $src = $this->dir_url . 'js/rest-resources-pane-manager.js';
     $deps = array('customize-rest-resources-namespace', 'customize-rest-resources-manager', 'customize-controls', 'customize-rest-resources-section', 'customize-rest-resource-control');
     $wp_scripts->add($handle, $src, $deps, $this->version);
     $handle = 'customize-rest-resources-preview-manager';
     $src = $this->dir_url . 'js/rest-resources-preview-manager.js';
     $deps = array('customize-rest-resources-namespace', 'customize-rest-resources-manager', 'customize-preview');
     $wp_scripts->add($handle, $src, $deps, $this->version);
     $handle = 'customize-rest-resources-section';
     $src = $this->dir_url . 'js/rest-resources-section.js';
     $deps = array('customize-rest-resources-namespace', 'customize-controls');
     $wp_scripts->add($handle, $src, $deps, $this->version);
     $handle = 'customize-rest-resource-control';
     $src = $this->dir_url . 'js/rest-resource-control.js';
     $deps = array('customize-rest-resources-namespace', 'customize-controls');
     $wp_scripts->add($handle, $src, $deps, $this->version);
 }
开发者ID:chandra-patel,项目名称:wp-customize-rest-resources,代码行数:33,代码来源:class-plugin.php

示例13: array

 /**
  * Register scripts.
  *
  * @param \WP_Scripts $wp_scripts
  * @action wp_default_scripts
  */
 function register_scripts(\WP_Scripts $wp_scripts)
 {
     $slug = 'base';
     $handle = "{$this->slug}-{$slug}";
     $src = $this->dir_url . 'js/base.js';
     $deps = array();
     $wp_scripts->add($handle, $src, $deps);
     $this->script_handles[$slug] = $handle;
     $slug = 'widget-number-incrementing';
     $handle = "{$this->slug}-{$slug}";
     $src = $this->dir_url . 'js/widget-number-incrementing.js';
     $deps = array($this->script_handles['base'], 'wp-util');
     $wp_scripts->add($handle, $src, $deps);
     $this->script_handles[$slug] = $handle;
     $slug = 'widget-number-incrementing-customizer';
     $handle = "{$this->slug}-{$slug}";
     $src = $this->dir_url . 'js/widget-number-incrementing-customizer.js';
     $deps = array('customize-widgets', $this->script_handles['widget-number-incrementing']);
     $wp_scripts->add($handle, $src, $deps);
     $this->script_handles[$slug] = $handle;
     $slug = 'https-resource-proxy';
     $handle = "{$this->slug}-{$slug}";
     $src = $this->dir_url . 'js/https-resource-proxy.js';
     $deps = array('jquery');
     $wp_scripts->add($handle, $src, $deps);
     $this->script_handles[$slug] = $handle;
     $slug = 'deferred-customize-widgets';
     $handle = "{$this->slug}-{$slug}";
     $src = $this->dir_url . 'js/deferred-customize-widgets.js';
     $deps = array('jquery', 'customize-widgets');
     $wp_scripts->add($handle, $src, $deps);
     $this->script_handles[$slug] = $handle;
 }
开发者ID:BE-Webdesign,项目名称:wp-customize-widgets-plus,代码行数:39,代码来源:class-plugin.php

示例14: wp_default_scripts

/**
 * Register all WordPress scripts.
 *
 * Localizes some of them.
 * args order: `$scripts->add( 'handle', 'url', 'dependencies', 'query-string', 1 );`
 * when last arg === 1 queues the script for the footer
 *
 * @since 2.6.0
 *
 * @param WP_Scripts $scripts WP_Scripts object.
 */
function wp_default_scripts( &$scripts ) {
	include( ABSPATH . WPINC . '/version.php' ); // include an unmodified $wp_version

	$develop_src = false !== strpos( $wp_version, '-src' );

	if ( ! defined( 'SCRIPT_DEBUG' ) ) {
		define( 'SCRIPT_DEBUG', $develop_src );
	}

	if ( ! $guessurl = site_url() ) {
		$guessed_url = true;
		$guessurl = wp_guess_url();
	}

	$scripts->base_url = $guessurl;
	$scripts->content_url = defined('WP_CONTENT_URL')? WP_CONTENT_URL : '';
	$scripts->default_version = get_bloginfo( 'version' );
	$scripts->default_dirs = array('/wp-admin/js/', '/wp-includes/js/');

	$suffix = SCRIPT_DEBUG ? '' : '.min';
	$dev_suffix = $develop_src ? '' : '.min';

	$scripts->add( 'utils', "/wp-includes/js/utils$suffix.js" );
	did_action( 'init' ) && $scripts->localize( 'utils', 'userSettings', array(
		'url' => (string) SITECOOKIEPATH,
		'uid' => (string) get_current_user_id(),
		'time' => (string) time(),
		'secure' => (string) ( 'https' === parse_url( site_url(), PHP_URL_SCHEME ) ),
	) );

	$scripts->add( 'common', "/wp-admin/js/common$suffix.js", array('jquery', 'hoverIntent', 'utils'), false, 1 );
	did_action( 'init' ) && $scripts->localize( 'common', 'commonL10n', array(
		'warnDelete' => __( "You are about to permanently delete these items.\n  'Cancel' to stop, 'OK' to delete." ),
		'dismiss'    => __( 'Dismiss this notice.' ),
	) );

	$scripts->add( 'wp-a11y', "/wp-includes/js/wp-a11y$suffix.js", array( 'jquery' ), false, 1 );

	$scripts->add( 'sack', "/wp-includes/js/tw-sack$suffix.js", array(), '1.6.1', 1 );

	$scripts->add( 'quicktags', "/wp-includes/js/quicktags$suffix.js", array(), false, 1 );
	did_action( 'init' ) && $scripts->localize( 'quicktags', 'quicktagsL10n', array(
		'closeAllOpenTags'      => __( 'Close all open tags' ),
		'closeTags'             => __( 'close tags' ),
		'enterURL'              => __( 'Enter the URL' ),
		'enterImageURL'         => __( 'Enter the URL of the image' ),
		'enterImageDescription' => __( 'Enter a description of the image' ),
		'textdirection'         => __( 'text direction' ),
		'toggleTextdirection'   => __( 'Toggle Editor Text Direction' ),
		'dfw'                   => __( 'Distraction-free writing mode' ),
		'strong'          => __( 'Bold' ),
		'strongClose'     => __( 'Close bold tag' ),
		'em'              => __( 'Italic' ),
		'emClose'         => __( 'Close italic tag' ),
		'link'            => __( 'Insert link' ),
		'blockquote'      => __( 'Blockquote' ),
		'blockquoteClose' => __( 'Close blockquote tag' ),
		'del'             => __( 'Deleted text (strikethrough)' ),
		'delClose'        => __( 'Close deleted text tag' ),
		'ins'             => __( 'Inserted text' ),
		'insClose'        => __( 'Close inserted text tag' ),
		'image'           => __( 'Insert image' ),
		'ul'              => __( 'Bulleted list' ),
		'ulClose'         => __( 'Close bulleted list tag' ),
		'ol'              => __( 'Numbered list' ),
		'olClose'         => __( 'Close numbered list tag' ),
		'li'              => __( 'List item' ),
		'liClose'         => __( 'Close list item tag' ),
		'code'            => __( 'Code' ),
		'codeClose'       => __( 'Close code tag' ),
		'more'            => __( 'Insert Read More tag' ),
	) );

	$scripts->add( 'colorpicker', "/wp-includes/js/colorpicker$suffix.js", array('prototype'), '3517m' );

	$scripts->add( 'editor', "/wp-admin/js/editor$suffix.js", array('utils','jquery'), false, 1 );

	// Back-compat for old DFW. To-do: remove at the end of 2016.
	$scripts->add( 'wp-fullscreen-stub', "/wp-admin/js/wp-fullscreen-stub$suffix.js", array(), false, 1 );

	$scripts->add( 'wp-ajax-response', "/wp-includes/js/wp-ajax-response$suffix.js", array('jquery'), false, 1 );
	did_action( 'init' ) && $scripts->localize( 'wp-ajax-response', 'wpAjax', array(
		'noPerm' => __('Sorry, you are not allowed to do that.'),
		'broken' => __('An unidentified error has occurred.')
	) );

	$scripts->add( 'wp-pointer', "/wp-includes/js/wp-pointer$suffix.js", array( 'jquery-ui-widget', 'jquery-ui-position' ), '20111129a', 1 );
	did_action( 'init' ) && $scripts->localize( 'wp-pointer', 'wpPointerL10n', array(
		'dismiss' => __('Dismiss'),
//.........这里部分代码省略.........
开发者ID:staylor,项目名称:develop.svn.wordpress.org,代码行数:101,代码来源:script-loader.php

示例15: sp_plugin_register_script

function sp_plugin_register_script($handle, $src, $deps = array(), $ver = false, $in_footer = false)
{
    global $sp_plugin_scripts;
    if (!is_a($sp_plugin_scripts, 'WP_Scripts')) {
        $sp_plugin_scripts = new WP_Scripts();
    }
    $sp_plugin_scripts->add($handle, $src, $deps, $ver);
    if ($in_footer) {
        $sp_plugin_scripts->add_data($handle, 'group', 1);
    }
}
开发者ID:bself,项目名称:nuimage-wp,代码行数:11,代码来源:sp-api-plugins.php


注:本文中的WP_Scripts::add方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。