~canonical-sysadmins/wordpress/4.2.4

« back to all changes in this revision

Viewing changes to wp-includes/class.wp-styles.php

  • Committer: Nick Moffitt
  • Date: 2015-01-15 11:05:37 UTC
  • mfrom: (1.1.1 wp4-upstream)
  • Revision ID: nick.moffitt@canonical.com-20150115110537-8bp1y42eyg0jsa7c
Tags: 4.1
MergeĀ upstreamĀ versionĀ 4.1

Show diffs side-by-side

added added

removed removed

Lines of Context:
39
39
                do_action_ref_array( 'wp_default_styles', array(&$this) );
40
40
        }
41
41
 
 
42
        /**
 
43
         * @param string $handle
 
44
         * @return bool
 
45
         */
42
46
        public function do_item( $handle ) {
43
47
                if ( !parent::do_item($handle) )
44
48
                        return false;
110
114
                if ( $this->do_concat ) {
111
115
                        $this->print_html .= $tag;
112
116
                        if ( $inline_style = $this->print_inline_style( $handle, false ) )
113
 
                                $this->print_html .= sprintf( "<style type='text/css'>\n%s\n</style>\n", $inline_style );
 
117
                                $this->print_html .= sprintf( "<style id='%s-inline-css' type='text/css'>\n%s\n</style>\n", esc_attr( $handle ), $inline_style );
114
118
                } else {
115
119
                        echo $tag;
116
120
                        $this->print_inline_style( $handle );
119
123
                return true;
120
124
        }
121
125
 
 
126
        /**
 
127
         * @param string $handle
 
128
         * @param string $code
 
129
         */
122
130
        public function add_inline_style( $handle, $code ) {
123
 
                if ( !$code )
 
131
                if ( ! $code ) {
124
132
                        return false;
 
133
                }
125
134
 
126
135
                $after = $this->get_data( $handle, 'after' );
127
 
                if ( !$after )
 
136
                if ( ! $after ) {
128
137
                        $after = array();
 
138
                }
129
139
 
130
140
                $after[] = $code;
131
141
 
132
142
                return $this->add_data( $handle, 'after', $after );
133
143
        }
134
144
 
 
145
        /**
 
146
         * @param string $handle
 
147
         * @param bool $echo
 
148
         * @return bool
 
149
         */
135
150
        public function print_inline_style( $handle, $echo = true ) {
136
151
                $output = $this->get_data( $handle, 'after' );
137
152
 
138
 
                if ( empty( $output ) )
 
153
                if ( empty( $output ) ) {
139
154
                        return false;
 
155
                }
140
156
 
141
157
                $output = implode( "\n", $output );
142
158
 
143
 
                if ( !$echo )
 
159
                if ( ! $echo ) {
144
160
                        return $output;
 
161
                }
145
162
 
146
 
                echo "<style type='text/css'>\n";
147
 
                echo "$output\n";
148
 
                echo "</style>\n";
 
163
                printf( "<style id='%s-inline-css' type='text/css'>\n%s\n</style>\n", esc_attr( $handle ), $output );
149
164
 
150
165
                return true;
151
166
        }
152
167
 
 
168
        /**
 
169
         * @param mixed $handles
 
170
         * @param bool $recursion
 
171
         * @param mixed $group
 
172
         * @return bool
 
173
         */
153
174
        public function all_deps( $handles, $recursion = false, $group = false ) {
154
175
                $r = parent::all_deps( $handles, $recursion );
155
176
                if ( !$recursion ) {
165
186
                return $r;
166
187
        }
167
188
 
 
189
        /**
 
190
         * @param string $src
 
191
         * @param string $ver
 
192
         * @param string $handle
 
193
         * @return string
 
194
         */
168
195
        public function _css_href( $src, $ver, $handle ) {
169
196
                if ( !is_bool($src) && !preg_match('|^(https?:)?//|', $src) && ! ( $this->content_url && 0 === strpos($src, $this->content_url) ) ) {
170
197
                        $src = $this->base_url . $src;
185
212
                return esc_url( $src );
186
213
        }
187
214
 
 
215
        /**
 
216
         * @param string $src
 
217
         * @return bool
 
218
         */
188
219
        public function in_default_dir($src) {
189
220
                if ( ! $this->default_dirs )
190
221
                        return true;