~tennessee.team/www-ubuntu-us-tn/trunk

« back to all changes in this revision

Viewing changes to news/wp-admin/load-styles.php

  • Committer: Christopher Lunsford
  • Date: 2009-09-09 20:30:13 UTC
  • Revision ID: binarymutant@gmail.com-20090909203013-jureydmhbulqtl4c
merge

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
<?php
 
2
 
 
3
/**
 
4
 * Disable error reporting
 
5
 *
 
6
 * Set this to error_reporting( E_ALL ) or error_reporting( E_ALL | E_STRICT ) for debugging
 
7
 */
 
8
error_reporting(0);
 
9
 
 
10
/** Set ABSPATH for execution */
 
11
define( 'ABSPATH', dirname(dirname(__FILE__)) . '/' );
 
12
define( 'WPINC', 'wp-includes' );
 
13
 
 
14
/**
 
15
 * @ignore
 
16
 */
 
17
function __() {}
 
18
 
 
19
/**
 
20
 * @ignore
 
21
 */
 
22
function _c() {}
 
23
 
 
24
/**
 
25
 * @ignore
 
26
 */
 
27
function _x() {}
 
28
 
 
29
 
 
30
/**
 
31
 * @ignore
 
32
 */
 
33
function add_filter() {}
 
34
 
 
35
/**
 
36
 * @ignore
 
37
 */
 
38
function esc_attr() {}
 
39
 
 
40
/**
 
41
 * @ignore
 
42
 */
 
43
function apply_filters() {}
 
44
 
 
45
/**
 
46
 * @ignore
 
47
 */
 
48
function get_option() {}
 
49
 
 
50
/**
 
51
 * @ignore
 
52
 */
 
53
function is_lighttpd_before_150() {}
 
54
 
 
55
/**
 
56
 * @ignore
 
57
 */
 
58
function add_action() {}
 
59
 
 
60
/**
 
61
 * @ignore
 
62
 */
 
63
function do_action_ref_array() {}
 
64
 
 
65
/**
 
66
 * @ignore
 
67
 */
 
68
function get_bloginfo() {}
 
69
 
 
70
/**
 
71
 * @ignore
 
72
 */
 
73
function is_admin() {return true;}
 
74
 
 
75
/**
 
76
 * @ignore
 
77
 */
 
78
function site_url() {}
 
79
 
 
80
/**
 
81
 * @ignore
 
82
 */
 
83
function admin_url() {}
 
84
 
 
85
/**
 
86
 * @ignore
 
87
 */
 
88
function wp_guess_url() {}
 
89
 
 
90
function get_file($path) {
 
91
 
 
92
        if ( function_exists('realpath') )
 
93
                $path = realpath($path);
 
94
 
 
95
        if ( ! $path || ! @is_file($path) )
 
96
                return '';
 
97
 
 
98
        return @file_get_contents($path);
 
99
}
 
100
 
 
101
require(ABSPATH . '/wp-includes/script-loader.php');
 
102
require(ABSPATH . '/wp-includes/version.php');
 
103
 
 
104
$load = preg_replace( '/[^a-z0-9,_-]+/i', '', $_GET['load'] );
 
105
$load = explode(',', $load);
 
106
 
 
107
if ( empty($load) )
 
108
        exit;
 
109
 
 
110
$compress = ( isset($_GET['c']) && $_GET['c'] );
 
111
$force_gzip = ( $compress && 'gzip' == $_GET['c'] );
 
112
$rtl = ( isset($_GET['dir']) && 'rtl' == $_GET['dir'] );
 
113
$expires_offset = 31536000;
 
114
$out = '';
 
115
 
 
116
$wp_styles = new WP_Styles();
 
117
wp_default_styles($wp_styles);
 
118
 
 
119
foreach( $load as $handle ) {
 
120
        if ( !array_key_exists($handle, $wp_styles->registered) )
 
121
                continue;
 
122
 
 
123
        $style = $wp_styles->registered[$handle];
 
124
        $path = ABSPATH . $style->src;
 
125
 
 
126
        $content = get_file($path) . "\n";
 
127
 
 
128
        if ( $rtl && isset($style->extra['rtl']) && $style->extra['rtl'] ) {
 
129
                $rtl_path = is_bool($style->extra['rtl']) ? str_replace( '.css', '-rtl.css', $path ) : ABSPATH . $style->extra['rtl'];
 
130
                $content .= get_file($rtl_path) . "\n";
 
131
        }
 
132
 
 
133
        $out .= str_replace( '../images/', 'images/', $content );
 
134
}
 
135
 
 
136
header('Content-Type: text/css');
 
137
header('Expires: ' . gmdate( "D, d M Y H:i:s", time() + $expires_offset ) . ' GMT');
 
138
header("Cache-Control: public, max-age=$expires_offset");
 
139
 
 
140
if ( $compress && ! ini_get('zlib.output_compression') && 'ob_gzhandler' != ini_get('output_handler') ) {
 
141
        header('Vary: Accept-Encoding'); // Handle proxies
 
142
        if ( false !== strpos( strtolower($_SERVER['HTTP_ACCEPT_ENCODING']), 'deflate') && function_exists('gzdeflate') && ! $force_gzip ) {
 
143
                header('Content-Encoding: deflate');
 
144
                $out = gzdeflate( $out, 3 );
 
145
        } elseif ( false !== strpos( strtolower($_SERVER['HTTP_ACCEPT_ENCODING']), 'gzip') && function_exists('gzencode') ) {
 
146
                header('Content-Encoding: gzip');
 
147
                $out = gzencode( $out, 3 );
 
148
        }
 
149
}
 
150
 
 
151
echo $out;
 
152
exit;