@@ -3,13 +3,14 @@ discard block |
||
3 | 3 | * Loads the correct template based on the visitor's url |
4 | 4 | * @package WordPress |
5 | 5 | */ |
6 | -if ( defined('WP_USE_THEMES') && WP_USE_THEMES ) |
|
6 | +if ( defined('WP_USE_THEMES') && WP_USE_THEMES ) { |
|
7 | 7 | /** |
8 | 8 | * Fires before determining which template to load. |
9 | 9 | * |
10 | 10 | * @since 1.5.0 |
11 | 11 | */ |
12 | 12 | do_action( 'template_redirect' ); |
13 | +} |
|
13 | 14 | |
14 | 15 | /** |
15 | 16 | * Filter whether to allow 'HEAD' requests to generate content. |
@@ -21,8 +22,9 @@ discard block |
||
21 | 22 | * |
22 | 23 | * @param bool $exit Whether to exit without generating any content for 'HEAD' requests. Default true. |
23 | 24 | */ |
24 | -if ( 'HEAD' === $_SERVER['REQUEST_METHOD'] && apply_filters( 'exit_on_http_head', true ) ) |
|
25 | +if ( 'HEAD' === $_SERVER['REQUEST_METHOD'] && apply_filters( 'exit_on_http_head', true ) ) { |
|
25 | 26 | exit(); |
27 | +} |
|
26 | 28 | |
27 | 29 | // Process feeds and trackbacks even if not using themes. |
28 | 30 | if ( is_robots() ) : |
@@ -61,8 +63,10 @@ discard block |
||
61 | 63 | elseif ( is_date() && $template = get_date_template() ) : |
62 | 64 | elseif ( is_archive() && $template = get_archive_template() ) : |
63 | 65 | elseif ( is_paged() && $template = get_paged_template() ) : |
64 | - else : |
|
66 | + else { |
|
67 | + : |
|
65 | 68 | $template = get_index_template(); |
69 | + } |
|
66 | 70 | endif; |
67 | 71 | /** |
68 | 72 | * Filter the path of the current template before including it. |
@@ -3,13 +3,13 @@ discard block |
||
3 | 3 | * Loads the correct template based on the visitor's url |
4 | 4 | * @package WordPress |
5 | 5 | */ |
6 | -if ( defined('WP_USE_THEMES') && WP_USE_THEMES ) |
|
6 | +if (defined('WP_USE_THEMES') && WP_USE_THEMES) |
|
7 | 7 | /** |
8 | 8 | * Fires before determining which template to load. |
9 | 9 | * |
10 | 10 | * @since 1.5.0 |
11 | 11 | */ |
12 | - do_action( 'template_redirect' ); |
|
12 | + do_action('template_redirect'); |
|
13 | 13 | |
14 | 14 | /** |
15 | 15 | * Filters whether to allow 'HEAD' requests to generate content. |
@@ -21,45 +21,45 @@ discard block |
||
21 | 21 | * |
22 | 22 | * @param bool $exit Whether to exit without generating any content for 'HEAD' requests. Default true. |
23 | 23 | */ |
24 | -if ( 'HEAD' === $_SERVER['REQUEST_METHOD'] && apply_filters( 'exit_on_http_head', true ) ) |
|
24 | +if ('HEAD' === $_SERVER['REQUEST_METHOD'] && apply_filters('exit_on_http_head', true)) |
|
25 | 25 | exit(); |
26 | 26 | |
27 | 27 | // Process feeds and trackbacks even if not using themes. |
28 | -if ( is_robots() ) : |
|
28 | +if (is_robots()) : |
|
29 | 29 | /** |
30 | 30 | * Fired when the template loader determines a robots.txt request. |
31 | 31 | * |
32 | 32 | * @since 2.1.0 |
33 | 33 | */ |
34 | - do_action( 'do_robots' ); |
|
34 | + do_action('do_robots'); |
|
35 | 35 | return; |
36 | -elseif ( is_feed() ) : |
|
36 | +elseif (is_feed()) : |
|
37 | 37 | do_feed(); |
38 | 38 | return; |
39 | -elseif ( is_trackback() ) : |
|
40 | - include( ABSPATH . 'wp-trackback.php' ); |
|
39 | +elseif (is_trackback()) : |
|
40 | + include(ABSPATH.'wp-trackback.php'); |
|
41 | 41 | return; |
42 | 42 | endif; |
43 | 43 | |
44 | -if ( defined('WP_USE_THEMES') && WP_USE_THEMES ) : |
|
44 | +if (defined('WP_USE_THEMES') && WP_USE_THEMES) : |
|
45 | 45 | $template = false; |
46 | - if ( is_embed() && $template = get_embed_template() ) : |
|
47 | - elseif ( is_404() && $template = get_404_template() ) : |
|
48 | - elseif ( is_search() && $template = get_search_template() ) : |
|
49 | - elseif ( is_front_page() && $template = get_front_page_template() ) : |
|
50 | - elseif ( is_home() && $template = get_home_template() ) : |
|
51 | - elseif ( is_post_type_archive() && $template = get_post_type_archive_template() ) : |
|
52 | - elseif ( is_tax() && $template = get_taxonomy_template() ) : |
|
53 | - elseif ( is_attachment() && $template = get_attachment_template() ) : |
|
46 | + if (is_embed() && $template = get_embed_template()) : |
|
47 | + elseif (is_404() && $template = get_404_template()) : |
|
48 | + elseif (is_search() && $template = get_search_template()) : |
|
49 | + elseif (is_front_page() && $template = get_front_page_template()) : |
|
50 | + elseif (is_home() && $template = get_home_template()) : |
|
51 | + elseif (is_post_type_archive() && $template = get_post_type_archive_template()) : |
|
52 | + elseif (is_tax() && $template = get_taxonomy_template()) : |
|
53 | + elseif (is_attachment() && $template = get_attachment_template()) : |
|
54 | 54 | remove_filter('the_content', 'prepend_attachment'); |
55 | - elseif ( is_single() && $template = get_single_template() ) : |
|
56 | - elseif ( is_page() && $template = get_page_template() ) : |
|
57 | - elseif ( is_singular() && $template = get_singular_template() ) : |
|
58 | - elseif ( is_category() && $template = get_category_template() ) : |
|
59 | - elseif ( is_tag() && $template = get_tag_template() ) : |
|
60 | - elseif ( is_author() && $template = get_author_template() ) : |
|
61 | - elseif ( is_date() && $template = get_date_template() ) : |
|
62 | - elseif ( is_archive() && $template = get_archive_template() ) : |
|
55 | + elseif (is_single() && $template = get_single_template()) : |
|
56 | + elseif (is_page() && $template = get_page_template()) : |
|
57 | + elseif (is_singular() && $template = get_singular_template()) : |
|
58 | + elseif (is_category() && $template = get_category_template()) : |
|
59 | + elseif (is_tag() && $template = get_tag_template()) : |
|
60 | + elseif (is_author() && $template = get_author_template()) : |
|
61 | + elseif (is_date() && $template = get_date_template()) : |
|
62 | + elseif (is_archive() && $template = get_archive_template()) : |
|
63 | 63 | else : |
64 | 64 | $template = get_index_template(); |
65 | 65 | endif; |
@@ -70,12 +70,12 @@ discard block |
||
70 | 70 | * |
71 | 71 | * @param string $template The path of the template to include. |
72 | 72 | */ |
73 | - if ( $template = apply_filters( 'template_include', $template ) ) { |
|
74 | - include( $template ); |
|
75 | - } elseif ( current_user_can( 'switch_themes' ) ) { |
|
73 | + if ($template = apply_filters('template_include', $template)) { |
|
74 | + include($template); |
|
75 | + } elseif (current_user_can('switch_themes')) { |
|
76 | 76 | $theme = wp_get_theme(); |
77 | - if ( $theme->errors() ) { |
|
78 | - wp_die( $theme->errors() ); |
|
77 | + if ($theme->errors()) { |
|
78 | + wp_die($theme->errors()); |
|
79 | 79 | } |
80 | 80 | } |
81 | 81 | return; |
@@ -139,8 +139,9 @@ discard block |
||
139 | 139 | function wp_print_media_templates() { |
140 | 140 | global $is_IE; |
141 | 141 | $class = 'media-modal wp-core-ui'; |
142 | - if ( $is_IE && strpos($_SERVER['HTTP_USER_AGENT'], 'MSIE 7') !== false ) |
|
143 | - $class .= ' ie7'; |
|
142 | + if ( $is_IE && strpos($_SERVER['HTTP_USER_AGENT'], 'MSIE 7') !== false ) { |
|
143 | + $class .= ' ie7'; |
|
144 | + } |
|
144 | 145 | ?> |
145 | 146 | <!--[if lte IE 8]> |
146 | 147 | <style> |
@@ -198,9 +199,12 @@ discard block |
||
198 | 199 | /** This action is documented in wp-admin/includes/media.php */ |
199 | 200 | do_action( 'upload_ui_over_quota' ); ?> |
200 | 201 | |
201 | - <?php else : ?> |
|
202 | + <?php else { |
|
203 | + : ?> |
|
202 | 204 | <div class="upload-ui"> |
203 | - <h2 class="upload-instructions drop-instructions"><?php _e( 'Drop files anywhere to upload' ); ?></h2> |
|
205 | + <h2 class="upload-instructions drop-instructions"><?php _e( 'Drop files anywhere to upload' ); |
|
206 | +} |
|
207 | +?></h2> |
|
204 | 208 | <p class="upload-instructions drop-instructions"><?php _ex( 'or', 'Uploader: Drop files here - or - Select Files' ); ?></p> |
205 | 209 | <button type="button" class="browser button button-hero"><?php _e( 'Select Files' ); ?></button> |
206 | 210 | </div> |
@@ -432,8 +436,11 @@ discard block |
||
432 | 436 | <# } else { #> |
433 | 437 | <button type="button" class="button-link trash-attachment"><?php _ex( 'Trash', 'verb' ); ?></button> |
434 | 438 | <# } #> |
435 | - <?php else: ?> |
|
436 | - <button type="button" class="button-link delete-attachment"><?php _e( 'Delete Permanently' ); ?></button> |
|
439 | + <?php else { |
|
440 | + : ?> |
|
441 | + <button type="button" class="button-link delete-attachment"><?php _e( 'Delete Permanently' ); |
|
442 | +} |
|
443 | +?></button> |
|
437 | 444 | <?php endif; ?> |
438 | 445 | <# } #> |
439 | 446 | </div> |
@@ -533,8 +540,11 @@ discard block |
||
533 | 540 | <# } else { #> |
534 | 541 | <button type="button" class="button-link trash-attachment"><?php _ex( 'Trash', 'verb' ); ?></button> |
535 | 542 | <# } #> |
536 | - <?php else: ?> |
|
537 | - <button type="button" class="button-link delete-attachment"><?php _e( 'Delete Permanently' ); ?></button> |
|
543 | + <?php else { |
|
544 | + : ?> |
|
545 | + <button type="button" class="button-link delete-attachment"><?php _e( 'Delete Permanently' ); |
|
546 | +} |
|
547 | +?></button> |
|
538 | 548 | <?php endif; ?> |
539 | 549 | <# } #> |
540 | 550 |
@@ -22,7 +22,7 @@ discard block |
||
22 | 22 | width="{{ _.isUndefined( data.model.width ) ? 400 : data.model.width }}" |
23 | 23 | preload="{{ _.isUndefined( data.model.preload ) ? 'none' : data.model.preload }}" |
24 | 24 | <# |
25 | - <?php foreach ( array( 'autoplay', 'loop' ) as $attr ): |
|
25 | + <?php foreach (array('autoplay', 'loop') as $attr): |
|
26 | 26 | ?>if ( ! _.isUndefined( data.model.<?php echo $attr ?> ) && data.model.<?php echo $attr ?> ) { |
27 | 27 | #> <?php echo $attr ?><# |
28 | 28 | } |
@@ -32,7 +32,7 @@ discard block |
||
32 | 32 | <source src="{{ data.model.src }}" type="{{ wp.media.view.settings.embedMimes[ data.model.src.split('.').pop() ] }}" /> |
33 | 33 | <# } #> |
34 | 34 | |
35 | - <?php foreach ( $audio_types as $type ): |
|
35 | + <?php foreach ($audio_types as $type): |
|
36 | 36 | ?><# if ( ! _.isEmpty( data.model.<?php echo $type ?> ) ) { #> |
37 | 37 | <source src="{{ data.model.<?php echo $type ?> }}" type="{{ wp.media.view.settings.embedMimes[ '<?php echo $type ?>' ] }}" /> |
38 | 38 | <# } #> |
@@ -90,9 +90,9 @@ discard block |
||
90 | 90 | <# if ( w ) { #>width="{{ w }}"<# } #> |
91 | 91 | <# if ( h ) { #>height="{{ h }}"<# } #> |
92 | 92 | <?php |
93 | - $props = array( 'poster' => '', 'preload' => 'metadata' ); |
|
94 | - foreach ( $props as $key => $value ): |
|
95 | - if ( empty( $value ) ) { |
|
93 | + $props = array('poster' => '', 'preload' => 'metadata'); |
|
94 | + foreach ($props as $key => $value): |
|
95 | + if (empty($value)) { |
|
96 | 96 | ?><# |
97 | 97 | if ( ! _.isUndefined( data.model.<?php echo $key ?> ) && data.model.<?php echo $key ?> ) { |
98 | 98 | #> <?php echo $key ?>="{{ data.model.<?php echo $key ?> }}"<# |
@@ -102,7 +102,7 @@ discard block |
||
102 | 102 | } |
103 | 103 | endforeach; |
104 | 104 | ?><# |
105 | - <?php foreach ( array( 'autoplay', 'loop' ) as $attr ): |
|
105 | + <?php foreach (array('autoplay', 'loop') as $attr): |
|
106 | 106 | ?> if ( ! _.isUndefined( data.model.<?php echo $attr ?> ) && data.model.<?php echo $attr ?> ) { |
107 | 107 | #> <?php echo $attr ?><# |
108 | 108 | } |
@@ -118,7 +118,7 @@ discard block |
||
118 | 118 | <# } |
119 | 119 | } #> |
120 | 120 | |
121 | - <?php foreach ( $video_types as $type ): |
|
121 | + <?php foreach ($video_types as $type): |
|
122 | 122 | ?><# if ( data.model.<?php echo $type ?> ) { #> |
123 | 123 | <source src="{{ data.model.<?php echo $type ?> }}" type="{{ settings.embedMimes[ '<?php echo $type ?>' ] }}" /> |
124 | 124 | <# } #> |
@@ -139,7 +139,7 @@ discard block |
||
139 | 139 | function wp_print_media_templates() { |
140 | 140 | global $is_IE; |
141 | 141 | $class = 'media-modal wp-core-ui'; |
142 | - if ( $is_IE && strpos($_SERVER['HTTP_USER_AGENT'], 'MSIE 7') !== false ) |
|
142 | + if ($is_IE && strpos($_SERVER['HTTP_USER_AGENT'], 'MSIE 7') !== false) |
|
143 | 143 | $class .= ' ie7'; |
144 | 144 | ?> |
145 | 145 | <!--[if lte IE 8]> |
@@ -163,7 +163,7 @@ discard block |
||
163 | 163 | |
164 | 164 | <script type="text/html" id="tmpl-media-modal"> |
165 | 165 | <div class="<?php echo $class; ?>"> |
166 | - <button type="button" class="button-link media-modal-close"><span class="media-modal-icon"><span class="screen-reader-text"><?php _e( 'Close media panel' ); ?></span></span></button> |
|
166 | + <button type="button" class="button-link media-modal-close"><span class="media-modal-icon"><span class="screen-reader-text"><?php _e('Close media panel'); ?></span></span></button> |
|
167 | 167 | <div class="media-modal-content"></div> |
168 | 168 | </div> |
169 | 169 | <div class="media-modal-backdrop"></div> |
@@ -171,38 +171,38 @@ discard block |
||
171 | 171 | |
172 | 172 | <script type="text/html" id="tmpl-uploader-window"> |
173 | 173 | <div class="uploader-window-content"> |
174 | - <h1><?php _e( 'Drop files to upload' ); ?></h1> |
|
174 | + <h1><?php _e('Drop files to upload'); ?></h1> |
|
175 | 175 | </div> |
176 | 176 | </script> |
177 | 177 | |
178 | 178 | <script type="text/html" id="tmpl-uploader-editor"> |
179 | 179 | <div class="uploader-editor-content"> |
180 | - <div class="uploader-editor-title"><?php _e( 'Drop files to upload' ); ?></div> |
|
180 | + <div class="uploader-editor-title"><?php _e('Drop files to upload'); ?></div> |
|
181 | 181 | </div> |
182 | 182 | </script> |
183 | 183 | |
184 | 184 | <script type="text/html" id="tmpl-uploader-inline"> |
185 | 185 | <# var messageClass = data.message ? 'has-upload-message' : 'no-upload-message'; #> |
186 | 186 | <# if ( data.canClose ) { #> |
187 | - <button class="close dashicons dashicons-no"><span class="screen-reader-text"><?php _e( 'Close uploader' ); ?></span></button> |
|
187 | + <button class="close dashicons dashicons-no"><span class="screen-reader-text"><?php _e('Close uploader'); ?></span></button> |
|
188 | 188 | <# } #> |
189 | 189 | <div class="uploader-inline-content {{ messageClass }}"> |
190 | 190 | <# if ( data.message ) { #> |
191 | 191 | <h2 class="upload-message">{{ data.message }}</h2> |
192 | 192 | <# } #> |
193 | - <?php if ( ! _device_can_upload() ) : ?> |
|
194 | - <h2 class="upload-instructions"><?php printf( __( 'The web browser on your device cannot be used to upload files. You may be able to use the <a href="%s">native app for your device</a> instead.' ), 'https://apps.wordpress.org/' ); ?></h2> |
|
195 | - <?php elseif ( is_multisite() && ! is_upload_space_available() ) : ?> |
|
196 | - <h2 class="upload-instructions"><?php _e( 'Upload Limit Exceeded' ); ?></h2> |
|
193 | + <?php if ( ! _device_can_upload()) : ?> |
|
194 | + <h2 class="upload-instructions"><?php printf(__('The web browser on your device cannot be used to upload files. You may be able to use the <a href="%s">native app for your device</a> instead.'), 'https://apps.wordpress.org/'); ?></h2> |
|
195 | + <?php elseif (is_multisite() && ! is_upload_space_available()) : ?> |
|
196 | + <h2 class="upload-instructions"><?php _e('Upload Limit Exceeded'); ?></h2> |
|
197 | 197 | <?php |
198 | 198 | /** This action is documented in wp-admin/includes/media.php */ |
199 | - do_action( 'upload_ui_over_quota' ); ?> |
|
199 | + do_action('upload_ui_over_quota'); ?> |
|
200 | 200 | |
201 | 201 | <?php else : ?> |
202 | 202 | <div class="upload-ui"> |
203 | - <h2 class="upload-instructions drop-instructions"><?php _e( 'Drop files anywhere to upload' ); ?></h2> |
|
204 | - <p class="upload-instructions drop-instructions"><?php _ex( 'or', 'Uploader: Drop files here - or - Select Files' ); ?></p> |
|
205 | - <button type="button" class="browser button button-hero"><?php _e( 'Select Files' ); ?></button> |
|
203 | + <h2 class="upload-instructions drop-instructions"><?php _e('Drop files anywhere to upload'); ?></h2> |
|
204 | + <p class="upload-instructions drop-instructions"><?php _ex('or', 'Uploader: Drop files here - or - Select Files'); ?></p> |
|
205 | + <button type="button" class="browser button button-hero"><?php _e('Select Files'); ?></button> |
|
206 | 206 | </div> |
207 | 207 | |
208 | 208 | <div class="upload-inline-status"></div> |
@@ -210,55 +210,55 @@ discard block |
||
210 | 210 | <div class="post-upload-ui"> |
211 | 211 | <?php |
212 | 212 | /** This action is documented in wp-admin/includes/media.php */ |
213 | - do_action( 'pre-upload-ui' ); |
|
213 | + do_action('pre-upload-ui'); |
|
214 | 214 | /** This action is documented in wp-admin/includes/media.php */ |
215 | - do_action( 'pre-plupload-upload-ui' ); |
|
215 | + do_action('pre-plupload-upload-ui'); |
|
216 | 216 | |
217 | - if ( 10 === remove_action( 'post-plupload-upload-ui', 'media_upload_flash_bypass' ) ) { |
|
217 | + if (10 === remove_action('post-plupload-upload-ui', 'media_upload_flash_bypass')) { |
|
218 | 218 | /** This action is documented in wp-admin/includes/media.php */ |
219 | - do_action( 'post-plupload-upload-ui' ); |
|
220 | - add_action( 'post-plupload-upload-ui', 'media_upload_flash_bypass' ); |
|
219 | + do_action('post-plupload-upload-ui'); |
|
220 | + add_action('post-plupload-upload-ui', 'media_upload_flash_bypass'); |
|
221 | 221 | } else { |
222 | 222 | /** This action is documented in wp-admin/includes/media.php */ |
223 | - do_action( 'post-plupload-upload-ui' ); |
|
223 | + do_action('post-plupload-upload-ui'); |
|
224 | 224 | } |
225 | 225 | |
226 | 226 | $max_upload_size = wp_max_upload_size(); |
227 | - if ( ! $max_upload_size ) { |
|
227 | + if ( ! $max_upload_size) { |
|
228 | 228 | $max_upload_size = 0; |
229 | 229 | } |
230 | 230 | ?> |
231 | 231 | |
232 | 232 | <p class="max-upload-size"><?php |
233 | - printf( __( 'Maximum upload file size: %s.' ), esc_html( size_format( $max_upload_size ) ) ); |
|
233 | + printf(__('Maximum upload file size: %s.'), esc_html(size_format($max_upload_size))); |
|
234 | 234 | ?></p> |
235 | 235 | |
236 | 236 | <# if ( data.suggestedWidth && data.suggestedHeight ) { #> |
237 | 237 | <p class="suggested-dimensions"> |
238 | - <?php _e( 'Suggested image dimensions:' ); ?> {{data.suggestedWidth}} × {{data.suggestedHeight}} |
|
238 | + <?php _e('Suggested image dimensions:'); ?> {{data.suggestedWidth}} × {{data.suggestedHeight}} |
|
239 | 239 | </p> |
240 | 240 | <# } #> |
241 | 241 | |
242 | 242 | <?php |
243 | 243 | /** This action is documented in wp-admin/includes/media.php */ |
244 | - do_action( 'post-upload-ui' ); ?> |
|
244 | + do_action('post-upload-ui'); ?> |
|
245 | 245 | </div> |
246 | 246 | <?php endif; ?> |
247 | 247 | </div> |
248 | 248 | </script> |
249 | 249 | |
250 | 250 | <script type="text/html" id="tmpl-media-library-view-switcher"> |
251 | - <a href="<?php echo esc_url( add_query_arg( 'mode', 'list', $_SERVER['REQUEST_URI'] ) ) ?>" class="view-list"> |
|
252 | - <span class="screen-reader-text"><?php _e( 'List View' ); ?></span> |
|
251 | + <a href="<?php echo esc_url(add_query_arg('mode', 'list', $_SERVER['REQUEST_URI'])) ?>" class="view-list"> |
|
252 | + <span class="screen-reader-text"><?php _e('List View'); ?></span> |
|
253 | 253 | </a> |
254 | - <a href="<?php echo esc_url( add_query_arg( 'mode', 'grid', $_SERVER['REQUEST_URI'] ) ) ?>" class="view-grid current"> |
|
255 | - <span class="screen-reader-text"><?php _e( 'Grid View' ); ?></span> |
|
254 | + <a href="<?php echo esc_url(add_query_arg('mode', 'grid', $_SERVER['REQUEST_URI'])) ?>" class="view-grid current"> |
|
255 | + <span class="screen-reader-text"><?php _e('Grid View'); ?></span> |
|
256 | 256 | </a> |
257 | 257 | </script> |
258 | 258 | |
259 | 259 | <script type="text/html" id="tmpl-uploader-status"> |
260 | - <h2><?php _e( 'Uploading' ); ?></h2> |
|
261 | - <button type="button" class="button-link upload-dismiss-errors"><span class="screen-reader-text"><?php _e( 'Dismiss Errors' ); ?></span></button> |
|
260 | + <h2><?php _e('Uploading'); ?></h2> |
|
261 | + <button type="button" class="button-link upload-dismiss-errors"><span class="screen-reader-text"><?php _e('Dismiss Errors'); ?></span></button> |
|
262 | 262 | |
263 | 263 | <div class="media-progress-bar"><div></div></div> |
264 | 264 | <div class="upload-details"> |
@@ -278,8 +278,8 @@ discard block |
||
278 | 278 | |
279 | 279 | <script type="text/html" id="tmpl-edit-attachment-frame"> |
280 | 280 | <div class="edit-media-header"> |
281 | - <button class="left dashicons <# if ( ! data.hasPrevious ) { #> disabled <# } #>"><span class="screen-reader-text"><?php _e( 'Edit previous media item' ); ?></span></button> |
|
282 | - <button class="right dashicons <# if ( ! data.hasNext ) { #> disabled <# } #>"><span class="screen-reader-text"><?php _e( 'Edit next media item' ); ?></span></button> |
|
281 | + <button class="left dashicons <# if ( ! data.hasPrevious ) { #> disabled <# } #>"><span class="screen-reader-text"><?php _e('Edit previous media item'); ?></span></button> |
|
282 | + <button class="right dashicons <# if ( ! data.hasNext ) { #> disabled <# } #>"><span class="screen-reader-text"><?php _e('Edit next media item'); ?></span></button> |
|
283 | 283 | </div> |
284 | 284 | <div class="media-frame-title"></div> |
285 | 285 | <div class="media-frame-content"></div> |
@@ -324,9 +324,9 @@ discard block |
||
324 | 324 | |
325 | 325 | <div class="attachment-actions"> |
326 | 326 | <# if ( 'image' === data.type && ! data.uploading && data.sizes && data.can.save ) { #> |
327 | - <button type="button" class="button edit-attachment"><?php _e( 'Edit Image' ); ?></button> |
|
327 | + <button type="button" class="button edit-attachment"><?php _e('Edit Image'); ?></button> |
|
328 | 328 | <# } else if ( 'pdf' === data.subtype && data.sizes ) { #> |
329 | - <?php _e( 'Document Preview' ); ?> |
|
329 | + <?php _e('Document Preview'); ?> |
|
330 | 330 | <# } #> |
331 | 331 | </div> |
332 | 332 | </div> |
@@ -337,24 +337,24 @@ discard block |
||
337 | 337 | <span class="saved"><?php esc_html_e('Saved.'); ?></span> |
338 | 338 | </span> |
339 | 339 | <div class="details"> |
340 | - <div class="filename"><strong><?php _e( 'File name:' ); ?></strong> {{ data.filename }}</div> |
|
341 | - <div class="filename"><strong><?php _e( 'File type:' ); ?></strong> {{ data.mime }}</div> |
|
342 | - <div class="uploaded"><strong><?php _e( 'Uploaded on:' ); ?></strong> {{ data.dateFormatted }}</div> |
|
340 | + <div class="filename"><strong><?php _e('File name:'); ?></strong> {{ data.filename }}</div> |
|
341 | + <div class="filename"><strong><?php _e('File type:'); ?></strong> {{ data.mime }}</div> |
|
342 | + <div class="uploaded"><strong><?php _e('Uploaded on:'); ?></strong> {{ data.dateFormatted }}</div> |
|
343 | 343 | |
344 | - <div class="file-size"><strong><?php _e( 'File size:' ); ?></strong> {{ data.filesizeHumanReadable }}</div> |
|
344 | + <div class="file-size"><strong><?php _e('File size:'); ?></strong> {{ data.filesizeHumanReadable }}</div> |
|
345 | 345 | <# if ( 'image' === data.type && ! data.uploading ) { #> |
346 | 346 | <# if ( data.width && data.height ) { #> |
347 | - <div class="dimensions"><strong><?php _e( 'Dimensions:' ); ?></strong> {{ data.width }} × {{ data.height }}</div> |
|
347 | + <div class="dimensions"><strong><?php _e('Dimensions:'); ?></strong> {{ data.width }} × {{ data.height }}</div> |
|
348 | 348 | <# } #> |
349 | 349 | <# } #> |
350 | 350 | |
351 | 351 | <# if ( data.fileLength ) { #> |
352 | - <div class="file-length"><strong><?php _e( 'Length:' ); ?></strong> {{ data.fileLength }}</div> |
|
352 | + <div class="file-length"><strong><?php _e('Length:'); ?></strong> {{ data.fileLength }}</div> |
|
353 | 353 | <# } #> |
354 | 354 | |
355 | 355 | <# if ( 'audio' === data.type && data.meta.bitrate ) { #> |
356 | 356 | <div class="bitrate"> |
357 | - <strong><?php _e( 'Bitrate:' ); ?></strong> {{ Math.round( data.meta.bitrate / 1000 ) }}kb/s |
|
357 | + <strong><?php _e('Bitrate:'); ?></strong> {{ Math.round( data.meta.bitrate / 1000 ) }}kb/s |
|
358 | 358 | <# if ( data.meta.bitrate_mode ) { #> |
359 | 359 | {{ ' ' + data.meta.bitrate_mode.toUpperCase() }} |
360 | 360 | <# } #> |
@@ -374,30 +374,30 @@ discard block |
||
374 | 374 | <input type="text" value="{{ data.url }}" readonly /> |
375 | 375 | </label> |
376 | 376 | <# var maybeReadOnly = data.can.save || data.allowLocalEdits ? '' : 'readonly'; #> |
377 | - <?php if ( post_type_supports( 'attachment', 'title' ) ) : ?> |
|
377 | + <?php if (post_type_supports('attachment', 'title')) : ?> |
|
378 | 378 | <label class="setting" data-setting="title"> |
379 | 379 | <span class="name"><?php _e('Title'); ?></span> |
380 | 380 | <input type="text" value="{{ data.title }}" {{ maybeReadOnly }} /> |
381 | 381 | </label> |
382 | 382 | <?php endif; ?> |
383 | 383 | <# if ( 'audio' === data.type ) { #> |
384 | - <?php foreach ( array( |
|
385 | - 'artist' => __( 'Artist' ), |
|
386 | - 'album' => __( 'Album' ), |
|
387 | - ) as $key => $label ) : ?> |
|
388 | - <label class="setting" data-setting="<?php echo esc_attr( $key ) ?>"> |
|
384 | + <?php foreach (array( |
|
385 | + 'artist' => __('Artist'), |
|
386 | + 'album' => __('Album'), |
|
387 | + ) as $key => $label) : ?> |
|
388 | + <label class="setting" data-setting="<?php echo esc_attr($key) ?>"> |
|
389 | 389 | <span class="name"><?php echo $label ?></span> |
390 | 390 | <input type="text" value="{{ data.<?php echo $key ?> || data.meta.<?php echo $key ?> || '' }}" /> |
391 | 391 | </label> |
392 | 392 | <?php endforeach; ?> |
393 | 393 | <# } #> |
394 | 394 | <label class="setting" data-setting="caption"> |
395 | - <span class="name"><?php _e( 'Caption' ); ?></span> |
|
395 | + <span class="name"><?php _e('Caption'); ?></span> |
|
396 | 396 | <textarea {{ maybeReadOnly }}>{{ data.caption }}</textarea> |
397 | 397 | </label> |
398 | 398 | <# if ( 'image' === data.type ) { #> |
399 | 399 | <label class="setting" data-setting="alt"> |
400 | - <span class="name"><?php _e( 'Alt Text' ); ?></span> |
|
400 | + <span class="name"><?php _e('Alt Text'); ?></span> |
|
401 | 401 | <input type="text" value="{{ data.alt }}" {{ maybeReadOnly }} /> |
402 | 402 | </label> |
403 | 403 | <# } #> |
@@ -406,12 +406,12 @@ discard block |
||
406 | 406 | <textarea {{ maybeReadOnly }}>{{ data.description }}</textarea> |
407 | 407 | </label> |
408 | 408 | <label class="setting"> |
409 | - <span class="name"><?php _e( 'Uploaded By' ); ?></span> |
|
409 | + <span class="name"><?php _e('Uploaded By'); ?></span> |
|
410 | 410 | <span class="value">{{ data.authorName }}</span> |
411 | 411 | </label> |
412 | 412 | <# if ( data.uploadedToTitle ) { #> |
413 | 413 | <label class="setting"> |
414 | - <span class="name"><?php _e( 'Uploaded To' ); ?></span> |
|
414 | + <span class="name"><?php _e('Uploaded To'); ?></span> |
|
415 | 415 | <# if ( data.uploadedToLink ) { #> |
416 | 416 | <span class="value"><a href="{{ data.uploadedToLink }}">{{ data.uploadedToTitle }}</a></span> |
417 | 417 | <# } else { #> |
@@ -423,19 +423,19 @@ discard block |
||
423 | 423 | </div> |
424 | 424 | |
425 | 425 | <div class="actions"> |
426 | - <a class="view-attachment" href="{{ data.link }}"><?php _e( 'View attachment page' ); ?></a> |
|
426 | + <a class="view-attachment" href="{{ data.link }}"><?php _e('View attachment page'); ?></a> |
|
427 | 427 | <# if ( data.can.save ) { #> | |
428 | - <a href="post.php?post={{ data.id }}&action=edit"><?php _e( 'Edit more details' ); ?></a> |
|
428 | + <a href="post.php?post={{ data.id }}&action=edit"><?php _e('Edit more details'); ?></a> |
|
429 | 429 | <# } #> |
430 | 430 | <# if ( ! data.uploading && data.can.remove ) { #> | |
431 | - <?php if ( MEDIA_TRASH ): ?> |
|
431 | + <?php if (MEDIA_TRASH): ?> |
|
432 | 432 | <# if ( 'trash' === data.status ) { #> |
433 | - <button type="button" class="button-link untrash-attachment"><?php _e( 'Untrash' ); ?></button> |
|
433 | + <button type="button" class="button-link untrash-attachment"><?php _e('Untrash'); ?></button> |
|
434 | 434 | <# } else { #> |
435 | - <button type="button" class="button-link trash-attachment"><?php _ex( 'Trash', 'verb' ); ?></button> |
|
435 | + <button type="button" class="button-link trash-attachment"><?php _ex('Trash', 'verb'); ?></button> |
|
436 | 436 | <# } #> |
437 | 437 | <?php else: ?> |
438 | - <button type="button" class="button-link delete-attachment"><?php _e( 'Delete Permanently' ); ?></button> |
|
438 | + <button type="button" class="button-link delete-attachment"><?php _e('Delete Permanently'); ?></button> |
|
439 | 439 | <?php endif; ?> |
440 | 440 | <# } #> |
441 | 441 | </div> |
@@ -468,11 +468,11 @@ discard block |
||
468 | 468 | <# } #> |
469 | 469 | </div> |
470 | 470 | <# if ( data.buttons.close ) { #> |
471 | - <button type="button" class="button-link attachment-close media-modal-icon"><span class="screen-reader-text"><?php _e( 'Remove' ); ?></span></button> |
|
471 | + <button type="button" class="button-link attachment-close media-modal-icon"><span class="screen-reader-text"><?php _e('Remove'); ?></span></button> |
|
472 | 472 | <# } #> |
473 | 473 | </div> |
474 | 474 | <# if ( data.buttons.check ) { #> |
475 | - <button type="button" class="button-link check" tabindex="-1"><span class="media-modal-icon"></span><span class="screen-reader-text"><?php _e( 'Deselect' ); ?></span></button> |
|
475 | + <button type="button" class="button-link check" tabindex="-1"><span class="media-modal-icon"></span><span class="screen-reader-text"><?php _e('Deselect'); ?></span></button> |
|
476 | 476 | <# } #> |
477 | 477 | <# |
478 | 478 | var maybeReadOnly = data.can.save || data.allowLocalEdits ? '' : 'readonly'; |
@@ -495,7 +495,7 @@ discard block |
||
495 | 495 | |
496 | 496 | <script type="text/html" id="tmpl-attachment-details"> |
497 | 497 | <h2> |
498 | - <?php _e( 'Attachment Details' ); ?> |
|
498 | + <?php _e('Attachment Details'); ?> |
|
499 | 499 | <span class="settings-save-status"> |
500 | 500 | <span class="spinner"></span> |
501 | 501 | <span class="saved"><?php esc_html_e('Saved.'); ?></span> |
@@ -522,23 +522,23 @@ discard block |
||
522 | 522 | <# } #> |
523 | 523 | |
524 | 524 | <# if ( data.can.save && data.sizes ) { #> |
525 | - <a class="edit-attachment" href="{{ data.editLink }}&image-editor" target="_blank"><?php _e( 'Edit Image' ); ?></a> |
|
525 | + <a class="edit-attachment" href="{{ data.editLink }}&image-editor" target="_blank"><?php _e('Edit Image'); ?></a> |
|
526 | 526 | <# } #> |
527 | 527 | <# } #> |
528 | 528 | |
529 | 529 | <# if ( data.fileLength ) { #> |
530 | - <div class="file-length"><?php _e( 'Length:' ); ?> {{ data.fileLength }}</div> |
|
530 | + <div class="file-length"><?php _e('Length:'); ?> {{ data.fileLength }}</div> |
|
531 | 531 | <# } #> |
532 | 532 | |
533 | 533 | <# if ( ! data.uploading && data.can.remove ) { #> |
534 | - <?php if ( MEDIA_TRASH ): ?> |
|
534 | + <?php if (MEDIA_TRASH): ?> |
|
535 | 535 | <# if ( 'trash' === data.status ) { #> |
536 | - <button type="button" class="button-link untrash-attachment"><?php _e( 'Untrash' ); ?></button> |
|
536 | + <button type="button" class="button-link untrash-attachment"><?php _e('Untrash'); ?></button> |
|
537 | 537 | <# } else { #> |
538 | - <button type="button" class="button-link trash-attachment"><?php _ex( 'Trash', 'verb' ); ?></button> |
|
538 | + <button type="button" class="button-link trash-attachment"><?php _ex('Trash', 'verb'); ?></button> |
|
539 | 539 | <# } #> |
540 | 540 | <?php else: ?> |
541 | - <button type="button" class="button-link delete-attachment"><?php _e( 'Delete Permanently' ); ?></button> |
|
541 | + <button type="button" class="button-link delete-attachment"><?php _e('Delete Permanently'); ?></button> |
|
542 | 542 | <?php endif; ?> |
543 | 543 | <# } #> |
544 | 544 | |
@@ -555,18 +555,18 @@ discard block |
||
555 | 555 | <input type="text" value="{{ data.url }}" readonly /> |
556 | 556 | </label> |
557 | 557 | <# var maybeReadOnly = data.can.save || data.allowLocalEdits ? '' : 'readonly'; #> |
558 | - <?php if ( post_type_supports( 'attachment', 'title' ) ) : ?> |
|
558 | + <?php if (post_type_supports('attachment', 'title')) : ?> |
|
559 | 559 | <label class="setting" data-setting="title"> |
560 | 560 | <span class="name"><?php _e('Title'); ?></span> |
561 | 561 | <input type="text" value="{{ data.title }}" {{ maybeReadOnly }} /> |
562 | 562 | </label> |
563 | 563 | <?php endif; ?> |
564 | 564 | <# if ( 'audio' === data.type ) { #> |
565 | - <?php foreach ( array( |
|
566 | - 'artist' => __( 'Artist' ), |
|
567 | - 'album' => __( 'Album' ), |
|
568 | - ) as $key => $label ) : ?> |
|
569 | - <label class="setting" data-setting="<?php echo esc_attr( $key ) ?>"> |
|
565 | + <?php foreach (array( |
|
566 | + 'artist' => __('Artist'), |
|
567 | + 'album' => __('Album'), |
|
568 | + ) as $key => $label) : ?> |
|
569 | + <label class="setting" data-setting="<?php echo esc_attr($key) ?>"> |
|
570 | 570 | <span class="name"><?php echo $label ?></span> |
571 | 571 | <input type="text" value="{{ data.<?php echo $key ?> || data.meta.<?php echo $key ?> || '' }}" /> |
572 | 572 | </label> |
@@ -592,17 +592,17 @@ discard block |
||
592 | 592 | <div class="selection-info"> |
593 | 593 | <span class="count"></span> |
594 | 594 | <# if ( data.editable ) { #> |
595 | - <button type="button" class="button-link edit-selection"><?php _e( 'Edit Selection' ); ?></button> |
|
595 | + <button type="button" class="button-link edit-selection"><?php _e('Edit Selection'); ?></button> |
|
596 | 596 | <# } #> |
597 | 597 | <# if ( data.clearable ) { #> |
598 | - <button type="button" class="button-link clear-selection"><?php _e( 'Clear' ); ?></button> |
|
598 | + <button type="button" class="button-link clear-selection"><?php _e('Clear'); ?></button> |
|
599 | 599 | <# } #> |
600 | 600 | </div> |
601 | 601 | <div class="selection-view"></div> |
602 | 602 | </script> |
603 | 603 | |
604 | 604 | <script type="text/html" id="tmpl-attachment-display-settings"> |
605 | - <h2><?php _e( 'Attachment Display Settings' ); ?></h2> |
|
605 | + <h2><?php _e('Attachment Display Settings'); ?></h2> |
|
606 | 606 | |
607 | 607 | <# if ( 'image' === data.type ) { #> |
608 | 608 | <label class="setting"> |
@@ -614,16 +614,16 @@ discard block |
||
614 | 614 | <# } #>> |
615 | 615 | |
616 | 616 | <option value="left"> |
617 | - <?php esc_html_e( 'Left' ); ?> |
|
617 | + <?php esc_html_e('Left'); ?> |
|
618 | 618 | </option> |
619 | 619 | <option value="center"> |
620 | - <?php esc_html_e( 'Center' ); ?> |
|
620 | + <?php esc_html_e('Center'); ?> |
|
621 | 621 | </option> |
622 | 622 | <option value="right"> |
623 | - <?php esc_html_e( 'Right' ); ?> |
|
623 | + <?php esc_html_e('Right'); ?> |
|
624 | 624 | </option> |
625 | 625 | <option value="none" selected> |
626 | - <?php esc_html_e( 'None' ); ?> |
|
626 | + <?php esc_html_e('None'); ?> |
|
627 | 627 | </option> |
628 | 628 | </select> |
629 | 629 | </label> |
@@ -645,31 +645,31 @@ discard block |
||
645 | 645 | |
646 | 646 | <# if ( data.model.canEmbed ) { #> |
647 | 647 | <option value="embed" selected> |
648 | - <?php esc_html_e( 'Embed Media Player' ); ?> |
|
648 | + <?php esc_html_e('Embed Media Player'); ?> |
|
649 | 649 | </option> |
650 | 650 | <option value="file"> |
651 | 651 | <# } else { #> |
652 | 652 | <option value="none" selected> |
653 | - <?php esc_html_e( 'None' ); ?> |
|
653 | + <?php esc_html_e('None'); ?> |
|
654 | 654 | </option> |
655 | 655 | <option value="file"> |
656 | 656 | <# } #> |
657 | 657 | <# if ( data.model.canEmbed ) { #> |
658 | - <?php esc_html_e( 'Link to Media File' ); ?> |
|
658 | + <?php esc_html_e('Link to Media File'); ?> |
|
659 | 659 | <# } else { #> |
660 | - <?php esc_html_e( 'Media File' ); ?> |
|
660 | + <?php esc_html_e('Media File'); ?> |
|
661 | 661 | <# } #> |
662 | 662 | </option> |
663 | 663 | <option value="post"> |
664 | 664 | <# if ( data.model.canEmbed ) { #> |
665 | - <?php esc_html_e( 'Link to Attachment Page' ); ?> |
|
665 | + <?php esc_html_e('Link to Attachment Page'); ?> |
|
666 | 666 | <# } else { #> |
667 | - <?php esc_html_e( 'Attachment Page' ); ?> |
|
667 | + <?php esc_html_e('Attachment Page'); ?> |
|
668 | 668 | <# } #> |
669 | 669 | </option> |
670 | 670 | <# if ( 'image' === data.type ) { #> |
671 | 671 | <option value="custom"> |
672 | - <?php esc_html_e( 'Custom URL' ); ?> |
|
672 | + <?php esc_html_e('Custom URL'); ?> |
|
673 | 673 | </option> |
674 | 674 | <# } #> |
675 | 675 | </select> |
@@ -687,19 +687,19 @@ discard block |
||
687 | 687 | <# } #>> |
688 | 688 | <?php |
689 | 689 | /** This filter is documented in wp-admin/includes/media.php */ |
690 | - $sizes = apply_filters( 'image_size_names_choose', array( |
|
690 | + $sizes = apply_filters('image_size_names_choose', array( |
|
691 | 691 | 'thumbnail' => __('Thumbnail'), |
692 | 692 | 'medium' => __('Medium'), |
693 | 693 | 'large' => __('Large'), |
694 | 694 | 'full' => __('Full Size'), |
695 | - ) ); |
|
695 | + )); |
|
696 | 696 | |
697 | - foreach ( $sizes as $value => $name ) : ?> |
|
697 | + foreach ($sizes as $value => $name) : ?> |
|
698 | 698 | <# |
699 | - var size = data.sizes['<?php echo esc_js( $value ); ?>']; |
|
699 | + var size = data.sizes['<?php echo esc_js($value); ?>']; |
|
700 | 700 | if ( size ) { #> |
701 | - <option value="<?php echo esc_attr( $value ); ?>" <?php selected( $value, 'full' ); ?>> |
|
702 | - <?php echo esc_html( $name ); ?> – {{ size.width }} × {{ size.height }} |
|
701 | + <option value="<?php echo esc_attr($value); ?>" <?php selected($value, 'full'); ?>> |
|
702 | + <?php echo esc_html($name); ?> – {{ size.width }} × {{ size.height }} |
|
703 | 703 | </option> |
704 | 704 | <# } #> |
705 | 705 | <?php endforeach; ?> |
@@ -709,7 +709,7 @@ discard block |
||
709 | 709 | </script> |
710 | 710 | |
711 | 711 | <script type="text/html" id="tmpl-gallery-settings"> |
712 | - <h2><?php _e( 'Gallery Settings' ); ?></h2> |
|
712 | + <h2><?php _e('Gallery Settings'); ?></h2> |
|
713 | 713 | |
714 | 714 | <label class="setting"> |
715 | 715 | <span><?php _e('Link To'); ?></span> |
@@ -722,13 +722,13 @@ discard block |
||
722 | 722 | <option value="post" <# if ( ! wp.media.galleryDefaults.link || 'post' == wp.media.galleryDefaults.link ) { |
723 | 723 | #>selected="selected"<# } |
724 | 724 | #>> |
725 | - <?php esc_html_e( 'Attachment Page' ); ?> |
|
725 | + <?php esc_html_e('Attachment Page'); ?> |
|
726 | 726 | </option> |
727 | 727 | <option value="file" <# if ( 'file' == wp.media.galleryDefaults.link ) { #>selected="selected"<# } #>> |
728 | - <?php esc_html_e( 'Media File' ); ?> |
|
728 | + <?php esc_html_e('Media File'); ?> |
|
729 | 729 | </option> |
730 | 730 | <option value="none" <# if ( 'none' == wp.media.galleryDefaults.link ) { #>selected="selected"<# } #>> |
731 | - <?php esc_html_e( 'None' ); ?> |
|
731 | + <?php esc_html_e('None'); ?> |
|
732 | 732 | </option> |
733 | 733 | </select> |
734 | 734 | </label> |
@@ -737,23 +737,23 @@ discard block |
||
737 | 737 | <span><?php _e('Columns'); ?></span> |
738 | 738 | <select class="columns" name="columns" |
739 | 739 | data-setting="columns"> |
740 | - <?php for ( $i = 1; $i <= 9; $i++ ) : ?> |
|
741 | - <option value="<?php echo esc_attr( $i ); ?>" <# |
|
740 | + <?php for ($i = 1; $i <= 9; $i++) : ?> |
|
741 | + <option value="<?php echo esc_attr($i); ?>" <# |
|
742 | 742 | if ( <?php echo $i ?> == wp.media.galleryDefaults.columns ) { #>selected="selected"<# } |
743 | 743 | #>> |
744 | - <?php echo esc_html( $i ); ?> |
|
744 | + <?php echo esc_html($i); ?> |
|
745 | 745 | </option> |
746 | 746 | <?php endfor; ?> |
747 | 747 | </select> |
748 | 748 | </label> |
749 | 749 | |
750 | 750 | <label class="setting"> |
751 | - <span><?php _e( 'Random Order' ); ?></span> |
|
751 | + <span><?php _e('Random Order'); ?></span> |
|
752 | 752 | <input type="checkbox" data-setting="_orderbyRandom" /> |
753 | 753 | </label> |
754 | 754 | |
755 | 755 | <label class="setting size"> |
756 | - <span><?php _e( 'Size' ); ?></span> |
|
756 | + <span><?php _e('Size'); ?></span> |
|
757 | 757 | <select class="size" name="size" |
758 | 758 | data-setting="size" |
759 | 759 | <# if ( data.userSettings ) { #> |
@@ -762,16 +762,16 @@ discard block |
||
762 | 762 | > |
763 | 763 | <?php |
764 | 764 | /** This filter is documented in wp-admin/includes/media.php */ |
765 | - $size_names = apply_filters( 'image_size_names_choose', array( |
|
766 | - 'thumbnail' => __( 'Thumbnail' ), |
|
767 | - 'medium' => __( 'Medium' ), |
|
768 | - 'large' => __( 'Large' ), |
|
769 | - 'full' => __( 'Full Size' ), |
|
770 | - ) ); |
|
771 | - |
|
772 | - foreach ( $size_names as $size => $label ) : ?> |
|
773 | - <option value="<?php echo esc_attr( $size ); ?>"> |
|
774 | - <?php echo esc_html( $label ); ?> |
|
765 | + $size_names = apply_filters('image_size_names_choose', array( |
|
766 | + 'thumbnail' => __('Thumbnail'), |
|
767 | + 'medium' => __('Medium'), |
|
768 | + 'large' => __('Large'), |
|
769 | + 'full' => __('Full Size'), |
|
770 | + )); |
|
771 | + |
|
772 | + foreach ($size_names as $size => $label) : ?> |
|
773 | + <option value="<?php echo esc_attr($size); ?>"> |
|
774 | + <?php echo esc_html($label); ?> |
|
775 | 775 | </option> |
776 | 776 | <?php endforeach; ?> |
777 | 777 | </select> |
@@ -779,7 +779,7 @@ discard block |
||
779 | 779 | </script> |
780 | 780 | |
781 | 781 | <script type="text/html" id="tmpl-playlist-settings"> |
782 | - <h2><?php _e( 'Playlist Settings' ); ?></h2> |
|
782 | + <h2><?php _e('Playlist Settings'); ?></h2> |
|
783 | 783 | |
784 | 784 | <# var emptyModel = _.isEmpty( data.model ), |
785 | 785 | isVideo = 'video' === data.controller.get('library').props.get('type'); #> |
@@ -789,9 +789,9 @@ discard block |
||
789 | 789 | checked="checked" |
790 | 790 | <# } #> /> |
791 | 791 | <# if ( isVideo ) { #> |
792 | - <span><?php _e( 'Show Video List' ); ?></span> |
|
792 | + <span><?php _e('Show Video List'); ?></span> |
|
793 | 793 | <# } else { #> |
794 | - <span><?php _e( 'Show Tracklist' ); ?></span> |
|
794 | + <span><?php _e('Show Tracklist'); ?></span> |
|
795 | 795 | <# } #> |
796 | 796 | </label> |
797 | 797 | |
@@ -800,7 +800,7 @@ discard block |
||
800 | 800 | <input type="checkbox" data-setting="artists" <# if ( emptyModel ) { #> |
801 | 801 | checked="checked" |
802 | 802 | <# } #> /> |
803 | - <span><?php _e( 'Show Artist Name in Tracklist' ); ?></span> |
|
803 | + <span><?php _e('Show Artist Name in Tracklist'); ?></span> |
|
804 | 804 | </label> |
805 | 805 | <# } #> |
806 | 806 | |
@@ -808,13 +808,13 @@ discard block |
||
808 | 808 | <input type="checkbox" data-setting="images" <# if ( emptyModel ) { #> |
809 | 809 | checked="checked" |
810 | 810 | <# } #> /> |
811 | - <span><?php _e( 'Show Images' ); ?></span> |
|
811 | + <span><?php _e('Show Images'); ?></span> |
|
812 | 812 | </label> |
813 | 813 | </script> |
814 | 814 | |
815 | 815 | <script type="text/html" id="tmpl-embed-link-settings"> |
816 | 816 | <label class="setting link-text"> |
817 | - <span><?php _e( 'Link Text' ); ?></span> |
|
817 | + <span><?php _e('Link Text'); ?></span> |
|
818 | 818 | <input type="text" class="alignment" data-setting="linkText" /> |
819 | 819 | </label> |
820 | 820 | <div class="embed-container" style="display: none;"> |
@@ -829,7 +829,7 @@ discard block |
||
829 | 829 | |
830 | 830 | <?php |
831 | 831 | /** This filter is documented in wp-admin/includes/media.php */ |
832 | - if ( ! apply_filters( 'disable_captions', '' ) ) : ?> |
|
832 | + if ( ! apply_filters('disable_captions', '')) : ?> |
|
833 | 833 | <label class="setting caption"> |
834 | 834 | <span><?php _e('Caption'); ?></span> |
835 | 835 | <textarea data-setting="caption" /> |
@@ -845,16 +845,16 @@ discard block |
||
845 | 845 | <span><?php _e('Align'); ?></span> |
846 | 846 | <div class="button-group button-large" data-setting="align"> |
847 | 847 | <button class="button" value="left"> |
848 | - <?php esc_html_e( 'Left' ); ?> |
|
848 | + <?php esc_html_e('Left'); ?> |
|
849 | 849 | </button> |
850 | 850 | <button class="button" value="center"> |
851 | - <?php esc_html_e( 'Center' ); ?> |
|
851 | + <?php esc_html_e('Center'); ?> |
|
852 | 852 | </button> |
853 | 853 | <button class="button" value="right"> |
854 | - <?php esc_html_e( 'Right' ); ?> |
|
854 | + <?php esc_html_e('Right'); ?> |
|
855 | 855 | </button> |
856 | 856 | <button class="button active" value="none"> |
857 | - <?php esc_html_e( 'None' ); ?> |
|
857 | + <?php esc_html_e('None'); ?> |
|
858 | 858 | </button> |
859 | 859 | </div> |
860 | 860 | </div> |
@@ -863,13 +863,13 @@ discard block |
||
863 | 863 | <span><?php _e('Link To'); ?></span> |
864 | 864 | <div class="button-group button-large" data-setting="link"> |
865 | 865 | <button class="button" value="file"> |
866 | - <?php esc_html_e( 'Image URL' ); ?> |
|
866 | + <?php esc_html_e('Image URL'); ?> |
|
867 | 867 | </button> |
868 | 868 | <button class="button" value="custom"> |
869 | - <?php esc_html_e( 'Custom URL' ); ?> |
|
869 | + <?php esc_html_e('Custom URL'); ?> |
|
870 | 870 | </button> |
871 | 871 | <button class="button active" value="none"> |
872 | - <?php esc_html_e( 'None' ); ?> |
|
872 | + <?php esc_html_e('None'); ?> |
|
873 | 873 | </button> |
874 | 874 | </div> |
875 | 875 | <input type="text" class="link-to-custom" data-setting="linkUrl" /> |
@@ -885,8 +885,8 @@ discard block |
||
885 | 885 | |
886 | 886 | <# if ( data.attachment && window.imageEdit ) { #> |
887 | 887 | <div class="actions"> |
888 | - <input type="button" class="edit-attachment button" value="<?php esc_attr_e( 'Edit Original' ); ?>" /> |
|
889 | - <input type="button" class="replace-attachment button" value="<?php esc_attr_e( 'Replace' ); ?>" /> |
|
888 | + <input type="button" class="edit-attachment button" value="<?php esc_attr_e('Edit Original'); ?>" /> |
|
889 | + <input type="button" class="replace-attachment button" value="<?php esc_attr_e('Replace'); ?>" /> |
|
890 | 890 | </div> |
891 | 891 | <# } #> |
892 | 892 | </div> |
@@ -894,7 +894,7 @@ discard block |
||
894 | 894 | <div class="column-settings"> |
895 | 895 | <?php |
896 | 896 | /** This filter is documented in wp-admin/includes/media.php */ |
897 | - if ( ! apply_filters( 'disable_captions', '' ) ) : ?> |
|
897 | + if ( ! apply_filters('disable_captions', '')) : ?> |
|
898 | 898 | <label class="setting caption"> |
899 | 899 | <span><?php _e('Caption'); ?></span> |
900 | 900 | <textarea data-setting="caption">{{ data.model.caption }}</textarea> |
@@ -906,21 +906,21 @@ discard block |
||
906 | 906 | <input type="text" data-setting="alt" value="{{ data.model.alt }}" /> |
907 | 907 | </label> |
908 | 908 | |
909 | - <h2><?php _e( 'Display Settings' ); ?></h2> |
|
909 | + <h2><?php _e('Display Settings'); ?></h2> |
|
910 | 910 | <div class="setting align"> |
911 | 911 | <span><?php _e('Align'); ?></span> |
912 | 912 | <div class="button-group button-large" data-setting="align"> |
913 | 913 | <button class="button" value="left"> |
914 | - <?php esc_html_e( 'Left' ); ?> |
|
914 | + <?php esc_html_e('Left'); ?> |
|
915 | 915 | </button> |
916 | 916 | <button class="button" value="center"> |
917 | - <?php esc_html_e( 'Center' ); ?> |
|
917 | + <?php esc_html_e('Center'); ?> |
|
918 | 918 | </button> |
919 | 919 | <button class="button" value="right"> |
920 | - <?php esc_html_e( 'Right' ); ?> |
|
920 | + <?php esc_html_e('Right'); ?> |
|
921 | 921 | </button> |
922 | 922 | <button class="button active" value="none"> |
923 | - <?php esc_html_e( 'None' ); ?> |
|
923 | + <?php esc_html_e('None'); ?> |
|
924 | 924 | </button> |
925 | 925 | </div> |
926 | 926 | </div> |
@@ -936,30 +936,30 @@ discard block |
||
936 | 936 | <# } #>> |
937 | 937 | <?php |
938 | 938 | /** This filter is documented in wp-admin/includes/media.php */ |
939 | - $sizes = apply_filters( 'image_size_names_choose', array( |
|
939 | + $sizes = apply_filters('image_size_names_choose', array( |
|
940 | 940 | 'thumbnail' => __('Thumbnail'), |
941 | 941 | 'medium' => __('Medium'), |
942 | 942 | 'large' => __('Large'), |
943 | 943 | 'full' => __('Full Size'), |
944 | - ) ); |
|
944 | + )); |
|
945 | 945 | |
946 | - foreach ( $sizes as $value => $name ) : ?> |
|
946 | + foreach ($sizes as $value => $name) : ?> |
|
947 | 947 | <# |
948 | - var size = data.sizes['<?php echo esc_js( $value ); ?>']; |
|
948 | + var size = data.sizes['<?php echo esc_js($value); ?>']; |
|
949 | 949 | if ( size ) { #> |
950 | - <option value="<?php echo esc_attr( $value ); ?>"> |
|
951 | - <?php echo esc_html( $name ); ?> – {{ size.width }} × {{ size.height }} |
|
950 | + <option value="<?php echo esc_attr($value); ?>"> |
|
951 | + <?php echo esc_html($name); ?> – {{ size.width }} × {{ size.height }} |
|
952 | 952 | </option> |
953 | 953 | <# } #> |
954 | 954 | <?php endforeach; ?> |
955 | - <option value="<?php echo esc_attr( 'custom' ); ?>"> |
|
956 | - <?php _e( 'Custom Size' ); ?> |
|
955 | + <option value="<?php echo esc_attr('custom'); ?>"> |
|
956 | + <?php _e('Custom Size'); ?> |
|
957 | 957 | </option> |
958 | 958 | </select> |
959 | 959 | </label> |
960 | 960 | <# } #> |
961 | 961 | <div class="custom-size<# if ( data.model.size !== 'custom' ) { #> hidden<# } #>"> |
962 | - <label><span><?php _e( 'Width' ); ?> <small>(px)</small></span> <input data-setting="customWidth" type="number" step="1" value="{{ data.model.customWidth }}" /></label><span class="sep">×</span><label><span><?php _e( 'Height' ); ?> <small>(px)</small></span><input data-setting="customHeight" type="number" step="1" value="{{ data.model.customHeight }}" /></label> |
|
962 | + <label><span><?php _e('Width'); ?> <small>(px)</small></span> <input data-setting="customWidth" type="number" step="1" value="{{ data.model.customWidth }}" /></label><span class="sep">×</span><label><span><?php _e('Height'); ?> <small>(px)</small></span><input data-setting="customHeight" type="number" step="1" value="{{ data.model.customHeight }}" /></label> |
|
963 | 963 | </div> |
964 | 964 | <# } #> |
965 | 965 | |
@@ -968,27 +968,27 @@ discard block |
||
968 | 968 | <select data-setting="link"> |
969 | 969 | <# if ( data.attachment ) { #> |
970 | 970 | <option value="file"> |
971 | - <?php esc_html_e( 'Media File' ); ?> |
|
971 | + <?php esc_html_e('Media File'); ?> |
|
972 | 972 | </option> |
973 | 973 | <option value="post"> |
974 | - <?php esc_html_e( 'Attachment Page' ); ?> |
|
974 | + <?php esc_html_e('Attachment Page'); ?> |
|
975 | 975 | </option> |
976 | 976 | <# } else { #> |
977 | 977 | <option value="file"> |
978 | - <?php esc_html_e( 'Image URL' ); ?> |
|
978 | + <?php esc_html_e('Image URL'); ?> |
|
979 | 979 | </option> |
980 | 980 | <# } #> |
981 | 981 | <option value="custom"> |
982 | - <?php esc_html_e( 'Custom URL' ); ?> |
|
982 | + <?php esc_html_e('Custom URL'); ?> |
|
983 | 983 | </option> |
984 | 984 | <option value="none"> |
985 | - <?php esc_html_e( 'None' ); ?> |
|
985 | + <?php esc_html_e('None'); ?> |
|
986 | 986 | </option> |
987 | 987 | </select> |
988 | 988 | <input type="text" class="link-to-custom" data-setting="linkUrl" /> |
989 | 989 | </div> |
990 | 990 | <div class="advanced-section"> |
991 | - <h2><button type="button" class="button-link advanced-toggle"><?php _e( 'Advanced Options' ); ?></button></h2> |
|
991 | + <h2><button type="button" class="button-link advanced-toggle"><?php _e('Advanced Options'); ?></button></h2> |
|
992 | 992 | <div class="advanced-settings hidden"> |
993 | 993 | <div class="advanced-image"> |
994 | 994 | <label class="setting title-text"> |
@@ -1002,7 +1002,7 @@ discard block |
||
1002 | 1002 | </div> |
1003 | 1003 | <div class="advanced-link"> |
1004 | 1004 | <div class="setting link-target"> |
1005 | - <label><input type="checkbox" data-setting="linkTargetBlank" value="_blank" <# if ( data.model.linkTargetBlank ) { #>checked="checked"<# } #>><?php _e( 'Open link in a new tab' ); ?></label> |
|
1005 | + <label><input type="checkbox" data-setting="linkTargetBlank" value="_blank" <# if ( data.model.linkTargetBlank ) { #>checked="checked"<# } #>><?php _e('Open link in a new tab'); ?></label> |
|
1006 | 1006 | </div> |
1007 | 1007 | <label class="setting link-rel"> |
1008 | 1008 | <span><?php _e('Link Rel'); ?></span> |
@@ -1045,28 +1045,28 @@ discard block |
||
1045 | 1045 | <label class="setting"> |
1046 | 1046 | <span>SRC</span> |
1047 | 1047 | <input type="text" disabled="disabled" data-setting="src" value="{{ data.model.src }}" /> |
1048 | - <button type="button" class="button-link remove-setting"><?php _e( 'Remove audio source' ); ?></button> |
|
1048 | + <button type="button" class="button-link remove-setting"><?php _e('Remove audio source'); ?></button> |
|
1049 | 1049 | </label> |
1050 | 1050 | <# } #> |
1051 | 1051 | <?php |
1052 | 1052 | |
1053 | - foreach ( $audio_types as $type ): |
|
1053 | + foreach ($audio_types as $type): |
|
1054 | 1054 | ?><# if ( ! _.isEmpty( data.model.<?php echo $type ?> ) ) { |
1055 | 1055 | if ( ! _.isUndefined( html5types.<?php echo $type ?> ) ) { |
1056 | 1056 | delete html5types.<?php echo $type ?>; |
1057 | 1057 | } |
1058 | 1058 | #> |
1059 | 1059 | <label class="setting"> |
1060 | - <span><?php echo strtoupper( $type ) ?></span> |
|
1060 | + <span><?php echo strtoupper($type) ?></span> |
|
1061 | 1061 | <input type="text" disabled="disabled" data-setting="<?php echo $type ?>" value="{{ data.model.<?php echo $type ?> }}" /> |
1062 | - <button type="button" class="button-link remove-setting"><?php _e( 'Remove audio source' ); ?></button> |
|
1062 | + <button type="button" class="button-link remove-setting"><?php _e('Remove audio source'); ?></button> |
|
1063 | 1063 | </label> |
1064 | 1064 | <# } #> |
1065 | 1065 | <?php endforeach ?> |
1066 | 1066 | |
1067 | 1067 | <# if ( ! _.isEmpty( html5types ) ) { #> |
1068 | 1068 | <div class="setting"> |
1069 | - <span><?php _e( 'Add alternate sources for maximum HTML5 playback:' ) ?></span> |
|
1069 | + <span><?php _e('Add alternate sources for maximum HTML5 playback:') ?></span> |
|
1070 | 1070 | <div class="button-large"> |
1071 | 1071 | <# _.each( html5types, function (mime, type) { #> |
1072 | 1072 | <button class="button add-media-source" data-mime="{{ mime }}">{{ type }}</button> |
@@ -1076,22 +1076,22 @@ discard block |
||
1076 | 1076 | <# } #> |
1077 | 1077 | |
1078 | 1078 | <div class="setting preload"> |
1079 | - <span><?php _e( 'Preload' ); ?></span> |
|
1079 | + <span><?php _e('Preload'); ?></span> |
|
1080 | 1080 | <div class="button-group button-large" data-setting="preload"> |
1081 | - <button class="button" value="auto"><?php _ex( 'Auto', 'auto preload' ); ?></button> |
|
1082 | - <button class="button" value="metadata"><?php _e( 'Metadata' ); ?></button> |
|
1083 | - <button class="button active" value="none"><?php _e( 'None' ); ?></button> |
|
1081 | + <button class="button" value="auto"><?php _ex('Auto', 'auto preload'); ?></button> |
|
1082 | + <button class="button" value="metadata"><?php _e('Metadata'); ?></button> |
|
1083 | + <button class="button active" value="none"><?php _e('None'); ?></button> |
|
1084 | 1084 | </div> |
1085 | 1085 | </div> |
1086 | 1086 | |
1087 | 1087 | <label class="setting checkbox-setting"> |
1088 | 1088 | <input type="checkbox" data-setting="autoplay" /> |
1089 | - <span><?php _e( 'Autoplay' ); ?></span> |
|
1089 | + <span><?php _e('Autoplay'); ?></span> |
|
1090 | 1090 | </label> |
1091 | 1091 | |
1092 | 1092 | <label class="setting checkbox-setting"> |
1093 | 1093 | <input type="checkbox" data-setting="loop" /> |
1094 | - <span><?php _e( 'Loop' ); ?></span> |
|
1094 | + <span><?php _e('Loop'); ?></span> |
|
1095 | 1095 | </label> |
1096 | 1096 | </div> |
1097 | 1097 | </div> |
@@ -1128,19 +1128,19 @@ discard block |
||
1128 | 1128 | <label class="setting"> |
1129 | 1129 | <span>SRC</span> |
1130 | 1130 | <input type="text" disabled="disabled" data-setting="src" value="{{ data.model.src }}" /> |
1131 | - <button type="button" class="button-link remove-setting"><?php _e( 'Remove video source' ); ?></button> |
|
1131 | + <button type="button" class="button-link remove-setting"><?php _e('Remove video source'); ?></button> |
|
1132 | 1132 | </label> |
1133 | 1133 | <# } #> |
1134 | - <?php foreach ( $video_types as $type ): |
|
1134 | + <?php foreach ($video_types as $type): |
|
1135 | 1135 | ?><# if ( ! _.isEmpty( data.model.<?php echo $type ?> ) ) { |
1136 | 1136 | if ( ! _.isUndefined( html5types.<?php echo $type ?> ) ) { |
1137 | 1137 | delete html5types.<?php echo $type ?>; |
1138 | 1138 | } |
1139 | 1139 | #> |
1140 | 1140 | <label class="setting"> |
1141 | - <span><?php echo strtoupper( $type ) ?></span> |
|
1141 | + <span><?php echo strtoupper($type) ?></span> |
|
1142 | 1142 | <input type="text" disabled="disabled" data-setting="<?php echo $type ?>" value="{{ data.model.<?php echo $type ?> }}" /> |
1143 | - <button type="button" class="button-link remove-setting"><?php _e( 'Remove video source' ); ?></button> |
|
1143 | + <button type="button" class="button-link remove-setting"><?php _e('Remove video source'); ?></button> |
|
1144 | 1144 | </label> |
1145 | 1145 | <# } #> |
1146 | 1146 | <?php endforeach ?> |
@@ -1148,7 +1148,7 @@ discard block |
||
1148 | 1148 | |
1149 | 1149 | <# if ( ! _.isEmpty( html5types ) ) { #> |
1150 | 1150 | <div class="setting"> |
1151 | - <span><?php _e( 'Add alternate sources for maximum HTML5 playback:' ); ?></span> |
|
1151 | + <span><?php _e('Add alternate sources for maximum HTML5 playback:'); ?></span> |
|
1152 | 1152 | <div class="button-large"> |
1153 | 1153 | <# _.each( html5types, function (mime, type) { #> |
1154 | 1154 | <button class="button add-media-source" data-mime="{{ mime }}">{{ type }}</button> |
@@ -1159,32 +1159,32 @@ discard block |
||
1159 | 1159 | |
1160 | 1160 | <# if ( ! _.isEmpty( data.model.poster ) ) { #> |
1161 | 1161 | <label class="setting"> |
1162 | - <span><?php _e( 'Poster Image' ); ?></span> |
|
1162 | + <span><?php _e('Poster Image'); ?></span> |
|
1163 | 1163 | <input type="text" disabled="disabled" data-setting="poster" value="{{ data.model.poster }}" /> |
1164 | - <button type="button" class="button-link remove-setting"><?php _e( 'Remove poster image' ); ?></button> |
|
1164 | + <button type="button" class="button-link remove-setting"><?php _e('Remove poster image'); ?></button> |
|
1165 | 1165 | </label> |
1166 | 1166 | <# } #> |
1167 | 1167 | <div class="setting preload"> |
1168 | - <span><?php _e( 'Preload' ); ?></span> |
|
1168 | + <span><?php _e('Preload'); ?></span> |
|
1169 | 1169 | <div class="button-group button-large" data-setting="preload"> |
1170 | - <button class="button" value="auto"><?php _ex( 'Auto', 'auto preload' ); ?></button> |
|
1171 | - <button class="button" value="metadata"><?php _e( 'Metadata' ); ?></button> |
|
1172 | - <button class="button active" value="none"><?php _e( 'None' ); ?></button> |
|
1170 | + <button class="button" value="auto"><?php _ex('Auto', 'auto preload'); ?></button> |
|
1171 | + <button class="button" value="metadata"><?php _e('Metadata'); ?></button> |
|
1172 | + <button class="button active" value="none"><?php _e('None'); ?></button> |
|
1173 | 1173 | </div> |
1174 | 1174 | </div> |
1175 | 1175 | |
1176 | 1176 | <label class="setting checkbox-setting"> |
1177 | 1177 | <input type="checkbox" data-setting="autoplay" /> |
1178 | - <span><?php _e( 'Autoplay' ); ?></span> |
|
1178 | + <span><?php _e('Autoplay'); ?></span> |
|
1179 | 1179 | </label> |
1180 | 1180 | |
1181 | 1181 | <label class="setting checkbox-setting"> |
1182 | 1182 | <input type="checkbox" data-setting="loop" /> |
1183 | - <span><?php _e( 'Loop' ); ?></span> |
|
1183 | + <span><?php _e('Loop'); ?></span> |
|
1184 | 1184 | </label> |
1185 | 1185 | |
1186 | 1186 | <label class="setting" data-setting="content"> |
1187 | - <span><?php _e( 'Tracks (subtitles, captions, descriptions, chapters, or metadata)' ); ?></span> |
|
1187 | + <span><?php _e('Tracks (subtitles, captions, descriptions, chapters, or metadata)'); ?></span> |
|
1188 | 1188 | <# |
1189 | 1189 | var content = ''; |
1190 | 1190 | if ( ! _.isEmpty( data.model.content ) ) { |
@@ -1193,11 +1193,11 @@ discard block |
||
1193 | 1193 | content += track.outerHTML; #> |
1194 | 1194 | <p> |
1195 | 1195 | <input class="content-track" type="text" value="{{ track.outerHTML }}" /> |
1196 | - <button type="button" class="button-link remove-setting remove-track"><?php _ex( 'Remove video track', 'media' ); ?></button> |
|
1196 | + <button type="button" class="button-link remove-setting remove-track"><?php _ex('Remove video track', 'media'); ?></button> |
|
1197 | 1197 | </p> |
1198 | 1198 | <# } ); #> |
1199 | 1199 | <# } else { #> |
1200 | - <em><?php _e( 'There are no associated subtitles.' ); ?></em> |
|
1200 | + <em><?php _e('There are no associated subtitles.'); ?></em> |
|
1201 | 1201 | <# } #> |
1202 | 1202 | <textarea class="hidden content-setting">{{ content }}</textarea> |
1203 | 1203 | </label> |
@@ -1230,31 +1230,31 @@ discard block |
||
1230 | 1230 | </div> |
1231 | 1231 | <# } else { #> |
1232 | 1232 | <div class="wpview-error"> |
1233 | - <div class="dashicons dashicons-format-gallery"></div><p><?php _e( 'No items found.' ); ?></p> |
|
1233 | + <div class="dashicons dashicons-format-gallery"></div><p><?php _e('No items found.'); ?></p> |
|
1234 | 1234 | </div> |
1235 | 1235 | <# } #> |
1236 | 1236 | </script> |
1237 | 1237 | |
1238 | 1238 | <script type="text/html" id="tmpl-crop-content"> |
1239 | - <img class="crop-image" src="{{ data.url }}" alt="<?php esc_attr_e( 'Image crop area preview. Requires mouse interaction.' ); ?>"> |
|
1239 | + <img class="crop-image" src="{{ data.url }}" alt="<?php esc_attr_e('Image crop area preview. Requires mouse interaction.'); ?>"> |
|
1240 | 1240 | <div class="upload-errors"></div> |
1241 | 1241 | </script> |
1242 | 1242 | |
1243 | 1243 | <script type="text/html" id="tmpl-site-icon-preview"> |
1244 | - <h2><?php _e( 'Preview' ); ?></h2> |
|
1245 | - <strong aria-hidden="true"><?php _e( 'As a browser icon' ); ?></strong> |
|
1244 | + <h2><?php _e('Preview'); ?></h2> |
|
1245 | + <strong aria-hidden="true"><?php _e('As a browser icon'); ?></strong> |
|
1246 | 1246 | <div class="favicon-preview"> |
1247 | - <img src="<?php echo esc_url( admin_url( 'images/' . ( is_rtl() ? 'browser-rtl.png' : 'browser.png' ) ) ); ?>" class="browser-preview" width="182" height="" alt="" /> |
|
1247 | + <img src="<?php echo esc_url(admin_url('images/'.(is_rtl() ? 'browser-rtl.png' : 'browser.png'))); ?>" class="browser-preview" width="182" height="" alt="" /> |
|
1248 | 1248 | |
1249 | 1249 | <div class="favicon"> |
1250 | - <img id="preview-favicon" src="{{ data.url }}" alt="<?php esc_attr_e( 'Preview as a browser icon' ); ?>"/> |
|
1250 | + <img id="preview-favicon" src="{{ data.url }}" alt="<?php esc_attr_e('Preview as a browser icon'); ?>"/> |
|
1251 | 1251 | </div> |
1252 | - <span class="browser-title" aria-hidden="true"><?php bloginfo( 'name' ); ?></span> |
|
1252 | + <span class="browser-title" aria-hidden="true"><?php bloginfo('name'); ?></span> |
|
1253 | 1253 | </div> |
1254 | 1254 | |
1255 | - <strong aria-hidden="true"><?php _e( 'As an app icon' ); ?></strong> |
|
1255 | + <strong aria-hidden="true"><?php _e('As an app icon'); ?></strong> |
|
1256 | 1256 | <div class="app-icon-preview"> |
1257 | - <img id="preview-app-icon" src="{{ data.url }}" alt="<?php esc_attr_e( 'Preview as an app icon' ); ?>"/> |
|
1257 | + <img id="preview-app-icon" src="{{ data.url }}" alt="<?php esc_attr_e('Preview as an app icon'); ?>"/> |
|
1258 | 1258 | </div> |
1259 | 1259 | </script> |
1260 | 1260 | |
@@ -1265,5 +1265,5 @@ discard block |
||
1265 | 1265 | * |
1266 | 1266 | * @since 3.5.0 |
1267 | 1267 | */ |
1268 | - do_action( 'print_media_templates' ); |
|
1268 | + do_action('print_media_templates'); |
|
1269 | 1269 | } |
@@ -43,7 +43,7 @@ discard block |
||
43 | 43 | * @param string $role Role name. |
44 | 44 | * @param array $capabilities List of capabilities. |
45 | 45 | */ |
46 | - public function __construct( $role, $capabilities ) { |
|
46 | + public function __construct($role, $capabilities) { |
|
47 | 47 | $this->name = $role; |
48 | 48 | $this->capabilities = $capabilities; |
49 | 49 | } |
@@ -57,9 +57,9 @@ discard block |
||
57 | 57 | * @param string $cap Capability name. |
58 | 58 | * @param bool $grant Whether role has capability privilege. |
59 | 59 | */ |
60 | - public function add_cap( $cap, $grant = true ) { |
|
60 | + public function add_cap($cap, $grant = true) { |
|
61 | 61 | $this->capabilities[$cap] = $grant; |
62 | - wp_roles()->add_cap( $this->name, $cap, $grant ); |
|
62 | + wp_roles()->add_cap($this->name, $cap, $grant); |
|
63 | 63 | } |
64 | 64 | |
65 | 65 | /** |
@@ -75,9 +75,9 @@ discard block |
||
75 | 75 | * |
76 | 76 | * @param string $cap Capability name. |
77 | 77 | */ |
78 | - public function remove_cap( $cap ) { |
|
79 | - unset( $this->capabilities[$cap] ); |
|
80 | - wp_roles()->remove_cap( $this->name, $cap ); |
|
78 | + public function remove_cap($cap) { |
|
79 | + unset($this->capabilities[$cap]); |
|
80 | + wp_roles()->remove_cap($this->name, $cap); |
|
81 | 81 | } |
82 | 82 | |
83 | 83 | /** |
@@ -94,7 +94,7 @@ discard block |
||
94 | 94 | * @param string $cap Capability name. |
95 | 95 | * @return bool True if the role has the given capability. False otherwise. |
96 | 96 | */ |
97 | - public function has_cap( $cap ) { |
|
97 | + public function has_cap($cap) { |
|
98 | 98 | /** |
99 | 99 | * Filter which capabilities a role has. |
100 | 100 | * |
@@ -104,9 +104,9 @@ discard block |
||
104 | 104 | * @param string $cap Capability name. |
105 | 105 | * @param string $name Role name. |
106 | 106 | */ |
107 | - $capabilities = apply_filters( 'role_has_cap', $this->capabilities, $cap, $this->name ); |
|
107 | + $capabilities = apply_filters('role_has_cap', $this->capabilities, $cap, $this->name); |
|
108 | 108 | |
109 | - if ( !empty( $capabilities[$cap] ) ) |
|
109 | + if ( ! empty($capabilities[$cap])) |
|
110 | 110 | return $capabilities[$cap]; |
111 | 111 | else |
112 | 112 | return false; |
@@ -106,10 +106,11 @@ |
||
106 | 106 | */ |
107 | 107 | $capabilities = apply_filters( 'role_has_cap', $this->capabilities, $cap, $this->name ); |
108 | 108 | |
109 | - if ( !empty( $capabilities[$cap] ) ) |
|
110 | - return $capabilities[$cap]; |
|
111 | - else |
|
112 | - return false; |
|
109 | + if ( !empty( $capabilities[$cap] ) ) { |
|
110 | + return $capabilities[$cap]; |
|
111 | + } else { |
|
112 | + return false; |
|
113 | + } |
|
113 | 114 | } |
114 | 115 | |
115 | 116 | } |
@@ -35,26 +35,26 @@ discard block |
||
35 | 35 | 'headers' => array(), 'body' => null, 'cookies' => array() |
36 | 36 | ); |
37 | 37 | |
38 | - $r = wp_parse_args( $args, $defaults ); |
|
38 | + $r = wp_parse_args($args, $defaults); |
|
39 | 39 | |
40 | - if ( isset( $r['headers']['User-Agent'] ) ) { |
|
40 | + if (isset($r['headers']['User-Agent'])) { |
|
41 | 41 | $r['user-agent'] = $r['headers']['User-Agent']; |
42 | - unset( $r['headers']['User-Agent'] ); |
|
43 | - } elseif ( isset( $r['headers']['user-agent'] ) ) { |
|
42 | + unset($r['headers']['User-Agent']); |
|
43 | + } elseif (isset($r['headers']['user-agent'])) { |
|
44 | 44 | $r['user-agent'] = $r['headers']['user-agent']; |
45 | - unset( $r['headers']['user-agent'] ); |
|
45 | + unset($r['headers']['user-agent']); |
|
46 | 46 | } |
47 | 47 | |
48 | 48 | // Construct Cookie: header if any cookies are set. |
49 | - WP_Http::buildCookieHeader( $r ); |
|
49 | + WP_Http::buildCookieHeader($r); |
|
50 | 50 | |
51 | 51 | $arrURL = parse_url($url); |
52 | 52 | |
53 | 53 | $connect_host = $arrURL['host']; |
54 | 54 | |
55 | - $secure_transport = ( $arrURL['scheme'] == 'ssl' || $arrURL['scheme'] == 'https' ); |
|
56 | - if ( ! isset( $arrURL['port'] ) ) { |
|
57 | - if ( $arrURL['scheme'] == 'ssl' || $arrURL['scheme'] == 'https' ) { |
|
55 | + $secure_transport = ($arrURL['scheme'] == 'ssl' || $arrURL['scheme'] == 'https'); |
|
56 | + if ( ! isset($arrURL['port'])) { |
|
57 | + if ($arrURL['scheme'] == 'ssl' || $arrURL['scheme'] == 'https') { |
|
58 | 58 | $arrURL['port'] = 443; |
59 | 59 | $secure_transport = true; |
60 | 60 | } else { |
@@ -63,16 +63,16 @@ discard block |
||
63 | 63 | } |
64 | 64 | |
65 | 65 | // Always pass a Path, defaulting to the root in cases such as http://example.com |
66 | - if ( ! isset( $arrURL['path'] ) ) { |
|
66 | + if ( ! isset($arrURL['path'])) { |
|
67 | 67 | $arrURL['path'] = '/'; |
68 | 68 | } |
69 | 69 | |
70 | - if ( isset( $r['headers']['Host'] ) || isset( $r['headers']['host'] ) ) { |
|
71 | - if ( isset( $r['headers']['Host'] ) ) |
|
70 | + if (isset($r['headers']['Host']) || isset($r['headers']['host'])) { |
|
71 | + if (isset($r['headers']['Host'])) |
|
72 | 72 | $arrURL['host'] = $r['headers']['Host']; |
73 | 73 | else |
74 | 74 | $arrURL['host'] = $r['headers']['host']; |
75 | - unset( $r['headers']['Host'], $r['headers']['host'] ); |
|
75 | + unset($r['headers']['Host'], $r['headers']['host']); |
|
76 | 76 | } |
77 | 77 | |
78 | 78 | /* |
@@ -80,14 +80,14 @@ discard block |
||
80 | 80 | * to ::1, which fails when the server is not set up for it. For compatibility, always |
81 | 81 | * connect to the IPv4 address. |
82 | 82 | */ |
83 | - if ( 'localhost' == strtolower( $connect_host ) ) |
|
83 | + if ('localhost' == strtolower($connect_host)) |
|
84 | 84 | $connect_host = '127.0.0.1'; |
85 | 85 | |
86 | - $connect_host = $secure_transport ? 'ssl://' . $connect_host : 'tcp://' . $connect_host; |
|
86 | + $connect_host = $secure_transport ? 'ssl://'.$connect_host : 'tcp://'.$connect_host; |
|
87 | 87 | |
88 | - $is_local = isset( $r['local'] ) && $r['local']; |
|
89 | - $ssl_verify = isset( $r['sslverify'] ) && $r['sslverify']; |
|
90 | - if ( $is_local ) { |
|
88 | + $is_local = isset($r['local']) && $r['local']; |
|
89 | + $ssl_verify = isset($r['sslverify']) && $r['sslverify']; |
|
90 | + if ($is_local) { |
|
91 | 91 | /** |
92 | 92 | * Filter whether SSL should be verified for local requests. |
93 | 93 | * |
@@ -95,8 +95,8 @@ discard block |
||
95 | 95 | * |
96 | 96 | * @param bool $ssl_verify Whether to verify the SSL connection. Default true. |
97 | 97 | */ |
98 | - $ssl_verify = apply_filters( 'https_local_ssl_verify', $ssl_verify ); |
|
99 | - } elseif ( ! $is_local ) { |
|
98 | + $ssl_verify = apply_filters('https_local_ssl_verify', $ssl_verify); |
|
99 | + } elseif ( ! $is_local) { |
|
100 | 100 | /** |
101 | 101 | * Filter whether SSL should be verified for non-local requests. |
102 | 102 | * |
@@ -104,12 +104,12 @@ discard block |
||
104 | 104 | * |
105 | 105 | * @param bool $ssl_verify Whether to verify the SSL connection. Default true. |
106 | 106 | */ |
107 | - $ssl_verify = apply_filters( 'https_ssl_verify', $ssl_verify ); |
|
107 | + $ssl_verify = apply_filters('https_ssl_verify', $ssl_verify); |
|
108 | 108 | } |
109 | 109 | |
110 | 110 | $proxy = new WP_HTTP_Proxy(); |
111 | 111 | |
112 | - $context = stream_context_create( array( |
|
112 | + $context = stream_context_create(array( |
|
113 | 113 | 'ssl' => array( |
114 | 114 | 'verify_peer' => $ssl_verify, |
115 | 115 | //'CN_match' => $arrURL['host'], // This is handled by self::verify_ssl_certificate() |
@@ -118,11 +118,11 @@ discard block |
||
118 | 118 | 'cafile' => $r['sslcertificates'], |
119 | 119 | 'allow_self_signed' => ! $ssl_verify, |
120 | 120 | ) |
121 | - ) ); |
|
121 | + )); |
|
122 | 122 | |
123 | - $timeout = (int) floor( $r['timeout'] ); |
|
123 | + $timeout = (int) floor($r['timeout']); |
|
124 | 124 | $utimeout = $timeout == $r['timeout'] ? 0 : 1000000 * $r['timeout'] % 1000000; |
125 | - $connect_timeout = max( $timeout, 1 ); |
|
125 | + $connect_timeout = max($timeout, 1); |
|
126 | 126 | |
127 | 127 | // Store error number. |
128 | 128 | $connection_error = null; |
@@ -130,159 +130,159 @@ discard block |
||
130 | 130 | // Store error string. |
131 | 131 | $connection_error_str = null; |
132 | 132 | |
133 | - if ( !WP_DEBUG ) { |
|
133 | + if ( ! WP_DEBUG) { |
|
134 | 134 | // In the event that the SSL connection fails, silence the many PHP Warnings. |
135 | - if ( $secure_transport ) |
|
135 | + if ($secure_transport) |
|
136 | 136 | $error_reporting = error_reporting(0); |
137 | 137 | |
138 | - if ( $proxy->is_enabled() && $proxy->send_through_proxy( $url ) ) |
|
139 | - $handle = @stream_socket_client( 'tcp://' . $proxy->host() . ':' . $proxy->port(), $connection_error, $connection_error_str, $connect_timeout, STREAM_CLIENT_CONNECT, $context ); |
|
138 | + if ($proxy->is_enabled() && $proxy->send_through_proxy($url)) |
|
139 | + $handle = @stream_socket_client('tcp://'.$proxy->host().':'.$proxy->port(), $connection_error, $connection_error_str, $connect_timeout, STREAM_CLIENT_CONNECT, $context); |
|
140 | 140 | else |
141 | - $handle = @stream_socket_client( $connect_host . ':' . $arrURL['port'], $connection_error, $connection_error_str, $connect_timeout, STREAM_CLIENT_CONNECT, $context ); |
|
141 | + $handle = @stream_socket_client($connect_host.':'.$arrURL['port'], $connection_error, $connection_error_str, $connect_timeout, STREAM_CLIENT_CONNECT, $context); |
|
142 | 142 | |
143 | - if ( $secure_transport ) |
|
144 | - error_reporting( $error_reporting ); |
|
143 | + if ($secure_transport) |
|
144 | + error_reporting($error_reporting); |
|
145 | 145 | |
146 | 146 | } else { |
147 | - if ( $proxy->is_enabled() && $proxy->send_through_proxy( $url ) ) |
|
148 | - $handle = stream_socket_client( 'tcp://' . $proxy->host() . ':' . $proxy->port(), $connection_error, $connection_error_str, $connect_timeout, STREAM_CLIENT_CONNECT, $context ); |
|
147 | + if ($proxy->is_enabled() && $proxy->send_through_proxy($url)) |
|
148 | + $handle = stream_socket_client('tcp://'.$proxy->host().':'.$proxy->port(), $connection_error, $connection_error_str, $connect_timeout, STREAM_CLIENT_CONNECT, $context); |
|
149 | 149 | else |
150 | - $handle = stream_socket_client( $connect_host . ':' . $arrURL['port'], $connection_error, $connection_error_str, $connect_timeout, STREAM_CLIENT_CONNECT, $context ); |
|
150 | + $handle = stream_socket_client($connect_host.':'.$arrURL['port'], $connection_error, $connection_error_str, $connect_timeout, STREAM_CLIENT_CONNECT, $context); |
|
151 | 151 | } |
152 | 152 | |
153 | - if ( false === $handle ) { |
|
153 | + if (false === $handle) { |
|
154 | 154 | // SSL connection failed due to expired/invalid cert, or, OpenSSL configuration is broken. |
155 | - if ( $secure_transport && 0 === $connection_error && '' === $connection_error_str ) |
|
156 | - return new WP_Error( 'http_request_failed', __( 'The SSL certificate for the host could not be verified.' ) ); |
|
155 | + if ($secure_transport && 0 === $connection_error && '' === $connection_error_str) |
|
156 | + return new WP_Error('http_request_failed', __('The SSL certificate for the host could not be verified.')); |
|
157 | 157 | |
158 | - return new WP_Error('http_request_failed', $connection_error . ': ' . $connection_error_str ); |
|
158 | + return new WP_Error('http_request_failed', $connection_error.': '.$connection_error_str); |
|
159 | 159 | } |
160 | 160 | |
161 | 161 | // Verify that the SSL certificate is valid for this request. |
162 | - if ( $secure_transport && $ssl_verify && ! $proxy->is_enabled() ) { |
|
163 | - if ( ! self::verify_ssl_certificate( $handle, $arrURL['host'] ) ) |
|
164 | - return new WP_Error( 'http_request_failed', __( 'The SSL certificate for the host could not be verified.' ) ); |
|
162 | + if ($secure_transport && $ssl_verify && ! $proxy->is_enabled()) { |
|
163 | + if ( ! self::verify_ssl_certificate($handle, $arrURL['host'])) |
|
164 | + return new WP_Error('http_request_failed', __('The SSL certificate for the host could not be verified.')); |
|
165 | 165 | } |
166 | 166 | |
167 | - stream_set_timeout( $handle, $timeout, $utimeout ); |
|
167 | + stream_set_timeout($handle, $timeout, $utimeout); |
|
168 | 168 | |
169 | - if ( $proxy->is_enabled() && $proxy->send_through_proxy( $url ) ) //Some proxies require full URL in this field. |
|
169 | + if ($proxy->is_enabled() && $proxy->send_through_proxy($url)) //Some proxies require full URL in this field. |
|
170 | 170 | $requestPath = $url; |
171 | 171 | else |
172 | - $requestPath = $arrURL['path'] . ( isset($arrURL['query']) ? '?' . $arrURL['query'] : '' ); |
|
172 | + $requestPath = $arrURL['path'].(isset($arrURL['query']) ? '?'.$arrURL['query'] : ''); |
|
173 | 173 | |
174 | - $strHeaders = strtoupper($r['method']) . ' ' . $requestPath . ' HTTP/' . $r['httpversion'] . "\r\n"; |
|
174 | + $strHeaders = strtoupper($r['method']).' '.$requestPath.' HTTP/'.$r['httpversion']."\r\n"; |
|
175 | 175 | |
176 | 176 | $include_port_in_host_header = ( |
177 | - ( $proxy->is_enabled() && $proxy->send_through_proxy( $url ) ) || |
|
178 | - ( 'http' == $arrURL['scheme'] && 80 != $arrURL['port'] ) || |
|
179 | - ( 'https' == $arrURL['scheme'] && 443 != $arrURL['port'] ) |
|
177 | + ($proxy->is_enabled() && $proxy->send_through_proxy($url)) || |
|
178 | + ('http' == $arrURL['scheme'] && 80 != $arrURL['port']) || |
|
179 | + ('https' == $arrURL['scheme'] && 443 != $arrURL['port']) |
|
180 | 180 | ); |
181 | 181 | |
182 | - if ( $include_port_in_host_header ) { |
|
183 | - $strHeaders .= 'Host: ' . $arrURL['host'] . ':' . $arrURL['port'] . "\r\n"; |
|
182 | + if ($include_port_in_host_header) { |
|
183 | + $strHeaders .= 'Host: '.$arrURL['host'].':'.$arrURL['port']."\r\n"; |
|
184 | 184 | } else { |
185 | - $strHeaders .= 'Host: ' . $arrURL['host'] . "\r\n"; |
|
185 | + $strHeaders .= 'Host: '.$arrURL['host']."\r\n"; |
|
186 | 186 | } |
187 | 187 | |
188 | - if ( isset($r['user-agent']) ) |
|
189 | - $strHeaders .= 'User-agent: ' . $r['user-agent'] . "\r\n"; |
|
188 | + if (isset($r['user-agent'])) |
|
189 | + $strHeaders .= 'User-agent: '.$r['user-agent']."\r\n"; |
|
190 | 190 | |
191 | - if ( is_array($r['headers']) ) { |
|
192 | - foreach ( (array) $r['headers'] as $header => $headerValue ) |
|
193 | - $strHeaders .= $header . ': ' . $headerValue . "\r\n"; |
|
191 | + if (is_array($r['headers'])) { |
|
192 | + foreach ((array) $r['headers'] as $header => $headerValue) |
|
193 | + $strHeaders .= $header.': '.$headerValue."\r\n"; |
|
194 | 194 | } else { |
195 | 195 | $strHeaders .= $r['headers']; |
196 | 196 | } |
197 | 197 | |
198 | - if ( $proxy->use_authentication() ) |
|
199 | - $strHeaders .= $proxy->authentication_header() . "\r\n"; |
|
198 | + if ($proxy->use_authentication()) |
|
199 | + $strHeaders .= $proxy->authentication_header()."\r\n"; |
|
200 | 200 | |
201 | 201 | $strHeaders .= "\r\n"; |
202 | 202 | |
203 | - if ( ! is_null($r['body']) ) |
|
203 | + if ( ! is_null($r['body'])) |
|
204 | 204 | $strHeaders .= $r['body']; |
205 | 205 | |
206 | 206 | fwrite($handle, $strHeaders); |
207 | 207 | |
208 | - if ( ! $r['blocking'] ) { |
|
209 | - stream_set_blocking( $handle, 0 ); |
|
210 | - fclose( $handle ); |
|
211 | - return array( 'headers' => array(), 'body' => '', 'response' => array('code' => false, 'message' => false), 'cookies' => array() ); |
|
208 | + if ( ! $r['blocking']) { |
|
209 | + stream_set_blocking($handle, 0); |
|
210 | + fclose($handle); |
|
211 | + return array('headers' => array(), 'body' => '', 'response' => array('code' => false, 'message' => false), 'cookies' => array()); |
|
212 | 212 | } |
213 | 213 | |
214 | 214 | $strResponse = ''; |
215 | 215 | $bodyStarted = false; |
216 | 216 | $keep_reading = true; |
217 | 217 | $block_size = 4096; |
218 | - if ( isset( $r['limit_response_size'] ) ) |
|
219 | - $block_size = min( $block_size, $r['limit_response_size'] ); |
|
218 | + if (isset($r['limit_response_size'])) |
|
219 | + $block_size = min($block_size, $r['limit_response_size']); |
|
220 | 220 | |
221 | 221 | // If streaming to a file setup the file handle. |
222 | - if ( $r['stream'] ) { |
|
223 | - if ( ! WP_DEBUG ) |
|
224 | - $stream_handle = @fopen( $r['filename'], 'w+' ); |
|
222 | + if ($r['stream']) { |
|
223 | + if ( ! WP_DEBUG) |
|
224 | + $stream_handle = @fopen($r['filename'], 'w+'); |
|
225 | 225 | else |
226 | - $stream_handle = fopen( $r['filename'], 'w+' ); |
|
227 | - if ( ! $stream_handle ) |
|
228 | - return new WP_Error( 'http_request_failed', sprintf( __( 'Could not open handle for fopen() to %s' ), $r['filename'] ) ); |
|
226 | + $stream_handle = fopen($r['filename'], 'w+'); |
|
227 | + if ( ! $stream_handle) |
|
228 | + return new WP_Error('http_request_failed', sprintf(__('Could not open handle for fopen() to %s'), $r['filename'])); |
|
229 | 229 | |
230 | 230 | $bytes_written = 0; |
231 | - while ( ! feof($handle) && $keep_reading ) { |
|
232 | - $block = fread( $handle, $block_size ); |
|
233 | - if ( ! $bodyStarted ) { |
|
231 | + while ( ! feof($handle) && $keep_reading) { |
|
232 | + $block = fread($handle, $block_size); |
|
233 | + if ( ! $bodyStarted) { |
|
234 | 234 | $strResponse .= $block; |
235 | - if ( strpos( $strResponse, "\r\n\r\n" ) ) { |
|
236 | - $process = WP_Http::processResponse( $strResponse ); |
|
235 | + if (strpos($strResponse, "\r\n\r\n")) { |
|
236 | + $process = WP_Http::processResponse($strResponse); |
|
237 | 237 | $bodyStarted = true; |
238 | 238 | $block = $process['body']; |
239 | - unset( $strResponse ); |
|
239 | + unset($strResponse); |
|
240 | 240 | $process['body'] = ''; |
241 | 241 | } |
242 | 242 | } |
243 | 243 | |
244 | - $this_block_size = strlen( $block ); |
|
244 | + $this_block_size = strlen($block); |
|
245 | 245 | |
246 | - if ( isset( $r['limit_response_size'] ) && ( $bytes_written + $this_block_size ) > $r['limit_response_size'] ) { |
|
247 | - $this_block_size = ( $r['limit_response_size'] - $bytes_written ); |
|
248 | - $block = substr( $block, 0, $this_block_size ); |
|
246 | + if (isset($r['limit_response_size']) && ($bytes_written + $this_block_size) > $r['limit_response_size']) { |
|
247 | + $this_block_size = ($r['limit_response_size'] - $bytes_written); |
|
248 | + $block = substr($block, 0, $this_block_size); |
|
249 | 249 | } |
250 | 250 | |
251 | - $bytes_written_to_file = fwrite( $stream_handle, $block ); |
|
251 | + $bytes_written_to_file = fwrite($stream_handle, $block); |
|
252 | 252 | |
253 | - if ( $bytes_written_to_file != $this_block_size ) { |
|
254 | - fclose( $handle ); |
|
255 | - fclose( $stream_handle ); |
|
256 | - return new WP_Error( 'http_request_failed', __( 'Failed to write request to temporary file.' ) ); |
|
253 | + if ($bytes_written_to_file != $this_block_size) { |
|
254 | + fclose($handle); |
|
255 | + fclose($stream_handle); |
|
256 | + return new WP_Error('http_request_failed', __('Failed to write request to temporary file.')); |
|
257 | 257 | } |
258 | 258 | |
259 | 259 | $bytes_written += $bytes_written_to_file; |
260 | 260 | |
261 | - $keep_reading = !isset( $r['limit_response_size'] ) || $bytes_written < $r['limit_response_size']; |
|
261 | + $keep_reading = ! isset($r['limit_response_size']) || $bytes_written < $r['limit_response_size']; |
|
262 | 262 | } |
263 | 263 | |
264 | - fclose( $stream_handle ); |
|
264 | + fclose($stream_handle); |
|
265 | 265 | |
266 | 266 | } else { |
267 | 267 | $header_length = 0; |
268 | - while ( ! feof( $handle ) && $keep_reading ) { |
|
269 | - $block = fread( $handle, $block_size ); |
|
268 | + while ( ! feof($handle) && $keep_reading) { |
|
269 | + $block = fread($handle, $block_size); |
|
270 | 270 | $strResponse .= $block; |
271 | - if ( ! $bodyStarted && strpos( $strResponse, "\r\n\r\n" ) ) { |
|
272 | - $header_length = strpos( $strResponse, "\r\n\r\n" ) + 4; |
|
271 | + if ( ! $bodyStarted && strpos($strResponse, "\r\n\r\n")) { |
|
272 | + $header_length = strpos($strResponse, "\r\n\r\n") + 4; |
|
273 | 273 | $bodyStarted = true; |
274 | 274 | } |
275 | - $keep_reading = ( ! $bodyStarted || !isset( $r['limit_response_size'] ) || strlen( $strResponse ) < ( $header_length + $r['limit_response_size'] ) ); |
|
275 | + $keep_reading = ( ! $bodyStarted || ! isset($r['limit_response_size']) || strlen($strResponse) < ($header_length + $r['limit_response_size'])); |
|
276 | 276 | } |
277 | 277 | |
278 | - $process = WP_Http::processResponse( $strResponse ); |
|
279 | - unset( $strResponse ); |
|
278 | + $process = WP_Http::processResponse($strResponse); |
|
279 | + unset($strResponse); |
|
280 | 280 | |
281 | 281 | } |
282 | 282 | |
283 | - fclose( $handle ); |
|
283 | + fclose($handle); |
|
284 | 284 | |
285 | - $arrHeaders = WP_Http::processHeaders( $process['headers'], $url ); |
|
285 | + $arrHeaders = WP_Http::processHeaders($process['headers'], $url); |
|
286 | 286 | |
287 | 287 | $response = array( |
288 | 288 | 'headers' => $arrHeaders['headers'], |
@@ -294,18 +294,18 @@ discard block |
||
294 | 294 | ); |
295 | 295 | |
296 | 296 | // Handle redirects. |
297 | - if ( false !== ( $redirect_response = WP_Http::handle_redirects( $url, $r, $response ) ) ) |
|
297 | + if (false !== ($redirect_response = WP_Http::handle_redirects($url, $r, $response))) |
|
298 | 298 | return $redirect_response; |
299 | 299 | |
300 | 300 | // If the body was chunk encoded, then decode it. |
301 | - if ( ! empty( $process['body'] ) && isset( $arrHeaders['headers']['transfer-encoding'] ) && 'chunked' == $arrHeaders['headers']['transfer-encoding'] ) |
|
301 | + if ( ! empty($process['body']) && isset($arrHeaders['headers']['transfer-encoding']) && 'chunked' == $arrHeaders['headers']['transfer-encoding']) |
|
302 | 302 | $process['body'] = WP_Http::chunkTransferDecode($process['body']); |
303 | 303 | |
304 | - if ( true === $r['decompress'] && true === WP_Http_Encoding::should_decode($arrHeaders['headers']) ) |
|
305 | - $process['body'] = WP_Http_Encoding::decompress( $process['body'] ); |
|
304 | + if (true === $r['decompress'] && true === WP_Http_Encoding::should_decode($arrHeaders['headers'])) |
|
305 | + $process['body'] = WP_Http_Encoding::decompress($process['body']); |
|
306 | 306 | |
307 | - if ( isset( $r['limit_response_size'] ) && strlen( $process['body'] ) > $r['limit_response_size'] ) |
|
308 | - $process['body'] = substr( $process['body'], 0, $r['limit_response_size'] ); |
|
307 | + if (isset($r['limit_response_size']) && strlen($process['body']) > $r['limit_response_size']) |
|
308 | + $process['body'] = substr($process['body'], 0, $r['limit_response_size']); |
|
309 | 309 | |
310 | 310 | $response['body'] = $process['body']; |
311 | 311 | |
@@ -329,51 +329,51 @@ discard block |
||
329 | 329 | * @param string $host The hostname being requested |
330 | 330 | * @return bool If the cerficiate presented in $stream is valid for $host |
331 | 331 | */ |
332 | - public static function verify_ssl_certificate( $stream, $host ) { |
|
333 | - $context_options = stream_context_get_options( $stream ); |
|
332 | + public static function verify_ssl_certificate($stream, $host) { |
|
333 | + $context_options = stream_context_get_options($stream); |
|
334 | 334 | |
335 | - if ( empty( $context_options['ssl']['peer_certificate'] ) ) |
|
335 | + if (empty($context_options['ssl']['peer_certificate'])) |
|
336 | 336 | return false; |
337 | 337 | |
338 | - $cert = openssl_x509_parse( $context_options['ssl']['peer_certificate'] ); |
|
339 | - if ( ! $cert ) |
|
338 | + $cert = openssl_x509_parse($context_options['ssl']['peer_certificate']); |
|
339 | + if ( ! $cert) |
|
340 | 340 | return false; |
341 | 341 | |
342 | 342 | /* |
343 | 343 | * If the request is being made to an IP address, we'll validate against IP fields |
344 | 344 | * in the cert (if they exist) |
345 | 345 | */ |
346 | - $host_type = ( WP_Http::is_ip_address( $host ) ? 'ip' : 'dns' ); |
|
346 | + $host_type = (WP_Http::is_ip_address($host) ? 'ip' : 'dns'); |
|
347 | 347 | |
348 | 348 | $certificate_hostnames = array(); |
349 | - if ( ! empty( $cert['extensions']['subjectAltName'] ) ) { |
|
350 | - $match_against = preg_split( '/,\s*/', $cert['extensions']['subjectAltName'] ); |
|
351 | - foreach ( $match_against as $match ) { |
|
352 | - list( $match_type, $match_host ) = explode( ':', $match ); |
|
353 | - if ( $host_type == strtolower( trim( $match_type ) ) ) // IP: or DNS: |
|
354 | - $certificate_hostnames[] = strtolower( trim( $match_host ) ); |
|
349 | + if ( ! empty($cert['extensions']['subjectAltName'])) { |
|
350 | + $match_against = preg_split('/,\s*/', $cert['extensions']['subjectAltName']); |
|
351 | + foreach ($match_against as $match) { |
|
352 | + list($match_type, $match_host) = explode(':', $match); |
|
353 | + if ($host_type == strtolower(trim($match_type))) // IP: or DNS: |
|
354 | + $certificate_hostnames[] = strtolower(trim($match_host)); |
|
355 | 355 | } |
356 | - } elseif ( !empty( $cert['subject']['CN'] ) ) { |
|
356 | + } elseif ( ! empty($cert['subject']['CN'])) { |
|
357 | 357 | // Only use the CN when the certificate includes no subjectAltName extension. |
358 | - $certificate_hostnames[] = strtolower( $cert['subject']['CN'] ); |
|
358 | + $certificate_hostnames[] = strtolower($cert['subject']['CN']); |
|
359 | 359 | } |
360 | 360 | |
361 | 361 | // Exact hostname/IP matches. |
362 | - if ( in_array( strtolower( $host ), $certificate_hostnames ) ) |
|
362 | + if (in_array(strtolower($host), $certificate_hostnames)) |
|
363 | 363 | return true; |
364 | 364 | |
365 | 365 | // IP's can't be wildcards, Stop processing. |
366 | - if ( 'ip' == $host_type ) |
|
366 | + if ('ip' == $host_type) |
|
367 | 367 | return false; |
368 | 368 | |
369 | 369 | // Test to see if the domain is at least 2 deep for wildcard support. |
370 | - if ( substr_count( $host, '.' ) < 2 ) |
|
370 | + if (substr_count($host, '.') < 2) |
|
371 | 371 | return false; |
372 | 372 | |
373 | 373 | // Wildcard subdomains certs (*.example.com) are valid for a.example.com but not a.b.example.com. |
374 | - $wildcard_host = preg_replace( '/^[^.]+\./', '*.', $host ); |
|
374 | + $wildcard_host = preg_replace('/^[^.]+\./', '*.', $host); |
|
375 | 375 | |
376 | - return in_array( strtolower( $wildcard_host ), $certificate_hostnames ); |
|
376 | + return in_array(strtolower($wildcard_host), $certificate_hostnames); |
|
377 | 377 | } |
378 | 378 | |
379 | 379 | /** |
@@ -387,16 +387,16 @@ discard block |
||
387 | 387 | * @param array $args Optional. Array of request arguments. Default empty array. |
388 | 388 | * @return bool False means this class can not be used, true means it can. |
389 | 389 | */ |
390 | - public static function test( $args = array() ) { |
|
391 | - if ( ! function_exists( 'stream_socket_client' ) ) |
|
390 | + public static function test($args = array()) { |
|
391 | + if ( ! function_exists('stream_socket_client')) |
|
392 | 392 | return false; |
393 | 393 | |
394 | - $is_ssl = isset( $args['ssl'] ) && $args['ssl']; |
|
394 | + $is_ssl = isset($args['ssl']) && $args['ssl']; |
|
395 | 395 | |
396 | - if ( $is_ssl ) { |
|
397 | - if ( ! extension_loaded( 'openssl' ) ) |
|
396 | + if ($is_ssl) { |
|
397 | + if ( ! extension_loaded('openssl')) |
|
398 | 398 | return false; |
399 | - if ( ! function_exists( 'openssl_x509_parse' ) ) |
|
399 | + if ( ! function_exists('openssl_x509_parse')) |
|
400 | 400 | return false; |
401 | 401 | } |
402 | 402 | |
@@ -408,7 +408,7 @@ discard block |
||
408 | 408 | * @param bool $use_class Whether the class can be used. Default true. |
409 | 409 | * @param array $args Request arguments. |
410 | 410 | */ |
411 | - return apply_filters( 'use_streams_transport', true, $args ); |
|
411 | + return apply_filters('use_streams_transport', true, $args); |
|
412 | 412 | } |
413 | 413 | } |
414 | 414 |
@@ -68,10 +68,11 @@ discard block |
||
68 | 68 | } |
69 | 69 | |
70 | 70 | if ( isset( $r['headers']['Host'] ) || isset( $r['headers']['host'] ) ) { |
71 | - if ( isset( $r['headers']['Host'] ) ) |
|
72 | - $arrURL['host'] = $r['headers']['Host']; |
|
73 | - else |
|
74 | - $arrURL['host'] = $r['headers']['host']; |
|
71 | + if ( isset( $r['headers']['Host'] ) ) { |
|
72 | + $arrURL['host'] = $r['headers']['Host']; |
|
73 | + } else { |
|
74 | + $arrURL['host'] = $r['headers']['host']; |
|
75 | + } |
|
75 | 76 | unset( $r['headers']['Host'], $r['headers']['host'] ); |
76 | 77 | } |
77 | 78 | |
@@ -80,8 +81,9 @@ discard block |
||
80 | 81 | * to ::1, which fails when the server is not set up for it. For compatibility, always |
81 | 82 | * connect to the IPv4 address. |
82 | 83 | */ |
83 | - if ( 'localhost' == strtolower( $connect_host ) ) |
|
84 | - $connect_host = '127.0.0.1'; |
|
84 | + if ( 'localhost' == strtolower( $connect_host ) ) { |
|
85 | + $connect_host = '127.0.0.1'; |
|
86 | + } |
|
85 | 87 | |
86 | 88 | $connect_host = $secure_transport ? 'ssl://' . $connect_host : 'tcp://' . $connect_host; |
87 | 89 | |
@@ -132,44 +134,52 @@ discard block |
||
132 | 134 | |
133 | 135 | if ( !WP_DEBUG ) { |
134 | 136 | // In the event that the SSL connection fails, silence the many PHP Warnings. |
135 | - if ( $secure_transport ) |
|
136 | - $error_reporting = error_reporting(0); |
|
137 | + if ( $secure_transport ) { |
|
138 | + $error_reporting = error_reporting(0); |
|
139 | + } |
|
137 | 140 | |
138 | - if ( $proxy->is_enabled() && $proxy->send_through_proxy( $url ) ) |
|
139 | - $handle = @stream_socket_client( 'tcp://' . $proxy->host() . ':' . $proxy->port(), $connection_error, $connection_error_str, $connect_timeout, STREAM_CLIENT_CONNECT, $context ); |
|
140 | - else |
|
141 | - $handle = @stream_socket_client( $connect_host . ':' . $arrURL['port'], $connection_error, $connection_error_str, $connect_timeout, STREAM_CLIENT_CONNECT, $context ); |
|
141 | + if ( $proxy->is_enabled() && $proxy->send_through_proxy( $url ) ) { |
|
142 | + $handle = @stream_socket_client( 'tcp://' . $proxy->host() . ':' . $proxy->port(), $connection_error, $connection_error_str, $connect_timeout, STREAM_CLIENT_CONNECT, $context ); |
|
143 | + } else { |
|
144 | + $handle = @stream_socket_client( $connect_host . ':' . $arrURL['port'], $connection_error, $connection_error_str, $connect_timeout, STREAM_CLIENT_CONNECT, $context ); |
|
145 | + } |
|
142 | 146 | |
143 | - if ( $secure_transport ) |
|
144 | - error_reporting( $error_reporting ); |
|
147 | + if ( $secure_transport ) { |
|
148 | + error_reporting( $error_reporting ); |
|
149 | + } |
|
145 | 150 | |
146 | 151 | } else { |
147 | - if ( $proxy->is_enabled() && $proxy->send_through_proxy( $url ) ) |
|
148 | - $handle = stream_socket_client( 'tcp://' . $proxy->host() . ':' . $proxy->port(), $connection_error, $connection_error_str, $connect_timeout, STREAM_CLIENT_CONNECT, $context ); |
|
149 | - else |
|
150 | - $handle = stream_socket_client( $connect_host . ':' . $arrURL['port'], $connection_error, $connection_error_str, $connect_timeout, STREAM_CLIENT_CONNECT, $context ); |
|
152 | + if ( $proxy->is_enabled() && $proxy->send_through_proxy( $url ) ) { |
|
153 | + $handle = stream_socket_client( 'tcp://' . $proxy->host() . ':' . $proxy->port(), $connection_error, $connection_error_str, $connect_timeout, STREAM_CLIENT_CONNECT, $context ); |
|
154 | + } else { |
|
155 | + $handle = stream_socket_client( $connect_host . ':' . $arrURL['port'], $connection_error, $connection_error_str, $connect_timeout, STREAM_CLIENT_CONNECT, $context ); |
|
156 | + } |
|
151 | 157 | } |
152 | 158 | |
153 | 159 | if ( false === $handle ) { |
154 | 160 | // SSL connection failed due to expired/invalid cert, or, OpenSSL configuration is broken. |
155 | - if ( $secure_transport && 0 === $connection_error && '' === $connection_error_str ) |
|
156 | - return new WP_Error( 'http_request_failed', __( 'The SSL certificate for the host could not be verified.' ) ); |
|
161 | + if ( $secure_transport && 0 === $connection_error && '' === $connection_error_str ) { |
|
162 | + return new WP_Error( 'http_request_failed', __( 'The SSL certificate for the host could not be verified.' ) ); |
|
163 | + } |
|
157 | 164 | |
158 | 165 | return new WP_Error('http_request_failed', $connection_error . ': ' . $connection_error_str ); |
159 | 166 | } |
160 | 167 | |
161 | 168 | // Verify that the SSL certificate is valid for this request. |
162 | 169 | if ( $secure_transport && $ssl_verify && ! $proxy->is_enabled() ) { |
163 | - if ( ! self::verify_ssl_certificate( $handle, $arrURL['host'] ) ) |
|
164 | - return new WP_Error( 'http_request_failed', __( 'The SSL certificate for the host could not be verified.' ) ); |
|
170 | + if ( ! self::verify_ssl_certificate( $handle, $arrURL['host'] ) ) { |
|
171 | + return new WP_Error( 'http_request_failed', __( 'The SSL certificate for the host could not be verified.' ) ); |
|
172 | + } |
|
165 | 173 | } |
166 | 174 | |
167 | 175 | stream_set_timeout( $handle, $timeout, $utimeout ); |
168 | 176 | |
169 | - if ( $proxy->is_enabled() && $proxy->send_through_proxy( $url ) ) //Some proxies require full URL in this field. |
|
177 | + if ( $proxy->is_enabled() && $proxy->send_through_proxy( $url ) ) { |
|
178 | + //Some proxies require full URL in this field. |
|
170 | 179 | $requestPath = $url; |
171 | - else |
|
172 | - $requestPath = $arrURL['path'] . ( isset($arrURL['query']) ? '?' . $arrURL['query'] : '' ); |
|
180 | + } else { |
|
181 | + $requestPath = $arrURL['path'] . ( isset($arrURL['query']) ? '?' . $arrURL['query'] : '' ); |
|
182 | + } |
|
173 | 183 | |
174 | 184 | $strHeaders = strtoupper($r['method']) . ' ' . $requestPath . ' HTTP/' . $r['httpversion'] . "\r\n"; |
175 | 185 | |
@@ -185,23 +195,27 @@ discard block |
||
185 | 195 | $strHeaders .= 'Host: ' . $arrURL['host'] . "\r\n"; |
186 | 196 | } |
187 | 197 | |
188 | - if ( isset($r['user-agent']) ) |
|
189 | - $strHeaders .= 'User-agent: ' . $r['user-agent'] . "\r\n"; |
|
198 | + if ( isset($r['user-agent']) ) { |
|
199 | + $strHeaders .= 'User-agent: ' . $r['user-agent'] . "\r\n"; |
|
200 | + } |
|
190 | 201 | |
191 | 202 | if ( is_array($r['headers']) ) { |
192 | - foreach ( (array) $r['headers'] as $header => $headerValue ) |
|
193 | - $strHeaders .= $header . ': ' . $headerValue . "\r\n"; |
|
203 | + foreach ( (array) $r['headers'] as $header => $headerValue ) { |
|
204 | + $strHeaders .= $header . ': ' . $headerValue . "\r\n"; |
|
205 | + } |
|
194 | 206 | } else { |
195 | 207 | $strHeaders .= $r['headers']; |
196 | 208 | } |
197 | 209 | |
198 | - if ( $proxy->use_authentication() ) |
|
199 | - $strHeaders .= $proxy->authentication_header() . "\r\n"; |
|
210 | + if ( $proxy->use_authentication() ) { |
|
211 | + $strHeaders .= $proxy->authentication_header() . "\r\n"; |
|
212 | + } |
|
200 | 213 | |
201 | 214 | $strHeaders .= "\r\n"; |
202 | 215 | |
203 | - if ( ! is_null($r['body']) ) |
|
204 | - $strHeaders .= $r['body']; |
|
216 | + if ( ! is_null($r['body']) ) { |
|
217 | + $strHeaders .= $r['body']; |
|
218 | + } |
|
205 | 219 | |
206 | 220 | fwrite($handle, $strHeaders); |
207 | 221 | |
@@ -215,17 +229,20 @@ discard block |
||
215 | 229 | $bodyStarted = false; |
216 | 230 | $keep_reading = true; |
217 | 231 | $block_size = 4096; |
218 | - if ( isset( $r['limit_response_size'] ) ) |
|
219 | - $block_size = min( $block_size, $r['limit_response_size'] ); |
|
232 | + if ( isset( $r['limit_response_size'] ) ) { |
|
233 | + $block_size = min( $block_size, $r['limit_response_size'] ); |
|
234 | + } |
|
220 | 235 | |
221 | 236 | // If streaming to a file setup the file handle. |
222 | 237 | if ( $r['stream'] ) { |
223 | - if ( ! WP_DEBUG ) |
|
224 | - $stream_handle = @fopen( $r['filename'], 'w+' ); |
|
225 | - else |
|
226 | - $stream_handle = fopen( $r['filename'], 'w+' ); |
|
227 | - if ( ! $stream_handle ) |
|
228 | - return new WP_Error( 'http_request_failed', sprintf( __( 'Could not open handle for fopen() to %s' ), $r['filename'] ) ); |
|
238 | + if ( ! WP_DEBUG ) { |
|
239 | + $stream_handle = @fopen( $r['filename'], 'w+' ); |
|
240 | + } else { |
|
241 | + $stream_handle = fopen( $r['filename'], 'w+' ); |
|
242 | + } |
|
243 | + if ( ! $stream_handle ) { |
|
244 | + return new WP_Error( 'http_request_failed', sprintf( __( 'Could not open handle for fopen() to %s' ), $r['filename'] ) ); |
|
245 | + } |
|
229 | 246 | |
230 | 247 | $bytes_written = 0; |
231 | 248 | while ( ! feof($handle) && $keep_reading ) { |
@@ -294,18 +311,22 @@ discard block |
||
294 | 311 | ); |
295 | 312 | |
296 | 313 | // Handle redirects. |
297 | - if ( false !== ( $redirect_response = WP_Http::handle_redirects( $url, $r, $response ) ) ) |
|
298 | - return $redirect_response; |
|
314 | + if ( false !== ( $redirect_response = WP_Http::handle_redirects( $url, $r, $response ) ) ) { |
|
315 | + return $redirect_response; |
|
316 | + } |
|
299 | 317 | |
300 | 318 | // If the body was chunk encoded, then decode it. |
301 | - if ( ! empty( $process['body'] ) && isset( $arrHeaders['headers']['transfer-encoding'] ) && 'chunked' == $arrHeaders['headers']['transfer-encoding'] ) |
|
302 | - $process['body'] = WP_Http::chunkTransferDecode($process['body']); |
|
319 | + if ( ! empty( $process['body'] ) && isset( $arrHeaders['headers']['transfer-encoding'] ) && 'chunked' == $arrHeaders['headers']['transfer-encoding'] ) { |
|
320 | + $process['body'] = WP_Http::chunkTransferDecode($process['body']); |
|
321 | + } |
|
303 | 322 | |
304 | - if ( true === $r['decompress'] && true === WP_Http_Encoding::should_decode($arrHeaders['headers']) ) |
|
305 | - $process['body'] = WP_Http_Encoding::decompress( $process['body'] ); |
|
323 | + if ( true === $r['decompress'] && true === WP_Http_Encoding::should_decode($arrHeaders['headers']) ) { |
|
324 | + $process['body'] = WP_Http_Encoding::decompress( $process['body'] ); |
|
325 | + } |
|
306 | 326 | |
307 | - if ( isset( $r['limit_response_size'] ) && strlen( $process['body'] ) > $r['limit_response_size'] ) |
|
308 | - $process['body'] = substr( $process['body'], 0, $r['limit_response_size'] ); |
|
327 | + if ( isset( $r['limit_response_size'] ) && strlen( $process['body'] ) > $r['limit_response_size'] ) { |
|
328 | + $process['body'] = substr( $process['body'], 0, $r['limit_response_size'] ); |
|
329 | + } |
|
309 | 330 | |
310 | 331 | $response['body'] = $process['body']; |
311 | 332 | |
@@ -332,12 +353,14 @@ discard block |
||
332 | 353 | public static function verify_ssl_certificate( $stream, $host ) { |
333 | 354 | $context_options = stream_context_get_options( $stream ); |
334 | 355 | |
335 | - if ( empty( $context_options['ssl']['peer_certificate'] ) ) |
|
336 | - return false; |
|
356 | + if ( empty( $context_options['ssl']['peer_certificate'] ) ) { |
|
357 | + return false; |
|
358 | + } |
|
337 | 359 | |
338 | 360 | $cert = openssl_x509_parse( $context_options['ssl']['peer_certificate'] ); |
339 | - if ( ! $cert ) |
|
340 | - return false; |
|
361 | + if ( ! $cert ) { |
|
362 | + return false; |
|
363 | + } |
|
341 | 364 | |
342 | 365 | /* |
343 | 366 | * If the request is being made to an IP address, we'll validate against IP fields |
@@ -350,8 +373,10 @@ discard block |
||
350 | 373 | $match_against = preg_split( '/,\s*/', $cert['extensions']['subjectAltName'] ); |
351 | 374 | foreach ( $match_against as $match ) { |
352 | 375 | list( $match_type, $match_host ) = explode( ':', $match ); |
353 | - if ( $host_type == strtolower( trim( $match_type ) ) ) // IP: or DNS: |
|
376 | + if ( $host_type == strtolower( trim( $match_type ) ) ) { |
|
377 | + // IP: or DNS: |
|
354 | 378 | $certificate_hostnames[] = strtolower( trim( $match_host ) ); |
379 | + } |
|
355 | 380 | } |
356 | 381 | } elseif ( !empty( $cert['subject']['CN'] ) ) { |
357 | 382 | // Only use the CN when the certificate includes no subjectAltName extension. |
@@ -359,16 +384,19 @@ discard block |
||
359 | 384 | } |
360 | 385 | |
361 | 386 | // Exact hostname/IP matches. |
362 | - if ( in_array( strtolower( $host ), $certificate_hostnames ) ) |
|
363 | - return true; |
|
387 | + if ( in_array( strtolower( $host ), $certificate_hostnames ) ) { |
|
388 | + return true; |
|
389 | + } |
|
364 | 390 | |
365 | 391 | // IP's can't be wildcards, Stop processing. |
366 | - if ( 'ip' == $host_type ) |
|
367 | - return false; |
|
392 | + if ( 'ip' == $host_type ) { |
|
393 | + return false; |
|
394 | + } |
|
368 | 395 | |
369 | 396 | // Test to see if the domain is at least 2 deep for wildcard support. |
370 | - if ( substr_count( $host, '.' ) < 2 ) |
|
371 | - return false; |
|
397 | + if ( substr_count( $host, '.' ) < 2 ) { |
|
398 | + return false; |
|
399 | + } |
|
372 | 400 | |
373 | 401 | // Wildcard subdomains certs (*.example.com) are valid for a.example.com but not a.b.example.com. |
374 | 402 | $wildcard_host = preg_replace( '/^[^.]+\./', '*.', $host ); |
@@ -388,16 +416,19 @@ discard block |
||
388 | 416 | * @return bool False means this class can not be used, true means it can. |
389 | 417 | */ |
390 | 418 | public static function test( $args = array() ) { |
391 | - if ( ! function_exists( 'stream_socket_client' ) ) |
|
392 | - return false; |
|
419 | + if ( ! function_exists( 'stream_socket_client' ) ) { |
|
420 | + return false; |
|
421 | + } |
|
393 | 422 | |
394 | 423 | $is_ssl = isset( $args['ssl'] ) && $args['ssl']; |
395 | 424 | |
396 | 425 | if ( $is_ssl ) { |
397 | - if ( ! extension_loaded( 'openssl' ) ) |
|
398 | - return false; |
|
399 | - if ( ! function_exists( 'openssl_x509_parse' ) ) |
|
400 | - return false; |
|
426 | + if ( ! extension_loaded( 'openssl' ) ) { |
|
427 | + return false; |
|
428 | + } |
|
429 | + if ( ! function_exists( 'openssl_x509_parse' ) ) { |
|
430 | + return false; |
|
431 | + } |
|
401 | 432 | } |
402 | 433 | |
403 | 434 | /** |
@@ -147,18 +147,18 @@ discard block |
||
147 | 147 | * @param string $id An specific ID for the panel. |
148 | 148 | * @param array $args Panel arguments. |
149 | 149 | */ |
150 | - public function __construct( $manager, $id, $args = array() ) { |
|
151 | - $keys = array_keys( get_object_vars( $this ) ); |
|
152 | - foreach ( $keys as $key ) { |
|
153 | - if ( isset( $args[ $key ] ) ) { |
|
154 | - $this->$key = $args[ $key ]; |
|
150 | + public function __construct($manager, $id, $args = array()) { |
|
151 | + $keys = array_keys(get_object_vars($this)); |
|
152 | + foreach ($keys as $key) { |
|
153 | + if (isset($args[$key])) { |
|
154 | + $this->$key = $args[$key]; |
|
155 | 155 | } |
156 | 156 | } |
157 | 157 | |
158 | 158 | $this->manager = $manager; |
159 | 159 | $this->id = $id; |
160 | - if ( empty( $this->active_callback ) ) { |
|
161 | - $this->active_callback = array( $this, 'active_callback' ); |
|
160 | + if (empty($this->active_callback)) { |
|
161 | + $this->active_callback = array($this, 'active_callback'); |
|
162 | 162 | } |
163 | 163 | self::$instance_count += 1; |
164 | 164 | $this->instance_number = self::$instance_count; |
@@ -176,7 +176,7 @@ discard block |
||
176 | 176 | */ |
177 | 177 | final public function active() { |
178 | 178 | $panel = $this; |
179 | - $active = call_user_func( $this->active_callback, $this ); |
|
179 | + $active = call_user_func($this->active_callback, $this); |
|
180 | 180 | |
181 | 181 | /** |
182 | 182 | * Filter response of WP_Customize_Panel::active(). |
@@ -186,7 +186,7 @@ discard block |
||
186 | 186 | * @param bool $active Whether the Customizer panel is active. |
187 | 187 | * @param WP_Customize_Panel $panel {@see WP_Customize_Panel} instance. |
188 | 188 | */ |
189 | - $active = apply_filters( 'customize_panel_active', $active, $panel ); |
|
189 | + $active = apply_filters('customize_panel_active', $active, $panel); |
|
190 | 190 | |
191 | 191 | return $active; |
192 | 192 | } |
@@ -214,8 +214,8 @@ discard block |
||
214 | 214 | * @return array The array to be exported to the client as JSON. |
215 | 215 | */ |
216 | 216 | public function json() { |
217 | - $array = wp_array_slice_assoc( (array) $this, array( 'id', 'description', 'priority', 'type' ) ); |
|
218 | - $array['title'] = html_entity_decode( $this->title, ENT_QUOTES, get_bloginfo( 'charset' ) ); |
|
217 | + $array = wp_array_slice_assoc((array) $this, array('id', 'description', 'priority', 'type')); |
|
218 | + $array['title'] = html_entity_decode($this->title, ENT_QUOTES, get_bloginfo('charset')); |
|
219 | 219 | $array['content'] = $this->get_content(); |
220 | 220 | $array['active'] = $this->active(); |
221 | 221 | $array['instanceNumber'] = $this->instance_number; |
@@ -231,11 +231,11 @@ discard block |
||
231 | 231 | * @return bool False if theme doesn't support the panel or the user doesn't have the capability. |
232 | 232 | */ |
233 | 233 | final public function check_capabilities() { |
234 | - if ( $this->capability && ! call_user_func_array( 'current_user_can', (array) $this->capability ) ) { |
|
234 | + if ($this->capability && ! call_user_func_array('current_user_can', (array) $this->capability)) { |
|
235 | 235 | return false; |
236 | 236 | } |
237 | 237 | |
238 | - if ( $this->theme_supports && ! call_user_func_array( 'current_theme_supports', (array) $this->theme_supports ) ) { |
|
238 | + if ($this->theme_supports && ! call_user_func_array('current_theme_supports', (array) $this->theme_supports)) { |
|
239 | 239 | return false; |
240 | 240 | } |
241 | 241 | |
@@ -252,7 +252,7 @@ discard block |
||
252 | 252 | final public function get_content() { |
253 | 253 | ob_start(); |
254 | 254 | $this->maybe_render(); |
255 | - return trim( ob_get_clean() ); |
|
255 | + return trim(ob_get_clean()); |
|
256 | 256 | } |
257 | 257 | |
258 | 258 | /** |
@@ -261,7 +261,7 @@ discard block |
||
261 | 261 | * @since 4.0.0 |
262 | 262 | */ |
263 | 263 | final public function maybe_render() { |
264 | - if ( ! $this->check_capabilities() ) { |
|
264 | + if ( ! $this->check_capabilities()) { |
|
265 | 265 | return; |
266 | 266 | } |
267 | 267 | |
@@ -272,7 +272,7 @@ discard block |
||
272 | 272 | * |
273 | 273 | * @param WP_Customize_Panel $this WP_Customize_Panel instance. |
274 | 274 | */ |
275 | - do_action( 'customize_render_panel', $this ); |
|
275 | + do_action('customize_render_panel', $this); |
|
276 | 276 | |
277 | 277 | /** |
278 | 278 | * Fires before rendering a specific Customizer panel. |
@@ -282,7 +282,7 @@ discard block |
||
282 | 282 | * |
283 | 283 | * @since 4.0.0 |
284 | 284 | */ |
285 | - do_action( "customize_render_panel_{$this->id}" ); |
|
285 | + do_action("customize_render_panel_{$this->id}"); |
|
286 | 286 | |
287 | 287 | $this->render(); |
288 | 288 | } |
@@ -319,10 +319,10 @@ discard block |
||
319 | 319 | */ |
320 | 320 | public function print_template() { |
321 | 321 | ?> |
322 | - <script type="text/html" id="tmpl-customize-panel-<?php echo esc_attr( $this->type ); ?>-content"> |
|
322 | + <script type="text/html" id="tmpl-customize-panel-<?php echo esc_attr($this->type); ?>-content"> |
|
323 | 323 | <?php $this->content_template(); ?> |
324 | 324 | </script> |
325 | - <script type="text/html" id="tmpl-customize-panel-<?php echo esc_attr( $this->type ); ?>"> |
|
325 | + <script type="text/html" id="tmpl-customize-panel-<?php echo esc_attr($this->type); ?>"> |
|
326 | 326 | <?php $this->render_template(); ?> |
327 | 327 | </script> |
328 | 328 | <?php |
@@ -344,7 +344,7 @@ discard block |
||
344 | 344 | <li id="accordion-panel-{{ data.id }}" class="accordion-section control-section control-panel control-panel-{{ data.type }}"> |
345 | 345 | <h3 class="accordion-section-title" tabindex="0"> |
346 | 346 | {{ data.title }} |
347 | - <span class="screen-reader-text"><?php _e( 'Press return or enter to open this panel' ); ?></span> |
|
347 | + <span class="screen-reader-text"><?php _e('Press return or enter to open this panel'); ?></span> |
|
348 | 348 | </h3> |
349 | 349 | <ul class="accordion-sub-container control-panel-content"></ul> |
350 | 350 | </li> |
@@ -365,14 +365,14 @@ discard block |
||
365 | 365 | protected function content_template() { |
366 | 366 | ?> |
367 | 367 | <li class="panel-meta customize-info accordion-section <# if ( ! data.description ) { #> cannot-expand<# } #>"> |
368 | - <button class="customize-panel-back" tabindex="-1"><span class="screen-reader-text"><?php _e( 'Back' ); ?></span></button> |
|
368 | + <button class="customize-panel-back" tabindex="-1"><span class="screen-reader-text"><?php _e('Back'); ?></span></button> |
|
369 | 369 | <div class="accordion-section-title"> |
370 | 370 | <span class="preview-notice"><?php |
371 | 371 | /* translators: %s: the site/panel title in the Customizer */ |
372 | - echo sprintf( __( 'You are customizing %s' ), '<strong class="panel-title">{{ data.title }}</strong>' ); |
|
372 | + echo sprintf(__('You are customizing %s'), '<strong class="panel-title">{{ data.title }}</strong>'); |
|
373 | 373 | ?></span> |
374 | 374 | <# if ( data.description ) { #> |
375 | - <button class="customize-help-toggle dashicons dashicons-editor-help" tabindex="0" aria-expanded="false"><span class="screen-reader-text"><?php _e( 'Help' ); ?></span></button> |
|
375 | + <button class="customize-help-toggle dashicons dashicons-editor-help" tabindex="0" aria-expanded="false"><span class="screen-reader-text"><?php _e('Help'); ?></span></button> |
|
376 | 376 | <# } #> |
377 | 377 | </div> |
378 | 378 | <# if ( data.description ) { #> |
@@ -386,4 +386,4 @@ discard block |
||
386 | 386 | } |
387 | 387 | |
388 | 388 | /** WP_Customize_Nav_Menus_Panel class */ |
389 | -require_once( ABSPATH . WPINC . '/customize/class-wp-customize-nav-menus-panel.php' ); |
|
389 | +require_once(ABSPATH.WPINC.'/customize/class-wp-customize-nav-menus-panel.php'); |
@@ -578,8 +578,9 @@ discard block |
||
578 | 578 | if ( is_taxonomy_hierarchical( $query['taxonomy'] ) && $query['include_children'] ) { |
579 | 579 | $this->transform_query( $query, 'term_id' ); |
580 | 580 | |
581 | - if ( is_wp_error( $query ) ) |
|
582 | - return; |
|
581 | + if ( is_wp_error( $query ) ) { |
|
582 | + return; |
|
583 | + } |
|
583 | 584 | |
584 | 585 | $children = array(); |
585 | 586 | foreach ( $query['terms'] as $term ) { |
@@ -606,11 +607,13 @@ discard block |
||
606 | 607 | public function transform_query( &$query, $resulting_field ) { |
607 | 608 | global $wpdb; |
608 | 609 | |
609 | - if ( empty( $query['terms'] ) ) |
|
610 | - return; |
|
610 | + if ( empty( $query['terms'] ) ) { |
|
611 | + return; |
|
612 | + } |
|
611 | 613 | |
612 | - if ( $query['field'] == $resulting_field ) |
|
613 | - return; |
|
614 | + if ( $query['field'] == $resulting_field ) { |
|
615 | + return; |
|
616 | + } |
|
614 | 617 | |
615 | 618 | $resulting_field = sanitize_key( $resulting_field ); |
616 | 619 |
@@ -50,7 +50,7 @@ discard block |
||
50 | 50 | * @access private |
51 | 51 | * @var string |
52 | 52 | */ |
53 | - private static $no_results = array( 'join' => array( '' ), 'where' => array( '0 = 1' ) ); |
|
53 | + private static $no_results = array('join' => array(''), 'where' => array('0 = 1')); |
|
54 | 54 | |
55 | 55 | /** |
56 | 56 | * A flat list of table aliases used in the JOIN clauses. |
@@ -118,14 +118,14 @@ discard block |
||
118 | 118 | * } |
119 | 119 | * } |
120 | 120 | */ |
121 | - public function __construct( $tax_query ) { |
|
122 | - if ( isset( $tax_query['relation'] ) ) { |
|
123 | - $this->relation = $this->sanitize_relation( $tax_query['relation'] ); |
|
121 | + public function __construct($tax_query) { |
|
122 | + if (isset($tax_query['relation'])) { |
|
123 | + $this->relation = $this->sanitize_relation($tax_query['relation']); |
|
124 | 124 | } else { |
125 | 125 | $this->relation = 'AND'; |
126 | 126 | } |
127 | 127 | |
128 | - $this->queries = $this->sanitize_query( $tax_query ); |
|
128 | + $this->queries = $this->sanitize_query($tax_query); |
|
129 | 129 | } |
130 | 130 | |
131 | 131 | /** |
@@ -140,7 +140,7 @@ discard block |
||
140 | 140 | * @param array $queries Array of queries clauses. |
141 | 141 | * @return array Sanitized array of query clauses. |
142 | 142 | */ |
143 | - public function sanitize_query( $queries ) { |
|
143 | + public function sanitize_query($queries) { |
|
144 | 144 | $cleaned_query = array(); |
145 | 145 | |
146 | 146 | $defaults = array( |
@@ -151,14 +151,14 @@ discard block |
||
151 | 151 | 'include_children' => true, |
152 | 152 | ); |
153 | 153 | |
154 | - foreach ( $queries as $key => $query ) { |
|
155 | - if ( 'relation' === $key ) { |
|
156 | - $cleaned_query['relation'] = $this->sanitize_relation( $query ); |
|
154 | + foreach ($queries as $key => $query) { |
|
155 | + if ('relation' === $key) { |
|
156 | + $cleaned_query['relation'] = $this->sanitize_relation($query); |
|
157 | 157 | |
158 | 158 | // First-order clause. |
159 | - } elseif ( self::is_first_order_clause( $query ) ) { |
|
159 | + } elseif (self::is_first_order_clause($query)) { |
|
160 | 160 | |
161 | - $cleaned_clause = array_merge( $defaults, $query ); |
|
161 | + $cleaned_clause = array_merge($defaults, $query); |
|
162 | 162 | $cleaned_clause['terms'] = (array) $cleaned_clause['terms']; |
163 | 163 | $cleaned_query[] = $cleaned_clause; |
164 | 164 | |
@@ -166,32 +166,32 @@ discard block |
||
166 | 166 | * Keep a copy of the clause in the flate |
167 | 167 | * $queried_terms array, for use in WP_Query. |
168 | 168 | */ |
169 | - if ( ! empty( $cleaned_clause['taxonomy'] ) && 'NOT IN' !== $cleaned_clause['operator'] ) { |
|
169 | + if ( ! empty($cleaned_clause['taxonomy']) && 'NOT IN' !== $cleaned_clause['operator']) { |
|
170 | 170 | $taxonomy = $cleaned_clause['taxonomy']; |
171 | - if ( ! isset( $this->queried_terms[ $taxonomy ] ) ) { |
|
172 | - $this->queried_terms[ $taxonomy ] = array(); |
|
171 | + if ( ! isset($this->queried_terms[$taxonomy])) { |
|
172 | + $this->queried_terms[$taxonomy] = array(); |
|
173 | 173 | } |
174 | 174 | |
175 | 175 | /* |
176 | 176 | * Backward compatibility: Only store the first |
177 | 177 | * 'terms' and 'field' found for a given taxonomy. |
178 | 178 | */ |
179 | - if ( ! empty( $cleaned_clause['terms'] ) && ! isset( $this->queried_terms[ $taxonomy ]['terms'] ) ) { |
|
180 | - $this->queried_terms[ $taxonomy ]['terms'] = $cleaned_clause['terms']; |
|
179 | + if ( ! empty($cleaned_clause['terms']) && ! isset($this->queried_terms[$taxonomy]['terms'])) { |
|
180 | + $this->queried_terms[$taxonomy]['terms'] = $cleaned_clause['terms']; |
|
181 | 181 | } |
182 | 182 | |
183 | - if ( ! empty( $cleaned_clause['field'] ) && ! isset( $this->queried_terms[ $taxonomy ]['field'] ) ) { |
|
184 | - $this->queried_terms[ $taxonomy ]['field'] = $cleaned_clause['field']; |
|
183 | + if ( ! empty($cleaned_clause['field']) && ! isset($this->queried_terms[$taxonomy]['field'])) { |
|
184 | + $this->queried_terms[$taxonomy]['field'] = $cleaned_clause['field']; |
|
185 | 185 | } |
186 | 186 | } |
187 | 187 | |
188 | 188 | // Otherwise, it's a nested query, so we recurse. |
189 | - } elseif ( is_array( $query ) ) { |
|
190 | - $cleaned_subquery = $this->sanitize_query( $query ); |
|
189 | + } elseif (is_array($query)) { |
|
190 | + $cleaned_subquery = $this->sanitize_query($query); |
|
191 | 191 | |
192 | - if ( ! empty( $cleaned_subquery ) ) { |
|
192 | + if ( ! empty($cleaned_subquery)) { |
|
193 | 193 | // All queries with children must have a relation. |
194 | - if ( ! isset( $cleaned_subquery['relation'] ) ) { |
|
194 | + if ( ! isset($cleaned_subquery['relation'])) { |
|
195 | 195 | $cleaned_subquery['relation'] = 'AND'; |
196 | 196 | } |
197 | 197 | |
@@ -212,8 +212,8 @@ discard block |
||
212 | 212 | * @param string $relation Raw relation key from the query argument. |
213 | 213 | * @return string Sanitized relation ('AND' or 'OR'). |
214 | 214 | */ |
215 | - public function sanitize_relation( $relation ) { |
|
216 | - if ( 'OR' === strtoupper( $relation ) ) { |
|
215 | + public function sanitize_relation($relation) { |
|
216 | + if ('OR' === strtoupper($relation)) { |
|
217 | 217 | return 'OR'; |
218 | 218 | } else { |
219 | 219 | return 'AND'; |
@@ -237,8 +237,8 @@ discard block |
||
237 | 237 | * @param array $query Tax query arguments. |
238 | 238 | * @return bool Whether the query clause is a first-order clause. |
239 | 239 | */ |
240 | - protected static function is_first_order_clause( $query ) { |
|
241 | - return is_array( $query ) && ( empty( $query ) || array_key_exists( 'terms', $query ) || array_key_exists( 'taxonomy', $query ) || array_key_exists( 'include_children', $query ) || array_key_exists( 'field', $query ) || array_key_exists( 'operator', $query ) ); |
|
240 | + protected static function is_first_order_clause($query) { |
|
241 | + return is_array($query) && (empty($query) || array_key_exists('terms', $query) || array_key_exists('taxonomy', $query) || array_key_exists('include_children', $query) || array_key_exists('field', $query) || array_key_exists('operator', $query)); |
|
242 | 242 | } |
243 | 243 | |
244 | 244 | /** |
@@ -258,7 +258,7 @@ discard block |
||
258 | 258 | * @type string $where SQL fragment to append to the main WHERE clause. |
259 | 259 | * } |
260 | 260 | */ |
261 | - public function get_sql( $primary_table, $primary_id_column ) { |
|
261 | + public function get_sql($primary_table, $primary_id_column) { |
|
262 | 262 | $this->primary_table = $primary_table; |
263 | 263 | $this->primary_id_column = $primary_id_column; |
264 | 264 | |
@@ -287,10 +287,10 @@ discard block |
||
287 | 287 | * To keep $this->queries unaltered, pass a copy. |
288 | 288 | */ |
289 | 289 | $queries = $this->queries; |
290 | - $sql = $this->get_sql_for_query( $queries ); |
|
290 | + $sql = $this->get_sql_for_query($queries); |
|
291 | 291 | |
292 | - if ( ! empty( $sql['where'] ) ) { |
|
293 | - $sql['where'] = ' AND ' . $sql['where']; |
|
292 | + if ( ! empty($sql['where'])) { |
|
293 | + $sql['where'] = ' AND '.$sql['where']; |
|
294 | 294 | } |
295 | 295 | |
296 | 296 | return $sql; |
@@ -315,7 +315,7 @@ discard block |
||
315 | 315 | * @type string $where SQL fragment to append to the main WHERE clause. |
316 | 316 | * } |
317 | 317 | */ |
318 | - protected function get_sql_for_query( &$query, $depth = 0 ) { |
|
318 | + protected function get_sql_for_query(&$query, $depth = 0) { |
|
319 | 319 | $sql_chunks = array( |
320 | 320 | 'join' => array(), |
321 | 321 | 'where' => array(), |
@@ -327,32 +327,32 @@ discard block |
||
327 | 327 | ); |
328 | 328 | |
329 | 329 | $indent = ''; |
330 | - for ( $i = 0; $i < $depth; $i++ ) { |
|
330 | + for ($i = 0; $i < $depth; $i++) { |
|
331 | 331 | $indent .= " "; |
332 | 332 | } |
333 | 333 | |
334 | - foreach ( $query as $key => &$clause ) { |
|
335 | - if ( 'relation' === $key ) { |
|
334 | + foreach ($query as $key => &$clause) { |
|
335 | + if ('relation' === $key) { |
|
336 | 336 | $relation = $query['relation']; |
337 | - } elseif ( is_array( $clause ) ) { |
|
337 | + } elseif (is_array($clause)) { |
|
338 | 338 | |
339 | 339 | // This is a first-order clause. |
340 | - if ( $this->is_first_order_clause( $clause ) ) { |
|
341 | - $clause_sql = $this->get_sql_for_clause( $clause, $query ); |
|
340 | + if ($this->is_first_order_clause($clause)) { |
|
341 | + $clause_sql = $this->get_sql_for_clause($clause, $query); |
|
342 | 342 | |
343 | - $where_count = count( $clause_sql['where'] ); |
|
344 | - if ( ! $where_count ) { |
|
343 | + $where_count = count($clause_sql['where']); |
|
344 | + if ( ! $where_count) { |
|
345 | 345 | $sql_chunks['where'][] = ''; |
346 | - } elseif ( 1 === $where_count ) { |
|
346 | + } elseif (1 === $where_count) { |
|
347 | 347 | $sql_chunks['where'][] = $clause_sql['where'][0]; |
348 | 348 | } else { |
349 | - $sql_chunks['where'][] = '( ' . implode( ' AND ', $clause_sql['where'] ) . ' )'; |
|
349 | + $sql_chunks['where'][] = '( '.implode(' AND ', $clause_sql['where']).' )'; |
|
350 | 350 | } |
351 | 351 | |
352 | - $sql_chunks['join'] = array_merge( $sql_chunks['join'], $clause_sql['join'] ); |
|
352 | + $sql_chunks['join'] = array_merge($sql_chunks['join'], $clause_sql['join']); |
|
353 | 353 | // This is a subquery, so we recurse. |
354 | 354 | } else { |
355 | - $clause_sql = $this->get_sql_for_query( $clause, $depth + 1 ); |
|
355 | + $clause_sql = $this->get_sql_for_query($clause, $depth + 1); |
|
356 | 356 | |
357 | 357 | $sql_chunks['where'][] = $clause_sql['where']; |
358 | 358 | $sql_chunks['join'][] = $clause_sql['join']; |
@@ -361,21 +361,21 @@ discard block |
||
361 | 361 | } |
362 | 362 | |
363 | 363 | // Filter to remove empties. |
364 | - $sql_chunks['join'] = array_filter( $sql_chunks['join'] ); |
|
365 | - $sql_chunks['where'] = array_filter( $sql_chunks['where'] ); |
|
364 | + $sql_chunks['join'] = array_filter($sql_chunks['join']); |
|
365 | + $sql_chunks['where'] = array_filter($sql_chunks['where']); |
|
366 | 366 | |
367 | - if ( empty( $relation ) ) { |
|
367 | + if (empty($relation)) { |
|
368 | 368 | $relation = 'AND'; |
369 | 369 | } |
370 | 370 | |
371 | 371 | // Filter duplicate JOIN clauses and combine into a single string. |
372 | - if ( ! empty( $sql_chunks['join'] ) ) { |
|
373 | - $sql['join'] = implode( ' ', array_unique( $sql_chunks['join'] ) ); |
|
372 | + if ( ! empty($sql_chunks['join'])) { |
|
373 | + $sql['join'] = implode(' ', array_unique($sql_chunks['join'])); |
|
374 | 374 | } |
375 | 375 | |
376 | 376 | // Generate a single WHERE clause with proper brackets and indentation. |
377 | - if ( ! empty( $sql_chunks['where'] ) ) { |
|
378 | - $sql['where'] = '( ' . "\n " . $indent . implode( ' ' . "\n " . $indent . $relation . ' ' . "\n " . $indent, $sql_chunks['where'] ) . "\n" . $indent . ')'; |
|
377 | + if ( ! empty($sql_chunks['where'])) { |
|
378 | + $sql['where'] = '( '."\n ".$indent.implode(' '."\n ".$indent.$relation.' '."\n ".$indent, $sql_chunks['where'])."\n".$indent.')'; |
|
379 | 379 | } |
380 | 380 | |
381 | 381 | return $sql; |
@@ -398,7 +398,7 @@ discard block |
||
398 | 398 | * @type string $where SQL fragment to append to the main WHERE clause. |
399 | 399 | * } |
400 | 400 | */ |
401 | - public function get_sql_for_clause( &$clause, $parent_query ) { |
|
401 | + public function get_sql_for_clause(&$clause, $parent_query) { |
|
402 | 402 | global $wpdb; |
403 | 403 | |
404 | 404 | $sql = array( |
@@ -408,31 +408,31 @@ discard block |
||
408 | 408 | |
409 | 409 | $join = $where = ''; |
410 | 410 | |
411 | - $this->clean_query( $clause ); |
|
411 | + $this->clean_query($clause); |
|
412 | 412 | |
413 | - if ( is_wp_error( $clause ) ) { |
|
413 | + if (is_wp_error($clause)) { |
|
414 | 414 | return self::$no_results; |
415 | 415 | } |
416 | 416 | |
417 | 417 | $terms = $clause['terms']; |
418 | - $operator = strtoupper( $clause['operator'] ); |
|
418 | + $operator = strtoupper($clause['operator']); |
|
419 | 419 | |
420 | - if ( 'IN' == $operator ) { |
|
420 | + if ('IN' == $operator) { |
|
421 | 421 | |
422 | - if ( empty( $terms ) ) { |
|
422 | + if (empty($terms)) { |
|
423 | 423 | return self::$no_results; |
424 | 424 | } |
425 | 425 | |
426 | - $terms = implode( ',', $terms ); |
|
426 | + $terms = implode(',', $terms); |
|
427 | 427 | |
428 | 428 | /* |
429 | 429 | * Before creating another table join, see if this clause has a |
430 | 430 | * sibling with an existing join that can be shared. |
431 | 431 | */ |
432 | - $alias = $this->find_compatible_table_alias( $clause, $parent_query ); |
|
433 | - if ( false === $alias ) { |
|
434 | - $i = count( $this->table_aliases ); |
|
435 | - $alias = $i ? 'tt' . $i : $wpdb->term_relationships; |
|
432 | + $alias = $this->find_compatible_table_alias($clause, $parent_query); |
|
433 | + if (false === $alias) { |
|
434 | + $i = count($this->table_aliases); |
|
435 | + $alias = $i ? 'tt'.$i : $wpdb->term_relationships; |
|
436 | 436 | |
437 | 437 | // Store the alias as part of a flat array to build future iterators. |
438 | 438 | $this->table_aliases[] = $alias; |
@@ -448,13 +448,13 @@ discard block |
||
448 | 448 | |
449 | 449 | $where = "$alias.term_taxonomy_id $operator ($terms)"; |
450 | 450 | |
451 | - } elseif ( 'NOT IN' == $operator ) { |
|
451 | + } elseif ('NOT IN' == $operator) { |
|
452 | 452 | |
453 | - if ( empty( $terms ) ) { |
|
453 | + if (empty($terms)) { |
|
454 | 454 | return $sql; |
455 | 455 | } |
456 | 456 | |
457 | - $terms = implode( ',', $terms ); |
|
457 | + $terms = implode(',', $terms); |
|
458 | 458 | |
459 | 459 | $where = "$this->primary_table.$this->primary_id_column NOT IN ( |
460 | 460 | SELECT object_id |
@@ -462,15 +462,15 @@ discard block |
||
462 | 462 | WHERE term_taxonomy_id IN ($terms) |
463 | 463 | )"; |
464 | 464 | |
465 | - } elseif ( 'AND' == $operator ) { |
|
465 | + } elseif ('AND' == $operator) { |
|
466 | 466 | |
467 | - if ( empty( $terms ) ) { |
|
467 | + if (empty($terms)) { |
|
468 | 468 | return $sql; |
469 | 469 | } |
470 | 470 | |
471 | - $num_terms = count( $terms ); |
|
471 | + $num_terms = count($terms); |
|
472 | 472 | |
473 | - $terms = implode( ',', $terms ); |
|
473 | + $terms = implode(',', $terms); |
|
474 | 474 | |
475 | 475 | $where = "( |
476 | 476 | SELECT COUNT(1) |
@@ -479,16 +479,16 @@ discard block |
||
479 | 479 | AND object_id = $this->primary_table.$this->primary_id_column |
480 | 480 | ) = $num_terms"; |
481 | 481 | |
482 | - } elseif ( 'NOT EXISTS' === $operator || 'EXISTS' === $operator ) { |
|
482 | + } elseif ('NOT EXISTS' === $operator || 'EXISTS' === $operator) { |
|
483 | 483 | |
484 | - $where = $wpdb->prepare( "$operator ( |
|
484 | + $where = $wpdb->prepare("$operator ( |
|
485 | 485 | SELECT 1 |
486 | 486 | FROM $wpdb->term_relationships |
487 | 487 | INNER JOIN $wpdb->term_taxonomy |
488 | 488 | ON $wpdb->term_taxonomy.term_taxonomy_id = $wpdb->term_relationships.term_taxonomy_id |
489 | 489 | WHERE $wpdb->term_taxonomy.taxonomy = %s |
490 | 490 | AND $wpdb->term_relationships.object_id = $this->primary_table.$this->primary_id_column |
491 | - )", $clause['taxonomy'] ); |
|
491 | + )", $clause['taxonomy']); |
|
492 | 492 | |
493 | 493 | } |
494 | 494 | |
@@ -517,32 +517,32 @@ discard block |
||
517 | 517 | * @param array $parent_query Parent query of $clause. |
518 | 518 | * @return string|false Table alias if found, otherwise false. |
519 | 519 | */ |
520 | - protected function find_compatible_table_alias( $clause, $parent_query ) { |
|
520 | + protected function find_compatible_table_alias($clause, $parent_query) { |
|
521 | 521 | $alias = false; |
522 | 522 | |
523 | 523 | // Sanity check. Only IN queries use the JOIN syntax . |
524 | - if ( ! isset( $clause['operator'] ) || 'IN' !== $clause['operator'] ) { |
|
524 | + if ( ! isset($clause['operator']) || 'IN' !== $clause['operator']) { |
|
525 | 525 | return $alias; |
526 | 526 | } |
527 | 527 | |
528 | 528 | // Since we're only checking IN queries, we're only concerned with OR relations. |
529 | - if ( ! isset( $parent_query['relation'] ) || 'OR' !== $parent_query['relation'] ) { |
|
529 | + if ( ! isset($parent_query['relation']) || 'OR' !== $parent_query['relation']) { |
|
530 | 530 | return $alias; |
531 | 531 | } |
532 | 532 | |
533 | - $compatible_operators = array( 'IN' ); |
|
533 | + $compatible_operators = array('IN'); |
|
534 | 534 | |
535 | - foreach ( $parent_query as $sibling ) { |
|
536 | - if ( ! is_array( $sibling ) || ! $this->is_first_order_clause( $sibling ) ) { |
|
535 | + foreach ($parent_query as $sibling) { |
|
536 | + if ( ! is_array($sibling) || ! $this->is_first_order_clause($sibling)) { |
|
537 | 537 | continue; |
538 | 538 | } |
539 | 539 | |
540 | - if ( empty( $sibling['alias'] ) || empty( $sibling['operator'] ) ) { |
|
540 | + if (empty($sibling['alias']) || empty($sibling['operator'])) { |
|
541 | 541 | continue; |
542 | 542 | } |
543 | 543 | |
544 | 544 | // The sibling must both have compatible operator to share its alias. |
545 | - if ( in_array( strtoupper( $sibling['operator'] ), $compatible_operators ) ) { |
|
545 | + if (in_array(strtoupper($sibling['operator']), $compatible_operators)) { |
|
546 | 546 | $alias = $sibling['alias']; |
547 | 547 | break; |
548 | 548 | } |
@@ -559,37 +559,37 @@ discard block |
||
559 | 559 | * |
560 | 560 | * @param array $query The single query. Passed by reference. |
561 | 561 | */ |
562 | - private function clean_query( &$query ) { |
|
563 | - if ( empty( $query['taxonomy'] ) ) { |
|
564 | - if ( 'term_taxonomy_id' !== $query['field'] ) { |
|
565 | - $query = new WP_Error( 'invalid_taxonomy', __( 'Invalid taxonomy.' ) ); |
|
562 | + private function clean_query(&$query) { |
|
563 | + if (empty($query['taxonomy'])) { |
|
564 | + if ('term_taxonomy_id' !== $query['field']) { |
|
565 | + $query = new WP_Error('invalid_taxonomy', __('Invalid taxonomy.')); |
|
566 | 566 | return; |
567 | 567 | } |
568 | 568 | |
569 | 569 | // so long as there are shared terms, include_children requires that a taxonomy is set |
570 | 570 | $query['include_children'] = false; |
571 | - } elseif ( ! taxonomy_exists( $query['taxonomy'] ) ) { |
|
572 | - $query = new WP_Error( 'invalid_taxonomy', __( 'Invalid taxonomy.' ) ); |
|
571 | + } elseif ( ! taxonomy_exists($query['taxonomy'])) { |
|
572 | + $query = new WP_Error('invalid_taxonomy', __('Invalid taxonomy.')); |
|
573 | 573 | return; |
574 | 574 | } |
575 | 575 | |
576 | - $query['terms'] = array_unique( (array) $query['terms'] ); |
|
576 | + $query['terms'] = array_unique((array) $query['terms']); |
|
577 | 577 | |
578 | - if ( is_taxonomy_hierarchical( $query['taxonomy'] ) && $query['include_children'] ) { |
|
579 | - $this->transform_query( $query, 'term_id' ); |
|
578 | + if (is_taxonomy_hierarchical($query['taxonomy']) && $query['include_children']) { |
|
579 | + $this->transform_query($query, 'term_id'); |
|
580 | 580 | |
581 | - if ( is_wp_error( $query ) ) |
|
581 | + if (is_wp_error($query)) |
|
582 | 582 | return; |
583 | 583 | |
584 | 584 | $children = array(); |
585 | - foreach ( $query['terms'] as $term ) { |
|
586 | - $children = array_merge( $children, get_term_children( $term, $query['taxonomy'] ) ); |
|
585 | + foreach ($query['terms'] as $term) { |
|
586 | + $children = array_merge($children, get_term_children($term, $query['taxonomy'])); |
|
587 | 587 | $children[] = $term; |
588 | 588 | } |
589 | 589 | $query['terms'] = $children; |
590 | 590 | } |
591 | 591 | |
592 | - $this->transform_query( $query, 'term_taxonomy_id' ); |
|
592 | + $this->transform_query($query, 'term_taxonomy_id'); |
|
593 | 593 | } |
594 | 594 | |
595 | 595 | /** |
@@ -603,64 +603,64 @@ discard block |
||
603 | 603 | * @param string $resulting_field The resulting field. Accepts 'slug', 'name', 'term_taxonomy_id', |
604 | 604 | * or 'term_id'. Default 'term_id'. |
605 | 605 | */ |
606 | - public function transform_query( &$query, $resulting_field ) { |
|
606 | + public function transform_query(&$query, $resulting_field) { |
|
607 | 607 | global $wpdb; |
608 | 608 | |
609 | - if ( empty( $query['terms'] ) ) |
|
609 | + if (empty($query['terms'])) |
|
610 | 610 | return; |
611 | 611 | |
612 | - if ( $query['field'] == $resulting_field ) |
|
612 | + if ($query['field'] == $resulting_field) |
|
613 | 613 | return; |
614 | 614 | |
615 | - $resulting_field = sanitize_key( $resulting_field ); |
|
615 | + $resulting_field = sanitize_key($resulting_field); |
|
616 | 616 | |
617 | - switch ( $query['field'] ) { |
|
617 | + switch ($query['field']) { |
|
618 | 618 | case 'slug': |
619 | 619 | case 'name': |
620 | - foreach ( $query['terms'] as &$term ) { |
|
620 | + foreach ($query['terms'] as &$term) { |
|
621 | 621 | /* |
622 | 622 | * 0 is the $term_id parameter. We don't have a term ID yet, but it doesn't |
623 | 623 | * matter because `sanitize_term_field()` ignores the $term_id param when the |
624 | 624 | * context is 'db'. |
625 | 625 | */ |
626 | - $clean_term = sanitize_term_field( $query['field'], $term, 0, $query['taxonomy'], 'db' ); |
|
626 | + $clean_term = sanitize_term_field($query['field'], $term, 0, $query['taxonomy'], 'db'); |
|
627 | 627 | |
628 | 628 | // Match sanitization in wp_insert_term(). |
629 | - $clean_term = wp_unslash( $clean_term ); |
|
629 | + $clean_term = wp_unslash($clean_term); |
|
630 | 630 | |
631 | - $term = "'" . esc_sql( $clean_term ) . "'"; |
|
631 | + $term = "'".esc_sql($clean_term)."'"; |
|
632 | 632 | } |
633 | 633 | |
634 | - $terms = implode( ",", $query['terms'] ); |
|
634 | + $terms = implode(",", $query['terms']); |
|
635 | 635 | |
636 | - $terms = $wpdb->get_col( " |
|
636 | + $terms = $wpdb->get_col(" |
|
637 | 637 | SELECT $wpdb->term_taxonomy.$resulting_field |
638 | 638 | FROM $wpdb->term_taxonomy |
639 | 639 | INNER JOIN $wpdb->terms USING (term_id) |
640 | 640 | WHERE taxonomy = '{$query['taxonomy']}' |
641 | 641 | AND $wpdb->terms.{$query['field']} IN ($terms) |
642 | - " ); |
|
642 | + "); |
|
643 | 643 | break; |
644 | 644 | case 'term_taxonomy_id': |
645 | - $terms = implode( ',', array_map( 'intval', $query['terms'] ) ); |
|
646 | - $terms = $wpdb->get_col( " |
|
645 | + $terms = implode(',', array_map('intval', $query['terms'])); |
|
646 | + $terms = $wpdb->get_col(" |
|
647 | 647 | SELECT $resulting_field |
648 | 648 | FROM $wpdb->term_taxonomy |
649 | 649 | WHERE term_taxonomy_id IN ($terms) |
650 | - " ); |
|
650 | + "); |
|
651 | 651 | break; |
652 | 652 | default: |
653 | - $terms = implode( ',', array_map( 'intval', $query['terms'] ) ); |
|
654 | - $terms = $wpdb->get_col( " |
|
653 | + $terms = implode(',', array_map('intval', $query['terms'])); |
|
654 | + $terms = $wpdb->get_col(" |
|
655 | 655 | SELECT $resulting_field |
656 | 656 | FROM $wpdb->term_taxonomy |
657 | 657 | WHERE taxonomy = '{$query['taxonomy']}' |
658 | 658 | AND term_id IN ($terms) |
659 | - " ); |
|
659 | + "); |
|
660 | 660 | } |
661 | 661 | |
662 | - if ( 'AND' == $query['operator'] && count( $terms ) < count( $query['terms'] ) ) { |
|
663 | - $query = new WP_Error( 'inexistent_terms', __( 'Inexistent terms.' ) ); |
|
662 | + if ('AND' == $query['operator'] && count($terms) < count($query['terms'])) { |
|
663 | + $query = new WP_Error('inexistent_terms', __('Inexistent terms.')); |
|
664 | 664 | return; |
665 | 665 | } |
666 | 666 |
@@ -258,16 +258,16 @@ |
||
258 | 258 | } |
259 | 259 | |
260 | 260 | /** |
261 | - * paged_walk() - produce a page of nested elements |
|
262 | - * |
|
263 | - * Given an array of hierarchical elements, the maximum depth, a specific page number, |
|
264 | - * and number of elements per page, this function first determines all top level root elements |
|
265 | - * belonging to that page, then lists them and all of their children in hierarchical order. |
|
266 | - * |
|
261 | + * paged_walk() - produce a page of nested elements |
|
262 | + * |
|
263 | + * Given an array of hierarchical elements, the maximum depth, a specific page number, |
|
264 | + * and number of elements per page, this function first determines all top level root elements |
|
265 | + * belonging to that page, then lists them and all of their children in hierarchical order. |
|
266 | + * |
|
267 | 267 | * $max_depth = 0 means display all levels. |
268 | 268 | * $max_depth > 0 specifies the number of display levels. |
269 | 269 | * |
270 | - * @since 2.7.0 |
|
270 | + * @since 2.7.0 |
|
271 | 271 | * |
272 | 272 | * @param array $elements |
273 | 273 | * @param int $max_depth The maximum hierarchical depth. |
@@ -60,7 +60,7 @@ discard block |
||
60 | 60 | * @param int $depth Depth of the item. |
61 | 61 | * @param array $args An array of additional arguments. |
62 | 62 | */ |
63 | - public function start_lvl( &$output, $depth = 0, $args = array() ) {} |
|
63 | + public function start_lvl(&$output, $depth = 0, $args = array()) {} |
|
64 | 64 | |
65 | 65 | /** |
66 | 66 | * Ends the list of after the elements are added. |
@@ -75,7 +75,7 @@ discard block |
||
75 | 75 | * @param int $depth Depth of the item. |
76 | 76 | * @param array $args An array of additional arguments. |
77 | 77 | */ |
78 | - public function end_lvl( &$output, $depth = 0, $args = array() ) {} |
|
78 | + public function end_lvl(&$output, $depth = 0, $args = array()) {} |
|
79 | 79 | |
80 | 80 | /** |
81 | 81 | * Start the element output. |
@@ -92,7 +92,7 @@ discard block |
||
92 | 92 | * @param array $args An array of additional arguments. |
93 | 93 | * @param int $current_object_id ID of the current item. |
94 | 94 | */ |
95 | - public function start_el( &$output, $object, $depth = 0, $args = array(), $current_object_id = 0 ) {} |
|
95 | + public function start_el(&$output, $object, $depth = 0, $args = array(), $current_object_id = 0) {} |
|
96 | 96 | |
97 | 97 | /** |
98 | 98 | * Ends the element output, if needed. |
@@ -107,7 +107,7 @@ discard block |
||
107 | 107 | * @param int $depth Depth of the item. |
108 | 108 | * @param array $args An array of additional arguments. |
109 | 109 | */ |
110 | - public function end_el( &$output, $object, $depth = 0, $args = array() ) {} |
|
110 | + public function end_el(&$output, $object, $depth = 0, $args = array()) {} |
|
111 | 111 | |
112 | 112 | /** |
113 | 113 | * Traverse elements to create list from elements. |
@@ -128,8 +128,8 @@ discard block |
||
128 | 128 | * @param array $args An array of arguments. |
129 | 129 | * @param string $output Passed by reference. Used to append additional content. |
130 | 130 | */ |
131 | - public function display_element( $element, &$children_elements, $max_depth, $depth, $args, &$output ) { |
|
132 | - if ( ! $element ) { |
|
131 | + public function display_element($element, &$children_elements, $max_depth, $depth, $args, &$output) { |
|
132 | + if ( ! $element) { |
|
133 | 133 | return; |
134 | 134 | } |
135 | 135 | |
@@ -137,38 +137,38 @@ discard block |
||
137 | 137 | $id = $element->$id_field; |
138 | 138 | |
139 | 139 | //display this element |
140 | - $this->has_children = ! empty( $children_elements[ $id ] ); |
|
141 | - if ( isset( $args[0] ) && is_array( $args[0] ) ) { |
|
140 | + $this->has_children = ! empty($children_elements[$id]); |
|
141 | + if (isset($args[0]) && is_array($args[0])) { |
|
142 | 142 | $args[0]['has_children'] = $this->has_children; // Backwards compatibility. |
143 | 143 | } |
144 | 144 | |
145 | - $cb_args = array_merge( array(&$output, $element, $depth), $args); |
|
145 | + $cb_args = array_merge(array(&$output, $element, $depth), $args); |
|
146 | 146 | call_user_func_array(array($this, 'start_el'), $cb_args); |
147 | 147 | |
148 | 148 | // descend only when the depth is right and there are childrens for this element |
149 | - if ( ($max_depth == 0 || $max_depth > $depth+1 ) && isset( $children_elements[$id]) ) { |
|
149 | + if (($max_depth == 0 || $max_depth > $depth + 1) && isset($children_elements[$id])) { |
|
150 | 150 | |
151 | - foreach ( $children_elements[ $id ] as $child ){ |
|
151 | + foreach ($children_elements[$id] as $child) { |
|
152 | 152 | |
153 | - if ( !isset($newlevel) ) { |
|
153 | + if ( ! isset($newlevel)) { |
|
154 | 154 | $newlevel = true; |
155 | 155 | //start the child delimiter |
156 | - $cb_args = array_merge( array(&$output, $depth), $args); |
|
156 | + $cb_args = array_merge(array(&$output, $depth), $args); |
|
157 | 157 | call_user_func_array(array($this, 'start_lvl'), $cb_args); |
158 | 158 | } |
159 | - $this->display_element( $child, $children_elements, $max_depth, $depth + 1, $args, $output ); |
|
159 | + $this->display_element($child, $children_elements, $max_depth, $depth + 1, $args, $output); |
|
160 | 160 | } |
161 | - unset( $children_elements[ $id ] ); |
|
161 | + unset($children_elements[$id]); |
|
162 | 162 | } |
163 | 163 | |
164 | - if ( isset($newlevel) && $newlevel ){ |
|
164 | + if (isset($newlevel) && $newlevel) { |
|
165 | 165 | //end the child delimiter |
166 | - $cb_args = array_merge( array(&$output, $depth), $args); |
|
166 | + $cb_args = array_merge(array(&$output, $depth), $args); |
|
167 | 167 | call_user_func_array(array($this, 'end_lvl'), $cb_args); |
168 | 168 | } |
169 | 169 | |
170 | 170 | //end this element |
171 | - $cb_args = array_merge( array(&$output, $element, $depth), $args); |
|
171 | + $cb_args = array_merge(array(&$output, $element, $depth), $args); |
|
172 | 172 | call_user_func_array(array($this, 'end_el'), $cb_args); |
173 | 173 | } |
174 | 174 | |
@@ -187,12 +187,12 @@ discard block |
||
187 | 187 | * @param int $max_depth The maximum hierarchical depth. |
188 | 188 | * @return string The hierarchical item output. |
189 | 189 | */ |
190 | - public function walk( $elements, $max_depth ) { |
|
190 | + public function walk($elements, $max_depth) { |
|
191 | 191 | $args = array_slice(func_get_args(), 2); |
192 | 192 | $output = ''; |
193 | 193 | |
194 | 194 | //invalid parameter or nothing to walk |
195 | - if ( $max_depth < -1 || empty( $elements ) ) { |
|
195 | + if ($max_depth < -1 || empty($elements)) { |
|
196 | 196 | return $output; |
197 | 197 | } |
198 | 198 | |
@@ -201,8 +201,8 @@ discard block |
||
201 | 201 | // flat display |
202 | 202 | if ( -1 == $max_depth ) { |
203 | 203 | $empty_array = array(); |
204 | - foreach ( $elements as $e ) |
|
205 | - $this->display_element( $e, $empty_array, 1, 0, $args, $output ); |
|
204 | + foreach ($elements as $e) |
|
205 | + $this->display_element($e, $empty_array, 1, 0, $args, $output); |
|
206 | 206 | return $output; |
207 | 207 | } |
208 | 208 | |
@@ -214,44 +214,44 @@ discard block |
||
214 | 214 | */ |
215 | 215 | $top_level_elements = array(); |
216 | 216 | $children_elements = array(); |
217 | - foreach ( $elements as $e) { |
|
218 | - if ( empty( $e->$parent_field ) ) |
|
217 | + foreach ($elements as $e) { |
|
218 | + if (empty($e->$parent_field)) |
|
219 | 219 | $top_level_elements[] = $e; |
220 | 220 | else |
221 | - $children_elements[ $e->$parent_field ][] = $e; |
|
221 | + $children_elements[$e->$parent_field][] = $e; |
|
222 | 222 | } |
223 | 223 | |
224 | 224 | /* |
225 | 225 | * When none of the elements is top level. |
226 | 226 | * Assume the first one must be root of the sub elements. |
227 | 227 | */ |
228 | - if ( empty($top_level_elements) ) { |
|
228 | + if (empty($top_level_elements)) { |
|
229 | 229 | |
230 | - $first = array_slice( $elements, 0, 1 ); |
|
230 | + $first = array_slice($elements, 0, 1); |
|
231 | 231 | $root = $first[0]; |
232 | 232 | |
233 | 233 | $top_level_elements = array(); |
234 | 234 | $children_elements = array(); |
235 | - foreach ( $elements as $e) { |
|
236 | - if ( $root->$parent_field == $e->$parent_field ) |
|
235 | + foreach ($elements as $e) { |
|
236 | + if ($root->$parent_field == $e->$parent_field) |
|
237 | 237 | $top_level_elements[] = $e; |
238 | 238 | else |
239 | - $children_elements[ $e->$parent_field ][] = $e; |
|
239 | + $children_elements[$e->$parent_field][] = $e; |
|
240 | 240 | } |
241 | 241 | } |
242 | 242 | |
243 | - foreach ( $top_level_elements as $e ) |
|
244 | - $this->display_element( $e, $children_elements, $max_depth, 0, $args, $output ); |
|
243 | + foreach ($top_level_elements as $e) |
|
244 | + $this->display_element($e, $children_elements, $max_depth, 0, $args, $output); |
|
245 | 245 | |
246 | 246 | /* |
247 | 247 | * If we are displaying all levels, and remaining children_elements is not empty, |
248 | 248 | * then we got orphans, which should be displayed regardless. |
249 | 249 | */ |
250 | - if ( ( $max_depth == 0 ) && count( $children_elements ) > 0 ) { |
|
250 | + if (($max_depth == 0) && count($children_elements) > 0) { |
|
251 | 251 | $empty_array = array(); |
252 | - foreach ( $children_elements as $orphans ) |
|
253 | - foreach ( $orphans as $op ) |
|
254 | - $this->display_element( $op, $empty_array, 1, 0, $args, $output ); |
|
252 | + foreach ($children_elements as $orphans) |
|
253 | + foreach ($orphans as $op) |
|
254 | + $this->display_element($op, $empty_array, 1, 0, $args, $output); |
|
255 | 255 | } |
256 | 256 | |
257 | 257 | return $output; |
@@ -275,20 +275,20 @@ discard block |
||
275 | 275 | * @param int $per_page |
276 | 276 | * @return string XHTML of the specified page of elements |
277 | 277 | */ |
278 | - public function paged_walk( $elements, $max_depth, $page_num, $per_page ) { |
|
279 | - if ( empty( $elements ) || $max_depth < -1 ) { |
|
278 | + public function paged_walk($elements, $max_depth, $page_num, $per_page) { |
|
279 | + if (empty($elements) || $max_depth < -1) { |
|
280 | 280 | return ''; |
281 | 281 | } |
282 | 282 | |
283 | - $args = array_slice( func_get_args(), 4 ); |
|
283 | + $args = array_slice(func_get_args(), 4); |
|
284 | 284 | $output = ''; |
285 | 285 | |
286 | 286 | $parent_field = $this->db_fields['parent']; |
287 | 287 | |
288 | 288 | $count = -1; |
289 | 289 | if ( -1 == $max_depth ) |
290 | - $total_top = count( $elements ); |
|
291 | - if ( $page_num < 1 || $per_page < 0 ) { |
|
290 | + $total_top = count($elements); |
|
291 | + if ($page_num < 1 || $per_page < 0) { |
|
292 | 292 | // No paging |
293 | 293 | $paging = false; |
294 | 294 | $start = 0; |
@@ -297,7 +297,7 @@ discard block |
||
297 | 297 | $this->max_pages = 1; |
298 | 298 | } else { |
299 | 299 | $paging = true; |
300 | - $start = ( (int)$page_num - 1 ) * (int)$per_page; |
|
300 | + $start = ((int) $page_num - 1) * (int) $per_page; |
|
301 | 301 | $end = $start + $per_page; |
302 | 302 | if ( -1 == $max_depth ) |
303 | 303 | $this->max_pages = ceil($total_top / $per_page); |
@@ -305,21 +305,21 @@ discard block |
||
305 | 305 | |
306 | 306 | // flat display |
307 | 307 | if ( -1 == $max_depth ) { |
308 | - if ( !empty($args[0]['reverse_top_level']) ) { |
|
309 | - $elements = array_reverse( $elements ); |
|
308 | + if ( ! empty($args[0]['reverse_top_level'])) { |
|
309 | + $elements = array_reverse($elements); |
|
310 | 310 | $oldstart = $start; |
311 | 311 | $start = $total_top - $end; |
312 | 312 | $end = $total_top - $oldstart; |
313 | 313 | } |
314 | 314 | |
315 | 315 | $empty_array = array(); |
316 | - foreach ( $elements as $e ) { |
|
316 | + foreach ($elements as $e) { |
|
317 | 317 | $count++; |
318 | - if ( $count < $start ) |
|
318 | + if ($count < $start) |
|
319 | 319 | continue; |
320 | - if ( $count >= $end ) |
|
320 | + if ($count >= $end) |
|
321 | 321 | break; |
322 | - $this->display_element( $e, $empty_array, 1, 0, $args, $output ); |
|
322 | + $this->display_element($e, $empty_array, 1, 0, $args, $output); |
|
323 | 323 | } |
324 | 324 | return $output; |
325 | 325 | } |
@@ -331,51 +331,51 @@ discard block |
||
331 | 331 | */ |
332 | 332 | $top_level_elements = array(); |
333 | 333 | $children_elements = array(); |
334 | - foreach ( $elements as $e) { |
|
335 | - if ( 0 == $e->$parent_field ) |
|
334 | + foreach ($elements as $e) { |
|
335 | + if (0 == $e->$parent_field) |
|
336 | 336 | $top_level_elements[] = $e; |
337 | 337 | else |
338 | - $children_elements[ $e->$parent_field ][] = $e; |
|
338 | + $children_elements[$e->$parent_field][] = $e; |
|
339 | 339 | } |
340 | 340 | |
341 | - $total_top = count( $top_level_elements ); |
|
342 | - if ( $paging ) |
|
341 | + $total_top = count($top_level_elements); |
|
342 | + if ($paging) |
|
343 | 343 | $this->max_pages = ceil($total_top / $per_page); |
344 | 344 | else |
345 | 345 | $end = $total_top; |
346 | 346 | |
347 | - if ( !empty($args[0]['reverse_top_level']) ) { |
|
348 | - $top_level_elements = array_reverse( $top_level_elements ); |
|
347 | + if ( ! empty($args[0]['reverse_top_level'])) { |
|
348 | + $top_level_elements = array_reverse($top_level_elements); |
|
349 | 349 | $oldstart = $start; |
350 | 350 | $start = $total_top - $end; |
351 | 351 | $end = $total_top - $oldstart; |
352 | 352 | } |
353 | - if ( !empty($args[0]['reverse_children']) ) { |
|
354 | - foreach ( $children_elements as $parent => $children ) |
|
355 | - $children_elements[$parent] = array_reverse( $children ); |
|
353 | + if ( ! empty($args[0]['reverse_children'])) { |
|
354 | + foreach ($children_elements as $parent => $children) |
|
355 | + $children_elements[$parent] = array_reverse($children); |
|
356 | 356 | } |
357 | 357 | |
358 | - foreach ( $top_level_elements as $e ) { |
|
358 | + foreach ($top_level_elements as $e) { |
|
359 | 359 | $count++; |
360 | 360 | |
361 | 361 | // For the last page, need to unset earlier children in order to keep track of orphans. |
362 | - if ( $end >= $total_top && $count < $start ) |
|
363 | - $this->unset_children( $e, $children_elements ); |
|
362 | + if ($end >= $total_top && $count < $start) |
|
363 | + $this->unset_children($e, $children_elements); |
|
364 | 364 | |
365 | - if ( $count < $start ) |
|
365 | + if ($count < $start) |
|
366 | 366 | continue; |
367 | 367 | |
368 | - if ( $count >= $end ) |
|
368 | + if ($count >= $end) |
|
369 | 369 | break; |
370 | 370 | |
371 | - $this->display_element( $e, $children_elements, $max_depth, 0, $args, $output ); |
|
371 | + $this->display_element($e, $children_elements, $max_depth, 0, $args, $output); |
|
372 | 372 | } |
373 | 373 | |
374 | - if ( $end >= $total_top && count( $children_elements ) > 0 ) { |
|
374 | + if ($end >= $total_top && count($children_elements) > 0) { |
|
375 | 375 | $empty_array = array(); |
376 | - foreach ( $children_elements as $orphans ) |
|
377 | - foreach ( $orphans as $op ) |
|
378 | - $this->display_element( $op, $empty_array, 1, 0, $args, $output ); |
|
376 | + foreach ($children_elements as $orphans) |
|
377 | + foreach ($orphans as $op) |
|
378 | + $this->display_element($op, $empty_array, 1, 0, $args, $output); |
|
379 | 379 | } |
380 | 380 | |
381 | 381 | return $output; |
@@ -390,12 +390,12 @@ discard block |
||
390 | 390 | * @param array $elements Elements to list. |
391 | 391 | * @return int Number of root elements. |
392 | 392 | */ |
393 | - public function get_number_of_root_elements( $elements ){ |
|
393 | + public function get_number_of_root_elements($elements) { |
|
394 | 394 | $num = 0; |
395 | 395 | $parent_field = $this->db_fields['parent']; |
396 | 396 | |
397 | - foreach ( $elements as $e) { |
|
398 | - if ( 0 == $e->$parent_field ) |
|
397 | + foreach ($elements as $e) { |
|
398 | + if (0 == $e->$parent_field) |
|
399 | 399 | $num++; |
400 | 400 | } |
401 | 401 | return $num; |
@@ -407,19 +407,19 @@ discard block |
||
407 | 407 | * @param object $e |
408 | 408 | * @param array $children_elements |
409 | 409 | */ |
410 | - public function unset_children( $e, &$children_elements ){ |
|
411 | - if ( ! $e || ! $children_elements ) { |
|
410 | + public function unset_children($e, &$children_elements) { |
|
411 | + if ( ! $e || ! $children_elements) { |
|
412 | 412 | return; |
413 | 413 | } |
414 | 414 | |
415 | 415 | $id_field = $this->db_fields['id']; |
416 | 416 | $id = $e->$id_field; |
417 | 417 | |
418 | - if ( !empty($children_elements[$id]) && is_array($children_elements[$id]) ) |
|
419 | - foreach ( (array) $children_elements[$id] as $child ) |
|
420 | - $this->unset_children( $child, $children_elements ); |
|
418 | + if ( ! empty($children_elements[$id]) && is_array($children_elements[$id])) |
|
419 | + foreach ((array) $children_elements[$id] as $child) |
|
420 | + $this->unset_children($child, $children_elements); |
|
421 | 421 | |
422 | - unset( $children_elements[ $id ] ); |
|
422 | + unset($children_elements[$id]); |
|
423 | 423 | } |
424 | 424 | |
425 | 425 | } // Walker |
@@ -201,8 +201,9 @@ discard block |
||
201 | 201 | // flat display |
202 | 202 | if ( -1 == $max_depth ) { |
203 | 203 | $empty_array = array(); |
204 | - foreach ( $elements as $e ) |
|
205 | - $this->display_element( $e, $empty_array, 1, 0, $args, $output ); |
|
204 | + foreach ( $elements as $e ) { |
|
205 | + $this->display_element( $e, $empty_array, 1, 0, $args, $output ); |
|
206 | + } |
|
206 | 207 | return $output; |
207 | 208 | } |
208 | 209 | |
@@ -215,10 +216,11 @@ discard block |
||
215 | 216 | $top_level_elements = array(); |
216 | 217 | $children_elements = array(); |
217 | 218 | foreach ( $elements as $e) { |
218 | - if ( empty( $e->$parent_field ) ) |
|
219 | - $top_level_elements[] = $e; |
|
220 | - else |
|
221 | - $children_elements[ $e->$parent_field ][] = $e; |
|
219 | + if ( empty( $e->$parent_field ) ) { |
|
220 | + $top_level_elements[] = $e; |
|
221 | + } else { |
|
222 | + $children_elements[ $e->$parent_field ][] = $e; |
|
223 | + } |
|
222 | 224 | } |
223 | 225 | |
224 | 226 | /* |
@@ -233,15 +235,17 @@ discard block |
||
233 | 235 | $top_level_elements = array(); |
234 | 236 | $children_elements = array(); |
235 | 237 | foreach ( $elements as $e) { |
236 | - if ( $root->$parent_field == $e->$parent_field ) |
|
237 | - $top_level_elements[] = $e; |
|
238 | - else |
|
239 | - $children_elements[ $e->$parent_field ][] = $e; |
|
238 | + if ( $root->$parent_field == $e->$parent_field ) { |
|
239 | + $top_level_elements[] = $e; |
|
240 | + } else { |
|
241 | + $children_elements[ $e->$parent_field ][] = $e; |
|
242 | + } |
|
240 | 243 | } |
241 | 244 | } |
242 | 245 | |
243 | - foreach ( $top_level_elements as $e ) |
|
244 | - $this->display_element( $e, $children_elements, $max_depth, 0, $args, $output ); |
|
246 | + foreach ( $top_level_elements as $e ) { |
|
247 | + $this->display_element( $e, $children_elements, $max_depth, 0, $args, $output ); |
|
248 | + } |
|
245 | 249 | |
246 | 250 | /* |
247 | 251 | * If we are displaying all levels, and remaining children_elements is not empty, |
@@ -249,9 +253,10 @@ discard block |
||
249 | 253 | */ |
250 | 254 | if ( ( $max_depth == 0 ) && count( $children_elements ) > 0 ) { |
251 | 255 | $empty_array = array(); |
252 | - foreach ( $children_elements as $orphans ) |
|
253 | - foreach ( $orphans as $op ) |
|
256 | + foreach ( $children_elements as $orphans ) { |
|
257 | + foreach ( $orphans as $op ) |
|
254 | 258 | $this->display_element( $op, $empty_array, 1, 0, $args, $output ); |
259 | + } |
|
255 | 260 | } |
256 | 261 | |
257 | 262 | return $output; |
@@ -286,21 +291,24 @@ discard block |
||
286 | 291 | $parent_field = $this->db_fields['parent']; |
287 | 292 | |
288 | 293 | $count = -1; |
289 | - if ( -1 == $max_depth ) |
|
290 | - $total_top = count( $elements ); |
|
294 | + if ( -1 == $max_depth ) { |
|
295 | + $total_top = count( $elements ); |
|
296 | + } |
|
291 | 297 | if ( $page_num < 1 || $per_page < 0 ) { |
292 | 298 | // No paging |
293 | 299 | $paging = false; |
294 | 300 | $start = 0; |
295 | - if ( -1 == $max_depth ) |
|
296 | - $end = $total_top; |
|
301 | + if ( -1 == $max_depth ) { |
|
302 | + $end = $total_top; |
|
303 | + } |
|
297 | 304 | $this->max_pages = 1; |
298 | 305 | } else { |
299 | 306 | $paging = true; |
300 | 307 | $start = ( (int)$page_num - 1 ) * (int)$per_page; |
301 | 308 | $end = $start + $per_page; |
302 | - if ( -1 == $max_depth ) |
|
303 | - $this->max_pages = ceil($total_top / $per_page); |
|
309 | + if ( -1 == $max_depth ) { |
|
310 | + $this->max_pages = ceil($total_top / $per_page); |
|
311 | + } |
|
304 | 312 | } |
305 | 313 | |
306 | 314 | // flat display |
@@ -315,10 +323,12 @@ discard block |
||
315 | 323 | $empty_array = array(); |
316 | 324 | foreach ( $elements as $e ) { |
317 | 325 | $count++; |
318 | - if ( $count < $start ) |
|
319 | - continue; |
|
320 | - if ( $count >= $end ) |
|
321 | - break; |
|
326 | + if ( $count < $start ) { |
|
327 | + continue; |
|
328 | + } |
|
329 | + if ( $count >= $end ) { |
|
330 | + break; |
|
331 | + } |
|
322 | 332 | $this->display_element( $e, $empty_array, 1, 0, $args, $output ); |
323 | 333 | } |
324 | 334 | return $output; |
@@ -332,17 +342,19 @@ discard block |
||
332 | 342 | $top_level_elements = array(); |
333 | 343 | $children_elements = array(); |
334 | 344 | foreach ( $elements as $e) { |
335 | - if ( 0 == $e->$parent_field ) |
|
336 | - $top_level_elements[] = $e; |
|
337 | - else |
|
338 | - $children_elements[ $e->$parent_field ][] = $e; |
|
345 | + if ( 0 == $e->$parent_field ) { |
|
346 | + $top_level_elements[] = $e; |
|
347 | + } else { |
|
348 | + $children_elements[ $e->$parent_field ][] = $e; |
|
349 | + } |
|
339 | 350 | } |
340 | 351 | |
341 | 352 | $total_top = count( $top_level_elements ); |
342 | - if ( $paging ) |
|
343 | - $this->max_pages = ceil($total_top / $per_page); |
|
344 | - else |
|
345 | - $end = $total_top; |
|
353 | + if ( $paging ) { |
|
354 | + $this->max_pages = ceil($total_top / $per_page); |
|
355 | + } else { |
|
356 | + $end = $total_top; |
|
357 | + } |
|
346 | 358 | |
347 | 359 | if ( !empty($args[0]['reverse_top_level']) ) { |
348 | 360 | $top_level_elements = array_reverse( $top_level_elements ); |
@@ -351,31 +363,36 @@ discard block |
||
351 | 363 | $end = $total_top - $oldstart; |
352 | 364 | } |
353 | 365 | if ( !empty($args[0]['reverse_children']) ) { |
354 | - foreach ( $children_elements as $parent => $children ) |
|
355 | - $children_elements[$parent] = array_reverse( $children ); |
|
366 | + foreach ( $children_elements as $parent => $children ) { |
|
367 | + $children_elements[$parent] = array_reverse( $children ); |
|
368 | + } |
|
356 | 369 | } |
357 | 370 | |
358 | 371 | foreach ( $top_level_elements as $e ) { |
359 | 372 | $count++; |
360 | 373 | |
361 | 374 | // For the last page, need to unset earlier children in order to keep track of orphans. |
362 | - if ( $end >= $total_top && $count < $start ) |
|
363 | - $this->unset_children( $e, $children_elements ); |
|
375 | + if ( $end >= $total_top && $count < $start ) { |
|
376 | + $this->unset_children( $e, $children_elements ); |
|
377 | + } |
|
364 | 378 | |
365 | - if ( $count < $start ) |
|
366 | - continue; |
|
379 | + if ( $count < $start ) { |
|
380 | + continue; |
|
381 | + } |
|
367 | 382 | |
368 | - if ( $count >= $end ) |
|
369 | - break; |
|
383 | + if ( $count >= $end ) { |
|
384 | + break; |
|
385 | + } |
|
370 | 386 | |
371 | 387 | $this->display_element( $e, $children_elements, $max_depth, 0, $args, $output ); |
372 | 388 | } |
373 | 389 | |
374 | 390 | if ( $end >= $total_top && count( $children_elements ) > 0 ) { |
375 | 391 | $empty_array = array(); |
376 | - foreach ( $children_elements as $orphans ) |
|
377 | - foreach ( $orphans as $op ) |
|
392 | + foreach ( $children_elements as $orphans ) { |
|
393 | + foreach ( $orphans as $op ) |
|
378 | 394 | $this->display_element( $op, $empty_array, 1, 0, $args, $output ); |
395 | + } |
|
379 | 396 | } |
380 | 397 | |
381 | 398 | return $output; |
@@ -395,8 +412,9 @@ discard block |
||
395 | 412 | $parent_field = $this->db_fields['parent']; |
396 | 413 | |
397 | 414 | foreach ( $elements as $e) { |
398 | - if ( 0 == $e->$parent_field ) |
|
399 | - $num++; |
|
415 | + if ( 0 == $e->$parent_field ) { |
|
416 | + $num++; |
|
417 | + } |
|
400 | 418 | } |
401 | 419 | return $num; |
402 | 420 | } |
@@ -415,9 +433,10 @@ discard block |
||
415 | 433 | $id_field = $this->db_fields['id']; |
416 | 434 | $id = $e->$id_field; |
417 | 435 | |
418 | - if ( !empty($children_elements[$id]) && is_array($children_elements[$id]) ) |
|
419 | - foreach ( (array) $children_elements[$id] as $child ) |
|
436 | + if ( !empty($children_elements[$id]) && is_array($children_elements[$id]) ) { |
|
437 | + foreach ( (array) $children_elements[$id] as $child ) |
|
420 | 438 | $this->unset_children( $child, $children_elements ); |
439 | + } |
|
421 | 440 | |
422 | 441 | unset( $children_elements[ $id ] ); |
423 | 442 | } |
@@ -57,11 +57,11 @@ discard block |
||
57 | 57 | $this->settings = array( |
58 | 58 | 'term' => array( |
59 | 59 | 'filter' => 'get_term_metadata', |
60 | - 'callback' => array( $this, 'lazyload_term_meta' ), |
|
60 | + 'callback' => array($this, 'lazyload_term_meta'), |
|
61 | 61 | ), |
62 | 62 | 'comment' => array( |
63 | 63 | 'filter' => 'get_comment_metadata', |
64 | - 'callback' => array( $this, 'lazyload_comment_meta' ), |
|
64 | + 'callback' => array($this, 'lazyload_comment_meta'), |
|
65 | 65 | ), |
66 | 66 | ); |
67 | 67 | } |
@@ -76,25 +76,25 @@ discard block |
||
76 | 76 | * @param array $object_ids Array of object IDs. |
77 | 77 | * @return bool|WP_Error True on success, WP_Error on failure. |
78 | 78 | */ |
79 | - public function queue_objects( $object_type, $object_ids ) { |
|
80 | - if ( ! isset( $this->settings[ $object_type ] ) ) { |
|
81 | - return new WP_Error( 'invalid_object_type', __( 'Invalid object type' ) ); |
|
79 | + public function queue_objects($object_type, $object_ids) { |
|
80 | + if ( ! isset($this->settings[$object_type])) { |
|
81 | + return new WP_Error('invalid_object_type', __('Invalid object type')); |
|
82 | 82 | } |
83 | 83 | |
84 | - $type_settings = $this->settings[ $object_type ]; |
|
84 | + $type_settings = $this->settings[$object_type]; |
|
85 | 85 | |
86 | - if ( ! isset( $this->pending_objects[ $object_type ] ) ) { |
|
87 | - $this->pending_objects[ $object_type ] = array(); |
|
86 | + if ( ! isset($this->pending_objects[$object_type])) { |
|
87 | + $this->pending_objects[$object_type] = array(); |
|
88 | 88 | } |
89 | 89 | |
90 | - foreach ( $object_ids as $object_id ) { |
|
90 | + foreach ($object_ids as $object_id) { |
|
91 | 91 | // Keyed by ID for faster lookup. |
92 | - if ( ! isset( $this->pending_objects[ $object_type ][ $object_id ] ) ) { |
|
93 | - $this->pending_objects[ $object_type ][ $object_id ] = 1; |
|
92 | + if ( ! isset($this->pending_objects[$object_type][$object_id])) { |
|
93 | + $this->pending_objects[$object_type][$object_id] = 1; |
|
94 | 94 | } |
95 | 95 | } |
96 | 96 | |
97 | - add_filter( $type_settings['filter'], $type_settings['callback'] ); |
|
97 | + add_filter($type_settings['filter'], $type_settings['callback']); |
|
98 | 98 | |
99 | 99 | /** |
100 | 100 | * Fires after objects are added to the metadata lazy-load queue. |
@@ -105,7 +105,7 @@ discard block |
||
105 | 105 | * @param string $object_type Type of object being queued. |
106 | 106 | * @param WP_Metadata_Lazyloader $lazyloader The lazy-loader object. |
107 | 107 | */ |
108 | - do_action( 'metadata_lazyloader_queued_objects', $object_ids, $object_type, $this ); |
|
108 | + do_action('metadata_lazyloader_queued_objects', $object_ids, $object_type, $this); |
|
109 | 109 | } |
110 | 110 | |
111 | 111 | /** |
@@ -117,15 +117,15 @@ discard block |
||
117 | 117 | * @param string $object_type Object type. Accepts 'comment' or 'term'. |
118 | 118 | * @return bool|WP_Error True on success, WP_Error on failure. |
119 | 119 | */ |
120 | - public function reset_queue( $object_type ) { |
|
121 | - if ( ! isset( $this->settings[ $object_type ] ) ) { |
|
122 | - return new WP_Error( 'invalid_object_type', __( 'Invalid object type' ) ); |
|
120 | + public function reset_queue($object_type) { |
|
121 | + if ( ! isset($this->settings[$object_type])) { |
|
122 | + return new WP_Error('invalid_object_type', __('Invalid object type')); |
|
123 | 123 | } |
124 | 124 | |
125 | - $type_settings = $this->settings[ $object_type ]; |
|
125 | + $type_settings = $this->settings[$object_type]; |
|
126 | 126 | |
127 | - $this->pending_objects[ $object_type ] = array(); |
|
128 | - remove_filter( $type_settings['filter'], $type_settings['callback'] ); |
|
127 | + $this->pending_objects[$object_type] = array(); |
|
128 | + remove_filter($type_settings['filter'], $type_settings['callback']); |
|
129 | 129 | } |
130 | 130 | |
131 | 131 | /** |
@@ -141,12 +141,12 @@ discard block |
||
141 | 141 | * @return mixed In order not to short-circuit `get_metadata()`. Generally, this is `null`, but it could be |
142 | 142 | * another value if filtered by a plugin. |
143 | 143 | */ |
144 | - public function lazyload_term_meta( $check ) { |
|
145 | - if ( ! empty( $this->pending_objects['term'] ) ) { |
|
146 | - update_termmeta_cache( array_keys( $this->pending_objects['term'] ) ); |
|
144 | + public function lazyload_term_meta($check) { |
|
145 | + if ( ! empty($this->pending_objects['term'])) { |
|
146 | + update_termmeta_cache(array_keys($this->pending_objects['term'])); |
|
147 | 147 | |
148 | 148 | // No need to run again for this set of terms. |
149 | - $this->reset_queue( 'term' ); |
|
149 | + $this->reset_queue('term'); |
|
150 | 150 | } |
151 | 151 | |
152 | 152 | return $check; |
@@ -163,12 +163,12 @@ discard block |
||
163 | 163 | * @param mixed $check The `$check` param passed from the 'get_comment_metadata' hook. |
164 | 164 | * @return mixed The original value of `$check`, so as not to short-circuit `get_comment_metadata()`. |
165 | 165 | */ |
166 | - public function lazyload_comment_meta( $check ) { |
|
167 | - if ( ! empty( $this->pending_objects['comment'] ) ) { |
|
168 | - update_meta_cache( 'comment', array_keys( $this->pending_objects['comment'] ) ); |
|
166 | + public function lazyload_comment_meta($check) { |
|
167 | + if ( ! empty($this->pending_objects['comment'])) { |
|
168 | + update_meta_cache('comment', array_keys($this->pending_objects['comment'])); |
|
169 | 169 | |
170 | 170 | // No need to run again for this set of comments. |
171 | - $this->reset_queue( 'comment' ); |
|
171 | + $this->reset_queue('comment'); |
|
172 | 172 | } |
173 | 173 | |
174 | 174 | return $check; |
@@ -462,8 +462,9 @@ discard block |
||
462 | 462 | $posts = get_page_hierarchy( $pages ); |
463 | 463 | |
464 | 464 | // If we have no pages get out quick. |
465 | - if ( !$posts ) |
|
466 | - return array( array(), array() ); |
|
465 | + if ( !$posts ) { |
|
466 | + return array( array(), array() ); |
|
467 | + } |
|
467 | 468 | |
468 | 469 | // Now reverse it, because we need parents after children for rewrite rules to work properly. |
469 | 470 | $posts = array_reverse($posts, true); |
@@ -524,8 +525,9 @@ discard block |
||
524 | 525 | * @return string|false False on no permalink structure. Date permalink structure. |
525 | 526 | */ |
526 | 527 | public function get_date_permastruct() { |
527 | - if ( isset($this->date_structure) ) |
|
528 | - return $this->date_structure; |
|
528 | + if ( isset($this->date_structure) ) { |
|
529 | + return $this->date_structure; |
|
530 | + } |
|
529 | 531 | |
530 | 532 | if ( empty($this->permalink_structure) ) { |
531 | 533 | $this->date_structure = ''; |
@@ -545,8 +547,9 @@ discard block |
||
545 | 547 | } |
546 | 548 | } |
547 | 549 | |
548 | - if ( empty($date_endian) ) |
|
549 | - $date_endian = '%year%/%monthnum%/%day%'; |
|
550 | + if ( empty($date_endian) ) { |
|
551 | + $date_endian = '%year%/%monthnum%/%day%'; |
|
552 | + } |
|
550 | 553 | |
551 | 554 | /* |
552 | 555 | * Do not allow the date tags and %post_id% to overlap in the permalink |
@@ -582,8 +585,9 @@ discard block |
||
582 | 585 | public function get_year_permastruct() { |
583 | 586 | $structure = $this->get_date_permastruct(); |
584 | 587 | |
585 | - if ( empty($structure) ) |
|
586 | - return false; |
|
588 | + if ( empty($structure) ) { |
|
589 | + return false; |
|
590 | + } |
|
587 | 591 | |
588 | 592 | $structure = str_replace('%monthnum%', '', $structure); |
589 | 593 | $structure = str_replace('%day%', '', $structure); |
@@ -606,8 +610,9 @@ discard block |
||
606 | 610 | public function get_month_permastruct() { |
607 | 611 | $structure = $this->get_date_permastruct(); |
608 | 612 | |
609 | - if ( empty($structure) ) |
|
610 | - return false; |
|
613 | + if ( empty($structure) ) { |
|
614 | + return false; |
|
615 | + } |
|
611 | 616 | |
612 | 617 | $structure = str_replace('%day%', '', $structure); |
613 | 618 | $structure = preg_replace('#/+#', '/', $structure); |
@@ -673,11 +678,13 @@ discard block |
||
673 | 678 | * @return string|false False if not found. Permalink structure string. |
674 | 679 | */ |
675 | 680 | public function get_extra_permastruct($name) { |
676 | - if ( empty($this->permalink_structure) ) |
|
677 | - return false; |
|
681 | + if ( empty($this->permalink_structure) ) { |
|
682 | + return false; |
|
683 | + } |
|
678 | 684 | |
679 | - if ( isset($this->extra_permastructs[$name]) ) |
|
680 | - return $this->extra_permastructs[$name]['struct']; |
|
685 | + if ( isset($this->extra_permastructs[$name]) ) { |
|
686 | + return $this->extra_permastructs[$name]['struct']; |
|
687 | + } |
|
681 | 688 | |
682 | 689 | return false; |
683 | 690 | } |
@@ -695,8 +702,9 @@ discard block |
||
695 | 702 | * @return string|false False if not found. Permalink structure string. |
696 | 703 | */ |
697 | 704 | public function get_author_permastruct() { |
698 | - if ( isset($this->author_structure) ) |
|
699 | - return $this->author_structure; |
|
705 | + if ( isset($this->author_structure) ) { |
|
706 | + return $this->author_structure; |
|
707 | + } |
|
700 | 708 | |
701 | 709 | if ( empty($this->permalink_structure) ) { |
702 | 710 | $this->author_structure = ''; |
@@ -721,8 +729,9 @@ discard block |
||
721 | 729 | * @return string|false False if not found. Permalink structure string. |
722 | 730 | */ |
723 | 731 | public function get_search_permastruct() { |
724 | - if ( isset($this->search_structure) ) |
|
725 | - return $this->search_structure; |
|
732 | + if ( isset($this->search_structure) ) { |
|
733 | + return $this->search_structure; |
|
734 | + } |
|
726 | 735 | |
727 | 736 | if ( empty($this->permalink_structure) ) { |
728 | 737 | $this->search_structure = ''; |
@@ -747,8 +756,9 @@ discard block |
||
747 | 756 | * @return string|false False if not found. Permalink structure string. |
748 | 757 | */ |
749 | 758 | public function get_page_permastruct() { |
750 | - if ( isset($this->page_structure) ) |
|
751 | - return $this->page_structure; |
|
759 | + if ( isset($this->page_structure) ) { |
|
760 | + return $this->page_structure; |
|
761 | + } |
|
752 | 762 | |
753 | 763 | if (empty($this->permalink_structure)) { |
754 | 764 | $this->page_structure = ''; |
@@ -773,8 +783,9 @@ discard block |
||
773 | 783 | * @return string|false False if not found. Permalink structure string. |
774 | 784 | */ |
775 | 785 | public function get_feed_permastruct() { |
776 | - if ( isset($this->feed_structure) ) |
|
777 | - return $this->feed_structure; |
|
786 | + if ( isset($this->feed_structure) ) { |
|
787 | + return $this->feed_structure; |
|
788 | + } |
|
778 | 789 | |
779 | 790 | if ( empty($this->permalink_structure) ) { |
780 | 791 | $this->feed_structure = ''; |
@@ -799,8 +810,9 @@ discard block |
||
799 | 810 | * @return string|false False if not found. Permalink structure string. |
800 | 811 | */ |
801 | 812 | public function get_comment_feed_permastruct() { |
802 | - if ( isset($this->comment_feed_structure) ) |
|
803 | - return $this->comment_feed_structure; |
|
813 | + if ( isset($this->comment_feed_structure) ) { |
|
814 | + return $this->comment_feed_structure; |
|
815 | + } |
|
804 | 816 | |
805 | 817 | if (empty($this->permalink_structure)) { |
806 | 818 | $this->comment_feed_structure = ''; |
@@ -894,8 +906,9 @@ discard block |
||
894 | 906 | public function generate_rewrite_rules($permalink_structure, $ep_mask = EP_NONE, $paged = true, $feed = true, $forcomments = false, $walk_dirs = true, $endpoints = true) { |
895 | 907 | // Build a regex to match the feed section of URLs, something like (feed|atom|rss|rss2)/? |
896 | 908 | $feedregex2 = ''; |
897 | - foreach ( (array) $this->feeds as $feed_name) |
|
898 | - $feedregex2 .= $feed_name . '|'; |
|
909 | + foreach ( (array) $this->feeds as $feed_name) { |
|
910 | + $feedregex2 .= $feed_name . '|'; |
|
911 | + } |
|
899 | 912 | $feedregex2 = '(' . trim($feedregex2, '|') . ')/?$'; |
900 | 913 | |
901 | 914 | /* |
@@ -942,10 +955,11 @@ discard block |
||
942 | 955 | */ |
943 | 956 | $queries = array(); |
944 | 957 | for ( $i = 0; $i < $num_tokens; ++$i ) { |
945 | - if ( 0 < $i ) |
|
946 | - $queries[$i] = $queries[$i - 1] . '&'; |
|
947 | - else |
|
948 | - $queries[$i] = ''; |
|
958 | + if ( 0 < $i ) { |
|
959 | + $queries[$i] = $queries[$i - 1] . '&'; |
|
960 | + } else { |
|
961 | + $queries[$i] = ''; |
|
962 | + } |
|
949 | 963 | |
950 | 964 | $query_token = str_replace($this->rewritecode, $this->queryreplace, $tokens[0][$i]) . $this->preg_index($i+1); |
951 | 965 | $queries[$i] .= $query_token; |
@@ -953,8 +967,9 @@ discard block |
||
953 | 967 | |
954 | 968 | // Get the structure, minus any cruft (stuff that isn't tags) at the front. |
955 | 969 | $structure = $permalink_structure; |
956 | - if ( $front != '/' ) |
|
957 | - $structure = str_replace($front, '', $structure); |
|
970 | + if ( $front != '/' ) { |
|
971 | + $structure = str_replace($front, '', $structure); |
|
972 | + } |
|
958 | 973 | |
959 | 974 | /* |
960 | 975 | * Create a list of dirs to walk over, making rewrite rules for each level |
@@ -1056,8 +1071,9 @@ discard block |
||
1056 | 1071 | if ( $endpoints ) { |
1057 | 1072 | foreach ( (array) $ep_query_append as $regex => $ep) { |
1058 | 1073 | // Add the endpoints on if the mask fits. |
1059 | - if ( $ep[0] & $ep_mask || $ep[0] & $ep_mask_specific ) |
|
1060 | - $rewrite[$match . $regex] = $index . '?' . $query . $ep[1] . $this->preg_index($num_toks + 2); |
|
1074 | + if ( $ep[0] & $ep_mask || $ep[0] & $ep_mask_specific ) { |
|
1075 | + $rewrite[$match . $regex] = $index . '?' . $query . $ep[1] . $this->preg_index($num_toks + 2); |
|
1076 | + } |
|
1061 | 1077 | } |
1062 | 1078 | } |
1063 | 1079 | |
@@ -1078,8 +1094,9 @@ discard block |
||
1078 | 1094 | || (strpos($struct, '%year%') !== false && strpos($struct, '%monthnum%') !== false && strpos($struct, '%day%') !== false && strpos($struct, '%hour%') !== false && strpos($struct, '%minute%') !== false && strpos($struct, '%second%') !== false) |
1079 | 1095 | ) { |
1080 | 1096 | $post = true; |
1081 | - if ( strpos($struct, '%pagename%') !== false ) |
|
1082 | - $page = true; |
|
1097 | + if ( strpos($struct, '%pagename%') !== false ) { |
|
1098 | + $page = true; |
|
1099 | + } |
|
1083 | 1100 | } |
1084 | 1101 | |
1085 | 1102 | if ( ! $post ) { |
@@ -1270,8 +1287,9 @@ discard block |
||
1270 | 1287 | public function rewrite_rules() { |
1271 | 1288 | $rewrite = array(); |
1272 | 1289 | |
1273 | - if ( empty($this->permalink_structure) ) |
|
1274 | - return $rewrite; |
|
1290 | + if ( empty($this->permalink_structure) ) { |
|
1291 | + return $rewrite; |
|
1292 | + } |
|
1275 | 1293 | |
1276 | 1294 | // robots.txt -only if installed at the root |
1277 | 1295 | $home_path = parse_url( home_url() ); |
@@ -1394,10 +1412,11 @@ discard block |
||
1394 | 1412 | // Extra permastructs. |
1395 | 1413 | foreach ( $this->extra_permastructs as $permastructname => $struct ) { |
1396 | 1414 | if ( is_array( $struct ) ) { |
1397 | - if ( count( $struct ) == 2 ) |
|
1398 | - $rules = $this->generate_rewrite_rules( $struct[0], $struct[1] ); |
|
1399 | - else |
|
1400 | - $rules = $this->generate_rewrite_rules( $struct['struct'], $struct['ep_mask'], $struct['paged'], $struct['feed'], $struct['forcomments'], $struct['walk_dirs'], $struct['endpoints'] ); |
|
1415 | + if ( count( $struct ) == 2 ) { |
|
1416 | + $rules = $this->generate_rewrite_rules( $struct[0], $struct[1] ); |
|
1417 | + } else { |
|
1418 | + $rules = $this->generate_rewrite_rules( $struct['struct'], $struct['ep_mask'], $struct['paged'], $struct['feed'], $struct['forcomments'], $struct['walk_dirs'], $struct['endpoints'] ); |
|
1419 | + } |
|
1401 | 1420 | } else { |
1402 | 1421 | $rules = $this->generate_rewrite_rules( $struct ); |
1403 | 1422 | } |
@@ -1431,10 +1450,11 @@ discard block |
||
1431 | 1450 | } |
1432 | 1451 | |
1433 | 1452 | // Put them together. |
1434 | - if ( $this->use_verbose_page_rules ) |
|
1435 | - $this->rules = array_merge($this->extra_rules_top, $robots_rewrite, $deprecated_files, $registration_pages, $root_rewrite, $comments_rewrite, $search_rewrite, $author_rewrite, $date_rewrite, $page_rewrite, $post_rewrite, $this->extra_rules); |
|
1436 | - else |
|
1437 | - $this->rules = array_merge($this->extra_rules_top, $robots_rewrite, $deprecated_files, $registration_pages, $root_rewrite, $comments_rewrite, $search_rewrite, $author_rewrite, $date_rewrite, $post_rewrite, $page_rewrite, $this->extra_rules); |
|
1453 | + if ( $this->use_verbose_page_rules ) { |
|
1454 | + $this->rules = array_merge($this->extra_rules_top, $robots_rewrite, $deprecated_files, $registration_pages, $root_rewrite, $comments_rewrite, $search_rewrite, $author_rewrite, $date_rewrite, $page_rewrite, $post_rewrite, $this->extra_rules); |
|
1455 | + } else { |
|
1456 | + $this->rules = array_merge($this->extra_rules_top, $robots_rewrite, $deprecated_files, $registration_pages, $root_rewrite, $comments_rewrite, $search_rewrite, $author_rewrite, $date_rewrite, $post_rewrite, $page_rewrite, $this->extra_rules); |
|
1457 | + } |
|
1438 | 1458 | |
1439 | 1459 | /** |
1440 | 1460 | * Fires after the rewrite rules are generated. |
@@ -1496,18 +1516,21 @@ discard block |
||
1496 | 1516 | * @return string |
1497 | 1517 | */ |
1498 | 1518 | public function mod_rewrite_rules() { |
1499 | - if ( ! $this->using_permalinks() ) |
|
1500 | - return ''; |
|
1519 | + if ( ! $this->using_permalinks() ) { |
|
1520 | + return ''; |
|
1521 | + } |
|
1501 | 1522 | |
1502 | 1523 | $site_root = parse_url( site_url() ); |
1503 | - if ( isset( $site_root['path'] ) ) |
|
1504 | - $site_root = trailingslashit($site_root['path']); |
|
1524 | + if ( isset( $site_root['path'] ) ) { |
|
1525 | + $site_root = trailingslashit($site_root['path']); |
|
1526 | + } |
|
1505 | 1527 | |
1506 | 1528 | $home_root = parse_url(home_url()); |
1507 | - if ( isset( $home_root['path'] ) ) |
|
1508 | - $home_root = trailingslashit($home_root['path']); |
|
1509 | - else |
|
1510 | - $home_root = '/'; |
|
1529 | + if ( isset( $home_root['path'] ) ) { |
|
1530 | + $home_root = trailingslashit($home_root['path']); |
|
1531 | + } else { |
|
1532 | + $home_root = '/'; |
|
1533 | + } |
|
1511 | 1534 | |
1512 | 1535 | $rules = "<IfModule mod_rewrite.c>\n"; |
1513 | 1536 | $rules .= "RewriteEngine On\n"; |
@@ -1536,10 +1559,11 @@ discard block |
||
1536 | 1559 | // Apache 1.3 does not support the reluctant (non-greedy) modifier. |
1537 | 1560 | $match = str_replace('.+?', '.+', $match); |
1538 | 1561 | |
1539 | - if ( strpos($query, $this->index) !== false ) |
|
1540 | - $rules .= 'RewriteRule ^' . $match . ' ' . $home_root . $query . " [QSA,L]\n"; |
|
1541 | - else |
|
1542 | - $rules .= 'RewriteRule ^' . $match . ' ' . $site_root . $query . " [QSA,L]\n"; |
|
1562 | + if ( strpos($query, $this->index) !== false ) { |
|
1563 | + $rules .= 'RewriteRule ^' . $match . ' ' . $home_root . $query . " [QSA,L]\n"; |
|
1564 | + } else { |
|
1565 | + $rules .= 'RewriteRule ^' . $match . ' ' . $site_root . $query . " [QSA,L]\n"; |
|
1566 | + } |
|
1543 | 1567 | } |
1544 | 1568 | } else { |
1545 | 1569 | $rules .= "RewriteCond %{REQUEST_FILENAME} !-f\n" . |
@@ -1583,8 +1607,9 @@ discard block |
||
1583 | 1607 | * @return string IIS7 URL rewrite rule sets. |
1584 | 1608 | */ |
1585 | 1609 | public function iis7_url_rewrite_rules( $add_parent_tags = false ) { |
1586 | - if ( ! $this->using_permalinks() ) |
|
1587 | - return ''; |
|
1610 | + if ( ! $this->using_permalinks() ) { |
|
1611 | + return ''; |
|
1612 | + } |
|
1588 | 1613 | $rules = ''; |
1589 | 1614 | if ( $add_parent_tags ) { |
1590 | 1615 | $rules .= '<configuration> |
@@ -1744,10 +1769,12 @@ discard block |
||
1744 | 1769 | */ |
1745 | 1770 | public function add_permastruct( $name, $struct, $args = array() ) { |
1746 | 1771 | // Backwards compatibility for the old parameters: $with_front and $ep_mask. |
1747 | - if ( ! is_array( $args ) ) |
|
1748 | - $args = array( 'with_front' => $args ); |
|
1749 | - if ( func_num_args() == 4 ) |
|
1750 | - $args['ep_mask'] = func_get_arg( 3 ); |
|
1772 | + if ( ! is_array( $args ) ) { |
|
1773 | + $args = array( 'with_front' => $args ); |
|
1774 | + } |
|
1775 | + if ( func_num_args() == 4 ) { |
|
1776 | + $args['ep_mask'] = func_get_arg( 3 ); |
|
1777 | + } |
|
1751 | 1778 | |
1752 | 1779 | $defaults = array( |
1753 | 1780 | 'with_front' => true, |
@@ -1761,10 +1788,11 @@ discard block |
||
1761 | 1788 | $args = array_intersect_key( $args, $defaults ); |
1762 | 1789 | $args = wp_parse_args( $args, $defaults ); |
1763 | 1790 | |
1764 | - if ( $args['with_front'] ) |
|
1765 | - $struct = $this->front . $struct; |
|
1766 | - else |
|
1767 | - $struct = $this->root . $struct; |
|
1791 | + if ( $args['with_front'] ) { |
|
1792 | + $struct = $this->front . $struct; |
|
1793 | + } else { |
|
1794 | + $struct = $this->root . $struct; |
|
1795 | + } |
|
1768 | 1796 | $args['struct'] = $struct; |
1769 | 1797 | |
1770 | 1798 | $this->extra_permastructs[ $name ] = $args; |
@@ -1825,10 +1853,12 @@ discard block |
||
1825 | 1853 | if ( ! $hard || ! apply_filters( 'flush_rewrite_rules_hard', true ) ) { |
1826 | 1854 | return; |
1827 | 1855 | } |
1828 | - if ( function_exists( 'save_mod_rewrite_rules' ) ) |
|
1829 | - save_mod_rewrite_rules(); |
|
1830 | - if ( function_exists( 'iis7_save_url_rewrite_rules' ) ) |
|
1831 | - iis7_save_url_rewrite_rules(); |
|
1856 | + if ( function_exists( 'save_mod_rewrite_rules' ) ) { |
|
1857 | + save_mod_rewrite_rules(); |
|
1858 | + } |
|
1859 | + if ( function_exists( 'iis7_save_url_rewrite_rules' ) ) { |
|
1860 | + iis7_save_url_rewrite_rules(); |
|
1861 | + } |
|
1832 | 1862 | } |
1833 | 1863 | |
1834 | 1864 | /** |
@@ -1847,8 +1877,9 @@ discard block |
||
1847 | 1877 | $this->front = substr($this->permalink_structure, 0, strpos($this->permalink_structure, '%')); |
1848 | 1878 | $this->root = ''; |
1849 | 1879 | |
1850 | - if ( $this->using_index_permalinks() ) |
|
1851 | - $this->root = $this->index . '/'; |
|
1880 | + if ( $this->using_index_permalinks() ) { |
|
1881 | + $this->root = $this->index . '/'; |
|
1882 | + } |
|
1852 | 1883 | |
1853 | 1884 | unset($this->author_structure); |
1854 | 1885 | unset($this->date_structure); |
@@ -1859,10 +1890,11 @@ discard block |
||
1859 | 1890 | $this->use_trailing_slashes = ( '/' == substr($this->permalink_structure, -1, 1) ); |
1860 | 1891 | |
1861 | 1892 | // Enable generic rules for pages if permalink structure doesn't begin with a wildcard. |
1862 | - if ( preg_match("/^[^%]*%(?:postname|category|tag|author)%/", $this->permalink_structure) ) |
|
1863 | - $this->use_verbose_page_rules = true; |
|
1864 | - else |
|
1865 | - $this->use_verbose_page_rules = false; |
|
1893 | + if ( preg_match("/^[^%]*%(?:postname|category|tag|author)%/", $this->permalink_structure) ) { |
|
1894 | + $this->use_verbose_page_rules = true; |
|
1895 | + } else { |
|
1896 | + $this->use_verbose_page_rules = false; |
|
1897 | + } |
|
1866 | 1898 | } |
1867 | 1899 | |
1868 | 1900 | /** |
@@ -364,7 +364,7 @@ discard block |
||
364 | 364 | * @since 1.5.0 |
365 | 365 | * @var array |
366 | 366 | */ |
367 | - public $feeds = array( 'feed', 'rdf', 'rss', 'rss2', 'atom' ); |
|
367 | + public $feeds = array('feed', 'rdf', 'rss', 'rss2', 'atom'); |
|
368 | 368 | |
369 | 369 | /** |
370 | 370 | * Determines whether permalinks are being used. |
@@ -391,12 +391,12 @@ discard block |
||
391 | 391 | * @return bool Whether permalink links are enabled and index.php is in the URL. |
392 | 392 | */ |
393 | 393 | public function using_index_permalinks() { |
394 | - if ( empty( $this->permalink_structure ) ) { |
|
394 | + if (empty($this->permalink_structure)) { |
|
395 | 395 | return false; |
396 | 396 | } |
397 | 397 | |
398 | 398 | // If the index is not in the permalink, we're using mod_rewrite. |
399 | - return preg_match( '#^/*' . $this->index . '#', $this->permalink_structure ); |
|
399 | + return preg_match('#^/*'.$this->index.'#', $this->permalink_structure); |
|
400 | 400 | } |
401 | 401 | |
402 | 402 | /** |
@@ -433,8 +433,8 @@ discard block |
||
433 | 433 | $match_prefix = '$'; |
434 | 434 | $match_suffix = ''; |
435 | 435 | |
436 | - if ( ! empty($this->matches) ) { |
|
437 | - $match_prefix = '$' . $this->matches . '['; |
|
436 | + if ( ! empty($this->matches)) { |
|
437 | + $match_prefix = '$'.$this->matches.'['; |
|
438 | 438 | $match_suffix = ']'; |
439 | 439 | } |
440 | 440 | |
@@ -459,11 +459,11 @@ discard block |
||
459 | 459 | |
460 | 460 | // Get pages in order of hierarchy, i.e. children after parents. |
461 | 461 | $pages = $wpdb->get_results("SELECT ID, post_name, post_parent FROM $wpdb->posts WHERE post_type = 'page' AND post_status != 'auto-draft'"); |
462 | - $posts = get_page_hierarchy( $pages ); |
|
462 | + $posts = get_page_hierarchy($pages); |
|
463 | 463 | |
464 | 464 | // If we have no pages get out quick. |
465 | - if ( !$posts ) |
|
466 | - return array( array(), array() ); |
|
465 | + if ( ! $posts) |
|
466 | + return array(array(), array()); |
|
467 | 467 | |
468 | 468 | // Now reverse it, because we need parents after children for rewrite rules to work properly. |
469 | 469 | $posts = array_reverse($posts, true); |
@@ -471,12 +471,12 @@ discard block |
||
471 | 471 | $page_uris = array(); |
472 | 472 | $page_attachment_uris = array(); |
473 | 473 | |
474 | - foreach ( $posts as $id => $post ) { |
|
474 | + foreach ($posts as $id => $post) { |
|
475 | 475 | // URL => page name |
476 | 476 | $uri = get_page_uri($id); |
477 | - $attachments = $wpdb->get_results( $wpdb->prepare( "SELECT ID, post_name, post_parent FROM $wpdb->posts WHERE post_type = 'attachment' AND post_parent = %d", $id )); |
|
478 | - if ( !empty($attachments) ) { |
|
479 | - foreach ( $attachments as $attachment ) { |
|
477 | + $attachments = $wpdb->get_results($wpdb->prepare("SELECT ID, post_name, post_parent FROM $wpdb->posts WHERE post_type = 'attachment' AND post_parent = %d", $id)); |
|
478 | + if ( ! empty($attachments)) { |
|
479 | + foreach ($attachments as $attachment) { |
|
480 | 480 | $attach_uri = get_page_uri($attachment->ID); |
481 | 481 | $page_attachment_uris[$attach_uri] = $attachment->ID; |
482 | 482 | } |
@@ -485,7 +485,7 @@ discard block |
||
485 | 485 | $page_uris[$uri] = $id; |
486 | 486 | } |
487 | 487 | |
488 | - return array( $page_uris, $page_attachment_uris ); |
|
488 | + return array($page_uris, $page_attachment_uris); |
|
489 | 489 | } |
490 | 490 | |
491 | 491 | /** |
@@ -498,9 +498,9 @@ discard block |
||
498 | 498 | */ |
499 | 499 | public function page_rewrite_rules() { |
500 | 500 | // The extra .? at the beginning prevents clashes with other regular expressions in the rules array. |
501 | - $this->add_rewrite_tag( '%pagename%', '(.?.+?)', 'pagename=' ); |
|
501 | + $this->add_rewrite_tag('%pagename%', '(.?.+?)', 'pagename='); |
|
502 | 502 | |
503 | - return $this->generate_rewrite_rules( $this->get_page_permastruct(), EP_PAGES, true, true, false, false ); |
|
503 | + return $this->generate_rewrite_rules($this->get_page_permastruct(), EP_PAGES, true, true, false, false); |
|
504 | 504 | } |
505 | 505 | |
506 | 506 | /** |
@@ -524,10 +524,10 @@ discard block |
||
524 | 524 | * @return string|false False on no permalink structure. Date permalink structure. |
525 | 525 | */ |
526 | 526 | public function get_date_permastruct() { |
527 | - if ( isset($this->date_structure) ) |
|
527 | + if (isset($this->date_structure)) |
|
528 | 528 | return $this->date_structure; |
529 | 529 | |
530 | - if ( empty($this->permalink_structure) ) { |
|
530 | + if (empty($this->permalink_structure)) { |
|
531 | 531 | $this->date_structure = ''; |
532 | 532 | return false; |
533 | 533 | } |
@@ -538,14 +538,14 @@ discard block |
||
538 | 538 | $this->date_structure = ''; |
539 | 539 | $date_endian = ''; |
540 | 540 | |
541 | - foreach ( $endians as $endian ) { |
|
542 | - if ( false !== strpos($this->permalink_structure, $endian) ) { |
|
543 | - $date_endian= $endian; |
|
541 | + foreach ($endians as $endian) { |
|
542 | + if (false !== strpos($this->permalink_structure, $endian)) { |
|
543 | + $date_endian = $endian; |
|
544 | 544 | break; |
545 | 545 | } |
546 | 546 | } |
547 | 547 | |
548 | - if ( empty($date_endian) ) |
|
548 | + if (empty($date_endian)) |
|
549 | 549 | $date_endian = '%year%/%monthnum%/%day%'; |
550 | 550 | |
551 | 551 | /* |
@@ -555,15 +555,15 @@ discard block |
||
555 | 555 | $front = $this->front; |
556 | 556 | preg_match_all('/%.+?%/', $this->permalink_structure, $tokens); |
557 | 557 | $tok_index = 1; |
558 | - foreach ( (array) $tokens[0] as $token) { |
|
559 | - if ( '%post_id%' == $token && ($tok_index <= 3) ) { |
|
560 | - $front = $front . 'date/'; |
|
558 | + foreach ((array) $tokens[0] as $token) { |
|
559 | + if ('%post_id%' == $token && ($tok_index <= 3)) { |
|
560 | + $front = $front.'date/'; |
|
561 | 561 | break; |
562 | 562 | } |
563 | 563 | $tok_index++; |
564 | 564 | } |
565 | 565 | |
566 | - $this->date_structure = $front . $date_endian; |
|
566 | + $this->date_structure = $front.$date_endian; |
|
567 | 567 | |
568 | 568 | return $this->date_structure; |
569 | 569 | } |
@@ -582,7 +582,7 @@ discard block |
||
582 | 582 | public function get_year_permastruct() { |
583 | 583 | $structure = $this->get_date_permastruct(); |
584 | 584 | |
585 | - if ( empty($structure) ) |
|
585 | + if (empty($structure)) |
|
586 | 586 | return false; |
587 | 587 | |
588 | 588 | $structure = str_replace('%monthnum%', '', $structure); |
@@ -606,7 +606,7 @@ discard block |
||
606 | 606 | public function get_month_permastruct() { |
607 | 607 | $structure = $this->get_date_permastruct(); |
608 | 608 | |
609 | - if ( empty($structure) ) |
|
609 | + if (empty($structure)) |
|
610 | 610 | return false; |
611 | 611 | |
612 | 612 | $structure = str_replace('%day%', '', $structure); |
@@ -673,10 +673,10 @@ discard block |
||
673 | 673 | * @return string|false False if not found. Permalink structure string. |
674 | 674 | */ |
675 | 675 | public function get_extra_permastruct($name) { |
676 | - if ( empty($this->permalink_structure) ) |
|
676 | + if (empty($this->permalink_structure)) |
|
677 | 677 | return false; |
678 | 678 | |
679 | - if ( isset($this->extra_permastructs[$name]) ) |
|
679 | + if (isset($this->extra_permastructs[$name])) |
|
680 | 680 | return $this->extra_permastructs[$name]['struct']; |
681 | 681 | |
682 | 682 | return false; |
@@ -695,15 +695,15 @@ discard block |
||
695 | 695 | * @return string|false False if not found. Permalink structure string. |
696 | 696 | */ |
697 | 697 | public function get_author_permastruct() { |
698 | - if ( isset($this->author_structure) ) |
|
698 | + if (isset($this->author_structure)) |
|
699 | 699 | return $this->author_structure; |
700 | 700 | |
701 | - if ( empty($this->permalink_structure) ) { |
|
701 | + if (empty($this->permalink_structure)) { |
|
702 | 702 | $this->author_structure = ''; |
703 | 703 | return false; |
704 | 704 | } |
705 | 705 | |
706 | - $this->author_structure = $this->front . $this->author_base . '/%author%'; |
|
706 | + $this->author_structure = $this->front.$this->author_base.'/%author%'; |
|
707 | 707 | |
708 | 708 | return $this->author_structure; |
709 | 709 | } |
@@ -721,15 +721,15 @@ discard block |
||
721 | 721 | * @return string|false False if not found. Permalink structure string. |
722 | 722 | */ |
723 | 723 | public function get_search_permastruct() { |
724 | - if ( isset($this->search_structure) ) |
|
724 | + if (isset($this->search_structure)) |
|
725 | 725 | return $this->search_structure; |
726 | 726 | |
727 | - if ( empty($this->permalink_structure) ) { |
|
727 | + if (empty($this->permalink_structure)) { |
|
728 | 728 | $this->search_structure = ''; |
729 | 729 | return false; |
730 | 730 | } |
731 | 731 | |
732 | - $this->search_structure = $this->root . $this->search_base . '/%search%'; |
|
732 | + $this->search_structure = $this->root.$this->search_base.'/%search%'; |
|
733 | 733 | |
734 | 734 | return $this->search_structure; |
735 | 735 | } |
@@ -747,7 +747,7 @@ discard block |
||
747 | 747 | * @return string|false False if not found. Permalink structure string. |
748 | 748 | */ |
749 | 749 | public function get_page_permastruct() { |
750 | - if ( isset($this->page_structure) ) |
|
750 | + if (isset($this->page_structure)) |
|
751 | 751 | return $this->page_structure; |
752 | 752 | |
753 | 753 | if (empty($this->permalink_structure)) { |
@@ -755,7 +755,7 @@ discard block |
||
755 | 755 | return false; |
756 | 756 | } |
757 | 757 | |
758 | - $this->page_structure = $this->root . '%pagename%'; |
|
758 | + $this->page_structure = $this->root.'%pagename%'; |
|
759 | 759 | |
760 | 760 | return $this->page_structure; |
761 | 761 | } |
@@ -773,15 +773,15 @@ discard block |
||
773 | 773 | * @return string|false False if not found. Permalink structure string. |
774 | 774 | */ |
775 | 775 | public function get_feed_permastruct() { |
776 | - if ( isset($this->feed_structure) ) |
|
776 | + if (isset($this->feed_structure)) |
|
777 | 777 | return $this->feed_structure; |
778 | 778 | |
779 | - if ( empty($this->permalink_structure) ) { |
|
779 | + if (empty($this->permalink_structure)) { |
|
780 | 780 | $this->feed_structure = ''; |
781 | 781 | return false; |
782 | 782 | } |
783 | 783 | |
784 | - $this->feed_structure = $this->root . $this->feed_base . '/%feed%'; |
|
784 | + $this->feed_structure = $this->root.$this->feed_base.'/%feed%'; |
|
785 | 785 | |
786 | 786 | return $this->feed_structure; |
787 | 787 | } |
@@ -799,7 +799,7 @@ discard block |
||
799 | 799 | * @return string|false False if not found. Permalink structure string. |
800 | 800 | */ |
801 | 801 | public function get_comment_feed_permastruct() { |
802 | - if ( isset($this->comment_feed_structure) ) |
|
802 | + if (isset($this->comment_feed_structure)) |
|
803 | 803 | return $this->comment_feed_structure; |
804 | 804 | |
805 | 805 | if (empty($this->permalink_structure)) { |
@@ -807,7 +807,7 @@ discard block |
||
807 | 807 | return false; |
808 | 808 | } |
809 | 809 | |
810 | - $this->comment_feed_structure = $this->root . $this->comments_base . '/' . $this->feed_base . '/%feed%'; |
|
810 | + $this->comment_feed_structure = $this->root.$this->comments_base.'/'.$this->feed_base.'/%feed%'; |
|
811 | 811 | |
812 | 812 | return $this->comment_feed_structure; |
813 | 813 | } |
@@ -829,11 +829,11 @@ discard block |
||
829 | 829 | * @param string $regex Regular expression to substitute the tag for in rewrite rules. |
830 | 830 | * @param string $query String to append to the rewritten query. Must end in '='. |
831 | 831 | */ |
832 | - public function add_rewrite_tag( $tag, $regex, $query ) { |
|
833 | - $position = array_search( $tag, $this->rewritecode ); |
|
834 | - if ( false !== $position && null !== $position ) { |
|
835 | - $this->rewritereplace[ $position ] = $regex; |
|
836 | - $this->queryreplace[ $position ] = $query; |
|
832 | + public function add_rewrite_tag($tag, $regex, $query) { |
|
833 | + $position = array_search($tag, $this->rewritecode); |
|
834 | + if (false !== $position && null !== $position) { |
|
835 | + $this->rewritereplace[$position] = $regex; |
|
836 | + $this->queryreplace[$position] = $query; |
|
837 | 837 | } else { |
838 | 838 | $this->rewritecode[] = $tag; |
839 | 839 | $this->rewritereplace[] = $regex; |
@@ -854,12 +854,12 @@ discard block |
||
854 | 854 | * |
855 | 855 | * @param string $tag Name of the rewrite tag to remove. |
856 | 856 | */ |
857 | - public function remove_rewrite_tag( $tag ) { |
|
858 | - $position = array_search( $tag, $this->rewritecode ); |
|
859 | - if ( false !== $position && null !== $position ) { |
|
860 | - unset( $this->rewritecode[ $position ] ); |
|
861 | - unset( $this->rewritereplace[ $position ] ); |
|
862 | - unset( $this->queryreplace[ $position ] ); |
|
857 | + public function remove_rewrite_tag($tag) { |
|
858 | + $position = array_search($tag, $this->rewritecode); |
|
859 | + if (false !== $position && null !== $position) { |
|
860 | + unset($this->rewritecode[$position]); |
|
861 | + unset($this->rewritereplace[$position]); |
|
862 | + unset($this->queryreplace[$position]); |
|
863 | 863 | } |
864 | 864 | } |
865 | 865 | |
@@ -894,32 +894,32 @@ discard block |
||
894 | 894 | public function generate_rewrite_rules($permalink_structure, $ep_mask = EP_NONE, $paged = true, $feed = true, $forcomments = false, $walk_dirs = true, $endpoints = true) { |
895 | 895 | // Build a regex to match the feed section of URLs, something like (feed|atom|rss|rss2)/? |
896 | 896 | $feedregex2 = ''; |
897 | - foreach ( (array) $this->feeds as $feed_name) |
|
898 | - $feedregex2 .= $feed_name . '|'; |
|
899 | - $feedregex2 = '(' . trim($feedregex2, '|') . ')/?$'; |
|
897 | + foreach ((array) $this->feeds as $feed_name) |
|
898 | + $feedregex2 .= $feed_name.'|'; |
|
899 | + $feedregex2 = '('.trim($feedregex2, '|').')/?$'; |
|
900 | 900 | |
901 | 901 | /* |
902 | 902 | * $feedregex is identical but with /feed/ added on as well, so URLs like <permalink>/feed/atom |
903 | 903 | * and <permalink>/atom are both possible |
904 | 904 | */ |
905 | - $feedregex = $this->feed_base . '/' . $feedregex2; |
|
905 | + $feedregex = $this->feed_base.'/'.$feedregex2; |
|
906 | 906 | |
907 | 907 | // Build a regex to match the trackback and page/xx parts of URLs. |
908 | 908 | $trackbackregex = 'trackback/?$'; |
909 | - $pageregex = $this->pagination_base . '/?([0-9]{1,})/?$'; |
|
910 | - $commentregex = $this->comments_pagination_base . '-([0-9]{1,})/?$'; |
|
909 | + $pageregex = $this->pagination_base.'/?([0-9]{1,})/?$'; |
|
910 | + $commentregex = $this->comments_pagination_base.'-([0-9]{1,})/?$'; |
|
911 | 911 | $embedregex = 'embed/?$'; |
912 | 912 | |
913 | 913 | // Build up an array of endpoint regexes to append => queries to append. |
914 | - if ( $endpoints ) { |
|
915 | - $ep_query_append = array (); |
|
916 | - foreach ( (array) $this->endpoints as $endpoint) { |
|
914 | + if ($endpoints) { |
|
915 | + $ep_query_append = array(); |
|
916 | + foreach ((array) $this->endpoints as $endpoint) { |
|
917 | 917 | // Match everything after the endpoint name, but allow for nothing to appear there. |
918 | - $epmatch = $endpoint[1] . '(/(.*))?/?$'; |
|
918 | + $epmatch = $endpoint[1].'(/(.*))?/?$'; |
|
919 | 919 | |
920 | 920 | // This will be appended on to the rest of the query for each dir. |
921 | - $epquery = '&' . $endpoint[2] . '='; |
|
922 | - $ep_query_append[$epmatch] = array ( $endpoint[0], $epquery ); |
|
921 | + $epquery = '&'.$endpoint[2].'='; |
|
922 | + $ep_query_append[$epmatch] = array($endpoint[0], $epquery); |
|
923 | 923 | } |
924 | 924 | } |
925 | 925 | |
@@ -941,19 +941,19 @@ discard block |
||
941 | 941 | * like tagname=$matches[i] where i is the current $i. |
942 | 942 | */ |
943 | 943 | $queries = array(); |
944 | - for ( $i = 0; $i < $num_tokens; ++$i ) { |
|
945 | - if ( 0 < $i ) |
|
946 | - $queries[$i] = $queries[$i - 1] . '&'; |
|
944 | + for ($i = 0; $i < $num_tokens; ++$i) { |
|
945 | + if (0 < $i) |
|
946 | + $queries[$i] = $queries[$i - 1].'&'; |
|
947 | 947 | else |
948 | 948 | $queries[$i] = ''; |
949 | 949 | |
950 | - $query_token = str_replace($this->rewritecode, $this->queryreplace, $tokens[0][$i]) . $this->preg_index($i+1); |
|
950 | + $query_token = str_replace($this->rewritecode, $this->queryreplace, $tokens[0][$i]).$this->preg_index($i + 1); |
|
951 | 951 | $queries[$i] .= $query_token; |
952 | 952 | } |
953 | 953 | |
954 | 954 | // Get the structure, minus any cruft (stuff that isn't tags) at the front. |
955 | 955 | $structure = $permalink_structure; |
956 | - if ( $front != '/' ) |
|
956 | + if ($front != '/') |
|
957 | 957 | $structure = str_replace($front, '', $structure); |
958 | 958 | |
959 | 959 | /* |
@@ -962,7 +962,7 @@ discard block |
||
962 | 962 | * rewrite rules for /%year%/, /%year%/%monthnum%/ and /%year%/%monthnum%/%postname% |
963 | 963 | */ |
964 | 964 | $structure = trim($structure, '/'); |
965 | - $dirs = $walk_dirs ? explode('/', $structure) : array( $structure ); |
|
965 | + $dirs = $walk_dirs ? explode('/', $structure) : array($structure); |
|
966 | 966 | $num_dirs = count($dirs); |
967 | 967 | |
968 | 968 | // Strip slashes from the front of $front. |
@@ -971,9 +971,9 @@ discard block |
||
971 | 971 | // The main workhorse loop. |
972 | 972 | $post_rewrite = array(); |
973 | 973 | $struct = $front; |
974 | - for ( $j = 0; $j < $num_dirs; ++$j ) { |
|
974 | + for ($j = 0; $j < $num_dirs; ++$j) { |
|
975 | 975 | // Get the struct for this dir, and trim slashes off the front. |
976 | - $struct .= $dirs[$j] . '/'; // Accumulate. see comment near explode('/', $structure) above. |
|
976 | + $struct .= $dirs[$j].'/'; // Accumulate. see comment near explode('/', $structure) above. |
|
977 | 977 | $struct = ltrim($struct, '/'); |
978 | 978 | |
979 | 979 | // Replace tags with regexes. |
@@ -983,10 +983,10 @@ discard block |
||
983 | 983 | $num_toks = preg_match_all('/%.+?%/', $struct, $toks); |
984 | 984 | |
985 | 985 | // Get the 'tagname=$matches[i]'. |
986 | - $query = ( ! empty( $num_toks ) && isset( $queries[$num_toks - 1] ) ) ? $queries[$num_toks - 1] : ''; |
|
986 | + $query = ( ! empty($num_toks) && isset($queries[$num_toks - 1])) ? $queries[$num_toks - 1] : ''; |
|
987 | 987 | |
988 | 988 | // Set up $ep_mask_specific which is used to match more specific URL types. |
989 | - switch ( $dirs[$j] ) { |
|
989 | + switch ($dirs[$j]) { |
|
990 | 990 | case '%year%': |
991 | 991 | $ep_mask_specific = EP_YEAR; |
992 | 992 | break; |
@@ -1001,33 +1001,33 @@ discard block |
||
1001 | 1001 | } |
1002 | 1002 | |
1003 | 1003 | // Create query for /page/xx. |
1004 | - $pagematch = $match . $pageregex; |
|
1005 | - $pagequery = $index . '?' . $query . '&paged=' . $this->preg_index($num_toks + 1); |
|
1004 | + $pagematch = $match.$pageregex; |
|
1005 | + $pagequery = $index.'?'.$query.'&paged='.$this->preg_index($num_toks + 1); |
|
1006 | 1006 | |
1007 | 1007 | // Create query for /comment-page-xx. |
1008 | - $commentmatch = $match . $commentregex; |
|
1009 | - $commentquery = $index . '?' . $query . '&cpage=' . $this->preg_index($num_toks + 1); |
|
1008 | + $commentmatch = $match.$commentregex; |
|
1009 | + $commentquery = $index.'?'.$query.'&cpage='.$this->preg_index($num_toks + 1); |
|
1010 | 1010 | |
1011 | - if ( get_option('page_on_front') ) { |
|
1011 | + if (get_option('page_on_front')) { |
|
1012 | 1012 | // Create query for Root /comment-page-xx. |
1013 | - $rootcommentmatch = $match . $commentregex; |
|
1014 | - $rootcommentquery = $index . '?' . $query . '&page_id=' . get_option('page_on_front') . '&cpage=' . $this->preg_index($num_toks + 1); |
|
1013 | + $rootcommentmatch = $match.$commentregex; |
|
1014 | + $rootcommentquery = $index.'?'.$query.'&page_id='.get_option('page_on_front').'&cpage='.$this->preg_index($num_toks + 1); |
|
1015 | 1015 | } |
1016 | 1016 | |
1017 | 1017 | // Create query for /feed/(feed|atom|rss|rss2|rdf). |
1018 | - $feedmatch = $match . $feedregex; |
|
1019 | - $feedquery = $feedindex . '?' . $query . '&feed=' . $this->preg_index($num_toks + 1); |
|
1018 | + $feedmatch = $match.$feedregex; |
|
1019 | + $feedquery = $feedindex.'?'.$query.'&feed='.$this->preg_index($num_toks + 1); |
|
1020 | 1020 | |
1021 | 1021 | // Create query for /(feed|atom|rss|rss2|rdf) (see comment near creation of $feedregex). |
1022 | - $feedmatch2 = $match . $feedregex2; |
|
1023 | - $feedquery2 = $feedindex . '?' . $query . '&feed=' . $this->preg_index($num_toks + 1); |
|
1022 | + $feedmatch2 = $match.$feedregex2; |
|
1023 | + $feedquery2 = $feedindex.'?'.$query.'&feed='.$this->preg_index($num_toks + 1); |
|
1024 | 1024 | |
1025 | 1025 | // Create query and regex for embeds. |
1026 | - $embedmatch = $match . $embedregex; |
|
1027 | - $embedquery = $embedindex . '?' . $query . '&embed=true'; |
|
1026 | + $embedmatch = $match.$embedregex; |
|
1027 | + $embedquery = $embedindex.'?'.$query.'&embed=true'; |
|
1028 | 1028 | |
1029 | 1029 | // If asked to, turn the feed queries into comment feed ones. |
1030 | - if ( $forcomments ) { |
|
1030 | + if ($forcomments) { |
|
1031 | 1031 | $feedquery .= '&withcomments=1'; |
1032 | 1032 | $feedquery2 .= '&withcomments=1'; |
1033 | 1033 | } |
@@ -1036,33 +1036,33 @@ discard block |
||
1036 | 1036 | $rewrite = array(); |
1037 | 1037 | |
1038 | 1038 | // ...adding on /feed/ regexes => queries |
1039 | - if ( $feed ) { |
|
1040 | - $rewrite = array( $feedmatch => $feedquery, $feedmatch2 => $feedquery2, $embedmatch => $embedquery ); |
|
1039 | + if ($feed) { |
|
1040 | + $rewrite = array($feedmatch => $feedquery, $feedmatch2 => $feedquery2, $embedmatch => $embedquery); |
|
1041 | 1041 | } |
1042 | 1042 | |
1043 | 1043 | //...and /page/xx ones |
1044 | - if ( $paged ) { |
|
1045 | - $rewrite = array_merge( $rewrite, array( $pagematch => $pagequery ) ); |
|
1044 | + if ($paged) { |
|
1045 | + $rewrite = array_merge($rewrite, array($pagematch => $pagequery)); |
|
1046 | 1046 | } |
1047 | 1047 | |
1048 | 1048 | // Only on pages with comments add ../comment-page-xx/. |
1049 | - if ( EP_PAGES & $ep_mask || EP_PERMALINK & $ep_mask ) { |
|
1049 | + if (EP_PAGES & $ep_mask || EP_PERMALINK & $ep_mask) { |
|
1050 | 1050 | $rewrite = array_merge($rewrite, array($commentmatch => $commentquery)); |
1051 | - } elseif ( EP_ROOT & $ep_mask && get_option('page_on_front') ) { |
|
1051 | + } elseif (EP_ROOT & $ep_mask && get_option('page_on_front')) { |
|
1052 | 1052 | $rewrite = array_merge($rewrite, array($rootcommentmatch => $rootcommentquery)); |
1053 | 1053 | } |
1054 | 1054 | |
1055 | 1055 | // Do endpoints. |
1056 | - if ( $endpoints ) { |
|
1057 | - foreach ( (array) $ep_query_append as $regex => $ep) { |
|
1056 | + if ($endpoints) { |
|
1057 | + foreach ((array) $ep_query_append as $regex => $ep) { |
|
1058 | 1058 | // Add the endpoints on if the mask fits. |
1059 | - if ( $ep[0] & $ep_mask || $ep[0] & $ep_mask_specific ) |
|
1060 | - $rewrite[$match . $regex] = $index . '?' . $query . $ep[1] . $this->preg_index($num_toks + 2); |
|
1059 | + if ($ep[0] & $ep_mask || $ep[0] & $ep_mask_specific) |
|
1060 | + $rewrite[$match.$regex] = $index.'?'.$query.$ep[1].$this->preg_index($num_toks + 2); |
|
1061 | 1061 | } |
1062 | 1062 | } |
1063 | 1063 | |
1064 | 1064 | // If we've got some tags in this dir. |
1065 | - if ( $num_toks ) { |
|
1065 | + if ($num_toks) { |
|
1066 | 1066 | $post = false; |
1067 | 1067 | $page = false; |
1068 | 1068 | |
@@ -1072,97 +1072,97 @@ discard block |
||
1072 | 1072 | * 2) post ID, 3) page name, 4) timestamp (year, month, day, hour, second and |
1073 | 1073 | * minute all present). Set these flags now as we need them for the endpoints. |
1074 | 1074 | */ |
1075 | - if ( strpos($struct, '%postname%') !== false |
|
1075 | + if (strpos($struct, '%postname%') !== false |
|
1076 | 1076 | || strpos($struct, '%post_id%') !== false |
1077 | 1077 | || strpos($struct, '%pagename%') !== false |
1078 | 1078 | || (strpos($struct, '%year%') !== false && strpos($struct, '%monthnum%') !== false && strpos($struct, '%day%') !== false && strpos($struct, '%hour%') !== false && strpos($struct, '%minute%') !== false && strpos($struct, '%second%') !== false) |
1079 | 1079 | ) { |
1080 | 1080 | $post = true; |
1081 | - if ( strpos($struct, '%pagename%') !== false ) |
|
1081 | + if (strpos($struct, '%pagename%') !== false) |
|
1082 | 1082 | $page = true; |
1083 | 1083 | } |
1084 | 1084 | |
1085 | - if ( ! $post ) { |
|
1085 | + if ( ! $post) { |
|
1086 | 1086 | // For custom post types, we need to add on endpoints as well. |
1087 | - foreach ( get_post_types( array('_builtin' => false ) ) as $ptype ) { |
|
1088 | - if ( strpos($struct, "%$ptype%") !== false ) { |
|
1087 | + foreach (get_post_types(array('_builtin' => false)) as $ptype) { |
|
1088 | + if (strpos($struct, "%$ptype%") !== false) { |
|
1089 | 1089 | $post = true; |
1090 | 1090 | |
1091 | 1091 | // This is for page style attachment URLs. |
1092 | - $page = is_post_type_hierarchical( $ptype ); |
|
1092 | + $page = is_post_type_hierarchical($ptype); |
|
1093 | 1093 | break; |
1094 | 1094 | } |
1095 | 1095 | } |
1096 | 1096 | } |
1097 | 1097 | |
1098 | 1098 | // If creating rules for a permalink, do all the endpoints like attachments etc. |
1099 | - if ( $post ) { |
|
1099 | + if ($post) { |
|
1100 | 1100 | // Create query and regex for trackback. |
1101 | - $trackbackmatch = $match . $trackbackregex; |
|
1102 | - $trackbackquery = $trackbackindex . '?' . $query . '&tb=1'; |
|
1101 | + $trackbackmatch = $match.$trackbackregex; |
|
1102 | + $trackbackquery = $trackbackindex.'?'.$query.'&tb=1'; |
|
1103 | 1103 | |
1104 | 1104 | // Create query and regex for embeds. |
1105 | - $embedmatch = $match . $embedregex; |
|
1106 | - $embedquery = $embedindex . '?' . $query . '&embed=true'; |
|
1105 | + $embedmatch = $match.$embedregex; |
|
1106 | + $embedquery = $embedindex.'?'.$query.'&embed=true'; |
|
1107 | 1107 | |
1108 | 1108 | // Trim slashes from the end of the regex for this dir. |
1109 | 1109 | $match = rtrim($match, '/'); |
1110 | 1110 | |
1111 | 1111 | // Get rid of brackets. |
1112 | - $submatchbase = str_replace( array('(', ')'), '', $match); |
|
1112 | + $submatchbase = str_replace(array('(', ')'), '', $match); |
|
1113 | 1113 | |
1114 | 1114 | // Add a rule for at attachments, which take the form of <permalink>/some-text. |
1115 | - $sub1 = $submatchbase . '/([^/]+)/'; |
|
1115 | + $sub1 = $submatchbase.'/([^/]+)/'; |
|
1116 | 1116 | |
1117 | 1117 | // Add trackback regex <permalink>/trackback/... |
1118 | - $sub1tb = $sub1 . $trackbackregex; |
|
1118 | + $sub1tb = $sub1.$trackbackregex; |
|
1119 | 1119 | |
1120 | 1120 | // And <permalink>/feed/(atom|...) |
1121 | - $sub1feed = $sub1 . $feedregex; |
|
1121 | + $sub1feed = $sub1.$feedregex; |
|
1122 | 1122 | |
1123 | 1123 | // And <permalink>/(feed|atom...) |
1124 | - $sub1feed2 = $sub1 . $feedregex2; |
|
1124 | + $sub1feed2 = $sub1.$feedregex2; |
|
1125 | 1125 | |
1126 | 1126 | // And <permalink>/comment-page-xx |
1127 | - $sub1comment = $sub1 . $commentregex; |
|
1127 | + $sub1comment = $sub1.$commentregex; |
|
1128 | 1128 | |
1129 | 1129 | // And <permalink>/embed/... |
1130 | - $sub1embed = $sub1 . $embedregex; |
|
1130 | + $sub1embed = $sub1.$embedregex; |
|
1131 | 1131 | |
1132 | 1132 | /* |
1133 | 1133 | * Add another rule to match attachments in the explicit form: |
1134 | 1134 | * <permalink>/attachment/some-text |
1135 | 1135 | */ |
1136 | - $sub2 = $submatchbase . '/attachment/([^/]+)/'; |
|
1136 | + $sub2 = $submatchbase.'/attachment/([^/]+)/'; |
|
1137 | 1137 | |
1138 | 1138 | // And add trackbacks <permalink>/attachment/trackback. |
1139 | - $sub2tb = $sub2 . $trackbackregex; |
|
1139 | + $sub2tb = $sub2.$trackbackregex; |
|
1140 | 1140 | |
1141 | 1141 | // Feeds, <permalink>/attachment/feed/(atom|...) |
1142 | - $sub2feed = $sub2 . $feedregex; |
|
1142 | + $sub2feed = $sub2.$feedregex; |
|
1143 | 1143 | |
1144 | 1144 | // And feeds again on to this <permalink>/attachment/(feed|atom...) |
1145 | - $sub2feed2 = $sub2 . $feedregex2; |
|
1145 | + $sub2feed2 = $sub2.$feedregex2; |
|
1146 | 1146 | |
1147 | 1147 | // And <permalink>/comment-page-xx |
1148 | - $sub2comment = $sub2 . $commentregex; |
|
1148 | + $sub2comment = $sub2.$commentregex; |
|
1149 | 1149 | |
1150 | 1150 | // And <permalink>/embed/... |
1151 | - $sub2embed = $sub2 . $embedregex; |
|
1151 | + $sub2embed = $sub2.$embedregex; |
|
1152 | 1152 | |
1153 | 1153 | // Create queries for these extra tag-ons we've just dealt with. |
1154 | - $subquery = $index . '?attachment=' . $this->preg_index(1); |
|
1155 | - $subtbquery = $subquery . '&tb=1'; |
|
1156 | - $subfeedquery = $subquery . '&feed=' . $this->preg_index(2); |
|
1157 | - $subcommentquery = $subquery . '&cpage=' . $this->preg_index(2); |
|
1158 | - $subembedquery = $subquery . '&embed=true'; |
|
1154 | + $subquery = $index.'?attachment='.$this->preg_index(1); |
|
1155 | + $subtbquery = $subquery.'&tb=1'; |
|
1156 | + $subfeedquery = $subquery.'&feed='.$this->preg_index(2); |
|
1157 | + $subcommentquery = $subquery.'&cpage='.$this->preg_index(2); |
|
1158 | + $subembedquery = $subquery.'&embed=true'; |
|
1159 | 1159 | |
1160 | 1160 | // Do endpoints for attachments. |
1161 | - if ( !empty($endpoints) ) { |
|
1162 | - foreach ( (array) $ep_query_append as $regex => $ep ) { |
|
1163 | - if ( $ep[0] & EP_ATTACHMENT ) { |
|
1164 | - $rewrite[$sub1 . $regex] = $subquery . $ep[1] . $this->preg_index(3); |
|
1165 | - $rewrite[$sub2 . $regex] = $subquery . $ep[1] . $this->preg_index(3); |
|
1161 | + if ( ! empty($endpoints)) { |
|
1162 | + foreach ((array) $ep_query_append as $regex => $ep) { |
|
1163 | + if ($ep[0] & EP_ATTACHMENT) { |
|
1164 | + $rewrite[$sub1.$regex] = $subquery.$ep[1].$this->preg_index(3); |
|
1165 | + $rewrite[$sub2.$regex] = $subquery.$ep[1].$this->preg_index(3); |
|
1166 | 1166 | } |
1167 | 1167 | } |
1168 | 1168 | } |
@@ -1180,14 +1180,14 @@ discard block |
||
1180 | 1180 | * Previously: '(/[0-9]+)?/?$', which produced '/2' for page. |
1181 | 1181 | * When cast to int, returned 0. |
1182 | 1182 | */ |
1183 | - $match = $match . '(?:/([0-9]+))?/?$'; |
|
1184 | - $query = $index . '?' . $query . '&page=' . $this->preg_index($num_toks + 1); |
|
1183 | + $match = $match.'(?:/([0-9]+))?/?$'; |
|
1184 | + $query = $index.'?'.$query.'&page='.$this->preg_index($num_toks + 1); |
|
1185 | 1185 | |
1186 | 1186 | // Not matching a permalink so this is a lot simpler. |
1187 | 1187 | } else { |
1188 | 1188 | // Close the match and finalise the query. |
1189 | 1189 | $match .= '?$'; |
1190 | - $query = $index . '?' . $query; |
|
1190 | + $query = $index.'?'.$query; |
|
1191 | 1191 | } |
1192 | 1192 | |
1193 | 1193 | /* |
@@ -1198,27 +1198,27 @@ discard block |
||
1198 | 1198 | $rewrite = array_merge($rewrite, array($match => $query)); |
1199 | 1199 | |
1200 | 1200 | // If we're matching a permalink, add those extras (attachments etc) on. |
1201 | - if ( $post ) { |
|
1201 | + if ($post) { |
|
1202 | 1202 | // Add trackback. |
1203 | 1203 | $rewrite = array_merge(array($trackbackmatch => $trackbackquery), $rewrite); |
1204 | 1204 | |
1205 | 1205 | // Add embed. |
1206 | - $rewrite = array_merge( array( $embedmatch => $embedquery ), $rewrite ); |
|
1206 | + $rewrite = array_merge(array($embedmatch => $embedquery), $rewrite); |
|
1207 | 1207 | |
1208 | 1208 | // Add regexes/queries for attachments, attachment trackbacks and so on. |
1209 | - if ( ! $page ) { |
|
1209 | + if ( ! $page) { |
|
1210 | 1210 | // Require <permalink>/attachment/stuff form for pages because of confusion with subpages. |
1211 | - $rewrite = array_merge( $rewrite, array( |
|
1211 | + $rewrite = array_merge($rewrite, array( |
|
1212 | 1212 | $sub1 => $subquery, |
1213 | 1213 | $sub1tb => $subtbquery, |
1214 | 1214 | $sub1feed => $subfeedquery, |
1215 | 1215 | $sub1feed2 => $subfeedquery, |
1216 | 1216 | $sub1comment => $subcommentquery, |
1217 | 1217 | $sub1embed => $subembedquery |
1218 | - ) ); |
|
1218 | + )); |
|
1219 | 1219 | } |
1220 | 1220 | |
1221 | - $rewrite = array_merge( array( $sub2 => $subquery, $sub2tb => $subtbquery, $sub2feed => $subfeedquery, $sub2feed2 => $subfeedquery, $sub2comment => $subcommentquery, $sub2embed => $subembedquery ), $rewrite ); |
|
1221 | + $rewrite = array_merge(array($sub2 => $subquery, $sub2tb => $subtbquery, $sub2feed => $subfeedquery, $sub2feed2 => $subfeedquery, $sub2comment => $subcommentquery, $sub2embed => $subembedquery), $rewrite); |
|
1222 | 1222 | } |
1223 | 1223 | } |
1224 | 1224 | // Add the rules for this dir to the accumulating $post_rewrite. |
@@ -1270,31 +1270,31 @@ discard block |
||
1270 | 1270 | public function rewrite_rules() { |
1271 | 1271 | $rewrite = array(); |
1272 | 1272 | |
1273 | - if ( empty($this->permalink_structure) ) |
|
1273 | + if (empty($this->permalink_structure)) |
|
1274 | 1274 | return $rewrite; |
1275 | 1275 | |
1276 | 1276 | // robots.txt -only if installed at the root |
1277 | - $home_path = parse_url( home_url() ); |
|
1278 | - $robots_rewrite = ( empty( $home_path['path'] ) || '/' == $home_path['path'] ) ? array( 'robots\.txt$' => $this->index . '?robots=1' ) : array(); |
|
1277 | + $home_path = parse_url(home_url()); |
|
1278 | + $robots_rewrite = (empty($home_path['path']) || '/' == $home_path['path']) ? array('robots\.txt$' => $this->index.'?robots=1') : array(); |
|
1279 | 1279 | |
1280 | 1280 | // Old feed and service files. |
1281 | 1281 | $deprecated_files = array( |
1282 | - '.*wp-(atom|rdf|rss|rss2|feed|commentsrss2)\.php$' => $this->index . '?feed=old', |
|
1283 | - '.*wp-app\.php(/.*)?$' => $this->index . '?error=403', |
|
1282 | + '.*wp-(atom|rdf|rss|rss2|feed|commentsrss2)\.php$' => $this->index.'?feed=old', |
|
1283 | + '.*wp-app\.php(/.*)?$' => $this->index.'?error=403', |
|
1284 | 1284 | ); |
1285 | 1285 | |
1286 | 1286 | // Registration rules. |
1287 | 1287 | $registration_pages = array(); |
1288 | - if ( is_multisite() && is_main_site() ) { |
|
1289 | - $registration_pages['.*wp-signup.php$'] = $this->index . '?signup=true'; |
|
1290 | - $registration_pages['.*wp-activate.php$'] = $this->index . '?activate=true'; |
|
1288 | + if (is_multisite() && is_main_site()) { |
|
1289 | + $registration_pages['.*wp-signup.php$'] = $this->index.'?signup=true'; |
|
1290 | + $registration_pages['.*wp-activate.php$'] = $this->index.'?activate=true'; |
|
1291 | 1291 | } |
1292 | 1292 | |
1293 | 1293 | // Deprecated. |
1294 | - $registration_pages['.*wp-register.php$'] = $this->index . '?register=true'; |
|
1294 | + $registration_pages['.*wp-register.php$'] = $this->index.'?register=true'; |
|
1295 | 1295 | |
1296 | 1296 | // Post rewrite rules. |
1297 | - $post_rewrite = $this->generate_rewrite_rules( $this->permalink_structure, EP_PERMALINK ); |
|
1297 | + $post_rewrite = $this->generate_rewrite_rules($this->permalink_structure, EP_PERMALINK); |
|
1298 | 1298 | |
1299 | 1299 | /** |
1300 | 1300 | * Filters rewrite rules used for "post" archives. |
@@ -1303,7 +1303,7 @@ discard block |
||
1303 | 1303 | * |
1304 | 1304 | * @param array $post_rewrite The rewrite rules for posts. |
1305 | 1305 | */ |
1306 | - $post_rewrite = apply_filters( 'post_rewrite_rules', $post_rewrite ); |
|
1306 | + $post_rewrite = apply_filters('post_rewrite_rules', $post_rewrite); |
|
1307 | 1307 | |
1308 | 1308 | // Date rewrite rules. |
1309 | 1309 | $date_rewrite = $this->generate_rewrite_rules($this->get_date_permastruct(), EP_DATE); |
@@ -1317,10 +1317,10 @@ discard block |
||
1317 | 1317 | * |
1318 | 1318 | * @param array $date_rewrite The rewrite rules for date archives. |
1319 | 1319 | */ |
1320 | - $date_rewrite = apply_filters( 'date_rewrite_rules', $date_rewrite ); |
|
1320 | + $date_rewrite = apply_filters('date_rewrite_rules', $date_rewrite); |
|
1321 | 1321 | |
1322 | 1322 | // Root-level rewrite rules. |
1323 | - $root_rewrite = $this->generate_rewrite_rules($this->root . '/', EP_ROOT); |
|
1323 | + $root_rewrite = $this->generate_rewrite_rules($this->root.'/', EP_ROOT); |
|
1324 | 1324 | |
1325 | 1325 | /** |
1326 | 1326 | * Filters rewrite rules used for root-level archives. |
@@ -1332,10 +1332,10 @@ discard block |
||
1332 | 1332 | * |
1333 | 1333 | * @param array $root_rewrite The root-level rewrite rules. |
1334 | 1334 | */ |
1335 | - $root_rewrite = apply_filters( 'root_rewrite_rules', $root_rewrite ); |
|
1335 | + $root_rewrite = apply_filters('root_rewrite_rules', $root_rewrite); |
|
1336 | 1336 | |
1337 | 1337 | // Comments rewrite rules. |
1338 | - $comments_rewrite = $this->generate_rewrite_rules($this->root . $this->comments_base, EP_COMMENTS, false, true, true, false); |
|
1338 | + $comments_rewrite = $this->generate_rewrite_rules($this->root.$this->comments_base, EP_COMMENTS, false, true, true, false); |
|
1339 | 1339 | |
1340 | 1340 | /** |
1341 | 1341 | * Filters rewrite rules used for comment feed archives. |
@@ -1346,7 +1346,7 @@ discard block |
||
1346 | 1346 | * |
1347 | 1347 | * @param array $comments_rewrite The rewrite rules for the site-wide comments feeds. |
1348 | 1348 | */ |
1349 | - $comments_rewrite = apply_filters( 'comments_rewrite_rules', $comments_rewrite ); |
|
1349 | + $comments_rewrite = apply_filters('comments_rewrite_rules', $comments_rewrite); |
|
1350 | 1350 | |
1351 | 1351 | // Search rewrite rules. |
1352 | 1352 | $search_structure = $this->get_search_permastruct(); |
@@ -1362,7 +1362,7 @@ discard block |
||
1362 | 1362 | * |
1363 | 1363 | * @param array $search_rewrite The rewrite rules for search queries. |
1364 | 1364 | */ |
1365 | - $search_rewrite = apply_filters( 'search_rewrite_rules', $search_rewrite ); |
|
1365 | + $search_rewrite = apply_filters('search_rewrite_rules', $search_rewrite); |
|
1366 | 1366 | |
1367 | 1367 | // Author rewrite rules. |
1368 | 1368 | $author_rewrite = $this->generate_rewrite_rules($this->get_author_permastruct(), EP_AUTHORS); |
@@ -1377,7 +1377,7 @@ discard block |
||
1377 | 1377 | * |
1378 | 1378 | * @param array $author_rewrite The rewrite rules for author archives. |
1379 | 1379 | */ |
1380 | - $author_rewrite = apply_filters( 'author_rewrite_rules', $author_rewrite ); |
|
1380 | + $author_rewrite = apply_filters('author_rewrite_rules', $author_rewrite); |
|
1381 | 1381 | |
1382 | 1382 | // Pages rewrite rules. |
1383 | 1383 | $page_rewrite = $this->page_rewrite_rules(); |
@@ -1389,17 +1389,17 @@ discard block |
||
1389 | 1389 | * |
1390 | 1390 | * @param array $page_rewrite The rewrite rules for the "page" post type. |
1391 | 1391 | */ |
1392 | - $page_rewrite = apply_filters( 'page_rewrite_rules', $page_rewrite ); |
|
1392 | + $page_rewrite = apply_filters('page_rewrite_rules', $page_rewrite); |
|
1393 | 1393 | |
1394 | 1394 | // Extra permastructs. |
1395 | - foreach ( $this->extra_permastructs as $permastructname => $struct ) { |
|
1396 | - if ( is_array( $struct ) ) { |
|
1397 | - if ( count( $struct ) == 2 ) |
|
1398 | - $rules = $this->generate_rewrite_rules( $struct[0], $struct[1] ); |
|
1395 | + foreach ($this->extra_permastructs as $permastructname => $struct) { |
|
1396 | + if (is_array($struct)) { |
|
1397 | + if (count($struct) == 2) |
|
1398 | + $rules = $this->generate_rewrite_rules($struct[0], $struct[1]); |
|
1399 | 1399 | else |
1400 | - $rules = $this->generate_rewrite_rules( $struct['struct'], $struct['ep_mask'], $struct['paged'], $struct['feed'], $struct['forcomments'], $struct['walk_dirs'], $struct['endpoints'] ); |
|
1400 | + $rules = $this->generate_rewrite_rules($struct['struct'], $struct['ep_mask'], $struct['paged'], $struct['feed'], $struct['forcomments'], $struct['walk_dirs'], $struct['endpoints']); |
|
1401 | 1401 | } else { |
1402 | - $rules = $this->generate_rewrite_rules( $struct ); |
|
1402 | + $rules = $this->generate_rewrite_rules($struct); |
|
1403 | 1403 | } |
1404 | 1404 | |
1405 | 1405 | /** |
@@ -1413,8 +1413,8 @@ discard block |
||
1413 | 1413 | * |
1414 | 1414 | * @param array $rules The rewrite rules generated for the current permastruct. |
1415 | 1415 | */ |
1416 | - $rules = apply_filters( "{$permastructname}_rewrite_rules", $rules ); |
|
1417 | - if ( 'post_tag' == $permastructname ) { |
|
1416 | + $rules = apply_filters("{$permastructname}_rewrite_rules", $rules); |
|
1417 | + if ('post_tag' == $permastructname) { |
|
1418 | 1418 | |
1419 | 1419 | /** |
1420 | 1420 | * Filters rewrite rules used specifically for Tags. |
@@ -1424,17 +1424,17 @@ discard block |
||
1424 | 1424 | * |
1425 | 1425 | * @param array $rules The rewrite rules generated for tags. |
1426 | 1426 | */ |
1427 | - $rules = apply_filters( 'tag_rewrite_rules', $rules ); |
|
1427 | + $rules = apply_filters('tag_rewrite_rules', $rules); |
|
1428 | 1428 | } |
1429 | 1429 | |
1430 | 1430 | $this->extra_rules_top = array_merge($this->extra_rules_top, $rules); |
1431 | 1431 | } |
1432 | 1432 | |
1433 | 1433 | // Put them together. |
1434 | - if ( $this->use_verbose_page_rules ) |
|
1435 | - $this->rules = array_merge($this->extra_rules_top, $robots_rewrite, $deprecated_files, $registration_pages, $root_rewrite, $comments_rewrite, $search_rewrite, $author_rewrite, $date_rewrite, $page_rewrite, $post_rewrite, $this->extra_rules); |
|
1434 | + if ($this->use_verbose_page_rules) |
|
1435 | + $this->rules = array_merge($this->extra_rules_top, $robots_rewrite, $deprecated_files, $registration_pages, $root_rewrite, $comments_rewrite, $search_rewrite, $author_rewrite, $date_rewrite, $page_rewrite, $post_rewrite, $this->extra_rules); |
|
1436 | 1436 | else |
1437 | - $this->rules = array_merge($this->extra_rules_top, $robots_rewrite, $deprecated_files, $registration_pages, $root_rewrite, $comments_rewrite, $search_rewrite, $author_rewrite, $date_rewrite, $post_rewrite, $page_rewrite, $this->extra_rules); |
|
1437 | + $this->rules = array_merge($this->extra_rules_top, $robots_rewrite, $deprecated_files, $registration_pages, $root_rewrite, $comments_rewrite, $search_rewrite, $author_rewrite, $date_rewrite, $post_rewrite, $page_rewrite, $this->extra_rules); |
|
1438 | 1438 | |
1439 | 1439 | /** |
1440 | 1440 | * Fires after the rewrite rules are generated. |
@@ -1443,7 +1443,7 @@ discard block |
||
1443 | 1443 | * |
1444 | 1444 | * @param WP_Rewrite $this Current WP_Rewrite instance, passed by reference. |
1445 | 1445 | */ |
1446 | - do_action_ref_array( 'generate_rewrite_rules', array( &$this ) ); |
|
1446 | + do_action_ref_array('generate_rewrite_rules', array(&$this)); |
|
1447 | 1447 | |
1448 | 1448 | /** |
1449 | 1449 | * Filters the full set of generated rewrite rules. |
@@ -1452,7 +1452,7 @@ discard block |
||
1452 | 1452 | * |
1453 | 1453 | * @param array $this->rules The compiled array of rewrite rules. |
1454 | 1454 | */ |
1455 | - $this->rules = apply_filters( 'rewrite_rules_array', $this->rules ); |
|
1455 | + $this->rules = apply_filters('rewrite_rules_array', $this->rules); |
|
1456 | 1456 | |
1457 | 1457 | return $this->rules; |
1458 | 1458 | } |
@@ -1472,11 +1472,11 @@ discard block |
||
1472 | 1472 | */ |
1473 | 1473 | public function wp_rewrite_rules() { |
1474 | 1474 | $this->rules = get_option('rewrite_rules'); |
1475 | - if ( empty($this->rules) ) { |
|
1475 | + if (empty($this->rules)) { |
|
1476 | 1476 | $this->matches = 'matches'; |
1477 | 1477 | $this->rewrite_rules(); |
1478 | - if ( ! did_action( 'wp_loaded' ) ) { |
|
1479 | - add_action( 'wp_loaded', array( $this, 'flush_rules' ) ); |
|
1478 | + if ( ! did_action('wp_loaded')) { |
|
1479 | + add_action('wp_loaded', array($this, 'flush_rules')); |
|
1480 | 1480 | return $this->rules; |
1481 | 1481 | } |
1482 | 1482 | update_option('rewrite_rules', $this->rules); |
@@ -1500,15 +1500,15 @@ discard block |
||
1500 | 1500 | * @return string |
1501 | 1501 | */ |
1502 | 1502 | public function mod_rewrite_rules() { |
1503 | - if ( ! $this->using_permalinks() ) |
|
1503 | + if ( ! $this->using_permalinks()) |
|
1504 | 1504 | return ''; |
1505 | 1505 | |
1506 | - $site_root = parse_url( site_url() ); |
|
1507 | - if ( isset( $site_root['path'] ) ) |
|
1506 | + $site_root = parse_url(site_url()); |
|
1507 | + if (isset($site_root['path'])) |
|
1508 | 1508 | $site_root = trailingslashit($site_root['path']); |
1509 | 1509 | |
1510 | 1510 | $home_root = parse_url(home_url()); |
1511 | - if ( isset( $home_root['path'] ) ) |
|
1511 | + if (isset($home_root['path'])) |
|
1512 | 1512 | $home_root = trailingslashit($home_root['path']); |
1513 | 1513 | else |
1514 | 1514 | $home_root = '/'; |
@@ -1521,33 +1521,33 @@ discard block |
||
1521 | 1521 | $rules .= "RewriteRule ^index\.php$ - [L]\n"; |
1522 | 1522 | |
1523 | 1523 | // Add in the rules that don't redirect to WP's index.php (and thus shouldn't be handled by WP at all). |
1524 | - foreach ( (array) $this->non_wp_rules as $match => $query) { |
|
1524 | + foreach ((array) $this->non_wp_rules as $match => $query) { |
|
1525 | 1525 | // Apache 1.3 does not support the reluctant (non-greedy) modifier. |
1526 | 1526 | $match = str_replace('.+?', '.+', $match); |
1527 | 1527 | |
1528 | - $rules .= 'RewriteRule ^' . $match . ' ' . $home_root . $query . " [QSA,L]\n"; |
|
1528 | + $rules .= 'RewriteRule ^'.$match.' '.$home_root.$query." [QSA,L]\n"; |
|
1529 | 1529 | } |
1530 | 1530 | |
1531 | - if ( $this->use_verbose_rules ) { |
|
1531 | + if ($this->use_verbose_rules) { |
|
1532 | 1532 | $this->matches = ''; |
1533 | 1533 | $rewrite = $this->rewrite_rules(); |
1534 | 1534 | $num_rules = count($rewrite); |
1535 | - $rules .= "RewriteCond %{REQUEST_FILENAME} -f [OR]\n" . |
|
1536 | - "RewriteCond %{REQUEST_FILENAME} -d\n" . |
|
1535 | + $rules .= "RewriteCond %{REQUEST_FILENAME} -f [OR]\n". |
|
1536 | + "RewriteCond %{REQUEST_FILENAME} -d\n". |
|
1537 | 1537 | "RewriteRule ^.*$ - [S=$num_rules]\n"; |
1538 | 1538 | |
1539 | - foreach ( (array) $rewrite as $match => $query) { |
|
1539 | + foreach ((array) $rewrite as $match => $query) { |
|
1540 | 1540 | // Apache 1.3 does not support the reluctant (non-greedy) modifier. |
1541 | 1541 | $match = str_replace('.+?', '.+', $match); |
1542 | 1542 | |
1543 | - if ( strpos($query, $this->index) !== false ) |
|
1544 | - $rules .= 'RewriteRule ^' . $match . ' ' . $home_root . $query . " [QSA,L]\n"; |
|
1543 | + if (strpos($query, $this->index) !== false) |
|
1544 | + $rules .= 'RewriteRule ^'.$match.' '.$home_root.$query." [QSA,L]\n"; |
|
1545 | 1545 | else |
1546 | - $rules .= 'RewriteRule ^' . $match . ' ' . $site_root . $query . " [QSA,L]\n"; |
|
1546 | + $rules .= 'RewriteRule ^'.$match.' '.$site_root.$query." [QSA,L]\n"; |
|
1547 | 1547 | } |
1548 | 1548 | } else { |
1549 | - $rules .= "RewriteCond %{REQUEST_FILENAME} !-f\n" . |
|
1550 | - "RewriteCond %{REQUEST_FILENAME} !-d\n" . |
|
1549 | + $rules .= "RewriteCond %{REQUEST_FILENAME} !-f\n". |
|
1550 | + "RewriteCond %{REQUEST_FILENAME} !-d\n". |
|
1551 | 1551 | "RewriteRule . {$home_root}{$this->index} [L]\n"; |
1552 | 1552 | } |
1553 | 1553 | |
@@ -1560,7 +1560,7 @@ discard block |
||
1560 | 1560 | * |
1561 | 1561 | * @param string $rules mod_rewrite Rewrite rules formatted for .htaccess. |
1562 | 1562 | */ |
1563 | - $rules = apply_filters( 'mod_rewrite_rules', $rules ); |
|
1563 | + $rules = apply_filters('mod_rewrite_rules', $rules); |
|
1564 | 1564 | |
1565 | 1565 | /** |
1566 | 1566 | * Filters the list of rewrite rules formatted for output to an .htaccess file. |
@@ -1570,7 +1570,7 @@ discard block |
||
1570 | 1570 | * |
1571 | 1571 | * @param string $rules mod_rewrite Rewrite rules formatted for .htaccess. |
1572 | 1572 | */ |
1573 | - return apply_filters( 'rewrite_rules', $rules ); |
|
1573 | + return apply_filters('rewrite_rules', $rules); |
|
1574 | 1574 | } |
1575 | 1575 | |
1576 | 1576 | /** |
@@ -1586,11 +1586,11 @@ discard block |
||
1586 | 1586 | * Default false. |
1587 | 1587 | * @return string IIS7 URL rewrite rule sets. |
1588 | 1588 | */ |
1589 | - public function iis7_url_rewrite_rules( $add_parent_tags = false ) { |
|
1590 | - if ( ! $this->using_permalinks() ) |
|
1589 | + public function iis7_url_rewrite_rules($add_parent_tags = false) { |
|
1590 | + if ( ! $this->using_permalinks()) |
|
1591 | 1591 | return ''; |
1592 | 1592 | $rules = ''; |
1593 | - if ( $add_parent_tags ) { |
|
1593 | + if ($add_parent_tags) { |
|
1594 | 1594 | $rules .= '<configuration> |
1595 | 1595 | <system.webServer> |
1596 | 1596 | <rewrite> |
@@ -1598,7 +1598,7 @@ discard block |
||
1598 | 1598 | } |
1599 | 1599 | |
1600 | 1600 | $rules .= ' |
1601 | - <rule name="WordPress: ' . esc_attr( home_url() ) . '" patternSyntax="Wildcard"> |
|
1601 | + <rule name="WordPress: ' . esc_attr(home_url()).'" patternSyntax="Wildcard"> |
|
1602 | 1602 | <match url="*" /> |
1603 | 1603 | <conditions> |
1604 | 1604 | <add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" /> |
@@ -1607,7 +1607,7 @@ discard block |
||
1607 | 1607 | <action type="Rewrite" url="index.php" /> |
1608 | 1608 | </rule>'; |
1609 | 1609 | |
1610 | - if ( $add_parent_tags ) { |
|
1610 | + if ($add_parent_tags) { |
|
1611 | 1611 | $rules .= ' |
1612 | 1612 | </rules> |
1613 | 1613 | </rewrite> |
@@ -1622,7 +1622,7 @@ discard block |
||
1622 | 1622 | * |
1623 | 1623 | * @param string $rules Rewrite rules formatted for IIS web.config. |
1624 | 1624 | */ |
1625 | - return apply_filters( 'iis7_url_rewrite_rules', $rules ); |
|
1625 | + return apply_filters('iis7_url_rewrite_rules', $rules); |
|
1626 | 1626 | } |
1627 | 1627 | |
1628 | 1628 | /** |
@@ -1640,25 +1640,25 @@ discard block |
||
1640 | 1640 | * @param string $after Optional. Priority of the new rule. Accepts 'top' |
1641 | 1641 | * or 'bottom'. Default 'bottom'. |
1642 | 1642 | */ |
1643 | - public function add_rule( $regex, $query, $after = 'bottom' ) { |
|
1644 | - if ( is_array( $query ) ) { |
|
1643 | + public function add_rule($regex, $query, $after = 'bottom') { |
|
1644 | + if (is_array($query)) { |
|
1645 | 1645 | $external = false; |
1646 | - $query = add_query_arg( $query, 'index.php' ); |
|
1646 | + $query = add_query_arg($query, 'index.php'); |
|
1647 | 1647 | } else { |
1648 | - $index = false === strpos( $query, '?' ) ? strlen( $query ) : strpos( $query, '?' ); |
|
1649 | - $front = substr( $query, 0, $index ); |
|
1648 | + $index = false === strpos($query, '?') ? strlen($query) : strpos($query, '?'); |
|
1649 | + $front = substr($query, 0, $index); |
|
1650 | 1650 | |
1651 | 1651 | $external = $front != $this->index; |
1652 | 1652 | } |
1653 | 1653 | |
1654 | 1654 | // "external" = it doesn't correspond to index.php. |
1655 | - if ( $external ) { |
|
1656 | - $this->add_external_rule( $regex, $query ); |
|
1655 | + if ($external) { |
|
1656 | + $this->add_external_rule($regex, $query); |
|
1657 | 1657 | } else { |
1658 | - if ( 'bottom' == $after ) { |
|
1659 | - $this->extra_rules = array_merge( $this->extra_rules, array( $regex => $query ) ); |
|
1658 | + if ('bottom' == $after) { |
|
1659 | + $this->extra_rules = array_merge($this->extra_rules, array($regex => $query)); |
|
1660 | 1660 | } else { |
1661 | - $this->extra_rules_top = array_merge( $this->extra_rules_top, array( $regex => $query ) ); |
|
1661 | + $this->extra_rules_top = array_merge($this->extra_rules_top, array($regex => $query)); |
|
1662 | 1662 | } |
1663 | 1663 | } |
1664 | 1664 | } |
@@ -1672,8 +1672,8 @@ discard block |
||
1672 | 1672 | * @param string $regex Regular expression to match request against. |
1673 | 1673 | * @param string $query The corresponding query vars for this rewrite rule. |
1674 | 1674 | */ |
1675 | - public function add_external_rule( $regex, $query ) { |
|
1676 | - $this->non_wp_rules[ $regex ] = $query; |
|
1675 | + public function add_external_rule($regex, $query) { |
|
1676 | + $this->non_wp_rules[$regex] = $query; |
|
1677 | 1677 | } |
1678 | 1678 | |
1679 | 1679 | /** |
@@ -1693,17 +1693,17 @@ discard block |
||
1693 | 1693 | * skip registering a query_var for this endpoint. Defaults to the |
1694 | 1694 | * value of `$name`. |
1695 | 1695 | */ |
1696 | - public function add_endpoint( $name, $places, $query_var = true ) { |
|
1696 | + public function add_endpoint($name, $places, $query_var = true) { |
|
1697 | 1697 | global $wp; |
1698 | 1698 | |
1699 | 1699 | // For backward compatibility, if null has explicitly been passed as `$query_var`, assume `true`. |
1700 | - if ( true === $query_var || null === func_get_arg( 2 ) ) { |
|
1700 | + if (true === $query_var || null === func_get_arg(2)) { |
|
1701 | 1701 | $query_var = $name; |
1702 | 1702 | } |
1703 | - $this->endpoints[] = array( $places, $name, $query_var ); |
|
1703 | + $this->endpoints[] = array($places, $name, $query_var); |
|
1704 | 1704 | |
1705 | - if ( $query_var ) { |
|
1706 | - $wp->add_query_var( $query_var ); |
|
1705 | + if ($query_var) { |
|
1706 | + $wp->add_query_var($query_var); |
|
1707 | 1707 | } |
1708 | 1708 | } |
1709 | 1709 | |
@@ -1746,12 +1746,12 @@ discard block |
||
1746 | 1746 | * @type bool $endpoints Whether endpoints should be applied to the generated rules. Default true. |
1747 | 1747 | * } |
1748 | 1748 | */ |
1749 | - public function add_permastruct( $name, $struct, $args = array() ) { |
|
1749 | + public function add_permastruct($name, $struct, $args = array()) { |
|
1750 | 1750 | // Back-compat for the old parameters: $with_front and $ep_mask. |
1751 | - if ( ! is_array( $args ) ) |
|
1752 | - $args = array( 'with_front' => $args ); |
|
1753 | - if ( func_num_args() == 4 ) |
|
1754 | - $args['ep_mask'] = func_get_arg( 3 ); |
|
1751 | + if ( ! is_array($args)) |
|
1752 | + $args = array('with_front' => $args); |
|
1753 | + if (func_num_args() == 4) |
|
1754 | + $args['ep_mask'] = func_get_arg(3); |
|
1755 | 1755 | |
1756 | 1756 | $defaults = array( |
1757 | 1757 | 'with_front' => true, |
@@ -1762,16 +1762,16 @@ discard block |
||
1762 | 1762 | 'walk_dirs' => true, |
1763 | 1763 | 'endpoints' => true, |
1764 | 1764 | ); |
1765 | - $args = array_intersect_key( $args, $defaults ); |
|
1766 | - $args = wp_parse_args( $args, $defaults ); |
|
1765 | + $args = array_intersect_key($args, $defaults); |
|
1766 | + $args = wp_parse_args($args, $defaults); |
|
1767 | 1767 | |
1768 | - if ( $args['with_front'] ) |
|
1769 | - $struct = $this->front . $struct; |
|
1768 | + if ($args['with_front']) |
|
1769 | + $struct = $this->front.$struct; |
|
1770 | 1770 | else |
1771 | - $struct = $this->root . $struct; |
|
1771 | + $struct = $this->root.$struct; |
|
1772 | 1772 | $args['struct'] = $struct; |
1773 | 1773 | |
1774 | - $this->extra_permastructs[ $name ] = $args; |
|
1774 | + $this->extra_permastructs[$name] = $args; |
|
1775 | 1775 | } |
1776 | 1776 | |
1777 | 1777 | /** |
@@ -1782,8 +1782,8 @@ discard block |
||
1782 | 1782 | * |
1783 | 1783 | * @param string $name Name for permalink structure. |
1784 | 1784 | */ |
1785 | - public function remove_permastruct( $name ) { |
|
1786 | - unset( $this->extra_permastructs[ $name ] ); |
|
1785 | + public function remove_permastruct($name) { |
|
1786 | + unset($this->extra_permastructs[$name]); |
|
1787 | 1787 | } |
1788 | 1788 | |
1789 | 1789 | /** |
@@ -1799,22 +1799,22 @@ discard block |
||
1799 | 1799 | * |
1800 | 1800 | * @param bool $hard Whether to update .htaccess (hard flush) or just update rewrite_rules option (soft flush). Default is true (hard). |
1801 | 1801 | */ |
1802 | - public function flush_rules( $hard = true ) { |
|
1802 | + public function flush_rules($hard = true) { |
|
1803 | 1803 | static $do_hard_later = null; |
1804 | 1804 | |
1805 | 1805 | // Prevent this action from running before everyone has registered their rewrites. |
1806 | - if ( ! did_action( 'wp_loaded' ) ) { |
|
1807 | - add_action( 'wp_loaded', array( $this, 'flush_rules' ) ); |
|
1808 | - $do_hard_later = ( isset( $do_hard_later ) ) ? $do_hard_later || $hard : $hard; |
|
1806 | + if ( ! did_action('wp_loaded')) { |
|
1807 | + add_action('wp_loaded', array($this, 'flush_rules')); |
|
1808 | + $do_hard_later = (isset($do_hard_later)) ? $do_hard_later || $hard : $hard; |
|
1809 | 1809 | return; |
1810 | 1810 | } |
1811 | 1811 | |
1812 | - if ( isset( $do_hard_later ) ) { |
|
1812 | + if (isset($do_hard_later)) { |
|
1813 | 1813 | $hard = $do_hard_later; |
1814 | - unset( $do_hard_later ); |
|
1814 | + unset($do_hard_later); |
|
1815 | 1815 | } |
1816 | 1816 | |
1817 | - update_option( 'rewrite_rules', '' ); |
|
1817 | + update_option('rewrite_rules', ''); |
|
1818 | 1818 | $this->wp_rewrite_rules(); |
1819 | 1819 | |
1820 | 1820 | /** |
@@ -1826,12 +1826,12 @@ discard block |
||
1826 | 1826 | * |
1827 | 1827 | * @param bool $hard Whether to flush rewrite rules "hard". Default true. |
1828 | 1828 | */ |
1829 | - if ( ! $hard || ! apply_filters( 'flush_rewrite_rules_hard', true ) ) { |
|
1829 | + if ( ! $hard || ! apply_filters('flush_rewrite_rules_hard', true)) { |
|
1830 | 1830 | return; |
1831 | 1831 | } |
1832 | - if ( function_exists( 'save_mod_rewrite_rules' ) ) |
|
1832 | + if (function_exists('save_mod_rewrite_rules')) |
|
1833 | 1833 | save_mod_rewrite_rules(); |
1834 | - if ( function_exists( 'iis7_save_url_rewrite_rules' ) ) |
|
1834 | + if (function_exists('iis7_save_url_rewrite_rules')) |
|
1835 | 1835 | iis7_save_url_rewrite_rules(); |
1836 | 1836 | } |
1837 | 1837 | |
@@ -1851,8 +1851,8 @@ discard block |
||
1851 | 1851 | $this->front = substr($this->permalink_structure, 0, strpos($this->permalink_structure, '%')); |
1852 | 1852 | $this->root = ''; |
1853 | 1853 | |
1854 | - if ( $this->using_index_permalinks() ) |
|
1855 | - $this->root = $this->index . '/'; |
|
1854 | + if ($this->using_index_permalinks()) |
|
1855 | + $this->root = $this->index.'/'; |
|
1856 | 1856 | |
1857 | 1857 | unset($this->author_structure); |
1858 | 1858 | unset($this->date_structure); |
@@ -1860,10 +1860,10 @@ discard block |
||
1860 | 1860 | unset($this->search_structure); |
1861 | 1861 | unset($this->feed_structure); |
1862 | 1862 | unset($this->comment_feed_structure); |
1863 | - $this->use_trailing_slashes = ( '/' == substr($this->permalink_structure, -1, 1) ); |
|
1863 | + $this->use_trailing_slashes = ('/' == substr($this->permalink_structure, -1, 1)); |
|
1864 | 1864 | |
1865 | 1865 | // Enable generic rules for pages if permalink structure doesn't begin with a wildcard. |
1866 | - if ( preg_match("/^[^%]*%(?:postname|category|tag|author)%/", $this->permalink_structure) ) |
|
1866 | + if (preg_match("/^[^%]*%(?:postname|category|tag|author)%/", $this->permalink_structure)) |
|
1867 | 1867 | $this->use_verbose_page_rules = true; |
1868 | 1868 | else |
1869 | 1869 | $this->use_verbose_page_rules = false; |
@@ -1885,7 +1885,7 @@ discard block |
||
1885 | 1885 | * @param string $permalink_structure Permalink structure. |
1886 | 1886 | */ |
1887 | 1887 | public function set_permalink_structure($permalink_structure) { |
1888 | - if ( $permalink_structure != $this->permalink_structure ) { |
|
1888 | + if ($permalink_structure != $this->permalink_structure) { |
|
1889 | 1889 | $old_permalink_structure = $this->permalink_structure; |
1890 | 1890 | update_option('permalink_structure', $permalink_structure); |
1891 | 1891 | |
@@ -1899,7 +1899,7 @@ discard block |
||
1899 | 1899 | * @param string $old_permalink_structure The previous permalink structure. |
1900 | 1900 | * @param string $permalink_structure The new permalink structure. |
1901 | 1901 | */ |
1902 | - do_action( 'permalink_structure_changed', $old_permalink_structure, $permalink_structure ); |
|
1902 | + do_action('permalink_structure_changed', $old_permalink_structure, $permalink_structure); |
|
1903 | 1903 | } |
1904 | 1904 | } |
1905 | 1905 | |
@@ -1916,7 +1916,7 @@ discard block |
||
1916 | 1916 | * @param string $category_base Category permalink structure base. |
1917 | 1917 | */ |
1918 | 1918 | public function set_category_base($category_base) { |
1919 | - if ( $category_base != get_option('category_base') ) { |
|
1919 | + if ($category_base != get_option('category_base')) { |
|
1920 | 1920 | update_option('category_base', $category_base); |
1921 | 1921 | $this->init(); |
1922 | 1922 | } |
@@ -1934,9 +1934,9 @@ discard block |
||
1934 | 1934 | * |
1935 | 1935 | * @param string $tag_base Tag permalink structure base. |
1936 | 1936 | */ |
1937 | - public function set_tag_base( $tag_base ) { |
|
1938 | - if ( $tag_base != get_option( 'tag_base') ) { |
|
1939 | - update_option( 'tag_base', $tag_base ); |
|
1937 | + public function set_tag_base($tag_base) { |
|
1938 | + if ($tag_base != get_option('tag_base')) { |
|
1939 | + update_option('tag_base', $tag_base); |
|
1940 | 1940 | $this->init(); |
1941 | 1941 | } |
1942 | 1942 | } |