本文整理汇总了PHP中WP_Scripts::localize方法的典型用法代码示例。如果您正苦于以下问题:PHP WP_Scripts::localize方法的具体用法?PHP WP_Scripts::localize怎么用?PHP WP_Scripts::localize使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类WP_Scripts
的用法示例。
在下文中一共展示了WP_Scripts::localize方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: 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 the selected 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' => __('You do not have permission 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')));
$scripts->add('autosave', "/wp-includes/js/autosave{$suffix}.js", array('heartbeat'), false, 1);
$scripts->add('heartbeat', "/wp-includes/js/heartbeat{$suffix}.js", array('jquery'), false, 1);
did_action('init') && $scripts->localize('heartbeat', 'heartbeatSettings', apply_filters('heartbeat_settings', array()));
$scripts->add('wp-auth-check', "/wp-includes/js/wp-auth-check{$suffix}.js", array('heartbeat'), false, 1);
did_action('init') && $scripts->localize('wp-auth-check', 'authcheckL10n', array('beforeunload' => __('Your session has expired. You can log in again from this page or go to the login page.'), 'interval' => apply_filters('wp_auth_check_interval', 3 * MINUTE_IN_SECONDS)));
$scripts->add('wp-lists', "/wp-includes/js/wp-lists{$suffix}.js", array('wp-ajax-response', 'jquery-color'), false, 1);
// WordPress no longer uses or bundles Prototype or script.aculo.us. These are now pulled from an external source.
$scripts->add('prototype', 'https://ajax.googleapis.com/ajax/libs/prototype/1.7.1.0/prototype.js', array(), '1.7.1');
$scripts->add('scriptaculous-root', 'https://ajax.googleapis.com/ajax/libs/scriptaculous/1.9.0/scriptaculous.js', array('prototype'), '1.9.0');
$scripts->add('scriptaculous-builder', 'https://ajax.googleapis.com/ajax/libs/scriptaculous/1.9.0/builder.js', array('scriptaculous-root'), '1.9.0');
$scripts->add('scriptaculous-dragdrop', 'https://ajax.googleapis.com/ajax/libs/scriptaculous/1.9.0/dragdrop.js', array('scriptaculous-builder', 'scriptaculous-effects'), '1.9.0');
$scripts->add('scriptaculous-effects', 'https://ajax.googleapis.com/ajax/libs/scriptaculous/1.9.0/effects.js', array('scriptaculous-root'), '1.9.0');
$scripts->add('scriptaculous-slider', 'https://ajax.googleapis.com/ajax/libs/scriptaculous/1.9.0/slider.js', array('scriptaculous-effects'), '1.9.0');
$scripts->add('scriptaculous-sound', 'https://ajax.googleapis.com/ajax/libs/scriptaculous/1.9.0/sound.js', array('scriptaculous-root'), '1.9.0');
$scripts->add('scriptaculous-controls', 'https://ajax.googleapis.com/ajax/libs/scriptaculous/1.9.0/controls.js', array('scriptaculous-root'), '1.9.0');
$scripts->add('scriptaculous', false, array('scriptaculous-dragdrop', 'scriptaculous-slider', 'scriptaculous-controls'));
// not used in core, replaced by Jcrop.js
$scripts->add('cropper', '/wp-includes/js/crop/cropper.js', array('scriptaculous-dragdrop'));
// jQuery
$scripts->add('jquery', false, array('jquery-core', 'jquery-migrate'), '1.11.3');
$scripts->add('jquery-core', '/wp-includes/js/jquery/jquery.js', array(), '1.11.3');
$scripts->add('jquery-migrate', "/wp-includes/js/jquery/jquery-migrate{$suffix}.js", array(), '1.2.1');
// full jQuery UI
$scripts->add('jquery-ui-core', "/wp-includes/js/jquery/ui/core{$dev_suffix}.js", array('jquery'), '1.11.4', 1);
$scripts->add('jquery-effects-core', "/wp-includes/js/jquery/ui/effect{$dev_suffix}.js", array('jquery'), '1.11.4', 1);
$scripts->add('jquery-effects-blind', "/wp-includes/js/jquery/ui/effect-blind{$dev_suffix}.js", array('jquery-effects-core'), '1.11.4', 1);
$scripts->add('jquery-effects-bounce', "/wp-includes/js/jquery/ui/effect-bounce{$dev_suffix}.js", array('jquery-effects-core'), '1.11.4', 1);
$scripts->add('jquery-effects-clip', "/wp-includes/js/jquery/ui/effect-clip{$dev_suffix}.js", array('jquery-effects-core'), '1.11.4', 1);
$scripts->add('jquery-effects-drop', "/wp-includes/js/jquery/ui/effect-drop{$dev_suffix}.js", array('jquery-effects-core'), '1.11.4', 1);
$scripts->add('jquery-effects-explode', "/wp-includes/js/jquery/ui/effect-explode{$dev_suffix}.js", array('jquery-effects-core'), '1.11.4', 1);
$scripts->add('jquery-effects-fade', "/wp-includes/js/jquery/ui/effect-fade{$dev_suffix}.js", array('jquery-effects-core'), '1.11.4', 1);
$scripts->add('jquery-effects-fold', "/wp-includes/js/jquery/ui/effect-fold{$dev_suffix}.js", array('jquery-effects-core'), '1.11.4', 1);
$scripts->add('jquery-effects-highlight', "/wp-includes/js/jquery/ui/effect-highlight{$dev_suffix}.js", array('jquery-effects-core'), '1.11.4', 1);
$scripts->add('jquery-effects-puff', "/wp-includes/js/jquery/ui/effect-puff{$dev_suffix}.js", array('jquery-effects-core', 'jquery-effects-scale'), '1.11.4', 1);
$scripts->add('jquery-effects-pulsate', "/wp-includes/js/jquery/ui/effect-pulsate{$dev_suffix}.js", array('jquery-effects-core'), '1.11.4', 1);
$scripts->add('jquery-effects-scale', "/wp-includes/js/jquery/ui/effect-scale{$dev_suffix}.js", array('jquery-effects-core', 'jquery-effects-size'), '1.11.4', 1);
$scripts->add('jquery-effects-shake', "/wp-includes/js/jquery/ui/effect-shake{$dev_suffix}.js", array('jquery-effects-core'), '1.11.4', 1);
$scripts->add('jquery-effects-size', "/wp-includes/js/jquery/ui/effect-size{$dev_suffix}.js", array('jquery-effects-core'), '1.11.4', 1);
$scripts->add('jquery-effects-slide', "/wp-includes/js/jquery/ui/effect-slide{$dev_suffix}.js", array('jquery-effects-core'), '1.11.4', 1);
$scripts->add('jquery-effects-transfer', "/wp-includes/js/jquery/ui/effect-transfer{$dev_suffix}.js", array('jquery-effects-core'), '1.11.4', 1);
$scripts->add('jquery-ui-accordion', "/wp-includes/js/jquery/ui/accordion{$dev_suffix}.js", array('jquery-ui-core', 'jquery-ui-widget'), '1.11.4', 1);
$scripts->add('jquery-ui-autocomplete', "/wp-includes/js/jquery/ui/autocomplete{$dev_suffix}.js", array('jquery-ui-menu'), '1.11.4', 1);
$scripts->add('jquery-ui-button', "/wp-includes/js/jquery/ui/button{$dev_suffix}.js", array('jquery-ui-core', 'jquery-ui-widget'), '1.11.4', 1);
$scripts->add('jquery-ui-datepicker', "/wp-includes/js/jquery/ui/datepicker{$dev_suffix}.js", array('jquery-ui-core'), '1.11.4', 1);
$scripts->add('jquery-ui-dialog', "/wp-includes/js/jquery/ui/dialog{$dev_suffix}.js", array('jquery-ui-resizable', 'jquery-ui-draggable', 'jquery-ui-button', 'jquery-ui-position'), '1.11.4', 1);
$scripts->add('jquery-ui-draggable', "/wp-includes/js/jquery/ui/draggable{$dev_suffix}.js", array('jquery-ui-mouse'), '1.11.4', 1);
$scripts->add('jquery-ui-droppable', "/wp-includes/js/jquery/ui/droppable{$dev_suffix}.js", array('jquery-ui-draggable'), '1.11.4', 1);
$scripts->add('jquery-ui-menu', "/wp-includes/js/jquery/ui/menu{$dev_suffix}.js", array('jquery-ui-core', 'jquery-ui-widget', 'jquery-ui-position'), '1.11.4', 1);
$scripts->add('jquery-ui-mouse', "/wp-includes/js/jquery/ui/mouse{$dev_suffix}.js", array('jquery-ui-core', 'jquery-ui-widget'), '1.11.4', 1);
$scripts->add('jquery-ui-position', "/wp-includes/js/jquery/ui/position{$dev_suffix}.js", array('jquery'), '1.11.4', 1);
$scripts->add('jquery-ui-progressbar', "/wp-includes/js/jquery/ui/progressbar{$dev_suffix}.js", array('jquery-ui-core', 'jquery-ui-widget'), '1.11.4', 1);
$scripts->add('jquery-ui-resizable', "/wp-includes/js/jquery/ui/resizable{$dev_suffix}.js", array('jquery-ui-mouse'), '1.11.4', 1);
$scripts->add('jquery-ui-selectable', "/wp-includes/js/jquery/ui/selectable{$dev_suffix}.js", array('jquery-ui-mouse'), '1.11.4', 1);
$scripts->add('jquery-ui-selectmenu', "/wp-includes/js/jquery/ui/selectmenu{$dev_suffix}.js", array('jquery-ui-menu'), '1.11.4', 1);
$scripts->add('jquery-ui-slider', "/wp-includes/js/jquery/ui/slider{$dev_suffix}.js", array('jquery-ui-mouse'), '1.11.4', 1);
//.........这里部分代码省略.........
示例2: 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'),
//.........这里部分代码省略.........