Move utils.js (cookie and user setting functions) to wp-includes to enable front-end use.
Make it a dependency of media-views (and therefore media-editor). Move its userSettings JS object from admin-header to being paired with the script in script loader. see #22730. git-svn-id: http://core.svn.wordpress.org/trunk@23036 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
392ade0221
commit
36554dd983
|
@ -50,12 +50,7 @@ $admin_body_class = preg_replace('/[^a-z0-9_-]+/i', '-', $hook_suffix);
|
||||||
?>
|
?>
|
||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
addLoadEvent = function(func){if(typeof jQuery!="undefined")jQuery(document).ready(func);else if(typeof wpOnload!='function'){wpOnload=func;}else{var oldonload=wpOnload;wpOnload=function(){oldonload();func();}}};
|
addLoadEvent = function(func){if(typeof jQuery!="undefined")jQuery(document).ready(func);else if(typeof wpOnload!='function'){wpOnload=func;}else{var oldonload=wpOnload;wpOnload=function(){oldonload();func();}}};
|
||||||
var userSettings = {
|
var ajaxurl = '<?php echo admin_url( 'admin-ajax.php', 'relative' ); ?>',
|
||||||
'url': '<?php echo SITECOOKIEPATH; ?>',
|
|
||||||
'uid': '<?php if ( ! isset($current_user) ) $current_user = wp_get_current_user(); echo $current_user->ID; ?>',
|
|
||||||
'time':'<?php echo time() ?>'
|
|
||||||
},
|
|
||||||
ajaxurl = '<?php echo admin_url( 'admin-ajax.php', 'relative' ); ?>',
|
|
||||||
pagenow = '<?php echo $current_screen->id; ?>',
|
pagenow = '<?php echo $current_screen->id; ?>',
|
||||||
typenow = '<?php echo $current_screen->post_type; ?>',
|
typenow = '<?php echo $current_screen->post_type; ?>',
|
||||||
adminpage = '<?php echo $admin_body_class; ?>',
|
adminpage = '<?php echo $admin_body_class; ?>',
|
||||||
|
|
|
@ -59,7 +59,12 @@ function wp_default_scripts( &$scripts ) {
|
||||||
|
|
||||||
$suffix = defined('SCRIPT_DEBUG') && SCRIPT_DEBUG ? '' : '.min';
|
$suffix = defined('SCRIPT_DEBUG') && SCRIPT_DEBUG ? '' : '.min';
|
||||||
|
|
||||||
$scripts->add( 'utils', "/wp-admin/js/utils$suffix.js" );
|
$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(),
|
||||||
|
) );
|
||||||
|
|
||||||
$scripts->add( 'common', "/wp-admin/js/common$suffix.js", array('jquery', 'hoverIntent', 'utils'), false, 1 );
|
$scripts->add( 'common', "/wp-admin/js/common$suffix.js", array('jquery', 'hoverIntent', 'utils'), false, 1 );
|
||||||
did_action( 'init' ) && $scripts->localize( 'common', 'commonL10n', array(
|
did_action( 'init' ) && $scripts->localize( 'common', 'commonL10n', array(
|
||||||
|
@ -329,7 +334,7 @@ function wp_default_scripts( &$scripts ) {
|
||||||
|
|
||||||
// To enqueue media-views or media-editor, call wp_enqueue_media().
|
// To enqueue media-views or media-editor, call wp_enqueue_media().
|
||||||
// Both rely on numerous settings, styles, and templates to operate correctly.
|
// Both rely on numerous settings, styles, and templates to operate correctly.
|
||||||
$scripts->add( 'media-views', "/wp-includes/js/media-views$suffix.js", array( 'media-models', 'wp-plupload', 'jquery-ui-sortable' ), false, 1 );
|
$scripts->add( 'media-views', "/wp-includes/js/media-views$suffix.js", array( 'utils', 'media-models', 'wp-plupload', 'jquery-ui-sortable' ), false, 1 );
|
||||||
$scripts->add( 'media-editor', "/wp-includes/js/media-editor$suffix.js", array( 'shortcode', 'media-views' ), false, 1 );
|
$scripts->add( 'media-editor', "/wp-includes/js/media-editor$suffix.js", array( 'shortcode', 'media-views' ), false, 1 );
|
||||||
$scripts->add( 'mce-view', "/wp-includes/js/mce-view$suffix.js", array( 'shortcode', 'media-models' ), false, 1 );
|
$scripts->add( 'mce-view', "/wp-includes/js/mce-view$suffix.js", array( 'shortcode', 'media-models' ), false, 1 );
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue