@@ -176,8 +176,9 @@ discard block |
||
176 | 176 | $this->init(); |
177 | 177 | $this->upgrade_strings(); |
178 | 178 | |
179 | - if ( ! $language_updates ) |
|
180 | - $language_updates = wp_get_translation_updates(); |
|
179 | + if ( ! $language_updates ) { |
|
180 | + $language_updates = wp_get_translation_updates(); |
|
181 | + } |
|
181 | 182 | |
182 | 183 | if ( empty( $language_updates ) ) { |
183 | 184 | $this->skin->header(); |
@@ -188,8 +189,9 @@ discard block |
||
188 | 189 | return true; |
189 | 190 | } |
190 | 191 | |
191 | - if ( 'upgrader_process_complete' == current_filter() ) |
|
192 | - $this->skin->feedback( 'starting_upgrade' ); |
|
192 | + if ( 'upgrader_process_complete' == current_filter() ) { |
|
193 | + $this->skin->feedback( 'starting_upgrade' ); |
|
194 | + } |
|
193 | 195 | |
194 | 196 | // Remove any existing upgrade filters from the plugin/theme upgraders #WP29425 & #WP29230 |
195 | 197 | remove_all_filters( 'upgrader_pre_install' ); |
@@ -218,9 +220,10 @@ discard block |
||
218 | 220 | * as we then may need to create a /plugins or /themes directory inside of it. |
219 | 221 | */ |
220 | 222 | $remote_destination = $wp_filesystem->find_folder( WP_LANG_DIR ); |
221 | - if ( ! $wp_filesystem->exists( $remote_destination ) ) |
|
222 | - if ( ! $wp_filesystem->mkdir( $remote_destination, FS_CHMOD_DIR ) ) |
|
223 | + if ( ! $wp_filesystem->exists( $remote_destination ) ) { |
|
224 | + if ( ! $wp_filesystem->mkdir( $remote_destination, FS_CHMOD_DIR ) ) |
|
223 | 225 | return new WP_Error( 'mkdir_failed_lang_dir', $this->strings['mkdir_failed'], $remote_destination ); |
226 | + } |
|
224 | 227 | |
225 | 228 | $language_updates_results = array(); |
226 | 229 | |
@@ -229,10 +232,11 @@ discard block |
||
229 | 232 | $this->skin->language_update = $language_update; |
230 | 233 | |
231 | 234 | $destination = WP_LANG_DIR; |
232 | - if ( 'plugin' == $language_update->type ) |
|
233 | - $destination .= '/plugins'; |
|
234 | - elseif ( 'theme' == $language_update->type ) |
|
235 | - $destination .= '/themes'; |
|
235 | + if ( 'plugin' == $language_update->type ) { |
|
236 | + $destination .= '/plugins'; |
|
237 | + } elseif ( 'theme' == $language_update->type ) { |
|
238 | + $destination .= '/themes'; |
|
239 | + } |
|
236 | 240 | |
237 | 241 | $this->update_current++; |
238 | 242 | |
@@ -317,8 +321,9 @@ discard block |
||
317 | 321 | public function check_package( $source, $remote_source ) { |
318 | 322 | global $wp_filesystem; |
319 | 323 | |
320 | - if ( is_wp_error( $source ) ) |
|
321 | - return $source; |
|
324 | + if ( is_wp_error( $source ) ) { |
|
325 | + return $source; |
|
326 | + } |
|
322 | 327 | |
323 | 328 | // Check that the folder contains a valid language. |
324 | 329 | $files = $wp_filesystem->dirlist( $remote_source ); |
@@ -326,10 +331,11 @@ discard block |
||
326 | 331 | // Check to see if a .po and .mo exist in the folder. |
327 | 332 | $po = $mo = false; |
328 | 333 | foreach ( (array) $files as $file => $filedata ) { |
329 | - if ( '.po' == substr( $file, -3 ) ) |
|
330 | - $po = true; |
|
331 | - elseif ( '.mo' == substr( $file, -3 ) ) |
|
332 | - $mo = true; |
|
334 | + if ( '.po' == substr( $file, -3 ) ) { |
|
335 | + $po = true; |
|
336 | + } elseif ( '.mo' == substr( $file, -3 ) ) { |
|
337 | + $mo = true; |
|
338 | + } |
|
333 | 339 | } |
334 | 340 | |
335 | 341 | if ( ! $mo || ! $po ) { |
@@ -361,14 +367,16 @@ discard block |
||
361 | 367 | |
362 | 368 | case 'theme': |
363 | 369 | $theme = wp_get_theme( $update->slug ); |
364 | - if ( $theme->exists() ) |
|
365 | - return $theme->Get( 'Name' ); |
|
370 | + if ( $theme->exists() ) { |
|
371 | + return $theme->Get( 'Name' ); |
|
372 | + } |
|
366 | 373 | break; |
367 | 374 | case 'plugin': |
368 | 375 | $plugin_data = get_plugins( '/' . $update->slug ); |
369 | 376 | $plugin_data = reset( $plugin_data ); |
370 | - if ( $plugin_data ) |
|
371 | - return $plugin_data['Name']; |
|
377 | + if ( $plugin_data ) { |
|
378 | + return $plugin_data['Name']; |
|
379 | + } |
|
372 | 380 | break; |
373 | 381 | } |
374 | 382 | return ''; |
@@ -50,15 +50,15 @@ discard block |
||
50 | 50 | * a Language_Pack_Upgrader instance, the method will bail to |
51 | 51 | * avoid recursion. Otherwise unused. Default false. |
52 | 52 | */ |
53 | - public static function async_upgrade( $upgrader = false ) { |
|
53 | + public static function async_upgrade($upgrader = false) { |
|
54 | 54 | // Avoid recursion. |
55 | - if ( $upgrader && $upgrader instanceof Language_Pack_Upgrader ) { |
|
55 | + if ($upgrader && $upgrader instanceof Language_Pack_Upgrader) { |
|
56 | 56 | return; |
57 | 57 | } |
58 | 58 | |
59 | 59 | // Nothing to do? |
60 | 60 | $language_updates = wp_get_translation_updates(); |
61 | - if ( ! $language_updates ) { |
|
61 | + if ( ! $language_updates) { |
|
62 | 62 | return; |
63 | 63 | } |
64 | 64 | |
@@ -67,12 +67,12 @@ discard block |
||
67 | 67 | * Noted: this is not the ideal way to accomplish this. |
68 | 68 | */ |
69 | 69 | $check_vcs = new WP_Automatic_Updater; |
70 | - if ( $check_vcs->is_vcs_checkout( WP_CONTENT_DIR ) ) { |
|
70 | + if ($check_vcs->is_vcs_checkout(WP_CONTENT_DIR)) { |
|
71 | 71 | return; |
72 | 72 | } |
73 | 73 | |
74 | - foreach ( $language_updates as $key => $language_update ) { |
|
75 | - $update = ! empty( $language_update->autoupdate ); |
|
74 | + foreach ($language_updates as $key => $language_update) { |
|
75 | + $update = ! empty($language_update->autoupdate); |
|
76 | 76 | |
77 | 77 | /** |
78 | 78 | * Filters whether to asynchronously update translation for core, a plugin, or a theme. |
@@ -82,28 +82,28 @@ discard block |
||
82 | 82 | * @param bool $update Whether to update. |
83 | 83 | * @param object $language_update The update offer. |
84 | 84 | */ |
85 | - $update = apply_filters( 'async_update_translation', $update, $language_update ); |
|
85 | + $update = apply_filters('async_update_translation', $update, $language_update); |
|
86 | 86 | |
87 | - if ( ! $update ) { |
|
88 | - unset( $language_updates[ $key ] ); |
|
87 | + if ( ! $update) { |
|
88 | + unset($language_updates[$key]); |
|
89 | 89 | } |
90 | 90 | } |
91 | 91 | |
92 | - if ( empty( $language_updates ) ) { |
|
92 | + if (empty($language_updates)) { |
|
93 | 93 | return; |
94 | 94 | } |
95 | 95 | |
96 | 96 | // Re-use the automatic upgrader skin if the parent upgrader is using it. |
97 | - if ( $upgrader && $upgrader->skin instanceof Automatic_Upgrader_Skin ) { |
|
97 | + if ($upgrader && $upgrader->skin instanceof Automatic_Upgrader_Skin) { |
|
98 | 98 | $skin = $upgrader->skin; |
99 | 99 | } else { |
100 | - $skin = new Language_Pack_Upgrader_Skin( array( |
|
100 | + $skin = new Language_Pack_Upgrader_Skin(array( |
|
101 | 101 | 'skip_header_footer' => true, |
102 | - ) ); |
|
102 | + )); |
|
103 | 103 | } |
104 | 104 | |
105 | - $lp_upgrader = new Language_Pack_Upgrader( $skin ); |
|
106 | - $lp_upgrader->bulk_upgrade( $language_updates ); |
|
105 | + $lp_upgrader = new Language_Pack_Upgrader($skin); |
|
106 | + $lp_upgrader->bulk_upgrade($language_updates); |
|
107 | 107 | } |
108 | 108 | |
109 | 109 | /** |
@@ -113,13 +113,13 @@ discard block |
||
113 | 113 | * @access public |
114 | 114 | */ |
115 | 115 | public function upgrade_strings() { |
116 | - $this->strings['starting_upgrade'] = __( 'Some of your translations need updating. Sit tight for a few more seconds while we update them as well.' ); |
|
117 | - $this->strings['up_to_date'] = __( 'The translations are up to date.' ); |
|
118 | - $this->strings['no_package'] = __( 'Update package not available.' ); |
|
119 | - $this->strings['downloading_package'] = __( 'Downloading translation from <span class="code">%s</span>…' ); |
|
120 | - $this->strings['unpack_package'] = __( 'Unpacking the update…' ); |
|
121 | - $this->strings['process_failed'] = __( 'Translation update failed.' ); |
|
122 | - $this->strings['process_success'] = __( 'Translation updated successfully.' ); |
|
116 | + $this->strings['starting_upgrade'] = __('Some of your translations need updating. Sit tight for a few more seconds while we update them as well.'); |
|
117 | + $this->strings['up_to_date'] = __('The translations are up to date.'); |
|
118 | + $this->strings['no_package'] = __('Update package not available.'); |
|
119 | + $this->strings['downloading_package'] = __('Downloading translation from <span class="code">%s</span>…'); |
|
120 | + $this->strings['unpack_package'] = __('Unpacking the update…'); |
|
121 | + $this->strings['process_failed'] = __('Translation update failed.'); |
|
122 | + $this->strings['process_success'] = __('Translation updated successfully.'); |
|
123 | 123 | } |
124 | 124 | |
125 | 125 | /** |
@@ -133,14 +133,14 @@ discard block |
||
133 | 133 | * Language_Pack_Upgrader::bulk_upgrade(). Default empty array. |
134 | 134 | * @return array|bool|WP_Error The result of the upgrade, or a WP_Error object instead. |
135 | 135 | */ |
136 | - public function upgrade( $update = false, $args = array() ) { |
|
137 | - if ( $update ) { |
|
138 | - $update = array( $update ); |
|
136 | + public function upgrade($update = false, $args = array()) { |
|
137 | + if ($update) { |
|
138 | + $update = array($update); |
|
139 | 139 | } |
140 | 140 | |
141 | - $results = $this->bulk_upgrade( $update, $args ); |
|
141 | + $results = $this->bulk_upgrade($update, $args); |
|
142 | 142 | |
143 | - if ( ! is_array( $results ) ) { |
|
143 | + if ( ! is_array($results)) { |
|
144 | 144 | return $results; |
145 | 145 | } |
146 | 146 | |
@@ -165,73 +165,73 @@ discard block |
||
165 | 165 | * @return array|bool|WP_Error Will return an array of results, or true if there are no updates, |
166 | 166 | * false or WP_Error for initial errors. |
167 | 167 | */ |
168 | - public function bulk_upgrade( $language_updates = array(), $args = array() ) { |
|
168 | + public function bulk_upgrade($language_updates = array(), $args = array()) { |
|
169 | 169 | global $wp_filesystem; |
170 | 170 | |
171 | 171 | $defaults = array( |
172 | 172 | 'clear_update_cache' => true, |
173 | 173 | ); |
174 | - $parsed_args = wp_parse_args( $args, $defaults ); |
|
174 | + $parsed_args = wp_parse_args($args, $defaults); |
|
175 | 175 | |
176 | 176 | $this->init(); |
177 | 177 | $this->upgrade_strings(); |
178 | 178 | |
179 | - if ( ! $language_updates ) |
|
179 | + if ( ! $language_updates) |
|
180 | 180 | $language_updates = wp_get_translation_updates(); |
181 | 181 | |
182 | - if ( empty( $language_updates ) ) { |
|
182 | + if (empty($language_updates)) { |
|
183 | 183 | $this->skin->header(); |
184 | - $this->skin->set_result( true ); |
|
185 | - $this->skin->feedback( 'up_to_date' ); |
|
184 | + $this->skin->set_result(true); |
|
185 | + $this->skin->feedback('up_to_date'); |
|
186 | 186 | $this->skin->bulk_footer(); |
187 | 187 | $this->skin->footer(); |
188 | 188 | return true; |
189 | 189 | } |
190 | 190 | |
191 | - if ( 'upgrader_process_complete' == current_filter() ) |
|
192 | - $this->skin->feedback( 'starting_upgrade' ); |
|
191 | + if ('upgrader_process_complete' == current_filter()) |
|
192 | + $this->skin->feedback('starting_upgrade'); |
|
193 | 193 | |
194 | 194 | // Remove any existing upgrade filters from the plugin/theme upgraders #WP29425 & #WP29230 |
195 | - remove_all_filters( 'upgrader_pre_install' ); |
|
196 | - remove_all_filters( 'upgrader_clear_destination' ); |
|
197 | - remove_all_filters( 'upgrader_post_install' ); |
|
198 | - remove_all_filters( 'upgrader_source_selection' ); |
|
195 | + remove_all_filters('upgrader_pre_install'); |
|
196 | + remove_all_filters('upgrader_clear_destination'); |
|
197 | + remove_all_filters('upgrader_post_install'); |
|
198 | + remove_all_filters('upgrader_source_selection'); |
|
199 | 199 | |
200 | - add_filter( 'upgrader_source_selection', array( $this, 'check_package' ), 10, 2 ); |
|
200 | + add_filter('upgrader_source_selection', array($this, 'check_package'), 10, 2); |
|
201 | 201 | |
202 | 202 | $this->skin->header(); |
203 | 203 | |
204 | 204 | // Connect to the Filesystem first. |
205 | - $res = $this->fs_connect( array( WP_CONTENT_DIR, WP_LANG_DIR ) ); |
|
206 | - if ( ! $res ) { |
|
205 | + $res = $this->fs_connect(array(WP_CONTENT_DIR, WP_LANG_DIR)); |
|
206 | + if ( ! $res) { |
|
207 | 207 | $this->skin->footer(); |
208 | 208 | return false; |
209 | 209 | } |
210 | 210 | |
211 | 211 | $results = array(); |
212 | 212 | |
213 | - $this->update_count = count( $language_updates ); |
|
213 | + $this->update_count = count($language_updates); |
|
214 | 214 | $this->update_current = 0; |
215 | 215 | |
216 | 216 | /* |
217 | 217 | * The filesystem's mkdir() is not recursive. Make sure WP_LANG_DIR exists, |
218 | 218 | * as we then may need to create a /plugins or /themes directory inside of it. |
219 | 219 | */ |
220 | - $remote_destination = $wp_filesystem->find_folder( WP_LANG_DIR ); |
|
221 | - if ( ! $wp_filesystem->exists( $remote_destination ) ) |
|
222 | - if ( ! $wp_filesystem->mkdir( $remote_destination, FS_CHMOD_DIR ) ) |
|
223 | - return new WP_Error( 'mkdir_failed_lang_dir', $this->strings['mkdir_failed'], $remote_destination ); |
|
220 | + $remote_destination = $wp_filesystem->find_folder(WP_LANG_DIR); |
|
221 | + if ( ! $wp_filesystem->exists($remote_destination)) |
|
222 | + if ( ! $wp_filesystem->mkdir($remote_destination, FS_CHMOD_DIR)) |
|
223 | + return new WP_Error('mkdir_failed_lang_dir', $this->strings['mkdir_failed'], $remote_destination); |
|
224 | 224 | |
225 | 225 | $language_updates_results = array(); |
226 | 226 | |
227 | - foreach ( $language_updates as $language_update ) { |
|
227 | + foreach ($language_updates as $language_update) { |
|
228 | 228 | |
229 | 229 | $this->skin->language_update = $language_update; |
230 | 230 | |
231 | 231 | $destination = WP_LANG_DIR; |
232 | - if ( 'plugin' == $language_update->type ) |
|
232 | + if ('plugin' == $language_update->type) |
|
233 | 233 | $destination .= '/plugins'; |
234 | - elseif ( 'theme' == $language_update->type ) |
|
234 | + elseif ('theme' == $language_update->type) |
|
235 | 235 | $destination .= '/themes'; |
236 | 236 | |
237 | 237 | $this->update_current++; |
@@ -249,51 +249,51 @@ discard block |
||
249 | 249 | ) |
250 | 250 | ); |
251 | 251 | |
252 | - $result = $this->run( $options ); |
|
252 | + $result = $this->run($options); |
|
253 | 253 | |
254 | 254 | $results[] = $this->result; |
255 | 255 | |
256 | 256 | // Prevent credentials auth screen from displaying multiple times. |
257 | - if ( false === $result ) { |
|
257 | + if (false === $result) { |
|
258 | 258 | break; |
259 | 259 | } |
260 | 260 | |
261 | 261 | $language_updates_results[] = array( |
262 | 262 | 'language' => $language_update->language, |
263 | 263 | 'type' => $language_update->type, |
264 | - 'slug' => isset( $language_update->slug ) ? $language_update->slug : 'default', |
|
264 | + 'slug' => isset($language_update->slug) ? $language_update->slug : 'default', |
|
265 | 265 | 'version' => $language_update->version, |
266 | 266 | ); |
267 | 267 | } |
268 | 268 | |
269 | 269 | // Remove upgrade hooks which are not required for translation updates. |
270 | - remove_action( 'upgrader_process_complete', array( 'Language_Pack_Upgrader', 'async_upgrade' ), 20 ); |
|
271 | - remove_action( 'upgrader_process_complete', 'wp_version_check' ); |
|
272 | - remove_action( 'upgrader_process_complete', 'wp_update_plugins' ); |
|
273 | - remove_action( 'upgrader_process_complete', 'wp_update_themes' ); |
|
270 | + remove_action('upgrader_process_complete', array('Language_Pack_Upgrader', 'async_upgrade'), 20); |
|
271 | + remove_action('upgrader_process_complete', 'wp_version_check'); |
|
272 | + remove_action('upgrader_process_complete', 'wp_update_plugins'); |
|
273 | + remove_action('upgrader_process_complete', 'wp_update_themes'); |
|
274 | 274 | |
275 | 275 | /** This action is documented in wp-admin/includes/class-wp-upgrader.php */ |
276 | - do_action( 'upgrader_process_complete', $this, array( |
|
276 | + do_action('upgrader_process_complete', $this, array( |
|
277 | 277 | 'action' => 'update', |
278 | 278 | 'type' => 'translation', |
279 | 279 | 'bulk' => true, |
280 | 280 | 'translations' => $language_updates_results |
281 | - ) ); |
|
281 | + )); |
|
282 | 282 | |
283 | 283 | // Re-add upgrade hooks. |
284 | - add_action( 'upgrader_process_complete', array( 'Language_Pack_Upgrader', 'async_upgrade' ), 20 ); |
|
285 | - add_action( 'upgrader_process_complete', 'wp_version_check', 10, 0 ); |
|
286 | - add_action( 'upgrader_process_complete', 'wp_update_plugins', 10, 0 ); |
|
287 | - add_action( 'upgrader_process_complete', 'wp_update_themes', 10, 0 ); |
|
284 | + add_action('upgrader_process_complete', array('Language_Pack_Upgrader', 'async_upgrade'), 20); |
|
285 | + add_action('upgrader_process_complete', 'wp_version_check', 10, 0); |
|
286 | + add_action('upgrader_process_complete', 'wp_update_plugins', 10, 0); |
|
287 | + add_action('upgrader_process_complete', 'wp_update_themes', 10, 0); |
|
288 | 288 | |
289 | 289 | $this->skin->bulk_footer(); |
290 | 290 | |
291 | 291 | $this->skin->footer(); |
292 | 292 | |
293 | 293 | // Clean up our hooks, in case something else does an upgrade on this connection. |
294 | - remove_filter( 'upgrader_source_selection', array( $this, 'check_package' ) ); |
|
294 | + remove_filter('upgrader_source_selection', array($this, 'check_package')); |
|
295 | 295 | |
296 | - if ( $parsed_args['clear_update_cache'] ) { |
|
296 | + if ($parsed_args['clear_update_cache']) { |
|
297 | 297 | wp_clean_update_cache(); |
298 | 298 | } |
299 | 299 | |
@@ -314,28 +314,28 @@ discard block |
||
314 | 314 | * @param string|WP_Error $source |
315 | 315 | * @param string $remote_source |
316 | 316 | */ |
317 | - public function check_package( $source, $remote_source ) { |
|
317 | + public function check_package($source, $remote_source) { |
|
318 | 318 | global $wp_filesystem; |
319 | 319 | |
320 | - if ( is_wp_error( $source ) ) |
|
320 | + if (is_wp_error($source)) |
|
321 | 321 | return $source; |
322 | 322 | |
323 | 323 | // Check that the folder contains a valid language. |
324 | - $files = $wp_filesystem->dirlist( $remote_source ); |
|
324 | + $files = $wp_filesystem->dirlist($remote_source); |
|
325 | 325 | |
326 | 326 | // Check to see if a .po and .mo exist in the folder. |
327 | 327 | $po = $mo = false; |
328 | - foreach ( (array) $files as $file => $filedata ) { |
|
329 | - if ( '.po' == substr( $file, -3 ) ) |
|
328 | + foreach ((array) $files as $file => $filedata) { |
|
329 | + if ('.po' == substr($file, -3)) |
|
330 | 330 | $po = true; |
331 | - elseif ( '.mo' == substr( $file, -3 ) ) |
|
331 | + elseif ('.mo' == substr($file, -3)) |
|
332 | 332 | $mo = true; |
333 | 333 | } |
334 | 334 | |
335 | - if ( ! $mo || ! $po ) { |
|
336 | - return new WP_Error( 'incompatible_archive_pomo', $this->strings['incompatible_archive'], |
|
335 | + if ( ! $mo || ! $po) { |
|
336 | + return new WP_Error('incompatible_archive_pomo', $this->strings['incompatible_archive'], |
|
337 | 337 | /* translators: 1: .po 2: .mo */ |
338 | - sprintf( __( 'The language pack is missing either the %1$s or %2$s files.' ), |
|
338 | + sprintf(__('The language pack is missing either the %1$s or %2$s files.'), |
|
339 | 339 | '<code>.po</code>', |
340 | 340 | '<code>.mo</code>' |
341 | 341 | ) |
@@ -354,20 +354,20 @@ discard block |
||
354 | 354 | * @param object $update The data for an update. |
355 | 355 | * @return string The name of the item being updated. |
356 | 356 | */ |
357 | - public function get_name_for_update( $update ) { |
|
358 | - switch ( $update->type ) { |
|
357 | + public function get_name_for_update($update) { |
|
358 | + switch ($update->type) { |
|
359 | 359 | case 'core': |
360 | 360 | return 'WordPress'; // Not translated |
361 | 361 | |
362 | 362 | case 'theme': |
363 | - $theme = wp_get_theme( $update->slug ); |
|
364 | - if ( $theme->exists() ) |
|
365 | - return $theme->Get( 'Name' ); |
|
363 | + $theme = wp_get_theme($update->slug); |
|
364 | + if ($theme->exists()) |
|
365 | + return $theme->Get('Name'); |
|
366 | 366 | break; |
367 | 367 | case 'plugin': |
368 | - $plugin_data = get_plugins( '/' . $update->slug ); |
|
369 | - $plugin_data = reset( $plugin_data ); |
|
370 | - if ( $plugin_data ) |
|
368 | + $plugin_data = get_plugins('/'.$update->slug); |
|
369 | + $plugin_data = reset($plugin_data); |
|
370 | + if ($plugin_data) |
|
371 | 371 | return $plugin_data['Name']; |
372 | 372 | break; |
373 | 373 | } |
@@ -33,9 +33,9 @@ discard block |
||
33 | 33 | $this->strings['downloading_package'] = __('Downloading update from <span class="code">%s</span>…'); |
34 | 34 | $this->strings['unpack_package'] = __('Unpacking the update…'); |
35 | 35 | $this->strings['copy_failed'] = __('Could not copy files.'); |
36 | - $this->strings['copy_failed_space'] = __('Could not copy files. You may have run out of disk space.' ); |
|
37 | - $this->strings['start_rollback'] = __( 'Attempting to roll back to previous version.' ); |
|
38 | - $this->strings['rollback_was_required'] = __( 'Due to an error during updating, WordPress has rolled back to your previous version.' ); |
|
36 | + $this->strings['copy_failed_space'] = __('Could not copy files. You may have run out of disk space.'); |
|
37 | + $this->strings['start_rollback'] = __('Attempting to roll back to previous version.'); |
|
38 | + $this->strings['rollback_was_required'] = __('Due to an error during updating, WordPress has rolled back to your previous version.'); |
|
39 | 39 | } |
40 | 40 | |
41 | 41 | /** |
@@ -60,10 +60,10 @@ discard block |
||
60 | 60 | * } |
61 | 61 | * @return null|false|WP_Error False or WP_Error on failure, null on success. |
62 | 62 | */ |
63 | - public function upgrade( $current, $args = array() ) { |
|
63 | + public function upgrade($current, $args = array()) { |
|
64 | 64 | global $wp_filesystem; |
65 | 65 | |
66 | - include( ABSPATH . WPINC . '/version.php' ); // $wp_version; |
|
66 | + include(ABSPATH.WPINC.'/version.php'); // $wp_version; |
|
67 | 67 | |
68 | 68 | $start_time = time(); |
69 | 69 | |
@@ -73,26 +73,26 @@ discard block |
||
73 | 73 | 'do_rollback' => false, |
74 | 74 | 'allow_relaxed_file_ownership' => false, |
75 | 75 | ); |
76 | - $parsed_args = wp_parse_args( $args, $defaults ); |
|
76 | + $parsed_args = wp_parse_args($args, $defaults); |
|
77 | 77 | |
78 | 78 | $this->init(); |
79 | 79 | $this->upgrade_strings(); |
80 | 80 | |
81 | 81 | // Is an update available? |
82 | - if ( !isset( $current->response ) || $current->response == 'latest' ) |
|
82 | + if ( ! isset($current->response) || $current->response == 'latest') |
|
83 | 83 | return new WP_Error('up_to_date', $this->strings['up_to_date']); |
84 | 84 | |
85 | - $res = $this->fs_connect( array( ABSPATH, WP_CONTENT_DIR ), $parsed_args['allow_relaxed_file_ownership'] ); |
|
86 | - if ( ! $res || is_wp_error( $res ) ) { |
|
85 | + $res = $this->fs_connect(array(ABSPATH, WP_CONTENT_DIR), $parsed_args['allow_relaxed_file_ownership']); |
|
86 | + if ( ! $res || is_wp_error($res)) { |
|
87 | 87 | return $res; |
88 | 88 | } |
89 | 89 | |
90 | 90 | $wp_dir = trailingslashit($wp_filesystem->abspath()); |
91 | 91 | |
92 | 92 | $partial = true; |
93 | - if ( $parsed_args['do_rollback'] ) |
|
93 | + if ($parsed_args['do_rollback']) |
|
94 | 94 | $partial = false; |
95 | - elseif ( $parsed_args['pre_check_md5'] && ! $this->check_files() ) |
|
95 | + elseif ($parsed_args['pre_check_md5'] && ! $this->check_files()) |
|
96 | 96 | $partial = false; |
97 | 97 | |
98 | 98 | /* |
@@ -101,112 +101,112 @@ discard block |
||
101 | 101 | * the new_bundled zip. Don't though if the constant is set to skip bundled items. |
102 | 102 | * If the API returns a no_content zip, go with it. Finally, default to the full zip. |
103 | 103 | */ |
104 | - if ( $parsed_args['do_rollback'] && $current->packages->rollback ) |
|
104 | + if ($parsed_args['do_rollback'] && $current->packages->rollback) |
|
105 | 105 | $to_download = 'rollback'; |
106 | - elseif ( $current->packages->partial && 'reinstall' != $current->response && $wp_version == $current->partial_version && $partial ) |
|
106 | + elseif ($current->packages->partial && 'reinstall' != $current->response && $wp_version == $current->partial_version && $partial) |
|
107 | 107 | $to_download = 'partial'; |
108 | - elseif ( $current->packages->new_bundled && version_compare( $wp_version, $current->new_bundled, '<' ) |
|
109 | - && ( ! defined( 'CORE_UPGRADE_SKIP_NEW_BUNDLED' ) || ! CORE_UPGRADE_SKIP_NEW_BUNDLED ) ) |
|
108 | + elseif ($current->packages->new_bundled && version_compare($wp_version, $current->new_bundled, '<') |
|
109 | + && ( ! defined('CORE_UPGRADE_SKIP_NEW_BUNDLED') || ! CORE_UPGRADE_SKIP_NEW_BUNDLED)) |
|
110 | 110 | $to_download = 'new_bundled'; |
111 | - elseif ( $current->packages->no_content ) |
|
111 | + elseif ($current->packages->no_content) |
|
112 | 112 | $to_download = 'no_content'; |
113 | 113 | else |
114 | 114 | $to_download = 'full'; |
115 | 115 | |
116 | 116 | // Lock to prevent multiple Core Updates occuring |
117 | - $lock = WP_Upgrader::create_lock( 'core_updater', 15 * MINUTE_IN_SECONDS ); |
|
118 | - if ( ! $lock ) { |
|
119 | - return new WP_Error( 'locked', $this->strings['locked'] ); |
|
117 | + $lock = WP_Upgrader::create_lock('core_updater', 15 * MINUTE_IN_SECONDS); |
|
118 | + if ( ! $lock) { |
|
119 | + return new WP_Error('locked', $this->strings['locked']); |
|
120 | 120 | } |
121 | 121 | |
122 | - $download = $this->download_package( $current->packages->$to_download ); |
|
123 | - if ( is_wp_error( $download ) ) { |
|
124 | - WP_Upgrader::release_lock( 'core_updater' ); |
|
122 | + $download = $this->download_package($current->packages->$to_download); |
|
123 | + if (is_wp_error($download)) { |
|
124 | + WP_Upgrader::release_lock('core_updater'); |
|
125 | 125 | return $download; |
126 | 126 | } |
127 | 127 | |
128 | - $working_dir = $this->unpack_package( $download ); |
|
129 | - if ( is_wp_error( $working_dir ) ) { |
|
130 | - WP_Upgrader::release_lock( 'core_updater' ); |
|
128 | + $working_dir = $this->unpack_package($download); |
|
129 | + if (is_wp_error($working_dir)) { |
|
130 | + WP_Upgrader::release_lock('core_updater'); |
|
131 | 131 | return $working_dir; |
132 | 132 | } |
133 | 133 | |
134 | 134 | // Copy update-core.php from the new version into place. |
135 | - if ( !$wp_filesystem->copy($working_dir . '/wordpress/wp-admin/includes/update-core.php', $wp_dir . 'wp-admin/includes/update-core.php', true) ) { |
|
135 | + if ( ! $wp_filesystem->copy($working_dir.'/wordpress/wp-admin/includes/update-core.php', $wp_dir.'wp-admin/includes/update-core.php', true)) { |
|
136 | 136 | $wp_filesystem->delete($working_dir, true); |
137 | - WP_Upgrader::release_lock( 'core_updater' ); |
|
138 | - return new WP_Error( 'copy_failed_for_update_core_file', __( 'The update cannot be installed because we will be unable to copy some files. This is usually due to inconsistent file permissions.' ), 'wp-admin/includes/update-core.php' ); |
|
137 | + WP_Upgrader::release_lock('core_updater'); |
|
138 | + return new WP_Error('copy_failed_for_update_core_file', __('The update cannot be installed because we will be unable to copy some files. This is usually due to inconsistent file permissions.'), 'wp-admin/includes/update-core.php'); |
|
139 | 139 | } |
140 | - $wp_filesystem->chmod($wp_dir . 'wp-admin/includes/update-core.php', FS_CHMOD_FILE); |
|
140 | + $wp_filesystem->chmod($wp_dir.'wp-admin/includes/update-core.php', FS_CHMOD_FILE); |
|
141 | 141 | |
142 | - require_once( ABSPATH . 'wp-admin/includes/update-core.php' ); |
|
142 | + require_once(ABSPATH.'wp-admin/includes/update-core.php'); |
|
143 | 143 | |
144 | - if ( ! function_exists( 'update_core' ) ) { |
|
145 | - WP_Upgrader::release_lock( 'core_updater' ); |
|
146 | - return new WP_Error( 'copy_failed_space', $this->strings['copy_failed_space'] ); |
|
144 | + if ( ! function_exists('update_core')) { |
|
145 | + WP_Upgrader::release_lock('core_updater'); |
|
146 | + return new WP_Error('copy_failed_space', $this->strings['copy_failed_space']); |
|
147 | 147 | } |
148 | 148 | |
149 | - $result = update_core( $working_dir, $wp_dir ); |
|
149 | + $result = update_core($working_dir, $wp_dir); |
|
150 | 150 | |
151 | 151 | // In the event of an issue, we may be able to roll back. |
152 | - if ( $parsed_args['attempt_rollback'] && $current->packages->rollback && ! $parsed_args['do_rollback'] ) { |
|
152 | + if ($parsed_args['attempt_rollback'] && $current->packages->rollback && ! $parsed_args['do_rollback']) { |
|
153 | 153 | $try_rollback = false; |
154 | - if ( is_wp_error( $result ) ) { |
|
154 | + if (is_wp_error($result)) { |
|
155 | 155 | $error_code = $result->get_error_code(); |
156 | 156 | /* |
157 | 157 | * Not all errors are equal. These codes are critical: copy_failed__copy_dir, |
158 | 158 | * mkdir_failed__copy_dir, copy_failed__copy_dir_retry, and disk_full. |
159 | 159 | * do_rollback allows for update_core() to trigger a rollback if needed. |
160 | 160 | */ |
161 | - if ( false !== strpos( $error_code, 'do_rollback' ) ) |
|
161 | + if (false !== strpos($error_code, 'do_rollback')) |
|
162 | 162 | $try_rollback = true; |
163 | - elseif ( false !== strpos( $error_code, '__copy_dir' ) ) |
|
163 | + elseif (false !== strpos($error_code, '__copy_dir')) |
|
164 | 164 | $try_rollback = true; |
165 | - elseif ( 'disk_full' === $error_code ) |
|
165 | + elseif ('disk_full' === $error_code) |
|
166 | 166 | $try_rollback = true; |
167 | 167 | } |
168 | 168 | |
169 | - if ( $try_rollback ) { |
|
169 | + if ($try_rollback) { |
|
170 | 170 | /** This filter is documented in wp-admin/includes/update-core.php */ |
171 | - apply_filters( 'update_feedback', $result ); |
|
171 | + apply_filters('update_feedback', $result); |
|
172 | 172 | |
173 | 173 | /** This filter is documented in wp-admin/includes/update-core.php */ |
174 | - apply_filters( 'update_feedback', $this->strings['start_rollback'] ); |
|
174 | + apply_filters('update_feedback', $this->strings['start_rollback']); |
|
175 | 175 | |
176 | - $rollback_result = $this->upgrade( $current, array_merge( $parsed_args, array( 'do_rollback' => true ) ) ); |
|
176 | + $rollback_result = $this->upgrade($current, array_merge($parsed_args, array('do_rollback' => true))); |
|
177 | 177 | |
178 | 178 | $original_result = $result; |
179 | - $result = new WP_Error( 'rollback_was_required', $this->strings['rollback_was_required'], (object) array( 'update' => $original_result, 'rollback' => $rollback_result ) ); |
|
179 | + $result = new WP_Error('rollback_was_required', $this->strings['rollback_was_required'], (object) array('update' => $original_result, 'rollback' => $rollback_result)); |
|
180 | 180 | } |
181 | 181 | } |
182 | 182 | |
183 | 183 | /** This action is documented in wp-admin/includes/class-wp-upgrader.php */ |
184 | - do_action( 'upgrader_process_complete', $this, array( 'action' => 'update', 'type' => 'core' ) ); |
|
184 | + do_action('upgrader_process_complete', $this, array('action' => 'update', 'type' => 'core')); |
|
185 | 185 | |
186 | 186 | // Clear the current updates |
187 | - delete_site_transient( 'update_core' ); |
|
187 | + delete_site_transient('update_core'); |
|
188 | 188 | |
189 | - if ( ! $parsed_args['do_rollback'] ) { |
|
189 | + if ( ! $parsed_args['do_rollback']) { |
|
190 | 190 | $stats = array( |
191 | 191 | 'update_type' => $current->response, |
192 | 192 | 'success' => true, |
193 | 193 | 'fs_method' => $wp_filesystem->method, |
194 | - 'fs_method_forced' => defined( 'FS_METHOD' ) || has_filter( 'filesystem_method' ), |
|
195 | - 'fs_method_direct' => !empty( $GLOBALS['_wp_filesystem_direct_method'] ) ? $GLOBALS['_wp_filesystem_direct_method'] : '', |
|
194 | + 'fs_method_forced' => defined('FS_METHOD') || has_filter('filesystem_method'), |
|
195 | + 'fs_method_direct' => ! empty($GLOBALS['_wp_filesystem_direct_method']) ? $GLOBALS['_wp_filesystem_direct_method'] : '', |
|
196 | 196 | 'time_taken' => time() - $start_time, |
197 | 197 | 'reported' => $wp_version, |
198 | 198 | 'attempted' => $current->version, |
199 | 199 | ); |
200 | 200 | |
201 | - if ( is_wp_error( $result ) ) { |
|
201 | + if (is_wp_error($result)) { |
|
202 | 202 | $stats['success'] = false; |
203 | 203 | // Did a rollback occur? |
204 | - if ( ! empty( $try_rollback ) ) { |
|
204 | + if ( ! empty($try_rollback)) { |
|
205 | 205 | $stats['error_code'] = $original_result->get_error_code(); |
206 | 206 | $stats['error_data'] = $original_result->get_error_data(); |
207 | 207 | // Was the rollback successful? If not, collect its error too. |
208 | - $stats['rollback'] = ! is_wp_error( $rollback_result ); |
|
209 | - if ( is_wp_error( $rollback_result ) ) { |
|
208 | + $stats['rollback'] = ! is_wp_error($rollback_result); |
|
209 | + if (is_wp_error($rollback_result)) { |
|
210 | 210 | $stats['rollback_code'] = $rollback_result->get_error_code(); |
211 | 211 | $stats['rollback_data'] = $rollback_result->get_error_data(); |
212 | 212 | } |
@@ -216,10 +216,10 @@ discard block |
||
216 | 216 | } |
217 | 217 | } |
218 | 218 | |
219 | - wp_version_check( $stats ); |
|
219 | + wp_version_check($stats); |
|
220 | 220 | } |
221 | 221 | |
222 | - WP_Upgrader::release_lock( 'core_updater' ); |
|
222 | + WP_Upgrader::release_lock('core_updater'); |
|
223 | 223 | |
224 | 224 | return $result; |
225 | 225 | } |
@@ -235,12 +235,12 @@ discard block |
||
235 | 235 | * @param string $offered_ver The offered version, of the format x.y.z. |
236 | 236 | * @return bool True if we should update to the offered version, otherwise false. |
237 | 237 | */ |
238 | - public static function should_update_to_version( $offered_ver ) { |
|
239 | - include( ABSPATH . WPINC . '/version.php' ); // $wp_version; // x.y.z |
|
238 | + public static function should_update_to_version($offered_ver) { |
|
239 | + include(ABSPATH.WPINC.'/version.php'); // $wp_version; // x.y.z |
|
240 | 240 | |
241 | - $current_branch = implode( '.', array_slice( preg_split( '/[.-]/', $wp_version ), 0, 2 ) ); // x.y |
|
242 | - $new_branch = implode( '.', array_slice( preg_split( '/[.-]/', $offered_ver ), 0, 2 ) ); // x.y |
|
243 | - $current_is_development_version = (bool) strpos( $wp_version, '-' ); |
|
241 | + $current_branch = implode('.', array_slice(preg_split('/[.-]/', $wp_version), 0, 2)); // x.y |
|
242 | + $new_branch = implode('.', array_slice(preg_split('/[.-]/', $offered_ver), 0, 2)); // x.y |
|
243 | + $current_is_development_version = (bool) strpos($wp_version, '-'); |
|
244 | 244 | |
245 | 245 | // Defaults: |
246 | 246 | $upgrade_dev = true; |
@@ -248,14 +248,14 @@ discard block |
||
248 | 248 | $upgrade_major = false; |
249 | 249 | |
250 | 250 | // WP_AUTO_UPDATE_CORE = true (all), 'minor', false. |
251 | - if ( defined( 'WP_AUTO_UPDATE_CORE' ) ) { |
|
252 | - if ( false === WP_AUTO_UPDATE_CORE ) { |
|
251 | + if (defined('WP_AUTO_UPDATE_CORE')) { |
|
252 | + if (false === WP_AUTO_UPDATE_CORE) { |
|
253 | 253 | // Defaults to turned off, unless a filter allows it |
254 | 254 | $upgrade_dev = $upgrade_minor = $upgrade_major = false; |
255 | - } elseif ( true === WP_AUTO_UPDATE_CORE ) { |
|
255 | + } elseif (true === WP_AUTO_UPDATE_CORE) { |
|
256 | 256 | // ALL updates for core |
257 | 257 | $upgrade_dev = $upgrade_minor = $upgrade_major = true; |
258 | - } elseif ( 'minor' === WP_AUTO_UPDATE_CORE ) { |
|
258 | + } elseif ('minor' === WP_AUTO_UPDATE_CORE) { |
|
259 | 259 | // Only minor updates for core |
260 | 260 | $upgrade_dev = $upgrade_major = false; |
261 | 261 | $upgrade_minor = true; |
@@ -263,32 +263,32 @@ discard block |
||
263 | 263 | } |
264 | 264 | |
265 | 265 | // 1: If we're already on that version, not much point in updating? |
266 | - if ( $offered_ver == $wp_version ) |
|
266 | + if ($offered_ver == $wp_version) |
|
267 | 267 | return false; |
268 | 268 | |
269 | 269 | // 2: If we're running a newer version, that's a nope |
270 | - if ( version_compare( $wp_version, $offered_ver, '>' ) ) |
|
270 | + if (version_compare($wp_version, $offered_ver, '>')) |
|
271 | 271 | return false; |
272 | 272 | |
273 | - $failure_data = get_site_option( 'auto_core_update_failed' ); |
|
274 | - if ( $failure_data ) { |
|
273 | + $failure_data = get_site_option('auto_core_update_failed'); |
|
274 | + if ($failure_data) { |
|
275 | 275 | // If this was a critical update failure, cannot update. |
276 | - if ( ! empty( $failure_data['critical'] ) ) |
|
276 | + if ( ! empty($failure_data['critical'])) |
|
277 | 277 | return false; |
278 | 278 | |
279 | 279 | // Don't claim we can update on update-core.php if we have a non-critical failure logged. |
280 | - if ( $wp_version == $failure_data['current'] && false !== strpos( $offered_ver, '.1.next.minor' ) ) |
|
280 | + if ($wp_version == $failure_data['current'] && false !== strpos($offered_ver, '.1.next.minor')) |
|
281 | 281 | return false; |
282 | 282 | |
283 | 283 | // Cannot update if we're retrying the same A to B update that caused a non-critical failure. |
284 | 284 | // Some non-critical failures do allow retries, like download_failed. |
285 | 285 | // 3.7.1 => 3.7.2 resulted in files_not_writable, if we are still on 3.7.1 and still trying to update to 3.7.2. |
286 | - if ( empty( $failure_data['retry'] ) && $wp_version == $failure_data['current'] && $offered_ver == $failure_data['attempted'] ) |
|
286 | + if (empty($failure_data['retry']) && $wp_version == $failure_data['current'] && $offered_ver == $failure_data['attempted']) |
|
287 | 287 | return false; |
288 | 288 | } |
289 | 289 | |
290 | 290 | // 3: 3.7-alpha-25000 -> 3.7-alpha-25678 -> 3.7-beta1 -> 3.7-beta2 |
291 | - if ( $current_is_development_version ) { |
|
291 | + if ($current_is_development_version) { |
|
292 | 292 | |
293 | 293 | /** |
294 | 294 | * Filters whether to enable automatic core updates for development versions. |
@@ -298,13 +298,13 @@ discard block |
||
298 | 298 | * @param bool $upgrade_dev Whether to enable automatic updates for |
299 | 299 | * development versions. |
300 | 300 | */ |
301 | - if ( ! apply_filters( 'allow_dev_auto_core_updates', $upgrade_dev ) ) |
|
301 | + if ( ! apply_filters('allow_dev_auto_core_updates', $upgrade_dev)) |
|
302 | 302 | return false; |
303 | 303 | // Else fall through to minor + major branches below. |
304 | 304 | } |
305 | 305 | |
306 | 306 | // 4: Minor In-branch updates (3.7.0 -> 3.7.1 -> 3.7.2 -> 3.7.4) |
307 | - if ( $current_branch == $new_branch ) { |
|
307 | + if ($current_branch == $new_branch) { |
|
308 | 308 | |
309 | 309 | /** |
310 | 310 | * Filters whether to enable minor automatic core updates. |
@@ -313,11 +313,11 @@ discard block |
||
313 | 313 | * |
314 | 314 | * @param bool $upgrade_minor Whether to enable minor automatic core updates. |
315 | 315 | */ |
316 | - return apply_filters( 'allow_minor_auto_core_updates', $upgrade_minor ); |
|
316 | + return apply_filters('allow_minor_auto_core_updates', $upgrade_minor); |
|
317 | 317 | } |
318 | 318 | |
319 | 319 | // 5: Major version updates (3.7.0 -> 3.8.0 -> 3.9.1) |
320 | - if ( version_compare( $new_branch, $current_branch, '>' ) ) { |
|
320 | + if (version_compare($new_branch, $current_branch, '>')) { |
|
321 | 321 | |
322 | 322 | /** |
323 | 323 | * Filters whether to enable major automatic core updates. |
@@ -326,7 +326,7 @@ discard block |
||
326 | 326 | * |
327 | 327 | * @param bool $upgrade_major Whether to enable major automatic core updates. |
328 | 328 | */ |
329 | - return apply_filters( 'allow_major_auto_core_updates', $upgrade_major ); |
|
329 | + return apply_filters('allow_major_auto_core_updates', $upgrade_major); |
|
330 | 330 | } |
331 | 331 | |
332 | 332 | // If we're not sure, we don't want it |
@@ -347,16 +347,16 @@ discard block |
||
347 | 347 | public function check_files() { |
348 | 348 | global $wp_version, $wp_local_package; |
349 | 349 | |
350 | - $checksums = get_core_checksums( $wp_version, isset( $wp_local_package ) ? $wp_local_package : 'en_US' ); |
|
350 | + $checksums = get_core_checksums($wp_version, isset($wp_local_package) ? $wp_local_package : 'en_US'); |
|
351 | 351 | |
352 | - if ( ! is_array( $checksums ) ) |
|
352 | + if ( ! is_array($checksums)) |
|
353 | 353 | return false; |
354 | 354 | |
355 | - foreach ( $checksums as $file => $checksum ) { |
|
355 | + foreach ($checksums as $file => $checksum) { |
|
356 | 356 | // Skip files which get updated |
357 | - if ( 'wp-content' == substr( $file, 0, 10 ) ) |
|
357 | + if ('wp-content' == substr($file, 0, 10)) |
|
358 | 358 | continue; |
359 | - if ( ! file_exists( ABSPATH . $file ) || md5_file( ABSPATH . $file ) !== $checksum ) |
|
359 | + if ( ! file_exists(ABSPATH.$file) || md5_file(ABSPATH.$file) !== $checksum) |
|
360 | 360 | return false; |
361 | 361 | } |
362 | 362 |
@@ -79,8 +79,9 @@ discard block |
||
79 | 79 | $this->upgrade_strings(); |
80 | 80 | |
81 | 81 | // Is an update available? |
82 | - if ( !isset( $current->response ) || $current->response == 'latest' ) |
|
83 | - return new WP_Error('up_to_date', $this->strings['up_to_date']); |
|
82 | + if ( !isset( $current->response ) || $current->response == 'latest' ) { |
|
83 | + return new WP_Error('up_to_date', $this->strings['up_to_date']); |
|
84 | + } |
|
84 | 85 | |
85 | 86 | $res = $this->fs_connect( array( ABSPATH, WP_CONTENT_DIR ), $parsed_args['allow_relaxed_file_ownership'] ); |
86 | 87 | if ( ! $res || is_wp_error( $res ) ) { |
@@ -90,10 +91,11 @@ discard block |
||
90 | 91 | $wp_dir = trailingslashit($wp_filesystem->abspath()); |
91 | 92 | |
92 | 93 | $partial = true; |
93 | - if ( $parsed_args['do_rollback'] ) |
|
94 | - $partial = false; |
|
95 | - elseif ( $parsed_args['pre_check_md5'] && ! $this->check_files() ) |
|
96 | - $partial = false; |
|
94 | + if ( $parsed_args['do_rollback'] ) { |
|
95 | + $partial = false; |
|
96 | + } elseif ( $parsed_args['pre_check_md5'] && ! $this->check_files() ) { |
|
97 | + $partial = false; |
|
98 | + } |
|
97 | 99 | |
98 | 100 | /* |
99 | 101 | * If partial update is returned from the API, use that, unless we're doing |
@@ -101,17 +103,18 @@ discard block |
||
101 | 103 | * the new_bundled zip. Don't though if the constant is set to skip bundled items. |
102 | 104 | * If the API returns a no_content zip, go with it. Finally, default to the full zip. |
103 | 105 | */ |
104 | - if ( $parsed_args['do_rollback'] && $current->packages->rollback ) |
|
105 | - $to_download = 'rollback'; |
|
106 | - elseif ( $current->packages->partial && 'reinstall' != $current->response && $wp_version == $current->partial_version && $partial ) |
|
107 | - $to_download = 'partial'; |
|
108 | - elseif ( $current->packages->new_bundled && version_compare( $wp_version, $current->new_bundled, '<' ) |
|
109 | - && ( ! defined( 'CORE_UPGRADE_SKIP_NEW_BUNDLED' ) || ! CORE_UPGRADE_SKIP_NEW_BUNDLED ) ) |
|
110 | - $to_download = 'new_bundled'; |
|
111 | - elseif ( $current->packages->no_content ) |
|
112 | - $to_download = 'no_content'; |
|
113 | - else |
|
114 | - $to_download = 'full'; |
|
106 | + if ( $parsed_args['do_rollback'] && $current->packages->rollback ) { |
|
107 | + $to_download = 'rollback'; |
|
108 | + } elseif ( $current->packages->partial && 'reinstall' != $current->response && $wp_version == $current->partial_version && $partial ) { |
|
109 | + $to_download = 'partial'; |
|
110 | + } elseif ( $current->packages->new_bundled && version_compare( $wp_version, $current->new_bundled, '<' ) |
|
111 | + && ( ! defined( 'CORE_UPGRADE_SKIP_NEW_BUNDLED' ) || ! CORE_UPGRADE_SKIP_NEW_BUNDLED ) ) { |
|
112 | + $to_download = 'new_bundled'; |
|
113 | + } elseif ( $current->packages->no_content ) { |
|
114 | + $to_download = 'no_content'; |
|
115 | + } else { |
|
116 | + $to_download = 'full'; |
|
117 | + } |
|
115 | 118 | |
116 | 119 | // Lock to prevent multiple Core Updates occuring |
117 | 120 | $lock = WP_Upgrader::create_lock( 'core_updater', 15 * MINUTE_IN_SECONDS ); |
@@ -158,12 +161,13 @@ discard block |
||
158 | 161 | * mkdir_failed__copy_dir, copy_failed__copy_dir_retry, and disk_full. |
159 | 162 | * do_rollback allows for update_core() to trigger a rollback if needed. |
160 | 163 | */ |
161 | - if ( false !== strpos( $error_code, 'do_rollback' ) ) |
|
162 | - $try_rollback = true; |
|
163 | - elseif ( false !== strpos( $error_code, '__copy_dir' ) ) |
|
164 | - $try_rollback = true; |
|
165 | - elseif ( 'disk_full' === $error_code ) |
|
166 | - $try_rollback = true; |
|
164 | + if ( false !== strpos( $error_code, 'do_rollback' ) ) { |
|
165 | + $try_rollback = true; |
|
166 | + } elseif ( false !== strpos( $error_code, '__copy_dir' ) ) { |
|
167 | + $try_rollback = true; |
|
168 | + } elseif ( 'disk_full' === $error_code ) { |
|
169 | + $try_rollback = true; |
|
170 | + } |
|
167 | 171 | } |
168 | 172 | |
169 | 173 | if ( $try_rollback ) { |
@@ -263,28 +267,33 @@ discard block |
||
263 | 267 | } |
264 | 268 | |
265 | 269 | // 1: If we're already on that version, not much point in updating? |
266 | - if ( $offered_ver == $wp_version ) |
|
267 | - return false; |
|
270 | + if ( $offered_ver == $wp_version ) { |
|
271 | + return false; |
|
272 | + } |
|
268 | 273 | |
269 | 274 | // 2: If we're running a newer version, that's a nope |
270 | - if ( version_compare( $wp_version, $offered_ver, '>' ) ) |
|
271 | - return false; |
|
275 | + if ( version_compare( $wp_version, $offered_ver, '>' ) ) { |
|
276 | + return false; |
|
277 | + } |
|
272 | 278 | |
273 | 279 | $failure_data = get_site_option( 'auto_core_update_failed' ); |
274 | 280 | if ( $failure_data ) { |
275 | 281 | // If this was a critical update failure, cannot update. |
276 | - if ( ! empty( $failure_data['critical'] ) ) |
|
277 | - return false; |
|
282 | + if ( ! empty( $failure_data['critical'] ) ) { |
|
283 | + return false; |
|
284 | + } |
|
278 | 285 | |
279 | 286 | // Don't claim we can update on update-core.php if we have a non-critical failure logged. |
280 | - if ( $wp_version == $failure_data['current'] && false !== strpos( $offered_ver, '.1.next.minor' ) ) |
|
281 | - return false; |
|
287 | + if ( $wp_version == $failure_data['current'] && false !== strpos( $offered_ver, '.1.next.minor' ) ) { |
|
288 | + return false; |
|
289 | + } |
|
282 | 290 | |
283 | 291 | // Cannot update if we're retrying the same A to B update that caused a non-critical failure. |
284 | 292 | // Some non-critical failures do allow retries, like download_failed. |
285 | 293 | // 3.7.1 => 3.7.2 resulted in files_not_writable, if we are still on 3.7.1 and still trying to update to 3.7.2. |
286 | - if ( empty( $failure_data['retry'] ) && $wp_version == $failure_data['current'] && $offered_ver == $failure_data['attempted'] ) |
|
287 | - return false; |
|
294 | + if ( empty( $failure_data['retry'] ) && $wp_version == $failure_data['current'] && $offered_ver == $failure_data['attempted'] ) { |
|
295 | + return false; |
|
296 | + } |
|
288 | 297 | } |
289 | 298 | |
290 | 299 | // 3: 3.7-alpha-25000 -> 3.7-alpha-25678 -> 3.7-beta1 -> 3.7-beta2 |
@@ -298,8 +307,9 @@ discard block |
||
298 | 307 | * @param bool $upgrade_dev Whether to enable automatic updates for |
299 | 308 | * development versions. |
300 | 309 | */ |
301 | - if ( ! apply_filters( 'allow_dev_auto_core_updates', $upgrade_dev ) ) |
|
302 | - return false; |
|
310 | + if ( ! apply_filters( 'allow_dev_auto_core_updates', $upgrade_dev ) ) { |
|
311 | + return false; |
|
312 | + } |
|
303 | 313 | // Else fall through to minor + major branches below. |
304 | 314 | } |
305 | 315 | |
@@ -349,15 +359,18 @@ discard block |
||
349 | 359 | |
350 | 360 | $checksums = get_core_checksums( $wp_version, isset( $wp_local_package ) ? $wp_local_package : 'en_US' ); |
351 | 361 | |
352 | - if ( ! is_array( $checksums ) ) |
|
353 | - return false; |
|
362 | + if ( ! is_array( $checksums ) ) { |
|
363 | + return false; |
|
364 | + } |
|
354 | 365 | |
355 | 366 | foreach ( $checksums as $file => $checksum ) { |
356 | 367 | // Skip files which get updated |
357 | - if ( 'wp-content' == substr( $file, 0, 10 ) ) |
|
358 | - continue; |
|
359 | - if ( ! file_exists( ABSPATH . $file ) || md5_file( ABSPATH . $file ) !== $checksum ) |
|
360 | - return false; |
|
368 | + if ( 'wp-content' == substr( $file, 0, 10 ) ) { |
|
369 | + continue; |
|
370 | + } |
|
371 | + if ( ! file_exists( ABSPATH . $file ) || md5_file( ABSPATH . $file ) !== $checksum ) { |
|
372 | + return false; |
|
373 | + } |
|
361 | 374 | } |
362 | 375 | |
363 | 376 | return true; |
@@ -13,10 +13,12 @@ discard block |
||
13 | 13 | */ |
14 | 14 | function get_preferred_from_update_core() { |
15 | 15 | $updates = get_core_updates(); |
16 | - if ( ! is_array( $updates ) ) |
|
17 | - return false; |
|
18 | - if ( empty( $updates ) ) |
|
19 | - return (object) array( 'response' => 'latest' ); |
|
16 | + if ( ! is_array( $updates ) ) { |
|
17 | + return false; |
|
18 | + } |
|
19 | + if ( empty( $updates ) ) { |
|
20 | + return (object) array( 'response' => 'latest' ); |
|
21 | + } |
|
20 | 22 | return $updates[0]; |
21 | 23 | } |
22 | 24 | |
@@ -31,19 +33,22 @@ discard block |
||
31 | 33 | $options = array_merge( array( 'available' => true, 'dismissed' => false ), $options ); |
32 | 34 | $dismissed = get_site_option( 'dismissed_update_core' ); |
33 | 35 | |
34 | - if ( ! is_array( $dismissed ) ) |
|
35 | - $dismissed = array(); |
|
36 | + if ( ! is_array( $dismissed ) ) { |
|
37 | + $dismissed = array(); |
|
38 | + } |
|
36 | 39 | |
37 | 40 | $from_api = get_site_transient( 'update_core' ); |
38 | 41 | |
39 | - if ( ! isset( $from_api->updates ) || ! is_array( $from_api->updates ) ) |
|
40 | - return false; |
|
42 | + if ( ! isset( $from_api->updates ) || ! is_array( $from_api->updates ) ) { |
|
43 | + return false; |
|
44 | + } |
|
41 | 45 | |
42 | 46 | $updates = $from_api->updates; |
43 | 47 | $result = array(); |
44 | 48 | foreach ( $updates as $update ) { |
45 | - if ( $update->response == 'autoupdate' ) |
|
46 | - continue; |
|
49 | + if ( $update->response == 'autoupdate' ) { |
|
50 | + continue; |
|
51 | + } |
|
47 | 52 | |
48 | 53 | if ( array_key_exists( $update->current . '|' . $update->locale, $dismissed ) ) { |
49 | 54 | if ( $options['dismissed'] ) { |
@@ -71,22 +76,26 @@ discard block |
||
71 | 76 | */ |
72 | 77 | function find_core_auto_update() { |
73 | 78 | $updates = get_site_transient( 'update_core' ); |
74 | - if ( ! $updates || empty( $updates->updates ) ) |
|
75 | - return false; |
|
79 | + if ( ! $updates || empty( $updates->updates ) ) { |
|
80 | + return false; |
|
81 | + } |
|
76 | 82 | |
77 | 83 | include_once( ABSPATH . 'wp-admin/includes/class-wp-upgrader.php' ); |
78 | 84 | |
79 | 85 | $auto_update = false; |
80 | 86 | $upgrader = new WP_Automatic_Updater; |
81 | 87 | foreach ( $updates->updates as $update ) { |
82 | - if ( 'autoupdate' != $update->response ) |
|
83 | - continue; |
|
88 | + if ( 'autoupdate' != $update->response ) { |
|
89 | + continue; |
|
90 | + } |
|
84 | 91 | |
85 | - if ( ! $upgrader->should_update( 'core', $update, ABSPATH ) ) |
|
86 | - continue; |
|
92 | + if ( ! $upgrader->should_update( 'core', $update, ABSPATH ) ) { |
|
93 | + continue; |
|
94 | + } |
|
87 | 95 | |
88 | - if ( ! $auto_update || version_compare( $update->current, $auto_update->current, '>' ) ) |
|
89 | - $auto_update = $update; |
|
96 | + if ( ! $auto_update || version_compare( $update->current, $auto_update->current, '>' ) ) { |
|
97 | + $auto_update = $update; |
|
98 | + } |
|
90 | 99 | } |
91 | 100 | return $auto_update; |
92 | 101 | } |
@@ -103,8 +112,9 @@ discard block |
||
103 | 112 | function get_core_checksums( $version, $locale ) { |
104 | 113 | $url = $http_url = 'http://api.wordpress.org/core/checksums/1.0/?' . http_build_query( compact( 'version', 'locale' ), null, '&' ); |
105 | 114 | |
106 | - if ( $ssl = wp_http_supports( array( 'ssl' ) ) ) |
|
107 | - $url = set_url_scheme( $url, 'https' ); |
|
115 | + if ( $ssl = wp_http_supports( array( 'ssl' ) ) ) { |
|
116 | + $url = set_url_scheme( $url, 'https' ); |
|
117 | + } |
|
108 | 118 | |
109 | 119 | $options = array( |
110 | 120 | 'timeout' => ( ( defined('DOING_CRON') && DOING_CRON ) ? 30 : 3 ), |
@@ -116,14 +126,16 @@ discard block |
||
116 | 126 | $response = wp_remote_get( $http_url, $options ); |
117 | 127 | } |
118 | 128 | |
119 | - if ( is_wp_error( $response ) || 200 != wp_remote_retrieve_response_code( $response ) ) |
|
120 | - return false; |
|
129 | + if ( is_wp_error( $response ) || 200 != wp_remote_retrieve_response_code( $response ) ) { |
|
130 | + return false; |
|
131 | + } |
|
121 | 132 | |
122 | 133 | $body = trim( wp_remote_retrieve_body( $response ) ); |
123 | 134 | $body = json_decode( $body, true ); |
124 | 135 | |
125 | - if ( ! is_array( $body ) || ! isset( $body['checksums'] ) || ! is_array( $body['checksums'] ) ) |
|
126 | - return false; |
|
136 | + if ( ! is_array( $body ) || ! isset( $body['checksums'] ) || ! is_array( $body['checksums'] ) ) { |
|
137 | + return false; |
|
138 | + } |
|
127 | 139 | |
128 | 140 | return $body['checksums']; |
129 | 141 | } |
@@ -149,8 +161,9 @@ discard block |
||
149 | 161 | $dismissed = get_site_option( 'dismissed_update_core' ); |
150 | 162 | $key = $version . '|' . $locale; |
151 | 163 | |
152 | - if ( ! isset( $dismissed[$key] ) ) |
|
153 | - return false; |
|
164 | + if ( ! isset( $dismissed[$key] ) ) { |
|
165 | + return false; |
|
166 | + } |
|
154 | 167 | |
155 | 168 | unset( $dismissed[$key] ); |
156 | 169 | return update_site_option( 'dismissed_update_core', $dismissed ); |
@@ -165,13 +178,15 @@ discard block |
||
165 | 178 | function find_core_update( $version, $locale ) { |
166 | 179 | $from_api = get_site_transient( 'update_core' ); |
167 | 180 | |
168 | - if ( ! isset( $from_api->updates ) || ! is_array( $from_api->updates ) ) |
|
169 | - return false; |
|
181 | + if ( ! isset( $from_api->updates ) || ! is_array( $from_api->updates ) ) { |
|
182 | + return false; |
|
183 | + } |
|
170 | 184 | |
171 | 185 | $updates = $from_api->updates; |
172 | 186 | foreach ( $updates as $update ) { |
173 | - if ( $update->current == $version && $update->locale == $locale ) |
|
174 | - return $update; |
|
187 | + if ( $update->current == $version && $update->locale == $locale ) { |
|
188 | + return $update; |
|
189 | + } |
|
175 | 190 | } |
176 | 191 | return false; |
177 | 192 | } |
@@ -182,21 +197,26 @@ discard block |
||
182 | 197 | * @return string |
183 | 198 | */ |
184 | 199 | function core_update_footer( $msg = '' ) { |
185 | - if ( !current_user_can('update_core') ) |
|
186 | - return sprintf( __( 'Version %s' ), get_bloginfo( 'version', 'display' ) ); |
|
200 | + if ( !current_user_can('update_core') ) { |
|
201 | + return sprintf( __( 'Version %s' ), get_bloginfo( 'version', 'display' ) ); |
|
202 | + } |
|
187 | 203 | |
188 | 204 | $cur = get_preferred_from_update_core(); |
189 | - if ( ! is_object( $cur ) ) |
|
190 | - $cur = new stdClass; |
|
205 | + if ( ! is_object( $cur ) ) { |
|
206 | + $cur = new stdClass; |
|
207 | + } |
|
191 | 208 | |
192 | - if ( ! isset( $cur->current ) ) |
|
193 | - $cur->current = ''; |
|
209 | + if ( ! isset( $cur->current ) ) { |
|
210 | + $cur->current = ''; |
|
211 | + } |
|
194 | 212 | |
195 | - if ( ! isset( $cur->url ) ) |
|
196 | - $cur->url = ''; |
|
213 | + if ( ! isset( $cur->url ) ) { |
|
214 | + $cur->url = ''; |
|
215 | + } |
|
197 | 216 | |
198 | - if ( ! isset( $cur->response ) ) |
|
199 | - $cur->response = ''; |
|
217 | + if ( ! isset( $cur->response ) ) { |
|
218 | + $cur->response = ''; |
|
219 | + } |
|
200 | 220 | |
201 | 221 | switch ( $cur->response ) { |
202 | 222 | case 'development' : |
@@ -217,18 +237,21 @@ discard block |
||
217 | 237 | * @return false|void |
218 | 238 | */ |
219 | 239 | function update_nag() { |
220 | - if ( is_multisite() && !current_user_can('update_core') ) |
|
221 | - return false; |
|
240 | + if ( is_multisite() && !current_user_can('update_core') ) { |
|
241 | + return false; |
|
242 | + } |
|
222 | 243 | |
223 | 244 | global $pagenow; |
224 | 245 | |
225 | - if ( 'update-core.php' == $pagenow ) |
|
226 | - return; |
|
246 | + if ( 'update-core.php' == $pagenow ) { |
|
247 | + return; |
|
248 | + } |
|
227 | 249 | |
228 | 250 | $cur = get_preferred_from_update_core(); |
229 | 251 | |
230 | - if ( ! isset( $cur->response ) || $cur->response != 'upgrade' ) |
|
231 | - return false; |
|
252 | + if ( ! isset( $cur->response ) || $cur->response != 'upgrade' ) { |
|
253 | + return false; |
|
254 | + } |
|
232 | 255 | |
233 | 256 | if ( current_user_can( 'update_core' ) ) { |
234 | 257 | $msg = sprintf( |
@@ -270,8 +293,9 @@ discard block |
||
270 | 293 | if ( current_user_can('update_core') ) { |
271 | 294 | $cur = get_preferred_from_update_core(); |
272 | 295 | |
273 | - if ( isset( $cur->response ) && $cur->response == 'upgrade' ) |
|
274 | - $msg .= '<a href="' . network_admin_url( 'update-core.php' ) . '" class="button" aria-describedby="wp-version">' . sprintf( __( 'Update to %s' ), $cur->current ? $cur->current : __( 'Latest' ) ) . '</a> '; |
|
296 | + if ( isset( $cur->response ) && $cur->response == 'upgrade' ) { |
|
297 | + $msg .= '<a href="' . network_admin_url( 'update-core.php' ) . '" class="button" aria-describedby="wp-version">' . sprintf( __( 'Update to %s' ), $cur->current ? $cur->current : __( 'Latest' ) ) . '</a> '; |
|
298 | + } |
|
275 | 299 | } |
276 | 300 | |
277 | 301 | /* translators: 1: version number, 2: theme name */ |
@@ -316,8 +340,9 @@ discard block |
||
316 | 340 | * @since 2.9.0 |
317 | 341 | */ |
318 | 342 | function wp_plugin_update_rows() { |
319 | - if ( !current_user_can('update_plugins' ) ) |
|
320 | - return; |
|
343 | + if ( !current_user_can('update_plugins' ) ) { |
|
344 | + return; |
|
345 | + } |
|
321 | 346 | |
322 | 347 | $plugins = get_site_transient( 'update_plugins' ); |
323 | 348 | if ( isset($plugins->response) && is_array($plugins->response) ) { |
@@ -447,8 +472,9 @@ discard block |
||
447 | 472 | function get_theme_updates() { |
448 | 473 | $current = get_site_transient('update_themes'); |
449 | 474 | |
450 | - if ( ! isset( $current->response ) ) |
|
451 | - return array(); |
|
475 | + if ( ! isset( $current->response ) ) { |
|
476 | + return array(); |
|
477 | + } |
|
452 | 478 | |
453 | 479 | $update_themes = array(); |
454 | 480 | foreach ( $current->response as $stylesheet => $data ) { |
@@ -463,8 +489,9 @@ discard block |
||
463 | 489 | * @since 3.1.0 |
464 | 490 | */ |
465 | 491 | function wp_theme_update_rows() { |
466 | - if ( !current_user_can('update_themes' ) ) |
|
467 | - return; |
|
492 | + if ( !current_user_can('update_themes' ) ) { |
|
493 | + return; |
|
494 | + } |
|
468 | 495 | |
469 | 496 | $themes = get_site_transient( 'update_themes' ); |
470 | 497 | if ( isset($themes->response) && is_array($themes->response) ) { |
@@ -581,17 +608,20 @@ discard block |
||
581 | 608 | * This flag is cleared whenever a successful update occurs using Core_Upgrader. |
582 | 609 | */ |
583 | 610 | $comparison = ! empty( $failed['critical'] ) ? '>=' : '>'; |
584 | - if ( version_compare( $failed['attempted'], $wp_version, $comparison ) ) |
|
585 | - $nag = true; |
|
611 | + if ( version_compare( $failed['attempted'], $wp_version, $comparison ) ) { |
|
612 | + $nag = true; |
|
613 | + } |
|
586 | 614 | } |
587 | 615 | |
588 | - if ( ! $nag ) |
|
589 | - return false; |
|
616 | + if ( ! $nag ) { |
|
617 | + return false; |
|
618 | + } |
|
590 | 619 | |
591 | - if ( current_user_can('update_core') ) |
|
592 | - $msg = sprintf( __('An automated WordPress update has failed to complete - <a href="%s">please attempt the update again now</a>.'), 'update-core.php' ); |
|
593 | - else |
|
594 | - $msg = __('An automated WordPress update has failed to complete! Please notify the site administrator.'); |
|
620 | + if ( current_user_can('update_core') ) { |
|
621 | + $msg = sprintf( __('An automated WordPress update has failed to complete - <a href="%s">please attempt the update again now</a>.'), 'update-core.php' ); |
|
622 | + } else { |
|
623 | + $msg = __('An automated WordPress update has failed to complete! Please notify the site administrator.'); |
|
624 | + } |
|
595 | 625 | |
596 | 626 | echo "<div class='update-nag'>$msg</div>"; |
597 | 627 | } |
@@ -206,16 +206,16 @@ |
||
206 | 206 | $cur->response = ''; |
207 | 207 | |
208 | 208 | switch ( $cur->response ) { |
209 | - case 'development' : |
|
210 | - /* translators: 1: WordPress version number, 2: WordPress updates admin screen URL */ |
|
211 | - return sprintf( __( 'You are using a development version (%1$s). Cool! Please <a href="%2$s">stay updated</a>.' ), get_bloginfo( 'version', 'display' ), network_admin_url( 'update-core.php' ) ); |
|
209 | + case 'development' : |
|
210 | + /* translators: 1: WordPress version number, 2: WordPress updates admin screen URL */ |
|
211 | + return sprintf( __( 'You are using a development version (%1$s). Cool! Please <a href="%2$s">stay updated</a>.' ), get_bloginfo( 'version', 'display' ), network_admin_url( 'update-core.php' ) ); |
|
212 | 212 | |
213 | - case 'upgrade' : |
|
214 | - return '<strong><a href="' . network_admin_url( 'update-core.php' ) . '">' . sprintf( __( 'Get Version %s' ), $cur->current ) . '</a></strong>'; |
|
213 | + case 'upgrade' : |
|
214 | + return '<strong><a href="' . network_admin_url( 'update-core.php' ) . '">' . sprintf( __( 'Get Version %s' ), $cur->current ) . '</a></strong>'; |
|
215 | 215 | |
216 | - case 'latest' : |
|
217 | - default : |
|
218 | - return sprintf( __( 'Version %s' ), get_bloginfo( 'version', 'display' ) ); |
|
216 | + case 'latest' : |
|
217 | + default : |
|
218 | + return sprintf( __( 'Version %s' ), get_bloginfo( 'version', 'display' ) ); |
|
219 | 219 | } |
220 | 220 | } |
221 | 221 |
@@ -13,10 +13,10 @@ discard block |
||
13 | 13 | */ |
14 | 14 | function get_preferred_from_update_core() { |
15 | 15 | $updates = get_core_updates(); |
16 | - if ( ! is_array( $updates ) ) |
|
16 | + if ( ! is_array($updates)) |
|
17 | 17 | return false; |
18 | - if ( empty( $updates ) ) |
|
19 | - return (object) array( 'response' => 'latest' ); |
|
18 | + if (empty($updates)) |
|
19 | + return (object) array('response' => 'latest'); |
|
20 | 20 | return $updates[0]; |
21 | 21 | } |
22 | 22 | |
@@ -27,31 +27,31 @@ discard block |
||
27 | 27 | * set $options['available'] to false to skip not-dismissed updates. |
28 | 28 | * @return array|false Array of the update objects on success, false on failure. |
29 | 29 | */ |
30 | -function get_core_updates( $options = array() ) { |
|
31 | - $options = array_merge( array( 'available' => true, 'dismissed' => false ), $options ); |
|
32 | - $dismissed = get_site_option( 'dismissed_update_core' ); |
|
30 | +function get_core_updates($options = array()) { |
|
31 | + $options = array_merge(array('available' => true, 'dismissed' => false), $options); |
|
32 | + $dismissed = get_site_option('dismissed_update_core'); |
|
33 | 33 | |
34 | - if ( ! is_array( $dismissed ) ) |
|
34 | + if ( ! is_array($dismissed)) |
|
35 | 35 | $dismissed = array(); |
36 | 36 | |
37 | - $from_api = get_site_transient( 'update_core' ); |
|
37 | + $from_api = get_site_transient('update_core'); |
|
38 | 38 | |
39 | - if ( ! isset( $from_api->updates ) || ! is_array( $from_api->updates ) ) |
|
39 | + if ( ! isset($from_api->updates) || ! is_array($from_api->updates)) |
|
40 | 40 | return false; |
41 | 41 | |
42 | 42 | $updates = $from_api->updates; |
43 | 43 | $result = array(); |
44 | - foreach ( $updates as $update ) { |
|
45 | - if ( $update->response == 'autoupdate' ) |
|
44 | + foreach ($updates as $update) { |
|
45 | + if ($update->response == 'autoupdate') |
|
46 | 46 | continue; |
47 | 47 | |
48 | - if ( array_key_exists( $update->current . '|' . $update->locale, $dismissed ) ) { |
|
49 | - if ( $options['dismissed'] ) { |
|
48 | + if (array_key_exists($update->current.'|'.$update->locale, $dismissed)) { |
|
49 | + if ($options['dismissed']) { |
|
50 | 50 | $update->dismissed = true; |
51 | 51 | $result[] = $update; |
52 | 52 | } |
53 | 53 | } else { |
54 | - if ( $options['available'] ) { |
|
54 | + if ($options['available']) { |
|
55 | 55 | $update->dismissed = false; |
56 | 56 | $result[] = $update; |
57 | 57 | } |
@@ -70,22 +70,22 @@ discard block |
||
70 | 70 | * @return array|false False on failure, otherwise the core update offering. |
71 | 71 | */ |
72 | 72 | function find_core_auto_update() { |
73 | - $updates = get_site_transient( 'update_core' ); |
|
74 | - if ( ! $updates || empty( $updates->updates ) ) |
|
73 | + $updates = get_site_transient('update_core'); |
|
74 | + if ( ! $updates || empty($updates->updates)) |
|
75 | 75 | return false; |
76 | 76 | |
77 | - include_once( ABSPATH . 'wp-admin/includes/class-wp-upgrader.php' ); |
|
77 | + include_once(ABSPATH.'wp-admin/includes/class-wp-upgrader.php'); |
|
78 | 78 | |
79 | 79 | $auto_update = false; |
80 | 80 | $upgrader = new WP_Automatic_Updater; |
81 | - foreach ( $updates->updates as $update ) { |
|
82 | - if ( 'autoupdate' != $update->response ) |
|
81 | + foreach ($updates->updates as $update) { |
|
82 | + if ('autoupdate' != $update->response) |
|
83 | 83 | continue; |
84 | 84 | |
85 | - if ( ! $upgrader->should_update( 'core', $update, ABSPATH ) ) |
|
85 | + if ( ! $upgrader->should_update('core', $update, ABSPATH)) |
|
86 | 86 | continue; |
87 | 87 | |
88 | - if ( ! $auto_update || version_compare( $update->current, $auto_update->current, '>' ) ) |
|
88 | + if ( ! $auto_update || version_compare($update->current, $auto_update->current, '>')) |
|
89 | 89 | $auto_update = $update; |
90 | 90 | } |
91 | 91 | return $auto_update; |
@@ -100,36 +100,36 @@ discard block |
||
100 | 100 | * @param string $locale Locale to query. |
101 | 101 | * @return bool|array False on failure. An array of checksums on success. |
102 | 102 | */ |
103 | -function get_core_checksums( $version, $locale ) { |
|
104 | - $url = $http_url = 'http://api.wordpress.org/core/checksums/1.0/?' . http_build_query( compact( 'version', 'locale' ), null, '&' ); |
|
103 | +function get_core_checksums($version, $locale) { |
|
104 | + $url = $http_url = 'http://api.wordpress.org/core/checksums/1.0/?'.http_build_query(compact('version', 'locale'), null, '&'); |
|
105 | 105 | |
106 | - if ( $ssl = wp_http_supports( array( 'ssl' ) ) ) |
|
107 | - $url = set_url_scheme( $url, 'https' ); |
|
106 | + if ($ssl = wp_http_supports(array('ssl'))) |
|
107 | + $url = set_url_scheme($url, 'https'); |
|
108 | 108 | |
109 | 109 | $options = array( |
110 | - 'timeout' => ( ( defined('DOING_CRON') && DOING_CRON ) ? 30 : 3 ), |
|
110 | + 'timeout' => ((defined('DOING_CRON') && DOING_CRON) ? 30 : 3), |
|
111 | 111 | ); |
112 | 112 | |
113 | - $response = wp_remote_get( $url, $options ); |
|
114 | - if ( $ssl && is_wp_error( $response ) ) { |
|
113 | + $response = wp_remote_get($url, $options); |
|
114 | + if ($ssl && is_wp_error($response)) { |
|
115 | 115 | trigger_error( |
116 | 116 | sprintf( |
117 | 117 | /* translators: %s: support forums URL */ |
118 | - __( '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="%s">support forums</a>.' ), |
|
119 | - __( 'https://wordpress.org/support/' ) |
|
120 | - ) . ' ' . __( '(WordPress could not establish a secure connection to WordPress.org. Please contact your server administrator.)' ), |
|
118 | + __('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="%s">support forums</a>.'), |
|
119 | + __('https://wordpress.org/support/') |
|
120 | + ).' '.__('(WordPress could not establish a secure connection to WordPress.org. Please contact your server administrator.)'), |
|
121 | 121 | headers_sent() || WP_DEBUG ? E_USER_WARNING : E_USER_NOTICE |
122 | 122 | ); |
123 | - $response = wp_remote_get( $http_url, $options ); |
|
123 | + $response = wp_remote_get($http_url, $options); |
|
124 | 124 | } |
125 | 125 | |
126 | - if ( is_wp_error( $response ) || 200 != wp_remote_retrieve_response_code( $response ) ) |
|
126 | + if (is_wp_error($response) || 200 != wp_remote_retrieve_response_code($response)) |
|
127 | 127 | return false; |
128 | 128 | |
129 | - $body = trim( wp_remote_retrieve_body( $response ) ); |
|
130 | - $body = json_decode( $body, true ); |
|
129 | + $body = trim(wp_remote_retrieve_body($response)); |
|
130 | + $body = json_decode($body, true); |
|
131 | 131 | |
132 | - if ( ! is_array( $body ) || ! isset( $body['checksums'] ) || ! is_array( $body['checksums'] ) ) |
|
132 | + if ( ! is_array($body) || ! isset($body['checksums']) || ! is_array($body['checksums'])) |
|
133 | 133 | return false; |
134 | 134 | |
135 | 135 | return $body['checksums']; |
@@ -140,10 +140,10 @@ discard block |
||
140 | 140 | * @param object $update |
141 | 141 | * @return bool |
142 | 142 | */ |
143 | -function dismiss_core_update( $update ) { |
|
144 | - $dismissed = get_site_option( 'dismissed_update_core' ); |
|
145 | - $dismissed[ $update->current . '|' . $update->locale ] = true; |
|
146 | - return update_site_option( 'dismissed_update_core', $dismissed ); |
|
143 | +function dismiss_core_update($update) { |
|
144 | + $dismissed = get_site_option('dismissed_update_core'); |
|
145 | + $dismissed[$update->current.'|'.$update->locale] = true; |
|
146 | + return update_site_option('dismissed_update_core', $dismissed); |
|
147 | 147 | } |
148 | 148 | |
149 | 149 | /** |
@@ -152,15 +152,15 @@ discard block |
||
152 | 152 | * @param string $locale |
153 | 153 | * @return bool |
154 | 154 | */ |
155 | -function undismiss_core_update( $version, $locale ) { |
|
156 | - $dismissed = get_site_option( 'dismissed_update_core' ); |
|
157 | - $key = $version . '|' . $locale; |
|
155 | +function undismiss_core_update($version, $locale) { |
|
156 | + $dismissed = get_site_option('dismissed_update_core'); |
|
157 | + $key = $version.'|'.$locale; |
|
158 | 158 | |
159 | - if ( ! isset( $dismissed[$key] ) ) |
|
159 | + if ( ! isset($dismissed[$key])) |
|
160 | 160 | return false; |
161 | 161 | |
162 | - unset( $dismissed[$key] ); |
|
163 | - return update_site_option( 'dismissed_update_core', $dismissed ); |
|
162 | + unset($dismissed[$key]); |
|
163 | + return update_site_option('dismissed_update_core', $dismissed); |
|
164 | 164 | } |
165 | 165 | |
166 | 166 | /** |
@@ -169,15 +169,15 @@ discard block |
||
169 | 169 | * @param string $locale |
170 | 170 | * @return object|false |
171 | 171 | */ |
172 | -function find_core_update( $version, $locale ) { |
|
173 | - $from_api = get_site_transient( 'update_core' ); |
|
172 | +function find_core_update($version, $locale) { |
|
173 | + $from_api = get_site_transient('update_core'); |
|
174 | 174 | |
175 | - if ( ! isset( $from_api->updates ) || ! is_array( $from_api->updates ) ) |
|
175 | + if ( ! isset($from_api->updates) || ! is_array($from_api->updates)) |
|
176 | 176 | return false; |
177 | 177 | |
178 | 178 | $updates = $from_api->updates; |
179 | - foreach ( $updates as $update ) { |
|
180 | - if ( $update->current == $version && $update->locale == $locale ) |
|
179 | + foreach ($updates as $update) { |
|
180 | + if ($update->current == $version && $update->locale == $locale) |
|
181 | 181 | return $update; |
182 | 182 | } |
183 | 183 | return false; |
@@ -188,34 +188,34 @@ discard block |
||
188 | 188 | * @param string $msg |
189 | 189 | * @return string |
190 | 190 | */ |
191 | -function core_update_footer( $msg = '' ) { |
|
192 | - if ( !current_user_can('update_core') ) |
|
193 | - return sprintf( __( 'Version %s' ), get_bloginfo( 'version', 'display' ) ); |
|
191 | +function core_update_footer($msg = '') { |
|
192 | + if ( ! current_user_can('update_core')) |
|
193 | + return sprintf(__('Version %s'), get_bloginfo('version', 'display')); |
|
194 | 194 | |
195 | 195 | $cur = get_preferred_from_update_core(); |
196 | - if ( ! is_object( $cur ) ) |
|
196 | + if ( ! is_object($cur)) |
|
197 | 197 | $cur = new stdClass; |
198 | 198 | |
199 | - if ( ! isset( $cur->current ) ) |
|
199 | + if ( ! isset($cur->current)) |
|
200 | 200 | $cur->current = ''; |
201 | 201 | |
202 | - if ( ! isset( $cur->url ) ) |
|
202 | + if ( ! isset($cur->url)) |
|
203 | 203 | $cur->url = ''; |
204 | 204 | |
205 | - if ( ! isset( $cur->response ) ) |
|
205 | + if ( ! isset($cur->response)) |
|
206 | 206 | $cur->response = ''; |
207 | 207 | |
208 | - switch ( $cur->response ) { |
|
208 | + switch ($cur->response) { |
|
209 | 209 | case 'development' : |
210 | 210 | /* translators: 1: WordPress version number, 2: WordPress updates admin screen URL */ |
211 | - return sprintf( __( 'You are using a development version (%1$s). Cool! Please <a href="%2$s">stay updated</a>.' ), get_bloginfo( 'version', 'display' ), network_admin_url( 'update-core.php' ) ); |
|
211 | + return sprintf(__('You are using a development version (%1$s). Cool! Please <a href="%2$s">stay updated</a>.'), get_bloginfo('version', 'display'), network_admin_url('update-core.php')); |
|
212 | 212 | |
213 | 213 | case 'upgrade' : |
214 | - return '<strong><a href="' . network_admin_url( 'update-core.php' ) . '">' . sprintf( __( 'Get Version %s' ), $cur->current ) . '</a></strong>'; |
|
214 | + return '<strong><a href="'.network_admin_url('update-core.php').'">'.sprintf(__('Get Version %s'), $cur->current).'</a></strong>'; |
|
215 | 215 | |
216 | 216 | case 'latest' : |
217 | 217 | default : |
218 | - return sprintf( __( 'Version %s' ), get_bloginfo( 'version', 'display' ) ); |
|
218 | + return sprintf(__('Version %s'), get_bloginfo('version', 'display')); |
|
219 | 219 | } |
220 | 220 | } |
221 | 221 | |
@@ -225,39 +225,39 @@ discard block |
||
225 | 225 | * @return false|void |
226 | 226 | */ |
227 | 227 | function update_nag() { |
228 | - if ( is_multisite() && !current_user_can('update_core') ) |
|
228 | + if (is_multisite() && ! current_user_can('update_core')) |
|
229 | 229 | return false; |
230 | 230 | |
231 | 231 | global $pagenow; |
232 | 232 | |
233 | - if ( 'update-core.php' == $pagenow ) |
|
233 | + if ('update-core.php' == $pagenow) |
|
234 | 234 | return; |
235 | 235 | |
236 | 236 | $cur = get_preferred_from_update_core(); |
237 | 237 | |
238 | - if ( ! isset( $cur->response ) || $cur->response != 'upgrade' ) |
|
238 | + if ( ! isset($cur->response) || $cur->response != 'upgrade') |
|
239 | 239 | return false; |
240 | 240 | |
241 | - if ( current_user_can( 'update_core' ) ) { |
|
241 | + if (current_user_can('update_core')) { |
|
242 | 242 | $msg = sprintf( |
243 | 243 | /* translators: 1: Codex URL to release notes, 2: new WordPress version, 3: URL to network admin, 4: accessibility text */ |
244 | - __( '<a href="%1$s">WordPress %2$s</a> is available! <a href="%3$s" aria-label="%4$s">Please update now</a>.' ), |
|
244 | + __('<a href="%1$s">WordPress %2$s</a> is available! <a href="%3$s" aria-label="%4$s">Please update now</a>.'), |
|
245 | 245 | sprintf( |
246 | 246 | /* translators: %s: WordPress version */ |
247 | - esc_url( __( 'https://codex.wordpress.org/Version_%s' ) ), |
|
247 | + esc_url(__('https://codex.wordpress.org/Version_%s')), |
|
248 | 248 | $cur->current |
249 | 249 | ), |
250 | 250 | $cur->current, |
251 | - network_admin_url( 'update-core.php' ), |
|
252 | - esc_attr__( 'Please update WordPress now' ) |
|
251 | + network_admin_url('update-core.php'), |
|
252 | + esc_attr__('Please update WordPress now') |
|
253 | 253 | ); |
254 | 254 | } else { |
255 | 255 | $msg = sprintf( |
256 | 256 | /* translators: 1: Codex URL to release notes, 2: new WordPress version */ |
257 | - __( '<a href="%1$s">WordPress %2$s</a> is available! Please notify the site administrator.' ), |
|
257 | + __('<a href="%1$s">WordPress %2$s</a> is available! Please notify the site administrator.'), |
|
258 | 258 | sprintf( |
259 | 259 | /* translators: %s: WordPress version */ |
260 | - esc_url( __( 'https://codex.wordpress.org/Version_%s' ) ), |
|
260 | + esc_url(__('https://codex.wordpress.org/Version_%s')), |
|
261 | 261 | $cur->current |
262 | 262 | ), |
263 | 263 | $cur->current |
@@ -269,21 +269,21 @@ discard block |
||
269 | 269 | // Called directly from dashboard |
270 | 270 | function update_right_now_message() { |
271 | 271 | $theme_name = wp_get_theme(); |
272 | - if ( current_user_can( 'switch_themes' ) ) { |
|
273 | - $theme_name = sprintf( '<a href="themes.php">%1$s</a>', $theme_name ); |
|
272 | + if (current_user_can('switch_themes')) { |
|
273 | + $theme_name = sprintf('<a href="themes.php">%1$s</a>', $theme_name); |
|
274 | 274 | } |
275 | 275 | |
276 | 276 | $msg = ''; |
277 | 277 | |
278 | - if ( current_user_can('update_core') ) { |
|
278 | + if (current_user_can('update_core')) { |
|
279 | 279 | $cur = get_preferred_from_update_core(); |
280 | 280 | |
281 | - if ( isset( $cur->response ) && $cur->response == 'upgrade' ) |
|
282 | - $msg .= '<a href="' . network_admin_url( 'update-core.php' ) . '" class="button" aria-describedby="wp-version">' . sprintf( __( 'Update to %s' ), $cur->current ? $cur->current : __( 'Latest' ) ) . '</a> '; |
|
281 | + if (isset($cur->response) && $cur->response == 'upgrade') |
|
282 | + $msg .= '<a href="'.network_admin_url('update-core.php').'" class="button" aria-describedby="wp-version">'.sprintf(__('Update to %s'), $cur->current ? $cur->current : __('Latest')).'</a> '; |
|
283 | 283 | } |
284 | 284 | |
285 | 285 | /* translators: 1: version number, 2: theme name */ |
286 | - $content = __( 'WordPress %1$s running %2$s theme.' ); |
|
286 | + $content = __('WordPress %1$s running %2$s theme.'); |
|
287 | 287 | |
288 | 288 | /** |
289 | 289 | * Filters the text displayed in the 'At a Glance' dashboard widget. |
@@ -294,9 +294,9 @@ discard block |
||
294 | 294 | * |
295 | 295 | * @param string $content Default text. |
296 | 296 | */ |
297 | - $content = apply_filters( 'update_right_now_text', $content ); |
|
297 | + $content = apply_filters('update_right_now_text', $content); |
|
298 | 298 | |
299 | - $msg .= sprintf( '<span id="wp-version">' . $content . '</span>', get_bloginfo( 'version', 'display' ), $theme_name ); |
|
299 | + $msg .= sprintf('<span id="wp-version">'.$content.'</span>', get_bloginfo('version', 'display'), $theme_name); |
|
300 | 300 | |
301 | 301 | echo "<p id='wp-version-message'>$msg</p>"; |
302 | 302 | } |
@@ -309,11 +309,11 @@ discard block |
||
309 | 309 | function get_plugin_updates() { |
310 | 310 | $all_plugins = get_plugins(); |
311 | 311 | $upgrade_plugins = array(); |
312 | - $current = get_site_transient( 'update_plugins' ); |
|
313 | - foreach ( (array)$all_plugins as $plugin_file => $plugin_data) { |
|
314 | - if ( isset( $current->response[ $plugin_file ] ) ) { |
|
315 | - $upgrade_plugins[ $plugin_file ] = (object) $plugin_data; |
|
316 | - $upgrade_plugins[ $plugin_file ]->update = $current->response[ $plugin_file ]; |
|
312 | + $current = get_site_transient('update_plugins'); |
|
313 | + foreach ((array) $all_plugins as $plugin_file => $plugin_data) { |
|
314 | + if (isset($current->response[$plugin_file])) { |
|
315 | + $upgrade_plugins[$plugin_file] = (object) $plugin_data; |
|
316 | + $upgrade_plugins[$plugin_file]->update = $current->response[$plugin_file]; |
|
317 | 317 | } |
318 | 318 | } |
319 | 319 | |
@@ -324,14 +324,14 @@ discard block |
||
324 | 324 | * @since 2.9.0 |
325 | 325 | */ |
326 | 326 | function wp_plugin_update_rows() { |
327 | - if ( !current_user_can('update_plugins' ) ) |
|
327 | + if ( ! current_user_can('update_plugins')) |
|
328 | 328 | return; |
329 | 329 | |
330 | - $plugins = get_site_transient( 'update_plugins' ); |
|
331 | - if ( isset($plugins->response) && is_array($plugins->response) ) { |
|
332 | - $plugins = array_keys( $plugins->response ); |
|
333 | - foreach ( $plugins as $plugin_file ) { |
|
334 | - add_action( "after_plugin_row_$plugin_file", 'wp_plugin_update_row', 10, 2 ); |
|
330 | + $plugins = get_site_transient('update_plugins'); |
|
331 | + if (isset($plugins->response) && is_array($plugins->response)) { |
|
332 | + $plugins = array_keys($plugins->response); |
|
333 | + foreach ($plugins as $plugin_file) { |
|
334 | + add_action("after_plugin_row_$plugin_file", 'wp_plugin_update_row', 10, 2); |
|
335 | 335 | } |
336 | 336 | } |
337 | 337 | } |
@@ -343,74 +343,74 @@ discard block |
||
343 | 343 | * @param array $plugin_data Plugin information. |
344 | 344 | * @return false|void |
345 | 345 | */ |
346 | -function wp_plugin_update_row( $file, $plugin_data ) { |
|
347 | - $current = get_site_transient( 'update_plugins' ); |
|
348 | - if ( ! isset( $current->response[ $file ] ) ) { |
|
346 | +function wp_plugin_update_row($file, $plugin_data) { |
|
347 | + $current = get_site_transient('update_plugins'); |
|
348 | + if ( ! isset($current->response[$file])) { |
|
349 | 349 | return false; |
350 | 350 | } |
351 | 351 | |
352 | - $response = $current->response[ $file ]; |
|
352 | + $response = $current->response[$file]; |
|
353 | 353 | |
354 | 354 | $plugins_allowedtags = array( |
355 | - 'a' => array( 'href' => array(), 'title' => array() ), |
|
356 | - 'abbr' => array( 'title' => array() ), |
|
357 | - 'acronym' => array( 'title' => array() ), |
|
355 | + 'a' => array('href' => array(), 'title' => array()), |
|
356 | + 'abbr' => array('title' => array()), |
|
357 | + 'acronym' => array('title' => array()), |
|
358 | 358 | 'code' => array(), |
359 | 359 | 'em' => array(), |
360 | 360 | 'strong' => array(), |
361 | 361 | ); |
362 | 362 | |
363 | - $plugin_name = wp_kses( $plugin_data['Name'], $plugins_allowedtags ); |
|
364 | - $details_url = self_admin_url( 'plugin-install.php?tab=plugin-information&plugin=' . $response->slug . '§ion=changelog&TB_iframe=true&width=600&height=800' ); |
|
363 | + $plugin_name = wp_kses($plugin_data['Name'], $plugins_allowedtags); |
|
364 | + $details_url = self_admin_url('plugin-install.php?tab=plugin-information&plugin='.$response->slug.'§ion=changelog&TB_iframe=true&width=600&height=800'); |
|
365 | 365 | |
366 | 366 | /** @var WP_Plugins_List_Table $wp_list_table */ |
367 | - $wp_list_table = _get_list_table( 'WP_Plugins_List_Table' ); |
|
367 | + $wp_list_table = _get_list_table('WP_Plugins_List_Table'); |
|
368 | 368 | |
369 | - if ( is_network_admin() || ! is_multisite() ) { |
|
370 | - if ( is_network_admin() ) { |
|
371 | - $active_class = is_plugin_active_for_network( $file ) ? ' active' : ''; |
|
369 | + if (is_network_admin() || ! is_multisite()) { |
|
370 | + if (is_network_admin()) { |
|
371 | + $active_class = is_plugin_active_for_network($file) ? ' active' : ''; |
|
372 | 372 | } else { |
373 | - $active_class = is_plugin_active( $file ) ? ' active' : ''; |
|
373 | + $active_class = is_plugin_active($file) ? ' active' : ''; |
|
374 | 374 | } |
375 | 375 | |
376 | - echo '<tr class="plugin-update-tr' . $active_class . '" id="' . esc_attr( $response->slug . '-update' ) . '" data-slug="' . esc_attr( $response->slug ) . '" data-plugin="' . esc_attr( $file ) . '"><td colspan="' . esc_attr( $wp_list_table->get_column_count() ) . '" class="plugin-update colspanchange"><div class="update-message notice inline notice-warning notice-alt"><p>'; |
|
376 | + echo '<tr class="plugin-update-tr'.$active_class.'" id="'.esc_attr($response->slug.'-update').'" data-slug="'.esc_attr($response->slug).'" data-plugin="'.esc_attr($file).'"><td colspan="'.esc_attr($wp_list_table->get_column_count()).'" class="plugin-update colspanchange"><div class="update-message notice inline notice-warning notice-alt"><p>'; |
|
377 | 377 | |
378 | - if ( ! current_user_can( 'update_plugins' ) ) { |
|
378 | + if ( ! current_user_can('update_plugins')) { |
|
379 | 379 | /* translators: 1: plugin name, 2: details URL, 3: additional link attributes, 4: version number */ |
380 | - printf( __( 'There is a new version of %1$s available. <a href="%2$s" %3$s>View version %4$s details</a>.' ), |
|
380 | + printf(__('There is a new version of %1$s available. <a href="%2$s" %3$s>View version %4$s details</a>.'), |
|
381 | 381 | $plugin_name, |
382 | - esc_url( $details_url ), |
|
383 | - sprintf( 'class="thickbox open-plugin-details-modal" aria-label="%s"', |
|
382 | + esc_url($details_url), |
|
383 | + sprintf('class="thickbox open-plugin-details-modal" aria-label="%s"', |
|
384 | 384 | /* translators: 1: plugin name, 2: version number */ |
385 | - esc_attr( sprintf( __( 'View %1$s version %2$s details' ), $plugin_name, $response->new_version ) ) |
|
385 | + esc_attr(sprintf(__('View %1$s version %2$s details'), $plugin_name, $response->new_version)) |
|
386 | 386 | ), |
387 | 387 | $response->new_version |
388 | 388 | ); |
389 | - } elseif ( empty( $response->package ) ) { |
|
389 | + } elseif (empty($response->package)) { |
|
390 | 390 | /* translators: 1: plugin name, 2: details URL, 3: additional link attributes, 4: version number */ |
391 | - printf( __( 'There is a new version of %1$s available. <a href="%2$s" %3$s>View version %4$s details</a>. <em>Automatic update is unavailable for this plugin.</em>' ), |
|
391 | + printf(__('There is a new version of %1$s available. <a href="%2$s" %3$s>View version %4$s details</a>. <em>Automatic update is unavailable for this plugin.</em>'), |
|
392 | 392 | $plugin_name, |
393 | - esc_url( $details_url ), |
|
394 | - sprintf( 'class="thickbox open-plugin-details-modal" aria-label="%s"', |
|
393 | + esc_url($details_url), |
|
394 | + sprintf('class="thickbox open-plugin-details-modal" aria-label="%s"', |
|
395 | 395 | /* translators: 1: plugin name, 2: version number */ |
396 | - esc_attr( sprintf( __( 'View %1$s version %2$s details' ), $plugin_name, $response->new_version ) ) |
|
396 | + esc_attr(sprintf(__('View %1$s version %2$s details'), $plugin_name, $response->new_version)) |
|
397 | 397 | ), |
398 | 398 | $response->new_version |
399 | 399 | ); |
400 | 400 | } else { |
401 | 401 | /* translators: 1: plugin name, 2: details URL, 3: additional link attributes, 4: version number, 5: update URL, 6: additional link attributes */ |
402 | - printf( __( 'There is a new version of %1$s available. <a href="%2$s" %3$s>View version %4$s details</a> or <a href="%5$s" %6$s>update now</a>.' ), |
|
402 | + printf(__('There is a new version of %1$s available. <a href="%2$s" %3$s>View version %4$s details</a> or <a href="%5$s" %6$s>update now</a>.'), |
|
403 | 403 | $plugin_name, |
404 | - esc_url( $details_url ), |
|
405 | - sprintf( 'class="thickbox open-plugin-details-modal" aria-label="%s"', |
|
404 | + esc_url($details_url), |
|
405 | + sprintf('class="thickbox open-plugin-details-modal" aria-label="%s"', |
|
406 | 406 | /* translators: 1: plugin name, 2: version number */ |
407 | - esc_attr( sprintf( __( 'View %1$s version %2$s details' ), $plugin_name, $response->new_version ) ) |
|
407 | + esc_attr(sprintf(__('View %1$s version %2$s details'), $plugin_name, $response->new_version)) |
|
408 | 408 | ), |
409 | 409 | $response->new_version, |
410 | - wp_nonce_url( self_admin_url( 'update.php?action=upgrade-plugin&plugin=' ) . $file, 'upgrade-plugin_' . $file ), |
|
411 | - sprintf( 'class="update-link" aria-label="%s"', |
|
410 | + wp_nonce_url(self_admin_url('update.php?action=upgrade-plugin&plugin=').$file, 'upgrade-plugin_'.$file), |
|
411 | + sprintf('class="update-link" aria-label="%s"', |
|
412 | 412 | /* translators: %s: plugin name */ |
413 | - esc_attr( sprintf( __( 'Update %s now' ), $plugin_name ) ) |
|
413 | + esc_attr(sprintf(__('Update %s now'), $plugin_name)) |
|
414 | 414 | ) |
415 | 415 | ); |
416 | 416 | } |
@@ -450,7 +450,7 @@ discard block |
||
450 | 450 | * @type string $package Plugin update package URL. |
451 | 451 | * } |
452 | 452 | */ |
453 | - do_action( "in_plugin_update_message-{$file}", $plugin_data, $response ); |
|
453 | + do_action("in_plugin_update_message-{$file}", $plugin_data, $response); |
|
454 | 454 | |
455 | 455 | echo '</p></div></td></tr>'; |
456 | 456 | } |
@@ -463,13 +463,13 @@ discard block |
||
463 | 463 | function get_theme_updates() { |
464 | 464 | $current = get_site_transient('update_themes'); |
465 | 465 | |
466 | - if ( ! isset( $current->response ) ) |
|
466 | + if ( ! isset($current->response)) |
|
467 | 467 | return array(); |
468 | 468 | |
469 | 469 | $update_themes = array(); |
470 | - foreach ( $current->response as $stylesheet => $data ) { |
|
471 | - $update_themes[ $stylesheet ] = wp_get_theme( $stylesheet ); |
|
472 | - $update_themes[ $stylesheet ]->update = $data; |
|
470 | + foreach ($current->response as $stylesheet => $data) { |
|
471 | + $update_themes[$stylesheet] = wp_get_theme($stylesheet); |
|
472 | + $update_themes[$stylesheet]->update = $data; |
|
473 | 473 | } |
474 | 474 | |
475 | 475 | return $update_themes; |
@@ -479,15 +479,15 @@ discard block |
||
479 | 479 | * @since 3.1.0 |
480 | 480 | */ |
481 | 481 | function wp_theme_update_rows() { |
482 | - if ( !current_user_can('update_themes' ) ) |
|
482 | + if ( ! current_user_can('update_themes')) |
|
483 | 483 | return; |
484 | 484 | |
485 | - $themes = get_site_transient( 'update_themes' ); |
|
486 | - if ( isset($themes->response) && is_array($themes->response) ) { |
|
487 | - $themes = array_keys( $themes->response ); |
|
485 | + $themes = get_site_transient('update_themes'); |
|
486 | + if (isset($themes->response) && is_array($themes->response)) { |
|
487 | + $themes = array_keys($themes->response); |
|
488 | 488 | |
489 | - foreach ( $themes as $theme ) { |
|
490 | - add_action( "after_theme_row_$theme", 'wp_theme_update_row', 10, 2 ); |
|
489 | + foreach ($themes as $theme) { |
|
490 | + add_action("after_theme_row_$theme", 'wp_theme_update_row', 10, 2); |
|
491 | 491 | } |
492 | 492 | } |
493 | 493 | } |
@@ -499,63 +499,63 @@ discard block |
||
499 | 499 | * @param WP_Theme $theme Theme object. |
500 | 500 | * @return false|void |
501 | 501 | */ |
502 | -function wp_theme_update_row( $theme_key, $theme ) { |
|
503 | - $current = get_site_transient( 'update_themes' ); |
|
502 | +function wp_theme_update_row($theme_key, $theme) { |
|
503 | + $current = get_site_transient('update_themes'); |
|
504 | 504 | |
505 | - if ( ! isset( $current->response[ $theme_key ] ) ) { |
|
505 | + if ( ! isset($current->response[$theme_key])) { |
|
506 | 506 | return false; |
507 | 507 | } |
508 | 508 | |
509 | - $response = $current->response[ $theme_key ]; |
|
509 | + $response = $current->response[$theme_key]; |
|
510 | 510 | |
511 | - $details_url = add_query_arg( array( |
|
511 | + $details_url = add_query_arg(array( |
|
512 | 512 | 'TB_iframe' => 'true', |
513 | 513 | 'width' => 1024, |
514 | 514 | 'height' => 800, |
515 | - ), $current->response[ $theme_key ]['url'] ); |
|
515 | + ), $current->response[$theme_key]['url']); |
|
516 | 516 | |
517 | 517 | /** @var WP_MS_Themes_List_Table $wp_list_table */ |
518 | - $wp_list_table = _get_list_table( 'WP_MS_Themes_List_Table' ); |
|
518 | + $wp_list_table = _get_list_table('WP_MS_Themes_List_Table'); |
|
519 | 519 | |
520 | - $active = $theme->is_allowed( 'network' ) ? ' active' : ''; |
|
520 | + $active = $theme->is_allowed('network') ? ' active' : ''; |
|
521 | 521 | |
522 | - echo '<tr class="plugin-update-tr' . $active . '" id="' . esc_attr( $theme->get_stylesheet() . '-update' ) . '" data-slug="' . esc_attr( $theme->get_stylesheet() ) . '"><td colspan="' . $wp_list_table->get_column_count() . '" class="plugin-update colspanchange"><div class="update-message notice inline notice-warning notice-alt"><p>'; |
|
523 | - if ( ! current_user_can( 'update_themes' ) ) { |
|
522 | + echo '<tr class="plugin-update-tr'.$active.'" id="'.esc_attr($theme->get_stylesheet().'-update').'" data-slug="'.esc_attr($theme->get_stylesheet()).'"><td colspan="'.$wp_list_table->get_column_count().'" class="plugin-update colspanchange"><div class="update-message notice inline notice-warning notice-alt"><p>'; |
|
523 | + if ( ! current_user_can('update_themes')) { |
|
524 | 524 | /* translators: 1: theme name, 2: details URL, 3: additional link attributes, 4: version number */ |
525 | - printf( __( 'There is a new version of %1$s available. <a href="%2$s" %3$s>View version %4$s details</a>.'), |
|
525 | + printf(__('There is a new version of %1$s available. <a href="%2$s" %3$s>View version %4$s details</a>.'), |
|
526 | 526 | $theme['Name'], |
527 | - esc_url( $details_url ), |
|
528 | - sprintf( 'class="thickbox open-plugin-details-modal" aria-label="%s"', |
|
527 | + esc_url($details_url), |
|
528 | + sprintf('class="thickbox open-plugin-details-modal" aria-label="%s"', |
|
529 | 529 | /* translators: 1: theme name, 2: version number */ |
530 | - esc_attr( sprintf( __( 'View %1$s version %2$s details' ), $theme['Name'], $response['new_version'] ) ) |
|
530 | + esc_attr(sprintf(__('View %1$s version %2$s details'), $theme['Name'], $response['new_version'])) |
|
531 | 531 | ), |
532 | 532 | $response['new_version'] |
533 | 533 | ); |
534 | - } elseif ( empty( $response['package'] ) ) { |
|
534 | + } elseif (empty($response['package'])) { |
|
535 | 535 | /* translators: 1: theme name, 2: details URL, 3: additional link attributes, 4: version number */ |
536 | - printf( __( 'There is a new version of %1$s available. <a href="%2$s" %3$s>View version %4$s details</a>. <em>Automatic update is unavailable for this theme.</em>' ), |
|
536 | + printf(__('There is a new version of %1$s available. <a href="%2$s" %3$s>View version %4$s details</a>. <em>Automatic update is unavailable for this theme.</em>'), |
|
537 | 537 | $theme['Name'], |
538 | - esc_url( $details_url ), |
|
539 | - sprintf( 'class="thickbox open-plugin-details-modal" aria-label="%s"', |
|
538 | + esc_url($details_url), |
|
539 | + sprintf('class="thickbox open-plugin-details-modal" aria-label="%s"', |
|
540 | 540 | /* translators: 1: theme name, 2: version number */ |
541 | - esc_attr( sprintf( __( 'View %1$s version %2$s details' ), $theme['Name'], $response['new_version'] ) ) |
|
541 | + esc_attr(sprintf(__('View %1$s version %2$s details'), $theme['Name'], $response['new_version'])) |
|
542 | 542 | ), |
543 | 543 | $response['new_version'] |
544 | 544 | ); |
545 | 545 | } else { |
546 | 546 | /* translators: 1: theme name, 2: details URL, 3: additional link attributes, 4: version number, 5: update URL, 6: additional link attributes */ |
547 | - printf( __( 'There is a new version of %1$s available. <a href="%2$s" %3$s>View version %4$s details</a> or <a href="%5$s" %6$s>update now</a>.' ), |
|
547 | + printf(__('There is a new version of %1$s available. <a href="%2$s" %3$s>View version %4$s details</a> or <a href="%5$s" %6$s>update now</a>.'), |
|
548 | 548 | $theme['Name'], |
549 | - esc_url( $details_url ), |
|
550 | - sprintf( 'class="thickbox open-plugin-details-modal" aria-label="%s"', |
|
549 | + esc_url($details_url), |
|
550 | + sprintf('class="thickbox open-plugin-details-modal" aria-label="%s"', |
|
551 | 551 | /* translators: 1: theme name, 2: version number */ |
552 | - esc_attr( sprintf( __( 'View %1$s version %2$s details' ), $theme['Name'], $response['new_version'] ) ) |
|
552 | + esc_attr(sprintf(__('View %1$s version %2$s details'), $theme['Name'], $response['new_version'])) |
|
553 | 553 | ), |
554 | 554 | $response['new_version'], |
555 | - wp_nonce_url( self_admin_url( 'update.php?action=upgrade-theme&theme=' ) . $theme_key, 'upgrade-theme_' . $theme_key ), |
|
556 | - sprintf( 'class="update-link" aria-label="%s"', |
|
555 | + wp_nonce_url(self_admin_url('update.php?action=upgrade-theme&theme=').$theme_key, 'upgrade-theme_'.$theme_key), |
|
556 | + sprintf('class="update-link" aria-label="%s"', |
|
557 | 557 | /* translators: %s: theme name */ |
558 | - esc_attr( sprintf( __( 'Update %s now' ), $theme['Name'] ) ) |
|
558 | + esc_attr(sprintf(__('Update %s now'), $theme['Name'])) |
|
559 | 559 | ) |
560 | 560 | ); |
561 | 561 | } |
@@ -578,7 +578,7 @@ discard block |
||
578 | 578 | * @type string $package Theme update package URL. |
579 | 579 | * } |
580 | 580 | */ |
581 | - do_action( "in_theme_update_message-{$theme_key}", $theme, $response ); |
|
581 | + do_action("in_theme_update_message-{$theme_key}", $theme, $response); |
|
582 | 582 | |
583 | 583 | echo '</p></div></td></tr>'; |
584 | 584 | } |
@@ -589,11 +589,11 @@ discard block |
||
589 | 589 | * @return false|void |
590 | 590 | */ |
591 | 591 | function maintenance_nag() { |
592 | - include( ABSPATH . WPINC . '/version.php' ); // include an unmodified $wp_version |
|
592 | + include(ABSPATH.WPINC.'/version.php'); // include an unmodified $wp_version |
|
593 | 593 | global $upgrading; |
594 | - $nag = isset( $upgrading ); |
|
595 | - if ( ! $nag ) { |
|
596 | - $failed = get_site_option( 'auto_core_update_failed' ); |
|
594 | + $nag = isset($upgrading); |
|
595 | + if ( ! $nag) { |
|
596 | + $failed = get_site_option('auto_core_update_failed'); |
|
597 | 597 | /* |
598 | 598 | * If an update failed critically, we may have copied over version.php but not other files. |
599 | 599 | * In that case, if the install claims we're running the version we attempted, nag. |
@@ -604,16 +604,16 @@ discard block |
||
604 | 604 | * |
605 | 605 | * This flag is cleared whenever a successful update occurs using Core_Upgrader. |
606 | 606 | */ |
607 | - $comparison = ! empty( $failed['critical'] ) ? '>=' : '>'; |
|
608 | - if ( version_compare( $failed['attempted'], $wp_version, $comparison ) ) |
|
607 | + $comparison = ! empty($failed['critical']) ? '>=' : '>'; |
|
608 | + if (version_compare($failed['attempted'], $wp_version, $comparison)) |
|
609 | 609 | $nag = true; |
610 | 610 | } |
611 | 611 | |
612 | - if ( ! $nag ) |
|
612 | + if ( ! $nag) |
|
613 | 613 | return false; |
614 | 614 | |
615 | - if ( current_user_can('update_core') ) |
|
616 | - $msg = sprintf( __('An automated WordPress update has failed to complete - <a href="%s">please attempt the update again now</a>.'), 'update-core.php' ); |
|
615 | + if (current_user_can('update_core')) |
|
616 | + $msg = sprintf(__('An automated WordPress update has failed to complete - <a href="%s">please attempt the update again now</a>.'), 'update-core.php'); |
|
617 | 617 | else |
618 | 618 | $msg = __('An automated WordPress update has failed to complete! Please notify the site administrator.'); |
619 | 619 | |
@@ -649,24 +649,24 @@ discard block |
||
649 | 649 | <# if ( 'plugin' === data.type ) { #> |
650 | 650 | <?php |
651 | 651 | /* translators: %s: Number of plugins */ |
652 | - printf( __( '%s plugin successfully updated.' ), '{{ data.successes }}' ); |
|
652 | + printf(__('%s plugin successfully updated.'), '{{ data.successes }}'); |
|
653 | 653 | ?> |
654 | 654 | <# } else { #> |
655 | 655 | <?php |
656 | 656 | /* translators: %s: Number of themes */ |
657 | - printf( __( '%s theme successfully updated.' ), '{{ data.successes }}' ); |
|
657 | + printf(__('%s theme successfully updated.'), '{{ data.successes }}'); |
|
658 | 658 | ?> |
659 | 659 | <# } #> |
660 | 660 | <# } else { #> |
661 | 661 | <# if ( 'plugin' === data.type ) { #> |
662 | 662 | <?php |
663 | 663 | /* translators: %s: Number of plugins */ |
664 | - printf( __( '%s plugins successfully updated.' ), '{{ data.successes }}' ); |
|
664 | + printf(__('%s plugins successfully updated.'), '{{ data.successes }}'); |
|
665 | 665 | ?> |
666 | 666 | <# } else { #> |
667 | 667 | <?php |
668 | 668 | /* translators: %s: Number of themes */ |
669 | - printf( __( '%s themes successfully updated.' ), '{{ data.successes }}' ); |
|
669 | + printf(__('%s themes successfully updated.'), '{{ data.successes }}'); |
|
670 | 670 | ?> |
671 | 671 | <# } #> |
672 | 672 | <# } #> |
@@ -676,15 +676,15 @@ discard block |
||
676 | 676 | <# if ( 1 === data.errors ) { #> |
677 | 677 | <?php |
678 | 678 | /* translators: %s: Number of failed updates */ |
679 | - printf( __( '%s update failed.' ), '{{ data.errors }}' ); |
|
679 | + printf(__('%s update failed.'), '{{ data.errors }}'); |
|
680 | 680 | ?> |
681 | 681 | <# } else { #> |
682 | 682 | <?php |
683 | 683 | /* translators: %s: Number of failed updates */ |
684 | - printf( __( '%s updates failed.' ), '{{ data.errors }}' ); |
|
684 | + printf(__('%s updates failed.'), '{{ data.errors }}'); |
|
685 | 685 | ?> |
686 | 686 | <# } #> |
687 | - <span class="screen-reader-text"><?php _e( 'Show more details' ); ?></span> |
|
687 | + <span class="screen-reader-text"><?php _e('Show more details'); ?></span> |
|
688 | 688 | <span class="toggle-indicator" aria-hidden="true"></span> |
689 | 689 | </button> |
690 | 690 | <# } #> |
@@ -744,7 +744,7 @@ discard block |
||
744 | 744 | <?php |
745 | 745 | printf( |
746 | 746 | /* translators: %s: Plugin name */ |
747 | - _x( '%s was successfully deleted.', 'plugin' ), |
|
747 | + _x('%s was successfully deleted.', 'plugin'), |
|
748 | 748 | '<strong>{{{ data.name }}}</strong>' |
749 | 749 | ); |
750 | 750 | ?> |
@@ -752,7 +752,7 @@ discard block |
||
752 | 752 | <?php |
753 | 753 | printf( |
754 | 754 | /* translators: %s: Theme name */ |
755 | - _x( '%s was successfully deleted.', 'theme' ), |
|
755 | + _x('%s was successfully deleted.', 'theme'), |
|
756 | 756 | '<strong>{{{ data.name }}}</strong>' |
757 | 757 | ); |
758 | 758 | ?> |
@@ -21,7 +21,7 @@ discard block |
||
21 | 21 | * @param array $args |
22 | 22 | */ |
23 | 23 | public function __construct($args = array()) { |
24 | - $defaults = array( 'url' => '', 'theme' => '', 'nonce' => '', 'title' => __('Update Theme') ); |
|
24 | + $defaults = array('url' => '', 'theme' => '', 'nonce' => '', 'title' => __('Update Theme')); |
|
25 | 25 | $args = wp_parse_args($args, $defaults); |
26 | 26 | |
27 | 27 | $this->theme = $args['theme']; |
@@ -33,37 +33,37 @@ discard block |
||
33 | 33 | * @access public |
34 | 34 | */ |
35 | 35 | public function after() { |
36 | - $this->decrement_update_count( 'theme' ); |
|
36 | + $this->decrement_update_count('theme'); |
|
37 | 37 | |
38 | 38 | $update_actions = array(); |
39 | - if ( ! empty( $this->upgrader->result['destination_name'] ) && $theme_info = $this->upgrader->theme_info() ) { |
|
39 | + if ( ! empty($this->upgrader->result['destination_name']) && $theme_info = $this->upgrader->theme_info()) { |
|
40 | 40 | $name = $theme_info->display('Name'); |
41 | 41 | $stylesheet = $this->upgrader->result['destination_name']; |
42 | 42 | $template = $theme_info->get_template(); |
43 | 43 | |
44 | - $activate_link = add_query_arg( array( |
|
44 | + $activate_link = add_query_arg(array( |
|
45 | 45 | 'action' => 'activate', |
46 | - 'template' => urlencode( $template ), |
|
47 | - 'stylesheet' => urlencode( $stylesheet ), |
|
48 | - ), admin_url('themes.php') ); |
|
49 | - $activate_link = wp_nonce_url( $activate_link, 'switch-theme_' . $stylesheet ); |
|
46 | + 'template' => urlencode($template), |
|
47 | + 'stylesheet' => urlencode($stylesheet), |
|
48 | + ), admin_url('themes.php')); |
|
49 | + $activate_link = wp_nonce_url($activate_link, 'switch-theme_'.$stylesheet); |
|
50 | 50 | |
51 | - if ( get_stylesheet() == $stylesheet ) { |
|
52 | - if ( current_user_can( 'edit_theme_options' ) && current_user_can( 'customize' ) ) { |
|
53 | - $update_actions['preview'] = '<a href="' . wp_customize_url( $stylesheet ) . '" class="hide-if-no-customize load-customize"><span aria-hidden="true">' . __( 'Customize' ) . '</span><span class="screen-reader-text">' . sprintf( __( 'Customize “%s”' ), $name ) . '</span></a>'; |
|
51 | + if (get_stylesheet() == $stylesheet) { |
|
52 | + if (current_user_can('edit_theme_options') && current_user_can('customize')) { |
|
53 | + $update_actions['preview'] = '<a href="'.wp_customize_url($stylesheet).'" class="hide-if-no-customize load-customize"><span aria-hidden="true">'.__('Customize').'</span><span class="screen-reader-text">'.sprintf(__('Customize “%s”'), $name).'</span></a>'; |
|
54 | 54 | } |
55 | - } elseif ( current_user_can( 'switch_themes' ) ) { |
|
56 | - if ( current_user_can( 'edit_theme_options' ) && current_user_can( 'customize' ) ) { |
|
57 | - $update_actions['preview'] = '<a href="' . wp_customize_url( $stylesheet ) . '" class="hide-if-no-customize load-customize"><span aria-hidden="true">' . __( 'Live Preview' ) . '</span><span class="screen-reader-text">' . sprintf( __( 'Live Preview “%s”' ), $name ) . '</span></a>'; |
|
55 | + } elseif (current_user_can('switch_themes')) { |
|
56 | + if (current_user_can('edit_theme_options') && current_user_can('customize')) { |
|
57 | + $update_actions['preview'] = '<a href="'.wp_customize_url($stylesheet).'" class="hide-if-no-customize load-customize"><span aria-hidden="true">'.__('Live Preview').'</span><span class="screen-reader-text">'.sprintf(__('Live Preview “%s”'), $name).'</span></a>'; |
|
58 | 58 | } |
59 | - $update_actions['activate'] = '<a href="' . esc_url( $activate_link ) . '" class="activatelink"><span aria-hidden="true">' . __( 'Activate' ) . '</span><span class="screen-reader-text">' . sprintf( __( 'Activate “%s”' ), $name ) . '</span></a>'; |
|
59 | + $update_actions['activate'] = '<a href="'.esc_url($activate_link).'" class="activatelink"><span aria-hidden="true">'.__('Activate').'</span><span class="screen-reader-text">'.sprintf(__('Activate “%s”'), $name).'</span></a>'; |
|
60 | 60 | } |
61 | 61 | |
62 | - if ( ! $this->result || is_wp_error( $this->result ) || is_network_admin() ) |
|
63 | - unset( $update_actions['preview'], $update_actions['activate'] ); |
|
62 | + if ( ! $this->result || is_wp_error($this->result) || is_network_admin()) |
|
63 | + unset($update_actions['preview'], $update_actions['activate']); |
|
64 | 64 | } |
65 | 65 | |
66 | - $update_actions['themes_page'] = '<a href="' . self_admin_url( 'themes.php' ) . '" target="_parent">' . __( 'Return to Themes page' ) . '</a>'; |
|
66 | + $update_actions['themes_page'] = '<a href="'.self_admin_url('themes.php').'" target="_parent">'.__('Return to Themes page').'</a>'; |
|
67 | 67 | |
68 | 68 | /** |
69 | 69 | * Filters the list of action links available following a single theme update. |
@@ -73,9 +73,9 @@ discard block |
||
73 | 73 | * @param array $update_actions Array of theme action links. |
74 | 74 | * @param string $theme Theme directory name. |
75 | 75 | */ |
76 | - $update_actions = apply_filters( 'update_theme_complete_actions', $update_actions, $this->theme ); |
|
76 | + $update_actions = apply_filters('update_theme_complete_actions', $update_actions, $this->theme); |
|
77 | 77 | |
78 | - if ( ! empty($update_actions) ) |
|
79 | - $this->feedback(implode(' | ', (array)$update_actions)); |
|
78 | + if ( ! empty($update_actions)) |
|
79 | + $this->feedback(implode(' | ', (array) $update_actions)); |
|
80 | 80 | } |
81 | 81 | } |
@@ -59,8 +59,9 @@ discard block |
||
59 | 59 | $update_actions['activate'] = '<a href="' . esc_url( $activate_link ) . '" class="activatelink"><span aria-hidden="true">' . __( 'Activate' ) . '</span><span class="screen-reader-text">' . sprintf( __( 'Activate “%s”' ), $name ) . '</span></a>'; |
60 | 60 | } |
61 | 61 | |
62 | - if ( ! $this->result || is_wp_error( $this->result ) || is_network_admin() ) |
|
63 | - unset( $update_actions['preview'], $update_actions['activate'] ); |
|
62 | + if ( ! $this->result || is_wp_error( $this->result ) || is_network_admin() ) { |
|
63 | + unset( $update_actions['preview'], $update_actions['activate'] ); |
|
64 | + } |
|
64 | 65 | } |
65 | 66 | |
66 | 67 | $update_actions['themes_page'] = '<a href="' . self_admin_url( 'themes.php' ) . '" target="_parent">' . __( 'Return to Themes page' ) . '</a>'; |
@@ -75,7 +76,8 @@ discard block |
||
75 | 76 | */ |
76 | 77 | $update_actions = apply_filters( 'update_theme_complete_actions', $update_actions, $this->theme ); |
77 | 78 | |
78 | - if ( ! empty($update_actions) ) |
|
79 | - $this->feedback(implode(' | ', (array)$update_actions)); |
|
79 | + if ( ! empty($update_actions) ) { |
|
80 | + $this->feedback(implode(' | ', (array)$update_actions)); |
|
81 | + } |
|
80 | 82 | } |
81 | 83 | } |
@@ -38,8 +38,9 @@ discard block |
||
38 | 38 | |
39 | 39 | $charset_collate = $wpdb->get_charset_collate(); |
40 | 40 | |
41 | - if ( $blog_id && $blog_id != $wpdb->blogid ) |
|
42 | - $old_blog_id = $wpdb->set_blog_id( $blog_id ); |
|
41 | + if ( $blog_id && $blog_id != $wpdb->blogid ) { |
|
42 | + $old_blog_id = $wpdb->set_blog_id( $blog_id ); |
|
43 | + } |
|
43 | 44 | |
44 | 45 | // Engage multisite if in the middle of turning it on from network.php. |
45 | 46 | $is_multisite = is_multisite() || ( defined( 'WP_INSTALLING_NETWORK' ) && WP_INSTALLING_NETWORK ); |
@@ -235,10 +236,11 @@ discard block |
||
235 | 236 | ) $charset_collate;\n"; |
236 | 237 | |
237 | 238 | // Global tables |
238 | - if ( $is_multisite ) |
|
239 | - $global_tables = $users_multi_table . $usermeta_table; |
|
240 | - else |
|
241 | - $global_tables = $users_single_table . $usermeta_table; |
|
239 | + if ( $is_multisite ) { |
|
240 | + $global_tables = $users_multi_table . $usermeta_table; |
|
241 | + } else { |
|
242 | + $global_tables = $users_single_table . $usermeta_table; |
|
243 | + } |
|
242 | 244 | |
243 | 245 | // Multisite global tables. |
244 | 246 | $ms_global_tables = "CREATE TABLE $wpdb->blogs ( |
@@ -315,8 +317,9 @@ discard block |
||
315 | 317 | break; |
316 | 318 | case 'global' : |
317 | 319 | $queries = $global_tables; |
318 | - if ( $is_multisite ) |
|
319 | - $queries .= $ms_global_tables; |
|
320 | + if ( $is_multisite ) { |
|
321 | + $queries .= $ms_global_tables; |
|
322 | + } |
|
320 | 323 | break; |
321 | 324 | case 'ms_global' : |
322 | 325 | $queries = $ms_global_tables; |
@@ -324,13 +327,15 @@ discard block |
||
324 | 327 | case 'all' : |
325 | 328 | default: |
326 | 329 | $queries = $global_tables . $blog_tables; |
327 | - if ( $is_multisite ) |
|
328 | - $queries .= $ms_global_tables; |
|
330 | + if ( $is_multisite ) { |
|
331 | + $queries .= $ms_global_tables; |
|
332 | + } |
|
329 | 333 | break; |
330 | 334 | } |
331 | 335 | |
332 | - if ( isset( $old_blog_id ) ) |
|
333 | - $wpdb->set_blog_id( $old_blog_id ); |
|
336 | + if ( isset( $old_blog_id ) ) { |
|
337 | + $wpdb->set_blog_id( $old_blog_id ); |
|
338 | + } |
|
334 | 339 | |
335 | 340 | return $queries; |
336 | 341 | } |
@@ -385,10 +390,11 @@ discard block |
||
385 | 390 | for all timezone strings supported by PHP. |
386 | 391 | */ |
387 | 392 | $offset_or_tz = _x( '0', 'default GMT offset or timezone string' ); |
388 | - if ( is_numeric( $offset_or_tz ) ) |
|
389 | - $gmt_offset = $offset_or_tz; |
|
390 | - elseif ( $offset_or_tz && in_array( $offset_or_tz, timezone_identifiers_list() ) ) |
|
391 | - $timezone_string = $offset_or_tz; |
|
393 | + if ( is_numeric( $offset_or_tz ) ) { |
|
394 | + $gmt_offset = $offset_or_tz; |
|
395 | + } elseif ( $offset_or_tz && in_array( $offset_or_tz, timezone_identifiers_list() ) ) { |
|
396 | + $timezone_string = $offset_or_tz; |
|
397 | + } |
|
392 | 398 | |
393 | 399 | $options = array( |
394 | 400 | 'siteurl' => $guessurl, |
@@ -539,25 +545,32 @@ discard block |
||
539 | 545 | |
540 | 546 | $insert = ''; |
541 | 547 | foreach ( $options as $option => $value ) { |
542 | - if ( in_array($option, $existing_options) ) |
|
543 | - continue; |
|
544 | - if ( in_array($option, $fat_options) ) |
|
545 | - $autoload = 'no'; |
|
546 | - else |
|
547 | - $autoload = 'yes'; |
|
548 | - |
|
549 | - if ( is_array($value) ) |
|
550 | - $value = serialize($value); |
|
551 | - if ( !empty($insert) ) |
|
552 | - $insert .= ', '; |
|
548 | + if ( in_array($option, $existing_options) ) { |
|
549 | + continue; |
|
550 | + } |
|
551 | + if ( in_array($option, $fat_options) ) { |
|
552 | + $autoload = 'no'; |
|
553 | + } else { |
|
554 | + $autoload = 'yes'; |
|
555 | + } |
|
556 | + |
|
557 | + if ( is_array($value) ) { |
|
558 | + $value = serialize($value); |
|
559 | + } |
|
560 | + if ( !empty($insert) ) { |
|
561 | + $insert .= ', '; |
|
562 | + } |
|
553 | 563 | $insert .= $wpdb->prepare( "(%s, %s, %s)", $option, $value, $autoload ); |
554 | 564 | } |
555 | 565 | |
556 | - if ( !empty($insert) ) |
|
557 | - $wpdb->query("INSERT INTO $wpdb->options (option_name, option_value, autoload) VALUES " . $insert); |
|
566 | + if ( !empty($insert) ) { |
|
567 | + $wpdb->query("INSERT INTO $wpdb->options (option_name, option_value, autoload) VALUES " . $insert); |
|
568 | + } |
|
558 | 569 | |
559 | 570 | // In case it is set, but blank, update "home". |
560 | - if ( !__get_option('home') ) update_option('home', $guessurl); |
|
571 | + if ( !__get_option('home') ) { |
|
572 | + update_option('home', $guessurl); |
|
573 | + } |
|
561 | 574 | |
562 | 575 | // Delete unused options. |
563 | 576 | $unusedoptions = array( |
@@ -578,8 +591,9 @@ discard block |
||
578 | 591 | 'wporg_popular_tags', 'what_to_show', 'rss_language', 'language', 'enable_xmlrpc', 'enable_app', |
579 | 592 | 'embed_autourls', 'default_post_edit_rows', 'gzipcompression', 'advanced_edit' |
580 | 593 | ); |
581 | - foreach ( $unusedoptions as $option ) |
|
582 | - delete_option($option); |
|
594 | + foreach ( $unusedoptions as $option ) { |
|
595 | + delete_option($option); |
|
596 | + } |
|
583 | 597 | |
584 | 598 | // Delete obsolete magpie stuff. |
585 | 599 | $wpdb->query("DELETE FROM $wpdb->options WHERE option_name REGEXP '^rss_[0-9a-f]{32}(_ts)?$'"); |
@@ -737,8 +751,9 @@ discard block |
||
737 | 751 | $roles = array('administrator', 'editor'); |
738 | 752 | foreach ($roles as $role) { |
739 | 753 | $role = get_role($role); |
740 | - if ( empty($role) ) |
|
741 | - continue; |
|
754 | + if ( empty($role) ) { |
|
755 | + continue; |
|
756 | + } |
|
742 | 757 | |
743 | 758 | $role->add_cap('edit_others_pages'); |
744 | 759 | $role->add_cap('edit_published_pages'); |
@@ -869,8 +884,9 @@ discard block |
||
869 | 884 | */ |
870 | 885 | if ( !function_exists( 'install_network' ) ) : |
871 | 886 | function install_network() { |
872 | - if ( ! defined( 'WP_INSTALLING_NETWORK' ) ) |
|
873 | - define( 'WP_INSTALLING_NETWORK', true ); |
|
887 | + if ( ! defined( 'WP_INSTALLING_NETWORK' ) ) { |
|
888 | + define( 'WP_INSTALLING_NETWORK', true ); |
|
889 | + } |
|
874 | 890 | |
875 | 891 | dbDelta( wp_get_db_schema( 'global' ) ); |
876 | 892 | } |
@@ -900,20 +916,25 @@ discard block |
||
900 | 916 | global $wpdb, $current_site, $wp_db_version, $wp_rewrite; |
901 | 917 | |
902 | 918 | $errors = new WP_Error(); |
903 | - if ( '' == $domain ) |
|
904 | - $errors->add( 'empty_domain', __( 'You must provide a domain name.' ) ); |
|
905 | - if ( '' == $site_name ) |
|
906 | - $errors->add( 'empty_sitename', __( 'You must provide a name for your network of sites.' ) ); |
|
919 | + if ( '' == $domain ) { |
|
920 | + $errors->add( 'empty_domain', __( 'You must provide a domain name.' ) ); |
|
921 | + } |
|
922 | + if ( '' == $site_name ) { |
|
923 | + $errors->add( 'empty_sitename', __( 'You must provide a name for your network of sites.' ) ); |
|
924 | + } |
|
907 | 925 | |
908 | 926 | // Check for network collision. |
909 | - if ( $network_id == $wpdb->get_var( $wpdb->prepare( "SELECT id FROM $wpdb->site WHERE id = %d", $network_id ) ) ) |
|
910 | - $errors->add( 'siteid_exists', __( 'The network already exists.' ) ); |
|
927 | + if ( $network_id == $wpdb->get_var( $wpdb->prepare( "SELECT id FROM $wpdb->site WHERE id = %d", $network_id ) ) ) { |
|
928 | + $errors->add( 'siteid_exists', __( 'The network already exists.' ) ); |
|
929 | + } |
|
911 | 930 | |
912 | - if ( ! is_email( $email ) ) |
|
913 | - $errors->add( 'invalid_email', __( 'You must provide a valid email address.' ) ); |
|
931 | + if ( ! is_email( $email ) ) { |
|
932 | + $errors->add( 'invalid_email', __( 'You must provide a valid email address.' ) ); |
|
933 | + } |
|
914 | 934 | |
915 | - if ( $errors->get_error_code() ) |
|
916 | - return $errors; |
|
935 | + if ( $errors->get_error_code() ) { |
|
936 | + return $errors; |
|
937 | + } |
|
917 | 938 | |
918 | 939 | // If a user with the provided email does not exist, default to the current user as the new network admin. |
919 | 940 | $site_user = get_user_by( 'email', $email ); |
@@ -955,8 +976,9 @@ discard block |
||
955 | 976 | $users = get_users( array( 'fields' => array( 'ID', 'user_login' ) ) ); |
956 | 977 | if ( $users ) { |
957 | 978 | foreach ( $users as $user ) { |
958 | - if ( is_super_admin( $user->ID ) && !in_array( $user->user_login, $site_admins ) ) |
|
959 | - $site_admins[] = $user->user_login; |
|
979 | + if ( is_super_admin( $user->ID ) && !in_array( $user->user_login, $site_admins ) ) { |
|
980 | + $site_admins[] = $user->user_login; |
|
981 | + } |
|
960 | 982 | } |
961 | 983 | } |
962 | 984 | } else { |
@@ -1019,8 +1041,9 @@ discard block |
||
1019 | 1041 | 'active_sitewide_plugins' => array(), |
1020 | 1042 | 'WPLANG' => get_locale(), |
1021 | 1043 | ); |
1022 | - if ( ! $subdomain_install ) |
|
1023 | - $sitemeta['illegal_names'][] = 'blog'; |
|
1044 | + if ( ! $subdomain_install ) { |
|
1045 | + $sitemeta['illegal_names'][] = 'blog'; |
|
1046 | + } |
|
1024 | 1047 | |
1025 | 1048 | /** |
1026 | 1049 | * Filters meta for a network on creation. |
@@ -1034,10 +1057,12 @@ discard block |
||
1034 | 1057 | |
1035 | 1058 | $insert = ''; |
1036 | 1059 | foreach ( $sitemeta as $meta_key => $meta_value ) { |
1037 | - if ( is_array( $meta_value ) ) |
|
1038 | - $meta_value = serialize( $meta_value ); |
|
1039 | - if ( !empty( $insert ) ) |
|
1040 | - $insert .= ', '; |
|
1060 | + if ( is_array( $meta_value ) ) { |
|
1061 | + $meta_value = serialize( $meta_value ); |
|
1062 | + } |
|
1063 | + if ( !empty( $insert ) ) { |
|
1064 | + $insert .= ', '; |
|
1065 | + } |
|
1041 | 1066 | $insert .= $wpdb->prepare( "( %d, %s, %s)", $network_id, $meta_key, $meta_value ); |
1042 | 1067 | } |
1043 | 1068 | $wpdb->query( "INSERT INTO $wpdb->sitemeta ( site_id, meta_key, meta_value ) VALUES " . $insert ); |
@@ -1059,24 +1084,27 @@ discard block |
||
1059 | 1084 | update_user_meta( $site_user->ID, 'source_domain', $domain ); |
1060 | 1085 | update_user_meta( $site_user->ID, 'primary_blog', $blog_id ); |
1061 | 1086 | |
1062 | - if ( $subdomain_install ) |
|
1063 | - $wp_rewrite->set_permalink_structure( '/%year%/%monthnum%/%day%/%postname%/' ); |
|
1064 | - else |
|
1065 | - $wp_rewrite->set_permalink_structure( '/blog/%year%/%monthnum%/%day%/%postname%/' ); |
|
1087 | + if ( $subdomain_install ) { |
|
1088 | + $wp_rewrite->set_permalink_structure( '/%year%/%monthnum%/%day%/%postname%/' ); |
|
1089 | + } else { |
|
1090 | + $wp_rewrite->set_permalink_structure( '/blog/%year%/%monthnum%/%day%/%postname%/' ); |
|
1091 | + } |
|
1066 | 1092 | |
1067 | 1093 | flush_rewrite_rules(); |
1068 | 1094 | |
1069 | - if ( ! $subdomain_install ) |
|
1070 | - return true; |
|
1095 | + if ( ! $subdomain_install ) { |
|
1096 | + return true; |
|
1097 | + } |
|
1071 | 1098 | |
1072 | 1099 | $vhost_ok = false; |
1073 | 1100 | $errstr = ''; |
1074 | 1101 | $hostname = substr( md5( time() ), 0, 6 ) . '.' . $domain; // Very random hostname! |
1075 | 1102 | $page = wp_remote_get( 'http://' . $hostname, array( 'timeout' => 5, 'httpversion' => '1.1' ) ); |
1076 | - if ( is_wp_error( $page ) ) |
|
1077 | - $errstr = $page->get_error_message(); |
|
1078 | - elseif ( 200 == wp_remote_retrieve_response_code( $page ) ) |
|
1079 | - $vhost_ok = true; |
|
1103 | + if ( is_wp_error( $page ) ) { |
|
1104 | + $errstr = $page->get_error_message(); |
|
1105 | + } elseif ( 200 == wp_remote_retrieve_response_code( $page ) ) { |
|
1106 | + $vhost_ok = true; |
|
1107 | + } |
|
1080 | 1108 | |
1081 | 1109 | if ( ! $vhost_ok ) { |
1082 | 1110 | $msg = '<p><strong>' . __( 'Warning! Wildcard DNS may not be configured correctly!' ) . '</strong></p>'; |
@@ -33,16 +33,16 @@ discard block |
||
33 | 33 | * @param int $blog_id Optional. The site ID for which to retrieve SQL. Default is the current site ID. |
34 | 34 | * @return string The SQL needed to create the requested tables. |
35 | 35 | */ |
36 | -function wp_get_db_schema( $scope = 'all', $blog_id = null ) { |
|
36 | +function wp_get_db_schema($scope = 'all', $blog_id = null) { |
|
37 | 37 | global $wpdb; |
38 | 38 | |
39 | 39 | $charset_collate = $wpdb->get_charset_collate(); |
40 | 40 | |
41 | - if ( $blog_id && $blog_id != $wpdb->blogid ) |
|
42 | - $old_blog_id = $wpdb->set_blog_id( $blog_id ); |
|
41 | + if ($blog_id && $blog_id != $wpdb->blogid) |
|
42 | + $old_blog_id = $wpdb->set_blog_id($blog_id); |
|
43 | 43 | |
44 | 44 | // Engage multisite if in the middle of turning it on from network.php. |
45 | - $is_multisite = is_multisite() || ( defined( 'WP_INSTALLING_NETWORK' ) && WP_INSTALLING_NETWORK ); |
|
45 | + $is_multisite = is_multisite() || (defined('WP_INSTALLING_NETWORK') && WP_INSTALLING_NETWORK); |
|
46 | 46 | |
47 | 47 | /* |
48 | 48 | * Indexes have a maximum size of 767 bytes. Historically, we haven't need to be concerned about that. |
@@ -235,10 +235,10 @@ discard block |
||
235 | 235 | ) $charset_collate;\n"; |
236 | 236 | |
237 | 237 | // Global tables |
238 | - if ( $is_multisite ) |
|
239 | - $global_tables = $users_multi_table . $usermeta_table; |
|
238 | + if ($is_multisite) |
|
239 | + $global_tables = $users_multi_table.$usermeta_table; |
|
240 | 240 | else |
241 | - $global_tables = $users_single_table . $usermeta_table; |
|
241 | + $global_tables = $users_single_table.$usermeta_table; |
|
242 | 242 | |
243 | 243 | // Multisite global tables. |
244 | 244 | $ms_global_tables = "CREATE TABLE $wpdb->blogs ( |
@@ -309,13 +309,13 @@ discard block |
||
309 | 309 | KEY domain_path (domain(140),path(51)) |
310 | 310 | ) $charset_collate;"; |
311 | 311 | |
312 | - switch ( $scope ) { |
|
312 | + switch ($scope) { |
|
313 | 313 | case 'blog' : |
314 | 314 | $queries = $blog_tables; |
315 | 315 | break; |
316 | 316 | case 'global' : |
317 | 317 | $queries = $global_tables; |
318 | - if ( $is_multisite ) |
|
318 | + if ($is_multisite) |
|
319 | 319 | $queries .= $ms_global_tables; |
320 | 320 | break; |
321 | 321 | case 'ms_global' : |
@@ -323,20 +323,20 @@ discard block |
||
323 | 323 | break; |
324 | 324 | case 'all' : |
325 | 325 | default: |
326 | - $queries = $global_tables . $blog_tables; |
|
327 | - if ( $is_multisite ) |
|
326 | + $queries = $global_tables.$blog_tables; |
|
327 | + if ($is_multisite) |
|
328 | 328 | $queries .= $ms_global_tables; |
329 | 329 | break; |
330 | 330 | } |
331 | 331 | |
332 | - if ( isset( $old_blog_id ) ) |
|
333 | - $wpdb->set_blog_id( $old_blog_id ); |
|
332 | + if (isset($old_blog_id)) |
|
333 | + $wpdb->set_blog_id($old_blog_id); |
|
334 | 334 | |
335 | 335 | return $queries; |
336 | 336 | } |
337 | 337 | |
338 | 338 | // Populate for back compat. |
339 | -$wp_queries = wp_get_db_schema( 'all' ); |
|
339 | +$wp_queries = wp_get_db_schema('all'); |
|
340 | 340 | |
341 | 341 | /** |
342 | 342 | * Create WordPress options and set the default values. |
@@ -356,9 +356,9 @@ discard block |
||
356 | 356 | * |
357 | 357 | * @since 2.6.0 |
358 | 358 | */ |
359 | - do_action( 'populate_options' ); |
|
359 | + do_action('populate_options'); |
|
360 | 360 | |
361 | - if ( ini_get('safe_mode') ) { |
|
361 | + if (ini_get('safe_mode')) { |
|
362 | 362 | // Safe mode can break mkdir() so use a flat structure by default. |
363 | 363 | $uploads_use_yearmonth_folders = 0; |
364 | 364 | } else { |
@@ -367,13 +367,13 @@ discard block |
||
367 | 367 | |
368 | 368 | // If WP_DEFAULT_THEME doesn't exist, fall back to the latest core default theme. |
369 | 369 | $stylesheet = $template = WP_DEFAULT_THEME; |
370 | - $theme = wp_get_theme( WP_DEFAULT_THEME ); |
|
371 | - if ( ! $theme->exists() ) { |
|
370 | + $theme = wp_get_theme(WP_DEFAULT_THEME); |
|
371 | + if ( ! $theme->exists()) { |
|
372 | 372 | $theme = WP_Theme::get_core_default_theme(); |
373 | 373 | } |
374 | 374 | |
375 | 375 | // If we can't find a core default theme, WP_DEFAULT_THEME is the best we can do. |
376 | - if ( $theme ) { |
|
376 | + if ($theme) { |
|
377 | 377 | $stylesheet = $theme->get_stylesheet(); |
378 | 378 | $template = $theme->get_template(); |
379 | 379 | } |
@@ -384,10 +384,10 @@ discard block |
||
384 | 384 | or a valid timezone string (America/New_York). See https://secure.php.net/manual/en/timezones.php |
385 | 385 | for all timezone strings supported by PHP. |
386 | 386 | */ |
387 | - $offset_or_tz = _x( '0', 'default GMT offset or timezone string' ); |
|
388 | - if ( is_numeric( $offset_or_tz ) ) |
|
387 | + $offset_or_tz = _x('0', 'default GMT offset or timezone string'); |
|
388 | + if (is_numeric($offset_or_tz)) |
|
389 | 389 | $gmt_offset = $offset_or_tz; |
390 | - elseif ( $offset_or_tz && in_array( $offset_or_tz, timezone_identifiers_list() ) ) |
|
390 | + elseif ($offset_or_tz && in_array($offset_or_tz, timezone_identifiers_list())) |
|
391 | 391 | $timezone_string = $offset_or_tz; |
392 | 392 | |
393 | 393 | $options = array( |
@@ -399,7 +399,7 @@ discard block |
||
399 | 399 | 'users_can_register' => 0, |
400 | 400 | 'admin_email' => '[email protected]', |
401 | 401 | /* translators: default start of the week. 0 = Sunday, 1 = Monday */ |
402 | - 'start_of_week' => _x( '1', 'start of week' ), |
|
402 | + 'start_of_week' => _x('1', 'start of week'), |
|
403 | 403 | 'use_balanceTags' => 0, |
404 | 404 | 'use_smilies' => 1, |
405 | 405 | 'require_name_email' => 1, |
@@ -519,45 +519,45 @@ discard block |
||
519 | 519 | ); |
520 | 520 | |
521 | 521 | // 3.3 |
522 | - if ( ! is_multisite() ) { |
|
523 | - $options['initial_db_version'] = ! empty( $wp_current_db_version ) && $wp_current_db_version < $wp_db_version |
|
522 | + if ( ! is_multisite()) { |
|
523 | + $options['initial_db_version'] = ! empty($wp_current_db_version) && $wp_current_db_version < $wp_db_version |
|
524 | 524 | ? $wp_current_db_version : $wp_db_version; |
525 | 525 | } |
526 | 526 | |
527 | 527 | // 3.0 multisite |
528 | - if ( is_multisite() ) { |
|
528 | + if (is_multisite()) { |
|
529 | 529 | /* translators: site tagline */ |
530 | - $options[ 'blogdescription' ] = sprintf(__('Just another %s site'), get_network()->site_name ); |
|
531 | - $options[ 'permalink_structure' ] = '/%year%/%monthnum%/%day%/%postname%/'; |
|
530 | + $options['blogdescription'] = sprintf(__('Just another %s site'), get_network()->site_name); |
|
531 | + $options['permalink_structure'] = '/%year%/%monthnum%/%day%/%postname%/'; |
|
532 | 532 | } |
533 | 533 | |
534 | 534 | // Set autoload to no for these options |
535 | - $fat_options = array( 'moderation_keys', 'recently_edited', 'blacklist_keys', 'uninstall_plugins' ); |
|
535 | + $fat_options = array('moderation_keys', 'recently_edited', 'blacklist_keys', 'uninstall_plugins'); |
|
536 | 536 | |
537 | - $keys = "'" . implode( "', '", array_keys( $options ) ) . "'"; |
|
538 | - $existing_options = $wpdb->get_col( "SELECT option_name FROM $wpdb->options WHERE option_name in ( $keys )" ); |
|
537 | + $keys = "'".implode("', '", array_keys($options))."'"; |
|
538 | + $existing_options = $wpdb->get_col("SELECT option_name FROM $wpdb->options WHERE option_name in ( $keys )"); |
|
539 | 539 | |
540 | 540 | $insert = ''; |
541 | - foreach ( $options as $option => $value ) { |
|
542 | - if ( in_array($option, $existing_options) ) |
|
541 | + foreach ($options as $option => $value) { |
|
542 | + if (in_array($option, $existing_options)) |
|
543 | 543 | continue; |
544 | - if ( in_array($option, $fat_options) ) |
|
544 | + if (in_array($option, $fat_options)) |
|
545 | 545 | $autoload = 'no'; |
546 | 546 | else |
547 | 547 | $autoload = 'yes'; |
548 | 548 | |
549 | - if ( is_array($value) ) |
|
549 | + if (is_array($value)) |
|
550 | 550 | $value = serialize($value); |
551 | - if ( !empty($insert) ) |
|
551 | + if ( ! empty($insert)) |
|
552 | 552 | $insert .= ', '; |
553 | - $insert .= $wpdb->prepare( "(%s, %s, %s)", $option, $value, $autoload ); |
|
553 | + $insert .= $wpdb->prepare("(%s, %s, %s)", $option, $value, $autoload); |
|
554 | 554 | } |
555 | 555 | |
556 | - if ( !empty($insert) ) |
|
557 | - $wpdb->query("INSERT INTO $wpdb->options (option_name, option_value, autoload) VALUES " . $insert); |
|
556 | + if ( ! empty($insert)) |
|
557 | + $wpdb->query("INSERT INTO $wpdb->options (option_name, option_value, autoload) VALUES ".$insert); |
|
558 | 558 | |
559 | 559 | // In case it is set, but blank, update "home". |
560 | - if ( !__get_option('home') ) update_option('home', $guessurl); |
|
560 | + if ( ! __get_option('home')) update_option('home', $guessurl); |
|
561 | 561 | |
562 | 562 | // Delete unused options. |
563 | 563 | $unusedoptions = array( |
@@ -578,7 +578,7 @@ discard block |
||
578 | 578 | 'wporg_popular_tags', 'what_to_show', 'rss_language', 'language', 'enable_xmlrpc', 'enable_app', |
579 | 579 | 'embed_autourls', 'default_post_edit_rows', 'gzipcompression', 'advanced_edit' |
580 | 580 | ); |
581 | - foreach ( $unusedoptions as $option ) |
|
581 | + foreach ($unusedoptions as $option) |
|
582 | 582 | delete_option($option); |
583 | 583 | |
584 | 584 | // Delete obsolete magpie stuff. |
@@ -595,15 +595,15 @@ discard block |
||
595 | 595 | AND a.option_name NOT LIKE %s |
596 | 596 | AND b.option_name = CONCAT( '_transient_timeout_', SUBSTRING( a.option_name, 12 ) ) |
597 | 597 | AND b.option_value < %d"; |
598 | - $wpdb->query( $wpdb->prepare( $sql, $wpdb->esc_like( '_transient_' ) . '%', $wpdb->esc_like( '_transient_timeout_' ) . '%', $time ) ); |
|
598 | + $wpdb->query($wpdb->prepare($sql, $wpdb->esc_like('_transient_').'%', $wpdb->esc_like('_transient_timeout_').'%', $time)); |
|
599 | 599 | |
600 | - if ( is_main_site() && is_main_network() ) { |
|
600 | + if (is_main_site() && is_main_network()) { |
|
601 | 601 | $sql = "DELETE a, b FROM $wpdb->options a, $wpdb->options b |
602 | 602 | WHERE a.option_name LIKE %s |
603 | 603 | AND a.option_name NOT LIKE %s |
604 | 604 | AND b.option_name = CONCAT( '_site_transient_timeout_', SUBSTRING( a.option_name, 17 ) ) |
605 | 605 | AND b.option_value < %d"; |
606 | - $wpdb->query( $wpdb->prepare( $sql, $wpdb->esc_like( '_site_transient_' ) . '%', $wpdb->esc_like( '_site_transient_timeout_' ) . '%', $time ) ); |
|
606 | + $wpdb->query($wpdb->prepare($sql, $wpdb->esc_like('_site_transient_').'%', $wpdb->esc_like('_site_transient_timeout_').'%', $time)); |
|
607 | 607 | } |
608 | 608 | } |
609 | 609 | |
@@ -737,7 +737,7 @@ discard block |
||
737 | 737 | $roles = array('administrator', 'editor'); |
738 | 738 | foreach ($roles as $role) { |
739 | 739 | $role = get_role($role); |
740 | - if ( empty($role) ) |
|
740 | + if (empty($role)) |
|
741 | 741 | continue; |
742 | 742 | |
743 | 743 | $role->add_cap('edit_others_pages'); |
@@ -758,19 +758,19 @@ discard block |
||
758 | 758 | } |
759 | 759 | |
760 | 760 | $role = get_role('administrator'); |
761 | - if ( ! empty($role) ) { |
|
761 | + if ( ! empty($role)) { |
|
762 | 762 | $role->add_cap('delete_users'); |
763 | 763 | $role->add_cap('create_users'); |
764 | 764 | } |
765 | 765 | |
766 | 766 | $role = get_role('author'); |
767 | - if ( ! empty($role) ) { |
|
767 | + if ( ! empty($role)) { |
|
768 | 768 | $role->add_cap('delete_posts'); |
769 | 769 | $role->add_cap('delete_published_posts'); |
770 | 770 | } |
771 | 771 | |
772 | 772 | $role = get_role('contributor'); |
773 | - if ( ! empty($role) ) { |
|
773 | + if ( ! empty($role)) { |
|
774 | 774 | $role->add_cap('delete_posts'); |
775 | 775 | } |
776 | 776 | } |
@@ -781,10 +781,10 @@ discard block |
||
781 | 781 | * @since 2.3.0 |
782 | 782 | */ |
783 | 783 | function populate_roles_230() { |
784 | - $role = get_role( 'administrator' ); |
|
784 | + $role = get_role('administrator'); |
|
785 | 785 | |
786 | - if ( !empty( $role ) ) { |
|
787 | - $role->add_cap( 'unfiltered_upload' ); |
|
786 | + if ( ! empty($role)) { |
|
787 | + $role->add_cap('unfiltered_upload'); |
|
788 | 788 | } |
789 | 789 | } |
790 | 790 | |
@@ -794,10 +794,10 @@ discard block |
||
794 | 794 | * @since 2.5.0 |
795 | 795 | */ |
796 | 796 | function populate_roles_250() { |
797 | - $role = get_role( 'administrator' ); |
|
797 | + $role = get_role('administrator'); |
|
798 | 798 | |
799 | - if ( !empty( $role ) ) { |
|
800 | - $role->add_cap( 'edit_dashboard' ); |
|
799 | + if ( ! empty($role)) { |
|
800 | + $role->add_cap('edit_dashboard'); |
|
801 | 801 | } |
802 | 802 | } |
803 | 803 | |
@@ -807,11 +807,11 @@ discard block |
||
807 | 807 | * @since 2.6.0 |
808 | 808 | */ |
809 | 809 | function populate_roles_260() { |
810 | - $role = get_role( 'administrator' ); |
|
810 | + $role = get_role('administrator'); |
|
811 | 811 | |
812 | - if ( !empty( $role ) ) { |
|
813 | - $role->add_cap( 'update_plugins' ); |
|
814 | - $role->add_cap( 'delete_plugins' ); |
|
812 | + if ( ! empty($role)) { |
|
813 | + $role->add_cap('update_plugins'); |
|
814 | + $role->add_cap('delete_plugins'); |
|
815 | 815 | } |
816 | 816 | } |
817 | 817 | |
@@ -821,11 +821,11 @@ discard block |
||
821 | 821 | * @since 2.7.0 |
822 | 822 | */ |
823 | 823 | function populate_roles_270() { |
824 | - $role = get_role( 'administrator' ); |
|
824 | + $role = get_role('administrator'); |
|
825 | 825 | |
826 | - if ( !empty( $role ) ) { |
|
827 | - $role->add_cap( 'install_plugins' ); |
|
828 | - $role->add_cap( 'update_themes' ); |
|
826 | + if ( ! empty($role)) { |
|
827 | + $role->add_cap('install_plugins'); |
|
828 | + $role->add_cap('update_themes'); |
|
829 | 829 | } |
830 | 830 | } |
831 | 831 | |
@@ -835,10 +835,10 @@ discard block |
||
835 | 835 | * @since 2.8.0 |
836 | 836 | */ |
837 | 837 | function populate_roles_280() { |
838 | - $role = get_role( 'administrator' ); |
|
838 | + $role = get_role('administrator'); |
|
839 | 839 | |
840 | - if ( !empty( $role ) ) { |
|
841 | - $role->add_cap( 'install_themes' ); |
|
840 | + if ( ! empty($role)) { |
|
841 | + $role->add_cap('install_themes'); |
|
842 | 842 | } |
843 | 843 | } |
844 | 844 | |
@@ -848,30 +848,30 @@ discard block |
||
848 | 848 | * @since 3.0.0 |
849 | 849 | */ |
850 | 850 | function populate_roles_300() { |
851 | - $role = get_role( 'administrator' ); |
|
852 | - |
|
853 | - if ( !empty( $role ) ) { |
|
854 | - $role->add_cap( 'update_core' ); |
|
855 | - $role->add_cap( 'list_users' ); |
|
856 | - $role->add_cap( 'remove_users' ); |
|
857 | - $role->add_cap( 'promote_users' ); |
|
858 | - $role->add_cap( 'edit_theme_options' ); |
|
859 | - $role->add_cap( 'delete_themes' ); |
|
860 | - $role->add_cap( 'export' ); |
|
851 | + $role = get_role('administrator'); |
|
852 | + |
|
853 | + if ( ! empty($role)) { |
|
854 | + $role->add_cap('update_core'); |
|
855 | + $role->add_cap('list_users'); |
|
856 | + $role->add_cap('remove_users'); |
|
857 | + $role->add_cap('promote_users'); |
|
858 | + $role->add_cap('edit_theme_options'); |
|
859 | + $role->add_cap('delete_themes'); |
|
860 | + $role->add_cap('export'); |
|
861 | 861 | } |
862 | 862 | } |
863 | 863 | |
864 | -if ( !function_exists( 'install_network' ) ) : |
|
864 | +if ( ! function_exists('install_network')) : |
|
865 | 865 | /** |
866 | 866 | * Install Network. |
867 | 867 | * |
868 | 868 | * @since 3.0.0 |
869 | 869 | */ |
870 | 870 | function install_network() { |
871 | - if ( ! defined( 'WP_INSTALLING_NETWORK' ) ) |
|
872 | - define( 'WP_INSTALLING_NETWORK', true ); |
|
871 | + if ( ! defined('WP_INSTALLING_NETWORK')) |
|
872 | + define('WP_INSTALLING_NETWORK', true); |
|
873 | 873 | |
874 | - dbDelta( wp_get_db_schema( 'global' ) ); |
|
874 | + dbDelta(wp_get_db_schema('global')); |
|
875 | 875 | } |
876 | 876 | endif; |
877 | 877 | |
@@ -895,75 +895,75 @@ discard block |
||
895 | 895 | * @return bool|WP_Error True on success, or WP_Error on warning (with the install otherwise successful, |
896 | 896 | * so the error code must be checked) or failure. |
897 | 897 | */ |
898 | -function populate_network( $network_id = 1, $domain = '', $email = '', $site_name = '', $path = '/', $subdomain_install = false ) { |
|
898 | +function populate_network($network_id = 1, $domain = '', $email = '', $site_name = '', $path = '/', $subdomain_install = false) { |
|
899 | 899 | global $wpdb, $current_site, $wp_db_version, $wp_rewrite; |
900 | 900 | |
901 | 901 | $errors = new WP_Error(); |
902 | - if ( '' == $domain ) |
|
903 | - $errors->add( 'empty_domain', __( 'You must provide a domain name.' ) ); |
|
904 | - if ( '' == $site_name ) |
|
905 | - $errors->add( 'empty_sitename', __( 'You must provide a name for your network of sites.' ) ); |
|
902 | + if ('' == $domain) |
|
903 | + $errors->add('empty_domain', __('You must provide a domain name.')); |
|
904 | + if ('' == $site_name) |
|
905 | + $errors->add('empty_sitename', __('You must provide a name for your network of sites.')); |
|
906 | 906 | |
907 | 907 | // Check for network collision. |
908 | - if ( $network_id == $wpdb->get_var( $wpdb->prepare( "SELECT id FROM $wpdb->site WHERE id = %d", $network_id ) ) ) |
|
909 | - $errors->add( 'siteid_exists', __( 'The network already exists.' ) ); |
|
908 | + if ($network_id == $wpdb->get_var($wpdb->prepare("SELECT id FROM $wpdb->site WHERE id = %d", $network_id))) |
|
909 | + $errors->add('siteid_exists', __('The network already exists.')); |
|
910 | 910 | |
911 | - if ( ! is_email( $email ) ) |
|
912 | - $errors->add( 'invalid_email', __( 'You must provide a valid email address.' ) ); |
|
911 | + if ( ! is_email($email)) |
|
912 | + $errors->add('invalid_email', __('You must provide a valid email address.')); |
|
913 | 913 | |
914 | - if ( $errors->get_error_code() ) |
|
914 | + if ($errors->get_error_code()) |
|
915 | 915 | return $errors; |
916 | 916 | |
917 | 917 | // If a user with the provided email does not exist, default to the current user as the new network admin. |
918 | - $site_user = get_user_by( 'email', $email ); |
|
919 | - if ( false === $site_user ) { |
|
918 | + $site_user = get_user_by('email', $email); |
|
919 | + if (false === $site_user) { |
|
920 | 920 | $site_user = wp_get_current_user(); |
921 | 921 | } |
922 | 922 | |
923 | 923 | // Set up site tables. |
924 | - $template = get_option( 'template' ); |
|
925 | - $stylesheet = get_option( 'stylesheet' ); |
|
926 | - $allowed_themes = array( $stylesheet => true ); |
|
924 | + $template = get_option('template'); |
|
925 | + $stylesheet = get_option('stylesheet'); |
|
926 | + $allowed_themes = array($stylesheet => true); |
|
927 | 927 | |
928 | - if ( $template != $stylesheet ) { |
|
929 | - $allowed_themes[ $template ] = true; |
|
928 | + if ($template != $stylesheet) { |
|
929 | + $allowed_themes[$template] = true; |
|
930 | 930 | } |
931 | 931 | |
932 | - if ( WP_DEFAULT_THEME != $stylesheet && WP_DEFAULT_THEME != $template ) { |
|
933 | - $allowed_themes[ WP_DEFAULT_THEME ] = true; |
|
932 | + if (WP_DEFAULT_THEME != $stylesheet && WP_DEFAULT_THEME != $template) { |
|
933 | + $allowed_themes[WP_DEFAULT_THEME] = true; |
|
934 | 934 | } |
935 | 935 | |
936 | 936 | // If WP_DEFAULT_THEME doesn't exist, also whitelist the latest core default theme. |
937 | - if ( ! wp_get_theme( WP_DEFAULT_THEME )->exists() ) { |
|
938 | - if ( $core_default = WP_Theme::get_core_default_theme() ) { |
|
939 | - $allowed_themes[ $core_default->get_stylesheet() ] = true; |
|
937 | + if ( ! wp_get_theme(WP_DEFAULT_THEME)->exists()) { |
|
938 | + if ($core_default = WP_Theme::get_core_default_theme()) { |
|
939 | + $allowed_themes[$core_default->get_stylesheet()] = true; |
|
940 | 940 | } |
941 | 941 | } |
942 | 942 | |
943 | - if ( 1 == $network_id ) { |
|
944 | - $wpdb->insert( $wpdb->site, array( 'domain' => $domain, 'path' => $path ) ); |
|
943 | + if (1 == $network_id) { |
|
944 | + $wpdb->insert($wpdb->site, array('domain' => $domain, 'path' => $path)); |
|
945 | 945 | $network_id = $wpdb->insert_id; |
946 | 946 | } else { |
947 | - $wpdb->insert( $wpdb->site, array( 'domain' => $domain, 'path' => $path, 'id' => $network_id ) ); |
|
947 | + $wpdb->insert($wpdb->site, array('domain' => $domain, 'path' => $path, 'id' => $network_id)); |
|
948 | 948 | } |
949 | 949 | |
950 | - wp_cache_delete( 'networks_have_paths', 'site-options' ); |
|
950 | + wp_cache_delete('networks_have_paths', 'site-options'); |
|
951 | 951 | |
952 | - if ( !is_multisite() ) { |
|
953 | - $site_admins = array( $site_user->user_login ); |
|
954 | - $users = get_users( array( 'fields' => array( 'ID', 'user_login' ) ) ); |
|
955 | - if ( $users ) { |
|
956 | - foreach ( $users as $user ) { |
|
957 | - if ( is_super_admin( $user->ID ) && !in_array( $user->user_login, $site_admins ) ) |
|
952 | + if ( ! is_multisite()) { |
|
953 | + $site_admins = array($site_user->user_login); |
|
954 | + $users = get_users(array('fields' => array('ID', 'user_login'))); |
|
955 | + if ($users) { |
|
956 | + foreach ($users as $user) { |
|
957 | + if (is_super_admin($user->ID) && ! in_array($user->user_login, $site_admins)) |
|
958 | 958 | $site_admins[] = $user->user_login; |
959 | 959 | } |
960 | 960 | } |
961 | 961 | } else { |
962 | - $site_admins = get_site_option( 'site_admins' ); |
|
962 | + $site_admins = get_site_option('site_admins'); |
|
963 | 963 | } |
964 | 964 | |
965 | 965 | /* translators: Do not translate USERNAME, SITE_NAME, BLOG_URL, PASSWORD: those are placeholders. */ |
966 | - $welcome_email = __( 'Howdy USERNAME, |
|
966 | + $welcome_email = __('Howdy USERNAME, |
|
967 | 967 | |
968 | 968 | Your new SITE_NAME site has been successfully set up at: |
969 | 969 | BLOG_URL |
@@ -990,35 +990,35 @@ discard block |
||
990 | 990 | ); |
991 | 991 | $audio_exts = wp_get_audio_extensions(); |
992 | 992 | $video_exts = wp_get_video_extensions(); |
993 | - $upload_filetypes = array_unique( array_merge( $misc_exts, $audio_exts, $video_exts ) ); |
|
993 | + $upload_filetypes = array_unique(array_merge($misc_exts, $audio_exts, $video_exts)); |
|
994 | 994 | |
995 | 995 | $sitemeta = array( |
996 | 996 | 'site_name' => $site_name, |
997 | 997 | 'admin_email' => $email, |
998 | 998 | 'admin_user_id' => $site_user->ID, |
999 | 999 | 'registration' => 'none', |
1000 | - 'upload_filetypes' => implode( ' ', $upload_filetypes ), |
|
1000 | + 'upload_filetypes' => implode(' ', $upload_filetypes), |
|
1001 | 1001 | 'blog_upload_space' => 100, |
1002 | 1002 | 'fileupload_maxk' => 1500, |
1003 | 1003 | 'site_admins' => $site_admins, |
1004 | 1004 | 'allowedthemes' => $allowed_themes, |
1005 | - 'illegal_names' => array( 'www', 'web', 'root', 'admin', 'main', 'invite', 'administrator', 'files' ), |
|
1005 | + 'illegal_names' => array('www', 'web', 'root', 'admin', 'main', 'invite', 'administrator', 'files'), |
|
1006 | 1006 | 'wpmu_upgrade_site' => $wp_db_version, |
1007 | 1007 | 'welcome_email' => $welcome_email, |
1008 | 1008 | /* translators: %s: site link */ |
1009 | - 'first_post' => __( 'Welcome to %s. This is your first post. Edit or delete it, then start blogging!' ), |
|
1009 | + 'first_post' => __('Welcome to %s. This is your first post. Edit or delete it, then start blogging!'), |
|
1010 | 1010 | // @todo - network admins should have a method of editing the network siteurl (used for cookie hash) |
1011 | - 'siteurl' => get_option( 'siteurl' ) . '/', |
|
1011 | + 'siteurl' => get_option('siteurl').'/', |
|
1012 | 1012 | 'add_new_users' => '0', |
1013 | - 'upload_space_check_disabled' => is_multisite() ? get_site_option( 'upload_space_check_disabled' ) : '1', |
|
1014 | - 'subdomain_install' => intval( $subdomain_install ), |
|
1013 | + 'upload_space_check_disabled' => is_multisite() ? get_site_option('upload_space_check_disabled') : '1', |
|
1014 | + 'subdomain_install' => intval($subdomain_install), |
|
1015 | 1015 | 'global_terms_enabled' => global_terms_enabled() ? '1' : '0', |
1016 | - 'ms_files_rewriting' => is_multisite() ? get_site_option( 'ms_files_rewriting' ) : '0', |
|
1017 | - 'initial_db_version' => get_option( 'initial_db_version' ), |
|
1016 | + 'ms_files_rewriting' => is_multisite() ? get_site_option('ms_files_rewriting') : '0', |
|
1017 | + 'initial_db_version' => get_option('initial_db_version'), |
|
1018 | 1018 | 'active_sitewide_plugins' => array(), |
1019 | 1019 | 'WPLANG' => get_locale(), |
1020 | 1020 | ); |
1021 | - if ( ! $subdomain_install ) |
|
1021 | + if ( ! $subdomain_install) |
|
1022 | 1022 | $sitemeta['illegal_names'][] = 'blog'; |
1023 | 1023 | |
1024 | 1024 | /** |
@@ -1029,17 +1029,17 @@ discard block |
||
1029 | 1029 | * @param array $sitemeta Associative array of network meta keys and values to be inserted. |
1030 | 1030 | * @param int $network_id ID of network to populate. |
1031 | 1031 | */ |
1032 | - $sitemeta = apply_filters( 'populate_network_meta', $sitemeta, $network_id ); |
|
1032 | + $sitemeta = apply_filters('populate_network_meta', $sitemeta, $network_id); |
|
1033 | 1033 | |
1034 | 1034 | $insert = ''; |
1035 | - foreach ( $sitemeta as $meta_key => $meta_value ) { |
|
1036 | - if ( is_array( $meta_value ) ) |
|
1037 | - $meta_value = serialize( $meta_value ); |
|
1038 | - if ( !empty( $insert ) ) |
|
1035 | + foreach ($sitemeta as $meta_key => $meta_value) { |
|
1036 | + if (is_array($meta_value)) |
|
1037 | + $meta_value = serialize($meta_value); |
|
1038 | + if ( ! empty($insert)) |
|
1039 | 1039 | $insert .= ', '; |
1040 | - $insert .= $wpdb->prepare( "( %d, %s, %s)", $network_id, $meta_key, $meta_value ); |
|
1040 | + $insert .= $wpdb->prepare("( %d, %s, %s)", $network_id, $meta_key, $meta_value); |
|
1041 | 1041 | } |
1042 | - $wpdb->query( "INSERT INTO $wpdb->sitemeta ( site_id, meta_key, meta_value ) VALUES " . $insert ); |
|
1042 | + $wpdb->query("INSERT INTO $wpdb->sitemeta ( site_id, meta_key, meta_value ) VALUES ".$insert); |
|
1043 | 1043 | |
1044 | 1044 | /* |
1045 | 1045 | * When upgrading from single to multisite, assume the current site will |
@@ -1048,58 +1048,58 @@ discard block |
||
1048 | 1048 | * these steps since the main site of the new network has not yet been |
1049 | 1049 | * created. |
1050 | 1050 | */ |
1051 | - if ( ! is_multisite() ) { |
|
1051 | + if ( ! is_multisite()) { |
|
1052 | 1052 | $current_site = new stdClass; |
1053 | 1053 | $current_site->domain = $domain; |
1054 | 1054 | $current_site->path = $path; |
1055 | - $current_site->site_name = ucfirst( $domain ); |
|
1056 | - $wpdb->insert( $wpdb->blogs, array( 'site_id' => $network_id, 'blog_id' => 1, 'domain' => $domain, 'path' => $path, 'registered' => current_time( 'mysql' ) ) ); |
|
1055 | + $current_site->site_name = ucfirst($domain); |
|
1056 | + $wpdb->insert($wpdb->blogs, array('site_id' => $network_id, 'blog_id' => 1, 'domain' => $domain, 'path' => $path, 'registered' => current_time('mysql'))); |
|
1057 | 1057 | $current_site->blog_id = $blog_id = $wpdb->insert_id; |
1058 | - update_user_meta( $site_user->ID, 'source_domain', $domain ); |
|
1059 | - update_user_meta( $site_user->ID, 'primary_blog', $blog_id ); |
|
1058 | + update_user_meta($site_user->ID, 'source_domain', $domain); |
|
1059 | + update_user_meta($site_user->ID, 'primary_blog', $blog_id); |
|
1060 | 1060 | |
1061 | - if ( $subdomain_install ) |
|
1062 | - $wp_rewrite->set_permalink_structure( '/%year%/%monthnum%/%day%/%postname%/' ); |
|
1061 | + if ($subdomain_install) |
|
1062 | + $wp_rewrite->set_permalink_structure('/%year%/%monthnum%/%day%/%postname%/'); |
|
1063 | 1063 | else |
1064 | - $wp_rewrite->set_permalink_structure( '/blog/%year%/%monthnum%/%day%/%postname%/' ); |
|
1064 | + $wp_rewrite->set_permalink_structure('/blog/%year%/%monthnum%/%day%/%postname%/'); |
|
1065 | 1065 | |
1066 | 1066 | flush_rewrite_rules(); |
1067 | 1067 | |
1068 | - if ( ! $subdomain_install ) |
|
1068 | + if ( ! $subdomain_install) |
|
1069 | 1069 | return true; |
1070 | 1070 | |
1071 | 1071 | $vhost_ok = false; |
1072 | 1072 | $errstr = ''; |
1073 | - $hostname = substr( md5( time() ), 0, 6 ) . '.' . $domain; // Very random hostname! |
|
1074 | - $page = wp_remote_get( 'http://' . $hostname, array( 'timeout' => 5, 'httpversion' => '1.1' ) ); |
|
1075 | - if ( is_wp_error( $page ) ) |
|
1073 | + $hostname = substr(md5(time()), 0, 6).'.'.$domain; // Very random hostname! |
|
1074 | + $page = wp_remote_get('http://'.$hostname, array('timeout' => 5, 'httpversion' => '1.1')); |
|
1075 | + if (is_wp_error($page)) |
|
1076 | 1076 | $errstr = $page->get_error_message(); |
1077 | - elseif ( 200 == wp_remote_retrieve_response_code( $page ) ) |
|
1077 | + elseif (200 == wp_remote_retrieve_response_code($page)) |
|
1078 | 1078 | $vhost_ok = true; |
1079 | 1079 | |
1080 | - if ( ! $vhost_ok ) { |
|
1081 | - $msg = '<p><strong>' . __( 'Warning! Wildcard DNS may not be configured correctly!' ) . '</strong></p>'; |
|
1080 | + if ( ! $vhost_ok) { |
|
1081 | + $msg = '<p><strong>'.__('Warning! Wildcard DNS may not be configured correctly!').'</strong></p>'; |
|
1082 | 1082 | |
1083 | - $msg .= '<p>' . sprintf( |
|
1083 | + $msg .= '<p>'.sprintf( |
|
1084 | 1084 | /* translators: %s: host name */ |
1085 | - __( 'The installer attempted to contact a random hostname (%s) on your domain.' ), |
|
1086 | - '<code>' . $hostname . '</code>' |
|
1085 | + __('The installer attempted to contact a random hostname (%s) on your domain.'), |
|
1086 | + '<code>'.$hostname.'</code>' |
|
1087 | 1087 | ); |
1088 | - if ( ! empty ( $errstr ) ) { |
|
1088 | + if ( ! empty ($errstr)) { |
|
1089 | 1089 | /* translators: %s: error message */ |
1090 | - $msg .= ' ' . sprintf( __( 'This resulted in an error message: %s' ), '<code>' . $errstr . '</code>' ); |
|
1090 | + $msg .= ' '.sprintf(__('This resulted in an error message: %s'), '<code>'.$errstr.'</code>'); |
|
1091 | 1091 | } |
1092 | 1092 | $msg .= '</p>'; |
1093 | 1093 | |
1094 | - $msg .= '<p>' . sprintf( |
|
1094 | + $msg .= '<p>'.sprintf( |
|
1095 | 1095 | /* translators: %s: asterisk symbol (*) */ |
1096 | - __( 'To use a subdomain configuration, you must have a wildcard entry in your DNS. This usually means adding a %s hostname record pointing at your web server in your DNS configuration tool.' ), |
|
1096 | + __('To use a subdomain configuration, you must have a wildcard entry in your DNS. This usually means adding a %s hostname record pointing at your web server in your DNS configuration tool.'), |
|
1097 | 1097 | '<code>*</code>' |
1098 | - ) . '</p>'; |
|
1098 | + ).'</p>'; |
|
1099 | 1099 | |
1100 | - $msg .= '<p>' . __( 'You can still use your site but any subdomain you create may not be accessible. If you know your DNS is correct, ignore this message.' ) . '</p>'; |
|
1100 | + $msg .= '<p>'.__('You can still use your site but any subdomain you create may not be accessible. If you know your DNS is correct, ignore this message.').'</p>'; |
|
1101 | 1101 | |
1102 | - return new WP_Error( 'no_wildcard_dns', $msg ); |
|
1102 | + return new WP_Error('no_wildcard_dns', $msg); |
|
1103 | 1103 | } |
1104 | 1104 | } |
1105 | 1105 |
@@ -520,7 +520,7 @@ discard block |
||
520 | 520 | * @since 3.5.0 |
521 | 521 | * |
522 | 522 | * @param WP_Image_Editor $image WP_Image_Editor instance. |
523 | - * @param array $changes Array of change operations. |
|
523 | + * @param array $changes Array of change operations. |
|
524 | 524 | */ |
525 | 525 | $image = apply_filters( 'wp_image_editor_before_change', $image, $changes ); |
526 | 526 | } elseif ( is_resource( $image ) ) { |
@@ -532,7 +532,7 @@ discard block |
||
532 | 532 | * @deprecated 3.5.0 Use wp_image_editor_before_change instead. |
533 | 533 | * |
534 | 534 | * @param resource $image GD image resource. |
535 | - * @param array $changes Array of change operations. |
|
535 | + * @param array $changes Array of change operations. |
|
536 | 536 | */ |
537 | 537 | $image = apply_filters( 'image_edit_before_change', $image, $changes ); |
538 | 538 | } |
@@ -384,7 +384,7 @@ |
||
384 | 384 | * @ignore |
385 | 385 | * @param resource $img Image resource. |
386 | 386 | * @param float|int $angle Image rotation angle, in degrees. |
387 | - * @return resource|false GD image resource, false otherwise. |
|
387 | + * @return resource GD image resource, false otherwise. |
|
388 | 388 | */ |
389 | 389 | function _rotate_image_resource($img, $angle) { |
390 | 390 | _deprecated_function( __FUNCTION__, '3.5.0', __( 'Use WP_Image_Editor::rotate' ) ); |
@@ -20,22 +20,22 @@ discard block |
||
20 | 20 | $sub_sizes = isset($meta['sizes']) && is_array($meta['sizes']); |
21 | 21 | $note = ''; |
22 | 22 | |
23 | - if ( isset( $meta['width'], $meta['height'] ) ) |
|
24 | - $big = max( $meta['width'], $meta['height'] ); |
|
23 | + if (isset($meta['width'], $meta['height'])) |
|
24 | + $big = max($meta['width'], $meta['height']); |
|
25 | 25 | else |
26 | - die( __('Image data does not exist. Please re-upload the image.') ); |
|
26 | + die(__('Image data does not exist. Please re-upload the image.')); |
|
27 | 27 | |
28 | 28 | $sizer = $big > 400 ? 400 / $big : 1; |
29 | 29 | |
30 | - $backup_sizes = get_post_meta( $post_id, '_wp_attachment_backup_sizes', true ); |
|
30 | + $backup_sizes = get_post_meta($post_id, '_wp_attachment_backup_sizes', true); |
|
31 | 31 | $can_restore = false; |
32 | - if ( ! empty( $backup_sizes ) && isset( $backup_sizes['full-orig'], $meta['file'] ) ) |
|
33 | - $can_restore = $backup_sizes['full-orig']['file'] != basename( $meta['file'] ); |
|
32 | + if ( ! empty($backup_sizes) && isset($backup_sizes['full-orig'], $meta['file'])) |
|
33 | + $can_restore = $backup_sizes['full-orig']['file'] != basename($meta['file']); |
|
34 | 34 | |
35 | - if ( $msg ) { |
|
36 | - if ( isset($msg->error) ) |
|
35 | + if ($msg) { |
|
36 | + if (isset($msg->error)) |
|
37 | 37 | $note = "<div class='error'><p>$msg->error</p></div>"; |
38 | - elseif ( isset($msg->msg) ) |
|
38 | + elseif (isset($msg->msg)) |
|
39 | 39 | $note = "<div class='updated'><p>$msg->msg</p></div>"; |
40 | 40 | } |
41 | 41 | |
@@ -46,28 +46,28 @@ discard block |
||
46 | 46 | <div class="imgedit-settings"> |
47 | 47 | <div class="imgedit-group"> |
48 | 48 | <div class="imgedit-group-top"> |
49 | - <h2><?php _e( 'Scale Image' ); ?></h2> |
|
50 | - <button type="button" class="dashicons dashicons-editor-help imgedit-help-toggle" onclick="imageEdit.toggleHelp(this);return false;" aria-expanded="false"><span class="screen-reader-text"><?php esc_html_e( 'Scale Image Help' ); ?></span></button> |
|
49 | + <h2><?php _e('Scale Image'); ?></h2> |
|
50 | + <button type="button" class="dashicons dashicons-editor-help imgedit-help-toggle" onclick="imageEdit.toggleHelp(this);return false;" aria-expanded="false"><span class="screen-reader-text"><?php esc_html_e('Scale Image Help'); ?></span></button> |
|
51 | 51 | <div class="imgedit-help"> |
52 | 52 | <p><?php _e('You can proportionally scale the original image. For best results, scaling should be done before you crop, flip, or rotate. Images can only be scaled down, not up.'); ?></p> |
53 | 53 | </div> |
54 | - <?php if ( isset( $meta['width'], $meta['height'] ) ): ?> |
|
55 | - <p><?php printf( __('Original dimensions %s'), $meta['width'] . ' × ' . $meta['height'] ); ?></p> |
|
54 | + <?php if (isset($meta['width'], $meta['height'])): ?> |
|
55 | + <p><?php printf(__('Original dimensions %s'), $meta['width'].' × '.$meta['height']); ?></p> |
|
56 | 56 | <?php endif ?> |
57 | 57 | <div class="imgedit-submit"> |
58 | 58 | |
59 | 59 | <fieldset class="imgedit-scale"> |
60 | - <legend><?php _e( 'New dimensions:' ); ?></legend> |
|
60 | + <legend><?php _e('New dimensions:'); ?></legend> |
|
61 | 61 | <div class="nowrap"> |
62 | - <label><span class="screen-reader-text"><?php _e( 'scale width' ); ?></span> |
|
63 | - <input type="text" id="imgedit-scale-width-<?php echo $post_id; ?>" onkeyup="imageEdit.scaleChanged(<?php echo $post_id; ?>, 1, this)" onblur="imageEdit.scaleChanged(<?php echo $post_id; ?>, 1, this)" value="<?php echo isset( $meta['width'] ) ? $meta['width'] : 0; ?>" /> |
|
62 | + <label><span class="screen-reader-text"><?php _e('scale width'); ?></span> |
|
63 | + <input type="text" id="imgedit-scale-width-<?php echo $post_id; ?>" onkeyup="imageEdit.scaleChanged(<?php echo $post_id; ?>, 1, this)" onblur="imageEdit.scaleChanged(<?php echo $post_id; ?>, 1, this)" value="<?php echo isset($meta['width']) ? $meta['width'] : 0; ?>" /> |
|
64 | 64 | </label> |
65 | 65 | <span class="imgedit-separator">×</span> |
66 | - <label><span class="screen-reader-text"><?php _e( 'scale height' ); ?></span> |
|
67 | - <input type="text" id="imgedit-scale-height-<?php echo $post_id; ?>" onkeyup="imageEdit.scaleChanged(<?php echo $post_id; ?>, 0, this)" onblur="imageEdit.scaleChanged(<?php echo $post_id; ?>, 0, this)" value="<?php echo isset( $meta['height'] ) ? $meta['height'] : 0; ?>" /> |
|
66 | + <label><span class="screen-reader-text"><?php _e('scale height'); ?></span> |
|
67 | + <input type="text" id="imgedit-scale-height-<?php echo $post_id; ?>" onkeyup="imageEdit.scaleChanged(<?php echo $post_id; ?>, 0, this)" onblur="imageEdit.scaleChanged(<?php echo $post_id; ?>, 0, this)" value="<?php echo isset($meta['height']) ? $meta['height'] : 0; ?>" /> |
|
68 | 68 | </label> |
69 | 69 | <span class="imgedit-scale-warn" id="imgedit-scale-warn-<?php echo $post_id; ?>">!</span> |
70 | - <input id="imgedit-scale-button" type="button" onclick="imageEdit.action(<?php echo "$post_id, '$nonce'"; ?>, 'scale')" class="button button-primary" value="<?php esc_attr_e( 'Scale' ); ?>" /> |
|
70 | + <input id="imgedit-scale-button" type="button" onclick="imageEdit.action(<?php echo "$post_id, '$nonce'"; ?>, 'scale')" class="button button-primary" value="<?php esc_attr_e('Scale'); ?>" /> |
|
71 | 71 | </div> |
72 | 72 | </fieldset> |
73 | 73 | |
@@ -75,20 +75,20 @@ discard block |
||
75 | 75 | </div> |
76 | 76 | </div> |
77 | 77 | |
78 | -<?php if ( $can_restore ) { ?> |
|
78 | +<?php if ($can_restore) { ?> |
|
79 | 79 | |
80 | 80 | <div class="imgedit-group"> |
81 | 81 | <div class="imgedit-group-top"> |
82 | - <h2><button type="button" onclick="imageEdit.toggleHelp(this);" class="button-link"><?php _e( 'Restore Original Image' ); ?> <span class="dashicons dashicons-arrow-down imgedit-help-toggle"></span></button></h2> |
|
82 | + <h2><button type="button" onclick="imageEdit.toggleHelp(this);" class="button-link"><?php _e('Restore Original Image'); ?> <span class="dashicons dashicons-arrow-down imgedit-help-toggle"></span></button></h2> |
|
83 | 83 | <div class="imgedit-help"> |
84 | 84 | <p><?php _e('Discard any changes and restore the original image.'); |
85 | 85 | |
86 | - if ( !defined('IMAGE_EDIT_OVERWRITE') || !IMAGE_EDIT_OVERWRITE ) |
|
86 | + if ( ! defined('IMAGE_EDIT_OVERWRITE') || ! IMAGE_EDIT_OVERWRITE) |
|
87 | 87 | echo ' '.__('Previously edited copies of the image will not be deleted.'); |
88 | 88 | |
89 | 89 | ?></p> |
90 | 90 | <div class="imgedit-submit"> |
91 | - <input type="button" onclick="imageEdit.action(<?php echo "$post_id, '$nonce'"; ?>, 'restore')" class="button button-primary" value="<?php esc_attr_e( 'Restore image' ); ?>" <?php echo $can_restore; ?> /> |
|
91 | + <input type="button" onclick="imageEdit.action(<?php echo "$post_id, '$nonce'"; ?>, 'restore')" class="button button-primary" value="<?php esc_attr_e('Restore image'); ?>" <?php echo $can_restore; ?> /> |
|
92 | 92 | </div> |
93 | 93 | </div> |
94 | 94 | </div> |
@@ -98,8 +98,8 @@ discard block |
||
98 | 98 | |
99 | 99 | <div class="imgedit-group"> |
100 | 100 | <div class="imgedit-group-top"> |
101 | - <h2><?php _e( 'Image Crop' ); ?></h2> |
|
102 | - <button type="button" class="dashicons dashicons-editor-help imgedit-help-toggle" onclick="imageEdit.toggleHelp(this);return false;" aria-expanded="false"><span class="screen-reader-text"><?php esc_html_e( 'Image Crop Help' ); ?></span></button> |
|
101 | + <h2><?php _e('Image Crop'); ?></h2> |
|
102 | + <button type="button" class="dashicons dashicons-editor-help imgedit-help-toggle" onclick="imageEdit.toggleHelp(this);return false;" aria-expanded="false"><span class="screen-reader-text"><?php esc_html_e('Image Crop Help'); ?></span></button> |
|
103 | 103 | |
104 | 104 | <div class="imgedit-help"> |
105 | 105 | <p><?php _e('To crop the image, click on it and drag to make your selection.'); ?></p> |
@@ -113,26 +113,26 @@ discard block |
||
113 | 113 | </div> |
114 | 114 | |
115 | 115 | <fieldset class="imgedit-crop-ratio"> |
116 | - <legend><?php _e( 'Aspect ratio:' ); ?></legend> |
|
116 | + <legend><?php _e('Aspect ratio:'); ?></legend> |
|
117 | 117 | <div class="nowrap"> |
118 | - <label><span class="screen-reader-text"><?php _e( 'crop ratio width' ); ?></span> |
|
118 | + <label><span class="screen-reader-text"><?php _e('crop ratio width'); ?></span> |
|
119 | 119 | <input type="text" id="imgedit-crop-width-<?php echo $post_id; ?>" onkeyup="imageEdit.setRatioSelection(<?php echo $post_id; ?>, 0, this)" onblur="imageEdit.setRatioSelection(<?php echo $post_id; ?>, 0, this)" /> |
120 | 120 | </label> |
121 | 121 | <span class="imgedit-separator">:</span> |
122 | - <label><span class="screen-reader-text"><?php _e( 'crop ratio height' ); ?></span> |
|
122 | + <label><span class="screen-reader-text"><?php _e('crop ratio height'); ?></span> |
|
123 | 123 | <input type="text" id="imgedit-crop-height-<?php echo $post_id; ?>" onkeyup="imageEdit.setRatioSelection(<?php echo $post_id; ?>, 1, this)" onblur="imageEdit.setRatioSelection(<?php echo $post_id; ?>, 1, this)" /> |
124 | 124 | </label> |
125 | 125 | </div> |
126 | 126 | </fieldset> |
127 | 127 | |
128 | 128 | <fieldset id="imgedit-crop-sel-<?php echo $post_id; ?>" class="imgedit-crop-sel"> |
129 | - <legend><?php _e( 'Selection:' ); ?></legend> |
|
129 | + <legend><?php _e('Selection:'); ?></legend> |
|
130 | 130 | <div class="nowrap"> |
131 | - <label><span class="screen-reader-text"><?php _e( 'selection width' ); ?></span> |
|
131 | + <label><span class="screen-reader-text"><?php _e('selection width'); ?></span> |
|
132 | 132 | <input type="text" id="imgedit-sel-width-<?php echo $post_id; ?>" onkeyup="imageEdit.setNumSelection(<?php echo $post_id; ?>, this)" onblur="imageEdit.setNumSelection(<?php echo $post_id; ?>, this)" /> |
133 | 133 | </label> |
134 | 134 | <span class="imgedit-separator">×</span> |
135 | - <label><span class="screen-reader-text"><?php _e( 'selection height' ); ?></span> |
|
135 | + <label><span class="screen-reader-text"><?php _e('selection height'); ?></span> |
|
136 | 136 | <input type="text" id="imgedit-sel-height-<?php echo $post_id; ?>" onkeyup="imageEdit.setNumSelection(<?php echo $post_id; ?>, this)" onblur="imageEdit.setNumSelection(<?php echo $post_id; ?>, this)" /> |
137 | 137 | </label> |
138 | 138 | </div> |
@@ -140,25 +140,25 @@ discard block |
||
140 | 140 | |
141 | 141 | </div> |
142 | 142 | |
143 | - <?php if ( $thumb && $sub_sizes ) { |
|
144 | - $thumb_img = wp_constrain_dimensions( $thumb['width'], $thumb['height'], 160, 120 ); |
|
143 | + <?php if ($thumb && $sub_sizes) { |
|
144 | + $thumb_img = wp_constrain_dimensions($thumb['width'], $thumb['height'], 160, 120); |
|
145 | 145 | ?> |
146 | 146 | |
147 | 147 | <div class="imgedit-group imgedit-applyto"> |
148 | 148 | <div class="imgedit-group-top"> |
149 | - <h2><?php _e( 'Thumbnail Settings' ); ?></h2> |
|
150 | - <button type="button" class="dashicons dashicons-editor-help imgedit-help-toggle" onclick="imageEdit.toggleHelp(this);return false;" aria-expanded="false"><span class="screen-reader-text"><?php esc_html_e( 'Thumbnail Settings Help' ); ?></span></button> |
|
149 | + <h2><?php _e('Thumbnail Settings'); ?></h2> |
|
150 | + <button type="button" class="dashicons dashicons-editor-help imgedit-help-toggle" onclick="imageEdit.toggleHelp(this);return false;" aria-expanded="false"><span class="screen-reader-text"><?php esc_html_e('Thumbnail Settings Help'); ?></span></button> |
|
151 | 151 | <p class="imgedit-help"><?php _e('You can edit the image while preserving the thumbnail. For example, you may wish to have a square thumbnail that displays just a section of the image.'); ?></p> |
152 | 152 | </div> |
153 | 153 | |
154 | 154 | <figure class="imgedit-thumbnail-preview"> |
155 | 155 | <img src="<?php echo $thumb['url']; ?>" width="<?php echo $thumb_img[0]; ?>" height="<?php echo $thumb_img[1]; ?>" class="imgedit-size-preview" alt="" draggable="false" /> |
156 | - <figcaption class="imgedit-thumbnail-preview-caption"><?php _e( 'Current thumbnail' ); ?></figcaption> |
|
156 | + <figcaption class="imgedit-thumbnail-preview-caption"><?php _e('Current thumbnail'); ?></figcaption> |
|
157 | 157 | </figure> |
158 | 158 | |
159 | 159 | <div id="imgedit-save-target-<?php echo $post_id; ?>" class="imgedit-save-target"> |
160 | 160 | <fieldset> |
161 | - <legend><strong><?php _e( 'Apply changes to:' ); ?></strong></legend> |
|
161 | + <legend><strong><?php _e('Apply changes to:'); ?></strong></legend> |
|
162 | 162 | |
163 | 163 | <label class="imgedit-label"> |
164 | 164 | <input type="radio" name="imgedit-target-<?php echo $post_id; ?>" value="all" checked="checked" /> |
@@ -182,26 +182,26 @@ discard block |
||
182 | 182 | <div class="imgedit-panel-content wp-clearfix"> |
183 | 183 | <?php echo $note; ?> |
184 | 184 | <div class="imgedit-menu wp-clearfix"> |
185 | - <button type="button" onclick="imageEdit.crop(<?php echo "$post_id, '$nonce'"; ?>, this)" class="imgedit-crop button disabled" disabled><span class="screen-reader-text"><?php esc_html_e( 'Crop' ); ?></span></button><?php |
|
185 | + <button type="button" onclick="imageEdit.crop(<?php echo "$post_id, '$nonce'"; ?>, this)" class="imgedit-crop button disabled" disabled><span class="screen-reader-text"><?php esc_html_e('Crop'); ?></span></button><?php |
|
186 | 186 | |
187 | 187 | // On some setups GD library does not provide imagerotate() - Ticket #11536 |
188 | - if ( wp_image_editor_supports( array( 'mime_type' => get_post_mime_type( $post_id ), 'methods' => array( 'rotate' ) ) ) ) { |
|
188 | + if (wp_image_editor_supports(array('mime_type' => get_post_mime_type($post_id), 'methods' => array('rotate')))) { |
|
189 | 189 | $note_no_rotate = ''; |
190 | 190 | ?> |
191 | - <button type="button" class="imgedit-rleft button" onclick="imageEdit.rotate( 90, <?php echo "$post_id, '$nonce'"; ?>, this)"><span class="screen-reader-text"><?php esc_html_e( 'Rotate counter-clockwise' ); ?></span></button> |
|
192 | - <button type="button" class="imgedit-rright button" onclick="imageEdit.rotate(-90, <?php echo "$post_id, '$nonce'"; ?>, this)"><span class="screen-reader-text"><?php esc_html_e( 'Rotate clockwise' ); ?></span></button> |
|
191 | + <button type="button" class="imgedit-rleft button" onclick="imageEdit.rotate( 90, <?php echo "$post_id, '$nonce'"; ?>, this)"><span class="screen-reader-text"><?php esc_html_e('Rotate counter-clockwise'); ?></span></button> |
|
192 | + <button type="button" class="imgedit-rright button" onclick="imageEdit.rotate(-90, <?php echo "$post_id, '$nonce'"; ?>, this)"><span class="screen-reader-text"><?php esc_html_e('Rotate clockwise'); ?></span></button> |
|
193 | 193 | <?php } else { |
194 | - $note_no_rotate = '<p class="note-no-rotate"><em>' . __( 'Image rotation is not supported by your web host.' ) . '</em></p>'; |
|
194 | + $note_no_rotate = '<p class="note-no-rotate"><em>'.__('Image rotation is not supported by your web host.').'</em></p>'; |
|
195 | 195 | ?> |
196 | 196 | <button type="button" class="imgedit-rleft button disabled" disabled></button> |
197 | 197 | <button type="button" class="imgedit-rright button disabled" disabled></button> |
198 | 198 | <?php } ?> |
199 | 199 | |
200 | - <button type="button" onclick="imageEdit.flip(1, <?php echo "$post_id, '$nonce'"; ?>, this)" class="imgedit-flipv button"><span class="screen-reader-text"><?php esc_html_e( 'Flip vertically' ); ?></span></button> |
|
201 | - <button type="button" onclick="imageEdit.flip(2, <?php echo "$post_id, '$nonce'"; ?>, this)" class="imgedit-fliph button"><span class="screen-reader-text"><?php esc_html_e( 'Flip horizontally' ); ?></span></button> |
|
200 | + <button type="button" onclick="imageEdit.flip(1, <?php echo "$post_id, '$nonce'"; ?>, this)" class="imgedit-flipv button"><span class="screen-reader-text"><?php esc_html_e('Flip vertically'); ?></span></button> |
|
201 | + <button type="button" onclick="imageEdit.flip(2, <?php echo "$post_id, '$nonce'"; ?>, this)" class="imgedit-fliph button"><span class="screen-reader-text"><?php esc_html_e('Flip horizontally'); ?></span></button> |
|
202 | 202 | |
203 | - <button type="button" id="image-undo-<?php echo $post_id; ?>" onclick="imageEdit.undo(<?php echo "$post_id, '$nonce'"; ?>, this)" class="imgedit-undo button disabled" disabled><span class="screen-reader-text"><?php esc_html_e( 'Undo' ); ?></span></button> |
|
204 | - <button type="button" id="image-redo-<?php echo $post_id; ?>" onclick="imageEdit.redo(<?php echo "$post_id, '$nonce'"; ?>, this)" class="imgedit-redo button disabled" disabled><span class="screen-reader-text"><?php esc_html_e( 'Redo' ); ?></span></button> |
|
203 | + <button type="button" id="image-undo-<?php echo $post_id; ?>" onclick="imageEdit.undo(<?php echo "$post_id, '$nonce'"; ?>, this)" class="imgedit-undo button disabled" disabled><span class="screen-reader-text"><?php esc_html_e('Undo'); ?></span></button> |
|
204 | + <button type="button" id="image-redo-<?php echo $post_id; ?>" onclick="imageEdit.redo(<?php echo "$post_id, '$nonce'"; ?>, this)" class="imgedit-redo button disabled" disabled><span class="screen-reader-text"><?php esc_html_e('Redo'); ?></span></button> |
|
205 | 205 | <?php echo $note_no_rotate; ?> |
206 | 206 | </div> |
207 | 207 | |
@@ -209,16 +209,16 @@ discard block |
||
209 | 209 | <input type="hidden" id="imgedit-history-<?php echo $post_id; ?>" value="" /> |
210 | 210 | <input type="hidden" id="imgedit-undone-<?php echo $post_id; ?>" value="0" /> |
211 | 211 | <input type="hidden" id="imgedit-selection-<?php echo $post_id; ?>" value="" /> |
212 | - <input type="hidden" id="imgedit-x-<?php echo $post_id; ?>" value="<?php echo isset( $meta['width'] ) ? $meta['width'] : 0; ?>" /> |
|
213 | - <input type="hidden" id="imgedit-y-<?php echo $post_id; ?>" value="<?php echo isset( $meta['height'] ) ? $meta['height'] : 0; ?>" /> |
|
212 | + <input type="hidden" id="imgedit-x-<?php echo $post_id; ?>" value="<?php echo isset($meta['width']) ? $meta['width'] : 0; ?>" /> |
|
213 | + <input type="hidden" id="imgedit-y-<?php echo $post_id; ?>" value="<?php echo isset($meta['height']) ? $meta['height'] : 0; ?>" /> |
|
214 | 214 | |
215 | 215 | <div id="imgedit-crop-<?php echo $post_id; ?>" class="imgedit-crop-wrap"> |
216 | - <img id="image-preview-<?php echo $post_id; ?>" onload="imageEdit.imgLoaded('<?php echo $post_id; ?>')" src="<?php echo admin_url( 'admin-ajax.php', 'relative' ); ?>?action=imgedit-preview&_ajax_nonce=<?php echo $nonce; ?>&postid=<?php echo $post_id; ?>&rand=<?php echo rand(1, 99999); ?>" alt="" /> |
|
216 | + <img id="image-preview-<?php echo $post_id; ?>" onload="imageEdit.imgLoaded('<?php echo $post_id; ?>')" src="<?php echo admin_url('admin-ajax.php', 'relative'); ?>?action=imgedit-preview&_ajax_nonce=<?php echo $nonce; ?>&postid=<?php echo $post_id; ?>&rand=<?php echo rand(1, 99999); ?>" alt="" /> |
|
217 | 217 | </div> |
218 | 218 | |
219 | 219 | <div class="imgedit-submit"> |
220 | - <input type="button" onclick="imageEdit.close(<?php echo $post_id; ?>, 1)" class="button imgedit-cancel-btn" value="<?php esc_attr_e( 'Cancel' ); ?>" /> |
|
221 | - <input type="button" onclick="imageEdit.save(<?php echo "$post_id, '$nonce'"; ?>)" disabled="disabled" class="button button-primary imgedit-submit-btn" value="<?php esc_attr_e( 'Save' ); ?>" /> |
|
220 | + <input type="button" onclick="imageEdit.close(<?php echo $post_id; ?>, 1)" class="button imgedit-cancel-btn" value="<?php esc_attr_e('Cancel'); ?>" /> |
|
221 | + <input type="button" onclick="imageEdit.save(<?php echo "$post_id, '$nonce'"; ?>)" disabled="disabled" class="button button-primary imgedit-submit-btn" value="<?php esc_attr_e('Save'); ?>" /> |
|
222 | 222 | </div> |
223 | 223 | </div> |
224 | 224 | |
@@ -238,8 +238,8 @@ discard block |
||
238 | 238 | * @param int $post_id |
239 | 239 | * @return bool |
240 | 240 | */ |
241 | -function wp_stream_image( $image, $mime_type, $post_id ) { |
|
242 | - if ( $image instanceof WP_Image_Editor ) { |
|
241 | +function wp_stream_image($image, $mime_type, $post_id) { |
|
242 | + if ($image instanceof WP_Image_Editor) { |
|
243 | 243 | |
244 | 244 | /** |
245 | 245 | * Filters the WP_Image_Editor instance for the image to be streamed to the browser. |
@@ -249,14 +249,14 @@ discard block |
||
249 | 249 | * @param WP_Image_Editor $image WP_Image_Editor instance. |
250 | 250 | * @param int $post_id Post ID. |
251 | 251 | */ |
252 | - $image = apply_filters( 'image_editor_save_pre', $image, $post_id ); |
|
252 | + $image = apply_filters('image_editor_save_pre', $image, $post_id); |
|
253 | 253 | |
254 | - if ( is_wp_error( $image->stream( $mime_type ) ) ) |
|
254 | + if (is_wp_error($image->stream($mime_type))) |
|
255 | 255 | return false; |
256 | 256 | |
257 | 257 | return true; |
258 | 258 | } else { |
259 | - _deprecated_argument( __FUNCTION__, '3.5.0', __( '$image needs to be an WP_Image_Editor object' ) ); |
|
259 | + _deprecated_argument(__FUNCTION__, '3.5.0', __('$image needs to be an WP_Image_Editor object')); |
|
260 | 260 | |
261 | 261 | /** |
262 | 262 | * Filters the GD image resource to be streamed to the browser. |
@@ -267,18 +267,18 @@ discard block |
||
267 | 267 | * @param resource $image Image resource to be streamed. |
268 | 268 | * @param int $post_id Post ID. |
269 | 269 | */ |
270 | - $image = apply_filters( 'image_save_pre', $image, $post_id ); |
|
270 | + $image = apply_filters('image_save_pre', $image, $post_id); |
|
271 | 271 | |
272 | - switch ( $mime_type ) { |
|
272 | + switch ($mime_type) { |
|
273 | 273 | case 'image/jpeg': |
274 | - header( 'Content-Type: image/jpeg' ); |
|
275 | - return imagejpeg( $image, null, 90 ); |
|
274 | + header('Content-Type: image/jpeg'); |
|
275 | + return imagejpeg($image, null, 90); |
|
276 | 276 | case 'image/png': |
277 | - header( 'Content-Type: image/png' ); |
|
278 | - return imagepng( $image ); |
|
277 | + header('Content-Type: image/png'); |
|
278 | + return imagepng($image); |
|
279 | 279 | case 'image/gif': |
280 | - header( 'Content-Type: image/gif' ); |
|
281 | - return imagegif( $image ); |
|
280 | + header('Content-Type: image/gif'); |
|
281 | + return imagegif($image); |
|
282 | 282 | default: |
283 | 283 | return false; |
284 | 284 | } |
@@ -294,11 +294,11 @@ discard block |
||
294 | 294 | * @param int $post_id |
295 | 295 | * @return bool |
296 | 296 | */ |
297 | -function wp_save_image_file( $filename, $image, $mime_type, $post_id ) { |
|
298 | - if ( $image instanceof WP_Image_Editor ) { |
|
297 | +function wp_save_image_file($filename, $image, $mime_type, $post_id) { |
|
298 | + if ($image instanceof WP_Image_Editor) { |
|
299 | 299 | |
300 | 300 | /** This filter is documented in wp-admin/includes/image-edit.php */ |
301 | - $image = apply_filters( 'image_editor_save_pre', $image, $post_id ); |
|
301 | + $image = apply_filters('image_editor_save_pre', $image, $post_id); |
|
302 | 302 | |
303 | 303 | /** |
304 | 304 | * Filters whether to skip saving the image file. |
@@ -314,17 +314,17 @@ discard block |
||
314 | 314 | * @param string $mime_type Image mime type. |
315 | 315 | * @param int $post_id Post ID. |
316 | 316 | */ |
317 | - $saved = apply_filters( 'wp_save_image_editor_file', null, $filename, $image, $mime_type, $post_id ); |
|
317 | + $saved = apply_filters('wp_save_image_editor_file', null, $filename, $image, $mime_type, $post_id); |
|
318 | 318 | |
319 | - if ( null !== $saved ) |
|
319 | + if (null !== $saved) |
|
320 | 320 | return $saved; |
321 | 321 | |
322 | - return $image->save( $filename, $mime_type ); |
|
322 | + return $image->save($filename, $mime_type); |
|
323 | 323 | } else { |
324 | - _deprecated_argument( __FUNCTION__, '3.5.0', __( '$image needs to be an WP_Image_Editor object' ) ); |
|
324 | + _deprecated_argument(__FUNCTION__, '3.5.0', __('$image needs to be an WP_Image_Editor object')); |
|
325 | 325 | |
326 | 326 | /** This filter is documented in wp-admin/includes/image-edit.php */ |
327 | - $image = apply_filters( 'image_save_pre', $image, $post_id ); |
|
327 | + $image = apply_filters('image_save_pre', $image, $post_id); |
|
328 | 328 | |
329 | 329 | /** |
330 | 330 | * Filters whether to skip saving the image file. |
@@ -341,20 +341,20 @@ discard block |
||
341 | 341 | * @param string $mime_type Image mime type. |
342 | 342 | * @param int $post_id Post ID. |
343 | 343 | */ |
344 | - $saved = apply_filters( 'wp_save_image_file', null, $filename, $image, $mime_type, $post_id ); |
|
344 | + $saved = apply_filters('wp_save_image_file', null, $filename, $image, $mime_type, $post_id); |
|
345 | 345 | |
346 | - if ( null !== $saved ) |
|
346 | + if (null !== $saved) |
|
347 | 347 | return $saved; |
348 | 348 | |
349 | - switch ( $mime_type ) { |
|
349 | + switch ($mime_type) { |
|
350 | 350 | case 'image/jpeg': |
351 | 351 | |
352 | 352 | /** This filter is documented in wp-includes/class-wp-image-editor.php */ |
353 | - return imagejpeg( $image, $filename, apply_filters( 'jpeg_quality', 90, 'edit_image' ) ); |
|
353 | + return imagejpeg($image, $filename, apply_filters('jpeg_quality', 90, 'edit_image')); |
|
354 | 354 | case 'image/png': |
355 | - return imagepng( $image, $filename ); |
|
355 | + return imagepng($image, $filename); |
|
356 | 356 | case 'image/gif': |
357 | - return imagegif( $image, $filename ); |
|
357 | + return imagegif($image, $filename); |
|
358 | 358 | default: |
359 | 359 | return false; |
360 | 360 | } |
@@ -387,10 +387,10 @@ discard block |
||
387 | 387 | * @return resource|false GD image resource, false otherwise. |
388 | 388 | */ |
389 | 389 | function _rotate_image_resource($img, $angle) { |
390 | - _deprecated_function( __FUNCTION__, '3.5.0', 'WP_Image_Editor::rotate()' ); |
|
391 | - if ( function_exists('imagerotate') ) { |
|
390 | + _deprecated_function(__FUNCTION__, '3.5.0', 'WP_Image_Editor::rotate()'); |
|
391 | + if (function_exists('imagerotate')) { |
|
392 | 392 | $rotated = imagerotate($img, $angle, 0); |
393 | - if ( is_resource($rotated) ) { |
|
393 | + if (is_resource($rotated)) { |
|
394 | 394 | imagedestroy($img); |
395 | 395 | $img = $rotated; |
396 | 396 | } |
@@ -410,17 +410,17 @@ discard block |
||
410 | 410 | * @return resource (maybe) flipped image resource. |
411 | 411 | */ |
412 | 412 | function _flip_image_resource($img, $horz, $vert) { |
413 | - _deprecated_function( __FUNCTION__, '3.5.0', 'WP_Image_Editor::flip()' ); |
|
413 | + _deprecated_function(__FUNCTION__, '3.5.0', 'WP_Image_Editor::flip()'); |
|
414 | 414 | $w = imagesx($img); |
415 | 415 | $h = imagesy($img); |
416 | 416 | $dst = wp_imagecreatetruecolor($w, $h); |
417 | - if ( is_resource($dst) ) { |
|
417 | + if (is_resource($dst)) { |
|
418 | 418 | $sx = $vert ? ($w - 1) : 0; |
419 | 419 | $sy = $horz ? ($h - 1) : 0; |
420 | 420 | $sw = $vert ? -$w : $w; |
421 | 421 | $sh = $horz ? -$h : $h; |
422 | 422 | |
423 | - if ( imagecopyresampled($dst, $img, 0, 0, $sx, $sy, $w, $h, $sw, $sh) ) { |
|
423 | + if (imagecopyresampled($dst, $img, 0, 0, $sx, $sy, $w, $h, $sw, $sh)) { |
|
424 | 424 | imagedestroy($img); |
425 | 425 | $img = $dst; |
426 | 426 | } |
@@ -443,8 +443,8 @@ discard block |
||
443 | 443 | */ |
444 | 444 | function _crop_image_resource($img, $x, $y, $w, $h) { |
445 | 445 | $dst = wp_imagecreatetruecolor($w, $h); |
446 | - if ( is_resource($dst) ) { |
|
447 | - if ( imagecopy($dst, $img, 0, 0, $x, $y, $w, $h) ) { |
|
446 | + if (is_resource($dst)) { |
|
447 | + if (imagecopy($dst, $img, 0, 0, $x, $y, $w, $h)) { |
|
448 | 448 | imagedestroy($img); |
449 | 449 | $img = $dst; |
450 | 450 | } |
@@ -461,24 +461,24 @@ discard block |
||
461 | 461 | * @param array $changes Array of change operations. |
462 | 462 | * @return WP_Image_Editor WP_Image_Editor instance with changes applied. |
463 | 463 | */ |
464 | -function image_edit_apply_changes( $image, $changes ) { |
|
465 | - if ( is_resource( $image ) ) |
|
466 | - _deprecated_argument( __FUNCTION__, '3.5.0', __( '$image needs to be an WP_Image_Editor object' ) ); |
|
464 | +function image_edit_apply_changes($image, $changes) { |
|
465 | + if (is_resource($image)) |
|
466 | + _deprecated_argument(__FUNCTION__, '3.5.0', __('$image needs to be an WP_Image_Editor object')); |
|
467 | 467 | |
468 | - if ( !is_array($changes) ) |
|
468 | + if ( ! is_array($changes)) |
|
469 | 469 | return $image; |
470 | 470 | |
471 | 471 | // Expand change operations. |
472 | - foreach ( $changes as $key => $obj ) { |
|
473 | - if ( isset($obj->r) ) { |
|
472 | + foreach ($changes as $key => $obj) { |
|
473 | + if (isset($obj->r)) { |
|
474 | 474 | $obj->type = 'rotate'; |
475 | 475 | $obj->angle = $obj->r; |
476 | 476 | unset($obj->r); |
477 | - } elseif ( isset($obj->f) ) { |
|
477 | + } elseif (isset($obj->f)) { |
|
478 | 478 | $obj->type = 'flip'; |
479 | 479 | $obj->axis = $obj->f; |
480 | 480 | unset($obj->f); |
481 | - } elseif ( isset($obj->c) ) { |
|
481 | + } elseif (isset($obj->c)) { |
|
482 | 482 | $obj->type = 'crop'; |
483 | 483 | $obj->sel = $obj->c; |
484 | 484 | unset($obj->c); |
@@ -487,12 +487,12 @@ discard block |
||
487 | 487 | } |
488 | 488 | |
489 | 489 | // Combine operations. |
490 | - if ( count($changes) > 1 ) { |
|
490 | + if (count($changes) > 1) { |
|
491 | 491 | $filtered = array($changes[0]); |
492 | - for ( $i = 0, $j = 1, $c = count( $changes ); $j < $c; $j++ ) { |
|
492 | + for ($i = 0, $j = 1, $c = count($changes); $j < $c; $j++) { |
|
493 | 493 | $combined = false; |
494 | - if ( $filtered[$i]->type == $changes[$j]->type ) { |
|
495 | - switch ( $filtered[$i]->type ) { |
|
494 | + if ($filtered[$i]->type == $changes[$j]->type) { |
|
495 | + switch ($filtered[$i]->type) { |
|
496 | 496 | case 'rotate': |
497 | 497 | $filtered[$i]->angle += $changes[$j]->angle; |
498 | 498 | $combined = true; |
@@ -503,7 +503,7 @@ discard block |
||
503 | 503 | break; |
504 | 504 | } |
505 | 505 | } |
506 | - if ( !$combined ) |
|
506 | + if ( ! $combined) |
|
507 | 507 | $filtered[++$i] = $changes[$j]; |
508 | 508 | } |
509 | 509 | $changes = $filtered; |
@@ -511,7 +511,7 @@ discard block |
||
511 | 511 | } |
512 | 512 | |
513 | 513 | // Image resource before applying the changes. |
514 | - if ( $image instanceof WP_Image_Editor ) { |
|
514 | + if ($image instanceof WP_Image_Editor) { |
|
515 | 515 | |
516 | 516 | /** |
517 | 517 | * Filters the WP_Image_Editor instance before applying changes to the image. |
@@ -521,8 +521,8 @@ discard block |
||
521 | 521 | * @param WP_Image_Editor $image WP_Image_Editor instance. |
522 | 522 | * @param array $changes Array of change operations. |
523 | 523 | */ |
524 | - $image = apply_filters( 'wp_image_editor_before_change', $image, $changes ); |
|
525 | - } elseif ( is_resource( $image ) ) { |
|
524 | + $image = apply_filters('wp_image_editor_before_change', $image, $changes); |
|
525 | + } elseif (is_resource($image)) { |
|
526 | 526 | |
527 | 527 | /** |
528 | 528 | * Filters the GD image resource before applying changes to the image. |
@@ -533,39 +533,39 @@ discard block |
||
533 | 533 | * @param resource $image GD image resource. |
534 | 534 | * @param array $changes Array of change operations. |
535 | 535 | */ |
536 | - $image = apply_filters( 'image_edit_before_change', $image, $changes ); |
|
536 | + $image = apply_filters('image_edit_before_change', $image, $changes); |
|
537 | 537 | } |
538 | 538 | |
539 | - foreach ( $changes as $operation ) { |
|
540 | - switch ( $operation->type ) { |
|
539 | + foreach ($changes as $operation) { |
|
540 | + switch ($operation->type) { |
|
541 | 541 | case 'rotate': |
542 | - if ( $operation->angle != 0 ) { |
|
543 | - if ( $image instanceof WP_Image_Editor ) |
|
544 | - $image->rotate( $operation->angle ); |
|
542 | + if ($operation->angle != 0) { |
|
543 | + if ($image instanceof WP_Image_Editor) |
|
544 | + $image->rotate($operation->angle); |
|
545 | 545 | else |
546 | - $image = _rotate_image_resource( $image, $operation->angle ); |
|
546 | + $image = _rotate_image_resource($image, $operation->angle); |
|
547 | 547 | } |
548 | 548 | break; |
549 | 549 | case 'flip': |
550 | - if ( $operation->axis != 0 ) |
|
551 | - if ( $image instanceof WP_Image_Editor ) |
|
552 | - $image->flip( ($operation->axis & 1) != 0, ($operation->axis & 2) != 0 ); |
|
550 | + if ($operation->axis != 0) |
|
551 | + if ($image instanceof WP_Image_Editor) |
|
552 | + $image->flip(($operation->axis & 1) != 0, ($operation->axis & 2) != 0); |
|
553 | 553 | else |
554 | - $image = _flip_image_resource( $image, ( $operation->axis & 1 ) != 0, ( $operation->axis & 2 ) != 0 ); |
|
554 | + $image = _flip_image_resource($image, ($operation->axis & 1) != 0, ($operation->axis & 2) != 0); |
|
555 | 555 | break; |
556 | 556 | case 'crop': |
557 | 557 | $sel = $operation->sel; |
558 | 558 | |
559 | - if ( $image instanceof WP_Image_Editor ) { |
|
559 | + if ($image instanceof WP_Image_Editor) { |
|
560 | 560 | $size = $image->get_size(); |
561 | 561 | $w = $size['width']; |
562 | 562 | $h = $size['height']; |
563 | 563 | |
564 | - $scale = 1 / _image_get_preview_ratio( $w, $h ); // discard preview scaling |
|
565 | - $image->crop( $sel->x * $scale, $sel->y * $scale, $sel->w * $scale, $sel->h * $scale ); |
|
564 | + $scale = 1 / _image_get_preview_ratio($w, $h); // discard preview scaling |
|
565 | + $image->crop($sel->x * $scale, $sel->y * $scale, $sel->w * $scale, $sel->h * $scale); |
|
566 | 566 | } else { |
567 | - $scale = 1 / _image_get_preview_ratio( imagesx( $image ), imagesy( $image ) ); // discard preview scaling |
|
568 | - $image = _crop_image_resource( $image, $sel->x * $scale, $sel->y * $scale, $sel->w * $scale, $sel->h * $scale ); |
|
567 | + $scale = 1 / _image_get_preview_ratio(imagesx($image), imagesy($image)); // discard preview scaling |
|
568 | + $image = _crop_image_resource($image, $sel->x * $scale, $sel->y * $scale, $sel->w * $scale, $sel->h * $scale); |
|
569 | 569 | } |
570 | 570 | break; |
571 | 571 | } |
@@ -582,34 +582,34 @@ discard block |
||
582 | 582 | * @param int $post_id |
583 | 583 | * @return bool |
584 | 584 | */ |
585 | -function stream_preview_image( $post_id ) { |
|
586 | - $post = get_post( $post_id ); |
|
585 | +function stream_preview_image($post_id) { |
|
586 | + $post = get_post($post_id); |
|
587 | 587 | |
588 | - wp_raise_memory_limit( 'admin' ); |
|
588 | + wp_raise_memory_limit('admin'); |
|
589 | 589 | |
590 | - $img = wp_get_image_editor( _load_image_to_edit_path( $post_id ) ); |
|
590 | + $img = wp_get_image_editor(_load_image_to_edit_path($post_id)); |
|
591 | 591 | |
592 | - if ( is_wp_error( $img ) ) { |
|
592 | + if (is_wp_error($img)) { |
|
593 | 593 | return false; |
594 | 594 | } |
595 | 595 | |
596 | - $changes = !empty($_REQUEST['history']) ? json_decode( wp_unslash($_REQUEST['history']) ) : null; |
|
597 | - if ( $changes ) |
|
598 | - $img = image_edit_apply_changes( $img, $changes ); |
|
596 | + $changes = ! empty($_REQUEST['history']) ? json_decode(wp_unslash($_REQUEST['history'])) : null; |
|
597 | + if ($changes) |
|
598 | + $img = image_edit_apply_changes($img, $changes); |
|
599 | 599 | |
600 | 600 | // Scale the image. |
601 | 601 | $size = $img->get_size(); |
602 | 602 | $w = $size['width']; |
603 | 603 | $h = $size['height']; |
604 | 604 | |
605 | - $ratio = _image_get_preview_ratio( $w, $h ); |
|
606 | - $w2 = max ( 1, $w * $ratio ); |
|
607 | - $h2 = max ( 1, $h * $ratio ); |
|
605 | + $ratio = _image_get_preview_ratio($w, $h); |
|
606 | + $w2 = max(1, $w * $ratio); |
|
607 | + $h2 = max(1, $h * $ratio); |
|
608 | 608 | |
609 | - if ( is_wp_error( $img->resize( $w2, $h2 ) ) ) |
|
609 | + if (is_wp_error($img->resize($w2, $h2))) |
|
610 | 610 | return false; |
611 | 611 | |
612 | - return wp_stream_image( $img, $post->post_mime_type, $post_id ); |
|
612 | + return wp_stream_image($img, $post->post_mime_type, $post_id); |
|
613 | 613 | } |
614 | 614 | |
615 | 615 | /** |
@@ -623,30 +623,30 @@ discard block |
||
623 | 623 | function wp_restore_image($post_id) { |
624 | 624 | $meta = wp_get_attachment_metadata($post_id); |
625 | 625 | $file = get_attached_file($post_id); |
626 | - $backup_sizes = $old_backup_sizes = get_post_meta( $post_id, '_wp_attachment_backup_sizes', true ); |
|
626 | + $backup_sizes = $old_backup_sizes = get_post_meta($post_id, '_wp_attachment_backup_sizes', true); |
|
627 | 627 | $restored = false; |
628 | 628 | $msg = new stdClass; |
629 | 629 | |
630 | - if ( !is_array($backup_sizes) ) { |
|
630 | + if ( ! is_array($backup_sizes)) { |
|
631 | 631 | $msg->error = __('Cannot load image metadata.'); |
632 | 632 | return $msg; |
633 | 633 | } |
634 | 634 | |
635 | 635 | $parts = pathinfo($file); |
636 | - $suffix = time() . rand(100, 999); |
|
636 | + $suffix = time().rand(100, 999); |
|
637 | 637 | $default_sizes = get_intermediate_image_sizes(); |
638 | 638 | |
639 | - if ( isset($backup_sizes['full-orig']) && is_array($backup_sizes['full-orig']) ) { |
|
639 | + if (isset($backup_sizes['full-orig']) && is_array($backup_sizes['full-orig'])) { |
|
640 | 640 | $data = $backup_sizes['full-orig']; |
641 | 641 | |
642 | - if ( $parts['basename'] != $data['file'] ) { |
|
643 | - if ( defined('IMAGE_EDIT_OVERWRITE') && IMAGE_EDIT_OVERWRITE ) { |
|
642 | + if ($parts['basename'] != $data['file']) { |
|
643 | + if (defined('IMAGE_EDIT_OVERWRITE') && IMAGE_EDIT_OVERWRITE) { |
|
644 | 644 | |
645 | 645 | // Delete only if it's an edited image. |
646 | - if ( preg_match('/-e[0-9]{13}\./', $parts['basename']) ) { |
|
647 | - wp_delete_file( $file ); |
|
646 | + if (preg_match('/-e[0-9]{13}\./', $parts['basename'])) { |
|
647 | + wp_delete_file($file); |
|
648 | 648 | } |
649 | - } elseif ( isset( $meta['width'], $meta['height'] ) ) { |
|
649 | + } elseif (isset($meta['width'], $meta['height'])) { |
|
650 | 650 | $backup_sizes["full-$suffix"] = array('width' => $meta['width'], 'height' => $meta['height'], 'file' => $parts['basename']); |
651 | 651 | } |
652 | 652 | } |
@@ -654,21 +654,21 @@ discard block |
||
654 | 654 | $restored_file = path_join($parts['dirname'], $data['file']); |
655 | 655 | $restored = update_attached_file($post_id, $restored_file); |
656 | 656 | |
657 | - $meta['file'] = _wp_relative_upload_path( $restored_file ); |
|
657 | + $meta['file'] = _wp_relative_upload_path($restored_file); |
|
658 | 658 | $meta['width'] = $data['width']; |
659 | 659 | $meta['height'] = $data['height']; |
660 | 660 | } |
661 | 661 | |
662 | - foreach ( $default_sizes as $default_size ) { |
|
663 | - if ( isset($backup_sizes["$default_size-orig"]) ) { |
|
662 | + foreach ($default_sizes as $default_size) { |
|
663 | + if (isset($backup_sizes["$default_size-orig"])) { |
|
664 | 664 | $data = $backup_sizes["$default_size-orig"]; |
665 | - if ( isset($meta['sizes'][$default_size]) && $meta['sizes'][$default_size]['file'] != $data['file'] ) { |
|
666 | - if ( defined('IMAGE_EDIT_OVERWRITE') && IMAGE_EDIT_OVERWRITE ) { |
|
665 | + if (isset($meta['sizes'][$default_size]) && $meta['sizes'][$default_size]['file'] != $data['file']) { |
|
666 | + if (defined('IMAGE_EDIT_OVERWRITE') && IMAGE_EDIT_OVERWRITE) { |
|
667 | 667 | |
668 | 668 | // Delete only if it's an edited image. |
669 | - if ( preg_match('/-e[0-9]{13}-/', $meta['sizes'][$default_size]['file']) ) { |
|
670 | - $delete_file = path_join( $parts['dirname'], $meta['sizes'][$default_size]['file'] ); |
|
671 | - wp_delete_file( $delete_file ); |
|
669 | + if (preg_match('/-e[0-9]{13}-/', $meta['sizes'][$default_size]['file'])) { |
|
670 | + $delete_file = path_join($parts['dirname'], $meta['sizes'][$default_size]['file']); |
|
671 | + wp_delete_file($delete_file); |
|
672 | 672 | } |
673 | 673 | } else { |
674 | 674 | $backup_sizes["$default_size-{$suffix}"] = $meta['sizes'][$default_size]; |
@@ -681,14 +681,14 @@ discard block |
||
681 | 681 | } |
682 | 682 | } |
683 | 683 | |
684 | - if ( ! wp_update_attachment_metadata( $post_id, $meta ) || |
|
685 | - ( $old_backup_sizes !== $backup_sizes && ! update_post_meta( $post_id, '_wp_attachment_backup_sizes', $backup_sizes ) ) ) { |
|
684 | + if ( ! wp_update_attachment_metadata($post_id, $meta) || |
|
685 | + ($old_backup_sizes !== $backup_sizes && ! update_post_meta($post_id, '_wp_attachment_backup_sizes', $backup_sizes))) { |
|
686 | 686 | |
687 | 687 | $msg->error = __('Cannot save image metadata.'); |
688 | 688 | return $msg; |
689 | 689 | } |
690 | 690 | |
691 | - if ( !$restored ) |
|
691 | + if ( ! $restored) |
|
692 | 692 | $msg->error = __('Image metadata is inconsistent.'); |
693 | 693 | else |
694 | 694 | $msg->msg = __('Image restored successfully.'); |
@@ -703,25 +703,25 @@ discard block |
||
703 | 703 | * @param int $post_id |
704 | 704 | * @return \stdClass |
705 | 705 | */ |
706 | -function wp_save_image( $post_id ) { |
|
706 | +function wp_save_image($post_id) { |
|
707 | 707 | $_wp_additional_image_sizes = wp_get_additional_image_sizes(); |
708 | 708 | |
709 | 709 | $return = new stdClass; |
710 | 710 | $success = $delete = $scaled = $nocrop = false; |
711 | - $post = get_post( $post_id ); |
|
711 | + $post = get_post($post_id); |
|
712 | 712 | |
713 | - $img = wp_get_image_editor( _load_image_to_edit_path( $post_id, 'full' ) ); |
|
714 | - if ( is_wp_error( $img ) ) { |
|
715 | - $return->error = esc_js( __('Unable to create new image.') ); |
|
713 | + $img = wp_get_image_editor(_load_image_to_edit_path($post_id, 'full')); |
|
714 | + if (is_wp_error($img)) { |
|
715 | + $return->error = esc_js(__('Unable to create new image.')); |
|
716 | 716 | return $return; |
717 | 717 | } |
718 | 718 | |
719 | - $fwidth = !empty($_REQUEST['fwidth']) ? intval($_REQUEST['fwidth']) : 0; |
|
720 | - $fheight = !empty($_REQUEST['fheight']) ? intval($_REQUEST['fheight']) : 0; |
|
721 | - $target = !empty($_REQUEST['target']) ? preg_replace('/[^a-z0-9_-]+/i', '', $_REQUEST['target']) : ''; |
|
722 | - $scale = !empty($_REQUEST['do']) && 'scale' == $_REQUEST['do']; |
|
719 | + $fwidth = ! empty($_REQUEST['fwidth']) ? intval($_REQUEST['fwidth']) : 0; |
|
720 | + $fheight = ! empty($_REQUEST['fheight']) ? intval($_REQUEST['fheight']) : 0; |
|
721 | + $target = ! empty($_REQUEST['target']) ? preg_replace('/[^a-z0-9_-]+/i', '', $_REQUEST['target']) : ''; |
|
722 | + $scale = ! empty($_REQUEST['do']) && 'scale' == $_REQUEST['do']; |
|
723 | 723 | |
724 | - if ( $scale && $fwidth > 0 && $fheight > 0 ) { |
|
724 | + if ($scale && $fwidth > 0 && $fheight > 0) { |
|
725 | 725 | $size = $img->get_size(); |
726 | 726 | $sX = $size['width']; |
727 | 727 | $sY = $size['height']; |
@@ -730,58 +730,58 @@ discard block |
||
730 | 730 | $diff = round($sX / $sY, 2) - round($fwidth / $fheight, 2); |
731 | 731 | if ( -0.1 < $diff && $diff < 0.1 ) { |
732 | 732 | // Scale the full size image. |
733 | - if ( $img->resize( $fwidth, $fheight ) ) |
|
733 | + if ($img->resize($fwidth, $fheight)) |
|
734 | 734 | $scaled = true; |
735 | 735 | } |
736 | 736 | |
737 | - if ( !$scaled ) { |
|
738 | - $return->error = esc_js( __('Error while saving the scaled image. Please reload the page and try again.') ); |
|
737 | + if ( ! $scaled) { |
|
738 | + $return->error = esc_js(__('Error while saving the scaled image. Please reload the page and try again.')); |
|
739 | 739 | return $return; |
740 | 740 | } |
741 | - } elseif ( !empty($_REQUEST['history']) ) { |
|
742 | - $changes = json_decode( wp_unslash($_REQUEST['history']) ); |
|
743 | - if ( $changes ) |
|
741 | + } elseif ( ! empty($_REQUEST['history'])) { |
|
742 | + $changes = json_decode(wp_unslash($_REQUEST['history'])); |
|
743 | + if ($changes) |
|
744 | 744 | $img = image_edit_apply_changes($img, $changes); |
745 | 745 | } else { |
746 | - $return->error = esc_js( __('Nothing to save, the image has not changed.') ); |
|
746 | + $return->error = esc_js(__('Nothing to save, the image has not changed.')); |
|
747 | 747 | return $return; |
748 | 748 | } |
749 | 749 | |
750 | 750 | $meta = wp_get_attachment_metadata($post_id); |
751 | - $backup_sizes = get_post_meta( $post->ID, '_wp_attachment_backup_sizes', true ); |
|
751 | + $backup_sizes = get_post_meta($post->ID, '_wp_attachment_backup_sizes', true); |
|
752 | 752 | |
753 | - if ( !is_array($meta) ) { |
|
754 | - $return->error = esc_js( __('Image data does not exist. Please re-upload the image.') ); |
|
753 | + if ( ! is_array($meta)) { |
|
754 | + $return->error = esc_js(__('Image data does not exist. Please re-upload the image.')); |
|
755 | 755 | return $return; |
756 | 756 | } |
757 | 757 | |
758 | - if ( !is_array($backup_sizes) ) |
|
758 | + if ( ! is_array($backup_sizes)) |
|
759 | 759 | $backup_sizes = array(); |
760 | 760 | |
761 | 761 | // Generate new filename. |
762 | - $path = get_attached_file( $post_id ); |
|
762 | + $path = get_attached_file($post_id); |
|
763 | 763 | |
764 | - $basename = pathinfo( $path, PATHINFO_BASENAME ); |
|
765 | - $dirname = pathinfo( $path, PATHINFO_DIRNAME ); |
|
766 | - $ext = pathinfo( $path, PATHINFO_EXTENSION ); |
|
767 | - $filename = pathinfo( $path, PATHINFO_FILENAME ); |
|
768 | - $suffix = time() . rand(100, 999); |
|
764 | + $basename = pathinfo($path, PATHINFO_BASENAME); |
|
765 | + $dirname = pathinfo($path, PATHINFO_DIRNAME); |
|
766 | + $ext = pathinfo($path, PATHINFO_EXTENSION); |
|
767 | + $filename = pathinfo($path, PATHINFO_FILENAME); |
|
768 | + $suffix = time().rand(100, 999); |
|
769 | 769 | |
770 | - if ( defined('IMAGE_EDIT_OVERWRITE') && IMAGE_EDIT_OVERWRITE && |
|
771 | - isset($backup_sizes['full-orig']) && $backup_sizes['full-orig']['file'] != $basename ) { |
|
770 | + if (defined('IMAGE_EDIT_OVERWRITE') && IMAGE_EDIT_OVERWRITE && |
|
771 | + isset($backup_sizes['full-orig']) && $backup_sizes['full-orig']['file'] != $basename) { |
|
772 | 772 | |
773 | - if ( 'thumbnail' == $target ) { |
|
773 | + if ('thumbnail' == $target) { |
|
774 | 774 | $new_path = "{$dirname}/{$filename}-temp.{$ext}"; |
775 | 775 | } else { |
776 | 776 | $new_path = $path; |
777 | 777 | } |
778 | 778 | } else { |
779 | - while ( true ) { |
|
780 | - $filename = preg_replace( '/-e([0-9]+)$/', '', $filename ); |
|
779 | + while (true) { |
|
780 | + $filename = preg_replace('/-e([0-9]+)$/', '', $filename); |
|
781 | 781 | $filename .= "-e{$suffix}"; |
782 | 782 | $new_filename = "{$filename}.{$ext}"; |
783 | 783 | $new_path = "{$dirname}/$new_filename"; |
784 | - if ( file_exists($new_path) ) { |
|
784 | + if (file_exists($new_path)) { |
|
785 | 785 | $suffix++; |
786 | 786 | } else { |
787 | 787 | break; |
@@ -790,42 +790,42 @@ discard block |
||
790 | 790 | } |
791 | 791 | |
792 | 792 | // Save the full-size file, also needed to create sub-sizes. |
793 | - if ( !wp_save_image_file($new_path, $img, $post->post_mime_type, $post_id) ) { |
|
794 | - $return->error = esc_js( __('Unable to save the image.') ); |
|
793 | + if ( ! wp_save_image_file($new_path, $img, $post->post_mime_type, $post_id)) { |
|
794 | + $return->error = esc_js(__('Unable to save the image.')); |
|
795 | 795 | return $return; |
796 | 796 | } |
797 | 797 | |
798 | - if ( 'nothumb' === $target || 'all' === $target || 'full' === $target || $scaled ) { |
|
798 | + if ('nothumb' === $target || 'all' === $target || 'full' === $target || $scaled) { |
|
799 | 799 | $tag = false; |
800 | - if ( isset( $backup_sizes['full-orig'] ) ) { |
|
801 | - if ( ( ! defined( 'IMAGE_EDIT_OVERWRITE' ) || ! IMAGE_EDIT_OVERWRITE ) && $backup_sizes['full-orig']['file'] !== $basename ) { |
|
800 | + if (isset($backup_sizes['full-orig'])) { |
|
801 | + if (( ! defined('IMAGE_EDIT_OVERWRITE') || ! IMAGE_EDIT_OVERWRITE) && $backup_sizes['full-orig']['file'] !== $basename) { |
|
802 | 802 | $tag = "full-$suffix"; |
803 | 803 | } |
804 | 804 | } else { |
805 | 805 | $tag = 'full-orig'; |
806 | 806 | } |
807 | 807 | |
808 | - if ( $tag ) { |
|
809 | - $backup_sizes[$tag] = array('width' => $meta['width'], 'height' => $meta['height'], 'file' => $basename ); |
|
808 | + if ($tag) { |
|
809 | + $backup_sizes[$tag] = array('width' => $meta['width'], 'height' => $meta['height'], 'file' => $basename); |
|
810 | 810 | } |
811 | - $success = ( $path === $new_path ) || update_attached_file( $post_id, $new_path ); |
|
811 | + $success = ($path === $new_path) || update_attached_file($post_id, $new_path); |
|
812 | 812 | |
813 | - $meta['file'] = _wp_relative_upload_path( $new_path ); |
|
813 | + $meta['file'] = _wp_relative_upload_path($new_path); |
|
814 | 814 | |
815 | 815 | $size = $img->get_size(); |
816 | 816 | $meta['width'] = $size['width']; |
817 | 817 | $meta['height'] = $size['height']; |
818 | 818 | |
819 | - if ( $success && ('nothumb' == $target || 'all' == $target) ) { |
|
819 | + if ($success && ('nothumb' == $target || 'all' == $target)) { |
|
820 | 820 | $sizes = get_intermediate_image_sizes(); |
821 | - if ( 'nothumb' == $target ) |
|
822 | - $sizes = array_diff( $sizes, array('thumbnail') ); |
|
821 | + if ('nothumb' == $target) |
|
822 | + $sizes = array_diff($sizes, array('thumbnail')); |
|
823 | 823 | } |
824 | 824 | |
825 | 825 | $return->fw = $meta['width']; |
826 | 826 | $return->fh = $meta['height']; |
827 | - } elseif ( 'thumbnail' == $target ) { |
|
828 | - $sizes = array( 'thumbnail' ); |
|
827 | + } elseif ('thumbnail' == $target) { |
|
828 | + $sizes = array('thumbnail'); |
|
829 | 829 | $success = $delete = $nocrop = true; |
830 | 830 | } |
831 | 831 | |
@@ -835,63 +835,63 @@ discard block |
||
835 | 835 | * keeping the new resized images from overwriting the existing image files. |
836 | 836 | * https://core.trac.wordpress.org/ticket/32171 |
837 | 837 | */ |
838 | - if ( defined( 'IMAGE_EDIT_OVERWRITE' ) && IMAGE_EDIT_OVERWRITE && ! empty( $meta['sizes'] ) ) { |
|
839 | - foreach ( $meta['sizes'] as $size ) { |
|
840 | - if ( ! empty( $size['file'] ) && preg_match( '/-e[0-9]{13}-/', $size['file'] ) ) { |
|
841 | - $delete_file = path_join( $dirname, $size['file'] ); |
|
842 | - wp_delete_file( $delete_file ); |
|
838 | + if (defined('IMAGE_EDIT_OVERWRITE') && IMAGE_EDIT_OVERWRITE && ! empty($meta['sizes'])) { |
|
839 | + foreach ($meta['sizes'] as $size) { |
|
840 | + if ( ! empty($size['file']) && preg_match('/-e[0-9]{13}-/', $size['file'])) { |
|
841 | + $delete_file = path_join($dirname, $size['file']); |
|
842 | + wp_delete_file($delete_file); |
|
843 | 843 | } |
844 | 844 | } |
845 | 845 | } |
846 | 846 | |
847 | - if ( isset( $sizes ) ) { |
|
847 | + if (isset($sizes)) { |
|
848 | 848 | $_sizes = array(); |
849 | 849 | |
850 | - foreach ( $sizes as $size ) { |
|
850 | + foreach ($sizes as $size) { |
|
851 | 851 | $tag = false; |
852 | - if ( isset( $meta['sizes'][$size] ) ) { |
|
853 | - if ( isset($backup_sizes["$size-orig"]) ) { |
|
854 | - if ( ( !defined('IMAGE_EDIT_OVERWRITE') || !IMAGE_EDIT_OVERWRITE ) && $backup_sizes["$size-orig"]['file'] != $meta['sizes'][$size]['file'] ) |
|
852 | + if (isset($meta['sizes'][$size])) { |
|
853 | + if (isset($backup_sizes["$size-orig"])) { |
|
854 | + if (( ! defined('IMAGE_EDIT_OVERWRITE') || ! IMAGE_EDIT_OVERWRITE) && $backup_sizes["$size-orig"]['file'] != $meta['sizes'][$size]['file']) |
|
855 | 855 | $tag = "$size-$suffix"; |
856 | 856 | } else { |
857 | 857 | $tag = "$size-orig"; |
858 | 858 | } |
859 | 859 | |
860 | - if ( $tag ) |
|
860 | + if ($tag) |
|
861 | 861 | $backup_sizes[$tag] = $meta['sizes'][$size]; |
862 | 862 | } |
863 | 863 | |
864 | - if ( isset( $_wp_additional_image_sizes[ $size ] ) ) { |
|
865 | - $width = intval( $_wp_additional_image_sizes[ $size ]['width'] ); |
|
866 | - $height = intval( $_wp_additional_image_sizes[ $size ]['height'] ); |
|
867 | - $crop = ( $nocrop ) ? false : $_wp_additional_image_sizes[ $size ]['crop']; |
|
864 | + if (isset($_wp_additional_image_sizes[$size])) { |
|
865 | + $width = intval($_wp_additional_image_sizes[$size]['width']); |
|
866 | + $height = intval($_wp_additional_image_sizes[$size]['height']); |
|
867 | + $crop = ($nocrop) ? false : $_wp_additional_image_sizes[$size]['crop']; |
|
868 | 868 | } else { |
869 | - $height = get_option( "{$size}_size_h" ); |
|
870 | - $width = get_option( "{$size}_size_w" ); |
|
871 | - $crop = ( $nocrop ) ? false : get_option( "{$size}_crop" ); |
|
869 | + $height = get_option("{$size}_size_h"); |
|
870 | + $width = get_option("{$size}_size_w"); |
|
871 | + $crop = ($nocrop) ? false : get_option("{$size}_crop"); |
|
872 | 872 | } |
873 | 873 | |
874 | - $_sizes[ $size ] = array( 'width' => $width, 'height' => $height, 'crop' => $crop ); |
|
874 | + $_sizes[$size] = array('width' => $width, 'height' => $height, 'crop' => $crop); |
|
875 | 875 | } |
876 | 876 | |
877 | - $meta['sizes'] = array_merge( $meta['sizes'], $img->multi_resize( $_sizes ) ); |
|
877 | + $meta['sizes'] = array_merge($meta['sizes'], $img->multi_resize($_sizes)); |
|
878 | 878 | } |
879 | 879 | |
880 | - unset( $img ); |
|
880 | + unset($img); |
|
881 | 881 | |
882 | - if ( $success ) { |
|
883 | - wp_update_attachment_metadata( $post_id, $meta ); |
|
884 | - update_post_meta( $post_id, '_wp_attachment_backup_sizes', $backup_sizes); |
|
882 | + if ($success) { |
|
883 | + wp_update_attachment_metadata($post_id, $meta); |
|
884 | + update_post_meta($post_id, '_wp_attachment_backup_sizes', $backup_sizes); |
|
885 | 885 | |
886 | - if ( $target == 'thumbnail' || $target == 'all' || $target == 'full' ) { |
|
886 | + if ($target == 'thumbnail' || $target == 'all' || $target == 'full') { |
|
887 | 887 | // Check if it's an image edit from attachment edit screen |
888 | - if ( ! empty( $_REQUEST['context'] ) && 'edit-attachment' == $_REQUEST['context'] ) { |
|
889 | - $thumb_url = wp_get_attachment_image_src( $post_id, array( 900, 600 ), true ); |
|
888 | + if ( ! empty($_REQUEST['context']) && 'edit-attachment' == $_REQUEST['context']) { |
|
889 | + $thumb_url = wp_get_attachment_image_src($post_id, array(900, 600), true); |
|
890 | 890 | $return->thumbnail = $thumb_url[0]; |
891 | 891 | } else { |
892 | 892 | $file_url = wp_get_attachment_url($post_id); |
893 | - if ( ! empty( $meta['sizes']['thumbnail'] ) && $thumb = $meta['sizes']['thumbnail'] ) { |
|
894 | - $return->thumbnail = path_join( dirname($file_url), $thumb['file'] ); |
|
893 | + if ( ! empty($meta['sizes']['thumbnail']) && $thumb = $meta['sizes']['thumbnail']) { |
|
894 | + $return->thumbnail = path_join(dirname($file_url), $thumb['file']); |
|
895 | 895 | } else { |
896 | 896 | $return->thumbnail = "$file_url?w=128&h=128"; |
897 | 897 | } |
@@ -901,10 +901,10 @@ discard block |
||
901 | 901 | $delete = true; |
902 | 902 | } |
903 | 903 | |
904 | - if ( $delete ) { |
|
905 | - wp_delete_file( $new_path ); |
|
904 | + if ($delete) { |
|
905 | + wp_delete_file($new_path); |
|
906 | 906 | } |
907 | 907 | |
908 | - $return->msg = esc_js( __('Image saved') ); |
|
908 | + $return->msg = esc_js(__('Image saved')); |
|
909 | 909 | return $return; |
910 | 910 | } |
@@ -20,23 +20,26 @@ discard block |
||
20 | 20 | $sub_sizes = isset($meta['sizes']) && is_array($meta['sizes']); |
21 | 21 | $note = ''; |
22 | 22 | |
23 | - if ( isset( $meta['width'], $meta['height'] ) ) |
|
24 | - $big = max( $meta['width'], $meta['height'] ); |
|
25 | - else |
|
26 | - die( __('Image data does not exist. Please re-upload the image.') ); |
|
23 | + if ( isset( $meta['width'], $meta['height'] ) ) { |
|
24 | + $big = max( $meta['width'], $meta['height'] ); |
|
25 | + } else { |
|
26 | + die( __('Image data does not exist. Please re-upload the image.') ); |
|
27 | + } |
|
27 | 28 | |
28 | 29 | $sizer = $big > 400 ? 400 / $big : 1; |
29 | 30 | |
30 | 31 | $backup_sizes = get_post_meta( $post_id, '_wp_attachment_backup_sizes', true ); |
31 | 32 | $can_restore = false; |
32 | - if ( ! empty( $backup_sizes ) && isset( $backup_sizes['full-orig'], $meta['file'] ) ) |
|
33 | - $can_restore = $backup_sizes['full-orig']['file'] != basename( $meta['file'] ); |
|
33 | + if ( ! empty( $backup_sizes ) && isset( $backup_sizes['full-orig'], $meta['file'] ) ) { |
|
34 | + $can_restore = $backup_sizes['full-orig']['file'] != basename( $meta['file'] ); |
|
35 | + } |
|
34 | 36 | |
35 | 37 | if ( $msg ) { |
36 | - if ( isset($msg->error) ) |
|
37 | - $note = "<div class='error'><p>$msg->error</p></div>"; |
|
38 | - elseif ( isset($msg->msg) ) |
|
39 | - $note = "<div class='updated'><p>$msg->msg</p></div>"; |
|
38 | + if ( isset($msg->error) ) { |
|
39 | + $note = "<div class='error'><p>$msg->error</p></div>"; |
|
40 | + } elseif ( isset($msg->msg) ) { |
|
41 | + $note = "<div class='updated'><p>$msg->msg</p></div>"; |
|
42 | + } |
|
40 | 43 | } |
41 | 44 | |
42 | 45 | ?> |
@@ -83,8 +86,9 @@ discard block |
||
83 | 86 | <div class="imgedit-help"> |
84 | 87 | <p><?php _e('Discard any changes and restore the original image.'); |
85 | 88 | |
86 | - if ( !defined('IMAGE_EDIT_OVERWRITE') || !IMAGE_EDIT_OVERWRITE ) |
|
87 | - echo ' '.__('Previously edited copies of the image will not be deleted.'); |
|
89 | + if ( !defined('IMAGE_EDIT_OVERWRITE') || !IMAGE_EDIT_OVERWRITE ) { |
|
90 | + echo ' '.__('Previously edited copies of the image will not be deleted.'); |
|
91 | + } |
|
88 | 92 | |
89 | 93 | ?></p> |
90 | 94 | <div class="imgedit-submit"> |
@@ -251,8 +255,9 @@ discard block |
||
251 | 255 | */ |
252 | 256 | $image = apply_filters( 'image_editor_save_pre', $image, $post_id ); |
253 | 257 | |
254 | - if ( is_wp_error( $image->stream( $mime_type ) ) ) |
|
255 | - return false; |
|
258 | + if ( is_wp_error( $image->stream( $mime_type ) ) ) { |
|
259 | + return false; |
|
260 | + } |
|
256 | 261 | |
257 | 262 | return true; |
258 | 263 | } else { |
@@ -316,8 +321,9 @@ discard block |
||
316 | 321 | */ |
317 | 322 | $saved = apply_filters( 'wp_save_image_editor_file', null, $filename, $image, $mime_type, $post_id ); |
318 | 323 | |
319 | - if ( null !== $saved ) |
|
320 | - return $saved; |
|
324 | + if ( null !== $saved ) { |
|
325 | + return $saved; |
|
326 | + } |
|
321 | 327 | |
322 | 328 | return $image->save( $filename, $mime_type ); |
323 | 329 | } else { |
@@ -343,8 +349,9 @@ discard block |
||
343 | 349 | */ |
344 | 350 | $saved = apply_filters( 'wp_save_image_file', null, $filename, $image, $mime_type, $post_id ); |
345 | 351 | |
346 | - if ( null !== $saved ) |
|
347 | - return $saved; |
|
352 | + if ( null !== $saved ) { |
|
353 | + return $saved; |
|
354 | + } |
|
348 | 355 | |
349 | 356 | switch ( $mime_type ) { |
350 | 357 | case 'image/jpeg': |
@@ -462,11 +469,13 @@ discard block |
||
462 | 469 | * @return WP_Image_Editor WP_Image_Editor instance with changes applied. |
463 | 470 | */ |
464 | 471 | function image_edit_apply_changes( $image, $changes ) { |
465 | - if ( is_resource( $image ) ) |
|
466 | - _deprecated_argument( __FUNCTION__, '3.5.0', __( '$image needs to be an WP_Image_Editor object' ) ); |
|
472 | + if ( is_resource( $image ) ) { |
|
473 | + _deprecated_argument( __FUNCTION__, '3.5.0', __( '$image needs to be an WP_Image_Editor object' ) ); |
|
474 | + } |
|
467 | 475 | |
468 | - if ( !is_array($changes) ) |
|
469 | - return $image; |
|
476 | + if ( !is_array($changes) ) { |
|
477 | + return $image; |
|
478 | + } |
|
470 | 479 | |
471 | 480 | // Expand change operations. |
472 | 481 | foreach ( $changes as $key => $obj ) { |
@@ -503,8 +512,9 @@ discard block |
||
503 | 512 | break; |
504 | 513 | } |
505 | 514 | } |
506 | - if ( !$combined ) |
|
507 | - $filtered[++$i] = $changes[$j]; |
|
515 | + if ( !$combined ) { |
|
516 | + $filtered[++$i] = $changes[$j]; |
|
517 | + } |
|
508 | 518 | } |
509 | 519 | $changes = $filtered; |
510 | 520 | unset($filtered); |
@@ -540,18 +550,20 @@ discard block |
||
540 | 550 | switch ( $operation->type ) { |
541 | 551 | case 'rotate': |
542 | 552 | if ( $operation->angle != 0 ) { |
543 | - if ( $image instanceof WP_Image_Editor ) |
|
544 | - $image->rotate( $operation->angle ); |
|
545 | - else |
|
546 | - $image = _rotate_image_resource( $image, $operation->angle ); |
|
553 | + if ( $image instanceof WP_Image_Editor ) { |
|
554 | + $image->rotate( $operation->angle ); |
|
555 | + } else { |
|
556 | + $image = _rotate_image_resource( $image, $operation->angle ); |
|
557 | + } |
|
547 | 558 | } |
548 | 559 | break; |
549 | 560 | case 'flip': |
550 | - if ( $operation->axis != 0 ) |
|
551 | - if ( $image instanceof WP_Image_Editor ) |
|
561 | + if ( $operation->axis != 0 ) { |
|
562 | + if ( $image instanceof WP_Image_Editor ) |
|
552 | 563 | $image->flip( ($operation->axis & 1) != 0, ($operation->axis & 2) != 0 ); |
553 | - else |
|
554 | - $image = _flip_image_resource( $image, ( $operation->axis & 1 ) != 0, ( $operation->axis & 2 ) != 0 ); |
|
564 | + } else { |
|
565 | + $image = _flip_image_resource( $image, ( $operation->axis & 1 ) != 0, ( $operation->axis & 2 ) != 0 ); |
|
566 | + } |
|
555 | 567 | break; |
556 | 568 | case 'crop': |
557 | 569 | $sel = $operation->sel; |
@@ -594,8 +606,9 @@ discard block |
||
594 | 606 | } |
595 | 607 | |
596 | 608 | $changes = !empty($_REQUEST['history']) ? json_decode( wp_unslash($_REQUEST['history']) ) : null; |
597 | - if ( $changes ) |
|
598 | - $img = image_edit_apply_changes( $img, $changes ); |
|
609 | + if ( $changes ) { |
|
610 | + $img = image_edit_apply_changes( $img, $changes ); |
|
611 | + } |
|
599 | 612 | |
600 | 613 | // Scale the image. |
601 | 614 | $size = $img->get_size(); |
@@ -606,8 +619,9 @@ discard block |
||
606 | 619 | $w2 = max ( 1, $w * $ratio ); |
607 | 620 | $h2 = max ( 1, $h * $ratio ); |
608 | 621 | |
609 | - if ( is_wp_error( $img->resize( $w2, $h2 ) ) ) |
|
610 | - return false; |
|
622 | + if ( is_wp_error( $img->resize( $w2, $h2 ) ) ) { |
|
623 | + return false; |
|
624 | + } |
|
611 | 625 | |
612 | 626 | return wp_stream_image( $img, $post->post_mime_type, $post_id ); |
613 | 627 | } |
@@ -688,10 +702,11 @@ discard block |
||
688 | 702 | return $msg; |
689 | 703 | } |
690 | 704 | |
691 | - if ( !$restored ) |
|
692 | - $msg->error = __('Image metadata is inconsistent.'); |
|
693 | - else |
|
694 | - $msg->msg = __('Image restored successfully.'); |
|
705 | + if ( !$restored ) { |
|
706 | + $msg->error = __('Image metadata is inconsistent.'); |
|
707 | + } else { |
|
708 | + $msg->msg = __('Image restored successfully.'); |
|
709 | + } |
|
695 | 710 | |
696 | 711 | return $msg; |
697 | 712 | } |
@@ -730,8 +745,9 @@ discard block |
||
730 | 745 | $diff = round($sX / $sY, 2) - round($fwidth / $fheight, 2); |
731 | 746 | if ( -0.1 < $diff && $diff < 0.1 ) { |
732 | 747 | // Scale the full size image. |
733 | - if ( $img->resize( $fwidth, $fheight ) ) |
|
734 | - $scaled = true; |
|
748 | + if ( $img->resize( $fwidth, $fheight ) ) { |
|
749 | + $scaled = true; |
|
750 | + } |
|
735 | 751 | } |
736 | 752 | |
737 | 753 | if ( !$scaled ) { |
@@ -740,8 +756,9 @@ discard block |
||
740 | 756 | } |
741 | 757 | } elseif ( !empty($_REQUEST['history']) ) { |
742 | 758 | $changes = json_decode( wp_unslash($_REQUEST['history']) ); |
743 | - if ( $changes ) |
|
744 | - $img = image_edit_apply_changes($img, $changes); |
|
759 | + if ( $changes ) { |
|
760 | + $img = image_edit_apply_changes($img, $changes); |
|
761 | + } |
|
745 | 762 | } else { |
746 | 763 | $return->error = esc_js( __('Nothing to save, the image has not changed.') ); |
747 | 764 | return $return; |
@@ -755,8 +772,9 @@ discard block |
||
755 | 772 | return $return; |
756 | 773 | } |
757 | 774 | |
758 | - if ( !is_array($backup_sizes) ) |
|
759 | - $backup_sizes = array(); |
|
775 | + if ( !is_array($backup_sizes) ) { |
|
776 | + $backup_sizes = array(); |
|
777 | + } |
|
760 | 778 | |
761 | 779 | // Generate new filename. |
762 | 780 | $path = get_attached_file( $post_id ); |
@@ -818,8 +836,9 @@ discard block |
||
818 | 836 | |
819 | 837 | if ( $success && ('nothumb' == $target || 'all' == $target) ) { |
820 | 838 | $sizes = get_intermediate_image_sizes(); |
821 | - if ( 'nothumb' == $target ) |
|
822 | - $sizes = array_diff( $sizes, array('thumbnail') ); |
|
839 | + if ( 'nothumb' == $target ) { |
|
840 | + $sizes = array_diff( $sizes, array('thumbnail') ); |
|
841 | + } |
|
823 | 842 | } |
824 | 843 | |
825 | 844 | $return->fw = $meta['width']; |
@@ -851,14 +870,16 @@ discard block |
||
851 | 870 | $tag = false; |
852 | 871 | if ( isset( $meta['sizes'][$size] ) ) { |
853 | 872 | if ( isset($backup_sizes["$size-orig"]) ) { |
854 | - if ( ( !defined('IMAGE_EDIT_OVERWRITE') || !IMAGE_EDIT_OVERWRITE ) && $backup_sizes["$size-orig"]['file'] != $meta['sizes'][$size]['file'] ) |
|
855 | - $tag = "$size-$suffix"; |
|
873 | + if ( ( !defined('IMAGE_EDIT_OVERWRITE') || !IMAGE_EDIT_OVERWRITE ) && $backup_sizes["$size-orig"]['file'] != $meta['sizes'][$size]['file'] ) { |
|
874 | + $tag = "$size-$suffix"; |
|
875 | + } |
|
856 | 876 | } else { |
857 | 877 | $tag = "$size-orig"; |
858 | 878 | } |
859 | 879 | |
860 | - if ( $tag ) |
|
861 | - $backup_sizes[$tag] = $meta['sizes'][$size]; |
|
880 | + if ( $tag ) { |
|
881 | + $backup_sizes[$tag] = $meta['sizes'][$size]; |
|
882 | + } |
|
862 | 883 | } |
863 | 884 | |
864 | 885 | if ( isset( $_wp_additional_image_sizes[ $size ] ) ) { |
@@ -23,35 +23,35 @@ discard block |
||
23 | 23 | * |
24 | 24 | * @param array $args |
25 | 25 | */ |
26 | - public function __construct( $args = array() ) { |
|
27 | - $defaults = array( 'url' => '', 'nonce' => '', 'title' => __( 'Update Translations' ), 'skip_header_footer' => false ); |
|
28 | - $args = wp_parse_args( $args, $defaults ); |
|
29 | - if ( $args['skip_header_footer'] ) { |
|
26 | + public function __construct($args = array()) { |
|
27 | + $defaults = array('url' => '', 'nonce' => '', 'title' => __('Update Translations'), 'skip_header_footer' => false); |
|
28 | + $args = wp_parse_args($args, $defaults); |
|
29 | + if ($args['skip_header_footer']) { |
|
30 | 30 | $this->done_header = true; |
31 | 31 | $this->done_footer = true; |
32 | 32 | $this->display_footer_actions = false; |
33 | 33 | } |
34 | - parent::__construct( $args ); |
|
34 | + parent::__construct($args); |
|
35 | 35 | } |
36 | 36 | |
37 | 37 | /** |
38 | 38 | * @access public |
39 | 39 | */ |
40 | 40 | public function before() { |
41 | - $name = $this->upgrader->get_name_for_update( $this->language_update ); |
|
41 | + $name = $this->upgrader->get_name_for_update($this->language_update); |
|
42 | 42 | |
43 | 43 | echo '<div class="update-messages lp-show-latest">'; |
44 | 44 | |
45 | - printf( '<h2>' . __( 'Updating translations for %1$s (%2$s)…' ) . '</h2>', $name, $this->language_update->language ); |
|
45 | + printf('<h2>'.__('Updating translations for %1$s (%2$s)…').'</h2>', $name, $this->language_update->language); |
|
46 | 46 | } |
47 | 47 | |
48 | 48 | /** |
49 | 49 | * |
50 | 50 | * @param string|WP_Error $error |
51 | 51 | */ |
52 | - public function error( $error ) { |
|
52 | + public function error($error) { |
|
53 | 53 | echo '<div class="lp-error">'; |
54 | - parent::error( $error ); |
|
54 | + parent::error($error); |
|
55 | 55 | echo '</div>'; |
56 | 56 | } |
57 | 57 | |
@@ -66,9 +66,9 @@ discard block |
||
66 | 66 | * @access public |
67 | 67 | */ |
68 | 68 | public function bulk_footer() { |
69 | - $this->decrement_update_count( 'translation' ); |
|
69 | + $this->decrement_update_count('translation'); |
|
70 | 70 | $update_actions = array(); |
71 | - $update_actions['updates_page'] = '<a href="' . self_admin_url( 'update-core.php' ) . '" target="_parent">' . __( 'Return to WordPress Updates page' ) . '</a>'; |
|
71 | + $update_actions['updates_page'] = '<a href="'.self_admin_url('update-core.php').'" target="_parent">'.__('Return to WordPress Updates page').'</a>'; |
|
72 | 72 | |
73 | 73 | /** |
74 | 74 | * Filters the list of action links available following a translations update. |
@@ -77,9 +77,9 @@ discard block |
||
77 | 77 | * |
78 | 78 | * @param array $update_actions Array of translations update links. |
79 | 79 | */ |
80 | - $update_actions = apply_filters( 'update_translations_complete_actions', $update_actions ); |
|
80 | + $update_actions = apply_filters('update_translations_complete_actions', $update_actions); |
|
81 | 81 | |
82 | - if ( $update_actions && $this->display_footer_actions ) |
|
83 | - $this->feedback( implode( ' | ', $update_actions ) ); |
|
82 | + if ($update_actions && $this->display_footer_actions) |
|
83 | + $this->feedback(implode(' | ', $update_actions)); |
|
84 | 84 | } |
85 | 85 | } |
@@ -79,7 +79,8 @@ |
||
79 | 79 | */ |
80 | 80 | $update_actions = apply_filters( 'update_translations_complete_actions', $update_actions ); |
81 | 81 | |
82 | - if ( $update_actions && $this->display_footer_actions ) |
|
83 | - $this->feedback( implode( ' | ', $update_actions ) ); |
|
82 | + if ( $update_actions && $this->display_footer_actions ) { |
|
83 | + $this->feedback( implode( ' | ', $update_actions ) ); |
|
84 | + } |
|
84 | 85 | } |
85 | 86 | } |
@@ -35,7 +35,7 @@ discard block |
||
35 | 35 | */ |
36 | 36 | public function after($title = '') { |
37 | 37 | parent::after($this->plugin_info['Title']); |
38 | - $this->decrement_update_count( 'plugin' ); |
|
38 | + $this->decrement_update_count('plugin'); |
|
39 | 39 | } |
40 | 40 | |
41 | 41 | /** |
@@ -43,12 +43,12 @@ discard block |
||
43 | 43 | */ |
44 | 44 | public function bulk_footer() { |
45 | 45 | parent::bulk_footer(); |
46 | - $update_actions = array( |
|
47 | - 'plugins_page' => '<a href="' . self_admin_url( 'plugins.php' ) . '" target="_parent">' . __( 'Return to Plugins page' ) . '</a>', |
|
48 | - 'updates_page' => '<a href="' . self_admin_url( 'update-core.php' ) . '" target="_parent">' . __( 'Return to WordPress Updates page' ) . '</a>' |
|
46 | + $update_actions = array( |
|
47 | + 'plugins_page' => '<a href="'.self_admin_url('plugins.php').'" target="_parent">'.__('Return to Plugins page').'</a>', |
|
48 | + 'updates_page' => '<a href="'.self_admin_url('update-core.php').'" target="_parent">'.__('Return to WordPress Updates page').'</a>' |
|
49 | 49 | ); |
50 | - if ( ! current_user_can( 'activate_plugins' ) ) |
|
51 | - unset( $update_actions['plugins_page'] ); |
|
50 | + if ( ! current_user_can('activate_plugins')) |
|
51 | + unset($update_actions['plugins_page']); |
|
52 | 52 | |
53 | 53 | /** |
54 | 54 | * Filters the list of action links available following bulk plugin updates. |
@@ -58,9 +58,9 @@ discard block |
||
58 | 58 | * @param array $update_actions Array of plugin action links. |
59 | 59 | * @param array $plugin_info Array of information for the last-updated plugin. |
60 | 60 | */ |
61 | - $update_actions = apply_filters( 'update_bulk_plugins_complete_actions', $update_actions, $this->plugin_info ); |
|
61 | + $update_actions = apply_filters('update_bulk_plugins_complete_actions', $update_actions, $this->plugin_info); |
|
62 | 62 | |
63 | - if ( ! empty($update_actions) ) |
|
64 | - $this->feedback(implode(' | ', (array)$update_actions)); |
|
63 | + if ( ! empty($update_actions)) |
|
64 | + $this->feedback(implode(' | ', (array) $update_actions)); |
|
65 | 65 | } |
66 | 66 | } |
@@ -47,8 +47,9 @@ discard block |
||
47 | 47 | 'plugins_page' => '<a href="' . self_admin_url( 'plugins.php' ) . '" target="_parent">' . __( 'Return to Plugins page' ) . '</a>', |
48 | 48 | 'updates_page' => '<a href="' . self_admin_url( 'update-core.php' ) . '" target="_parent">' . __( 'Return to WordPress Updates page' ) . '</a>' |
49 | 49 | ); |
50 | - if ( ! current_user_can( 'activate_plugins' ) ) |
|
51 | - unset( $update_actions['plugins_page'] ); |
|
50 | + if ( ! current_user_can( 'activate_plugins' ) ) { |
|
51 | + unset( $update_actions['plugins_page'] ); |
|
52 | + } |
|
52 | 53 | |
53 | 54 | /** |
54 | 55 | * Filters the list of action links available following bulk plugin updates. |
@@ -60,7 +61,8 @@ discard block |
||
60 | 61 | */ |
61 | 62 | $update_actions = apply_filters( 'update_bulk_plugins_complete_actions', $update_actions, $this->plugin_info ); |
62 | 63 | |
63 | - if ( ! empty($update_actions) ) |
|
64 | - $this->feedback(implode(' | ', (array)$update_actions)); |
|
64 | + if ( ! empty($update_actions) ) { |
|
65 | + $this->feedback(implode(' | ', (array)$update_actions)); |
|
66 | + } |
|
65 | 67 | } |
66 | 68 | } |
@@ -22,14 +22,14 @@ discard block |
||
22 | 22 | * |
23 | 23 | * @param array $args |
24 | 24 | */ |
25 | - public function __construct( $args = array() ) { |
|
26 | - $defaults = array( 'url' => '', 'plugin' => '', 'nonce' => '', 'title' => __('Update Plugin') ); |
|
25 | + public function __construct($args = array()) { |
|
26 | + $defaults = array('url' => '', 'plugin' => '', 'nonce' => '', 'title' => __('Update Plugin')); |
|
27 | 27 | $args = wp_parse_args($args, $defaults); |
28 | 28 | |
29 | 29 | $this->plugin = $args['plugin']; |
30 | 30 | |
31 | - $this->plugin_active = is_plugin_active( $this->plugin ); |
|
32 | - $this->plugin_network_active = is_plugin_active_for_network( $this->plugin ); |
|
31 | + $this->plugin_active = is_plugin_active($this->plugin); |
|
32 | + $this->plugin_network_active = is_plugin_active_for_network($this->plugin); |
|
33 | 33 | |
34 | 34 | parent::__construct($args); |
35 | 35 | } |
@@ -39,19 +39,19 @@ discard block |
||
39 | 39 | */ |
40 | 40 | public function after() { |
41 | 41 | $this->plugin = $this->upgrader->plugin_info(); |
42 | - if ( !empty($this->plugin) && !is_wp_error($this->result) && $this->plugin_active ){ |
|
42 | + if ( ! empty($this->plugin) && ! is_wp_error($this->result) && $this->plugin_active) { |
|
43 | 43 | // Currently used only when JS is off for a single plugin update? |
44 | - echo '<iframe title="' . esc_attr__( 'Update progress' ) . '" style="border:0;overflow:hidden" width="100%" height="170" src="' . wp_nonce_url( 'update.php?action=activate-plugin&networkwide=' . $this->plugin_network_active . '&plugin=' . urlencode( $this->plugin ), 'activate-plugin_' . $this->plugin ) . '"></iframe>'; |
|
44 | + echo '<iframe title="'.esc_attr__('Update progress').'" style="border:0;overflow:hidden" width="100%" height="170" src="'.wp_nonce_url('update.php?action=activate-plugin&networkwide='.$this->plugin_network_active.'&plugin='.urlencode($this->plugin), 'activate-plugin_'.$this->plugin).'"></iframe>'; |
|
45 | 45 | } |
46 | 46 | |
47 | - $this->decrement_update_count( 'plugin' ); |
|
47 | + $this->decrement_update_count('plugin'); |
|
48 | 48 | |
49 | - $update_actions = array( |
|
50 | - 'activate_plugin' => '<a href="' . wp_nonce_url( 'plugins.php?action=activate&plugin=' . urlencode( $this->plugin ), 'activate-plugin_' . $this->plugin) . '" target="_parent">' . __( 'Activate Plugin' ) . '</a>', |
|
51 | - 'plugins_page' => '<a href="' . self_admin_url( 'plugins.php' ) . '" target="_parent">' . __( 'Return to Plugins page' ) . '</a>' |
|
49 | + $update_actions = array( |
|
50 | + 'activate_plugin' => '<a href="'.wp_nonce_url('plugins.php?action=activate&plugin='.urlencode($this->plugin), 'activate-plugin_'.$this->plugin).'" target="_parent">'.__('Activate Plugin').'</a>', |
|
51 | + 'plugins_page' => '<a href="'.self_admin_url('plugins.php').'" target="_parent">'.__('Return to Plugins page').'</a>' |
|
52 | 52 | ); |
53 | - if ( $this->plugin_active || ! $this->result || is_wp_error( $this->result ) || ! current_user_can( 'activate_plugins' ) ) |
|
54 | - unset( $update_actions['activate_plugin'] ); |
|
53 | + if ($this->plugin_active || ! $this->result || is_wp_error($this->result) || ! current_user_can('activate_plugins')) |
|
54 | + unset($update_actions['activate_plugin']); |
|
55 | 55 | |
56 | 56 | /** |
57 | 57 | * Filters the list of action links available following a single plugin update. |
@@ -61,9 +61,9 @@ discard block |
||
61 | 61 | * @param array $update_actions Array of plugin action links. |
62 | 62 | * @param string $plugin Path to the plugin file. |
63 | 63 | */ |
64 | - $update_actions = apply_filters( 'update_plugin_complete_actions', $update_actions, $this->plugin ); |
|
64 | + $update_actions = apply_filters('update_plugin_complete_actions', $update_actions, $this->plugin); |
|
65 | 65 | |
66 | - if ( ! empty($update_actions) ) |
|
67 | - $this->feedback(implode(' | ', (array)$update_actions)); |
|
66 | + if ( ! empty($update_actions)) |
|
67 | + $this->feedback(implode(' | ', (array) $update_actions)); |
|
68 | 68 | } |
69 | 69 | } |
@@ -50,8 +50,9 @@ discard block |
||
50 | 50 | 'activate_plugin' => '<a href="' . wp_nonce_url( 'plugins.php?action=activate&plugin=' . urlencode( $this->plugin ), 'activate-plugin_' . $this->plugin) . '" target="_parent">' . __( 'Activate Plugin' ) . '</a>', |
51 | 51 | 'plugins_page' => '<a href="' . self_admin_url( 'plugins.php' ) . '" target="_parent">' . __( 'Return to Plugins page' ) . '</a>' |
52 | 52 | ); |
53 | - if ( $this->plugin_active || ! $this->result || is_wp_error( $this->result ) || ! current_user_can( 'activate_plugins' ) ) |
|
54 | - unset( $update_actions['activate_plugin'] ); |
|
53 | + if ( $this->plugin_active || ! $this->result || is_wp_error( $this->result ) || ! current_user_can( 'activate_plugins' ) ) { |
|
54 | + unset( $update_actions['activate_plugin'] ); |
|
55 | + } |
|
55 | 56 | |
56 | 57 | /** |
57 | 58 | * Filters the list of action links available following a single plugin update. |
@@ -63,7 +64,8 @@ discard block |
||
63 | 64 | */ |
64 | 65 | $update_actions = apply_filters( 'update_plugin_complete_actions', $update_actions, $this->plugin ); |
65 | 66 | |
66 | - if ( ! empty($update_actions) ) |
|
67 | - $this->feedback(implode(' | ', (array)$update_actions)); |
|
67 | + if ( ! empty($update_actions) ) { |
|
68 | + $this->feedback(implode(' | ', (array)$update_actions)); |
|
69 | + } |
|
68 | 70 | } |
69 | 71 | } |