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


PHP WP_Scripts::enqueue方法代碼示例

本文整理匯總了PHP中WP_Scripts::enqueue方法的典型用法代碼示例。如果您正苦於以下問題:PHP WP_Scripts::enqueue方法的具體用法?PHP WP_Scripts::enqueue怎麽用?PHP WP_Scripts::enqueue使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在WP_Scripts的用法示例。


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

示例1: 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

示例2: 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

示例3: sp_plugin_enqueue_script

function sp_plugin_enqueue_script($handle, $src = false, $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();
    }
    if ($src) {
        $_handle = explode('?', $handle);
        global $spDevice;
        $media = 'desktop';
        if ($spDevice == 'mobile') {
            $media = 'mobile';
        }
        if ($spDevice == 'tablet') {
            $media = 'tablet';
        }
        $sp_plugin_scripts->add($_handle[0], $src, $deps, $ver, $media);
        if ($in_footer) {
            $sp_plugin_scripts->add_data($_handle[0], 'group', 1);
        }
    }
    $sp_plugin_scripts->enqueue($handle);
}
開發者ID:bself,項目名稱:nuimage-wp,代碼行數:23,代碼來源:sp-api-plugins.php

示例4: 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

示例5: 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

示例6: sp_plugin_enqueue_script

function sp_plugin_enqueue_script($handle, $src = false, $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();
    }
    if ($src) {
        $_handle = explode('?', $handle);
        $sp_plugin_scripts->add($_handle[0], $src, $deps, $ver);
        if ($in_footer) {
            $sp_plugin_scripts->add_data($_handle[0], 'group', 1);
        }
    }
    $sp_plugin_scripts->enqueue($handle);
}
開發者ID:Bakerpedia,項目名稱:Developement_WPengine,代碼行數:15,代碼來源:sp-api-plugins.php


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