本文整理汇总了PHP中wp_default_scripts函数的典型用法代码示例。如果您正苦于以下问题:PHP wp_default_scripts函数的具体用法?PHP wp_default_scripts怎么用?PHP wp_default_scripts使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了wp_default_scripts函数的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: setUp
function setUp()
{
parent::setUp();
$scripts = new WP_Scripts();
wp_default_scripts($scripts);
$this->scripts = $scripts;
}
示例2: test_location_of_jquery
function test_location_of_jquery()
{
$scripts = new WP_Scripts();
wp_default_scripts($scripts);
$object = $scripts->query('jquery', 'registered');
$this->assertInstanceOf('_WP_Dependency', $object);
$this->assertEquals('/wp-includes/js/jquery/jquery.js', $object->src);
}
示例3: test_location_of_jquery
function test_location_of_jquery()
{
$scripts = new WP_Scripts();
wp_default_scripts($scripts);
$jquery_scripts = array('jquery-core' => '/wp-includes/js/jquery/jquery.js');
if (SCRIPT_DEBUG) {
$jquery_scripts['jquery-migrate'] = '/wp-includes/js/jquery/jquery-migrate.js';
} else {
$jquery_scripts['jquery-migrate'] = '/wp-includes/js/jquery/jquery-migrate.min.js';
}
$object = $scripts->query('jquery', 'registered');
$this->assertInstanceOf('_WP_Dependency', $object);
$this->assertEqualSets($object->deps, array_keys($jquery_scripts));
foreach ($object->deps as $dep) {
$o = $scripts->query($dep, 'registered');
$this->assertInstanceOf('_WP_Dependency', $object);
$this->assertTrue(isset($jquery_scripts[$dep]));
$this->assertEquals($jquery_scripts[$dep], $o->src);
}
}
示例4: site_url
{
return true;
}
function site_url()
{
}
function admin_url()
{
}
function wp_guess_url()
{
}
require ABSPATH . '/wp-includes/script-loader.php';
require ABSPATH . '/wp-includes/version.php';
$wp_scripts = new WP_Scripts();
wp_default_scripts($wp_scripts);
$wp_styles = new WP_Styles();
wp_default_styles($wp_styles);
$defaults = $man_version = '';
foreach ($wp_scripts->registered as $script) {
if (empty($script->src) || strpos($script->src, 'tiny_mce_config.php')) {
continue;
}
$ver = empty($script->ver) ? $wp_version : $script->ver;
$src = str_replace(array('/wp-admin/', '/wp-includes/'), array('', '../wp-includes/'), $script->src);
$defaults .= '{ "url" : "' . $src . '?ver=' . $ver . '" },' . "\n";
$man_version .= $ver;
}
foreach ($wp_styles->registered as $style) {
if (empty($style->src)) {
continue;
示例5: add_js_config
/**
* Set up JS config for output.
*
* @param string $hook Hook suffix for the current screen.
*/
function add_js_config($hook = null)
{
global $post;
// If we are in the admin, only load LivePress JS on the
// post page and the livepress settings page
if (is_admin() && $hook != null && $hook != 'post-new.php' && $hook != 'post.php' && $hook != 'settings_page_livepress-settings') {
return;
}
$is_live = isset($post) ? LivePress_Updater::instance()->blogging_tools->get_post_live_status($post->ID) : false;
// On the front end, only load LivePress JS on pages that are live,
// or when the WordPress admin bar is showing
if (!is_admin() && !is_admin_bar_showing() && !$is_live) {
return;
}
$ljsc = new LivePress_JavaScript_Config();
if ($this->livepress_config->debug() || $this->livepress_config->script_debug()) {
$ljsc->new_value('debug', true, Livepress_Configuration_Item::$BOOLEAN);
}
$ljsc->new_value('ajax_nonce', $this->options['ajax_nonce']);
$ljsc->new_value('ajax_comment_nonce', $this->options['ajax_comment_nonce']);
$ljsc->new_value('ajax_status_nonce', $this->options['ajax_status_nonce']);
$ljsc->new_value('lp_add_live_update_tags_nonce', $this->options['lp_add_live_update_tags_nonce']);
$ljsc->new_value('ajax_twitter_search_nonce', $this->options['ajax_twitter_search_nonce']);
$ljsc->new_value('ajax_twitter_follow_nonce', $this->options['ajax_twitter_follow_nonce']);
$ljsc->new_value('ajax_api_validate_nonce', $this->options['ajax_api_validate_nonce']);
$ljsc->new_value('ajax_lp_post_to_twitter', $this->options['ajax_lp_post_to_twitter']);
$ljsc->new_value('ajax_check_oauth', $this->options['ajax_check_oauth']);
$ljsc->new_value('lp_update_shortlink_nonce', $this->options['lp_update_shortlink_nonce']);
$ljsc->new_value('ajax_lp_collaboration_comments', $this->options['ajax_lp_collaboration_comments']);
$ljsc->new_value('ajax_get_live_edition_data', $this->options['ajax_get_live_edition_data']);
$ljsc->new_value('ajax_lp_im_integration', $this->options['ajax_lp_im_integration']);
$ljsc->new_value('ajax_render_tabs', $this->options['ajax_render_tabs']);
$ljsc->new_value('ajax_update_live_comments', $this->options['ajax_update_live_comments']);
$ljsc->new_value('ajax_new_im_follower', $this->options['ajax_new_im_follower']);
$ljsc->new_value('ajax_start_editor', $this->options['ajax_start_editor']);
$ljsc->new_value('ver', LP_PLUGIN_VERSION);
$ljsc->new_value('oover', $this->livepress_config->lp_ver(), Livepress_Configuration_Item::$ARRAY);
global $wp_scripts;
if ($wp_scripts === null) {
$wp_scripts = new WP_Scripts();
wp_default_scripts($wp_scripts);
}
if (is_a($wp_scripts, 'WP_Scripts')) {
$src = $wp_scripts->query('jquery');
$src = $src->src;
if (!preg_match('|^https?://|', $src) && !($wp_scripts->content_url && 0 === strpos($src, $wp_scripts->content_url))) {
$src = $wp_scripts->base_url . $src;
}
$ljsc->new_value('jquery_url', $src . '?');
}
if (function_exists('get_current_screen')) {
$screen = get_current_screen();
if (is_a($screen, 'WP_Screen')) {
$ljsc->new_value('current_screen', array('base' => $screen->base, 'id' => $screen->id), Livepress_Configuration_Item::$ARRAY);
}
}
$ljsc->new_value('wpstatic_url', LP_PLUGIN_URL);
$ljsc->new_value('static_url', $this->livepress_config->static_host());
$ljsc->new_value('lp_plugin_url', LP_PLUGIN_URL);
$ljsc->new_value('blog_gmt_offset', get_option('gmt_offset'), Livepress_Configuration_Item::$LITERAL);
$theme_name = strtolower(wp_get_theme()->Name);
$ljsc->new_value('theme_name', $theme_name);
try {
if (isset($this->title_css_selectors[$theme_name])) {
$title_css_selector = $this->title_css_selectors[$theme_name];
$title_css_selector = apply_filters('livepress_title_css_selector', $title_css_selector, $theme_name);
$ljsc->new_value('custom_title_css_selector', $title_css_selector);
}
} catch (livepress_invalid_option_exception $e) {
}
try {
if (isset($this->background_colors[$theme_name])) {
$background_color = $this->background_colors[$theme_name];
$background_color = apply_filters('livepress_background_color', $background_color, $theme_name);
$ljsc->new_value('custom_background_color', $background_color);
}
} catch (livepress_invalid_option_exception $e) {
}
if (is_home()) {
$page_type = 'home';
} elseif (is_page()) {
$page_type = 'page';
} elseif (is_single()) {
$page_type = 'single';
} elseif (is_admin()) {
$page_type = 'admin';
} else {
$page_type = 'undefined';
}
$ljsc->new_value('page_type', $page_type);
// Comments
if (isset($post->ID)) {
$args = array('post_id' => isset($post->ID) ? $post->ID : null);
$post_comments = get_comments($args);
$old_comments = isset($GLOBALS['wp_query']->comments) ? $GLOBALS['wp_query']->comments : null;
//.........这里部分代码省略.........
示例6: get_wp_scripts
public function get_wp_scripts()
{
global $wp_scripts;
if ($wp_scripts == null) {
$wp_scripts = new WP_Scripts();
wp_default_scripts($wp_scripts);
}
return $wp_scripts;
}
示例7: attachmentEditHeadIframe
/**
* Output the script/link tags needed by the edit iframe
*
* @since 0.0.1a
* @return void
*/
public function attachmentEditHeadIframe()
{
global $wp_scripts;
wp_default_scripts($wp_scripts);
// I don't know if all these scripts are really needed by the media edit screen.
// They're just there, so they'll be here too :P
include IJ_POST_ATTACHMENTS_DIR . '/html/attachmentEditHead.php';
// Add the needed vars to set the thumbnail :)
$wp_scripts->localize('set-post-thumbnail', 'post_id', $_GET['post_id']);
$wp_scripts->print_extra_script('set-post-thumbnail');
}
示例8: ExtractStandardScripts
function ExtractStandardScripts($xmlScriptData, $bWithDependencies)
{
// ** Setup
$result = array();
global $wp_scripts;
// ** Extract the standard scripts (with dependencies?) from $xmlScriptData
$standardScripts = $xmlScriptData->getElementsByTagName("standard");
foreach ($standardScripts as $iStdScript) {
// * Get all the default Wordpress scripts
// Note: This is done here for efficiency (if no standard wordpress script files are required, this will never be executed)
if (!$wp_scripts) {
$wp_scripts = new WP_Scripts();
wp_default_scripts($wp_scripts);
}
// * Get the standard script
$stdScriptName = $iStdScript->attributes->getNamedItem("name")->nodeValue;
if (!array_key_exists($stdScriptName, $wp_scripts->registered)) {
continue;
}
// * Get the dependencies
if ($bWithDependencies) {
$this->AppendStandardScriptDependencies($stdScriptName, $wp_scripts, $result);
}
// * Add to result
if (!in_array($stdScriptName, $result)) {
$result[] = $stdScriptName;
}
}
return $result;
}
示例9: test_wp_add_inline_script_customize_dependency
/**
* @ticket 36392
*/
public function test_wp_add_inline_script_customize_dependency()
{
global $wp_scripts;
wp_default_scripts($wp_scripts);
$wp_scripts->base_url = '';
$wp_scripts->do_concat = true;
$expected_tail = "<![endif]-->\n";
$expected_tail .= "<script type='text/javascript' src='/customize-dependency.js'></script>\n";
$expected_tail .= "<script type='text/javascript'>\n";
$expected_tail .= "tryCustomizeDependency()\n";
$expected_tail .= "</script>\n";
$handle = 'customize-dependency';
wp_enqueue_script($handle, '/customize-dependency.js', array('customize-controls'), null);
wp_add_inline_script($handle, 'tryCustomizeDependency()');
wp_print_scripts();
$print_scripts = get_echo('_print_scripts');
$tail = substr($print_scripts, strrpos($print_scripts, "<![endif]-->"));
$this->assertEquals($expected_tail, $tail);
}