Changeset 10442
- Timestamp:
- 01/26/2009 12:59:10 PM (16 years ago)
- Location:
- trunk
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/wp-admin/includes/template.php
r10424 r10442 3396 3396 3397 3397 /** 3398 * Test support for compress ed JavaScript and CSS3398 * Test support for compressing JavaScript from PHP 3399 3399 * 3400 3400 * Outputs JavaScript that tests if compression from PHP works as expected … … 3407 3407 function compression_test() { 3408 3408 ?> 3409 <script type="text/javascript" src="load-scripts.php?test=1 "></script>3409 <script type="text/javascript" src="load-scripts.php?test=1<?php echo ( defined('ENFORCE_GZIP') && ENFORCE_GZIP ) ? '&c=gzip' : ''; ?>"></script> 3410 3410 <script type="text/javascript"> 3411 3411 /* <![CDATA[ */ -
trunk/wp-admin/load-scripts.php
r10372 r10442 93 93 exit(''); 94 94 95 if ( false !== strpos( strtolower($_SERVER['HTTP_ACCEPT_ENCODING']), 'gzip') && function_exists('gzencode') ) { 95 $out = 'var wpCompressionTest = 1;'; 96 $force_gzip = ( isset($_GET['c']) && 'gzip' == $_GET['c'] ); 97 98 if ( false !== strpos( strtolower($_SERVER['HTTP_ACCEPT_ENCODING']), 'deflate') && function_exists('gzdeflate') && ! $force_gzip ) { 99 header('Content-Encoding: deflate'); 100 $out = gzdeflate( $out, 3 ); 101 } elseif ( false !== strpos( strtolower($_SERVER['HTTP_ACCEPT_ENCODING']), 'gzip') && function_exists('gzencode') ) { 96 102 header('Content-Encoding: gzip'); 97 $out = gzencode( 'var wpCompressionTest = 1;', 3 ); 103 $out = gzencode( $out, 3 ); 104 } else { 105 exit(''); 98 106 } 99 100 if ( ! isset($out) ) 101 exit(''); 102 107 103 108 header( 'Expires: Wed, 11 Jan 1984 05:00:00 GMT' ); 104 109 header( 'Last-Modified: ' . gmdate( 'D, d M Y H:i:s' ) . ' GMT' ); … … 119 124 require(ABSPATH . '/wp-includes/version.php'); 120 125 121 $compress = ( isset($_GET['c']) && 1 == $_GET['c'] ); 126 $compress = ( isset($_GET['c']) && $_GET['c'] ); 127 $force_gzip = ( $compress && 'gzip' == $_GET['c'] ); 122 128 $expires_offset = 31536000; 123 129 $out = ''; … … 138 144 header("Cache-Control: public, max-age=$expires_offset"); 139 145 140 if ( $compress && ! ini_get('zlib.output_compression') && function_exists('gzencode')) {146 if ( $compress && ! ini_get('zlib.output_compression') ) { 141 147 header('Vary: Accept-Encoding'); // Handle proxies 142 if ( false !== strpos( strtolower($_SERVER['HTTP_ACCEPT_ENCODING']), 'gzip') ) { 148 if ( false !== strpos( strtolower($_SERVER['HTTP_ACCEPT_ENCODING']), 'deflate') && function_exists('gzdeflate') && ! $force_gzip ) { 149 header('Content-Encoding: deflate'); 150 $out = gzdeflate( $out, 3 ); 151 } elseif ( false !== strpos( strtolower($_SERVER['HTTP_ACCEPT_ENCODING']), 'gzip') && function_exists('gzencode') ) { 143 152 header('Content-Encoding: gzip'); 144 153 $out = gzencode( $out, 3 ); -
trunk/wp-admin/load-styles.php
r10372 r10442 98 98 exit; 99 99 100 $compress = ( isset($_GET['c']) && 1 == $_GET['c'] ); 101 $rtl = ( isset($_GET['rtl']) && 1 == $_GET['rtl'] ); 100 $compress = ( isset($_GET['c']) && $_GET['c'] ); 101 $force_gzip = ( $compress && 'gzip' == $_GET['c'] ); 102 $rtl = ( isset($_GET['dir']) && 'rtl' == $_GET['dir'] ); 102 103 $expires_offset = 31536000; 103 104 $out = ''; … … 127 128 header("Cache-Control: public, max-age=$expires_offset"); 128 129 129 if ( $compress && ! ini_get('zlib.output_compression') && function_exists('gzencode')) {130 if ( $compress && ! ini_get('zlib.output_compression') ) { 130 131 header('Vary: Accept-Encoding'); // Handle proxies 131 if ( false !== strpos( strtolower($_SERVER['HTTP_ACCEPT_ENCODING']), 'gzip') ) { 132 if ( false !== strpos( strtolower($_SERVER['HTTP_ACCEPT_ENCODING']), 'deflate') && function_exists('gzdeflate') && ! $force_gzip ) { 133 header('Content-Encoding: deflate'); 134 $out = gzdeflate( $out, 3 ); 135 } elseif ( false !== strpos( strtolower($_SERVER['HTTP_ACCEPT_ENCODING']), 'gzip') && function_exists('gzencode') ) { 132 136 header('Content-Encoding: gzip'); 133 137 $out = gzencode( $out, 3 ); -
trunk/wp-includes/class.wp-scripts.php
r10367 r10442 27 27 var $print_html = ''; 28 28 var $print_code = ''; 29 var $src = ''; 29 var $ext_handles = ''; 30 var $ext_version = ''; 30 31 var $default_dirs; 31 32 … … 100 101 if ( $this->in_default_dir($srce) ) { 101 102 $this->print_code .= $this->print_scripts_l10n( $handle, false ); 102 $this->concat .= $handle . ',';103 $this->concat_version .= $ver;103 $this->concat .= "$handle,"; 104 $this->concat_version .= "$handle$ver"; 104 105 return true; 106 } else { 107 $this->ext_handles .= "$handle,"; 108 $this->ext_version .= "$handle$ver"; 105 109 } 106 110 } … … 111 115 } 112 116 113 $this->src .= "$src,";114 117 $src = add_query_arg('ver', $ver, $src); 115 118 $src = clean_url(apply_filters( 'script_loader_src', $src, $handle )); … … 147 150 } 148 151 149 function all_deps( $handles, $recursion = false ) {152 function all_deps( $handles, $recursion = false, $group = false ) { 150 153 $r = parent::all_deps( $handles, $recursion ); 151 154 if ( !$recursion ) … … 182 185 return false; 183 186 } 187 188 function reset() { 189 $this->do_concat = false; 190 $this->print_code = ''; 191 $this->concat = ''; 192 $this->concat_version = ''; 193 $this->print_html = ''; 194 $this->ext_version = ''; 195 $this->ext_handles = ''; 196 } 184 197 } -
trunk/wp-includes/class.wp-styles.php
r10357 r10442 42 42 if ( $this->do_concat ) { 43 43 if ( $this->in_default_dir($this->registered[$handle]->src) && !isset($this->registered[$handle]->extra['conditional']) && !isset($this->registered[$handle]->extra['alt']) ) { 44 $this->concat .= $handle . ',';45 $this->concat_version .= $ver;44 $this->concat .= "$handle,"; 45 $this->concat_version .= "$handle$ver"; 46 46 return true; 47 47 } … … 89 89 } 90 90 91 function all_deps( $handles, $recursion = false ) {91 function all_deps( $handles, $recursion = false, $group = false ) { 92 92 $r = parent::all_deps( $handles, $recursion ); 93 93 if ( !$recursion ) -
trunk/wp-includes/default-filters.php
r10377 r10442 165 165 166 166 // Actions 167 add_action('wp_head', 'wp_enqueue_scripts', 1); 167 168 add_action('wp_head', 'feed_links_extra', 3); 168 169 add_action('wp_head', 'rsd_link'); … … 171 172 add_action('publish_future_post', 'check_and_publish_future_post', 10, 1); 172 173 add_action('wp_head', 'noindex', 1); 173 add_action('wp_head', 'wp_print_styles', 9);174 add_action('wp_head', 'wp_print_ scripts');174 add_action('wp_head', 'wp_print_styles', 8); 175 add_action('wp_head', 'wp_print_head_scripts', 9); 175 176 add_action('wp_head', 'wp_generator'); 177 add_action('wp_footer', 'wp_print_footer_scripts'); 176 178 if(!defined('DOING_CRON')) 177 179 add_action('init', 'wp_cron'); … … 183 185 add_action('do_robots', 'do_robots'); 184 186 add_action('sanitize_comment_cookies', 'sanitize_comment_cookies'); 185 add_action('admin_print_scripts', ' wp_print_head_scripts', 20);186 add_action('admin_print_footer_scripts', ' wp_print_footer_scripts', 20);187 add_action('admin_print_styles', ' wp_print_admin_styles', 20);187 add_action('admin_print_scripts', 'print_head_scripts', 20); 188 add_action('admin_print_footer_scripts', 'print_footer_scripts', 20); 189 add_action('admin_print_styles', 'print_admin_styles', 20); 188 190 add_action('init', 'smilies_init', 5); 189 191 add_action( 'plugins_loaded', 'wp_maybe_load_widgets', 0 ); -
trunk/wp-includes/script-loader.php
r10441 r10442 527 527 528 528 /** 529 * Print the script queue in the HTML head.529 * Prints the script queue in the HTML head on admin pages. 530 530 * 531 531 * Postpones the scripts that were queued for the footer. 532 * wp_print_footer_scripts() has to becalled in the footer to print these scripts.533 * 534 * @since unknown532 * print_footer_scripts() is called in the footer to print these scripts. 533 * 534 * @since 2.8 535 535 * @see wp_print_scripts() 536 536 */ 537 function wp_print_head_scripts() { 538 do_action( 'wp_print_scripts' ); 537 function print_head_scripts() { 538 if ( ! did_action('wp_print_scripts') ) 539 do_action('wp_print_scripts'); 540 539 541 global $wp_scripts, $concatenate_scripts; 540 542 … … 542 544 $wp_scripts = new WP_Scripts(); 543 545 544 if ( ! isset($concatenate_scripts) ) 545 script_concat_settings(); 546 546 script_concat_settings(); 547 547 $wp_scripts->do_concat = $concatenate_scripts; 548 548 $wp_scripts->do_head_items(); … … 551 551 _pring_scripts(); 552 552 553 $wp_scripts->do_concat = false; 554 $wp_scripts->print_code = $wp_scripts->concat = $wp_scripts->concat_version = $wp_scripts->print_html = $wp_scripts->src = ''; 553 $wp_scripts->reset(); 555 554 return $wp_scripts->done; 556 555 } 557 556 558 557 /** 559 * Print the scripts that were queued for the footer.560 * 561 * @since unknown562 */ 563 function wp_print_footer_scripts() {558 * Prints the scripts that were queued for the footer on admin pages. 559 * 560 * @since 2.8 561 */ 562 function print_footer_scripts() { 564 563 global $wp_scripts, $concatenate_scripts; 565 564 … … 567 566 return array(); // No need to run if not instantiated. 568 567 569 if ( ! isset($concatenate_scripts) ) 570 script_concat_settings(); 571 568 script_concat_settings(); 572 569 $wp_scripts->do_concat = $concatenate_scripts; 573 570 $wp_scripts->do_footer_items(); … … 576 573 _pring_scripts(); 577 574 578 $wp_scripts->do_concat = false; 579 $wp_scripts->concat = $wp_scripts->concat_version = $wp_scripts->print_code = $wp_scripts->print_html = $wp_scripts->src = ''; 575 $wp_scripts->reset(); 580 576 return $wp_scripts->done; 581 577 } … … 585 581 586 582 $zip = $compress_scripts ? 1 : 0; 583 if ( $zip && defined('ENFORCE_GZIP') && ENFORCE_GZIP ) 584 $zip = 'gzip'; 587 585 588 586 if ( !empty($wp_scripts->concat) ) { … … 596 594 } 597 595 598 $ver = md5("$wp_scripts->concat " . "$wp_scripts->concat_version");599 $src = $wp_scripts->base_url . "/wp-admin/load-scripts.php?c={$zip}&load=" . rtrim($wp_scripts->concat, ',') . "&ver=$ver";596 $ver = md5("$wp_scripts->concat_version"); 597 $src = $wp_scripts->base_url . "/wp-admin/load-scripts.php?c={$zip}&load=" . trim($wp_scripts->concat, ', ') . "&ver=$ver"; 600 598 echo "<script type='text/javascript' src='$src'></script>\n"; 601 599 } … … 603 601 if ( !empty($wp_scripts->print_html) ) 604 602 echo $wp_scripts->print_html; 605 606 } 607 608 function wp_print_admin_styles() { 603 } 604 605 /** 606 * Prints the script queue in the HTML head on the front end. 607 * 608 * Postpones the scripts that were queued for the footer. 609 * wp_print_footer_scripts() is called in the footer to print these scripts. 610 * 611 * @since 2.8 612 */ 613 function wp_print_head_scripts() { 614 if ( ! did_action('wp_print_scripts') ) 615 do_action('wp_print_scripts'); 616 617 global $wp_scripts; 618 619 if ( !is_a($wp_scripts, 'WP_Scripts') ) 620 return array(); // no need to run if nothing is queued 621 622 return print_head_scripts(); 623 } 624 625 /** 626 * Prints the scripts that were queued for the footer on the front end. 627 * 628 * @since 2.8 629 */ 630 function wp_print_footer_scripts() { 631 return print_footer_scripts(); 632 } 633 634 /** 635 * Wrapper for do_action('wp_enqueue_scripts') 636 * 637 * Allows plugins to queue scripts for the front end using wp_enqueue_script(). 638 * Runs first in wp_head() where all is_home(), is_page(), etc. functions are available. 639 * 640 * @since 2.8 641 */ 642 function wp_enqueue_scripts() { 643 do_action('wp_enqueue_scripts'); 644 } 645 646 function print_admin_styles() { 609 647 global $wp_styles, $concatenate_scripts, $compress_css; 610 648 … … 612 650 $wp_styles = new WP_Styles(); 613 651 614 if ( ! isset($concatenate_scripts) ) 615 script_concat_settings(); 616 652 script_concat_settings(); 617 653 $wp_styles->do_concat = $concatenate_scripts; 618 654 $zip = $compress_css ? 1 : 0; 655 if ( $zip && defined('ENFORCE_GZIP') && ENFORCE_GZIP ) 656 $zip = 'gzip'; 619 657 620 658 $wp_styles->do_items(false); … … 622 660 if ( apply_filters('print_admin_styles', true) ) { 623 661 if ( !empty($wp_styles->concat) ) { 624 $ ver = md5("$wp_styles->concat" . "$wp_styles->concat_version");625 $ rtl = 'rtl' === $wp_styles->text_direction ? 1 : 0;626 $href = $wp_styles->base_url . "/wp-admin/load-styles.php?c={$zip}& rtl={$rtl}&load=" . rtrim($wp_styles->concat, ',') . "&ver=$ver";662 $dir = $wp_styles->text_direction; 663 $ver = md5("$wp_styles->concat_version{$dir}"); 664 $href = $wp_styles->base_url . "/wp-admin/load-styles.php?c={$zip}&dir={$dir}&load=" . trim($wp_styles->concat, ', ') . "&ver=$ver"; 627 665 echo "<link rel='stylesheet' href='$href' type='text/css' media='all' />\n"; 628 666 } … … 640 678 global $concatenate_scripts, $compress_scripts, $compress_css; 641 679 642 $concatenate_scripts = defined('CONCATENATE_SCRIPTS') ? CONCATENATE_SCRIPTS : true; 643 if ( $concatenate_scripts && -1 == get_option('concatenate_scripts') ) 644 $concatenate_scripts = false; 645 646 $compress_scripts = defined('COMPRESS_SCRIPTS') ? COMPRESS_SCRIPTS : true; 647 if ( $compress_scripts && ! get_option('can_compress_scripts') ) 648 $compress_scripts = false; 649 650 $compress_css = defined('COMPRESS_CSS') ? COMPRESS_CSS : true; 651 if ( $compress_css && ! get_option('can_compress_scripts') ) 652 $compress_css = false; 680 if ( ! isset($concatenate_scripts) ) { 681 $concatenate_scripts = defined('CONCATENATE_SCRIPTS') ? CONCATENATE_SCRIPTS : true; 682 if ( ! is_admin() || ( $concatenate_scripts && -1 == get_user_option('concatenate_scripts') ) ) 683 $concatenate_scripts = false; 684 } 685 686 if ( ! isset($compress_scripts) ) { 687 $compress_scripts = defined('COMPRESS_SCRIPTS') ? COMPRESS_SCRIPTS : true; 688 if ( $compress_scripts && ! get_option('can_compress_scripts') ) 689 $compress_scripts = false; 690 } 691 692 if ( ! isset($compress_css) ) { 693 $compress_css = defined('COMPRESS_CSS') ? COMPRESS_CSS : true; 694 if ( $compress_css && ! get_option('can_compress_scripts') ) 695 $compress_css = false; 696 } 653 697 } 654 698
Note: See TracChangeset
for help on using the changeset viewer.