ネクストベータ代表Blog

WEBシステム SI屋の代表のブログです。

*

WordPressを読む 54 /blog/wp-includes/script-loader.php

      2015/02/19

/blog/wp-includes/script-loader.php

require class.wp-dependencies.php

require class.wp-scripts.php

require functions.wp-scripts.php

require class.wp-styles.php

require functions.wp-styles.php

関数 wp_default_scripts()

関数 wp_default_styles()

/**
* Assign default styles to $styles object.
*
* Nothing is returned, because the $styles parameter is passed by reference.
* Meaning that whatever object is passed will be updated without having to
* reassign the variable that was passed back to the same value. This saves
* memory.
*
* Adding default styles is not the only task, it also assigns the base_url
* property, the default version, and text direction for the object.
*
* @since 2.6.0
*
* @param object $styles
*/
function wp_default_styles( &$styles ) {
include( ABSPATH . WPINC . ‘/version.php’ ); // include an unmodified $wp_version

if ( ! defined( ‘SCRIPT_DEBUG’ ) )
define( ‘SCRIPT_DEBUG’, false !== strpos( $wp_version, ‘-src’ ) );

if ( ! $guessurl = site_url() )
$guessurl = wp_guess_url();

$styles->base_url = $guessurl;
$styles->content_url = defined(‘WP_CONTENT_URL’)? WP_CONTENT_URL : ”;
$styles->default_version = get_bloginfo( ‘version’ );
$styles->text_direction = function_exists( ‘is_rtl’ ) && is_rtl() ? ‘rtl’ : ‘ltr’;
$styles->default_dirs = array(‘/wp-admin/’, ‘/wp-includes/css/’);

$open_sans_font_url = ”;

/* translators: If there are characters in your language that are not supported
* by Open Sans, translate this to ‘off’. Do not translate into your own language.
*/
if ( ‘off’ !== _x( ‘on’, ‘Open Sans font: on or off’ ) ) {
$subsets = ‘latin,latin-ext’;

/* translators: To add an additional Open Sans character subset specific to your language,
* translate this to ‘greek’, ‘cyrillic’ or ‘vietnamese’. Do not translate into your own language.
*/
$subset = _x( ‘no-subset’, ‘Open Sans font: add new subset (greek, cyrillic, vietnamese)’ );

if ( ‘cyrillic’ == $subset ) {
$subsets .= ‘,cyrillic,cyrillic-ext’;
} elseif ( ‘greek’ == $subset ) {
$subsets .= ‘,greek,greek-ext’;
} elseif ( ‘vietnamese’ == $subset ) {
$subsets .= ‘,vietnamese’;
}

// Hotlink Open Sans, for now
$open_sans_font_url = “//fonts.googleapis.com/css?family=Open+Sans:300italic,400italic,600italic,300,400,600&subset=$subsets”;
}

// Register a stylesheet for the selected admin color scheme.
$styles->add( ‘colors’, true, array( ‘wp-admin’, ‘buttons’, ‘open-sans’, ‘dashicons’ ) );

$suffix = SCRIPT_DEBUG ? ” : ‘.min’;

// Admin CSS
$styles->add( ‘wp-admin’, “/wp-admin/css/wp-admin$suffix.css”, array( ‘open-sans’, ‘dashicons’ ) );
$styles->add( ‘login’, “/wp-admin/css/login$suffix.css”, array( ‘buttons’, ‘open-sans’, ‘dashicons’ ) );
$styles->add( ‘install’, “/wp-admin/css/install$suffix.css”, array( ‘buttons’, ‘open-sans’ ) );
$styles->add( ‘wp-color-picker’, “/wp-admin/css/color-picker$suffix.css” );
$styles->add( ‘customize-controls’, “/wp-admin/css/customize-controls$suffix.css”, array( ‘wp-admin’, ‘colors’, ‘ie’, ‘imgareaselect’ ) );
$styles->add( ‘customize-widgets’, “/wp-admin/css/customize-widgets$suffix.css”, array( ‘wp-admin’, ‘colors’ ) );
$styles->add( ‘ie’, “/wp-admin/css/ie$suffix.css” );

$styles->add_data( ‘ie’, ‘conditional’, ‘lte IE 7’ );

// Common dependencies
$styles->add( ‘buttons’, “/wp-includes/css/buttons$suffix.css” );
$styles->add( ‘dashicons’, “/wp-includes/css/dashicons$suffix.css” );
$styles->add( ‘open-sans’, $open_sans_font_url );

// Includes CSS
$styles->add( ‘admin-bar’, “/wp-includes/css/admin-bar$suffix.css”, array( ‘open-sans’, ‘dashicons’ ) );
$styles->add( ‘wp-auth-check’, “/wp-includes/css/wp-auth-check$suffix.css”, array( ‘dashicons’ ) );
$styles->add( ‘editor-buttons’, “/wp-includes/css/editor$suffix.css”, array( ‘dashicons’ ) );
$styles->add( ‘media-views’, “/wp-includes/css/media-views$suffix.css”, array( ‘buttons’, ‘dashicons’, ‘wp-mediaelement’ ) );
$styles->add( ‘wp-pointer’, “/wp-includes/css/wp-pointer$suffix.css”, array( ‘dashicons’ ) );

// External libraries and friends
$styles->add( ‘imgareaselect’, ‘/wp-includes/js/imgareaselect/imgareaselect.css’, array(), ‘0.9.8’ );
$styles->add( ‘wp-jquery-ui-dialog’, “/wp-includes/css/jquery-ui-dialog$suffix.css”, array( ‘dashicons’ ) );
$styles->add( ‘mediaelement’, “/wp-includes/js/mediaelement/mediaelementplayer.min.css”, array(), ‘2.15.0’ );
$styles->add( ‘wp-mediaelement’, “/wp-includes/js/mediaelement/wp-mediaelement.css”, array( ‘mediaelement’ ) );
$styles->add( ‘thickbox’, ‘/wp-includes/js/thickbox/thickbox.css’, array( ‘dashicons’ ) );

// Deprecated CSS
$styles->add( ‘media’, “/wp-admin/css/deprecated-media$suffix.css” );
$styles->add( ‘farbtastic’, ‘/wp-admin/css/farbtastic.css’, array(), ‘1.3u1’ );
$styles->add( ‘jcrop’, “/wp-includes/js/jcrop/jquery.Jcrop.min.css”, array(), ‘0.9.12’ );
$styles->add( ‘colors-fresh’, false, array( ‘wp-admin’, ‘buttons’ ) ); // Old handle.

// RTL CSS
$rtl_styles = array(
// wp-admin
‘wp-admin’, ‘install’, ‘wp-color-picker’, ‘customize-controls’, ‘customize-widgets’, ‘ie’, ‘login’,
// wp-includes
‘buttons’, ‘admin-bar’, ‘wp-auth-check’, ‘editor-buttons’, ‘media-views’, ‘wp-pointer’,
‘wp-jquery-ui-dialog’,
// deprecated
‘media’, ‘farbtastic’,
);

foreach ( $rtl_styles as $rtl_style ) {
$styles->add_data( $rtl_style, ‘rtl’, ‘replace’ );
if ( $suffix ) {
$styles->add_data( $rtl_style, ‘suffix’, $suffix );
}
}
}

関数 wp_prototype_before_jquery()

/**
* Reorder JavaScript scripts array to place prototype before jQuery.
*
* @since 2.3.1
*
* @param array $js_array JavaScript scripts array
* @return array Reordered array, if needed.
*/
function wp_prototype_before_jquery( $js_array ) {
if ( false === $prototype = array_search( ‘prototype’, $js_array, true ) )
return $js_array;

if ( false === $jquery = array_search( ‘jquery’, $js_array, true ) )
return $js_array;

if ( $prototype < $jquery ) return $js_array; unset($js_array[$prototype]); array_splice( $js_array, $jquery, 0, 'prototype' ); return $js_array; }

関数 wp_just_in_time_script_localization()

/**
* Load localized data on print rather than initialization.
*
* These localizations require information that may not be loaded even by init.
*
* @since 2.5.0
*/
function wp_just_in_time_script_localization() {

wp_localize_script( ‘autosave’, ‘autosaveL10n’, array(
‘autosaveInterval’ => AUTOSAVE_INTERVAL,
‘blog_id’ => get_current_blog_id(),
) );

}

関数 wp_style_loader_src()

/**
* Administration Screen CSS for changing the styles.
*
* If installing the ‘wp-admin/’ directory will be replaced with ‘./’.
*
* The $_wp_admin_css_colors global manages the Administration Screens CSS
* stylesheet that is loaded. The option that is set is ‘admin_color’ and is the
* color and key for the array. The value for the color key is an object with
* a ‘url’ parameter that has the URL path to the CSS file.
*
* The query from $src parameter will be appended to the URL that is given from
* the $_wp_admin_css_colors array value URL.
*
* @since 2.6.0
* @uses $_wp_admin_css_colors
*
* @param string $src Source URL.
* @param string $handle Either ‘colors’ or ‘colors-rtl’.
* @return string URL path to CSS stylesheet for Administration Screens.
*/
function wp_style_loader_src( $src, $handle ) {
global $_wp_admin_css_colors;

if ( defined(‘WP_INSTALLING’) )
return preg_replace( ‘#^wp-admin/#’, ‘./’, $src );

if ( ‘colors’ == $handle ) {
$color = get_user_option(‘admin_color’);

if ( empty($color) || !isset($_wp_admin_css_colors[$color]) )
$color = ‘fresh’;

$color = $_wp_admin_css_colors[$color];
$parsed = parse_url( $src );
$url = $color->url;

if ( ! $url ) {
return false;
}

if ( isset($parsed[‘query’]) && $parsed[‘query’] ) {
wp_parse_str( $parsed[‘query’], $qv );
$url = add_query_arg( $qv, $url );
}

return $url;
}

return $src;
}

関数 print_head_scripts()

/**
* Prints the script queue in the HTML head on admin pages.
*
* Postpones the scripts that were queued for the footer.
* print_footer_scripts() is called in the footer to print these scripts.
*
* @since 2.8.0
*
* @see wp_print_scripts()
*/
function print_head_scripts() {
global $wp_scripts, $concatenate_scripts;

if ( ! did_action(‘wp_print_scripts’) ) {
/** This action is documented in wp-includes/functions.wp-scripts.php */
do_action( ‘wp_print_scripts’ );
}

if ( !is_a($wp_scripts, ‘WP_Scripts’) )
$wp_scripts = new WP_Scripts();

script_concat_settings();
$wp_scripts->do_concat = $concatenate_scripts;
$wp_scripts->do_head_items();

/**
* Filter whether to print the head scripts.
*
* @since 2.8.0
*
* @param bool $print Whether to print the head scripts. Default true.
*/
if ( apply_filters( ‘print_head_scripts’, true ) ) {
_print_scripts();
}

$wp_scripts->reset();
return $wp_scripts->done;
}

関数 print_footer_scripts()

/**
* Prints the scripts that were queued for the footer or too late for the HTML head.
*
* @since 2.8.0
*/
function print_footer_scripts() {
global $wp_scripts, $concatenate_scripts;

if ( !is_a($wp_scripts, ‘WP_Scripts’) )
return array(); // No need to run if not instantiated.

script_concat_settings();
$wp_scripts->do_concat = $concatenate_scripts;
$wp_scripts->do_footer_items();

/**
* Filter whether to print the footer scripts.
*
* @since 2.8.0
*
* @param bool $print Whether to print the footer scripts. Default true.
*/
if ( apply_filters( ‘print_footer_scripts’, true ) ) {
_print_scripts();
}

$wp_scripts->reset();
return $wp_scripts->done;
}

関数 _print_scripts()

/**
* @internal use
*/
function _print_scripts() {
global $wp_scripts, $compress_scripts;

$zip = $compress_scripts ? 1 : 0;
if ( $zip && defined(‘ENFORCE_GZIP’) && ENFORCE_GZIP )
$zip = ‘gzip’;

if ( $concat = trim( $wp_scripts->concat, ‘, ‘ ) ) {

if ( !empty($wp_scripts->print_code) ) {
echo “\n\n”;
}

$concat = str_split( $concat, 128 );
$concat = ‘load%5B%5D=’ . implode( ‘&load%5B%5D=’, $concat );

$src = $wp_scripts->base_url . “/wp-admin/load-scripts.php?c={$zip}&” . $concat . ‘&ver=’ . $wp_scripts->default_version;
echo “\n”;
}

if ( !empty($wp_scripts->print_html) )
echo $wp_scripts->print_html;
}

関数 wp_print_head_scripts()

/**
* Prints the script queue in the HTML head on the front end.
*
* Postpones the scripts that were queued for the footer.
* wp_print_footer_scripts() is called in the footer to print these scripts.
*
* @since 2.8.0
*/
function wp_print_head_scripts() {
if ( ! did_action(‘wp_print_scripts’) ) {
/** This action is documented in wp-includes/functions.wp-scripts.php */
do_action( ‘wp_print_scripts’ );
}

global $wp_scripts;

if ( !is_a($wp_scripts, ‘WP_Scripts’) )
return array(); // no need to run if nothing is queued

return print_head_scripts();
}

関数 _wp_footer_scripts()

/**
* Private, for use in *_footer_scripts hooks
*
* @since 3.3.0
*/
function _wp_footer_scripts() {
print_late_styles();
print_footer_scripts();
}

関数 wp_print_footer_scripts()

/**
* Hooks to print the scripts and styles in the footer.
*
* @since 2.8.0
*/
function wp_print_footer_scripts() {
/**
* Fires when footer scripts are printed.
*
* @since 2.8.0
*/
do_action( ‘wp_print_footer_scripts’ );
}

関数 wp_enqueue_scripts()

/**
* Wrapper for do_action(‘wp_enqueue_scripts’)
*
* Allows plugins to queue scripts for the front end using wp_enqueue_script().
* Runs first in wp_head() where all is_home(), is_page(), etc. functions are available.
*
* @since 2.8.0
*/
function wp_enqueue_scripts() {
/**
* Fires when scripts and styles are enqueued.
*
* @since 2.8.0
*/
do_action( ‘wp_enqueue_scripts’ );
}

関数 print_admin_styles()

/**
* Prints the styles queue in the HTML head on admin pages.
*
* @since 2.8.0
*/
function print_admin_styles() {
global $wp_styles, $concatenate_scripts;

if ( !is_a($wp_styles, ‘WP_Styles’) )
$wp_styles = new WP_Styles();

script_concat_settings();
$wp_styles->do_concat = $concatenate_scripts;
$wp_styles->do_items(false);

/**
* Filter whether to print the admin styles.
*
* @since 2.8.0
*
* @param bool $print Whether to print the admin styles. Default true.
*/
if ( apply_filters( ‘print_admin_styles’, true ) ) {
_print_styles();
}

$wp_styles->reset();
return $wp_styles->done;
}

関数 print_late_styles()

/**
* Prints the styles that were queued too late for the HTML head.
*
* @since 3.3.0
*/
function print_late_styles() {
global $wp_styles, $concatenate_scripts;

if ( !is_a($wp_styles, ‘WP_Styles’) )
return;

$wp_styles->do_concat = $concatenate_scripts;
$wp_styles->do_footer_items();

/**
* Filter whether to print the styles queued too late for the HTML head.
*
* @since 3.3.0
*
* @param bool $print Whether to print the ‘late’ styles. Default true.
*/
if ( apply_filters( ‘print_late_styles’, true ) ) {
_print_styles();
}

$wp_styles->reset();
return $wp_styles->done;
}

関数 _print_styles()

/**
* @internal use
*/
function _print_styles() {
global $wp_styles, $compress_css;

$zip = $compress_css ? 1 : 0;
if ( $zip && defined(‘ENFORCE_GZIP’) && ENFORCE_GZIP )
$zip = ‘gzip’;

if ( !empty($wp_styles->concat) ) {
$dir = $wp_styles->text_direction;
$ver = $wp_styles->default_version;
$href = $wp_styles->base_url . “/wp-admin/load-styles.php?c={$zip}&dir={$dir}&load=” . trim($wp_styles->concat, ‘, ‘) . ‘&ver=’ . $ver;
echo “\n”;

if ( !empty($wp_styles->print_code) ) {
echo “

\n”;
}
}

if ( !empty($wp_styles->print_html) )
echo $wp_styles->print_html;
}

関数 script_concat_settings()

/**
* Determine the concatenation and compression settings for scripts and styles.
*
* @since 2.8.0
*/
function script_concat_settings() {
global $concatenate_scripts, $compress_scripts, $compress_css;

$compressed_output = ( ini_get(‘zlib.output_compression’) || ‘ob_gzhandler’ == ini_get(‘output_handler’) );

if ( ! isset($concatenate_scripts) ) {
$concatenate_scripts = defined(‘CONCATENATE_SCRIPTS’) ? CONCATENATE_SCRIPTS : true;
if ( ! is_admin() || ( defined(‘SCRIPT_DEBUG’) && SCRIPT_DEBUG ) )
$concatenate_scripts = false;
}

if ( ! isset($compress_scripts) ) {
$compress_scripts = defined(‘COMPRESS_SCRIPTS’) ? COMPRESS_SCRIPTS : true;
if ( $compress_scripts && ( ! get_site_option(‘can_compress_scripts’) || $compressed_output ) )
$compress_scripts = false;
}

if ( ! isset($compress_css) ) {
$compress_css = defined(‘COMPRESS_CSS’) ? COMPRESS_CSS : true;
if ( $compress_css && ( ! get_site_option(‘can_compress_scripts’) || $compressed_output ) )
$compress_css = false;
}
}

add_action( ‘wp_default_scripts’, ‘wp_default_scripts’ );
add_filter( ‘wp_print_scripts’, ‘wp_just_in_time_script_localization’ );
add_filter( ‘print_scripts_array’, ‘wp_prototype_before_jquery’ );

add_action( ‘wp_default_styles’, ‘wp_default_styles’ );
add_filter( ‘style_loader_src’, ‘wp_style_loader_src’, 10, 2 );

 - Wordpress


Fatal error: Uncaught exception 'JSMin_UnterminatedStringException' with message 'JSMin: Unterminated String at byte 2690: ";' in /usr/local/www/apache22/data/next-beta/net/blog/wp-content/plugins/autoptimize/classes/external/php/minify-2.3.1-jsmin.php:211 Stack trace: #0 /usr/local/www/apache22/data/next-beta/net/blog/wp-content/plugins/autoptimize/classes/external/php/minify-2.3.1-jsmin.php(150): JSMin->action(1) #1 /usr/local/www/apache22/data/next-beta/net/blog/wp-content/plugins/autoptimize/classes/external/php/minify-2.3.1-jsmin.php(84): JSMin->min() #2 /usr/local/www/apache22/data/next-beta/net/blog/wp-content/plugins/autoptimize/classes/autoptimizeScripts.php(237): JSMin::minify('\n\n\t\t\twindow._wp...') #3 /usr/local/www/apache22/data/next-beta/net/blog/wp-content/plugins/autoptimize/autoptimize.php(266): autoptimizeScripts->minify() #4 [internal function]: autoptimize_end_buffering('<!DOCTYPE html>...', 9) #5 /usr/local/www/apache22/data/next-beta/net/blog/wp-includes/functions.php(3828): ob_end_flush() #6 [int in /usr/local/www/apache22/data/next-beta/net/blog/wp-content/plugins/autoptimize/classes/external/php/minify-2.3.1-jsmin.php on line 211