@@ -25,17 +25,17 @@ discard block |
||
25 | 25 | */ |
26 | 26 | public function __construct() { |
27 | 27 | // Hack to get the [embed] shortcode to run before wpautop() |
28 | - add_filter( 'the_content', array( $this, 'run_shortcode' ), 8 ); |
|
28 | + add_filter('the_content', array($this, 'run_shortcode'), 8); |
|
29 | 29 | |
30 | 30 | // Shortcode placeholder for strip_shortcodes() |
31 | - add_shortcode( 'embed', '__return_false' ); |
|
31 | + add_shortcode('embed', '__return_false'); |
|
32 | 32 | |
33 | 33 | // Attempts to embed all URLs in a post |
34 | - add_filter( 'the_content', array( $this, 'autoembed' ), 8 ); |
|
34 | + add_filter('the_content', array($this, 'autoembed'), 8); |
|
35 | 35 | |
36 | 36 | // After a post is saved, cache oEmbed items via AJAX |
37 | - add_action( 'edit_form_advanced', array( $this, 'maybe_run_ajax_cache' ) ); |
|
38 | - add_action( 'edit_page_form', array( $this, 'maybe_run_ajax_cache' ) ); |
|
37 | + add_action('edit_form_advanced', array($this, 'maybe_run_ajax_cache')); |
|
38 | + add_action('edit_page_form', array($this, 'maybe_run_ajax_cache')); |
|
39 | 39 | } |
40 | 40 | |
41 | 41 | /** |
@@ -50,17 +50,17 @@ discard block |
||
50 | 50 | * @param string $content Content to parse |
51 | 51 | * @return string Content with shortcode parsed |
52 | 52 | */ |
53 | - public function run_shortcode( $content ) { |
|
53 | + public function run_shortcode($content) { |
|
54 | 54 | global $shortcode_tags; |
55 | 55 | |
56 | 56 | // Back up current registered shortcodes and clear them all out |
57 | 57 | $orig_shortcode_tags = $shortcode_tags; |
58 | 58 | remove_all_shortcodes(); |
59 | 59 | |
60 | - add_shortcode( 'embed', array( $this, 'shortcode' ) ); |
|
60 | + add_shortcode('embed', array($this, 'shortcode')); |
|
61 | 61 | |
62 | 62 | // Do the shortcode (only the [embed] one is registered) |
63 | - $content = do_shortcode( $content, true ); |
|
63 | + $content = do_shortcode($content, true); |
|
64 | 64 | |
65 | 65 | // Put the original shortcodes back |
66 | 66 | $shortcode_tags = $orig_shortcode_tags; |
@@ -75,13 +75,13 @@ discard block |
||
75 | 75 | public function maybe_run_ajax_cache() { |
76 | 76 | $post = get_post(); |
77 | 77 | |
78 | - if ( ! $post || empty( $_GET['message'] ) ) |
|
78 | + if ( ! $post || empty($_GET['message'])) |
|
79 | 79 | return; |
80 | 80 | |
81 | 81 | ?> |
82 | 82 | <script type="text/javascript"> |
83 | 83 | jQuery(document).ready(function($){ |
84 | - $.get("<?php echo admin_url( 'admin-ajax.php?action=oembed-cache&post=' . $post->ID, 'relative' ); ?>"); |
|
84 | + $.get("<?php echo admin_url('admin-ajax.php?action=oembed-cache&post='.$post->ID, 'relative'); ?>"); |
|
85 | 85 | }); |
86 | 86 | </script> |
87 | 87 | <?php |
@@ -96,7 +96,7 @@ discard block |
||
96 | 96 | * @param callable $callback The callback function that will be called if the regex is matched. |
97 | 97 | * @param int $priority Optional. Used to specify the order in which the registered handlers will be tested (default: 10). Lower numbers correspond with earlier testing, and handlers with the same priority are tested in the order in which they were added to the action. |
98 | 98 | */ |
99 | - public function register_handler( $id, $regex, $callback, $priority = 10 ) { |
|
99 | + public function register_handler($id, $regex, $callback, $priority = 10) { |
|
100 | 100 | $this->handlers[$priority][$id] = array( |
101 | 101 | 'regex' => $regex, |
102 | 102 | 'callback' => $callback, |
@@ -109,8 +109,8 @@ discard block |
||
109 | 109 | * @param string $id The handler ID that should be removed. |
110 | 110 | * @param int $priority Optional. The priority of the handler to be removed (default: 10). |
111 | 111 | */ |
112 | - public function unregister_handler( $id, $priority = 10 ) { |
|
113 | - unset( $this->handlers[ $priority ][ $id ] ); |
|
112 | + public function unregister_handler($id, $priority = 10) { |
|
113 | + unset($this->handlers[$priority][$id]); |
|
114 | 114 | } |
115 | 115 | |
116 | 116 | /** |
@@ -129,35 +129,35 @@ discard block |
||
129 | 129 | * @return string|false The embed HTML on success, otherwise the original URL. |
130 | 130 | * `->maybe_make_link()` can return false on failure. |
131 | 131 | */ |
132 | - public function shortcode( $attr, $url = '' ) { |
|
132 | + public function shortcode($attr, $url = '') { |
|
133 | 133 | $post = get_post(); |
134 | 134 | |
135 | - if ( empty( $url ) && ! empty( $attr['src'] ) ) { |
|
135 | + if (empty($url) && ! empty($attr['src'])) { |
|
136 | 136 | $url = $attr['src']; |
137 | 137 | } |
138 | 138 | |
139 | 139 | $this->last_url = $url; |
140 | 140 | |
141 | - if ( empty( $url ) ) { |
|
141 | + if (empty($url)) { |
|
142 | 142 | $this->last_attr = $attr; |
143 | 143 | return ''; |
144 | 144 | } |
145 | 145 | |
146 | 146 | $rawattr = $attr; |
147 | - $attr = wp_parse_args( $attr, wp_embed_defaults( $url ) ); |
|
147 | + $attr = wp_parse_args($attr, wp_embed_defaults($url)); |
|
148 | 148 | |
149 | 149 | $this->last_attr = $attr; |
150 | 150 | |
151 | 151 | // kses converts & into & and we need to undo this |
152 | 152 | // See https://core.trac.wordpress.org/ticket/11311 |
153 | - $url = str_replace( '&', '&', $url ); |
|
153 | + $url = str_replace('&', '&', $url); |
|
154 | 154 | |
155 | 155 | // Look for known internal handlers |
156 | - ksort( $this->handlers ); |
|
157 | - foreach ( $this->handlers as $priority => $handlers ) { |
|
158 | - foreach ( $handlers as $id => $handler ) { |
|
159 | - if ( preg_match( $handler['regex'], $url, $matches ) && is_callable( $handler['callback'] ) ) { |
|
160 | - if ( false !== $return = call_user_func( $handler['callback'], $matches, $attr, $url, $rawattr ) ) |
|
156 | + ksort($this->handlers); |
|
157 | + foreach ($this->handlers as $priority => $handlers) { |
|
158 | + foreach ($handlers as $id => $handler) { |
|
159 | + if (preg_match($handler['regex'], $url, $matches) && is_callable($handler['callback'])) { |
|
160 | + if (false !== $return = call_user_func($handler['callback'], $matches, $attr, $url, $rawattr)) |
|
161 | 161 | /** |
162 | 162 | * Filter the returned embed handler. |
163 | 163 | * |
@@ -169,22 +169,22 @@ discard block |
||
169 | 169 | * @param string $url The attempted embed URL. |
170 | 170 | * @param array $attr An array of shortcode attributes. |
171 | 171 | */ |
172 | - return apply_filters( 'embed_handler_html', $return, $url, $attr ); |
|
172 | + return apply_filters('embed_handler_html', $return, $url, $attr); |
|
173 | 173 | } |
174 | 174 | } |
175 | 175 | } |
176 | 176 | |
177 | - $post_ID = ( ! empty( $post->ID ) ) ? $post->ID : null; |
|
178 | - if ( ! empty( $this->post_ID ) ) // Potentially set by WP_Embed::cache_oembed() |
|
177 | + $post_ID = ( ! empty($post->ID)) ? $post->ID : null; |
|
178 | + if ( ! empty($this->post_ID)) // Potentially set by WP_Embed::cache_oembed() |
|
179 | 179 | $post_ID = $this->post_ID; |
180 | 180 | |
181 | 181 | // Unknown URL format. Let oEmbed have a go. |
182 | - if ( $post_ID ) { |
|
182 | + if ($post_ID) { |
|
183 | 183 | |
184 | 184 | // Check for a cached result (stored in the post meta) |
185 | - $key_suffix = md5( $url . serialize( $attr ) ); |
|
186 | - $cachekey = '_oembed_' . $key_suffix; |
|
187 | - $cachekey_time = '_oembed_time_' . $key_suffix; |
|
185 | + $key_suffix = md5($url.serialize($attr)); |
|
186 | + $cachekey = '_oembed_'.$key_suffix; |
|
187 | + $cachekey_time = '_oembed_time_'.$key_suffix; |
|
188 | 188 | |
189 | 189 | /** |
190 | 190 | * Filter the oEmbed TTL value (time to live). |
@@ -196,23 +196,23 @@ discard block |
||
196 | 196 | * @param array $attr An array of shortcode attributes. |
197 | 197 | * @param int $post_ID Post ID. |
198 | 198 | */ |
199 | - $ttl = apply_filters( 'oembed_ttl', DAY_IN_SECONDS, $url, $attr, $post_ID ); |
|
199 | + $ttl = apply_filters('oembed_ttl', DAY_IN_SECONDS, $url, $attr, $post_ID); |
|
200 | 200 | |
201 | - $cache = get_post_meta( $post_ID, $cachekey, true ); |
|
202 | - $cache_time = get_post_meta( $post_ID, $cachekey_time, true ); |
|
201 | + $cache = get_post_meta($post_ID, $cachekey, true); |
|
202 | + $cache_time = get_post_meta($post_ID, $cachekey_time, true); |
|
203 | 203 | |
204 | - if ( ! $cache_time ) { |
|
204 | + if ( ! $cache_time) { |
|
205 | 205 | $cache_time = 0; |
206 | 206 | } |
207 | 207 | |
208 | - $cached_recently = ( time() - $cache_time ) < $ttl; |
|
208 | + $cached_recently = (time() - $cache_time) < $ttl; |
|
209 | 209 | |
210 | - if ( $this->usecache || $cached_recently ) { |
|
210 | + if ($this->usecache || $cached_recently) { |
|
211 | 211 | // Failures are cached. Serve one if we're using the cache. |
212 | - if ( '{{unknown}}' === $cache ) |
|
213 | - return $this->maybe_make_link( $url ); |
|
212 | + if ('{{unknown}}' === $cache) |
|
213 | + return $this->maybe_make_link($url); |
|
214 | 214 | |
215 | - if ( ! empty( $cache ) ) { |
|
215 | + if ( ! empty($cache)) { |
|
216 | 216 | /** |
217 | 217 | * Filter the cached oEmbed HTML. |
218 | 218 | * |
@@ -225,7 +225,7 @@ discard block |
||
225 | 225 | * @param array $attr An array of shortcode attributes. |
226 | 226 | * @param int $post_ID Post ID. |
227 | 227 | */ |
228 | - return apply_filters( 'embed_oembed_html', $cache, $url, $attr, $post_ID ); |
|
228 | + return apply_filters('embed_oembed_html', $cache, $url, $attr, $post_ID); |
|
229 | 229 | } |
230 | 230 | } |
231 | 231 | |
@@ -239,28 +239,28 @@ discard block |
||
239 | 239 | * |
240 | 240 | * @param bool $enable Whether to enable `<link>` tag discovery. Default true. |
241 | 241 | */ |
242 | - $attr['discover'] = ( apply_filters( 'embed_oembed_discover', true ) ); |
|
242 | + $attr['discover'] = (apply_filters('embed_oembed_discover', true)); |
|
243 | 243 | |
244 | 244 | // Use oEmbed to get the HTML |
245 | - $html = wp_oembed_get( $url, $attr ); |
|
245 | + $html = wp_oembed_get($url, $attr); |
|
246 | 246 | |
247 | 247 | // Maybe cache the result |
248 | - if ( $html ) { |
|
249 | - update_post_meta( $post_ID, $cachekey, $html ); |
|
250 | - update_post_meta( $post_ID, $cachekey_time, time() ); |
|
251 | - } elseif ( ! $cache ) { |
|
252 | - update_post_meta( $post_ID, $cachekey, '{{unknown}}' ); |
|
248 | + if ($html) { |
|
249 | + update_post_meta($post_ID, $cachekey, $html); |
|
250 | + update_post_meta($post_ID, $cachekey_time, time()); |
|
251 | + } elseif ( ! $cache) { |
|
252 | + update_post_meta($post_ID, $cachekey, '{{unknown}}'); |
|
253 | 253 | } |
254 | 254 | |
255 | 255 | // If there was a result, return it |
256 | - if ( $html ) { |
|
256 | + if ($html) { |
|
257 | 257 | /** This filter is documented in wp-includes/class-wp-embed.php */ |
258 | - return apply_filters( 'embed_oembed_html', $html, $url, $attr, $post_ID ); |
|
258 | + return apply_filters('embed_oembed_html', $html, $url, $attr, $post_ID); |
|
259 | 259 | } |
260 | 260 | } |
261 | 261 | |
262 | 262 | // Still unknown |
263 | - return $this->maybe_make_link( $url ); |
|
263 | + return $this->maybe_make_link($url); |
|
264 | 264 | } |
265 | 265 | |
266 | 266 | /** |
@@ -268,14 +268,14 @@ discard block |
||
268 | 268 | * |
269 | 269 | * @param int $post_ID Post ID to delete the caches for. |
270 | 270 | */ |
271 | - public function delete_oembed_caches( $post_ID ) { |
|
272 | - $post_metas = get_post_custom_keys( $post_ID ); |
|
273 | - if ( empty($post_metas) ) |
|
271 | + public function delete_oembed_caches($post_ID) { |
|
272 | + $post_metas = get_post_custom_keys($post_ID); |
|
273 | + if (empty($post_metas)) |
|
274 | 274 | return; |
275 | 275 | |
276 | - foreach ( $post_metas as $post_meta_key ) { |
|
277 | - if ( '_oembed_' == substr( $post_meta_key, 0, 8 ) ) |
|
278 | - delete_post_meta( $post_ID, $post_meta_key ); |
|
276 | + foreach ($post_metas as $post_meta_key) { |
|
277 | + if ('_oembed_' == substr($post_meta_key, 0, 8)) |
|
278 | + delete_post_meta($post_ID, $post_meta_key); |
|
279 | 279 | } |
280 | 280 | } |
281 | 281 | |
@@ -284,10 +284,10 @@ discard block |
||
284 | 284 | * |
285 | 285 | * @param int $post_ID Post ID to do the caching for. |
286 | 286 | */ |
287 | - public function cache_oembed( $post_ID ) { |
|
288 | - $post = get_post( $post_ID ); |
|
287 | + public function cache_oembed($post_ID) { |
|
288 | + $post = get_post($post_ID); |
|
289 | 289 | |
290 | - $post_types = get_post_types( array( 'show_ui' => true ) ); |
|
290 | + $post_types = get_post_types(array('show_ui' => true)); |
|
291 | 291 | /** |
292 | 292 | * Filter the array of post types to cache oEmbed results for. |
293 | 293 | * |
@@ -295,17 +295,17 @@ discard block |
||
295 | 295 | * |
296 | 296 | * @param array $post_types Array of post types to cache oEmbed results for. Defaults to post types with `show_ui` set to true. |
297 | 297 | */ |
298 | - if ( empty( $post->ID ) || ! in_array( $post->post_type, apply_filters( 'embed_cache_oembed_types', $post_types ) ) ){ |
|
298 | + if (empty($post->ID) || ! in_array($post->post_type, apply_filters('embed_cache_oembed_types', $post_types))) { |
|
299 | 299 | return; |
300 | 300 | } |
301 | 301 | |
302 | 302 | // Trigger a caching |
303 | - if ( ! empty( $post->post_content ) ) { |
|
303 | + if ( ! empty($post->post_content)) { |
|
304 | 304 | $this->post_ID = $post->ID; |
305 | 305 | $this->usecache = false; |
306 | 306 | |
307 | - $content = $this->run_shortcode( $post->post_content ); |
|
308 | - $this->autoembed( $content ); |
|
307 | + $content = $this->run_shortcode($post->post_content); |
|
308 | + $this->autoembed($content); |
|
309 | 309 | |
310 | 310 | $this->usecache = true; |
311 | 311 | } |
@@ -319,15 +319,15 @@ discard block |
||
319 | 319 | * @param string $content The content to be searched. |
320 | 320 | * @return string Potentially modified $content. |
321 | 321 | */ |
322 | - public function autoembed( $content ) { |
|
322 | + public function autoembed($content) { |
|
323 | 323 | // Replace line breaks from all HTML elements with placeholders. |
324 | - $content = wp_replace_in_html_tags( $content, array( "\n" => '<!-- wp-line-break -->' ) ); |
|
324 | + $content = wp_replace_in_html_tags($content, array("\n" => '<!-- wp-line-break -->')); |
|
325 | 325 | |
326 | 326 | // Find URLs that are on their own line. |
327 | - $content = preg_replace_callback( '|^(\s*)(https?://[^\s"]+)(\s*)$|im', array( $this, 'autoembed_callback' ), $content ); |
|
327 | + $content = preg_replace_callback('|^(\s*)(https?://[^\s"]+)(\s*)$|im', array($this, 'autoembed_callback'), $content); |
|
328 | 328 | |
329 | 329 | // Put the line breaks back. |
330 | - return str_replace( '<!-- wp-line-break -->', "\n", $content ); |
|
330 | + return str_replace('<!-- wp-line-break -->', "\n", $content); |
|
331 | 331 | } |
332 | 332 | |
333 | 333 | /** |
@@ -336,13 +336,13 @@ discard block |
||
336 | 336 | * @param array $match A regex match array. |
337 | 337 | * @return string The embed HTML on success, otherwise the original URL. |
338 | 338 | */ |
339 | - public function autoembed_callback( $match ) { |
|
339 | + public function autoembed_callback($match) { |
|
340 | 340 | $oldval = $this->linkifunknown; |
341 | 341 | $this->linkifunknown = false; |
342 | - $return = $this->shortcode( array(), $match[2] ); |
|
342 | + $return = $this->shortcode(array(), $match[2]); |
|
343 | 343 | $this->linkifunknown = $oldval; |
344 | 344 | |
345 | - return $match[1] . $return . $match[3]; |
|
345 | + return $match[1].$return.$match[3]; |
|
346 | 346 | } |
347 | 347 | |
348 | 348 | /** |
@@ -351,12 +351,12 @@ discard block |
||
351 | 351 | * @param string $url URL to potentially be linked. |
352 | 352 | * @return false|string Linked URL or the original URL. False if 'return_false_on_fail' is true. |
353 | 353 | */ |
354 | - public function maybe_make_link( $url ) { |
|
355 | - if ( $this->return_false_on_fail ) { |
|
354 | + public function maybe_make_link($url) { |
|
355 | + if ($this->return_false_on_fail) { |
|
356 | 356 | return false; |
357 | 357 | } |
358 | 358 | |
359 | - $output = ( $this->linkifunknown ) ? '<a href="' . esc_url($url) . '">' . esc_html($url) . '</a>' : $url; |
|
359 | + $output = ($this->linkifunknown) ? '<a href="'.esc_url($url).'">'.esc_html($url).'</a>' : $url; |
|
360 | 360 | |
361 | 361 | /** |
362 | 362 | * Filter the returned, maybe-linked embed URL. |
@@ -366,7 +366,7 @@ discard block |
||
366 | 366 | * @param string $output The linked or original URL. |
367 | 367 | * @param string $url The original URL. |
368 | 368 | */ |
369 | - return apply_filters( 'embed_maybe_make_link', $output, $url ); |
|
369 | + return apply_filters('embed_maybe_make_link', $output, $url); |
|
370 | 370 | } |
371 | 371 | } |
372 | 372 | $GLOBALS['wp_embed'] = new WP_Embed(); |
@@ -44,31 +44,31 @@ discard block |
||
44 | 44 | * |
45 | 45 | * @param object $manager An instance of the WP_Customize_Manager class. |
46 | 46 | */ |
47 | - public function __construct( $manager ) { |
|
47 | + public function __construct($manager) { |
|
48 | 48 | $this->previewed_menus = array(); |
49 | 49 | $this->manager = $manager; |
50 | 50 | |
51 | 51 | // Skip useless hooks when the user can't manage nav menus anyway. |
52 | - if ( ! current_user_can( 'edit_theme_options' ) ) { |
|
52 | + if ( ! current_user_can('edit_theme_options')) { |
|
53 | 53 | return; |
54 | 54 | } |
55 | 55 | |
56 | - add_filter( 'customize_refresh_nonces', array( $this, 'filter_nonces' ) ); |
|
57 | - add_action( 'wp_ajax_load-available-menu-items-customizer', array( $this, 'ajax_load_available_items' ) ); |
|
58 | - add_action( 'wp_ajax_search-available-menu-items-customizer', array( $this, 'ajax_search_available_items' ) ); |
|
59 | - add_action( 'customize_controls_enqueue_scripts', array( $this, 'enqueue_scripts' ) ); |
|
56 | + add_filter('customize_refresh_nonces', array($this, 'filter_nonces')); |
|
57 | + add_action('wp_ajax_load-available-menu-items-customizer', array($this, 'ajax_load_available_items')); |
|
58 | + add_action('wp_ajax_search-available-menu-items-customizer', array($this, 'ajax_search_available_items')); |
|
59 | + add_action('customize_controls_enqueue_scripts', array($this, 'enqueue_scripts')); |
|
60 | 60 | |
61 | 61 | // Needs to run after core Navigation section is set up. |
62 | - add_action( 'customize_register', array( $this, 'customize_register' ), 11 ); |
|
62 | + add_action('customize_register', array($this, 'customize_register'), 11); |
|
63 | 63 | |
64 | - add_filter( 'customize_dynamic_setting_args', array( $this, 'filter_dynamic_setting_args' ), 10, 2 ); |
|
65 | - add_filter( 'customize_dynamic_setting_class', array( $this, 'filter_dynamic_setting_class' ), 10, 3 ); |
|
66 | - add_action( 'customize_controls_print_footer_scripts', array( $this, 'print_templates' ) ); |
|
67 | - add_action( 'customize_controls_print_footer_scripts', array( $this, 'available_items_template' ) ); |
|
68 | - add_action( 'customize_preview_init', array( $this, 'customize_preview_init' ) ); |
|
64 | + add_filter('customize_dynamic_setting_args', array($this, 'filter_dynamic_setting_args'), 10, 2); |
|
65 | + add_filter('customize_dynamic_setting_class', array($this, 'filter_dynamic_setting_class'), 10, 3); |
|
66 | + add_action('customize_controls_print_footer_scripts', array($this, 'print_templates')); |
|
67 | + add_action('customize_controls_print_footer_scripts', array($this, 'available_items_template')); |
|
68 | + add_action('customize_preview_init', array($this, 'customize_preview_init')); |
|
69 | 69 | |
70 | 70 | // Selective Refresh partials. |
71 | - add_filter( 'customize_dynamic_partial_args', array( $this, 'customize_dynamic_partial_args' ), 10, 2 ); |
|
71 | + add_filter('customize_dynamic_partial_args', array($this, 'customize_dynamic_partial_args'), 10, 2); |
|
72 | 72 | } |
73 | 73 | |
74 | 74 | /** |
@@ -80,8 +80,8 @@ discard block |
||
80 | 80 | * @param array $nonces Array of nonces. |
81 | 81 | * @return array $nonces Modified array of nonces. |
82 | 82 | */ |
83 | - public function filter_nonces( $nonces ) { |
|
84 | - $nonces['customize-menus'] = wp_create_nonce( 'customize-menus' ); |
|
83 | + public function filter_nonces($nonces) { |
|
84 | + $nonces['customize-menus'] = wp_create_nonce('customize-menus'); |
|
85 | 85 | return $nonces; |
86 | 86 | } |
87 | 87 | |
@@ -92,25 +92,25 @@ discard block |
||
92 | 92 | * @access public |
93 | 93 | */ |
94 | 94 | public function ajax_load_available_items() { |
95 | - check_ajax_referer( 'customize-menus', 'customize-menus-nonce' ); |
|
95 | + check_ajax_referer('customize-menus', 'customize-menus-nonce'); |
|
96 | 96 | |
97 | - if ( ! current_user_can( 'edit_theme_options' ) ) { |
|
97 | + if ( ! current_user_can('edit_theme_options')) { |
|
98 | 98 | wp_die( -1 ); |
99 | 99 | } |
100 | 100 | |
101 | - if ( empty( $_POST['type'] ) || empty( $_POST['object'] ) ) { |
|
102 | - wp_send_json_error( 'nav_menus_missing_type_or_object_parameter' ); |
|
101 | + if (empty($_POST['type']) || empty($_POST['object'])) { |
|
102 | + wp_send_json_error('nav_menus_missing_type_or_object_parameter'); |
|
103 | 103 | } |
104 | 104 | |
105 | - $type = sanitize_key( $_POST['type'] ); |
|
106 | - $object = sanitize_key( $_POST['object'] ); |
|
107 | - $page = empty( $_POST['page'] ) ? 0 : absint( $_POST['page'] ); |
|
108 | - $items = $this->load_available_items_query( $type, $object, $page ); |
|
105 | + $type = sanitize_key($_POST['type']); |
|
106 | + $object = sanitize_key($_POST['object']); |
|
107 | + $page = empty($_POST['page']) ? 0 : absint($_POST['page']); |
|
108 | + $items = $this->load_available_items_query($type, $object, $page); |
|
109 | 109 | |
110 | - if ( is_wp_error( $items ) ) { |
|
111 | - wp_send_json_error( $items->get_error_code() ); |
|
110 | + if (is_wp_error($items)) { |
|
111 | + wp_send_json_error($items->get_error_code()); |
|
112 | 112 | } else { |
113 | - wp_send_json_success( array( 'items' => $items ) ); |
|
113 | + wp_send_json_success(array('items' => $items)); |
|
114 | 114 | } |
115 | 115 | } |
116 | 116 | |
@@ -126,62 +126,62 @@ discard block |
||
126 | 126 | * @param int $page Optional. The page number used to generate the query offset. Default is '0'. |
127 | 127 | * @return WP_Error|array Returns either a WP_Error object or an array of menu items. |
128 | 128 | */ |
129 | - public function load_available_items_query( $type = 'post_type', $object = 'page', $page = 0 ) { |
|
129 | + public function load_available_items_query($type = 'post_type', $object = 'page', $page = 0) { |
|
130 | 130 | $items = array(); |
131 | 131 | |
132 | - if ( 'post_type' === $type ) { |
|
133 | - $post_type = get_post_type_object( $object ); |
|
134 | - if ( ! $post_type ) { |
|
135 | - return new WP_Error( 'nav_menus_invalid_post_type' ); |
|
132 | + if ('post_type' === $type) { |
|
133 | + $post_type = get_post_type_object($object); |
|
134 | + if ( ! $post_type) { |
|
135 | + return new WP_Error('nav_menus_invalid_post_type'); |
|
136 | 136 | } |
137 | 137 | |
138 | - if ( 0 === $page && 'page' === $object ) { |
|
138 | + if (0 === $page && 'page' === $object) { |
|
139 | 139 | // Add "Home" link. Treat as a page, but switch to custom on add. |
140 | 140 | $items[] = array( |
141 | 141 | 'id' => 'home', |
142 | - 'title' => _x( 'Home', 'nav menu home label' ), |
|
142 | + 'title' => _x('Home', 'nav menu home label'), |
|
143 | 143 | 'type' => 'custom', |
144 | - 'type_label' => __( 'Custom Link' ), |
|
144 | + 'type_label' => __('Custom Link'), |
|
145 | 145 | 'object' => '', |
146 | 146 | 'url' => home_url(), |
147 | 147 | ); |
148 | - } elseif ( 'post' !== $object && 0 === $page && $post_type->has_archive ) { |
|
148 | + } elseif ('post' !== $object && 0 === $page && $post_type->has_archive) { |
|
149 | 149 | // Add a post type archive link. |
150 | 150 | $items[] = array( |
151 | - 'id' => $object . '-archive', |
|
151 | + 'id' => $object.'-archive', |
|
152 | 152 | 'title' => $post_type->labels->archives, |
153 | 153 | 'type' => 'post_type_archive', |
154 | - 'type_label' => __( 'Post Type Archive' ), |
|
154 | + 'type_label' => __('Post Type Archive'), |
|
155 | 155 | 'object' => $object, |
156 | - 'url' => get_post_type_archive_link( $object ), |
|
156 | + 'url' => get_post_type_archive_link($object), |
|
157 | 157 | ); |
158 | 158 | } |
159 | 159 | |
160 | - $posts = get_posts( array( |
|
160 | + $posts = get_posts(array( |
|
161 | 161 | 'numberposts' => 10, |
162 | 162 | 'offset' => 10 * $page, |
163 | 163 | 'orderby' => 'date', |
164 | 164 | 'order' => 'DESC', |
165 | 165 | 'post_type' => $object, |
166 | - ) ); |
|
167 | - foreach ( $posts as $post ) { |
|
166 | + )); |
|
167 | + foreach ($posts as $post) { |
|
168 | 168 | $post_title = $post->post_title; |
169 | - if ( '' === $post_title ) { |
|
169 | + if ('' === $post_title) { |
|
170 | 170 | /* translators: %d: ID of a post */ |
171 | - $post_title = sprintf( __( '#%d (no title)' ), $post->ID ); |
|
171 | + $post_title = sprintf(__('#%d (no title)'), $post->ID); |
|
172 | 172 | } |
173 | 173 | $items[] = array( |
174 | 174 | 'id' => "post-{$post->ID}", |
175 | - 'title' => html_entity_decode( $post_title, ENT_QUOTES, get_bloginfo( 'charset' ) ), |
|
175 | + 'title' => html_entity_decode($post_title, ENT_QUOTES, get_bloginfo('charset')), |
|
176 | 176 | 'type' => 'post_type', |
177 | - 'type_label' => get_post_type_object( $post->post_type )->labels->singular_name, |
|
177 | + 'type_label' => get_post_type_object($post->post_type)->labels->singular_name, |
|
178 | 178 | 'object' => $post->post_type, |
179 | - 'object_id' => intval( $post->ID ), |
|
180 | - 'url' => get_permalink( intval( $post->ID ) ), |
|
179 | + 'object_id' => intval($post->ID), |
|
180 | + 'url' => get_permalink(intval($post->ID)), |
|
181 | 181 | ); |
182 | 182 | } |
183 | - } elseif ( 'taxonomy' === $type ) { |
|
184 | - $terms = get_terms( $object, array( |
|
183 | + } elseif ('taxonomy' === $type) { |
|
184 | + $terms = get_terms($object, array( |
|
185 | 185 | 'child_of' => 0, |
186 | 186 | 'exclude' => '', |
187 | 187 | 'hide_empty' => false, |
@@ -192,20 +192,20 @@ discard block |
||
192 | 192 | 'order' => 'DESC', |
193 | 193 | 'orderby' => 'count', |
194 | 194 | 'pad_counts' => false, |
195 | - ) ); |
|
196 | - if ( is_wp_error( $terms ) ) { |
|
195 | + )); |
|
196 | + if (is_wp_error($terms)) { |
|
197 | 197 | return $terms; |
198 | 198 | } |
199 | 199 | |
200 | - foreach ( $terms as $term ) { |
|
200 | + foreach ($terms as $term) { |
|
201 | 201 | $items[] = array( |
202 | 202 | 'id' => "term-{$term->term_id}", |
203 | - 'title' => html_entity_decode( $term->name, ENT_QUOTES, get_bloginfo( 'charset' ) ), |
|
203 | + 'title' => html_entity_decode($term->name, ENT_QUOTES, get_bloginfo('charset')), |
|
204 | 204 | 'type' => 'taxonomy', |
205 | - 'type_label' => get_taxonomy( $term->taxonomy )->labels->singular_name, |
|
205 | + 'type_label' => get_taxonomy($term->taxonomy)->labels->singular_name, |
|
206 | 206 | 'object' => $term->taxonomy, |
207 | - 'object_id' => intval( $term->term_id ), |
|
208 | - 'url' => get_term_link( intval( $term->term_id ), $term->taxonomy ), |
|
207 | + 'object_id' => intval($term->term_id), |
|
208 | + 'url' => get_term_link(intval($term->term_id), $term->taxonomy), |
|
209 | 209 | ); |
210 | 210 | } |
211 | 211 | } |
@@ -220,7 +220,7 @@ discard block |
||
220 | 220 | * @param string $object The object name. |
221 | 221 | * @param int $page The current page number. |
222 | 222 | */ |
223 | - $items = apply_filters( 'customize_nav_menu_available_items', $items, $type, $object, $page ); |
|
223 | + $items = apply_filters('customize_nav_menu_available_items', $items, $type, $object, $page); |
|
224 | 224 | |
225 | 225 | return $items; |
226 | 226 | } |
@@ -232,28 +232,28 @@ discard block |
||
232 | 232 | * @access public |
233 | 233 | */ |
234 | 234 | public function ajax_search_available_items() { |
235 | - check_ajax_referer( 'customize-menus', 'customize-menus-nonce' ); |
|
235 | + check_ajax_referer('customize-menus', 'customize-menus-nonce'); |
|
236 | 236 | |
237 | - if ( ! current_user_can( 'edit_theme_options' ) ) { |
|
237 | + if ( ! current_user_can('edit_theme_options')) { |
|
238 | 238 | wp_die( -1 ); |
239 | 239 | } |
240 | 240 | |
241 | - if ( empty( $_POST['search'] ) ) { |
|
242 | - wp_send_json_error( 'nav_menus_missing_search_parameter' ); |
|
241 | + if (empty($_POST['search'])) { |
|
242 | + wp_send_json_error('nav_menus_missing_search_parameter'); |
|
243 | 243 | } |
244 | 244 | |
245 | - $p = isset( $_POST['page'] ) ? absint( $_POST['page'] ) : 0; |
|
246 | - if ( $p < 1 ) { |
|
245 | + $p = isset($_POST['page']) ? absint($_POST['page']) : 0; |
|
246 | + if ($p < 1) { |
|
247 | 247 | $p = 1; |
248 | 248 | } |
249 | 249 | |
250 | - $s = sanitize_text_field( wp_unslash( $_POST['search'] ) ); |
|
251 | - $items = $this->search_available_items_query( array( 'pagenum' => $p, 's' => $s ) ); |
|
250 | + $s = sanitize_text_field(wp_unslash($_POST['search'])); |
|
251 | + $items = $this->search_available_items_query(array('pagenum' => $p, 's' => $s)); |
|
252 | 252 | |
253 | - if ( empty( $items ) ) { |
|
254 | - wp_send_json_error( array( 'message' => __( 'No results found.' ) ) ); |
|
253 | + if (empty($items)) { |
|
254 | + wp_send_json_error(array('message' => __('No results found.'))); |
|
255 | 255 | } else { |
256 | - wp_send_json_success( array( 'items' => $items ) ); |
|
256 | + wp_send_json_success(array('items' => $items)); |
|
257 | 257 | } |
258 | 258 | } |
259 | 259 | |
@@ -268,12 +268,12 @@ discard block |
||
268 | 268 | * @param array $args Optional. Accepts 'pagenum' and 's' (search) arguments. |
269 | 269 | * @return array Menu items. |
270 | 270 | */ |
271 | - public function search_available_items_query( $args = array() ) { |
|
271 | + public function search_available_items_query($args = array()) { |
|
272 | 272 | $items = array(); |
273 | 273 | |
274 | - $post_type_objects = get_post_types( array( 'show_in_nav_menus' => true ), 'objects' ); |
|
274 | + $post_type_objects = get_post_types(array('show_in_nav_menus' => true), 'objects'); |
|
275 | 275 | $query = array( |
276 | - 'post_type' => array_keys( $post_type_objects ), |
|
276 | + 'post_type' => array_keys($post_type_objects), |
|
277 | 277 | 'suppress_filters' => true, |
278 | 278 | 'update_post_term_cache' => false, |
279 | 279 | 'update_post_meta_cache' => false, |
@@ -281,55 +281,55 @@ discard block |
||
281 | 281 | 'posts_per_page' => 20, |
282 | 282 | ); |
283 | 283 | |
284 | - $args['pagenum'] = isset( $args['pagenum'] ) ? absint( $args['pagenum'] ) : 1; |
|
285 | - $query['offset'] = $args['pagenum'] > 1 ? $query['posts_per_page'] * ( $args['pagenum'] - 1 ) : 0; |
|
284 | + $args['pagenum'] = isset($args['pagenum']) ? absint($args['pagenum']) : 1; |
|
285 | + $query['offset'] = $args['pagenum'] > 1 ? $query['posts_per_page'] * ($args['pagenum'] - 1) : 0; |
|
286 | 286 | |
287 | - if ( isset( $args['s'] ) ) { |
|
287 | + if (isset($args['s'])) { |
|
288 | 288 | $query['s'] = $args['s']; |
289 | 289 | } |
290 | 290 | |
291 | 291 | // Query posts. |
292 | - $get_posts = new WP_Query( $query ); |
|
292 | + $get_posts = new WP_Query($query); |
|
293 | 293 | |
294 | 294 | // Check if any posts were found. |
295 | - if ( $get_posts->post_count ) { |
|
296 | - foreach ( $get_posts->posts as $post ) { |
|
295 | + if ($get_posts->post_count) { |
|
296 | + foreach ($get_posts->posts as $post) { |
|
297 | 297 | $post_title = $post->post_title; |
298 | - if ( '' === $post_title ) { |
|
298 | + if ('' === $post_title) { |
|
299 | 299 | /* translators: %d: ID of a post */ |
300 | - $post_title = sprintf( __( '#%d (no title)' ), $post->ID ); |
|
300 | + $post_title = sprintf(__('#%d (no title)'), $post->ID); |
|
301 | 301 | } |
302 | 302 | $items[] = array( |
303 | - 'id' => 'post-' . $post->ID, |
|
304 | - 'title' => html_entity_decode( $post_title, ENT_QUOTES, get_bloginfo( 'charset' ) ), |
|
303 | + 'id' => 'post-'.$post->ID, |
|
304 | + 'title' => html_entity_decode($post_title, ENT_QUOTES, get_bloginfo('charset')), |
|
305 | 305 | 'type' => 'post_type', |
306 | - 'type_label' => $post_type_objects[ $post->post_type ]->labels->singular_name, |
|
306 | + 'type_label' => $post_type_objects[$post->post_type]->labels->singular_name, |
|
307 | 307 | 'object' => $post->post_type, |
308 | - 'object_id' => intval( $post->ID ), |
|
309 | - 'url' => get_permalink( intval( $post->ID ) ), |
|
308 | + 'object_id' => intval($post->ID), |
|
309 | + 'url' => get_permalink(intval($post->ID)), |
|
310 | 310 | ); |
311 | 311 | } |
312 | 312 | } |
313 | 313 | |
314 | 314 | // Query taxonomy terms. |
315 | - $taxonomies = get_taxonomies( array( 'show_in_nav_menus' => true ), 'names' ); |
|
316 | - $terms = get_terms( $taxonomies, array( |
|
315 | + $taxonomies = get_taxonomies(array('show_in_nav_menus' => true), 'names'); |
|
316 | + $terms = get_terms($taxonomies, array( |
|
317 | 317 | 'name__like' => $args['s'], |
318 | 318 | 'number' => 20, |
319 | 319 | 'offset' => 20 * ($args['pagenum'] - 1), |
320 | - ) ); |
|
320 | + )); |
|
321 | 321 | |
322 | 322 | // Check if any taxonomies were found. |
323 | - if ( ! empty( $terms ) ) { |
|
324 | - foreach ( $terms as $term ) { |
|
323 | + if ( ! empty($terms)) { |
|
324 | + foreach ($terms as $term) { |
|
325 | 325 | $items[] = array( |
326 | - 'id' => 'term-' . $term->term_id, |
|
327 | - 'title' => html_entity_decode( $term->name, ENT_QUOTES, get_bloginfo( 'charset' ) ), |
|
326 | + 'id' => 'term-'.$term->term_id, |
|
327 | + 'title' => html_entity_decode($term->name, ENT_QUOTES, get_bloginfo('charset')), |
|
328 | 328 | 'type' => 'taxonomy', |
329 | - 'type_label' => get_taxonomy( $term->taxonomy )->labels->singular_name, |
|
329 | + 'type_label' => get_taxonomy($term->taxonomy)->labels->singular_name, |
|
330 | 330 | 'object' => $term->taxonomy, |
331 | - 'object_id' => intval( $term->term_id ), |
|
332 | - 'url' => get_term_link( intval( $term->term_id ), $term->taxonomy ), |
|
331 | + 'object_id' => intval($term->term_id), |
|
332 | + 'url' => get_term_link(intval($term->term_id), $term->taxonomy), |
|
333 | 333 | ); |
334 | 334 | } |
335 | 335 | } |
@@ -342,7 +342,7 @@ discard block |
||
342 | 342 | * @param array $items The array of menu items. |
343 | 343 | * @param array $args Includes 'pagenum' and 's' (search) arguments. |
344 | 344 | */ |
345 | - $items = apply_filters( 'customize_nav_menu_searched_items', $items, $args ); |
|
345 | + $items = apply_filters('customize_nav_menu_searched_items', $items, $args); |
|
346 | 346 | |
347 | 347 | return $items; |
348 | 348 | } |
@@ -354,46 +354,46 @@ discard block |
||
354 | 354 | * @access public |
355 | 355 | */ |
356 | 356 | public function enqueue_scripts() { |
357 | - wp_enqueue_style( 'customize-nav-menus' ); |
|
358 | - wp_enqueue_script( 'customize-nav-menus' ); |
|
357 | + wp_enqueue_style('customize-nav-menus'); |
|
358 | + wp_enqueue_script('customize-nav-menus'); |
|
359 | 359 | |
360 | - $temp_nav_menu_setting = new WP_Customize_Nav_Menu_Setting( $this->manager, 'nav_menu[-1]' ); |
|
361 | - $temp_nav_menu_item_setting = new WP_Customize_Nav_Menu_Item_Setting( $this->manager, 'nav_menu_item[-1]' ); |
|
360 | + $temp_nav_menu_setting = new WP_Customize_Nav_Menu_Setting($this->manager, 'nav_menu[-1]'); |
|
361 | + $temp_nav_menu_item_setting = new WP_Customize_Nav_Menu_Item_Setting($this->manager, 'nav_menu_item[-1]'); |
|
362 | 362 | |
363 | 363 | // Pass data to JS. |
364 | 364 | $settings = array( |
365 | 365 | 'allMenus' => wp_get_nav_menus(), |
366 | 366 | 'itemTypes' => $this->available_item_types(), |
367 | 367 | 'l10n' => array( |
368 | - 'untitled' => _x( '(no label)', 'missing menu item navigation label' ), |
|
369 | - 'unnamed' => _x( '(unnamed)', 'Missing menu name.' ), |
|
370 | - 'custom_label' => __( 'Custom Link' ), |
|
368 | + 'untitled' => _x('(no label)', 'missing menu item navigation label'), |
|
369 | + 'unnamed' => _x('(unnamed)', 'Missing menu name.'), |
|
370 | + 'custom_label' => __('Custom Link'), |
|
371 | 371 | /* translators: %s: menu location */ |
372 | - 'menuLocation' => _x( '(Currently set to: %s)', 'menu' ), |
|
373 | - 'menuNameLabel' => __( 'Menu Name' ), |
|
374 | - 'itemAdded' => __( 'Menu item added' ), |
|
375 | - 'itemDeleted' => __( 'Menu item deleted' ), |
|
376 | - 'menuAdded' => __( 'Menu created' ), |
|
377 | - 'menuDeleted' => __( 'Menu deleted' ), |
|
378 | - 'movedUp' => __( 'Menu item moved up' ), |
|
379 | - 'movedDown' => __( 'Menu item moved down' ), |
|
380 | - 'movedLeft' => __( 'Menu item moved out of submenu' ), |
|
381 | - 'movedRight' => __( 'Menu item is now a sub-item' ), |
|
372 | + 'menuLocation' => _x('(Currently set to: %s)', 'menu'), |
|
373 | + 'menuNameLabel' => __('Menu Name'), |
|
374 | + 'itemAdded' => __('Menu item added'), |
|
375 | + 'itemDeleted' => __('Menu item deleted'), |
|
376 | + 'menuAdded' => __('Menu created'), |
|
377 | + 'menuDeleted' => __('Menu deleted'), |
|
378 | + 'movedUp' => __('Menu item moved up'), |
|
379 | + 'movedDown' => __('Menu item moved down'), |
|
380 | + 'movedLeft' => __('Menu item moved out of submenu'), |
|
381 | + 'movedRight' => __('Menu item is now a sub-item'), |
|
382 | 382 | /* translators: ▸ is the unicode right-pointing triangle, and %s is the section title in the Customizer */ |
383 | - 'customizingMenus' => sprintf( __( 'Customizing ▸ %s' ), esc_html( $this->manager->get_panel( 'nav_menus' )->title ) ), |
|
383 | + 'customizingMenus' => sprintf(__('Customizing ▸ %s'), esc_html($this->manager->get_panel('nav_menus')->title)), |
|
384 | 384 | /* translators: %s: title of menu item which is invalid */ |
385 | - 'invalidTitleTpl' => __( '%s (Invalid)' ), |
|
385 | + 'invalidTitleTpl' => __('%s (Invalid)'), |
|
386 | 386 | /* translators: %s: title of menu item in draft status */ |
387 | - 'pendingTitleTpl' => __( '%s (Pending)' ), |
|
388 | - 'itemsFound' => __( 'Number of items found: %d' ), |
|
389 | - 'itemsFoundMore' => __( 'Additional items found: %d' ), |
|
390 | - 'itemsLoadingMore' => __( 'Loading more results... please wait.' ), |
|
391 | - 'reorderModeOn' => __( 'Reorder mode enabled' ), |
|
392 | - 'reorderModeOff' => __( 'Reorder mode closed' ), |
|
393 | - 'reorderLabelOn' => esc_attr__( 'Reorder menu items' ), |
|
394 | - 'reorderLabelOff' => esc_attr__( 'Close reorder mode' ), |
|
387 | + 'pendingTitleTpl' => __('%s (Pending)'), |
|
388 | + 'itemsFound' => __('Number of items found: %d'), |
|
389 | + 'itemsFoundMore' => __('Additional items found: %d'), |
|
390 | + 'itemsLoadingMore' => __('Loading more results... please wait.'), |
|
391 | + 'reorderModeOn' => __('Reorder mode enabled'), |
|
392 | + 'reorderModeOff' => __('Reorder mode closed'), |
|
393 | + 'reorderLabelOn' => esc_attr__('Reorder menu items'), |
|
394 | + 'reorderLabelOff' => esc_attr__('Close reorder mode'), |
|
395 | 395 | ), |
396 | - 'settingTransport' => isset( $this->manager->selective_refresh ) ? 'postMessage' : 'refresh', |
|
396 | + 'settingTransport' => isset($this->manager->selective_refresh) ? 'postMessage' : 'refresh', |
|
397 | 397 | 'phpIntMax' => PHP_INT_MAX, |
398 | 398 | 'defaultSettingValues' => array( |
399 | 399 | 'nav_menu' => $temp_nav_menu_setting->default, |
@@ -402,29 +402,29 @@ discard block |
||
402 | 402 | 'locationSlugMappedToName' => get_registered_nav_menus(), |
403 | 403 | ); |
404 | 404 | |
405 | - $data = sprintf( 'var _wpCustomizeNavMenusSettings = %s;', wp_json_encode( $settings ) ); |
|
406 | - wp_scripts()->add_data( 'customize-nav-menus', 'data', $data ); |
|
405 | + $data = sprintf('var _wpCustomizeNavMenusSettings = %s;', wp_json_encode($settings)); |
|
406 | + wp_scripts()->add_data('customize-nav-menus', 'data', $data); |
|
407 | 407 | |
408 | 408 | // This is copied from nav-menus.php, and it has an unfortunate object name of `menus`. |
409 | 409 | $nav_menus_l10n = array( |
410 | 410 | 'oneThemeLocationNoMenus' => null, |
411 | - 'moveUp' => __( 'Move up one' ), |
|
412 | - 'moveDown' => __( 'Move down one' ), |
|
413 | - 'moveToTop' => __( 'Move to the top' ), |
|
411 | + 'moveUp' => __('Move up one'), |
|
412 | + 'moveDown' => __('Move down one'), |
|
413 | + 'moveToTop' => __('Move to the top'), |
|
414 | 414 | /* translators: %s: previous item name */ |
415 | - 'moveUnder' => __( 'Move under %s' ), |
|
415 | + 'moveUnder' => __('Move under %s'), |
|
416 | 416 | /* translators: %s: previous item name */ |
417 | - 'moveOutFrom' => __( 'Move out from under %s' ), |
|
417 | + 'moveOutFrom' => __('Move out from under %s'), |
|
418 | 418 | /* translators: %s: previous item name */ |
419 | - 'under' => __( 'Under %s' ), |
|
419 | + 'under' => __('Under %s'), |
|
420 | 420 | /* translators: %s: previous item name */ |
421 | - 'outFrom' => __( 'Out from under %s' ), |
|
421 | + 'outFrom' => __('Out from under %s'), |
|
422 | 422 | /* translators: 1: item name, 2: item position, 3: total number of items */ |
423 | - 'menuFocus' => __( '%1$s. Menu item %2$d of %3$d.' ), |
|
423 | + 'menuFocus' => __('%1$s. Menu item %2$d of %3$d.'), |
|
424 | 424 | /* translators: 1: item name, 2: item position, 3: parent item name */ |
425 | - 'subMenuFocus' => __( '%1$s. Sub item number %2$d under %3$s.' ), |
|
425 | + 'subMenuFocus' => __('%1$s. Sub item number %2$d under %3$s.'), |
|
426 | 426 | ); |
427 | - wp_localize_script( 'nav-menu', 'menus', $nav_menus_l10n ); |
|
427 | + wp_localize_script('nav-menu', 'menus', $nav_menus_l10n); |
|
428 | 428 | } |
429 | 429 | |
430 | 430 | /** |
@@ -441,16 +441,16 @@ discard block |
||
441 | 441 | * @param string $setting_id ID for dynamic setting, usually coming from `$_POST['customized']`. |
442 | 442 | * @return array|false |
443 | 443 | */ |
444 | - public function filter_dynamic_setting_args( $setting_args, $setting_id ) { |
|
445 | - if ( preg_match( WP_Customize_Nav_Menu_Setting::ID_PATTERN, $setting_id ) ) { |
|
444 | + public function filter_dynamic_setting_args($setting_args, $setting_id) { |
|
445 | + if (preg_match(WP_Customize_Nav_Menu_Setting::ID_PATTERN, $setting_id)) { |
|
446 | 446 | $setting_args = array( |
447 | 447 | 'type' => WP_Customize_Nav_Menu_Setting::TYPE, |
448 | - 'transport' => isset( $this->manager->selective_refresh ) ? 'postMessage' : 'refresh', |
|
448 | + 'transport' => isset($this->manager->selective_refresh) ? 'postMessage' : 'refresh', |
|
449 | 449 | ); |
450 | - } elseif ( preg_match( WP_Customize_Nav_Menu_Item_Setting::ID_PATTERN, $setting_id ) ) { |
|
450 | + } elseif (preg_match(WP_Customize_Nav_Menu_Item_Setting::ID_PATTERN, $setting_id)) { |
|
451 | 451 | $setting_args = array( |
452 | 452 | 'type' => WP_Customize_Nav_Menu_Item_Setting::TYPE, |
453 | - 'transport' => isset( $this->manager->selective_refresh ) ? 'postMessage' : 'refresh', |
|
453 | + 'transport' => isset($this->manager->selective_refresh) ? 'postMessage' : 'refresh', |
|
454 | 454 | ); |
455 | 455 | } |
456 | 456 | return $setting_args; |
@@ -467,12 +467,12 @@ discard block |
||
467 | 467 | * @param array $setting_args WP_Customize_Setting or a subclass. |
468 | 468 | * @return string |
469 | 469 | */ |
470 | - public function filter_dynamic_setting_class( $setting_class, $setting_id, $setting_args ) { |
|
471 | - unset( $setting_id ); |
|
470 | + public function filter_dynamic_setting_class($setting_class, $setting_id, $setting_args) { |
|
471 | + unset($setting_id); |
|
472 | 472 | |
473 | - if ( ! empty( $setting_args['type'] ) && WP_Customize_Nav_Menu_Setting::TYPE === $setting_args['type'] ) { |
|
473 | + if ( ! empty($setting_args['type']) && WP_Customize_Nav_Menu_Setting::TYPE === $setting_args['type']) { |
|
474 | 474 | $setting_class = 'WP_Customize_Nav_Menu_Setting'; |
475 | - } elseif ( ! empty( $setting_args['type'] ) && WP_Customize_Nav_Menu_Item_Setting::TYPE === $setting_args['type'] ) { |
|
475 | + } elseif ( ! empty($setting_args['type']) && WP_Customize_Nav_Menu_Item_Setting::TYPE === $setting_args['type']) { |
|
476 | 476 | $setting_class = 'WP_Customize_Nav_Menu_Item_Setting'; |
477 | 477 | } |
478 | 478 | return $setting_class; |
@@ -487,140 +487,140 @@ discard block |
||
487 | 487 | public function customize_register() { |
488 | 488 | |
489 | 489 | // Require JS-rendered control types. |
490 | - $this->manager->register_panel_type( 'WP_Customize_Nav_Menus_Panel' ); |
|
491 | - $this->manager->register_control_type( 'WP_Customize_Nav_Menu_Control' ); |
|
492 | - $this->manager->register_control_type( 'WP_Customize_Nav_Menu_Name_Control' ); |
|
493 | - $this->manager->register_control_type( 'WP_Customize_Nav_Menu_Auto_Add_Control' ); |
|
494 | - $this->manager->register_control_type( 'WP_Customize_Nav_Menu_Item_Control' ); |
|
490 | + $this->manager->register_panel_type('WP_Customize_Nav_Menus_Panel'); |
|
491 | + $this->manager->register_control_type('WP_Customize_Nav_Menu_Control'); |
|
492 | + $this->manager->register_control_type('WP_Customize_Nav_Menu_Name_Control'); |
|
493 | + $this->manager->register_control_type('WP_Customize_Nav_Menu_Auto_Add_Control'); |
|
494 | + $this->manager->register_control_type('WP_Customize_Nav_Menu_Item_Control'); |
|
495 | 495 | |
496 | 496 | // Create a panel for Menus. |
497 | - $description = '<p>' . __( 'This panel is used for managing navigation menus for content you have already published on your site. You can create menus and add items for existing content such as pages, posts, categories, tags, formats, or custom links.' ) . '</p>'; |
|
498 | - if ( current_theme_supports( 'widgets' ) ) { |
|
499 | - $description .= '<p>' . sprintf( __( 'Menus can be displayed in locations defined by your theme or in <a href="%s">widget areas</a> by adding a “Custom Menu” widget.' ), "javascript:wp.customize.panel( 'widgets' ).focus();" ) . '</p>'; |
|
497 | + $description = '<p>'.__('This panel is used for managing navigation menus for content you have already published on your site. You can create menus and add items for existing content such as pages, posts, categories, tags, formats, or custom links.').'</p>'; |
|
498 | + if (current_theme_supports('widgets')) { |
|
499 | + $description .= '<p>'.sprintf(__('Menus can be displayed in locations defined by your theme or in <a href="%s">widget areas</a> by adding a “Custom Menu” widget.'), "javascript:wp.customize.panel( 'widgets' ).focus();").'</p>'; |
|
500 | 500 | } else { |
501 | - $description .= '<p>' . __( 'Menus can be displayed in locations defined by your theme.' ) . '</p>'; |
|
501 | + $description .= '<p>'.__('Menus can be displayed in locations defined by your theme.').'</p>'; |
|
502 | 502 | } |
503 | - $this->manager->add_panel( new WP_Customize_Nav_Menus_Panel( $this->manager, 'nav_menus', array( |
|
504 | - 'title' => __( 'Menus' ), |
|
503 | + $this->manager->add_panel(new WP_Customize_Nav_Menus_Panel($this->manager, 'nav_menus', array( |
|
504 | + 'title' => __('Menus'), |
|
505 | 505 | 'description' => $description, |
506 | 506 | 'priority' => 100, |
507 | 507 | // 'theme_supports' => 'menus|widgets', @todo allow multiple theme supports |
508 | - ) ) ); |
|
508 | + ))); |
|
509 | 509 | $menus = wp_get_nav_menus(); |
510 | 510 | |
511 | 511 | // Menu locations. |
512 | 512 | $locations = get_registered_nav_menus(); |
513 | - $num_locations = count( array_keys( $locations ) ); |
|
514 | - if ( 1 == $num_locations ) { |
|
515 | - $description = '<p>' . __( 'Your theme supports one menu. Select which menu you would like to use.' ); |
|
513 | + $num_locations = count(array_keys($locations)); |
|
514 | + if (1 == $num_locations) { |
|
515 | + $description = '<p>'.__('Your theme supports one menu. Select which menu you would like to use.'); |
|
516 | 516 | } else { |
517 | - $description = '<p>' . sprintf( _n( 'Your theme supports %s menu. Select which menu appears in each location.', 'Your theme supports %s menus. Select which menu appears in each location.', $num_locations ), number_format_i18n( $num_locations ) ); |
|
517 | + $description = '<p>'.sprintf(_n('Your theme supports %s menu. Select which menu appears in each location.', 'Your theme supports %s menus. Select which menu appears in each location.', $num_locations), number_format_i18n($num_locations)); |
|
518 | 518 | } |
519 | - $description .= '</p><p>' . __( 'You can also place menus in widget areas with the Custom Menu widget.' ) . '</p>'; |
|
519 | + $description .= '</p><p>'.__('You can also place menus in widget areas with the Custom Menu widget.').'</p>'; |
|
520 | 520 | |
521 | - $this->manager->add_section( 'menu_locations', array( |
|
522 | - 'title' => __( 'Menu Locations' ), |
|
521 | + $this->manager->add_section('menu_locations', array( |
|
522 | + 'title' => __('Menu Locations'), |
|
523 | 523 | 'panel' => 'nav_menus', |
524 | 524 | 'priority' => 5, |
525 | 525 | 'description' => $description, |
526 | - ) ); |
|
526 | + )); |
|
527 | 527 | |
528 | - $choices = array( '0' => __( '— Select —' ) ); |
|
529 | - foreach ( $menus as $menu ) { |
|
530 | - $choices[ $menu->term_id ] = wp_html_excerpt( $menu->name, 40, '…' ); |
|
528 | + $choices = array('0' => __('— Select —')); |
|
529 | + foreach ($menus as $menu) { |
|
530 | + $choices[$menu->term_id] = wp_html_excerpt($menu->name, 40, '…'); |
|
531 | 531 | } |
532 | 532 | |
533 | - foreach ( $locations as $location => $description ) { |
|
533 | + foreach ($locations as $location => $description) { |
|
534 | 534 | $setting_id = "nav_menu_locations[{$location}]"; |
535 | 535 | |
536 | - $setting = $this->manager->get_setting( $setting_id ); |
|
537 | - if ( $setting ) { |
|
538 | - $setting->transport = isset( $this->manager->selective_refresh ) ? 'postMessage' : 'refresh'; |
|
539 | - remove_filter( "customize_sanitize_{$setting_id}", 'absint' ); |
|
540 | - add_filter( "customize_sanitize_{$setting_id}", array( $this, 'intval_base10' ) ); |
|
536 | + $setting = $this->manager->get_setting($setting_id); |
|
537 | + if ($setting) { |
|
538 | + $setting->transport = isset($this->manager->selective_refresh) ? 'postMessage' : 'refresh'; |
|
539 | + remove_filter("customize_sanitize_{$setting_id}", 'absint'); |
|
540 | + add_filter("customize_sanitize_{$setting_id}", array($this, 'intval_base10')); |
|
541 | 541 | } else { |
542 | - $this->manager->add_setting( $setting_id, array( |
|
543 | - 'sanitize_callback' => array( $this, 'intval_base10' ), |
|
542 | + $this->manager->add_setting($setting_id, array( |
|
543 | + 'sanitize_callback' => array($this, 'intval_base10'), |
|
544 | 544 | 'theme_supports' => 'menus', |
545 | 545 | 'type' => 'theme_mod', |
546 | - 'transport' => isset( $this->manager->selective_refresh ) ? 'postMessage' : 'refresh', |
|
546 | + 'transport' => isset($this->manager->selective_refresh) ? 'postMessage' : 'refresh', |
|
547 | 547 | 'default' => 0, |
548 | - ) ); |
|
548 | + )); |
|
549 | 549 | } |
550 | 550 | |
551 | - $this->manager->add_control( new WP_Customize_Nav_Menu_Location_Control( $this->manager, $setting_id, array( |
|
551 | + $this->manager->add_control(new WP_Customize_Nav_Menu_Location_Control($this->manager, $setting_id, array( |
|
552 | 552 | 'label' => $description, |
553 | 553 | 'location_id' => $location, |
554 | 554 | 'section' => 'menu_locations', |
555 | 555 | 'choices' => $choices, |
556 | - ) ) ); |
|
556 | + ))); |
|
557 | 557 | } |
558 | 558 | |
559 | 559 | // Register each menu as a Customizer section, and add each menu item to each menu. |
560 | - foreach ( $menus as $menu ) { |
|
560 | + foreach ($menus as $menu) { |
|
561 | 561 | $menu_id = $menu->term_id; |
562 | 562 | |
563 | 563 | // Create a section for each menu. |
564 | - $section_id = 'nav_menu[' . $menu_id . ']'; |
|
565 | - $this->manager->add_section( new WP_Customize_Nav_Menu_Section( $this->manager, $section_id, array( |
|
566 | - 'title' => html_entity_decode( $menu->name, ENT_QUOTES, get_bloginfo( 'charset' ) ), |
|
564 | + $section_id = 'nav_menu['.$menu_id.']'; |
|
565 | + $this->manager->add_section(new WP_Customize_Nav_Menu_Section($this->manager, $section_id, array( |
|
566 | + 'title' => html_entity_decode($menu->name, ENT_QUOTES, get_bloginfo('charset')), |
|
567 | 567 | 'priority' => 10, |
568 | 568 | 'panel' => 'nav_menus', |
569 | - ) ) ); |
|
569 | + ))); |
|
570 | 570 | |
571 | - $nav_menu_setting_id = 'nav_menu[' . $menu_id . ']'; |
|
572 | - $this->manager->add_setting( new WP_Customize_Nav_Menu_Setting( $this->manager, $nav_menu_setting_id, array( |
|
573 | - 'transport' => isset( $this->manager->selective_refresh ) ? 'postMessage' : 'refresh', |
|
574 | - ) ) ); |
|
571 | + $nav_menu_setting_id = 'nav_menu['.$menu_id.']'; |
|
572 | + $this->manager->add_setting(new WP_Customize_Nav_Menu_Setting($this->manager, $nav_menu_setting_id, array( |
|
573 | + 'transport' => isset($this->manager->selective_refresh) ? 'postMessage' : 'refresh', |
|
574 | + ))); |
|
575 | 575 | |
576 | 576 | // Add the menu contents. |
577 | - $menu_items = (array) wp_get_nav_menu_items( $menu_id ); |
|
577 | + $menu_items = (array) wp_get_nav_menu_items($menu_id); |
|
578 | 578 | |
579 | - foreach ( array_values( $menu_items ) as $i => $item ) { |
|
579 | + foreach (array_values($menu_items) as $i => $item) { |
|
580 | 580 | |
581 | 581 | // Create a setting for each menu item (which doesn't actually manage data, currently). |
582 | - $menu_item_setting_id = 'nav_menu_item[' . $item->ID . ']'; |
|
582 | + $menu_item_setting_id = 'nav_menu_item['.$item->ID.']'; |
|
583 | 583 | |
584 | 584 | $value = (array) $item; |
585 | 585 | $value['nav_menu_term_id'] = $menu_id; |
586 | - $this->manager->add_setting( new WP_Customize_Nav_Menu_Item_Setting( $this->manager, $menu_item_setting_id, array( |
|
586 | + $this->manager->add_setting(new WP_Customize_Nav_Menu_Item_Setting($this->manager, $menu_item_setting_id, array( |
|
587 | 587 | 'value' => $value, |
588 | - 'transport' => isset( $this->manager->selective_refresh ) ? 'postMessage' : 'refresh', |
|
589 | - ) ) ); |
|
588 | + 'transport' => isset($this->manager->selective_refresh) ? 'postMessage' : 'refresh', |
|
589 | + ))); |
|
590 | 590 | |
591 | 591 | // Create a control for each menu item. |
592 | - $this->manager->add_control( new WP_Customize_Nav_Menu_Item_Control( $this->manager, $menu_item_setting_id, array( |
|
592 | + $this->manager->add_control(new WP_Customize_Nav_Menu_Item_Control($this->manager, $menu_item_setting_id, array( |
|
593 | 593 | 'label' => $item->title, |
594 | 594 | 'section' => $section_id, |
595 | 595 | 'priority' => 10 + $i, |
596 | - ) ) ); |
|
596 | + ))); |
|
597 | 597 | } |
598 | 598 | |
599 | 599 | // Note: other controls inside of this section get added dynamically in JS via the MenuSection.ready() function. |
600 | 600 | } |
601 | 601 | |
602 | 602 | // Add the add-new-menu section and controls. |
603 | - $this->manager->add_section( new WP_Customize_New_Menu_Section( $this->manager, 'add_menu', array( |
|
604 | - 'title' => __( 'Add a Menu' ), |
|
603 | + $this->manager->add_section(new WP_Customize_New_Menu_Section($this->manager, 'add_menu', array( |
|
604 | + 'title' => __('Add a Menu'), |
|
605 | 605 | 'panel' => 'nav_menus', |
606 | 606 | 'priority' => 999, |
607 | - ) ) ); |
|
607 | + ))); |
|
608 | 608 | |
609 | - $this->manager->add_control( 'new_menu_name', array( |
|
609 | + $this->manager->add_control('new_menu_name', array( |
|
610 | 610 | 'label' => '', |
611 | 611 | 'section' => 'add_menu', |
612 | 612 | 'type' => 'text', |
613 | 613 | 'settings' => array(), |
614 | 614 | 'input_attrs' => array( |
615 | 615 | 'class' => 'menu-name-field', |
616 | - 'placeholder' => __( 'New menu name' ), |
|
616 | + 'placeholder' => __('New menu name'), |
|
617 | 617 | ), |
618 | - ) ); |
|
618 | + )); |
|
619 | 619 | |
620 | - $this->manager->add_control( new WP_Customize_New_Menu_Control( $this->manager, 'create_new_menu', array( |
|
620 | + $this->manager->add_control(new WP_Customize_New_Menu_Control($this->manager, 'create_new_menu', array( |
|
621 | 621 | 'section' => 'add_menu', |
622 | 622 | 'settings' => array(), |
623 | - ) ) ); |
|
623 | + ))); |
|
624 | 624 | } |
625 | 625 | |
626 | 626 | /** |
@@ -635,8 +635,8 @@ discard block |
||
635 | 635 | * @param mixed $value Number to convert. |
636 | 636 | * @return int Integer. |
637 | 637 | */ |
638 | - public function intval_base10( $value ) { |
|
639 | - return intval( $value, 10 ); |
|
638 | + public function intval_base10($value) { |
|
639 | + return intval($value, 10); |
|
640 | 640 | } |
641 | 641 | |
642 | 642 | /** |
@@ -650,9 +650,9 @@ discard block |
||
650 | 650 | public function available_item_types() { |
651 | 651 | $item_types = array(); |
652 | 652 | |
653 | - $post_types = get_post_types( array( 'show_in_nav_menus' => true ), 'objects' ); |
|
654 | - if ( $post_types ) { |
|
655 | - foreach ( $post_types as $slug => $post_type ) { |
|
653 | + $post_types = get_post_types(array('show_in_nav_menus' => true), 'objects'); |
|
654 | + if ($post_types) { |
|
655 | + foreach ($post_types as $slug => $post_type) { |
|
656 | 656 | $item_types[] = array( |
657 | 657 | 'title' => $post_type->labels->name, |
658 | 658 | 'type' => 'post_type', |
@@ -661,10 +661,10 @@ discard block |
||
661 | 661 | } |
662 | 662 | } |
663 | 663 | |
664 | - $taxonomies = get_taxonomies( array( 'show_in_nav_menus' => true ), 'objects' ); |
|
665 | - if ( $taxonomies ) { |
|
666 | - foreach ( $taxonomies as $slug => $taxonomy ) { |
|
667 | - if ( 'post_format' === $taxonomy && ! current_theme_supports( 'post-formats' ) ) { |
|
664 | + $taxonomies = get_taxonomies(array('show_in_nav_menus' => true), 'objects'); |
|
665 | + if ($taxonomies) { |
|
666 | + foreach ($taxonomies as $slug => $taxonomy) { |
|
667 | + if ('post_format' === $taxonomy && ! current_theme_supports('post-formats')) { |
|
668 | 668 | continue; |
669 | 669 | } |
670 | 670 | $item_types[] = array( |
@@ -682,7 +682,7 @@ discard block |
||
682 | 682 | * |
683 | 683 | * @param array $item_types Custom menu item types. |
684 | 684 | */ |
685 | - $item_types = apply_filters( 'customize_nav_menu_available_item_types', $item_types ); |
|
685 | + $item_types = apply_filters('customize_nav_menu_available_item_types', $item_types); |
|
686 | 686 | |
687 | 687 | return $item_types; |
688 | 688 | } |
@@ -708,7 +708,7 @@ discard block |
||
708 | 708 | <button type="button" class="button-link item-add"> |
709 | 709 | <span class="screen-reader-text"><?php |
710 | 710 | /* translators: 1: Title of a menu item, 2: Type of a menu item */ |
711 | - printf( __( 'Add to menu: %1$s (%2$s)' ), '{{ data.title || wp.customize.Menus.data.l10n.untitled }}', '{{ data.type_label }}' ); |
|
711 | + printf(__('Add to menu: %1$s (%2$s)'), '{{ data.title || wp.customize.Menus.data.l10n.untitled }}', '{{ data.type_label }}'); |
|
712 | 712 | ?></span> |
713 | 713 | </button> |
714 | 714 | </div> |
@@ -721,10 +721,10 @@ discard block |
||
721 | 721 | <?php |
722 | 722 | printf( |
723 | 723 | '<button type="button" class="menus-move-up">%1$s</button><button type="button" class="menus-move-down">%2$s</button><button type="button" class="menus-move-left">%3$s</button><button type="button" class="menus-move-right">%4$s</button>', |
724 | - __( 'Move up' ), |
|
725 | - __( 'Move down' ), |
|
726 | - __( 'Move one level up' ), |
|
727 | - __( 'Move one level down' ) |
|
724 | + __('Move up'), |
|
725 | + __('Move down'), |
|
726 | + __('Move one level up'), |
|
727 | + __('Move one level down') |
|
728 | 728 | ); |
729 | 729 | ?> |
730 | 730 | </div> |
@@ -743,49 +743,49 @@ discard block |
||
743 | 743 | <div id="available-menu-items" class="accordion-container"> |
744 | 744 | <div class="customize-section-title"> |
745 | 745 | <button type="button" class="customize-section-back" tabindex="-1"> |
746 | - <span class="screen-reader-text"><?php _e( 'Back' ); ?></span> |
|
746 | + <span class="screen-reader-text"><?php _e('Back'); ?></span> |
|
747 | 747 | </button> |
748 | 748 | <h3> |
749 | 749 | <span class="customize-action"> |
750 | 750 | <?php |
751 | 751 | /* translators: ▸ is the unicode right-pointing triangle, and %s is the section title in the Customizer */ |
752 | - printf( __( 'Customizing ▸ %s' ), esc_html( $this->manager->get_panel( 'nav_menus' )->title ) ); |
|
752 | + printf(__('Customizing ▸ %s'), esc_html($this->manager->get_panel('nav_menus')->title)); |
|
753 | 753 | ?> |
754 | 754 | </span> |
755 | - <?php _e( 'Add Menu Items' ); ?> |
|
755 | + <?php _e('Add Menu Items'); ?> |
|
756 | 756 | </h3> |
757 | 757 | </div> |
758 | 758 | <div id="available-menu-items-search" class="accordion-section cannot-expand"> |
759 | 759 | <div class="accordion-section-title"> |
760 | - <label class="screen-reader-text" for="menu-items-search"><?php _e( 'Search Menu Items' ); ?></label> |
|
761 | - <input type="text" id="menu-items-search" placeholder="<?php esc_attr_e( 'Search menu items…' ) ?>" aria-describedby="menu-items-search-desc" /> |
|
762 | - <p class="screen-reader-text" id="menu-items-search-desc"><?php _e( 'The search results will be updated as you type.' ); ?></p> |
|
760 | + <label class="screen-reader-text" for="menu-items-search"><?php _e('Search Menu Items'); ?></label> |
|
761 | + <input type="text" id="menu-items-search" placeholder="<?php esc_attr_e('Search menu items…') ?>" aria-describedby="menu-items-search-desc" /> |
|
762 | + <p class="screen-reader-text" id="menu-items-search-desc"><?php _e('The search results will be updated as you type.'); ?></p> |
|
763 | 763 | <span class="spinner"></span> |
764 | - <span class="clear-results"><span class="screen-reader-text"><?php _e( 'Clear Results' ); ?></span></span> |
|
764 | + <span class="clear-results"><span class="screen-reader-text"><?php _e('Clear Results'); ?></span></span> |
|
765 | 765 | </div> |
766 | 766 | <ul class="accordion-section-content" data-type="search"></ul> |
767 | 767 | </div> |
768 | 768 | <div id="new-custom-menu-item" class="accordion-section"> |
769 | 769 | <h4 class="accordion-section-title" role="presentation"> |
770 | - <?php _e( 'Custom Links' ); ?> |
|
770 | + <?php _e('Custom Links'); ?> |
|
771 | 771 | <button type="button" class="button-link" aria-expanded="false"> |
772 | - <span class="screen-reader-text"><?php _e( 'Toggle section: Custom Links' ); ?></span> |
|
772 | + <span class="screen-reader-text"><?php _e('Toggle section: Custom Links'); ?></span> |
|
773 | 773 | <span class="toggle-indicator" aria-hidden="true"></span> |
774 | 774 | </button> |
775 | 775 | </h4> |
776 | 776 | <div class="accordion-section-content customlinkdiv"> |
777 | 777 | <input type="hidden" value="custom" id="custom-menu-item-type" name="menu-item[-1][menu-item-type]" /> |
778 | 778 | <p id="menu-item-url-wrap" class="wp-clearfix"> |
779 | - <label class="howto" for="custom-menu-item-url"><?php _e( 'URL' ); ?></label> |
|
779 | + <label class="howto" for="custom-menu-item-url"><?php _e('URL'); ?></label> |
|
780 | 780 | <input id="custom-menu-item-url" name="menu-item[-1][menu-item-url]" type="text" class="code menu-item-textbox" value="http://"> |
781 | 781 | </p> |
782 | 782 | <p id="menu-item-name-wrap" class="wp-clearfix"> |
783 | - <label class="howto" for="custom-menu-item-name"><?php _e( 'Link Text' ); ?></label> |
|
783 | + <label class="howto" for="custom-menu-item-name"><?php _e('Link Text'); ?></label> |
|
784 | 784 | <input id="custom-menu-item-name" name="menu-item[-1][menu-item-title]" type="text" class="regular-text menu-item-textbox"> |
785 | 785 | </p> |
786 | 786 | <p class="button-controls"> |
787 | 787 | <span class="add-to-menu"> |
788 | - <input type="submit" class="button-secondary submit-add-to-menu right" value="<?php esc_attr_e( 'Add to Menu' ); ?>" name="add-custom-menu-item" id="custom-menu-item-submit"> |
|
788 | + <input type="submit" class="button-secondary submit-add-to-menu right" value="<?php esc_attr_e('Add to Menu'); ?>" name="add-custom-menu-item" id="custom-menu-item-submit"> |
|
789 | 789 | <span class="spinner"></span> |
790 | 790 | </span> |
791 | 791 | </p> |
@@ -793,22 +793,22 @@ discard block |
||
793 | 793 | </div> |
794 | 794 | <?php |
795 | 795 | // Containers for per-post-type item browsing; items added with JS. |
796 | - foreach ( $this->available_item_types() as $available_item_type ) { |
|
797 | - $id = sprintf( 'available-menu-items-%s-%s', $available_item_type['type'], $available_item_type['object'] ); |
|
796 | + foreach ($this->available_item_types() as $available_item_type) { |
|
797 | + $id = sprintf('available-menu-items-%s-%s', $available_item_type['type'], $available_item_type['object']); |
|
798 | 798 | ?> |
799 | - <div id="<?php echo esc_attr( $id ); ?>" class="accordion-section"> |
|
799 | + <div id="<?php echo esc_attr($id); ?>" class="accordion-section"> |
|
800 | 800 | <h4 class="accordion-section-title" role="presentation"> |
801 | - <?php echo esc_html( $available_item_type['title'] ); ?> |
|
801 | + <?php echo esc_html($available_item_type['title']); ?> |
|
802 | 802 | <span class="spinner"></span> |
803 | - <span class="no-items"><?php _e( 'No items' ); ?></span> |
|
803 | + <span class="no-items"><?php _e('No items'); ?></span> |
|
804 | 804 | <button type="button" class="button-link" aria-expanded="false"> |
805 | 805 | <span class="screen-reader-text"><?php |
806 | 806 | /* translators: %s: Title of a section with menu items */ |
807 | - printf( __( 'Toggle section: %s' ), esc_html( $available_item_type['title'] ) ); ?></span> |
|
807 | + printf(__('Toggle section: %s'), esc_html($available_item_type['title'])); ?></span> |
|
808 | 808 | <span class="toggle-indicator" aria-hidden="true"></span> |
809 | 809 | </button> |
810 | 810 | </h4> |
811 | - <ul class="accordion-section-content" data-type="<?php echo esc_attr( $available_item_type['type'] ); ?>" data-object="<?php echo esc_attr( $available_item_type['object'] ); ?>"></ul> |
|
811 | + <ul class="accordion-section-content" data-type="<?php echo esc_attr($available_item_type['type']); ?>" data-object="<?php echo esc_attr($available_item_type['object']); ?>"></ul> |
|
812 | 812 | </div> |
813 | 813 | <?php |
814 | 814 | } |
@@ -840,17 +840,17 @@ discard block |
||
840 | 840 | * @param string $partial_id Partial ID. |
841 | 841 | * @return array Partial args. |
842 | 842 | */ |
843 | - public function customize_dynamic_partial_args( $partial_args, $partial_id ) { |
|
843 | + public function customize_dynamic_partial_args($partial_args, $partial_id) { |
|
844 | 844 | |
845 | - if ( preg_match( '/^nav_menu_instance\[[0-9a-f]{32}\]$/', $partial_id ) ) { |
|
846 | - if ( false === $partial_args ) { |
|
845 | + if (preg_match('/^nav_menu_instance\[[0-9a-f]{32}\]$/', $partial_id)) { |
|
846 | + if (false === $partial_args) { |
|
847 | 847 | $partial_args = array(); |
848 | 848 | } |
849 | 849 | $partial_args = array_merge( |
850 | 850 | $partial_args, |
851 | 851 | array( |
852 | 852 | 'type' => 'nav_menu_instance', |
853 | - 'render_callback' => array( $this, 'render_nav_menu_partial' ), |
|
853 | + 'render_callback' => array($this, 'render_nav_menu_partial'), |
|
854 | 854 | 'container_inclusive' => true, |
855 | 855 | 'settings' => array(), // Empty because the nav menu instance may relate to a menu or a location. |
856 | 856 | 'capability' => 'edit_theme_options', |
@@ -868,11 +868,11 @@ discard block |
||
868 | 868 | * @access public |
869 | 869 | */ |
870 | 870 | public function customize_preview_init() { |
871 | - add_action( 'wp_enqueue_scripts', array( $this, 'customize_preview_enqueue_deps' ) ); |
|
872 | - add_filter( 'wp_nav_menu_args', array( $this, 'filter_wp_nav_menu_args' ), 1000 ); |
|
873 | - add_filter( 'wp_nav_menu', array( $this, 'filter_wp_nav_menu' ), 10, 2 ); |
|
874 | - add_filter( 'wp_footer', array( $this, 'export_preview_data' ), 1 ); |
|
875 | - add_filter( 'customize_render_partials_response', array( $this, 'export_partial_rendered_nav_menu_instances' ) ); |
|
871 | + add_action('wp_enqueue_scripts', array($this, 'customize_preview_enqueue_deps')); |
|
872 | + add_filter('wp_nav_menu_args', array($this, 'filter_wp_nav_menu_args'), 1000); |
|
873 | + add_filter('wp_nav_menu', array($this, 'filter_wp_nav_menu'), 10, 2); |
|
874 | + add_filter('wp_footer', array($this, 'export_preview_data'), 1); |
|
875 | + add_filter('customize_render_partials_response', array($this, 'export_partial_rendered_nav_menu_instances')); |
|
876 | 876 | } |
877 | 877 | |
878 | 878 | /** |
@@ -886,7 +886,7 @@ discard block |
||
886 | 886 | * @param array $args An array containing wp_nav_menu() arguments. |
887 | 887 | * @return array Arguments. |
888 | 888 | */ |
889 | - public function filter_wp_nav_menu_args( $args ) { |
|
889 | + public function filter_wp_nav_menu_args($args) { |
|
890 | 890 | /* |
891 | 891 | * The following conditions determine whether or not this instance of |
892 | 892 | * wp_nav_menu() can use selective refreshed. A wp_nav_menu() can be |
@@ -894,25 +894,25 @@ discard block |
||
894 | 894 | */ |
895 | 895 | $can_partial_refresh = ( |
896 | 896 | // ...if wp_nav_menu() is directly echoing out the menu (and thus isn't manipulating the string after generated), |
897 | - ! empty( $args['echo'] ) |
|
897 | + ! empty($args['echo']) |
|
898 | 898 | && |
899 | 899 | // ...and if the fallback_cb can be serialized to JSON, since it will be included in the placement context data, |
900 | - ( empty( $args['fallback_cb'] ) || is_string( $args['fallback_cb'] ) ) |
|
900 | + (empty($args['fallback_cb']) || is_string($args['fallback_cb'])) |
|
901 | 901 | && |
902 | 902 | // ...and if the walker can also be serialized to JSON, since it will be included in the placement context data as well, |
903 | - ( empty( $args['walker'] ) || is_string( $args['walker'] ) ) |
|
903 | + (empty($args['walker']) || is_string($args['walker'])) |
|
904 | 904 | // ...and if it has a theme location assigned or an assigned menu to display, |
905 | 905 | && ( |
906 | - ! empty( $args['theme_location'] ) |
|
906 | + ! empty($args['theme_location']) |
|
907 | 907 | || |
908 | - ( ! empty( $args['menu'] ) && ( is_numeric( $args['menu'] ) || is_object( $args['menu'] ) ) ) |
|
908 | + ( ! empty($args['menu']) && (is_numeric($args['menu']) || is_object($args['menu']))) |
|
909 | 909 | ) |
910 | 910 | && |
911 | 911 | // ...and if the nav menu would be rendered with a wrapper container element (upon which to attach data-* attributes). |
912 | 912 | ( |
913 | - ! empty( $args['container'] ) |
|
913 | + ! empty($args['container']) |
|
914 | 914 | || |
915 | - ( isset( $args['items_wrap'] ) && '<' === substr( $args['items_wrap'], 0, 1 ) ) |
|
915 | + (isset($args['items_wrap']) && '<' === substr($args['items_wrap'], 0, 1)) |
|
916 | 916 | ) |
917 | 917 | ); |
918 | 918 | $args['can_partial_refresh'] = $can_partial_refresh; |
@@ -920,7 +920,7 @@ discard block |
||
920 | 920 | $exported_args = $args; |
921 | 921 | |
922 | 922 | // Empty out args which may not be JSON-serializable. |
923 | - if ( ! $can_partial_refresh ) { |
|
923 | + if ( ! $can_partial_refresh) { |
|
924 | 924 | $exported_args['fallback_cb'] = ''; |
925 | 925 | $exported_args['walker'] = ''; |
926 | 926 | } |
@@ -929,15 +929,15 @@ discard block |
||
929 | 929 | * Replace object menu arg with a term_id menu arg, as this exports better |
930 | 930 | * to JS and is easier to compare hashes. |
931 | 931 | */ |
932 | - if ( ! empty( $exported_args['menu'] ) && is_object( $exported_args['menu'] ) ) { |
|
932 | + if ( ! empty($exported_args['menu']) && is_object($exported_args['menu'])) { |
|
933 | 933 | $exported_args['menu'] = $exported_args['menu']->term_id; |
934 | 934 | } |
935 | 935 | |
936 | - ksort( $exported_args ); |
|
937 | - $exported_args['args_hmac'] = $this->hash_nav_menu_args( $exported_args ); |
|
936 | + ksort($exported_args); |
|
937 | + $exported_args['args_hmac'] = $this->hash_nav_menu_args($exported_args); |
|
938 | 938 | |
939 | 939 | $args['customize_preview_nav_menus_args'] = $exported_args; |
940 | - $this->preview_nav_menu_instance_args[ $exported_args['args_hmac'] ] = $exported_args; |
|
940 | + $this->preview_nav_menu_instance_args[$exported_args['args_hmac']] = $exported_args; |
|
941 | 941 | return $args; |
942 | 942 | } |
943 | 943 | |
@@ -955,12 +955,12 @@ discard block |
||
955 | 955 | * @param object $args An object containing wp_nav_menu() arguments. |
956 | 956 | * @return null |
957 | 957 | */ |
958 | - public function filter_wp_nav_menu( $nav_menu_content, $args ) { |
|
959 | - if ( isset( $args->customize_preview_nav_menus_args['can_partial_refresh'] ) && $args->customize_preview_nav_menus_args['can_partial_refresh'] ) { |
|
960 | - $attributes = sprintf( ' data-customize-partial-id="%s"', esc_attr( 'nav_menu_instance[' . $args->customize_preview_nav_menus_args['args_hmac'] . ']' ) ); |
|
958 | + public function filter_wp_nav_menu($nav_menu_content, $args) { |
|
959 | + if (isset($args->customize_preview_nav_menus_args['can_partial_refresh']) && $args->customize_preview_nav_menus_args['can_partial_refresh']) { |
|
960 | + $attributes = sprintf(' data-customize-partial-id="%s"', esc_attr('nav_menu_instance['.$args->customize_preview_nav_menus_args['args_hmac'].']')); |
|
961 | 961 | $attributes .= ' data-customize-partial-type="nav_menu_instance"'; |
962 | - $attributes .= sprintf( ' data-customize-partial-placement-context="%s"', esc_attr( wp_json_encode( $args->customize_preview_nav_menus_args ) ) ); |
|
963 | - $nav_menu_content = preg_replace( '#^(<\w+)#', '$1 ' . $attributes, $nav_menu_content, 1 ); |
|
962 | + $attributes .= sprintf(' data-customize-partial-placement-context="%s"', esc_attr(wp_json_encode($args->customize_preview_nav_menus_args))); |
|
963 | + $nav_menu_content = preg_replace('#^(<\w+)#', '$1 '.$attributes, $nav_menu_content, 1); |
|
964 | 964 | } |
965 | 965 | return $nav_menu_content; |
966 | 966 | } |
@@ -977,8 +977,8 @@ discard block |
||
977 | 977 | * @param array $args The arguments to hash. |
978 | 978 | * @return string Hashed nav menu arguments. |
979 | 979 | */ |
980 | - public function hash_nav_menu_args( $args ) { |
|
981 | - return wp_hash( serialize( $args ) ); |
|
980 | + public function hash_nav_menu_args($args) { |
|
981 | + return wp_hash(serialize($args)); |
|
982 | 982 | } |
983 | 983 | |
984 | 984 | /** |
@@ -988,13 +988,13 @@ discard block |
||
988 | 988 | * @access public |
989 | 989 | */ |
990 | 990 | public function customize_preview_enqueue_deps() { |
991 | - if ( isset( $this->manager->selective_refresh ) ) { |
|
991 | + if (isset($this->manager->selective_refresh)) { |
|
992 | 992 | $script = wp_scripts()->registered['customize-preview-nav-menus']; |
993 | 993 | $script->deps[] = 'customize-selective-refresh'; |
994 | 994 | } |
995 | 995 | |
996 | - wp_enqueue_script( 'customize-preview-nav-menus' ); // Note that we have overridden this. |
|
997 | - wp_enqueue_style( 'customize-preview' ); |
|
996 | + wp_enqueue_script('customize-preview-nav-menus'); // Note that we have overridden this. |
|
997 | + wp_enqueue_style('customize-preview'); |
|
998 | 998 | } |
999 | 999 | |
1000 | 1000 | /** |
@@ -1009,7 +1009,7 @@ discard block |
||
1009 | 1009 | $exports = array( |
1010 | 1010 | 'navMenuInstanceArgs' => $this->preview_nav_menu_instance_args, |
1011 | 1011 | ); |
1012 | - printf( '<script>var _wpCustomizePreviewNavMenusExports = %s;</script>', wp_json_encode( $exports ) ); |
|
1012 | + printf('<script>var _wpCustomizePreviewNavMenusExports = %s;</script>', wp_json_encode($exports)); |
|
1013 | 1013 | } |
1014 | 1014 | |
1015 | 1015 | /** |
@@ -1021,7 +1021,7 @@ discard block |
||
1021 | 1021 | * @param array $response Response. |
1022 | 1022 | * @return array Response. |
1023 | 1023 | */ |
1024 | - public function export_partial_rendered_nav_menu_instances( $response ) { |
|
1024 | + public function export_partial_rendered_nav_menu_instances($response) { |
|
1025 | 1025 | $response['nav_menu_instance_args'] = $this->preview_nav_menu_instance_args; |
1026 | 1026 | return $response; |
1027 | 1027 | } |
@@ -1038,25 +1038,25 @@ discard block |
||
1038 | 1038 | * @param array $nav_menu_args Nav menu args supplied as container context. |
1039 | 1039 | * @return string|false |
1040 | 1040 | */ |
1041 | - public function render_nav_menu_partial( $partial, $nav_menu_args ) { |
|
1042 | - unset( $partial ); |
|
1041 | + public function render_nav_menu_partial($partial, $nav_menu_args) { |
|
1042 | + unset($partial); |
|
1043 | 1043 | |
1044 | - if ( ! isset( $nav_menu_args['args_hmac'] ) ) { |
|
1044 | + if ( ! isset($nav_menu_args['args_hmac'])) { |
|
1045 | 1045 | // Error: missing_args_hmac. |
1046 | 1046 | return false; |
1047 | 1047 | } |
1048 | 1048 | |
1049 | 1049 | $nav_menu_args_hmac = $nav_menu_args['args_hmac']; |
1050 | - unset( $nav_menu_args['args_hmac'] ); |
|
1050 | + unset($nav_menu_args['args_hmac']); |
|
1051 | 1051 | |
1052 | - ksort( $nav_menu_args ); |
|
1053 | - if ( ! hash_equals( $this->hash_nav_menu_args( $nav_menu_args ), $nav_menu_args_hmac ) ) { |
|
1052 | + ksort($nav_menu_args); |
|
1053 | + if ( ! hash_equals($this->hash_nav_menu_args($nav_menu_args), $nav_menu_args_hmac)) { |
|
1054 | 1054 | // Error: args_hmac_mismatch. |
1055 | 1055 | return false; |
1056 | 1056 | } |
1057 | 1057 | |
1058 | 1058 | ob_start(); |
1059 | - wp_nav_menu( $nav_menu_args ); |
|
1059 | + wp_nav_menu($nav_menu_args); |
|
1060 | 1060 | $content = ob_get_clean(); |
1061 | 1061 | |
1062 | 1062 | return $content; |
@@ -25,7 +25,7 @@ discard block |
||
25 | 25 | */ |
26 | 26 | public static $early_providers = array(); |
27 | 27 | |
28 | - private $compat_methods = array( '_fetch_with_format', '_parse_json', '_parse_xml', '_parse_body' ); |
|
28 | + private $compat_methods = array('_fetch_with_format', '_parse_json', '_parse_xml', '_parse_body'); |
|
29 | 29 | |
30 | 30 | /** |
31 | 31 | * Constructor |
@@ -33,62 +33,62 @@ discard block |
||
33 | 33 | * @since 2.9.0 |
34 | 34 | */ |
35 | 35 | public function __construct() { |
36 | - $host = urlencode( home_url() ); |
|
36 | + $host = urlencode(home_url()); |
|
37 | 37 | $providers = array( |
38 | - '#http://((m|www)\.)?youtube\.com/watch.*#i' => array( 'http://www.youtube.com/oembed', true ), |
|
39 | - '#https://((m|www)\.)?youtube\.com/watch.*#i' => array( 'http://www.youtube.com/oembed?scheme=https', true ), |
|
40 | - '#http://((m|www)\.)?youtube\.com/playlist.*#i' => array( 'http://www.youtube.com/oembed', true ), |
|
41 | - '#https://((m|www)\.)?youtube\.com/playlist.*#i' => array( 'http://www.youtube.com/oembed?scheme=https', true ), |
|
42 | - '#http://youtu\.be/.*#i' => array( 'http://www.youtube.com/oembed', true ), |
|
43 | - '#https://youtu\.be/.*#i' => array( 'http://www.youtube.com/oembed?scheme=https', true ), |
|
44 | - '#https?://(.+\.)?vimeo\.com/.*#i' => array( 'http://vimeo.com/api/oembed.{format}', true ), |
|
45 | - '#https?://(www\.)?dailymotion\.com/.*#i' => array( 'https://www.dailymotion.com/services/oembed', true ), |
|
46 | - '#https?://dai.ly/.*#i' => array( 'https://www.dailymotion.com/services/oembed', true ), |
|
47 | - '#https?://(www\.)?flickr\.com/.*#i' => array( 'https://www.flickr.com/services/oembed/', true ), |
|
48 | - '#https?://flic\.kr/.*#i' => array( 'https://www.flickr.com/services/oembed/', true ), |
|
49 | - '#https?://(.+\.)?smugmug\.com/.*#i' => array( 'http://api.smugmug.com/services/oembed/', true ), |
|
50 | - '#https?://(www\.)?hulu\.com/watch/.*#i' => array( 'http://www.hulu.com/api/oembed.{format}', true ), |
|
51 | - 'http://i*.photobucket.com/albums/*' => array( 'http://api.photobucket.com/oembed', false ), |
|
52 | - 'http://gi*.photobucket.com/groups/*' => array( 'http://api.photobucket.com/oembed', false ), |
|
53 | - '#https?://(www\.)?scribd\.com/doc/.*#i' => array( 'http://www.scribd.com/services/oembed', true ), |
|
54 | - '#https?://wordpress.tv/.*#i' => array( 'http://wordpress.tv/oembed/', true ), |
|
55 | - '#https?://(.+\.)?polldaddy\.com/.*#i' => array( 'https://polldaddy.com/oembed/', true ), |
|
56 | - '#https?://poll\.fm/.*#i' => array( 'https://polldaddy.com/oembed/', true ), |
|
57 | - '#https?://(www\.)?funnyordie\.com/videos/.*#i' => array( 'http://www.funnyordie.com/oembed', true ), |
|
58 | - '#https?://(www\.)?twitter\.com/.+?/status(es)?/.*#i' => array( 'https://publish.twitter.com/oembed', true ), |
|
59 | - '#https?://(www\.)?twitter\.com/.+?/timelines/.*#i' => array( 'https://publish.twitter.com/oembed', true ), |
|
60 | - '#https?://(www\.)?twitter\.com/i/moments/.*#i' => array( 'https://publish.twitter.com/oembed', true ), |
|
61 | - '#https?://vine.co/v/.*#i' => array( 'https://vine.co/oembed.{format}', true ), |
|
62 | - '#https?://(www\.)?soundcloud\.com/.*#i' => array( 'http://soundcloud.com/oembed', true ), |
|
63 | - '#https?://(.+?\.)?slideshare\.net/.*#i' => array( 'https://www.slideshare.net/api/oembed/2', true ), |
|
64 | - '#https?://(www\.)?instagr(\.am|am\.com)/p/.*#i' => array( 'https://api.instagram.com/oembed', true ), |
|
65 | - '#https?://(open|play)\.spotify\.com/.*#i' => array( 'https://embed.spotify.com/oembed/', true ), |
|
66 | - '#https?://(.+\.)?imgur\.com/.*#i' => array( 'http://api.imgur.com/oembed', true ), |
|
67 | - '#https?://(www\.)?meetu(\.ps|p\.com)/.*#i' => array( 'http://api.meetup.com/oembed', true ), |
|
68 | - '#https?://(www\.)?issuu\.com/.+/docs/.+#i' => array( 'http://issuu.com/oembed_wp', true ), |
|
69 | - '#https?://(www\.)?collegehumor\.com/video/.*#i' => array( 'http://www.collegehumor.com/oembed.{format}', true ), |
|
70 | - '#https?://(www\.)?mixcloud\.com/.*#i' => array( 'http://www.mixcloud.com/oembed', true ), |
|
71 | - '#https?://(www\.|embed\.)?ted\.com/talks/.*#i' => array( 'http://www.ted.com/talks/oembed.{format}', true ), |
|
72 | - '#https?://(www\.)?(animoto|video214)\.com/play/.*#i' => array( 'https://animoto.com/oembeds/create', true ), |
|
73 | - '#https?://(.+)\.tumblr\.com/post/.*#i' => array( 'https://www.tumblr.com/oembed/1.0', true ), |
|
74 | - '#https?://(www\.)?kickstarter\.com/projects/.*#i' => array( 'https://www.kickstarter.com/services/oembed', true ), |
|
75 | - '#https?://kck\.st/.*#i' => array( 'https://www.kickstarter.com/services/oembed', true ), |
|
76 | - '#https?://cloudup\.com/.*#i' => array( 'https://cloudup.com/oembed', true ), |
|
77 | - '#https?://(www\.)?reverbnation\.com/.*#i' => array( 'https://www.reverbnation.com/oembed', true ), |
|
78 | - '#https?://videopress.com/v/.*#' => array( 'https://public-api.wordpress.com/oembed/1.0/?for=' . $host, true ), |
|
79 | - '#https?://(www\.)?reddit\.com/r/[^/]+/comments/.*#i' => array( 'https://www.reddit.com/oembed', true ), |
|
80 | - '#https?://(www\.)?speakerdeck\.com/.*#i' => array( 'https://speakerdeck.com/oembed.{format}', true ), |
|
38 | + '#http://((m|www)\.)?youtube\.com/watch.*#i' => array('http://www.youtube.com/oembed', true), |
|
39 | + '#https://((m|www)\.)?youtube\.com/watch.*#i' => array('http://www.youtube.com/oembed?scheme=https', true), |
|
40 | + '#http://((m|www)\.)?youtube\.com/playlist.*#i' => array('http://www.youtube.com/oembed', true), |
|
41 | + '#https://((m|www)\.)?youtube\.com/playlist.*#i' => array('http://www.youtube.com/oembed?scheme=https', true), |
|
42 | + '#http://youtu\.be/.*#i' => array('http://www.youtube.com/oembed', true), |
|
43 | + '#https://youtu\.be/.*#i' => array('http://www.youtube.com/oembed?scheme=https', true), |
|
44 | + '#https?://(.+\.)?vimeo\.com/.*#i' => array('http://vimeo.com/api/oembed.{format}', true), |
|
45 | + '#https?://(www\.)?dailymotion\.com/.*#i' => array('https://www.dailymotion.com/services/oembed', true), |
|
46 | + '#https?://dai.ly/.*#i' => array('https://www.dailymotion.com/services/oembed', true), |
|
47 | + '#https?://(www\.)?flickr\.com/.*#i' => array('https://www.flickr.com/services/oembed/', true), |
|
48 | + '#https?://flic\.kr/.*#i' => array('https://www.flickr.com/services/oembed/', true), |
|
49 | + '#https?://(.+\.)?smugmug\.com/.*#i' => array('http://api.smugmug.com/services/oembed/', true), |
|
50 | + '#https?://(www\.)?hulu\.com/watch/.*#i' => array('http://www.hulu.com/api/oembed.{format}', true), |
|
51 | + 'http://i*.photobucket.com/albums/*' => array('http://api.photobucket.com/oembed', false), |
|
52 | + 'http://gi*.photobucket.com/groups/*' => array('http://api.photobucket.com/oembed', false), |
|
53 | + '#https?://(www\.)?scribd\.com/doc/.*#i' => array('http://www.scribd.com/services/oembed', true), |
|
54 | + '#https?://wordpress.tv/.*#i' => array('http://wordpress.tv/oembed/', true), |
|
55 | + '#https?://(.+\.)?polldaddy\.com/.*#i' => array('https://polldaddy.com/oembed/', true), |
|
56 | + '#https?://poll\.fm/.*#i' => array('https://polldaddy.com/oembed/', true), |
|
57 | + '#https?://(www\.)?funnyordie\.com/videos/.*#i' => array('http://www.funnyordie.com/oembed', true), |
|
58 | + '#https?://(www\.)?twitter\.com/.+?/status(es)?/.*#i' => array('https://publish.twitter.com/oembed', true), |
|
59 | + '#https?://(www\.)?twitter\.com/.+?/timelines/.*#i' => array('https://publish.twitter.com/oembed', true), |
|
60 | + '#https?://(www\.)?twitter\.com/i/moments/.*#i' => array('https://publish.twitter.com/oembed', true), |
|
61 | + '#https?://vine.co/v/.*#i' => array('https://vine.co/oembed.{format}', true), |
|
62 | + '#https?://(www\.)?soundcloud\.com/.*#i' => array('http://soundcloud.com/oembed', true), |
|
63 | + '#https?://(.+?\.)?slideshare\.net/.*#i' => array('https://www.slideshare.net/api/oembed/2', true), |
|
64 | + '#https?://(www\.)?instagr(\.am|am\.com)/p/.*#i' => array('https://api.instagram.com/oembed', true), |
|
65 | + '#https?://(open|play)\.spotify\.com/.*#i' => array('https://embed.spotify.com/oembed/', true), |
|
66 | + '#https?://(.+\.)?imgur\.com/.*#i' => array('http://api.imgur.com/oembed', true), |
|
67 | + '#https?://(www\.)?meetu(\.ps|p\.com)/.*#i' => array('http://api.meetup.com/oembed', true), |
|
68 | + '#https?://(www\.)?issuu\.com/.+/docs/.+#i' => array('http://issuu.com/oembed_wp', true), |
|
69 | + '#https?://(www\.)?collegehumor\.com/video/.*#i' => array('http://www.collegehumor.com/oembed.{format}', true), |
|
70 | + '#https?://(www\.)?mixcloud\.com/.*#i' => array('http://www.mixcloud.com/oembed', true), |
|
71 | + '#https?://(www\.|embed\.)?ted\.com/talks/.*#i' => array('http://www.ted.com/talks/oembed.{format}', true), |
|
72 | + '#https?://(www\.)?(animoto|video214)\.com/play/.*#i' => array('https://animoto.com/oembeds/create', true), |
|
73 | + '#https?://(.+)\.tumblr\.com/post/.*#i' => array('https://www.tumblr.com/oembed/1.0', true), |
|
74 | + '#https?://(www\.)?kickstarter\.com/projects/.*#i' => array('https://www.kickstarter.com/services/oembed', true), |
|
75 | + '#https?://kck\.st/.*#i' => array('https://www.kickstarter.com/services/oembed', true), |
|
76 | + '#https?://cloudup\.com/.*#i' => array('https://cloudup.com/oembed', true), |
|
77 | + '#https?://(www\.)?reverbnation\.com/.*#i' => array('https://www.reverbnation.com/oembed', true), |
|
78 | + '#https?://videopress.com/v/.*#' => array('https://public-api.wordpress.com/oembed/1.0/?for='.$host, true), |
|
79 | + '#https?://(www\.)?reddit\.com/r/[^/]+/comments/.*#i' => array('https://www.reddit.com/oembed', true), |
|
80 | + '#https?://(www\.)?speakerdeck\.com/.*#i' => array('https://speakerdeck.com/oembed.{format}', true), |
|
81 | 81 | ); |
82 | 82 | |
83 | - if ( ! empty( self::$early_providers['add'] ) ) { |
|
84 | - foreach ( self::$early_providers['add'] as $format => $data ) { |
|
85 | - $providers[ $format ] = $data; |
|
83 | + if ( ! empty(self::$early_providers['add'])) { |
|
84 | + foreach (self::$early_providers['add'] as $format => $data) { |
|
85 | + $providers[$format] = $data; |
|
86 | 86 | } |
87 | 87 | } |
88 | 88 | |
89 | - if ( ! empty( self::$early_providers['remove'] ) ) { |
|
90 | - foreach ( self::$early_providers['remove'] as $format ) { |
|
91 | - unset( $providers[ $format ] ); |
|
89 | + if ( ! empty(self::$early_providers['remove'])) { |
|
90 | + foreach (self::$early_providers['remove'] as $format) { |
|
91 | + unset($providers[$format]); |
|
92 | 92 | } |
93 | 93 | } |
94 | 94 | |
@@ -163,10 +163,10 @@ discard block |
||
163 | 163 | * |
164 | 164 | * @param array $providers An array of popular oEmbed providers. |
165 | 165 | */ |
166 | - $this->providers = apply_filters( 'oembed_providers', $providers ); |
|
166 | + $this->providers = apply_filters('oembed_providers', $providers); |
|
167 | 167 | |
168 | 168 | // Fix any embeds that contain new lines in the middle of the HTML which breaks wpautop(). |
169 | - add_filter( 'oembed_dataparse', array($this, '_strip_newlines'), 10, 3 ); |
|
169 | + add_filter('oembed_dataparse', array($this, '_strip_newlines'), 10, 3); |
|
170 | 170 | } |
171 | 171 | |
172 | 172 | /** |
@@ -179,9 +179,9 @@ discard block |
||
179 | 179 | * @param array $arguments Arguments to pass when calling. |
180 | 180 | * @return mixed|bool Return value of the callback, false otherwise. |
181 | 181 | */ |
182 | - public function __call( $name, $arguments ) { |
|
183 | - if ( in_array( $name, $this->compat_methods ) ) { |
|
184 | - return call_user_func_array( array( $this, $name ), $arguments ); |
|
182 | + public function __call($name, $arguments) { |
|
183 | + if (in_array($name, $this->compat_methods)) { |
|
184 | + return call_user_func_array(array($this, $name), $arguments); |
|
185 | 185 | } |
186 | 186 | return false; |
187 | 187 | } |
@@ -198,30 +198,30 @@ discard block |
||
198 | 198 | * @param string|array $args Optional provider arguments. |
199 | 199 | * @return false|string False on failure, otherwise the oEmbed provider URL. |
200 | 200 | */ |
201 | - public function get_provider( $url, $args = '' ) { |
|
201 | + public function get_provider($url, $args = '') { |
|
202 | 202 | |
203 | 203 | $provider = false; |
204 | 204 | |
205 | - if ( !isset($args['discover']) ) |
|
205 | + if ( ! isset($args['discover'])) |
|
206 | 206 | $args['discover'] = true; |
207 | 207 | |
208 | - foreach ( $this->providers as $matchmask => $data ) { |
|
209 | - list( $providerurl, $regex ) = $data; |
|
208 | + foreach ($this->providers as $matchmask => $data) { |
|
209 | + list($providerurl, $regex) = $data; |
|
210 | 210 | |
211 | 211 | // Turn the asterisk-type provider URLs into regex |
212 | - if ( !$regex ) { |
|
213 | - $matchmask = '#' . str_replace( '___wildcard___', '(.+)', preg_quote( str_replace( '*', '___wildcard___', $matchmask ), '#' ) ) . '#i'; |
|
214 | - $matchmask = preg_replace( '|^#http\\\://|', '#https?\://', $matchmask ); |
|
212 | + if ( ! $regex) { |
|
213 | + $matchmask = '#'.str_replace('___wildcard___', '(.+)', preg_quote(str_replace('*', '___wildcard___', $matchmask), '#')).'#i'; |
|
214 | + $matchmask = preg_replace('|^#http\\\://|', '#https?\://', $matchmask); |
|
215 | 215 | } |
216 | 216 | |
217 | - if ( preg_match( $matchmask, $url ) ) { |
|
218 | - $provider = str_replace( '{format}', 'json', $providerurl ); // JSON is easier to deal with than XML |
|
217 | + if (preg_match($matchmask, $url)) { |
|
218 | + $provider = str_replace('{format}', 'json', $providerurl); // JSON is easier to deal with than XML |
|
219 | 219 | break; |
220 | 220 | } |
221 | 221 | } |
222 | 222 | |
223 | - if ( !$provider && $args['discover'] ) |
|
224 | - $provider = $this->discover( $url ); |
|
223 | + if ( ! $provider && $args['discover']) |
|
224 | + $provider = $this->discover($url); |
|
225 | 225 | |
226 | 226 | return $provider; |
227 | 227 | } |
@@ -244,12 +244,12 @@ discard block |
||
244 | 244 | * @param bool $regex Optional. Whether the $format parameter is in a regex format. |
245 | 245 | * Default false. |
246 | 246 | */ |
247 | - public static function _add_provider_early( $format, $provider, $regex = false ) { |
|
248 | - if ( empty( self::$early_providers['add'] ) ) { |
|
247 | + public static function _add_provider_early($format, $provider, $regex = false) { |
|
248 | + if (empty(self::$early_providers['add'])) { |
|
249 | 249 | self::$early_providers['add'] = array(); |
250 | 250 | } |
251 | 251 | |
252 | - self::$early_providers['add'][ $format ] = array( $provider, $regex ); |
|
252 | + self::$early_providers['add'][$format] = array($provider, $regex); |
|
253 | 253 | } |
254 | 254 | |
255 | 255 | /** |
@@ -267,8 +267,8 @@ discard block |
||
267 | 267 | * @param string $format The format of URL that this provider can handle. You can use |
268 | 268 | * asterisks as wildcards. |
269 | 269 | */ |
270 | - public static function _remove_provider_early( $format ) { |
|
271 | - if ( empty( self::$early_providers['remove'] ) ) { |
|
270 | + public static function _remove_provider_early($format) { |
|
271 | + if (empty(self::$early_providers['remove'])) { |
|
272 | 272 | self::$early_providers['remove'] = array(); |
273 | 273 | } |
274 | 274 | |
@@ -285,10 +285,10 @@ discard block |
||
285 | 285 | * @param array $args Optional arguments. Usually passed from a shortcode. |
286 | 286 | * @return false|string False on failure, otherwise the UNSANITIZED (and potentially unsafe) HTML that should be used to embed. |
287 | 287 | */ |
288 | - public function get_html( $url, $args = '' ) { |
|
289 | - $provider = $this->get_provider( $url, $args ); |
|
288 | + public function get_html($url, $args = '') { |
|
289 | + $provider = $this->get_provider($url, $args); |
|
290 | 290 | |
291 | - if ( !$provider || false === $data = $this->fetch( $provider, $url, $args ) ) |
|
291 | + if ( ! $provider || false === $data = $this->fetch($provider, $url, $args)) |
|
292 | 292 | return false; |
293 | 293 | |
294 | 294 | /** |
@@ -300,7 +300,7 @@ discard block |
||
300 | 300 | * @param string $url URL of the content to be embedded. |
301 | 301 | * @param array $args Optional arguments, usually passed from a shortcode. |
302 | 302 | */ |
303 | - return apply_filters( 'oembed_result', $this->data2html( $data, $url ), $url, $args ); |
|
303 | + return apply_filters('oembed_result', $this->data2html($data, $url), $url, $args); |
|
304 | 304 | } |
305 | 305 | |
306 | 306 | /** |
@@ -309,7 +309,7 @@ discard block |
||
309 | 309 | * @param string $url The URL that should be inspected for discovery `<link>` tags. |
310 | 310 | * @return false|string False on failure, otherwise the oEmbed provider URL. |
311 | 311 | */ |
312 | - public function discover( $url ) { |
|
312 | + public function discover($url) { |
|
313 | 313 | $providers = array(); |
314 | 314 | $args = array( |
315 | 315 | 'limit_response_size' => 153600, // 150 KB |
@@ -325,11 +325,11 @@ discard block |
||
325 | 325 | * @param array $args oEmbed remote get arguments. |
326 | 326 | * @param string $url URL to be inspected. |
327 | 327 | */ |
328 | - $args = apply_filters( 'oembed_remote_get_args', $args, $url ); |
|
328 | + $args = apply_filters('oembed_remote_get_args', $args, $url); |
|
329 | 329 | |
330 | 330 | // Fetch URL content |
331 | - $request = wp_safe_remote_get( $url, $args ); |
|
332 | - if ( $html = wp_remote_retrieve_body( $request ) ) { |
|
331 | + $request = wp_safe_remote_get($url, $args); |
|
332 | + if ($html = wp_remote_retrieve_body($request)) { |
|
333 | 333 | |
334 | 334 | /** |
335 | 335 | * Filter the link types that contain oEmbed provider URLs. |
@@ -340,35 +340,35 @@ discard block |
||
340 | 340 | * 'text/xml+oembed', and 'application/xml+oembed' (incorrect, |
341 | 341 | * used by at least Vimeo). |
342 | 342 | */ |
343 | - $linktypes = apply_filters( 'oembed_linktypes', array( |
|
343 | + $linktypes = apply_filters('oembed_linktypes', array( |
|
344 | 344 | 'application/json+oembed' => 'json', |
345 | 345 | 'text/xml+oembed' => 'xml', |
346 | 346 | 'application/xml+oembed' => 'xml', |
347 | - ) ); |
|
347 | + )); |
|
348 | 348 | |
349 | 349 | // Strip <body> |
350 | - if ( $html_head_end = stripos( $html, '</head>' ) ) { |
|
351 | - $html = substr( $html, 0, $html_head_end ); |
|
350 | + if ($html_head_end = stripos($html, '</head>')) { |
|
351 | + $html = substr($html, 0, $html_head_end); |
|
352 | 352 | } |
353 | 353 | |
354 | 354 | // Do a quick check |
355 | 355 | $tagfound = false; |
356 | - foreach ( $linktypes as $linktype => $format ) { |
|
357 | - if ( stripos($html, $linktype) ) { |
|
356 | + foreach ($linktypes as $linktype => $format) { |
|
357 | + if (stripos($html, $linktype)) { |
|
358 | 358 | $tagfound = true; |
359 | 359 | break; |
360 | 360 | } |
361 | 361 | } |
362 | 362 | |
363 | - if ( $tagfound && preg_match_all( '#<link([^<>]+)/?>#iU', $html, $links ) ) { |
|
364 | - foreach ( $links[1] as $link ) { |
|
365 | - $atts = shortcode_parse_atts( $link ); |
|
363 | + if ($tagfound && preg_match_all('#<link([^<>]+)/?>#iU', $html, $links)) { |
|
364 | + foreach ($links[1] as $link) { |
|
365 | + $atts = shortcode_parse_atts($link); |
|
366 | 366 | |
367 | - if ( !empty($atts['type']) && !empty($linktypes[$atts['type']]) && !empty($atts['href']) ) { |
|
368 | - $providers[$linktypes[$atts['type']]] = htmlspecialchars_decode( $atts['href'] ); |
|
367 | + if ( ! empty($atts['type']) && ! empty($linktypes[$atts['type']]) && ! empty($atts['href'])) { |
|
368 | + $providers[$linktypes[$atts['type']]] = htmlspecialchars_decode($atts['href']); |
|
369 | 369 | |
370 | 370 | // Stop here if it's JSON (that's all we need) |
371 | - if ( 'json' == $linktypes[$atts['type']] ) |
|
371 | + if ('json' == $linktypes[$atts['type']]) |
|
372 | 372 | break; |
373 | 373 | } |
374 | 374 | } |
@@ -376,9 +376,9 @@ discard block |
||
376 | 376 | } |
377 | 377 | |
378 | 378 | // JSON is preferred to XML |
379 | - if ( !empty($providers['json']) ) |
|
379 | + if ( ! empty($providers['json'])) |
|
380 | 380 | return $providers['json']; |
381 | - elseif ( !empty($providers['xml']) ) |
|
381 | + elseif ( ! empty($providers['xml'])) |
|
382 | 382 | return $providers['xml']; |
383 | 383 | else |
384 | 384 | return false; |
@@ -392,12 +392,12 @@ discard block |
||
392 | 392 | * @param array $args Optional arguments. Usually passed from a shortcode. |
393 | 393 | * @return false|object False on failure, otherwise the result in the form of an object. |
394 | 394 | */ |
395 | - public function fetch( $provider, $url, $args = '' ) { |
|
396 | - $args = wp_parse_args( $args, wp_embed_defaults( $url ) ); |
|
395 | + public function fetch($provider, $url, $args = '') { |
|
396 | + $args = wp_parse_args($args, wp_embed_defaults($url)); |
|
397 | 397 | |
398 | - $provider = add_query_arg( 'maxwidth', (int) $args['width'], $provider ); |
|
399 | - $provider = add_query_arg( 'maxheight', (int) $args['height'], $provider ); |
|
400 | - $provider = add_query_arg( 'url', urlencode($url), $provider ); |
|
398 | + $provider = add_query_arg('maxwidth', (int) $args['width'], $provider); |
|
399 | + $provider = add_query_arg('maxheight', (int) $args['height'], $provider); |
|
400 | + $provider = add_query_arg('url', urlencode($url), $provider); |
|
401 | 401 | |
402 | 402 | /** |
403 | 403 | * Filter the oEmbed URL to be fetched. |
@@ -408,13 +408,13 @@ discard block |
||
408 | 408 | * @param string $url URL of the content to be embedded. |
409 | 409 | * @param array $args Optional arguments, usually passed from a shortcode. |
410 | 410 | */ |
411 | - $provider = apply_filters( 'oembed_fetch_url', $provider, $url, $args ); |
|
411 | + $provider = apply_filters('oembed_fetch_url', $provider, $url, $args); |
|
412 | 412 | |
413 | - foreach ( array( 'json', 'xml' ) as $format ) { |
|
414 | - $result = $this->_fetch_with_format( $provider, $format ); |
|
415 | - if ( is_wp_error( $result ) && 'not-implemented' == $result->get_error_code() ) |
|
413 | + foreach (array('json', 'xml') as $format) { |
|
414 | + $result = $this->_fetch_with_format($provider, $format); |
|
415 | + if (is_wp_error($result) && 'not-implemented' == $result->get_error_code()) |
|
416 | 416 | continue; |
417 | - return ( $result && ! is_wp_error( $result ) ) ? $result : false; |
|
417 | + return ($result && ! is_wp_error($result)) ? $result : false; |
|
418 | 418 | } |
419 | 419 | return false; |
420 | 420 | } |
@@ -428,19 +428,19 @@ discard block |
||
428 | 428 | * @param string $format Format to use |
429 | 429 | * @return false|object|WP_Error False on failure, otherwise the result in the form of an object. |
430 | 430 | */ |
431 | - private function _fetch_with_format( $provider_url_with_args, $format ) { |
|
432 | - $provider_url_with_args = add_query_arg( 'format', $format, $provider_url_with_args ); |
|
431 | + private function _fetch_with_format($provider_url_with_args, $format) { |
|
432 | + $provider_url_with_args = add_query_arg('format', $format, $provider_url_with_args); |
|
433 | 433 | |
434 | 434 | /** This filter is documented in wp-includes/class-oembed.php */ |
435 | - $args = apply_filters( 'oembed_remote_get_args', array(), $provider_url_with_args ); |
|
435 | + $args = apply_filters('oembed_remote_get_args', array(), $provider_url_with_args); |
|
436 | 436 | |
437 | - $response = wp_safe_remote_get( $provider_url_with_args, $args ); |
|
438 | - if ( 501 == wp_remote_retrieve_response_code( $response ) ) |
|
439 | - return new WP_Error( 'not-implemented' ); |
|
440 | - if ( ! $body = wp_remote_retrieve_body( $response ) ) |
|
437 | + $response = wp_safe_remote_get($provider_url_with_args, $args); |
|
438 | + if (501 == wp_remote_retrieve_response_code($response)) |
|
439 | + return new WP_Error('not-implemented'); |
|
440 | + if ( ! $body = wp_remote_retrieve_body($response)) |
|
441 | 441 | return false; |
442 | 442 | $parse_method = "_parse_$format"; |
443 | - return $this->$parse_method( $body ); |
|
443 | + return $this->$parse_method($body); |
|
444 | 444 | } |
445 | 445 | |
446 | 446 | /** |
@@ -452,9 +452,9 @@ discard block |
||
452 | 452 | * @param string $response_body |
453 | 453 | * @return object|false |
454 | 454 | */ |
455 | - private function _parse_json( $response_body ) { |
|
456 | - $data = json_decode( trim( $response_body ) ); |
|
457 | - return ( $data && is_object( $data ) ) ? $data : false; |
|
455 | + private function _parse_json($response_body) { |
|
456 | + $data = json_decode(trim($response_body)); |
|
457 | + return ($data && is_object($data)) ? $data : false; |
|
458 | 458 | } |
459 | 459 | |
460 | 460 | /** |
@@ -466,17 +466,17 @@ discard block |
||
466 | 466 | * @param string $response_body |
467 | 467 | * @return object|false |
468 | 468 | */ |
469 | - private function _parse_xml( $response_body ) { |
|
470 | - if ( ! function_exists( 'libxml_disable_entity_loader' ) ) |
|
469 | + private function _parse_xml($response_body) { |
|
470 | + if ( ! function_exists('libxml_disable_entity_loader')) |
|
471 | 471 | return false; |
472 | 472 | |
473 | - $loader = libxml_disable_entity_loader( true ); |
|
474 | - $errors = libxml_use_internal_errors( true ); |
|
473 | + $loader = libxml_disable_entity_loader(true); |
|
474 | + $errors = libxml_use_internal_errors(true); |
|
475 | 475 | |
476 | - $return = $this->_parse_xml_body( $response_body ); |
|
476 | + $return = $this->_parse_xml_body($response_body); |
|
477 | 477 | |
478 | - libxml_use_internal_errors( $errors ); |
|
479 | - libxml_disable_entity_loader( $loader ); |
|
478 | + libxml_use_internal_errors($errors); |
|
479 | + libxml_disable_entity_loader($loader); |
|
480 | 480 | |
481 | 481 | return $return; |
482 | 482 | } |
@@ -490,29 +490,29 @@ discard block |
||
490 | 490 | * @param string $response_body |
491 | 491 | * @return object|false |
492 | 492 | */ |
493 | - private function _parse_xml_body( $response_body ) { |
|
494 | - if ( ! function_exists( 'simplexml_import_dom' ) || ! class_exists( 'DOMDocument', false ) ) |
|
493 | + private function _parse_xml_body($response_body) { |
|
494 | + if ( ! function_exists('simplexml_import_dom') || ! class_exists('DOMDocument', false)) |
|
495 | 495 | return false; |
496 | 496 | |
497 | 497 | $dom = new DOMDocument; |
498 | - $success = $dom->loadXML( $response_body ); |
|
499 | - if ( ! $success ) |
|
498 | + $success = $dom->loadXML($response_body); |
|
499 | + if ( ! $success) |
|
500 | 500 | return false; |
501 | 501 | |
502 | - if ( isset( $dom->doctype ) ) |
|
502 | + if (isset($dom->doctype)) |
|
503 | 503 | return false; |
504 | 504 | |
505 | - foreach ( $dom->childNodes as $child ) { |
|
506 | - if ( XML_DOCUMENT_TYPE_NODE === $child->nodeType ) |
|
505 | + foreach ($dom->childNodes as $child) { |
|
506 | + if (XML_DOCUMENT_TYPE_NODE === $child->nodeType) |
|
507 | 507 | return false; |
508 | 508 | } |
509 | 509 | |
510 | - $xml = simplexml_import_dom( $dom ); |
|
511 | - if ( ! $xml ) |
|
510 | + $xml = simplexml_import_dom($dom); |
|
511 | + if ( ! $xml) |
|
512 | 512 | return false; |
513 | 513 | |
514 | 514 | $return = new stdClass; |
515 | - foreach ( $xml as $key => $value ) { |
|
515 | + foreach ($xml as $key => $value) { |
|
516 | 516 | $return->$key = (string) $value; |
517 | 517 | } |
518 | 518 | |
@@ -526,32 +526,32 @@ discard block |
||
526 | 526 | * @param string $url The URL to the content that is desired to be embedded. |
527 | 527 | * @return false|string False on error, otherwise the HTML needed to embed. |
528 | 528 | */ |
529 | - public function data2html( $data, $url ) { |
|
530 | - if ( ! is_object( $data ) || empty( $data->type ) ) |
|
529 | + public function data2html($data, $url) { |
|
530 | + if ( ! is_object($data) || empty($data->type)) |
|
531 | 531 | return false; |
532 | 532 | |
533 | 533 | $return = false; |
534 | 534 | |
535 | - switch ( $data->type ) { |
|
535 | + switch ($data->type) { |
|
536 | 536 | case 'photo': |
537 | - if ( empty( $data->url ) || empty( $data->width ) || empty( $data->height ) ) |
|
537 | + if (empty($data->url) || empty($data->width) || empty($data->height)) |
|
538 | 538 | break; |
539 | - if ( ! is_string( $data->url ) || ! is_numeric( $data->width ) || ! is_numeric( $data->height ) ) |
|
539 | + if ( ! is_string($data->url) || ! is_numeric($data->width) || ! is_numeric($data->height)) |
|
540 | 540 | break; |
541 | 541 | |
542 | - $title = ! empty( $data->title ) && is_string( $data->title ) ? $data->title : ''; |
|
543 | - $return = '<a href="' . esc_url( $url ) . '"><img src="' . esc_url( $data->url ) . '" alt="' . esc_attr($title) . '" width="' . esc_attr($data->width) . '" height="' . esc_attr($data->height) . '" /></a>'; |
|
542 | + $title = ! empty($data->title) && is_string($data->title) ? $data->title : ''; |
|
543 | + $return = '<a href="'.esc_url($url).'"><img src="'.esc_url($data->url).'" alt="'.esc_attr($title).'" width="'.esc_attr($data->width).'" height="'.esc_attr($data->height).'" /></a>'; |
|
544 | 544 | break; |
545 | 545 | |
546 | 546 | case 'video': |
547 | 547 | case 'rich': |
548 | - if ( ! empty( $data->html ) && is_string( $data->html ) ) |
|
548 | + if ( ! empty($data->html) && is_string($data->html)) |
|
549 | 549 | $return = $data->html; |
550 | 550 | break; |
551 | 551 | |
552 | 552 | case 'link': |
553 | - if ( ! empty( $data->title ) && is_string( $data->title ) ) |
|
554 | - $return = '<a href="' . esc_url( $url ) . '">' . esc_html( $data->title ) . '</a>'; |
|
553 | + if ( ! empty($data->title) && is_string($data->title)) |
|
554 | + $return = '<a href="'.esc_url($url).'">'.esc_html($data->title).'</a>'; |
|
555 | 555 | break; |
556 | 556 | |
557 | 557 | default: |
@@ -569,7 +569,7 @@ discard block |
||
569 | 569 | * @param object $data A data object result from an oEmbed provider. |
570 | 570 | * @param string $url The URL of the content to be embedded. |
571 | 571 | */ |
572 | - return apply_filters( 'oembed_dataparse', $return, $data, $url ); |
|
572 | + return apply_filters('oembed_dataparse', $return, $data, $url); |
|
573 | 573 | } |
574 | 574 | |
575 | 575 | /** |
@@ -581,33 +581,33 @@ discard block |
||
581 | 581 | * @param string $url The original URL passed to oEmbed. |
582 | 582 | * @return string Possibly modified $html |
583 | 583 | */ |
584 | - public function _strip_newlines( $html, $data, $url ) { |
|
585 | - if ( false === strpos( $html, "\n" ) ) { |
|
584 | + public function _strip_newlines($html, $data, $url) { |
|
585 | + if (false === strpos($html, "\n")) { |
|
586 | 586 | return $html; |
587 | 587 | } |
588 | 588 | |
589 | 589 | $count = 1; |
590 | 590 | $found = array(); |
591 | 591 | $token = '__PRE__'; |
592 | - $search = array( "\t", "\n", "\r", ' ' ); |
|
593 | - $replace = array( '__TAB__', '__NL__', '__CR__', '__SPACE__' ); |
|
594 | - $tokenized = str_replace( $search, $replace, $html ); |
|
592 | + $search = array("\t", "\n", "\r", ' '); |
|
593 | + $replace = array('__TAB__', '__NL__', '__CR__', '__SPACE__'); |
|
594 | + $tokenized = str_replace($search, $replace, $html); |
|
595 | 595 | |
596 | - preg_match_all( '#(<pre[^>]*>.+?</pre>)#i', $tokenized, $matches, PREG_SET_ORDER ); |
|
597 | - foreach ( $matches as $i => $match ) { |
|
598 | - $tag_html = str_replace( $replace, $search, $match[0] ); |
|
599 | - $tag_token = $token . $i; |
|
596 | + preg_match_all('#(<pre[^>]*>.+?</pre>)#i', $tokenized, $matches, PREG_SET_ORDER); |
|
597 | + foreach ($matches as $i => $match) { |
|
598 | + $tag_html = str_replace($replace, $search, $match[0]); |
|
599 | + $tag_token = $token.$i; |
|
600 | 600 | |
601 | - $found[ $tag_token ] = $tag_html; |
|
602 | - $html = str_replace( $tag_html, $tag_token, $html, $count ); |
|
601 | + $found[$tag_token] = $tag_html; |
|
602 | + $html = str_replace($tag_html, $tag_token, $html, $count); |
|
603 | 603 | } |
604 | 604 | |
605 | - $replaced = str_replace( $replace, $search, $html ); |
|
606 | - $stripped = str_replace( array( "\r\n", "\n" ), '', $replaced ); |
|
607 | - $pre = array_values( $found ); |
|
608 | - $tokens = array_keys( $found ); |
|
605 | + $replaced = str_replace($replace, $search, $html); |
|
606 | + $stripped = str_replace(array("\r\n", "\n"), '', $replaced); |
|
607 | + $pre = array_values($found); |
|
608 | + $tokens = array_keys($found); |
|
609 | 609 | |
610 | - return str_replace( $tokens, $pre, $stripped ); |
|
610 | + return str_replace($tokens, $pre, $stripped); |
|
611 | 611 | } |
612 | 612 | } |
613 | 613 | |
@@ -624,7 +624,7 @@ discard block |
||
624 | 624 | function _wp_oembed_get_object() { |
625 | 625 | static $wp_oembed = null; |
626 | 626 | |
627 | - if ( is_null( $wp_oembed ) ) { |
|
627 | + if (is_null($wp_oembed)) { |
|
628 | 628 | $wp_oembed = new WP_oEmbed(); |
629 | 629 | } |
630 | 630 | return $wp_oembed; |
@@ -202,8 +202,9 @@ discard block |
||
202 | 202 | |
203 | 203 | $provider = false; |
204 | 204 | |
205 | - if ( !isset($args['discover']) ) |
|
206 | - $args['discover'] = true; |
|
205 | + if ( !isset($args['discover']) ) { |
|
206 | + $args['discover'] = true; |
|
207 | + } |
|
207 | 208 | |
208 | 209 | foreach ( $this->providers as $matchmask => $data ) { |
209 | 210 | list( $providerurl, $regex ) = $data; |
@@ -220,8 +221,9 @@ discard block |
||
220 | 221 | } |
221 | 222 | } |
222 | 223 | |
223 | - if ( !$provider && $args['discover'] ) |
|
224 | - $provider = $this->discover( $url ); |
|
224 | + if ( !$provider && $args['discover'] ) { |
|
225 | + $provider = $this->discover( $url ); |
|
226 | + } |
|
225 | 227 | |
226 | 228 | return $provider; |
227 | 229 | } |
@@ -288,8 +290,9 @@ discard block |
||
288 | 290 | public function get_html( $url, $args = '' ) { |
289 | 291 | $provider = $this->get_provider( $url, $args ); |
290 | 292 | |
291 | - if ( !$provider || false === $data = $this->fetch( $provider, $url, $args ) ) |
|
292 | - return false; |
|
293 | + if ( !$provider || false === $data = $this->fetch( $provider, $url, $args ) ) { |
|
294 | + return false; |
|
295 | + } |
|
293 | 296 | |
294 | 297 | /** |
295 | 298 | * Filter the HTML returned by the oEmbed provider. |
@@ -368,20 +371,22 @@ discard block |
||
368 | 371 | $providers[$linktypes[$atts['type']]] = htmlspecialchars_decode( $atts['href'] ); |
369 | 372 | |
370 | 373 | // Stop here if it's JSON (that's all we need) |
371 | - if ( 'json' == $linktypes[$atts['type']] ) |
|
372 | - break; |
|
374 | + if ( 'json' == $linktypes[$atts['type']] ) { |
|
375 | + break; |
|
376 | + } |
|
373 | 377 | } |
374 | 378 | } |
375 | 379 | } |
376 | 380 | } |
377 | 381 | |
378 | 382 | // JSON is preferred to XML |
379 | - if ( !empty($providers['json']) ) |
|
380 | - return $providers['json']; |
|
381 | - elseif ( !empty($providers['xml']) ) |
|
382 | - return $providers['xml']; |
|
383 | - else |
|
384 | - return false; |
|
383 | + if ( !empty($providers['json']) ) { |
|
384 | + return $providers['json']; |
|
385 | + } elseif ( !empty($providers['xml']) ) { |
|
386 | + return $providers['xml']; |
|
387 | + } else { |
|
388 | + return false; |
|
389 | + } |
|
385 | 390 | } |
386 | 391 | |
387 | 392 | /** |
@@ -412,8 +417,9 @@ discard block |
||
412 | 417 | |
413 | 418 | foreach ( array( 'json', 'xml' ) as $format ) { |
414 | 419 | $result = $this->_fetch_with_format( $provider, $format ); |
415 | - if ( is_wp_error( $result ) && 'not-implemented' == $result->get_error_code() ) |
|
416 | - continue; |
|
420 | + if ( is_wp_error( $result ) && 'not-implemented' == $result->get_error_code() ) { |
|
421 | + continue; |
|
422 | + } |
|
417 | 423 | return ( $result && ! is_wp_error( $result ) ) ? $result : false; |
418 | 424 | } |
419 | 425 | return false; |
@@ -435,10 +441,12 @@ discard block |
||
435 | 441 | $args = apply_filters( 'oembed_remote_get_args', array(), $provider_url_with_args ); |
436 | 442 | |
437 | 443 | $response = wp_safe_remote_get( $provider_url_with_args, $args ); |
438 | - if ( 501 == wp_remote_retrieve_response_code( $response ) ) |
|
439 | - return new WP_Error( 'not-implemented' ); |
|
440 | - if ( ! $body = wp_remote_retrieve_body( $response ) ) |
|
441 | - return false; |
|
444 | + if ( 501 == wp_remote_retrieve_response_code( $response ) ) { |
|
445 | + return new WP_Error( 'not-implemented' ); |
|
446 | + } |
|
447 | + if ( ! $body = wp_remote_retrieve_body( $response ) ) { |
|
448 | + return false; |
|
449 | + } |
|
442 | 450 | $parse_method = "_parse_$format"; |
443 | 451 | return $this->$parse_method( $body ); |
444 | 452 | } |
@@ -467,8 +475,9 @@ discard block |
||
467 | 475 | * @return object|false |
468 | 476 | */ |
469 | 477 | private function _parse_xml( $response_body ) { |
470 | - if ( ! function_exists( 'libxml_disable_entity_loader' ) ) |
|
471 | - return false; |
|
478 | + if ( ! function_exists( 'libxml_disable_entity_loader' ) ) { |
|
479 | + return false; |
|
480 | + } |
|
472 | 481 | |
473 | 482 | $loader = libxml_disable_entity_loader( true ); |
474 | 483 | $errors = libxml_use_internal_errors( true ); |
@@ -491,25 +500,30 @@ discard block |
||
491 | 500 | * @return object|false |
492 | 501 | */ |
493 | 502 | private function _parse_xml_body( $response_body ) { |
494 | - if ( ! function_exists( 'simplexml_import_dom' ) || ! class_exists( 'DOMDocument', false ) ) |
|
495 | - return false; |
|
503 | + if ( ! function_exists( 'simplexml_import_dom' ) || ! class_exists( 'DOMDocument', false ) ) { |
|
504 | + return false; |
|
505 | + } |
|
496 | 506 | |
497 | 507 | $dom = new DOMDocument; |
498 | 508 | $success = $dom->loadXML( $response_body ); |
499 | - if ( ! $success ) |
|
500 | - return false; |
|
509 | + if ( ! $success ) { |
|
510 | + return false; |
|
511 | + } |
|
501 | 512 | |
502 | - if ( isset( $dom->doctype ) ) |
|
503 | - return false; |
|
513 | + if ( isset( $dom->doctype ) ) { |
|
514 | + return false; |
|
515 | + } |
|
504 | 516 | |
505 | 517 | foreach ( $dom->childNodes as $child ) { |
506 | - if ( XML_DOCUMENT_TYPE_NODE === $child->nodeType ) |
|
507 | - return false; |
|
518 | + if ( XML_DOCUMENT_TYPE_NODE === $child->nodeType ) { |
|
519 | + return false; |
|
520 | + } |
|
508 | 521 | } |
509 | 522 | |
510 | 523 | $xml = simplexml_import_dom( $dom ); |
511 | - if ( ! $xml ) |
|
512 | - return false; |
|
524 | + if ( ! $xml ) { |
|
525 | + return false; |
|
526 | + } |
|
513 | 527 | |
514 | 528 | $return = new stdClass; |
515 | 529 | foreach ( $xml as $key => $value ) { |
@@ -527,17 +541,20 @@ discard block |
||
527 | 541 | * @return false|string False on error, otherwise the HTML needed to embed. |
528 | 542 | */ |
529 | 543 | public function data2html( $data, $url ) { |
530 | - if ( ! is_object( $data ) || empty( $data->type ) ) |
|
531 | - return false; |
|
544 | + if ( ! is_object( $data ) || empty( $data->type ) ) { |
|
545 | + return false; |
|
546 | + } |
|
532 | 547 | |
533 | 548 | $return = false; |
534 | 549 | |
535 | 550 | switch ( $data->type ) { |
536 | 551 | case 'photo': |
537 | - if ( empty( $data->url ) || empty( $data->width ) || empty( $data->height ) ) |
|
538 | - break; |
|
539 | - if ( ! is_string( $data->url ) || ! is_numeric( $data->width ) || ! is_numeric( $data->height ) ) |
|
540 | - break; |
|
552 | + if ( empty( $data->url ) || empty( $data->width ) || empty( $data->height ) ) { |
|
553 | + break; |
|
554 | + } |
|
555 | + if ( ! is_string( $data->url ) || ! is_numeric( $data->width ) || ! is_numeric( $data->height ) ) { |
|
556 | + break; |
|
557 | + } |
|
541 | 558 | |
542 | 559 | $title = ! empty( $data->title ) && is_string( $data->title ) ? $data->title : ''; |
543 | 560 | $return = '<a href="' . esc_url( $url ) . '"><img src="' . esc_url( $data->url ) . '" alt="' . esc_attr($title) . '" width="' . esc_attr($data->width) . '" height="' . esc_attr($data->height) . '" /></a>'; |
@@ -545,13 +562,15 @@ discard block |
||
545 | 562 | |
546 | 563 | case 'video': |
547 | 564 | case 'rich': |
548 | - if ( ! empty( $data->html ) && is_string( $data->html ) ) |
|
549 | - $return = $data->html; |
|
565 | + if ( ! empty( $data->html ) && is_string( $data->html ) ) { |
|
566 | + $return = $data->html; |
|
567 | + } |
|
550 | 568 | break; |
551 | 569 | |
552 | 570 | case 'link': |
553 | - if ( ! empty( $data->title ) && is_string( $data->title ) ) |
|
554 | - $return = '<a href="' . esc_url( $url ) . '">' . esc_html( $data->title ) . '</a>'; |
|
571 | + if ( ! empty( $data->title ) && is_string( $data->title ) ) { |
|
572 | + $return = '<a href="' . esc_url( $url ) . '">' . esc_html( $data->title ) . '</a>'; |
|
573 | + } |
|
555 | 574 | break; |
556 | 575 | |
557 | 576 | default: |
@@ -1,10 +1,10 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | /** |
3 | - * WordPress environment setup class. |
|
4 | - * |
|
5 | - * @package WordPress |
|
6 | - * @since 2.0.0 |
|
7 | - */ |
|
3 | + * WordPress environment setup class. |
|
4 | + * |
|
5 | + * @package WordPress |
|
6 | + * @since 2.0.0 |
|
7 | + */ |
|
8 | 8 | class WP { |
9 | 9 | /** |
10 | 10 | * Public query variables. |
@@ -609,22 +609,22 @@ discard block |
||
609 | 609 | } |
610 | 610 | |
611 | 611 | /** |
612 | - * Set the Headers for 404, if nothing is found for requested URL. |
|
613 | - * |
|
614 | - * Issue a 404 if a request doesn't match any posts and doesn't match |
|
615 | - * any object (e.g. an existing-but-empty category, tag, author) and a 404 was not already |
|
616 | - * issued, and if the request was not a search or the homepage. |
|
617 | - * |
|
618 | - * Otherwise, issue a 200. |
|
619 | - * |
|
620 | - * This sets headers after posts have been queried. handle_404() really means "handle status." |
|
621 | - * By inspecting the result of querying posts, seemingly successful requests can be switched to |
|
622 | - * a 404 so that canonical redirection logic can kick in. |
|
623 | - * |
|
624 | - * @since 2.0.0 |
|
625 | - * @access public |
|
626 | - * |
|
627 | - * @global WP_Query $wp_query |
|
612 | + * Set the Headers for 404, if nothing is found for requested URL. |
|
613 | + * |
|
614 | + * Issue a 404 if a request doesn't match any posts and doesn't match |
|
615 | + * any object (e.g. an existing-but-empty category, tag, author) and a 404 was not already |
|
616 | + * issued, and if the request was not a search or the homepage. |
|
617 | + * |
|
618 | + * Otherwise, issue a 200. |
|
619 | + * |
|
620 | + * This sets headers after posts have been queried. handle_404() really means "handle status." |
|
621 | + * By inspecting the result of querying posts, seemingly successful requests can be switched to |
|
622 | + * a 404 so that canonical redirection logic can kick in. |
|
623 | + * |
|
624 | + * @since 2.0.0 |
|
625 | + * @access public |
|
626 | + * |
|
627 | + * @global WP_Query $wp_query |
|
628 | 628 | */ |
629 | 629 | public function handle_404() { |
630 | 630 | global $wp_query; |
@@ -15,7 +15,7 @@ discard block |
||
15 | 15 | * @access public |
16 | 16 | * @var array |
17 | 17 | */ |
18 | - public $public_query_vars = array('m', 'p', 'posts', 'w', 'cat', 'withcomments', 'withoutcomments', 's', 'search', 'exact', 'sentence', 'calendar', 'page', 'paged', 'more', 'tb', 'pb', 'author', 'order', 'orderby', 'year', 'monthnum', 'day', 'hour', 'minute', 'second', 'name', 'category_name', 'tag', 'feed', 'author_name', 'static', 'pagename', 'page_id', 'error', 'attachment', 'attachment_id', 'subpost', 'subpost_id', 'preview', 'robots', 'taxonomy', 'term', 'cpage', 'post_type', 'embed' ); |
|
18 | + public $public_query_vars = array('m', 'p', 'posts', 'w', 'cat', 'withcomments', 'withoutcomments', 's', 'search', 'exact', 'sentence', 'calendar', 'page', 'paged', 'more', 'tb', 'pb', 'author', 'order', 'orderby', 'year', 'monthnum', 'day', 'hour', 'minute', 'second', 'name', 'category_name', 'tag', 'feed', 'author_name', 'static', 'pagename', 'page_id', 'error', 'attachment', 'attachment_id', 'subpost', 'subpost_id', 'preview', 'robots', 'taxonomy', 'term', 'cpage', 'post_type', 'embed'); |
|
19 | 19 | |
20 | 20 | /** |
21 | 21 | * Private query variables. |
@@ -26,7 +26,7 @@ discard block |
||
26 | 26 | * @access public |
27 | 27 | * @var array |
28 | 28 | */ |
29 | - public $private_query_vars = array( 'offset', 'posts_per_page', 'posts_per_archive_page', 'showposts', 'nopaging', 'post_type', 'post_status', 'category__in', 'category__not_in', 'category__and', 'tag__in', 'tag__not_in', 'tag__and', 'tag_slug__in', 'tag_slug__and', 'tag_id', 'post_mime_type', 'perm', 'comments_per_page', 'post__in', 'post__not_in', 'post_parent', 'post_parent__in', 'post_parent__not_in', 'title' ); |
|
29 | + public $private_query_vars = array('offset', 'posts_per_page', 'posts_per_archive_page', 'showposts', 'nopaging', 'post_type', 'post_status', 'category__in', 'category__not_in', 'category__and', 'tag__in', 'tag__not_in', 'tag__and', 'tag_slug__in', 'tag_slug__and', 'tag_id', 'post_mime_type', 'perm', 'comments_per_page', 'post__in', 'post__not_in', 'post_parent', 'post_parent__in', 'post_parent__not_in', 'title'); |
|
30 | 30 | |
31 | 31 | /** |
32 | 32 | * Extra query variables set by the user. |
@@ -100,7 +100,7 @@ discard block |
||
100 | 100 | * @param string $qv Query variable name. |
101 | 101 | */ |
102 | 102 | public function add_query_var($qv) { |
103 | - if ( !in_array($qv, $this->public_query_vars) ) |
|
103 | + if ( ! in_array($qv, $this->public_query_vars)) |
|
104 | 104 | $this->public_query_vars[] = $qv; |
105 | 105 | } |
106 | 106 | |
@@ -112,8 +112,8 @@ discard block |
||
112 | 112 | * |
113 | 113 | * @param string $name Query variable name. |
114 | 114 | */ |
115 | - public function remove_query_var( $name ) { |
|
116 | - $this->public_query_vars = array_diff( $this->public_query_vars, array( $name ) ); |
|
115 | + public function remove_query_var($name) { |
|
116 | + $this->public_query_vars = array_diff($this->public_query_vars, array($name)); |
|
117 | 117 | } |
118 | 118 | |
119 | 119 | /** |
@@ -154,35 +154,35 @@ discard block |
||
154 | 154 | * @param WP $this Current WordPress environment instance. |
155 | 155 | * @param array|string $extra_query_vars Extra passed query variables. |
156 | 156 | */ |
157 | - if ( ! apply_filters( 'do_parse_request', true, $this, $extra_query_vars ) ) |
|
157 | + if ( ! apply_filters('do_parse_request', true, $this, $extra_query_vars)) |
|
158 | 158 | return; |
159 | 159 | |
160 | 160 | $this->query_vars = array(); |
161 | 161 | $post_type_query_vars = array(); |
162 | 162 | |
163 | - if ( is_array( $extra_query_vars ) ) { |
|
163 | + if (is_array($extra_query_vars)) { |
|
164 | 164 | $this->extra_query_vars = & $extra_query_vars; |
165 | - } elseif ( ! empty( $extra_query_vars ) ) { |
|
166 | - parse_str( $extra_query_vars, $this->extra_query_vars ); |
|
165 | + } elseif ( ! empty($extra_query_vars)) { |
|
166 | + parse_str($extra_query_vars, $this->extra_query_vars); |
|
167 | 167 | } |
168 | 168 | // Process PATH_INFO, REQUEST_URI, and 404 for permalinks. |
169 | 169 | |
170 | 170 | // Fetch the rewrite rules. |
171 | 171 | $rewrite = $wp_rewrite->wp_rewrite_rules(); |
172 | 172 | |
173 | - if ( ! empty($rewrite) ) { |
|
173 | + if ( ! empty($rewrite)) { |
|
174 | 174 | // If we match a rewrite rule, this will be cleared. |
175 | 175 | $error = '404'; |
176 | 176 | $this->did_permalink = true; |
177 | 177 | |
178 | - $pathinfo = isset( $_SERVER['PATH_INFO'] ) ? $_SERVER['PATH_INFO'] : ''; |
|
179 | - list( $pathinfo ) = explode( '?', $pathinfo ); |
|
180 | - $pathinfo = str_replace( "%", "%25", $pathinfo ); |
|
178 | + $pathinfo = isset($_SERVER['PATH_INFO']) ? $_SERVER['PATH_INFO'] : ''; |
|
179 | + list($pathinfo) = explode('?', $pathinfo); |
|
180 | + $pathinfo = str_replace("%", "%25", $pathinfo); |
|
181 | 181 | |
182 | - list( $req_uri ) = explode( '?', $_SERVER['REQUEST_URI'] ); |
|
182 | + list($req_uri) = explode('?', $_SERVER['REQUEST_URI']); |
|
183 | 183 | $self = $_SERVER['PHP_SELF']; |
184 | - $home_path = trim( parse_url( home_url(), PHP_URL_PATH ), '/' ); |
|
185 | - $home_path_regex = sprintf( '|^%s|i', preg_quote( $home_path, '|' ) ); |
|
184 | + $home_path = trim(parse_url(home_url(), PHP_URL_PATH), '/'); |
|
185 | + $home_path_regex = sprintf('|^%s|i', preg_quote($home_path, '|')); |
|
186 | 186 | |
187 | 187 | // Trim path info from the end and the leading home path from the |
188 | 188 | // front. For path info requests, this leaves us with the requesting |
@@ -190,22 +190,22 @@ discard block |
||
190 | 190 | // requested permalink. |
191 | 191 | $req_uri = str_replace($pathinfo, '', $req_uri); |
192 | 192 | $req_uri = trim($req_uri, '/'); |
193 | - $req_uri = preg_replace( $home_path_regex, '', $req_uri ); |
|
193 | + $req_uri = preg_replace($home_path_regex, '', $req_uri); |
|
194 | 194 | $req_uri = trim($req_uri, '/'); |
195 | 195 | $pathinfo = trim($pathinfo, '/'); |
196 | - $pathinfo = preg_replace( $home_path_regex, '', $pathinfo ); |
|
196 | + $pathinfo = preg_replace($home_path_regex, '', $pathinfo); |
|
197 | 197 | $pathinfo = trim($pathinfo, '/'); |
198 | 198 | $self = trim($self, '/'); |
199 | - $self = preg_replace( $home_path_regex, '', $self ); |
|
199 | + $self = preg_replace($home_path_regex, '', $self); |
|
200 | 200 | $self = trim($self, '/'); |
201 | 201 | |
202 | 202 | // The requested permalink is in $pathinfo for path info requests and |
203 | 203 | // $req_uri for other requests. |
204 | - if ( ! empty($pathinfo) && !preg_match('|^.*' . $wp_rewrite->index . '$|', $pathinfo) ) { |
|
204 | + if ( ! empty($pathinfo) && ! preg_match('|^.*'.$wp_rewrite->index.'$|', $pathinfo)) { |
|
205 | 205 | $request = $pathinfo; |
206 | 206 | } else { |
207 | 207 | // If the request uri is the index, blank it out so that we don't try to match it against a rule. |
208 | - if ( $req_uri == $wp_rewrite->index ) |
|
208 | + if ($req_uri == $wp_rewrite->index) |
|
209 | 209 | $req_uri = ''; |
210 | 210 | $request = $req_uri; |
211 | 211 | } |
@@ -214,32 +214,32 @@ discard block |
||
214 | 214 | |
215 | 215 | // Look for matches. |
216 | 216 | $request_match = $request; |
217 | - if ( empty( $request_match ) ) { |
|
217 | + if (empty($request_match)) { |
|
218 | 218 | // An empty request could only match against ^$ regex |
219 | - if ( isset( $rewrite['$'] ) ) { |
|
219 | + if (isset($rewrite['$'])) { |
|
220 | 220 | $this->matched_rule = '$'; |
221 | 221 | $query = $rewrite['$']; |
222 | 222 | $matches = array(''); |
223 | 223 | } |
224 | 224 | } else { |
225 | - foreach ( (array) $rewrite as $match => $query ) { |
|
225 | + foreach ((array) $rewrite as $match => $query) { |
|
226 | 226 | // If the requesting file is the anchor of the match, prepend it to the path info. |
227 | - if ( ! empty($req_uri) && strpos($match, $req_uri) === 0 && $req_uri != $request ) |
|
228 | - $request_match = $req_uri . '/' . $request; |
|
227 | + if ( ! empty($req_uri) && strpos($match, $req_uri) === 0 && $req_uri != $request) |
|
228 | + $request_match = $req_uri.'/'.$request; |
|
229 | 229 | |
230 | - if ( preg_match("#^$match#", $request_match, $matches) || |
|
231 | - preg_match("#^$match#", urldecode($request_match), $matches) ) { |
|
230 | + if (preg_match("#^$match#", $request_match, $matches) || |
|
231 | + preg_match("#^$match#", urldecode($request_match), $matches)) { |
|
232 | 232 | |
233 | - if ( $wp_rewrite->use_verbose_page_rules && preg_match( '/pagename=\$matches\[([0-9]+)\]/', $query, $varmatch ) ) { |
|
233 | + if ($wp_rewrite->use_verbose_page_rules && preg_match('/pagename=\$matches\[([0-9]+)\]/', $query, $varmatch)) { |
|
234 | 234 | // This is a verbose page match, let's check to be sure about it. |
235 | - $page = get_page_by_path( $matches[ $varmatch[1] ] ); |
|
236 | - if ( ! $page ) { |
|
235 | + $page = get_page_by_path($matches[$varmatch[1]]); |
|
236 | + if ( ! $page) { |
|
237 | 237 | continue; |
238 | 238 | } |
239 | 239 | |
240 | - $post_status_obj = get_post_status_object( $page->post_status ); |
|
240 | + $post_status_obj = get_post_status_object($page->post_status); |
|
241 | 241 | if ( ! $post_status_obj->public && ! $post_status_obj->protected |
242 | - && ! $post_status_obj->private && $post_status_obj->exclude_from_search ) { |
|
242 | + && ! $post_status_obj->private && $post_status_obj->exclude_from_search) { |
|
243 | 243 | continue; |
244 | 244 | } |
245 | 245 | } |
@@ -251,7 +251,7 @@ discard block |
||
251 | 251 | } |
252 | 252 | } |
253 | 253 | |
254 | - if ( isset( $this->matched_rule ) ) { |
|
254 | + if (isset($this->matched_rule)) { |
|
255 | 255 | // Trim the query of everything up to the '?'. |
256 | 256 | $query = preg_replace("!^.+\?!", '', $query); |
257 | 257 | |
@@ -264,16 +264,16 @@ discard block |
||
264 | 264 | parse_str($query, $perma_query_vars); |
265 | 265 | |
266 | 266 | // If we're processing a 404 request, clear the error var since we found something. |
267 | - if ( '404' == $error ) |
|
268 | - unset( $error, $_GET['error'] ); |
|
267 | + if ('404' == $error) |
|
268 | + unset($error, $_GET['error']); |
|
269 | 269 | } |
270 | 270 | |
271 | 271 | // If req_uri is empty or if it is a request for ourself, unset error. |
272 | - if ( empty($request) || $req_uri == $self || strpos($_SERVER['PHP_SELF'], 'wp-admin/') !== false ) { |
|
273 | - unset( $error, $_GET['error'] ); |
|
272 | + if (empty($request) || $req_uri == $self || strpos($_SERVER['PHP_SELF'], 'wp-admin/') !== false) { |
|
273 | + unset($error, $_GET['error']); |
|
274 | 274 | |
275 | - if ( isset($perma_query_vars) && strpos($_SERVER['PHP_SELF'], 'wp-admin/') !== false ) |
|
276 | - unset( $perma_query_vars ); |
|
275 | + if (isset($perma_query_vars) && strpos($_SERVER['PHP_SELF'], 'wp-admin/') !== false) |
|
276 | + unset($perma_query_vars); |
|
277 | 277 | |
278 | 278 | $this->did_permalink = false; |
279 | 279 | } |
@@ -290,36 +290,36 @@ discard block |
||
290 | 290 | * |
291 | 291 | * @param array $public_query_vars The array of whitelisted query variables. |
292 | 292 | */ |
293 | - $this->public_query_vars = apply_filters( 'query_vars', $this->public_query_vars ); |
|
293 | + $this->public_query_vars = apply_filters('query_vars', $this->public_query_vars); |
|
294 | 294 | |
295 | - foreach ( get_post_types( array(), 'objects' ) as $post_type => $t ) { |
|
296 | - if ( is_post_type_viewable( $t ) && $t->query_var ) { |
|
295 | + foreach (get_post_types(array(), 'objects') as $post_type => $t) { |
|
296 | + if (is_post_type_viewable($t) && $t->query_var) { |
|
297 | 297 | $post_type_query_vars[$t->query_var] = $post_type; |
298 | 298 | } |
299 | 299 | } |
300 | 300 | |
301 | - foreach ( $this->public_query_vars as $wpvar ) { |
|
302 | - if ( isset( $this->extra_query_vars[$wpvar] ) ) |
|
301 | + foreach ($this->public_query_vars as $wpvar) { |
|
302 | + if (isset($this->extra_query_vars[$wpvar])) |
|
303 | 303 | $this->query_vars[$wpvar] = $this->extra_query_vars[$wpvar]; |
304 | - elseif ( isset( $_POST[$wpvar] ) ) |
|
304 | + elseif (isset($_POST[$wpvar])) |
|
305 | 305 | $this->query_vars[$wpvar] = $_POST[$wpvar]; |
306 | - elseif ( isset( $_GET[$wpvar] ) ) |
|
306 | + elseif (isset($_GET[$wpvar])) |
|
307 | 307 | $this->query_vars[$wpvar] = $_GET[$wpvar]; |
308 | - elseif ( isset( $perma_query_vars[$wpvar] ) ) |
|
308 | + elseif (isset($perma_query_vars[$wpvar])) |
|
309 | 309 | $this->query_vars[$wpvar] = $perma_query_vars[$wpvar]; |
310 | 310 | |
311 | - if ( !empty( $this->query_vars[$wpvar] ) ) { |
|
312 | - if ( ! is_array( $this->query_vars[$wpvar] ) ) { |
|
311 | + if ( ! empty($this->query_vars[$wpvar])) { |
|
312 | + if ( ! is_array($this->query_vars[$wpvar])) { |
|
313 | 313 | $this->query_vars[$wpvar] = (string) $this->query_vars[$wpvar]; |
314 | 314 | } else { |
315 | - foreach ( $this->query_vars[$wpvar] as $vkey => $v ) { |
|
316 | - if ( !is_object( $v ) ) { |
|
315 | + foreach ($this->query_vars[$wpvar] as $vkey => $v) { |
|
316 | + if ( ! is_object($v)) { |
|
317 | 317 | $this->query_vars[$wpvar][$vkey] = (string) $v; |
318 | 318 | } |
319 | 319 | } |
320 | 320 | } |
321 | 321 | |
322 | - if ( isset($post_type_query_vars[$wpvar] ) ) { |
|
322 | + if (isset($post_type_query_vars[$wpvar])) { |
|
323 | 323 | $this->query_vars['post_type'] = $post_type_query_vars[$wpvar]; |
324 | 324 | $this->query_vars['name'] = $this->query_vars[$wpvar]; |
325 | 325 | } |
@@ -327,43 +327,43 @@ discard block |
||
327 | 327 | } |
328 | 328 | |
329 | 329 | // Convert urldecoded spaces back into + |
330 | - foreach ( get_taxonomies( array() , 'objects' ) as $taxonomy => $t ) |
|
331 | - if ( $t->query_var && isset( $this->query_vars[$t->query_var] ) ) |
|
332 | - $this->query_vars[$t->query_var] = str_replace( ' ', '+', $this->query_vars[$t->query_var] ); |
|
330 | + foreach (get_taxonomies(array(), 'objects') as $taxonomy => $t) |
|
331 | + if ($t->query_var && isset($this->query_vars[$t->query_var])) |
|
332 | + $this->query_vars[$t->query_var] = str_replace(' ', '+', $this->query_vars[$t->query_var]); |
|
333 | 333 | |
334 | 334 | // Don't allow non-publicly queryable taxonomies to be queried from the front end. |
335 | - if ( ! is_admin() ) { |
|
336 | - foreach ( get_taxonomies( array( 'publicly_queryable' => false ), 'objects' ) as $taxonomy => $t ) { |
|
335 | + if ( ! is_admin()) { |
|
336 | + foreach (get_taxonomies(array('publicly_queryable' => false), 'objects') as $taxonomy => $t) { |
|
337 | 337 | /* |
338 | 338 | * Disallow when set to the 'taxonomy' query var. |
339 | 339 | * Non-publicly queryable taxonomies cannot register custom query vars. See register_taxonomy(). |
340 | 340 | */ |
341 | - if ( isset( $this->query_vars['taxonomy'] ) && $taxonomy === $this->query_vars['taxonomy'] ) { |
|
342 | - unset( $this->query_vars['taxonomy'], $this->query_vars['term'] ); |
|
341 | + if (isset($this->query_vars['taxonomy']) && $taxonomy === $this->query_vars['taxonomy']) { |
|
342 | + unset($this->query_vars['taxonomy'], $this->query_vars['term']); |
|
343 | 343 | } |
344 | 344 | } |
345 | 345 | } |
346 | 346 | |
347 | 347 | // Limit publicly queried post_types to those that are publicly_queryable |
348 | - if ( isset( $this->query_vars['post_type']) ) { |
|
349 | - $queryable_post_types = get_post_types( array('publicly_queryable' => true) ); |
|
350 | - if ( ! is_array( $this->query_vars['post_type'] ) ) { |
|
351 | - if ( ! in_array( $this->query_vars['post_type'], $queryable_post_types ) ) |
|
352 | - unset( $this->query_vars['post_type'] ); |
|
348 | + if (isset($this->query_vars['post_type'])) { |
|
349 | + $queryable_post_types = get_post_types(array('publicly_queryable' => true)); |
|
350 | + if ( ! is_array($this->query_vars['post_type'])) { |
|
351 | + if ( ! in_array($this->query_vars['post_type'], $queryable_post_types)) |
|
352 | + unset($this->query_vars['post_type']); |
|
353 | 353 | } else { |
354 | - $this->query_vars['post_type'] = array_intersect( $this->query_vars['post_type'], $queryable_post_types ); |
|
354 | + $this->query_vars['post_type'] = array_intersect($this->query_vars['post_type'], $queryable_post_types); |
|
355 | 355 | } |
356 | 356 | } |
357 | 357 | |
358 | 358 | // Resolve conflicts between posts with numeric slugs and date archive queries. |
359 | - $this->query_vars = wp_resolve_numeric_slug_conflicts( $this->query_vars ); |
|
359 | + $this->query_vars = wp_resolve_numeric_slug_conflicts($this->query_vars); |
|
360 | 360 | |
361 | - foreach ( (array) $this->private_query_vars as $var) { |
|
362 | - if ( isset($this->extra_query_vars[$var]) ) |
|
361 | + foreach ((array) $this->private_query_vars as $var) { |
|
362 | + if (isset($this->extra_query_vars[$var])) |
|
363 | 363 | $this->query_vars[$var] = $this->extra_query_vars[$var]; |
364 | 364 | } |
365 | 365 | |
366 | - if ( isset($error) ) |
|
366 | + if (isset($error)) |
|
367 | 367 | $this->query_vars['error'] = $error; |
368 | 368 | |
369 | 369 | /** |
@@ -373,7 +373,7 @@ discard block |
||
373 | 373 | * |
374 | 374 | * @param array $query_vars The array of requested query variables. |
375 | 375 | */ |
376 | - $this->query_vars = apply_filters( 'request', $this->query_vars ); |
|
376 | + $this->query_vars = apply_filters('request', $this->query_vars); |
|
377 | 377 | |
378 | 378 | /** |
379 | 379 | * Fires once all query variables for the current request have been parsed. |
@@ -382,7 +382,7 @@ discard block |
||
382 | 382 | * |
383 | 383 | * @param WP &$this Current WordPress environment instance (passed by reference). |
384 | 384 | */ |
385 | - do_action_ref_array( 'parse_request', array( &$this ) ); |
|
385 | + do_action_ref_array('parse_request', array(&$this)); |
|
386 | 386 | } |
387 | 387 | |
388 | 388 | /** |
@@ -400,50 +400,50 @@ discard block |
||
400 | 400 | $status = null; |
401 | 401 | $exit_required = false; |
402 | 402 | |
403 | - if ( is_user_logged_in() ) |
|
403 | + if (is_user_logged_in()) |
|
404 | 404 | $headers = array_merge($headers, wp_get_nocache_headers()); |
405 | - if ( ! empty( $this->query_vars['error'] ) ) { |
|
405 | + if ( ! empty($this->query_vars['error'])) { |
|
406 | 406 | $status = (int) $this->query_vars['error']; |
407 | - if ( 404 === $status ) { |
|
408 | - if ( ! is_user_logged_in() ) |
|
407 | + if (404 === $status) { |
|
408 | + if ( ! is_user_logged_in()) |
|
409 | 409 | $headers = array_merge($headers, wp_get_nocache_headers()); |
410 | - $headers['Content-Type'] = get_option('html_type') . '; charset=' . get_option('blog_charset'); |
|
411 | - } elseif ( in_array( $status, array( 403, 500, 502, 503 ) ) ) { |
|
410 | + $headers['Content-Type'] = get_option('html_type').'; charset='.get_option('blog_charset'); |
|
411 | + } elseif (in_array($status, array(403, 500, 502, 503))) { |
|
412 | 412 | $exit_required = true; |
413 | 413 | } |
414 | - } elseif ( empty( $this->query_vars['feed'] ) ) { |
|
415 | - $headers['Content-Type'] = get_option('html_type') . '; charset=' . get_option('blog_charset'); |
|
414 | + } elseif (empty($this->query_vars['feed'])) { |
|
415 | + $headers['Content-Type'] = get_option('html_type').'; charset='.get_option('blog_charset'); |
|
416 | 416 | } else { |
417 | 417 | // Set the correct content type for feeds |
418 | 418 | $type = $this->query_vars['feed']; |
419 | - if ( 'feed' == $this->query_vars['feed'] ) { |
|
419 | + if ('feed' == $this->query_vars['feed']) { |
|
420 | 420 | $type = get_default_feed(); |
421 | 421 | } |
422 | - $headers['Content-Type'] = feed_content_type( $type ) . '; charset=' . get_option( 'blog_charset' ); |
|
422 | + $headers['Content-Type'] = feed_content_type($type).'; charset='.get_option('blog_charset'); |
|
423 | 423 | |
424 | 424 | // We're showing a feed, so WP is indeed the only thing that last changed |
425 | - if ( !empty($this->query_vars['withcomments']) |
|
426 | - || false !== strpos( $this->query_vars['feed'], 'comments-' ) |
|
427 | - || ( empty($this->query_vars['withoutcomments']) |
|
428 | - && ( !empty($this->query_vars['p']) |
|
429 | - || !empty($this->query_vars['name']) |
|
430 | - || !empty($this->query_vars['page_id']) |
|
431 | - || !empty($this->query_vars['pagename']) |
|
432 | - || !empty($this->query_vars['attachment']) |
|
433 | - || !empty($this->query_vars['attachment_id']) |
|
425 | + if ( ! empty($this->query_vars['withcomments']) |
|
426 | + || false !== strpos($this->query_vars['feed'], 'comments-') |
|
427 | + || (empty($this->query_vars['withoutcomments']) |
|
428 | + && ( ! empty($this->query_vars['p']) |
|
429 | + || ! empty($this->query_vars['name']) |
|
430 | + || ! empty($this->query_vars['page_id']) |
|
431 | + || ! empty($this->query_vars['pagename']) |
|
432 | + || ! empty($this->query_vars['attachment']) |
|
433 | + || ! empty($this->query_vars['attachment_id']) |
|
434 | 434 | ) |
435 | 435 | ) |
436 | 436 | ) |
437 | 437 | $wp_last_modified = mysql2date('D, d M Y H:i:s', get_lastcommentmodified('GMT'), 0).' GMT'; |
438 | 438 | else |
439 | 439 | $wp_last_modified = mysql2date('D, d M Y H:i:s', get_lastpostmodified('GMT'), 0).' GMT'; |
440 | - $wp_etag = '"' . md5($wp_last_modified) . '"'; |
|
440 | + $wp_etag = '"'.md5($wp_last_modified).'"'; |
|
441 | 441 | $headers['Last-Modified'] = $wp_last_modified; |
442 | 442 | $headers['ETag'] = $wp_etag; |
443 | 443 | |
444 | 444 | // Support for Conditional GET |
445 | 445 | if (isset($_SERVER['HTTP_IF_NONE_MATCH'])) |
446 | - $client_etag = wp_unslash( $_SERVER['HTTP_IF_NONE_MATCH'] ); |
|
446 | + $client_etag = wp_unslash($_SERVER['HTTP_IF_NONE_MATCH']); |
|
447 | 447 | else $client_etag = false; |
448 | 448 | |
449 | 449 | $client_last_modified = empty($_SERVER['HTTP_IF_MODIFIED_SINCE']) ? '' : trim($_SERVER['HTTP_IF_MODIFIED_SINCE']); |
@@ -453,9 +453,8 @@ discard block |
||
453 | 453 | // Make a timestamp for our most recent modification... |
454 | 454 | $wp_modified_timestamp = strtotime($wp_last_modified); |
455 | 455 | |
456 | - if ( ($client_last_modified && $client_etag) ? |
|
457 | - (($client_modified_timestamp >= $wp_modified_timestamp) && ($client_etag == $wp_etag)) : |
|
458 | - (($client_modified_timestamp >= $wp_modified_timestamp) || ($client_etag == $wp_etag)) ) { |
|
456 | + if (($client_last_modified && $client_etag) ? |
|
457 | + (($client_modified_timestamp >= $wp_modified_timestamp) && ($client_etag == $wp_etag)) : (($client_modified_timestamp >= $wp_modified_timestamp) || ($client_etag == $wp_etag))) { |
|
459 | 458 | $status = 304; |
460 | 459 | $exit_required = true; |
461 | 460 | } |
@@ -469,23 +468,23 @@ discard block |
||
469 | 468 | * @param array $headers The list of headers to be sent. |
470 | 469 | * @param WP $this Current WordPress environment instance. |
471 | 470 | */ |
472 | - $headers = apply_filters( 'wp_headers', $headers, $this ); |
|
471 | + $headers = apply_filters('wp_headers', $headers, $this); |
|
473 | 472 | |
474 | - if ( ! empty( $status ) ) |
|
475 | - status_header( $status ); |
|
473 | + if ( ! empty($status)) |
|
474 | + status_header($status); |
|
476 | 475 | |
477 | 476 | // If Last-Modified is set to false, it should not be sent (no-cache situation). |
478 | - if ( isset( $headers['Last-Modified'] ) && false === $headers['Last-Modified'] ) { |
|
479 | - unset( $headers['Last-Modified'] ); |
|
477 | + if (isset($headers['Last-Modified']) && false === $headers['Last-Modified']) { |
|
478 | + unset($headers['Last-Modified']); |
|
480 | 479 | |
481 | 480 | // In PHP 5.3+, make sure we are not sending a Last-Modified header. |
482 | - if ( function_exists( 'header_remove' ) ) { |
|
483 | - @header_remove( 'Last-Modified' ); |
|
481 | + if (function_exists('header_remove')) { |
|
482 | + @header_remove('Last-Modified'); |
|
484 | 483 | } else { |
485 | 484 | // In PHP 5.2, send an empty Last-Modified header, but only as a |
486 | 485 | // last resort to override a header already sent. #WP23021 |
487 | - foreach ( headers_list() as $header ) { |
|
488 | - if ( 0 === stripos( $header, 'Last-Modified' ) ) { |
|
486 | + foreach (headers_list() as $header) { |
|
487 | + if (0 === stripos($header, 'Last-Modified')) { |
|
489 | 488 | $headers['Last-Modified'] = ''; |
490 | 489 | break; |
491 | 490 | } |
@@ -493,10 +492,10 @@ discard block |
||
493 | 492 | } |
494 | 493 | } |
495 | 494 | |
496 | - foreach ( (array) $headers as $name => $field_value ) |
|
495 | + foreach ((array) $headers as $name => $field_value) |
|
497 | 496 | @header("{$name}: {$field_value}"); |
498 | 497 | |
499 | - if ( $exit_required ) |
|
498 | + if ($exit_required) |
|
500 | 499 | exit(); |
501 | 500 | |
502 | 501 | /** |
@@ -506,7 +505,7 @@ discard block |
||
506 | 505 | * |
507 | 506 | * @param WP &$this Current WordPress environment instance (passed by reference). |
508 | 507 | */ |
509 | - do_action_ref_array( 'send_headers', array( &$this ) ); |
|
508 | + do_action_ref_array('send_headers', array(&$this)); |
|
510 | 509 | } |
511 | 510 | |
512 | 511 | /** |
@@ -520,16 +519,16 @@ discard block |
||
520 | 519 | */ |
521 | 520 | public function build_query_string() { |
522 | 521 | $this->query_string = ''; |
523 | - foreach ( (array) array_keys($this->query_vars) as $wpvar) { |
|
524 | - if ( '' != $this->query_vars[$wpvar] ) { |
|
522 | + foreach ((array) array_keys($this->query_vars) as $wpvar) { |
|
523 | + if ('' != $this->query_vars[$wpvar]) { |
|
525 | 524 | $this->query_string .= (strlen($this->query_string) < 1) ? '' : '&'; |
526 | - if ( !is_scalar($this->query_vars[$wpvar]) ) // Discard non-scalars. |
|
525 | + if ( ! is_scalar($this->query_vars[$wpvar])) // Discard non-scalars. |
|
527 | 526 | continue; |
528 | - $this->query_string .= $wpvar . '=' . rawurlencode($this->query_vars[$wpvar]); |
|
527 | + $this->query_string .= $wpvar.'='.rawurlencode($this->query_vars[$wpvar]); |
|
529 | 528 | } |
530 | 529 | } |
531 | 530 | |
532 | - if ( has_filter( 'query_string' ) ) { // Don't bother filtering and parsing if no plugins are hooked in. |
|
531 | + if (has_filter('query_string')) { // Don't bother filtering and parsing if no plugins are hooked in. |
|
533 | 532 | /** |
534 | 533 | * Filter the query string before parsing. |
535 | 534 | * |
@@ -538,7 +537,7 @@ discard block |
||
538 | 537 | * |
539 | 538 | * @param string $query_string The query string to modify. |
540 | 539 | */ |
541 | - $this->query_string = apply_filters( 'query_string', $this->query_string ); |
|
540 | + $this->query_string = apply_filters('query_string', $this->query_string); |
|
542 | 541 | parse_str($this->query_string, $this->query_vars); |
543 | 542 | } |
544 | 543 | } |
@@ -566,22 +565,22 @@ discard block |
||
566 | 565 | global $wp_query; |
567 | 566 | |
568 | 567 | // Extract updated query vars back into global namespace. |
569 | - foreach ( (array) $wp_query->query_vars as $key => $value ) { |
|
570 | - $GLOBALS[ $key ] = $value; |
|
568 | + foreach ((array) $wp_query->query_vars as $key => $value) { |
|
569 | + $GLOBALS[$key] = $value; |
|
571 | 570 | } |
572 | 571 | |
573 | 572 | $GLOBALS['query_string'] = $this->query_string; |
574 | 573 | $GLOBALS['posts'] = & $wp_query->posts; |
575 | - $GLOBALS['post'] = isset( $wp_query->post ) ? $wp_query->post : null; |
|
574 | + $GLOBALS['post'] = isset($wp_query->post) ? $wp_query->post : null; |
|
576 | 575 | $GLOBALS['request'] = $wp_query->request; |
577 | 576 | |
578 | - if ( $wp_query->is_single() || $wp_query->is_page() ) { |
|
577 | + if ($wp_query->is_single() || $wp_query->is_page()) { |
|
579 | 578 | $GLOBALS['more'] = 1; |
580 | 579 | $GLOBALS['single'] = 1; |
581 | 580 | } |
582 | 581 | |
583 | - if ( $wp_query->is_author() && isset( $wp_query->post ) ) |
|
584 | - $GLOBALS['authordata'] = get_userdata( $wp_query->post->post_author ); |
|
582 | + if ($wp_query->is_author() && isset($wp_query->post)) |
|
583 | + $GLOBALS['authordata'] = get_userdata($wp_query->post->post_author); |
|
585 | 584 | } |
586 | 585 | |
587 | 586 | /** |
@@ -640,70 +639,70 @@ discard block |
||
640 | 639 | * @param bool $preempt Whether to short-circuit default header status handling. Default false. |
641 | 640 | * @param WP_Query $wp_query WordPress Query object. |
642 | 641 | */ |
643 | - if ( false !== apply_filters( 'pre_handle_404', false, $wp_query ) ) { |
|
642 | + if (false !== apply_filters('pre_handle_404', false, $wp_query)) { |
|
644 | 643 | return; |
645 | 644 | } |
646 | 645 | |
647 | 646 | // If we've already issued a 404, bail. |
648 | - if ( is_404() ) |
|
647 | + if (is_404()) |
|
649 | 648 | return; |
650 | 649 | |
651 | 650 | // Never 404 for the admin, robots, or if we found posts. |
652 | - if ( is_admin() || is_robots() || $wp_query->posts ) { |
|
651 | + if (is_admin() || is_robots() || $wp_query->posts) { |
|
653 | 652 | |
654 | 653 | $success = true; |
655 | - if ( is_singular() ) { |
|
654 | + if (is_singular()) { |
|
656 | 655 | $p = false; |
657 | 656 | |
658 | - if ( $wp_query->post instanceof WP_Post ) { |
|
657 | + if ($wp_query->post instanceof WP_Post) { |
|
659 | 658 | $p = clone $wp_query->post; |
660 | 659 | } |
661 | 660 | |
662 | 661 | // Only set X-Pingback for single posts that allow pings. |
663 | - if ( $p && pings_open( $p ) ) { |
|
664 | - @header( 'X-Pingback: ' . get_bloginfo( 'pingback_url' ) ); |
|
662 | + if ($p && pings_open($p)) { |
|
663 | + @header('X-Pingback: '.get_bloginfo('pingback_url')); |
|
665 | 664 | } |
666 | 665 | |
667 | 666 | // check for paged content that exceeds the max number of pages |
668 | 667 | $next = '<!--nextpage-->'; |
669 | - if ( $p && false !== strpos( $p->post_content, $next ) && ! empty( $this->query_vars['page'] ) ) { |
|
670 | - $page = trim( $this->query_vars['page'], '/' ); |
|
671 | - $success = (int) $page <= ( substr_count( $p->post_content, $next ) + 1 ); |
|
668 | + if ($p && false !== strpos($p->post_content, $next) && ! empty($this->query_vars['page'])) { |
|
669 | + $page = trim($this->query_vars['page'], '/'); |
|
670 | + $success = (int) $page <= (substr_count($p->post_content, $next) + 1); |
|
672 | 671 | } |
673 | 672 | } |
674 | 673 | |
675 | - if ( $success ) { |
|
676 | - status_header( 200 ); |
|
674 | + if ($success) { |
|
675 | + status_header(200); |
|
677 | 676 | return; |
678 | 677 | } |
679 | 678 | } |
680 | 679 | |
681 | 680 | // We will 404 for paged queries, as no posts were found. |
682 | - if ( ! is_paged() ) { |
|
681 | + if ( ! is_paged()) { |
|
683 | 682 | |
684 | 683 | // Don't 404 for authors without posts as long as they matched an author on this site. |
685 | - $author = get_query_var( 'author' ); |
|
686 | - if ( is_author() && is_numeric( $author ) && $author > 0 && is_user_member_of_blog( $author ) ) { |
|
687 | - status_header( 200 ); |
|
684 | + $author = get_query_var('author'); |
|
685 | + if (is_author() && is_numeric($author) && $author > 0 && is_user_member_of_blog($author)) { |
|
686 | + status_header(200); |
|
688 | 687 | return; |
689 | 688 | } |
690 | 689 | |
691 | 690 | // Don't 404 for these queries if they matched an object. |
692 | - if ( ( is_tag() || is_category() || is_tax() || is_post_type_archive() ) && get_queried_object() ) { |
|
693 | - status_header( 200 ); |
|
691 | + if ((is_tag() || is_category() || is_tax() || is_post_type_archive()) && get_queried_object()) { |
|
692 | + status_header(200); |
|
694 | 693 | return; |
695 | 694 | } |
696 | 695 | |
697 | 696 | // Don't 404 for these queries either. |
698 | - if ( is_home() || is_search() || is_feed() ) { |
|
699 | - status_header( 200 ); |
|
697 | + if (is_home() || is_search() || is_feed()) { |
|
698 | + status_header(200); |
|
700 | 699 | return; |
701 | 700 | } |
702 | 701 | } |
703 | 702 | |
704 | 703 | // Guess it's time to 404. |
705 | 704 | $wp_query->set_404(); |
706 | - status_header( 404 ); |
|
705 | + status_header(404); |
|
707 | 706 | nocache_headers(); |
708 | 707 | } |
709 | 708 | |
@@ -734,7 +733,7 @@ discard block |
||
734 | 733 | * |
735 | 734 | * @param WP &$this Current WordPress environment instance (passed by reference). |
736 | 735 | */ |
737 | - do_action_ref_array( 'wp', array( &$this ) ); |
|
736 | + do_action_ref_array('wp', array(&$this)); |
|
738 | 737 | } |
739 | 738 | } |
740 | 739 | |
@@ -824,6 +823,6 @@ discard block |
||
824 | 823 | */ |
825 | 824 | public function callback($matches) { |
826 | 825 | $index = intval(substr($matches[0], 9, -1)); |
827 | - return ( isset( $this->_matches[$index] ) ? urlencode($this->_matches[$index]) : '' ); |
|
826 | + return (isset($this->_matches[$index]) ? urlencode($this->_matches[$index]) : ''); |
|
828 | 827 | } |
829 | 828 | } |
@@ -100,8 +100,9 @@ discard block |
||
100 | 100 | * @param string $qv Query variable name. |
101 | 101 | */ |
102 | 102 | public function add_query_var($qv) { |
103 | - if ( !in_array($qv, $this->public_query_vars) ) |
|
104 | - $this->public_query_vars[] = $qv; |
|
103 | + if ( !in_array($qv, $this->public_query_vars) ) { |
|
104 | + $this->public_query_vars[] = $qv; |
|
105 | + } |
|
105 | 106 | } |
106 | 107 | |
107 | 108 | /** |
@@ -154,8 +155,9 @@ discard block |
||
154 | 155 | * @param WP $this Current WordPress environment instance. |
155 | 156 | * @param array|string $extra_query_vars Extra passed query variables. |
156 | 157 | */ |
157 | - if ( ! apply_filters( 'do_parse_request', true, $this, $extra_query_vars ) ) |
|
158 | - return; |
|
158 | + if ( ! apply_filters( 'do_parse_request', true, $this, $extra_query_vars ) ) { |
|
159 | + return; |
|
160 | + } |
|
159 | 161 | |
160 | 162 | $this->query_vars = array(); |
161 | 163 | $post_type_query_vars = array(); |
@@ -205,8 +207,9 @@ discard block |
||
205 | 207 | $request = $pathinfo; |
206 | 208 | } else { |
207 | 209 | // If the request uri is the index, blank it out so that we don't try to match it against a rule. |
208 | - if ( $req_uri == $wp_rewrite->index ) |
|
209 | - $req_uri = ''; |
|
210 | + if ( $req_uri == $wp_rewrite->index ) { |
|
211 | + $req_uri = ''; |
|
212 | + } |
|
210 | 213 | $request = $req_uri; |
211 | 214 | } |
212 | 215 | |
@@ -224,8 +227,9 @@ discard block |
||
224 | 227 | } else { |
225 | 228 | foreach ( (array) $rewrite as $match => $query ) { |
226 | 229 | // If the requesting file is the anchor of the match, prepend it to the path info. |
227 | - if ( ! empty($req_uri) && strpos($match, $req_uri) === 0 && $req_uri != $request ) |
|
228 | - $request_match = $req_uri . '/' . $request; |
|
230 | + if ( ! empty($req_uri) && strpos($match, $req_uri) === 0 && $req_uri != $request ) { |
|
231 | + $request_match = $req_uri . '/' . $request; |
|
232 | + } |
|
229 | 233 | |
230 | 234 | if ( preg_match("#^$match#", $request_match, $matches) || |
231 | 235 | preg_match("#^$match#", urldecode($request_match), $matches) ) { |
@@ -264,16 +268,18 @@ discard block |
||
264 | 268 | parse_str($query, $perma_query_vars); |
265 | 269 | |
266 | 270 | // If we're processing a 404 request, clear the error var since we found something. |
267 | - if ( '404' == $error ) |
|
268 | - unset( $error, $_GET['error'] ); |
|
271 | + if ( '404' == $error ) { |
|
272 | + unset( $error, $_GET['error'] ); |
|
273 | + } |
|
269 | 274 | } |
270 | 275 | |
271 | 276 | // If req_uri is empty or if it is a request for ourself, unset error. |
272 | 277 | if ( empty($request) || $req_uri == $self || strpos($_SERVER['PHP_SELF'], 'wp-admin/') !== false ) { |
273 | 278 | unset( $error, $_GET['error'] ); |
274 | 279 | |
275 | - if ( isset($perma_query_vars) && strpos($_SERVER['PHP_SELF'], 'wp-admin/') !== false ) |
|
276 | - unset( $perma_query_vars ); |
|
280 | + if ( isset($perma_query_vars) && strpos($_SERVER['PHP_SELF'], 'wp-admin/') !== false ) { |
|
281 | + unset( $perma_query_vars ); |
|
282 | + } |
|
277 | 283 | |
278 | 284 | $this->did_permalink = false; |
279 | 285 | } |
@@ -299,14 +305,15 @@ discard block |
||
299 | 305 | } |
300 | 306 | |
301 | 307 | foreach ( $this->public_query_vars as $wpvar ) { |
302 | - if ( isset( $this->extra_query_vars[$wpvar] ) ) |
|
303 | - $this->query_vars[$wpvar] = $this->extra_query_vars[$wpvar]; |
|
304 | - elseif ( isset( $_POST[$wpvar] ) ) |
|
305 | - $this->query_vars[$wpvar] = $_POST[$wpvar]; |
|
306 | - elseif ( isset( $_GET[$wpvar] ) ) |
|
307 | - $this->query_vars[$wpvar] = $_GET[$wpvar]; |
|
308 | - elseif ( isset( $perma_query_vars[$wpvar] ) ) |
|
309 | - $this->query_vars[$wpvar] = $perma_query_vars[$wpvar]; |
|
308 | + if ( isset( $this->extra_query_vars[$wpvar] ) ) { |
|
309 | + $this->query_vars[$wpvar] = $this->extra_query_vars[$wpvar]; |
|
310 | + } elseif ( isset( $_POST[$wpvar] ) ) { |
|
311 | + $this->query_vars[$wpvar] = $_POST[$wpvar]; |
|
312 | + } elseif ( isset( $_GET[$wpvar] ) ) { |
|
313 | + $this->query_vars[$wpvar] = $_GET[$wpvar]; |
|
314 | + } elseif ( isset( $perma_query_vars[$wpvar] ) ) { |
|
315 | + $this->query_vars[$wpvar] = $perma_query_vars[$wpvar]; |
|
316 | + } |
|
310 | 317 | |
311 | 318 | if ( !empty( $this->query_vars[$wpvar] ) ) { |
312 | 319 | if ( ! is_array( $this->query_vars[$wpvar] ) ) { |
@@ -327,9 +334,10 @@ discard block |
||
327 | 334 | } |
328 | 335 | |
329 | 336 | // Convert urldecoded spaces back into + |
330 | - foreach ( get_taxonomies( array() , 'objects' ) as $taxonomy => $t ) |
|
331 | - if ( $t->query_var && isset( $this->query_vars[$t->query_var] ) ) |
|
337 | + foreach ( get_taxonomies( array() , 'objects' ) as $taxonomy => $t ) { |
|
338 | + if ( $t->query_var && isset( $this->query_vars[$t->query_var] ) ) |
|
332 | 339 | $this->query_vars[$t->query_var] = str_replace( ' ', '+', $this->query_vars[$t->query_var] ); |
340 | + } |
|
333 | 341 | |
334 | 342 | // Don't allow non-publicly queryable taxonomies to be queried from the front end. |
335 | 343 | if ( ! is_admin() ) { |
@@ -348,8 +356,9 @@ discard block |
||
348 | 356 | if ( isset( $this->query_vars['post_type']) ) { |
349 | 357 | $queryable_post_types = get_post_types( array('publicly_queryable' => true) ); |
350 | 358 | if ( ! is_array( $this->query_vars['post_type'] ) ) { |
351 | - if ( ! in_array( $this->query_vars['post_type'], $queryable_post_types ) ) |
|
352 | - unset( $this->query_vars['post_type'] ); |
|
359 | + if ( ! in_array( $this->query_vars['post_type'], $queryable_post_types ) ) { |
|
360 | + unset( $this->query_vars['post_type'] ); |
|
361 | + } |
|
353 | 362 | } else { |
354 | 363 | $this->query_vars['post_type'] = array_intersect( $this->query_vars['post_type'], $queryable_post_types ); |
355 | 364 | } |
@@ -359,12 +368,14 @@ discard block |
||
359 | 368 | $this->query_vars = wp_resolve_numeric_slug_conflicts( $this->query_vars ); |
360 | 369 | |
361 | 370 | foreach ( (array) $this->private_query_vars as $var) { |
362 | - if ( isset($this->extra_query_vars[$var]) ) |
|
363 | - $this->query_vars[$var] = $this->extra_query_vars[$var]; |
|
371 | + if ( isset($this->extra_query_vars[$var]) ) { |
|
372 | + $this->query_vars[$var] = $this->extra_query_vars[$var]; |
|
373 | + } |
|
364 | 374 | } |
365 | 375 | |
366 | - if ( isset($error) ) |
|
367 | - $this->query_vars['error'] = $error; |
|
376 | + if ( isset($error) ) { |
|
377 | + $this->query_vars['error'] = $error; |
|
378 | + } |
|
368 | 379 | |
369 | 380 | /** |
370 | 381 | * Filter the array of parsed query variables. |
@@ -400,13 +411,15 @@ discard block |
||
400 | 411 | $status = null; |
401 | 412 | $exit_required = false; |
402 | 413 | |
403 | - if ( is_user_logged_in() ) |
|
404 | - $headers = array_merge($headers, wp_get_nocache_headers()); |
|
414 | + if ( is_user_logged_in() ) { |
|
415 | + $headers = array_merge($headers, wp_get_nocache_headers()); |
|
416 | + } |
|
405 | 417 | if ( ! empty( $this->query_vars['error'] ) ) { |
406 | 418 | $status = (int) $this->query_vars['error']; |
407 | 419 | if ( 404 === $status ) { |
408 | - if ( ! is_user_logged_in() ) |
|
409 | - $headers = array_merge($headers, wp_get_nocache_headers()); |
|
420 | + if ( ! is_user_logged_in() ) { |
|
421 | + $headers = array_merge($headers, wp_get_nocache_headers()); |
|
422 | + } |
|
410 | 423 | $headers['Content-Type'] = get_option('html_type') . '; charset=' . get_option('blog_charset'); |
411 | 424 | } elseif ( in_array( $status, array( 403, 500, 502, 503 ) ) ) { |
412 | 425 | $exit_required = true; |
@@ -433,18 +446,21 @@ discard block |
||
433 | 446 | || !empty($this->query_vars['attachment_id']) |
434 | 447 | ) |
435 | 448 | ) |
436 | - ) |
|
437 | - $wp_last_modified = mysql2date('D, d M Y H:i:s', get_lastcommentmodified('GMT'), 0).' GMT'; |
|
438 | - else |
|
439 | - $wp_last_modified = mysql2date('D, d M Y H:i:s', get_lastpostmodified('GMT'), 0).' GMT'; |
|
449 | + ) { |
|
450 | + $wp_last_modified = mysql2date('D, d M Y H:i:s', get_lastcommentmodified('GMT'), 0).' GMT'; |
|
451 | + } else { |
|
452 | + $wp_last_modified = mysql2date('D, d M Y H:i:s', get_lastpostmodified('GMT'), 0).' GMT'; |
|
453 | + } |
|
440 | 454 | $wp_etag = '"' . md5($wp_last_modified) . '"'; |
441 | 455 | $headers['Last-Modified'] = $wp_last_modified; |
442 | 456 | $headers['ETag'] = $wp_etag; |
443 | 457 | |
444 | 458 | // Support for Conditional GET |
445 | - if (isset($_SERVER['HTTP_IF_NONE_MATCH'])) |
|
446 | - $client_etag = wp_unslash( $_SERVER['HTTP_IF_NONE_MATCH'] ); |
|
447 | - else $client_etag = false; |
|
459 | + if (isset($_SERVER['HTTP_IF_NONE_MATCH'])) { |
|
460 | + $client_etag = wp_unslash( $_SERVER['HTTP_IF_NONE_MATCH'] ); |
|
461 | + } else { |
|
462 | + $client_etag = false; |
|
463 | + } |
|
448 | 464 | |
449 | 465 | $client_last_modified = empty($_SERVER['HTTP_IF_MODIFIED_SINCE']) ? '' : trim($_SERVER['HTTP_IF_MODIFIED_SINCE']); |
450 | 466 | // If string is empty, return 0. If not, attempt to parse into a timestamp |
@@ -471,8 +487,9 @@ discard block |
||
471 | 487 | */ |
472 | 488 | $headers = apply_filters( 'wp_headers', $headers, $this ); |
473 | 489 | |
474 | - if ( ! empty( $status ) ) |
|
475 | - status_header( $status ); |
|
490 | + if ( ! empty( $status ) ) { |
|
491 | + status_header( $status ); |
|
492 | + } |
|
476 | 493 | |
477 | 494 | // If Last-Modified is set to false, it should not be sent (no-cache situation). |
478 | 495 | if ( isset( $headers['Last-Modified'] ) && false === $headers['Last-Modified'] ) { |
@@ -493,11 +510,13 @@ discard block |
||
493 | 510 | } |
494 | 511 | } |
495 | 512 | |
496 | - foreach ( (array) $headers as $name => $field_value ) |
|
497 | - @header("{$name}: {$field_value}"); |
|
513 | + foreach ( (array) $headers as $name => $field_value ) { |
|
514 | + @header("{$name}: {$field_value}"); |
|
515 | + } |
|
498 | 516 | |
499 | - if ( $exit_required ) |
|
500 | - exit(); |
|
517 | + if ( $exit_required ) { |
|
518 | + exit(); |
|
519 | + } |
|
501 | 520 | |
502 | 521 | /** |
503 | 522 | * Fires once the requested HTTP headers for caching, content type, etc. have been sent. |
@@ -523,8 +542,10 @@ discard block |
||
523 | 542 | foreach ( (array) array_keys($this->query_vars) as $wpvar) { |
524 | 543 | if ( '' != $this->query_vars[$wpvar] ) { |
525 | 544 | $this->query_string .= (strlen($this->query_string) < 1) ? '' : '&'; |
526 | - if ( !is_scalar($this->query_vars[$wpvar]) ) // Discard non-scalars. |
|
545 | + if ( !is_scalar($this->query_vars[$wpvar]) ) { |
|
546 | + // Discard non-scalars. |
|
527 | 547 | continue; |
548 | + } |
|
528 | 549 | $this->query_string .= $wpvar . '=' . rawurlencode($this->query_vars[$wpvar]); |
529 | 550 | } |
530 | 551 | } |
@@ -580,8 +601,9 @@ discard block |
||
580 | 601 | $GLOBALS['single'] = 1; |
581 | 602 | } |
582 | 603 | |
583 | - if ( $wp_query->is_author() && isset( $wp_query->post ) ) |
|
584 | - $GLOBALS['authordata'] = get_userdata( $wp_query->post->post_author ); |
|
604 | + if ( $wp_query->is_author() && isset( $wp_query->post ) ) { |
|
605 | + $GLOBALS['authordata'] = get_userdata( $wp_query->post->post_author ); |
|
606 | + } |
|
585 | 607 | } |
586 | 608 | |
587 | 609 | /** |
@@ -645,8 +667,9 @@ discard block |
||
645 | 667 | } |
646 | 668 | |
647 | 669 | // If we've already issued a 404, bail. |
648 | - if ( is_404() ) |
|
649 | - return; |
|
670 | + if ( is_404() ) { |
|
671 | + return; |
|
672 | + } |
|
650 | 673 | |
651 | 674 | // Never 404 for the admin, robots, or if we found posts. |
652 | 675 | if ( is_admin() || is_robots() || $wp_query->posts ) { |
@@ -615,15 +615,15 @@ |
||
615 | 615 | wp_version_check(); |
616 | 616 | } |
617 | 617 | /** |
618 | - * Check the last time plugins were run before checking plugin versions. |
|
619 | - * |
|
620 | - * This might have been backported to WordPress 2.6.1 for performance reasons. |
|
621 | - * This is used for the wp-admin to check only so often instead of every page |
|
622 | - * load. |
|
623 | - * |
|
624 | - * @since 2.7.0 |
|
625 | - * @access private |
|
626 | - */ |
|
618 | + * Check the last time plugins were run before checking plugin versions. |
|
619 | + * |
|
620 | + * This might have been backported to WordPress 2.6.1 for performance reasons. |
|
621 | + * This is used for the wp-admin to check only so often instead of every page |
|
622 | + * load. |
|
623 | + * |
|
624 | + * @since 2.7.0 |
|
625 | + * @access private |
|
626 | + */ |
|
627 | 627 | function _maybe_update_plugins() { |
628 | 628 | $current = get_site_transient( 'update_plugins' ); |
629 | 629 | if ( isset( $current->last_checked ) && 12 * HOUR_IN_SECONDS > ( time() - $current->last_checked ) ) |
@@ -21,36 +21,36 @@ discard block |
||
21 | 21 | * @param array $extra_stats Extra statistics to report to the WordPress.org API. |
22 | 22 | * @param bool $force_check Whether to bypass the transient cache and force a fresh update check. Defaults to false, true if $extra_stats is set. |
23 | 23 | */ |
24 | -function wp_version_check( $extra_stats = array(), $force_check = false ) { |
|
25 | - if ( wp_installing() ) { |
|
24 | +function wp_version_check($extra_stats = array(), $force_check = false) { |
|
25 | + if (wp_installing()) { |
|
26 | 26 | return; |
27 | 27 | } |
28 | 28 | |
29 | 29 | global $wpdb, $wp_local_package; |
30 | 30 | // include an unmodified $wp_version |
31 | - include( ABSPATH . WPINC . '/version.php' ); |
|
31 | + include(ABSPATH.WPINC.'/version.php'); |
|
32 | 32 | $php_version = phpversion(); |
33 | 33 | |
34 | - $current = get_site_transient( 'update_core' ); |
|
35 | - $translations = wp_get_installed_translations( 'core' ); |
|
34 | + $current = get_site_transient('update_core'); |
|
35 | + $translations = wp_get_installed_translations('core'); |
|
36 | 36 | |
37 | 37 | // Invalidate the transient when $wp_version changes |
38 | - if ( is_object( $current ) && $wp_version != $current->version_checked ) |
|
38 | + if (is_object($current) && $wp_version != $current->version_checked) |
|
39 | 39 | $current = false; |
40 | 40 | |
41 | - if ( ! is_object($current) ) { |
|
41 | + if ( ! is_object($current)) { |
|
42 | 42 | $current = new stdClass; |
43 | 43 | $current->updates = array(); |
44 | 44 | $current->version_checked = $wp_version; |
45 | 45 | } |
46 | 46 | |
47 | - if ( ! empty( $extra_stats ) ) |
|
47 | + if ( ! empty($extra_stats)) |
|
48 | 48 | $force_check = true; |
49 | 49 | |
50 | 50 | // Wait 60 seconds between multiple version check requests |
51 | 51 | $timeout = 60; |
52 | - $time_not_changed = isset( $current->last_checked ) && $timeout > ( time() - $current->last_checked ); |
|
53 | - if ( ! $force_check && $time_not_changed ) { |
|
52 | + $time_not_changed = isset($current->last_checked) && $timeout > (time() - $current->last_checked); |
|
53 | + if ( ! $force_check && $time_not_changed) { |
|
54 | 54 | return; |
55 | 55 | } |
56 | 56 | |
@@ -61,18 +61,18 @@ discard block |
||
61 | 61 | * |
62 | 62 | * @param string $locale Current locale. |
63 | 63 | */ |
64 | - $locale = apply_filters( 'core_version_check_locale', get_locale() ); |
|
64 | + $locale = apply_filters('core_version_check_locale', get_locale()); |
|
65 | 65 | |
66 | 66 | // Update last_checked for current to prevent multiple blocking requests if request hangs |
67 | 67 | $current->last_checked = time(); |
68 | - set_site_transient( 'update_core', $current ); |
|
68 | + set_site_transient('update_core', $current); |
|
69 | 69 | |
70 | - if ( method_exists( $wpdb, 'db_version' ) ) |
|
70 | + if (method_exists($wpdb, 'db_version')) |
|
71 | 71 | $mysql_version = preg_replace('/[^0-9.].*/', '', $wpdb->db_version()); |
72 | 72 | else |
73 | 73 | $mysql_version = 'N/A'; |
74 | 74 | |
75 | - if ( is_multisite() ) { |
|
75 | + if (is_multisite()) { |
|
76 | 76 | $user_count = get_user_count(); |
77 | 77 | $num_blogs = get_blog_count(); |
78 | 78 | $wp_install = network_site_url(); |
@@ -82,7 +82,7 @@ discard block |
||
82 | 82 | $user_count = $user_count['total_users']; |
83 | 83 | $multisite_enabled = 0; |
84 | 84 | $num_blogs = 1; |
85 | - $wp_install = home_url( '/' ); |
|
85 | + $wp_install = home_url('/'); |
|
86 | 86 | } |
87 | 87 | |
88 | 88 | $query = array( |
@@ -90,65 +90,65 @@ discard block |
||
90 | 90 | 'php' => $php_version, |
91 | 91 | 'locale' => $locale, |
92 | 92 | 'mysql' => $mysql_version, |
93 | - 'local_package' => isset( $wp_local_package ) ? $wp_local_package : '', |
|
93 | + 'local_package' => isset($wp_local_package) ? $wp_local_package : '', |
|
94 | 94 | 'blogs' => $num_blogs, |
95 | 95 | 'users' => $user_count, |
96 | 96 | 'multisite_enabled' => $multisite_enabled, |
97 | - 'initial_db_version' => get_site_option( 'initial_db_version' ), |
|
97 | + 'initial_db_version' => get_site_option('initial_db_version'), |
|
98 | 98 | ); |
99 | 99 | |
100 | 100 | $post_body = array( |
101 | - 'translations' => wp_json_encode( $translations ), |
|
101 | + 'translations' => wp_json_encode($translations), |
|
102 | 102 | ); |
103 | 103 | |
104 | - if ( is_array( $extra_stats ) ) |
|
105 | - $post_body = array_merge( $post_body, $extra_stats ); |
|
104 | + if (is_array($extra_stats)) |
|
105 | + $post_body = array_merge($post_body, $extra_stats); |
|
106 | 106 | |
107 | - $url = $http_url = 'http://api.wordpress.org/core/version-check/1.7/?' . http_build_query( $query, null, '&' ); |
|
108 | - if ( $ssl = wp_http_supports( array( 'ssl' ) ) ) |
|
109 | - $url = set_url_scheme( $url, 'https' ); |
|
107 | + $url = $http_url = 'http://api.wordpress.org/core/version-check/1.7/?'.http_build_query($query, null, '&'); |
|
108 | + if ($ssl = wp_http_supports(array('ssl'))) |
|
109 | + $url = set_url_scheme($url, 'https'); |
|
110 | 110 | |
111 | 111 | $options = array( |
112 | - 'timeout' => ( ( defined('DOING_CRON') && DOING_CRON ) ? 30 : 3 ), |
|
113 | - 'user-agent' => 'WordPress/' . $wp_version . '; ' . home_url( '/' ), |
|
112 | + 'timeout' => ((defined('DOING_CRON') && DOING_CRON) ? 30 : 3), |
|
113 | + 'user-agent' => 'WordPress/'.$wp_version.'; '.home_url('/'), |
|
114 | 114 | 'headers' => array( |
115 | 115 | 'wp_install' => $wp_install, |
116 | - 'wp_blog' => home_url( '/' ) |
|
116 | + 'wp_blog' => home_url('/') |
|
117 | 117 | ), |
118 | 118 | 'body' => $post_body, |
119 | 119 | ); |
120 | 120 | |
121 | - $response = wp_remote_post( $url, $options ); |
|
122 | - if ( $ssl && is_wp_error( $response ) ) { |
|
123 | - trigger_error( __( 'An unexpected error occurred. Something may be wrong with WordPress.org or this server’s configuration. If you continue to have problems, please try the <a href="https://wordpress.org/support/">support forums</a>.' ) . ' ' . __( '(WordPress could not establish a secure connection to WordPress.org. Please contact your server administrator.)' ), headers_sent() || WP_DEBUG ? E_USER_WARNING : E_USER_NOTICE ); |
|
124 | - $response = wp_remote_post( $http_url, $options ); |
|
121 | + $response = wp_remote_post($url, $options); |
|
122 | + if ($ssl && is_wp_error($response)) { |
|
123 | + trigger_error(__('An unexpected error occurred. Something may be wrong with WordPress.org or this server’s configuration. If you continue to have problems, please try the <a href="https://wordpress.org/support/">support forums</a>.').' '.__('(WordPress could not establish a secure connection to WordPress.org. Please contact your server administrator.)'), headers_sent() || WP_DEBUG ? E_USER_WARNING : E_USER_NOTICE); |
|
124 | + $response = wp_remote_post($http_url, $options); |
|
125 | 125 | } |
126 | 126 | |
127 | - if ( is_wp_error( $response ) || 200 != wp_remote_retrieve_response_code( $response ) ) { |
|
127 | + if (is_wp_error($response) || 200 != wp_remote_retrieve_response_code($response)) { |
|
128 | 128 | return; |
129 | 129 | } |
130 | 130 | |
131 | - $body = trim( wp_remote_retrieve_body( $response ) ); |
|
132 | - $body = json_decode( $body, true ); |
|
131 | + $body = trim(wp_remote_retrieve_body($response)); |
|
132 | + $body = json_decode($body, true); |
|
133 | 133 | |
134 | - if ( ! is_array( $body ) || ! isset( $body['offers'] ) ) { |
|
134 | + if ( ! is_array($body) || ! isset($body['offers'])) { |
|
135 | 135 | return; |
136 | 136 | } |
137 | 137 | |
138 | 138 | $offers = $body['offers']; |
139 | 139 | |
140 | - foreach ( $offers as &$offer ) { |
|
141 | - foreach ( $offer as $offer_key => $value ) { |
|
142 | - if ( 'packages' == $offer_key ) |
|
143 | - $offer['packages'] = (object) array_intersect_key( array_map( 'esc_url', $offer['packages'] ), |
|
144 | - array_fill_keys( array( 'full', 'no_content', 'new_bundled', 'partial', 'rollback' ), '' ) ); |
|
145 | - elseif ( 'download' == $offer_key ) |
|
146 | - $offer['download'] = esc_url( $value ); |
|
140 | + foreach ($offers as &$offer) { |
|
141 | + foreach ($offer as $offer_key => $value) { |
|
142 | + if ('packages' == $offer_key) |
|
143 | + $offer['packages'] = (object) array_intersect_key(array_map('esc_url', $offer['packages']), |
|
144 | + array_fill_keys(array('full', 'no_content', 'new_bundled', 'partial', 'rollback'), '')); |
|
145 | + elseif ('download' == $offer_key) |
|
146 | + $offer['download'] = esc_url($value); |
|
147 | 147 | else |
148 | - $offer[ $offer_key ] = esc_html( $value ); |
|
148 | + $offer[$offer_key] = esc_html($value); |
|
149 | 149 | } |
150 | - $offer = (object) array_intersect_key( $offer, array_fill_keys( array( 'response', 'download', 'locale', |
|
151 | - 'packages', 'current', 'version', 'php_version', 'mysql_version', 'new_bundled', 'partial_version', 'notify_email', 'support_email', 'new_files' ), '' ) ); |
|
150 | + $offer = (object) array_intersect_key($offer, array_fill_keys(array('response', 'download', 'locale', |
|
151 | + 'packages', 'current', 'version', 'php_version', 'mysql_version', 'new_bundled', 'partial_version', 'notify_email', 'support_email', 'new_files'), '')); |
|
152 | 152 | } |
153 | 153 | |
154 | 154 | $updates = new stdClass(); |
@@ -156,22 +156,22 @@ discard block |
||
156 | 156 | $updates->last_checked = time(); |
157 | 157 | $updates->version_checked = $wp_version; |
158 | 158 | |
159 | - if ( isset( $body['translations'] ) ) |
|
159 | + if (isset($body['translations'])) |
|
160 | 160 | $updates->translations = $body['translations']; |
161 | 161 | |
162 | - set_site_transient( 'update_core', $updates ); |
|
162 | + set_site_transient('update_core', $updates); |
|
163 | 163 | |
164 | - if ( ! empty( $body['ttl'] ) ) { |
|
164 | + if ( ! empty($body['ttl'])) { |
|
165 | 165 | $ttl = (int) $body['ttl']; |
166 | - if ( $ttl && ( time() + $ttl < wp_next_scheduled( 'wp_version_check' ) ) ) { |
|
166 | + if ($ttl && (time() + $ttl < wp_next_scheduled('wp_version_check'))) { |
|
167 | 167 | // Queue an event to re-run the update check in $ttl seconds. |
168 | - wp_schedule_single_event( time() + $ttl, 'wp_version_check' ); |
|
168 | + wp_schedule_single_event(time() + $ttl, 'wp_version_check'); |
|
169 | 169 | } |
170 | 170 | } |
171 | 171 | |
172 | 172 | // Trigger background updates if running non-interactively, and we weren't called from the update handler. |
173 | - if ( defined( 'DOING_CRON' ) && DOING_CRON && ! doing_action( 'wp_maybe_auto_update' ) ) { |
|
174 | - do_action( 'wp_maybe_auto_update' ); |
|
173 | + if (defined('DOING_CRON') && DOING_CRON && ! doing_action('wp_maybe_auto_update')) { |
|
174 | + do_action('wp_maybe_auto_update'); |
|
175 | 175 | } |
176 | 176 | } |
177 | 177 | |
@@ -187,31 +187,31 @@ discard block |
||
187 | 187 | * |
188 | 188 | * @param array $extra_stats Extra statistics to report to the WordPress.org API. |
189 | 189 | */ |
190 | -function wp_update_plugins( $extra_stats = array() ) { |
|
191 | - if ( wp_installing() ) { |
|
190 | +function wp_update_plugins($extra_stats = array()) { |
|
191 | + if (wp_installing()) { |
|
192 | 192 | return; |
193 | 193 | } |
194 | 194 | |
195 | 195 | // include an unmodified $wp_version |
196 | - include( ABSPATH . WPINC . '/version.php' ); |
|
196 | + include(ABSPATH.WPINC.'/version.php'); |
|
197 | 197 | |
198 | 198 | // If running blog-side, bail unless we've not checked in the last 12 hours |
199 | - if ( !function_exists( 'get_plugins' ) ) |
|
200 | - require_once( ABSPATH . 'wp-admin/includes/plugin.php' ); |
|
199 | + if ( ! function_exists('get_plugins')) |
|
200 | + require_once(ABSPATH.'wp-admin/includes/plugin.php'); |
|
201 | 201 | |
202 | 202 | $plugins = get_plugins(); |
203 | - $translations = wp_get_installed_translations( 'plugins' ); |
|
203 | + $translations = wp_get_installed_translations('plugins'); |
|
204 | 204 | |
205 | - $active = get_option( 'active_plugins', array() ); |
|
206 | - $current = get_site_transient( 'update_plugins' ); |
|
207 | - if ( ! is_object($current) ) |
|
205 | + $active = get_option('active_plugins', array()); |
|
206 | + $current = get_site_transient('update_plugins'); |
|
207 | + if ( ! is_object($current)) |
|
208 | 208 | $current = new stdClass; |
209 | 209 | |
210 | 210 | $new_option = new stdClass; |
211 | 211 | $new_option->last_checked = time(); |
212 | 212 | |
213 | 213 | // Check for update on a different schedule, depending on the page. |
214 | - switch ( current_filter() ) { |
|
214 | + switch (current_filter()) { |
|
215 | 215 | case 'upgrader_process_complete' : |
216 | 216 | $timeout = 0; |
217 | 217 | break; |
@@ -223,27 +223,27 @@ discard block |
||
223 | 223 | $timeout = HOUR_IN_SECONDS; |
224 | 224 | break; |
225 | 225 | default : |
226 | - if ( defined( 'DOING_CRON' ) && DOING_CRON ) { |
|
226 | + if (defined('DOING_CRON') && DOING_CRON) { |
|
227 | 227 | $timeout = 0; |
228 | 228 | } else { |
229 | 229 | $timeout = 12 * HOUR_IN_SECONDS; |
230 | 230 | } |
231 | 231 | } |
232 | 232 | |
233 | - $time_not_changed = isset( $current->last_checked ) && $timeout > ( time() - $current->last_checked ); |
|
233 | + $time_not_changed = isset($current->last_checked) && $timeout > (time() - $current->last_checked); |
|
234 | 234 | |
235 | - if ( $time_not_changed && ! $extra_stats ) { |
|
235 | + if ($time_not_changed && ! $extra_stats) { |
|
236 | 236 | $plugin_changed = false; |
237 | - foreach ( $plugins as $file => $p ) { |
|
238 | - $new_option->checked[ $file ] = $p['Version']; |
|
237 | + foreach ($plugins as $file => $p) { |
|
238 | + $new_option->checked[$file] = $p['Version']; |
|
239 | 239 | |
240 | - if ( !isset( $current->checked[ $file ] ) || strval($current->checked[ $file ]) !== strval($p['Version']) ) |
|
240 | + if ( ! isset($current->checked[$file]) || strval($current->checked[$file]) !== strval($p['Version'])) |
|
241 | 241 | $plugin_changed = true; |
242 | 242 | } |
243 | 243 | |
244 | - if ( isset ( $current->response ) && is_array( $current->response ) ) { |
|
245 | - foreach ( $current->response as $plugin_file => $update_details ) { |
|
246 | - if ( ! isset($plugins[ $plugin_file ]) ) { |
|
244 | + if (isset ($current->response) && is_array($current->response)) { |
|
245 | + foreach ($current->response as $plugin_file => $update_details) { |
|
246 | + if ( ! isset($plugins[$plugin_file])) { |
|
247 | 247 | $plugin_changed = true; |
248 | 248 | break; |
249 | 249 | } |
@@ -251,18 +251,18 @@ discard block |
||
251 | 251 | } |
252 | 252 | |
253 | 253 | // Bail if we've checked recently and if nothing has changed |
254 | - if ( ! $plugin_changed ) { |
|
254 | + if ( ! $plugin_changed) { |
|
255 | 255 | return; |
256 | 256 | } |
257 | 257 | } |
258 | 258 | |
259 | 259 | // Update last_checked for current to prevent multiple blocking requests if request hangs |
260 | 260 | $current->last_checked = time(); |
261 | - set_site_transient( 'update_plugins', $current ); |
|
261 | + set_site_transient('update_plugins', $current); |
|
262 | 262 | |
263 | - $to_send = compact( 'plugins', 'active' ); |
|
263 | + $to_send = compact('plugins', 'active'); |
|
264 | 264 | |
265 | - $locales = array_values( get_available_languages() ); |
|
265 | + $locales = array_values(get_available_languages()); |
|
266 | 266 | |
267 | 267 | /** |
268 | 268 | * Filter the locales requested for plugin translations. |
@@ -272,62 +272,62 @@ discard block |
||
272 | 272 | * |
273 | 273 | * @param array $locales Plugin locales. Default is all available locales of the site. |
274 | 274 | */ |
275 | - $locales = apply_filters( 'plugins_update_check_locales', $locales ); |
|
276 | - $locales = array_unique( $locales ); |
|
275 | + $locales = apply_filters('plugins_update_check_locales', $locales); |
|
276 | + $locales = array_unique($locales); |
|
277 | 277 | |
278 | - if ( defined( 'DOING_CRON' ) && DOING_CRON ) { |
|
278 | + if (defined('DOING_CRON') && DOING_CRON) { |
|
279 | 279 | $timeout = 30; |
280 | 280 | } else { |
281 | 281 | // Three seconds, plus one extra second for every 10 plugins |
282 | - $timeout = 3 + (int) ( count( $plugins ) / 10 ); |
|
282 | + $timeout = 3 + (int) (count($plugins) / 10); |
|
283 | 283 | } |
284 | 284 | |
285 | 285 | $options = array( |
286 | 286 | 'timeout' => $timeout, |
287 | 287 | 'body' => array( |
288 | - 'plugins' => wp_json_encode( $to_send ), |
|
289 | - 'translations' => wp_json_encode( $translations ), |
|
290 | - 'locale' => wp_json_encode( $locales ), |
|
291 | - 'all' => wp_json_encode( true ), |
|
288 | + 'plugins' => wp_json_encode($to_send), |
|
289 | + 'translations' => wp_json_encode($translations), |
|
290 | + 'locale' => wp_json_encode($locales), |
|
291 | + 'all' => wp_json_encode(true), |
|
292 | 292 | ), |
293 | - 'user-agent' => 'WordPress/' . $wp_version . '; ' . get_bloginfo( 'url' ) |
|
293 | + 'user-agent' => 'WordPress/'.$wp_version.'; '.get_bloginfo('url') |
|
294 | 294 | ); |
295 | 295 | |
296 | - if ( $extra_stats ) { |
|
297 | - $options['body']['update_stats'] = wp_json_encode( $extra_stats ); |
|
296 | + if ($extra_stats) { |
|
297 | + $options['body']['update_stats'] = wp_json_encode($extra_stats); |
|
298 | 298 | } |
299 | 299 | |
300 | 300 | $url = $http_url = 'http://api.wordpress.org/plugins/update-check/1.1/'; |
301 | - if ( $ssl = wp_http_supports( array( 'ssl' ) ) ) |
|
302 | - $url = set_url_scheme( $url, 'https' ); |
|
301 | + if ($ssl = wp_http_supports(array('ssl'))) |
|
302 | + $url = set_url_scheme($url, 'https'); |
|
303 | 303 | |
304 | - $raw_response = wp_remote_post( $url, $options ); |
|
305 | - if ( $ssl && is_wp_error( $raw_response ) ) { |
|
306 | - trigger_error( __( 'An unexpected error occurred. Something may be wrong with WordPress.org or this server’s configuration. If you continue to have problems, please try the <a href="https://wordpress.org/support/">support forums</a>.' ) . ' ' . __( '(WordPress could not establish a secure connection to WordPress.org. Please contact your server administrator.)' ), headers_sent() || WP_DEBUG ? E_USER_WARNING : E_USER_NOTICE ); |
|
307 | - $raw_response = wp_remote_post( $http_url, $options ); |
|
304 | + $raw_response = wp_remote_post($url, $options); |
|
305 | + if ($ssl && is_wp_error($raw_response)) { |
|
306 | + trigger_error(__('An unexpected error occurred. Something may be wrong with WordPress.org or this server’s configuration. If you continue to have problems, please try the <a href="https://wordpress.org/support/">support forums</a>.').' '.__('(WordPress could not establish a secure connection to WordPress.org. Please contact your server administrator.)'), headers_sent() || WP_DEBUG ? E_USER_WARNING : E_USER_NOTICE); |
|
307 | + $raw_response = wp_remote_post($http_url, $options); |
|
308 | 308 | } |
309 | 309 | |
310 | - if ( is_wp_error( $raw_response ) || 200 != wp_remote_retrieve_response_code( $raw_response ) ) { |
|
310 | + if (is_wp_error($raw_response) || 200 != wp_remote_retrieve_response_code($raw_response)) { |
|
311 | 311 | return; |
312 | 312 | } |
313 | 313 | |
314 | - $response = json_decode( wp_remote_retrieve_body( $raw_response ), true ); |
|
315 | - foreach ( $response['plugins'] as &$plugin ) { |
|
314 | + $response = json_decode(wp_remote_retrieve_body($raw_response), true); |
|
315 | + foreach ($response['plugins'] as &$plugin) { |
|
316 | 316 | $plugin = (object) $plugin; |
317 | - if ( isset( $plugin->compatibility ) ) { |
|
317 | + if (isset($plugin->compatibility)) { |
|
318 | 318 | $plugin->compatibility = (object) $plugin->compatibility; |
319 | - foreach ( $plugin->compatibility as &$data ) { |
|
319 | + foreach ($plugin->compatibility as &$data) { |
|
320 | 320 | $data = (object) $data; |
321 | 321 | } |
322 | 322 | } |
323 | 323 | } |
324 | - unset( $plugin, $data ); |
|
325 | - foreach ( $response['no_update'] as &$plugin ) { |
|
324 | + unset($plugin, $data); |
|
325 | + foreach ($response['no_update'] as &$plugin) { |
|
326 | 326 | $plugin = (object) $plugin; |
327 | 327 | } |
328 | - unset( $plugin ); |
|
328 | + unset($plugin); |
|
329 | 329 | |
330 | - if ( is_array( $response ) ) { |
|
330 | + if (is_array($response)) { |
|
331 | 331 | $new_option->response = $response['plugins']; |
332 | 332 | $new_option->translations = $response['translations']; |
333 | 333 | // TODO: Perhaps better to store no_update in a separate transient with an expiry? |
@@ -338,7 +338,7 @@ discard block |
||
338 | 338 | $new_option->no_update = array(); |
339 | 339 | } |
340 | 340 | |
341 | - set_site_transient( 'update_plugins', $new_option ); |
|
341 | + set_site_transient('update_plugins', $new_option); |
|
342 | 342 | } |
343 | 343 | |
344 | 344 | /** |
@@ -352,30 +352,30 @@ discard block |
||
352 | 352 | * |
353 | 353 | * @param array $extra_stats Extra statistics to report to the WordPress.org API. |
354 | 354 | */ |
355 | -function wp_update_themes( $extra_stats = array() ) { |
|
356 | - if ( wp_installing() ) { |
|
355 | +function wp_update_themes($extra_stats = array()) { |
|
356 | + if (wp_installing()) { |
|
357 | 357 | return; |
358 | 358 | } |
359 | 359 | |
360 | 360 | // include an unmodified $wp_version |
361 | - include( ABSPATH . WPINC . '/version.php' ); |
|
361 | + include(ABSPATH.WPINC.'/version.php'); |
|
362 | 362 | |
363 | 363 | $installed_themes = wp_get_themes(); |
364 | - $translations = wp_get_installed_translations( 'themes' ); |
|
364 | + $translations = wp_get_installed_translations('themes'); |
|
365 | 365 | |
366 | - $last_update = get_site_transient( 'update_themes' ); |
|
367 | - if ( ! is_object($last_update) ) |
|
366 | + $last_update = get_site_transient('update_themes'); |
|
367 | + if ( ! is_object($last_update)) |
|
368 | 368 | $last_update = new stdClass; |
369 | 369 | |
370 | 370 | $themes = $checked = $request = array(); |
371 | 371 | |
372 | 372 | // Put slug of current theme into request. |
373 | - $request['active'] = get_option( 'stylesheet' ); |
|
373 | + $request['active'] = get_option('stylesheet'); |
|
374 | 374 | |
375 | - foreach ( $installed_themes as $theme ) { |
|
376 | - $checked[ $theme->get_stylesheet() ] = $theme->get('Version'); |
|
375 | + foreach ($installed_themes as $theme) { |
|
376 | + $checked[$theme->get_stylesheet()] = $theme->get('Version'); |
|
377 | 377 | |
378 | - $themes[ $theme->get_stylesheet() ] = array( |
|
378 | + $themes[$theme->get_stylesheet()] = array( |
|
379 | 379 | 'Name' => $theme->get('Name'), |
380 | 380 | 'Title' => $theme->get('Name'), |
381 | 381 | 'Version' => $theme->get('Version'), |
@@ -387,7 +387,7 @@ discard block |
||
387 | 387 | } |
388 | 388 | |
389 | 389 | // Check for update on a different schedule, depending on the page. |
390 | - switch ( current_filter() ) { |
|
390 | + switch (current_filter()) { |
|
391 | 391 | case 'upgrader_process_complete' : |
392 | 392 | $timeout = 0; |
393 | 393 | break; |
@@ -399,25 +399,25 @@ discard block |
||
399 | 399 | $timeout = HOUR_IN_SECONDS; |
400 | 400 | break; |
401 | 401 | default : |
402 | - if ( defined( 'DOING_CRON' ) && DOING_CRON ) { |
|
402 | + if (defined('DOING_CRON') && DOING_CRON) { |
|
403 | 403 | $timeout = 0; |
404 | 404 | } else { |
405 | 405 | $timeout = 12 * HOUR_IN_SECONDS; |
406 | 406 | } |
407 | 407 | } |
408 | 408 | |
409 | - $time_not_changed = isset( $last_update->last_checked ) && $timeout > ( time() - $last_update->last_checked ); |
|
409 | + $time_not_changed = isset($last_update->last_checked) && $timeout > (time() - $last_update->last_checked); |
|
410 | 410 | |
411 | - if ( $time_not_changed && ! $extra_stats ) { |
|
411 | + if ($time_not_changed && ! $extra_stats) { |
|
412 | 412 | $theme_changed = false; |
413 | - foreach ( $checked as $slug => $v ) { |
|
414 | - if ( !isset( $last_update->checked[ $slug ] ) || strval($last_update->checked[ $slug ]) !== strval($v) ) |
|
413 | + foreach ($checked as $slug => $v) { |
|
414 | + if ( ! isset($last_update->checked[$slug]) || strval($last_update->checked[$slug]) !== strval($v)) |
|
415 | 415 | $theme_changed = true; |
416 | 416 | } |
417 | 417 | |
418 | - if ( isset ( $last_update->response ) && is_array( $last_update->response ) ) { |
|
419 | - foreach ( $last_update->response as $slug => $update_details ) { |
|
420 | - if ( ! isset($checked[ $slug ]) ) { |
|
418 | + if (isset ($last_update->response) && is_array($last_update->response)) { |
|
419 | + foreach ($last_update->response as $slug => $update_details) { |
|
420 | + if ( ! isset($checked[$slug])) { |
|
421 | 421 | $theme_changed = true; |
422 | 422 | break; |
423 | 423 | } |
@@ -425,18 +425,18 @@ discard block |
||
425 | 425 | } |
426 | 426 | |
427 | 427 | // Bail if we've checked recently and if nothing has changed |
428 | - if ( ! $theme_changed ) { |
|
428 | + if ( ! $theme_changed) { |
|
429 | 429 | return; |
430 | 430 | } |
431 | 431 | } |
432 | 432 | |
433 | 433 | // Update last_checked for current to prevent multiple blocking requests if request hangs |
434 | 434 | $last_update->last_checked = time(); |
435 | - set_site_transient( 'update_themes', $last_update ); |
|
435 | + set_site_transient('update_themes', $last_update); |
|
436 | 436 | |
437 | 437 | $request['themes'] = $themes; |
438 | 438 | |
439 | - $locales = array_values( get_available_languages() ); |
|
439 | + $locales = array_values(get_available_languages()); |
|
440 | 440 | |
441 | 441 | /** |
442 | 442 | * Filter the locales requested for theme translations. |
@@ -446,41 +446,41 @@ discard block |
||
446 | 446 | * |
447 | 447 | * @param array $locales Theme locales. Default is all available locales of the site. |
448 | 448 | */ |
449 | - $locales = apply_filters( 'themes_update_check_locales', $locales ); |
|
450 | - $locales = array_unique( $locales ); |
|
449 | + $locales = apply_filters('themes_update_check_locales', $locales); |
|
450 | + $locales = array_unique($locales); |
|
451 | 451 | |
452 | - if ( defined( 'DOING_CRON' ) && DOING_CRON ) { |
|
452 | + if (defined('DOING_CRON') && DOING_CRON) { |
|
453 | 453 | $timeout = 30; |
454 | 454 | } else { |
455 | 455 | // Three seconds, plus one extra second for every 10 themes |
456 | - $timeout = 3 + (int) ( count( $themes ) / 10 ); |
|
456 | + $timeout = 3 + (int) (count($themes) / 10); |
|
457 | 457 | } |
458 | 458 | |
459 | 459 | $options = array( |
460 | 460 | 'timeout' => $timeout, |
461 | 461 | 'body' => array( |
462 | - 'themes' => wp_json_encode( $request ), |
|
463 | - 'translations' => wp_json_encode( $translations ), |
|
464 | - 'locale' => wp_json_encode( $locales ), |
|
462 | + 'themes' => wp_json_encode($request), |
|
463 | + 'translations' => wp_json_encode($translations), |
|
464 | + 'locale' => wp_json_encode($locales), |
|
465 | 465 | ), |
466 | - 'user-agent' => 'WordPress/' . $wp_version . '; ' . get_bloginfo( 'url' ) |
|
466 | + 'user-agent' => 'WordPress/'.$wp_version.'; '.get_bloginfo('url') |
|
467 | 467 | ); |
468 | 468 | |
469 | - if ( $extra_stats ) { |
|
470 | - $options['body']['update_stats'] = wp_json_encode( $extra_stats ); |
|
469 | + if ($extra_stats) { |
|
470 | + $options['body']['update_stats'] = wp_json_encode($extra_stats); |
|
471 | 471 | } |
472 | 472 | |
473 | 473 | $url = $http_url = 'http://api.wordpress.org/themes/update-check/1.1/'; |
474 | - if ( $ssl = wp_http_supports( array( 'ssl' ) ) ) |
|
475 | - $url = set_url_scheme( $url, 'https' ); |
|
474 | + if ($ssl = wp_http_supports(array('ssl'))) |
|
475 | + $url = set_url_scheme($url, 'https'); |
|
476 | 476 | |
477 | - $raw_response = wp_remote_post( $url, $options ); |
|
478 | - if ( $ssl && is_wp_error( $raw_response ) ) { |
|
479 | - trigger_error( __( 'An unexpected error occurred. Something may be wrong with WordPress.org or this server’s configuration. If you continue to have problems, please try the <a href="https://wordpress.org/support/">support forums</a>.' ) . ' ' . __( '(WordPress could not establish a secure connection to WordPress.org. Please contact your server administrator.)' ), headers_sent() || WP_DEBUG ? E_USER_WARNING : E_USER_NOTICE ); |
|
480 | - $raw_response = wp_remote_post( $http_url, $options ); |
|
477 | + $raw_response = wp_remote_post($url, $options); |
|
478 | + if ($ssl && is_wp_error($raw_response)) { |
|
479 | + trigger_error(__('An unexpected error occurred. Something may be wrong with WordPress.org or this server’s configuration. If you continue to have problems, please try the <a href="https://wordpress.org/support/">support forums</a>.').' '.__('(WordPress could not establish a secure connection to WordPress.org. Please contact your server administrator.)'), headers_sent() || WP_DEBUG ? E_USER_WARNING : E_USER_NOTICE); |
|
480 | + $raw_response = wp_remote_post($http_url, $options); |
|
481 | 481 | } |
482 | 482 | |
483 | - if ( is_wp_error( $raw_response ) || 200 != wp_remote_retrieve_response_code( $raw_response ) ) { |
|
483 | + if (is_wp_error($raw_response) || 200 != wp_remote_retrieve_response_code($raw_response)) { |
|
484 | 484 | return; |
485 | 485 | } |
486 | 486 | |
@@ -488,14 +488,14 @@ discard block |
||
488 | 488 | $new_update->last_checked = time(); |
489 | 489 | $new_update->checked = $checked; |
490 | 490 | |
491 | - $response = json_decode( wp_remote_retrieve_body( $raw_response ), true ); |
|
491 | + $response = json_decode(wp_remote_retrieve_body($raw_response), true); |
|
492 | 492 | |
493 | - if ( is_array( $response ) ) { |
|
493 | + if (is_array($response)) { |
|
494 | 494 | $new_update->response = $response['themes']; |
495 | 495 | $new_update->translations = $response['translations']; |
496 | 496 | } |
497 | 497 | |
498 | - set_site_transient( 'update_themes', $new_update ); |
|
498 | + set_site_transient('update_themes', $new_update); |
|
499 | 499 | } |
500 | 500 | |
501 | 501 | /** |
@@ -504,8 +504,8 @@ discard block |
||
504 | 504 | * @since 3.7.0 |
505 | 505 | */ |
506 | 506 | function wp_maybe_auto_update() { |
507 | - include_once( ABSPATH . '/wp-admin/includes/admin.php' ); |
|
508 | - include_once( ABSPATH . '/wp-admin/includes/class-wp-upgrader.php' ); |
|
507 | + include_once(ABSPATH.'/wp-admin/includes/admin.php'); |
|
508 | + include_once(ABSPATH.'/wp-admin/includes/class-wp-upgrader.php'); |
|
509 | 509 | |
510 | 510 | $upgrader = new WP_Automatic_Updater; |
511 | 511 | $upgrader->run(); |
@@ -520,13 +520,13 @@ discard block |
||
520 | 520 | */ |
521 | 521 | function wp_get_translation_updates() { |
522 | 522 | $updates = array(); |
523 | - $transients = array( 'update_core' => 'core', 'update_plugins' => 'plugin', 'update_themes' => 'theme' ); |
|
524 | - foreach ( $transients as $transient => $type ) { |
|
525 | - $transient = get_site_transient( $transient ); |
|
526 | - if ( empty( $transient->translations ) ) |
|
523 | + $transients = array('update_core' => 'core', 'update_plugins' => 'plugin', 'update_themes' => 'theme'); |
|
524 | + foreach ($transients as $transient => $type) { |
|
525 | + $transient = get_site_transient($transient); |
|
526 | + if (empty($transient->translations)) |
|
527 | 527 | continue; |
528 | 528 | |
529 | - foreach ( $transient->translations as $translation ) { |
|
529 | + foreach ($transient->translations as $translation) { |
|
530 | 530 | $updates[] = (object) $translation; |
531 | 531 | } |
532 | 532 | } |
@@ -541,43 +541,43 @@ discard block |
||
541 | 541 | * @return array |
542 | 542 | */ |
543 | 543 | function wp_get_update_data() { |
544 | - $counts = array( 'plugins' => 0, 'themes' => 0, 'wordpress' => 0, 'translations' => 0 ); |
|
544 | + $counts = array('plugins' => 0, 'themes' => 0, 'wordpress' => 0, 'translations' => 0); |
|
545 | 545 | |
546 | - if ( $plugins = current_user_can( 'update_plugins' ) ) { |
|
547 | - $update_plugins = get_site_transient( 'update_plugins' ); |
|
548 | - if ( ! empty( $update_plugins->response ) ) |
|
549 | - $counts['plugins'] = count( $update_plugins->response ); |
|
546 | + if ($plugins = current_user_can('update_plugins')) { |
|
547 | + $update_plugins = get_site_transient('update_plugins'); |
|
548 | + if ( ! empty($update_plugins->response)) |
|
549 | + $counts['plugins'] = count($update_plugins->response); |
|
550 | 550 | } |
551 | 551 | |
552 | - if ( $themes = current_user_can( 'update_themes' ) ) { |
|
553 | - $update_themes = get_site_transient( 'update_themes' ); |
|
554 | - if ( ! empty( $update_themes->response ) ) |
|
555 | - $counts['themes'] = count( $update_themes->response ); |
|
552 | + if ($themes = current_user_can('update_themes')) { |
|
553 | + $update_themes = get_site_transient('update_themes'); |
|
554 | + if ( ! empty($update_themes->response)) |
|
555 | + $counts['themes'] = count($update_themes->response); |
|
556 | 556 | } |
557 | 557 | |
558 | - if ( ( $core = current_user_can( 'update_core' ) ) && function_exists( 'get_core_updates' ) ) { |
|
559 | - $update_wordpress = get_core_updates( array('dismissed' => false) ); |
|
560 | - if ( ! empty( $update_wordpress ) && ! in_array( $update_wordpress[0]->response, array('development', 'latest') ) && current_user_can('update_core') ) |
|
558 | + if (($core = current_user_can('update_core')) && function_exists('get_core_updates')) { |
|
559 | + $update_wordpress = get_core_updates(array('dismissed' => false)); |
|
560 | + if ( ! empty($update_wordpress) && ! in_array($update_wordpress[0]->response, array('development', 'latest')) && current_user_can('update_core')) |
|
561 | 561 | $counts['wordpress'] = 1; |
562 | 562 | } |
563 | 563 | |
564 | - if ( ( $core || $plugins || $themes ) && wp_get_translation_updates() ) |
|
564 | + if (($core || $plugins || $themes) && wp_get_translation_updates()) |
|
565 | 565 | $counts['translations'] = 1; |
566 | 566 | |
567 | 567 | $counts['total'] = $counts['plugins'] + $counts['themes'] + $counts['wordpress'] + $counts['translations']; |
568 | 568 | $titles = array(); |
569 | - if ( $counts['wordpress'] ) |
|
570 | - $titles['wordpress'] = sprintf( __( '%d WordPress Update'), $counts['wordpress'] ); |
|
571 | - if ( $counts['plugins'] ) |
|
572 | - $titles['plugins'] = sprintf( _n( '%d Plugin Update', '%d Plugin Updates', $counts['plugins'] ), $counts['plugins'] ); |
|
573 | - if ( $counts['themes'] ) |
|
574 | - $titles['themes'] = sprintf( _n( '%d Theme Update', '%d Theme Updates', $counts['themes'] ), $counts['themes'] ); |
|
575 | - if ( $counts['translations'] ) |
|
576 | - $titles['translations'] = __( 'Translation Updates' ); |
|
577 | - |
|
578 | - $update_title = $titles ? esc_attr( implode( ', ', $titles ) ) : ''; |
|
579 | - |
|
580 | - $update_data = array( 'counts' => $counts, 'title' => $update_title ); |
|
569 | + if ($counts['wordpress']) |
|
570 | + $titles['wordpress'] = sprintf(__('%d WordPress Update'), $counts['wordpress']); |
|
571 | + if ($counts['plugins']) |
|
572 | + $titles['plugins'] = sprintf(_n('%d Plugin Update', '%d Plugin Updates', $counts['plugins']), $counts['plugins']); |
|
573 | + if ($counts['themes']) |
|
574 | + $titles['themes'] = sprintf(_n('%d Theme Update', '%d Theme Updates', $counts['themes']), $counts['themes']); |
|
575 | + if ($counts['translations']) |
|
576 | + $titles['translations'] = __('Translation Updates'); |
|
577 | + |
|
578 | + $update_title = $titles ? esc_attr(implode(', ', $titles)) : ''; |
|
579 | + |
|
580 | + $update_data = array('counts' => $counts, 'title' => $update_title); |
|
581 | 581 | /** |
582 | 582 | * Filter the returned array of update data for plugins, themes, and WordPress core. |
583 | 583 | * |
@@ -591,7 +591,7 @@ discard block |
||
591 | 591 | * } |
592 | 592 | * @param array $titles An array of update counts and UI strings for available updates. |
593 | 593 | */ |
594 | - return apply_filters( 'wp_get_update_data', $update_data, $titles ); |
|
594 | + return apply_filters('wp_get_update_data', $update_data, $titles); |
|
595 | 595 | } |
596 | 596 | |
597 | 597 | /** |
@@ -603,13 +603,13 @@ discard block |
||
603 | 603 | */ |
604 | 604 | function _maybe_update_core() { |
605 | 605 | // include an unmodified $wp_version |
606 | - include( ABSPATH . WPINC . '/version.php' ); |
|
606 | + include(ABSPATH.WPINC.'/version.php'); |
|
607 | 607 | |
608 | - $current = get_site_transient( 'update_core' ); |
|
608 | + $current = get_site_transient('update_core'); |
|
609 | 609 | |
610 | - if ( isset( $current->last_checked, $current->version_checked ) && |
|
611 | - 12 * HOUR_IN_SECONDS > ( time() - $current->last_checked ) && |
|
612 | - $current->version_checked == $wp_version ) { |
|
610 | + if (isset($current->last_checked, $current->version_checked) && |
|
611 | + 12 * HOUR_IN_SECONDS > (time() - $current->last_checked) && |
|
612 | + $current->version_checked == $wp_version) { |
|
613 | 613 | return; |
614 | 614 | } |
615 | 615 | wp_version_check(); |
@@ -625,8 +625,8 @@ discard block |
||
625 | 625 | * @access private |
626 | 626 | */ |
627 | 627 | function _maybe_update_plugins() { |
628 | - $current = get_site_transient( 'update_plugins' ); |
|
629 | - if ( isset( $current->last_checked ) && 12 * HOUR_IN_SECONDS > ( time() - $current->last_checked ) ) |
|
628 | + $current = get_site_transient('update_plugins'); |
|
629 | + if (isset($current->last_checked) && 12 * HOUR_IN_SECONDS > (time() - $current->last_checked)) |
|
630 | 630 | return; |
631 | 631 | wp_update_plugins(); |
632 | 632 | } |
@@ -641,8 +641,8 @@ discard block |
||
641 | 641 | * @access private |
642 | 642 | */ |
643 | 643 | function _maybe_update_themes() { |
644 | - $current = get_site_transient( 'update_themes' ); |
|
645 | - if ( isset( $current->last_checked ) && 12 * HOUR_IN_SECONDS > ( time() - $current->last_checked ) ) |
|
644 | + $current = get_site_transient('update_themes'); |
|
645 | + if (isset($current->last_checked) && 12 * HOUR_IN_SECONDS > (time() - $current->last_checked)) |
|
646 | 646 | return; |
647 | 647 | wp_update_themes(); |
648 | 648 | } |
@@ -653,13 +653,13 @@ discard block |
||
653 | 653 | * @since 3.1.0 |
654 | 654 | */ |
655 | 655 | function wp_schedule_update_checks() { |
656 | - if ( ! wp_next_scheduled( 'wp_version_check' ) && ! wp_installing() ) |
|
656 | + if ( ! wp_next_scheduled('wp_version_check') && ! wp_installing()) |
|
657 | 657 | wp_schedule_event(time(), 'twicedaily', 'wp_version_check'); |
658 | 658 | |
659 | - if ( ! wp_next_scheduled( 'wp_update_plugins' ) && ! wp_installing() ) |
|
659 | + if ( ! wp_next_scheduled('wp_update_plugins') && ! wp_installing()) |
|
660 | 660 | wp_schedule_event(time(), 'twicedaily', 'wp_update_plugins'); |
661 | 661 | |
662 | - if ( ! wp_next_scheduled( 'wp_update_themes' ) && ! wp_installing() ) |
|
662 | + if ( ! wp_next_scheduled('wp_update_themes') && ! wp_installing()) |
|
663 | 663 | wp_schedule_event(time(), 'twicedaily', 'wp_update_themes'); |
664 | 664 | } |
665 | 665 | |
@@ -669,39 +669,39 @@ discard block |
||
669 | 669 | * @since 4.1.0 |
670 | 670 | */ |
671 | 671 | function wp_clean_update_cache() { |
672 | - if ( function_exists( 'wp_clean_plugins_cache' ) ) { |
|
672 | + if (function_exists('wp_clean_plugins_cache')) { |
|
673 | 673 | wp_clean_plugins_cache(); |
674 | 674 | } else { |
675 | - delete_site_transient( 'update_plugins' ); |
|
675 | + delete_site_transient('update_plugins'); |
|
676 | 676 | } |
677 | 677 | wp_clean_themes_cache(); |
678 | - delete_site_transient( 'update_core' ); |
|
678 | + delete_site_transient('update_core'); |
|
679 | 679 | } |
680 | 680 | |
681 | -if ( ( ! is_main_site() && ! is_network_admin() ) || ( defined( 'DOING_AJAX' ) && DOING_AJAX ) ) { |
|
681 | +if (( ! is_main_site() && ! is_network_admin()) || (defined('DOING_AJAX') && DOING_AJAX)) { |
|
682 | 682 | return; |
683 | 683 | } |
684 | 684 | |
685 | -add_action( 'admin_init', '_maybe_update_core' ); |
|
686 | -add_action( 'wp_version_check', 'wp_version_check' ); |
|
687 | -add_action( 'upgrader_process_complete', 'wp_version_check', 10, 0 ); |
|
685 | +add_action('admin_init', '_maybe_update_core'); |
|
686 | +add_action('wp_version_check', 'wp_version_check'); |
|
687 | +add_action('upgrader_process_complete', 'wp_version_check', 10, 0); |
|
688 | 688 | |
689 | -add_action( 'load-plugins.php', 'wp_update_plugins' ); |
|
690 | -add_action( 'load-update.php', 'wp_update_plugins' ); |
|
691 | -add_action( 'load-update-core.php', 'wp_update_plugins' ); |
|
692 | -add_action( 'admin_init', '_maybe_update_plugins' ); |
|
693 | -add_action( 'wp_update_plugins', 'wp_update_plugins' ); |
|
694 | -add_action( 'upgrader_process_complete', 'wp_update_plugins', 10, 0 ); |
|
689 | +add_action('load-plugins.php', 'wp_update_plugins'); |
|
690 | +add_action('load-update.php', 'wp_update_plugins'); |
|
691 | +add_action('load-update-core.php', 'wp_update_plugins'); |
|
692 | +add_action('admin_init', '_maybe_update_plugins'); |
|
693 | +add_action('wp_update_plugins', 'wp_update_plugins'); |
|
694 | +add_action('upgrader_process_complete', 'wp_update_plugins', 10, 0); |
|
695 | 695 | |
696 | -add_action( 'load-themes.php', 'wp_update_themes' ); |
|
697 | -add_action( 'load-update.php', 'wp_update_themes' ); |
|
698 | -add_action( 'load-update-core.php', 'wp_update_themes' ); |
|
699 | -add_action( 'admin_init', '_maybe_update_themes' ); |
|
700 | -add_action( 'wp_update_themes', 'wp_update_themes' ); |
|
701 | -add_action( 'upgrader_process_complete', 'wp_update_themes', 10, 0 ); |
|
696 | +add_action('load-themes.php', 'wp_update_themes'); |
|
697 | +add_action('load-update.php', 'wp_update_themes'); |
|
698 | +add_action('load-update-core.php', 'wp_update_themes'); |
|
699 | +add_action('admin_init', '_maybe_update_themes'); |
|
700 | +add_action('wp_update_themes', 'wp_update_themes'); |
|
701 | +add_action('upgrader_process_complete', 'wp_update_themes', 10, 0); |
|
702 | 702 | |
703 | -add_action( 'update_option_WPLANG', 'wp_clean_update_cache' , 10, 0 ); |
|
703 | +add_action('update_option_WPLANG', 'wp_clean_update_cache', 10, 0); |
|
704 | 704 | |
705 | -add_action( 'wp_maybe_auto_update', 'wp_maybe_auto_update' ); |
|
705 | +add_action('wp_maybe_auto_update', 'wp_maybe_auto_update'); |
|
706 | 706 | |
707 | -add_action( 'init', 'wp_schedule_update_checks' ); |
|
707 | +add_action('init', 'wp_schedule_update_checks'); |
@@ -35,8 +35,9 @@ discard block |
||
35 | 35 | $translations = wp_get_installed_translations( 'core' ); |
36 | 36 | |
37 | 37 | // Invalidate the transient when $wp_version changes |
38 | - if ( is_object( $current ) && $wp_version != $current->version_checked ) |
|
39 | - $current = false; |
|
38 | + if ( is_object( $current ) && $wp_version != $current->version_checked ) { |
|
39 | + $current = false; |
|
40 | + } |
|
40 | 41 | |
41 | 42 | if ( ! is_object($current) ) { |
42 | 43 | $current = new stdClass; |
@@ -44,8 +45,9 @@ discard block |
||
44 | 45 | $current->version_checked = $wp_version; |
45 | 46 | } |
46 | 47 | |
47 | - if ( ! empty( $extra_stats ) ) |
|
48 | - $force_check = true; |
|
48 | + if ( ! empty( $extra_stats ) ) { |
|
49 | + $force_check = true; |
|
50 | + } |
|
49 | 51 | |
50 | 52 | // Wait 60 seconds between multiple version check requests |
51 | 53 | $timeout = 60; |
@@ -67,10 +69,11 @@ discard block |
||
67 | 69 | $current->last_checked = time(); |
68 | 70 | set_site_transient( 'update_core', $current ); |
69 | 71 | |
70 | - if ( method_exists( $wpdb, 'db_version' ) ) |
|
71 | - $mysql_version = preg_replace('/[^0-9.].*/', '', $wpdb->db_version()); |
|
72 | - else |
|
73 | - $mysql_version = 'N/A'; |
|
72 | + if ( method_exists( $wpdb, 'db_version' ) ) { |
|
73 | + $mysql_version = preg_replace('/[^0-9.].*/', '', $wpdb->db_version()); |
|
74 | + } else { |
|
75 | + $mysql_version = 'N/A'; |
|
76 | + } |
|
74 | 77 | |
75 | 78 | if ( is_multisite() ) { |
76 | 79 | $user_count = get_user_count(); |
@@ -101,12 +104,14 @@ discard block |
||
101 | 104 | 'translations' => wp_json_encode( $translations ), |
102 | 105 | ); |
103 | 106 | |
104 | - if ( is_array( $extra_stats ) ) |
|
105 | - $post_body = array_merge( $post_body, $extra_stats ); |
|
107 | + if ( is_array( $extra_stats ) ) { |
|
108 | + $post_body = array_merge( $post_body, $extra_stats ); |
|
109 | + } |
|
106 | 110 | |
107 | 111 | $url = $http_url = 'http://api.wordpress.org/core/version-check/1.7/?' . http_build_query( $query, null, '&' ); |
108 | - if ( $ssl = wp_http_supports( array( 'ssl' ) ) ) |
|
109 | - $url = set_url_scheme( $url, 'https' ); |
|
112 | + if ( $ssl = wp_http_supports( array( 'ssl' ) ) ) { |
|
113 | + $url = set_url_scheme( $url, 'https' ); |
|
114 | + } |
|
110 | 115 | |
111 | 116 | $options = array( |
112 | 117 | 'timeout' => ( ( defined('DOING_CRON') && DOING_CRON ) ? 30 : 3 ), |
@@ -139,13 +144,14 @@ discard block |
||
139 | 144 | |
140 | 145 | foreach ( $offers as &$offer ) { |
141 | 146 | foreach ( $offer as $offer_key => $value ) { |
142 | - if ( 'packages' == $offer_key ) |
|
143 | - $offer['packages'] = (object) array_intersect_key( array_map( 'esc_url', $offer['packages'] ), |
|
147 | + if ( 'packages' == $offer_key ) { |
|
148 | + $offer['packages'] = (object) array_intersect_key( array_map( 'esc_url', $offer['packages'] ), |
|
144 | 149 | array_fill_keys( array( 'full', 'no_content', 'new_bundled', 'partial', 'rollback' ), '' ) ); |
145 | - elseif ( 'download' == $offer_key ) |
|
146 | - $offer['download'] = esc_url( $value ); |
|
147 | - else |
|
148 | - $offer[ $offer_key ] = esc_html( $value ); |
|
150 | + } elseif ( 'download' == $offer_key ) { |
|
151 | + $offer['download'] = esc_url( $value ); |
|
152 | + } else { |
|
153 | + $offer[ $offer_key ] = esc_html( $value ); |
|
154 | + } |
|
149 | 155 | } |
150 | 156 | $offer = (object) array_intersect_key( $offer, array_fill_keys( array( 'response', 'download', 'locale', |
151 | 157 | 'packages', 'current', 'version', 'php_version', 'mysql_version', 'new_bundled', 'partial_version', 'notify_email', 'support_email', 'new_files' ), '' ) ); |
@@ -156,8 +162,9 @@ discard block |
||
156 | 162 | $updates->last_checked = time(); |
157 | 163 | $updates->version_checked = $wp_version; |
158 | 164 | |
159 | - if ( isset( $body['translations'] ) ) |
|
160 | - $updates->translations = $body['translations']; |
|
165 | + if ( isset( $body['translations'] ) ) { |
|
166 | + $updates->translations = $body['translations']; |
|
167 | + } |
|
161 | 168 | |
162 | 169 | set_site_transient( 'update_core', $updates ); |
163 | 170 | |
@@ -196,16 +203,18 @@ discard block |
||
196 | 203 | include( ABSPATH . WPINC . '/version.php' ); |
197 | 204 | |
198 | 205 | // If running blog-side, bail unless we've not checked in the last 12 hours |
199 | - if ( !function_exists( 'get_plugins' ) ) |
|
200 | - require_once( ABSPATH . 'wp-admin/includes/plugin.php' ); |
|
206 | + if ( !function_exists( 'get_plugins' ) ) { |
|
207 | + require_once( ABSPATH . 'wp-admin/includes/plugin.php' ); |
|
208 | + } |
|
201 | 209 | |
202 | 210 | $plugins = get_plugins(); |
203 | 211 | $translations = wp_get_installed_translations( 'plugins' ); |
204 | 212 | |
205 | 213 | $active = get_option( 'active_plugins', array() ); |
206 | 214 | $current = get_site_transient( 'update_plugins' ); |
207 | - if ( ! is_object($current) ) |
|
208 | - $current = new stdClass; |
|
215 | + if ( ! is_object($current) ) { |
|
216 | + $current = new stdClass; |
|
217 | + } |
|
209 | 218 | |
210 | 219 | $new_option = new stdClass; |
211 | 220 | $new_option->last_checked = time(); |
@@ -237,8 +246,9 @@ discard block |
||
237 | 246 | foreach ( $plugins as $file => $p ) { |
238 | 247 | $new_option->checked[ $file ] = $p['Version']; |
239 | 248 | |
240 | - if ( !isset( $current->checked[ $file ] ) || strval($current->checked[ $file ]) !== strval($p['Version']) ) |
|
241 | - $plugin_changed = true; |
|
249 | + if ( !isset( $current->checked[ $file ] ) || strval($current->checked[ $file ]) !== strval($p['Version']) ) { |
|
250 | + $plugin_changed = true; |
|
251 | + } |
|
242 | 252 | } |
243 | 253 | |
244 | 254 | if ( isset ( $current->response ) && is_array( $current->response ) ) { |
@@ -298,8 +308,9 @@ discard block |
||
298 | 308 | } |
299 | 309 | |
300 | 310 | $url = $http_url = 'http://api.wordpress.org/plugins/update-check/1.1/'; |
301 | - if ( $ssl = wp_http_supports( array( 'ssl' ) ) ) |
|
302 | - $url = set_url_scheme( $url, 'https' ); |
|
311 | + if ( $ssl = wp_http_supports( array( 'ssl' ) ) ) { |
|
312 | + $url = set_url_scheme( $url, 'https' ); |
|
313 | + } |
|
303 | 314 | |
304 | 315 | $raw_response = wp_remote_post( $url, $options ); |
305 | 316 | if ( $ssl && is_wp_error( $raw_response ) ) { |
@@ -364,8 +375,9 @@ discard block |
||
364 | 375 | $translations = wp_get_installed_translations( 'themes' ); |
365 | 376 | |
366 | 377 | $last_update = get_site_transient( 'update_themes' ); |
367 | - if ( ! is_object($last_update) ) |
|
368 | - $last_update = new stdClass; |
|
378 | + if ( ! is_object($last_update) ) { |
|
379 | + $last_update = new stdClass; |
|
380 | + } |
|
369 | 381 | |
370 | 382 | $themes = $checked = $request = array(); |
371 | 383 | |
@@ -411,8 +423,9 @@ discard block |
||
411 | 423 | if ( $time_not_changed && ! $extra_stats ) { |
412 | 424 | $theme_changed = false; |
413 | 425 | foreach ( $checked as $slug => $v ) { |
414 | - if ( !isset( $last_update->checked[ $slug ] ) || strval($last_update->checked[ $slug ]) !== strval($v) ) |
|
415 | - $theme_changed = true; |
|
426 | + if ( !isset( $last_update->checked[ $slug ] ) || strval($last_update->checked[ $slug ]) !== strval($v) ) { |
|
427 | + $theme_changed = true; |
|
428 | + } |
|
416 | 429 | } |
417 | 430 | |
418 | 431 | if ( isset ( $last_update->response ) && is_array( $last_update->response ) ) { |
@@ -471,8 +484,9 @@ discard block |
||
471 | 484 | } |
472 | 485 | |
473 | 486 | $url = $http_url = 'http://api.wordpress.org/themes/update-check/1.1/'; |
474 | - if ( $ssl = wp_http_supports( array( 'ssl' ) ) ) |
|
475 | - $url = set_url_scheme( $url, 'https' ); |
|
487 | + if ( $ssl = wp_http_supports( array( 'ssl' ) ) ) { |
|
488 | + $url = set_url_scheme( $url, 'https' ); |
|
489 | + } |
|
476 | 490 | |
477 | 491 | $raw_response = wp_remote_post( $url, $options ); |
478 | 492 | if ( $ssl && is_wp_error( $raw_response ) ) { |
@@ -523,8 +537,9 @@ discard block |
||
523 | 537 | $transients = array( 'update_core' => 'core', 'update_plugins' => 'plugin', 'update_themes' => 'theme' ); |
524 | 538 | foreach ( $transients as $transient => $type ) { |
525 | 539 | $transient = get_site_transient( $transient ); |
526 | - if ( empty( $transient->translations ) ) |
|
527 | - continue; |
|
540 | + if ( empty( $transient->translations ) ) { |
|
541 | + continue; |
|
542 | + } |
|
528 | 543 | |
529 | 544 | foreach ( $transient->translations as $translation ) { |
530 | 545 | $updates[] = (object) $translation; |
@@ -545,35 +560,43 @@ discard block |
||
545 | 560 | |
546 | 561 | if ( $plugins = current_user_can( 'update_plugins' ) ) { |
547 | 562 | $update_plugins = get_site_transient( 'update_plugins' ); |
548 | - if ( ! empty( $update_plugins->response ) ) |
|
549 | - $counts['plugins'] = count( $update_plugins->response ); |
|
563 | + if ( ! empty( $update_plugins->response ) ) { |
|
564 | + $counts['plugins'] = count( $update_plugins->response ); |
|
565 | + } |
|
550 | 566 | } |
551 | 567 | |
552 | 568 | if ( $themes = current_user_can( 'update_themes' ) ) { |
553 | 569 | $update_themes = get_site_transient( 'update_themes' ); |
554 | - if ( ! empty( $update_themes->response ) ) |
|
555 | - $counts['themes'] = count( $update_themes->response ); |
|
570 | + if ( ! empty( $update_themes->response ) ) { |
|
571 | + $counts['themes'] = count( $update_themes->response ); |
|
572 | + } |
|
556 | 573 | } |
557 | 574 | |
558 | 575 | if ( ( $core = current_user_can( 'update_core' ) ) && function_exists( 'get_core_updates' ) ) { |
559 | 576 | $update_wordpress = get_core_updates( array('dismissed' => false) ); |
560 | - if ( ! empty( $update_wordpress ) && ! in_array( $update_wordpress[0]->response, array('development', 'latest') ) && current_user_can('update_core') ) |
|
561 | - $counts['wordpress'] = 1; |
|
577 | + if ( ! empty( $update_wordpress ) && ! in_array( $update_wordpress[0]->response, array('development', 'latest') ) && current_user_can('update_core') ) { |
|
578 | + $counts['wordpress'] = 1; |
|
579 | + } |
|
562 | 580 | } |
563 | 581 | |
564 | - if ( ( $core || $plugins || $themes ) && wp_get_translation_updates() ) |
|
565 | - $counts['translations'] = 1; |
|
582 | + if ( ( $core || $plugins || $themes ) && wp_get_translation_updates() ) { |
|
583 | + $counts['translations'] = 1; |
|
584 | + } |
|
566 | 585 | |
567 | 586 | $counts['total'] = $counts['plugins'] + $counts['themes'] + $counts['wordpress'] + $counts['translations']; |
568 | 587 | $titles = array(); |
569 | - if ( $counts['wordpress'] ) |
|
570 | - $titles['wordpress'] = sprintf( __( '%d WordPress Update'), $counts['wordpress'] ); |
|
571 | - if ( $counts['plugins'] ) |
|
572 | - $titles['plugins'] = sprintf( _n( '%d Plugin Update', '%d Plugin Updates', $counts['plugins'] ), $counts['plugins'] ); |
|
573 | - if ( $counts['themes'] ) |
|
574 | - $titles['themes'] = sprintf( _n( '%d Theme Update', '%d Theme Updates', $counts['themes'] ), $counts['themes'] ); |
|
575 | - if ( $counts['translations'] ) |
|
576 | - $titles['translations'] = __( 'Translation Updates' ); |
|
588 | + if ( $counts['wordpress'] ) { |
|
589 | + $titles['wordpress'] = sprintf( __( '%d WordPress Update'), $counts['wordpress'] ); |
|
590 | + } |
|
591 | + if ( $counts['plugins'] ) { |
|
592 | + $titles['plugins'] = sprintf( _n( '%d Plugin Update', '%d Plugin Updates', $counts['plugins'] ), $counts['plugins'] ); |
|
593 | + } |
|
594 | + if ( $counts['themes'] ) { |
|
595 | + $titles['themes'] = sprintf( _n( '%d Theme Update', '%d Theme Updates', $counts['themes'] ), $counts['themes'] ); |
|
596 | + } |
|
597 | + if ( $counts['translations'] ) { |
|
598 | + $titles['translations'] = __( 'Translation Updates' ); |
|
599 | + } |
|
577 | 600 | |
578 | 601 | $update_title = $titles ? esc_attr( implode( ', ', $titles ) ) : ''; |
579 | 602 | |
@@ -626,8 +649,9 @@ discard block |
||
626 | 649 | */ |
627 | 650 | function _maybe_update_plugins() { |
628 | 651 | $current = get_site_transient( 'update_plugins' ); |
629 | - if ( isset( $current->last_checked ) && 12 * HOUR_IN_SECONDS > ( time() - $current->last_checked ) ) |
|
630 | - return; |
|
652 | + if ( isset( $current->last_checked ) && 12 * HOUR_IN_SECONDS > ( time() - $current->last_checked ) ) { |
|
653 | + return; |
|
654 | + } |
|
631 | 655 | wp_update_plugins(); |
632 | 656 | } |
633 | 657 | |
@@ -642,8 +666,9 @@ discard block |
||
642 | 666 | */ |
643 | 667 | function _maybe_update_themes() { |
644 | 668 | $current = get_site_transient( 'update_themes' ); |
645 | - if ( isset( $current->last_checked ) && 12 * HOUR_IN_SECONDS > ( time() - $current->last_checked ) ) |
|
646 | - return; |
|
669 | + if ( isset( $current->last_checked ) && 12 * HOUR_IN_SECONDS > ( time() - $current->last_checked ) ) { |
|
670 | + return; |
|
671 | + } |
|
647 | 672 | wp_update_themes(); |
648 | 673 | } |
649 | 674 | |
@@ -653,15 +678,18 @@ discard block |
||
653 | 678 | * @since 3.1.0 |
654 | 679 | */ |
655 | 680 | function wp_schedule_update_checks() { |
656 | - if ( ! wp_next_scheduled( 'wp_version_check' ) && ! wp_installing() ) |
|
657 | - wp_schedule_event(time(), 'twicedaily', 'wp_version_check'); |
|
681 | + if ( ! wp_next_scheduled( 'wp_version_check' ) && ! wp_installing() ) { |
|
682 | + wp_schedule_event(time(), 'twicedaily', 'wp_version_check'); |
|
683 | + } |
|
658 | 684 | |
659 | - if ( ! wp_next_scheduled( 'wp_update_plugins' ) && ! wp_installing() ) |
|
660 | - wp_schedule_event(time(), 'twicedaily', 'wp_update_plugins'); |
|
685 | + if ( ! wp_next_scheduled( 'wp_update_plugins' ) && ! wp_installing() ) { |
|
686 | + wp_schedule_event(time(), 'twicedaily', 'wp_update_plugins'); |
|
687 | + } |
|
661 | 688 | |
662 | - if ( ! wp_next_scheduled( 'wp_update_themes' ) && ! wp_installing() ) |
|
663 | - wp_schedule_event(time(), 'twicedaily', 'wp_update_themes'); |
|
664 | -} |
|
689 | + if ( ! wp_next_scheduled( 'wp_update_themes' ) && ! wp_installing() ) { |
|
690 | + wp_schedule_event(time(), 'twicedaily', 'wp_update_themes'); |
|
691 | + } |
|
692 | + } |
|
665 | 693 | |
666 | 694 | /** |
667 | 695 | * Clear existing update caches for plugins, themes, and core. |
@@ -1,11 +1,11 @@ |
||
1 | 1 | <?php |
2 | 2 | /** |
3 | - * Rewrite API: WP_Rewrite class |
|
4 | - * |
|
5 | - * @package WordPress |
|
6 | - * @subpackage Rewrite |
|
7 | - * @since 1.5.0 |
|
8 | - */ |
|
3 | + * Rewrite API: WP_Rewrite class |
|
4 | + * |
|
5 | + * @package WordPress |
|
6 | + * @subpackage Rewrite |
|
7 | + * @since 1.5.0 |
|
8 | + */ |
|
9 | 9 | |
10 | 10 | /** |
11 | 11 | * Core class used to implement a rewrite component API. |
@@ -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 | * Filter 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 | * Filter 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 | * Filter 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 | * Filter 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 | * Filter 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,7 +1472,7 @@ 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 | 1478 | update_option('rewrite_rules', $this->rules); |
@@ -1496,15 +1496,15 @@ discard block |
||
1496 | 1496 | * @return string |
1497 | 1497 | */ |
1498 | 1498 | public function mod_rewrite_rules() { |
1499 | - if ( ! $this->using_permalinks() ) |
|
1499 | + if ( ! $this->using_permalinks()) |
|
1500 | 1500 | return ''; |
1501 | 1501 | |
1502 | - $site_root = parse_url( site_url() ); |
|
1503 | - if ( isset( $site_root['path'] ) ) |
|
1502 | + $site_root = parse_url(site_url()); |
|
1503 | + if (isset($site_root['path'])) |
|
1504 | 1504 | $site_root = trailingslashit($site_root['path']); |
1505 | 1505 | |
1506 | 1506 | $home_root = parse_url(home_url()); |
1507 | - if ( isset( $home_root['path'] ) ) |
|
1507 | + if (isset($home_root['path'])) |
|
1508 | 1508 | $home_root = trailingslashit($home_root['path']); |
1509 | 1509 | else |
1510 | 1510 | $home_root = '/'; |
@@ -1517,33 +1517,33 @@ discard block |
||
1517 | 1517 | $rules .= "RewriteRule ^index\.php$ - [L]\n"; |
1518 | 1518 | |
1519 | 1519 | // Add in the rules that don't redirect to WP's index.php (and thus shouldn't be handled by WP at all). |
1520 | - foreach ( (array) $this->non_wp_rules as $match => $query) { |
|
1520 | + foreach ((array) $this->non_wp_rules as $match => $query) { |
|
1521 | 1521 | // Apache 1.3 does not support the reluctant (non-greedy) modifier. |
1522 | 1522 | $match = str_replace('.+?', '.+', $match); |
1523 | 1523 | |
1524 | - $rules .= 'RewriteRule ^' . $match . ' ' . $home_root . $query . " [QSA,L]\n"; |
|
1524 | + $rules .= 'RewriteRule ^'.$match.' '.$home_root.$query." [QSA,L]\n"; |
|
1525 | 1525 | } |
1526 | 1526 | |
1527 | - if ( $this->use_verbose_rules ) { |
|
1527 | + if ($this->use_verbose_rules) { |
|
1528 | 1528 | $this->matches = ''; |
1529 | 1529 | $rewrite = $this->rewrite_rules(); |
1530 | 1530 | $num_rules = count($rewrite); |
1531 | - $rules .= "RewriteCond %{REQUEST_FILENAME} -f [OR]\n" . |
|
1532 | - "RewriteCond %{REQUEST_FILENAME} -d\n" . |
|
1531 | + $rules .= "RewriteCond %{REQUEST_FILENAME} -f [OR]\n". |
|
1532 | + "RewriteCond %{REQUEST_FILENAME} -d\n". |
|
1533 | 1533 | "RewriteRule ^.*$ - [S=$num_rules]\n"; |
1534 | 1534 | |
1535 | - foreach ( (array) $rewrite as $match => $query) { |
|
1535 | + foreach ((array) $rewrite as $match => $query) { |
|
1536 | 1536 | // Apache 1.3 does not support the reluctant (non-greedy) modifier. |
1537 | 1537 | $match = str_replace('.+?', '.+', $match); |
1538 | 1538 | |
1539 | - if ( strpos($query, $this->index) !== false ) |
|
1540 | - $rules .= 'RewriteRule ^' . $match . ' ' . $home_root . $query . " [QSA,L]\n"; |
|
1539 | + if (strpos($query, $this->index) !== false) |
|
1540 | + $rules .= 'RewriteRule ^'.$match.' '.$home_root.$query." [QSA,L]\n"; |
|
1541 | 1541 | else |
1542 | - $rules .= 'RewriteRule ^' . $match . ' ' . $site_root . $query . " [QSA,L]\n"; |
|
1542 | + $rules .= 'RewriteRule ^'.$match.' '.$site_root.$query." [QSA,L]\n"; |
|
1543 | 1543 | } |
1544 | 1544 | } else { |
1545 | - $rules .= "RewriteCond %{REQUEST_FILENAME} !-f\n" . |
|
1546 | - "RewriteCond %{REQUEST_FILENAME} !-d\n" . |
|
1545 | + $rules .= "RewriteCond %{REQUEST_FILENAME} !-f\n". |
|
1546 | + "RewriteCond %{REQUEST_FILENAME} !-d\n". |
|
1547 | 1547 | "RewriteRule . {$home_root}{$this->index} [L]\n"; |
1548 | 1548 | } |
1549 | 1549 | |
@@ -1556,7 +1556,7 @@ discard block |
||
1556 | 1556 | * |
1557 | 1557 | * @param string $rules mod_rewrite Rewrite rules formatted for .htaccess. |
1558 | 1558 | */ |
1559 | - $rules = apply_filters( 'mod_rewrite_rules', $rules ); |
|
1559 | + $rules = apply_filters('mod_rewrite_rules', $rules); |
|
1560 | 1560 | |
1561 | 1561 | /** |
1562 | 1562 | * Filter the list of rewrite rules formatted for output to an .htaccess file. |
@@ -1566,7 +1566,7 @@ discard block |
||
1566 | 1566 | * |
1567 | 1567 | * @param string $rules mod_rewrite Rewrite rules formatted for .htaccess. |
1568 | 1568 | */ |
1569 | - return apply_filters( 'rewrite_rules', $rules ); |
|
1569 | + return apply_filters('rewrite_rules', $rules); |
|
1570 | 1570 | } |
1571 | 1571 | |
1572 | 1572 | /** |
@@ -1582,11 +1582,11 @@ discard block |
||
1582 | 1582 | * Default false. |
1583 | 1583 | * @return string IIS7 URL rewrite rule sets. |
1584 | 1584 | */ |
1585 | - public function iis7_url_rewrite_rules( $add_parent_tags = false ) { |
|
1586 | - if ( ! $this->using_permalinks() ) |
|
1585 | + public function iis7_url_rewrite_rules($add_parent_tags = false) { |
|
1586 | + if ( ! $this->using_permalinks()) |
|
1587 | 1587 | return ''; |
1588 | 1588 | $rules = ''; |
1589 | - if ( $add_parent_tags ) { |
|
1589 | + if ($add_parent_tags) { |
|
1590 | 1590 | $rules .= '<configuration> |
1591 | 1591 | <system.webServer> |
1592 | 1592 | <rewrite> |
@@ -1594,7 +1594,7 @@ discard block |
||
1594 | 1594 | } |
1595 | 1595 | |
1596 | 1596 | $rules .= ' |
1597 | - <rule name="WordPress: ' . esc_attr( home_url() ) . '" patternSyntax="Wildcard"> |
|
1597 | + <rule name="WordPress: ' . esc_attr(home_url()).'" patternSyntax="Wildcard"> |
|
1598 | 1598 | <match url="*" /> |
1599 | 1599 | <conditions> |
1600 | 1600 | <add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" /> |
@@ -1603,7 +1603,7 @@ discard block |
||
1603 | 1603 | <action type="Rewrite" url="index.php" /> |
1604 | 1604 | </rule>'; |
1605 | 1605 | |
1606 | - if ( $add_parent_tags ) { |
|
1606 | + if ($add_parent_tags) { |
|
1607 | 1607 | $rules .= ' |
1608 | 1608 | </rules> |
1609 | 1609 | </rewrite> |
@@ -1618,7 +1618,7 @@ discard block |
||
1618 | 1618 | * |
1619 | 1619 | * @param string $rules Rewrite rules formatted for IIS web.config. |
1620 | 1620 | */ |
1621 | - return apply_filters( 'iis7_url_rewrite_rules', $rules ); |
|
1621 | + return apply_filters('iis7_url_rewrite_rules', $rules); |
|
1622 | 1622 | } |
1623 | 1623 | |
1624 | 1624 | /** |
@@ -1636,25 +1636,25 @@ discard block |
||
1636 | 1636 | * @param string $after Optional. Priority of the new rule. Accepts 'top' |
1637 | 1637 | * or 'bottom'. Default 'bottom'. |
1638 | 1638 | */ |
1639 | - public function add_rule( $regex, $query, $after = 'bottom' ) { |
|
1640 | - if ( is_array( $query ) ) { |
|
1639 | + public function add_rule($regex, $query, $after = 'bottom') { |
|
1640 | + if (is_array($query)) { |
|
1641 | 1641 | $external = false; |
1642 | - $query = add_query_arg( $query, 'index.php' ); |
|
1642 | + $query = add_query_arg($query, 'index.php'); |
|
1643 | 1643 | } else { |
1644 | - $index = false === strpos( $query, '?' ) ? strlen( $query ) : strpos( $query, '?' ); |
|
1645 | - $front = substr( $query, 0, $index ); |
|
1644 | + $index = false === strpos($query, '?') ? strlen($query) : strpos($query, '?'); |
|
1645 | + $front = substr($query, 0, $index); |
|
1646 | 1646 | |
1647 | 1647 | $external = $front != $this->index; |
1648 | 1648 | } |
1649 | 1649 | |
1650 | 1650 | // "external" = it doesn't correspond to index.php. |
1651 | - if ( $external ) { |
|
1652 | - $this->add_external_rule( $regex, $query ); |
|
1651 | + if ($external) { |
|
1652 | + $this->add_external_rule($regex, $query); |
|
1653 | 1653 | } else { |
1654 | - if ( 'bottom' == $after ) { |
|
1655 | - $this->extra_rules = array_merge( $this->extra_rules, array( $regex => $query ) ); |
|
1654 | + if ('bottom' == $after) { |
|
1655 | + $this->extra_rules = array_merge($this->extra_rules, array($regex => $query)); |
|
1656 | 1656 | } else { |
1657 | - $this->extra_rules_top = array_merge( $this->extra_rules_top, array( $regex => $query ) ); |
|
1657 | + $this->extra_rules_top = array_merge($this->extra_rules_top, array($regex => $query)); |
|
1658 | 1658 | } |
1659 | 1659 | } |
1660 | 1660 | } |
@@ -1668,8 +1668,8 @@ discard block |
||
1668 | 1668 | * @param string $regex Regular expression to match request against. |
1669 | 1669 | * @param string $query The corresponding query vars for this rewrite rule. |
1670 | 1670 | */ |
1671 | - public function add_external_rule( $regex, $query ) { |
|
1672 | - $this->non_wp_rules[ $regex ] = $query; |
|
1671 | + public function add_external_rule($regex, $query) { |
|
1672 | + $this->non_wp_rules[$regex] = $query; |
|
1673 | 1673 | } |
1674 | 1674 | |
1675 | 1675 | /** |
@@ -1689,17 +1689,17 @@ discard block |
||
1689 | 1689 | * skip registering a query_var for this endpoint. Defaults to the |
1690 | 1690 | * value of `$name`. |
1691 | 1691 | */ |
1692 | - public function add_endpoint( $name, $places, $query_var = true ) { |
|
1692 | + public function add_endpoint($name, $places, $query_var = true) { |
|
1693 | 1693 | global $wp; |
1694 | 1694 | |
1695 | 1695 | // For backward compatibility, if null has explicitly been passed as `$query_var`, assume `true`. |
1696 | - if ( true === $query_var || null === func_get_arg( 2 ) ) { |
|
1696 | + if (true === $query_var || null === func_get_arg(2)) { |
|
1697 | 1697 | $query_var = $name; |
1698 | 1698 | } |
1699 | - $this->endpoints[] = array( $places, $name, $query_var ); |
|
1699 | + $this->endpoints[] = array($places, $name, $query_var); |
|
1700 | 1700 | |
1701 | - if ( $query_var ) { |
|
1702 | - $wp->add_query_var( $query_var ); |
|
1701 | + if ($query_var) { |
|
1702 | + $wp->add_query_var($query_var); |
|
1703 | 1703 | } |
1704 | 1704 | } |
1705 | 1705 | |
@@ -1742,12 +1742,12 @@ discard block |
||
1742 | 1742 | * @type bool $endpoints Whether endpoints should be applied to the generated rules. Default true. |
1743 | 1743 | * } |
1744 | 1744 | */ |
1745 | - public function add_permastruct( $name, $struct, $args = array() ) { |
|
1745 | + public function add_permastruct($name, $struct, $args = array()) { |
|
1746 | 1746 | // 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 ); |
|
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); |
|
1751 | 1751 | |
1752 | 1752 | $defaults = array( |
1753 | 1753 | 'with_front' => true, |
@@ -1758,16 +1758,16 @@ discard block |
||
1758 | 1758 | 'walk_dirs' => true, |
1759 | 1759 | 'endpoints' => true, |
1760 | 1760 | ); |
1761 | - $args = array_intersect_key( $args, $defaults ); |
|
1762 | - $args = wp_parse_args( $args, $defaults ); |
|
1761 | + $args = array_intersect_key($args, $defaults); |
|
1762 | + $args = wp_parse_args($args, $defaults); |
|
1763 | 1763 | |
1764 | - if ( $args['with_front'] ) |
|
1765 | - $struct = $this->front . $struct; |
|
1764 | + if ($args['with_front']) |
|
1765 | + $struct = $this->front.$struct; |
|
1766 | 1766 | else |
1767 | - $struct = $this->root . $struct; |
|
1767 | + $struct = $this->root.$struct; |
|
1768 | 1768 | $args['struct'] = $struct; |
1769 | 1769 | |
1770 | - $this->extra_permastructs[ $name ] = $args; |
|
1770 | + $this->extra_permastructs[$name] = $args; |
|
1771 | 1771 | } |
1772 | 1772 | |
1773 | 1773 | /** |
@@ -1778,8 +1778,8 @@ discard block |
||
1778 | 1778 | * |
1779 | 1779 | * @param string $name Name for permalink structure. |
1780 | 1780 | */ |
1781 | - public function remove_permastruct( $name ) { |
|
1782 | - unset( $this->extra_permastructs[ $name ] ); |
|
1781 | + public function remove_permastruct($name) { |
|
1782 | + unset($this->extra_permastructs[$name]); |
|
1783 | 1783 | } |
1784 | 1784 | |
1785 | 1785 | /** |
@@ -1795,22 +1795,22 @@ discard block |
||
1795 | 1795 | * |
1796 | 1796 | * @param bool $hard Whether to update .htaccess (hard flush) or just update rewrite_rules option (soft flush). Default is true (hard). |
1797 | 1797 | */ |
1798 | - public function flush_rules( $hard = true ) { |
|
1798 | + public function flush_rules($hard = true) { |
|
1799 | 1799 | static $do_hard_later = null; |
1800 | 1800 | |
1801 | 1801 | // Prevent this action from running before everyone has registered their rewrites. |
1802 | - if ( ! did_action( 'wp_loaded' ) ) { |
|
1803 | - add_action( 'wp_loaded', array( $this, 'flush_rules' ) ); |
|
1804 | - $do_hard_later = ( isset( $do_hard_later ) ) ? $do_hard_later || $hard : $hard; |
|
1802 | + if ( ! did_action('wp_loaded')) { |
|
1803 | + add_action('wp_loaded', array($this, 'flush_rules')); |
|
1804 | + $do_hard_later = (isset($do_hard_later)) ? $do_hard_later || $hard : $hard; |
|
1805 | 1805 | return; |
1806 | 1806 | } |
1807 | 1807 | |
1808 | - if ( isset( $do_hard_later ) ) { |
|
1808 | + if (isset($do_hard_later)) { |
|
1809 | 1809 | $hard = $do_hard_later; |
1810 | - unset( $do_hard_later ); |
|
1810 | + unset($do_hard_later); |
|
1811 | 1811 | } |
1812 | 1812 | |
1813 | - update_option( 'rewrite_rules', '' ); |
|
1813 | + update_option('rewrite_rules', ''); |
|
1814 | 1814 | $this->wp_rewrite_rules(); |
1815 | 1815 | |
1816 | 1816 | /** |
@@ -1822,12 +1822,12 @@ discard block |
||
1822 | 1822 | * |
1823 | 1823 | * @param bool $hard Whether to flush rewrite rules "hard". Default true. |
1824 | 1824 | */ |
1825 | - if ( ! $hard || ! apply_filters( 'flush_rewrite_rules_hard', true ) ) { |
|
1825 | + if ( ! $hard || ! apply_filters('flush_rewrite_rules_hard', true)) { |
|
1826 | 1826 | return; |
1827 | 1827 | } |
1828 | - if ( function_exists( 'save_mod_rewrite_rules' ) ) |
|
1828 | + if (function_exists('save_mod_rewrite_rules')) |
|
1829 | 1829 | save_mod_rewrite_rules(); |
1830 | - if ( function_exists( 'iis7_save_url_rewrite_rules' ) ) |
|
1830 | + if (function_exists('iis7_save_url_rewrite_rules')) |
|
1831 | 1831 | iis7_save_url_rewrite_rules(); |
1832 | 1832 | } |
1833 | 1833 | |
@@ -1847,8 +1847,8 @@ discard block |
||
1847 | 1847 | $this->front = substr($this->permalink_structure, 0, strpos($this->permalink_structure, '%')); |
1848 | 1848 | $this->root = ''; |
1849 | 1849 | |
1850 | - if ( $this->using_index_permalinks() ) |
|
1851 | - $this->root = $this->index . '/'; |
|
1850 | + if ($this->using_index_permalinks()) |
|
1851 | + $this->root = $this->index.'/'; |
|
1852 | 1852 | |
1853 | 1853 | unset($this->author_structure); |
1854 | 1854 | unset($this->date_structure); |
@@ -1856,10 +1856,10 @@ discard block |
||
1856 | 1856 | unset($this->search_structure); |
1857 | 1857 | unset($this->feed_structure); |
1858 | 1858 | unset($this->comment_feed_structure); |
1859 | - $this->use_trailing_slashes = ( '/' == substr($this->permalink_structure, -1, 1) ); |
|
1859 | + $this->use_trailing_slashes = ('/' == substr($this->permalink_structure, -1, 1)); |
|
1860 | 1860 | |
1861 | 1861 | // 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) ) |
|
1862 | + if (preg_match("/^[^%]*%(?:postname|category|tag|author)%/", $this->permalink_structure)) |
|
1863 | 1863 | $this->use_verbose_page_rules = true; |
1864 | 1864 | else |
1865 | 1865 | $this->use_verbose_page_rules = false; |
@@ -1881,7 +1881,7 @@ discard block |
||
1881 | 1881 | * @param string $permalink_structure Permalink structure. |
1882 | 1882 | */ |
1883 | 1883 | public function set_permalink_structure($permalink_structure) { |
1884 | - if ( $permalink_structure != $this->permalink_structure ) { |
|
1884 | + if ($permalink_structure != $this->permalink_structure) { |
|
1885 | 1885 | $old_permalink_structure = $this->permalink_structure; |
1886 | 1886 | update_option('permalink_structure', $permalink_structure); |
1887 | 1887 | |
@@ -1895,7 +1895,7 @@ discard block |
||
1895 | 1895 | * @param string $old_permalink_structure The previous permalink structure. |
1896 | 1896 | * @param string $permalink_structure The new permalink structure. |
1897 | 1897 | */ |
1898 | - do_action( 'permalink_structure_changed', $old_permalink_structure, $permalink_structure ); |
|
1898 | + do_action('permalink_structure_changed', $old_permalink_structure, $permalink_structure); |
|
1899 | 1899 | } |
1900 | 1900 | } |
1901 | 1901 | |
@@ -1912,7 +1912,7 @@ discard block |
||
1912 | 1912 | * @param string $category_base Category permalink structure base. |
1913 | 1913 | */ |
1914 | 1914 | public function set_category_base($category_base) { |
1915 | - if ( $category_base != get_option('category_base') ) { |
|
1915 | + if ($category_base != get_option('category_base')) { |
|
1916 | 1916 | update_option('category_base', $category_base); |
1917 | 1917 | $this->init(); |
1918 | 1918 | } |
@@ -1930,9 +1930,9 @@ discard block |
||
1930 | 1930 | * |
1931 | 1931 | * @param string $tag_base Tag permalink structure base. |
1932 | 1932 | */ |
1933 | - public function set_tag_base( $tag_base ) { |
|
1934 | - if ( $tag_base != get_option( 'tag_base') ) { |
|
1935 | - update_option( 'tag_base', $tag_base ); |
|
1933 | + public function set_tag_base($tag_base) { |
|
1934 | + if ($tag_base != get_option('tag_base')) { |
|
1935 | + update_option('tag_base', $tag_base); |
|
1936 | 1936 | $this->init(); |
1937 | 1937 | } |
1938 | 1938 | } |
@@ -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 | /** |
@@ -12,7 +12,7 @@ discard block |
||
12 | 12 | * |
13 | 13 | * @var string |
14 | 14 | */ |
15 | -define( 'REST_API_VERSION', '2.0' ); |
|
15 | +define('REST_API_VERSION', '2.0'); |
|
16 | 16 | |
17 | 17 | /** |
18 | 18 | * Registers a REST API route. |
@@ -29,26 +29,26 @@ discard block |
||
29 | 29 | * false merges (with newer overriding if duplicate keys exist). Default false. |
30 | 30 | * @return bool True on success, false on error. |
31 | 31 | */ |
32 | -function register_rest_route( $namespace, $route, $args = array(), $override = false ) { |
|
32 | +function register_rest_route($namespace, $route, $args = array(), $override = false) { |
|
33 | 33 | /** @var WP_REST_Server $wp_rest_server */ |
34 | 34 | global $wp_rest_server; |
35 | 35 | |
36 | - if ( empty( $namespace ) ) { |
|
36 | + if (empty($namespace)) { |
|
37 | 37 | /* |
38 | 38 | * Non-namespaced routes are not allowed, with the exception of the main |
39 | 39 | * and namespace indexes. If you really need to register a |
40 | 40 | * non-namespaced route, call `WP_REST_Server::register_route` directly. |
41 | 41 | */ |
42 | - _doing_it_wrong( 'register_rest_route', __( 'Routes must be namespaced with plugin or theme name and version.' ), '4.4.0' ); |
|
42 | + _doing_it_wrong('register_rest_route', __('Routes must be namespaced with plugin or theme name and version.'), '4.4.0'); |
|
43 | 43 | return false; |
44 | - } else if ( empty( $route ) ) { |
|
45 | - _doing_it_wrong( 'register_rest_route', __( 'Route must be specified.' ), '4.4.0' ); |
|
44 | + } else if (empty($route)) { |
|
45 | + _doing_it_wrong('register_rest_route', __('Route must be specified.'), '4.4.0'); |
|
46 | 46 | return false; |
47 | 47 | } |
48 | 48 | |
49 | - if ( isset( $args['callback'] ) ) { |
|
49 | + if (isset($args['callback'])) { |
|
50 | 50 | // Upgrade a single set to multiple. |
51 | - $args = array( $args ); |
|
51 | + $args = array($args); |
|
52 | 52 | } |
53 | 53 | |
54 | 54 | $defaults = array( |
@@ -56,17 +56,17 @@ discard block |
||
56 | 56 | 'callback' => null, |
57 | 57 | 'args' => array(), |
58 | 58 | ); |
59 | - foreach ( $args as $key => &$arg_group ) { |
|
60 | - if ( ! is_numeric( $arg_group ) ) { |
|
59 | + foreach ($args as $key => &$arg_group) { |
|
60 | + if ( ! is_numeric($arg_group)) { |
|
61 | 61 | // Route option, skip here. |
62 | 62 | continue; |
63 | 63 | } |
64 | 64 | |
65 | - $arg_group = array_merge( $defaults, $arg_group ); |
|
65 | + $arg_group = array_merge($defaults, $arg_group); |
|
66 | 66 | } |
67 | 67 | |
68 | - $full_route = '/' . trim( $namespace, '/' ) . '/' . trim( $route, '/' ); |
|
69 | - $wp_rest_server->register_route( $namespace, $full_route, $args, $override ); |
|
68 | + $full_route = '/'.trim($namespace, '/').'/'.trim($route, '/'); |
|
69 | + $wp_rest_server->register_route($namespace, $full_route, $args, $override); |
|
70 | 70 | return true; |
71 | 71 | } |
72 | 72 | |
@@ -82,7 +82,7 @@ discard block |
||
82 | 82 | rest_api_register_rewrites(); |
83 | 83 | |
84 | 84 | global $wp; |
85 | - $wp->add_query_var( 'rest_route' ); |
|
85 | + $wp->add_query_var('rest_route'); |
|
86 | 86 | } |
87 | 87 | |
88 | 88 | /** |
@@ -93,8 +93,8 @@ discard block |
||
93 | 93 | * @see add_rewrite_rule() |
94 | 94 | */ |
95 | 95 | function rest_api_register_rewrites() { |
96 | - add_rewrite_rule( '^' . rest_get_url_prefix() . '/?$','index.php?rest_route=/','top' ); |
|
97 | - add_rewrite_rule( '^' . rest_get_url_prefix() . '/(.*)?','index.php?rest_route=/$matches[1]','top' ); |
|
96 | + add_rewrite_rule('^'.rest_get_url_prefix().'/?$', 'index.php?rest_route=/', 'top'); |
|
97 | + add_rewrite_rule('^'.rest_get_url_prefix().'/(.*)?', 'index.php?rest_route=/$matches[1]', 'top'); |
|
98 | 98 | } |
99 | 99 | |
100 | 100 | /** |
@@ -107,16 +107,16 @@ discard block |
||
107 | 107 | */ |
108 | 108 | function rest_api_default_filters() { |
109 | 109 | // Deprecated reporting. |
110 | - add_action( 'deprecated_function_run', 'rest_handle_deprecated_function', 10, 3 ); |
|
111 | - add_filter( 'deprecated_function_trigger_error', '__return_false' ); |
|
112 | - add_action( 'deprecated_argument_run', 'rest_handle_deprecated_argument', 10, 3 ); |
|
113 | - add_filter( 'deprecated_argument_trigger_error', '__return_false' ); |
|
110 | + add_action('deprecated_function_run', 'rest_handle_deprecated_function', 10, 3); |
|
111 | + add_filter('deprecated_function_trigger_error', '__return_false'); |
|
112 | + add_action('deprecated_argument_run', 'rest_handle_deprecated_argument', 10, 3); |
|
113 | + add_filter('deprecated_argument_trigger_error', '__return_false'); |
|
114 | 114 | |
115 | 115 | // Default serving. |
116 | - add_filter( 'rest_pre_serve_request', 'rest_send_cors_headers' ); |
|
117 | - add_filter( 'rest_post_dispatch', 'rest_send_allow_header', 10, 3 ); |
|
116 | + add_filter('rest_pre_serve_request', 'rest_send_cors_headers'); |
|
117 | + add_filter('rest_post_dispatch', 'rest_send_allow_header', 10, 3); |
|
118 | 118 | |
119 | - add_filter( 'rest_pre_dispatch', 'rest_handle_options_request', 10, 3 ); |
|
119 | + add_filter('rest_pre_dispatch', 'rest_handle_options_request', 10, 3); |
|
120 | 120 | } |
121 | 121 | |
122 | 122 | /** |
@@ -128,7 +128,7 @@ discard block |
||
128 | 128 | * @global WP_REST_Server $wp_rest_server ResponseHandler instance (usually WP_REST_Server). |
129 | 129 | */ |
130 | 130 | function rest_api_loaded() { |
131 | - if ( empty( $GLOBALS['wp']->query_vars['rest_route'] ) ) { |
|
131 | + if (empty($GLOBALS['wp']->query_vars['rest_route'])) { |
|
132 | 132 | return; |
133 | 133 | } |
134 | 134 | |
@@ -138,13 +138,13 @@ discard block |
||
138 | 138 | * @since 4.4.0 |
139 | 139 | * @var bool |
140 | 140 | */ |
141 | - define( 'REST_REQUEST', true ); |
|
141 | + define('REST_REQUEST', true); |
|
142 | 142 | |
143 | 143 | // Initialize the server. |
144 | 144 | $server = rest_get_server(); |
145 | 145 | |
146 | 146 | // Fire off the request. |
147 | - $server->serve_request( $GLOBALS['wp']->query_vars['rest_route'] ); |
|
147 | + $server->serve_request($GLOBALS['wp']->query_vars['rest_route']); |
|
148 | 148 | |
149 | 149 | // We're done. |
150 | 150 | die(); |
@@ -165,7 +165,7 @@ discard block |
||
165 | 165 | * |
166 | 166 | * @param string $prefix URL prefix. Default 'wp-json'. |
167 | 167 | */ |
168 | - return apply_filters( 'rest_url_prefix', 'wp-json' ); |
|
168 | + return apply_filters('rest_url_prefix', 'wp-json'); |
|
169 | 169 | } |
170 | 170 | |
171 | 171 | /** |
@@ -182,26 +182,26 @@ discard block |
||
182 | 182 | * @param string $scheme Optional. Sanitization scheme. Default 'rest'. |
183 | 183 | * @return string Full URL to the endpoint. |
184 | 184 | */ |
185 | -function get_rest_url( $blog_id = null, $path = '/', $scheme = 'rest' ) { |
|
186 | - if ( empty( $path ) ) { |
|
185 | +function get_rest_url($blog_id = null, $path = '/', $scheme = 'rest') { |
|
186 | + if (empty($path)) { |
|
187 | 187 | $path = '/'; |
188 | 188 | } |
189 | 189 | |
190 | - if ( is_multisite() && get_blog_option( $blog_id, 'permalink_structure' ) || get_option( 'permalink_structure' ) ) { |
|
191 | - $url = get_home_url( $blog_id, rest_get_url_prefix(), $scheme ); |
|
192 | - $url .= '/' . ltrim( $path, '/' ); |
|
190 | + if (is_multisite() && get_blog_option($blog_id, 'permalink_structure') || get_option('permalink_structure')) { |
|
191 | + $url = get_home_url($blog_id, rest_get_url_prefix(), $scheme); |
|
192 | + $url .= '/'.ltrim($path, '/'); |
|
193 | 193 | } else { |
194 | - $url = trailingslashit( get_home_url( $blog_id, '', $scheme ) ); |
|
194 | + $url = trailingslashit(get_home_url($blog_id, '', $scheme)); |
|
195 | 195 | |
196 | - $path = '/' . ltrim( $path, '/' ); |
|
196 | + $path = '/'.ltrim($path, '/'); |
|
197 | 197 | |
198 | - $url = add_query_arg( 'rest_route', $path, $url ); |
|
198 | + $url = add_query_arg('rest_route', $path, $url); |
|
199 | 199 | } |
200 | 200 | |
201 | - if ( is_ssl() ) { |
|
201 | + if (is_ssl()) { |
|
202 | 202 | // If the current host is the same as the REST URL host, force the REST URL scheme to HTTPS. |
203 | - if ( $_SERVER['SERVER_NAME'] === parse_url( get_home_url( $blog_id ), PHP_URL_HOST ) ) { |
|
204 | - $url = set_url_scheme( $url, 'https' ); |
|
203 | + if ($_SERVER['SERVER_NAME'] === parse_url(get_home_url($blog_id), PHP_URL_HOST)) { |
|
204 | + $url = set_url_scheme($url, 'https'); |
|
205 | 205 | } |
206 | 206 | } |
207 | 207 | |
@@ -217,7 +217,7 @@ discard block |
||
217 | 217 | * @param int $blog_id Blog ID. |
218 | 218 | * @param string $scheme Sanitization scheme. |
219 | 219 | */ |
220 | - return apply_filters( 'rest_url', $url, $path, $blog_id, $scheme ); |
|
220 | + return apply_filters('rest_url', $url, $path, $blog_id, $scheme); |
|
221 | 221 | } |
222 | 222 | |
223 | 223 | /** |
@@ -231,8 +231,8 @@ discard block |
||
231 | 231 | * @param string $scheme Optional. Sanitization scheme. Default 'json'. |
232 | 232 | * @return string Full URL to the endpoint. |
233 | 233 | */ |
234 | -function rest_url( $path = '', $scheme = 'json' ) { |
|
235 | - return get_rest_url( null, $path, $scheme ); |
|
234 | +function rest_url($path = '', $scheme = 'json') { |
|
235 | + return get_rest_url(null, $path, $scheme); |
|
236 | 236 | } |
237 | 237 | |
238 | 238 | /** |
@@ -247,9 +247,9 @@ discard block |
||
247 | 247 | * @param WP_REST_Request|string $request Request. |
248 | 248 | * @return WP_REST_Response REST response. |
249 | 249 | */ |
250 | -function rest_do_request( $request ) { |
|
251 | - $request = rest_ensure_request( $request ); |
|
252 | - return rest_get_server()->dispatch( $request ); |
|
250 | +function rest_do_request($request) { |
|
251 | + $request = rest_ensure_request($request); |
|
252 | + return rest_get_server()->dispatch($request); |
|
253 | 253 | } |
254 | 254 | |
255 | 255 | /** |
@@ -267,7 +267,7 @@ discard block |
||
267 | 267 | /* @var WP_REST_Server $wp_rest_server */ |
268 | 268 | global $wp_rest_server; |
269 | 269 | |
270 | - if ( empty( $wp_rest_server ) ) { |
|
270 | + if (empty($wp_rest_server)) { |
|
271 | 271 | /** |
272 | 272 | * Filter the REST Server Class. |
273 | 273 | * |
@@ -278,7 +278,7 @@ discard block |
||
278 | 278 | * |
279 | 279 | * @param string $class_name The name of the server class. Default 'WP_REST_Server'. |
280 | 280 | */ |
281 | - $wp_rest_server_class = apply_filters( 'wp_rest_server_class', 'WP_REST_Server' ); |
|
281 | + $wp_rest_server_class = apply_filters('wp_rest_server_class', 'WP_REST_Server'); |
|
282 | 282 | $wp_rest_server = new $wp_rest_server_class; |
283 | 283 | |
284 | 284 | /** |
@@ -291,7 +291,7 @@ discard block |
||
291 | 291 | * |
292 | 292 | * @param WP_REST_Server $wp_rest_server Server object. |
293 | 293 | */ |
294 | - do_action( 'rest_api_init', $wp_rest_server ); |
|
294 | + do_action('rest_api_init', $wp_rest_server); |
|
295 | 295 | } |
296 | 296 | |
297 | 297 | return $wp_rest_server; |
@@ -305,12 +305,12 @@ discard block |
||
305 | 305 | * @param array|WP_REST_Request $request Request to check. |
306 | 306 | * @return WP_REST_Request REST request instance. |
307 | 307 | */ |
308 | -function rest_ensure_request( $request ) { |
|
309 | - if ( $request instanceof WP_REST_Request ) { |
|
308 | +function rest_ensure_request($request) { |
|
309 | + if ($request instanceof WP_REST_Request) { |
|
310 | 310 | return $request; |
311 | 311 | } |
312 | 312 | |
313 | - return new WP_REST_Request( 'GET', '', $request ); |
|
313 | + return new WP_REST_Request('GET', '', $request); |
|
314 | 314 | } |
315 | 315 | |
316 | 316 | /** |
@@ -326,16 +326,16 @@ discard block |
||
326 | 326 | * @return mixed WP_Error if response generated an error, WP_HTTP_Response if response |
327 | 327 | * is a already an instance, otherwise returns a new WP_REST_Response instance. |
328 | 328 | */ |
329 | -function rest_ensure_response( $response ) { |
|
330 | - if ( is_wp_error( $response ) ) { |
|
329 | +function rest_ensure_response($response) { |
|
330 | + if (is_wp_error($response)) { |
|
331 | 331 | return $response; |
332 | 332 | } |
333 | 333 | |
334 | - if ( $response instanceof WP_HTTP_Response ) { |
|
334 | + if ($response instanceof WP_HTTP_Response) { |
|
335 | 335 | return $response; |
336 | 336 | } |
337 | 337 | |
338 | - return new WP_REST_Response( $response ); |
|
338 | + return new WP_REST_Response($response); |
|
339 | 339 | } |
340 | 340 | |
341 | 341 | /** |
@@ -347,16 +347,16 @@ discard block |
||
347 | 347 | * @param string $replacement The function that should have been called. |
348 | 348 | * @param string $version Version. |
349 | 349 | */ |
350 | -function rest_handle_deprecated_function( $function, $replacement, $version ) { |
|
351 | - if ( ! empty( $replacement ) ) { |
|
350 | +function rest_handle_deprecated_function($function, $replacement, $version) { |
|
351 | + if ( ! empty($replacement)) { |
|
352 | 352 | /* translators: 1: function name, 2: WordPress version number, 3: new function name */ |
353 | - $string = sprintf( __( '%1$s (since %2$s; use %3$s instead)' ), $function, $version, $replacement ); |
|
353 | + $string = sprintf(__('%1$s (since %2$s; use %3$s instead)'), $function, $version, $replacement); |
|
354 | 354 | } else { |
355 | 355 | /* translators: 1: function name, 2: WordPress version number */ |
356 | - $string = sprintf( __( '%1$s (since %2$s; no alternative available)' ), $function, $version ); |
|
356 | + $string = sprintf(__('%1$s (since %2$s; no alternative available)'), $function, $version); |
|
357 | 357 | } |
358 | 358 | |
359 | - header( sprintf( 'X-WP-DeprecatedFunction: %s', $string ) ); |
|
359 | + header(sprintf('X-WP-DeprecatedFunction: %s', $string)); |
|
360 | 360 | } |
361 | 361 | |
362 | 362 | /** |
@@ -368,16 +368,16 @@ discard block |
||
368 | 368 | * @param string $message A message regarding the change. |
369 | 369 | * @param string $version Version. |
370 | 370 | */ |
371 | -function rest_handle_deprecated_argument( $function, $message, $version ) { |
|
372 | - if ( ! empty( $message ) ) { |
|
371 | +function rest_handle_deprecated_argument($function, $message, $version) { |
|
372 | + if ( ! empty($message)) { |
|
373 | 373 | /* translators: 1: function name, 2: WordPress version number, 3: error message */ |
374 | - $string = sprintf( __( '%1$s (since %2$s; %3$s)' ), $function, $version, $message ); |
|
374 | + $string = sprintf(__('%1$s (since %2$s; %3$s)'), $function, $version, $message); |
|
375 | 375 | } else { |
376 | 376 | /* translators: 1: function name, 2: WordPress version number */ |
377 | - $string = sprintf( __( '%1$s (since %2$s; no alternative available)' ), $function, $version ); |
|
377 | + $string = sprintf(__('%1$s (since %2$s; no alternative available)'), $function, $version); |
|
378 | 378 | } |
379 | 379 | |
380 | - header( sprintf( 'X-WP-DeprecatedParam: %s', $string ) ); |
|
380 | + header(sprintf('X-WP-DeprecatedParam: %s', $string)); |
|
381 | 381 | } |
382 | 382 | |
383 | 383 | /** |
@@ -388,13 +388,13 @@ discard block |
||
388 | 388 | * @param mixed $value Response data. |
389 | 389 | * @return mixed Response data. |
390 | 390 | */ |
391 | -function rest_send_cors_headers( $value ) { |
|
391 | +function rest_send_cors_headers($value) { |
|
392 | 392 | $origin = get_http_origin(); |
393 | 393 | |
394 | - if ( $origin ) { |
|
395 | - header( 'Access-Control-Allow-Origin: ' . esc_url_raw( $origin ) ); |
|
396 | - header( 'Access-Control-Allow-Methods: POST, GET, OPTIONS, PUT, DELETE' ); |
|
397 | - header( 'Access-Control-Allow-Credentials: true' ); |
|
394 | + if ($origin) { |
|
395 | + header('Access-Control-Allow-Origin: '.esc_url_raw($origin)); |
|
396 | + header('Access-Control-Allow-Methods: POST, GET, OPTIONS, PUT, DELETE'); |
|
397 | + header('Access-Control-Allow-Credentials: true'); |
|
398 | 398 | } |
399 | 399 | |
400 | 400 | return $value; |
@@ -413,8 +413,8 @@ discard block |
||
413 | 413 | * @param WP_REST_Request $request The request that was used to make current response. |
414 | 414 | * @return WP_REST_Response Modified response, either response or `null` to indicate pass-through. |
415 | 415 | */ |
416 | -function rest_handle_options_request( $response, $handler, $request ) { |
|
417 | - if ( ! empty( $response ) || $request->get_method() !== 'OPTIONS' ) { |
|
416 | +function rest_handle_options_request($response, $handler, $request) { |
|
417 | + if ( ! empty($response) || $request->get_method() !== 'OPTIONS') { |
|
418 | 418 | return $response; |
419 | 419 | } |
420 | 420 | |
@@ -423,19 +423,19 @@ discard block |
||
423 | 423 | |
424 | 424 | $accept = array(); |
425 | 425 | |
426 | - foreach ( $handler->get_routes() as $route => $endpoints ) { |
|
427 | - $match = preg_match( '@^' . $route . '$@i', $request->get_route(), $args ); |
|
426 | + foreach ($handler->get_routes() as $route => $endpoints) { |
|
427 | + $match = preg_match('@^'.$route.'$@i', $request->get_route(), $args); |
|
428 | 428 | |
429 | - if ( ! $match ) { |
|
429 | + if ( ! $match) { |
|
430 | 430 | continue; |
431 | 431 | } |
432 | 432 | |
433 | - $data = $handler->get_data_for_route( $route, $endpoints, 'help' ); |
|
434 | - $response->set_matched_route( $route ); |
|
433 | + $data = $handler->get_data_for_route($route, $endpoints, 'help'); |
|
434 | + $response->set_matched_route($route); |
|
435 | 435 | break; |
436 | 436 | } |
437 | 437 | |
438 | - $response->set_data( $data ); |
|
438 | + $response->set_data($data); |
|
439 | 439 | return $response; |
440 | 440 | } |
441 | 441 | |
@@ -449,10 +449,10 @@ discard block |
||
449 | 449 | * @param WP_REST_Request $request The request that was used to make current response. |
450 | 450 | * @return WP_REST_Response Response to be served, with "Allow" header if route has allowed methods. |
451 | 451 | */ |
452 | -function rest_send_allow_header( $response, $server, $request ) { |
|
452 | +function rest_send_allow_header($response, $server, $request) { |
|
453 | 453 | $matched_route = $response->get_matched_route(); |
454 | 454 | |
455 | - if ( ! $matched_route ) { |
|
455 | + if ( ! $matched_route) { |
|
456 | 456 | return $response; |
457 | 457 | } |
458 | 458 | |
@@ -461,25 +461,25 @@ discard block |
||
461 | 461 | $allowed_methods = array(); |
462 | 462 | |
463 | 463 | // Get the allowed methods across the routes. |
464 | - foreach ( $routes[ $matched_route ] as $_handler ) { |
|
465 | - foreach ( $_handler['methods'] as $handler_method => $value ) { |
|
464 | + foreach ($routes[$matched_route] as $_handler) { |
|
465 | + foreach ($_handler['methods'] as $handler_method => $value) { |
|
466 | 466 | |
467 | - if ( ! empty( $_handler['permission_callback'] ) ) { |
|
467 | + if ( ! empty($_handler['permission_callback'])) { |
|
468 | 468 | |
469 | - $permission = call_user_func( $_handler['permission_callback'], $request ); |
|
469 | + $permission = call_user_func($_handler['permission_callback'], $request); |
|
470 | 470 | |
471 | - $allowed_methods[ $handler_method ] = true === $permission; |
|
471 | + $allowed_methods[$handler_method] = true === $permission; |
|
472 | 472 | } else { |
473 | - $allowed_methods[ $handler_method ] = true; |
|
473 | + $allowed_methods[$handler_method] = true; |
|
474 | 474 | } |
475 | 475 | } |
476 | 476 | } |
477 | 477 | |
478 | 478 | // Strip out all the methods that are not allowed (false values). |
479 | - $allowed_methods = array_filter( $allowed_methods ); |
|
479 | + $allowed_methods = array_filter($allowed_methods); |
|
480 | 480 | |
481 | - if ( $allowed_methods ) { |
|
482 | - $response->header( 'Allow', implode( ', ', array_map( 'strtoupper', array_keys( $allowed_methods ) ) ) ); |
|
481 | + if ($allowed_methods) { |
|
482 | + $response->header('Allow', implode(', ', array_map('strtoupper', array_keys($allowed_methods)))); |
|
483 | 483 | } |
484 | 484 | |
485 | 485 | return $response; |
@@ -495,11 +495,11 @@ discard block |
||
495 | 495 | function rest_output_rsd() { |
496 | 496 | $api_root = get_rest_url(); |
497 | 497 | |
498 | - if ( empty( $api_root ) ) { |
|
498 | + if (empty($api_root)) { |
|
499 | 499 | return; |
500 | 500 | } |
501 | 501 | ?> |
502 | - <api name="WP-API" blogID="1" preferred="false" apiLink="<?php echo esc_url( $api_root ); ?>" /> |
|
502 | + <api name="WP-API" blogID="1" preferred="false" apiLink="<?php echo esc_url($api_root); ?>" /> |
|
503 | 503 | <?php |
504 | 504 | } |
505 | 505 | |
@@ -513,11 +513,11 @@ discard block |
||
513 | 513 | function rest_output_link_wp_head() { |
514 | 514 | $api_root = get_rest_url(); |
515 | 515 | |
516 | - if ( empty( $api_root ) ) { |
|
516 | + if (empty($api_root)) { |
|
517 | 517 | return; |
518 | 518 | } |
519 | 519 | |
520 | - echo "<link rel='https://api.w.org/' href='" . esc_url( $api_root ) . "' />\n"; |
|
520 | + echo "<link rel='https://api.w.org/' href='".esc_url($api_root)."' />\n"; |
|
521 | 521 | } |
522 | 522 | |
523 | 523 | /** |
@@ -526,17 +526,17 @@ discard block |
||
526 | 526 | * @since 4.4.0 |
527 | 527 | */ |
528 | 528 | function rest_output_link_header() { |
529 | - if ( headers_sent() ) { |
|
529 | + if (headers_sent()) { |
|
530 | 530 | return; |
531 | 531 | } |
532 | 532 | |
533 | 533 | $api_root = get_rest_url(); |
534 | 534 | |
535 | - if ( empty( $api_root ) ) { |
|
535 | + if (empty($api_root)) { |
|
536 | 536 | return; |
537 | 537 | } |
538 | 538 | |
539 | - header( 'Link: <' . esc_url_raw( $api_root ) . '>; rel="https://api.w.org/"', false ); |
|
539 | + header('Link: <'.esc_url_raw($api_root).'>; rel="https://api.w.org/"', false); |
|
540 | 540 | } |
541 | 541 | |
542 | 542 | /** |
@@ -554,8 +554,8 @@ discard block |
||
554 | 554 | * or another value if not. |
555 | 555 | * @return WP_Error|mixed|bool WP_Error if the cookie is invalid, the $result, otherwise true. |
556 | 556 | */ |
557 | -function rest_cookie_check_errors( $result ) { |
|
558 | - if ( ! empty( $result ) ) { |
|
557 | +function rest_cookie_check_errors($result) { |
|
558 | + if ( ! empty($result)) { |
|
559 | 559 | return $result; |
560 | 560 | } |
561 | 561 | |
@@ -566,30 +566,30 @@ discard block |
||
566 | 566 | * error, but we're still logged in, another authentication |
567 | 567 | * must have been used). |
568 | 568 | */ |
569 | - if ( true !== $wp_rest_auth_cookie && is_user_logged_in() ) { |
|
569 | + if (true !== $wp_rest_auth_cookie && is_user_logged_in()) { |
|
570 | 570 | return $result; |
571 | 571 | } |
572 | 572 | |
573 | 573 | // Determine if there is a nonce. |
574 | 574 | $nonce = null; |
575 | 575 | |
576 | - if ( isset( $_REQUEST['_wpnonce'] ) ) { |
|
576 | + if (isset($_REQUEST['_wpnonce'])) { |
|
577 | 577 | $nonce = $_REQUEST['_wpnonce']; |
578 | - } elseif ( isset( $_SERVER['HTTP_X_WP_NONCE'] ) ) { |
|
578 | + } elseif (isset($_SERVER['HTTP_X_WP_NONCE'])) { |
|
579 | 579 | $nonce = $_SERVER['HTTP_X_WP_NONCE']; |
580 | 580 | } |
581 | 581 | |
582 | - if ( null === $nonce ) { |
|
582 | + if (null === $nonce) { |
|
583 | 583 | // No nonce at all, so act as if it's an unauthenticated request. |
584 | - wp_set_current_user( 0 ); |
|
584 | + wp_set_current_user(0); |
|
585 | 585 | return true; |
586 | 586 | } |
587 | 587 | |
588 | 588 | // Check the nonce. |
589 | - $result = wp_verify_nonce( $nonce, 'wp_rest' ); |
|
589 | + $result = wp_verify_nonce($nonce, 'wp_rest'); |
|
590 | 590 | |
591 | - if ( ! $result ) { |
|
592 | - return new WP_Error( 'rest_cookie_invalid_nonce', __( 'Cookie nonce is invalid' ), array( 'status' => 403 ) ); |
|
591 | + if ( ! $result) { |
|
592 | + return new WP_Error('rest_cookie_invalid_nonce', __('Cookie nonce is invalid'), array('status' => 403)); |
|
593 | 593 | } |
594 | 594 | |
595 | 595 | return true; |
@@ -610,8 +610,8 @@ discard block |
||
610 | 610 | |
611 | 611 | $status_type = current_action(); |
612 | 612 | |
613 | - if ( 'auth_cookie_valid' !== $status_type ) { |
|
614 | - $wp_rest_auth_cookie = substr( $status_type, 12 ); |
|
613 | + if ('auth_cookie_valid' !== $status_type) { |
|
614 | + $wp_rest_auth_cookie = substr($status_type, 12); |
|
615 | 615 | return; |
616 | 616 | } |
617 | 617 | |
@@ -628,18 +628,18 @@ discard block |
||
628 | 628 | * the timestamp's timezone. Default false. |
629 | 629 | * @return int Unix timestamp. |
630 | 630 | */ |
631 | -function rest_parse_date( $date, $force_utc = false ) { |
|
632 | - if ( $force_utc ) { |
|
633 | - $date = preg_replace( '/[+-]\d+:?\d+$/', '+00:00', $date ); |
|
631 | +function rest_parse_date($date, $force_utc = false) { |
|
632 | + if ($force_utc) { |
|
633 | + $date = preg_replace('/[+-]\d+:?\d+$/', '+00:00', $date); |
|
634 | 634 | } |
635 | 635 | |
636 | 636 | $regex = '#^\d{4}-\d{2}-\d{2}[Tt ]\d{2}:\d{2}:\d{2}(?:\.\d+)?(?:Z|[+-]\d{2}(?::\d{2})?)?$#'; |
637 | 637 | |
638 | - if ( ! preg_match( $regex, $date, $matches ) ) { |
|
638 | + if ( ! preg_match($regex, $date, $matches)) { |
|
639 | 639 | return false; |
640 | 640 | } |
641 | 641 | |
642 | - return strtotime( $date ); |
|
642 | + return strtotime($date); |
|
643 | 643 | } |
644 | 644 | |
645 | 645 | /** |
@@ -654,15 +654,15 @@ discard block |
||
654 | 654 | * @return array|null Local and UTC datetime strings, in MySQL datetime format (Y-m-d H:i:s), |
655 | 655 | * null on failure. |
656 | 656 | */ |
657 | -function rest_get_date_with_gmt( $date, $force_utc = false ) { |
|
658 | - $date = rest_parse_date( $date, $force_utc ); |
|
657 | +function rest_get_date_with_gmt($date, $force_utc = false) { |
|
658 | + $date = rest_parse_date($date, $force_utc); |
|
659 | 659 | |
660 | - if ( empty( $date ) ) { |
|
660 | + if (empty($date)) { |
|
661 | 661 | return null; |
662 | 662 | } |
663 | 663 | |
664 | - $utc = date( 'Y-m-d H:i:s', $date ); |
|
665 | - $local = get_date_from_gmt( $utc ); |
|
664 | + $utc = date('Y-m-d H:i:s', $date); |
|
665 | + $local = get_date_from_gmt($utc); |
|
666 | 666 | |
667 | - return array( $local, $utc ); |
|
667 | + return array($local, $utc); |
|
668 | 668 | } |
@@ -17,19 +17,19 @@ discard block |
||
17 | 17 | */ |
18 | 18 | |
19 | 19 | /** WordPress Dependencies Class */ |
20 | -require( ABSPATH . WPINC . '/class.wp-dependencies.php' ); |
|
20 | +require(ABSPATH.WPINC.'/class.wp-dependencies.php'); |
|
21 | 21 | |
22 | 22 | /** WordPress Scripts Class */ |
23 | -require( ABSPATH . WPINC . '/class.wp-scripts.php' ); |
|
23 | +require(ABSPATH.WPINC.'/class.wp-scripts.php'); |
|
24 | 24 | |
25 | 25 | /** WordPress Scripts Functions */ |
26 | -require( ABSPATH . WPINC . '/functions.wp-scripts.php' ); |
|
26 | +require(ABSPATH.WPINC.'/functions.wp-scripts.php'); |
|
27 | 27 | |
28 | 28 | /** WordPress Styles Class */ |
29 | -require( ABSPATH . WPINC . '/class.wp-styles.php' ); |
|
29 | +require(ABSPATH.WPINC.'/class.wp-styles.php'); |
|
30 | 30 | |
31 | 31 | /** WordPress Styles Functions */ |
32 | -require( ABSPATH . WPINC . '/functions.wp-styles.php' ); |
|
32 | +require(ABSPATH.WPINC.'/functions.wp-styles.php'); |
|
33 | 33 | |
34 | 34 | /** |
35 | 35 | * Register all WordPress scripts. |
@@ -42,101 +42,101 @@ discard block |
||
42 | 42 | * |
43 | 43 | * @param WP_Scripts $scripts WP_Scripts object. |
44 | 44 | */ |
45 | -function wp_default_scripts( &$scripts ) { |
|
46 | - include( ABSPATH . WPINC . '/version.php' ); // include an unmodified $wp_version |
|
45 | +function wp_default_scripts(&$scripts) { |
|
46 | + include(ABSPATH.WPINC.'/version.php'); // include an unmodified $wp_version |
|
47 | 47 | |
48 | - $develop_src = false !== strpos( $wp_version, '-src' ); |
|
48 | + $develop_src = false !== strpos($wp_version, '-src'); |
|
49 | 49 | |
50 | - if ( ! defined( 'SCRIPT_DEBUG' ) ) { |
|
51 | - define( 'SCRIPT_DEBUG', $develop_src ); |
|
50 | + if ( ! defined('SCRIPT_DEBUG')) { |
|
51 | + define('SCRIPT_DEBUG', $develop_src); |
|
52 | 52 | } |
53 | 53 | |
54 | - if ( ! $guessurl = site_url() ) { |
|
54 | + if ( ! $guessurl = site_url()) { |
|
55 | 55 | $guessed_url = true; |
56 | 56 | $guessurl = wp_guess_url(); |
57 | 57 | } |
58 | 58 | |
59 | 59 | $scripts->base_url = $guessurl; |
60 | - $scripts->content_url = defined('WP_CONTENT_URL')? WP_CONTENT_URL : ''; |
|
61 | - $scripts->default_version = get_bloginfo( 'version' ); |
|
60 | + $scripts->content_url = defined('WP_CONTENT_URL') ? WP_CONTENT_URL : ''; |
|
61 | + $scripts->default_version = get_bloginfo('version'); |
|
62 | 62 | $scripts->default_dirs = array('/wp-admin/js/', '/wp-includes/js/'); |
63 | 63 | |
64 | 64 | $suffix = SCRIPT_DEBUG ? '' : '.min'; |
65 | 65 | $dev_suffix = $develop_src ? '' : '.min'; |
66 | 66 | |
67 | - $scripts->add( 'utils', "/wp-includes/js/utils$suffix.js" ); |
|
68 | - did_action( 'init' ) && $scripts->localize( 'utils', 'userSettings', array( |
|
67 | + $scripts->add('utils', "/wp-includes/js/utils$suffix.js"); |
|
68 | + did_action('init') && $scripts->localize('utils', 'userSettings', array( |
|
69 | 69 | 'url' => (string) SITECOOKIEPATH, |
70 | 70 | 'uid' => (string) get_current_user_id(), |
71 | 71 | 'time' => (string) time(), |
72 | - 'secure' => (string) ( 'https' === parse_url( site_url(), PHP_URL_SCHEME ) ), |
|
73 | - ) ); |
|
74 | - |
|
75 | - $scripts->add( 'common', "/wp-admin/js/common$suffix.js", array('jquery', 'hoverIntent', 'utils'), false, 1 ); |
|
76 | - did_action( 'init' ) && $scripts->localize( 'common', 'commonL10n', array( |
|
77 | - 'warnDelete' => __( "You are about to permanently delete these items.\n 'Cancel' to stop, 'OK' to delete." ), |
|
78 | - 'dismiss' => __( 'Dismiss this notice.' ), |
|
79 | - ) ); |
|
80 | - |
|
81 | - $scripts->add( 'wp-a11y', "/wp-includes/js/wp-a11y$suffix.js", array( 'jquery' ), false, 1 ); |
|
82 | - |
|
83 | - $scripts->add( 'sack', "/wp-includes/js/tw-sack$suffix.js", array(), '1.6.1', 1 ); |
|
84 | - |
|
85 | - $scripts->add( 'quicktags', "/wp-includes/js/quicktags$suffix.js", array(), false, 1 ); |
|
86 | - did_action( 'init' ) && $scripts->localize( 'quicktags', 'quicktagsL10n', array( |
|
87 | - 'closeAllOpenTags' => __( 'Close all open tags' ), |
|
88 | - 'closeTags' => __( 'close tags' ), |
|
89 | - 'enterURL' => __( 'Enter the URL' ), |
|
90 | - 'enterImageURL' => __( 'Enter the URL of the image' ), |
|
91 | - 'enterImageDescription' => __( 'Enter a description of the image' ), |
|
92 | - 'textdirection' => __( 'text direction' ), |
|
93 | - 'toggleTextdirection' => __( 'Toggle Editor Text Direction' ), |
|
94 | - 'dfw' => __( 'Distraction-free writing mode' ), |
|
95 | - 'strong' => __( 'Bold' ), |
|
96 | - 'strongClose' => __( 'Close bold tag' ), |
|
97 | - 'em' => __( 'Italic' ), |
|
98 | - 'emClose' => __( 'Close italic tag' ), |
|
99 | - 'link' => __( 'Insert link' ), |
|
100 | - 'blockquote' => __( 'Blockquote' ), |
|
101 | - 'blockquoteClose' => __( 'Close blockquote tag' ), |
|
102 | - 'del' => __( 'Deleted text (strikethrough)' ), |
|
103 | - 'delClose' => __( 'Close deleted text tag' ), |
|
104 | - 'ins' => __( 'Inserted text' ), |
|
105 | - 'insClose' => __( 'Close inserted text tag' ), |
|
106 | - 'image' => __( 'Insert image' ), |
|
107 | - 'ul' => __( 'Bulleted list' ), |
|
108 | - 'ulClose' => __( 'Close bulleted list tag' ), |
|
109 | - 'ol' => __( 'Numbered list' ), |
|
110 | - 'olClose' => __( 'Close numbered list tag' ), |
|
111 | - 'li' => __( 'List item' ), |
|
112 | - 'liClose' => __( 'Close list item tag' ), |
|
113 | - 'code' => __( 'Code' ), |
|
114 | - 'codeClose' => __( 'Close code tag' ), |
|
115 | - 'more' => __( 'Insert Read More tag' ), |
|
116 | - ) ); |
|
117 | - |
|
118 | - $scripts->add( 'colorpicker', "/wp-includes/js/colorpicker$suffix.js", array('prototype'), '3517m' ); |
|
119 | - |
|
120 | - $scripts->add( 'editor', "/wp-admin/js/editor$suffix.js", array('utils','jquery'), false, 1 ); |
|
72 | + 'secure' => (string) ('https' === parse_url(site_url(), PHP_URL_SCHEME)), |
|
73 | + )); |
|
74 | + |
|
75 | + $scripts->add('common', "/wp-admin/js/common$suffix.js", array('jquery', 'hoverIntent', 'utils'), false, 1); |
|
76 | + did_action('init') && $scripts->localize('common', 'commonL10n', array( |
|
77 | + 'warnDelete' => __("You are about to permanently delete these items.\n 'Cancel' to stop, 'OK' to delete."), |
|
78 | + 'dismiss' => __('Dismiss this notice.'), |
|
79 | + )); |
|
80 | + |
|
81 | + $scripts->add('wp-a11y', "/wp-includes/js/wp-a11y$suffix.js", array('jquery'), false, 1); |
|
82 | + |
|
83 | + $scripts->add('sack', "/wp-includes/js/tw-sack$suffix.js", array(), '1.6.1', 1); |
|
84 | + |
|
85 | + $scripts->add('quicktags', "/wp-includes/js/quicktags$suffix.js", array(), false, 1); |
|
86 | + did_action('init') && $scripts->localize('quicktags', 'quicktagsL10n', array( |
|
87 | + 'closeAllOpenTags' => __('Close all open tags'), |
|
88 | + 'closeTags' => __('close tags'), |
|
89 | + 'enterURL' => __('Enter the URL'), |
|
90 | + 'enterImageURL' => __('Enter the URL of the image'), |
|
91 | + 'enterImageDescription' => __('Enter a description of the image'), |
|
92 | + 'textdirection' => __('text direction'), |
|
93 | + 'toggleTextdirection' => __('Toggle Editor Text Direction'), |
|
94 | + 'dfw' => __('Distraction-free writing mode'), |
|
95 | + 'strong' => __('Bold'), |
|
96 | + 'strongClose' => __('Close bold tag'), |
|
97 | + 'em' => __('Italic'), |
|
98 | + 'emClose' => __('Close italic tag'), |
|
99 | + 'link' => __('Insert link'), |
|
100 | + 'blockquote' => __('Blockquote'), |
|
101 | + 'blockquoteClose' => __('Close blockquote tag'), |
|
102 | + 'del' => __('Deleted text (strikethrough)'), |
|
103 | + 'delClose' => __('Close deleted text tag'), |
|
104 | + 'ins' => __('Inserted text'), |
|
105 | + 'insClose' => __('Close inserted text tag'), |
|
106 | + 'image' => __('Insert image'), |
|
107 | + 'ul' => __('Bulleted list'), |
|
108 | + 'ulClose' => __('Close bulleted list tag'), |
|
109 | + 'ol' => __('Numbered list'), |
|
110 | + 'olClose' => __('Close numbered list tag'), |
|
111 | + 'li' => __('List item'), |
|
112 | + 'liClose' => __('Close list item tag'), |
|
113 | + 'code' => __('Code'), |
|
114 | + 'codeClose' => __('Close code tag'), |
|
115 | + 'more' => __('Insert Read More tag'), |
|
116 | + )); |
|
117 | + |
|
118 | + $scripts->add('colorpicker', "/wp-includes/js/colorpicker$suffix.js", array('prototype'), '3517m'); |
|
119 | + |
|
120 | + $scripts->add('editor', "/wp-admin/js/editor$suffix.js", array('utils', 'jquery'), false, 1); |
|
121 | 121 | |
122 | 122 | // Back-compat for old DFW. To-do: remove at the end of 2016. |
123 | - $scripts->add( 'wp-fullscreen-stub', "/wp-admin/js/wp-fullscreen-stub$suffix.js", array(), false, 1 ); |
|
123 | + $scripts->add('wp-fullscreen-stub', "/wp-admin/js/wp-fullscreen-stub$suffix.js", array(), false, 1); |
|
124 | 124 | |
125 | - $scripts->add( 'wp-ajax-response', "/wp-includes/js/wp-ajax-response$suffix.js", array('jquery'), false, 1 ); |
|
126 | - did_action( 'init' ) && $scripts->localize( 'wp-ajax-response', 'wpAjax', array( |
|
125 | + $scripts->add('wp-ajax-response', "/wp-includes/js/wp-ajax-response$suffix.js", array('jquery'), false, 1); |
|
126 | + did_action('init') && $scripts->localize('wp-ajax-response', 'wpAjax', array( |
|
127 | 127 | 'noPerm' => __('You do not have permission to do that.'), |
128 | 128 | 'broken' => __('An unidentified error has occurred.') |
129 | - ) ); |
|
129 | + )); |
|
130 | 130 | |
131 | - $scripts->add( 'wp-pointer', "/wp-includes/js/wp-pointer$suffix.js", array( 'jquery-ui-widget', 'jquery-ui-position' ), '20111129a', 1 ); |
|
132 | - did_action( 'init' ) && $scripts->localize( 'wp-pointer', 'wpPointerL10n', array( |
|
131 | + $scripts->add('wp-pointer', "/wp-includes/js/wp-pointer$suffix.js", array('jquery-ui-widget', 'jquery-ui-position'), '20111129a', 1); |
|
132 | + did_action('init') && $scripts->localize('wp-pointer', 'wpPointerL10n', array( |
|
133 | 133 | 'dismiss' => __('Dismiss'), |
134 | - ) ); |
|
134 | + )); |
|
135 | 135 | |
136 | - $scripts->add( 'autosave', "/wp-includes/js/autosave$suffix.js", array('heartbeat'), false, 1 ); |
|
136 | + $scripts->add('autosave', "/wp-includes/js/autosave$suffix.js", array('heartbeat'), false, 1); |
|
137 | 137 | |
138 | - $scripts->add( 'heartbeat', "/wp-includes/js/heartbeat$suffix.js", array('jquery'), false, 1 ); |
|
139 | - did_action( 'init' ) && $scripts->localize( 'heartbeat', 'heartbeatSettings', |
|
138 | + $scripts->add('heartbeat', "/wp-includes/js/heartbeat$suffix.js", array('jquery'), false, 1); |
|
139 | + did_action('init') && $scripts->localize('heartbeat', 'heartbeatSettings', |
|
140 | 140 | /** |
141 | 141 | * Filter the Heartbeat settings. |
142 | 142 | * |
@@ -144,11 +144,11 @@ discard block |
||
144 | 144 | * |
145 | 145 | * @param array $settings Heartbeat settings array. |
146 | 146 | */ |
147 | - apply_filters( 'heartbeat_settings', array() ) |
|
147 | + apply_filters('heartbeat_settings', array()) |
|
148 | 148 | ); |
149 | 149 | |
150 | - $scripts->add( 'wp-auth-check', "/wp-includes/js/wp-auth-check$suffix.js", array('heartbeat'), false, 1 ); |
|
151 | - did_action( 'init' ) && $scripts->localize( 'wp-auth-check', 'authcheckL10n', array( |
|
150 | + $scripts->add('wp-auth-check', "/wp-includes/js/wp-auth-check$suffix.js", array('heartbeat'), false, 1); |
|
151 | + did_action('init') && $scripts->localize('wp-auth-check', 'authcheckL10n', array( |
|
152 | 152 | 'beforeunload' => __('Your session has expired. You can log in again from this page or go to the login page.'), |
153 | 153 | |
154 | 154 | /** |
@@ -159,99 +159,99 @@ discard block |
||
159 | 159 | * @param int $interval The interval in which to check a user's authentication. |
160 | 160 | * Default 3 minutes in seconds, or 180. |
161 | 161 | */ |
162 | - 'interval' => apply_filters( 'wp_auth_check_interval', 3 * MINUTE_IN_SECONDS ), |
|
163 | - ) ); |
|
162 | + 'interval' => apply_filters('wp_auth_check_interval', 3 * MINUTE_IN_SECONDS), |
|
163 | + )); |
|
164 | 164 | |
165 | - $scripts->add( 'wp-lists', "/wp-includes/js/wp-lists$suffix.js", array( 'wp-ajax-response', 'jquery-color' ), false, 1 ); |
|
165 | + $scripts->add('wp-lists', "/wp-includes/js/wp-lists$suffix.js", array('wp-ajax-response', 'jquery-color'), false, 1); |
|
166 | 166 | |
167 | 167 | // WordPress no longer uses or bundles Prototype or script.aculo.us. These are now pulled from an external source. |
168 | - $scripts->add( 'prototype', 'https://ajax.googleapis.com/ajax/libs/prototype/1.7.1.0/prototype.js', array(), '1.7.1'); |
|
169 | - $scripts->add( 'scriptaculous-root', 'https://ajax.googleapis.com/ajax/libs/scriptaculous/1.9.0/scriptaculous.js', array('prototype'), '1.9.0'); |
|
170 | - $scripts->add( 'scriptaculous-builder', 'https://ajax.googleapis.com/ajax/libs/scriptaculous/1.9.0/builder.js', array('scriptaculous-root'), '1.9.0'); |
|
171 | - $scripts->add( 'scriptaculous-dragdrop', 'https://ajax.googleapis.com/ajax/libs/scriptaculous/1.9.0/dragdrop.js', array('scriptaculous-builder', 'scriptaculous-effects'), '1.9.0'); |
|
172 | - $scripts->add( 'scriptaculous-effects', 'https://ajax.googleapis.com/ajax/libs/scriptaculous/1.9.0/effects.js', array('scriptaculous-root'), '1.9.0'); |
|
173 | - $scripts->add( 'scriptaculous-slider', 'https://ajax.googleapis.com/ajax/libs/scriptaculous/1.9.0/slider.js', array('scriptaculous-effects'), '1.9.0'); |
|
174 | - $scripts->add( 'scriptaculous-sound', 'https://ajax.googleapis.com/ajax/libs/scriptaculous/1.9.0/sound.js', array( 'scriptaculous-root' ), '1.9.0' ); |
|
175 | - $scripts->add( 'scriptaculous-controls', 'https://ajax.googleapis.com/ajax/libs/scriptaculous/1.9.0/controls.js', array('scriptaculous-root'), '1.9.0'); |
|
176 | - $scripts->add( 'scriptaculous', false, array('scriptaculous-dragdrop', 'scriptaculous-slider', 'scriptaculous-controls') ); |
|
168 | + $scripts->add('prototype', 'https://ajax.googleapis.com/ajax/libs/prototype/1.7.1.0/prototype.js', array(), '1.7.1'); |
|
169 | + $scripts->add('scriptaculous-root', 'https://ajax.googleapis.com/ajax/libs/scriptaculous/1.9.0/scriptaculous.js', array('prototype'), '1.9.0'); |
|
170 | + $scripts->add('scriptaculous-builder', 'https://ajax.googleapis.com/ajax/libs/scriptaculous/1.9.0/builder.js', array('scriptaculous-root'), '1.9.0'); |
|
171 | + $scripts->add('scriptaculous-dragdrop', 'https://ajax.googleapis.com/ajax/libs/scriptaculous/1.9.0/dragdrop.js', array('scriptaculous-builder', 'scriptaculous-effects'), '1.9.0'); |
|
172 | + $scripts->add('scriptaculous-effects', 'https://ajax.googleapis.com/ajax/libs/scriptaculous/1.9.0/effects.js', array('scriptaculous-root'), '1.9.0'); |
|
173 | + $scripts->add('scriptaculous-slider', 'https://ajax.googleapis.com/ajax/libs/scriptaculous/1.9.0/slider.js', array('scriptaculous-effects'), '1.9.0'); |
|
174 | + $scripts->add('scriptaculous-sound', 'https://ajax.googleapis.com/ajax/libs/scriptaculous/1.9.0/sound.js', array('scriptaculous-root'), '1.9.0'); |
|
175 | + $scripts->add('scriptaculous-controls', 'https://ajax.googleapis.com/ajax/libs/scriptaculous/1.9.0/controls.js', array('scriptaculous-root'), '1.9.0'); |
|
176 | + $scripts->add('scriptaculous', false, array('scriptaculous-dragdrop', 'scriptaculous-slider', 'scriptaculous-controls')); |
|
177 | 177 | |
178 | 178 | // not used in core, replaced by Jcrop.js |
179 | - $scripts->add( 'cropper', '/wp-includes/js/crop/cropper.js', array('scriptaculous-dragdrop') ); |
|
179 | + $scripts->add('cropper', '/wp-includes/js/crop/cropper.js', array('scriptaculous-dragdrop')); |
|
180 | 180 | |
181 | 181 | // jQuery |
182 | - $scripts->add( 'jquery', false, array( 'jquery-core', 'jquery-migrate' ), '1.12.1' ); |
|
183 | - $scripts->add( 'jquery-core', '/wp-includes/js/jquery/jquery.js', array(), '1.12.1' ); |
|
184 | - $scripts->add( 'jquery-migrate', "/wp-includes/js/jquery/jquery-migrate$suffix.js", array(), '1.3.0' ); |
|
182 | + $scripts->add('jquery', false, array('jquery-core', 'jquery-migrate'), '1.12.1'); |
|
183 | + $scripts->add('jquery-core', '/wp-includes/js/jquery/jquery.js', array(), '1.12.1'); |
|
184 | + $scripts->add('jquery-migrate', "/wp-includes/js/jquery/jquery-migrate$suffix.js", array(), '1.3.0'); |
|
185 | 185 | |
186 | 186 | // full jQuery UI |
187 | - $scripts->add( 'jquery-ui-core', "/wp-includes/js/jquery/ui/core$dev_suffix.js", array('jquery'), '1.11.4', 1 ); |
|
188 | - $scripts->add( 'jquery-effects-core', "/wp-includes/js/jquery/ui/effect$dev_suffix.js", array('jquery'), '1.11.4', 1 ); |
|
189 | - |
|
190 | - $scripts->add( 'jquery-effects-blind', "/wp-includes/js/jquery/ui/effect-blind$dev_suffix.js", array('jquery-effects-core'), '1.11.4', 1 ); |
|
191 | - $scripts->add( 'jquery-effects-bounce', "/wp-includes/js/jquery/ui/effect-bounce$dev_suffix.js", array('jquery-effects-core'), '1.11.4', 1 ); |
|
192 | - $scripts->add( 'jquery-effects-clip', "/wp-includes/js/jquery/ui/effect-clip$dev_suffix.js", array('jquery-effects-core'), '1.11.4', 1 ); |
|
193 | - $scripts->add( 'jquery-effects-drop', "/wp-includes/js/jquery/ui/effect-drop$dev_suffix.js", array('jquery-effects-core'), '1.11.4', 1 ); |
|
194 | - $scripts->add( 'jquery-effects-explode', "/wp-includes/js/jquery/ui/effect-explode$dev_suffix.js", array('jquery-effects-core'), '1.11.4', 1 ); |
|
195 | - $scripts->add( 'jquery-effects-fade', "/wp-includes/js/jquery/ui/effect-fade$dev_suffix.js", array('jquery-effects-core'), '1.11.4', 1 ); |
|
196 | - $scripts->add( 'jquery-effects-fold', "/wp-includes/js/jquery/ui/effect-fold$dev_suffix.js", array('jquery-effects-core'), '1.11.4', 1 ); |
|
197 | - $scripts->add( 'jquery-effects-highlight', "/wp-includes/js/jquery/ui/effect-highlight$dev_suffix.js", array('jquery-effects-core'), '1.11.4', 1 ); |
|
198 | - $scripts->add( 'jquery-effects-puff', "/wp-includes/js/jquery/ui/effect-puff$dev_suffix.js", array('jquery-effects-core', 'jquery-effects-scale'), '1.11.4', 1 ); |
|
199 | - $scripts->add( 'jquery-effects-pulsate', "/wp-includes/js/jquery/ui/effect-pulsate$dev_suffix.js", array('jquery-effects-core'), '1.11.4', 1 ); |
|
200 | - $scripts->add( 'jquery-effects-scale', "/wp-includes/js/jquery/ui/effect-scale$dev_suffix.js", array('jquery-effects-core', 'jquery-effects-size'), '1.11.4', 1 ); |
|
201 | - $scripts->add( 'jquery-effects-shake', "/wp-includes/js/jquery/ui/effect-shake$dev_suffix.js", array('jquery-effects-core'), '1.11.4', 1 ); |
|
202 | - $scripts->add( 'jquery-effects-size', "/wp-includes/js/jquery/ui/effect-size$dev_suffix.js", array('jquery-effects-core'), '1.11.4', 1 ); |
|
203 | - $scripts->add( 'jquery-effects-slide', "/wp-includes/js/jquery/ui/effect-slide$dev_suffix.js", array('jquery-effects-core'), '1.11.4', 1 ); |
|
204 | - $scripts->add( 'jquery-effects-transfer', "/wp-includes/js/jquery/ui/effect-transfer$dev_suffix.js", array('jquery-effects-core'), '1.11.4', 1 ); |
|
205 | - |
|
206 | - $scripts->add( 'jquery-ui-accordion', "/wp-includes/js/jquery/ui/accordion$dev_suffix.js", array('jquery-ui-core', 'jquery-ui-widget'), '1.11.4', 1 ); |
|
207 | - $scripts->add( 'jquery-ui-autocomplete', "/wp-includes/js/jquery/ui/autocomplete$dev_suffix.js", array( 'jquery-ui-menu', 'wp-a11y' ), '1.11.4', 1 ); |
|
208 | - $scripts->add( 'jquery-ui-button', "/wp-includes/js/jquery/ui/button$dev_suffix.js", array('jquery-ui-core', 'jquery-ui-widget'), '1.11.4', 1 ); |
|
209 | - $scripts->add( 'jquery-ui-datepicker', "/wp-includes/js/jquery/ui/datepicker$dev_suffix.js", array('jquery-ui-core'), '1.11.4', 1 ); |
|
210 | - $scripts->add( 'jquery-ui-dialog', "/wp-includes/js/jquery/ui/dialog$dev_suffix.js", array('jquery-ui-resizable', 'jquery-ui-draggable', 'jquery-ui-button', 'jquery-ui-position'), '1.11.4', 1 ); |
|
211 | - $scripts->add( 'jquery-ui-draggable', "/wp-includes/js/jquery/ui/draggable$dev_suffix.js", array('jquery-ui-mouse'), '1.11.4', 1 ); |
|
212 | - $scripts->add( 'jquery-ui-droppable', "/wp-includes/js/jquery/ui/droppable$dev_suffix.js", array('jquery-ui-draggable'), '1.11.4', 1 ); |
|
213 | - $scripts->add( 'jquery-ui-menu', "/wp-includes/js/jquery/ui/menu$dev_suffix.js", array( 'jquery-ui-core', 'jquery-ui-widget', 'jquery-ui-position' ), '1.11.4', 1 ); |
|
214 | - $scripts->add( 'jquery-ui-mouse', "/wp-includes/js/jquery/ui/mouse$dev_suffix.js", array( 'jquery-ui-core', 'jquery-ui-widget' ), '1.11.4', 1 ); |
|
215 | - $scripts->add( 'jquery-ui-position', "/wp-includes/js/jquery/ui/position$dev_suffix.js", array('jquery'), '1.11.4', 1 ); |
|
216 | - $scripts->add( 'jquery-ui-progressbar', "/wp-includes/js/jquery/ui/progressbar$dev_suffix.js", array('jquery-ui-core', 'jquery-ui-widget'), '1.11.4', 1 ); |
|
217 | - $scripts->add( 'jquery-ui-resizable', "/wp-includes/js/jquery/ui/resizable$dev_suffix.js", array('jquery-ui-mouse'), '1.11.4', 1 ); |
|
218 | - $scripts->add( 'jquery-ui-selectable', "/wp-includes/js/jquery/ui/selectable$dev_suffix.js", array('jquery-ui-mouse'), '1.11.4', 1 ); |
|
219 | - $scripts->add( 'jquery-ui-selectmenu', "/wp-includes/js/jquery/ui/selectmenu$dev_suffix.js", array('jquery-ui-menu'), '1.11.4', 1 ); |
|
220 | - $scripts->add( 'jquery-ui-slider', "/wp-includes/js/jquery/ui/slider$dev_suffix.js", array('jquery-ui-mouse'), '1.11.4', 1 ); |
|
221 | - $scripts->add( 'jquery-ui-sortable', "/wp-includes/js/jquery/ui/sortable$dev_suffix.js", array('jquery-ui-mouse'), '1.11.4', 1 ); |
|
222 | - $scripts->add( 'jquery-ui-spinner', "/wp-includes/js/jquery/ui/spinner$dev_suffix.js", array( 'jquery-ui-button' ), '1.11.4', 1 ); |
|
223 | - $scripts->add( 'jquery-ui-tabs', "/wp-includes/js/jquery/ui/tabs$dev_suffix.js", array('jquery-ui-core', 'jquery-ui-widget'), '1.11.4', 1 ); |
|
224 | - $scripts->add( 'jquery-ui-tooltip', "/wp-includes/js/jquery/ui/tooltip$dev_suffix.js", array( 'jquery-ui-core', 'jquery-ui-widget', 'jquery-ui-position' ), '1.11.4', 1 ); |
|
225 | - $scripts->add( 'jquery-ui-widget', "/wp-includes/js/jquery/ui/widget$dev_suffix.js", array('jquery'), '1.11.4', 1 ); |
|
187 | + $scripts->add('jquery-ui-core', "/wp-includes/js/jquery/ui/core$dev_suffix.js", array('jquery'), '1.11.4', 1); |
|
188 | + $scripts->add('jquery-effects-core', "/wp-includes/js/jquery/ui/effect$dev_suffix.js", array('jquery'), '1.11.4', 1); |
|
189 | + |
|
190 | + $scripts->add('jquery-effects-blind', "/wp-includes/js/jquery/ui/effect-blind$dev_suffix.js", array('jquery-effects-core'), '1.11.4', 1); |
|
191 | + $scripts->add('jquery-effects-bounce', "/wp-includes/js/jquery/ui/effect-bounce$dev_suffix.js", array('jquery-effects-core'), '1.11.4', 1); |
|
192 | + $scripts->add('jquery-effects-clip', "/wp-includes/js/jquery/ui/effect-clip$dev_suffix.js", array('jquery-effects-core'), '1.11.4', 1); |
|
193 | + $scripts->add('jquery-effects-drop', "/wp-includes/js/jquery/ui/effect-drop$dev_suffix.js", array('jquery-effects-core'), '1.11.4', 1); |
|
194 | + $scripts->add('jquery-effects-explode', "/wp-includes/js/jquery/ui/effect-explode$dev_suffix.js", array('jquery-effects-core'), '1.11.4', 1); |
|
195 | + $scripts->add('jquery-effects-fade', "/wp-includes/js/jquery/ui/effect-fade$dev_suffix.js", array('jquery-effects-core'), '1.11.4', 1); |
|
196 | + $scripts->add('jquery-effects-fold', "/wp-includes/js/jquery/ui/effect-fold$dev_suffix.js", array('jquery-effects-core'), '1.11.4', 1); |
|
197 | + $scripts->add('jquery-effects-highlight', "/wp-includes/js/jquery/ui/effect-highlight$dev_suffix.js", array('jquery-effects-core'), '1.11.4', 1); |
|
198 | + $scripts->add('jquery-effects-puff', "/wp-includes/js/jquery/ui/effect-puff$dev_suffix.js", array('jquery-effects-core', 'jquery-effects-scale'), '1.11.4', 1); |
|
199 | + $scripts->add('jquery-effects-pulsate', "/wp-includes/js/jquery/ui/effect-pulsate$dev_suffix.js", array('jquery-effects-core'), '1.11.4', 1); |
|
200 | + $scripts->add('jquery-effects-scale', "/wp-includes/js/jquery/ui/effect-scale$dev_suffix.js", array('jquery-effects-core', 'jquery-effects-size'), '1.11.4', 1); |
|
201 | + $scripts->add('jquery-effects-shake', "/wp-includes/js/jquery/ui/effect-shake$dev_suffix.js", array('jquery-effects-core'), '1.11.4', 1); |
|
202 | + $scripts->add('jquery-effects-size', "/wp-includes/js/jquery/ui/effect-size$dev_suffix.js", array('jquery-effects-core'), '1.11.4', 1); |
|
203 | + $scripts->add('jquery-effects-slide', "/wp-includes/js/jquery/ui/effect-slide$dev_suffix.js", array('jquery-effects-core'), '1.11.4', 1); |
|
204 | + $scripts->add('jquery-effects-transfer', "/wp-includes/js/jquery/ui/effect-transfer$dev_suffix.js", array('jquery-effects-core'), '1.11.4', 1); |
|
205 | + |
|
206 | + $scripts->add('jquery-ui-accordion', "/wp-includes/js/jquery/ui/accordion$dev_suffix.js", array('jquery-ui-core', 'jquery-ui-widget'), '1.11.4', 1); |
|
207 | + $scripts->add('jquery-ui-autocomplete', "/wp-includes/js/jquery/ui/autocomplete$dev_suffix.js", array('jquery-ui-menu', 'wp-a11y'), '1.11.4', 1); |
|
208 | + $scripts->add('jquery-ui-button', "/wp-includes/js/jquery/ui/button$dev_suffix.js", array('jquery-ui-core', 'jquery-ui-widget'), '1.11.4', 1); |
|
209 | + $scripts->add('jquery-ui-datepicker', "/wp-includes/js/jquery/ui/datepicker$dev_suffix.js", array('jquery-ui-core'), '1.11.4', 1); |
|
210 | + $scripts->add('jquery-ui-dialog', "/wp-includes/js/jquery/ui/dialog$dev_suffix.js", array('jquery-ui-resizable', 'jquery-ui-draggable', 'jquery-ui-button', 'jquery-ui-position'), '1.11.4', 1); |
|
211 | + $scripts->add('jquery-ui-draggable', "/wp-includes/js/jquery/ui/draggable$dev_suffix.js", array('jquery-ui-mouse'), '1.11.4', 1); |
|
212 | + $scripts->add('jquery-ui-droppable', "/wp-includes/js/jquery/ui/droppable$dev_suffix.js", array('jquery-ui-draggable'), '1.11.4', 1); |
|
213 | + $scripts->add('jquery-ui-menu', "/wp-includes/js/jquery/ui/menu$dev_suffix.js", array('jquery-ui-core', 'jquery-ui-widget', 'jquery-ui-position'), '1.11.4', 1); |
|
214 | + $scripts->add('jquery-ui-mouse', "/wp-includes/js/jquery/ui/mouse$dev_suffix.js", array('jquery-ui-core', 'jquery-ui-widget'), '1.11.4', 1); |
|
215 | + $scripts->add('jquery-ui-position', "/wp-includes/js/jquery/ui/position$dev_suffix.js", array('jquery'), '1.11.4', 1); |
|
216 | + $scripts->add('jquery-ui-progressbar', "/wp-includes/js/jquery/ui/progressbar$dev_suffix.js", array('jquery-ui-core', 'jquery-ui-widget'), '1.11.4', 1); |
|
217 | + $scripts->add('jquery-ui-resizable', "/wp-includes/js/jquery/ui/resizable$dev_suffix.js", array('jquery-ui-mouse'), '1.11.4', 1); |
|
218 | + $scripts->add('jquery-ui-selectable', "/wp-includes/js/jquery/ui/selectable$dev_suffix.js", array('jquery-ui-mouse'), '1.11.4', 1); |
|
219 | + $scripts->add('jquery-ui-selectmenu', "/wp-includes/js/jquery/ui/selectmenu$dev_suffix.js", array('jquery-ui-menu'), '1.11.4', 1); |
|
220 | + $scripts->add('jquery-ui-slider', "/wp-includes/js/jquery/ui/slider$dev_suffix.js", array('jquery-ui-mouse'), '1.11.4', 1); |
|
221 | + $scripts->add('jquery-ui-sortable', "/wp-includes/js/jquery/ui/sortable$dev_suffix.js", array('jquery-ui-mouse'), '1.11.4', 1); |
|
222 | + $scripts->add('jquery-ui-spinner', "/wp-includes/js/jquery/ui/spinner$dev_suffix.js", array('jquery-ui-button'), '1.11.4', 1); |
|
223 | + $scripts->add('jquery-ui-tabs', "/wp-includes/js/jquery/ui/tabs$dev_suffix.js", array('jquery-ui-core', 'jquery-ui-widget'), '1.11.4', 1); |
|
224 | + $scripts->add('jquery-ui-tooltip', "/wp-includes/js/jquery/ui/tooltip$dev_suffix.js", array('jquery-ui-core', 'jquery-ui-widget', 'jquery-ui-position'), '1.11.4', 1); |
|
225 | + $scripts->add('jquery-ui-widget', "/wp-includes/js/jquery/ui/widget$dev_suffix.js", array('jquery'), '1.11.4', 1); |
|
226 | 226 | |
227 | 227 | // Strings for 'jquery-ui-autocomplete' live region messages |
228 | - did_action( 'init' ) && $scripts->localize( 'jquery-ui-autocomplete', 'uiAutocompleteL10n', array( |
|
229 | - 'noResults' => __( 'No search results.' ), |
|
228 | + did_action('init') && $scripts->localize('jquery-ui-autocomplete', 'uiAutocompleteL10n', array( |
|
229 | + 'noResults' => __('No search results.'), |
|
230 | 230 | /* translators: Number of results found when using jQuery UI Autocomplete */ |
231 | - 'oneResult' => __( '1 result found. Use up and down arrow keys to navigate.' ), |
|
232 | - 'manyResults' => __( '%d results found. Use up and down arrow keys to navigate.' ), |
|
233 | - ) ); |
|
231 | + 'oneResult' => __('1 result found. Use up and down arrow keys to navigate.'), |
|
232 | + 'manyResults' => __('%d results found. Use up and down arrow keys to navigate.'), |
|
233 | + )); |
|
234 | 234 | |
235 | 235 | // deprecated, not used in core, most functionality is included in jQuery 1.3 |
236 | - $scripts->add( 'jquery-form', "/wp-includes/js/jquery/jquery.form$suffix.js", array('jquery'), '3.37.0', 1 ); |
|
236 | + $scripts->add('jquery-form', "/wp-includes/js/jquery/jquery.form$suffix.js", array('jquery'), '3.37.0', 1); |
|
237 | 237 | |
238 | 238 | // jQuery plugins |
239 | - $scripts->add( 'jquery-color', "/wp-includes/js/jquery/jquery.color.min.js", array('jquery'), '2.1.1', 1 ); |
|
240 | - $scripts->add( 'suggest', "/wp-includes/js/jquery/suggest$suffix.js", array('jquery'), '1.1-20110113', 1 ); |
|
241 | - $scripts->add( 'schedule', '/wp-includes/js/jquery/jquery.schedule.js', array('jquery'), '20m', 1 ); |
|
242 | - $scripts->add( 'jquery-query', "/wp-includes/js/jquery/jquery.query.js", array('jquery'), '2.1.7', 1 ); |
|
243 | - $scripts->add( 'jquery-serialize-object', "/wp-includes/js/jquery/jquery.serialize-object.js", array('jquery'), '0.2', 1 ); |
|
244 | - $scripts->add( 'jquery-hotkeys', "/wp-includes/js/jquery/jquery.hotkeys$suffix.js", array('jquery'), '0.0.2m', 1 ); |
|
245 | - $scripts->add( 'jquery-table-hotkeys', "/wp-includes/js/jquery/jquery.table-hotkeys$suffix.js", array('jquery', 'jquery-hotkeys'), false, 1 ); |
|
246 | - $scripts->add( 'jquery-touch-punch', "/wp-includes/js/jquery/jquery.ui.touch-punch.js", array('jquery-ui-widget', 'jquery-ui-mouse'), '0.2.2', 1 ); |
|
239 | + $scripts->add('jquery-color', "/wp-includes/js/jquery/jquery.color.min.js", array('jquery'), '2.1.1', 1); |
|
240 | + $scripts->add('suggest', "/wp-includes/js/jquery/suggest$suffix.js", array('jquery'), '1.1-20110113', 1); |
|
241 | + $scripts->add('schedule', '/wp-includes/js/jquery/jquery.schedule.js', array('jquery'), '20m', 1); |
|
242 | + $scripts->add('jquery-query', "/wp-includes/js/jquery/jquery.query.js", array('jquery'), '2.1.7', 1); |
|
243 | + $scripts->add('jquery-serialize-object', "/wp-includes/js/jquery/jquery.serialize-object.js", array('jquery'), '0.2', 1); |
|
244 | + $scripts->add('jquery-hotkeys', "/wp-includes/js/jquery/jquery.hotkeys$suffix.js", array('jquery'), '0.0.2m', 1); |
|
245 | + $scripts->add('jquery-table-hotkeys', "/wp-includes/js/jquery/jquery.table-hotkeys$suffix.js", array('jquery', 'jquery-hotkeys'), false, 1); |
|
246 | + $scripts->add('jquery-touch-punch', "/wp-includes/js/jquery/jquery.ui.touch-punch.js", array('jquery-ui-widget', 'jquery-ui-mouse'), '0.2.2', 1); |
|
247 | 247 | |
248 | 248 | // Masonry v2 depended on jQuery. v3 does not. The older jquery-masonry handle is a shiv. |
249 | 249 | // It sets jQuery as a dependency, as the theme may have been implicitly loading it this way. |
250 | - $scripts->add( 'masonry', "/wp-includes/js/masonry.min.js", array(), '3.1.2', 1 ); |
|
251 | - $scripts->add( 'jquery-masonry', "/wp-includes/js/jquery/jquery.masonry$dev_suffix.js", array( 'jquery', 'masonry' ), '3.1.2', 1 ); |
|
250 | + $scripts->add('masonry', "/wp-includes/js/masonry.min.js", array(), '3.1.2', 1); |
|
251 | + $scripts->add('jquery-masonry', "/wp-includes/js/jquery/jquery.masonry$dev_suffix.js", array('jquery', 'masonry'), '3.1.2', 1); |
|
252 | 252 | |
253 | - $scripts->add( 'thickbox', "/wp-includes/js/thickbox/thickbox.js", array('jquery'), '3.1-20121105', 1 ); |
|
254 | - did_action( 'init' ) && $scripts->localize( 'thickbox', 'thickboxL10n', array( |
|
253 | + $scripts->add('thickbox', "/wp-includes/js/thickbox/thickbox.js", array('jquery'), '3.1-20121105', 1); |
|
254 | + did_action('init') && $scripts->localize('thickbox', 'thickboxL10n', array( |
|
255 | 255 | 'next' => __('Next >'), |
256 | 256 | 'prev' => __('< Prev'), |
257 | 257 | 'image' => __('Image'), |
@@ -259,11 +259,11 @@ discard block |
||
259 | 259 | 'close' => __('Close'), |
260 | 260 | 'noiframes' => __('This feature requires inline frames. You have iframes disabled or your browser does not support them.'), |
261 | 261 | 'loadingAnimation' => includes_url('js/thickbox/loadingAnimation.gif'), |
262 | - ) ); |
|
262 | + )); |
|
263 | 263 | |
264 | - $scripts->add( 'jcrop', "/wp-includes/js/jcrop/jquery.Jcrop.min.js", array('jquery'), '0.9.12'); |
|
264 | + $scripts->add('jcrop', "/wp-includes/js/jcrop/jquery.Jcrop.min.js", array('jquery'), '0.9.12'); |
|
265 | 265 | |
266 | - $scripts->add( 'swfobject', "/wp-includes/js/swfobject.js", array(), '2.2-20120417'); |
|
266 | + $scripts->add('swfobject', "/wp-includes/js/swfobject.js", array(), '2.2-20120417'); |
|
267 | 267 | |
268 | 268 | // error message for both plupload and swfupload |
269 | 269 | $uploader_l10n = array( |
@@ -291,73 +291,73 @@ discard block |
||
291 | 291 | 'error_uploading' => __('“%s” has failed to upload.') |
292 | 292 | ); |
293 | 293 | |
294 | - $scripts->add( 'plupload', '/wp-includes/js/plupload/plupload.full.min.js', array(), '2.1.8' ); |
|
294 | + $scripts->add('plupload', '/wp-includes/js/plupload/plupload.full.min.js', array(), '2.1.8'); |
|
295 | 295 | // Back compat handles: |
296 | - foreach ( array( 'all', 'html5', 'flash', 'silverlight', 'html4' ) as $handle ) { |
|
297 | - $scripts->add( "plupload-$handle", false, array( 'plupload' ), '2.1.1' ); |
|
296 | + foreach (array('all', 'html5', 'flash', 'silverlight', 'html4') as $handle) { |
|
297 | + $scripts->add("plupload-$handle", false, array('plupload'), '2.1.1'); |
|
298 | 298 | } |
299 | 299 | |
300 | - $scripts->add( 'plupload-handlers', "/wp-includes/js/plupload/handlers$suffix.js", array( 'plupload', 'jquery' ) ); |
|
301 | - did_action( 'init' ) && $scripts->localize( 'plupload-handlers', 'pluploadL10n', $uploader_l10n ); |
|
300 | + $scripts->add('plupload-handlers', "/wp-includes/js/plupload/handlers$suffix.js", array('plupload', 'jquery')); |
|
301 | + did_action('init') && $scripts->localize('plupload-handlers', 'pluploadL10n', $uploader_l10n); |
|
302 | 302 | |
303 | - $scripts->add( 'wp-plupload', "/wp-includes/js/plupload/wp-plupload$suffix.js", array( 'plupload', 'jquery', 'json2', 'media-models' ), false, 1 ); |
|
304 | - did_action( 'init' ) && $scripts->localize( 'wp-plupload', 'pluploadL10n', $uploader_l10n ); |
|
303 | + $scripts->add('wp-plupload', "/wp-includes/js/plupload/wp-plupload$suffix.js", array('plupload', 'jquery', 'json2', 'media-models'), false, 1); |
|
304 | + did_action('init') && $scripts->localize('wp-plupload', 'pluploadL10n', $uploader_l10n); |
|
305 | 305 | |
306 | 306 | // keep 'swfupload' for back-compat. |
307 | - $scripts->add( 'swfupload', '/wp-includes/js/swfupload/swfupload.js', array(), '2201-20110113'); |
|
308 | - $scripts->add( 'swfupload-swfobject', '/wp-includes/js/swfupload/plugins/swfupload.swfobject.js', array('swfupload', 'swfobject'), '2201a'); |
|
309 | - $scripts->add( 'swfupload-queue', '/wp-includes/js/swfupload/plugins/swfupload.queue.js', array('swfupload'), '2201'); |
|
310 | - $scripts->add( 'swfupload-speed', '/wp-includes/js/swfupload/plugins/swfupload.speed.js', array('swfupload'), '2201'); |
|
311 | - $scripts->add( 'swfupload-all', false, array('swfupload', 'swfupload-swfobject', 'swfupload-queue'), '2201'); |
|
312 | - $scripts->add( 'swfupload-handlers', "/wp-includes/js/swfupload/handlers$suffix.js", array('swfupload-all', 'jquery'), '2201-20110524'); |
|
313 | - did_action( 'init' ) && $scripts->localize( 'swfupload-handlers', 'swfuploadL10n', $uploader_l10n ); |
|
307 | + $scripts->add('swfupload', '/wp-includes/js/swfupload/swfupload.js', array(), '2201-20110113'); |
|
308 | + $scripts->add('swfupload-swfobject', '/wp-includes/js/swfupload/plugins/swfupload.swfobject.js', array('swfupload', 'swfobject'), '2201a'); |
|
309 | + $scripts->add('swfupload-queue', '/wp-includes/js/swfupload/plugins/swfupload.queue.js', array('swfupload'), '2201'); |
|
310 | + $scripts->add('swfupload-speed', '/wp-includes/js/swfupload/plugins/swfupload.speed.js', array('swfupload'), '2201'); |
|
311 | + $scripts->add('swfupload-all', false, array('swfupload', 'swfupload-swfobject', 'swfupload-queue'), '2201'); |
|
312 | + $scripts->add('swfupload-handlers', "/wp-includes/js/swfupload/handlers$suffix.js", array('swfupload-all', 'jquery'), '2201-20110524'); |
|
313 | + did_action('init') && $scripts->localize('swfupload-handlers', 'swfuploadL10n', $uploader_l10n); |
|
314 | 314 | |
315 | - $scripts->add( 'comment-reply', "/wp-includes/js/comment-reply$suffix.js", array(), false, 1 ); |
|
315 | + $scripts->add('comment-reply', "/wp-includes/js/comment-reply$suffix.js", array(), false, 1); |
|
316 | 316 | |
317 | - $scripts->add( 'json2', "/wp-includes/js/json2$suffix.js", array(), '2015-05-03' ); |
|
318 | - did_action( 'init' ) && $scripts->add_data( 'json2', 'conditional', 'lt IE 8' ); |
|
317 | + $scripts->add('json2', "/wp-includes/js/json2$suffix.js", array(), '2015-05-03'); |
|
318 | + did_action('init') && $scripts->add_data('json2', 'conditional', 'lt IE 8'); |
|
319 | 319 | |
320 | - $scripts->add( 'underscore', "/wp-includes/js/underscore$dev_suffix.js", array(), '1.8.3', 1 ); |
|
321 | - $scripts->add( 'backbone', "/wp-includes/js/backbone$dev_suffix.js", array( 'underscore','jquery' ), '1.2.3', 1 ); |
|
320 | + $scripts->add('underscore', "/wp-includes/js/underscore$dev_suffix.js", array(), '1.8.3', 1); |
|
321 | + $scripts->add('backbone', "/wp-includes/js/backbone$dev_suffix.js", array('underscore', 'jquery'), '1.2.3', 1); |
|
322 | 322 | |
323 | - $scripts->add( 'wp-util', "/wp-includes/js/wp-util$suffix.js", array('underscore', 'jquery'), false, 1 ); |
|
324 | - did_action( 'init' ) && $scripts->localize( 'wp-util', '_wpUtilSettings', array( |
|
323 | + $scripts->add('wp-util', "/wp-includes/js/wp-util$suffix.js", array('underscore', 'jquery'), false, 1); |
|
324 | + did_action('init') && $scripts->localize('wp-util', '_wpUtilSettings', array( |
|
325 | 325 | 'ajax' => array( |
326 | - 'url' => admin_url( 'admin-ajax.php', 'relative' ), |
|
326 | + 'url' => admin_url('admin-ajax.php', 'relative'), |
|
327 | 327 | ), |
328 | - ) ); |
|
328 | + )); |
|
329 | 329 | |
330 | - $scripts->add( 'wp-backbone', "/wp-includes/js/wp-backbone$suffix.js", array('backbone', 'wp-util'), false, 1 ); |
|
330 | + $scripts->add('wp-backbone', "/wp-includes/js/wp-backbone$suffix.js", array('backbone', 'wp-util'), false, 1); |
|
331 | 331 | |
332 | - $scripts->add( 'revisions', "/wp-admin/js/revisions$suffix.js", array( 'wp-backbone', 'jquery-ui-slider', 'hoverIntent' ), false, 1 ); |
|
332 | + $scripts->add('revisions', "/wp-admin/js/revisions$suffix.js", array('wp-backbone', 'jquery-ui-slider', 'hoverIntent'), false, 1); |
|
333 | 333 | |
334 | - $scripts->add( 'imgareaselect', "/wp-includes/js/imgareaselect/jquery.imgareaselect$suffix.js", array('jquery'), false, 1 ); |
|
334 | + $scripts->add('imgareaselect', "/wp-includes/js/imgareaselect/jquery.imgareaselect$suffix.js", array('jquery'), false, 1); |
|
335 | 335 | |
336 | - $scripts->add( 'mediaelement', "/wp-includes/js/mediaelement/mediaelement-and-player.min.js", array('jquery'), '2.18.1', 1 ); |
|
337 | - did_action( 'init' ) && $scripts->localize( 'mediaelement', 'mejsL10n', array( |
|
338 | - 'language' => get_bloginfo( 'language' ), |
|
336 | + $scripts->add('mediaelement', "/wp-includes/js/mediaelement/mediaelement-and-player.min.js", array('jquery'), '2.18.1', 1); |
|
337 | + did_action('init') && $scripts->localize('mediaelement', 'mejsL10n', array( |
|
338 | + 'language' => get_bloginfo('language'), |
|
339 | 339 | 'strings' => array( |
340 | - 'Close' => __( 'Close' ), |
|
341 | - 'Fullscreen' => __( 'Fullscreen' ), |
|
342 | - 'Download File' => __( 'Download File' ), |
|
343 | - 'Download Video' => __( 'Download Video' ), |
|
344 | - 'Play/Pause' => __( 'Play/Pause' ), |
|
345 | - 'Mute Toggle' => __( 'Mute Toggle' ), |
|
346 | - 'None' => __( 'None' ), |
|
347 | - 'Turn off Fullscreen' => __( 'Turn off Fullscreen' ), |
|
348 | - 'Go Fullscreen' => __( 'Go Fullscreen' ), |
|
349 | - 'Unmute' => __( 'Unmute' ), |
|
350 | - 'Mute' => __( 'Mute' ), |
|
351 | - 'Captions/Subtitles' => __( 'Captions/Subtitles' ) |
|
340 | + 'Close' => __('Close'), |
|
341 | + 'Fullscreen' => __('Fullscreen'), |
|
342 | + 'Download File' => __('Download File'), |
|
343 | + 'Download Video' => __('Download Video'), |
|
344 | + 'Play/Pause' => __('Play/Pause'), |
|
345 | + 'Mute Toggle' => __('Mute Toggle'), |
|
346 | + 'None' => __('None'), |
|
347 | + 'Turn off Fullscreen' => __('Turn off Fullscreen'), |
|
348 | + 'Go Fullscreen' => __('Go Fullscreen'), |
|
349 | + 'Unmute' => __('Unmute'), |
|
350 | + 'Mute' => __('Mute'), |
|
351 | + 'Captions/Subtitles' => __('Captions/Subtitles') |
|
352 | 352 | ), |
353 | - ) ); |
|
353 | + )); |
|
354 | 354 | |
355 | 355 | |
356 | - $scripts->add( 'wp-mediaelement', "/wp-includes/js/mediaelement/wp-mediaelement$suffix.js", array('mediaelement'), false, 1 ); |
|
356 | + $scripts->add('wp-mediaelement', "/wp-includes/js/mediaelement/wp-mediaelement$suffix.js", array('mediaelement'), false, 1); |
|
357 | 357 | $mejs_settings = array( |
358 | - 'pluginPath' => includes_url( 'js/mediaelement/', 'relative' ), |
|
358 | + 'pluginPath' => includes_url('js/mediaelement/', 'relative'), |
|
359 | 359 | ); |
360 | - did_action( 'init' ) && $scripts->localize( 'mediaelement', '_wpmejsSettings', |
|
360 | + did_action('init') && $scripts->localize('mediaelement', '_wpmejsSettings', |
|
361 | 361 | /** |
362 | 362 | * Filter the MediaElement configuration settings. |
363 | 363 | * |
@@ -365,154 +365,154 @@ discard block |
||
365 | 365 | * |
366 | 366 | * @param array $mejs_settings MediaElement settings array. |
367 | 367 | */ |
368 | - apply_filters( 'mejs_settings', $mejs_settings ) |
|
368 | + apply_filters('mejs_settings', $mejs_settings) |
|
369 | 369 | ); |
370 | 370 | |
371 | - $scripts->add( 'froogaloop', "/wp-includes/js/mediaelement/froogaloop.min.js", array(), '2.0' ); |
|
372 | - $scripts->add( 'wp-playlist', "/wp-includes/js/mediaelement/wp-playlist$suffix.js", array( 'wp-util', 'backbone', 'mediaelement' ), false, 1 ); |
|
373 | - |
|
374 | - $scripts->add( 'zxcvbn-async', "/wp-includes/js/zxcvbn-async$suffix.js", array(), '1.0' ); |
|
375 | - did_action( 'init' ) && $scripts->localize( 'zxcvbn-async', '_zxcvbnSettings', array( |
|
376 | - 'src' => empty( $guessed_url ) ? includes_url( '/js/zxcvbn.min.js' ) : $scripts->base_url . '/wp-includes/js/zxcvbn.min.js', |
|
377 | - ) ); |
|
378 | - |
|
379 | - $scripts->add( 'password-strength-meter', "/wp-admin/js/password-strength-meter$suffix.js", array( 'jquery', 'zxcvbn-async' ), false, 1 ); |
|
380 | - did_action( 'init' ) && $scripts->localize( 'password-strength-meter', 'pwsL10n', array( |
|
381 | - 'short' => _x( 'Very weak', 'password strength' ), |
|
382 | - 'bad' => _x( 'Weak', 'password strength' ), |
|
383 | - 'good' => _x( 'Medium', 'password strength' ), |
|
384 | - 'strong' => _x( 'Strong', 'password strength' ), |
|
385 | - 'mismatch' => _x( 'Mismatch', 'password mismatch' ), |
|
386 | - ) ); |
|
387 | - |
|
388 | - $scripts->add( 'user-profile', "/wp-admin/js/user-profile$suffix.js", array( 'jquery', 'password-strength-meter', 'wp-util' ), false, 1 ); |
|
389 | - did_action( 'init' ) && $scripts->localize( 'user-profile', 'userProfileL10n', array( |
|
390 | - 'warn' => __( 'Your new password has not been saved.' ), |
|
391 | - 'show' => __( 'Show' ), |
|
392 | - 'hide' => __( 'Hide' ), |
|
393 | - 'cancel' => __( 'Cancel' ), |
|
394 | - 'ariaShow' => esc_attr__( 'Show password' ), |
|
395 | - 'ariaHide' => esc_attr__( 'Hide password' ), |
|
396 | - ) ); |
|
397 | - |
|
398 | - $scripts->add( 'language-chooser', "/wp-admin/js/language-chooser$suffix.js", array( 'jquery' ), false, 1 ); |
|
399 | - |
|
400 | - $scripts->add( 'user-suggest', "/wp-admin/js/user-suggest$suffix.js", array( 'jquery-ui-autocomplete' ), false, 1 ); |
|
401 | - |
|
402 | - $scripts->add( 'admin-bar', "/wp-includes/js/admin-bar$suffix.js", array(), false, 1 ); |
|
403 | - |
|
404 | - $scripts->add( 'wplink', "/wp-includes/js/wplink$suffix.js", array( 'jquery', 'wp-a11y' ), false, 1 ); |
|
405 | - did_action( 'init' ) && $scripts->localize( 'wplink', 'wpLinkL10n', array( |
|
371 | + $scripts->add('froogaloop', "/wp-includes/js/mediaelement/froogaloop.min.js", array(), '2.0'); |
|
372 | + $scripts->add('wp-playlist', "/wp-includes/js/mediaelement/wp-playlist$suffix.js", array('wp-util', 'backbone', 'mediaelement'), false, 1); |
|
373 | + |
|
374 | + $scripts->add('zxcvbn-async', "/wp-includes/js/zxcvbn-async$suffix.js", array(), '1.0'); |
|
375 | + did_action('init') && $scripts->localize('zxcvbn-async', '_zxcvbnSettings', array( |
|
376 | + 'src' => empty($guessed_url) ? includes_url('/js/zxcvbn.min.js') : $scripts->base_url.'/wp-includes/js/zxcvbn.min.js', |
|
377 | + )); |
|
378 | + |
|
379 | + $scripts->add('password-strength-meter', "/wp-admin/js/password-strength-meter$suffix.js", array('jquery', 'zxcvbn-async'), false, 1); |
|
380 | + did_action('init') && $scripts->localize('password-strength-meter', 'pwsL10n', array( |
|
381 | + 'short' => _x('Very weak', 'password strength'), |
|
382 | + 'bad' => _x('Weak', 'password strength'), |
|
383 | + 'good' => _x('Medium', 'password strength'), |
|
384 | + 'strong' => _x('Strong', 'password strength'), |
|
385 | + 'mismatch' => _x('Mismatch', 'password mismatch'), |
|
386 | + )); |
|
387 | + |
|
388 | + $scripts->add('user-profile', "/wp-admin/js/user-profile$suffix.js", array('jquery', 'password-strength-meter', 'wp-util'), false, 1); |
|
389 | + did_action('init') && $scripts->localize('user-profile', 'userProfileL10n', array( |
|
390 | + 'warn' => __('Your new password has not been saved.'), |
|
391 | + 'show' => __('Show'), |
|
392 | + 'hide' => __('Hide'), |
|
393 | + 'cancel' => __('Cancel'), |
|
394 | + 'ariaShow' => esc_attr__('Show password'), |
|
395 | + 'ariaHide' => esc_attr__('Hide password'), |
|
396 | + )); |
|
397 | + |
|
398 | + $scripts->add('language-chooser', "/wp-admin/js/language-chooser$suffix.js", array('jquery'), false, 1); |
|
399 | + |
|
400 | + $scripts->add('user-suggest', "/wp-admin/js/user-suggest$suffix.js", array('jquery-ui-autocomplete'), false, 1); |
|
401 | + |
|
402 | + $scripts->add('admin-bar', "/wp-includes/js/admin-bar$suffix.js", array(), false, 1); |
|
403 | + |
|
404 | + $scripts->add('wplink', "/wp-includes/js/wplink$suffix.js", array('jquery', 'wp-a11y'), false, 1); |
|
405 | + did_action('init') && $scripts->localize('wplink', 'wpLinkL10n', array( |
|
406 | 406 | 'title' => __('Insert/edit link'), |
407 | 407 | 'update' => __('Update'), |
408 | 408 | 'save' => __('Add Link'), |
409 | 409 | 'noTitle' => __('(no title)'), |
410 | 410 | 'noMatchesFound' => __('No results found.'), |
411 | - 'linkSelected' => __( 'Link selected.' ), |
|
412 | - 'linkInserted' => __( 'Link inserted.' ), |
|
413 | - ) ); |
|
411 | + 'linkSelected' => __('Link selected.'), |
|
412 | + 'linkInserted' => __('Link inserted.'), |
|
413 | + )); |
|
414 | 414 | |
415 | - $scripts->add( 'wpdialogs', "/wp-includes/js/wpdialog$suffix.js", array( 'jquery-ui-dialog' ), false, 1 ); |
|
415 | + $scripts->add('wpdialogs', "/wp-includes/js/wpdialog$suffix.js", array('jquery-ui-dialog'), false, 1); |
|
416 | 416 | |
417 | - $scripts->add( 'word-count', "/wp-admin/js/word-count$suffix.js", array(), false, 1 ); |
|
418 | - did_action( 'init' ) && $scripts->localize( 'word-count', 'wordCountL10n', array( |
|
417 | + $scripts->add('word-count', "/wp-admin/js/word-count$suffix.js", array(), false, 1); |
|
418 | + did_action('init') && $scripts->localize('word-count', 'wordCountL10n', array( |
|
419 | 419 | /* |
420 | 420 | * translators: If your word count is based on single characters (e.g. East Asian characters), |
421 | 421 | * enter 'characters_excluding_spaces' or 'characters_including_spaces'. Otherwise, enter 'words'. |
422 | 422 | * Do not translate into your own language. |
423 | 423 | */ |
424 | - 'type' => _x( 'words', 'Word count type. Do not translate!' ), |
|
425 | - 'shortcodes' => ! empty( $GLOBALS['shortcode_tags'] ) ? array_keys( $GLOBALS['shortcode_tags'] ) : array() |
|
426 | - ) ); |
|
427 | - |
|
428 | - $scripts->add( 'media-upload', "/wp-admin/js/media-upload$suffix.js", array( 'thickbox', 'shortcode' ), false, 1 ); |
|
429 | - |
|
430 | - $scripts->add( 'hoverIntent', "/wp-includes/js/hoverIntent$suffix.js", array('jquery'), '1.8.1', 1 ); |
|
431 | - |
|
432 | - $scripts->add( 'customize-base', "/wp-includes/js/customize-base$suffix.js", array( 'jquery', 'json2', 'underscore' ), false, 1 ); |
|
433 | - $scripts->add( 'customize-loader', "/wp-includes/js/customize-loader$suffix.js", array( 'customize-base' ), false, 1 ); |
|
434 | - $scripts->add( 'customize-preview', "/wp-includes/js/customize-preview$suffix.js", array( 'customize-base' ), false, 1 ); |
|
435 | - $scripts->add( 'customize-models', "/wp-includes/js/customize-models.js", array( 'underscore', 'backbone' ), false, 1 ); |
|
436 | - $scripts->add( 'customize-views', "/wp-includes/js/customize-views.js", array( 'jquery', 'underscore', 'imgareaselect', 'customize-models', 'media-editor', 'media-views' ), false, 1 ); |
|
437 | - $scripts->add( 'customize-controls', "/wp-admin/js/customize-controls$suffix.js", array( 'customize-base', 'wp-a11y' ), false, 1 ); |
|
438 | - did_action( 'init' ) && $scripts->localize( 'customize-controls', '_wpCustomizeControlsL10n', array( |
|
439 | - 'activate' => __( 'Save & Activate' ), |
|
440 | - 'save' => __( 'Save & Publish' ), |
|
441 | - 'saveAlert' => __( 'The changes you made will be lost if you navigate away from this page.' ), |
|
442 | - 'saved' => __( 'Saved' ), |
|
443 | - 'cancel' => __( 'Cancel' ), |
|
444 | - 'close' => __( 'Close' ), |
|
445 | - 'cheatin' => __( 'Cheatin’ uh?' ), |
|
446 | - 'notAllowed' => __( 'You are not allowed to customize the appearance of this site.' ), |
|
447 | - 'previewIframeTitle' => __( 'Site Preview' ), |
|
448 | - 'loginIframeTitle' => __( 'Session expired' ), |
|
449 | - 'collapseSidebar' => __( 'Collapse Sidebar' ), |
|
450 | - 'expandSidebar' => __( 'Expand Sidebar' ), |
|
451 | - 'untitledBlogName' => __( '(Untitled)' ), |
|
424 | + 'type' => _x('words', 'Word count type. Do not translate!'), |
|
425 | + 'shortcodes' => ! empty($GLOBALS['shortcode_tags']) ? array_keys($GLOBALS['shortcode_tags']) : array() |
|
426 | + )); |
|
427 | + |
|
428 | + $scripts->add('media-upload', "/wp-admin/js/media-upload$suffix.js", array('thickbox', 'shortcode'), false, 1); |
|
429 | + |
|
430 | + $scripts->add('hoverIntent', "/wp-includes/js/hoverIntent$suffix.js", array('jquery'), '1.8.1', 1); |
|
431 | + |
|
432 | + $scripts->add('customize-base', "/wp-includes/js/customize-base$suffix.js", array('jquery', 'json2', 'underscore'), false, 1); |
|
433 | + $scripts->add('customize-loader', "/wp-includes/js/customize-loader$suffix.js", array('customize-base'), false, 1); |
|
434 | + $scripts->add('customize-preview', "/wp-includes/js/customize-preview$suffix.js", array('customize-base'), false, 1); |
|
435 | + $scripts->add('customize-models', "/wp-includes/js/customize-models.js", array('underscore', 'backbone'), false, 1); |
|
436 | + $scripts->add('customize-views', "/wp-includes/js/customize-views.js", array('jquery', 'underscore', 'imgareaselect', 'customize-models', 'media-editor', 'media-views'), false, 1); |
|
437 | + $scripts->add('customize-controls', "/wp-admin/js/customize-controls$suffix.js", array('customize-base', 'wp-a11y'), false, 1); |
|
438 | + did_action('init') && $scripts->localize('customize-controls', '_wpCustomizeControlsL10n', array( |
|
439 | + 'activate' => __('Save & Activate'), |
|
440 | + 'save' => __('Save & Publish'), |
|
441 | + 'saveAlert' => __('The changes you made will be lost if you navigate away from this page.'), |
|
442 | + 'saved' => __('Saved'), |
|
443 | + 'cancel' => __('Cancel'), |
|
444 | + 'close' => __('Close'), |
|
445 | + 'cheatin' => __('Cheatin’ uh?'), |
|
446 | + 'notAllowed' => __('You are not allowed to customize the appearance of this site.'), |
|
447 | + 'previewIframeTitle' => __('Site Preview'), |
|
448 | + 'loginIframeTitle' => __('Session expired'), |
|
449 | + 'collapseSidebar' => __('Collapse Sidebar'), |
|
450 | + 'expandSidebar' => __('Expand Sidebar'), |
|
451 | + 'untitledBlogName' => __('(Untitled)'), |
|
452 | 452 | // Used for overriding the file types allowed in plupload. |
453 | - 'allowedFiles' => __( 'Allowed Files' ), |
|
454 | - ) ); |
|
455 | - $scripts->add( 'customize-selective-refresh', "/wp-includes/js/customize-selective-refresh$suffix.js", array( 'jquery', 'wp-util', 'customize-preview' ), false, 1 ); |
|
453 | + 'allowedFiles' => __('Allowed Files'), |
|
454 | + )); |
|
455 | + $scripts->add('customize-selective-refresh', "/wp-includes/js/customize-selective-refresh$suffix.js", array('jquery', 'wp-util', 'customize-preview'), false, 1); |
|
456 | 456 | |
457 | - $scripts->add( 'customize-widgets', "/wp-admin/js/customize-widgets$suffix.js", array( 'jquery', 'jquery-ui-sortable', 'jquery-ui-droppable', 'wp-backbone', 'customize-controls' ), false, 1 ); |
|
458 | - $scripts->add( 'customize-preview-widgets', "/wp-includes/js/customize-preview-widgets$suffix.js", array( 'jquery', 'wp-util', 'customize-preview' ), false, 1 ); |
|
457 | + $scripts->add('customize-widgets', "/wp-admin/js/customize-widgets$suffix.js", array('jquery', 'jquery-ui-sortable', 'jquery-ui-droppable', 'wp-backbone', 'customize-controls'), false, 1); |
|
458 | + $scripts->add('customize-preview-widgets', "/wp-includes/js/customize-preview-widgets$suffix.js", array('jquery', 'wp-util', 'customize-preview'), false, 1); |
|
459 | 459 | |
460 | - $scripts->add( 'customize-nav-menus', "/wp-admin/js/customize-nav-menus$suffix.js", array( 'jquery', 'wp-backbone', 'customize-controls', 'accordion', 'nav-menu' ), false, 1 ); |
|
461 | - $scripts->add( 'customize-preview-nav-menus', "/wp-includes/js/customize-preview-nav-menus$suffix.js", array( 'jquery', 'wp-util', 'customize-preview' ), false, 1 ); |
|
460 | + $scripts->add('customize-nav-menus', "/wp-admin/js/customize-nav-menus$suffix.js", array('jquery', 'wp-backbone', 'customize-controls', 'accordion', 'nav-menu'), false, 1); |
|
461 | + $scripts->add('customize-preview-nav-menus', "/wp-includes/js/customize-preview-nav-menus$suffix.js", array('jquery', 'wp-util', 'customize-preview'), false, 1); |
|
462 | 462 | |
463 | - $scripts->add( 'accordion', "/wp-admin/js/accordion$suffix.js", array( 'jquery' ), false, 1 ); |
|
463 | + $scripts->add('accordion', "/wp-admin/js/accordion$suffix.js", array('jquery'), false, 1); |
|
464 | 464 | |
465 | - $scripts->add( 'shortcode', "/wp-includes/js/shortcode$suffix.js", array( 'underscore' ), false, 1 ); |
|
466 | - $scripts->add( 'media-models', "/wp-includes/js/media-models$suffix.js", array( 'wp-backbone' ), false, 1 ); |
|
467 | - did_action( 'init' ) && $scripts->localize( 'media-models', '_wpMediaModelsL10n', array( |
|
465 | + $scripts->add('shortcode', "/wp-includes/js/shortcode$suffix.js", array('underscore'), false, 1); |
|
466 | + $scripts->add('media-models', "/wp-includes/js/media-models$suffix.js", array('wp-backbone'), false, 1); |
|
467 | + did_action('init') && $scripts->localize('media-models', '_wpMediaModelsL10n', array( |
|
468 | 468 | 'settings' => array( |
469 | - 'ajaxurl' => admin_url( 'admin-ajax.php', 'relative' ), |
|
470 | - 'post' => array( 'id' => 0 ), |
|
469 | + 'ajaxurl' => admin_url('admin-ajax.php', 'relative'), |
|
470 | + 'post' => array('id' => 0), |
|
471 | 471 | ), |
472 | - ) ); |
|
472 | + )); |
|
473 | 473 | |
474 | - $scripts->add( 'wp-embed', "/wp-includes/js/wp-embed$suffix.js" ); |
|
474 | + $scripts->add('wp-embed', "/wp-includes/js/wp-embed$suffix.js"); |
|
475 | 475 | |
476 | 476 | // To enqueue media-views or media-editor, call wp_enqueue_media(). |
477 | 477 | // Both rely on numerous settings, styles, and templates to operate correctly. |
478 | - $scripts->add( 'media-views', "/wp-includes/js/media-views$suffix.js", array( 'utils', 'media-models', 'wp-plupload', 'jquery-ui-sortable', 'wp-mediaelement' ), false, 1 ); |
|
479 | - $scripts->add( 'media-editor', "/wp-includes/js/media-editor$suffix.js", array( 'shortcode', 'media-views' ), false, 1 ); |
|
480 | - $scripts->add( 'media-audiovideo', "/wp-includes/js/media-audiovideo$suffix.js", array( 'media-editor' ), false, 1 ); |
|
481 | - $scripts->add( 'mce-view', "/wp-includes/js/mce-view$suffix.js", array( 'shortcode', 'jquery', 'media-views', 'media-audiovideo' ), false, 1 ); |
|
482 | - |
|
483 | - if ( is_admin() ) { |
|
484 | - $scripts->add( 'admin-tags', "/wp-admin/js/tags$suffix.js", array( 'jquery', 'wp-ajax-response' ), false, 1 ); |
|
485 | - did_action( 'init' ) && $scripts->localize( 'admin-tags', 'tagsl10n', array( |
|
478 | + $scripts->add('media-views', "/wp-includes/js/media-views$suffix.js", array('utils', 'media-models', 'wp-plupload', 'jquery-ui-sortable', 'wp-mediaelement'), false, 1); |
|
479 | + $scripts->add('media-editor', "/wp-includes/js/media-editor$suffix.js", array('shortcode', 'media-views'), false, 1); |
|
480 | + $scripts->add('media-audiovideo', "/wp-includes/js/media-audiovideo$suffix.js", array('media-editor'), false, 1); |
|
481 | + $scripts->add('mce-view', "/wp-includes/js/mce-view$suffix.js", array('shortcode', 'jquery', 'media-views', 'media-audiovideo'), false, 1); |
|
482 | + |
|
483 | + if (is_admin()) { |
|
484 | + $scripts->add('admin-tags', "/wp-admin/js/tags$suffix.js", array('jquery', 'wp-ajax-response'), false, 1); |
|
485 | + did_action('init') && $scripts->localize('admin-tags', 'tagsl10n', array( |
|
486 | 486 | 'noPerm' => __('You do not have permission to do that.'), |
487 | 487 | 'broken' => __('An unidentified error has occurred.') |
488 | 488 | )); |
489 | 489 | |
490 | - $scripts->add( 'admin-comments', "/wp-admin/js/edit-comments$suffix.js", array('wp-lists', 'quicktags', 'jquery-query'), false, 1 ); |
|
491 | - did_action( 'init' ) && $scripts->localize( 'admin-comments', 'adminCommentsL10n', array( |
|
490 | + $scripts->add('admin-comments', "/wp-admin/js/edit-comments$suffix.js", array('wp-lists', 'quicktags', 'jquery-query'), false, 1); |
|
491 | + did_action('init') && $scripts->localize('admin-comments', 'adminCommentsL10n', array( |
|
492 | 492 | 'hotkeys_highlight_first' => isset($_GET['hotkeys_highlight_first']), |
493 | 493 | 'hotkeys_highlight_last' => isset($_GET['hotkeys_highlight_last']), |
494 | - 'replyApprove' => __( 'Approve and Reply' ), |
|
495 | - 'reply' => __( 'Reply' ), |
|
496 | - 'warnQuickEdit' => __( "Are you sure you want to edit this comment?\nThe changes you made will be lost." ), |
|
497 | - 'docTitleComments' => __( 'Comments' ), |
|
494 | + 'replyApprove' => __('Approve and Reply'), |
|
495 | + 'reply' => __('Reply'), |
|
496 | + 'warnQuickEdit' => __("Are you sure you want to edit this comment?\nThe changes you made will be lost."), |
|
497 | + 'docTitleComments' => __('Comments'), |
|
498 | 498 | /* translators: %s: comments count */ |
499 | - 'docTitleCommentsCount' => __( 'Comments (%s)' ), |
|
500 | - ) ); |
|
499 | + 'docTitleCommentsCount' => __('Comments (%s)'), |
|
500 | + )); |
|
501 | 501 | |
502 | - $scripts->add( 'xfn', "/wp-admin/js/xfn$suffix.js", array('jquery'), false, 1 ); |
|
502 | + $scripts->add('xfn', "/wp-admin/js/xfn$suffix.js", array('jquery'), false, 1); |
|
503 | 503 | |
504 | - $scripts->add( 'postbox', "/wp-admin/js/postbox$suffix.js", array('jquery-ui-sortable'), false, 1 ); |
|
505 | - did_action( 'init' ) && $scripts->localize( 'postbox', 'postBoxL10n', array( |
|
506 | - 'postBoxEmptyString' => __( 'Drag boxes here' ), |
|
507 | - ) ); |
|
504 | + $scripts->add('postbox', "/wp-admin/js/postbox$suffix.js", array('jquery-ui-sortable'), false, 1); |
|
505 | + did_action('init') && $scripts->localize('postbox', 'postBoxL10n', array( |
|
506 | + 'postBoxEmptyString' => __('Drag boxes here'), |
|
507 | + )); |
|
508 | 508 | |
509 | - $scripts->add( 'tags-box', "/wp-admin/js/tags-box$suffix.js", array( 'jquery', 'suggest' ), false, 1 ); |
|
510 | - did_action( 'init' ) && $scripts->localize( 'tags-box', 'tagsBoxL10n', array( |
|
511 | - 'tagDelimiter' => _x( ',', 'tag delimiter' ), |
|
512 | - ) ); |
|
509 | + $scripts->add('tags-box', "/wp-admin/js/tags-box$suffix.js", array('jquery', 'suggest'), false, 1); |
|
510 | + did_action('init') && $scripts->localize('tags-box', 'tagsBoxL10n', array( |
|
511 | + 'tagDelimiter' => _x(',', 'tag delimiter'), |
|
512 | + )); |
|
513 | 513 | |
514 | - $scripts->add( 'post', "/wp-admin/js/post$suffix.js", array( 'suggest', 'wp-lists', 'postbox', 'tags-box', 'underscore', 'word-count', 'wp-a11y' ), false, 1 ); |
|
515 | - did_action( 'init' ) && $scripts->localize( 'post', 'postL10n', array( |
|
514 | + $scripts->add('post', "/wp-admin/js/post$suffix.js", array('suggest', 'wp-lists', 'postbox', 'tags-box', 'underscore', 'word-count', 'wp-a11y'), false, 1); |
|
515 | + did_action('init') && $scripts->localize('post', 'postL10n', array( |
|
516 | 516 | 'ok' => __('OK'), |
517 | 517 | 'cancel' => __('Cancel'), |
518 | 518 | 'publishOn' => __('Publish on:'), |
@@ -535,133 +535,133 @@ discard block |
||
535 | 535 | 'published' => __('Published'), |
536 | 536 | 'saveAlert' => __('The changes you made will be lost if you navigate away from this page.'), |
537 | 537 | 'savingText' => __('Saving Draft…'), |
538 | - 'permalinkSaved' => __( 'Permalink saved' ), |
|
539 | - ) ); |
|
540 | - |
|
541 | - $scripts->add( 'press-this', "/wp-admin/js/press-this$suffix.js", array( 'jquery', 'tags-box' ), false, 1 ); |
|
542 | - did_action( 'init' ) && $scripts->localize( 'press-this', 'pressThisL10n', array( |
|
543 | - 'newPost' => __( 'Title' ), |
|
544 | - 'serverError' => __( 'Connection lost or the server is busy. Please try again later.' ), |
|
545 | - 'saveAlert' => __( 'The changes you made will be lost if you navigate away from this page.' ), |
|
538 | + 'permalinkSaved' => __('Permalink saved'), |
|
539 | + )); |
|
540 | + |
|
541 | + $scripts->add('press-this', "/wp-admin/js/press-this$suffix.js", array('jquery', 'tags-box'), false, 1); |
|
542 | + did_action('init') && $scripts->localize('press-this', 'pressThisL10n', array( |
|
543 | + 'newPost' => __('Title'), |
|
544 | + 'serverError' => __('Connection lost or the server is busy. Please try again later.'), |
|
545 | + 'saveAlert' => __('The changes you made will be lost if you navigate away from this page.'), |
|
546 | 546 | /* translators: %d: nth embed found in a post */ |
547 | - 'suggestedEmbedAlt' => __( 'Suggested embed #%d' ), |
|
547 | + 'suggestedEmbedAlt' => __('Suggested embed #%d'), |
|
548 | 548 | /* translators: %d: nth image found in a post */ |
549 | - 'suggestedImgAlt' => __( 'Suggested image #%d' ), |
|
550 | - ) ); |
|
549 | + 'suggestedImgAlt' => __('Suggested image #%d'), |
|
550 | + )); |
|
551 | 551 | |
552 | - $scripts->add( 'editor-expand', "/wp-admin/js/editor-expand$suffix.js", array( 'jquery' ), false, 1 ); |
|
552 | + $scripts->add('editor-expand', "/wp-admin/js/editor-expand$suffix.js", array('jquery'), false, 1); |
|
553 | 553 | |
554 | - $scripts->add( 'link', "/wp-admin/js/link$suffix.js", array( 'wp-lists', 'postbox' ), false, 1 ); |
|
554 | + $scripts->add('link', "/wp-admin/js/link$suffix.js", array('wp-lists', 'postbox'), false, 1); |
|
555 | 555 | |
556 | - $scripts->add( 'comment', "/wp-admin/js/comment$suffix.js", array( 'jquery', 'postbox' ) ); |
|
557 | - $scripts->add_data( 'comment', 'group', 1 ); |
|
558 | - did_action( 'init' ) && $scripts->localize( 'comment', 'commentL10n', array( |
|
559 | - 'submittedOn' => __( 'Submitted on:' ), |
|
556 | + $scripts->add('comment', "/wp-admin/js/comment$suffix.js", array('jquery', 'postbox')); |
|
557 | + $scripts->add_data('comment', 'group', 1); |
|
558 | + did_action('init') && $scripts->localize('comment', 'commentL10n', array( |
|
559 | + 'submittedOn' => __('Submitted on:'), |
|
560 | 560 | /* translators: 1: month, 2: day, 3: year, 4: hour, 5: minute */ |
561 | - 'dateFormat' => __( '%1$s %2$s, %3$s @ %4$s:%5$s' ) |
|
562 | - ) ); |
|
563 | - |
|
564 | - $scripts->add( 'admin-gallery', "/wp-admin/js/gallery$suffix.js", array( 'jquery-ui-sortable' ) ); |
|
565 | - |
|
566 | - $scripts->add( 'admin-widgets', "/wp-admin/js/widgets$suffix.js", array( 'jquery-ui-sortable', 'jquery-ui-draggable', 'jquery-ui-droppable' ), false, 1 ); |
|
567 | - |
|
568 | - $scripts->add( 'theme', "/wp-admin/js/theme$suffix.js", array( 'wp-backbone', 'wp-a11y' ), false, 1 ); |
|
569 | - |
|
570 | - $scripts->add( 'inline-edit-post', "/wp-admin/js/inline-edit-post$suffix.js", array( 'jquery', 'suggest', 'wp-a11y' ), false, 1 ); |
|
571 | - did_action( 'init' ) && $scripts->localize( 'inline-edit-post', 'inlineEditL10n', array( |
|
572 | - 'error' => __( 'Error while saving the changes.' ), |
|
573 | - 'ntdeltitle' => __( 'Remove From Bulk Edit' ), |
|
574 | - 'notitle' => __( '(no title)' ), |
|
575 | - 'comma' => trim( _x( ',', 'tag delimiter' ) ), |
|
576 | - 'saved' => __( 'Changes saved.' ), |
|
577 | - ) ); |
|
578 | - |
|
579 | - $scripts->add( 'inline-edit-tax', "/wp-admin/js/inline-edit-tax$suffix.js", array( 'jquery', 'wp-a11y' ), false, 1 ); |
|
580 | - did_action( 'init' ) && $scripts->localize( 'inline-edit-tax', 'inlineEditL10n', array( |
|
581 | - 'error' => __( 'Error while saving the changes.' ), |
|
582 | - 'saved' => __( 'Changes saved.' ), |
|
583 | - ) ); |
|
584 | - |
|
585 | - $scripts->add( 'plugin-install', "/wp-admin/js/plugin-install$suffix.js", array( 'jquery', 'jquery-ui-core', 'thickbox' ), false, 1 ); |
|
586 | - did_action( 'init' ) && $scripts->localize( 'plugin-install', 'plugininstallL10n', array( |
|
587 | - 'plugin_information' => __( 'Plugin:' ), |
|
588 | - 'plugin_modal_label' => __( 'Plugin details' ), |
|
561 | + 'dateFormat' => __('%1$s %2$s, %3$s @ %4$s:%5$s') |
|
562 | + )); |
|
563 | + |
|
564 | + $scripts->add('admin-gallery', "/wp-admin/js/gallery$suffix.js", array('jquery-ui-sortable')); |
|
565 | + |
|
566 | + $scripts->add('admin-widgets', "/wp-admin/js/widgets$suffix.js", array('jquery-ui-sortable', 'jquery-ui-draggable', 'jquery-ui-droppable'), false, 1); |
|
567 | + |
|
568 | + $scripts->add('theme', "/wp-admin/js/theme$suffix.js", array('wp-backbone', 'wp-a11y'), false, 1); |
|
569 | + |
|
570 | + $scripts->add('inline-edit-post', "/wp-admin/js/inline-edit-post$suffix.js", array('jquery', 'suggest', 'wp-a11y'), false, 1); |
|
571 | + did_action('init') && $scripts->localize('inline-edit-post', 'inlineEditL10n', array( |
|
572 | + 'error' => __('Error while saving the changes.'), |
|
573 | + 'ntdeltitle' => __('Remove From Bulk Edit'), |
|
574 | + 'notitle' => __('(no title)'), |
|
575 | + 'comma' => trim(_x(',', 'tag delimiter')), |
|
576 | + 'saved' => __('Changes saved.'), |
|
577 | + )); |
|
578 | + |
|
579 | + $scripts->add('inline-edit-tax', "/wp-admin/js/inline-edit-tax$suffix.js", array('jquery', 'wp-a11y'), false, 1); |
|
580 | + did_action('init') && $scripts->localize('inline-edit-tax', 'inlineEditL10n', array( |
|
581 | + 'error' => __('Error while saving the changes.'), |
|
582 | + 'saved' => __('Changes saved.'), |
|
583 | + )); |
|
584 | + |
|
585 | + $scripts->add('plugin-install', "/wp-admin/js/plugin-install$suffix.js", array('jquery', 'jquery-ui-core', 'thickbox'), false, 1); |
|
586 | + did_action('init') && $scripts->localize('plugin-install', 'plugininstallL10n', array( |
|
587 | + 'plugin_information' => __('Plugin:'), |
|
588 | + 'plugin_modal_label' => __('Plugin details'), |
|
589 | 589 | 'ays' => __('Are you sure you want to install this plugin?') |
590 | - ) ); |
|
590 | + )); |
|
591 | 591 | |
592 | - $scripts->add( 'updates', "/wp-admin/js/updates$suffix.js", array( 'jquery', 'wp-util', 'wp-a11y' ) ); |
|
593 | - did_action( 'init' ) && $scripts->localize( 'updates', '_wpUpdatesSettings', array( |
|
594 | - 'ajax_nonce' => wp_create_nonce( 'updates' ), |
|
592 | + $scripts->add('updates', "/wp-admin/js/updates$suffix.js", array('jquery', 'wp-util', 'wp-a11y')); |
|
593 | + did_action('init') && $scripts->localize('updates', '_wpUpdatesSettings', array( |
|
594 | + 'ajax_nonce' => wp_create_nonce('updates'), |
|
595 | 595 | 'l10n' => array( |
596 | - 'updating' => __( 'Updating...' ), // no ellipsis |
|
597 | - 'updated' => __( 'Updated!' ), |
|
598 | - 'updateFailedShort' => __( 'Update Failed!' ), |
|
596 | + 'updating' => __('Updating...'), // no ellipsis |
|
597 | + 'updated' => __('Updated!'), |
|
598 | + 'updateFailedShort' => __('Update Failed!'), |
|
599 | 599 | /* translators: Error string for a failed update */ |
600 | - 'updateFailed' => __( 'Update Failed: %s' ), |
|
600 | + 'updateFailed' => __('Update Failed: %s'), |
|
601 | 601 | /* translators: Plugin name and version */ |
602 | - 'updatingLabel' => __( 'Updating %s...' ), // no ellipsis |
|
602 | + 'updatingLabel' => __('Updating %s...'), // no ellipsis |
|
603 | 603 | /* translators: Plugin name and version */ |
604 | - 'updatedLabel' => __( '%s updated!' ), |
|
604 | + 'updatedLabel' => __('%s updated!'), |
|
605 | 605 | /* translators: Plugin name and version */ |
606 | - 'updateFailedLabel' => __( '%s update failed' ), |
|
606 | + 'updateFailedLabel' => __('%s update failed'), |
|
607 | 607 | /* translators: JavaScript accessible string */ |
608 | - 'updatingMsg' => __( 'Updating... please wait.' ), // no ellipsis |
|
608 | + 'updatingMsg' => __('Updating... please wait.'), // no ellipsis |
|
609 | 609 | /* translators: JavaScript accessible string */ |
610 | - 'updatedMsg' => __( 'Update completed successfully.' ), |
|
610 | + 'updatedMsg' => __('Update completed successfully.'), |
|
611 | 611 | /* translators: JavaScript accessible string */ |
612 | - 'updateCancel' => __( 'Update canceled.' ), |
|
613 | - 'beforeunload' => __( 'Plugin updates may not complete if you navigate away from this page.' ), |
|
612 | + 'updateCancel' => __('Update canceled.'), |
|
613 | + 'beforeunload' => __('Plugin updates may not complete if you navigate away from this page.'), |
|
614 | 614 | ) |
615 | - ) ); |
|
615 | + )); |
|
616 | 616 | |
617 | - $scripts->add( 'farbtastic', '/wp-admin/js/farbtastic.js', array('jquery'), '1.2' ); |
|
617 | + $scripts->add('farbtastic', '/wp-admin/js/farbtastic.js', array('jquery'), '1.2'); |
|
618 | 618 | |
619 | - $scripts->add( 'iris', '/wp-admin/js/iris.min.js', array( 'jquery-ui-draggable', 'jquery-ui-slider', 'jquery-touch-punch' ), '1.0.7', 1 ); |
|
620 | - $scripts->add( 'wp-color-picker', "/wp-admin/js/color-picker$suffix.js", array( 'iris' ), false, 1 ); |
|
621 | - did_action( 'init' ) && $scripts->localize( 'wp-color-picker', 'wpColorPickerL10n', array( |
|
622 | - 'clear' => __( 'Clear' ), |
|
623 | - 'defaultString' => __( 'Default' ), |
|
624 | - 'pick' => __( 'Select Color' ), |
|
625 | - 'current' => __( 'Current Color' ), |
|
626 | - ) ); |
|
619 | + $scripts->add('iris', '/wp-admin/js/iris.min.js', array('jquery-ui-draggable', 'jquery-ui-slider', 'jquery-touch-punch'), '1.0.7', 1); |
|
620 | + $scripts->add('wp-color-picker', "/wp-admin/js/color-picker$suffix.js", array('iris'), false, 1); |
|
621 | + did_action('init') && $scripts->localize('wp-color-picker', 'wpColorPickerL10n', array( |
|
622 | + 'clear' => __('Clear'), |
|
623 | + 'defaultString' => __('Default'), |
|
624 | + 'pick' => __('Select Color'), |
|
625 | + 'current' => __('Current Color'), |
|
626 | + )); |
|
627 | 627 | |
628 | - $scripts->add( 'dashboard', "/wp-admin/js/dashboard$suffix.js", array( 'jquery', 'admin-comments', 'postbox' ), false, 1 ); |
|
628 | + $scripts->add('dashboard', "/wp-admin/js/dashboard$suffix.js", array('jquery', 'admin-comments', 'postbox'), false, 1); |
|
629 | 629 | |
630 | - $scripts->add( 'list-revisions', "/wp-includes/js/wp-list-revisions$suffix.js" ); |
|
630 | + $scripts->add('list-revisions', "/wp-includes/js/wp-list-revisions$suffix.js"); |
|
631 | 631 | |
632 | - $scripts->add( 'media-grid', "/wp-includes/js/media-grid$suffix.js", array( 'media-editor' ), false, 1 ); |
|
633 | - $scripts->add( 'media', "/wp-admin/js/media$suffix.js", array( 'jquery' ), false, 1 ); |
|
634 | - did_action( 'init' ) && $scripts->localize( 'media', 'attachMediaBoxL10n', array( |
|
635 | - 'error' => __( 'An error has occurred. Please reload the page and try again.' ), |
|
632 | + $scripts->add('media-grid', "/wp-includes/js/media-grid$suffix.js", array('media-editor'), false, 1); |
|
633 | + $scripts->add('media', "/wp-admin/js/media$suffix.js", array('jquery'), false, 1); |
|
634 | + did_action('init') && $scripts->localize('media', 'attachMediaBoxL10n', array( |
|
635 | + 'error' => __('An error has occurred. Please reload the page and try again.'), |
|
636 | 636 | )); |
637 | 637 | |
638 | - $scripts->add( 'image-edit', "/wp-admin/js/image-edit$suffix.js", array('jquery', 'json2', 'imgareaselect'), false, 1 ); |
|
639 | - did_action( 'init' ) && $scripts->localize( 'image-edit', 'imageEditL10n', array( |
|
640 | - 'error' => __( 'Could not load the preview image. Please reload the page and try again.' ) |
|
638 | + $scripts->add('image-edit', "/wp-admin/js/image-edit$suffix.js", array('jquery', 'json2', 'imgareaselect'), false, 1); |
|
639 | + did_action('init') && $scripts->localize('image-edit', 'imageEditL10n', array( |
|
640 | + 'error' => __('Could not load the preview image. Please reload the page and try again.') |
|
641 | 641 | )); |
642 | 642 | |
643 | - $scripts->add( 'set-post-thumbnail', "/wp-admin/js/set-post-thumbnail$suffix.js", array( 'jquery' ), false, 1 ); |
|
644 | - did_action( 'init' ) && $scripts->localize( 'set-post-thumbnail', 'setPostThumbnailL10n', array( |
|
645 | - 'setThumbnail' => __( 'Use as featured image' ), |
|
646 | - 'saving' => __( 'Saving...' ), // no ellipsis |
|
647 | - 'error' => __( 'Could not set that as the thumbnail image. Try a different attachment.' ), |
|
648 | - 'done' => __( 'Done' ) |
|
649 | - ) ); |
|
643 | + $scripts->add('set-post-thumbnail', "/wp-admin/js/set-post-thumbnail$suffix.js", array('jquery'), false, 1); |
|
644 | + did_action('init') && $scripts->localize('set-post-thumbnail', 'setPostThumbnailL10n', array( |
|
645 | + 'setThumbnail' => __('Use as featured image'), |
|
646 | + 'saving' => __('Saving...'), // no ellipsis |
|
647 | + 'error' => __('Could not set that as the thumbnail image. Try a different attachment.'), |
|
648 | + 'done' => __('Done') |
|
649 | + )); |
|
650 | 650 | |
651 | 651 | // Navigation Menus |
652 | - $scripts->add( 'nav-menu', "/wp-admin/js/nav-menu$suffix.js", array( 'jquery-ui-sortable', 'jquery-ui-draggable', 'jquery-ui-droppable', 'wp-lists', 'postbox', 'json2' ) ); |
|
653 | - did_action( 'init' ) && $scripts->localize( 'nav-menu', 'navMenuL10n', array( |
|
654 | - 'noResultsFound' => __( 'No results found.' ), |
|
655 | - 'warnDeleteMenu' => __( "You are about to permanently delete this menu. \n 'Cancel' to stop, 'OK' to delete." ), |
|
656 | - 'saveAlert' => __( 'The changes you made will be lost if you navigate away from this page.' ), |
|
657 | - 'untitled' => _x( '(no label)', 'missing menu item navigation label' ) |
|
658 | - ) ); |
|
659 | - |
|
660 | - $scripts->add( 'custom-header', "/wp-admin/js/custom-header.js", array( 'jquery-masonry' ), false, 1 ); |
|
661 | - $scripts->add( 'custom-background', "/wp-admin/js/custom-background$suffix.js", array( 'wp-color-picker', 'media-views' ), false, 1 ); |
|
662 | - $scripts->add( 'media-gallery', "/wp-admin/js/media-gallery$suffix.js", array('jquery'), false, 1 ); |
|
663 | - |
|
664 | - $scripts->add( 'svg-painter', '/wp-admin/js/svg-painter.js', array( 'jquery' ), false, 1 ); |
|
652 | + $scripts->add('nav-menu', "/wp-admin/js/nav-menu$suffix.js", array('jquery-ui-sortable', 'jquery-ui-draggable', 'jquery-ui-droppable', 'wp-lists', 'postbox', 'json2')); |
|
653 | + did_action('init') && $scripts->localize('nav-menu', 'navMenuL10n', array( |
|
654 | + 'noResultsFound' => __('No results found.'), |
|
655 | + 'warnDeleteMenu' => __("You are about to permanently delete this menu. \n 'Cancel' to stop, 'OK' to delete."), |
|
656 | + 'saveAlert' => __('The changes you made will be lost if you navigate away from this page.'), |
|
657 | + 'untitled' => _x('(no label)', 'missing menu item navigation label') |
|
658 | + )); |
|
659 | + |
|
660 | + $scripts->add('custom-header', "/wp-admin/js/custom-header.js", array('jquery-masonry'), false, 1); |
|
661 | + $scripts->add('custom-background', "/wp-admin/js/custom-background$suffix.js", array('wp-color-picker', 'media-views'), false, 1); |
|
662 | + $scripts->add('media-gallery', "/wp-admin/js/media-gallery$suffix.js", array('jquery'), false, 1); |
|
663 | + |
|
664 | + $scripts->add('svg-painter', '/wp-admin/js/svg-painter.js', array('jquery'), false, 1); |
|
665 | 665 | } |
666 | 666 | } |
667 | 667 | |
@@ -680,19 +680,19 @@ discard block |
||
680 | 680 | * |
681 | 681 | * @param WP_Styles $styles |
682 | 682 | */ |
683 | -function wp_default_styles( &$styles ) { |
|
684 | - include( ABSPATH . WPINC . '/version.php' ); // include an unmodified $wp_version |
|
683 | +function wp_default_styles(&$styles) { |
|
684 | + include(ABSPATH.WPINC.'/version.php'); // include an unmodified $wp_version |
|
685 | 685 | |
686 | - if ( ! defined( 'SCRIPT_DEBUG' ) ) |
|
687 | - define( 'SCRIPT_DEBUG', false !== strpos( $wp_version, '-src' ) ); |
|
686 | + if ( ! defined('SCRIPT_DEBUG')) |
|
687 | + define('SCRIPT_DEBUG', false !== strpos($wp_version, '-src')); |
|
688 | 688 | |
689 | - if ( ! $guessurl = site_url() ) |
|
689 | + if ( ! $guessurl = site_url()) |
|
690 | 690 | $guessurl = wp_guess_url(); |
691 | 691 | |
692 | 692 | $styles->base_url = $guessurl; |
693 | - $styles->content_url = defined('WP_CONTENT_URL')? WP_CONTENT_URL : ''; |
|
694 | - $styles->default_version = get_bloginfo( 'version' ); |
|
695 | - $styles->text_direction = function_exists( 'is_rtl' ) && is_rtl() ? 'rtl' : 'ltr'; |
|
693 | + $styles->content_url = defined('WP_CONTENT_URL') ? WP_CONTENT_URL : ''; |
|
694 | + $styles->default_version = get_bloginfo('version'); |
|
695 | + $styles->text_direction = function_exists('is_rtl') && is_rtl() ? 'rtl' : 'ltr'; |
|
696 | 696 | $styles->default_dirs = array('/wp-admin/', '/wp-includes/css/'); |
697 | 697 | |
698 | 698 | $open_sans_font_url = ''; |
@@ -700,19 +700,19 @@ discard block |
||
700 | 700 | /* translators: If there are characters in your language that are not supported |
701 | 701 | * by Open Sans, translate this to 'off'. Do not translate into your own language. |
702 | 702 | */ |
703 | - if ( 'off' !== _x( 'on', 'Open Sans font: on or off' ) ) { |
|
703 | + if ('off' !== _x('on', 'Open Sans font: on or off')) { |
|
704 | 704 | $subsets = 'latin,latin-ext'; |
705 | 705 | |
706 | 706 | /* translators: To add an additional Open Sans character subset specific to your language, |
707 | 707 | * translate this to 'greek', 'cyrillic' or 'vietnamese'. Do not translate into your own language. |
708 | 708 | */ |
709 | - $subset = _x( 'no-subset', 'Open Sans font: add new subset (greek, cyrillic, vietnamese)' ); |
|
709 | + $subset = _x('no-subset', 'Open Sans font: add new subset (greek, cyrillic, vietnamese)'); |
|
710 | 710 | |
711 | - if ( 'cyrillic' == $subset ) { |
|
711 | + if ('cyrillic' == $subset) { |
|
712 | 712 | $subsets .= ',cyrillic,cyrillic-ext'; |
713 | - } elseif ( 'greek' == $subset ) { |
|
713 | + } elseif ('greek' == $subset) { |
|
714 | 714 | $subsets .= ',greek,greek-ext'; |
715 | - } elseif ( 'vietnamese' == $subset ) { |
|
715 | + } elseif ('vietnamese' == $subset) { |
|
716 | 716 | $subsets .= ',vietnamese'; |
717 | 717 | } |
718 | 718 | |
@@ -721,66 +721,66 @@ discard block |
||
721 | 721 | } |
722 | 722 | |
723 | 723 | // Register a stylesheet for the selected admin color scheme. |
724 | - $styles->add( 'colors', true, array( 'wp-admin', 'buttons' ) ); |
|
724 | + $styles->add('colors', true, array('wp-admin', 'buttons')); |
|
725 | 725 | |
726 | 726 | $suffix = SCRIPT_DEBUG ? '' : '.min'; |
727 | 727 | |
728 | 728 | // Admin CSS |
729 | - $styles->add( 'common', "/wp-admin/css/common$suffix.css" ); |
|
730 | - $styles->add( 'forms', "/wp-admin/css/forms$suffix.css" ); |
|
731 | - $styles->add( 'admin-menu', "/wp-admin/css/admin-menu$suffix.css" ); |
|
732 | - $styles->add( 'dashboard', "/wp-admin/css/dashboard$suffix.css" ); |
|
733 | - $styles->add( 'list-tables', "/wp-admin/css/list-tables$suffix.css" ); |
|
734 | - $styles->add( 'edit', "/wp-admin/css/edit$suffix.css" ); |
|
735 | - $styles->add( 'revisions', "/wp-admin/css/revisions$suffix.css" ); |
|
736 | - $styles->add( 'media', "/wp-admin/css/media$suffix.css" ); |
|
737 | - $styles->add( 'themes', "/wp-admin/css/themes$suffix.css" ); |
|
738 | - $styles->add( 'about', "/wp-admin/css/about$suffix.css" ); |
|
739 | - $styles->add( 'nav-menus', "/wp-admin/css/nav-menus$suffix.css" ); |
|
740 | - $styles->add( 'widgets', "/wp-admin/css/widgets$suffix.css" ); |
|
741 | - $styles->add( 'site-icon', "/wp-admin/css/site-icon$suffix.css" ); |
|
742 | - $styles->add( 'l10n', "/wp-admin/css/l10n$suffix.css" ); |
|
743 | - |
|
744 | - $styles->add( 'wp-admin', false, array( 'open-sans', 'dashicons', 'common', 'forms', 'admin-menu', 'dashboard', 'list-tables', 'edit', 'revisions', 'media', 'themes', 'about', 'nav-menus', 'widgets', 'site-icon', 'l10n' ) ); |
|
745 | - |
|
746 | - $styles->add( 'login', "/wp-admin/css/login$suffix.css", array( 'open-sans', 'dashicons', 'buttons', 'forms', 'l10n' ) ); |
|
747 | - $styles->add( 'install', "/wp-admin/css/install$suffix.css", array( 'open-sans', 'buttons' ) ); |
|
748 | - $styles->add( 'wp-color-picker', "/wp-admin/css/color-picker$suffix.css" ); |
|
749 | - $styles->add( 'customize-controls', "/wp-admin/css/customize-controls$suffix.css", array( 'wp-admin', 'colors', 'ie', 'imgareaselect' ) ); |
|
750 | - $styles->add( 'customize-widgets', "/wp-admin/css/customize-widgets$suffix.css", array( 'wp-admin', 'colors' ) ); |
|
751 | - $styles->add( 'customize-nav-menus', "/wp-admin/css/customize-nav-menus$suffix.css", array( 'wp-admin', 'colors' ) ); |
|
752 | - $styles->add( 'press-this', "/wp-admin/css/press-this$suffix.css", array( 'open-sans', 'buttons' ) ); |
|
753 | - |
|
754 | - $styles->add( 'ie', "/wp-admin/css/ie$suffix.css" ); |
|
755 | - $styles->add_data( 'ie', 'conditional', 'lte IE 7' ); |
|
729 | + $styles->add('common', "/wp-admin/css/common$suffix.css"); |
|
730 | + $styles->add('forms', "/wp-admin/css/forms$suffix.css"); |
|
731 | + $styles->add('admin-menu', "/wp-admin/css/admin-menu$suffix.css"); |
|
732 | + $styles->add('dashboard', "/wp-admin/css/dashboard$suffix.css"); |
|
733 | + $styles->add('list-tables', "/wp-admin/css/list-tables$suffix.css"); |
|
734 | + $styles->add('edit', "/wp-admin/css/edit$suffix.css"); |
|
735 | + $styles->add('revisions', "/wp-admin/css/revisions$suffix.css"); |
|
736 | + $styles->add('media', "/wp-admin/css/media$suffix.css"); |
|
737 | + $styles->add('themes', "/wp-admin/css/themes$suffix.css"); |
|
738 | + $styles->add('about', "/wp-admin/css/about$suffix.css"); |
|
739 | + $styles->add('nav-menus', "/wp-admin/css/nav-menus$suffix.css"); |
|
740 | + $styles->add('widgets', "/wp-admin/css/widgets$suffix.css"); |
|
741 | + $styles->add('site-icon', "/wp-admin/css/site-icon$suffix.css"); |
|
742 | + $styles->add('l10n', "/wp-admin/css/l10n$suffix.css"); |
|
743 | + |
|
744 | + $styles->add('wp-admin', false, array('open-sans', 'dashicons', 'common', 'forms', 'admin-menu', 'dashboard', 'list-tables', 'edit', 'revisions', 'media', 'themes', 'about', 'nav-menus', 'widgets', 'site-icon', 'l10n')); |
|
745 | + |
|
746 | + $styles->add('login', "/wp-admin/css/login$suffix.css", array('open-sans', 'dashicons', 'buttons', 'forms', 'l10n')); |
|
747 | + $styles->add('install', "/wp-admin/css/install$suffix.css", array('open-sans', 'buttons')); |
|
748 | + $styles->add('wp-color-picker', "/wp-admin/css/color-picker$suffix.css"); |
|
749 | + $styles->add('customize-controls', "/wp-admin/css/customize-controls$suffix.css", array('wp-admin', 'colors', 'ie', 'imgareaselect')); |
|
750 | + $styles->add('customize-widgets', "/wp-admin/css/customize-widgets$suffix.css", array('wp-admin', 'colors')); |
|
751 | + $styles->add('customize-nav-menus', "/wp-admin/css/customize-nav-menus$suffix.css", array('wp-admin', 'colors')); |
|
752 | + $styles->add('press-this', "/wp-admin/css/press-this$suffix.css", array('open-sans', 'buttons')); |
|
753 | + |
|
754 | + $styles->add('ie', "/wp-admin/css/ie$suffix.css"); |
|
755 | + $styles->add_data('ie', 'conditional', 'lte IE 7'); |
|
756 | 756 | |
757 | 757 | // Common dependencies |
758 | - $styles->add( 'buttons', "/wp-includes/css/buttons$suffix.css" ); |
|
759 | - $styles->add( 'dashicons', "/wp-includes/css/dashicons$suffix.css" ); |
|
760 | - $styles->add( 'open-sans', $open_sans_font_url ); |
|
758 | + $styles->add('buttons', "/wp-includes/css/buttons$suffix.css"); |
|
759 | + $styles->add('dashicons', "/wp-includes/css/dashicons$suffix.css"); |
|
760 | + $styles->add('open-sans', $open_sans_font_url); |
|
761 | 761 | |
762 | 762 | // Includes CSS |
763 | - $styles->add( 'admin-bar', "/wp-includes/css/admin-bar$suffix.css", array( 'open-sans', 'dashicons' ) ); |
|
764 | - $styles->add( 'wp-auth-check', "/wp-includes/css/wp-auth-check$suffix.css", array( 'dashicons' ) ); |
|
765 | - $styles->add( 'editor-buttons', "/wp-includes/css/editor$suffix.css", array( 'dashicons' ) ); |
|
766 | - $styles->add( 'media-views', "/wp-includes/css/media-views$suffix.css", array( 'buttons', 'dashicons', 'wp-mediaelement' ) ); |
|
767 | - $styles->add( 'wp-pointer', "/wp-includes/css/wp-pointer$suffix.css", array( 'dashicons' ) ); |
|
768 | - $styles->add( 'customize-preview', "/wp-includes/css/customize-preview$suffix.css" ); |
|
769 | - $styles->add( 'wp-embed-template-ie', "/wp-includes/css/wp-embed-template-ie$suffix.css" ); |
|
770 | - $styles->add_data( 'wp-embed-template-ie', 'conditional', 'lte IE 8' ); |
|
763 | + $styles->add('admin-bar', "/wp-includes/css/admin-bar$suffix.css", array('open-sans', 'dashicons')); |
|
764 | + $styles->add('wp-auth-check', "/wp-includes/css/wp-auth-check$suffix.css", array('dashicons')); |
|
765 | + $styles->add('editor-buttons', "/wp-includes/css/editor$suffix.css", array('dashicons')); |
|
766 | + $styles->add('media-views', "/wp-includes/css/media-views$suffix.css", array('buttons', 'dashicons', 'wp-mediaelement')); |
|
767 | + $styles->add('wp-pointer', "/wp-includes/css/wp-pointer$suffix.css", array('dashicons')); |
|
768 | + $styles->add('customize-preview', "/wp-includes/css/customize-preview$suffix.css"); |
|
769 | + $styles->add('wp-embed-template-ie', "/wp-includes/css/wp-embed-template-ie$suffix.css"); |
|
770 | + $styles->add_data('wp-embed-template-ie', 'conditional', 'lte IE 8'); |
|
771 | 771 | |
772 | 772 | // External libraries and friends |
773 | - $styles->add( 'imgareaselect', '/wp-includes/js/imgareaselect/imgareaselect.css', array(), '0.9.8' ); |
|
774 | - $styles->add( 'wp-jquery-ui-dialog', "/wp-includes/css/jquery-ui-dialog$suffix.css", array( 'dashicons' ) ); |
|
775 | - $styles->add( 'mediaelement', "/wp-includes/js/mediaelement/mediaelementplayer.min.css", array(), '2.18.1' ); |
|
776 | - $styles->add( 'wp-mediaelement', "/wp-includes/js/mediaelement/wp-mediaelement$suffix.css", array( 'mediaelement' ) ); |
|
777 | - $styles->add( 'thickbox', '/wp-includes/js/thickbox/thickbox.css', array( 'dashicons' ) ); |
|
773 | + $styles->add('imgareaselect', '/wp-includes/js/imgareaselect/imgareaselect.css', array(), '0.9.8'); |
|
774 | + $styles->add('wp-jquery-ui-dialog', "/wp-includes/css/jquery-ui-dialog$suffix.css", array('dashicons')); |
|
775 | + $styles->add('mediaelement', "/wp-includes/js/mediaelement/mediaelementplayer.min.css", array(), '2.18.1'); |
|
776 | + $styles->add('wp-mediaelement', "/wp-includes/js/mediaelement/wp-mediaelement$suffix.css", array('mediaelement')); |
|
777 | + $styles->add('thickbox', '/wp-includes/js/thickbox/thickbox.css', array('dashicons')); |
|
778 | 778 | |
779 | 779 | // Deprecated CSS |
780 | - $styles->add( 'deprecated-media', "/wp-admin/css/deprecated-media$suffix.css" ); |
|
781 | - $styles->add( 'farbtastic', "/wp-admin/css/farbtastic$suffix.css", array(), '1.3u1' ); |
|
782 | - $styles->add( 'jcrop', "/wp-includes/js/jcrop/jquery.Jcrop.min.css", array(), '0.9.12' ); |
|
783 | - $styles->add( 'colors-fresh', false, array( 'wp-admin', 'buttons' ) ); // Old handle. |
|
780 | + $styles->add('deprecated-media', "/wp-admin/css/deprecated-media$suffix.css"); |
|
781 | + $styles->add('farbtastic', "/wp-admin/css/farbtastic$suffix.css", array(), '1.3u1'); |
|
782 | + $styles->add('jcrop', "/wp-includes/js/jcrop/jquery.Jcrop.min.css", array(), '0.9.12'); |
|
783 | + $styles->add('colors-fresh', false, array('wp-admin', 'buttons')); // Old handle. |
|
784 | 784 | |
785 | 785 | // RTL CSS |
786 | 786 | $rtl_styles = array( |
@@ -795,10 +795,10 @@ discard block |
||
795 | 795 | 'deprecated-media', 'farbtastic', |
796 | 796 | ); |
797 | 797 | |
798 | - foreach ( $rtl_styles as $rtl_style ) { |
|
799 | - $styles->add_data( $rtl_style, 'rtl', 'replace' ); |
|
800 | - if ( $suffix ) { |
|
801 | - $styles->add_data( $rtl_style, 'suffix', $suffix ); |
|
798 | + foreach ($rtl_styles as $rtl_style) { |
|
799 | + $styles->add_data($rtl_style, 'rtl', 'replace'); |
|
800 | + if ($suffix) { |
|
801 | + $styles->add_data($rtl_style, 'suffix', $suffix); |
|
802 | 802 | } |
803 | 803 | } |
804 | 804 | } |
@@ -811,19 +811,19 @@ discard block |
||
811 | 811 | * @param array $js_array JavaScript scripts array |
812 | 812 | * @return array Reordered array, if needed. |
813 | 813 | */ |
814 | -function wp_prototype_before_jquery( $js_array ) { |
|
815 | - if ( false === $prototype = array_search( 'prototype', $js_array, true ) ) |
|
814 | +function wp_prototype_before_jquery($js_array) { |
|
815 | + if (false === $prototype = array_search('prototype', $js_array, true)) |
|
816 | 816 | return $js_array; |
817 | 817 | |
818 | - if ( false === $jquery = array_search( 'jquery', $js_array, true ) ) |
|
818 | + if (false === $jquery = array_search('jquery', $js_array, true)) |
|
819 | 819 | return $js_array; |
820 | 820 | |
821 | - if ( $prototype < $jquery ) |
|
821 | + if ($prototype < $jquery) |
|
822 | 822 | return $js_array; |
823 | 823 | |
824 | 824 | unset($js_array[$prototype]); |
825 | 825 | |
826 | - array_splice( $js_array, $jquery, 0, 'prototype' ); |
|
826 | + array_splice($js_array, $jquery, 0, 'prototype'); |
|
827 | 827 | |
828 | 828 | return $js_array; |
829 | 829 | } |
@@ -837,10 +837,10 @@ discard block |
||
837 | 837 | */ |
838 | 838 | function wp_just_in_time_script_localization() { |
839 | 839 | |
840 | - wp_localize_script( 'autosave', 'autosaveL10n', array( |
|
840 | + wp_localize_script('autosave', 'autosaveL10n', array( |
|
841 | 841 | 'autosaveInterval' => AUTOSAVE_INTERVAL, |
842 | 842 | 'blog_id' => get_current_blog_id(), |
843 | - ) ); |
|
843 | + )); |
|
844 | 844 | |
845 | 845 | } |
846 | 846 | |
@@ -864,29 +864,29 @@ discard block |
||
864 | 864 | * @param string $handle Either 'colors' or 'colors-rtl'. |
865 | 865 | * @return string|false URL path to CSS stylesheet for Administration Screens. |
866 | 866 | */ |
867 | -function wp_style_loader_src( $src, $handle ) { |
|
867 | +function wp_style_loader_src($src, $handle) { |
|
868 | 868 | global $_wp_admin_css_colors; |
869 | 869 | |
870 | - if ( wp_installing() ) |
|
871 | - return preg_replace( '#^wp-admin/#', './', $src ); |
|
870 | + if (wp_installing()) |
|
871 | + return preg_replace('#^wp-admin/#', './', $src); |
|
872 | 872 | |
873 | - if ( 'colors' == $handle ) { |
|
873 | + if ('colors' == $handle) { |
|
874 | 874 | $color = get_user_option('admin_color'); |
875 | 875 | |
876 | - if ( empty($color) || !isset($_wp_admin_css_colors[$color]) ) |
|
876 | + if (empty($color) || ! isset($_wp_admin_css_colors[$color])) |
|
877 | 877 | $color = 'fresh'; |
878 | 878 | |
879 | 879 | $color = $_wp_admin_css_colors[$color]; |
880 | 880 | $url = $color->url; |
881 | 881 | |
882 | - if ( ! $url ) { |
|
882 | + if ( ! $url) { |
|
883 | 883 | return false; |
884 | 884 | } |
885 | 885 | |
886 | - $parsed = parse_url( $src ); |
|
887 | - if ( isset($parsed['query']) && $parsed['query'] ) { |
|
888 | - wp_parse_str( $parsed['query'], $qv ); |
|
889 | - $url = add_query_arg( $qv, $url ); |
|
886 | + $parsed = parse_url($src); |
|
887 | + if (isset($parsed['query']) && $parsed['query']) { |
|
888 | + wp_parse_str($parsed['query'], $qv); |
|
889 | + $url = add_query_arg($qv, $url); |
|
890 | 890 | } |
891 | 891 | |
892 | 892 | return $url; |
@@ -912,9 +912,9 @@ discard block |
||
912 | 912 | function print_head_scripts() { |
913 | 913 | global $concatenate_scripts; |
914 | 914 | |
915 | - if ( ! did_action('wp_print_scripts') ) { |
|
915 | + if ( ! did_action('wp_print_scripts')) { |
|
916 | 916 | /** This action is documented in wp-includes/functions.wp-scripts.php */ |
917 | - do_action( 'wp_print_scripts' ); |
|
917 | + do_action('wp_print_scripts'); |
|
918 | 918 | } |
919 | 919 | |
920 | 920 | $wp_scripts = wp_scripts(); |
@@ -930,7 +930,7 @@ discard block |
||
930 | 930 | * |
931 | 931 | * @param bool $print Whether to print the head scripts. Default true. |
932 | 932 | */ |
933 | - if ( apply_filters( 'print_head_scripts', true ) ) { |
|
933 | + if (apply_filters('print_head_scripts', true)) { |
|
934 | 934 | _print_scripts(); |
935 | 935 | } |
936 | 936 | |
@@ -951,7 +951,7 @@ discard block |
||
951 | 951 | function print_footer_scripts() { |
952 | 952 | global $wp_scripts, $concatenate_scripts; |
953 | 953 | |
954 | - if ( ! ( $wp_scripts instanceof WP_Scripts ) ) { |
|
954 | + if ( ! ($wp_scripts instanceof WP_Scripts)) { |
|
955 | 955 | return array(); // No need to run if not instantiated. |
956 | 956 | } |
957 | 957 | script_concat_settings(); |
@@ -965,7 +965,7 @@ discard block |
||
965 | 965 | * |
966 | 966 | * @param bool $print Whether to print the footer scripts. Default true. |
967 | 967 | */ |
968 | - if ( apply_filters( 'print_footer_scripts', true ) ) { |
|
968 | + if (apply_filters('print_footer_scripts', true)) { |
|
969 | 969 | _print_scripts(); |
970 | 970 | } |
971 | 971 | |
@@ -985,12 +985,12 @@ discard block |
||
985 | 985 | global $wp_scripts, $compress_scripts; |
986 | 986 | |
987 | 987 | $zip = $compress_scripts ? 1 : 0; |
988 | - if ( $zip && defined('ENFORCE_GZIP') && ENFORCE_GZIP ) |
|
988 | + if ($zip && defined('ENFORCE_GZIP') && ENFORCE_GZIP) |
|
989 | 989 | $zip = 'gzip'; |
990 | 990 | |
991 | - if ( $concat = trim( $wp_scripts->concat, ', ' ) ) { |
|
991 | + if ($concat = trim($wp_scripts->concat, ', ')) { |
|
992 | 992 | |
993 | - if ( !empty($wp_scripts->print_code) ) { |
|
993 | + if ( ! empty($wp_scripts->print_code)) { |
|
994 | 994 | echo "\n<script type='text/javascript'>\n"; |
995 | 995 | echo "/* <![CDATA[ */\n"; // not needed in HTML 5 |
996 | 996 | echo $wp_scripts->print_code; |
@@ -998,18 +998,18 @@ discard block |
||
998 | 998 | echo "</script>\n"; |
999 | 999 | } |
1000 | 1000 | |
1001 | - if ( ! empty( $wp_scripts->print_html_before ) ) { |
|
1001 | + if ( ! empty($wp_scripts->print_html_before)) { |
|
1002 | 1002 | echo $wp_scripts->print_html_before; |
1003 | 1003 | } |
1004 | 1004 | |
1005 | - $concat = str_split( $concat, 128 ); |
|
1006 | - $concat = 'load%5B%5D=' . implode( '&load%5B%5D=', $concat ); |
|
1005 | + $concat = str_split($concat, 128); |
|
1006 | + $concat = 'load%5B%5D='.implode('&load%5B%5D=', $concat); |
|
1007 | 1007 | |
1008 | - $src = $wp_scripts->base_url . "/wp-admin/load-scripts.php?c={$zip}&" . $concat . '&ver=' . $wp_scripts->default_version; |
|
1009 | - echo "<script type='text/javascript' src='" . esc_attr($src) . "'></script>\n"; |
|
1008 | + $src = $wp_scripts->base_url."/wp-admin/load-scripts.php?c={$zip}&".$concat.'&ver='.$wp_scripts->default_version; |
|
1009 | + echo "<script type='text/javascript' src='".esc_attr($src)."'></script>\n"; |
|
1010 | 1010 | } |
1011 | 1011 | |
1012 | - if ( !empty($wp_scripts->print_html) ) |
|
1012 | + if ( ! empty($wp_scripts->print_html)) |
|
1013 | 1013 | echo $wp_scripts->print_html; |
1014 | 1014 | } |
1015 | 1015 | |
@@ -1026,14 +1026,14 @@ discard block |
||
1026 | 1026 | * @return array |
1027 | 1027 | */ |
1028 | 1028 | function wp_print_head_scripts() { |
1029 | - if ( ! did_action('wp_print_scripts') ) { |
|
1029 | + if ( ! did_action('wp_print_scripts')) { |
|
1030 | 1030 | /** This action is documented in wp-includes/functions.wp-scripts.php */ |
1031 | - do_action( 'wp_print_scripts' ); |
|
1031 | + do_action('wp_print_scripts'); |
|
1032 | 1032 | } |
1033 | 1033 | |
1034 | 1034 | global $wp_scripts; |
1035 | 1035 | |
1036 | - if ( ! ( $wp_scripts instanceof WP_Scripts ) ) { |
|
1036 | + if ( ! ($wp_scripts instanceof WP_Scripts)) { |
|
1037 | 1037 | return array(); // no need to run if nothing is queued |
1038 | 1038 | } |
1039 | 1039 | return print_head_scripts(); |
@@ -1060,7 +1060,7 @@ discard block |
||
1060 | 1060 | * |
1061 | 1061 | * @since 2.8.0 |
1062 | 1062 | */ |
1063 | - do_action( 'wp_print_footer_scripts' ); |
|
1063 | + do_action('wp_print_footer_scripts'); |
|
1064 | 1064 | } |
1065 | 1065 | |
1066 | 1066 | /** |
@@ -1077,7 +1077,7 @@ discard block |
||
1077 | 1077 | * |
1078 | 1078 | * @since 2.8.0 |
1079 | 1079 | */ |
1080 | - do_action( 'wp_enqueue_scripts' ); |
|
1080 | + do_action('wp_enqueue_scripts'); |
|
1081 | 1081 | } |
1082 | 1082 | |
1083 | 1083 | /** |
@@ -1105,7 +1105,7 @@ discard block |
||
1105 | 1105 | * |
1106 | 1106 | * @param bool $print Whether to print the admin styles. Default true. |
1107 | 1107 | */ |
1108 | - if ( apply_filters( 'print_admin_styles', true ) ) { |
|
1108 | + if (apply_filters('print_admin_styles', true)) { |
|
1109 | 1109 | _print_styles(); |
1110 | 1110 | } |
1111 | 1111 | |
@@ -1126,7 +1126,7 @@ discard block |
||
1126 | 1126 | function print_late_styles() { |
1127 | 1127 | global $wp_styles, $concatenate_scripts; |
1128 | 1128 | |
1129 | - if ( ! ( $wp_styles instanceof WP_Styles ) ) { |
|
1129 | + if ( ! ($wp_styles instanceof WP_Styles)) { |
|
1130 | 1130 | return; |
1131 | 1131 | } |
1132 | 1132 | |
@@ -1141,7 +1141,7 @@ discard block |
||
1141 | 1141 | * |
1142 | 1142 | * @param bool $print Whether to print the 'late' styles. Default true. |
1143 | 1143 | */ |
1144 | - if ( apply_filters( 'print_late_styles', true ) ) { |
|
1144 | + if (apply_filters('print_late_styles', true)) { |
|
1145 | 1145 | _print_styles(); |
1146 | 1146 | } |
1147 | 1147 | |
@@ -1163,27 +1163,27 @@ discard block |
||
1163 | 1163 | $wp_styles = wp_styles(); |
1164 | 1164 | |
1165 | 1165 | $zip = $compress_css ? 1 : 0; |
1166 | - if ( $zip && defined('ENFORCE_GZIP') && ENFORCE_GZIP ) |
|
1166 | + if ($zip && defined('ENFORCE_GZIP') && ENFORCE_GZIP) |
|
1167 | 1167 | $zip = 'gzip'; |
1168 | 1168 | |
1169 | - if ( $concat = trim( $wp_styles->concat, ', ' ) ) { |
|
1169 | + if ($concat = trim($wp_styles->concat, ', ')) { |
|
1170 | 1170 | $dir = $wp_styles->text_direction; |
1171 | 1171 | $ver = $wp_styles->default_version; |
1172 | 1172 | |
1173 | - $concat = str_split( $concat, 128 ); |
|
1174 | - $concat = 'load%5B%5D=' . implode( '&load%5B%5D=', $concat ); |
|
1173 | + $concat = str_split($concat, 128); |
|
1174 | + $concat = 'load%5B%5D='.implode('&load%5B%5D=', $concat); |
|
1175 | 1175 | |
1176 | - $href = $wp_styles->base_url . "/wp-admin/load-styles.php?c={$zip}&dir={$dir}&" . $concat . '&ver=' . $ver; |
|
1177 | - echo "<link rel='stylesheet' href='" . esc_attr($href) . "' type='text/css' media='all' />\n"; |
|
1176 | + $href = $wp_styles->base_url."/wp-admin/load-styles.php?c={$zip}&dir={$dir}&".$concat.'&ver='.$ver; |
|
1177 | + echo "<link rel='stylesheet' href='".esc_attr($href)."' type='text/css' media='all' />\n"; |
|
1178 | 1178 | |
1179 | - if ( !empty($wp_styles->print_code) ) { |
|
1179 | + if ( ! empty($wp_styles->print_code)) { |
|
1180 | 1180 | echo "<style type='text/css'>\n"; |
1181 | 1181 | echo $wp_styles->print_code; |
1182 | 1182 | echo "\n</style>\n"; |
1183 | 1183 | } |
1184 | 1184 | } |
1185 | 1185 | |
1186 | - if ( !empty($wp_styles->print_html) ) |
|
1186 | + if ( ! empty($wp_styles->print_html)) |
|
1187 | 1187 | echo $wp_styles->print_html; |
1188 | 1188 | } |
1189 | 1189 | |
@@ -1199,23 +1199,23 @@ discard block |
||
1199 | 1199 | function script_concat_settings() { |
1200 | 1200 | global $concatenate_scripts, $compress_scripts, $compress_css; |
1201 | 1201 | |
1202 | - $compressed_output = ( ini_get('zlib.output_compression') || 'ob_gzhandler' == ini_get('output_handler') ); |
|
1202 | + $compressed_output = (ini_get('zlib.output_compression') || 'ob_gzhandler' == ini_get('output_handler')); |
|
1203 | 1203 | |
1204 | - if ( ! isset($concatenate_scripts) ) { |
|
1204 | + if ( ! isset($concatenate_scripts)) { |
|
1205 | 1205 | $concatenate_scripts = defined('CONCATENATE_SCRIPTS') ? CONCATENATE_SCRIPTS : true; |
1206 | - if ( ( ! is_admin() && ! did_action( 'login_init' ) ) || ( defined('SCRIPT_DEBUG') && SCRIPT_DEBUG ) ) |
|
1206 | + if (( ! is_admin() && ! did_action('login_init')) || (defined('SCRIPT_DEBUG') && SCRIPT_DEBUG)) |
|
1207 | 1207 | $concatenate_scripts = false; |
1208 | 1208 | } |
1209 | 1209 | |
1210 | - if ( ! isset($compress_scripts) ) { |
|
1210 | + if ( ! isset($compress_scripts)) { |
|
1211 | 1211 | $compress_scripts = defined('COMPRESS_SCRIPTS') ? COMPRESS_SCRIPTS : true; |
1212 | - if ( $compress_scripts && ( ! get_site_option('can_compress_scripts') || $compressed_output ) ) |
|
1212 | + if ($compress_scripts && ( ! get_site_option('can_compress_scripts') || $compressed_output)) |
|
1213 | 1213 | $compress_scripts = false; |
1214 | 1214 | } |
1215 | 1215 | |
1216 | - if ( ! isset($compress_css) ) { |
|
1216 | + if ( ! isset($compress_css)) { |
|
1217 | 1217 | $compress_css = defined('COMPRESS_CSS') ? COMPRESS_CSS : true; |
1218 | - if ( $compress_css && ( ! get_site_option('can_compress_scripts') || $compressed_output ) ) |
|
1218 | + if ($compress_css && ( ! get_site_option('can_compress_scripts') || $compressed_output)) |
|
1219 | 1219 | $compress_css = false; |
1220 | 1220 | } |
1221 | 1221 | } |
@@ -683,11 +683,13 @@ discard block |
||
683 | 683 | function wp_default_styles( &$styles ) { |
684 | 684 | include( ABSPATH . WPINC . '/version.php' ); // include an unmodified $wp_version |
685 | 685 | |
686 | - if ( ! defined( 'SCRIPT_DEBUG' ) ) |
|
687 | - define( 'SCRIPT_DEBUG', false !== strpos( $wp_version, '-src' ) ); |
|
686 | + if ( ! defined( 'SCRIPT_DEBUG' ) ) { |
|
687 | + define( 'SCRIPT_DEBUG', false !== strpos( $wp_version, '-src' ) ); |
|
688 | + } |
|
688 | 689 | |
689 | - if ( ! $guessurl = site_url() ) |
|
690 | - $guessurl = wp_guess_url(); |
|
690 | + if ( ! $guessurl = site_url() ) { |
|
691 | + $guessurl = wp_guess_url(); |
|
692 | + } |
|
691 | 693 | |
692 | 694 | $styles->base_url = $guessurl; |
693 | 695 | $styles->content_url = defined('WP_CONTENT_URL')? WP_CONTENT_URL : ''; |
@@ -812,14 +814,17 @@ discard block |
||
812 | 814 | * @return array Reordered array, if needed. |
813 | 815 | */ |
814 | 816 | function wp_prototype_before_jquery( $js_array ) { |
815 | - if ( false === $prototype = array_search( 'prototype', $js_array, true ) ) |
|
816 | - return $js_array; |
|
817 | + if ( false === $prototype = array_search( 'prototype', $js_array, true ) ) { |
|
818 | + return $js_array; |
|
819 | + } |
|
817 | 820 | |
818 | - if ( false === $jquery = array_search( 'jquery', $js_array, true ) ) |
|
819 | - return $js_array; |
|
821 | + if ( false === $jquery = array_search( 'jquery', $js_array, true ) ) { |
|
822 | + return $js_array; |
|
823 | + } |
|
820 | 824 | |
821 | - if ( $prototype < $jquery ) |
|
822 | - return $js_array; |
|
825 | + if ( $prototype < $jquery ) { |
|
826 | + return $js_array; |
|
827 | + } |
|
823 | 828 | |
824 | 829 | unset($js_array[$prototype]); |
825 | 830 | |
@@ -867,14 +872,16 @@ discard block |
||
867 | 872 | function wp_style_loader_src( $src, $handle ) { |
868 | 873 | global $_wp_admin_css_colors; |
869 | 874 | |
870 | - if ( wp_installing() ) |
|
871 | - return preg_replace( '#^wp-admin/#', './', $src ); |
|
875 | + if ( wp_installing() ) { |
|
876 | + return preg_replace( '#^wp-admin/#', './', $src ); |
|
877 | + } |
|
872 | 878 | |
873 | 879 | if ( 'colors' == $handle ) { |
874 | 880 | $color = get_user_option('admin_color'); |
875 | 881 | |
876 | - if ( empty($color) || !isset($_wp_admin_css_colors[$color]) ) |
|
877 | - $color = 'fresh'; |
|
882 | + if ( empty($color) || !isset($_wp_admin_css_colors[$color]) ) { |
|
883 | + $color = 'fresh'; |
|
884 | + } |
|
878 | 885 | |
879 | 886 | $color = $_wp_admin_css_colors[$color]; |
880 | 887 | $url = $color->url; |
@@ -985,8 +992,9 @@ discard block |
||
985 | 992 | global $wp_scripts, $compress_scripts; |
986 | 993 | |
987 | 994 | $zip = $compress_scripts ? 1 : 0; |
988 | - if ( $zip && defined('ENFORCE_GZIP') && ENFORCE_GZIP ) |
|
989 | - $zip = 'gzip'; |
|
995 | + if ( $zip && defined('ENFORCE_GZIP') && ENFORCE_GZIP ) { |
|
996 | + $zip = 'gzip'; |
|
997 | + } |
|
990 | 998 | |
991 | 999 | if ( $concat = trim( $wp_scripts->concat, ', ' ) ) { |
992 | 1000 | |
@@ -1009,9 +1017,10 @@ discard block |
||
1009 | 1017 | echo "<script type='text/javascript' src='" . esc_attr($src) . "'></script>\n"; |
1010 | 1018 | } |
1011 | 1019 | |
1012 | - if ( !empty($wp_scripts->print_html) ) |
|
1013 | - echo $wp_scripts->print_html; |
|
1014 | -} |
|
1020 | + if ( !empty($wp_scripts->print_html) ) { |
|
1021 | + echo $wp_scripts->print_html; |
|
1022 | + } |
|
1023 | + } |
|
1015 | 1024 | |
1016 | 1025 | /** |
1017 | 1026 | * Prints the script queue in the HTML head on the front end. |
@@ -1163,8 +1172,9 @@ discard block |
||
1163 | 1172 | $wp_styles = wp_styles(); |
1164 | 1173 | |
1165 | 1174 | $zip = $compress_css ? 1 : 0; |
1166 | - if ( $zip && defined('ENFORCE_GZIP') && ENFORCE_GZIP ) |
|
1167 | - $zip = 'gzip'; |
|
1175 | + if ( $zip && defined('ENFORCE_GZIP') && ENFORCE_GZIP ) { |
|
1176 | + $zip = 'gzip'; |
|
1177 | + } |
|
1168 | 1178 | |
1169 | 1179 | if ( $concat = trim( $wp_styles->concat, ', ' ) ) { |
1170 | 1180 | $dir = $wp_styles->text_direction; |
@@ -1183,9 +1193,10 @@ discard block |
||
1183 | 1193 | } |
1184 | 1194 | } |
1185 | 1195 | |
1186 | - if ( !empty($wp_styles->print_html) ) |
|
1187 | - echo $wp_styles->print_html; |
|
1188 | -} |
|
1196 | + if ( !empty($wp_styles->print_html) ) { |
|
1197 | + echo $wp_styles->print_html; |
|
1198 | + } |
|
1199 | + } |
|
1189 | 1200 | |
1190 | 1201 | /** |
1191 | 1202 | * Determine the concatenation and compression settings for scripts and styles. |
@@ -1203,19 +1214,22 @@ discard block |
||
1203 | 1214 | |
1204 | 1215 | if ( ! isset($concatenate_scripts) ) { |
1205 | 1216 | $concatenate_scripts = defined('CONCATENATE_SCRIPTS') ? CONCATENATE_SCRIPTS : true; |
1206 | - if ( ( ! is_admin() && ! did_action( 'login_init' ) ) || ( defined('SCRIPT_DEBUG') && SCRIPT_DEBUG ) ) |
|
1207 | - $concatenate_scripts = false; |
|
1217 | + if ( ( ! is_admin() && ! did_action( 'login_init' ) ) || ( defined('SCRIPT_DEBUG') && SCRIPT_DEBUG ) ) { |
|
1218 | + $concatenate_scripts = false; |
|
1219 | + } |
|
1208 | 1220 | } |
1209 | 1221 | |
1210 | 1222 | if ( ! isset($compress_scripts) ) { |
1211 | 1223 | $compress_scripts = defined('COMPRESS_SCRIPTS') ? COMPRESS_SCRIPTS : true; |
1212 | - if ( $compress_scripts && ( ! get_site_option('can_compress_scripts') || $compressed_output ) ) |
|
1213 | - $compress_scripts = false; |
|
1224 | + if ( $compress_scripts && ( ! get_site_option('can_compress_scripts') || $compressed_output ) ) { |
|
1225 | + $compress_scripts = false; |
|
1226 | + } |
|
1214 | 1227 | } |
1215 | 1228 | |
1216 | 1229 | if ( ! isset($compress_css) ) { |
1217 | 1230 | $compress_css = defined('COMPRESS_CSS') ? COMPRESS_CSS : true; |
1218 | - if ( $compress_css && ( ! get_site_option('can_compress_scripts') || $compressed_output ) ) |
|
1219 | - $compress_css = false; |
|
1231 | + if ( $compress_css && ( ! get_site_option('can_compress_scripts') || $compressed_output ) ) { |
|
1232 | + $compress_css = false; |
|
1233 | + } |
|
1220 | 1234 | } |
1221 | 1235 | } |
@@ -62,7 +62,7 @@ discard block |
||
62 | 62 | * } |
63 | 63 | * @return array Parsed arguments array. |
64 | 64 | */ |
65 | - public static function parse_settings( $editor_id, $settings ) { |
|
65 | + public static function parse_settings($editor_id, $settings) { |
|
66 | 66 | |
67 | 67 | /** |
68 | 68 | * Filter the wp_editor() settings. |
@@ -74,9 +74,9 @@ discard block |
||
74 | 74 | * @param array $settings Array of editor arguments. |
75 | 75 | * @param string $editor_id ID for the current editor instance. |
76 | 76 | */ |
77 | - $settings = apply_filters( 'wp_editor_settings', $settings, $editor_id ); |
|
77 | + $settings = apply_filters('wp_editor_settings', $settings, $editor_id); |
|
78 | 78 | |
79 | - $set = wp_parse_args( $settings, array( |
|
79 | + $set = wp_parse_args($settings, array( |
|
80 | 80 | 'wpautop' => true, |
81 | 81 | 'media_buttons' => true, |
82 | 82 | 'default_editor' => '', |
@@ -92,43 +92,43 @@ discard block |
||
92 | 92 | '_content_editor_dfw' => false, |
93 | 93 | 'tinymce' => true, |
94 | 94 | 'quicktags' => true |
95 | - ) ); |
|
95 | + )); |
|
96 | 96 | |
97 | - self::$this_tinymce = ( $set['tinymce'] && user_can_richedit() ); |
|
97 | + self::$this_tinymce = ($set['tinymce'] && user_can_richedit()); |
|
98 | 98 | |
99 | - if ( self::$this_tinymce ) { |
|
100 | - if ( false !== strpos( $editor_id, '[' ) ) { |
|
99 | + if (self::$this_tinymce) { |
|
100 | + if (false !== strpos($editor_id, '[')) { |
|
101 | 101 | self::$this_tinymce = false; |
102 | - _deprecated_argument( 'wp_editor()', '3.9', 'TinyMCE editor IDs cannot have brackets.' ); |
|
102 | + _deprecated_argument('wp_editor()', '3.9', 'TinyMCE editor IDs cannot have brackets.'); |
|
103 | 103 | } |
104 | 104 | } |
105 | 105 | |
106 | 106 | self::$this_quicktags = (bool) $set['quicktags']; |
107 | 107 | |
108 | - if ( self::$this_tinymce ) |
|
108 | + if (self::$this_tinymce) |
|
109 | 109 | self::$has_tinymce = true; |
110 | 110 | |
111 | - if ( self::$this_quicktags ) |
|
111 | + if (self::$this_quicktags) |
|
112 | 112 | self::$has_quicktags = true; |
113 | 113 | |
114 | - if ( $set['dfw'] ) { |
|
114 | + if ($set['dfw']) { |
|
115 | 115 | self::$old_dfw_compat = true; |
116 | 116 | } |
117 | 117 | |
118 | - if ( empty( $set['editor_height'] ) ) |
|
118 | + if (empty($set['editor_height'])) |
|
119 | 119 | return $set; |
120 | 120 | |
121 | - if ( 'content' === $editor_id && empty( $set['tinymce']['wp_autoresize_on'] ) ) { |
|
121 | + if ('content' === $editor_id && empty($set['tinymce']['wp_autoresize_on'])) { |
|
122 | 122 | // A cookie (set when a user resizes the editor) overrides the height. |
123 | - $cookie = (int) get_user_setting( 'ed_size' ); |
|
123 | + $cookie = (int) get_user_setting('ed_size'); |
|
124 | 124 | |
125 | - if ( $cookie ) |
|
125 | + if ($cookie) |
|
126 | 126 | $set['editor_height'] = $cookie; |
127 | 127 | } |
128 | 128 | |
129 | - if ( $set['editor_height'] < 50 ) |
|
129 | + if ($set['editor_height'] < 50) |
|
130 | 130 | $set['editor_height'] = 50; |
131 | - elseif ( $set['editor_height'] > 5000 ) |
|
131 | + elseif ($set['editor_height'] > 5000) |
|
132 | 132 | $set['editor_height'] = 5000; |
133 | 133 | |
134 | 134 | return $set; |
@@ -142,75 +142,75 @@ discard block |
||
142 | 142 | * @param string $editor_id ID for the textarea and TinyMCE and Quicktags instances (can contain only ASCII letters and numbers). |
143 | 143 | * @param array $settings See the _parse_settings() method for description. |
144 | 144 | */ |
145 | - public static function editor( $content, $editor_id, $settings = array() ) { |
|
146 | - $set = self::parse_settings( $editor_id, $settings ); |
|
147 | - $editor_class = ' class="' . trim( esc_attr( $set['editor_class'] ) . ' wp-editor-area' ) . '"'; |
|
148 | - $tabindex = $set['tabindex'] ? ' tabindex="' . (int) $set['tabindex'] . '"' : ''; |
|
145 | + public static function editor($content, $editor_id, $settings = array()) { |
|
146 | + $set = self::parse_settings($editor_id, $settings); |
|
147 | + $editor_class = ' class="'.trim(esc_attr($set['editor_class']).' wp-editor-area').'"'; |
|
148 | + $tabindex = $set['tabindex'] ? ' tabindex="'.(int) $set['tabindex'].'"' : ''; |
|
149 | 149 | $default_editor = 'html'; |
150 | 150 | $buttons = $autocomplete = ''; |
151 | - $editor_id_attr = esc_attr( $editor_id ); |
|
151 | + $editor_id_attr = esc_attr($editor_id); |
|
152 | 152 | |
153 | - if ( $set['drag_drop_upload'] ) { |
|
153 | + if ($set['drag_drop_upload']) { |
|
154 | 154 | self::$drag_drop_upload = true; |
155 | 155 | } |
156 | 156 | |
157 | - if ( ! empty( $set['editor_height'] ) ) { |
|
158 | - $height = ' style="height: ' . (int) $set['editor_height'] . 'px"'; |
|
157 | + if ( ! empty($set['editor_height'])) { |
|
158 | + $height = ' style="height: '.(int) $set['editor_height'].'px"'; |
|
159 | 159 | } else { |
160 | - $height = ' rows="' . (int) $set['textarea_rows'] . '"'; |
|
160 | + $height = ' rows="'.(int) $set['textarea_rows'].'"'; |
|
161 | 161 | } |
162 | 162 | |
163 | - if ( ! current_user_can( 'upload_files' ) ) { |
|
163 | + if ( ! current_user_can('upload_files')) { |
|
164 | 164 | $set['media_buttons'] = false; |
165 | 165 | } |
166 | 166 | |
167 | - if ( self::$this_tinymce ) { |
|
167 | + if (self::$this_tinymce) { |
|
168 | 168 | $autocomplete = ' autocomplete="off"'; |
169 | 169 | |
170 | - if ( self::$this_quicktags ) { |
|
170 | + if (self::$this_quicktags) { |
|
171 | 171 | $default_editor = $set['default_editor'] ? $set['default_editor'] : wp_default_editor(); |
172 | 172 | // 'html' is used for the "Text" editor tab. |
173 | - if ( 'html' !== $default_editor ) { |
|
173 | + if ('html' !== $default_editor) { |
|
174 | 174 | $default_editor = 'tinymce'; |
175 | 175 | } |
176 | 176 | |
177 | - $buttons .= '<button type="button" id="' . $editor_id_attr . '-tmce" class="wp-switch-editor switch-tmce"' . |
|
178 | - ' data-wp-editor-id="' . $editor_id_attr . '">' . __('Visual') . "</button>\n"; |
|
179 | - $buttons .= '<button type="button" id="' . $editor_id_attr . '-html" class="wp-switch-editor switch-html"' . |
|
180 | - ' data-wp-editor-id="' . $editor_id_attr . '">' . _x( 'Text', 'Name for the Text editor tab (formerly HTML)' ) . "</button>\n"; |
|
177 | + $buttons .= '<button type="button" id="'.$editor_id_attr.'-tmce" class="wp-switch-editor switch-tmce"'. |
|
178 | + ' data-wp-editor-id="'.$editor_id_attr.'">'.__('Visual')."</button>\n"; |
|
179 | + $buttons .= '<button type="button" id="'.$editor_id_attr.'-html" class="wp-switch-editor switch-html"'. |
|
180 | + ' data-wp-editor-id="'.$editor_id_attr.'">'._x('Text', 'Name for the Text editor tab (formerly HTML)')."</button>\n"; |
|
181 | 181 | } else { |
182 | 182 | $default_editor = 'tinymce'; |
183 | 183 | } |
184 | 184 | } |
185 | 185 | |
186 | 186 | $switch_class = 'html' === $default_editor ? 'html-active' : 'tmce-active'; |
187 | - $wrap_class = 'wp-core-ui wp-editor-wrap ' . $switch_class; |
|
187 | + $wrap_class = 'wp-core-ui wp-editor-wrap '.$switch_class; |
|
188 | 188 | |
189 | - if ( $set['_content_editor_dfw'] ) { |
|
189 | + if ($set['_content_editor_dfw']) { |
|
190 | 190 | $wrap_class .= ' has-dfw'; |
191 | 191 | } |
192 | 192 | |
193 | - echo '<div id="wp-' . $editor_id_attr . '-wrap" class="' . $wrap_class . '">'; |
|
193 | + echo '<div id="wp-'.$editor_id_attr.'-wrap" class="'.$wrap_class.'">'; |
|
194 | 194 | |
195 | - if ( self::$editor_buttons_css ) { |
|
196 | - wp_print_styles( 'editor-buttons' ); |
|
195 | + if (self::$editor_buttons_css) { |
|
196 | + wp_print_styles('editor-buttons'); |
|
197 | 197 | self::$editor_buttons_css = false; |
198 | 198 | } |
199 | 199 | |
200 | - if ( ! empty( $set['editor_css'] ) ) { |
|
201 | - echo $set['editor_css'] . "\n"; |
|
200 | + if ( ! empty($set['editor_css'])) { |
|
201 | + echo $set['editor_css']."\n"; |
|
202 | 202 | } |
203 | 203 | |
204 | - if ( ! empty( $buttons ) || $set['media_buttons'] ) { |
|
205 | - echo '<div id="wp-' . $editor_id_attr . '-editor-tools" class="wp-editor-tools hide-if-no-js">'; |
|
204 | + if ( ! empty($buttons) || $set['media_buttons']) { |
|
205 | + echo '<div id="wp-'.$editor_id_attr.'-editor-tools" class="wp-editor-tools hide-if-no-js">'; |
|
206 | 206 | |
207 | - if ( $set['media_buttons'] ) { |
|
207 | + if ($set['media_buttons']) { |
|
208 | 208 | self::$has_medialib = true; |
209 | 209 | |
210 | - if ( ! function_exists( 'media_buttons' ) ) |
|
211 | - include( ABSPATH . 'wp-admin/includes/media.php' ); |
|
210 | + if ( ! function_exists('media_buttons')) |
|
211 | + include(ABSPATH.'wp-admin/includes/media.php'); |
|
212 | 212 | |
213 | - echo '<div id="wp-' . $editor_id_attr . '-media-buttons" class="wp-media-buttons">'; |
|
213 | + echo '<div id="wp-'.$editor_id_attr.'-media-buttons" class="wp-media-buttons">'; |
|
214 | 214 | |
215 | 215 | /** |
216 | 216 | * Fires after the default media button(s) are displayed. |
@@ -219,24 +219,24 @@ discard block |
||
219 | 219 | * |
220 | 220 | * @param string $editor_id Unique editor identifier, e.g. 'content'. |
221 | 221 | */ |
222 | - do_action( 'media_buttons', $editor_id ); |
|
222 | + do_action('media_buttons', $editor_id); |
|
223 | 223 | echo "</div>\n"; |
224 | 224 | } |
225 | 225 | |
226 | - echo '<div class="wp-editor-tabs">' . $buttons . "</div>\n"; |
|
226 | + echo '<div class="wp-editor-tabs">'.$buttons."</div>\n"; |
|
227 | 227 | echo "</div>\n"; |
228 | 228 | } |
229 | 229 | |
230 | 230 | $quicktags_toolbar = ''; |
231 | 231 | |
232 | - if ( self::$this_quicktags ) { |
|
233 | - if ( 'content' === $editor_id && ! empty( $GLOBALS['current_screen'] ) && $GLOBALS['current_screen']->base === 'post' ) { |
|
232 | + if (self::$this_quicktags) { |
|
233 | + if ('content' === $editor_id && ! empty($GLOBALS['current_screen']) && $GLOBALS['current_screen']->base === 'post') { |
|
234 | 234 | $toolbar_id = 'ed_toolbar'; |
235 | 235 | } else { |
236 | - $toolbar_id = 'qt_' . $editor_id_attr . '_toolbar'; |
|
236 | + $toolbar_id = 'qt_'.$editor_id_attr.'_toolbar'; |
|
237 | 237 | } |
238 | 238 | |
239 | - $quicktags_toolbar = '<div id="' . $toolbar_id . '" class="quicktags-toolbar"></div>'; |
|
239 | + $quicktags_toolbar = '<div id="'.$toolbar_id.'" class="quicktags-toolbar"></div>'; |
|
240 | 240 | } |
241 | 241 | |
242 | 242 | /** |
@@ -246,14 +246,14 @@ discard block |
||
246 | 246 | * |
247 | 247 | * @param string $output Editor's HTML markup. |
248 | 248 | */ |
249 | - $the_editor = apply_filters( 'the_editor', '<div id="wp-' . $editor_id_attr . '-editor-container" class="wp-editor-container">' . |
|
250 | - $quicktags_toolbar . |
|
251 | - '<textarea' . $editor_class . $height . $tabindex . $autocomplete . ' cols="40" name="' . esc_attr( $set['textarea_name'] ) . '" ' . |
|
252 | - 'id="' . $editor_id_attr . '">%s</textarea></div>' ); |
|
249 | + $the_editor = apply_filters('the_editor', '<div id="wp-'.$editor_id_attr.'-editor-container" class="wp-editor-container">'. |
|
250 | + $quicktags_toolbar. |
|
251 | + '<textarea'.$editor_class.$height.$tabindex.$autocomplete.' cols="40" name="'.esc_attr($set['textarea_name']).'" '. |
|
252 | + 'id="'.$editor_id_attr.'">%s</textarea></div>'); |
|
253 | 253 | |
254 | 254 | // Prepare the content for the Visual or Text editor, only when TinyMCE is used (back-compat). |
255 | - if ( self::$this_tinymce ) { |
|
256 | - add_filter( 'the_editor_content', 'format_for_editor', 10, 2 ); |
|
255 | + if (self::$this_tinymce) { |
|
256 | + add_filter('the_editor_content', 'format_for_editor', 10, 2); |
|
257 | 257 | } |
258 | 258 | |
259 | 259 | /** |
@@ -265,31 +265,31 @@ discard block |
||
265 | 265 | * @param string $default_editor The default editor for the current user. |
266 | 266 | * Either 'html' or 'tinymce'. |
267 | 267 | */ |
268 | - $content = apply_filters( 'the_editor_content', $content, $default_editor ); |
|
268 | + $content = apply_filters('the_editor_content', $content, $default_editor); |
|
269 | 269 | |
270 | 270 | // Remove the filter as the next editor on the same page may not need it. |
271 | - if ( self::$this_tinymce ) { |
|
272 | - remove_filter( 'the_editor_content', 'format_for_editor' ); |
|
271 | + if (self::$this_tinymce) { |
|
272 | + remove_filter('the_editor_content', 'format_for_editor'); |
|
273 | 273 | } |
274 | 274 | |
275 | 275 | // Back-compat for the `htmledit_pre` and `richedit_pre` filters |
276 | - if ( 'html' === $default_editor && has_filter( 'htmledit_pre' ) ) { |
|
276 | + if ('html' === $default_editor && has_filter('htmledit_pre')) { |
|
277 | 277 | // TODO: needs _deprecated_filter(), use _deprecated_function() as substitute for now |
278 | - _deprecated_function( 'add_filter( htmledit_pre )', '4.3.0', 'add_filter( format_for_editor )' ); |
|
279 | - $content = apply_filters( 'htmledit_pre', $content ); |
|
280 | - } elseif ( 'tinymce' === $default_editor && has_filter( 'richedit_pre' ) ) { |
|
281 | - _deprecated_function( 'add_filter( richedit_pre )', '4.3.0', 'add_filter( format_for_editor )' ); |
|
282 | - $content = apply_filters( 'richedit_pre', $content ); |
|
278 | + _deprecated_function('add_filter( htmledit_pre )', '4.3.0', 'add_filter( format_for_editor )'); |
|
279 | + $content = apply_filters('htmledit_pre', $content); |
|
280 | + } elseif ('tinymce' === $default_editor && has_filter('richedit_pre')) { |
|
281 | + _deprecated_function('add_filter( richedit_pre )', '4.3.0', 'add_filter( format_for_editor )'); |
|
282 | + $content = apply_filters('richedit_pre', $content); |
|
283 | 283 | } |
284 | 284 | |
285 | - if ( false !== stripos( $content, 'textarea' ) ) { |
|
286 | - $content = preg_replace( '%</textarea%i', '</textarea', $content ); |
|
285 | + if (false !== stripos($content, 'textarea')) { |
|
286 | + $content = preg_replace('%</textarea%i', '</textarea', $content); |
|
287 | 287 | } |
288 | 288 | |
289 | - printf( $the_editor, $content ); |
|
289 | + printf($the_editor, $content); |
|
290 | 290 | echo "\n</div>\n\n"; |
291 | 291 | |
292 | - self::editor_settings( $editor_id, $set ); |
|
292 | + self::editor_settings($editor_id, $set); |
|
293 | 293 | } |
294 | 294 | |
295 | 295 | /** |
@@ -304,30 +304,30 @@ discard block |
||
304 | 304 | public static function editor_settings($editor_id, $set) { |
305 | 305 | global $wp_version, $tinymce_version; |
306 | 306 | |
307 | - if ( empty(self::$first_init) ) { |
|
308 | - if ( is_admin() ) { |
|
309 | - add_action( 'admin_print_footer_scripts', array( __CLASS__, 'editor_js' ), 50 ); |
|
310 | - add_action( 'admin_print_footer_scripts', array( __CLASS__, 'enqueue_scripts' ), 1 ); |
|
307 | + if (empty(self::$first_init)) { |
|
308 | + if (is_admin()) { |
|
309 | + add_action('admin_print_footer_scripts', array(__CLASS__, 'editor_js'), 50); |
|
310 | + add_action('admin_print_footer_scripts', array(__CLASS__, 'enqueue_scripts'), 1); |
|
311 | 311 | } else { |
312 | - add_action( 'wp_print_footer_scripts', array( __CLASS__, 'editor_js' ), 50 ); |
|
313 | - add_action( 'wp_print_footer_scripts', array( __CLASS__, 'enqueue_scripts' ), 1 ); |
|
312 | + add_action('wp_print_footer_scripts', array(__CLASS__, 'editor_js'), 50); |
|
313 | + add_action('wp_print_footer_scripts', array(__CLASS__, 'enqueue_scripts'), 1); |
|
314 | 314 | } |
315 | 315 | } |
316 | 316 | |
317 | - if ( self::$this_quicktags ) { |
|
317 | + if (self::$this_quicktags) { |
|
318 | 318 | |
319 | 319 | $qtInit = array( |
320 | 320 | 'id' => $editor_id, |
321 | 321 | 'buttons' => '' |
322 | 322 | ); |
323 | 323 | |
324 | - if ( is_array($set['quicktags']) ) |
|
324 | + if (is_array($set['quicktags'])) |
|
325 | 325 | $qtInit = array_merge($qtInit, $set['quicktags']); |
326 | 326 | |
327 | - if ( empty($qtInit['buttons']) ) |
|
327 | + if (empty($qtInit['buttons'])) |
|
328 | 328 | $qtInit['buttons'] = 'strong,em,link,block,del,ins,img,ul,ol,li,code,more,close'; |
329 | 329 | |
330 | - if ( $set['_content_editor_dfw'] ) { |
|
330 | + if ($set['_content_editor_dfw']) { |
|
331 | 331 | $qtInit['buttons'] .= ',dfw'; |
332 | 332 | } |
333 | 333 | |
@@ -339,26 +339,26 @@ discard block |
||
339 | 339 | * @param array $qtInit Quicktags settings. |
340 | 340 | * @param string $editor_id The unique editor ID, e.g. 'content'. |
341 | 341 | */ |
342 | - $qtInit = apply_filters( 'quicktags_settings', $qtInit, $editor_id ); |
|
342 | + $qtInit = apply_filters('quicktags_settings', $qtInit, $editor_id); |
|
343 | 343 | |
344 | 344 | self::$qt_settings[$editor_id] = $qtInit; |
345 | 345 | |
346 | - self::$qt_buttons = array_merge( self::$qt_buttons, explode(',', $qtInit['buttons']) ); |
|
346 | + self::$qt_buttons = array_merge(self::$qt_buttons, explode(',', $qtInit['buttons'])); |
|
347 | 347 | } |
348 | 348 | |
349 | - if ( self::$this_tinymce ) { |
|
349 | + if (self::$this_tinymce) { |
|
350 | 350 | |
351 | - if ( empty( self::$first_init ) ) { |
|
352 | - self::$baseurl = includes_url( 'js/tinymce' ); |
|
351 | + if (empty(self::$first_init)) { |
|
352 | + self::$baseurl = includes_url('js/tinymce'); |
|
353 | 353 | |
354 | 354 | $mce_locale = get_locale(); |
355 | - self::$mce_locale = $mce_locale = empty( $mce_locale ) ? 'en' : strtolower( substr( $mce_locale, 0, 2 ) ); // ISO 639-1 |
|
355 | + self::$mce_locale = $mce_locale = empty($mce_locale) ? 'en' : strtolower(substr($mce_locale, 0, 2)); // ISO 639-1 |
|
356 | 356 | |
357 | 357 | /** This filter is documented in wp-admin/includes/media.php */ |
358 | - $no_captions = (bool) apply_filters( 'disable_captions', '' ); |
|
358 | + $no_captions = (bool) apply_filters('disable_captions', ''); |
|
359 | 359 | $ext_plugins = ''; |
360 | 360 | |
361 | - if ( $set['teeny'] ) { |
|
361 | + if ($set['teeny']) { |
|
362 | 362 | |
363 | 363 | /** |
364 | 364 | * Filter the list of teenyMCE plugins. |
@@ -368,7 +368,7 @@ discard block |
||
368 | 368 | * @param array $plugins An array of teenyMCE plugins. |
369 | 369 | * @param string $editor_id Unique editor identifier, e.g. 'content'. |
370 | 370 | */ |
371 | - self::$plugins = $plugins = apply_filters( 'teeny_mce_plugins', array( 'colorpicker', 'lists', 'fullscreen', 'image', 'wordpress', 'wpeditimage', 'wplink' ), $editor_id ); |
|
371 | + self::$plugins = $plugins = apply_filters('teeny_mce_plugins', array('colorpicker', 'lists', 'fullscreen', 'image', 'wordpress', 'wpeditimage', 'wplink'), $editor_id); |
|
372 | 372 | } else { |
373 | 373 | |
374 | 374 | /** |
@@ -388,7 +388,7 @@ discard block |
||
388 | 388 | * |
389 | 389 | * @param array $external_plugins An array of external TinyMCE plugins. |
390 | 390 | */ |
391 | - $mce_external_plugins = apply_filters( 'mce_external_plugins', array() ); |
|
391 | + $mce_external_plugins = apply_filters('mce_external_plugins', array()); |
|
392 | 392 | |
393 | 393 | $plugins = array( |
394 | 394 | 'charmap', |
@@ -412,7 +412,7 @@ discard block |
||
412 | 412 | 'wpembed', |
413 | 413 | ); |
414 | 414 | |
415 | - if ( ! self::$has_medialib ) { |
|
415 | + if ( ! self::$has_medialib) { |
|
416 | 416 | $plugins[] = 'image'; |
417 | 417 | } |
418 | 418 | |
@@ -426,15 +426,15 @@ discard block |
||
426 | 426 | * |
427 | 427 | * @param array $plugins An array of default TinyMCE plugins. |
428 | 428 | */ |
429 | - $plugins = array_unique( apply_filters( 'tiny_mce_plugins', $plugins ) ); |
|
429 | + $plugins = array_unique(apply_filters('tiny_mce_plugins', $plugins)); |
|
430 | 430 | |
431 | - if ( ( $key = array_search( 'spellchecker', $plugins ) ) !== false ) { |
|
431 | + if (($key = array_search('spellchecker', $plugins)) !== false) { |
|
432 | 432 | // Remove 'spellchecker' from the internal plugins if added with 'tiny_mce_plugins' filter to prevent errors. |
433 | 433 | // It can be added with 'mce_external_plugins'. |
434 | - unset( $plugins[$key] ); |
|
434 | + unset($plugins[$key]); |
|
435 | 435 | } |
436 | 436 | |
437 | - if ( ! empty( $mce_external_plugins ) ) { |
|
437 | + if ( ! empty($mce_external_plugins)) { |
|
438 | 438 | |
439 | 439 | /** |
440 | 440 | * Filter the translations loaded for external TinyMCE 3.x plugins. |
@@ -449,64 +449,64 @@ discard block |
||
449 | 449 | * |
450 | 450 | * @param array $translations Translations for external TinyMCE plugins. |
451 | 451 | */ |
452 | - $mce_external_languages = apply_filters( 'mce_external_languages', array() ); |
|
452 | + $mce_external_languages = apply_filters('mce_external_languages', array()); |
|
453 | 453 | |
454 | 454 | $loaded_langs = array(); |
455 | 455 | $strings = ''; |
456 | 456 | |
457 | - if ( ! empty( $mce_external_languages ) ) { |
|
458 | - foreach ( $mce_external_languages as $name => $path ) { |
|
459 | - if ( @is_file( $path ) && @is_readable( $path ) ) { |
|
460 | - include_once( $path ); |
|
461 | - $ext_plugins .= $strings . "\n"; |
|
457 | + if ( ! empty($mce_external_languages)) { |
|
458 | + foreach ($mce_external_languages as $name => $path) { |
|
459 | + if (@is_file($path) && @is_readable($path)) { |
|
460 | + include_once($path); |
|
461 | + $ext_plugins .= $strings."\n"; |
|
462 | 462 | $loaded_langs[] = $name; |
463 | 463 | } |
464 | 464 | } |
465 | 465 | } |
466 | 466 | |
467 | - foreach ( $mce_external_plugins as $name => $url ) { |
|
468 | - if ( in_array( $name, $plugins, true ) ) { |
|
469 | - unset( $mce_external_plugins[ $name ] ); |
|
467 | + foreach ($mce_external_plugins as $name => $url) { |
|
468 | + if (in_array($name, $plugins, true)) { |
|
469 | + unset($mce_external_plugins[$name]); |
|
470 | 470 | continue; |
471 | 471 | } |
472 | 472 | |
473 | - $url = set_url_scheme( $url ); |
|
474 | - $mce_external_plugins[ $name ] = $url; |
|
475 | - $plugurl = dirname( $url ); |
|
473 | + $url = set_url_scheme($url); |
|
474 | + $mce_external_plugins[$name] = $url; |
|
475 | + $plugurl = dirname($url); |
|
476 | 476 | $strings = ''; |
477 | 477 | |
478 | 478 | // Try to load langs/[locale].js and langs/[locale]_dlg.js |
479 | - if ( ! in_array( $name, $loaded_langs, true ) ) { |
|
480 | - $path = str_replace( content_url(), '', $plugurl ); |
|
481 | - $path = WP_CONTENT_DIR . $path . '/langs/'; |
|
479 | + if ( ! in_array($name, $loaded_langs, true)) { |
|
480 | + $path = str_replace(content_url(), '', $plugurl); |
|
481 | + $path = WP_CONTENT_DIR.$path.'/langs/'; |
|
482 | 482 | |
483 | - if ( function_exists('realpath') ) |
|
484 | - $path = trailingslashit( realpath($path) ); |
|
483 | + if (function_exists('realpath')) |
|
484 | + $path = trailingslashit(realpath($path)); |
|
485 | 485 | |
486 | - if ( @is_file( $path . $mce_locale . '.js' ) ) |
|
487 | - $strings .= @file_get_contents( $path . $mce_locale . '.js' ) . "\n"; |
|
486 | + if (@is_file($path.$mce_locale.'.js')) |
|
487 | + $strings .= @file_get_contents($path.$mce_locale.'.js')."\n"; |
|
488 | 488 | |
489 | - if ( @is_file( $path . $mce_locale . '_dlg.js' ) ) |
|
490 | - $strings .= @file_get_contents( $path . $mce_locale . '_dlg.js' ) . "\n"; |
|
489 | + if (@is_file($path.$mce_locale.'_dlg.js')) |
|
490 | + $strings .= @file_get_contents($path.$mce_locale.'_dlg.js')."\n"; |
|
491 | 491 | |
492 | - if ( 'en' != $mce_locale && empty( $strings ) ) { |
|
493 | - if ( @is_file( $path . 'en.js' ) ) { |
|
494 | - $str1 = @file_get_contents( $path . 'en.js' ); |
|
495 | - $strings .= preg_replace( '/([\'"])en\./', '$1' . $mce_locale . '.', $str1, 1 ) . "\n"; |
|
492 | + if ('en' != $mce_locale && empty($strings)) { |
|
493 | + if (@is_file($path.'en.js')) { |
|
494 | + $str1 = @file_get_contents($path.'en.js'); |
|
495 | + $strings .= preg_replace('/([\'"])en\./', '$1'.$mce_locale.'.', $str1, 1)."\n"; |
|
496 | 496 | } |
497 | 497 | |
498 | - if ( @is_file( $path . 'en_dlg.js' ) ) { |
|
499 | - $str2 = @file_get_contents( $path . 'en_dlg.js' ); |
|
500 | - $strings .= preg_replace( '/([\'"])en\./', '$1' . $mce_locale . '.', $str2, 1 ) . "\n"; |
|
498 | + if (@is_file($path.'en_dlg.js')) { |
|
499 | + $str2 = @file_get_contents($path.'en_dlg.js'); |
|
500 | + $strings .= preg_replace('/([\'"])en\./', '$1'.$mce_locale.'.', $str2, 1)."\n"; |
|
501 | 501 | } |
502 | 502 | } |
503 | 503 | |
504 | - if ( ! empty( $strings ) ) |
|
505 | - $ext_plugins .= "\n" . $strings . "\n"; |
|
504 | + if ( ! empty($strings)) |
|
505 | + $ext_plugins .= "\n".$strings."\n"; |
|
506 | 506 | } |
507 | 507 | |
508 | - $ext_plugins .= 'tinyMCEPreInit.load_ext("' . $plugurl . '", "' . $mce_locale . '");' . "\n"; |
|
509 | - $ext_plugins .= 'tinymce.PluginManager.load("' . $name . '", "' . $url . '");' . "\n"; |
|
508 | + $ext_plugins .= 'tinyMCEPreInit.load_ext("'.$plugurl.'", "'.$mce_locale.'");'."\n"; |
|
509 | + $ext_plugins .= 'tinymce.PluginManager.load("'.$name.'", "'.$url.'");'."\n"; |
|
510 | 510 | } |
511 | 511 | } |
512 | 512 | } |
@@ -518,20 +518,20 @@ discard block |
||
518 | 518 | 'theme' => 'modern', |
519 | 519 | 'skin' => 'lightgray', |
520 | 520 | 'language' => self::$mce_locale, |
521 | - 'formats' => '{' . |
|
522 | - 'alignleft: [' . |
|
523 | - '{selector: "p,h1,h2,h3,h4,h5,h6,td,th,div,ul,ol,li", styles: {textAlign:"left"}},' . |
|
524 | - '{selector: "img,table,dl.wp-caption", classes: "alignleft"}' . |
|
525 | - '],' . |
|
526 | - 'aligncenter: [' . |
|
527 | - '{selector: "p,h1,h2,h3,h4,h5,h6,td,th,div,ul,ol,li", styles: {textAlign:"center"}},' . |
|
528 | - '{selector: "img,table,dl.wp-caption", classes: "aligncenter"}' . |
|
529 | - '],' . |
|
530 | - 'alignright: [' . |
|
531 | - '{selector: "p,h1,h2,h3,h4,h5,h6,td,th,div,ul,ol,li", styles: {textAlign:"right"}},' . |
|
532 | - '{selector: "img,table,dl.wp-caption", classes: "alignright"}' . |
|
533 | - '],' . |
|
534 | - 'strikethrough: {inline: "del"}' . |
|
521 | + 'formats' => '{'. |
|
522 | + 'alignleft: ['. |
|
523 | + '{selector: "p,h1,h2,h3,h4,h5,h6,td,th,div,ul,ol,li", styles: {textAlign:"left"}},'. |
|
524 | + '{selector: "img,table,dl.wp-caption", classes: "alignleft"}'. |
|
525 | + '],'. |
|
526 | + 'aligncenter: ['. |
|
527 | + '{selector: "p,h1,h2,h3,h4,h5,h6,td,th,div,ul,ol,li", styles: {textAlign:"center"}},'. |
|
528 | + '{selector: "img,table,dl.wp-caption", classes: "aligncenter"}'. |
|
529 | + '],'. |
|
530 | + 'alignright: ['. |
|
531 | + '{selector: "p,h1,h2,h3,h4,h5,h6,td,th,div,ul,ol,li", styles: {textAlign:"right"}},'. |
|
532 | + '{selector: "img,table,dl.wp-caption", classes: "alignright"}'. |
|
533 | + '],'. |
|
534 | + 'strikethrough: {inline: "del"}'. |
|
535 | 535 | '}', |
536 | 536 | 'relative_urls' => false, |
537 | 537 | 'remove_script_host' => false, |
@@ -541,35 +541,35 @@ discard block |
||
541 | 541 | 'entities' => '38,amp,60,lt,62,gt', |
542 | 542 | 'entity_encoding' => 'raw', |
543 | 543 | 'keep_styles' => false, |
544 | - 'cache_suffix' => 'wp-mce-' . $tinymce_version, |
|
544 | + 'cache_suffix' => 'wp-mce-'.$tinymce_version, |
|
545 | 545 | |
546 | 546 | // Limit the preview styles in the menu/toolbar |
547 | 547 | 'preview_styles' => 'font-family font-size font-weight font-style text-decoration text-transform', |
548 | 548 | |
549 | 549 | 'end_container_on_empty_block' => true, |
550 | 550 | 'wpeditimage_disable_captions' => $no_captions, |
551 | - 'wpeditimage_html5_captions' => current_theme_supports( 'html5', 'caption' ), |
|
552 | - 'plugins' => implode( ',', $plugins ), |
|
553 | - 'wp_lang_attr' => get_bloginfo( 'language' ) |
|
551 | + 'wpeditimage_html5_captions' => current_theme_supports('html5', 'caption'), |
|
552 | + 'plugins' => implode(',', $plugins), |
|
553 | + 'wp_lang_attr' => get_bloginfo('language') |
|
554 | 554 | ); |
555 | 555 | |
556 | - if ( ! empty( $mce_external_plugins ) ) { |
|
557 | - self::$first_init['external_plugins'] = wp_json_encode( $mce_external_plugins ); |
|
556 | + if ( ! empty($mce_external_plugins)) { |
|
557 | + self::$first_init['external_plugins'] = wp_json_encode($mce_external_plugins); |
|
558 | 558 | } |
559 | 559 | |
560 | 560 | $suffix = SCRIPT_DEBUG ? '' : '.min'; |
561 | - $version = 'ver=' . $wp_version; |
|
562 | - $dashicons = includes_url( "css/dashicons$suffix.css?$version" ); |
|
561 | + $version = 'ver='.$wp_version; |
|
562 | + $dashicons = includes_url("css/dashicons$suffix.css?$version"); |
|
563 | 563 | |
564 | 564 | // WordPress default stylesheet and dashicons |
565 | 565 | $mce_css = array( |
566 | 566 | $dashicons, |
567 | - self::$baseurl . '/skins/wordpress/wp-content.css?' . $version |
|
567 | + self::$baseurl.'/skins/wordpress/wp-content.css?'.$version |
|
568 | 568 | ); |
569 | 569 | |
570 | 570 | $editor_styles = get_editor_stylesheets(); |
571 | - if ( ! empty( $editor_styles ) ) { |
|
572 | - foreach ( $editor_styles as $style ) { |
|
571 | + if ( ! empty($editor_styles)) { |
|
572 | + foreach ($editor_styles as $style) { |
|
573 | 573 | $mce_css[] = $style; |
574 | 574 | } |
575 | 575 | } |
@@ -581,13 +581,13 @@ discard block |
||
581 | 581 | * |
582 | 582 | * @param string $stylesheets Comma-delimited list of stylesheets. |
583 | 583 | */ |
584 | - $mce_css = trim( apply_filters( 'mce_css', implode( ',', $mce_css ) ), ' ,' ); |
|
584 | + $mce_css = trim(apply_filters('mce_css', implode(',', $mce_css)), ' ,'); |
|
585 | 585 | |
586 | - if ( ! empty($mce_css) ) |
|
586 | + if ( ! empty($mce_css)) |
|
587 | 587 | self::$first_init['content_css'] = $mce_css; |
588 | 588 | } |
589 | 589 | |
590 | - if ( $set['teeny'] ) { |
|
590 | + if ($set['teeny']) { |
|
591 | 591 | |
592 | 592 | /** |
593 | 593 | * Filter the list of teenyMCE buttons (Text tab). |
@@ -597,13 +597,13 @@ discard block |
||
597 | 597 | * @param array $buttons An array of teenyMCE buttons. |
598 | 598 | * @param string $editor_id Unique editor identifier, e.g. 'content'. |
599 | 599 | */ |
600 | - $mce_buttons = apply_filters( 'teeny_mce_buttons', array('bold', 'italic', 'underline', 'blockquote', 'strikethrough', 'bullist', 'numlist', 'alignleft', 'aligncenter', 'alignright', 'undo', 'redo', 'link', 'unlink', 'fullscreen'), $editor_id ); |
|
600 | + $mce_buttons = apply_filters('teeny_mce_buttons', array('bold', 'italic', 'underline', 'blockquote', 'strikethrough', 'bullist', 'numlist', 'alignleft', 'aligncenter', 'alignright', 'undo', 'redo', 'link', 'unlink', 'fullscreen'), $editor_id); |
|
601 | 601 | $mce_buttons_2 = $mce_buttons_3 = $mce_buttons_4 = array(); |
602 | 602 | } else { |
603 | - $mce_buttons = array( 'bold', 'italic', 'strikethrough', 'bullist', 'numlist', 'blockquote', 'hr', 'alignleft', 'aligncenter', 'alignright', 'link', 'unlink', 'wp_more', 'spellchecker' ); |
|
603 | + $mce_buttons = array('bold', 'italic', 'strikethrough', 'bullist', 'numlist', 'blockquote', 'hr', 'alignleft', 'aligncenter', 'alignright', 'link', 'unlink', 'wp_more', 'spellchecker'); |
|
604 | 604 | |
605 | - if ( ! wp_is_mobile() ) { |
|
606 | - if ( $set['_content_editor_dfw'] ) { |
|
605 | + if ( ! wp_is_mobile()) { |
|
606 | + if ($set['_content_editor_dfw']) { |
|
607 | 607 | $mce_buttons[] = 'dfw'; |
608 | 608 | } else { |
609 | 609 | $mce_buttons[] = 'fullscreen'; |
@@ -620,11 +620,11 @@ discard block |
||
620 | 620 | * @param array $buttons First-row list of buttons. |
621 | 621 | * @param string $editor_id Unique editor identifier, e.g. 'content'. |
622 | 622 | */ |
623 | - $mce_buttons = apply_filters( 'mce_buttons', $mce_buttons, $editor_id ); |
|
623 | + $mce_buttons = apply_filters('mce_buttons', $mce_buttons, $editor_id); |
|
624 | 624 | |
625 | - $mce_buttons_2 = array( 'formatselect', 'underline', 'alignjustify', 'forecolor', 'pastetext', 'removeformat', 'charmap', 'outdent', 'indent', 'undo', 'redo' ); |
|
625 | + $mce_buttons_2 = array('formatselect', 'underline', 'alignjustify', 'forecolor', 'pastetext', 'removeformat', 'charmap', 'outdent', 'indent', 'undo', 'redo'); |
|
626 | 626 | |
627 | - if ( ! wp_is_mobile() ) { |
|
627 | + if ( ! wp_is_mobile()) { |
|
628 | 628 | $mce_buttons_2[] = 'wp_help'; |
629 | 629 | } |
630 | 630 | |
@@ -636,7 +636,7 @@ discard block |
||
636 | 636 | * @param array $buttons Second-row list of buttons. |
637 | 637 | * @param string $editor_id Unique editor identifier, e.g. 'content'. |
638 | 638 | */ |
639 | - $mce_buttons_2 = apply_filters( 'mce_buttons_2', $mce_buttons_2, $editor_id ); |
|
639 | + $mce_buttons_2 = apply_filters('mce_buttons_2', $mce_buttons_2, $editor_id); |
|
640 | 640 | |
641 | 641 | /** |
642 | 642 | * Filter the third-row list of TinyMCE buttons (Visual tab). |
@@ -646,7 +646,7 @@ discard block |
||
646 | 646 | * @param array $buttons Third-row list of buttons. |
647 | 647 | * @param string $editor_id Unique editor identifier, e.g. 'content'. |
648 | 648 | */ |
649 | - $mce_buttons_3 = apply_filters( 'mce_buttons_3', array(), $editor_id ); |
|
649 | + $mce_buttons_3 = apply_filters('mce_buttons_3', array(), $editor_id); |
|
650 | 650 | |
651 | 651 | /** |
652 | 652 | * Filter the fourth-row list of TinyMCE buttons (Visual tab). |
@@ -656,30 +656,30 @@ discard block |
||
656 | 656 | * @param array $buttons Fourth-row list of buttons. |
657 | 657 | * @param string $editor_id Unique editor identifier, e.g. 'content'. |
658 | 658 | */ |
659 | - $mce_buttons_4 = apply_filters( 'mce_buttons_4', array(), $editor_id ); |
|
659 | + $mce_buttons_4 = apply_filters('mce_buttons_4', array(), $editor_id); |
|
660 | 660 | } |
661 | 661 | |
662 | 662 | $body_class = $editor_id; |
663 | 663 | |
664 | - if ( $post = get_post() ) { |
|
665 | - $body_class .= ' post-type-' . sanitize_html_class( $post->post_type ) . ' post-status-' . sanitize_html_class( $post->post_status ); |
|
666 | - if ( post_type_supports( $post->post_type, 'post-formats' ) ) { |
|
667 | - $post_format = get_post_format( $post ); |
|
668 | - if ( $post_format && ! is_wp_error( $post_format ) ) |
|
669 | - $body_class .= ' post-format-' . sanitize_html_class( $post_format ); |
|
664 | + if ($post = get_post()) { |
|
665 | + $body_class .= ' post-type-'.sanitize_html_class($post->post_type).' post-status-'.sanitize_html_class($post->post_status); |
|
666 | + if (post_type_supports($post->post_type, 'post-formats')) { |
|
667 | + $post_format = get_post_format($post); |
|
668 | + if ($post_format && ! is_wp_error($post_format)) |
|
669 | + $body_class .= ' post-format-'.sanitize_html_class($post_format); |
|
670 | 670 | else |
671 | 671 | $body_class .= ' post-format-standard'; |
672 | 672 | } |
673 | 673 | } |
674 | 674 | |
675 | - $body_class .= ' locale-' . sanitize_html_class( strtolower( str_replace( '_', '-', get_locale() ) ) ); |
|
675 | + $body_class .= ' locale-'.sanitize_html_class(strtolower(str_replace('_', '-', get_locale()))); |
|
676 | 676 | |
677 | - if ( !empty($set['tinymce']['body_class']) ) { |
|
678 | - $body_class .= ' ' . $set['tinymce']['body_class']; |
|
677 | + if ( ! empty($set['tinymce']['body_class'])) { |
|
678 | + $body_class .= ' '.$set['tinymce']['body_class']; |
|
679 | 679 | unset($set['tinymce']['body_class']); |
680 | 680 | } |
681 | 681 | |
682 | - $mceInit = array ( |
|
682 | + $mceInit = array( |
|
683 | 683 | 'selector' => "#$editor_id", |
684 | 684 | 'resize' => 'vertical', |
685 | 685 | 'menubar' => false, |
@@ -694,10 +694,10 @@ discard block |
||
694 | 694 | ); |
695 | 695 | |
696 | 696 | // Merge with the first part of the init array |
697 | - $mceInit = array_merge( self::$first_init, $mceInit ); |
|
697 | + $mceInit = array_merge(self::$first_init, $mceInit); |
|
698 | 698 | |
699 | - if ( is_array( $set['tinymce'] ) ) |
|
700 | - $mceInit = array_merge( $mceInit, $set['tinymce'] ); |
|
699 | + if (is_array($set['tinymce'])) |
|
700 | + $mceInit = array_merge($mceInit, $set['tinymce']); |
|
701 | 701 | |
702 | 702 | /* |
703 | 703 | * For people who really REALLY know what they're doing with TinyMCE |
@@ -707,7 +707,7 @@ discard block |
||
707 | 707 | * is to use the default cleanup by not specifying valid_elements, |
708 | 708 | * as TinyMCE checks against the full set of HTML 5.0 elements and attributes. |
709 | 709 | */ |
710 | - if ( $set['teeny'] ) { |
|
710 | + if ($set['teeny']) { |
|
711 | 711 | |
712 | 712 | /** |
713 | 713 | * Filter the teenyMCE config before init. |
@@ -717,7 +717,7 @@ discard block |
||
717 | 717 | * @param array $mceInit An array with teenyMCE config. |
718 | 718 | * @param string $editor_id Unique editor identifier, e.g. 'content'. |
719 | 719 | */ |
720 | - $mceInit = apply_filters( 'teeny_mce_before_init', $mceInit, $editor_id ); |
|
720 | + $mceInit = apply_filters('teeny_mce_before_init', $mceInit, $editor_id); |
|
721 | 721 | } else { |
722 | 722 | |
723 | 723 | /** |
@@ -728,10 +728,10 @@ discard block |
||
728 | 728 | * @param array $mceInit An array with TinyMCE config. |
729 | 729 | * @param string $editor_id Unique editor identifier, e.g. 'content'. |
730 | 730 | */ |
731 | - $mceInit = apply_filters( 'tiny_mce_before_init', $mceInit, $editor_id ); |
|
731 | + $mceInit = apply_filters('tiny_mce_before_init', $mceInit, $editor_id); |
|
732 | 732 | } |
733 | 733 | |
734 | - if ( empty( $mceInit['toolbar3'] ) && ! empty( $mceInit['toolbar4'] ) ) { |
|
734 | + if (empty($mceInit['toolbar3']) && ! empty($mceInit['toolbar4'])) { |
|
735 | 735 | $mceInit['toolbar3'] = $mceInit['toolbar4']; |
736 | 736 | $mceInit['toolbar4'] = ''; |
737 | 737 | } |
@@ -749,19 +749,19 @@ discard block |
||
749 | 749 | private static function _parse_init($init) { |
750 | 750 | $options = ''; |
751 | 751 | |
752 | - foreach ( $init as $k => $v ) { |
|
753 | - if ( is_bool($v) ) { |
|
752 | + foreach ($init as $k => $v) { |
|
753 | + if (is_bool($v)) { |
|
754 | 754 | $val = $v ? 'true' : 'false'; |
755 | - $options .= $k . ':' . $val . ','; |
|
755 | + $options .= $k.':'.$val.','; |
|
756 | 756 | continue; |
757 | - } elseif ( !empty($v) && is_string($v) && ( ('{' == $v{0} && '}' == $v{strlen($v) - 1}) || ('[' == $v{0} && ']' == $v{strlen($v) - 1}) || preg_match('/^\(?function ?\(/', $v) ) ) { |
|
758 | - $options .= $k . ':' . $v . ','; |
|
757 | + } elseif ( ! empty($v) && is_string($v) && (('{' == $v{0} && '}' == $v{strlen($v) - 1}) || ('[' == $v{0} && ']' == $v{strlen($v) - 1}) || preg_match('/^\(?function ?\(/', $v))) { |
|
758 | + $options .= $k.':'.$v.','; |
|
759 | 759 | continue; |
760 | 760 | } |
761 | - $options .= $k . ':"' . $v . '",'; |
|
761 | + $options .= $k.':"'.$v.'",'; |
|
762 | 762 | } |
763 | 763 | |
764 | - return '{' . trim( $options, ' ,' ) . '}'; |
|
764 | + return '{'.trim($options, ' ,').'}'; |
|
765 | 765 | } |
766 | 766 | |
767 | 767 | /** |
@@ -769,24 +769,24 @@ discard block |
||
769 | 769 | * @static |
770 | 770 | */ |
771 | 771 | public static function enqueue_scripts() { |
772 | - if ( self::$has_tinymce ) |
|
772 | + if (self::$has_tinymce) |
|
773 | 773 | wp_enqueue_script('editor'); |
774 | 774 | |
775 | - if ( self::$has_quicktags ) { |
|
776 | - wp_enqueue_script( 'quicktags' ); |
|
777 | - wp_enqueue_style( 'buttons' ); |
|
775 | + if (self::$has_quicktags) { |
|
776 | + wp_enqueue_script('quicktags'); |
|
777 | + wp_enqueue_style('buttons'); |
|
778 | 778 | } |
779 | 779 | |
780 | - if ( in_array('wplink', self::$plugins, true) || in_array('link', self::$qt_buttons, true) ) { |
|
780 | + if (in_array('wplink', self::$plugins, true) || in_array('link', self::$qt_buttons, true)) { |
|
781 | 781 | wp_enqueue_script('wplink'); |
782 | - wp_enqueue_script( 'jquery-ui-autocomplete' ); |
|
782 | + wp_enqueue_script('jquery-ui-autocomplete'); |
|
783 | 783 | } |
784 | 784 | |
785 | - if ( self::$old_dfw_compat ) { |
|
785 | + if (self::$old_dfw_compat) { |
|
786 | 786 | wp_enqueue_script('wp-fullscreen-stub'); |
787 | 787 | } |
788 | 788 | |
789 | - if ( self::$has_medialib ) { |
|
789 | + if (self::$has_medialib) { |
|
790 | 790 | add_thickbox(); |
791 | 791 | wp_enqueue_script('media-upload'); |
792 | 792 | } |
@@ -799,10 +799,10 @@ discard block |
||
799 | 799 | * @param array $to_load An array containing boolean values whether TinyMCE |
800 | 800 | * and Quicktags are being loaded. |
801 | 801 | */ |
802 | - do_action( 'wp_enqueue_editor', array( |
|
802 | + do_action('wp_enqueue_editor', array( |
|
803 | 803 | 'tinymce' => self::$has_tinymce, |
804 | 804 | 'quicktags' => self::$has_quicktags, |
805 | - ) ); |
|
805 | + )); |
|
806 | 806 | } |
807 | 807 | |
808 | 808 | /** |
@@ -814,261 +814,261 @@ discard block |
||
814 | 814 | * @param bool $json_only optional Whether to include the JavaScript calls to tinymce.addI18n() and tinymce.ScriptLoader.markDone(). |
815 | 815 | * @return string Translation object, JSON encoded. |
816 | 816 | */ |
817 | - public static function wp_mce_translation( $mce_locale = '', $json_only = false ) { |
|
817 | + public static function wp_mce_translation($mce_locale = '', $json_only = false) { |
|
818 | 818 | |
819 | 819 | $mce_translation = array( |
820 | 820 | // Default TinyMCE strings |
821 | - 'New document' => __( 'New document' ), |
|
822 | - 'Formats' => _x( 'Formats', 'TinyMCE' ), |
|
821 | + 'New document' => __('New document'), |
|
822 | + 'Formats' => _x('Formats', 'TinyMCE'), |
|
823 | 823 | |
824 | - 'Headings' => _x( 'Headings', 'TinyMCE' ), |
|
825 | - 'Heading 1' => __( 'Heading 1' ), |
|
826 | - 'Heading 2' => __( 'Heading 2' ), |
|
827 | - 'Heading 3' => __( 'Heading 3' ), |
|
828 | - 'Heading 4' => __( 'Heading 4' ), |
|
829 | - 'Heading 5' => __( 'Heading 5' ), |
|
830 | - 'Heading 6' => __( 'Heading 6' ), |
|
824 | + 'Headings' => _x('Headings', 'TinyMCE'), |
|
825 | + 'Heading 1' => __('Heading 1'), |
|
826 | + 'Heading 2' => __('Heading 2'), |
|
827 | + 'Heading 3' => __('Heading 3'), |
|
828 | + 'Heading 4' => __('Heading 4'), |
|
829 | + 'Heading 5' => __('Heading 5'), |
|
830 | + 'Heading 6' => __('Heading 6'), |
|
831 | 831 | |
832 | 832 | /* translators: block tags */ |
833 | - 'Blocks' => _x( 'Blocks', 'TinyMCE' ), |
|
834 | - 'Paragraph' => __( 'Paragraph' ), |
|
835 | - 'Blockquote' => __( 'Blockquote' ), |
|
836 | - 'Div' => _x( 'Div', 'HTML tag' ), |
|
837 | - 'Pre' => _x( 'Pre', 'HTML tag' ), |
|
838 | - 'Preformatted' => _x( 'Preformatted', 'HTML tag' ), |
|
839 | - 'Address' => _x( 'Address', 'HTML tag' ), |
|
840 | - |
|
841 | - 'Inline' => _x( 'Inline', 'HTML elements' ), |
|
842 | - 'Underline' => __( 'Underline' ), |
|
843 | - 'Strikethrough' => __( 'Strikethrough' ), |
|
844 | - 'Subscript' => __( 'Subscript' ), |
|
845 | - 'Superscript' => __( 'Superscript' ), |
|
846 | - 'Clear formatting' => __( 'Clear formatting' ), |
|
847 | - 'Bold' => __( 'Bold' ), |
|
848 | - 'Italic' => __( 'Italic' ), |
|
849 | - 'Code' => _x( 'Code', 'editor button' ), |
|
850 | - 'Source code' => __( 'Source code' ), |
|
851 | - 'Font Family' => __( 'Font Family' ), |
|
852 | - 'Font Sizes' => __( 'Font Sizes' ), |
|
853 | - |
|
854 | - 'Align center' => __( 'Align center' ), |
|
855 | - 'Align right' => __( 'Align right' ), |
|
856 | - 'Align left' => __( 'Align left' ), |
|
857 | - 'Justify' => __( 'Justify' ), |
|
858 | - 'Increase indent' => __( 'Increase indent' ), |
|
859 | - 'Decrease indent' => __( 'Decrease indent' ), |
|
860 | - |
|
861 | - 'Cut' => __( 'Cut' ), |
|
862 | - 'Copy' => __( 'Copy' ), |
|
863 | - 'Paste' => __( 'Paste' ), |
|
864 | - 'Select all' => __( 'Select all' ), |
|
865 | - 'Undo' => __( 'Undo' ), |
|
866 | - 'Redo' => __( 'Redo' ), |
|
867 | - |
|
868 | - 'Ok' => __( 'OK' ), |
|
869 | - 'Cancel' => __( 'Cancel' ), |
|
870 | - 'Close' => __( 'Close' ), |
|
871 | - 'Visual aids' => __( 'Visual aids' ), |
|
872 | - |
|
873 | - 'Bullet list' => __( 'Bulleted list' ), |
|
874 | - 'Numbered list' => __( 'Numbered list' ), |
|
875 | - 'Square' => _x( 'Square', 'list style' ), |
|
876 | - 'Default' => _x( 'Default', 'list style' ), |
|
877 | - 'Circle' => _x( 'Circle', 'list style' ), |
|
878 | - 'Disc' => _x('Disc', 'list style' ), |
|
879 | - 'Lower Greek' => _x( 'Lower Greek', 'list style' ), |
|
880 | - 'Lower Alpha' => _x( 'Lower Alpha', 'list style' ), |
|
881 | - 'Upper Alpha' => _x( 'Upper Alpha', 'list style' ), |
|
882 | - 'Upper Roman' => _x( 'Upper Roman', 'list style' ), |
|
883 | - 'Lower Roman' => _x( 'Lower Roman', 'list style' ), |
|
833 | + 'Blocks' => _x('Blocks', 'TinyMCE'), |
|
834 | + 'Paragraph' => __('Paragraph'), |
|
835 | + 'Blockquote' => __('Blockquote'), |
|
836 | + 'Div' => _x('Div', 'HTML tag'), |
|
837 | + 'Pre' => _x('Pre', 'HTML tag'), |
|
838 | + 'Preformatted' => _x('Preformatted', 'HTML tag'), |
|
839 | + 'Address' => _x('Address', 'HTML tag'), |
|
840 | + |
|
841 | + 'Inline' => _x('Inline', 'HTML elements'), |
|
842 | + 'Underline' => __('Underline'), |
|
843 | + 'Strikethrough' => __('Strikethrough'), |
|
844 | + 'Subscript' => __('Subscript'), |
|
845 | + 'Superscript' => __('Superscript'), |
|
846 | + 'Clear formatting' => __('Clear formatting'), |
|
847 | + 'Bold' => __('Bold'), |
|
848 | + 'Italic' => __('Italic'), |
|
849 | + 'Code' => _x('Code', 'editor button'), |
|
850 | + 'Source code' => __('Source code'), |
|
851 | + 'Font Family' => __('Font Family'), |
|
852 | + 'Font Sizes' => __('Font Sizes'), |
|
853 | + |
|
854 | + 'Align center' => __('Align center'), |
|
855 | + 'Align right' => __('Align right'), |
|
856 | + 'Align left' => __('Align left'), |
|
857 | + 'Justify' => __('Justify'), |
|
858 | + 'Increase indent' => __('Increase indent'), |
|
859 | + 'Decrease indent' => __('Decrease indent'), |
|
860 | + |
|
861 | + 'Cut' => __('Cut'), |
|
862 | + 'Copy' => __('Copy'), |
|
863 | + 'Paste' => __('Paste'), |
|
864 | + 'Select all' => __('Select all'), |
|
865 | + 'Undo' => __('Undo'), |
|
866 | + 'Redo' => __('Redo'), |
|
867 | + |
|
868 | + 'Ok' => __('OK'), |
|
869 | + 'Cancel' => __('Cancel'), |
|
870 | + 'Close' => __('Close'), |
|
871 | + 'Visual aids' => __('Visual aids'), |
|
872 | + |
|
873 | + 'Bullet list' => __('Bulleted list'), |
|
874 | + 'Numbered list' => __('Numbered list'), |
|
875 | + 'Square' => _x('Square', 'list style'), |
|
876 | + 'Default' => _x('Default', 'list style'), |
|
877 | + 'Circle' => _x('Circle', 'list style'), |
|
878 | + 'Disc' => _x('Disc', 'list style'), |
|
879 | + 'Lower Greek' => _x('Lower Greek', 'list style'), |
|
880 | + 'Lower Alpha' => _x('Lower Alpha', 'list style'), |
|
881 | + 'Upper Alpha' => _x('Upper Alpha', 'list style'), |
|
882 | + 'Upper Roman' => _x('Upper Roman', 'list style'), |
|
883 | + 'Lower Roman' => _x('Lower Roman', 'list style'), |
|
884 | 884 | |
885 | 885 | // Anchor plugin |
886 | - 'Name' => _x( 'Name', 'Name of link anchor (TinyMCE)' ), |
|
887 | - 'Anchor' => _x( 'Anchor', 'Link anchor (TinyMCE)' ), |
|
888 | - 'Anchors' => _x( 'Anchors', 'Link anchors (TinyMCE)' ), |
|
886 | + 'Name' => _x('Name', 'Name of link anchor (TinyMCE)'), |
|
887 | + 'Anchor' => _x('Anchor', 'Link anchor (TinyMCE)'), |
|
888 | + 'Anchors' => _x('Anchors', 'Link anchors (TinyMCE)'), |
|
889 | 889 | |
890 | 890 | // Fullpage plugin |
891 | - 'Document properties' => __( 'Document properties' ), |
|
892 | - 'Robots' => __( 'Robots' ), |
|
893 | - 'Title' => __( 'Title' ), |
|
894 | - 'Keywords' => __( 'Keywords' ), |
|
895 | - 'Encoding' => __( 'Encoding' ), |
|
896 | - 'Description' => __( 'Description' ), |
|
897 | - 'Author' => __( 'Author' ), |
|
891 | + 'Document properties' => __('Document properties'), |
|
892 | + 'Robots' => __('Robots'), |
|
893 | + 'Title' => __('Title'), |
|
894 | + 'Keywords' => __('Keywords'), |
|
895 | + 'Encoding' => __('Encoding'), |
|
896 | + 'Description' => __('Description'), |
|
897 | + 'Author' => __('Author'), |
|
898 | 898 | |
899 | 899 | // Media, image plugins |
900 | - 'Insert/edit image' => __( 'Insert/edit image' ), |
|
901 | - 'General' => __( 'General' ), |
|
902 | - 'Advanced' => __( 'Advanced' ), |
|
903 | - 'Source' => __( 'Source' ), |
|
904 | - 'Border' => __( 'Border' ), |
|
905 | - 'Constrain proportions' => __( 'Constrain proportions' ), |
|
906 | - 'Vertical space' => __( 'Vertical space' ), |
|
907 | - 'Image description' => __( 'Image description' ), |
|
908 | - 'Style' => __( 'Style' ), |
|
909 | - 'Dimensions' => __( 'Dimensions' ), |
|
910 | - 'Insert image' => __( 'Insert image' ), |
|
911 | - 'Insert date/time' => __( 'Insert date/time' ), |
|
912 | - 'Insert/edit video' => __( 'Insert/edit video' ), |
|
913 | - 'Poster' => __( 'Poster' ), |
|
914 | - 'Alternative source' => __( 'Alternative source' ), |
|
915 | - 'Paste your embed code below:' => __( 'Paste your embed code below:' ), |
|
916 | - 'Insert video' => __( 'Insert video' ), |
|
917 | - 'Embed' => __( 'Embed' ), |
|
900 | + 'Insert/edit image' => __('Insert/edit image'), |
|
901 | + 'General' => __('General'), |
|
902 | + 'Advanced' => __('Advanced'), |
|
903 | + 'Source' => __('Source'), |
|
904 | + 'Border' => __('Border'), |
|
905 | + 'Constrain proportions' => __('Constrain proportions'), |
|
906 | + 'Vertical space' => __('Vertical space'), |
|
907 | + 'Image description' => __('Image description'), |
|
908 | + 'Style' => __('Style'), |
|
909 | + 'Dimensions' => __('Dimensions'), |
|
910 | + 'Insert image' => __('Insert image'), |
|
911 | + 'Insert date/time' => __('Insert date/time'), |
|
912 | + 'Insert/edit video' => __('Insert/edit video'), |
|
913 | + 'Poster' => __('Poster'), |
|
914 | + 'Alternative source' => __('Alternative source'), |
|
915 | + 'Paste your embed code below:' => __('Paste your embed code below:'), |
|
916 | + 'Insert video' => __('Insert video'), |
|
917 | + 'Embed' => __('Embed'), |
|
918 | 918 | |
919 | 919 | // Each of these have a corresponding plugin |
920 | - 'Special character' => __( 'Special character' ), |
|
921 | - 'Right to left' => _x( 'Right to left', 'editor button' ), |
|
922 | - 'Left to right' => _x( 'Left to right', 'editor button' ), |
|
923 | - 'Emoticons' => __( 'Emoticons' ), |
|
924 | - 'Nonbreaking space' => __( 'Nonbreaking space' ), |
|
925 | - 'Page break' => __( 'Page break' ), |
|
926 | - 'Paste as text' => __( 'Paste as text' ), |
|
927 | - 'Preview' => __( 'Preview' ), |
|
928 | - 'Print' => __( 'Print' ), |
|
929 | - 'Save' => __( 'Save' ), |
|
930 | - 'Fullscreen' => __( 'Fullscreen' ), |
|
931 | - 'Horizontal line' => __( 'Horizontal line' ), |
|
932 | - 'Horizontal space' => __( 'Horizontal space' ), |
|
933 | - 'Restore last draft' => __( 'Restore last draft' ), |
|
934 | - 'Insert/edit link' => __( 'Insert/edit link' ), |
|
935 | - 'Remove link' => __( 'Remove link' ), |
|
936 | - |
|
937 | - 'Color' => __( 'Color' ), |
|
938 | - 'Custom color' => __( 'Custom color' ), |
|
939 | - 'Custom...' => _x( 'Custom...', 'label for custom color' ), // no ellipsis |
|
940 | - 'No color' => __( 'No color' ), |
|
920 | + 'Special character' => __('Special character'), |
|
921 | + 'Right to left' => _x('Right to left', 'editor button'), |
|
922 | + 'Left to right' => _x('Left to right', 'editor button'), |
|
923 | + 'Emoticons' => __('Emoticons'), |
|
924 | + 'Nonbreaking space' => __('Nonbreaking space'), |
|
925 | + 'Page break' => __('Page break'), |
|
926 | + 'Paste as text' => __('Paste as text'), |
|
927 | + 'Preview' => __('Preview'), |
|
928 | + 'Print' => __('Print'), |
|
929 | + 'Save' => __('Save'), |
|
930 | + 'Fullscreen' => __('Fullscreen'), |
|
931 | + 'Horizontal line' => __('Horizontal line'), |
|
932 | + 'Horizontal space' => __('Horizontal space'), |
|
933 | + 'Restore last draft' => __('Restore last draft'), |
|
934 | + 'Insert/edit link' => __('Insert/edit link'), |
|
935 | + 'Remove link' => __('Remove link'), |
|
936 | + |
|
937 | + 'Color' => __('Color'), |
|
938 | + 'Custom color' => __('Custom color'), |
|
939 | + 'Custom...' => _x('Custom...', 'label for custom color'), // no ellipsis |
|
940 | + 'No color' => __('No color'), |
|
941 | 941 | |
942 | 942 | // Spelling, search/replace plugins |
943 | - 'Could not find the specified string.' => __( 'Could not find the specified string.' ), |
|
944 | - 'Replace' => _x( 'Replace', 'find/replace' ), |
|
945 | - 'Next' => _x( 'Next', 'find/replace' ), |
|
943 | + 'Could not find the specified string.' => __('Could not find the specified string.'), |
|
944 | + 'Replace' => _x('Replace', 'find/replace'), |
|
945 | + 'Next' => _x('Next', 'find/replace'), |
|
946 | 946 | /* translators: previous */ |
947 | - 'Prev' => _x( 'Prev', 'find/replace' ), |
|
948 | - 'Whole words' => _x( 'Whole words', 'find/replace' ), |
|
949 | - 'Find and replace' => __( 'Find and replace' ), |
|
950 | - 'Replace with' => _x('Replace with', 'find/replace' ), |
|
951 | - 'Find' => _x( 'Find', 'find/replace' ), |
|
952 | - 'Replace all' => _x( 'Replace all', 'find/replace' ), |
|
953 | - 'Match case' => __( 'Match case' ), |
|
954 | - 'Spellcheck' => __( 'Check Spelling' ), |
|
955 | - 'Finish' => _x( 'Finish', 'spellcheck' ), |
|
956 | - 'Ignore all' => _x( 'Ignore all', 'spellcheck' ), |
|
957 | - 'Ignore' => _x( 'Ignore', 'spellcheck' ), |
|
958 | - 'Add to Dictionary' => __( 'Add to Dictionary' ), |
|
947 | + 'Prev' => _x('Prev', 'find/replace'), |
|
948 | + 'Whole words' => _x('Whole words', 'find/replace'), |
|
949 | + 'Find and replace' => __('Find and replace'), |
|
950 | + 'Replace with' => _x('Replace with', 'find/replace'), |
|
951 | + 'Find' => _x('Find', 'find/replace'), |
|
952 | + 'Replace all' => _x('Replace all', 'find/replace'), |
|
953 | + 'Match case' => __('Match case'), |
|
954 | + 'Spellcheck' => __('Check Spelling'), |
|
955 | + 'Finish' => _x('Finish', 'spellcheck'), |
|
956 | + 'Ignore all' => _x('Ignore all', 'spellcheck'), |
|
957 | + 'Ignore' => _x('Ignore', 'spellcheck'), |
|
958 | + 'Add to Dictionary' => __('Add to Dictionary'), |
|
959 | 959 | |
960 | 960 | // TinyMCE tables |
961 | - 'Insert table' => __( 'Insert table' ), |
|
962 | - 'Delete table' => __( 'Delete table' ), |
|
963 | - 'Table properties' => __( 'Table properties' ), |
|
964 | - 'Row properties' => __( 'Table row properties' ), |
|
965 | - 'Cell properties' => __( 'Table cell properties' ), |
|
966 | - 'Border color' => __( 'Border color' ), |
|
967 | - |
|
968 | - 'Row' => __( 'Row' ), |
|
969 | - 'Rows' => __( 'Rows' ), |
|
970 | - 'Column' => _x( 'Column', 'table column' ), |
|
971 | - 'Cols' => _x( 'Cols', 'table columns' ), |
|
972 | - 'Cell' => _x( 'Cell', 'table cell' ), |
|
973 | - 'Header cell' => __( 'Header cell' ), |
|
974 | - 'Header' => _x( 'Header', 'table header' ), |
|
975 | - 'Body' => _x( 'Body', 'table body' ), |
|
976 | - 'Footer' => _x( 'Footer', 'table footer' ), |
|
977 | - |
|
978 | - 'Insert row before' => __( 'Insert row before' ), |
|
979 | - 'Insert row after' => __( 'Insert row after' ), |
|
980 | - 'Insert column before' => __( 'Insert column before' ), |
|
981 | - 'Insert column after' => __( 'Insert column after' ), |
|
982 | - 'Paste row before' => __( 'Paste table row before' ), |
|
983 | - 'Paste row after' => __( 'Paste table row after' ), |
|
984 | - 'Delete row' => __( 'Delete row' ), |
|
985 | - 'Delete column' => __( 'Delete column' ), |
|
986 | - 'Cut row' => __( 'Cut table row' ), |
|
987 | - 'Copy row' => __( 'Copy table row' ), |
|
988 | - 'Merge cells' => __( 'Merge table cells' ), |
|
989 | - 'Split cell' => __( 'Split table cell' ), |
|
990 | - |
|
991 | - 'Height' => __( 'Height' ), |
|
992 | - 'Width' => __( 'Width' ), |
|
993 | - 'Caption' => __( 'Caption' ), |
|
994 | - 'Alignment' => __( 'Alignment' ), |
|
995 | - 'H Align' => _x( 'H Align', 'horizontal table cell alignment' ), |
|
996 | - 'Left' => __( 'Left' ), |
|
997 | - 'Center' => __( 'Center' ), |
|
998 | - 'Right' => __( 'Right' ), |
|
999 | - 'None' => _x( 'None', 'table cell alignment attribute' ), |
|
1000 | - 'V Align' => _x( 'V Align', 'vertical table cell alignment' ), |
|
1001 | - 'Top' => __( 'Top' ), |
|
1002 | - 'Middle' => __( 'Middle' ), |
|
1003 | - 'Bottom' => __( 'Bottom' ), |
|
1004 | - |
|
1005 | - 'Row group' => __( 'Row group' ), |
|
1006 | - 'Column group' => __( 'Column group' ), |
|
1007 | - 'Row type' => __( 'Row type' ), |
|
1008 | - 'Cell type' => __( 'Cell type' ), |
|
1009 | - 'Cell padding' => __( 'Cell padding' ), |
|
1010 | - 'Cell spacing' => __( 'Cell spacing' ), |
|
1011 | - 'Scope' => _x( 'Scope', 'table cell scope attribute' ), |
|
1012 | - |
|
1013 | - 'Insert template' => _x( 'Insert template', 'TinyMCE' ), |
|
1014 | - 'Templates' => _x( 'Templates', 'TinyMCE' ), |
|
1015 | - |
|
1016 | - 'Background color' => __( 'Background color' ), |
|
1017 | - 'Text color' => __( 'Text color' ), |
|
1018 | - 'Show blocks' => _x( 'Show blocks', 'editor button' ), |
|
1019 | - 'Show invisible characters' => __( 'Show invisible characters' ), |
|
961 | + 'Insert table' => __('Insert table'), |
|
962 | + 'Delete table' => __('Delete table'), |
|
963 | + 'Table properties' => __('Table properties'), |
|
964 | + 'Row properties' => __('Table row properties'), |
|
965 | + 'Cell properties' => __('Table cell properties'), |
|
966 | + 'Border color' => __('Border color'), |
|
967 | + |
|
968 | + 'Row' => __('Row'), |
|
969 | + 'Rows' => __('Rows'), |
|
970 | + 'Column' => _x('Column', 'table column'), |
|
971 | + 'Cols' => _x('Cols', 'table columns'), |
|
972 | + 'Cell' => _x('Cell', 'table cell'), |
|
973 | + 'Header cell' => __('Header cell'), |
|
974 | + 'Header' => _x('Header', 'table header'), |
|
975 | + 'Body' => _x('Body', 'table body'), |
|
976 | + 'Footer' => _x('Footer', 'table footer'), |
|
977 | + |
|
978 | + 'Insert row before' => __('Insert row before'), |
|
979 | + 'Insert row after' => __('Insert row after'), |
|
980 | + 'Insert column before' => __('Insert column before'), |
|
981 | + 'Insert column after' => __('Insert column after'), |
|
982 | + 'Paste row before' => __('Paste table row before'), |
|
983 | + 'Paste row after' => __('Paste table row after'), |
|
984 | + 'Delete row' => __('Delete row'), |
|
985 | + 'Delete column' => __('Delete column'), |
|
986 | + 'Cut row' => __('Cut table row'), |
|
987 | + 'Copy row' => __('Copy table row'), |
|
988 | + 'Merge cells' => __('Merge table cells'), |
|
989 | + 'Split cell' => __('Split table cell'), |
|
990 | + |
|
991 | + 'Height' => __('Height'), |
|
992 | + 'Width' => __('Width'), |
|
993 | + 'Caption' => __('Caption'), |
|
994 | + 'Alignment' => __('Alignment'), |
|
995 | + 'H Align' => _x('H Align', 'horizontal table cell alignment'), |
|
996 | + 'Left' => __('Left'), |
|
997 | + 'Center' => __('Center'), |
|
998 | + 'Right' => __('Right'), |
|
999 | + 'None' => _x('None', 'table cell alignment attribute'), |
|
1000 | + 'V Align' => _x('V Align', 'vertical table cell alignment'), |
|
1001 | + 'Top' => __('Top'), |
|
1002 | + 'Middle' => __('Middle'), |
|
1003 | + 'Bottom' => __('Bottom'), |
|
1004 | + |
|
1005 | + 'Row group' => __('Row group'), |
|
1006 | + 'Column group' => __('Column group'), |
|
1007 | + 'Row type' => __('Row type'), |
|
1008 | + 'Cell type' => __('Cell type'), |
|
1009 | + 'Cell padding' => __('Cell padding'), |
|
1010 | + 'Cell spacing' => __('Cell spacing'), |
|
1011 | + 'Scope' => _x('Scope', 'table cell scope attribute'), |
|
1012 | + |
|
1013 | + 'Insert template' => _x('Insert template', 'TinyMCE'), |
|
1014 | + 'Templates' => _x('Templates', 'TinyMCE'), |
|
1015 | + |
|
1016 | + 'Background color' => __('Background color'), |
|
1017 | + 'Text color' => __('Text color'), |
|
1018 | + 'Show blocks' => _x('Show blocks', 'editor button'), |
|
1019 | + 'Show invisible characters' => __('Show invisible characters'), |
|
1020 | 1020 | |
1021 | 1021 | /* translators: word count */ |
1022 | - 'Words: {0}' => sprintf( __( 'Words: %s' ), '{0}' ), |
|
1023 | - 'Paste is now in plain text mode. Contents will now be pasted as plain text until you toggle this option off.' => __( 'Paste is now in plain text mode. Contents will now be pasted as plain text until you toggle this option off.' ) . "\n\n" . __( 'If you’re looking to paste rich content from Microsoft Word, try turning this option off. The editor will clean up text pasted from Word automatically.' ), |
|
1024 | - 'Rich Text Area. Press ALT-F9 for menu. Press ALT-F10 for toolbar. Press ALT-0 for help' => __( 'Rich Text Area. Press Alt-Shift-H for help' ), |
|
1025 | - 'You have unsaved changes are you sure you want to navigate away?' => __( 'The changes you made will be lost if you navigate away from this page.' ), |
|
1026 | - 'Your browser doesn\'t support direct access to the clipboard. Please use the Ctrl+X/C/V keyboard shortcuts instead.' => __( 'Your browser does not support direct access to the clipboard. Please use keyboard shortcuts or your browser’s edit menu instead.' ), |
|
1022 | + 'Words: {0}' => sprintf(__('Words: %s'), '{0}'), |
|
1023 | + 'Paste is now in plain text mode. Contents will now be pasted as plain text until you toggle this option off.' => __('Paste is now in plain text mode. Contents will now be pasted as plain text until you toggle this option off.')."\n\n".__('If you’re looking to paste rich content from Microsoft Word, try turning this option off. The editor will clean up text pasted from Word automatically.'), |
|
1024 | + 'Rich Text Area. Press ALT-F9 for menu. Press ALT-F10 for toolbar. Press ALT-0 for help' => __('Rich Text Area. Press Alt-Shift-H for help'), |
|
1025 | + 'You have unsaved changes are you sure you want to navigate away?' => __('The changes you made will be lost if you navigate away from this page.'), |
|
1026 | + 'Your browser doesn\'t support direct access to the clipboard. Please use the Ctrl+X/C/V keyboard shortcuts instead.' => __('Your browser does not support direct access to the clipboard. Please use keyboard shortcuts or your browser’s edit menu instead.'), |
|
1027 | 1027 | |
1028 | 1028 | // TinyMCE menus |
1029 | - 'Insert' => _x( 'Insert', 'TinyMCE menu' ), |
|
1030 | - 'File' => _x( 'File', 'TinyMCE menu' ), |
|
1031 | - 'Edit' => _x( 'Edit', 'TinyMCE menu' ), |
|
1032 | - 'Tools' => _x( 'Tools', 'TinyMCE menu' ), |
|
1033 | - 'View' => _x( 'View', 'TinyMCE menu' ), |
|
1034 | - 'Table' => _x( 'Table', 'TinyMCE menu' ), |
|
1035 | - 'Format' => _x( 'Format', 'TinyMCE menu' ), |
|
1029 | + 'Insert' => _x('Insert', 'TinyMCE menu'), |
|
1030 | + 'File' => _x('File', 'TinyMCE menu'), |
|
1031 | + 'Edit' => _x('Edit', 'TinyMCE menu'), |
|
1032 | + 'Tools' => _x('Tools', 'TinyMCE menu'), |
|
1033 | + 'View' => _x('View', 'TinyMCE menu'), |
|
1034 | + 'Table' => _x('Table', 'TinyMCE menu'), |
|
1035 | + 'Format' => _x('Format', 'TinyMCE menu'), |
|
1036 | 1036 | |
1037 | 1037 | // WordPress strings |
1038 | - 'Toolbar Toggle' => __( 'Toolbar Toggle' ), |
|
1039 | - 'Insert Read More tag' => __( 'Insert Read More tag' ), |
|
1040 | - 'Insert Page Break tag' => __( 'Insert Page Break tag' ), |
|
1041 | - 'Read more...' => __( 'Read more...' ), // Title on the placeholder inside the editor (no ellipsis) |
|
1042 | - 'Distraction-free writing mode' => __( 'Distraction-free writing mode' ), |
|
1043 | - 'No alignment' => __( 'No alignment' ), // Tooltip for the 'alignnone' button in the image toolbar |
|
1044 | - 'Remove' => __( 'Remove' ), // Tooltip for the 'remove' button in the image toolbar |
|
1045 | - 'Edit ' => __( 'Edit' ), // Tooltip for the 'edit' button in the image toolbar |
|
1046 | - 'Paste URL or type to search' => __( 'Paste URL or type to search' ), // Placeholder for the inline link dialog |
|
1047 | - 'Link options' => __( 'Link options' ), |
|
1038 | + 'Toolbar Toggle' => __('Toolbar Toggle'), |
|
1039 | + 'Insert Read More tag' => __('Insert Read More tag'), |
|
1040 | + 'Insert Page Break tag' => __('Insert Page Break tag'), |
|
1041 | + 'Read more...' => __('Read more...'), // Title on the placeholder inside the editor (no ellipsis) |
|
1042 | + 'Distraction-free writing mode' => __('Distraction-free writing mode'), |
|
1043 | + 'No alignment' => __('No alignment'), // Tooltip for the 'alignnone' button in the image toolbar |
|
1044 | + 'Remove' => __('Remove'), // Tooltip for the 'remove' button in the image toolbar |
|
1045 | + 'Edit ' => __('Edit'), // Tooltip for the 'edit' button in the image toolbar |
|
1046 | + 'Paste URL or type to search' => __('Paste URL or type to search'), // Placeholder for the inline link dialog |
|
1047 | + 'Link options' => __('Link options'), |
|
1048 | 1048 | |
1049 | 1049 | // Shortcuts help modal |
1050 | - 'Keyboard Shortcuts' => __( 'Keyboard Shortcuts' ), |
|
1051 | - 'Default shortcuts,' => __( 'Default shortcuts,' ), |
|
1052 | - 'Additional shortcuts,' => __( 'Additional shortcuts,' ), |
|
1053 | - 'Focus shortcuts:' => __( 'Focus shortcuts:' ), |
|
1054 | - 'Inline toolbar (when an image, link or preview is selected)' => __( 'Inline toolbar (when an image, link or preview is selected)' ), |
|
1055 | - 'Editor menu (when enabled)' => __( 'Editor menu (when enabled)' ), |
|
1056 | - 'Editor toolbar' => __( 'Editor toolbar' ), |
|
1057 | - 'Elements path' => __( 'Elements path' ), |
|
1058 | - 'Ctrl + Alt + letter:' => __( 'Ctrl + Alt + letter:' ), |
|
1059 | - 'Shift + Alt + letter:' => __( 'Shift + Alt + letter:' ), |
|
1060 | - 'Cmd + letter:' => __( 'Cmd + letter:' ), |
|
1061 | - 'Ctrl + letter:' => __( 'Ctrl + letter:' ), |
|
1062 | - 'Letter' => __( 'Letter' ), |
|
1063 | - 'Action' => __( 'Action' ), |
|
1050 | + 'Keyboard Shortcuts' => __('Keyboard Shortcuts'), |
|
1051 | + 'Default shortcuts,' => __('Default shortcuts,'), |
|
1052 | + 'Additional shortcuts,' => __('Additional shortcuts,'), |
|
1053 | + 'Focus shortcuts:' => __('Focus shortcuts:'), |
|
1054 | + 'Inline toolbar (when an image, link or preview is selected)' => __('Inline toolbar (when an image, link or preview is selected)'), |
|
1055 | + 'Editor menu (when enabled)' => __('Editor menu (when enabled)'), |
|
1056 | + 'Editor toolbar' => __('Editor toolbar'), |
|
1057 | + 'Elements path' => __('Elements path'), |
|
1058 | + 'Ctrl + Alt + letter:' => __('Ctrl + Alt + letter:'), |
|
1059 | + 'Shift + Alt + letter:' => __('Shift + Alt + letter:'), |
|
1060 | + 'Cmd + letter:' => __('Cmd + letter:'), |
|
1061 | + 'Ctrl + letter:' => __('Ctrl + letter:'), |
|
1062 | + 'Letter' => __('Letter'), |
|
1063 | + 'Action' => __('Action'), |
|
1064 | 1064 | 'To move focus to other buttons use Tab or the arrow keys. To return focus to the editor press Escape or use one of the buttons.' => |
1065 | - __( 'To move focus to other buttons use Tab or the arrow keys. To return focus to the editor press Escape or use one of the buttons.' ), |
|
1065 | + __('To move focus to other buttons use Tab or the arrow keys. To return focus to the editor press Escape or use one of the buttons.'), |
|
1066 | 1066 | 'When starting a new paragraph with one of these formatting shortcuts followed by a space, the formatting will be applied automatically. Press Backspace or Escape to undo.' => |
1067 | - __( 'When starting a new paragraph with one of these formatting shortcuts followed by a space, the formatting will be applied automatically. Press Backspace or Escape to undo.' ), |
|
1067 | + __('When starting a new paragraph with one of these formatting shortcuts followed by a space, the formatting will be applied automatically. Press Backspace or Escape to undo.'), |
|
1068 | 1068 | 'The following formatting shortcuts are replaced when pressing Enter. Press Escape or the Undo button to undo.' => |
1069 | - __( 'The following formatting shortcuts are replaced when pressing Enter. Press Escape or the Undo button to undo.' ), |
|
1069 | + __('The following formatting shortcuts are replaced when pressing Enter. Press Escape or the Undo button to undo.'), |
|
1070 | 1070 | 'The next group of formatting shortcuts are applied as you type or when you insert them around plain text in the same paragraph. Press Escape or the Undo button to undo.' => |
1071 | - __( 'The next group of formatting shortcuts are applied as you type or when you insert them around plain text in the same paragraph. Press Escape or the Undo button to undo.' ), |
|
1071 | + __('The next group of formatting shortcuts are applied as you type or when you insert them around plain text in the same paragraph. Press Escape or the Undo button to undo.'), |
|
1072 | 1072 | ); |
1073 | 1073 | |
1074 | 1074 | /** |
@@ -1082,7 +1082,7 @@ discard block |
||
1082 | 1082 | * Url |
1083 | 1083 | */ |
1084 | 1084 | |
1085 | - if ( ! $mce_locale ) { |
|
1085 | + if ( ! $mce_locale) { |
|
1086 | 1086 | $mce_locale = self::$mce_locale; |
1087 | 1087 | } |
1088 | 1088 | |
@@ -1094,32 +1094,32 @@ discard block |
||
1094 | 1094 | * @param array $mce_translation Key/value pairs of strings. |
1095 | 1095 | * @param string $mce_locale Locale. |
1096 | 1096 | */ |
1097 | - $mce_translation = apply_filters( 'wp_mce_translation', $mce_translation, $mce_locale ); |
|
1097 | + $mce_translation = apply_filters('wp_mce_translation', $mce_translation, $mce_locale); |
|
1098 | 1098 | |
1099 | - foreach ( $mce_translation as $key => $value ) { |
|
1099 | + foreach ($mce_translation as $key => $value) { |
|
1100 | 1100 | // Remove strings that are not translated. |
1101 | - if ( $key === $value ) { |
|
1102 | - unset( $mce_translation[$key] ); |
|
1101 | + if ($key === $value) { |
|
1102 | + unset($mce_translation[$key]); |
|
1103 | 1103 | continue; |
1104 | 1104 | } |
1105 | 1105 | |
1106 | - if ( false !== strpos( $value, '&' ) ) { |
|
1107 | - $mce_translation[$key] = html_entity_decode( $value, ENT_QUOTES, 'UTF-8' ); |
|
1106 | + if (false !== strpos($value, '&')) { |
|
1107 | + $mce_translation[$key] = html_entity_decode($value, ENT_QUOTES, 'UTF-8'); |
|
1108 | 1108 | } |
1109 | 1109 | } |
1110 | 1110 | |
1111 | 1111 | // Set direction |
1112 | - if ( is_rtl() ) { |
|
1112 | + if (is_rtl()) { |
|
1113 | 1113 | $mce_translation['_dir'] = 'rtl'; |
1114 | 1114 | } |
1115 | 1115 | |
1116 | - if ( $json_only ) { |
|
1117 | - return wp_json_encode( $mce_translation ); |
|
1116 | + if ($json_only) { |
|
1117 | + return wp_json_encode($mce_translation); |
|
1118 | 1118 | } |
1119 | 1119 | |
1120 | - $baseurl = self::$baseurl ? self::$baseurl : includes_url( 'js/tinymce' ); |
|
1120 | + $baseurl = self::$baseurl ? self::$baseurl : includes_url('js/tinymce'); |
|
1121 | 1121 | |
1122 | - return "tinymce.addI18n( '$mce_locale', " . wp_json_encode( $mce_translation ) . ");\n" . |
|
1122 | + return "tinymce.addI18n( '$mce_locale', ".wp_json_encode($mce_translation).");\n". |
|
1123 | 1123 | "tinymce.ScriptLoader.markDone( '$baseurl/langs/$mce_locale.js' );\n"; |
1124 | 1124 | } |
1125 | 1125 | |
@@ -1141,38 +1141,38 @@ discard block |
||
1141 | 1141 | * These plugins can be refreshed by appending query string to the URL passed to "mce_external_plugins" filter. |
1142 | 1142 | * If the plugin has a popup dialog, a query string can be added to the button action that opens it (in the plugin's code). |
1143 | 1143 | */ |
1144 | - $version = 'ver=' . $tinymce_version; |
|
1145 | - $tmce_on = !empty(self::$mce_settings); |
|
1144 | + $version = 'ver='.$tinymce_version; |
|
1145 | + $tmce_on = ! empty(self::$mce_settings); |
|
1146 | 1146 | |
1147 | - if ( ! isset($concatenate_scripts) ) |
|
1147 | + if ( ! isset($concatenate_scripts)) |
|
1148 | 1148 | script_concat_settings(); |
1149 | 1149 | |
1150 | 1150 | $compressed = $compress_scripts && $concatenate_scripts && isset($_SERVER['HTTP_ACCEPT_ENCODING']) |
1151 | 1151 | && false !== stripos($_SERVER['HTTP_ACCEPT_ENCODING'], 'gzip'); |
1152 | 1152 | |
1153 | 1153 | $mceInit = $qtInit = ''; |
1154 | - if ( $tmce_on ) { |
|
1155 | - foreach ( self::$mce_settings as $editor_id => $init ) { |
|
1156 | - $options = self::_parse_init( $init ); |
|
1154 | + if ($tmce_on) { |
|
1155 | + foreach (self::$mce_settings as $editor_id => $init) { |
|
1156 | + $options = self::_parse_init($init); |
|
1157 | 1157 | $mceInit .= "'$editor_id':{$options},"; |
1158 | 1158 | } |
1159 | - $mceInit = '{' . trim($mceInit, ',') . '}'; |
|
1159 | + $mceInit = '{'.trim($mceInit, ',').'}'; |
|
1160 | 1160 | } else { |
1161 | 1161 | $mceInit = '{}'; |
1162 | 1162 | } |
1163 | 1163 | |
1164 | - if ( !empty(self::$qt_settings) ) { |
|
1165 | - foreach ( self::$qt_settings as $editor_id => $init ) { |
|
1166 | - $options = self::_parse_init( $init ); |
|
1164 | + if ( ! empty(self::$qt_settings)) { |
|
1165 | + foreach (self::$qt_settings as $editor_id => $init) { |
|
1166 | + $options = self::_parse_init($init); |
|
1167 | 1167 | $qtInit .= "'$editor_id':{$options},"; |
1168 | 1168 | } |
1169 | - $qtInit = '{' . trim($qtInit, ',') . '}'; |
|
1169 | + $qtInit = '{'.trim($qtInit, ',').'}'; |
|
1170 | 1170 | } else { |
1171 | 1171 | $qtInit = '{}'; |
1172 | 1172 | } |
1173 | 1173 | |
1174 | 1174 | $ref = array( |
1175 | - 'plugins' => implode( ',', self::$plugins ), |
|
1175 | + 'plugins' => implode(',', self::$plugins), |
|
1176 | 1176 | 'theme' => 'modern', |
1177 | 1177 | 'language' => self::$mce_locale |
1178 | 1178 | ); |
@@ -1186,7 +1186,7 @@ discard block |
||
1186 | 1186 | * |
1187 | 1187 | * @param array $mce_settings TinyMCE settings array. |
1188 | 1188 | */ |
1189 | - do_action( 'before_wp_tiny_mce', self::$mce_settings ); |
|
1189 | + do_action('before_wp_tiny_mce', self::$mce_settings); |
|
1190 | 1190 | ?> |
1191 | 1191 | |
1192 | 1192 | <script type="text/javascript"> |
@@ -1195,14 +1195,14 @@ discard block |
||
1195 | 1195 | suffix: "<?php echo $suffix; ?>", |
1196 | 1196 | <?php |
1197 | 1197 | |
1198 | - if ( self::$drag_drop_upload ) { |
|
1198 | + if (self::$drag_drop_upload) { |
|
1199 | 1199 | echo 'dragDropUpload: true,'; |
1200 | 1200 | } |
1201 | 1201 | |
1202 | 1202 | ?> |
1203 | 1203 | mceInit: <?php echo $mceInit; ?>, |
1204 | 1204 | qtInit: <?php echo $qtInit; ?>, |
1205 | - ref: <?php echo self::_parse_init( $ref ); ?>, |
|
1205 | + ref: <?php echo self::_parse_init($ref); ?>, |
|
1206 | 1206 | load_ext: function(url,lang){var sl=tinymce.ScriptLoader;sl.markDone(url+'/langs/'+lang+'.js');sl.markDone(url+'/langs/'+lang+'_dlg.js');} |
1207 | 1207 | }; |
1208 | 1208 | </script> |
@@ -1210,19 +1210,19 @@ discard block |
||
1210 | 1210 | |
1211 | 1211 | $baseurl = self::$baseurl; |
1212 | 1212 | // Load tinymce.js when running from /src, else load wp-tinymce.js.gz (production) or tinymce.min.js (SCRIPT_DEBUG) |
1213 | - $mce_suffix = false !== strpos( $wp_version, '-src' ) ? '' : '.min'; |
|
1213 | + $mce_suffix = false !== strpos($wp_version, '-src') ? '' : '.min'; |
|
1214 | 1214 | |
1215 | - if ( $tmce_on ) { |
|
1216 | - if ( $compressed ) { |
|
1215 | + if ($tmce_on) { |
|
1216 | + if ($compressed) { |
|
1217 | 1217 | echo "<script type='text/javascript' src='{$baseurl}/wp-tinymce.php?c=1&$version'></script>\n"; |
1218 | 1218 | } else { |
1219 | 1219 | echo "<script type='text/javascript' src='{$baseurl}/tinymce{$mce_suffix}.js?$version'></script>\n"; |
1220 | 1220 | echo "<script type='text/javascript' src='{$baseurl}/plugins/compat3x/plugin{$suffix}.js?$version'></script>\n"; |
1221 | 1221 | } |
1222 | 1222 | |
1223 | - echo "<script type='text/javascript'>\n" . self::wp_mce_translation() . "</script>\n"; |
|
1223 | + echo "<script type='text/javascript'>\n".self::wp_mce_translation()."</script>\n"; |
|
1224 | 1224 | |
1225 | - if ( self::$ext_plugins ) { |
|
1225 | + if (self::$ext_plugins) { |
|
1226 | 1226 | // Load the old-format English strings to prevent unsightly labels in old style popups |
1227 | 1227 | echo "<script type='text/javascript' src='{$baseurl}/langs/wp-langs-en.js?$version'></script>\n"; |
1228 | 1228 | } |
@@ -1236,17 +1236,17 @@ discard block |
||
1236 | 1236 | * |
1237 | 1237 | * @param array $mce_settings TinyMCE settings array. |
1238 | 1238 | */ |
1239 | - do_action( 'wp_tiny_mce_init', self::$mce_settings ); |
|
1239 | + do_action('wp_tiny_mce_init', self::$mce_settings); |
|
1240 | 1240 | |
1241 | 1241 | ?> |
1242 | 1242 | <script type="text/javascript"> |
1243 | 1243 | <?php |
1244 | 1244 | |
1245 | - if ( self::$ext_plugins ) |
|
1246 | - echo self::$ext_plugins . "\n"; |
|
1245 | + if (self::$ext_plugins) |
|
1246 | + echo self::$ext_plugins."\n"; |
|
1247 | 1247 | |
1248 | - if ( ! is_admin() ) |
|
1249 | - echo 'var ajaxurl = "' . admin_url( 'admin-ajax.php', 'relative' ) . '";'; |
|
1248 | + if ( ! is_admin()) |
|
1249 | + echo 'var ajaxurl = "'.admin_url('admin-ajax.php', 'relative').'";'; |
|
1250 | 1250 | |
1251 | 1251 | ?> |
1252 | 1252 | |
@@ -1281,7 +1281,7 @@ discard block |
||
1281 | 1281 | </script> |
1282 | 1282 | <?php |
1283 | 1283 | |
1284 | - if ( in_array( 'wplink', self::$plugins, true ) || in_array( 'link', self::$qt_buttons, true ) ) |
|
1284 | + if (in_array('wplink', self::$plugins, true) || in_array('link', self::$qt_buttons, true)) |
|
1285 | 1285 | self::wp_link_dialog(); |
1286 | 1286 | |
1287 | 1287 | /** |
@@ -1291,7 +1291,7 @@ discard block |
||
1291 | 1291 | * |
1292 | 1292 | * @param array $mce_settings TinyMCE settings array. |
1293 | 1293 | */ |
1294 | - do_action( 'after_wp_tiny_mce', self::$mce_settings ); |
|
1294 | + do_action('after_wp_tiny_mce', self::$mce_settings); |
|
1295 | 1295 | } |
1296 | 1296 | |
1297 | 1297 | /** |
@@ -1300,7 +1300,7 @@ discard block |
||
1300 | 1300 | * @global int $content_width |
1301 | 1301 | */ |
1302 | 1302 | public static function wp_fullscreen_html() { |
1303 | - _deprecated_function( __FUNCTION__, '4.3' ); |
|
1303 | + _deprecated_function(__FUNCTION__, '4.3'); |
|
1304 | 1304 | } |
1305 | 1305 | |
1306 | 1306 | /** |
@@ -1312,9 +1312,9 @@ discard block |
||
1312 | 1312 | * @param array $args Optional. Accepts 'pagenum' and 's' (search) arguments. |
1313 | 1313 | * @return false|array Results. |
1314 | 1314 | */ |
1315 | - public static function wp_link_query( $args = array() ) { |
|
1316 | - $pts = get_post_types( array( 'public' => true ), 'objects' ); |
|
1317 | - $pt_names = array_keys( $pts ); |
|
1315 | + public static function wp_link_query($args = array()) { |
|
1316 | + $pts = get_post_types(array('public' => true), 'objects'); |
|
1317 | + $pt_names = array_keys($pts); |
|
1318 | 1318 | |
1319 | 1319 | $query = array( |
1320 | 1320 | 'post_type' => $pt_names, |
@@ -1325,12 +1325,12 @@ discard block |
||
1325 | 1325 | 'posts_per_page' => 20, |
1326 | 1326 | ); |
1327 | 1327 | |
1328 | - $args['pagenum'] = isset( $args['pagenum'] ) ? absint( $args['pagenum'] ) : 1; |
|
1328 | + $args['pagenum'] = isset($args['pagenum']) ? absint($args['pagenum']) : 1; |
|
1329 | 1329 | |
1330 | - if ( isset( $args['s'] ) ) |
|
1330 | + if (isset($args['s'])) |
|
1331 | 1331 | $query['s'] = $args['s']; |
1332 | 1332 | |
1333 | - $query['offset'] = $args['pagenum'] > 1 ? $query['posts_per_page'] * ( $args['pagenum'] - 1 ) : 0; |
|
1333 | + $query['offset'] = $args['pagenum'] > 1 ? $query['posts_per_page'] * ($args['pagenum'] - 1) : 0; |
|
1334 | 1334 | |
1335 | 1335 | /** |
1336 | 1336 | * Filter the link query arguments. |
@@ -1343,27 +1343,27 @@ discard block |
||
1343 | 1343 | * |
1344 | 1344 | * @param array $query An array of WP_Query arguments. |
1345 | 1345 | */ |
1346 | - $query = apply_filters( 'wp_link_query_args', $query ); |
|
1346 | + $query = apply_filters('wp_link_query_args', $query); |
|
1347 | 1347 | |
1348 | 1348 | // Do main query. |
1349 | 1349 | $get_posts = new WP_Query; |
1350 | - $posts = $get_posts->query( $query ); |
|
1350 | + $posts = $get_posts->query($query); |
|
1351 | 1351 | // Check if any posts were found. |
1352 | - if ( ! $get_posts->post_count ) |
|
1352 | + if ( ! $get_posts->post_count) |
|
1353 | 1353 | return false; |
1354 | 1354 | |
1355 | 1355 | // Build results. |
1356 | 1356 | $results = array(); |
1357 | - foreach ( $posts as $post ) { |
|
1358 | - if ( 'post' == $post->post_type ) |
|
1359 | - $info = mysql2date( __( 'Y/m/d' ), $post->post_date ); |
|
1357 | + foreach ($posts as $post) { |
|
1358 | + if ('post' == $post->post_type) |
|
1359 | + $info = mysql2date(__('Y/m/d'), $post->post_date); |
|
1360 | 1360 | else |
1361 | - $info = $pts[ $post->post_type ]->labels->singular_name; |
|
1361 | + $info = $pts[$post->post_type]->labels->singular_name; |
|
1362 | 1362 | |
1363 | 1363 | $results[] = array( |
1364 | 1364 | 'ID' => $post->ID, |
1365 | - 'title' => trim( esc_html( strip_tags( get_the_title( $post ) ) ) ), |
|
1366 | - 'permalink' => get_permalink( $post->ID ), |
|
1365 | + 'title' => trim(esc_html(strip_tags(get_the_title($post)))), |
|
1366 | + 'permalink' => get_permalink($post->ID), |
|
1367 | 1367 | 'info' => $info, |
1368 | 1368 | ); |
1369 | 1369 | } |
@@ -1390,7 +1390,7 @@ discard block |
||
1390 | 1390 | * } |
1391 | 1391 | * @param array $query An array of WP_Query arguments. |
1392 | 1392 | */ |
1393 | - return apply_filters( 'wp_link_query', $results, $query ); |
|
1393 | + return apply_filters('wp_link_query', $results, $query); |
|
1394 | 1394 | } |
1395 | 1395 | |
1396 | 1396 | /** |
@@ -1406,31 +1406,31 @@ discard block |
||
1406 | 1406 | <div id="wp-link-backdrop" style="display: none"></div> |
1407 | 1407 | <div id="wp-link-wrap" class="wp-core-ui" style="display: none" role="dialog" aria-labelledby="link-modal-title"> |
1408 | 1408 | <form id="wp-link" tabindex="-1"> |
1409 | - <?php wp_nonce_field( 'internal-linking', '_ajax_linking_nonce', false ); ?> |
|
1410 | - <h1 id="link-modal-title"><?php _e( 'Insert/edit link' ) ?></h1> |
|
1411 | - <button type="button" id="wp-link-close"><span class="screen-reader-text"><?php _e( 'Close' ); ?></span></button> |
|
1409 | + <?php wp_nonce_field('internal-linking', '_ajax_linking_nonce', false); ?> |
|
1410 | + <h1 id="link-modal-title"><?php _e('Insert/edit link') ?></h1> |
|
1411 | + <button type="button" id="wp-link-close"><span class="screen-reader-text"><?php _e('Close'); ?></span></button> |
|
1412 | 1412 | <div id="link-selector"> |
1413 | 1413 | <div id="link-options"> |
1414 | 1414 | <div> |
1415 | - <label><span><?php _e( 'URL' ); ?></span> |
|
1416 | - <input id="wp-link-url" type="text" role="combobox" aria-autocomplete="list" aria-expanded="false" placeholder="<?php _e( 'Paste URL or type to search' ); ?>" /></label> |
|
1415 | + <label><span><?php _e('URL'); ?></span> |
|
1416 | + <input id="wp-link-url" type="text" role="combobox" aria-autocomplete="list" aria-expanded="false" placeholder="<?php _e('Paste URL or type to search'); ?>" /></label> |
|
1417 | 1417 | </div> |
1418 | 1418 | <div class="wp-link-text-field"> |
1419 | - <label><span><?php _e( 'Link Text' ); ?></span> |
|
1419 | + <label><span><?php _e('Link Text'); ?></span> |
|
1420 | 1420 | <input id="wp-link-text" type="text" /></label> |
1421 | 1421 | </div> |
1422 | 1422 | <div class="link-target"> |
1423 | 1423 | <label><span></span> |
1424 | - <input type="checkbox" id="wp-link-target" /> <?php _e( 'Open link in a new tab' ); ?></label> |
|
1424 | + <input type="checkbox" id="wp-link-target" /> <?php _e('Open link in a new tab'); ?></label> |
|
1425 | 1425 | </div> |
1426 | 1426 | </div> |
1427 | 1427 | </div> |
1428 | 1428 | <div class="submitbox"> |
1429 | 1429 | <div id="wp-link-cancel"> |
1430 | - <button type="button" class="button"><?php _e( 'Cancel' ); ?></button> |
|
1430 | + <button type="button" class="button"><?php _e('Cancel'); ?></button> |
|
1431 | 1431 | </div> |
1432 | 1432 | <div id="wp-link-update"> |
1433 | - <input type="submit" value="<?php esc_attr_e( 'Add Link' ); ?>" class="button button-primary" id="wp-link-submit" name="wp-link-submit"> |
|
1433 | + <input type="submit" value="<?php esc_attr_e('Add Link'); ?>" class="button button-primary" id="wp-link-submit" name="wp-link-submit"> |
|
1434 | 1434 | </div> |
1435 | 1435 | </div> |
1436 | 1436 | </form> |