+/**
+ * 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
+ * @see wp_print_scripts()
+ */
+function print_head_scripts() {
+ global $wp_scripts, $concatenate_scripts;
+
+ if ( ! did_action('wp_print_scripts') )
+ 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();
+
+ if ( apply_filters('print_head_scripts', true) )
+ _print_scripts();
+
+ $wp_scripts->reset();
+ return $wp_scripts->done;
+}
+
+/**
+ * Prints the scripts that were queued for the footer on admin pages.
+ *
+ * @since 2.8
+ */
+function print_footer_scripts() {
+ global $wp_scripts, $concatenate_scripts;
+
+ if ( ! did_action('wp_print_footer_scripts') )
+ do_action('wp_print_footer_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();
+
+ if ( apply_filters('print_footer_scripts', true) )
+ _print_scripts();
+
+ $wp_scripts->reset();
+ return $wp_scripts->done;
+}
+
+function _print_scripts() {
+ global $wp_scripts, $compress_scripts;
+
+ $zip = $compress_scripts ? 1 : 0;
+ if ( $zip && defined('ENFORCE_GZIP') && ENFORCE_GZIP )
+ $zip = 'gzip';
+
+ if ( !empty($wp_scripts->concat) ) {
+
+ if ( !empty($wp_scripts->print_code) ) {
+ echo "<script type='text/javascript'>\n";
+ echo "/* <![CDATA[ */\n";
+ echo $wp_scripts->print_code;
+ echo "/* ]]> */\n";
+ echo "</script>\n";
+ }
+
+ $ver = md5("$wp_scripts->concat_version");
+ $src = $wp_scripts->base_url . "/wp-admin/load-scripts.php?c={$zip}&load=" . trim($wp_scripts->concat, ', ') . "&ver=$ver";
+ echo "<script type='text/javascript' src='" . esc_attr($src) . "'></script>\n";
+ }
+
+ if ( !empty($wp_scripts->print_html) )
+ echo $wp_scripts->print_html;
+}
+
+/**
+ * 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
+ */
+function wp_print_head_scripts() {
+ if ( ! did_action('wp_print_scripts') )
+ 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();
+}
+
+/**
+ * Prints the scripts that were queued for the footer on the front end.
+ *
+ * @since 2.8
+ */
+function wp_print_footer_scripts() {
+ return print_footer_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
+ */
+function wp_enqueue_scripts() {
+ do_action('wp_enqueue_scripts');
+}
+
+function print_admin_styles() {
+ global $wp_styles, $concatenate_scripts, $compress_css;
+
+ if ( !is_a($wp_styles, 'WP_Styles') )
+ $wp_styles = new WP_Styles();
+
+ script_concat_settings();
+ $wp_styles->do_concat = $concatenate_scripts;
+ $zip = $compress_css ? 1 : 0;
+ if ( $zip && defined('ENFORCE_GZIP') && ENFORCE_GZIP )
+ $zip = 'gzip';
+
+ $wp_styles->do_items(false);
+
+ if ( apply_filters('print_admin_styles', true) ) {
+ if ( !empty($wp_styles->concat) ) {
+ $dir = $wp_styles->text_direction;
+ $ver = md5("$wp_styles->concat_version{$dir}");
+ $href = $wp_styles->base_url . "/wp-admin/load-styles.php?c={$zip}&dir={$dir}&load=" . trim($wp_styles->concat, ', ') . "&ver=$ver";
+ echo "<link rel='stylesheet' href='" . esc_attr($href) . "' type='text/css' media='all' />\n";
+ }
+
+ if ( !empty($wp_styles->print_html) )
+ echo $wp_styles->print_html;
+ }
+
+ $wp_styles->do_concat = false;
+ $wp_styles->concat = $wp_styles->concat_version = $wp_styles->print_html = '';
+ return $wp_styles->done;
+}
+
+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;
+ }
+}
+