@@ -9,18 +9,18 @@ discard block |
||
9 | 9 | /** WordPress Administration Bootstrap */ |
10 | 10 | require_once __DIR__ . '/admin.php'; |
11 | 11 | |
12 | -wp_enqueue_style( 'plugin-install' ); |
|
13 | -wp_enqueue_script( 'plugin-install' ); |
|
14 | -wp_enqueue_script( 'updates' ); |
|
12 | +wp_enqueue_style('plugin-install'); |
|
13 | +wp_enqueue_script('plugin-install'); |
|
14 | +wp_enqueue_script('updates'); |
|
15 | 15 | add_thickbox(); |
16 | 16 | |
17 | -if ( is_multisite() && ! is_network_admin() ) { |
|
18 | - wp_redirect( network_admin_url( 'update-core.php' ) ); |
|
17 | +if (is_multisite() && !is_network_admin()) { |
|
18 | + wp_redirect(network_admin_url('update-core.php')); |
|
19 | 19 | exit; |
20 | 20 | } |
21 | 21 | |
22 | -if ( ! current_user_can( 'update_core' ) && ! current_user_can( 'update_themes' ) && ! current_user_can( 'update_plugins' ) && ! current_user_can( 'update_languages' ) ) { |
|
23 | - wp_die( __( 'Sorry, you are not allowed to update this site.' ) ); |
|
22 | +if (!current_user_can('update_core') && !current_user_can('update_themes') && !current_user_can('update_plugins') && !current_user_can('update_languages')) { |
|
23 | + wp_die(__('Sorry, you are not allowed to update this site.')); |
|
24 | 24 | } |
25 | 25 | |
26 | 26 | /** |
@@ -33,27 +33,27 @@ discard block |
||
33 | 33 | * |
34 | 34 | * @param object $update |
35 | 35 | */ |
36 | -function list_core_update( $update ) { |
|
36 | +function list_core_update($update) { |
|
37 | 37 | global $wp_local_package, $wpdb; |
38 | 38 | static $first_pass = true; |
39 | 39 | |
40 | - $wp_version = get_bloginfo( 'version' ); |
|
41 | - $version_string = sprintf( '%s–%s', $update->current, get_locale() ); |
|
40 | + $wp_version = get_bloginfo('version'); |
|
41 | + $version_string = sprintf('%s–%s', $update->current, get_locale()); |
|
42 | 42 | |
43 | - if ( 'en_US' === $update->locale && 'en_US' === get_locale() ) { |
|
43 | + if ('en_US' === $update->locale && 'en_US' === get_locale()) { |
|
44 | 44 | $version_string = $update->current; |
45 | - } elseif ( 'en_US' === $update->locale && $update->packages->partial && $wp_version == $update->partial_version ) { |
|
45 | + } elseif ('en_US' === $update->locale && $update->packages->partial && $wp_version == $update->partial_version) { |
|
46 | 46 | $updates = get_core_updates(); |
47 | - if ( $updates && 1 === count( $updates ) ) { |
|
47 | + if ($updates && 1 === count($updates)) { |
|
48 | 48 | // If the only available update is a partial builds, it doesn't need a language-specific version string. |
49 | 49 | $version_string = $update->current; |
50 | 50 | } |
51 | - } elseif ( 'en_US' === $update->locale && 'en_US' !== get_locale() ) { |
|
52 | - $version_string = sprintf( '%s–%s', $update->current, $update->locale ); |
|
51 | + } elseif ('en_US' === $update->locale && 'en_US' !== get_locale()) { |
|
52 | + $version_string = sprintf('%s–%s', $update->current, $update->locale); |
|
53 | 53 | } |
54 | 54 | |
55 | 55 | $current = false; |
56 | - if ( ! isset( $update->response ) || 'latest' === $update->response ) { |
|
56 | + if (!isset($update->response) || 'latest' === $update->response) { |
|
57 | 57 | $current = true; |
58 | 58 | } |
59 | 59 | |
@@ -64,53 +64,53 @@ discard block |
||
64 | 64 | $show_buttons = true; |
65 | 65 | |
66 | 66 | // Nightly build versions have two hyphens and a commit number. |
67 | - if ( preg_match( '/-\w+-\d+/', $update->current ) ) { |
|
67 | + if (preg_match('/-\w+-\d+/', $update->current)) { |
|
68 | 68 | // Retrieve the major version number. |
69 | - preg_match( '/^\d+.\d+/', $update->current, $update_major ); |
|
69 | + preg_match('/^\d+.\d+/', $update->current, $update_major); |
|
70 | 70 | /* translators: %s: WordPress version. */ |
71 | - $submit = sprintf( __( 'Update to latest %s nightly' ), $update_major[0] ); |
|
71 | + $submit = sprintf(__('Update to latest %s nightly'), $update_major[0]); |
|
72 | 72 | } else { |
73 | 73 | /* translators: %s: WordPress version. */ |
74 | - $submit = sprintf( __( 'Update to version %s' ), $version_string ); |
|
74 | + $submit = sprintf(__('Update to version %s'), $version_string); |
|
75 | 75 | } |
76 | 76 | |
77 | - if ( 'development' === $update->response ) { |
|
78 | - $message = __( 'You can update to the latest nightly build manually:' ); |
|
77 | + if ('development' === $update->response) { |
|
78 | + $message = __('You can update to the latest nightly build manually:'); |
|
79 | 79 | } else { |
80 | - if ( $current ) { |
|
80 | + if ($current) { |
|
81 | 81 | /* translators: %s: WordPress version. */ |
82 | - $submit = sprintf( __( 'Re-install version %s' ), $version_string ); |
|
82 | + $submit = sprintf(__('Re-install version %s'), $version_string); |
|
83 | 83 | $form_action = 'update-core.php?action=do-core-reinstall'; |
84 | 84 | } else { |
85 | - $php_compat = version_compare( $php_version, $update->php_version, '>=' ); |
|
86 | - if ( file_exists( WP_CONTENT_DIR . '/db.php' ) && empty( $wpdb->is_mysql ) ) { |
|
85 | + $php_compat = version_compare($php_version, $update->php_version, '>='); |
|
86 | + if (file_exists(WP_CONTENT_DIR . '/db.php') && empty($wpdb->is_mysql)) { |
|
87 | 87 | $mysql_compat = true; |
88 | 88 | } else { |
89 | - $mysql_compat = version_compare( $mysql_version, $update->mysql_version, '>=' ); |
|
89 | + $mysql_compat = version_compare($mysql_version, $update->mysql_version, '>='); |
|
90 | 90 | } |
91 | 91 | |
92 | 92 | $version_url = sprintf( |
93 | 93 | /* translators: %s: WordPress version. */ |
94 | - esc_url( __( 'https://wordpress.org/support/wordpress-version/version-%s/' ) ), |
|
95 | - sanitize_title( $update->current ) |
|
94 | + esc_url(__('https://wordpress.org/support/wordpress-version/version-%s/')), |
|
95 | + sanitize_title($update->current) |
|
96 | 96 | ); |
97 | 97 | |
98 | 98 | $php_update_message = '</p><p>' . sprintf( |
99 | 99 | /* translators: %s: URL to Update PHP page. */ |
100 | - __( '<a href="%s">Learn more about updating PHP</a>.' ), |
|
101 | - esc_url( wp_get_update_php_url() ) |
|
100 | + __('<a href="%s">Learn more about updating PHP</a>.'), |
|
101 | + esc_url(wp_get_update_php_url()) |
|
102 | 102 | ); |
103 | 103 | |
104 | 104 | $annotation = wp_get_update_php_annotation(); |
105 | 105 | |
106 | - if ( $annotation ) { |
|
106 | + if ($annotation) { |
|
107 | 107 | $php_update_message .= '</p><p><em>' . $annotation . '</em>'; |
108 | 108 | } |
109 | 109 | |
110 | - if ( ! $mysql_compat && ! $php_compat ) { |
|
110 | + if (!$mysql_compat && !$php_compat) { |
|
111 | 111 | $message = sprintf( |
112 | 112 | /* translators: 1: URL to WordPress release notes, 2: WordPress version number, 3: Minimum required PHP version number, 4: Minimum required MySQL version number, 5: Current PHP version number, 6: Current MySQL version number. */ |
113 | - __( 'You cannot update because <a href="%1$s">WordPress %2$s</a> requires PHP version %3$s or higher and MySQL version %4$s or higher. You are running PHP version %5$s and MySQL version %6$s.' ), |
|
113 | + __('You cannot update because <a href="%1$s">WordPress %2$s</a> requires PHP version %3$s or higher and MySQL version %4$s or higher. You are running PHP version %5$s and MySQL version %6$s.'), |
|
114 | 114 | $version_url, |
115 | 115 | $update->current, |
116 | 116 | $update->php_version, |
@@ -118,19 +118,19 @@ discard block |
||
118 | 118 | $php_version, |
119 | 119 | $mysql_version |
120 | 120 | ) . $php_update_message; |
121 | - } elseif ( ! $php_compat ) { |
|
121 | + } elseif (!$php_compat) { |
|
122 | 122 | $message = sprintf( |
123 | 123 | /* translators: 1: URL to WordPress release notes, 2: WordPress version number, 3: Minimum required PHP version number, 4: Current PHP version number. */ |
124 | - __( 'You cannot update because <a href="%1$s">WordPress %2$s</a> requires PHP version %3$s or higher. You are running version %4$s.' ), |
|
124 | + __('You cannot update because <a href="%1$s">WordPress %2$s</a> requires PHP version %3$s or higher. You are running version %4$s.'), |
|
125 | 125 | $version_url, |
126 | 126 | $update->current, |
127 | 127 | $update->php_version, |
128 | 128 | $php_version |
129 | 129 | ) . $php_update_message; |
130 | - } elseif ( ! $mysql_compat ) { |
|
130 | + } elseif (!$mysql_compat) { |
|
131 | 131 | $message = sprintf( |
132 | 132 | /* translators: 1: URL to WordPress release notes, 2: WordPress version number, 3: Minimum required MySQL version number, 4: Current MySQL version number. */ |
133 | - __( 'You cannot update because <a href="%1$s">WordPress %2$s</a> requires MySQL version %3$s or higher. You are running version %4$s.' ), |
|
133 | + __('You cannot update because <a href="%1$s">WordPress %2$s</a> requires MySQL version %3$s or higher. You are running version %4$s.'), |
|
134 | 134 | $version_url, |
135 | 135 | $update->current, |
136 | 136 | $update->mysql_version, |
@@ -139,14 +139,14 @@ discard block |
||
139 | 139 | } else { |
140 | 140 | $message = sprintf( |
141 | 141 | /* translators: 1: Installed WordPress version number, 2: URL to WordPress release notes, 3: New WordPress version number, including locale if necessary. */ |
142 | - __( 'You can update from WordPress %1$s to <a href="%2$s">WordPress %3$s</a> manually:' ), |
|
142 | + __('You can update from WordPress %1$s to <a href="%2$s">WordPress %3$s</a> manually:'), |
|
143 | 143 | $wp_version, |
144 | 144 | $version_url, |
145 | 145 | $version_string |
146 | 146 | ); |
147 | 147 | } |
148 | 148 | |
149 | - if ( ! $mysql_compat || ! $php_compat ) { |
|
149 | + if (!$mysql_compat || !$php_compat) { |
|
150 | 150 | $show_buttons = false; |
151 | 151 | } |
152 | 152 | } |
@@ -156,36 +156,36 @@ discard block |
||
156 | 156 | echo $message; |
157 | 157 | echo '</p>'; |
158 | 158 | |
159 | - echo '<form method="post" action="' . esc_url( $form_action ) . '" name="upgrade" class="upgrade">'; |
|
160 | - wp_nonce_field( 'upgrade-core' ); |
|
159 | + echo '<form method="post" action="' . esc_url($form_action) . '" name="upgrade" class="upgrade">'; |
|
160 | + wp_nonce_field('upgrade-core'); |
|
161 | 161 | |
162 | 162 | echo '<p>'; |
163 | - echo '<input name="version" value="' . esc_attr( $update->current ) . '" type="hidden" />'; |
|
164 | - echo '<input name="locale" value="' . esc_attr( $update->locale ) . '" type="hidden" />'; |
|
165 | - if ( $show_buttons ) { |
|
166 | - if ( $first_pass ) { |
|
167 | - submit_button( $submit, $current ? '' : 'primary regular', 'upgrade', false ); |
|
163 | + echo '<input name="version" value="' . esc_attr($update->current) . '" type="hidden" />'; |
|
164 | + echo '<input name="locale" value="' . esc_attr($update->locale) . '" type="hidden" />'; |
|
165 | + if ($show_buttons) { |
|
166 | + if ($first_pass) { |
|
167 | + submit_button($submit, $current ? '' : 'primary regular', 'upgrade', false); |
|
168 | 168 | $first_pass = false; |
169 | 169 | } else { |
170 | - submit_button( $submit, '', 'upgrade', false ); |
|
170 | + submit_button($submit, '', 'upgrade', false); |
|
171 | 171 | } |
172 | 172 | } |
173 | - if ( 'en_US' !== $update->locale ) { |
|
174 | - if ( ! isset( $update->dismissed ) || ! $update->dismissed ) { |
|
175 | - submit_button( __( 'Hide this update' ), '', 'dismiss', false ); |
|
173 | + if ('en_US' !== $update->locale) { |
|
174 | + if (!isset($update->dismissed) || !$update->dismissed) { |
|
175 | + submit_button(__('Hide this update'), '', 'dismiss', false); |
|
176 | 176 | } else { |
177 | - submit_button( __( 'Bring back this update' ), '', 'undismiss', false ); |
|
177 | + submit_button(__('Bring back this update'), '', 'undismiss', false); |
|
178 | 178 | } |
179 | 179 | } |
180 | 180 | echo '</p>'; |
181 | 181 | |
182 | - if ( 'en_US' !== $update->locale && ( ! isset( $wp_local_package ) || $wp_local_package != $update->locale ) ) { |
|
183 | - echo '<p class="hint">' . __( 'This localized version contains both the translation and various other localization fixes.' ) . '</p>'; |
|
184 | - } elseif ( 'en_US' === $update->locale && 'en_US' !== get_locale() && ( ! $update->packages->partial && $wp_version == $update->partial_version ) ) { |
|
182 | + if ('en_US' !== $update->locale && (!isset($wp_local_package) || $wp_local_package != $update->locale)) { |
|
183 | + echo '<p class="hint">' . __('This localized version contains both the translation and various other localization fixes.') . '</p>'; |
|
184 | + } elseif ('en_US' === $update->locale && 'en_US' !== get_locale() && (!$update->packages->partial && $wp_version == $update->partial_version)) { |
|
185 | 185 | // Partial builds don't need language-specific warnings. |
186 | 186 | echo '<p class="hint">' . sprintf( |
187 | 187 | /* translators: %s: WordPress version. */ |
188 | - __( 'You are about to install WordPress %s <strong>in English (US).</strong> There is a chance this update will break your translation. You may prefer to wait for the localized version to be released.' ), |
|
188 | + __('You are about to install WordPress %s <strong>in English (US).</strong> There is a chance this update will break your translation. You may prefer to wait for the localized version to be released.'), |
|
189 | 189 | 'development' !== $update->response ? $update->current : '' |
190 | 190 | ) . '</p>'; |
191 | 191 | } |
@@ -207,9 +207,9 @@ discard block |
||
207 | 207 | ) |
208 | 208 | ); |
209 | 209 | |
210 | - if ( $dismissed ) { |
|
211 | - $show_text = esc_js( __( 'Show hidden updates' ) ); |
|
212 | - $hide_text = esc_js( __( 'Hide hidden updates' ) ); |
|
210 | + if ($dismissed) { |
|
211 | + $show_text = esc_js(__('Show hidden updates')); |
|
212 | + $hide_text = esc_js(__('Hide hidden updates')); |
|
213 | 213 | ?> |
214 | 214 | <script type="text/javascript"> |
215 | 215 | jQuery( function( $ ) { |
@@ -227,11 +227,11 @@ discard block |
||
227 | 227 | }); |
228 | 228 | </script> |
229 | 229 | <?php |
230 | - echo '<p class="hide-if-no-js"><button type="button" class="button" id="show-dismissed" aria-expanded="false">' . __( 'Show hidden updates' ) . '</button></p>'; |
|
230 | + echo '<p class="hide-if-no-js"><button type="button" class="button" id="show-dismissed" aria-expanded="false">' . __('Show hidden updates') . '</button></p>'; |
|
231 | 231 | echo '<ul id="dismissed-updates" class="core-updates dismissed">'; |
232 | - foreach ( (array) $dismissed as $update ) { |
|
232 | + foreach ((array) $dismissed as $update) { |
|
233 | 233 | echo '<li>'; |
234 | - list_core_update( $update ); |
|
234 | + list_core_update($update); |
|
235 | 235 | echo '</li>'; |
236 | 236 | } |
237 | 237 | echo '</ul>'; |
@@ -254,44 +254,44 @@ discard block |
||
254 | 254 | // Include an unmodified $wp_version. |
255 | 255 | require ABSPATH . WPINC . '/version.php'; |
256 | 256 | |
257 | - $is_development_version = preg_match( '/alpha|beta|RC/', $wp_version ); |
|
257 | + $is_development_version = preg_match('/alpha|beta|RC/', $wp_version); |
|
258 | 258 | |
259 | - if ( isset( $updates[0]->version ) && version_compare( $updates[0]->version, $wp_version, '>' ) ) { |
|
259 | + if (isset($updates[0]->version) && version_compare($updates[0]->version, $wp_version, '>')) { |
|
260 | 260 | echo '<h2 class="response">'; |
261 | - _e( 'An updated version of WordPress is available.' ); |
|
261 | + _e('An updated version of WordPress is available.'); |
|
262 | 262 | echo '</h2>'; |
263 | 263 | |
264 | 264 | echo '<div class="notice notice-warning inline"><p>'; |
265 | 265 | printf( |
266 | 266 | /* translators: 1: Documentation on WordPress backups, 2: Documentation on updating WordPress. */ |
267 | - __( '<strong>Important:</strong> Before updating, please <a href="%1$s">back up your database and files</a>. For help with updates, visit the <a href="%2$s">Updating WordPress</a> documentation page.' ), |
|
268 | - __( 'https://wordpress.org/support/article/wordpress-backups/' ), |
|
269 | - __( 'https://wordpress.org/support/article/updating-wordpress/' ) |
|
267 | + __('<strong>Important:</strong> Before updating, please <a href="%1$s">back up your database and files</a>. For help with updates, visit the <a href="%2$s">Updating WordPress</a> documentation page.'), |
|
268 | + __('https://wordpress.org/support/article/wordpress-backups/'), |
|
269 | + __('https://wordpress.org/support/article/updating-wordpress/') |
|
270 | 270 | ); |
271 | 271 | echo '</p></div>'; |
272 | - } elseif ( $is_development_version ) { |
|
273 | - echo '<h2 class="response">' . __( 'You are using a development version of WordPress.' ) . '</h2>'; |
|
272 | + } elseif ($is_development_version) { |
|
273 | + echo '<h2 class="response">' . __('You are using a development version of WordPress.') . '</h2>'; |
|
274 | 274 | } else { |
275 | - echo '<h2 class="response">' . __( 'You have the latest version of WordPress.' ) . '</h2>'; |
|
275 | + echo '<h2 class="response">' . __('You have the latest version of WordPress.') . '</h2>'; |
|
276 | 276 | } |
277 | 277 | |
278 | 278 | echo '<ul class="core-updates">'; |
279 | - foreach ( (array) $updates as $update ) { |
|
279 | + foreach ((array) $updates as $update) { |
|
280 | 280 | echo '<li>'; |
281 | - list_core_update( $update ); |
|
281 | + list_core_update($update); |
|
282 | 282 | echo '</li>'; |
283 | 283 | } |
284 | 284 | echo '</ul>'; |
285 | 285 | |
286 | 286 | // Don't show the maintenance mode notice when we are only showing a single re-install option. |
287 | - if ( $updates && ( count( $updates ) > 1 || 'latest' !== $updates[0]->response ) ) { |
|
288 | - echo '<p>' . __( 'While your site is being updated, it will be in maintenance mode. As soon as your updates are complete, this mode will be deactivated.' ) . '</p>'; |
|
289 | - } elseif ( ! $updates ) { |
|
290 | - list( $normalized_version ) = explode( '-', $wp_version ); |
|
287 | + if ($updates && (count($updates) > 1 || 'latest' !== $updates[0]->response)) { |
|
288 | + echo '<p>' . __('While your site is being updated, it will be in maintenance mode. As soon as your updates are complete, this mode will be deactivated.') . '</p>'; |
|
289 | + } elseif (!$updates) { |
|
290 | + list($normalized_version) = explode('-', $wp_version); |
|
291 | 291 | echo '<p>' . sprintf( |
292 | 292 | /* translators: 1: URL to About screen, 2: WordPress version. */ |
293 | - __( '<a href="%1$s">Learn more about WordPress %2$s</a>.' ), |
|
294 | - esc_url( self_admin_url( 'about.php' ) ), |
|
293 | + __('<a href="%1$s">Learn more about WordPress %2$s</a>.'), |
|
294 | + esc_url(self_admin_url('about.php')), |
|
295 | 295 | $normalized_version |
296 | 296 | ) . '</p>'; |
297 | 297 | } |
@@ -305,12 +305,12 @@ discard block |
||
305 | 305 | * @since 5.6.0 |
306 | 306 | */ |
307 | 307 | function core_auto_updates_settings() { |
308 | - if ( isset( $_GET['core-major-auto-updates-saved'] ) ) { |
|
309 | - if ( 'enabled' === $_GET['core-major-auto-updates-saved'] ) { |
|
310 | - $notice_text = __( 'Automatic updates for all WordPress versions have been enabled. Thank you!' ); |
|
308 | + if (isset($_GET['core-major-auto-updates-saved'])) { |
|
309 | + if ('enabled' === $_GET['core-major-auto-updates-saved']) { |
|
310 | + $notice_text = __('Automatic updates for all WordPress versions have been enabled. Thank you!'); |
|
311 | 311 | echo '<div class="notice notice-success is-dismissible"><p>' . $notice_text . '</p></div>'; |
312 | - } elseif ( 'disabled' === $_GET['core-major-auto-updates-saved'] ) { |
|
313 | - $notice_text = __( 'WordPress will only receive automatic security and maintenance releases from now on.' ); |
|
312 | + } elseif ('disabled' === $_GET['core-major-auto-updates-saved']) { |
|
313 | + $notice_text = __('WordPress will only receive automatic security and maintenance releases from now on.'); |
|
314 | 314 | echo '<div class="notice notice-success is-dismissible"><p>' . $notice_text . '</p></div>'; |
315 | 315 | } |
316 | 316 | } |
@@ -319,26 +319,26 @@ discard block |
||
319 | 319 | $updater = new WP_Automatic_Updater(); |
320 | 320 | |
321 | 321 | // Defaults: |
322 | - $upgrade_dev = get_site_option( 'auto_update_core_dev', 'enabled' ) === 'enabled'; |
|
323 | - $upgrade_minor = get_site_option( 'auto_update_core_minor', 'enabled' ) === 'enabled'; |
|
324 | - $upgrade_major = get_site_option( 'auto_update_core_major', 'unset' ) === 'enabled'; |
|
322 | + $upgrade_dev = get_site_option('auto_update_core_dev', 'enabled') === 'enabled'; |
|
323 | + $upgrade_minor = get_site_option('auto_update_core_minor', 'enabled') === 'enabled'; |
|
324 | + $upgrade_major = get_site_option('auto_update_core_major', 'unset') === 'enabled'; |
|
325 | 325 | |
326 | 326 | $can_set_update_option = true; |
327 | 327 | // WP_AUTO_UPDATE_CORE = true (all), 'beta', 'rc', 'development', 'branch-development', 'minor', false. |
328 | - if ( defined( 'WP_AUTO_UPDATE_CORE' ) ) { |
|
329 | - if ( false === WP_AUTO_UPDATE_CORE ) { |
|
328 | + if (defined('WP_AUTO_UPDATE_CORE')) { |
|
329 | + if (false === WP_AUTO_UPDATE_CORE) { |
|
330 | 330 | // Defaults to turned off, unless a filter allows it. |
331 | 331 | $upgrade_dev = false; |
332 | 332 | $upgrade_minor = false; |
333 | 333 | $upgrade_major = false; |
334 | - } elseif ( true === WP_AUTO_UPDATE_CORE |
|
335 | - || in_array( WP_AUTO_UPDATE_CORE, array( 'beta', 'rc', 'development', 'branch-development' ), true ) |
|
334 | + } elseif (true === WP_AUTO_UPDATE_CORE |
|
335 | + || in_array(WP_AUTO_UPDATE_CORE, array('beta', 'rc', 'development', 'branch-development'), true) |
|
336 | 336 | ) { |
337 | 337 | // ALL updates for core. |
338 | 338 | $upgrade_dev = true; |
339 | 339 | $upgrade_minor = true; |
340 | 340 | $upgrade_major = true; |
341 | - } elseif ( 'minor' === WP_AUTO_UPDATE_CORE ) { |
|
341 | + } elseif ('minor' === WP_AUTO_UPDATE_CORE) { |
|
342 | 342 | // Only minor updates for core. |
343 | 343 | $upgrade_dev = false; |
344 | 344 | $upgrade_minor = true; |
@@ -349,7 +349,7 @@ discard block |
||
349 | 349 | $can_set_update_option = false; |
350 | 350 | } |
351 | 351 | |
352 | - if ( $updater->is_disabled() ) { |
|
352 | + if ($updater->is_disabled()) { |
|
353 | 353 | $upgrade_dev = false; |
354 | 354 | $upgrade_minor = false; |
355 | 355 | $upgrade_major = false; |
@@ -364,16 +364,16 @@ discard block |
||
364 | 364 | } |
365 | 365 | |
366 | 366 | // Is the UI overridden by a plugin using the `allow_major_auto_core_updates` filter? |
367 | - if ( has_filter( 'allow_major_auto_core_updates' ) ) { |
|
367 | + if (has_filter('allow_major_auto_core_updates')) { |
|
368 | 368 | $can_set_update_option = false; |
369 | 369 | } |
370 | 370 | |
371 | 371 | /** This filter is documented in wp-admin/includes/class-core-upgrader.php */ |
372 | - $upgrade_dev = apply_filters( 'allow_dev_auto_core_updates', $upgrade_dev ); |
|
372 | + $upgrade_dev = apply_filters('allow_dev_auto_core_updates', $upgrade_dev); |
|
373 | 373 | /** This filter is documented in wp-admin/includes/class-core-upgrader.php */ |
374 | - $upgrade_minor = apply_filters( 'allow_minor_auto_core_updates', $upgrade_minor ); |
|
374 | + $upgrade_minor = apply_filters('allow_minor_auto_core_updates', $upgrade_minor); |
|
375 | 375 | /** This filter is documented in wp-admin/includes/class-core-upgrader.php */ |
376 | - $upgrade_major = apply_filters( 'allow_major_auto_core_updates', $upgrade_major ); |
|
376 | + $upgrade_major = apply_filters('allow_major_auto_core_updates', $upgrade_major); |
|
377 | 377 | |
378 | 378 | $auto_update_settings = array( |
379 | 379 | 'dev' => $upgrade_dev, |
@@ -381,47 +381,47 @@ discard block |
||
381 | 381 | 'major' => $upgrade_major, |
382 | 382 | ); |
383 | 383 | |
384 | - if ( $upgrade_major ) { |
|
385 | - $wp_version = get_bloginfo( 'version' ); |
|
384 | + if ($upgrade_major) { |
|
385 | + $wp_version = get_bloginfo('version'); |
|
386 | 386 | $updates = get_core_updates(); |
387 | 387 | |
388 | - if ( isset( $updates[0]->version ) && version_compare( $updates[0]->version, $wp_version, '>' ) ) { |
|
388 | + if (isset($updates[0]->version) && version_compare($updates[0]->version, $wp_version, '>')) { |
|
389 | 389 | echo '<p>' . wp_get_auto_update_message() . '</p>'; |
390 | 390 | } |
391 | 391 | } |
392 | 392 | |
393 | - $action_url = self_admin_url( 'update-core.php?action=core-major-auto-updates-settings' ); |
|
393 | + $action_url = self_admin_url('update-core.php?action=core-major-auto-updates-settings'); |
|
394 | 394 | ?> |
395 | 395 | |
396 | 396 | <p class="auto-update-status"> |
397 | 397 | <?php |
398 | 398 | |
399 | - if ( $updater->is_vcs_checkout( ABSPATH ) ) { |
|
400 | - _e( 'This site appears to be under version control. Automatic updates are disabled.' ); |
|
401 | - } elseif ( $upgrade_major ) { |
|
402 | - _e( 'This site is automatically kept up to date with each new version of WordPress.' ); |
|
399 | + if ($updater->is_vcs_checkout(ABSPATH)) { |
|
400 | + _e('This site appears to be under version control. Automatic updates are disabled.'); |
|
401 | + } elseif ($upgrade_major) { |
|
402 | + _e('This site is automatically kept up to date with each new version of WordPress.'); |
|
403 | 403 | |
404 | - if ( $can_set_update_option ) { |
|
404 | + if ($can_set_update_option) { |
|
405 | 405 | echo '<br>'; |
406 | 406 | printf( |
407 | 407 | '<a href="%s" class="core-auto-update-settings-link core-auto-update-settings-link-disable">%s</a>', |
408 | - wp_nonce_url( add_query_arg( 'value', 'disable', $action_url ), 'core-major-auto-updates-nonce' ), |
|
409 | - __( 'Switch to automatic updates for maintenance and security releases only.' ) |
|
408 | + wp_nonce_url(add_query_arg('value', 'disable', $action_url), 'core-major-auto-updates-nonce'), |
|
409 | + __('Switch to automatic updates for maintenance and security releases only.') |
|
410 | 410 | ); |
411 | 411 | } |
412 | - } elseif ( $upgrade_minor ) { |
|
413 | - _e( 'This site is automatically kept up to date with maintenance and security releases of WordPress only.' ); |
|
412 | + } elseif ($upgrade_minor) { |
|
413 | + _e('This site is automatically kept up to date with maintenance and security releases of WordPress only.'); |
|
414 | 414 | |
415 | - if ( $can_set_update_option ) { |
|
415 | + if ($can_set_update_option) { |
|
416 | 416 | echo '<br>'; |
417 | 417 | printf( |
418 | 418 | '<a href="%s" class="core-auto-update-settings-link core-auto-update-settings-link-enable">%s</a>', |
419 | - wp_nonce_url( add_query_arg( 'value', 'enable', $action_url ), 'core-major-auto-updates-nonce' ), |
|
420 | - __( 'Enable automatic updates for all new versions of WordPress.' ) |
|
419 | + wp_nonce_url(add_query_arg('value', 'enable', $action_url), 'core-major-auto-updates-nonce'), |
|
420 | + __('Enable automatic updates for all new versions of WordPress.') |
|
421 | 421 | ); |
422 | 422 | } |
423 | 423 | } else { |
424 | - _e( 'This site will not receive automatic updates for new versions of WordPress.' ); |
|
424 | + _e('This site will not receive automatic updates for new versions of WordPress.'); |
|
425 | 425 | } |
426 | 426 | ?> |
427 | 427 | </p> |
@@ -440,7 +440,7 @@ discard block |
||
440 | 440 | * @type bool $major Whether to enable major automatic core updates. |
441 | 441 | * } |
442 | 442 | */ |
443 | - do_action( 'after_core_auto_updates_settings', $auto_update_settings ); |
|
443 | + do_action('after_core_auto_updates_settings', $auto_update_settings); |
|
444 | 444 | } |
445 | 445 | |
446 | 446 | /** |
@@ -449,45 +449,45 @@ discard block |
||
449 | 449 | * @since 2.9.0 |
450 | 450 | */ |
451 | 451 | function list_plugin_updates() { |
452 | - $wp_version = get_bloginfo( 'version' ); |
|
453 | - $cur_wp_version = preg_replace( '/-.*$/', '', $wp_version ); |
|
452 | + $wp_version = get_bloginfo('version'); |
|
453 | + $cur_wp_version = preg_replace('/-.*$/', '', $wp_version); |
|
454 | 454 | |
455 | 455 | require_once ABSPATH . 'wp-admin/includes/plugin-install.php'; |
456 | 456 | $plugins = get_plugin_updates(); |
457 | - if ( empty( $plugins ) ) { |
|
458 | - echo '<h2>' . __( 'Plugins' ) . '</h2>'; |
|
459 | - echo '<p>' . __( 'Your plugins are all up to date.' ) . '</p>'; |
|
457 | + if (empty($plugins)) { |
|
458 | + echo '<h2>' . __('Plugins') . '</h2>'; |
|
459 | + echo '<p>' . __('Your plugins are all up to date.') . '</p>'; |
|
460 | 460 | return; |
461 | 461 | } |
462 | 462 | $form_action = 'update-core.php?action=do-plugin-upgrade'; |
463 | 463 | |
464 | 464 | $core_updates = get_core_updates(); |
465 | - if ( ! isset( $core_updates[0]->response ) || 'latest' === $core_updates[0]->response || 'development' === $core_updates[0]->response || version_compare( $core_updates[0]->current, $cur_wp_version, '=' ) ) { |
|
465 | + if (!isset($core_updates[0]->response) || 'latest' === $core_updates[0]->response || 'development' === $core_updates[0]->response || version_compare($core_updates[0]->current, $cur_wp_version, '=')) { |
|
466 | 466 | $core_update_version = false; |
467 | 467 | } else { |
468 | 468 | $core_update_version = $core_updates[0]->current; |
469 | 469 | } |
470 | 470 | |
471 | - $plugins_count = count( $plugins ); |
|
471 | + $plugins_count = count($plugins); |
|
472 | 472 | ?> |
473 | 473 | <h2> |
474 | 474 | <?php |
475 | 475 | printf( |
476 | 476 | '%s <span class="count">(%d)</span>', |
477 | - __( 'Plugins' ), |
|
478 | - number_format_i18n( $plugins_count ) |
|
477 | + __('Plugins'), |
|
478 | + number_format_i18n($plugins_count) |
|
479 | 479 | ); |
480 | 480 | ?> |
481 | 481 | </h2> |
482 | -<p><?php _e( 'The following plugins have new versions available. Check the ones you want to update and then click “Update Plugins”.' ); ?></p> |
|
483 | -<form method="post" action="<?php echo esc_url( $form_action ); ?>" name="upgrade-plugins" class="upgrade"> |
|
484 | - <?php wp_nonce_field( 'upgrade-core' ); ?> |
|
485 | -<p><input id="upgrade-plugins" class="button" type="submit" value="<?php esc_attr_e( 'Update Plugins' ); ?>" name="upgrade" /></p> |
|
482 | +<p><?php _e('The following plugins have new versions available. Check the ones you want to update and then click “Update Plugins”.'); ?></p> |
|
483 | +<form method="post" action="<?php echo esc_url($form_action); ?>" name="upgrade-plugins" class="upgrade"> |
|
484 | + <?php wp_nonce_field('upgrade-core'); ?> |
|
485 | +<p><input id="upgrade-plugins" class="button" type="submit" value="<?php esc_attr_e('Update Plugins'); ?>" name="upgrade" /></p> |
|
486 | 486 | <table class="widefat updates-table" id="update-plugins-table"> |
487 | 487 | <thead> |
488 | 488 | <tr> |
489 | 489 | <td class="manage-column check-column"><input type="checkbox" id="plugins-select-all" /></td> |
490 | - <td class="manage-column"><label for="plugins-select-all"><?php _e( 'Select All' ); ?></label></td> |
|
490 | + <td class="manage-column"><label for="plugins-select-all"><?php _e('Select All'); ?></label></td> |
|
491 | 491 | </tr> |
492 | 492 | </thead> |
493 | 493 | |
@@ -495,87 +495,87 @@ discard block |
||
495 | 495 | <?php |
496 | 496 | |
497 | 497 | $auto_updates = array(); |
498 | - if ( wp_is_auto_update_enabled_for_type( 'plugin' ) ) { |
|
499 | - $auto_updates = (array) get_site_option( 'auto_update_plugins', array() ); |
|
498 | + if (wp_is_auto_update_enabled_for_type('plugin')) { |
|
499 | + $auto_updates = (array) get_site_option('auto_update_plugins', array()); |
|
500 | 500 | $auto_update_notice = ' | ' . wp_get_auto_update_message(); |
501 | 501 | } |
502 | 502 | |
503 | - foreach ( (array) $plugins as $plugin_file => $plugin_data ) { |
|
504 | - $plugin_data = (object) _get_plugin_data_markup_translate( $plugin_file, (array) $plugin_data, false, true ); |
|
503 | + foreach ((array) $plugins as $plugin_file => $plugin_data) { |
|
504 | + $plugin_data = (object) _get_plugin_data_markup_translate($plugin_file, (array) $plugin_data, false, true); |
|
505 | 505 | |
506 | 506 | $icon = '<span class="dashicons dashicons-admin-plugins"></span>'; |
507 | - $preferred_icons = array( 'svg', '2x', '1x', 'default' ); |
|
508 | - foreach ( $preferred_icons as $preferred_icon ) { |
|
509 | - if ( ! empty( $plugin_data->update->icons[ $preferred_icon ] ) ) { |
|
510 | - $icon = '<img src="' . esc_url( $plugin_data->update->icons[ $preferred_icon ] ) . '" alt="" />'; |
|
507 | + $preferred_icons = array('svg', '2x', '1x', 'default'); |
|
508 | + foreach ($preferred_icons as $preferred_icon) { |
|
509 | + if (!empty($plugin_data->update->icons[$preferred_icon])) { |
|
510 | + $icon = '<img src="' . esc_url($plugin_data->update->icons[$preferred_icon]) . '" alt="" />'; |
|
511 | 511 | break; |
512 | 512 | } |
513 | 513 | } |
514 | 514 | |
515 | 515 | // Get plugin compat for running version of WordPress. |
516 | - if ( isset( $plugin_data->update->tested ) && version_compare( $plugin_data->update->tested, $cur_wp_version, '>=' ) ) { |
|
516 | + if (isset($plugin_data->update->tested) && version_compare($plugin_data->update->tested, $cur_wp_version, '>=')) { |
|
517 | 517 | /* translators: %s: WordPress version. */ |
518 | - $compat = '<br />' . sprintf( __( 'Compatibility with WordPress %s: 100%% (according to its author)' ), $cur_wp_version ); |
|
518 | + $compat = '<br />' . sprintf(__('Compatibility with WordPress %s: 100%% (according to its author)'), $cur_wp_version); |
|
519 | 519 | } else { |
520 | 520 | /* translators: %s: WordPress version. */ |
521 | - $compat = '<br />' . sprintf( __( 'Compatibility with WordPress %s: Unknown' ), $cur_wp_version ); |
|
521 | + $compat = '<br />' . sprintf(__('Compatibility with WordPress %s: Unknown'), $cur_wp_version); |
|
522 | 522 | } |
523 | 523 | // Get plugin compat for updated version of WordPress. |
524 | - if ( $core_update_version ) { |
|
525 | - if ( isset( $plugin_data->update->tested ) && version_compare( $plugin_data->update->tested, $core_update_version, '>=' ) ) { |
|
524 | + if ($core_update_version) { |
|
525 | + if (isset($plugin_data->update->tested) && version_compare($plugin_data->update->tested, $core_update_version, '>=')) { |
|
526 | 526 | /* translators: %s: WordPress version. */ |
527 | - $compat .= '<br />' . sprintf( __( 'Compatibility with WordPress %s: 100%% (according to its author)' ), $core_update_version ); |
|
527 | + $compat .= '<br />' . sprintf(__('Compatibility with WordPress %s: 100%% (according to its author)'), $core_update_version); |
|
528 | 528 | } else { |
529 | 529 | /* translators: %s: WordPress version. */ |
530 | - $compat .= '<br />' . sprintf( __( 'Compatibility with WordPress %s: Unknown' ), $core_update_version ); |
|
530 | + $compat .= '<br />' . sprintf(__('Compatibility with WordPress %s: Unknown'), $core_update_version); |
|
531 | 531 | } |
532 | 532 | } |
533 | 533 | |
534 | - $requires_php = isset( $plugin_data->update->requires_php ) ? $plugin_data->update->requires_php : null; |
|
535 | - $compatible_php = is_php_version_compatible( $requires_php ); |
|
534 | + $requires_php = isset($plugin_data->update->requires_php) ? $plugin_data->update->requires_php : null; |
|
535 | + $compatible_php = is_php_version_compatible($requires_php); |
|
536 | 536 | |
537 | - if ( ! $compatible_php && current_user_can( 'update_php' ) ) { |
|
538 | - $compat .= '<br>' . __( 'This update does not work with your version of PHP.' ) . ' '; |
|
537 | + if (!$compatible_php && current_user_can('update_php')) { |
|
538 | + $compat .= '<br>' . __('This update does not work with your version of PHP.') . ' '; |
|
539 | 539 | $compat .= sprintf( |
540 | 540 | /* translators: %s: URL to Update PHP page. */ |
541 | - __( '<a href="%s">Learn more about updating PHP</a>.' ), |
|
542 | - esc_url( wp_get_update_php_url() ) |
|
541 | + __('<a href="%s">Learn more about updating PHP</a>.'), |
|
542 | + esc_url(wp_get_update_php_url()) |
|
543 | 543 | ); |
544 | 544 | |
545 | 545 | $annotation = wp_get_update_php_annotation(); |
546 | 546 | |
547 | - if ( $annotation ) { |
|
547 | + if ($annotation) { |
|
548 | 548 | $compat .= '</p><p><em>' . $annotation . '</em>'; |
549 | 549 | } |
550 | 550 | } |
551 | 551 | |
552 | 552 | // Get the upgrade notice for the new plugin version. |
553 | - if ( isset( $plugin_data->update->upgrade_notice ) ) { |
|
554 | - $upgrade_notice = '<br />' . strip_tags( $plugin_data->update->upgrade_notice ); |
|
553 | + if (isset($plugin_data->update->upgrade_notice)) { |
|
554 | + $upgrade_notice = '<br />' . strip_tags($plugin_data->update->upgrade_notice); |
|
555 | 555 | } else { |
556 | 556 | $upgrade_notice = ''; |
557 | 557 | } |
558 | 558 | |
559 | - $details_url = self_admin_url( 'plugin-install.php?tab=plugin-information&plugin=' . $plugin_data->update->slug . '§ion=changelog&TB_iframe=true&width=640&height=662' ); |
|
559 | + $details_url = self_admin_url('plugin-install.php?tab=plugin-information&plugin=' . $plugin_data->update->slug . '§ion=changelog&TB_iframe=true&width=640&height=662'); |
|
560 | 560 | $details = sprintf( |
561 | 561 | '<a href="%1$s" class="thickbox open-plugin-details-modal" aria-label="%2$s">%3$s</a>', |
562 | - esc_url( $details_url ), |
|
562 | + esc_url($details_url), |
|
563 | 563 | /* translators: 1: Plugin name, 2: Version number. */ |
564 | - esc_attr( sprintf( __( 'View %1$s version %2$s details' ), $plugin_data->Name, $plugin_data->update->new_version ) ), |
|
564 | + esc_attr(sprintf(__('View %1$s version %2$s details'), $plugin_data->Name, $plugin_data->update->new_version)), |
|
565 | 565 | /* translators: %s: Plugin version. */ |
566 | - sprintf( __( 'View version %s details.' ), $plugin_data->update->new_version ) |
|
566 | + sprintf(__('View version %s details.'), $plugin_data->update->new_version) |
|
567 | 567 | ); |
568 | 568 | |
569 | - $checkbox_id = 'checkbox_' . md5( $plugin_file ); |
|
569 | + $checkbox_id = 'checkbox_' . md5($plugin_file); |
|
570 | 570 | ?> |
571 | 571 | <tr> |
572 | 572 | <td class="check-column"> |
573 | - <?php if ( $compatible_php ) : ?> |
|
574 | - <input type="checkbox" name="checked[]" id="<?php echo $checkbox_id; ?>" value="<?php echo esc_attr( $plugin_file ); ?>" /> |
|
573 | + <?php if ($compatible_php) : ?> |
|
574 | + <input type="checkbox" name="checked[]" id="<?php echo $checkbox_id; ?>" value="<?php echo esc_attr($plugin_file); ?>" /> |
|
575 | 575 | <label for="<?php echo $checkbox_id; ?>" class="screen-reader-text"> |
576 | 576 | <?php |
577 | 577 | /* translators: %s: Plugin name. */ |
578 | - printf( __( 'Select %s' ), $plugin_data->Name ); |
|
578 | + printf(__('Select %s'), $plugin_data->Name); |
|
579 | 579 | ?> |
580 | 580 | </label> |
581 | 581 | <?php endif; ?> |
@@ -586,14 +586,14 @@ discard block |
||
586 | 586 | <?php |
587 | 587 | printf( |
588 | 588 | /* translators: 1: Plugin version, 2: New version. */ |
589 | - __( 'You have version %1$s installed. Update to %2$s.' ), |
|
589 | + __('You have version %1$s installed. Update to %2$s.'), |
|
590 | 590 | $plugin_data->Version, |
591 | 591 | $plugin_data->update->new_version |
592 | 592 | ); |
593 | 593 | |
594 | 594 | echo ' ' . $details . $compat . $upgrade_notice; |
595 | 595 | |
596 | - if ( in_array( $plugin_file, $auto_updates, true ) ) { |
|
596 | + if (in_array($plugin_file, $auto_updates, true)) { |
|
597 | 597 | echo $auto_update_notice; |
598 | 598 | } |
599 | 599 | ?> |
@@ -607,11 +607,11 @@ discard block |
||
607 | 607 | <tfoot> |
608 | 608 | <tr> |
609 | 609 | <td class="manage-column check-column"><input type="checkbox" id="plugins-select-all-2" /></td> |
610 | - <td class="manage-column"><label for="plugins-select-all-2"><?php _e( 'Select All' ); ?></label></td> |
|
610 | + <td class="manage-column"><label for="plugins-select-all-2"><?php _e('Select All'); ?></label></td> |
|
611 | 611 | </tr> |
612 | 612 | </tfoot> |
613 | 613 | </table> |
614 | -<p><input id="upgrade-plugins-2" class="button" type="submit" value="<?php esc_attr_e( 'Update Plugins' ); ?>" name="upgrade" /></p> |
|
614 | +<p><input id="upgrade-plugins-2" class="button" type="submit" value="<?php esc_attr_e('Update Plugins'); ?>" name="upgrade" /></p> |
|
615 | 615 | </form> |
616 | 616 | <?php |
617 | 617 | } |
@@ -623,151 +623,151 @@ discard block |
||
623 | 623 | */ |
624 | 624 | function list_theme_updates() { |
625 | 625 | $themes = get_theme_updates(); |
626 | - if ( empty( $themes ) ) { |
|
627 | - echo '<h2>' . __( 'Themes' ) . '</h2>'; |
|
628 | - echo '<p>' . __( 'Your themes are all up to date.' ) . '</p>'; |
|
626 | + if (empty($themes)) { |
|
627 | + echo '<h2>' . __('Themes') . '</h2>'; |
|
628 | + echo '<p>' . __('Your themes are all up to date.') . '</p>'; |
|
629 | 629 | return; |
630 | 630 | } |
631 | 631 | |
632 | 632 | $form_action = 'update-core.php?action=do-theme-upgrade'; |
633 | 633 | |
634 | - $themes_count = count( $themes ); |
|
634 | + $themes_count = count($themes); |
|
635 | 635 | ?> |
636 | 636 | <h2> |
637 | 637 | <?php |
638 | 638 | printf( |
639 | 639 | '%s <span class="count">(%d)</span>', |
640 | - __( 'Themes' ), |
|
641 | - number_format_i18n( $themes_count ) |
|
640 | + __('Themes'), |
|
641 | + number_format_i18n($themes_count) |
|
642 | 642 | ); |
643 | 643 | ?> |
644 | 644 | </h2> |
645 | -<p><?php _e( 'The following themes have new versions available. Check the ones you want to update and then click “Update Themes”.' ); ?></p> |
|
645 | +<p><?php _e('The following themes have new versions available. Check the ones you want to update and then click “Update Themes”.'); ?></p> |
|
646 | 646 | <p> |
647 | 647 | <?php |
648 | 648 | printf( |
649 | 649 | /* translators: %s: Link to documentation on child themes. */ |
650 | - __( '<strong>Please Note:</strong> Any customizations you have made to theme files will be lost. Please consider using <a href="%s">child themes</a> for modifications.' ), |
|
651 | - __( 'https://developer.wordpress.org/themes/advanced-topics/child-themes/' ) |
|
650 | + __('<strong>Please Note:</strong> Any customizations you have made to theme files will be lost. Please consider using <a href="%s">child themes</a> for modifications.'), |
|
651 | + __('https://developer.wordpress.org/themes/advanced-topics/child-themes/') |
|
652 | 652 | ); |
653 | 653 | ?> |
654 | 654 | </p> |
655 | -<form method="post" action="<?php echo esc_url( $form_action ); ?>" name="upgrade-themes" class="upgrade"> |
|
656 | - <?php wp_nonce_field( 'upgrade-core' ); ?> |
|
657 | -<p><input id="upgrade-themes" class="button" type="submit" value="<?php esc_attr_e( 'Update Themes' ); ?>" name="upgrade" /></p> |
|
655 | +<form method="post" action="<?php echo esc_url($form_action); ?>" name="upgrade-themes" class="upgrade"> |
|
656 | + <?php wp_nonce_field('upgrade-core'); ?> |
|
657 | +<p><input id="upgrade-themes" class="button" type="submit" value="<?php esc_attr_e('Update Themes'); ?>" name="upgrade" /></p> |
|
658 | 658 | <table class="widefat updates-table" id="update-themes-table"> |
659 | 659 | <thead> |
660 | 660 | <tr> |
661 | 661 | <td class="manage-column check-column"><input type="checkbox" id="themes-select-all" /></td> |
662 | - <td class="manage-column"><label for="themes-select-all"><?php _e( 'Select All' ); ?></label></td> |
|
662 | + <td class="manage-column"><label for="themes-select-all"><?php _e('Select All'); ?></label></td> |
|
663 | 663 | </tr> |
664 | 664 | </thead> |
665 | 665 | |
666 | 666 | <tbody class="plugins"> |
667 | 667 | <?php |
668 | 668 | $auto_updates = array(); |
669 | - if ( wp_is_auto_update_enabled_for_type( 'theme' ) ) { |
|
670 | - $auto_updates = (array) get_site_option( 'auto_update_themes', array() ); |
|
669 | + if (wp_is_auto_update_enabled_for_type('theme')) { |
|
670 | + $auto_updates = (array) get_site_option('auto_update_themes', array()); |
|
671 | 671 | $auto_update_notice = ' | ' . wp_get_auto_update_message(); |
672 | 672 | } |
673 | 673 | |
674 | - foreach ( $themes as $stylesheet => $theme ) { |
|
675 | - $requires_wp = isset( $theme->update['requires'] ) ? $theme->update['requires'] : null; |
|
676 | - $requires_php = isset( $theme->update['requires_php'] ) ? $theme->update['requires_php'] : null; |
|
674 | + foreach ($themes as $stylesheet => $theme) { |
|
675 | + $requires_wp = isset($theme->update['requires']) ? $theme->update['requires'] : null; |
|
676 | + $requires_php = isset($theme->update['requires_php']) ? $theme->update['requires_php'] : null; |
|
677 | 677 | |
678 | - $compatible_wp = is_wp_version_compatible( $requires_wp ); |
|
679 | - $compatible_php = is_php_version_compatible( $requires_php ); |
|
678 | + $compatible_wp = is_wp_version_compatible($requires_wp); |
|
679 | + $compatible_php = is_php_version_compatible($requires_php); |
|
680 | 680 | |
681 | 681 | $compat = ''; |
682 | 682 | |
683 | - if ( ! $compatible_wp && ! $compatible_php ) { |
|
684 | - $compat .= '<br>' . __( 'This update does not work with your versions of WordPress and PHP.' ) . ' '; |
|
685 | - if ( current_user_can( 'update_core' ) && current_user_can( 'update_php' ) ) { |
|
683 | + if (!$compatible_wp && !$compatible_php) { |
|
684 | + $compat .= '<br>' . __('This update does not work with your versions of WordPress and PHP.') . ' '; |
|
685 | + if (current_user_can('update_core') && current_user_can('update_php')) { |
|
686 | 686 | $compat .= sprintf( |
687 | 687 | /* translators: 1: URL to WordPress Updates screen, 2: URL to Update PHP page. */ |
688 | - __( '<a href="%1$s">Please update WordPress</a>, and then <a href="%2$s">learn more about updating PHP</a>.' ), |
|
689 | - self_admin_url( 'update-core.php' ), |
|
690 | - esc_url( wp_get_update_php_url() ) |
|
688 | + __('<a href="%1$s">Please update WordPress</a>, and then <a href="%2$s">learn more about updating PHP</a>.'), |
|
689 | + self_admin_url('update-core.php'), |
|
690 | + esc_url(wp_get_update_php_url()) |
|
691 | 691 | ); |
692 | 692 | |
693 | 693 | $annotation = wp_get_update_php_annotation(); |
694 | 694 | |
695 | - if ( $annotation ) { |
|
695 | + if ($annotation) { |
|
696 | 696 | $compat .= '</p><p><em>' . $annotation . '</em>'; |
697 | 697 | } |
698 | - } elseif ( current_user_can( 'update_core' ) ) { |
|
698 | + } elseif (current_user_can('update_core')) { |
|
699 | 699 | $compat .= sprintf( |
700 | 700 | /* translators: %s: URL to WordPress Updates screen. */ |
701 | - __( '<a href="%s">Please update WordPress</a>.' ), |
|
702 | - self_admin_url( 'update-core.php' ) |
|
701 | + __('<a href="%s">Please update WordPress</a>.'), |
|
702 | + self_admin_url('update-core.php') |
|
703 | 703 | ); |
704 | - } elseif ( current_user_can( 'update_php' ) ) { |
|
704 | + } elseif (current_user_can('update_php')) { |
|
705 | 705 | $compat .= sprintf( |
706 | 706 | /* translators: %s: URL to Update PHP page. */ |
707 | - __( '<a href="%s">Learn more about updating PHP</a>.' ), |
|
708 | - esc_url( wp_get_update_php_url() ) |
|
707 | + __('<a href="%s">Learn more about updating PHP</a>.'), |
|
708 | + esc_url(wp_get_update_php_url()) |
|
709 | 709 | ); |
710 | 710 | |
711 | 711 | $annotation = wp_get_update_php_annotation(); |
712 | 712 | |
713 | - if ( $annotation ) { |
|
713 | + if ($annotation) { |
|
714 | 714 | $compat .= '</p><p><em>' . $annotation . '</em>'; |
715 | 715 | } |
716 | 716 | } |
717 | - } elseif ( ! $compatible_wp ) { |
|
718 | - $compat .= '<br>' . __( 'This update does not work with your version of WordPress.' ) . ' '; |
|
719 | - if ( current_user_can( 'update_core' ) ) { |
|
717 | + } elseif (!$compatible_wp) { |
|
718 | + $compat .= '<br>' . __('This update does not work with your version of WordPress.') . ' '; |
|
719 | + if (current_user_can('update_core')) { |
|
720 | 720 | $compat .= sprintf( |
721 | 721 | /* translators: %s: URL to WordPress Updates screen. */ |
722 | - __( '<a href="%s">Please update WordPress</a>.' ), |
|
723 | - self_admin_url( 'update-core.php' ) |
|
722 | + __('<a href="%s">Please update WordPress</a>.'), |
|
723 | + self_admin_url('update-core.php') |
|
724 | 724 | ); |
725 | 725 | } |
726 | - } elseif ( ! $compatible_php ) { |
|
727 | - $compat .= '<br>' . __( 'This update does not work with your version of PHP.' ) . ' '; |
|
728 | - if ( current_user_can( 'update_php' ) ) { |
|
726 | + } elseif (!$compatible_php) { |
|
727 | + $compat .= '<br>' . __('This update does not work with your version of PHP.') . ' '; |
|
728 | + if (current_user_can('update_php')) { |
|
729 | 729 | $compat .= sprintf( |
730 | 730 | /* translators: %s: URL to Update PHP page. */ |
731 | - __( '<a href="%s">Learn more about updating PHP</a>.' ), |
|
732 | - esc_url( wp_get_update_php_url() ) |
|
731 | + __('<a href="%s">Learn more about updating PHP</a>.'), |
|
732 | + esc_url(wp_get_update_php_url()) |
|
733 | 733 | ); |
734 | 734 | |
735 | 735 | $annotation = wp_get_update_php_annotation(); |
736 | 736 | |
737 | - if ( $annotation ) { |
|
737 | + if ($annotation) { |
|
738 | 738 | $compat .= '</p><p><em>' . $annotation . '</em>'; |
739 | 739 | } |
740 | 740 | } |
741 | 741 | } |
742 | 742 | |
743 | - $checkbox_id = 'checkbox_' . md5( $theme->get( 'Name' ) ); |
|
743 | + $checkbox_id = 'checkbox_' . md5($theme->get('Name')); |
|
744 | 744 | ?> |
745 | 745 | <tr> |
746 | 746 | <td class="check-column"> |
747 | - <?php if ( $compatible_wp && $compatible_php ) : ?> |
|
748 | - <input type="checkbox" name="checked[]" id="<?php echo $checkbox_id; ?>" value="<?php echo esc_attr( $stylesheet ); ?>" /> |
|
747 | + <?php if ($compatible_wp && $compatible_php) : ?> |
|
748 | + <input type="checkbox" name="checked[]" id="<?php echo $checkbox_id; ?>" value="<?php echo esc_attr($stylesheet); ?>" /> |
|
749 | 749 | <label for="<?php echo $checkbox_id; ?>" class="screen-reader-text"> |
750 | 750 | <?php |
751 | 751 | /* translators: %s: Theme name. */ |
752 | - printf( __( 'Select %s' ), $theme->display( 'Name' ) ); |
|
752 | + printf(__('Select %s'), $theme->display('Name')); |
|
753 | 753 | ?> |
754 | 754 | </label> |
755 | 755 | <?php endif; ?> |
756 | 756 | </td> |
757 | 757 | <td class="plugin-title"><p> |
758 | - <img src="<?php echo esc_url( $theme->get_screenshot() . '?ver=' . $theme->version ); ?>" width="85" height="64" class="updates-table-screenshot" alt="" /> |
|
759 | - <strong><?php echo $theme->display( 'Name' ); ?></strong> |
|
758 | + <img src="<?php echo esc_url($theme->get_screenshot() . '?ver=' . $theme->version); ?>" width="85" height="64" class="updates-table-screenshot" alt="" /> |
|
759 | + <strong><?php echo $theme->display('Name'); ?></strong> |
|
760 | 760 | <?php |
761 | 761 | printf( |
762 | 762 | /* translators: 1: Theme version, 2: New version. */ |
763 | - __( 'You have version %1$s installed. Update to %2$s.' ), |
|
764 | - $theme->display( 'Version' ), |
|
763 | + __('You have version %1$s installed. Update to %2$s.'), |
|
764 | + $theme->display('Version'), |
|
765 | 765 | $theme->update['new_version'] |
766 | 766 | ); |
767 | 767 | |
768 | 768 | echo ' ' . $compat; |
769 | 769 | |
770 | - if ( in_array( $stylesheet, $auto_updates, true ) ) { |
|
770 | + if (in_array($stylesheet, $auto_updates, true)) { |
|
771 | 771 | echo $auto_update_notice; |
772 | 772 | } |
773 | 773 | ?> |
@@ -781,11 +781,11 @@ discard block |
||
781 | 781 | <tfoot> |
782 | 782 | <tr> |
783 | 783 | <td class="manage-column check-column"><input type="checkbox" id="themes-select-all-2" /></td> |
784 | - <td class="manage-column"><label for="themes-select-all-2"><?php _e( 'Select All' ); ?></label></td> |
|
784 | + <td class="manage-column"><label for="themes-select-all-2"><?php _e('Select All'); ?></label></td> |
|
785 | 785 | </tr> |
786 | 786 | </tfoot> |
787 | 787 | </table> |
788 | -<p><input id="upgrade-themes-2" class="button" type="submit" value="<?php esc_attr_e( 'Update Themes' ); ?>" name="upgrade" /></p> |
|
788 | +<p><input id="upgrade-themes-2" class="button" type="submit" value="<?php esc_attr_e('Update Themes'); ?>" name="upgrade" /></p> |
|
789 | 789 | </form> |
790 | 790 | <?php |
791 | 791 | } |
@@ -797,21 +797,21 @@ discard block |
||
797 | 797 | */ |
798 | 798 | function list_translation_updates() { |
799 | 799 | $updates = wp_get_translation_updates(); |
800 | - if ( ! $updates ) { |
|
801 | - if ( 'en_US' !== get_locale() ) { |
|
802 | - echo '<h2>' . __( 'Translations' ) . '</h2>'; |
|
803 | - echo '<p>' . __( 'Your translations are all up to date.' ) . '</p>'; |
|
800 | + if (!$updates) { |
|
801 | + if ('en_US' !== get_locale()) { |
|
802 | + echo '<h2>' . __('Translations') . '</h2>'; |
|
803 | + echo '<p>' . __('Your translations are all up to date.') . '</p>'; |
|
804 | 804 | } |
805 | 805 | return; |
806 | 806 | } |
807 | 807 | |
808 | 808 | $form_action = 'update-core.php?action=do-translation-upgrade'; |
809 | 809 | ?> |
810 | - <h2><?php _e( 'Translations' ); ?></h2> |
|
811 | - <form method="post" action="<?php echo esc_url( $form_action ); ?>" name="upgrade-translations" class="upgrade"> |
|
812 | - <p><?php _e( 'New translations are available.' ); ?></p> |
|
813 | - <?php wp_nonce_field( 'upgrade-translations' ); ?> |
|
814 | - <p><input class="button" type="submit" value="<?php esc_attr_e( 'Update Translations' ); ?>" name="upgrade" /></p> |
|
810 | + <h2><?php _e('Translations'); ?></h2> |
|
811 | + <form method="post" action="<?php echo esc_url($form_action); ?>" name="upgrade-translations" class="upgrade"> |
|
812 | + <p><?php _e('New translations are available.'); ?></p> |
|
813 | + <?php wp_nonce_field('upgrade-translations'); ?> |
|
814 | + <p><input class="button" type="submit" value="<?php esc_attr_e('Update Translations'); ?>" name="upgrade" /></p> |
|
815 | 815 | </form> |
816 | 816 | <?php |
817 | 817 | } |
@@ -825,60 +825,60 @@ discard block |
||
825 | 825 | * |
826 | 826 | * @param bool $reinstall |
827 | 827 | */ |
828 | -function do_core_upgrade( $reinstall = false ) { |
|
828 | +function do_core_upgrade($reinstall = false) { |
|
829 | 829 | global $wp_filesystem; |
830 | 830 | |
831 | 831 | require_once ABSPATH . 'wp-admin/includes/class-wp-upgrader.php'; |
832 | 832 | |
833 | - if ( $reinstall ) { |
|
833 | + if ($reinstall) { |
|
834 | 834 | $url = 'update-core.php?action=do-core-reinstall'; |
835 | 835 | } else { |
836 | 836 | $url = 'update-core.php?action=do-core-upgrade'; |
837 | 837 | } |
838 | - $url = wp_nonce_url( $url, 'upgrade-core' ); |
|
838 | + $url = wp_nonce_url($url, 'upgrade-core'); |
|
839 | 839 | |
840 | - $version = isset( $_POST['version'] ) ? $_POST['version'] : false; |
|
841 | - $locale = isset( $_POST['locale'] ) ? $_POST['locale'] : 'en_US'; |
|
842 | - $update = find_core_update( $version, $locale ); |
|
843 | - if ( ! $update ) { |
|
840 | + $version = isset($_POST['version']) ? $_POST['version'] : false; |
|
841 | + $locale = isset($_POST['locale']) ? $_POST['locale'] : 'en_US'; |
|
842 | + $update = find_core_update($version, $locale); |
|
843 | + if (!$update) { |
|
844 | 844 | return; |
845 | 845 | } |
846 | 846 | |
847 | 847 | // Allow relaxed file ownership writes for User-initiated upgrades when the API specifies |
848 | 848 | // that it's safe to do so. This only happens when there are no new files to create. |
849 | - $allow_relaxed_file_ownership = ! $reinstall && isset( $update->new_files ) && ! $update->new_files; |
|
849 | + $allow_relaxed_file_ownership = !$reinstall && isset($update->new_files) && !$update->new_files; |
|
850 | 850 | |
851 | 851 | ?> |
852 | 852 | <div class="wrap"> |
853 | - <h1><?php _e( 'Update WordPress' ); ?></h1> |
|
853 | + <h1><?php _e('Update WordPress'); ?></h1> |
|
854 | 854 | <?php |
855 | 855 | |
856 | - $credentials = request_filesystem_credentials( $url, '', false, ABSPATH, array( 'version', 'locale' ), $allow_relaxed_file_ownership ); |
|
857 | - if ( false === $credentials ) { |
|
856 | + $credentials = request_filesystem_credentials($url, '', false, ABSPATH, array('version', 'locale'), $allow_relaxed_file_ownership); |
|
857 | + if (false === $credentials) { |
|
858 | 858 | echo '</div>'; |
859 | 859 | return; |
860 | 860 | } |
861 | 861 | |
862 | - if ( ! WP_Filesystem( $credentials, ABSPATH, $allow_relaxed_file_ownership ) ) { |
|
862 | + if (!WP_Filesystem($credentials, ABSPATH, $allow_relaxed_file_ownership)) { |
|
863 | 863 | // Failed to connect. Error and request again. |
864 | - request_filesystem_credentials( $url, '', true, ABSPATH, array( 'version', 'locale' ), $allow_relaxed_file_ownership ); |
|
864 | + request_filesystem_credentials($url, '', true, ABSPATH, array('version', 'locale'), $allow_relaxed_file_ownership); |
|
865 | 865 | echo '</div>'; |
866 | 866 | return; |
867 | 867 | } |
868 | 868 | |
869 | - if ( $wp_filesystem->errors->has_errors() ) { |
|
870 | - foreach ( $wp_filesystem->errors->get_error_messages() as $message ) { |
|
871 | - show_message( $message ); |
|
869 | + if ($wp_filesystem->errors->has_errors()) { |
|
870 | + foreach ($wp_filesystem->errors->get_error_messages() as $message) { |
|
871 | + show_message($message); |
|
872 | 872 | } |
873 | 873 | echo '</div>'; |
874 | 874 | return; |
875 | 875 | } |
876 | 876 | |
877 | - if ( $reinstall ) { |
|
877 | + if ($reinstall) { |
|
878 | 878 | $update->response = 'reinstall'; |
879 | 879 | } |
880 | 880 | |
881 | - add_filter( 'update_feedback', 'show_message' ); |
|
881 | + add_filter('update_feedback', 'show_message'); |
|
882 | 882 | |
883 | 883 | $upgrader = new Core_Upgrader(); |
884 | 884 | $result = $upgrader->upgrade( |
@@ -888,36 +888,36 @@ discard block |
||
888 | 888 | ) |
889 | 889 | ); |
890 | 890 | |
891 | - if ( is_wp_error( $result ) ) { |
|
892 | - show_message( $result ); |
|
893 | - if ( 'up_to_date' != $result->get_error_code() && 'locked' != $result->get_error_code() ) { |
|
894 | - show_message( __( 'Installation failed.' ) ); |
|
891 | + if (is_wp_error($result)) { |
|
892 | + show_message($result); |
|
893 | + if ('up_to_date' != $result->get_error_code() && 'locked' != $result->get_error_code()) { |
|
894 | + show_message(__('Installation failed.')); |
|
895 | 895 | } |
896 | 896 | echo '</div>'; |
897 | 897 | return; |
898 | 898 | } |
899 | 899 | |
900 | - show_message( __( 'WordPress updated successfully.' ) ); |
|
900 | + show_message(__('WordPress updated successfully.')); |
|
901 | 901 | show_message( |
902 | 902 | '<span class="hide-if-no-js">' . sprintf( |
903 | 903 | /* translators: 1: WordPress version, 2: URL to About screen. */ |
904 | - __( 'Welcome to WordPress %1$s. You will be redirected to the About WordPress screen. If not, click <a href="%2$s">here</a>.' ), |
|
904 | + __('Welcome to WordPress %1$s. You will be redirected to the About WordPress screen. If not, click <a href="%2$s">here</a>.'), |
|
905 | 905 | $result, |
906 | - esc_url( self_admin_url( 'about.php?updated' ) ) |
|
906 | + esc_url(self_admin_url('about.php?updated')) |
|
907 | 907 | ) . '</span>' |
908 | 908 | ); |
909 | 909 | show_message( |
910 | 910 | '<span class="hide-if-js">' . sprintf( |
911 | 911 | /* translators: 1: WordPress version, 2: URL to About screen. */ |
912 | - __( 'Welcome to WordPress %1$s. <a href="%2$s">Learn more</a>.' ), |
|
912 | + __('Welcome to WordPress %1$s. <a href="%2$s">Learn more</a>.'), |
|
913 | 913 | $result, |
914 | - esc_url( self_admin_url( 'about.php?updated' ) ) |
|
914 | + esc_url(self_admin_url('about.php?updated')) |
|
915 | 915 | ) . '</span>' |
916 | 916 | ); |
917 | 917 | ?> |
918 | 918 | </div> |
919 | 919 | <script type="text/javascript"> |
920 | - window.location = '<?php echo self_admin_url( 'about.php?updated' ); ?>'; |
|
920 | + window.location = '<?php echo self_admin_url('about.php?updated'); ?>'; |
|
921 | 921 | </script> |
922 | 922 | <?php |
923 | 923 | } |
@@ -928,14 +928,14 @@ discard block |
||
928 | 928 | * @since 2.7.0 |
929 | 929 | */ |
930 | 930 | function do_dismiss_core_update() { |
931 | - $version = isset( $_POST['version'] ) ? $_POST['version'] : false; |
|
932 | - $locale = isset( $_POST['locale'] ) ? $_POST['locale'] : 'en_US'; |
|
933 | - $update = find_core_update( $version, $locale ); |
|
934 | - if ( ! $update ) { |
|
931 | + $version = isset($_POST['version']) ? $_POST['version'] : false; |
|
932 | + $locale = isset($_POST['locale']) ? $_POST['locale'] : 'en_US'; |
|
933 | + $update = find_core_update($version, $locale); |
|
934 | + if (!$update) { |
|
935 | 935 | return; |
936 | 936 | } |
937 | - dismiss_core_update( $update ); |
|
938 | - wp_redirect( wp_nonce_url( 'update-core.php?action=upgrade-core', 'upgrade-core' ) ); |
|
937 | + dismiss_core_update($update); |
|
938 | + wp_redirect(wp_nonce_url('update-core.php?action=upgrade-core', 'upgrade-core')); |
|
939 | 939 | exit; |
940 | 940 | } |
941 | 941 | |
@@ -945,130 +945,130 @@ discard block |
||
945 | 945 | * @since 2.7.0 |
946 | 946 | */ |
947 | 947 | function do_undismiss_core_update() { |
948 | - $version = isset( $_POST['version'] ) ? $_POST['version'] : false; |
|
949 | - $locale = isset( $_POST['locale'] ) ? $_POST['locale'] : 'en_US'; |
|
950 | - $update = find_core_update( $version, $locale ); |
|
951 | - if ( ! $update ) { |
|
948 | + $version = isset($_POST['version']) ? $_POST['version'] : false; |
|
949 | + $locale = isset($_POST['locale']) ? $_POST['locale'] : 'en_US'; |
|
950 | + $update = find_core_update($version, $locale); |
|
951 | + if (!$update) { |
|
952 | 952 | return; |
953 | 953 | } |
954 | - undismiss_core_update( $version, $locale ); |
|
955 | - wp_redirect( wp_nonce_url( 'update-core.php?action=upgrade-core', 'upgrade-core' ) ); |
|
954 | + undismiss_core_update($version, $locale); |
|
955 | + wp_redirect(wp_nonce_url('update-core.php?action=upgrade-core', 'upgrade-core')); |
|
956 | 956 | exit; |
957 | 957 | } |
958 | 958 | |
959 | -$action = isset( $_GET['action'] ) ? $_GET['action'] : 'upgrade-core'; |
|
959 | +$action = isset($_GET['action']) ? $_GET['action'] : 'upgrade-core'; |
|
960 | 960 | |
961 | 961 | $upgrade_error = false; |
962 | -if ( ( 'do-theme-upgrade' === $action || ( 'do-plugin-upgrade' === $action && ! isset( $_GET['plugins'] ) ) ) |
|
963 | - && ! isset( $_POST['checked'] ) ) { |
|
964 | - $upgrade_error = ( 'do-theme-upgrade' === $action ) ? 'themes' : 'plugins'; |
|
962 | +if (('do-theme-upgrade' === $action || ('do-plugin-upgrade' === $action && !isset($_GET['plugins']))) |
|
963 | + && !isset($_POST['checked'])) { |
|
964 | + $upgrade_error = ('do-theme-upgrade' === $action) ? 'themes' : 'plugins'; |
|
965 | 965 | $action = 'upgrade-core'; |
966 | 966 | } |
967 | 967 | |
968 | -$title = __( 'WordPress Updates' ); |
|
968 | +$title = __('WordPress Updates'); |
|
969 | 969 | $parent_file = 'index.php'; |
970 | 970 | |
971 | -$updates_overview = '<p>' . __( 'On this screen, you can update to the latest version of WordPress, as well as update your themes, plugins, and translations from the WordPress.org repositories.' ) . '</p>'; |
|
972 | -$updates_overview .= '<p>' . __( 'If an update is available, you᾿ll see a notification appear in the Toolbar and navigation menu.' ) . ' ' . __( 'Keeping your site updated is important for security. It also makes the internet a safer place for you and your readers.' ) . '</p>'; |
|
971 | +$updates_overview = '<p>' . __('On this screen, you can update to the latest version of WordPress, as well as update your themes, plugins, and translations from the WordPress.org repositories.') . '</p>'; |
|
972 | +$updates_overview .= '<p>' . __('If an update is available, you᾿ll see a notification appear in the Toolbar and navigation menu.') . ' ' . __('Keeping your site updated is important for security. It also makes the internet a safer place for you and your readers.') . '</p>'; |
|
973 | 973 | |
974 | 974 | get_current_screen()->add_help_tab( |
975 | 975 | array( |
976 | 976 | 'id' => 'overview', |
977 | - 'title' => __( 'Overview' ), |
|
977 | + 'title' => __('Overview'), |
|
978 | 978 | 'content' => $updates_overview, |
979 | 979 | ) |
980 | 980 | ); |
981 | 981 | |
982 | -$updates_howto = '<p>' . __( '<strong>WordPress</strong> — Updating your WordPress installation is a simple one-click procedure: just <strong>click on the “Update now” button</strong> when you are notified that a new version is available.' ) . ' ' . __( 'In most cases, WordPress will automatically apply maintenance and security updates in the background for you.' ) . '</p>'; |
|
983 | -$updates_howto .= '<p>' . __( '<strong>Themes and Plugins</strong> — To update individual themes or plugins from this screen, use the checkboxes to make your selection, then <strong>click on the appropriate “Update” button</strong>. To update all of your themes or plugins at once, you can check the box at the top of the section to select all before clicking the update button.' ) . '</p>'; |
|
982 | +$updates_howto = '<p>' . __('<strong>WordPress</strong> — Updating your WordPress installation is a simple one-click procedure: just <strong>click on the “Update now” button</strong> when you are notified that a new version is available.') . ' ' . __('In most cases, WordPress will automatically apply maintenance and security updates in the background for you.') . '</p>'; |
|
983 | +$updates_howto .= '<p>' . __('<strong>Themes and Plugins</strong> — To update individual themes or plugins from this screen, use the checkboxes to make your selection, then <strong>click on the appropriate “Update” button</strong>. To update all of your themes or plugins at once, you can check the box at the top of the section to select all before clicking the update button.') . '</p>'; |
|
984 | 984 | |
985 | -if ( 'en_US' !== get_locale() ) { |
|
986 | - $updates_howto .= '<p>' . __( '<strong>Translations</strong> — The files translating WordPress into your language are updated for you whenever any other updates occur. But if these files are out of date, you can <strong>click the “Update Translations”</strong> button.' ) . '</p>'; |
|
985 | +if ('en_US' !== get_locale()) { |
|
986 | + $updates_howto .= '<p>' . __('<strong>Translations</strong> — The files translating WordPress into your language are updated for you whenever any other updates occur. But if these files are out of date, you can <strong>click the “Update Translations”</strong> button.') . '</p>'; |
|
987 | 987 | } |
988 | 988 | |
989 | 989 | get_current_screen()->add_help_tab( |
990 | 990 | array( |
991 | 991 | 'id' => 'how-to-update', |
992 | - 'title' => __( 'How to Update' ), |
|
992 | + 'title' => __('How to Update'), |
|
993 | 993 | 'content' => $updates_howto, |
994 | 994 | ) |
995 | 995 | ); |
996 | 996 | |
997 | 997 | $help_sidebar_autoupdates = ''; |
998 | 998 | |
999 | -if ( ( current_user_can( 'update_themes' ) && wp_is_auto_update_enabled_for_type( 'theme' ) ) || ( current_user_can( 'update_plugins' ) && wp_is_auto_update_enabled_for_type( 'plugin' ) ) ) { |
|
1000 | - $help_tab_autoupdates = '<p>' . __( 'Auto-updates can be enabled or disabled for WordPress major versions and for each individual theme or plugin. Themes or plugins with auto-updates enabled will display the estimated date of the next auto-update. Auto-updates depends on the WP-Cron task scheduling system.' ) . '</p>'; |
|
1001 | - $help_tab_autoupdates .= '<p>' . __( 'Please note: Third-party themes and plugins, or custom code, may override WordPress scheduling.' ) . '</p>'; |
|
999 | +if ((current_user_can('update_themes') && wp_is_auto_update_enabled_for_type('theme')) || (current_user_can('update_plugins') && wp_is_auto_update_enabled_for_type('plugin'))) { |
|
1000 | + $help_tab_autoupdates = '<p>' . __('Auto-updates can be enabled or disabled for WordPress major versions and for each individual theme or plugin. Themes or plugins with auto-updates enabled will display the estimated date of the next auto-update. Auto-updates depends on the WP-Cron task scheduling system.') . '</p>'; |
|
1001 | + $help_tab_autoupdates .= '<p>' . __('Please note: Third-party themes and plugins, or custom code, may override WordPress scheduling.') . '</p>'; |
|
1002 | 1002 | |
1003 | 1003 | get_current_screen()->add_help_tab( |
1004 | 1004 | array( |
1005 | 1005 | 'id' => 'plugins-themes-auto-updates', |
1006 | - 'title' => __( 'Auto-updates' ), |
|
1006 | + 'title' => __('Auto-updates'), |
|
1007 | 1007 | 'content' => $help_tab_autoupdates, |
1008 | 1008 | ) |
1009 | 1009 | ); |
1010 | 1010 | |
1011 | - $help_sidebar_autoupdates = '<p>' . __( '<a href="https://wordpress.org/support/article/plugins-themes-auto-updates/">Learn more: Auto-updates documentation</a>' ) . '</p>'; |
|
1011 | + $help_sidebar_autoupdates = '<p>' . __('<a href="https://wordpress.org/support/article/plugins-themes-auto-updates/">Learn more: Auto-updates documentation</a>') . '</p>'; |
|
1012 | 1012 | } |
1013 | 1013 | |
1014 | 1014 | get_current_screen()->set_help_sidebar( |
1015 | - '<p><strong>' . __( 'For more information:' ) . '</strong></p>' . |
|
1016 | - '<p>' . __( '<a href="https://wordpress.org/support/article/dashboard-updates-screen/">Documentation on Updating WordPress</a>' ) . '</p>' . |
|
1015 | + '<p><strong>' . __('For more information:') . '</strong></p>' . |
|
1016 | + '<p>' . __('<a href="https://wordpress.org/support/article/dashboard-updates-screen/">Documentation on Updating WordPress</a>') . '</p>' . |
|
1017 | 1017 | $help_sidebar_autoupdates . |
1018 | - '<p>' . __( '<a href="https://wordpress.org/support/">Support</a>' ) . '</p>' |
|
1018 | + '<p>' . __('<a href="https://wordpress.org/support/">Support</a>') . '</p>' |
|
1019 | 1019 | ); |
1020 | 1020 | |
1021 | -if ( 'upgrade-core' === $action ) { |
|
1021 | +if ('upgrade-core' === $action) { |
|
1022 | 1022 | // Force a update check when requested. |
1023 | - $force_check = ! empty( $_GET['force-check'] ); |
|
1024 | - wp_version_check( array(), $force_check ); |
|
1023 | + $force_check = !empty($_GET['force-check']); |
|
1024 | + wp_version_check(array(), $force_check); |
|
1025 | 1025 | |
1026 | 1026 | require_once ABSPATH . 'wp-admin/admin-header.php'; |
1027 | 1027 | ?> |
1028 | 1028 | <div class="wrap"> |
1029 | - <h1><?php _e( 'WordPress Updates' ); ?></h1> |
|
1030 | - <p><?php _e( 'Here you can find information about updates, set auto-updates and see what plugins or themes need updating.' ); ?></p> |
|
1029 | + <h1><?php _e('WordPress Updates'); ?></h1> |
|
1030 | + <p><?php _e('Here you can find information about updates, set auto-updates and see what plugins or themes need updating.'); ?></p> |
|
1031 | 1031 | |
1032 | 1032 | <?php |
1033 | - if ( $upgrade_error ) { |
|
1033 | + if ($upgrade_error) { |
|
1034 | 1034 | echo '<div class="error"><p>'; |
1035 | - if ( 'themes' === $upgrade_error ) { |
|
1036 | - _e( 'Please select one or more themes to update.' ); |
|
1035 | + if ('themes' === $upgrade_error) { |
|
1036 | + _e('Please select one or more themes to update.'); |
|
1037 | 1037 | } else { |
1038 | - _e( 'Please select one or more plugins to update.' ); |
|
1038 | + _e('Please select one or more plugins to update.'); |
|
1039 | 1039 | } |
1040 | 1040 | echo '</p></div>'; |
1041 | 1041 | } |
1042 | 1042 | |
1043 | 1043 | $last_update_check = false; |
1044 | - $current = get_site_transient( 'update_core' ); |
|
1044 | + $current = get_site_transient('update_core'); |
|
1045 | 1045 | |
1046 | - if ( $current && isset( $current->last_checked ) ) { |
|
1047 | - $last_update_check = $current->last_checked + get_option( 'gmt_offset' ) * HOUR_IN_SECONDS; |
|
1046 | + if ($current && isset($current->last_checked)) { |
|
1047 | + $last_update_check = $current->last_checked + get_option('gmt_offset') * HOUR_IN_SECONDS; |
|
1048 | 1048 | } |
1049 | 1049 | |
1050 | 1050 | echo '<h2 class="wp-current-version">'; |
1051 | 1051 | /* translators: Current version of WordPress. */ |
1052 | - printf( __( 'Current version: %s' ), get_bloginfo( 'version' ) ); |
|
1052 | + printf(__('Current version: %s'), get_bloginfo('version')); |
|
1053 | 1053 | echo '</h2>'; |
1054 | 1054 | |
1055 | 1055 | echo '<p class="update-last-checked">'; |
1056 | 1056 | /* translators: 1: Date, 2: Time. */ |
1057 | - printf( __( 'Last checked on %1$s at %2$s.' ), date_i18n( __( 'F j, Y' ), $last_update_check ), date_i18n( __( 'g:i a T' ), $last_update_check ) ); |
|
1058 | - echo ' <a href="' . esc_url( self_admin_url( 'update-core.php?force-check=1' ) ) . '">' . __( 'Check again.' ) . '</a>'; |
|
1057 | + printf(__('Last checked on %1$s at %2$s.'), date_i18n(__('F j, Y'), $last_update_check), date_i18n(__('g:i a T'), $last_update_check)); |
|
1058 | + echo ' <a href="' . esc_url(self_admin_url('update-core.php?force-check=1')) . '">' . __('Check again.') . '</a>'; |
|
1059 | 1059 | echo '</p>'; |
1060 | 1060 | |
1061 | - if ( current_user_can( 'update_core' ) ) { |
|
1061 | + if (current_user_can('update_core')) { |
|
1062 | 1062 | core_auto_updates_settings(); |
1063 | 1063 | core_upgrade_preamble(); |
1064 | 1064 | } |
1065 | - if ( current_user_can( 'update_plugins' ) ) { |
|
1065 | + if (current_user_can('update_plugins')) { |
|
1066 | 1066 | list_plugin_updates(); |
1067 | 1067 | } |
1068 | - if ( current_user_can( 'update_themes' ) ) { |
|
1068 | + if (current_user_can('update_themes')) { |
|
1069 | 1069 | list_theme_updates(); |
1070 | 1070 | } |
1071 | - if ( current_user_can( 'update_languages' ) ) { |
|
1071 | + if (current_user_can('update_languages')) { |
|
1072 | 1072 | list_translation_updates(); |
1073 | 1073 | } |
1074 | 1074 | |
@@ -1077,7 +1077,7 @@ discard block |
||
1077 | 1077 | * |
1078 | 1078 | * @since 2.9.0 |
1079 | 1079 | */ |
1080 | - do_action( 'core_upgrade_preamble' ); |
|
1080 | + do_action('core_upgrade_preamble'); |
|
1081 | 1081 | echo '</div>'; |
1082 | 1082 | |
1083 | 1083 | wp_localize_script( |
@@ -1090,30 +1090,30 @@ discard block |
||
1090 | 1090 | |
1091 | 1091 | require_once ABSPATH . 'wp-admin/admin-footer.php'; |
1092 | 1092 | |
1093 | -} elseif ( 'do-core-upgrade' === $action || 'do-core-reinstall' === $action ) { |
|
1093 | +} elseif ('do-core-upgrade' === $action || 'do-core-reinstall' === $action) { |
|
1094 | 1094 | |
1095 | - if ( ! current_user_can( 'update_core' ) ) { |
|
1096 | - wp_die( __( 'Sorry, you are not allowed to update this site.' ) ); |
|
1095 | + if (!current_user_can('update_core')) { |
|
1096 | + wp_die(__('Sorry, you are not allowed to update this site.')); |
|
1097 | 1097 | } |
1098 | 1098 | |
1099 | - check_admin_referer( 'upgrade-core' ); |
|
1099 | + check_admin_referer('upgrade-core'); |
|
1100 | 1100 | |
1101 | 1101 | // Do the (un)dismiss actions before headers, so that they can redirect. |
1102 | - if ( isset( $_POST['dismiss'] ) ) { |
|
1102 | + if (isset($_POST['dismiss'])) { |
|
1103 | 1103 | do_dismiss_core_update(); |
1104 | - } elseif ( isset( $_POST['undismiss'] ) ) { |
|
1104 | + } elseif (isset($_POST['undismiss'])) { |
|
1105 | 1105 | do_undismiss_core_update(); |
1106 | 1106 | } |
1107 | 1107 | |
1108 | 1108 | require_once ABSPATH . 'wp-admin/admin-header.php'; |
1109 | - if ( 'do-core-reinstall' === $action ) { |
|
1109 | + if ('do-core-reinstall' === $action) { |
|
1110 | 1110 | $reinstall = true; |
1111 | 1111 | } else { |
1112 | 1112 | $reinstall = false; |
1113 | 1113 | } |
1114 | 1114 | |
1115 | - if ( isset( $_POST['upgrade'] ) ) { |
|
1116 | - do_core_upgrade( $reinstall ); |
|
1115 | + if (isset($_POST['upgrade'])) { |
|
1116 | + do_core_upgrade($reinstall); |
|
1117 | 1117 | } |
1118 | 1118 | |
1119 | 1119 | wp_localize_script( |
@@ -1126,34 +1126,34 @@ discard block |
||
1126 | 1126 | |
1127 | 1127 | require_once ABSPATH . 'wp-admin/admin-footer.php'; |
1128 | 1128 | |
1129 | -} elseif ( 'do-plugin-upgrade' === $action ) { |
|
1129 | +} elseif ('do-plugin-upgrade' === $action) { |
|
1130 | 1130 | |
1131 | - if ( ! current_user_can( 'update_plugins' ) ) { |
|
1132 | - wp_die( __( 'Sorry, you are not allowed to update this site.' ) ); |
|
1131 | + if (!current_user_can('update_plugins')) { |
|
1132 | + wp_die(__('Sorry, you are not allowed to update this site.')); |
|
1133 | 1133 | } |
1134 | 1134 | |
1135 | - check_admin_referer( 'upgrade-core' ); |
|
1135 | + check_admin_referer('upgrade-core'); |
|
1136 | 1136 | |
1137 | - if ( isset( $_GET['plugins'] ) ) { |
|
1138 | - $plugins = explode( ',', $_GET['plugins'] ); |
|
1139 | - } elseif ( isset( $_POST['checked'] ) ) { |
|
1137 | + if (isset($_GET['plugins'])) { |
|
1138 | + $plugins = explode(',', $_GET['plugins']); |
|
1139 | + } elseif (isset($_POST['checked'])) { |
|
1140 | 1140 | $plugins = (array) $_POST['checked']; |
1141 | 1141 | } else { |
1142 | - wp_redirect( admin_url( 'update-core.php' ) ); |
|
1142 | + wp_redirect(admin_url('update-core.php')); |
|
1143 | 1143 | exit; |
1144 | 1144 | } |
1145 | 1145 | |
1146 | - $url = 'update.php?action=update-selected&plugins=' . urlencode( implode( ',', $plugins ) ); |
|
1147 | - $url = wp_nonce_url( $url, 'bulk-update-plugins' ); |
|
1146 | + $url = 'update.php?action=update-selected&plugins=' . urlencode(implode(',', $plugins)); |
|
1147 | + $url = wp_nonce_url($url, 'bulk-update-plugins'); |
|
1148 | 1148 | |
1149 | 1149 | // Used in the HTML title tag. |
1150 | - $title = __( 'Update Plugins' ); |
|
1150 | + $title = __('Update Plugins'); |
|
1151 | 1151 | |
1152 | 1152 | require_once ABSPATH . 'wp-admin/admin-header.php'; |
1153 | 1153 | ?> |
1154 | 1154 | <div class="wrap"> |
1155 | - <h1><?php _e( 'Update Plugins' ); ?></h1> |
|
1156 | - <iframe src="<?php echo $url; ?>" style="width: 100%; height: 100%; min-height: 750px;" frameborder="0" title="<?php esc_attr_e( 'Update progress' ); ?>"></iframe> |
|
1155 | + <h1><?php _e('Update Plugins'); ?></h1> |
|
1156 | + <iframe src="<?php echo $url; ?>" style="width: 100%; height: 100%; min-height: 750px;" frameborder="0" title="<?php esc_attr_e('Update progress'); ?>"></iframe> |
|
1157 | 1157 | </div> |
1158 | 1158 | <?php |
1159 | 1159 | |
@@ -1167,34 +1167,34 @@ discard block |
||
1167 | 1167 | |
1168 | 1168 | require_once ABSPATH . 'wp-admin/admin-footer.php'; |
1169 | 1169 | |
1170 | -} elseif ( 'do-theme-upgrade' === $action ) { |
|
1170 | +} elseif ('do-theme-upgrade' === $action) { |
|
1171 | 1171 | |
1172 | - if ( ! current_user_can( 'update_themes' ) ) { |
|
1173 | - wp_die( __( 'Sorry, you are not allowed to update this site.' ) ); |
|
1172 | + if (!current_user_can('update_themes')) { |
|
1173 | + wp_die(__('Sorry, you are not allowed to update this site.')); |
|
1174 | 1174 | } |
1175 | 1175 | |
1176 | - check_admin_referer( 'upgrade-core' ); |
|
1176 | + check_admin_referer('upgrade-core'); |
|
1177 | 1177 | |
1178 | - if ( isset( $_GET['themes'] ) ) { |
|
1179 | - $themes = explode( ',', $_GET['themes'] ); |
|
1180 | - } elseif ( isset( $_POST['checked'] ) ) { |
|
1178 | + if (isset($_GET['themes'])) { |
|
1179 | + $themes = explode(',', $_GET['themes']); |
|
1180 | + } elseif (isset($_POST['checked'])) { |
|
1181 | 1181 | $themes = (array) $_POST['checked']; |
1182 | 1182 | } else { |
1183 | - wp_redirect( admin_url( 'update-core.php' ) ); |
|
1183 | + wp_redirect(admin_url('update-core.php')); |
|
1184 | 1184 | exit; |
1185 | 1185 | } |
1186 | 1186 | |
1187 | - $url = 'update.php?action=update-selected-themes&themes=' . urlencode( implode( ',', $themes ) ); |
|
1188 | - $url = wp_nonce_url( $url, 'bulk-update-themes' ); |
|
1187 | + $url = 'update.php?action=update-selected-themes&themes=' . urlencode(implode(',', $themes)); |
|
1188 | + $url = wp_nonce_url($url, 'bulk-update-themes'); |
|
1189 | 1189 | |
1190 | 1190 | // Used in the HTML title tag. |
1191 | - $title = __( 'Update Themes' ); |
|
1191 | + $title = __('Update Themes'); |
|
1192 | 1192 | |
1193 | 1193 | require_once ABSPATH . 'wp-admin/admin-header.php'; |
1194 | 1194 | ?> |
1195 | 1195 | <div class="wrap"> |
1196 | - <h1><?php _e( 'Update Themes' ); ?></h1> |
|
1197 | - <iframe src="<?php echo $url; ?>" style="width: 100%; height: 100%; min-height: 750px;" frameborder="0" title="<?php esc_attr_e( 'Update progress' ); ?>"></iframe> |
|
1196 | + <h1><?php _e('Update Themes'); ?></h1> |
|
1197 | + <iframe src="<?php echo $url; ?>" style="width: 100%; height: 100%; min-height: 750px;" frameborder="0" title="<?php esc_attr_e('Update progress'); ?>"></iframe> |
|
1198 | 1198 | </div> |
1199 | 1199 | <?php |
1200 | 1200 | |
@@ -1208,23 +1208,23 @@ discard block |
||
1208 | 1208 | |
1209 | 1209 | require_once ABSPATH . 'wp-admin/admin-footer.php'; |
1210 | 1210 | |
1211 | -} elseif ( 'do-translation-upgrade' === $action ) { |
|
1211 | +} elseif ('do-translation-upgrade' === $action) { |
|
1212 | 1212 | |
1213 | - if ( ! current_user_can( 'update_languages' ) ) { |
|
1214 | - wp_die( __( 'Sorry, you are not allowed to update this site.' ) ); |
|
1213 | + if (!current_user_can('update_languages')) { |
|
1214 | + wp_die(__('Sorry, you are not allowed to update this site.')); |
|
1215 | 1215 | } |
1216 | 1216 | |
1217 | - check_admin_referer( 'upgrade-translations' ); |
|
1217 | + check_admin_referer('upgrade-translations'); |
|
1218 | 1218 | |
1219 | 1219 | require_once ABSPATH . 'wp-admin/admin-header.php'; |
1220 | 1220 | require_once ABSPATH . 'wp-admin/includes/class-wp-upgrader.php'; |
1221 | 1221 | |
1222 | 1222 | $url = 'update-core.php?action=do-translation-upgrade'; |
1223 | 1223 | $nonce = 'upgrade-translations'; |
1224 | - $title = __( 'Update Translations' ); |
|
1224 | + $title = __('Update Translations'); |
|
1225 | 1225 | $context = WP_LANG_DIR; |
1226 | 1226 | |
1227 | - $upgrader = new Language_Pack_Upgrader( new Language_Pack_Upgrader_Skin( compact( 'url', 'nonce', 'title', 'context' ) ) ); |
|
1227 | + $upgrader = new Language_Pack_Upgrader(new Language_Pack_Upgrader_Skin(compact('url', 'nonce', 'title', 'context'))); |
|
1228 | 1228 | $result = $upgrader->bulk_upgrade(); |
1229 | 1229 | |
1230 | 1230 | wp_localize_script( |
@@ -1237,27 +1237,27 @@ discard block |
||
1237 | 1237 | |
1238 | 1238 | require_once ABSPATH . 'wp-admin/admin-footer.php'; |
1239 | 1239 | |
1240 | -} elseif ( 'core-major-auto-updates-settings' === $action ) { |
|
1240 | +} elseif ('core-major-auto-updates-settings' === $action) { |
|
1241 | 1241 | |
1242 | - if ( ! current_user_can( 'update_core' ) ) { |
|
1243 | - wp_die( __( 'Sorry, you are not allowed to update this site.' ) ); |
|
1242 | + if (!current_user_can('update_core')) { |
|
1243 | + wp_die(__('Sorry, you are not allowed to update this site.')); |
|
1244 | 1244 | } |
1245 | 1245 | |
1246 | - $redirect_url = self_admin_url( 'update-core.php' ); |
|
1246 | + $redirect_url = self_admin_url('update-core.php'); |
|
1247 | 1247 | |
1248 | - if ( isset( $_GET['value'] ) ) { |
|
1249 | - check_admin_referer( 'core-major-auto-updates-nonce' ); |
|
1248 | + if (isset($_GET['value'])) { |
|
1249 | + check_admin_referer('core-major-auto-updates-nonce'); |
|
1250 | 1250 | |
1251 | - if ( 'enable' === $_GET['value'] ) { |
|
1252 | - update_site_option( 'auto_update_core_major', 'enabled' ); |
|
1253 | - $redirect_url = add_query_arg( 'core-major-auto-updates-saved', 'enabled', $redirect_url ); |
|
1254 | - } elseif ( 'disable' === $_GET['value'] ) { |
|
1255 | - update_site_option( 'auto_update_core_major', 'disabled' ); |
|
1256 | - $redirect_url = add_query_arg( 'core-major-auto-updates-saved', 'disabled', $redirect_url ); |
|
1251 | + if ('enable' === $_GET['value']) { |
|
1252 | + update_site_option('auto_update_core_major', 'enabled'); |
|
1253 | + $redirect_url = add_query_arg('core-major-auto-updates-saved', 'enabled', $redirect_url); |
|
1254 | + } elseif ('disable' === $_GET['value']) { |
|
1255 | + update_site_option('auto_update_core_major', 'disabled'); |
|
1256 | + $redirect_url = add_query_arg('core-major-auto-updates-saved', 'disabled', $redirect_url); |
|
1257 | 1257 | } |
1258 | 1258 | } |
1259 | 1259 | |
1260 | - wp_redirect( $redirect_url ); |
|
1260 | + wp_redirect($redirect_url); |
|
1261 | 1261 | exit; |
1262 | 1262 | } else { |
1263 | 1263 | /** |
@@ -1269,5 +1269,5 @@ discard block |
||
1269 | 1269 | * |
1270 | 1270 | * @since 3.2.0 |
1271 | 1271 | */ |
1272 | - do_action( "update-core-custom_{$action}" ); // phpcs:ignore WordPress.NamingConventions.ValidHookName.UseUnderscores |
|
1272 | + do_action("update-core-custom_{$action}"); // phpcs:ignore WordPress.NamingConventions.ValidHookName.UseUnderscores |
|
1273 | 1273 | } |
@@ -9,73 +9,73 @@ discard block |
||
9 | 9 | |
10 | 10 | require_once __DIR__ . '/admin.php'; |
11 | 11 | |
12 | -if ( ! is_multisite() ) { |
|
13 | - wp_die( __( 'Multisite support is not enabled.' ) ); |
|
12 | +if (!is_multisite()) { |
|
13 | + wp_die(__('Multisite support is not enabled.')); |
|
14 | 14 | } |
15 | 15 | |
16 | -if ( ! current_user_can( 'read' ) ) { |
|
17 | - wp_die( __( 'Sorry, you are not allowed to access this page.' ) ); |
|
16 | +if (!current_user_can('read')) { |
|
17 | + wp_die(__('Sorry, you are not allowed to access this page.')); |
|
18 | 18 | } |
19 | 19 | |
20 | -$action = isset( $_POST['action'] ) ? $_POST['action'] : 'splash'; |
|
20 | +$action = isset($_POST['action']) ? $_POST['action'] : 'splash'; |
|
21 | 21 | |
22 | -$blogs = get_blogs_of_user( $current_user->ID ); |
|
22 | +$blogs = get_blogs_of_user($current_user->ID); |
|
23 | 23 | |
24 | 24 | $updated = false; |
25 | -if ( 'updateblogsettings' === $action && isset( $_POST['primary_blog'] ) ) { |
|
26 | - check_admin_referer( 'update-my-sites' ); |
|
25 | +if ('updateblogsettings' === $action && isset($_POST['primary_blog'])) { |
|
26 | + check_admin_referer('update-my-sites'); |
|
27 | 27 | |
28 | - $blog = get_site( (int) $_POST['primary_blog'] ); |
|
29 | - if ( $blog && isset( $blog->domain ) ) { |
|
30 | - update_user_meta( $current_user->ID, 'primary_blog', (int) $_POST['primary_blog'] ); |
|
28 | + $blog = get_site((int) $_POST['primary_blog']); |
|
29 | + if ($blog && isset($blog->domain)) { |
|
30 | + update_user_meta($current_user->ID, 'primary_blog', (int) $_POST['primary_blog']); |
|
31 | 31 | $updated = true; |
32 | 32 | } else { |
33 | - wp_die( __( 'The primary site you chose does not exist.' ) ); |
|
33 | + wp_die(__('The primary site you chose does not exist.')); |
|
34 | 34 | } |
35 | 35 | } |
36 | 36 | |
37 | 37 | // Used in the HTML title tag. |
38 | -$title = __( 'My Sites' ); |
|
38 | +$title = __('My Sites'); |
|
39 | 39 | $parent_file = 'index.php'; |
40 | 40 | |
41 | 41 | get_current_screen()->add_help_tab( |
42 | 42 | array( |
43 | 43 | 'id' => 'overview', |
44 | - 'title' => __( 'Overview' ), |
|
44 | + 'title' => __('Overview'), |
|
45 | 45 | 'content' => |
46 | - '<p>' . __( 'This screen shows an individual user all of their sites in this network, and also allows that user to set a primary site. They can use the links under each site to visit either the front end or the dashboard for that site.' ) . '</p>', |
|
46 | + '<p>' . __('This screen shows an individual user all of their sites in this network, and also allows that user to set a primary site. They can use the links under each site to visit either the front end or the dashboard for that site.') . '</p>', |
|
47 | 47 | ) |
48 | 48 | ); |
49 | 49 | |
50 | 50 | get_current_screen()->set_help_sidebar( |
51 | - '<p><strong>' . __( 'For more information:' ) . '</strong></p>' . |
|
52 | - '<p>' . __( '<a href="https://codex.wordpress.org/Dashboard_My_Sites_Screen">Documentation on My Sites</a>' ) . '</p>' . |
|
53 | - '<p>' . __( '<a href="https://wordpress.org/support/">Support</a>' ) . '</p>' |
|
51 | + '<p><strong>' . __('For more information:') . '</strong></p>' . |
|
52 | + '<p>' . __('<a href="https://codex.wordpress.org/Dashboard_My_Sites_Screen">Documentation on My Sites</a>') . '</p>' . |
|
53 | + '<p>' . __('<a href="https://wordpress.org/support/">Support</a>') . '</p>' |
|
54 | 54 | ); |
55 | 55 | |
56 | 56 | require_once ABSPATH . 'wp-admin/admin-header.php'; |
57 | 57 | |
58 | -if ( $updated ) { ?> |
|
59 | - <div id="message" class="updated notice is-dismissible"><p><strong><?php _e( 'Settings saved.' ); ?></strong></p></div> |
|
58 | +if ($updated) { ?> |
|
59 | + <div id="message" class="updated notice is-dismissible"><p><strong><?php _e('Settings saved.'); ?></strong></p></div> |
|
60 | 60 | <?php } ?> |
61 | 61 | |
62 | 62 | <div class="wrap"> |
63 | 63 | <h1 class="wp-heading-inline"> |
64 | 64 | <?php |
65 | -echo esc_html( $title ); |
|
65 | +echo esc_html($title); |
|
66 | 66 | ?> |
67 | 67 | </h1> |
68 | 68 | |
69 | 69 | <?php |
70 | -if ( in_array( get_site_option( 'registration' ), array( 'all', 'blog' ), true ) ) { |
|
70 | +if (in_array(get_site_option('registration'), array('all', 'blog'), true)) { |
|
71 | 71 | /** This filter is documented in wp-login.php */ |
72 | - $sign_up_url = apply_filters( 'wp_signup_location', network_site_url( 'wp-signup.php' ) ); |
|
73 | - printf( ' <a href="%s" class="page-title-action">%s</a>', esc_url( $sign_up_url ), esc_html_x( 'Add New', 'site' ) ); |
|
72 | + $sign_up_url = apply_filters('wp_signup_location', network_site_url('wp-signup.php')); |
|
73 | + printf(' <a href="%s" class="page-title-action">%s</a>', esc_url($sign_up_url), esc_html_x('Add New', 'site')); |
|
74 | 74 | } |
75 | 75 | |
76 | -if ( empty( $blogs ) ) : |
|
76 | +if (empty($blogs)) : |
|
77 | 77 | echo '<p>'; |
78 | - _e( 'You must be a member of at least one site to use this page.' ); |
|
78 | + _e('You must be a member of at least one site to use this page.'); |
|
79 | 79 | echo '</p>'; |
80 | 80 | else : |
81 | 81 | ?> |
@@ -90,7 +90,7 @@ discard block |
||
90 | 90 | * |
91 | 91 | * @since 3.0.0 |
92 | 92 | */ |
93 | - do_action( 'myblogs_allblogs_options' ); |
|
93 | + do_action('myblogs_allblogs_options'); |
|
94 | 94 | ?> |
95 | 95 | <br clear="all" /> |
96 | 96 | <ul class="my-sites striped"> |
@@ -107,25 +107,25 @@ discard block |
||
107 | 107 | * @param string $settings_html The settings HTML markup. Default empty. |
108 | 108 | * @param string $context Context of the setting (global or site-specific). Default 'global'. |
109 | 109 | */ |
110 | - $settings_html = apply_filters( 'myblogs_options', '', 'global' ); |
|
110 | + $settings_html = apply_filters('myblogs_options', '', 'global'); |
|
111 | 111 | |
112 | - if ( $settings_html ) { |
|
113 | - echo '<h3>' . __( 'Global Settings' ) . '</h3>'; |
|
112 | + if ($settings_html) { |
|
113 | + echo '<h3>' . __('Global Settings') . '</h3>'; |
|
114 | 114 | echo $settings_html; |
115 | 115 | } |
116 | 116 | |
117 | - reset( $blogs ); |
|
117 | + reset($blogs); |
|
118 | 118 | |
119 | - foreach ( $blogs as $user_blog ) { |
|
120 | - switch_to_blog( $user_blog->userblog_id ); |
|
119 | + foreach ($blogs as $user_blog) { |
|
120 | + switch_to_blog($user_blog->userblog_id); |
|
121 | 121 | |
122 | 122 | echo '<li>'; |
123 | 123 | echo "<h3>{$user_blog->blogname}</h3>"; |
124 | 124 | |
125 | - $actions = "<a href='" . esc_url( home_url() ) . "'>" . __( 'Visit' ) . '</a>'; |
|
125 | + $actions = "<a href='" . esc_url(home_url()) . "'>" . __('Visit') . '</a>'; |
|
126 | 126 | |
127 | - if ( current_user_can( 'read' ) ) { |
|
128 | - $actions .= " | <a href='" . esc_url( admin_url() ) . "'>" . __( 'Dashboard' ) . '</a>'; |
|
127 | + if (current_user_can('read')) { |
|
128 | + $actions .= " | <a href='" . esc_url(admin_url()) . "'>" . __('Dashboard') . '</a>'; |
|
129 | 129 | } |
130 | 130 | |
131 | 131 | /** |
@@ -136,12 +136,12 @@ discard block |
||
136 | 136 | * @param string $actions The HTML site link markup. |
137 | 137 | * @param object $user_blog An object containing the site data. |
138 | 138 | */ |
139 | - $actions = apply_filters( 'myblogs_blog_actions', $actions, $user_blog ); |
|
139 | + $actions = apply_filters('myblogs_blog_actions', $actions, $user_blog); |
|
140 | 140 | |
141 | 141 | echo "<p class='my-sites-actions'>" . $actions . '</p>'; |
142 | 142 | |
143 | 143 | /** This filter is documented in wp-admin/my-sites.php */ |
144 | - echo apply_filters( 'myblogs_options', '', $user_blog ); |
|
144 | + echo apply_filters('myblogs_options', '', $user_blog); |
|
145 | 145 | |
146 | 146 | echo '</li>'; |
147 | 147 | |
@@ -150,11 +150,11 @@ discard block |
||
150 | 150 | ?> |
151 | 151 | </ul> |
152 | 152 | <?php |
153 | - if ( count( $blogs ) > 1 || has_action( 'myblogs_allblogs_options' ) || has_filter( 'myblogs_options' ) ) { |
|
153 | + if (count($blogs) > 1 || has_action('myblogs_allblogs_options') || has_filter('myblogs_options')) { |
|
154 | 154 | ?> |
155 | 155 | <input type="hidden" name="action" value="updateblogsettings" /> |
156 | 156 | <?php |
157 | - wp_nonce_field( 'update-my-sites' ); |
|
157 | + wp_nonce_field('update-my-sites'); |
|
158 | 158 | submit_button(); |
159 | 159 | } |
160 | 160 | ?> |
@@ -12,23 +12,23 @@ |
||
12 | 12 | /** WordPress Administration Widgets API */ |
13 | 13 | require_once ABSPATH . 'wp-admin/includes/widgets.php'; |
14 | 14 | |
15 | -if ( ! current_user_can( 'edit_theme_options' ) ) { |
|
15 | +if (!current_user_can('edit_theme_options')) { |
|
16 | 16 | wp_die( |
17 | - '<h1>' . __( 'You need a higher level of permission.' ) . '</h1>' . |
|
18 | - '<p>' . __( 'Sorry, you are not allowed to edit theme options on this site.' ) . '</p>', |
|
17 | + '<h1>' . __('You need a higher level of permission.') . '</h1>' . |
|
18 | + '<p>' . __('Sorry, you are not allowed to edit theme options on this site.') . '</p>', |
|
19 | 19 | 403 |
20 | 20 | ); |
21 | 21 | } |
22 | 22 | |
23 | -if ( ! current_theme_supports( 'widgets' ) ) { |
|
24 | - wp_die( __( 'The theme you are currently using is not widget-aware, meaning that it has no sidebars that you are able to change. For information on making your theme widget-aware, please <a href="https://developer.wordpress.org/themes/functionality/widgets/">follow these instructions</a>.' ) ); |
|
23 | +if (!current_theme_supports('widgets')) { |
|
24 | + wp_die(__('The theme you are currently using is not widget-aware, meaning that it has no sidebars that you are able to change. For information on making your theme widget-aware, please <a href="https://developer.wordpress.org/themes/functionality/widgets/">follow these instructions</a>.')); |
|
25 | 25 | } |
26 | 26 | |
27 | 27 | // Used in the HTML title tag. |
28 | -$title = __( 'Widgets' ); |
|
28 | +$title = __('Widgets'); |
|
29 | 29 | $parent_file = 'themes.php'; |
30 | 30 | |
31 | -if ( wp_use_widgets_block_editor() ) { |
|
31 | +if (wp_use_widgets_block_editor()) { |
|
32 | 32 | require ABSPATH . 'wp-admin/widgets-form-blocks.php'; |
33 | 33 | } else { |
34 | 34 | require ABSPATH . 'wp-admin/widgets-form.php'; |
@@ -10,54 +10,54 @@ discard block |
||
10 | 10 | /** WordPress Administration Bootstrap */ |
11 | 11 | require_once __DIR__ . '/admin.php'; |
12 | 12 | |
13 | -if ( ! current_user_can( 'list_users' ) ) { |
|
13 | +if (!current_user_can('list_users')) { |
|
14 | 14 | wp_die( |
15 | - '<h1>' . __( 'You need a higher level of permission.' ) . '</h1>' . |
|
16 | - '<p>' . __( 'Sorry, you are not allowed to list users.' ) . '</p>', |
|
15 | + '<h1>' . __('You need a higher level of permission.') . '</h1>' . |
|
16 | + '<p>' . __('Sorry, you are not allowed to list users.') . '</p>', |
|
17 | 17 | 403 |
18 | 18 | ); |
19 | 19 | } |
20 | 20 | |
21 | -$wp_list_table = _get_list_table( 'WP_Users_List_Table' ); |
|
21 | +$wp_list_table = _get_list_table('WP_Users_List_Table'); |
|
22 | 22 | $pagenum = $wp_list_table->get_pagenum(); |
23 | 23 | |
24 | 24 | // Used in the HTML title tag. |
25 | -$title = __( 'Users' ); |
|
25 | +$title = __('Users'); |
|
26 | 26 | $parent_file = 'users.php'; |
27 | 27 | |
28 | -add_screen_option( 'per_page' ); |
|
28 | +add_screen_option('per_page'); |
|
29 | 29 | |
30 | 30 | // Contextual help - choose Help on the top right of admin panel to preview this. |
31 | 31 | get_current_screen()->add_help_tab( |
32 | 32 | array( |
33 | 33 | 'id' => 'overview', |
34 | - 'title' => __( 'Overview' ), |
|
35 | - 'content' => '<p>' . __( 'This screen lists all the existing users for your site. Each user has one of five defined roles as set by the site admin: Site Administrator, Editor, Author, Contributor, or Subscriber. Users with roles other than Administrator will see fewer options in the dashboard navigation when they are logged in, based on their role.' ) . '</p>' . |
|
36 | - '<p>' . __( 'To add a new user for your site, click the Add New button at the top of the screen or Add New in the Users menu section.' ) . '</p>', |
|
34 | + 'title' => __('Overview'), |
|
35 | + 'content' => '<p>' . __('This screen lists all the existing users for your site. Each user has one of five defined roles as set by the site admin: Site Administrator, Editor, Author, Contributor, or Subscriber. Users with roles other than Administrator will see fewer options in the dashboard navigation when they are logged in, based on their role.') . '</p>' . |
|
36 | + '<p>' . __('To add a new user for your site, click the Add New button at the top of the screen or Add New in the Users menu section.') . '</p>', |
|
37 | 37 | ) |
38 | 38 | ); |
39 | 39 | |
40 | 40 | get_current_screen()->add_help_tab( |
41 | 41 | array( |
42 | 42 | 'id' => 'screen-content', |
43 | - 'title' => __( 'Screen Content' ), |
|
44 | - 'content' => '<p>' . __( 'You can customize the display of this screen in a number of ways:' ) . '</p>' . |
|
43 | + 'title' => __('Screen Content'), |
|
44 | + 'content' => '<p>' . __('You can customize the display of this screen in a number of ways:') . '</p>' . |
|
45 | 45 | '<ul>' . |
46 | - '<li>' . __( 'You can hide/display columns based on your needs and decide how many users to list per screen using the Screen Options tab.' ) . '</li>' . |
|
47 | - '<li>' . __( 'You can filter the list of users by User Role using the text links above the users list to show All, Administrator, Editor, Author, Contributor, or Subscriber. The default view is to show all users. Unused User Roles are not listed.' ) . '</li>' . |
|
48 | - '<li>' . __( 'You can view all posts made by a user by clicking on the number under the Posts column.' ) . '</li>' . |
|
46 | + '<li>' . __('You can hide/display columns based on your needs and decide how many users to list per screen using the Screen Options tab.') . '</li>' . |
|
47 | + '<li>' . __('You can filter the list of users by User Role using the text links above the users list to show All, Administrator, Editor, Author, Contributor, or Subscriber. The default view is to show all users. Unused User Roles are not listed.') . '</li>' . |
|
48 | + '<li>' . __('You can view all posts made by a user by clicking on the number under the Posts column.') . '</li>' . |
|
49 | 49 | '</ul>', |
50 | 50 | ) |
51 | 51 | ); |
52 | 52 | |
53 | -$help = '<p>' . __( 'Hovering over a row in the users list will display action links that allow you to manage users. You can perform the following actions:' ) . '</p>' . |
|
53 | +$help = '<p>' . __('Hovering over a row in the users list will display action links that allow you to manage users. You can perform the following actions:') . '</p>' . |
|
54 | 54 | '<ul>' . |
55 | - '<li>' . __( '<strong>Edit</strong> takes you to the editable profile screen for that user. You can also reach that screen by clicking on the username.' ) . '</li>'; |
|
55 | + '<li>' . __('<strong>Edit</strong> takes you to the editable profile screen for that user. You can also reach that screen by clicking on the username.') . '</li>'; |
|
56 | 56 | |
57 | -if ( is_multisite() ) { |
|
58 | - $help .= '<li>' . __( '<strong>Remove</strong> allows you to remove a user from your site. It does not delete their content. You can also remove multiple users at once by using bulk actions.' ) . '</li>'; |
|
57 | +if (is_multisite()) { |
|
58 | + $help .= '<li>' . __('<strong>Remove</strong> allows you to remove a user from your site. It does not delete their content. You can also remove multiple users at once by using bulk actions.') . '</li>'; |
|
59 | 59 | } else { |
60 | - $help .= '<li>' . __( '<strong>Delete</strong> brings you to the Delete Users screen for confirmation, where you can permanently remove a user from your site and delete their content. You can also delete multiple users at once by using bulk actions.' ) . '</li>'; |
|
60 | + $help .= '<li>' . __('<strong>Delete</strong> brings you to the Delete Users screen for confirmation, where you can permanently remove a user from your site and delete their content. You can also delete multiple users at once by using bulk actions.') . '</li>'; |
|
61 | 61 | } |
62 | 62 | |
63 | 63 | $help .= '</ul>'; |
@@ -65,32 +65,32 @@ discard block |
||
65 | 65 | get_current_screen()->add_help_tab( |
66 | 66 | array( |
67 | 67 | 'id' => 'action-links', |
68 | - 'title' => __( 'Available Actions' ), |
|
68 | + 'title' => __('Available Actions'), |
|
69 | 69 | 'content' => $help, |
70 | 70 | ) |
71 | 71 | ); |
72 | -unset( $help ); |
|
72 | +unset($help); |
|
73 | 73 | |
74 | 74 | get_current_screen()->set_help_sidebar( |
75 | - '<p><strong>' . __( 'For more information:' ) . '</strong></p>' . |
|
76 | - '<p>' . __( '<a href="https://wordpress.org/support/article/users-screen/">Documentation on Managing Users</a>' ) . '</p>' . |
|
77 | - '<p>' . __( '<a href="https://wordpress.org/support/article/roles-and-capabilities/">Descriptions of Roles and Capabilities</a>' ) . '</p>' . |
|
78 | - '<p>' . __( '<a href="https://wordpress.org/support/">Support</a>' ) . '</p>' |
|
75 | + '<p><strong>' . __('For more information:') . '</strong></p>' . |
|
76 | + '<p>' . __('<a href="https://wordpress.org/support/article/users-screen/">Documentation on Managing Users</a>') . '</p>' . |
|
77 | + '<p>' . __('<a href="https://wordpress.org/support/article/roles-and-capabilities/">Descriptions of Roles and Capabilities</a>') . '</p>' . |
|
78 | + '<p>' . __('<a href="https://wordpress.org/support/">Support</a>') . '</p>' |
|
79 | 79 | ); |
80 | 80 | |
81 | 81 | get_current_screen()->set_screen_reader_content( |
82 | 82 | array( |
83 | - 'heading_views' => __( 'Filter users list' ), |
|
84 | - 'heading_pagination' => __( 'Users list navigation' ), |
|
85 | - 'heading_list' => __( 'Users list' ), |
|
83 | + 'heading_views' => __('Filter users list'), |
|
84 | + 'heading_pagination' => __('Users list navigation'), |
|
85 | + 'heading_list' => __('Users list'), |
|
86 | 86 | ) |
87 | 87 | ); |
88 | 88 | |
89 | -if ( empty( $_REQUEST ) ) { |
|
90 | - $referer = '<input type="hidden" name="wp_http_referer" value="' . esc_attr( wp_unslash( $_SERVER['REQUEST_URI'] ) ) . '" />'; |
|
91 | -} elseif ( isset( $_REQUEST['wp_http_referer'] ) ) { |
|
92 | - $redirect = remove_query_arg( array( 'wp_http_referer', 'updated', 'delete_count' ), wp_unslash( $_REQUEST['wp_http_referer'] ) ); |
|
93 | - $referer = '<input type="hidden" name="wp_http_referer" value="' . esc_attr( $redirect ) . '" />'; |
|
89 | +if (empty($_REQUEST)) { |
|
90 | + $referer = '<input type="hidden" name="wp_http_referer" value="' . esc_attr(wp_unslash($_SERVER['REQUEST_URI'])) . '" />'; |
|
91 | +} elseif (isset($_REQUEST['wp_http_referer'])) { |
|
92 | + $redirect = remove_query_arg(array('wp_http_referer', 'updated', 'delete_count'), wp_unslash($_REQUEST['wp_http_referer'])); |
|
93 | + $referer = '<input type="hidden" name="wp_http_referer" value="' . esc_attr($redirect) . '" />'; |
|
94 | 94 | } else { |
95 | 95 | $redirect = 'users.php'; |
96 | 96 | $referer = ''; |
@@ -98,18 +98,18 @@ discard block |
||
98 | 98 | |
99 | 99 | $update = ''; |
100 | 100 | |
101 | -switch ( $wp_list_table->current_action() ) { |
|
101 | +switch ($wp_list_table->current_action()) { |
|
102 | 102 | |
103 | 103 | /* Bulk Dropdown menu Role changes */ |
104 | 104 | case 'promote': |
105 | - check_admin_referer( 'bulk-users' ); |
|
105 | + check_admin_referer('bulk-users'); |
|
106 | 106 | |
107 | - if ( ! current_user_can( 'promote_users' ) ) { |
|
108 | - wp_die( __( 'Sorry, you are not allowed to edit this user.' ), 403 ); |
|
107 | + if (!current_user_can('promote_users')) { |
|
108 | + wp_die(__('Sorry, you are not allowed to edit this user.'), 403); |
|
109 | 109 | } |
110 | 110 | |
111 | - if ( empty( $_REQUEST['users'] ) ) { |
|
112 | - wp_redirect( $redirect ); |
|
111 | + if (empty($_REQUEST['users'])) { |
|
112 | + wp_redirect($redirect); |
|
113 | 113 | exit; |
114 | 114 | } |
115 | 115 | |
@@ -118,92 +118,92 @@ discard block |
||
118 | 118 | |
119 | 119 | // Mocking the `none` role so we are able to save it to the database |
120 | 120 | $editable_roles['none'] = array( |
121 | - 'name' => __( '— No role for this site —' ), |
|
121 | + 'name' => __('— No role for this site —'), |
|
122 | 122 | ); |
123 | 123 | |
124 | - if ( ! $role || empty( $editable_roles[ $role ] ) ) { |
|
125 | - wp_die( __( 'Sorry, you are not allowed to give users that role.' ), 403 ); |
|
124 | + if (!$role || empty($editable_roles[$role])) { |
|
125 | + wp_die(__('Sorry, you are not allowed to give users that role.'), 403); |
|
126 | 126 | } |
127 | 127 | |
128 | - if ( 'none' === $role ) { |
|
128 | + if ('none' === $role) { |
|
129 | 129 | $role = ''; |
130 | 130 | } |
131 | 131 | |
132 | 132 | $userids = $_REQUEST['users']; |
133 | 133 | $update = 'promote'; |
134 | - foreach ( $userids as $id ) { |
|
134 | + foreach ($userids as $id) { |
|
135 | 135 | $id = (int) $id; |
136 | 136 | |
137 | - if ( ! current_user_can( 'promote_user', $id ) ) { |
|
138 | - wp_die( __( 'Sorry, you are not allowed to edit this user.' ), 403 ); |
|
137 | + if (!current_user_can('promote_user', $id)) { |
|
138 | + wp_die(__('Sorry, you are not allowed to edit this user.'), 403); |
|
139 | 139 | } |
140 | 140 | |
141 | 141 | // The new role of the current user must also have the promote_users cap or be a multisite super admin. |
142 | - if ( $id == $current_user->ID && ! $wp_roles->role_objects[ $role ]->has_cap( 'promote_users' ) |
|
143 | - && ! ( is_multisite() && current_user_can( 'manage_network_users' ) ) ) { |
|
142 | + if ($id == $current_user->ID && !$wp_roles->role_objects[$role]->has_cap('promote_users') |
|
143 | + && !(is_multisite() && current_user_can('manage_network_users'))) { |
|
144 | 144 | $update = 'err_admin_role'; |
145 | 145 | continue; |
146 | 146 | } |
147 | 147 | |
148 | 148 | // If the user doesn't already belong to the blog, bail. |
149 | - if ( is_multisite() && ! is_user_member_of_blog( $id ) ) { |
|
149 | + if (is_multisite() && !is_user_member_of_blog($id)) { |
|
150 | 150 | wp_die( |
151 | - '<h1>' . __( 'Something went wrong.' ) . '</h1>' . |
|
152 | - '<p>' . __( 'One of the selected users is not a member of this site.' ) . '</p>', |
|
151 | + '<h1>' . __('Something went wrong.') . '</h1>' . |
|
152 | + '<p>' . __('One of the selected users is not a member of this site.') . '</p>', |
|
153 | 153 | 403 |
154 | 154 | ); |
155 | 155 | } |
156 | 156 | |
157 | - $user = get_userdata( $id ); |
|
158 | - $user->set_role( $role ); |
|
157 | + $user = get_userdata($id); |
|
158 | + $user->set_role($role); |
|
159 | 159 | } |
160 | 160 | |
161 | - wp_redirect( add_query_arg( 'update', $update, $redirect ) ); |
|
161 | + wp_redirect(add_query_arg('update', $update, $redirect)); |
|
162 | 162 | exit; |
163 | 163 | |
164 | 164 | case 'dodelete': |
165 | - if ( is_multisite() ) { |
|
166 | - wp_die( __( 'User deletion is not allowed from this screen.' ), 400 ); |
|
165 | + if (is_multisite()) { |
|
166 | + wp_die(__('User deletion is not allowed from this screen.'), 400); |
|
167 | 167 | } |
168 | 168 | |
169 | - check_admin_referer( 'delete-users' ); |
|
169 | + check_admin_referer('delete-users'); |
|
170 | 170 | |
171 | - if ( empty( $_REQUEST['users'] ) ) { |
|
172 | - wp_redirect( $redirect ); |
|
171 | + if (empty($_REQUEST['users'])) { |
|
172 | + wp_redirect($redirect); |
|
173 | 173 | exit; |
174 | 174 | } |
175 | 175 | |
176 | - $userids = array_map( 'intval', (array) $_REQUEST['users'] ); |
|
176 | + $userids = array_map('intval', (array) $_REQUEST['users']); |
|
177 | 177 | |
178 | - if ( empty( $_REQUEST['delete_option'] ) ) { |
|
179 | - $url = self_admin_url( 'users.php?action=delete&users[]=' . implode( '&users[]=', $userids ) . '&error=true' ); |
|
180 | - $url = str_replace( '&', '&', wp_nonce_url( $url, 'bulk-users' ) ); |
|
181 | - wp_redirect( $url ); |
|
178 | + if (empty($_REQUEST['delete_option'])) { |
|
179 | + $url = self_admin_url('users.php?action=delete&users[]=' . implode('&users[]=', $userids) . '&error=true'); |
|
180 | + $url = str_replace('&', '&', wp_nonce_url($url, 'bulk-users')); |
|
181 | + wp_redirect($url); |
|
182 | 182 | exit; |
183 | 183 | } |
184 | 184 | |
185 | - if ( ! current_user_can( 'delete_users' ) ) { |
|
186 | - wp_die( __( 'Sorry, you are not allowed to delete users.' ), 403 ); |
|
185 | + if (!current_user_can('delete_users')) { |
|
186 | + wp_die(__('Sorry, you are not allowed to delete users.'), 403); |
|
187 | 187 | } |
188 | 188 | |
189 | 189 | $update = 'del'; |
190 | 190 | $delete_count = 0; |
191 | 191 | |
192 | - foreach ( $userids as $id ) { |
|
193 | - if ( ! current_user_can( 'delete_user', $id ) ) { |
|
194 | - wp_die( __( 'Sorry, you are not allowed to delete that user.' ), 403 ); |
|
192 | + foreach ($userids as $id) { |
|
193 | + if (!current_user_can('delete_user', $id)) { |
|
194 | + wp_die(__('Sorry, you are not allowed to delete that user.'), 403); |
|
195 | 195 | } |
196 | 196 | |
197 | - if ( $id == $current_user->ID ) { |
|
197 | + if ($id == $current_user->ID) { |
|
198 | 198 | $update = 'err_admin_del'; |
199 | 199 | continue; |
200 | 200 | } |
201 | - switch ( $_REQUEST['delete_option'] ) { |
|
201 | + switch ($_REQUEST['delete_option']) { |
|
202 | 202 | case 'delete': |
203 | - wp_delete_user( $id ); |
|
203 | + wp_delete_user($id); |
|
204 | 204 | break; |
205 | 205 | case 'reassign': |
206 | - wp_delete_user( $id, $_REQUEST['reassign_user'] ); |
|
206 | + wp_delete_user($id, $_REQUEST['reassign_user']); |
|
207 | 207 | break; |
208 | 208 | } |
209 | 209 | ++$delete_count; |
@@ -216,35 +216,35 @@ discard block |
||
216 | 216 | ), |
217 | 217 | $redirect |
218 | 218 | ); |
219 | - wp_redirect( $redirect ); |
|
219 | + wp_redirect($redirect); |
|
220 | 220 | exit; |
221 | 221 | |
222 | 222 | case 'resetpassword': |
223 | - check_admin_referer( 'bulk-users' ); |
|
224 | - if ( ! current_user_can( 'edit_users' ) ) { |
|
225 | - $errors = new WP_Error( 'edit_users', __( 'Sorry, you are not allowed to edit users.' ) ); |
|
223 | + check_admin_referer('bulk-users'); |
|
224 | + if (!current_user_can('edit_users')) { |
|
225 | + $errors = new WP_Error('edit_users', __('Sorry, you are not allowed to edit users.')); |
|
226 | 226 | } |
227 | - if ( empty( $_REQUEST['users'] ) ) { |
|
228 | - wp_redirect( $redirect ); |
|
227 | + if (empty($_REQUEST['users'])) { |
|
228 | + wp_redirect($redirect); |
|
229 | 229 | exit(); |
230 | 230 | } |
231 | - $userids = array_map( 'intval', (array) $_REQUEST['users'] ); |
|
231 | + $userids = array_map('intval', (array) $_REQUEST['users']); |
|
232 | 232 | |
233 | 233 | $reset_count = 0; |
234 | 234 | |
235 | - foreach ( $userids as $id ) { |
|
236 | - if ( ! current_user_can( 'edit_user', $id ) ) { |
|
237 | - wp_die( __( 'Sorry, you are not allowed to edit this user.' ) ); |
|
235 | + foreach ($userids as $id) { |
|
236 | + if (!current_user_can('edit_user', $id)) { |
|
237 | + wp_die(__('Sorry, you are not allowed to edit this user.')); |
|
238 | 238 | } |
239 | 239 | |
240 | - if ( $id === $current_user->ID ) { |
|
240 | + if ($id === $current_user->ID) { |
|
241 | 241 | $update = 'err_admin_reset'; |
242 | 242 | continue; |
243 | 243 | } |
244 | 244 | |
245 | 245 | // Send the password reset link. |
246 | - $user = get_userdata( $id ); |
|
247 | - if ( retrieve_password( $user->user_login ) ) { |
|
246 | + $user = get_userdata($id); |
|
247 | + if (retrieve_password($user->user_login)) { |
|
248 | 248 | ++$reset_count; |
249 | 249 | } |
250 | 250 | } |
@@ -256,35 +256,35 @@ discard block |
||
256 | 256 | ), |
257 | 257 | $redirect |
258 | 258 | ); |
259 | - wp_redirect( $redirect ); |
|
259 | + wp_redirect($redirect); |
|
260 | 260 | exit; |
261 | 261 | |
262 | 262 | case 'delete': |
263 | - if ( is_multisite() ) { |
|
264 | - wp_die( __( 'User deletion is not allowed from this screen.' ), 400 ); |
|
263 | + if (is_multisite()) { |
|
264 | + wp_die(__('User deletion is not allowed from this screen.'), 400); |
|
265 | 265 | } |
266 | 266 | |
267 | - check_admin_referer( 'bulk-users' ); |
|
267 | + check_admin_referer('bulk-users'); |
|
268 | 268 | |
269 | - if ( empty( $_REQUEST['users'] ) && empty( $_REQUEST['user'] ) ) { |
|
270 | - wp_redirect( $redirect ); |
|
269 | + if (empty($_REQUEST['users']) && empty($_REQUEST['user'])) { |
|
270 | + wp_redirect($redirect); |
|
271 | 271 | exit; |
272 | 272 | } |
273 | 273 | |
274 | - if ( ! current_user_can( 'delete_users' ) ) { |
|
275 | - $errors = new WP_Error( 'edit_users', __( 'Sorry, you are not allowed to delete users.' ) ); |
|
274 | + if (!current_user_can('delete_users')) { |
|
275 | + $errors = new WP_Error('edit_users', __('Sorry, you are not allowed to delete users.')); |
|
276 | 276 | } |
277 | 277 | |
278 | - if ( empty( $_REQUEST['users'] ) ) { |
|
279 | - $userids = array( (int) $_REQUEST['user'] ); |
|
278 | + if (empty($_REQUEST['users'])) { |
|
279 | + $userids = array((int) $_REQUEST['user']); |
|
280 | 280 | } else { |
281 | - $userids = array_map( 'intval', (array) $_REQUEST['users'] ); |
|
281 | + $userids = array_map('intval', (array) $_REQUEST['users']); |
|
282 | 282 | } |
283 | 283 | |
284 | 284 | $all_userids = $userids; |
285 | 285 | |
286 | - if ( in_array( $current_user->ID, $userids, true ) ) { |
|
287 | - $userids = array_diff( $userids, array( $current_user->ID ) ); |
|
286 | + if (in_array($current_user->ID, $userids, true)) { |
|
287 | + $userids = array_diff($userids, array($current_user->ID)); |
|
288 | 288 | } |
289 | 289 | |
290 | 290 | /** |
@@ -296,74 +296,74 @@ discard block |
||
296 | 296 | * @param bool $users_have_additional_content Whether the users have additional content. Default false. |
297 | 297 | * @param int[] $userids Array of IDs for users being deleted. |
298 | 298 | */ |
299 | - $users_have_content = (bool) apply_filters( 'users_have_additional_content', false, $userids ); |
|
299 | + $users_have_content = (bool) apply_filters('users_have_additional_content', false, $userids); |
|
300 | 300 | |
301 | - if ( $userids && ! $users_have_content ) { |
|
302 | - if ( $wpdb->get_var( "SELECT ID FROM {$wpdb->posts} WHERE post_author IN( " . implode( ',', $userids ) . ' ) LIMIT 1' ) ) { |
|
301 | + if ($userids && !$users_have_content) { |
|
302 | + if ($wpdb->get_var("SELECT ID FROM {$wpdb->posts} WHERE post_author IN( " . implode(',', $userids) . ' ) LIMIT 1')) { |
|
303 | 303 | $users_have_content = true; |
304 | - } elseif ( $wpdb->get_var( "SELECT link_id FROM {$wpdb->links} WHERE link_owner IN( " . implode( ',', $userids ) . ' ) LIMIT 1' ) ) { |
|
304 | + } elseif ($wpdb->get_var("SELECT link_id FROM {$wpdb->links} WHERE link_owner IN( " . implode(',', $userids) . ' ) LIMIT 1')) { |
|
305 | 305 | $users_have_content = true; |
306 | 306 | } |
307 | 307 | } |
308 | 308 | |
309 | - if ( $users_have_content ) { |
|
310 | - add_action( 'admin_head', 'delete_users_add_js' ); |
|
309 | + if ($users_have_content) { |
|
310 | + add_action('admin_head', 'delete_users_add_js'); |
|
311 | 311 | } |
312 | 312 | |
313 | 313 | require_once ABSPATH . 'wp-admin/admin-header.php'; |
314 | 314 | ?> |
315 | 315 | <form method="post" name="updateusers" id="updateusers"> |
316 | - <?php wp_nonce_field( 'delete-users' ); ?> |
|
316 | + <?php wp_nonce_field('delete-users'); ?> |
|
317 | 317 | <?php echo $referer; ?> |
318 | 318 | |
319 | 319 | <div class="wrap"> |
320 | -<h1><?php _e( 'Delete Users' ); ?></h1> |
|
321 | - <?php if ( isset( $_REQUEST['error'] ) ) : ?> |
|
320 | +<h1><?php _e('Delete Users'); ?></h1> |
|
321 | + <?php if (isset($_REQUEST['error'])) : ?> |
|
322 | 322 | <div class="error"> |
323 | - <p><strong><?php _e( 'Error:' ); ?></strong> <?php _e( 'Please select an option.' ); ?></p> |
|
323 | + <p><strong><?php _e('Error:'); ?></strong> <?php _e('Please select an option.'); ?></p> |
|
324 | 324 | </div> |
325 | 325 | <?php endif; ?> |
326 | 326 | |
327 | - <?php if ( 1 === count( $all_userids ) ) : ?> |
|
328 | - <p><?php _e( 'You have specified this user for deletion:' ); ?></p> |
|
327 | + <?php if (1 === count($all_userids)) : ?> |
|
328 | + <p><?php _e('You have specified this user for deletion:'); ?></p> |
|
329 | 329 | <?php else : ?> |
330 | - <p><?php _e( 'You have specified these users for deletion:' ); ?></p> |
|
330 | + <p><?php _e('You have specified these users for deletion:'); ?></p> |
|
331 | 331 | <?php endif; ?> |
332 | 332 | |
333 | 333 | <ul> |
334 | 334 | <?php |
335 | 335 | $go_delete = 0; |
336 | - foreach ( $all_userids as $id ) { |
|
337 | - $user = get_userdata( $id ); |
|
338 | - if ( $id == $current_user->ID ) { |
|
336 | + foreach ($all_userids as $id) { |
|
337 | + $user = get_userdata($id); |
|
338 | + if ($id == $current_user->ID) { |
|
339 | 339 | /* translators: 1: User ID, 2: User login. */ |
340 | - echo '<li>' . sprintf( __( 'ID #%1$s: %2$s <strong>The current user will not be deleted.</strong>' ), $id, $user->user_login ) . "</li>\n"; |
|
340 | + echo '<li>' . sprintf(__('ID #%1$s: %2$s <strong>The current user will not be deleted.</strong>'), $id, $user->user_login) . "</li>\n"; |
|
341 | 341 | } else { |
342 | 342 | /* translators: 1: User ID, 2: User login. */ |
343 | - echo '<li><input type="hidden" name="users[]" value="' . esc_attr( $id ) . '" />' . sprintf( __( 'ID #%1$s: %2$s' ), $id, $user->user_login ) . "</li>\n"; |
|
343 | + echo '<li><input type="hidden" name="users[]" value="' . esc_attr($id) . '" />' . sprintf(__('ID #%1$s: %2$s'), $id, $user->user_login) . "</li>\n"; |
|
344 | 344 | $go_delete++; |
345 | 345 | } |
346 | 346 | } |
347 | 347 | ?> |
348 | 348 | </ul> |
349 | 349 | <?php |
350 | - if ( $go_delete ) : |
|
350 | + if ($go_delete) : |
|
351 | 351 | |
352 | - if ( ! $users_have_content ) : |
|
352 | + if (!$users_have_content) : |
|
353 | 353 | ?> |
354 | 354 | <input type="hidden" name="delete_option" value="delete" /> |
355 | 355 | <?php else : ?> |
356 | - <?php if ( 1 == $go_delete ) : ?> |
|
357 | - <fieldset><p><legend><?php _e( 'What should be done with content owned by this user?' ); ?></legend></p> |
|
356 | + <?php if (1 == $go_delete) : ?> |
|
357 | + <fieldset><p><legend><?php _e('What should be done with content owned by this user?'); ?></legend></p> |
|
358 | 358 | <?php else : ?> |
359 | - <fieldset><p><legend><?php _e( 'What should be done with content owned by these users?' ); ?></legend></p> |
|
359 | + <fieldset><p><legend><?php _e('What should be done with content owned by these users?'); ?></legend></p> |
|
360 | 360 | <?php endif; ?> |
361 | 361 | <ul style="list-style:none;"> |
362 | 362 | <li><label><input type="radio" id="delete_option0" name="delete_option" value="delete" /> |
363 | - <?php _e( 'Delete all content.' ); ?></label></li> |
|
363 | + <?php _e('Delete all content.'); ?></label></li> |
|
364 | 364 | <li><input type="radio" id="delete_option1" name="delete_option" value="reassign" /> |
365 | 365 | <?php |
366 | - echo '<label for="delete_option1">' . __( 'Attribute all content to:' ) . '</label> '; |
|
366 | + echo '<label for="delete_option1">' . __('Attribute all content to:') . '</label> '; |
|
367 | 367 | wp_dropdown_users( |
368 | 368 | array( |
369 | 369 | 'name' => 'reassign_user', |
@@ -385,12 +385,12 @@ discard block |
||
385 | 385 | * @param WP_User $current_user WP_User object for the current user. |
386 | 386 | * @param int[] $userids Array of IDs for users being deleted. |
387 | 387 | */ |
388 | - do_action( 'delete_user_form', $current_user, $userids ); |
|
388 | + do_action('delete_user_form', $current_user, $userids); |
|
389 | 389 | ?> |
390 | 390 | <input type="hidden" name="action" value="dodelete" /> |
391 | - <?php submit_button( __( 'Confirm Deletion' ), 'primary' ); ?> |
|
391 | + <?php submit_button(__('Confirm Deletion'), 'primary'); ?> |
|
392 | 392 | <?php else : ?> |
393 | - <p><?php _e( 'There are no valid users selected for deletion.' ); ?></p> |
|
393 | + <p><?php _e('There are no valid users selected for deletion.'); ?></p> |
|
394 | 394 | <?php endif; ?> |
395 | 395 | </div> |
396 | 396 | </form> |
@@ -399,55 +399,55 @@ discard block |
||
399 | 399 | break; |
400 | 400 | |
401 | 401 | case 'doremove': |
402 | - check_admin_referer( 'remove-users' ); |
|
402 | + check_admin_referer('remove-users'); |
|
403 | 403 | |
404 | - if ( ! is_multisite() ) { |
|
405 | - wp_die( __( 'You cannot remove users.' ), 400 ); |
|
404 | + if (!is_multisite()) { |
|
405 | + wp_die(__('You cannot remove users.'), 400); |
|
406 | 406 | } |
407 | 407 | |
408 | - if ( empty( $_REQUEST['users'] ) ) { |
|
409 | - wp_redirect( $redirect ); |
|
408 | + if (empty($_REQUEST['users'])) { |
|
409 | + wp_redirect($redirect); |
|
410 | 410 | exit; |
411 | 411 | } |
412 | 412 | |
413 | - if ( ! current_user_can( 'remove_users' ) ) { |
|
414 | - wp_die( __( 'Sorry, you are not allowed to remove users.' ), 403 ); |
|
413 | + if (!current_user_can('remove_users')) { |
|
414 | + wp_die(__('Sorry, you are not allowed to remove users.'), 403); |
|
415 | 415 | } |
416 | 416 | |
417 | 417 | $userids = $_REQUEST['users']; |
418 | 418 | |
419 | 419 | $update = 'remove'; |
420 | - foreach ( $userids as $id ) { |
|
420 | + foreach ($userids as $id) { |
|
421 | 421 | $id = (int) $id; |
422 | - if ( ! current_user_can( 'remove_user', $id ) ) { |
|
422 | + if (!current_user_can('remove_user', $id)) { |
|
423 | 423 | $update = 'err_admin_remove'; |
424 | 424 | continue; |
425 | 425 | } |
426 | - remove_user_from_blog( $id, $blog_id ); |
|
426 | + remove_user_from_blog($id, $blog_id); |
|
427 | 427 | } |
428 | 428 | |
429 | - $redirect = add_query_arg( array( 'update' => $update ), $redirect ); |
|
430 | - wp_redirect( $redirect ); |
|
429 | + $redirect = add_query_arg(array('update' => $update), $redirect); |
|
430 | + wp_redirect($redirect); |
|
431 | 431 | exit; |
432 | 432 | |
433 | 433 | case 'remove': |
434 | - check_admin_referer( 'bulk-users' ); |
|
434 | + check_admin_referer('bulk-users'); |
|
435 | 435 | |
436 | - if ( ! is_multisite() ) { |
|
437 | - wp_die( __( 'You cannot remove users.' ), 400 ); |
|
436 | + if (!is_multisite()) { |
|
437 | + wp_die(__('You cannot remove users.'), 400); |
|
438 | 438 | } |
439 | 439 | |
440 | - if ( empty( $_REQUEST['users'] ) && empty( $_REQUEST['user'] ) ) { |
|
441 | - wp_redirect( $redirect ); |
|
440 | + if (empty($_REQUEST['users']) && empty($_REQUEST['user'])) { |
|
441 | + wp_redirect($redirect); |
|
442 | 442 | exit; |
443 | 443 | } |
444 | 444 | |
445 | - if ( ! current_user_can( 'remove_users' ) ) { |
|
446 | - $error = new WP_Error( 'edit_users', __( 'Sorry, you are not allowed to remove users.' ) ); |
|
445 | + if (!current_user_can('remove_users')) { |
|
446 | + $error = new WP_Error('edit_users', __('Sorry, you are not allowed to remove users.')); |
|
447 | 447 | } |
448 | 448 | |
449 | - if ( empty( $_REQUEST['users'] ) ) { |
|
450 | - $userids = array( (int) $_REQUEST['user'] ); |
|
449 | + if (empty($_REQUEST['users'])) { |
|
450 | + $userids = array((int) $_REQUEST['user']); |
|
451 | 451 | } else { |
452 | 452 | $userids = $_REQUEST['users']; |
453 | 453 | } |
@@ -455,40 +455,40 @@ discard block |
||
455 | 455 | require_once ABSPATH . 'wp-admin/admin-header.php'; |
456 | 456 | ?> |
457 | 457 | <form method="post" name="updateusers" id="updateusers"> |
458 | - <?php wp_nonce_field( 'remove-users' ); ?> |
|
458 | + <?php wp_nonce_field('remove-users'); ?> |
|
459 | 459 | <?php echo $referer; ?> |
460 | 460 | |
461 | 461 | <div class="wrap"> |
462 | -<h1><?php _e( 'Remove Users from Site' ); ?></h1> |
|
462 | +<h1><?php _e('Remove Users from Site'); ?></h1> |
|
463 | 463 | |
464 | - <?php if ( 1 === count( $userids ) ) : ?> |
|
465 | - <p><?php _e( 'You have specified this user for removal:' ); ?></p> |
|
464 | + <?php if (1 === count($userids)) : ?> |
|
465 | + <p><?php _e('You have specified this user for removal:'); ?></p> |
|
466 | 466 | <?php else : ?> |
467 | - <p><?php _e( 'You have specified these users for removal:' ); ?></p> |
|
467 | + <p><?php _e('You have specified these users for removal:'); ?></p> |
|
468 | 468 | <?php endif; ?> |
469 | 469 | |
470 | 470 | <ul> |
471 | 471 | <?php |
472 | 472 | $go_remove = false; |
473 | - foreach ( $userids as $id ) { |
|
473 | + foreach ($userids as $id) { |
|
474 | 474 | $id = (int) $id; |
475 | - $user = get_userdata( $id ); |
|
476 | - if ( ! current_user_can( 'remove_user', $id ) ) { |
|
475 | + $user = get_userdata($id); |
|
476 | + if (!current_user_can('remove_user', $id)) { |
|
477 | 477 | /* translators: 1: User ID, 2: User login. */ |
478 | - echo '<li>' . sprintf( __( 'ID #%1$s: %2$s <strong>Sorry, you are not allowed to remove this user.</strong>' ), $id, $user->user_login ) . "</li>\n"; |
|
478 | + echo '<li>' . sprintf(__('ID #%1$s: %2$s <strong>Sorry, you are not allowed to remove this user.</strong>'), $id, $user->user_login) . "</li>\n"; |
|
479 | 479 | } else { |
480 | 480 | /* translators: 1: User ID, 2: User login. */ |
481 | - echo "<li><input type=\"hidden\" name=\"users[]\" value=\"{$id}\" />" . sprintf( __( 'ID #%1$s: %2$s' ), $id, $user->user_login ) . "</li>\n"; |
|
481 | + echo "<li><input type=\"hidden\" name=\"users[]\" value=\"{$id}\" />" . sprintf(__('ID #%1$s: %2$s'), $id, $user->user_login) . "</li>\n"; |
|
482 | 482 | $go_remove = true; |
483 | 483 | } |
484 | 484 | } |
485 | 485 | ?> |
486 | 486 | </ul> |
487 | - <?php if ( $go_remove ) : ?> |
|
487 | + <?php if ($go_remove) : ?> |
|
488 | 488 | <input type="hidden" name="action" value="doremove" /> |
489 | - <?php submit_button( __( 'Confirm Removal' ), 'primary' ); ?> |
|
489 | + <?php submit_button(__('Confirm Removal'), 'primary'); ?> |
|
490 | 490 | <?php else : ?> |
491 | - <p><?php _e( 'There are no valid users selected for removal.' ); ?></p> |
|
491 | + <p><?php _e('There are no valid users selected for removal.'); ?></p> |
|
492 | 492 | <?php endif; ?> |
493 | 493 | </div> |
494 | 494 | </form> |
@@ -497,103 +497,103 @@ discard block |
||
497 | 497 | break; |
498 | 498 | |
499 | 499 | default: |
500 | - if ( ! empty( $_GET['_wp_http_referer'] ) ) { |
|
501 | - wp_redirect( remove_query_arg( array( '_wp_http_referer', '_wpnonce' ), wp_unslash( $_SERVER['REQUEST_URI'] ) ) ); |
|
500 | + if (!empty($_GET['_wp_http_referer'])) { |
|
501 | + wp_redirect(remove_query_arg(array('_wp_http_referer', '_wpnonce'), wp_unslash($_SERVER['REQUEST_URI']))); |
|
502 | 502 | exit; |
503 | 503 | } |
504 | 504 | |
505 | - if ( $wp_list_table->current_action() && ! empty( $_REQUEST['users'] ) ) { |
|
505 | + if ($wp_list_table->current_action() && !empty($_REQUEST['users'])) { |
|
506 | 506 | $screen = get_current_screen()->id; |
507 | 507 | $sendback = wp_get_referer(); |
508 | 508 | $userids = $_REQUEST['users']; |
509 | 509 | |
510 | 510 | /** This action is documented in wp-admin/edit.php */ |
511 | - $sendback = apply_filters( "handle_bulk_actions-{$screen}", $sendback, $wp_list_table->current_action(), $userids ); // phpcs:ignore WordPress.NamingConventions.ValidHookName.UseUnderscores |
|
511 | + $sendback = apply_filters("handle_bulk_actions-{$screen}", $sendback, $wp_list_table->current_action(), $userids); // phpcs:ignore WordPress.NamingConventions.ValidHookName.UseUnderscores |
|
512 | 512 | |
513 | - wp_safe_redirect( $sendback ); |
|
513 | + wp_safe_redirect($sendback); |
|
514 | 514 | exit; |
515 | 515 | } |
516 | 516 | |
517 | 517 | $wp_list_table->prepare_items(); |
518 | - $total_pages = $wp_list_table->get_pagination_arg( 'total_pages' ); |
|
519 | - if ( $pagenum > $total_pages && $total_pages > 0 ) { |
|
520 | - wp_redirect( add_query_arg( 'paged', $total_pages ) ); |
|
518 | + $total_pages = $wp_list_table->get_pagination_arg('total_pages'); |
|
519 | + if ($pagenum > $total_pages && $total_pages > 0) { |
|
520 | + wp_redirect(add_query_arg('paged', $total_pages)); |
|
521 | 521 | exit; |
522 | 522 | } |
523 | 523 | |
524 | 524 | require_once ABSPATH . 'wp-admin/admin-header.php'; |
525 | 525 | |
526 | 526 | $messages = array(); |
527 | - if ( isset( $_GET['update'] ) ) : |
|
528 | - switch ( $_GET['update'] ) { |
|
527 | + if (isset($_GET['update'])) : |
|
528 | + switch ($_GET['update']) { |
|
529 | 529 | case 'del': |
530 | 530 | case 'del_many': |
531 | - $delete_count = isset( $_GET['delete_count'] ) ? (int) $_GET['delete_count'] : 0; |
|
532 | - if ( 1 == $delete_count ) { |
|
533 | - $message = __( 'User deleted.' ); |
|
531 | + $delete_count = isset($_GET['delete_count']) ? (int) $_GET['delete_count'] : 0; |
|
532 | + if (1 == $delete_count) { |
|
533 | + $message = __('User deleted.'); |
|
534 | 534 | } else { |
535 | 535 | /* translators: %s: Number of users. */ |
536 | - $message = _n( '%s user deleted.', '%s users deleted.', $delete_count ); |
|
536 | + $message = _n('%s user deleted.', '%s users deleted.', $delete_count); |
|
537 | 537 | } |
538 | - $messages[] = '<div id="message" class="updated notice is-dismissible"><p>' . sprintf( $message, number_format_i18n( $delete_count ) ) . '</p></div>'; |
|
538 | + $messages[] = '<div id="message" class="updated notice is-dismissible"><p>' . sprintf($message, number_format_i18n($delete_count)) . '</p></div>'; |
|
539 | 539 | break; |
540 | 540 | case 'add': |
541 | - $message = __( 'New user created.' ); |
|
541 | + $message = __('New user created.'); |
|
542 | 542 | |
543 | - $user_id = isset( $_GET['id'] ) ? $_GET['id'] : false; |
|
544 | - if ( $user_id && current_user_can( 'edit_user', $user_id ) ) { |
|
543 | + $user_id = isset($_GET['id']) ? $_GET['id'] : false; |
|
544 | + if ($user_id && current_user_can('edit_user', $user_id)) { |
|
545 | 545 | $message .= sprintf( |
546 | 546 | ' <a href="%s">%s</a>', |
547 | 547 | esc_url( |
548 | 548 | add_query_arg( |
549 | 549 | 'wp_http_referer', |
550 | - urlencode( wp_unslash( $_SERVER['REQUEST_URI'] ) ), |
|
551 | - self_admin_url( 'user-edit.php?user_id=' . $user_id ) |
|
550 | + urlencode(wp_unslash($_SERVER['REQUEST_URI'])), |
|
551 | + self_admin_url('user-edit.php?user_id=' . $user_id) |
|
552 | 552 | ) |
553 | 553 | ), |
554 | - __( 'Edit user' ) |
|
554 | + __('Edit user') |
|
555 | 555 | ); |
556 | 556 | } |
557 | 557 | |
558 | 558 | $messages[] = '<div id="message" class="updated notice is-dismissible"><p>' . $message . '</p></div>'; |
559 | 559 | break; |
560 | 560 | case 'resetpassword': |
561 | - $reset_count = isset( $_GET['reset_count'] ) ? (int) $_GET['reset_count'] : 0; |
|
562 | - if ( 1 === $reset_count ) { |
|
563 | - $message = __( 'Password reset link sent.' ); |
|
561 | + $reset_count = isset($_GET['reset_count']) ? (int) $_GET['reset_count'] : 0; |
|
562 | + if (1 === $reset_count) { |
|
563 | + $message = __('Password reset link sent.'); |
|
564 | 564 | } else { |
565 | 565 | /* translators: %s: Number of users. */ |
566 | - $message = _n( 'Password reset links sent to %s user.', 'Password reset links sent to %s users.', $reset_count ); |
|
566 | + $message = _n('Password reset links sent to %s user.', 'Password reset links sent to %s users.', $reset_count); |
|
567 | 567 | } |
568 | - $messages[] = '<div id="message" class="updated notice is-dismissible"><p>' . sprintf( $message, number_format_i18n( $reset_count ) ) . '</p></div>'; |
|
568 | + $messages[] = '<div id="message" class="updated notice is-dismissible"><p>' . sprintf($message, number_format_i18n($reset_count)) . '</p></div>'; |
|
569 | 569 | break; |
570 | 570 | case 'promote': |
571 | - $messages[] = '<div id="message" class="updated notice is-dismissible"><p>' . __( 'Changed roles.' ) . '</p></div>'; |
|
571 | + $messages[] = '<div id="message" class="updated notice is-dismissible"><p>' . __('Changed roles.') . '</p></div>'; |
|
572 | 572 | break; |
573 | 573 | case 'err_admin_role': |
574 | - $messages[] = '<div id="message" class="error notice is-dismissible"><p>' . __( 'The current user’s role must have user editing capabilities.' ) . '</p></div>'; |
|
575 | - $messages[] = '<div id="message" class="updated notice is-dismissible"><p>' . __( 'Other user roles have been changed.' ) . '</p></div>'; |
|
574 | + $messages[] = '<div id="message" class="error notice is-dismissible"><p>' . __('The current user’s role must have user editing capabilities.') . '</p></div>'; |
|
575 | + $messages[] = '<div id="message" class="updated notice is-dismissible"><p>' . __('Other user roles have been changed.') . '</p></div>'; |
|
576 | 576 | break; |
577 | 577 | case 'err_admin_del': |
578 | - $messages[] = '<div id="message" class="error notice is-dismissible"><p>' . __( 'You cannot delete the current user.' ) . '</p></div>'; |
|
579 | - $messages[] = '<div id="message" class="updated notice is-dismissible"><p>' . __( 'Other users have been deleted.' ) . '</p></div>'; |
|
578 | + $messages[] = '<div id="message" class="error notice is-dismissible"><p>' . __('You cannot delete the current user.') . '</p></div>'; |
|
579 | + $messages[] = '<div id="message" class="updated notice is-dismissible"><p>' . __('Other users have been deleted.') . '</p></div>'; |
|
580 | 580 | break; |
581 | 581 | case 'remove': |
582 | - $messages[] = '<div id="message" class="updated notice is-dismissible fade"><p>' . __( 'User removed from this site.' ) . '</p></div>'; |
|
582 | + $messages[] = '<div id="message" class="updated notice is-dismissible fade"><p>' . __('User removed from this site.') . '</p></div>'; |
|
583 | 583 | break; |
584 | 584 | case 'err_admin_remove': |
585 | - $messages[] = '<div id="message" class="error notice is-dismissible"><p>' . __( 'You cannot remove the current user.' ) . '</p></div>'; |
|
586 | - $messages[] = '<div id="message" class="updated notice is-dismissible fade"><p>' . __( 'Other users have been removed.' ) . '</p></div>'; |
|
585 | + $messages[] = '<div id="message" class="error notice is-dismissible"><p>' . __('You cannot remove the current user.') . '</p></div>'; |
|
586 | + $messages[] = '<div id="message" class="updated notice is-dismissible fade"><p>' . __('Other users have been removed.') . '</p></div>'; |
|
587 | 587 | break; |
588 | 588 | } |
589 | 589 | endif; |
590 | 590 | ?> |
591 | 591 | |
592 | - <?php if ( isset( $errors ) && is_wp_error( $errors ) ) : ?> |
|
592 | + <?php if (isset($errors) && is_wp_error($errors)) : ?> |
|
593 | 593 | <div class="error"> |
594 | 594 | <ul> |
595 | 595 | <?php |
596 | - foreach ( $errors->get_error_messages() as $err ) { |
|
596 | + foreach ($errors->get_error_messages() as $err) { |
|
597 | 597 | echo "<li>$err</li>\n"; |
598 | 598 | } |
599 | 599 | ?> |
@@ -602,8 +602,8 @@ discard block |
||
602 | 602 | <?php |
603 | 603 | endif; |
604 | 604 | |
605 | - if ( ! empty( $messages ) ) { |
|
606 | - foreach ( $messages as $msg ) { |
|
605 | + if (!empty($messages)) { |
|
606 | + foreach ($messages as $msg) { |
|
607 | 607 | echo $msg; |
608 | 608 | } |
609 | 609 | } |
@@ -612,25 +612,25 @@ discard block |
||
612 | 612 | <div class="wrap"> |
613 | 613 | <h1 class="wp-heading-inline"> |
614 | 614 | <?php |
615 | - echo esc_html( $title ); |
|
615 | + echo esc_html($title); |
|
616 | 616 | ?> |
617 | 617 | </h1> |
618 | 618 | |
619 | 619 | <?php |
620 | - if ( current_user_can( 'create_users' ) ) { |
|
620 | + if (current_user_can('create_users')) { |
|
621 | 621 | ?> |
622 | - <a href="<?php echo esc_url( admin_url( 'user-new.php' ) ); ?>" class="page-title-action"><?php echo esc_html_x( 'Add New', 'user' ); ?></a> |
|
623 | -<?php } elseif ( is_multisite() && current_user_can( 'promote_users' ) ) { ?> |
|
624 | - <a href="<?php echo esc_url( admin_url( 'user-new.php' ) ); ?>" class="page-title-action"><?php echo esc_html_x( 'Add Existing', 'user' ); ?></a> |
|
622 | + <a href="<?php echo esc_url(admin_url('user-new.php')); ?>" class="page-title-action"><?php echo esc_html_x('Add New', 'user'); ?></a> |
|
623 | +<?php } elseif (is_multisite() && current_user_can('promote_users')) { ?> |
|
624 | + <a href="<?php echo esc_url(admin_url('user-new.php')); ?>" class="page-title-action"><?php echo esc_html_x('Add Existing', 'user'); ?></a> |
|
625 | 625 | <?php |
626 | 626 | } |
627 | 627 | |
628 | -if ( strlen( $usersearch ) ) { |
|
628 | +if (strlen($usersearch)) { |
|
629 | 629 | echo '<span class="subtitle">'; |
630 | 630 | printf( |
631 | 631 | /* translators: %s: Search query. */ |
632 | - __( 'Search results for: %s' ), |
|
633 | - '<strong>' . esc_html( $usersearch ) . '</strong>' |
|
632 | + __('Search results for: %s'), |
|
633 | + '<strong>' . esc_html($usersearch) . '</strong>' |
|
634 | 634 | ); |
635 | 635 | echo '</span>'; |
636 | 636 | } |
@@ -642,10 +642,10 @@ discard block |
||
642 | 642 | |
643 | 643 | <form method="get"> |
644 | 644 | |
645 | - <?php $wp_list_table->search_box( __( 'Search Users' ), 'user' ); ?> |
|
645 | + <?php $wp_list_table->search_box(__('Search Users'), 'user'); ?> |
|
646 | 646 | |
647 | - <?php if ( ! empty( $_REQUEST['role'] ) ) { ?> |
|
648 | -<input type="hidden" name="role" value="<?php echo esc_attr( $_REQUEST['role'] ); ?>" /> |
|
647 | + <?php if (!empty($_REQUEST['role'])) { ?> |
|
648 | +<input type="hidden" name="role" value="<?php echo esc_attr($_REQUEST['role']); ?>" /> |
|
649 | 649 | <?php } ?> |
650 | 650 | |
651 | 651 | <?php $wp_list_table->display(); ?> |
@@ -20,7 +20,7 @@ discard block |
||
20 | 20 | * @since 2.5.0 |
21 | 21 | * @var string |
22 | 22 | */ |
23 | -if(!defined('CRLF')) define('CRLF',"\r\n"); |
|
23 | +if (!defined('CRLF')) define('CRLF', "\r\n"); |
|
24 | 24 | |
25 | 25 | /** |
26 | 26 | * Sets whatever to autodetect ASCII mode. |
@@ -30,7 +30,7 @@ discard block |
||
30 | 30 | * @since 2.5.0 |
31 | 31 | * @var int |
32 | 32 | */ |
33 | -if(!defined("FTP_AUTOASCII")) define("FTP_AUTOASCII", -1); |
|
33 | +if (!defined("FTP_AUTOASCII")) define("FTP_AUTOASCII", -1); |
|
34 | 34 | |
35 | 35 | /** |
36 | 36 | * |
@@ -38,7 +38,7 @@ discard block |
||
38 | 38 | * @since 2.5.0 |
39 | 39 | * @var int |
40 | 40 | */ |
41 | -if(!defined("FTP_BINARY")) define("FTP_BINARY", 1); |
|
41 | +if (!defined("FTP_BINARY")) define("FTP_BINARY", 1); |
|
42 | 42 | |
43 | 43 | /** |
44 | 44 | * |
@@ -46,7 +46,7 @@ discard block |
||
46 | 46 | * @since 2.5.0 |
47 | 47 | * @var int |
48 | 48 | */ |
49 | -if(!defined("FTP_ASCII")) define("FTP_ASCII", 0); |
|
49 | +if (!defined("FTP_ASCII")) define("FTP_ASCII", 0); |
|
50 | 50 | |
51 | 51 | /** |
52 | 52 | * Whether to force FTP. |
@@ -56,25 +56,25 @@ discard block |
||
56 | 56 | * @since 2.5.0 |
57 | 57 | * @var bool |
58 | 58 | */ |
59 | -if(!defined('FTP_FORCE')) define('FTP_FORCE', true); |
|
59 | +if (!defined('FTP_FORCE')) define('FTP_FORCE', true); |
|
60 | 60 | |
61 | 61 | /** |
62 | 62 | * @since 2.5.0 |
63 | 63 | * @var string |
64 | 64 | */ |
65 | -define('FTP_OS_Unix','u'); |
|
65 | +define('FTP_OS_Unix', 'u'); |
|
66 | 66 | |
67 | 67 | /** |
68 | 68 | * @since 2.5.0 |
69 | 69 | * @var string |
70 | 70 | */ |
71 | -define('FTP_OS_Windows','w'); |
|
71 | +define('FTP_OS_Windows', 'w'); |
|
72 | 72 | |
73 | 73 | /** |
74 | 74 | * @since 2.5.0 |
75 | 75 | * @var string |
76 | 76 | */ |
77 | -define('FTP_OS_Mac','m'); |
|
77 | +define('FTP_OS_Mac', 'm'); |
|
78 | 78 | |
79 | 79 | /** |
80 | 80 | * PemFTP base class |
@@ -121,39 +121,39 @@ discard block |
||
121 | 121 | var $AutoAsciiExt; |
122 | 122 | |
123 | 123 | /* Constructor */ |
124 | - function __construct($port_mode=FALSE, $verb=FALSE, $le=FALSE) { |
|
125 | - $this->LocalEcho=$le; |
|
126 | - $this->Verbose=$verb; |
|
127 | - $this->_lastaction=NULL; |
|
128 | - $this->_error_array=array(); |
|
129 | - $this->_eol_code=array(FTP_OS_Unix=>"\n", FTP_OS_Mac=>"\r", FTP_OS_Windows=>"\r\n"); |
|
130 | - $this->AuthorizedTransferMode=array(FTP_AUTOASCII, FTP_ASCII, FTP_BINARY); |
|
131 | - $this->OS_FullName=array(FTP_OS_Unix => 'UNIX', FTP_OS_Windows => 'WINDOWS', FTP_OS_Mac => 'MACOS'); |
|
132 | - $this->AutoAsciiExt=array("ASP","BAT","C","CPP","CSS","CSV","JS","H","HTM","HTML","SHTML","INI","LOG","PHP3","PHTML","PL","PERL","SH","SQL","TXT"); |
|
133 | - $this->_port_available=($port_mode==TRUE); |
|
134 | - $this->SendMSG("Staring FTP client class".($this->_port_available?"":" without PORT mode support")); |
|
135 | - $this->_connected=FALSE; |
|
136 | - $this->_ready=FALSE; |
|
137 | - $this->_can_restore=FALSE; |
|
138 | - $this->_code=0; |
|
139 | - $this->_message=""; |
|
140 | - $this->_ftp_buff_size=4096; |
|
141 | - $this->_curtype=NULL; |
|
124 | + function __construct($port_mode = FALSE, $verb = FALSE, $le = FALSE) { |
|
125 | + $this->LocalEcho = $le; |
|
126 | + $this->Verbose = $verb; |
|
127 | + $this->_lastaction = NULL; |
|
128 | + $this->_error_array = array(); |
|
129 | + $this->_eol_code = array(FTP_OS_Unix=>"\n", FTP_OS_Mac=>"\r", FTP_OS_Windows=>"\r\n"); |
|
130 | + $this->AuthorizedTransferMode = array(FTP_AUTOASCII, FTP_ASCII, FTP_BINARY); |
|
131 | + $this->OS_FullName = array(FTP_OS_Unix => 'UNIX', FTP_OS_Windows => 'WINDOWS', FTP_OS_Mac => 'MACOS'); |
|
132 | + $this->AutoAsciiExt = array("ASP", "BAT", "C", "CPP", "CSS", "CSV", "JS", "H", "HTM", "HTML", "SHTML", "INI", "LOG", "PHP3", "PHTML", "PL", "PERL", "SH", "SQL", "TXT"); |
|
133 | + $this->_port_available = ($port_mode == TRUE); |
|
134 | + $this->SendMSG("Staring FTP client class" . ($this->_port_available ? "" : " without PORT mode support")); |
|
135 | + $this->_connected = FALSE; |
|
136 | + $this->_ready = FALSE; |
|
137 | + $this->_can_restore = FALSE; |
|
138 | + $this->_code = 0; |
|
139 | + $this->_message = ""; |
|
140 | + $this->_ftp_buff_size = 4096; |
|
141 | + $this->_curtype = NULL; |
|
142 | 142 | $this->SetUmask(0022); |
143 | 143 | $this->SetType(FTP_AUTOASCII); |
144 | 144 | $this->SetTimeout(30); |
145 | 145 | $this->Passive(!$this->_port_available); |
146 | - $this->_login="anonymous"; |
|
147 | - $this->_password="[email protected]"; |
|
148 | - $this->_features=array(); |
|
149 | - $this->OS_local=FTP_OS_Unix; |
|
150 | - $this->OS_remote=FTP_OS_Unix; |
|
151 | - $this->features=array(); |
|
152 | - if(strtoupper(substr(PHP_OS, 0, 3)) === 'WIN') $this->OS_local=FTP_OS_Windows; |
|
153 | - elseif(strtoupper(substr(PHP_OS, 0, 3)) === 'MAC') $this->OS_local=FTP_OS_Mac; |
|
146 | + $this->_login = "anonymous"; |
|
147 | + $this->_password = "[email protected]"; |
|
148 | + $this->_features = array(); |
|
149 | + $this->OS_local = FTP_OS_Unix; |
|
150 | + $this->OS_remote = FTP_OS_Unix; |
|
151 | + $this->features = array(); |
|
152 | + if (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN') $this->OS_local = FTP_OS_Windows; |
|
153 | + elseif (strtoupper(substr(PHP_OS, 0, 3)) === 'MAC') $this->OS_local = FTP_OS_Mac; |
|
154 | 154 | } |
155 | 155 | |
156 | - function ftp_base($port_mode=FALSE) { |
|
156 | + function ftp_base($port_mode = FALSE) { |
|
157 | 157 | $this->__construct($port_mode); |
158 | 158 | } |
159 | 159 | |
@@ -163,11 +163,11 @@ discard block |
||
163 | 163 | |
164 | 164 | function parselisting($line) { |
165 | 165 | $is_windows = ($this->OS_remote == FTP_OS_Windows); |
166 | - if ($is_windows && preg_match("/([0-9]{2})-([0-9]{2})-([0-9]{2}) +([0-9]{2}):([0-9]{2})(AM|PM) +([0-9]+|<DIR>) +(.+)/",$line,$lucifer)) { |
|
166 | + if ($is_windows && preg_match("/([0-9]{2})-([0-9]{2})-([0-9]{2}) +([0-9]{2}):([0-9]{2})(AM|PM) +([0-9]+|<DIR>) +(.+)/", $line, $lucifer)) { |
|
167 | 167 | $b = array(); |
168 | - if ($lucifer[3]<70) { $lucifer[3]+=2000; } else { $lucifer[3]+=1900; } // 4digit year fix |
|
169 | - $b['isdir'] = ($lucifer[7]=="<DIR>"); |
|
170 | - if ( $b['isdir'] ) |
|
168 | + if ($lucifer[3] < 70) { $lucifer[3] += 2000; } else { $lucifer[3] += 1900; } // 4digit year fix |
|
169 | + $b['isdir'] = ($lucifer[7] == "<DIR>"); |
|
170 | + if ($b['isdir']) |
|
171 | 171 | $b['type'] = 'd'; |
172 | 172 | else |
173 | 173 | $b['type'] = 'f'; |
@@ -177,19 +177,19 @@ discard block |
||
177 | 177 | $b['year'] = $lucifer[3]; |
178 | 178 | $b['hour'] = $lucifer[4]; |
179 | 179 | $b['minute'] = $lucifer[5]; |
180 | - $b['time'] = @mktime($lucifer[4]+(strcasecmp($lucifer[6],"PM")==0?12:0),$lucifer[5],0,$lucifer[1],$lucifer[2],$lucifer[3]); |
|
180 | + $b['time'] = @mktime($lucifer[4] + (strcasecmp($lucifer[6], "PM") == 0 ? 12 : 0), $lucifer[5], 0, $lucifer[1], $lucifer[2], $lucifer[3]); |
|
181 | 181 | $b['am/pm'] = $lucifer[6]; |
182 | 182 | $b['name'] = $lucifer[8]; |
183 | - } else if (!$is_windows && $lucifer=preg_split("/[ ]/",$line,9,PREG_SPLIT_NO_EMPTY)) { |
|
183 | + } else if (!$is_windows && $lucifer = preg_split("/[ ]/", $line, 9, PREG_SPLIT_NO_EMPTY)) { |
|
184 | 184 | //echo $line."\n"; |
185 | - $lcount=count($lucifer); |
|
186 | - if ($lcount<8) return ''; |
|
185 | + $lcount = count($lucifer); |
|
186 | + if ($lcount < 8) return ''; |
|
187 | 187 | $b = array(); |
188 | 188 | $b['isdir'] = $lucifer[0][0] === "d"; |
189 | 189 | $b['islink'] = $lucifer[0][0] === "l"; |
190 | - if ( $b['isdir'] ) |
|
190 | + if ($b['isdir']) |
|
191 | 191 | $b['type'] = 'd'; |
192 | - elseif ( $b['islink'] ) |
|
192 | + elseif ($b['islink']) |
|
193 | 193 | $b['type'] = 'l'; |
194 | 194 | else |
195 | 195 | $b['type'] = 'f'; |
@@ -198,15 +198,15 @@ discard block |
||
198 | 198 | $b['owner'] = $lucifer[2]; |
199 | 199 | $b['group'] = $lucifer[3]; |
200 | 200 | $b['size'] = $lucifer[4]; |
201 | - if ($lcount==8) { |
|
202 | - sscanf($lucifer[5],"%d-%d-%d",$b['year'],$b['month'],$b['day']); |
|
203 | - sscanf($lucifer[6],"%d:%d",$b['hour'],$b['minute']); |
|
204 | - $b['time'] = @mktime($b['hour'],$b['minute'],0,$b['month'],$b['day'],$b['year']); |
|
201 | + if ($lcount == 8) { |
|
202 | + sscanf($lucifer[5], "%d-%d-%d", $b['year'], $b['month'], $b['day']); |
|
203 | + sscanf($lucifer[6], "%d:%d", $b['hour'], $b['minute']); |
|
204 | + $b['time'] = @mktime($b['hour'], $b['minute'], 0, $b['month'], $b['day'], $b['year']); |
|
205 | 205 | $b['name'] = $lucifer[7]; |
206 | 206 | } else { |
207 | 207 | $b['month'] = $lucifer[5]; |
208 | 208 | $b['day'] = $lucifer[6]; |
209 | - if (preg_match("/([0-9]{2}):([0-9]{2})/",$lucifer[7],$l2)) { |
|
209 | + if (preg_match("/([0-9]{2}):([0-9]{2})/", $lucifer[7], $l2)) { |
|
210 | 210 | $b['year'] = gmdate("Y"); |
211 | 211 | $b['hour'] = $l2[1]; |
212 | 212 | $b['minute'] = $l2[2]; |
@@ -215,7 +215,7 @@ discard block |
||
215 | 215 | $b['hour'] = 0; |
216 | 216 | $b['minute'] = 0; |
217 | 217 | } |
218 | - $b['time'] = strtotime(sprintf("%d %s %d %02d:%02d",$b['day'],$b['month'],$b['year'],$b['hour'],$b['minute'])); |
|
218 | + $b['time'] = strtotime(sprintf("%d %s %d %02d:%02d", $b['day'], $b['month'], $b['year'], $b['hour'], $b['minute'])); |
|
219 | 219 | $b['name'] = $lucifer[8]; |
220 | 220 | } |
221 | 221 | } |
@@ -223,227 +223,227 @@ discard block |
||
223 | 223 | return $b; |
224 | 224 | } |
225 | 225 | |
226 | - function SendMSG($message = "", $crlf=true) { |
|
226 | + function SendMSG($message = "", $crlf = true) { |
|
227 | 227 | if ($this->Verbose) { |
228 | - echo $message.($crlf?CRLF:""); |
|
228 | + echo $message . ($crlf ?CRLF:""); |
|
229 | 229 | flush(); |
230 | 230 | } |
231 | 231 | return TRUE; |
232 | 232 | } |
233 | 233 | |
234 | - function SetType($mode=FTP_AUTOASCII) { |
|
235 | - if(!in_array($mode, $this->AuthorizedTransferMode)) { |
|
234 | + function SetType($mode = FTP_AUTOASCII) { |
|
235 | + if (!in_array($mode, $this->AuthorizedTransferMode)) { |
|
236 | 236 | $this->SendMSG("Wrong type"); |
237 | 237 | return FALSE; |
238 | 238 | } |
239 | - $this->_type=$mode; |
|
240 | - $this->SendMSG("Transfer type: ".($this->_type==FTP_BINARY?"binary":($this->_type==FTP_ASCII?"ASCII":"auto ASCII") ) ); |
|
239 | + $this->_type = $mode; |
|
240 | + $this->SendMSG("Transfer type: " . ($this->_type == FTP_BINARY ? "binary" : ($this->_type == FTP_ASCII ? "ASCII" : "auto ASCII"))); |
|
241 | 241 | return TRUE; |
242 | 242 | } |
243 | 243 | |
244 | - function _settype($mode=FTP_ASCII) { |
|
245 | - if($this->_ready) { |
|
246 | - if($mode==FTP_BINARY) { |
|
247 | - if($this->_curtype!=FTP_BINARY) { |
|
248 | - if(!$this->_exec("TYPE I", "SetType")) return FALSE; |
|
249 | - $this->_curtype=FTP_BINARY; |
|
244 | + function _settype($mode = FTP_ASCII) { |
|
245 | + if ($this->_ready) { |
|
246 | + if ($mode == FTP_BINARY) { |
|
247 | + if ($this->_curtype != FTP_BINARY) { |
|
248 | + if (!$this->_exec("TYPE I", "SetType")) return FALSE; |
|
249 | + $this->_curtype = FTP_BINARY; |
|
250 | 250 | } |
251 | - } elseif($this->_curtype!=FTP_ASCII) { |
|
252 | - if(!$this->_exec("TYPE A", "SetType")) return FALSE; |
|
253 | - $this->_curtype=FTP_ASCII; |
|
251 | + } elseif ($this->_curtype != FTP_ASCII) { |
|
252 | + if (!$this->_exec("TYPE A", "SetType")) return FALSE; |
|
253 | + $this->_curtype = FTP_ASCII; |
|
254 | 254 | } |
255 | 255 | } else return FALSE; |
256 | 256 | return TRUE; |
257 | 257 | } |
258 | 258 | |
259 | - function Passive($pasv=NULL) { |
|
260 | - if(is_null($pasv)) $this->_passive=!$this->_passive; |
|
261 | - else $this->_passive=$pasv; |
|
262 | - if(!$this->_port_available and !$this->_passive) { |
|
259 | + function Passive($pasv = NULL) { |
|
260 | + if (is_null($pasv)) $this->_passive = !$this->_passive; |
|
261 | + else $this->_passive = $pasv; |
|
262 | + if (!$this->_port_available and !$this->_passive) { |
|
263 | 263 | $this->SendMSG("Only passive connections available!"); |
264 | - $this->_passive=TRUE; |
|
264 | + $this->_passive = TRUE; |
|
265 | 265 | return FALSE; |
266 | 266 | } |
267 | - $this->SendMSG("Passive mode ".($this->_passive?"on":"off")); |
|
267 | + $this->SendMSG("Passive mode " . ($this->_passive ? "on" : "off")); |
|
268 | 268 | return TRUE; |
269 | 269 | } |
270 | 270 | |
271 | - function SetServer($host, $port=21, $reconnect=true) { |
|
272 | - if(!is_long($port)) { |
|
273 | - $this->verbose=true; |
|
271 | + function SetServer($host, $port = 21, $reconnect = true) { |
|
272 | + if (!is_long($port)) { |
|
273 | + $this->verbose = true; |
|
274 | 274 | $this->SendMSG("Incorrect port syntax"); |
275 | 275 | return FALSE; |
276 | 276 | } else { |
277 | - $ip=@gethostbyname($host); |
|
278 | - $dns=@gethostbyaddr($host); |
|
279 | - if(!$ip) $ip=$host; |
|
280 | - if(!$dns) $dns=$host; |
|
277 | + $ip = @gethostbyname($host); |
|
278 | + $dns = @gethostbyaddr($host); |
|
279 | + if (!$ip) $ip = $host; |
|
280 | + if (!$dns) $dns = $host; |
|
281 | 281 | // Validate the IPAddress PHP4 returns -1 for invalid, PHP5 false |
282 | 282 | // -1 === "255.255.255.255" which is the broadcast address which is also going to be invalid |
283 | 283 | $ipaslong = ip2long($ip); |
284 | - if ( ($ipaslong == false) || ($ipaslong === -1) ) { |
|
285 | - $this->SendMSG("Wrong host name/address \"".$host."\""); |
|
284 | + if (($ipaslong == false) || ($ipaslong === -1)) { |
|
285 | + $this->SendMSG("Wrong host name/address \"" . $host . "\""); |
|
286 | 286 | return FALSE; |
287 | 287 | } |
288 | - $this->_host=$ip; |
|
289 | - $this->_fullhost=$dns; |
|
290 | - $this->_port=$port; |
|
291 | - $this->_dataport=$port-1; |
|
292 | - } |
|
293 | - $this->SendMSG("Host \"".$this->_fullhost."(".$this->_host."):".$this->_port."\""); |
|
294 | - if($reconnect){ |
|
295 | - if($this->_connected) { |
|
288 | + $this->_host = $ip; |
|
289 | + $this->_fullhost = $dns; |
|
290 | + $this->_port = $port; |
|
291 | + $this->_dataport = $port - 1; |
|
292 | + } |
|
293 | + $this->SendMSG("Host \"" . $this->_fullhost . "(" . $this->_host . "):" . $this->_port . "\""); |
|
294 | + if ($reconnect) { |
|
295 | + if ($this->_connected) { |
|
296 | 296 | $this->SendMSG("Reconnecting"); |
297 | - if(!$this->quit(FTP_FORCE)) return FALSE; |
|
298 | - if(!$this->connect()) return FALSE; |
|
297 | + if (!$this->quit(FTP_FORCE)) return FALSE; |
|
298 | + if (!$this->connect()) return FALSE; |
|
299 | 299 | } |
300 | 300 | } |
301 | 301 | return TRUE; |
302 | 302 | } |
303 | 303 | |
304 | - function SetUmask($umask=0022) { |
|
305 | - $this->_umask=$umask; |
|
304 | + function SetUmask($umask = 0022) { |
|
305 | + $this->_umask = $umask; |
|
306 | 306 | umask($this->_umask); |
307 | - $this->SendMSG("UMASK 0".decoct($this->_umask)); |
|
307 | + $this->SendMSG("UMASK 0" . decoct($this->_umask)); |
|
308 | 308 | return TRUE; |
309 | 309 | } |
310 | 310 | |
311 | - function SetTimeout($timeout=30) { |
|
312 | - $this->_timeout=$timeout; |
|
313 | - $this->SendMSG("Timeout ".$this->_timeout); |
|
314 | - if($this->_connected) |
|
315 | - if(!$this->_settimeout($this->_ftp_control_sock)) return FALSE; |
|
311 | + function SetTimeout($timeout = 30) { |
|
312 | + $this->_timeout = $timeout; |
|
313 | + $this->SendMSG("Timeout " . $this->_timeout); |
|
314 | + if ($this->_connected) |
|
315 | + if (!$this->_settimeout($this->_ftp_control_sock)) return FALSE; |
|
316 | 316 | return TRUE; |
317 | 317 | } |
318 | 318 | |
319 | - function connect($server=NULL) { |
|
320 | - if(!empty($server)) { |
|
321 | - if(!$this->SetServer($server)) return false; |
|
319 | + function connect($server = NULL) { |
|
320 | + if (!empty($server)) { |
|
321 | + if (!$this->SetServer($server)) return false; |
|
322 | 322 | } |
323 | - if($this->_ready) return true; |
|
324 | - $this->SendMsg('Local OS : '.$this->OS_FullName[$this->OS_local]); |
|
325 | - if(!($this->_ftp_control_sock = $this->_connect($this->_host, $this->_port))) { |
|
326 | - $this->SendMSG("Error : Cannot connect to remote host \"".$this->_fullhost." :".$this->_port."\""); |
|
323 | + if ($this->_ready) return true; |
|
324 | + $this->SendMsg('Local OS : ' . $this->OS_FullName[$this->OS_local]); |
|
325 | + if (!($this->_ftp_control_sock = $this->_connect($this->_host, $this->_port))) { |
|
326 | + $this->SendMSG("Error : Cannot connect to remote host \"" . $this->_fullhost . " :" . $this->_port . "\""); |
|
327 | 327 | return FALSE; |
328 | 328 | } |
329 | - $this->SendMSG("Connected to remote host \"".$this->_fullhost.":".$this->_port."\". Waiting for greeting."); |
|
329 | + $this->SendMSG("Connected to remote host \"" . $this->_fullhost . ":" . $this->_port . "\". Waiting for greeting."); |
|
330 | 330 | do { |
331 | - if(!$this->_readmsg()) return FALSE; |
|
332 | - if(!$this->_checkCode()) return FALSE; |
|
333 | - $this->_lastaction=time(); |
|
334 | - } while($this->_code<200); |
|
335 | - $this->_ready=true; |
|
336 | - $syst=$this->systype(); |
|
337 | - if(!$syst) $this->SendMSG("Cannot detect remote OS"); |
|
331 | + if (!$this->_readmsg()) return FALSE; |
|
332 | + if (!$this->_checkCode()) return FALSE; |
|
333 | + $this->_lastaction = time(); |
|
334 | + } while ($this->_code < 200); |
|
335 | + $this->_ready = true; |
|
336 | + $syst = $this->systype(); |
|
337 | + if (!$syst) $this->SendMSG("Cannot detect remote OS"); |
|
338 | 338 | else { |
339 | - if(preg_match("/win|dos|novell/i", $syst[0])) $this->OS_remote=FTP_OS_Windows; |
|
340 | - elseif(preg_match("/os/i", $syst[0])) $this->OS_remote=FTP_OS_Mac; |
|
341 | - elseif(preg_match("/(li|u)nix/i", $syst[0])) $this->OS_remote=FTP_OS_Unix; |
|
342 | - else $this->OS_remote=FTP_OS_Mac; |
|
343 | - $this->SendMSG("Remote OS: ".$this->OS_FullName[$this->OS_remote]); |
|
344 | - } |
|
345 | - if(!$this->features()) $this->SendMSG("Cannot get features list. All supported - disabled"); |
|
346 | - else $this->SendMSG("Supported features: ".implode(", ", array_keys($this->_features))); |
|
339 | + if (preg_match("/win|dos|novell/i", $syst[0])) $this->OS_remote = FTP_OS_Windows; |
|
340 | + elseif (preg_match("/os/i", $syst[0])) $this->OS_remote = FTP_OS_Mac; |
|
341 | + elseif (preg_match("/(li|u)nix/i", $syst[0])) $this->OS_remote = FTP_OS_Unix; |
|
342 | + else $this->OS_remote = FTP_OS_Mac; |
|
343 | + $this->SendMSG("Remote OS: " . $this->OS_FullName[$this->OS_remote]); |
|
344 | + } |
|
345 | + if (!$this->features()) $this->SendMSG("Cannot get features list. All supported - disabled"); |
|
346 | + else $this->SendMSG("Supported features: " . implode(", ", array_keys($this->_features))); |
|
347 | 347 | return TRUE; |
348 | 348 | } |
349 | 349 | |
350 | - function quit($force=false) { |
|
351 | - if($this->_ready) { |
|
352 | - if(!$this->_exec("QUIT") and !$force) return FALSE; |
|
353 | - if(!$this->_checkCode() and !$force) return FALSE; |
|
354 | - $this->_ready=false; |
|
350 | + function quit($force = false) { |
|
351 | + if ($this->_ready) { |
|
352 | + if (!$this->_exec("QUIT") and !$force) return FALSE; |
|
353 | + if (!$this->_checkCode() and !$force) return FALSE; |
|
354 | + $this->_ready = false; |
|
355 | 355 | $this->SendMSG("Session finished"); |
356 | 356 | } |
357 | 357 | $this->_quit(); |
358 | 358 | return TRUE; |
359 | 359 | } |
360 | 360 | |
361 | - function login($user=NULL, $pass=NULL) { |
|
362 | - if(!is_null($user)) $this->_login=$user; |
|
363 | - else $this->_login="anonymous"; |
|
364 | - if(!is_null($pass)) $this->_password=$pass; |
|
365 | - else $this->_password="[email protected]"; |
|
366 | - if(!$this->_exec("USER ".$this->_login, "login")) return FALSE; |
|
367 | - if(!$this->_checkCode()) return FALSE; |
|
368 | - if($this->_code!=230) { |
|
369 | - if(!$this->_exec((($this->_code==331)?"PASS ":"ACCT ").$this->_password, "login")) return FALSE; |
|
370 | - if(!$this->_checkCode()) return FALSE; |
|
361 | + function login($user = NULL, $pass = NULL) { |
|
362 | + if (!is_null($user)) $this->_login = $user; |
|
363 | + else $this->_login = "anonymous"; |
|
364 | + if (!is_null($pass)) $this->_password = $pass; |
|
365 | + else $this->_password = "[email protected]"; |
|
366 | + if (!$this->_exec("USER " . $this->_login, "login")) return FALSE; |
|
367 | + if (!$this->_checkCode()) return FALSE; |
|
368 | + if ($this->_code != 230) { |
|
369 | + if (!$this->_exec((($this->_code == 331) ? "PASS " : "ACCT ") . $this->_password, "login")) return FALSE; |
|
370 | + if (!$this->_checkCode()) return FALSE; |
|
371 | 371 | } |
372 | 372 | $this->SendMSG("Authentication succeeded"); |
373 | - if(empty($this->_features)) { |
|
374 | - if(!$this->features()) $this->SendMSG("Cannot get features list. All supported - disabled"); |
|
375 | - else $this->SendMSG("Supported features: ".implode(", ", array_keys($this->_features))); |
|
373 | + if (empty($this->_features)) { |
|
374 | + if (!$this->features()) $this->SendMSG("Cannot get features list. All supported - disabled"); |
|
375 | + else $this->SendMSG("Supported features: " . implode(", ", array_keys($this->_features))); |
|
376 | 376 | } |
377 | 377 | return TRUE; |
378 | 378 | } |
379 | 379 | |
380 | 380 | function pwd() { |
381 | - if(!$this->_exec("PWD", "pwd")) return FALSE; |
|
382 | - if(!$this->_checkCode()) return FALSE; |
|
381 | + if (!$this->_exec("PWD", "pwd")) return FALSE; |
|
382 | + if (!$this->_checkCode()) return FALSE; |
|
383 | 383 | return preg_replace("/^[0-9]{3} \"(.+)\".*$/s", "\\1", $this->_message); |
384 | 384 | } |
385 | 385 | |
386 | 386 | function cdup() { |
387 | - if(!$this->_exec("CDUP", "cdup")) return FALSE; |
|
388 | - if(!$this->_checkCode()) return FALSE; |
|
387 | + if (!$this->_exec("CDUP", "cdup")) return FALSE; |
|
388 | + if (!$this->_checkCode()) return FALSE; |
|
389 | 389 | return true; |
390 | 390 | } |
391 | 391 | |
392 | 392 | function chdir($pathname) { |
393 | - if(!$this->_exec("CWD ".$pathname, "chdir")) return FALSE; |
|
394 | - if(!$this->_checkCode()) return FALSE; |
|
393 | + if (!$this->_exec("CWD " . $pathname, "chdir")) return FALSE; |
|
394 | + if (!$this->_checkCode()) return FALSE; |
|
395 | 395 | return TRUE; |
396 | 396 | } |
397 | 397 | |
398 | 398 | function rmdir($pathname) { |
399 | - if(!$this->_exec("RMD ".$pathname, "rmdir")) return FALSE; |
|
400 | - if(!$this->_checkCode()) return FALSE; |
|
399 | + if (!$this->_exec("RMD " . $pathname, "rmdir")) return FALSE; |
|
400 | + if (!$this->_checkCode()) return FALSE; |
|
401 | 401 | return TRUE; |
402 | 402 | } |
403 | 403 | |
404 | 404 | function mkdir($pathname) { |
405 | - if(!$this->_exec("MKD ".$pathname, "mkdir")) return FALSE; |
|
406 | - if(!$this->_checkCode()) return FALSE; |
|
405 | + if (!$this->_exec("MKD " . $pathname, "mkdir")) return FALSE; |
|
406 | + if (!$this->_checkCode()) return FALSE; |
|
407 | 407 | return TRUE; |
408 | 408 | } |
409 | 409 | |
410 | 410 | function rename($from, $to) { |
411 | - if(!$this->_exec("RNFR ".$from, "rename")) return FALSE; |
|
412 | - if(!$this->_checkCode()) return FALSE; |
|
413 | - if($this->_code==350) { |
|
414 | - if(!$this->_exec("RNTO ".$to, "rename")) return FALSE; |
|
415 | - if(!$this->_checkCode()) return FALSE; |
|
411 | + if (!$this->_exec("RNFR " . $from, "rename")) return FALSE; |
|
412 | + if (!$this->_checkCode()) return FALSE; |
|
413 | + if ($this->_code == 350) { |
|
414 | + if (!$this->_exec("RNTO " . $to, "rename")) return FALSE; |
|
415 | + if (!$this->_checkCode()) return FALSE; |
|
416 | 416 | } else return FALSE; |
417 | 417 | return TRUE; |
418 | 418 | } |
419 | 419 | |
420 | 420 | function filesize($pathname) { |
421 | - if(!isset($this->_features["SIZE"])) { |
|
421 | + if (!isset($this->_features["SIZE"])) { |
|
422 | 422 | $this->PushError("filesize", "not supported by server"); |
423 | 423 | return FALSE; |
424 | 424 | } |
425 | - if(!$this->_exec("SIZE ".$pathname, "filesize")) return FALSE; |
|
426 | - if(!$this->_checkCode()) return FALSE; |
|
425 | + if (!$this->_exec("SIZE " . $pathname, "filesize")) return FALSE; |
|
426 | + if (!$this->_checkCode()) return FALSE; |
|
427 | 427 | return preg_replace("/^[0-9]{3} ([0-9]+).*$/s", "\\1", $this->_message); |
428 | 428 | } |
429 | 429 | |
430 | 430 | function abort() { |
431 | - if(!$this->_exec("ABOR", "abort")) return FALSE; |
|
432 | - if(!$this->_checkCode()) { |
|
433 | - if($this->_code!=426) return FALSE; |
|
434 | - if(!$this->_readmsg("abort")) return FALSE; |
|
435 | - if(!$this->_checkCode()) return FALSE; |
|
431 | + if (!$this->_exec("ABOR", "abort")) return FALSE; |
|
432 | + if (!$this->_checkCode()) { |
|
433 | + if ($this->_code != 426) return FALSE; |
|
434 | + if (!$this->_readmsg("abort")) return FALSE; |
|
435 | + if (!$this->_checkCode()) return FALSE; |
|
436 | 436 | } |
437 | 437 | return true; |
438 | 438 | } |
439 | 439 | |
440 | 440 | function mdtm($pathname) { |
441 | - if(!isset($this->_features["MDTM"])) { |
|
441 | + if (!isset($this->_features["MDTM"])) { |
|
442 | 442 | $this->PushError("mdtm", "not supported by server"); |
443 | 443 | return FALSE; |
444 | 444 | } |
445 | - if(!$this->_exec("MDTM ".$pathname, "mdtm")) return FALSE; |
|
446 | - if(!$this->_checkCode()) return FALSE; |
|
445 | + if (!$this->_exec("MDTM " . $pathname, "mdtm")) return FALSE; |
|
446 | + if (!$this->_checkCode()) return FALSE; |
|
447 | 447 | $mdtm = preg_replace("/^[0-9]{3} ([0-9]+).*$/s", "\\1", $this->_message); |
448 | 448 | $date = sscanf($mdtm, "%4d%2d%2d%2d%2d%2d"); |
449 | 449 | $timestamp = mktime($date[3], $date[4], $date[5], $date[1], $date[2], $date[0]); |
@@ -451,61 +451,61 @@ discard block |
||
451 | 451 | } |
452 | 452 | |
453 | 453 | function systype() { |
454 | - if(!$this->_exec("SYST", "systype")) return FALSE; |
|
455 | - if(!$this->_checkCode()) return FALSE; |
|
454 | + if (!$this->_exec("SYST", "systype")) return FALSE; |
|
455 | + if (!$this->_checkCode()) return FALSE; |
|
456 | 456 | $DATA = explode(" ", $this->_message); |
457 | 457 | return array($DATA[1], $DATA[3]); |
458 | 458 | } |
459 | 459 | |
460 | 460 | function delete($pathname) { |
461 | - if(!$this->_exec("DELE ".$pathname, "delete")) return FALSE; |
|
462 | - if(!$this->_checkCode()) return FALSE; |
|
461 | + if (!$this->_exec("DELE " . $pathname, "delete")) return FALSE; |
|
462 | + if (!$this->_checkCode()) return FALSE; |
|
463 | 463 | return TRUE; |
464 | 464 | } |
465 | 465 | |
466 | - function site($command, $fnction="site") { |
|
467 | - if(!$this->_exec("SITE ".$command, $fnction)) return FALSE; |
|
468 | - if(!$this->_checkCode()) return FALSE; |
|
466 | + function site($command, $fnction = "site") { |
|
467 | + if (!$this->_exec("SITE " . $command, $fnction)) return FALSE; |
|
468 | + if (!$this->_checkCode()) return FALSE; |
|
469 | 469 | return TRUE; |
470 | 470 | } |
471 | 471 | |
472 | 472 | function chmod($pathname, $mode) { |
473 | - if(!$this->site( sprintf('CHMOD %o %s', $mode, $pathname), "chmod")) return FALSE; |
|
473 | + if (!$this->site(sprintf('CHMOD %o %s', $mode, $pathname), "chmod")) return FALSE; |
|
474 | 474 | return TRUE; |
475 | 475 | } |
476 | 476 | |
477 | 477 | function restore($from) { |
478 | - if(!isset($this->_features["REST"])) { |
|
478 | + if (!isset($this->_features["REST"])) { |
|
479 | 479 | $this->PushError("restore", "not supported by server"); |
480 | 480 | return FALSE; |
481 | 481 | } |
482 | - if($this->_curtype!=FTP_BINARY) { |
|
482 | + if ($this->_curtype != FTP_BINARY) { |
|
483 | 483 | $this->PushError("restore", "cannot restore in ASCII mode"); |
484 | 484 | return FALSE; |
485 | 485 | } |
486 | - if(!$this->_exec("REST ".$from, "resore")) return FALSE; |
|
487 | - if(!$this->_checkCode()) return FALSE; |
|
486 | + if (!$this->_exec("REST " . $from, "resore")) return FALSE; |
|
487 | + if (!$this->_checkCode()) return FALSE; |
|
488 | 488 | return TRUE; |
489 | 489 | } |
490 | 490 | |
491 | 491 | function features() { |
492 | - if(!$this->_exec("FEAT", "features")) return FALSE; |
|
493 | - if(!$this->_checkCode()) return FALSE; |
|
494 | - $f=preg_split("/[".CRLF."]+/", preg_replace("/[0-9]{3}[ -].*[".CRLF."]+/", "", $this->_message), -1, PREG_SPLIT_NO_EMPTY); |
|
495 | - $this->_features=array(); |
|
496 | - foreach($f as $k=>$v) { |
|
497 | - $v=explode(" ", trim($v)); |
|
498 | - $this->_features[array_shift($v)]=$v; |
|
492 | + if (!$this->_exec("FEAT", "features")) return FALSE; |
|
493 | + if (!$this->_checkCode()) return FALSE; |
|
494 | + $f = preg_split("/[" . CRLF . "]+/", preg_replace("/[0-9]{3}[ -].*[" . CRLF . "]+/", "", $this->_message), -1, PREG_SPLIT_NO_EMPTY); |
|
495 | + $this->_features = array(); |
|
496 | + foreach ($f as $k=>$v) { |
|
497 | + $v = explode(" ", trim($v)); |
|
498 | + $this->_features[array_shift($v)] = $v; |
|
499 | 499 | } |
500 | 500 | return true; |
501 | 501 | } |
502 | 502 | |
503 | - function rawlist($pathname="", $arg="") { |
|
504 | - return $this->_list(($arg?" ".$arg:"").($pathname?" ".$pathname:""), "LIST", "rawlist"); |
|
503 | + function rawlist($pathname = "", $arg = "") { |
|
504 | + return $this->_list(($arg ? " " . $arg : "") . ($pathname ? " " . $pathname : ""), "LIST", "rawlist"); |
|
505 | 505 | } |
506 | 506 | |
507 | - function nlist($pathname="", $arg="") { |
|
508 | - return $this->_list(($arg?" ".$arg:"").($pathname?" ".$pathname:""), "NLST", "nlist"); |
|
507 | + function nlist($pathname = "", $arg = "") { |
|
508 | + return $this->_list(($arg ? " " . $arg : "") . ($pathname ? " " . $pathname : ""), "NLST", "nlist"); |
|
509 | 509 | } |
510 | 510 | |
511 | 511 | function is_exists($pathname) { |
@@ -513,331 +513,330 @@ discard block |
||
513 | 513 | } |
514 | 514 | |
515 | 515 | function file_exists($pathname) { |
516 | - $exists=true; |
|
517 | - if(!$this->_exec("RNFR ".$pathname, "rename")) $exists=FALSE; |
|
516 | + $exists = true; |
|
517 | + if (!$this->_exec("RNFR " . $pathname, "rename")) $exists = FALSE; |
|
518 | 518 | else { |
519 | - if(!$this->_checkCode()) $exists=FALSE; |
|
519 | + if (!$this->_checkCode()) $exists = FALSE; |
|
520 | 520 | $this->abort(); |
521 | 521 | } |
522 | - if($exists) $this->SendMSG("Remote file ".$pathname." exists"); |
|
523 | - else $this->SendMSG("Remote file ".$pathname." does not exist"); |
|
522 | + if ($exists) $this->SendMSG("Remote file " . $pathname . " exists"); |
|
523 | + else $this->SendMSG("Remote file " . $pathname . " does not exist"); |
|
524 | 524 | return $exists; |
525 | 525 | } |
526 | 526 | |
527 | - function fget($fp, $remotefile, $rest=0) { |
|
528 | - if($this->_can_restore and $rest!=0) fseek($fp, $rest); |
|
529 | - $pi=pathinfo($remotefile); |
|
530 | - if($this->_type==FTP_ASCII or ($this->_type==FTP_AUTOASCII and in_array(strtoupper($pi["extension"]), $this->AutoAsciiExt))) $mode=FTP_ASCII; |
|
531 | - else $mode=FTP_BINARY; |
|
532 | - if(!$this->_data_prepare($mode)) { |
|
527 | + function fget($fp, $remotefile, $rest = 0) { |
|
528 | + if ($this->_can_restore and $rest != 0) fseek($fp, $rest); |
|
529 | + $pi = pathinfo($remotefile); |
|
530 | + if ($this->_type == FTP_ASCII or ($this->_type == FTP_AUTOASCII and in_array(strtoupper($pi["extension"]), $this->AutoAsciiExt))) $mode = FTP_ASCII; |
|
531 | + else $mode = FTP_BINARY; |
|
532 | + if (!$this->_data_prepare($mode)) { |
|
533 | 533 | return FALSE; |
534 | 534 | } |
535 | - if($this->_can_restore and $rest!=0) $this->restore($rest); |
|
536 | - if(!$this->_exec("RETR ".$remotefile, "get")) { |
|
535 | + if ($this->_can_restore and $rest != 0) $this->restore($rest); |
|
536 | + if (!$this->_exec("RETR " . $remotefile, "get")) { |
|
537 | 537 | $this->_data_close(); |
538 | 538 | return FALSE; |
539 | 539 | } |
540 | - if(!$this->_checkCode()) { |
|
540 | + if (!$this->_checkCode()) { |
|
541 | 541 | $this->_data_close(); |
542 | 542 | return FALSE; |
543 | 543 | } |
544 | - $out=$this->_data_read($mode, $fp); |
|
544 | + $out = $this->_data_read($mode, $fp); |
|
545 | 545 | $this->_data_close(); |
546 | - if(!$this->_readmsg()) return FALSE; |
|
547 | - if(!$this->_checkCode()) return FALSE; |
|
546 | + if (!$this->_readmsg()) return FALSE; |
|
547 | + if (!$this->_checkCode()) return FALSE; |
|
548 | 548 | return $out; |
549 | 549 | } |
550 | 550 | |
551 | - function get($remotefile, $localfile=NULL, $rest=0) { |
|
552 | - if(is_null($localfile)) $localfile=$remotefile; |
|
551 | + function get($remotefile, $localfile = NULL, $rest = 0) { |
|
552 | + if (is_null($localfile)) $localfile = $remotefile; |
|
553 | 553 | if (@file_exists($localfile)) $this->SendMSG("Warning : local file will be overwritten"); |
554 | 554 | $fp = @fopen($localfile, "w"); |
555 | 555 | if (!$fp) { |
556 | - $this->PushError("get","cannot open local file", "Cannot create \"".$localfile."\""); |
|
556 | + $this->PushError("get", "cannot open local file", "Cannot create \"" . $localfile . "\""); |
|
557 | 557 | return FALSE; |
558 | 558 | } |
559 | - if($this->_can_restore and $rest!=0) fseek($fp, $rest); |
|
560 | - $pi=pathinfo($remotefile); |
|
561 | - if($this->_type==FTP_ASCII or ($this->_type==FTP_AUTOASCII and in_array(strtoupper($pi["extension"]), $this->AutoAsciiExt))) $mode=FTP_ASCII; |
|
562 | - else $mode=FTP_BINARY; |
|
563 | - if(!$this->_data_prepare($mode)) { |
|
559 | + if ($this->_can_restore and $rest != 0) fseek($fp, $rest); |
|
560 | + $pi = pathinfo($remotefile); |
|
561 | + if ($this->_type == FTP_ASCII or ($this->_type == FTP_AUTOASCII and in_array(strtoupper($pi["extension"]), $this->AutoAsciiExt))) $mode = FTP_ASCII; |
|
562 | + else $mode = FTP_BINARY; |
|
563 | + if (!$this->_data_prepare($mode)) { |
|
564 | 564 | fclose($fp); |
565 | 565 | return FALSE; |
566 | 566 | } |
567 | - if($this->_can_restore and $rest!=0) $this->restore($rest); |
|
568 | - if(!$this->_exec("RETR ".$remotefile, "get")) { |
|
567 | + if ($this->_can_restore and $rest != 0) $this->restore($rest); |
|
568 | + if (!$this->_exec("RETR " . $remotefile, "get")) { |
|
569 | 569 | $this->_data_close(); |
570 | 570 | fclose($fp); |
571 | 571 | return FALSE; |
572 | 572 | } |
573 | - if(!$this->_checkCode()) { |
|
573 | + if (!$this->_checkCode()) { |
|
574 | 574 | $this->_data_close(); |
575 | 575 | fclose($fp); |
576 | 576 | return FALSE; |
577 | 577 | } |
578 | - $out=$this->_data_read($mode, $fp); |
|
578 | + $out = $this->_data_read($mode, $fp); |
|
579 | 579 | fclose($fp); |
580 | 580 | $this->_data_close(); |
581 | - if(!$this->_readmsg()) return FALSE; |
|
582 | - if(!$this->_checkCode()) return FALSE; |
|
581 | + if (!$this->_readmsg()) return FALSE; |
|
582 | + if (!$this->_checkCode()) return FALSE; |
|
583 | 583 | return $out; |
584 | 584 | } |
585 | 585 | |
586 | - function fput($remotefile, $fp, $rest=0) { |
|
587 | - if($this->_can_restore and $rest!=0) fseek($fp, $rest); |
|
588 | - $pi=pathinfo($remotefile); |
|
589 | - if($this->_type==FTP_ASCII or ($this->_type==FTP_AUTOASCII and in_array(strtoupper($pi["extension"]), $this->AutoAsciiExt))) $mode=FTP_ASCII; |
|
590 | - else $mode=FTP_BINARY; |
|
591 | - if(!$this->_data_prepare($mode)) { |
|
586 | + function fput($remotefile, $fp, $rest = 0) { |
|
587 | + if ($this->_can_restore and $rest != 0) fseek($fp, $rest); |
|
588 | + $pi = pathinfo($remotefile); |
|
589 | + if ($this->_type == FTP_ASCII or ($this->_type == FTP_AUTOASCII and in_array(strtoupper($pi["extension"]), $this->AutoAsciiExt))) $mode = FTP_ASCII; |
|
590 | + else $mode = FTP_BINARY; |
|
591 | + if (!$this->_data_prepare($mode)) { |
|
592 | 592 | return FALSE; |
593 | 593 | } |
594 | - if($this->_can_restore and $rest!=0) $this->restore($rest); |
|
595 | - if(!$this->_exec("STOR ".$remotefile, "put")) { |
|
594 | + if ($this->_can_restore and $rest != 0) $this->restore($rest); |
|
595 | + if (!$this->_exec("STOR " . $remotefile, "put")) { |
|
596 | 596 | $this->_data_close(); |
597 | 597 | return FALSE; |
598 | 598 | } |
599 | - if(!$this->_checkCode()) { |
|
599 | + if (!$this->_checkCode()) { |
|
600 | 600 | $this->_data_close(); |
601 | 601 | return FALSE; |
602 | 602 | } |
603 | - $ret=$this->_data_write($mode, $fp); |
|
603 | + $ret = $this->_data_write($mode, $fp); |
|
604 | 604 | $this->_data_close(); |
605 | - if(!$this->_readmsg()) return FALSE; |
|
606 | - if(!$this->_checkCode()) return FALSE; |
|
605 | + if (!$this->_readmsg()) return FALSE; |
|
606 | + if (!$this->_checkCode()) return FALSE; |
|
607 | 607 | return $ret; |
608 | 608 | } |
609 | 609 | |
610 | - function put($localfile, $remotefile=NULL, $rest=0) { |
|
611 | - if(is_null($remotefile)) $remotefile=$localfile; |
|
610 | + function put($localfile, $remotefile = NULL, $rest = 0) { |
|
611 | + if (is_null($remotefile)) $remotefile = $localfile; |
|
612 | 612 | if (!file_exists($localfile)) { |
613 | - $this->PushError("put","cannot open local file", "No such file or directory \"".$localfile."\""); |
|
613 | + $this->PushError("put", "cannot open local file", "No such file or directory \"" . $localfile . "\""); |
|
614 | 614 | return FALSE; |
615 | 615 | } |
616 | 616 | $fp = @fopen($localfile, "r"); |
617 | 617 | |
618 | 618 | if (!$fp) { |
619 | - $this->PushError("put","cannot open local file", "Cannot read file \"".$localfile."\""); |
|
619 | + $this->PushError("put", "cannot open local file", "Cannot read file \"" . $localfile . "\""); |
|
620 | 620 | return FALSE; |
621 | 621 | } |
622 | - if($this->_can_restore and $rest!=0) fseek($fp, $rest); |
|
623 | - $pi=pathinfo($localfile); |
|
624 | - if($this->_type==FTP_ASCII or ($this->_type==FTP_AUTOASCII and in_array(strtoupper($pi["extension"]), $this->AutoAsciiExt))) $mode=FTP_ASCII; |
|
625 | - else $mode=FTP_BINARY; |
|
626 | - if(!$this->_data_prepare($mode)) { |
|
622 | + if ($this->_can_restore and $rest != 0) fseek($fp, $rest); |
|
623 | + $pi = pathinfo($localfile); |
|
624 | + if ($this->_type == FTP_ASCII or ($this->_type == FTP_AUTOASCII and in_array(strtoupper($pi["extension"]), $this->AutoAsciiExt))) $mode = FTP_ASCII; |
|
625 | + else $mode = FTP_BINARY; |
|
626 | + if (!$this->_data_prepare($mode)) { |
|
627 | 627 | fclose($fp); |
628 | 628 | return FALSE; |
629 | 629 | } |
630 | - if($this->_can_restore and $rest!=0) $this->restore($rest); |
|
631 | - if(!$this->_exec("STOR ".$remotefile, "put")) { |
|
630 | + if ($this->_can_restore and $rest != 0) $this->restore($rest); |
|
631 | + if (!$this->_exec("STOR " . $remotefile, "put")) { |
|
632 | 632 | $this->_data_close(); |
633 | 633 | fclose($fp); |
634 | 634 | return FALSE; |
635 | 635 | } |
636 | - if(!$this->_checkCode()) { |
|
636 | + if (!$this->_checkCode()) { |
|
637 | 637 | $this->_data_close(); |
638 | 638 | fclose($fp); |
639 | 639 | return FALSE; |
640 | 640 | } |
641 | - $ret=$this->_data_write($mode, $fp); |
|
641 | + $ret = $this->_data_write($mode, $fp); |
|
642 | 642 | fclose($fp); |
643 | 643 | $this->_data_close(); |
644 | - if(!$this->_readmsg()) return FALSE; |
|
645 | - if(!$this->_checkCode()) return FALSE; |
|
644 | + if (!$this->_readmsg()) return FALSE; |
|
645 | + if (!$this->_checkCode()) return FALSE; |
|
646 | 646 | return $ret; |
647 | 647 | } |
648 | 648 | |
649 | - function mput($local=".", $remote=NULL, $continious=false) { |
|
650 | - $local=realpath($local); |
|
651 | - if(!@file_exists($local)) { |
|
652 | - $this->PushError("mput","cannot open local folder", "Cannot stat folder \"".$local."\""); |
|
649 | + function mput($local = ".", $remote = NULL, $continious = false) { |
|
650 | + $local = realpath($local); |
|
651 | + if (!@file_exists($local)) { |
|
652 | + $this->PushError("mput", "cannot open local folder", "Cannot stat folder \"" . $local . "\""); |
|
653 | 653 | return FALSE; |
654 | 654 | } |
655 | - if(!is_dir($local)) return $this->put($local, $remote); |
|
656 | - if(empty($remote)) $remote="."; |
|
657 | - elseif(!$this->file_exists($remote) and !$this->mkdir($remote)) return FALSE; |
|
658 | - if($handle = opendir($local)) { |
|
659 | - $list=array(); |
|
655 | + if (!is_dir($local)) return $this->put($local, $remote); |
|
656 | + if (empty($remote)) $remote = "."; |
|
657 | + elseif (!$this->file_exists($remote) and !$this->mkdir($remote)) return FALSE; |
|
658 | + if ($handle = opendir($local)) { |
|
659 | + $list = array(); |
|
660 | 660 | while (false !== ($file = readdir($handle))) { |
661 | - if ($file != "." && $file != "..") $list[]=$file; |
|
661 | + if ($file != "." && $file != "..") $list[] = $file; |
|
662 | 662 | } |
663 | 663 | closedir($handle); |
664 | 664 | } else { |
665 | - $this->PushError("mput","cannot open local folder", "Cannot read folder \"".$local."\""); |
|
665 | + $this->PushError("mput", "cannot open local folder", "Cannot read folder \"" . $local . "\""); |
|
666 | 666 | return FALSE; |
667 | 667 | } |
668 | - if(empty($list)) return TRUE; |
|
669 | - $ret=true; |
|
670 | - foreach($list as $el) { |
|
671 | - if(is_dir($local."/".$el)) $t=$this->mput($local."/".$el, $remote."/".$el); |
|
672 | - else $t=$this->put($local."/".$el, $remote."/".$el); |
|
673 | - if(!$t) { |
|
674 | - $ret=FALSE; |
|
675 | - if(!$continious) break; |
|
668 | + if (empty($list)) return TRUE; |
|
669 | + $ret = true; |
|
670 | + foreach ($list as $el) { |
|
671 | + if (is_dir($local . "/" . $el)) $t = $this->mput($local . "/" . $el, $remote . "/" . $el); |
|
672 | + else $t = $this->put($local . "/" . $el, $remote . "/" . $el); |
|
673 | + if (!$t) { |
|
674 | + $ret = FALSE; |
|
675 | + if (!$continious) break; |
|
676 | 676 | } |
677 | 677 | } |
678 | 678 | return $ret; |
679 | 679 | |
680 | 680 | } |
681 | 681 | |
682 | - function mget($remote, $local=".", $continious=false) { |
|
683 | - $list=$this->rawlist($remote, "-lA"); |
|
684 | - if($list===false) { |
|
685 | - $this->PushError("mget","cannot read remote folder list", "Cannot read remote folder \"".$remote."\" contents"); |
|
682 | + function mget($remote, $local = ".", $continious = false) { |
|
683 | + $list = $this->rawlist($remote, "-lA"); |
|
684 | + if ($list === false) { |
|
685 | + $this->PushError("mget", "cannot read remote folder list", "Cannot read remote folder \"" . $remote . "\" contents"); |
|
686 | 686 | return FALSE; |
687 | 687 | } |
688 | - if(empty($list)) return true; |
|
689 | - if(!@file_exists($local)) { |
|
690 | - if(!@mkdir($local)) { |
|
691 | - $this->PushError("mget","cannot create local folder", "Cannot create folder \"".$local."\""); |
|
688 | + if (empty($list)) return true; |
|
689 | + if (!@file_exists($local)) { |
|
690 | + if (!@mkdir($local)) { |
|
691 | + $this->PushError("mget", "cannot create local folder", "Cannot create folder \"" . $local . "\""); |
|
692 | 692 | return FALSE; |
693 | 693 | } |
694 | 694 | } |
695 | - foreach($list as $k=>$v) { |
|
696 | - $list[$k]=$this->parselisting($v); |
|
697 | - if( ! $list[$k] or $list[$k]["name"]=="." or $list[$k]["name"]=="..") unset($list[$k]); |
|
698 | - } |
|
699 | - $ret=true; |
|
700 | - foreach($list as $el) { |
|
701 | - if($el["type"]=="d") { |
|
702 | - if(!$this->mget($remote."/".$el["name"], $local."/".$el["name"], $continious)) { |
|
703 | - $this->PushError("mget", "cannot copy folder", "Cannot copy remote folder \"".$remote."/".$el["name"]."\" to local \"".$local."/".$el["name"]."\""); |
|
704 | - $ret=false; |
|
705 | - if(!$continious) break; |
|
695 | + foreach ($list as $k=>$v) { |
|
696 | + $list[$k] = $this->parselisting($v); |
|
697 | + if (!$list[$k] or $list[$k]["name"] == "." or $list[$k]["name"] == "..") unset($list[$k]); |
|
698 | + } |
|
699 | + $ret = true; |
|
700 | + foreach ($list as $el) { |
|
701 | + if ($el["type"] == "d") { |
|
702 | + if (!$this->mget($remote . "/" . $el["name"], $local . "/" . $el["name"], $continious)) { |
|
703 | + $this->PushError("mget", "cannot copy folder", "Cannot copy remote folder \"" . $remote . "/" . $el["name"] . "\" to local \"" . $local . "/" . $el["name"] . "\""); |
|
704 | + $ret = false; |
|
705 | + if (!$continious) break; |
|
706 | 706 | } |
707 | 707 | } else { |
708 | - if(!$this->get($remote."/".$el["name"], $local."/".$el["name"])) { |
|
709 | - $this->PushError("mget", "cannot copy file", "Cannot copy remote file \"".$remote."/".$el["name"]."\" to local \"".$local."/".$el["name"]."\""); |
|
710 | - $ret=false; |
|
711 | - if(!$continious) break; |
|
708 | + if (!$this->get($remote . "/" . $el["name"], $local . "/" . $el["name"])) { |
|
709 | + $this->PushError("mget", "cannot copy file", "Cannot copy remote file \"" . $remote . "/" . $el["name"] . "\" to local \"" . $local . "/" . $el["name"] . "\""); |
|
710 | + $ret = false; |
|
711 | + if (!$continious) break; |
|
712 | 712 | } |
713 | 713 | } |
714 | - @chmod($local."/".$el["name"], $el["perms"]); |
|
715 | - $t=strtotime($el["date"]); |
|
716 | - if($t!==-1 and $t!==false) @touch($local."/".$el["name"], $t); |
|
714 | + @chmod($local . "/" . $el["name"], $el["perms"]); |
|
715 | + $t = strtotime($el["date"]); |
|
716 | + if ($t !== -1 and $t !== false) @touch($local . "/" . $el["name"], $t); |
|
717 | 717 | } |
718 | 718 | return $ret; |
719 | 719 | } |
720 | 720 | |
721 | - function mdel($remote, $continious=false) { |
|
722 | - $list=$this->rawlist($remote, "-la"); |
|
723 | - if($list===false) { |
|
724 | - $this->PushError("mdel","cannot read remote folder list", "Cannot read remote folder \"".$remote."\" contents"); |
|
721 | + function mdel($remote, $continious = false) { |
|
722 | + $list = $this->rawlist($remote, "-la"); |
|
723 | + if ($list === false) { |
|
724 | + $this->PushError("mdel", "cannot read remote folder list", "Cannot read remote folder \"" . $remote . "\" contents"); |
|
725 | 725 | return false; |
726 | 726 | } |
727 | 727 | |
728 | - foreach($list as $k=>$v) { |
|
729 | - $list[$k]=$this->parselisting($v); |
|
730 | - if( ! $list[$k] or $list[$k]["name"]=="." or $list[$k]["name"]=="..") unset($list[$k]); |
|
728 | + foreach ($list as $k=>$v) { |
|
729 | + $list[$k] = $this->parselisting($v); |
|
730 | + if (!$list[$k] or $list[$k]["name"] == "." or $list[$k]["name"] == "..") unset($list[$k]); |
|
731 | 731 | } |
732 | - $ret=true; |
|
732 | + $ret = true; |
|
733 | 733 | |
734 | - foreach($list as $el) { |
|
735 | - if ( empty($el) ) |
|
734 | + foreach ($list as $el) { |
|
735 | + if (empty($el)) |
|
736 | 736 | continue; |
737 | 737 | |
738 | - if($el["type"]=="d") { |
|
739 | - if(!$this->mdel($remote."/".$el["name"], $continious)) { |
|
740 | - $ret=false; |
|
741 | - if(!$continious) break; |
|
738 | + if ($el["type"] == "d") { |
|
739 | + if (!$this->mdel($remote . "/" . $el["name"], $continious)) { |
|
740 | + $ret = false; |
|
741 | + if (!$continious) break; |
|
742 | 742 | } |
743 | 743 | } else { |
744 | - if (!$this->delete($remote."/".$el["name"])) { |
|
745 | - $this->PushError("mdel", "cannot delete file", "Cannot delete remote file \"".$remote."/".$el["name"]."\""); |
|
746 | - $ret=false; |
|
747 | - if(!$continious) break; |
|
744 | + if (!$this->delete($remote . "/" . $el["name"])) { |
|
745 | + $this->PushError("mdel", "cannot delete file", "Cannot delete remote file \"" . $remote . "/" . $el["name"] . "\""); |
|
746 | + $ret = false; |
|
747 | + if (!$continious) break; |
|
748 | 748 | } |
749 | 749 | } |
750 | 750 | } |
751 | 751 | |
752 | - if(!$this->rmdir($remote)) { |
|
753 | - $this->PushError("mdel", "cannot delete folder", "Cannot delete remote folder \"".$remote."/".$el["name"]."\""); |
|
754 | - $ret=false; |
|
752 | + if (!$this->rmdir($remote)) { |
|
753 | + $this->PushError("mdel", "cannot delete folder", "Cannot delete remote folder \"" . $remote . "/" . $el["name"] . "\""); |
|
754 | + $ret = false; |
|
755 | 755 | } |
756 | 756 | return $ret; |
757 | 757 | } |
758 | 758 | |
759 | 759 | function mmkdir($dir, $mode = 0777) { |
760 | - if(empty($dir)) return FALSE; |
|
761 | - if($this->is_exists($dir) or $dir == "/" ) return TRUE; |
|
762 | - if(!$this->mmkdir(dirname($dir), $mode)) return false; |
|
763 | - $r=$this->mkdir($dir, $mode); |
|
764 | - $this->chmod($dir,$mode); |
|
760 | + if (empty($dir)) return FALSE; |
|
761 | + if ($this->is_exists($dir) or $dir == "/") return TRUE; |
|
762 | + if (!$this->mmkdir(dirname($dir), $mode)) return false; |
|
763 | + $r = $this->mkdir($dir, $mode); |
|
764 | + $this->chmod($dir, $mode); |
|
765 | 765 | return $r; |
766 | 766 | } |
767 | 767 | |
768 | - function glob($pattern, $handle=NULL) { |
|
769 | - $path=$output=null; |
|
770 | - if(PHP_OS=='WIN32') $slash='\\'; |
|
771 | - else $slash='/'; |
|
772 | - $lastpos=strrpos($pattern,$slash); |
|
773 | - if(!($lastpos===false)) { |
|
774 | - $path=substr($pattern,0,-$lastpos-1); |
|
775 | - $pattern=substr($pattern,$lastpos); |
|
776 | - } else $path=getcwd(); |
|
777 | - if(is_array($handle) and !empty($handle)) { |
|
778 | - foreach($handle as $dir) { |
|
779 | - if($this->glob_pattern_match($pattern,$dir)) |
|
780 | - $output[]=$dir; |
|
768 | + function glob($pattern, $handle = NULL) { |
|
769 | + $path = $output = null; |
|
770 | + if (PHP_OS == 'WIN32') $slash = '\\'; |
|
771 | + else $slash = '/'; |
|
772 | + $lastpos = strrpos($pattern, $slash); |
|
773 | + if (!($lastpos === false)) { |
|
774 | + $path = substr($pattern, 0, -$lastpos - 1); |
|
775 | + $pattern = substr($pattern, $lastpos); |
|
776 | + } else $path = getcwd(); |
|
777 | + if (is_array($handle) and !empty($handle)) { |
|
778 | + foreach ($handle as $dir) { |
|
779 | + if ($this->glob_pattern_match($pattern, $dir)) |
|
780 | + $output[] = $dir; |
|
781 | 781 | } |
782 | 782 | } else { |
783 | - $handle=@opendir($path); |
|
784 | - if($handle===false) return false; |
|
785 | - while($dir=readdir($handle)) { |
|
786 | - if($this->glob_pattern_match($pattern,$dir)) |
|
787 | - $output[]=$dir; |
|
783 | + $handle = @opendir($path); |
|
784 | + if ($handle === false) return false; |
|
785 | + while ($dir = readdir($handle)) { |
|
786 | + if ($this->glob_pattern_match($pattern, $dir)) |
|
787 | + $output[] = $dir; |
|
788 | 788 | } |
789 | 789 | closedir($handle); |
790 | 790 | } |
791 | - if(is_array($output)) return $output; |
|
791 | + if (is_array($output)) return $output; |
|
792 | 792 | return false; |
793 | 793 | } |
794 | 794 | |
795 | - function glob_pattern_match($pattern,$subject) { |
|
796 | - $out=null; |
|
797 | - $chunks=explode(';',$pattern); |
|
798 | - foreach($chunks as $pattern) { |
|
799 | - $escape=array('$','^','.','{','}','(',')','[',']','|'); |
|
800 | - while(strpos($pattern,'**')!==false) |
|
801 | - $pattern=str_replace('**','*',$pattern); |
|
802 | - foreach($escape as $probe) |
|
803 | - $pattern=str_replace($probe,"\\$probe",$pattern); |
|
804 | - $pattern=str_replace('?*','*', |
|
805 | - str_replace('*?','*', |
|
806 | - str_replace('*',".*", |
|
807 | - str_replace('?','.{1,1}',$pattern)))); |
|
808 | - $out[]=$pattern; |
|
809 | - } |
|
810 | - if(count($out)==1) return($this->glob_regexp("^$out[0]$",$subject)); |
|
795 | + function glob_pattern_match($pattern, $subject) { |
|
796 | + $out = null; |
|
797 | + $chunks = explode(';', $pattern); |
|
798 | + foreach ($chunks as $pattern) { |
|
799 | + $escape = array('$', '^', '.', '{', '}', '(', ')', '[', ']', '|'); |
|
800 | + while (strpos($pattern, '**') !== false) |
|
801 | + $pattern = str_replace('**', '*', $pattern); |
|
802 | + foreach ($escape as $probe) |
|
803 | + $pattern = str_replace($probe, "\\$probe", $pattern); |
|
804 | + $pattern = str_replace('?*', '*', |
|
805 | + str_replace('*?', '*', |
|
806 | + str_replace('*', ".*", |
|
807 | + str_replace('?', '.{1,1}', $pattern)))); |
|
808 | + $out[] = $pattern; |
|
809 | + } |
|
810 | + if (count($out) == 1) return($this->glob_regexp("^$out[0]$", $subject)); |
|
811 | 811 | else { |
812 | - foreach($out as $tester) |
|
812 | + foreach ($out as $tester) |
|
813 | 813 | // TODO: This should probably be glob_regexp(), but needs tests. |
814 | - if($this->my_regexp("^$tester$",$subject)) return true; |
|
814 | + if ($this->my_regexp("^$tester$", $subject)) return true; |
|
815 | 815 | } |
816 | 816 | return false; |
817 | 817 | } |
818 | 818 | |
819 | - function glob_regexp($pattern,$subject) { |
|
820 | - $sensitive=(PHP_OS!='WIN32'); |
|
821 | - return ($sensitive? |
|
822 | - preg_match( '/' . preg_quote( $pattern, '/' ) . '/', $subject ) : |
|
823 | - preg_match( '/' . preg_quote( $pattern, '/' ) . '/i', $subject ) |
|
819 | + function glob_regexp($pattern, $subject) { |
|
820 | + $sensitive = (PHP_OS != 'WIN32'); |
|
821 | + return ($sensitive ? |
|
822 | + preg_match('/' . preg_quote($pattern, '/') . '/', $subject) : preg_match('/' . preg_quote($pattern, '/') . '/i', $subject) |
|
824 | 823 | ); |
825 | 824 | } |
826 | 825 | |
827 | 826 | function dirlist($remote) { |
828 | - $list=$this->rawlist($remote, "-la"); |
|
829 | - if($list===false) { |
|
830 | - $this->PushError("dirlist","cannot read remote folder list", "Cannot read remote folder \"".$remote."\" contents"); |
|
827 | + $list = $this->rawlist($remote, "-la"); |
|
828 | + if ($list === false) { |
|
829 | + $this->PushError("dirlist", "cannot read remote folder list", "Cannot read remote folder \"" . $remote . "\" contents"); |
|
831 | 830 | return false; |
832 | 831 | } |
833 | 832 | |
834 | 833 | $dirlist = array(); |
835 | - foreach($list as $k=>$v) { |
|
836 | - $entry=$this->parselisting($v); |
|
837 | - if ( empty($entry) ) |
|
834 | + foreach ($list as $k=>$v) { |
|
835 | + $entry = $this->parselisting($v); |
|
836 | + if (empty($entry)) |
|
838 | 837 | continue; |
839 | 838 | |
840 | - if($entry["name"]=="." or $entry["name"]=="..") |
|
839 | + if ($entry["name"] == "." or $entry["name"] == "..") |
|
841 | 840 | continue; |
842 | 841 | |
843 | 842 | $dirlist[$entry['name']] = $entry; |
@@ -849,27 +848,27 @@ discard block |
||
849 | 848 | // <!-- Private functions --> |
850 | 849 | // <!-- --------------------------------------------------------------------------------------- --> |
851 | 850 | function _checkCode() { |
852 | - return ($this->_code<400 and $this->_code>0); |
|
851 | + return ($this->_code < 400 and $this->_code > 0); |
|
853 | 852 | } |
854 | 853 | |
855 | - function _list($arg="", $cmd="LIST", $fnction="_list") { |
|
856 | - if(!$this->_data_prepare()) return false; |
|
857 | - if(!$this->_exec($cmd.$arg, $fnction)) { |
|
854 | + function _list($arg = "", $cmd = "LIST", $fnction = "_list") { |
|
855 | + if (!$this->_data_prepare()) return false; |
|
856 | + if (!$this->_exec($cmd . $arg, $fnction)) { |
|
858 | 857 | $this->_data_close(); |
859 | 858 | return FALSE; |
860 | 859 | } |
861 | - if(!$this->_checkCode()) { |
|
860 | + if (!$this->_checkCode()) { |
|
862 | 861 | $this->_data_close(); |
863 | 862 | return FALSE; |
864 | 863 | } |
865 | - $out=""; |
|
866 | - if($this->_code<200) { |
|
867 | - $out=$this->_data_read(); |
|
864 | + $out = ""; |
|
865 | + if ($this->_code < 200) { |
|
866 | + $out = $this->_data_read(); |
|
868 | 867 | $this->_data_close(); |
869 | - if(!$this->_readmsg()) return FALSE; |
|
870 | - if(!$this->_checkCode()) return FALSE; |
|
871 | - if($out === FALSE ) return FALSE; |
|
872 | - $out=preg_split("/[".CRLF."]+/", $out, -1, PREG_SPLIT_NO_EMPTY); |
|
868 | + if (!$this->_readmsg()) return FALSE; |
|
869 | + if (!$this->_checkCode()) return FALSE; |
|
870 | + if ($out === FALSE) return FALSE; |
|
871 | + $out = preg_split("/[" . CRLF . "]+/", $out, -1, PREG_SPLIT_NO_EMPTY); |
|
873 | 872 | // $this->SendMSG(implode($this->_eol_code[$this->OS_local], $out)); |
874 | 873 | } |
875 | 874 | return $out; |
@@ -879,34 +878,34 @@ discard block |
||
879 | 878 | // <!-- Partie : gestion des erreurs --> |
880 | 879 | // <!-- --------------------------------------------------------------------------------------- --> |
881 | 880 | // Gnre une erreur pour traitement externe la classe |
882 | - function PushError($fctname,$msg,$desc=false){ |
|
883 | - $error=array(); |
|
884 | - $error['time']=time(); |
|
885 | - $error['fctname']=$fctname; |
|
886 | - $error['msg']=$msg; |
|
887 | - $error['desc']=$desc; |
|
888 | - if($desc) $tmp=' ('.$desc.')'; else $tmp=''; |
|
889 | - $this->SendMSG($fctname.': '.$msg.$tmp); |
|
890 | - return(array_push($this->_error_array,$error)); |
|
881 | + function PushError($fctname, $msg, $desc = false) { |
|
882 | + $error = array(); |
|
883 | + $error['time'] = time(); |
|
884 | + $error['fctname'] = $fctname; |
|
885 | + $error['msg'] = $msg; |
|
886 | + $error['desc'] = $desc; |
|
887 | + if ($desc) $tmp = ' (' . $desc . ')'; else $tmp = ''; |
|
888 | + $this->SendMSG($fctname . ': ' . $msg . $tmp); |
|
889 | + return(array_push($this->_error_array, $error)); |
|
891 | 890 | } |
892 | 891 | |
893 | 892 | // Rcupre une erreur externe |
894 | - function PopError(){ |
|
895 | - if(count($this->_error_array)) return(array_pop($this->_error_array)); |
|
893 | + function PopError() { |
|
894 | + if (count($this->_error_array)) return(array_pop($this->_error_array)); |
|
896 | 895 | else return(false); |
897 | 896 | } |
898 | 897 | } |
899 | 898 | |
900 | -$mod_sockets = extension_loaded( 'sockets' ); |
|
901 | -if ( ! $mod_sockets && function_exists( 'dl' ) && is_callable( 'dl' ) ) { |
|
902 | - $prefix = ( PHP_SHLIB_SUFFIX == 'dll' ) ? 'php_' : ''; |
|
903 | - @dl( $prefix . 'sockets.' . PHP_SHLIB_SUFFIX ); // phpcs:ignore PHPCompatibility.FunctionUse.RemovedFunctions.dlDeprecated |
|
904 | - $mod_sockets = extension_loaded( 'sockets' ); |
|
899 | +$mod_sockets = extension_loaded('sockets'); |
|
900 | +if (!$mod_sockets && function_exists('dl') && is_callable('dl')) { |
|
901 | + $prefix = (PHP_SHLIB_SUFFIX == 'dll') ? 'php_' : ''; |
|
902 | + @dl($prefix . 'sockets.' . PHP_SHLIB_SUFFIX); // phpcs:ignore PHPCompatibility.FunctionUse.RemovedFunctions.dlDeprecated |
|
903 | + $mod_sockets = extension_loaded('sockets'); |
|
905 | 904 | } |
906 | 905 | |
907 | -require_once __DIR__ . "/class-ftp-" . ( $mod_sockets ? "sockets" : "pure" ) . ".php"; |
|
906 | +require_once __DIR__ . "/class-ftp-" . ($mod_sockets ? "sockets" : "pure") . ".php"; |
|
908 | 907 | |
909 | -if ( $mod_sockets ) { |
|
908 | +if ($mod_sockets) { |
|
910 | 909 | class ftp extends ftp_sockets {} |
911 | 910 | } else { |
912 | 911 | class ftp extends ftp_pure {} |
@@ -18,186 +18,186 @@ discard block |
||
18 | 18 | * Defaults to the `$_POST` superglobal. |
19 | 19 | * @return array|WP_Error Array of post data on success, WP_Error on failure. |
20 | 20 | */ |
21 | -function _wp_translate_postdata( $update = false, $post_data = null ) { |
|
21 | +function _wp_translate_postdata($update = false, $post_data = null) { |
|
22 | 22 | |
23 | - if ( empty( $post_data ) ) { |
|
23 | + if (empty($post_data)) { |
|
24 | 24 | $post_data = &$_POST; |
25 | 25 | } |
26 | 26 | |
27 | - if ( $update ) { |
|
27 | + if ($update) { |
|
28 | 28 | $post_data['ID'] = (int) $post_data['post_ID']; |
29 | 29 | } |
30 | 30 | |
31 | - $ptype = get_post_type_object( $post_data['post_type'] ); |
|
31 | + $ptype = get_post_type_object($post_data['post_type']); |
|
32 | 32 | |
33 | - if ( $update && ! current_user_can( 'edit_post', $post_data['ID'] ) ) { |
|
34 | - if ( 'page' === $post_data['post_type'] ) { |
|
35 | - return new WP_Error( 'edit_others_pages', __( 'Sorry, you are not allowed to edit pages as this user.' ) ); |
|
33 | + if ($update && !current_user_can('edit_post', $post_data['ID'])) { |
|
34 | + if ('page' === $post_data['post_type']) { |
|
35 | + return new WP_Error('edit_others_pages', __('Sorry, you are not allowed to edit pages as this user.')); |
|
36 | 36 | } else { |
37 | - return new WP_Error( 'edit_others_posts', __( 'Sorry, you are not allowed to edit posts as this user.' ) ); |
|
37 | + return new WP_Error('edit_others_posts', __('Sorry, you are not allowed to edit posts as this user.')); |
|
38 | 38 | } |
39 | - } elseif ( ! $update && ! current_user_can( $ptype->cap->create_posts ) ) { |
|
40 | - if ( 'page' === $post_data['post_type'] ) { |
|
41 | - return new WP_Error( 'edit_others_pages', __( 'Sorry, you are not allowed to create pages as this user.' ) ); |
|
39 | + } elseif (!$update && !current_user_can($ptype->cap->create_posts)) { |
|
40 | + if ('page' === $post_data['post_type']) { |
|
41 | + return new WP_Error('edit_others_pages', __('Sorry, you are not allowed to create pages as this user.')); |
|
42 | 42 | } else { |
43 | - return new WP_Error( 'edit_others_posts', __( 'Sorry, you are not allowed to create posts as this user.' ) ); |
|
43 | + return new WP_Error('edit_others_posts', __('Sorry, you are not allowed to create posts as this user.')); |
|
44 | 44 | } |
45 | 45 | } |
46 | 46 | |
47 | - if ( isset( $post_data['content'] ) ) { |
|
47 | + if (isset($post_data['content'])) { |
|
48 | 48 | $post_data['post_content'] = $post_data['content']; |
49 | 49 | } |
50 | 50 | |
51 | - if ( isset( $post_data['excerpt'] ) ) { |
|
51 | + if (isset($post_data['excerpt'])) { |
|
52 | 52 | $post_data['post_excerpt'] = $post_data['excerpt']; |
53 | 53 | } |
54 | 54 | |
55 | - if ( isset( $post_data['parent_id'] ) ) { |
|
55 | + if (isset($post_data['parent_id'])) { |
|
56 | 56 | $post_data['post_parent'] = (int) $post_data['parent_id']; |
57 | 57 | } |
58 | 58 | |
59 | - if ( isset( $post_data['trackback_url'] ) ) { |
|
59 | + if (isset($post_data['trackback_url'])) { |
|
60 | 60 | $post_data['to_ping'] = $post_data['trackback_url']; |
61 | 61 | } |
62 | 62 | |
63 | 63 | $post_data['user_ID'] = get_current_user_id(); |
64 | 64 | |
65 | - if ( ! empty( $post_data['post_author_override'] ) ) { |
|
65 | + if (!empty($post_data['post_author_override'])) { |
|
66 | 66 | $post_data['post_author'] = (int) $post_data['post_author_override']; |
67 | 67 | } else { |
68 | - if ( ! empty( $post_data['post_author'] ) ) { |
|
68 | + if (!empty($post_data['post_author'])) { |
|
69 | 69 | $post_data['post_author'] = (int) $post_data['post_author']; |
70 | 70 | } else { |
71 | 71 | $post_data['post_author'] = (int) $post_data['user_ID']; |
72 | 72 | } |
73 | 73 | } |
74 | 74 | |
75 | - if ( isset( $post_data['user_ID'] ) && ( $post_data['post_author'] != $post_data['user_ID'] ) |
|
76 | - && ! current_user_can( $ptype->cap->edit_others_posts ) ) { |
|
75 | + if (isset($post_data['user_ID']) && ($post_data['post_author'] != $post_data['user_ID']) |
|
76 | + && !current_user_can($ptype->cap->edit_others_posts)) { |
|
77 | 77 | |
78 | - if ( $update ) { |
|
79 | - if ( 'page' === $post_data['post_type'] ) { |
|
80 | - return new WP_Error( 'edit_others_pages', __( 'Sorry, you are not allowed to edit pages as this user.' ) ); |
|
78 | + if ($update) { |
|
79 | + if ('page' === $post_data['post_type']) { |
|
80 | + return new WP_Error('edit_others_pages', __('Sorry, you are not allowed to edit pages as this user.')); |
|
81 | 81 | } else { |
82 | - return new WP_Error( 'edit_others_posts', __( 'Sorry, you are not allowed to edit posts as this user.' ) ); |
|
82 | + return new WP_Error('edit_others_posts', __('Sorry, you are not allowed to edit posts as this user.')); |
|
83 | 83 | } |
84 | 84 | } else { |
85 | - if ( 'page' === $post_data['post_type'] ) { |
|
86 | - return new WP_Error( 'edit_others_pages', __( 'Sorry, you are not allowed to create pages as this user.' ) ); |
|
85 | + if ('page' === $post_data['post_type']) { |
|
86 | + return new WP_Error('edit_others_pages', __('Sorry, you are not allowed to create pages as this user.')); |
|
87 | 87 | } else { |
88 | - return new WP_Error( 'edit_others_posts', __( 'Sorry, you are not allowed to create posts as this user.' ) ); |
|
88 | + return new WP_Error('edit_others_posts', __('Sorry, you are not allowed to create posts as this user.')); |
|
89 | 89 | } |
90 | 90 | } |
91 | 91 | } |
92 | 92 | |
93 | - if ( ! empty( $post_data['post_status'] ) ) { |
|
94 | - $post_data['post_status'] = sanitize_key( $post_data['post_status'] ); |
|
93 | + if (!empty($post_data['post_status'])) { |
|
94 | + $post_data['post_status'] = sanitize_key($post_data['post_status']); |
|
95 | 95 | |
96 | 96 | // No longer an auto-draft. |
97 | - if ( 'auto-draft' === $post_data['post_status'] ) { |
|
97 | + if ('auto-draft' === $post_data['post_status']) { |
|
98 | 98 | $post_data['post_status'] = 'draft'; |
99 | 99 | } |
100 | 100 | |
101 | - if ( ! get_post_status_object( $post_data['post_status'] ) ) { |
|
102 | - unset( $post_data['post_status'] ); |
|
101 | + if (!get_post_status_object($post_data['post_status'])) { |
|
102 | + unset($post_data['post_status']); |
|
103 | 103 | } |
104 | 104 | } |
105 | 105 | |
106 | 106 | // What to do based on which button they pressed. |
107 | - if ( isset( $post_data['saveasdraft'] ) && '' !== $post_data['saveasdraft'] ) { |
|
107 | + if (isset($post_data['saveasdraft']) && '' !== $post_data['saveasdraft']) { |
|
108 | 108 | $post_data['post_status'] = 'draft'; |
109 | 109 | } |
110 | - if ( isset( $post_data['saveasprivate'] ) && '' !== $post_data['saveasprivate'] ) { |
|
110 | + if (isset($post_data['saveasprivate']) && '' !== $post_data['saveasprivate']) { |
|
111 | 111 | $post_data['post_status'] = 'private'; |
112 | 112 | } |
113 | - if ( isset( $post_data['publish'] ) && ( '' !== $post_data['publish'] ) |
|
114 | - && ( ! isset( $post_data['post_status'] ) || 'private' !== $post_data['post_status'] ) |
|
113 | + if (isset($post_data['publish']) && ('' !== $post_data['publish']) |
|
114 | + && (!isset($post_data['post_status']) || 'private' !== $post_data['post_status']) |
|
115 | 115 | ) { |
116 | 116 | $post_data['post_status'] = 'publish'; |
117 | 117 | } |
118 | - if ( isset( $post_data['advanced'] ) && '' !== $post_data['advanced'] ) { |
|
118 | + if (isset($post_data['advanced']) && '' !== $post_data['advanced']) { |
|
119 | 119 | $post_data['post_status'] = 'draft'; |
120 | 120 | } |
121 | - if ( isset( $post_data['pending'] ) && '' !== $post_data['pending'] ) { |
|
121 | + if (isset($post_data['pending']) && '' !== $post_data['pending']) { |
|
122 | 122 | $post_data['post_status'] = 'pending'; |
123 | 123 | } |
124 | 124 | |
125 | - if ( isset( $post_data['ID'] ) ) { |
|
125 | + if (isset($post_data['ID'])) { |
|
126 | 126 | $post_id = $post_data['ID']; |
127 | 127 | } else { |
128 | 128 | $post_id = false; |
129 | 129 | } |
130 | - $previous_status = $post_id ? get_post_field( 'post_status', $post_id ) : false; |
|
130 | + $previous_status = $post_id ? get_post_field('post_status', $post_id) : false; |
|
131 | 131 | |
132 | - if ( isset( $post_data['post_status'] ) && 'private' === $post_data['post_status'] && ! current_user_can( $ptype->cap->publish_posts ) ) { |
|
132 | + if (isset($post_data['post_status']) && 'private' === $post_data['post_status'] && !current_user_can($ptype->cap->publish_posts)) { |
|
133 | 133 | $post_data['post_status'] = $previous_status ? $previous_status : 'pending'; |
134 | 134 | } |
135 | 135 | |
136 | - $published_statuses = array( 'publish', 'future' ); |
|
136 | + $published_statuses = array('publish', 'future'); |
|
137 | 137 | |
138 | 138 | // Posts 'submitted for approval' are submitted to $_POST the same as if they were being published. |
139 | 139 | // Change status from 'publish' to 'pending' if user lacks permissions to publish or to resave published posts. |
140 | - if ( isset( $post_data['post_status'] ) |
|
141 | - && ( in_array( $post_data['post_status'], $published_statuses, true ) |
|
142 | - && ! current_user_can( $ptype->cap->publish_posts ) ) |
|
140 | + if (isset($post_data['post_status']) |
|
141 | + && (in_array($post_data['post_status'], $published_statuses, true) |
|
142 | + && !current_user_can($ptype->cap->publish_posts)) |
|
143 | 143 | ) { |
144 | - if ( ! in_array( $previous_status, $published_statuses, true ) || ! current_user_can( 'edit_post', $post_id ) ) { |
|
144 | + if (!in_array($previous_status, $published_statuses, true) || !current_user_can('edit_post', $post_id)) { |
|
145 | 145 | $post_data['post_status'] = 'pending'; |
146 | 146 | } |
147 | 147 | } |
148 | 148 | |
149 | - if ( ! isset( $post_data['post_status'] ) ) { |
|
149 | + if (!isset($post_data['post_status'])) { |
|
150 | 150 | $post_data['post_status'] = 'auto-draft' === $previous_status ? 'draft' : $previous_status; |
151 | 151 | } |
152 | 152 | |
153 | - if ( isset( $post_data['post_password'] ) && ! current_user_can( $ptype->cap->publish_posts ) ) { |
|
154 | - unset( $post_data['post_password'] ); |
|
153 | + if (isset($post_data['post_password']) && !current_user_can($ptype->cap->publish_posts)) { |
|
154 | + unset($post_data['post_password']); |
|
155 | 155 | } |
156 | 156 | |
157 | - if ( ! isset( $post_data['comment_status'] ) ) { |
|
157 | + if (!isset($post_data['comment_status'])) { |
|
158 | 158 | $post_data['comment_status'] = 'closed'; |
159 | 159 | } |
160 | 160 | |
161 | - if ( ! isset( $post_data['ping_status'] ) ) { |
|
161 | + if (!isset($post_data['ping_status'])) { |
|
162 | 162 | $post_data['ping_status'] = 'closed'; |
163 | 163 | } |
164 | 164 | |
165 | - foreach ( array( 'aa', 'mm', 'jj', 'hh', 'mn' ) as $timeunit ) { |
|
166 | - if ( ! empty( $post_data[ 'hidden_' . $timeunit ] ) && $post_data[ 'hidden_' . $timeunit ] != $post_data[ $timeunit ] ) { |
|
165 | + foreach (array('aa', 'mm', 'jj', 'hh', 'mn') as $timeunit) { |
|
166 | + if (!empty($post_data['hidden_' . $timeunit]) && $post_data['hidden_' . $timeunit] != $post_data[$timeunit]) { |
|
167 | 167 | $post_data['edit_date'] = '1'; |
168 | 168 | break; |
169 | 169 | } |
170 | 170 | } |
171 | 171 | |
172 | - if ( ! empty( $post_data['edit_date'] ) ) { |
|
172 | + if (!empty($post_data['edit_date'])) { |
|
173 | 173 | $aa = $post_data['aa']; |
174 | 174 | $mm = $post_data['mm']; |
175 | 175 | $jj = $post_data['jj']; |
176 | 176 | $hh = $post_data['hh']; |
177 | 177 | $mn = $post_data['mn']; |
178 | 178 | $ss = $post_data['ss']; |
179 | - $aa = ( $aa <= 0 ) ? gmdate( 'Y' ) : $aa; |
|
180 | - $mm = ( $mm <= 0 ) ? gmdate( 'n' ) : $mm; |
|
181 | - $jj = ( $jj > 31 ) ? 31 : $jj; |
|
182 | - $jj = ( $jj <= 0 ) ? gmdate( 'j' ) : $jj; |
|
183 | - $hh = ( $hh > 23 ) ? $hh - 24 : $hh; |
|
184 | - $mn = ( $mn > 59 ) ? $mn - 60 : $mn; |
|
185 | - $ss = ( $ss > 59 ) ? $ss - 60 : $ss; |
|
179 | + $aa = ($aa <= 0) ? gmdate('Y') : $aa; |
|
180 | + $mm = ($mm <= 0) ? gmdate('n') : $mm; |
|
181 | + $jj = ($jj > 31) ? 31 : $jj; |
|
182 | + $jj = ($jj <= 0) ? gmdate('j') : $jj; |
|
183 | + $hh = ($hh > 23) ? $hh - 24 : $hh; |
|
184 | + $mn = ($mn > 59) ? $mn - 60 : $mn; |
|
185 | + $ss = ($ss > 59) ? $ss - 60 : $ss; |
|
186 | 186 | |
187 | - $post_data['post_date'] = sprintf( '%04d-%02d-%02d %02d:%02d:%02d', $aa, $mm, $jj, $hh, $mn, $ss ); |
|
187 | + $post_data['post_date'] = sprintf('%04d-%02d-%02d %02d:%02d:%02d', $aa, $mm, $jj, $hh, $mn, $ss); |
|
188 | 188 | |
189 | - $valid_date = wp_checkdate( $mm, $jj, $aa, $post_data['post_date'] ); |
|
190 | - if ( ! $valid_date ) { |
|
191 | - return new WP_Error( 'invalid_date', __( 'Invalid date.' ) ); |
|
189 | + $valid_date = wp_checkdate($mm, $jj, $aa, $post_data['post_date']); |
|
190 | + if (!$valid_date) { |
|
191 | + return new WP_Error('invalid_date', __('Invalid date.')); |
|
192 | 192 | } |
193 | 193 | |
194 | - $post_data['post_date_gmt'] = get_gmt_from_date( $post_data['post_date'] ); |
|
194 | + $post_data['post_date_gmt'] = get_gmt_from_date($post_data['post_date']); |
|
195 | 195 | } |
196 | 196 | |
197 | - if ( isset( $post_data['post_category'] ) ) { |
|
198 | - $category_object = get_taxonomy( 'category' ); |
|
199 | - if ( ! current_user_can( $category_object->cap->assign_terms ) ) { |
|
200 | - unset( $post_data['post_category'] ); |
|
197 | + if (isset($post_data['post_category'])) { |
|
198 | + $category_object = get_taxonomy('category'); |
|
199 | + if (!current_user_can($category_object->cap->assign_terms)) { |
|
200 | + unset($post_data['post_category']); |
|
201 | 201 | } |
202 | 202 | } |
203 | 203 | |
@@ -213,17 +213,17 @@ discard block |
||
213 | 213 | * Defaults to the `$_POST` superglobal. |
214 | 214 | * @return array|WP_Error Array of post data on success, WP_Error on failure. |
215 | 215 | */ |
216 | -function _wp_get_allowed_postdata( $post_data = null ) { |
|
217 | - if ( empty( $post_data ) ) { |
|
216 | +function _wp_get_allowed_postdata($post_data = null) { |
|
217 | + if (empty($post_data)) { |
|
218 | 218 | $post_data = $_POST; |
219 | 219 | } |
220 | 220 | |
221 | 221 | // Pass through errors. |
222 | - if ( is_wp_error( $post_data ) ) { |
|
222 | + if (is_wp_error($post_data)) { |
|
223 | 223 | return $post_data; |
224 | 224 | } |
225 | 225 | |
226 | - return array_diff_key( $post_data, array_flip( array( 'meta_input', 'file', 'guid' ) ) ); |
|
226 | + return array_diff_key($post_data, array_flip(array('meta_input', 'file', 'guid'))); |
|
227 | 227 | } |
228 | 228 | |
229 | 229 | /** |
@@ -242,40 +242,40 @@ discard block |
||
242 | 242 | * Defaults to the `$_POST` superglobal. |
243 | 243 | * @return int Post ID. |
244 | 244 | */ |
245 | -function edit_post( $post_data = null ) { |
|
245 | +function edit_post($post_data = null) { |
|
246 | 246 | global $wpdb; |
247 | 247 | |
248 | - if ( empty( $post_data ) ) { |
|
248 | + if (empty($post_data)) { |
|
249 | 249 | $post_data = &$_POST; |
250 | 250 | } |
251 | 251 | |
252 | 252 | // Clear out any data in internal vars. |
253 | - unset( $post_data['filter'] ); |
|
253 | + unset($post_data['filter']); |
|
254 | 254 | |
255 | 255 | $post_ID = (int) $post_data['post_ID']; |
256 | - $post = get_post( $post_ID ); |
|
256 | + $post = get_post($post_ID); |
|
257 | 257 | |
258 | 258 | $post_data['post_type'] = $post->post_type; |
259 | 259 | $post_data['post_mime_type'] = $post->post_mime_type; |
260 | 260 | |
261 | - if ( ! empty( $post_data['post_status'] ) ) { |
|
262 | - $post_data['post_status'] = sanitize_key( $post_data['post_status'] ); |
|
261 | + if (!empty($post_data['post_status'])) { |
|
262 | + $post_data['post_status'] = sanitize_key($post_data['post_status']); |
|
263 | 263 | |
264 | - if ( 'inherit' === $post_data['post_status'] ) { |
|
265 | - unset( $post_data['post_status'] ); |
|
264 | + if ('inherit' === $post_data['post_status']) { |
|
265 | + unset($post_data['post_status']); |
|
266 | 266 | } |
267 | 267 | } |
268 | 268 | |
269 | - $ptype = get_post_type_object( $post_data['post_type'] ); |
|
270 | - if ( ! current_user_can( 'edit_post', $post_ID ) ) { |
|
271 | - if ( 'page' === $post_data['post_type'] ) { |
|
272 | - wp_die( __( 'Sorry, you are not allowed to edit this page.' ) ); |
|
269 | + $ptype = get_post_type_object($post_data['post_type']); |
|
270 | + if (!current_user_can('edit_post', $post_ID)) { |
|
271 | + if ('page' === $post_data['post_type']) { |
|
272 | + wp_die(__('Sorry, you are not allowed to edit this page.')); |
|
273 | 273 | } else { |
274 | - wp_die( __( 'Sorry, you are not allowed to edit this post.' ) ); |
|
274 | + wp_die(__('Sorry, you are not allowed to edit this post.')); |
|
275 | 275 | } |
276 | 276 | } |
277 | 277 | |
278 | - if ( post_type_supports( $ptype->name, 'revisions' ) ) { |
|
278 | + if (post_type_supports($ptype->name, 'revisions')) { |
|
279 | 279 | $revisions = wp_get_post_revisions( |
280 | 280 | $post_ID, |
281 | 281 | array( |
@@ -283,171 +283,171 @@ discard block |
||
283 | 283 | 'posts_per_page' => 1, |
284 | 284 | ) |
285 | 285 | ); |
286 | - $revision = current( $revisions ); |
|
286 | + $revision = current($revisions); |
|
287 | 287 | |
288 | 288 | // Check if the revisions have been upgraded. |
289 | - if ( $revisions && _wp_get_post_revision_version( $revision ) < 1 ) { |
|
290 | - _wp_upgrade_revisions_of_post( $post, wp_get_post_revisions( $post_ID ) ); |
|
289 | + if ($revisions && _wp_get_post_revision_version($revision) < 1) { |
|
290 | + _wp_upgrade_revisions_of_post($post, wp_get_post_revisions($post_ID)); |
|
291 | 291 | } |
292 | 292 | } |
293 | 293 | |
294 | - if ( isset( $post_data['visibility'] ) ) { |
|
295 | - switch ( $post_data['visibility'] ) { |
|
294 | + if (isset($post_data['visibility'])) { |
|
295 | + switch ($post_data['visibility']) { |
|
296 | 296 | case 'public': |
297 | 297 | $post_data['post_password'] = ''; |
298 | 298 | break; |
299 | 299 | case 'password': |
300 | - unset( $post_data['sticky'] ); |
|
300 | + unset($post_data['sticky']); |
|
301 | 301 | break; |
302 | 302 | case 'private': |
303 | 303 | $post_data['post_status'] = 'private'; |
304 | 304 | $post_data['post_password'] = ''; |
305 | - unset( $post_data['sticky'] ); |
|
305 | + unset($post_data['sticky']); |
|
306 | 306 | break; |
307 | 307 | } |
308 | 308 | } |
309 | 309 | |
310 | - $post_data = _wp_translate_postdata( true, $post_data ); |
|
311 | - if ( is_wp_error( $post_data ) ) { |
|
312 | - wp_die( $post_data->get_error_message() ); |
|
310 | + $post_data = _wp_translate_postdata(true, $post_data); |
|
311 | + if (is_wp_error($post_data)) { |
|
312 | + wp_die($post_data->get_error_message()); |
|
313 | 313 | } |
314 | - $translated = _wp_get_allowed_postdata( $post_data ); |
|
314 | + $translated = _wp_get_allowed_postdata($post_data); |
|
315 | 315 | |
316 | 316 | // Post formats. |
317 | - if ( isset( $post_data['post_format'] ) ) { |
|
318 | - set_post_format( $post_ID, $post_data['post_format'] ); |
|
317 | + if (isset($post_data['post_format'])) { |
|
318 | + set_post_format($post_ID, $post_data['post_format']); |
|
319 | 319 | } |
320 | 320 | |
321 | - $format_meta_urls = array( 'url', 'link_url', 'quote_source_url' ); |
|
322 | - foreach ( $format_meta_urls as $format_meta_url ) { |
|
321 | + $format_meta_urls = array('url', 'link_url', 'quote_source_url'); |
|
322 | + foreach ($format_meta_urls as $format_meta_url) { |
|
323 | 323 | $keyed = '_format_' . $format_meta_url; |
324 | - if ( isset( $post_data[ $keyed ] ) ) { |
|
325 | - update_post_meta( $post_ID, $keyed, wp_slash( esc_url_raw( wp_unslash( $post_data[ $keyed ] ) ) ) ); |
|
324 | + if (isset($post_data[$keyed])) { |
|
325 | + update_post_meta($post_ID, $keyed, wp_slash(esc_url_raw(wp_unslash($post_data[$keyed])))); |
|
326 | 326 | } |
327 | 327 | } |
328 | 328 | |
329 | - $format_keys = array( 'quote', 'quote_source_name', 'image', 'gallery', 'audio_embed', 'video_embed' ); |
|
329 | + $format_keys = array('quote', 'quote_source_name', 'image', 'gallery', 'audio_embed', 'video_embed'); |
|
330 | 330 | |
331 | - foreach ( $format_keys as $key ) { |
|
331 | + foreach ($format_keys as $key) { |
|
332 | 332 | $keyed = '_format_' . $key; |
333 | - if ( isset( $post_data[ $keyed ] ) ) { |
|
334 | - if ( current_user_can( 'unfiltered_html' ) ) { |
|
335 | - update_post_meta( $post_ID, $keyed, $post_data[ $keyed ] ); |
|
333 | + if (isset($post_data[$keyed])) { |
|
334 | + if (current_user_can('unfiltered_html')) { |
|
335 | + update_post_meta($post_ID, $keyed, $post_data[$keyed]); |
|
336 | 336 | } else { |
337 | - update_post_meta( $post_ID, $keyed, wp_filter_post_kses( $post_data[ $keyed ] ) ); |
|
337 | + update_post_meta($post_ID, $keyed, wp_filter_post_kses($post_data[$keyed])); |
|
338 | 338 | } |
339 | 339 | } |
340 | 340 | } |
341 | 341 | |
342 | - if ( 'attachment' === $post_data['post_type'] && preg_match( '#^(audio|video)/#', $post_data['post_mime_type'] ) ) { |
|
343 | - $id3data = wp_get_attachment_metadata( $post_ID ); |
|
344 | - if ( ! is_array( $id3data ) ) { |
|
342 | + if ('attachment' === $post_data['post_type'] && preg_match('#^(audio|video)/#', $post_data['post_mime_type'])) { |
|
343 | + $id3data = wp_get_attachment_metadata($post_ID); |
|
344 | + if (!is_array($id3data)) { |
|
345 | 345 | $id3data = array(); |
346 | 346 | } |
347 | 347 | |
348 | - foreach ( wp_get_attachment_id3_keys( $post, 'edit' ) as $key => $label ) { |
|
349 | - if ( isset( $post_data[ 'id3_' . $key ] ) ) { |
|
350 | - $id3data[ $key ] = sanitize_text_field( wp_unslash( $post_data[ 'id3_' . $key ] ) ); |
|
348 | + foreach (wp_get_attachment_id3_keys($post, 'edit') as $key => $label) { |
|
349 | + if (isset($post_data['id3_' . $key])) { |
|
350 | + $id3data[$key] = sanitize_text_field(wp_unslash($post_data['id3_' . $key])); |
|
351 | 351 | } |
352 | 352 | } |
353 | - wp_update_attachment_metadata( $post_ID, $id3data ); |
|
353 | + wp_update_attachment_metadata($post_ID, $id3data); |
|
354 | 354 | } |
355 | 355 | |
356 | 356 | // Meta stuff. |
357 | - if ( isset( $post_data['meta'] ) && $post_data['meta'] ) { |
|
358 | - foreach ( $post_data['meta'] as $key => $value ) { |
|
359 | - $meta = get_post_meta_by_id( $key ); |
|
360 | - if ( ! $meta ) { |
|
357 | + if (isset($post_data['meta']) && $post_data['meta']) { |
|
358 | + foreach ($post_data['meta'] as $key => $value) { |
|
359 | + $meta = get_post_meta_by_id($key); |
|
360 | + if (!$meta) { |
|
361 | 361 | continue; |
362 | 362 | } |
363 | - if ( $meta->post_id != $post_ID ) { |
|
363 | + if ($meta->post_id != $post_ID) { |
|
364 | 364 | continue; |
365 | 365 | } |
366 | - if ( is_protected_meta( $meta->meta_key, 'post' ) || ! current_user_can( 'edit_post_meta', $post_ID, $meta->meta_key ) ) { |
|
366 | + if (is_protected_meta($meta->meta_key, 'post') || !current_user_can('edit_post_meta', $post_ID, $meta->meta_key)) { |
|
367 | 367 | continue; |
368 | 368 | } |
369 | - if ( is_protected_meta( $value['key'], 'post' ) || ! current_user_can( 'edit_post_meta', $post_ID, $value['key'] ) ) { |
|
369 | + if (is_protected_meta($value['key'], 'post') || !current_user_can('edit_post_meta', $post_ID, $value['key'])) { |
|
370 | 370 | continue; |
371 | 371 | } |
372 | - update_meta( $key, $value['key'], $value['value'] ); |
|
372 | + update_meta($key, $value['key'], $value['value']); |
|
373 | 373 | } |
374 | 374 | } |
375 | 375 | |
376 | - if ( isset( $post_data['deletemeta'] ) && $post_data['deletemeta'] ) { |
|
377 | - foreach ( $post_data['deletemeta'] as $key => $value ) { |
|
378 | - $meta = get_post_meta_by_id( $key ); |
|
379 | - if ( ! $meta ) { |
|
376 | + if (isset($post_data['deletemeta']) && $post_data['deletemeta']) { |
|
377 | + foreach ($post_data['deletemeta'] as $key => $value) { |
|
378 | + $meta = get_post_meta_by_id($key); |
|
379 | + if (!$meta) { |
|
380 | 380 | continue; |
381 | 381 | } |
382 | - if ( $meta->post_id != $post_ID ) { |
|
382 | + if ($meta->post_id != $post_ID) { |
|
383 | 383 | continue; |
384 | 384 | } |
385 | - if ( is_protected_meta( $meta->meta_key, 'post' ) || ! current_user_can( 'delete_post_meta', $post_ID, $meta->meta_key ) ) { |
|
385 | + if (is_protected_meta($meta->meta_key, 'post') || !current_user_can('delete_post_meta', $post_ID, $meta->meta_key)) { |
|
386 | 386 | continue; |
387 | 387 | } |
388 | - delete_meta( $key ); |
|
388 | + delete_meta($key); |
|
389 | 389 | } |
390 | 390 | } |
391 | 391 | |
392 | 392 | // Attachment stuff. |
393 | - if ( 'attachment' === $post_data['post_type'] ) { |
|
394 | - if ( isset( $post_data['_wp_attachment_image_alt'] ) ) { |
|
395 | - $image_alt = wp_unslash( $post_data['_wp_attachment_image_alt'] ); |
|
393 | + if ('attachment' === $post_data['post_type']) { |
|
394 | + if (isset($post_data['_wp_attachment_image_alt'])) { |
|
395 | + $image_alt = wp_unslash($post_data['_wp_attachment_image_alt']); |
|
396 | 396 | |
397 | - if ( get_post_meta( $post_ID, '_wp_attachment_image_alt', true ) !== $image_alt ) { |
|
398 | - $image_alt = wp_strip_all_tags( $image_alt, true ); |
|
397 | + if (get_post_meta($post_ID, '_wp_attachment_image_alt', true) !== $image_alt) { |
|
398 | + $image_alt = wp_strip_all_tags($image_alt, true); |
|
399 | 399 | |
400 | 400 | // update_post_meta() expects slashed. |
401 | - update_post_meta( $post_ID, '_wp_attachment_image_alt', wp_slash( $image_alt ) ); |
|
401 | + update_post_meta($post_ID, '_wp_attachment_image_alt', wp_slash($image_alt)); |
|
402 | 402 | } |
403 | 403 | } |
404 | 404 | |
405 | - $attachment_data = isset( $post_data['attachments'][ $post_ID ] ) ? $post_data['attachments'][ $post_ID ] : array(); |
|
405 | + $attachment_data = isset($post_data['attachments'][$post_ID]) ? $post_data['attachments'][$post_ID] : array(); |
|
406 | 406 | |
407 | 407 | /** This filter is documented in wp-admin/includes/media.php */ |
408 | - $translated = apply_filters( 'attachment_fields_to_save', $translated, $attachment_data ); |
|
408 | + $translated = apply_filters('attachment_fields_to_save', $translated, $attachment_data); |
|
409 | 409 | } |
410 | 410 | |
411 | 411 | // Convert taxonomy input to term IDs, to avoid ambiguity. |
412 | - if ( isset( $post_data['tax_input'] ) ) { |
|
413 | - foreach ( (array) $post_data['tax_input'] as $taxonomy => $terms ) { |
|
414 | - $tax_object = get_taxonomy( $taxonomy ); |
|
412 | + if (isset($post_data['tax_input'])) { |
|
413 | + foreach ((array) $post_data['tax_input'] as $taxonomy => $terms) { |
|
414 | + $tax_object = get_taxonomy($taxonomy); |
|
415 | 415 | |
416 | - if ( $tax_object && isset( $tax_object->meta_box_sanitize_cb ) ) { |
|
417 | - $translated['tax_input'][ $taxonomy ] = call_user_func_array( $tax_object->meta_box_sanitize_cb, array( $taxonomy, $terms ) ); |
|
416 | + if ($tax_object && isset($tax_object->meta_box_sanitize_cb)) { |
|
417 | + $translated['tax_input'][$taxonomy] = call_user_func_array($tax_object->meta_box_sanitize_cb, array($taxonomy, $terms)); |
|
418 | 418 | } |
419 | 419 | } |
420 | 420 | } |
421 | 421 | |
422 | - add_meta( $post_ID ); |
|
422 | + add_meta($post_ID); |
|
423 | 423 | |
424 | - update_post_meta( $post_ID, '_edit_last', get_current_user_id() ); |
|
424 | + update_post_meta($post_ID, '_edit_last', get_current_user_id()); |
|
425 | 425 | |
426 | - $success = wp_update_post( $translated ); |
|
426 | + $success = wp_update_post($translated); |
|
427 | 427 | |
428 | 428 | // If the save failed, see if we can sanity check the main fields and try again. |
429 | - if ( ! $success && is_callable( array( $wpdb, 'strip_invalid_text_for_column' ) ) ) { |
|
430 | - $fields = array( 'post_title', 'post_content', 'post_excerpt' ); |
|
429 | + if (!$success && is_callable(array($wpdb, 'strip_invalid_text_for_column'))) { |
|
430 | + $fields = array('post_title', 'post_content', 'post_excerpt'); |
|
431 | 431 | |
432 | - foreach ( $fields as $field ) { |
|
433 | - if ( isset( $translated[ $field ] ) ) { |
|
434 | - $translated[ $field ] = $wpdb->strip_invalid_text_for_column( $wpdb->posts, $field, $translated[ $field ] ); |
|
432 | + foreach ($fields as $field) { |
|
433 | + if (isset($translated[$field])) { |
|
434 | + $translated[$field] = $wpdb->strip_invalid_text_for_column($wpdb->posts, $field, $translated[$field]); |
|
435 | 435 | } |
436 | 436 | } |
437 | 437 | |
438 | - wp_update_post( $translated ); |
|
438 | + wp_update_post($translated); |
|
439 | 439 | } |
440 | 440 | |
441 | 441 | // Now that we have an ID we can fix any attachment anchor hrefs. |
442 | - _fix_attachment_links( $post_ID ); |
|
442 | + _fix_attachment_links($post_ID); |
|
443 | 443 | |
444 | - wp_set_post_lock( $post_ID ); |
|
444 | + wp_set_post_lock($post_ID); |
|
445 | 445 | |
446 | - if ( current_user_can( $ptype->cap->edit_others_posts ) && current_user_can( $ptype->cap->publish_posts ) ) { |
|
447 | - if ( ! empty( $post_data['sticky'] ) ) { |
|
448 | - stick_post( $post_ID ); |
|
446 | + if (current_user_can($ptype->cap->edit_others_posts) && current_user_can($ptype->cap->publish_posts)) { |
|
447 | + if (!empty($post_data['sticky'])) { |
|
448 | + stick_post($post_ID); |
|
449 | 449 | } else { |
450 | - unstick_post( $post_ID ); |
|
450 | + unstick_post($post_ID); |
|
451 | 451 | } |
452 | 452 | } |
453 | 453 | |
@@ -468,44 +468,44 @@ discard block |
||
468 | 468 | * Defaults to the `$_POST` superglobal. |
469 | 469 | * @return array |
470 | 470 | */ |
471 | -function bulk_edit_posts( $post_data = null ) { |
|
471 | +function bulk_edit_posts($post_data = null) { |
|
472 | 472 | global $wpdb; |
473 | 473 | |
474 | - if ( empty( $post_data ) ) { |
|
474 | + if (empty($post_data)) { |
|
475 | 475 | $post_data = &$_POST; |
476 | 476 | } |
477 | 477 | |
478 | - if ( isset( $post_data['post_type'] ) ) { |
|
479 | - $ptype = get_post_type_object( $post_data['post_type'] ); |
|
478 | + if (isset($post_data['post_type'])) { |
|
479 | + $ptype = get_post_type_object($post_data['post_type']); |
|
480 | 480 | } else { |
481 | - $ptype = get_post_type_object( 'post' ); |
|
481 | + $ptype = get_post_type_object('post'); |
|
482 | 482 | } |
483 | 483 | |
484 | - if ( ! current_user_can( $ptype->cap->edit_posts ) ) { |
|
485 | - if ( 'page' === $ptype->name ) { |
|
486 | - wp_die( __( 'Sorry, you are not allowed to edit pages.' ) ); |
|
484 | + if (!current_user_can($ptype->cap->edit_posts)) { |
|
485 | + if ('page' === $ptype->name) { |
|
486 | + wp_die(__('Sorry, you are not allowed to edit pages.')); |
|
487 | 487 | } else { |
488 | - wp_die( __( 'Sorry, you are not allowed to edit posts.' ) ); |
|
488 | + wp_die(__('Sorry, you are not allowed to edit posts.')); |
|
489 | 489 | } |
490 | 490 | } |
491 | 491 | |
492 | 492 | if ( -1 == $post_data['_status'] ) { |
493 | 493 | $post_data['post_status'] = null; |
494 | - unset( $post_data['post_status'] ); |
|
494 | + unset($post_data['post_status']); |
|
495 | 495 | } else { |
496 | 496 | $post_data['post_status'] = $post_data['_status']; |
497 | 497 | } |
498 | - unset( $post_data['_status'] ); |
|
498 | + unset($post_data['_status']); |
|
499 | 499 | |
500 | - if ( ! empty( $post_data['post_status'] ) ) { |
|
501 | - $post_data['post_status'] = sanitize_key( $post_data['post_status'] ); |
|
500 | + if (!empty($post_data['post_status'])) { |
|
501 | + $post_data['post_status'] = sanitize_key($post_data['post_status']); |
|
502 | 502 | |
503 | - if ( 'inherit' === $post_data['post_status'] ) { |
|
504 | - unset( $post_data['post_status'] ); |
|
503 | + if ('inherit' === $post_data['post_status']) { |
|
504 | + unset($post_data['post_status']); |
|
505 | 505 | } |
506 | 506 | } |
507 | 507 | |
508 | - $post_IDs = array_map( 'intval', (array) $post_data['post'] ); |
|
508 | + $post_IDs = array_map('intval', (array) $post_data['post']); |
|
509 | 509 | |
510 | 510 | $reset = array( |
511 | 511 | 'post_author', |
@@ -522,48 +522,48 @@ discard block |
||
522 | 522 | 'post_format', |
523 | 523 | ); |
524 | 524 | |
525 | - foreach ( $reset as $field ) { |
|
526 | - if ( isset( $post_data[ $field ] ) && ( '' === $post_data[ $field ] || -1 == $post_data[ $field ] ) ) { |
|
527 | - unset( $post_data[ $field ] ); |
|
525 | + foreach ($reset as $field) { |
|
526 | + if (isset($post_data[$field]) && ('' === $post_data[$field] || -1 == $post_data[$field])) { |
|
527 | + unset($post_data[$field]); |
|
528 | 528 | } |
529 | 529 | } |
530 | 530 | |
531 | - if ( isset( $post_data['post_category'] ) ) { |
|
532 | - if ( is_array( $post_data['post_category'] ) && ! empty( $post_data['post_category'] ) ) { |
|
533 | - $new_cats = array_map( 'absint', $post_data['post_category'] ); |
|
531 | + if (isset($post_data['post_category'])) { |
|
532 | + if (is_array($post_data['post_category']) && !empty($post_data['post_category'])) { |
|
533 | + $new_cats = array_map('absint', $post_data['post_category']); |
|
534 | 534 | } else { |
535 | - unset( $post_data['post_category'] ); |
|
535 | + unset($post_data['post_category']); |
|
536 | 536 | } |
537 | 537 | } |
538 | 538 | |
539 | 539 | $tax_input = array(); |
540 | - if ( isset( $post_data['tax_input'] ) ) { |
|
541 | - foreach ( $post_data['tax_input'] as $tax_name => $terms ) { |
|
542 | - if ( empty( $terms ) ) { |
|
540 | + if (isset($post_data['tax_input'])) { |
|
541 | + foreach ($post_data['tax_input'] as $tax_name => $terms) { |
|
542 | + if (empty($terms)) { |
|
543 | 543 | continue; |
544 | 544 | } |
545 | - if ( is_taxonomy_hierarchical( $tax_name ) ) { |
|
546 | - $tax_input[ $tax_name ] = array_map( 'absint', $terms ); |
|
545 | + if (is_taxonomy_hierarchical($tax_name)) { |
|
546 | + $tax_input[$tax_name] = array_map('absint', $terms); |
|
547 | 547 | } else { |
548 | - $comma = _x( ',', 'tag delimiter' ); |
|
549 | - if ( ',' !== $comma ) { |
|
550 | - $terms = str_replace( $comma, ',', $terms ); |
|
548 | + $comma = _x(',', 'tag delimiter'); |
|
549 | + if (',' !== $comma) { |
|
550 | + $terms = str_replace($comma, ',', $terms); |
|
551 | 551 | } |
552 | - $tax_input[ $tax_name ] = explode( ',', trim( $terms, " \n\t\r\0\x0B," ) ); |
|
552 | + $tax_input[$tax_name] = explode(',', trim($terms, " \n\t\r\0\x0B,")); |
|
553 | 553 | } |
554 | 554 | } |
555 | 555 | } |
556 | 556 | |
557 | - if ( isset( $post_data['post_parent'] ) && (int) $post_data['post_parent'] ) { |
|
557 | + if (isset($post_data['post_parent']) && (int) $post_data['post_parent']) { |
|
558 | 558 | $parent = (int) $post_data['post_parent']; |
559 | - $pages = $wpdb->get_results( "SELECT ID, post_parent FROM $wpdb->posts WHERE post_type = 'page'" ); |
|
559 | + $pages = $wpdb->get_results("SELECT ID, post_parent FROM $wpdb->posts WHERE post_type = 'page'"); |
|
560 | 560 | $children = array(); |
561 | 561 | |
562 | - for ( $i = 0; $i < 50 && $parent > 0; $i++ ) { |
|
562 | + for ($i = 0; $i < 50 && $parent > 0; $i++) { |
|
563 | 563 | $children[] = $parent; |
564 | 564 | |
565 | - foreach ( $pages as $page ) { |
|
566 | - if ( (int) $page->ID === $parent ) { |
|
565 | + foreach ($pages as $page) { |
|
566 | + if ((int) $page->ID === $parent) { |
|
567 | 567 | $parent = (int) $page->post_parent; |
568 | 568 | break; |
569 | 569 | } |
@@ -576,83 +576,83 @@ discard block |
||
576 | 576 | $locked = array(); |
577 | 577 | $shared_post_data = $post_data; |
578 | 578 | |
579 | - foreach ( $post_IDs as $post_ID ) { |
|
579 | + foreach ($post_IDs as $post_ID) { |
|
580 | 580 | // Start with fresh post data with each iteration. |
581 | 581 | $post_data = $shared_post_data; |
582 | 582 | |
583 | - $post_type_object = get_post_type_object( get_post_type( $post_ID ) ); |
|
583 | + $post_type_object = get_post_type_object(get_post_type($post_ID)); |
|
584 | 584 | |
585 | - if ( ! isset( $post_type_object ) |
|
586 | - || ( isset( $children ) && in_array( $post_ID, $children, true ) ) |
|
587 | - || ! current_user_can( 'edit_post', $post_ID ) |
|
585 | + if (!isset($post_type_object) |
|
586 | + || (isset($children) && in_array($post_ID, $children, true)) |
|
587 | + || !current_user_can('edit_post', $post_ID) |
|
588 | 588 | ) { |
589 | 589 | $skipped[] = $post_ID; |
590 | 590 | continue; |
591 | 591 | } |
592 | 592 | |
593 | - if ( wp_check_post_lock( $post_ID ) ) { |
|
593 | + if (wp_check_post_lock($post_ID)) { |
|
594 | 594 | $locked[] = $post_ID; |
595 | 595 | continue; |
596 | 596 | } |
597 | 597 | |
598 | - $post = get_post( $post_ID ); |
|
599 | - $tax_names = get_object_taxonomies( $post ); |
|
600 | - foreach ( $tax_names as $tax_name ) { |
|
601 | - $taxonomy_obj = get_taxonomy( $tax_name ); |
|
602 | - if ( isset( $tax_input[ $tax_name ] ) && current_user_can( $taxonomy_obj->cap->assign_terms ) ) { |
|
603 | - $new_terms = $tax_input[ $tax_name ]; |
|
598 | + $post = get_post($post_ID); |
|
599 | + $tax_names = get_object_taxonomies($post); |
|
600 | + foreach ($tax_names as $tax_name) { |
|
601 | + $taxonomy_obj = get_taxonomy($tax_name); |
|
602 | + if (isset($tax_input[$tax_name]) && current_user_can($taxonomy_obj->cap->assign_terms)) { |
|
603 | + $new_terms = $tax_input[$tax_name]; |
|
604 | 604 | } else { |
605 | 605 | $new_terms = array(); |
606 | 606 | } |
607 | 607 | |
608 | - if ( $taxonomy_obj->hierarchical ) { |
|
609 | - $current_terms = (array) wp_get_object_terms( $post_ID, $tax_name, array( 'fields' => 'ids' ) ); |
|
608 | + if ($taxonomy_obj->hierarchical) { |
|
609 | + $current_terms = (array) wp_get_object_terms($post_ID, $tax_name, array('fields' => 'ids')); |
|
610 | 610 | } else { |
611 | - $current_terms = (array) wp_get_object_terms( $post_ID, $tax_name, array( 'fields' => 'names' ) ); |
|
611 | + $current_terms = (array) wp_get_object_terms($post_ID, $tax_name, array('fields' => 'names')); |
|
612 | 612 | } |
613 | 613 | |
614 | - $post_data['tax_input'][ $tax_name ] = array_merge( $current_terms, $new_terms ); |
|
614 | + $post_data['tax_input'][$tax_name] = array_merge($current_terms, $new_terms); |
|
615 | 615 | } |
616 | 616 | |
617 | - if ( isset( $new_cats ) && in_array( 'category', $tax_names, true ) ) { |
|
618 | - $cats = (array) wp_get_post_categories( $post_ID ); |
|
619 | - $post_data['post_category'] = array_unique( array_merge( $cats, $new_cats ) ); |
|
620 | - unset( $post_data['tax_input']['category'] ); |
|
617 | + if (isset($new_cats) && in_array('category', $tax_names, true)) { |
|
618 | + $cats = (array) wp_get_post_categories($post_ID); |
|
619 | + $post_data['post_category'] = array_unique(array_merge($cats, $new_cats)); |
|
620 | + unset($post_data['tax_input']['category']); |
|
621 | 621 | } |
622 | 622 | |
623 | 623 | $post_data['post_ID'] = $post_ID; |
624 | 624 | $post_data['post_type'] = $post->post_type; |
625 | 625 | $post_data['post_mime_type'] = $post->post_mime_type; |
626 | 626 | |
627 | - foreach ( array( 'comment_status', 'ping_status', 'post_author' ) as $field ) { |
|
628 | - if ( ! isset( $post_data[ $field ] ) ) { |
|
629 | - $post_data[ $field ] = $post->$field; |
|
627 | + foreach (array('comment_status', 'ping_status', 'post_author') as $field) { |
|
628 | + if (!isset($post_data[$field])) { |
|
629 | + $post_data[$field] = $post->$field; |
|
630 | 630 | } |
631 | 631 | } |
632 | 632 | |
633 | - $post_data = _wp_translate_postdata( true, $post_data ); |
|
634 | - if ( is_wp_error( $post_data ) ) { |
|
633 | + $post_data = _wp_translate_postdata(true, $post_data); |
|
634 | + if (is_wp_error($post_data)) { |
|
635 | 635 | $skipped[] = $post_ID; |
636 | 636 | continue; |
637 | 637 | } |
638 | - $post_data = _wp_get_allowed_postdata( $post_data ); |
|
638 | + $post_data = _wp_get_allowed_postdata($post_data); |
|
639 | 639 | |
640 | - if ( isset( $shared_post_data['post_format'] ) ) { |
|
641 | - set_post_format( $post_ID, $shared_post_data['post_format'] ); |
|
640 | + if (isset($shared_post_data['post_format'])) { |
|
641 | + set_post_format($post_ID, $shared_post_data['post_format']); |
|
642 | 642 | } |
643 | 643 | |
644 | 644 | // Prevent wp_insert_post() from overwriting post format with the old data. |
645 | - unset( $post_data['tax_input']['post_format'] ); |
|
645 | + unset($post_data['tax_input']['post_format']); |
|
646 | 646 | |
647 | - $post_id = wp_update_post( $post_data ); |
|
648 | - update_post_meta( $post_id, '_edit_last', get_current_user_id() ); |
|
647 | + $post_id = wp_update_post($post_data); |
|
648 | + update_post_meta($post_id, '_edit_last', get_current_user_id()); |
|
649 | 649 | $updated[] = $post_id; |
650 | 650 | |
651 | - if ( isset( $post_data['sticky'] ) && current_user_can( $ptype->cap->edit_others_posts ) ) { |
|
652 | - if ( 'sticky' === $post_data['sticky'] ) { |
|
653 | - stick_post( $post_ID ); |
|
651 | + if (isset($post_data['sticky']) && current_user_can($ptype->cap->edit_others_posts)) { |
|
652 | + if ('sticky' === $post_data['sticky']) { |
|
653 | + stick_post($post_ID); |
|
654 | 654 | } else { |
655 | - unstick_post( $post_ID ); |
|
655 | + unstick_post($post_ID); |
|
656 | 656 | } |
657 | 657 | } |
658 | 658 | } |
@@ -673,41 +673,41 @@ discard block |
||
673 | 673 | * @param bool $create_in_db Optional. Whether to insert the post into database. Default false. |
674 | 674 | * @return WP_Post Post object containing all the default post data as attributes |
675 | 675 | */ |
676 | -function get_default_post_to_edit( $post_type = 'post', $create_in_db = false ) { |
|
676 | +function get_default_post_to_edit($post_type = 'post', $create_in_db = false) { |
|
677 | 677 | $post_title = ''; |
678 | - if ( ! empty( $_REQUEST['post_title'] ) ) { |
|
679 | - $post_title = esc_html( wp_unslash( $_REQUEST['post_title'] ) ); |
|
678 | + if (!empty($_REQUEST['post_title'])) { |
|
679 | + $post_title = esc_html(wp_unslash($_REQUEST['post_title'])); |
|
680 | 680 | } |
681 | 681 | |
682 | 682 | $post_content = ''; |
683 | - if ( ! empty( $_REQUEST['content'] ) ) { |
|
684 | - $post_content = esc_html( wp_unslash( $_REQUEST['content'] ) ); |
|
683 | + if (!empty($_REQUEST['content'])) { |
|
684 | + $post_content = esc_html(wp_unslash($_REQUEST['content'])); |
|
685 | 685 | } |
686 | 686 | |
687 | 687 | $post_excerpt = ''; |
688 | - if ( ! empty( $_REQUEST['excerpt'] ) ) { |
|
689 | - $post_excerpt = esc_html( wp_unslash( $_REQUEST['excerpt'] ) ); |
|
688 | + if (!empty($_REQUEST['excerpt'])) { |
|
689 | + $post_excerpt = esc_html(wp_unslash($_REQUEST['excerpt'])); |
|
690 | 690 | } |
691 | 691 | |
692 | - if ( $create_in_db ) { |
|
692 | + if ($create_in_db) { |
|
693 | 693 | $post_id = wp_insert_post( |
694 | 694 | array( |
695 | - 'post_title' => __( 'Auto Draft' ), |
|
695 | + 'post_title' => __('Auto Draft'), |
|
696 | 696 | 'post_type' => $post_type, |
697 | 697 | 'post_status' => 'auto-draft', |
698 | 698 | ), |
699 | 699 | false, |
700 | 700 | false |
701 | 701 | ); |
702 | - $post = get_post( $post_id ); |
|
703 | - if ( current_theme_supports( 'post-formats' ) && post_type_supports( $post->post_type, 'post-formats' ) && get_option( 'default_post_format' ) ) { |
|
704 | - set_post_format( $post, get_option( 'default_post_format' ) ); |
|
702 | + $post = get_post($post_id); |
|
703 | + if (current_theme_supports('post-formats') && post_type_supports($post->post_type, 'post-formats') && get_option('default_post_format')) { |
|
704 | + set_post_format($post, get_option('default_post_format')); |
|
705 | 705 | } |
706 | - wp_after_insert_post( $post, false, null ); |
|
706 | + wp_after_insert_post($post, false, null); |
|
707 | 707 | |
708 | 708 | // Schedule auto-draft cleanup. |
709 | - if ( ! wp_next_scheduled( 'wp_scheduled_auto_draft_delete' ) ) { |
|
710 | - wp_schedule_event( time(), 'daily', 'wp_scheduled_auto_draft_delete' ); |
|
709 | + if (!wp_next_scheduled('wp_scheduled_auto_draft_delete')) { |
|
710 | + wp_schedule_event(time(), 'daily', 'wp_scheduled_auto_draft_delete'); |
|
711 | 711 | } |
712 | 712 | } else { |
713 | 713 | $post = new stdClass; |
@@ -721,14 +721,14 @@ discard block |
||
721 | 721 | $post->post_status = 'draft'; |
722 | 722 | $post->to_ping = ''; |
723 | 723 | $post->pinged = ''; |
724 | - $post->comment_status = get_default_comment_status( $post_type ); |
|
725 | - $post->ping_status = get_default_comment_status( $post_type, 'pingback' ); |
|
726 | - $post->post_pingback = get_option( 'default_pingback_flag' ); |
|
727 | - $post->post_category = get_option( 'default_category' ); |
|
724 | + $post->comment_status = get_default_comment_status($post_type); |
|
725 | + $post->ping_status = get_default_comment_status($post_type, 'pingback'); |
|
726 | + $post->post_pingback = get_option('default_pingback_flag'); |
|
727 | + $post->post_category = get_option('default_category'); |
|
728 | 728 | $post->page_template = 'default'; |
729 | 729 | $post->post_parent = 0; |
730 | 730 | $post->menu_order = 0; |
731 | - $post = new WP_Post( $post ); |
|
731 | + $post = new WP_Post($post); |
|
732 | 732 | } |
733 | 733 | |
734 | 734 | /** |
@@ -739,7 +739,7 @@ discard block |
||
739 | 739 | * @param string $post_content Default post content. |
740 | 740 | * @param WP_Post $post Post object. |
741 | 741 | */ |
742 | - $post->post_content = (string) apply_filters( 'default_content', $post_content, $post ); |
|
742 | + $post->post_content = (string) apply_filters('default_content', $post_content, $post); |
|
743 | 743 | |
744 | 744 | /** |
745 | 745 | * Filters the default post title initially used in the "Write Post" form. |
@@ -749,7 +749,7 @@ discard block |
||
749 | 749 | * @param string $post_title Default post title. |
750 | 750 | * @param WP_Post $post Post object. |
751 | 751 | */ |
752 | - $post->post_title = (string) apply_filters( 'default_title', $post_title, $post ); |
|
752 | + $post->post_title = (string) apply_filters('default_title', $post_title, $post); |
|
753 | 753 | |
754 | 754 | /** |
755 | 755 | * Filters the default post excerpt initially used in the "Write Post" form. |
@@ -759,7 +759,7 @@ discard block |
||
759 | 759 | * @param string $post_excerpt Default post excerpt. |
760 | 760 | * @param WP_Post $post Post object. |
761 | 761 | */ |
762 | - $post->post_excerpt = (string) apply_filters( 'default_excerpt', $post_excerpt, $post ); |
|
762 | + $post->post_excerpt = (string) apply_filters('default_excerpt', $post_excerpt, $post); |
|
763 | 763 | |
764 | 764 | return $post; |
765 | 765 | } |
@@ -780,45 +780,45 @@ discard block |
||
780 | 780 | * @param string $status Optional. Post status. |
781 | 781 | * @return int Post ID if post exists, 0 otherwise. |
782 | 782 | */ |
783 | -function post_exists( $title, $content = '', $date = '', $type = '', $status = '' ) { |
|
783 | +function post_exists($title, $content = '', $date = '', $type = '', $status = '') { |
|
784 | 784 | global $wpdb; |
785 | 785 | |
786 | - $post_title = wp_unslash( sanitize_post_field( 'post_title', $title, 0, 'db' ) ); |
|
787 | - $post_content = wp_unslash( sanitize_post_field( 'post_content', $content, 0, 'db' ) ); |
|
788 | - $post_date = wp_unslash( sanitize_post_field( 'post_date', $date, 0, 'db' ) ); |
|
789 | - $post_type = wp_unslash( sanitize_post_field( 'post_type', $type, 0, 'db' ) ); |
|
790 | - $post_status = wp_unslash( sanitize_post_field( 'post_status', $status, 0, 'db' ) ); |
|
786 | + $post_title = wp_unslash(sanitize_post_field('post_title', $title, 0, 'db')); |
|
787 | + $post_content = wp_unslash(sanitize_post_field('post_content', $content, 0, 'db')); |
|
788 | + $post_date = wp_unslash(sanitize_post_field('post_date', $date, 0, 'db')); |
|
789 | + $post_type = wp_unslash(sanitize_post_field('post_type', $type, 0, 'db')); |
|
790 | + $post_status = wp_unslash(sanitize_post_field('post_status', $status, 0, 'db')); |
|
791 | 791 | |
792 | 792 | $query = "SELECT ID FROM $wpdb->posts WHERE 1=1"; |
793 | 793 | $args = array(); |
794 | 794 | |
795 | - if ( ! empty( $date ) ) { |
|
795 | + if (!empty($date)) { |
|
796 | 796 | $query .= ' AND post_date = %s'; |
797 | 797 | $args[] = $post_date; |
798 | 798 | } |
799 | 799 | |
800 | - if ( ! empty( $title ) ) { |
|
800 | + if (!empty($title)) { |
|
801 | 801 | $query .= ' AND post_title = %s'; |
802 | 802 | $args[] = $post_title; |
803 | 803 | } |
804 | 804 | |
805 | - if ( ! empty( $content ) ) { |
|
805 | + if (!empty($content)) { |
|
806 | 806 | $query .= ' AND post_content = %s'; |
807 | 807 | $args[] = $post_content; |
808 | 808 | } |
809 | 809 | |
810 | - if ( ! empty( $type ) ) { |
|
810 | + if (!empty($type)) { |
|
811 | 811 | $query .= ' AND post_type = %s'; |
812 | 812 | $args[] = $post_type; |
813 | 813 | } |
814 | 814 | |
815 | - if ( ! empty( $status ) ) { |
|
815 | + if (!empty($status)) { |
|
816 | 816 | $query .= ' AND post_status = %s'; |
817 | 817 | $args[] = $post_status; |
818 | 818 | } |
819 | 819 | |
820 | - if ( ! empty( $args ) ) { |
|
821 | - return (int) $wpdb->get_var( $wpdb->prepare( $query, $args ) ); |
|
820 | + if (!empty($args)) { |
|
821 | + return (int) $wpdb->get_var($wpdb->prepare($query, $args)); |
|
822 | 822 | } |
823 | 823 | |
824 | 824 | return 0; |
@@ -834,70 +834,70 @@ discard block |
||
834 | 834 | * @return int|WP_Error Post ID on success, WP_Error on failure. |
835 | 835 | */ |
836 | 836 | function wp_write_post() { |
837 | - if ( isset( $_POST['post_type'] ) ) { |
|
838 | - $ptype = get_post_type_object( $_POST['post_type'] ); |
|
837 | + if (isset($_POST['post_type'])) { |
|
838 | + $ptype = get_post_type_object($_POST['post_type']); |
|
839 | 839 | } else { |
840 | - $ptype = get_post_type_object( 'post' ); |
|
840 | + $ptype = get_post_type_object('post'); |
|
841 | 841 | } |
842 | 842 | |
843 | - if ( ! current_user_can( $ptype->cap->edit_posts ) ) { |
|
844 | - if ( 'page' === $ptype->name ) { |
|
845 | - return new WP_Error( 'edit_pages', __( 'Sorry, you are not allowed to create pages on this site.' ) ); |
|
843 | + if (!current_user_can($ptype->cap->edit_posts)) { |
|
844 | + if ('page' === $ptype->name) { |
|
845 | + return new WP_Error('edit_pages', __('Sorry, you are not allowed to create pages on this site.')); |
|
846 | 846 | } else { |
847 | - return new WP_Error( 'edit_posts', __( 'Sorry, you are not allowed to create posts or drafts on this site.' ) ); |
|
847 | + return new WP_Error('edit_posts', __('Sorry, you are not allowed to create posts or drafts on this site.')); |
|
848 | 848 | } |
849 | 849 | } |
850 | 850 | |
851 | 851 | $_POST['post_mime_type'] = ''; |
852 | 852 | |
853 | 853 | // Clear out any data in internal vars. |
854 | - unset( $_POST['filter'] ); |
|
854 | + unset($_POST['filter']); |
|
855 | 855 | |
856 | 856 | // Edit, don't write, if we have a post ID. |
857 | - if ( isset( $_POST['post_ID'] ) ) { |
|
857 | + if (isset($_POST['post_ID'])) { |
|
858 | 858 | return edit_post(); |
859 | 859 | } |
860 | 860 | |
861 | - if ( isset( $_POST['visibility'] ) ) { |
|
862 | - switch ( $_POST['visibility'] ) { |
|
861 | + if (isset($_POST['visibility'])) { |
|
862 | + switch ($_POST['visibility']) { |
|
863 | 863 | case 'public': |
864 | 864 | $_POST['post_password'] = ''; |
865 | 865 | break; |
866 | 866 | case 'password': |
867 | - unset( $_POST['sticky'] ); |
|
867 | + unset($_POST['sticky']); |
|
868 | 868 | break; |
869 | 869 | case 'private': |
870 | 870 | $_POST['post_status'] = 'private'; |
871 | 871 | $_POST['post_password'] = ''; |
872 | - unset( $_POST['sticky'] ); |
|
872 | + unset($_POST['sticky']); |
|
873 | 873 | break; |
874 | 874 | } |
875 | 875 | } |
876 | 876 | |
877 | - $translated = _wp_translate_postdata( false ); |
|
878 | - if ( is_wp_error( $translated ) ) { |
|
877 | + $translated = _wp_translate_postdata(false); |
|
878 | + if (is_wp_error($translated)) { |
|
879 | 879 | return $translated; |
880 | 880 | } |
881 | - $translated = _wp_get_allowed_postdata( $translated ); |
|
881 | + $translated = _wp_get_allowed_postdata($translated); |
|
882 | 882 | |
883 | 883 | // Create the post. |
884 | - $post_ID = wp_insert_post( $translated ); |
|
885 | - if ( is_wp_error( $post_ID ) ) { |
|
884 | + $post_ID = wp_insert_post($translated); |
|
885 | + if (is_wp_error($post_ID)) { |
|
886 | 886 | return $post_ID; |
887 | 887 | } |
888 | 888 | |
889 | - if ( empty( $post_ID ) ) { |
|
889 | + if (empty($post_ID)) { |
|
890 | 890 | return 0; |
891 | 891 | } |
892 | 892 | |
893 | - add_meta( $post_ID ); |
|
893 | + add_meta($post_ID); |
|
894 | 894 | |
895 | - add_post_meta( $post_ID, '_edit_last', $GLOBALS['current_user']->ID ); |
|
895 | + add_post_meta($post_ID, '_edit_last', $GLOBALS['current_user']->ID); |
|
896 | 896 | |
897 | 897 | // Now that we have an ID we can fix any attachment anchor hrefs. |
898 | - _fix_attachment_links( $post_ID ); |
|
898 | + _fix_attachment_links($post_ID); |
|
899 | 899 | |
900 | - wp_set_post_lock( $post_ID ); |
|
900 | + wp_set_post_lock($post_ID); |
|
901 | 901 | |
902 | 902 | return $post_ID; |
903 | 903 | } |
@@ -911,8 +911,8 @@ discard block |
||
911 | 911 | */ |
912 | 912 | function write_post() { |
913 | 913 | $result = wp_write_post(); |
914 | - if ( is_wp_error( $result ) ) { |
|
915 | - wp_die( $result->get_error_message() ); |
|
914 | + if (is_wp_error($result)) { |
|
915 | + wp_die($result->get_error_message()); |
|
916 | 916 | } else { |
917 | 917 | return $result; |
918 | 918 | } |
@@ -930,36 +930,36 @@ discard block |
||
930 | 930 | * @param int $post_ID |
931 | 931 | * @return int|bool |
932 | 932 | */ |
933 | -function add_meta( $post_ID ) { |
|
933 | +function add_meta($post_ID) { |
|
934 | 934 | $post_ID = (int) $post_ID; |
935 | 935 | |
936 | - $metakeyselect = isset( $_POST['metakeyselect'] ) ? wp_unslash( trim( $_POST['metakeyselect'] ) ) : ''; |
|
937 | - $metakeyinput = isset( $_POST['metakeyinput'] ) ? wp_unslash( trim( $_POST['metakeyinput'] ) ) : ''; |
|
938 | - $metavalue = isset( $_POST['metavalue'] ) ? $_POST['metavalue'] : ''; |
|
939 | - if ( is_string( $metavalue ) ) { |
|
940 | - $metavalue = trim( $metavalue ); |
|
936 | + $metakeyselect = isset($_POST['metakeyselect']) ? wp_unslash(trim($_POST['metakeyselect'])) : ''; |
|
937 | + $metakeyinput = isset($_POST['metakeyinput']) ? wp_unslash(trim($_POST['metakeyinput'])) : ''; |
|
938 | + $metavalue = isset($_POST['metavalue']) ? $_POST['metavalue'] : ''; |
|
939 | + if (is_string($metavalue)) { |
|
940 | + $metavalue = trim($metavalue); |
|
941 | 941 | } |
942 | 942 | |
943 | - if ( ( ( '#NONE#' !== $metakeyselect ) && ! empty( $metakeyselect ) ) || ! empty( $metakeyinput ) ) { |
|
943 | + if ((('#NONE#' !== $metakeyselect) && !empty($metakeyselect)) || !empty($metakeyinput)) { |
|
944 | 944 | /* |
945 | 945 | * We have a key/value pair. If both the select and the input |
946 | 946 | * for the key have data, the input takes precedence. |
947 | 947 | */ |
948 | - if ( '#NONE#' !== $metakeyselect ) { |
|
948 | + if ('#NONE#' !== $metakeyselect) { |
|
949 | 949 | $metakey = $metakeyselect; |
950 | 950 | } |
951 | 951 | |
952 | - if ( $metakeyinput ) { |
|
952 | + if ($metakeyinput) { |
|
953 | 953 | $metakey = $metakeyinput; // Default. |
954 | 954 | } |
955 | 955 | |
956 | - if ( is_protected_meta( $metakey, 'post' ) || ! current_user_can( 'add_post_meta', $post_ID, $metakey ) ) { |
|
956 | + if (is_protected_meta($metakey, 'post') || !current_user_can('add_post_meta', $post_ID, $metakey)) { |
|
957 | 957 | return false; |
958 | 958 | } |
959 | 959 | |
960 | - $metakey = wp_slash( $metakey ); |
|
960 | + $metakey = wp_slash($metakey); |
|
961 | 961 | |
962 | - return add_post_meta( $post_ID, $metakey, $metavalue ); |
|
962 | + return add_post_meta($post_ID, $metakey, $metavalue); |
|
963 | 963 | } |
964 | 964 | |
965 | 965 | return false; |
@@ -973,8 +973,8 @@ discard block |
||
973 | 973 | * @param int $mid |
974 | 974 | * @return bool |
975 | 975 | */ |
976 | -function delete_meta( $mid ) { |
|
977 | - return delete_metadata_by_mid( 'post', $mid ); |
|
976 | +function delete_meta($mid) { |
|
977 | + return delete_metadata_by_mid('post', $mid); |
|
978 | 978 | } |
979 | 979 | |
980 | 980 | /** |
@@ -1008,8 +1008,8 @@ discard block |
||
1008 | 1008 | * @param int $mid |
1009 | 1009 | * @return object|bool |
1010 | 1010 | */ |
1011 | -function get_post_meta_by_id( $mid ) { |
|
1012 | - return get_metadata_by_mid( 'post', $mid ); |
|
1011 | +function get_post_meta_by_id($mid) { |
|
1012 | + return get_metadata_by_mid('post', $mid); |
|
1013 | 1013 | } |
1014 | 1014 | |
1015 | 1015 | /** |
@@ -1033,7 +1033,7 @@ discard block |
||
1033 | 1033 | * } |
1034 | 1034 | * } |
1035 | 1035 | */ |
1036 | -function has_meta( $postid ) { |
|
1036 | +function has_meta($postid) { |
|
1037 | 1037 | global $wpdb; |
1038 | 1038 | |
1039 | 1039 | return $wpdb->get_results( |
@@ -1057,11 +1057,11 @@ discard block |
||
1057 | 1057 | * @param string $meta_value Meta value. Expect slashed. |
1058 | 1058 | * @return bool |
1059 | 1059 | */ |
1060 | -function update_meta( $meta_id, $meta_key, $meta_value ) { |
|
1061 | - $meta_key = wp_unslash( $meta_key ); |
|
1062 | - $meta_value = wp_unslash( $meta_value ); |
|
1060 | +function update_meta($meta_id, $meta_key, $meta_value) { |
|
1061 | + $meta_key = wp_unslash($meta_key); |
|
1062 | + $meta_value = wp_unslash($meta_value); |
|
1063 | 1063 | |
1064 | - return update_metadata_by_mid( 'post', $meta_id, $meta_value, $meta_key ); |
|
1064 | + return update_metadata_by_mid('post', $meta_id, $meta_value, $meta_key); |
|
1065 | 1065 | } |
1066 | 1066 | |
1067 | 1067 | // |
@@ -1077,28 +1077,28 @@ discard block |
||
1077 | 1077 | * @param int|object $post Post ID or post object. |
1078 | 1078 | * @return void|int|WP_Error Void if nothing fixed. 0 or WP_Error on update failure. The post ID on update success. |
1079 | 1079 | */ |
1080 | -function _fix_attachment_links( $post ) { |
|
1081 | - $post = get_post( $post, ARRAY_A ); |
|
1080 | +function _fix_attachment_links($post) { |
|
1081 | + $post = get_post($post, ARRAY_A); |
|
1082 | 1082 | $content = $post['post_content']; |
1083 | 1083 | |
1084 | 1084 | // Don't run if no pretty permalinks or post is not published, scheduled, or privately published. |
1085 | - if ( ! get_option( 'permalink_structure' ) || ! in_array( $post['post_status'], array( 'publish', 'future', 'private' ), true ) ) { |
|
1085 | + if (!get_option('permalink_structure') || !in_array($post['post_status'], array('publish', 'future', 'private'), true)) { |
|
1086 | 1086 | return; |
1087 | 1087 | } |
1088 | 1088 | |
1089 | 1089 | // Short if there aren't any links or no '?attachment_id=' strings (strpos cannot be zero). |
1090 | - if ( ! strpos( $content, '?attachment_id=' ) || ! preg_match_all( '/<a ([^>]+)>[\s\S]+?<\/a>/', $content, $link_matches ) ) { |
|
1090 | + if (!strpos($content, '?attachment_id=') || !preg_match_all('/<a ([^>]+)>[\s\S]+?<\/a>/', $content, $link_matches)) { |
|
1091 | 1091 | return; |
1092 | 1092 | } |
1093 | 1093 | |
1094 | - $site_url = get_bloginfo( 'url' ); |
|
1095 | - $site_url = substr( $site_url, (int) strpos( $site_url, '://' ) ); // Remove the http(s). |
|
1094 | + $site_url = get_bloginfo('url'); |
|
1095 | + $site_url = substr($site_url, (int) strpos($site_url, '://')); // Remove the http(s). |
|
1096 | 1096 | $replace = ''; |
1097 | 1097 | |
1098 | - foreach ( $link_matches[1] as $key => $value ) { |
|
1099 | - if ( ! strpos( $value, '?attachment_id=' ) || ! strpos( $value, 'wp-att-' ) |
|
1100 | - || ! preg_match( '/href=(["\'])[^"\']*\?attachment_id=(\d+)[^"\']*\\1/', $value, $url_match ) |
|
1101 | - || ! preg_match( '/rel=["\'][^"\']*wp-att-(\d+)/', $value, $rel_match ) ) { |
|
1098 | + foreach ($link_matches[1] as $key => $value) { |
|
1099 | + if (!strpos($value, '?attachment_id=') || !strpos($value, 'wp-att-') |
|
1100 | + || !preg_match('/href=(["\'])[^"\']*\?attachment_id=(\d+)[^"\']*\\1/', $value, $url_match) |
|
1101 | + || !preg_match('/rel=["\'][^"\']*wp-att-(\d+)/', $value, $rel_match)) { |
|
1102 | 1102 | continue; |
1103 | 1103 | } |
1104 | 1104 | |
@@ -1106,22 +1106,22 @@ discard block |
||
1106 | 1106 | $url_id = (int) $url_match[2]; |
1107 | 1107 | $rel_id = (int) $rel_match[1]; |
1108 | 1108 | |
1109 | - if ( ! $url_id || ! $rel_id || $url_id != $rel_id || strpos( $url_match[0], $site_url ) === false ) { |
|
1109 | + if (!$url_id || !$rel_id || $url_id != $rel_id || strpos($url_match[0], $site_url) === false) { |
|
1110 | 1110 | continue; |
1111 | 1111 | } |
1112 | 1112 | |
1113 | - $link = $link_matches[0][ $key ]; |
|
1114 | - $replace = str_replace( $url_match[0], 'href=' . $quote . get_attachment_link( $url_id ) . $quote, $link ); |
|
1113 | + $link = $link_matches[0][$key]; |
|
1114 | + $replace = str_replace($url_match[0], 'href=' . $quote . get_attachment_link($url_id) . $quote, $link); |
|
1115 | 1115 | |
1116 | - $content = str_replace( $link, $replace, $content ); |
|
1116 | + $content = str_replace($link, $replace, $content); |
|
1117 | 1117 | } |
1118 | 1118 | |
1119 | - if ( $replace ) { |
|
1119 | + if ($replace) { |
|
1120 | 1120 | $post['post_content'] = $content; |
1121 | 1121 | // Escape data pulled from DB. |
1122 | - $post = add_magic_quotes( $post ); |
|
1122 | + $post = add_magic_quotes($post); |
|
1123 | 1123 | |
1124 | - return wp_update_post( $post ); |
|
1124 | + return wp_update_post($post); |
|
1125 | 1125 | } |
1126 | 1126 | } |
1127 | 1127 | |
@@ -1133,10 +1133,10 @@ discard block |
||
1133 | 1133 | * @param string $type The post_type you want the statuses for. Default 'post'. |
1134 | 1134 | * @return string[] An array of all the statuses for the supplied post type. |
1135 | 1135 | */ |
1136 | -function get_available_post_statuses( $type = 'post' ) { |
|
1137 | - $stati = wp_count_posts( $type ); |
|
1136 | +function get_available_post_statuses($type = 'post') { |
|
1137 | + $stati = wp_count_posts($type); |
|
1138 | 1138 | |
1139 | - return array_keys( get_object_vars( $stati ) ); |
|
1139 | + return array_keys(get_object_vars($stati)); |
|
1140 | 1140 | } |
1141 | 1141 | |
1142 | 1142 | /** |
@@ -1148,48 +1148,48 @@ discard block |
||
1148 | 1148 | * Defaults to the `$_GET` superglobal. |
1149 | 1149 | * @return array |
1150 | 1150 | */ |
1151 | -function wp_edit_posts_query( $q = false ) { |
|
1152 | - if ( false === $q ) { |
|
1151 | +function wp_edit_posts_query($q = false) { |
|
1152 | + if (false === $q) { |
|
1153 | 1153 | $q = $_GET; |
1154 | 1154 | } |
1155 | - $q['m'] = isset( $q['m'] ) ? (int) $q['m'] : 0; |
|
1156 | - $q['cat'] = isset( $q['cat'] ) ? (int) $q['cat'] : 0; |
|
1155 | + $q['m'] = isset($q['m']) ? (int) $q['m'] : 0; |
|
1156 | + $q['cat'] = isset($q['cat']) ? (int) $q['cat'] : 0; |
|
1157 | 1157 | $post_stati = get_post_stati(); |
1158 | 1158 | |
1159 | - if ( isset( $q['post_type'] ) && in_array( $q['post_type'], get_post_types(), true ) ) { |
|
1159 | + if (isset($q['post_type']) && in_array($q['post_type'], get_post_types(), true)) { |
|
1160 | 1160 | $post_type = $q['post_type']; |
1161 | 1161 | } else { |
1162 | 1162 | $post_type = 'post'; |
1163 | 1163 | } |
1164 | 1164 | |
1165 | - $avail_post_stati = get_available_post_statuses( $post_type ); |
|
1165 | + $avail_post_stati = get_available_post_statuses($post_type); |
|
1166 | 1166 | $post_status = ''; |
1167 | 1167 | $perm = ''; |
1168 | 1168 | |
1169 | - if ( isset( $q['post_status'] ) && in_array( $q['post_status'], $post_stati, true ) ) { |
|
1169 | + if (isset($q['post_status']) && in_array($q['post_status'], $post_stati, true)) { |
|
1170 | 1170 | $post_status = $q['post_status']; |
1171 | 1171 | $perm = 'readable'; |
1172 | 1172 | } |
1173 | 1173 | |
1174 | 1174 | $orderby = ''; |
1175 | 1175 | |
1176 | - if ( isset( $q['orderby'] ) ) { |
|
1176 | + if (isset($q['orderby'])) { |
|
1177 | 1177 | $orderby = $q['orderby']; |
1178 | - } elseif ( isset( $q['post_status'] ) && in_array( $q['post_status'], array( 'pending', 'draft' ), true ) ) { |
|
1178 | + } elseif (isset($q['post_status']) && in_array($q['post_status'], array('pending', 'draft'), true)) { |
|
1179 | 1179 | $orderby = 'modified'; |
1180 | 1180 | } |
1181 | 1181 | |
1182 | 1182 | $order = ''; |
1183 | 1183 | |
1184 | - if ( isset( $q['order'] ) ) { |
|
1184 | + if (isset($q['order'])) { |
|
1185 | 1185 | $order = $q['order']; |
1186 | - } elseif ( isset( $q['post_status'] ) && 'pending' === $q['post_status'] ) { |
|
1186 | + } elseif (isset($q['post_status']) && 'pending' === $q['post_status']) { |
|
1187 | 1187 | $order = 'ASC'; |
1188 | 1188 | } |
1189 | 1189 | |
1190 | 1190 | $per_page = "edit_{$post_type}_per_page"; |
1191 | - $posts_per_page = (int) get_user_option( $per_page ); |
|
1192 | - if ( empty( $posts_per_page ) || $posts_per_page < 1 ) { |
|
1191 | + $posts_per_page = (int) get_user_option($per_page); |
|
1192 | + if (empty($posts_per_page) || $posts_per_page < 1) { |
|
1193 | 1193 | $posts_per_page = 20; |
1194 | 1194 | } |
1195 | 1195 | |
@@ -1209,7 +1209,7 @@ discard block |
||
1209 | 1209 | * @param int $posts_per_page Number of posts to display per page for the given post |
1210 | 1210 | * type. Default 20. |
1211 | 1211 | */ |
1212 | - $posts_per_page = apply_filters( "edit_{$post_type}_per_page", $posts_per_page ); |
|
1212 | + $posts_per_page = apply_filters("edit_{$post_type}_per_page", $posts_per_page); |
|
1213 | 1213 | |
1214 | 1214 | /** |
1215 | 1215 | * Filters the number of posts displayed per page when specifically listing "posts". |
@@ -1219,12 +1219,12 @@ discard block |
||
1219 | 1219 | * @param int $posts_per_page Number of posts to be displayed. Default 20. |
1220 | 1220 | * @param string $post_type The post type. |
1221 | 1221 | */ |
1222 | - $posts_per_page = apply_filters( 'edit_posts_per_page', $posts_per_page, $post_type ); |
|
1222 | + $posts_per_page = apply_filters('edit_posts_per_page', $posts_per_page, $post_type); |
|
1223 | 1223 | |
1224 | - $query = compact( 'post_type', 'post_status', 'perm', 'order', 'orderby', 'posts_per_page' ); |
|
1224 | + $query = compact('post_type', 'post_status', 'perm', 'order', 'orderby', 'posts_per_page'); |
|
1225 | 1225 | |
1226 | 1226 | // Hierarchical types require special args. |
1227 | - if ( is_post_type_hierarchical( $post_type ) && empty( $orderby ) ) { |
|
1227 | + if (is_post_type_hierarchical($post_type) && empty($orderby)) { |
|
1228 | 1228 | $query['orderby'] = 'menu_order title'; |
1229 | 1229 | $query['order'] = 'asc'; |
1230 | 1230 | $query['posts_per_page'] = -1; |
@@ -1232,11 +1232,11 @@ discard block |
||
1232 | 1232 | $query['fields'] = 'id=>parent'; |
1233 | 1233 | } |
1234 | 1234 | |
1235 | - if ( ! empty( $q['show_sticky'] ) ) { |
|
1236 | - $query['post__in'] = (array) get_option( 'sticky_posts' ); |
|
1235 | + if (!empty($q['show_sticky'])) { |
|
1236 | + $query['post__in'] = (array) get_option('sticky_posts'); |
|
1237 | 1237 | } |
1238 | 1238 | |
1239 | - wp( $query ); |
|
1239 | + wp($query); |
|
1240 | 1240 | |
1241 | 1241 | return $avail_post_stati; |
1242 | 1242 | } |
@@ -1250,24 +1250,24 @@ discard block |
||
1250 | 1250 | * Defaults to the `$_GET` superglobal. |
1251 | 1251 | * @return array The parsed query vars. |
1252 | 1252 | */ |
1253 | -function wp_edit_attachments_query_vars( $q = false ) { |
|
1254 | - if ( false === $q ) { |
|
1253 | +function wp_edit_attachments_query_vars($q = false) { |
|
1254 | + if (false === $q) { |
|
1255 | 1255 | $q = $_GET; |
1256 | 1256 | } |
1257 | - $q['m'] = isset( $q['m'] ) ? (int) $q['m'] : 0; |
|
1258 | - $q['cat'] = isset( $q['cat'] ) ? (int) $q['cat'] : 0; |
|
1257 | + $q['m'] = isset($q['m']) ? (int) $q['m'] : 0; |
|
1258 | + $q['cat'] = isset($q['cat']) ? (int) $q['cat'] : 0; |
|
1259 | 1259 | $q['post_type'] = 'attachment'; |
1260 | - $post_type = get_post_type_object( 'attachment' ); |
|
1260 | + $post_type = get_post_type_object('attachment'); |
|
1261 | 1261 | $states = 'inherit'; |
1262 | - if ( current_user_can( $post_type->cap->read_private_posts ) ) { |
|
1262 | + if (current_user_can($post_type->cap->read_private_posts)) { |
|
1263 | 1263 | $states .= ',private'; |
1264 | 1264 | } |
1265 | 1265 | |
1266 | - $q['post_status'] = isset( $q['status'] ) && 'trash' === $q['status'] ? 'trash' : $states; |
|
1267 | - $q['post_status'] = isset( $q['attachment-filter'] ) && 'trash' === $q['attachment-filter'] ? 'trash' : $states; |
|
1266 | + $q['post_status'] = isset($q['status']) && 'trash' === $q['status'] ? 'trash' : $states; |
|
1267 | + $q['post_status'] = isset($q['attachment-filter']) && 'trash' === $q['attachment-filter'] ? 'trash' : $states; |
|
1268 | 1268 | |
1269 | - $media_per_page = (int) get_user_option( 'upload_per_page' ); |
|
1270 | - if ( empty( $media_per_page ) || $media_per_page < 1 ) { |
|
1269 | + $media_per_page = (int) get_user_option('upload_per_page'); |
|
1270 | + if (empty($media_per_page) || $media_per_page < 1) { |
|
1271 | 1271 | $media_per_page = 20; |
1272 | 1272 | } |
1273 | 1273 | |
@@ -1278,31 +1278,31 @@ discard block |
||
1278 | 1278 | * |
1279 | 1279 | * @param int $media_per_page Number of media to list. Default 20. |
1280 | 1280 | */ |
1281 | - $q['posts_per_page'] = apply_filters( 'upload_per_page', $media_per_page ); |
|
1281 | + $q['posts_per_page'] = apply_filters('upload_per_page', $media_per_page); |
|
1282 | 1282 | |
1283 | 1283 | $post_mime_types = get_post_mime_types(); |
1284 | - if ( isset( $q['post_mime_type'] ) && ! array_intersect( (array) $q['post_mime_type'], array_keys( $post_mime_types ) ) ) { |
|
1285 | - unset( $q['post_mime_type'] ); |
|
1284 | + if (isset($q['post_mime_type']) && !array_intersect((array) $q['post_mime_type'], array_keys($post_mime_types))) { |
|
1285 | + unset($q['post_mime_type']); |
|
1286 | 1286 | } |
1287 | 1287 | |
1288 | - foreach ( array_keys( $post_mime_types ) as $type ) { |
|
1289 | - if ( isset( $q['attachment-filter'] ) && "post_mime_type:$type" === $q['attachment-filter'] ) { |
|
1288 | + foreach (array_keys($post_mime_types) as $type) { |
|
1289 | + if (isset($q['attachment-filter']) && "post_mime_type:$type" === $q['attachment-filter']) { |
|
1290 | 1290 | $q['post_mime_type'] = $type; |
1291 | 1291 | break; |
1292 | 1292 | } |
1293 | 1293 | } |
1294 | 1294 | |
1295 | - if ( isset( $q['detached'] ) || ( isset( $q['attachment-filter'] ) && 'detached' === $q['attachment-filter'] ) ) { |
|
1295 | + if (isset($q['detached']) || (isset($q['attachment-filter']) && 'detached' === $q['attachment-filter'])) { |
|
1296 | 1296 | $q['post_parent'] = 0; |
1297 | 1297 | } |
1298 | 1298 | |
1299 | - if ( isset( $q['mine'] ) || ( isset( $q['attachment-filter'] ) && 'mine' === $q['attachment-filter'] ) ) { |
|
1299 | + if (isset($q['mine']) || (isset($q['attachment-filter']) && 'mine' === $q['attachment-filter'])) { |
|
1300 | 1300 | $q['author'] = get_current_user_id(); |
1301 | 1301 | } |
1302 | 1302 | |
1303 | 1303 | // Filter query clauses to include filenames. |
1304 | - if ( isset( $q['s'] ) ) { |
|
1305 | - add_filter( 'posts_clauses', '_filter_query_attachment_filenames' ); |
|
1304 | + if (isset($q['s'])) { |
|
1305 | + add_filter('posts_clauses', '_filter_query_attachment_filenames'); |
|
1306 | 1306 | } |
1307 | 1307 | |
1308 | 1308 | return $q; |
@@ -1318,13 +1318,13 @@ discard block |
||
1318 | 1318 | * Defaults to the `$_GET` superglobal. |
1319 | 1319 | * @return array |
1320 | 1320 | */ |
1321 | -function wp_edit_attachments_query( $q = false ) { |
|
1322 | - wp( wp_edit_attachments_query_vars( $q ) ); |
|
1321 | +function wp_edit_attachments_query($q = false) { |
|
1322 | + wp(wp_edit_attachments_query_vars($q)); |
|
1323 | 1323 | |
1324 | 1324 | $post_mime_types = get_post_mime_types(); |
1325 | - $avail_post_mime_types = get_available_post_mime_types( 'attachment' ); |
|
1325 | + $avail_post_mime_types = get_available_post_mime_types('attachment'); |
|
1326 | 1326 | |
1327 | - return array( $post_mime_types, $avail_post_mime_types ); |
|
1327 | + return array($post_mime_types, $avail_post_mime_types); |
|
1328 | 1328 | } |
1329 | 1329 | |
1330 | 1330 | /** |
@@ -1336,18 +1336,18 @@ discard block |
||
1336 | 1336 | * @param string $screen_id The screen on which the meta box is shown. |
1337 | 1337 | * @return string Space-separated string of class names. |
1338 | 1338 | */ |
1339 | -function postbox_classes( $box_id, $screen_id ) { |
|
1340 | - if ( isset( $_GET['edit'] ) && $_GET['edit'] == $box_id ) { |
|
1341 | - $classes = array( '' ); |
|
1342 | - } elseif ( get_user_option( 'closedpostboxes_' . $screen_id ) ) { |
|
1343 | - $closed = get_user_option( 'closedpostboxes_' . $screen_id ); |
|
1344 | - if ( ! is_array( $closed ) ) { |
|
1345 | - $classes = array( '' ); |
|
1339 | +function postbox_classes($box_id, $screen_id) { |
|
1340 | + if (isset($_GET['edit']) && $_GET['edit'] == $box_id) { |
|
1341 | + $classes = array(''); |
|
1342 | + } elseif (get_user_option('closedpostboxes_' . $screen_id)) { |
|
1343 | + $closed = get_user_option('closedpostboxes_' . $screen_id); |
|
1344 | + if (!is_array($closed)) { |
|
1345 | + $classes = array(''); |
|
1346 | 1346 | } else { |
1347 | - $classes = in_array( $box_id, $closed, true ) ? array( 'closed' ) : array( '' ); |
|
1347 | + $classes = in_array($box_id, $closed, true) ? array('closed') : array(''); |
|
1348 | 1348 | } |
1349 | 1349 | } else { |
1350 | - $classes = array( '' ); |
|
1350 | + $classes = array(''); |
|
1351 | 1351 | } |
1352 | 1352 | |
1353 | 1353 | /** |
@@ -1360,9 +1360,9 @@ discard block |
||
1360 | 1360 | * |
1361 | 1361 | * @param string[] $classes An array of postbox classes. |
1362 | 1362 | */ |
1363 | - $classes = apply_filters( "postbox_classes_{$screen_id}_{$box_id}", $classes ); |
|
1363 | + $classes = apply_filters("postbox_classes_{$screen_id}_{$box_id}", $classes); |
|
1364 | 1364 | |
1365 | - return implode( ' ', $classes ); |
|
1365 | + return implode(' ', $classes); |
|
1366 | 1366 | } |
1367 | 1367 | |
1368 | 1368 | /** |
@@ -1381,62 +1381,62 @@ discard block |
||
1381 | 1381 | * @type string $1 The post name. |
1382 | 1382 | * } |
1383 | 1383 | */ |
1384 | -function get_sample_permalink( $id, $title = null, $name = null ) { |
|
1385 | - $post = get_post( $id ); |
|
1386 | - if ( ! $post ) { |
|
1387 | - return array( '', '' ); |
|
1384 | +function get_sample_permalink($id, $title = null, $name = null) { |
|
1385 | + $post = get_post($id); |
|
1386 | + if (!$post) { |
|
1387 | + return array('', ''); |
|
1388 | 1388 | } |
1389 | 1389 | |
1390 | - $ptype = get_post_type_object( $post->post_type ); |
|
1390 | + $ptype = get_post_type_object($post->post_type); |
|
1391 | 1391 | |
1392 | 1392 | $original_status = $post->post_status; |
1393 | 1393 | $original_date = $post->post_date; |
1394 | 1394 | $original_name = $post->post_name; |
1395 | 1395 | |
1396 | 1396 | // Hack: get_permalink() would return plain permalink for drafts, so we will fake that our post is published. |
1397 | - if ( in_array( $post->post_status, array( 'draft', 'pending', 'future' ), true ) ) { |
|
1397 | + if (in_array($post->post_status, array('draft', 'pending', 'future'), true)) { |
|
1398 | 1398 | $post->post_status = 'publish'; |
1399 | - $post->post_name = sanitize_title( $post->post_name ? $post->post_name : $post->post_title, $post->ID ); |
|
1399 | + $post->post_name = sanitize_title($post->post_name ? $post->post_name : $post->post_title, $post->ID); |
|
1400 | 1400 | } |
1401 | 1401 | |
1402 | 1402 | // If the user wants to set a new name -- override the current one. |
1403 | 1403 | // Note: if empty name is supplied -- use the title instead, see #6072. |
1404 | - if ( ! is_null( $name ) ) { |
|
1405 | - $post->post_name = sanitize_title( $name ? $name : $title, $post->ID ); |
|
1404 | + if (!is_null($name)) { |
|
1405 | + $post->post_name = sanitize_title($name ? $name : $title, $post->ID); |
|
1406 | 1406 | } |
1407 | 1407 | |
1408 | - $post->post_name = wp_unique_post_slug( $post->post_name, $post->ID, $post->post_status, $post->post_type, $post->post_parent ); |
|
1408 | + $post->post_name = wp_unique_post_slug($post->post_name, $post->ID, $post->post_status, $post->post_type, $post->post_parent); |
|
1409 | 1409 | |
1410 | 1410 | $post->filter = 'sample'; |
1411 | 1411 | |
1412 | - $permalink = get_permalink( $post, true ); |
|
1412 | + $permalink = get_permalink($post, true); |
|
1413 | 1413 | |
1414 | 1414 | // Replace custom post_type token with generic pagename token for ease of use. |
1415 | - $permalink = str_replace( "%$post->post_type%", '%pagename%', $permalink ); |
|
1415 | + $permalink = str_replace("%$post->post_type%", '%pagename%', $permalink); |
|
1416 | 1416 | |
1417 | 1417 | // Handle page hierarchy. |
1418 | - if ( $ptype->hierarchical ) { |
|
1419 | - $uri = get_page_uri( $post ); |
|
1420 | - if ( $uri ) { |
|
1421 | - $uri = untrailingslashit( $uri ); |
|
1422 | - $uri = strrev( stristr( strrev( $uri ), '/' ) ); |
|
1423 | - $uri = untrailingslashit( $uri ); |
|
1418 | + if ($ptype->hierarchical) { |
|
1419 | + $uri = get_page_uri($post); |
|
1420 | + if ($uri) { |
|
1421 | + $uri = untrailingslashit($uri); |
|
1422 | + $uri = strrev(stristr(strrev($uri), '/')); |
|
1423 | + $uri = untrailingslashit($uri); |
|
1424 | 1424 | } |
1425 | 1425 | |
1426 | 1426 | /** This filter is documented in wp-admin/edit-tag-form.php */ |
1427 | - $uri = apply_filters( 'editable_slug', $uri, $post ); |
|
1428 | - if ( ! empty( $uri ) ) { |
|
1427 | + $uri = apply_filters('editable_slug', $uri, $post); |
|
1428 | + if (!empty($uri)) { |
|
1429 | 1429 | $uri .= '/'; |
1430 | 1430 | } |
1431 | - $permalink = str_replace( '%pagename%', "{$uri}%pagename%", $permalink ); |
|
1431 | + $permalink = str_replace('%pagename%', "{$uri}%pagename%", $permalink); |
|
1432 | 1432 | } |
1433 | 1433 | |
1434 | 1434 | /** This filter is documented in wp-admin/edit-tag-form.php */ |
1435 | - $permalink = array( $permalink, apply_filters( 'editable_slug', $post->post_name, $post ) ); |
|
1435 | + $permalink = array($permalink, apply_filters('editable_slug', $post->post_name, $post)); |
|
1436 | 1436 | $post->post_status = $original_status; |
1437 | 1437 | $post->post_date = $original_date; |
1438 | 1438 | $post->post_name = $original_name; |
1439 | - unset( $post->filter ); |
|
1439 | + unset($post->filter); |
|
1440 | 1440 | |
1441 | 1441 | /** |
1442 | 1442 | * Filters the sample permalink. |
@@ -1454,7 +1454,7 @@ discard block |
||
1454 | 1454 | * @param string $name Post name (slug). |
1455 | 1455 | * @param WP_Post $post Post object. |
1456 | 1456 | */ |
1457 | - return apply_filters( 'get_sample_permalink', $permalink, $post->ID, $title, $name, $post ); |
|
1457 | + return apply_filters('get_sample_permalink', $permalink, $post->ID, $title, $name, $post); |
|
1458 | 1458 | } |
1459 | 1459 | |
1460 | 1460 | /** |
@@ -1467,63 +1467,63 @@ discard block |
||
1467 | 1467 | * @param string|null $new_slug Optional. New slug. Default null. |
1468 | 1468 | * @return string The HTML of the sample permalink slug editor. |
1469 | 1469 | */ |
1470 | -function get_sample_permalink_html( $id, $new_title = null, $new_slug = null ) { |
|
1471 | - $post = get_post( $id ); |
|
1472 | - if ( ! $post ) { |
|
1470 | +function get_sample_permalink_html($id, $new_title = null, $new_slug = null) { |
|
1471 | + $post = get_post($id); |
|
1472 | + if (!$post) { |
|
1473 | 1473 | return ''; |
1474 | 1474 | } |
1475 | 1475 | |
1476 | - list($permalink, $post_name) = get_sample_permalink( $post->ID, $new_title, $new_slug ); |
|
1476 | + list($permalink, $post_name) = get_sample_permalink($post->ID, $new_title, $new_slug); |
|
1477 | 1477 | |
1478 | 1478 | $view_link = false; |
1479 | 1479 | $preview_target = ''; |
1480 | 1480 | |
1481 | - if ( current_user_can( 'read_post', $post->ID ) ) { |
|
1482 | - if ( 'draft' === $post->post_status || empty( $post->post_name ) ) { |
|
1483 | - $view_link = get_preview_post_link( $post ); |
|
1481 | + if (current_user_can('read_post', $post->ID)) { |
|
1482 | + if ('draft' === $post->post_status || empty($post->post_name)) { |
|
1483 | + $view_link = get_preview_post_link($post); |
|
1484 | 1484 | $preview_target = " target='wp-preview-{$post->ID}'"; |
1485 | 1485 | } else { |
1486 | - if ( 'publish' === $post->post_status || 'attachment' === $post->post_type ) { |
|
1487 | - $view_link = get_permalink( $post ); |
|
1486 | + if ('publish' === $post->post_status || 'attachment' === $post->post_type) { |
|
1487 | + $view_link = get_permalink($post); |
|
1488 | 1488 | } else { |
1489 | 1489 | // Allow non-published (private, future) to be viewed at a pretty permalink, in case $post->post_name is set. |
1490 | - $view_link = str_replace( array( '%pagename%', '%postname%' ), $post->post_name, $permalink ); |
|
1490 | + $view_link = str_replace(array('%pagename%', '%postname%'), $post->post_name, $permalink); |
|
1491 | 1491 | } |
1492 | 1492 | } |
1493 | 1493 | } |
1494 | 1494 | |
1495 | 1495 | // Permalinks without a post/page name placeholder don't have anything to edit. |
1496 | - if ( false === strpos( $permalink, '%postname%' ) && false === strpos( $permalink, '%pagename%' ) ) { |
|
1497 | - $return = '<strong>' . __( 'Permalink:' ) . "</strong>\n"; |
|
1496 | + if (false === strpos($permalink, '%postname%') && false === strpos($permalink, '%pagename%')) { |
|
1497 | + $return = '<strong>' . __('Permalink:') . "</strong>\n"; |
|
1498 | 1498 | |
1499 | - if ( false !== $view_link ) { |
|
1500 | - $display_link = urldecode( $view_link ); |
|
1501 | - $return .= '<a id="sample-permalink" href="' . esc_url( $view_link ) . '"' . $preview_target . '>' . esc_html( $display_link ) . "</a>\n"; |
|
1499 | + if (false !== $view_link) { |
|
1500 | + $display_link = urldecode($view_link); |
|
1501 | + $return .= '<a id="sample-permalink" href="' . esc_url($view_link) . '"' . $preview_target . '>' . esc_html($display_link) . "</a>\n"; |
|
1502 | 1502 | } else { |
1503 | 1503 | $return .= '<span id="sample-permalink">' . $permalink . "</span>\n"; |
1504 | 1504 | } |
1505 | 1505 | |
1506 | 1506 | // Encourage a pretty permalink setting. |
1507 | - if ( ! get_option( 'permalink_structure' ) && current_user_can( 'manage_options' ) |
|
1508 | - && ! ( 'page' === get_option( 'show_on_front' ) && get_option( 'page_on_front' ) == $id ) |
|
1507 | + if (!get_option('permalink_structure') && current_user_can('manage_options') |
|
1508 | + && !('page' === get_option('show_on_front') && get_option('page_on_front') == $id) |
|
1509 | 1509 | ) { |
1510 | - $return .= '<span id="change-permalinks"><a href="options-permalink.php" class="button button-small">' . __( 'Change Permalink Structure' ) . "</a></span>\n"; |
|
1510 | + $return .= '<span id="change-permalinks"><a href="options-permalink.php" class="button button-small">' . __('Change Permalink Structure') . "</a></span>\n"; |
|
1511 | 1511 | } |
1512 | 1512 | } else { |
1513 | - if ( mb_strlen( $post_name ) > 34 ) { |
|
1514 | - $post_name_abridged = mb_substr( $post_name, 0, 16 ) . '…' . mb_substr( $post_name, -16 ); |
|
1513 | + if (mb_strlen($post_name) > 34) { |
|
1514 | + $post_name_abridged = mb_substr($post_name, 0, 16) . '…' . mb_substr($post_name, -16); |
|
1515 | 1515 | } else { |
1516 | 1516 | $post_name_abridged = $post_name; |
1517 | 1517 | } |
1518 | 1518 | |
1519 | - $post_name_html = '<span id="editable-post-name">' . esc_html( $post_name_abridged ) . '</span>'; |
|
1520 | - $display_link = str_replace( array( '%pagename%', '%postname%' ), $post_name_html, esc_html( urldecode( $permalink ) ) ); |
|
1519 | + $post_name_html = '<span id="editable-post-name">' . esc_html($post_name_abridged) . '</span>'; |
|
1520 | + $display_link = str_replace(array('%pagename%', '%postname%'), $post_name_html, esc_html(urldecode($permalink))); |
|
1521 | 1521 | |
1522 | - $return = '<strong>' . __( 'Permalink:' ) . "</strong>\n"; |
|
1523 | - $return .= '<span id="sample-permalink"><a href="' . esc_url( $view_link ) . '"' . $preview_target . '>' . $display_link . "</a></span>\n"; |
|
1522 | + $return = '<strong>' . __('Permalink:') . "</strong>\n"; |
|
1523 | + $return .= '<span id="sample-permalink"><a href="' . esc_url($view_link) . '"' . $preview_target . '>' . $display_link . "</a></span>\n"; |
|
1524 | 1524 | $return .= '‎'; // Fix bi-directional text display defect in RTL languages. |
1525 | - $return .= '<span id="edit-slug-buttons"><button type="button" class="edit-slug button button-small hide-if-no-js" aria-label="' . __( 'Edit permalink' ) . '">' . __( 'Edit' ) . "</button></span>\n"; |
|
1526 | - $return .= '<span id="editable-post-name-full">' . esc_html( $post_name ) . "</span>\n"; |
|
1525 | + $return .= '<span id="edit-slug-buttons"><button type="button" class="edit-slug button button-small hide-if-no-js" aria-label="' . __('Edit permalink') . '">' . __('Edit') . "</button></span>\n"; |
|
1526 | + $return .= '<span id="editable-post-name-full">' . esc_html($post_name) . "</span>\n"; |
|
1527 | 1527 | } |
1528 | 1528 | |
1529 | 1529 | /** |
@@ -1538,7 +1538,7 @@ discard block |
||
1538 | 1538 | * @param string $new_slug New sample permalink slug. |
1539 | 1539 | * @param WP_Post $post Post object. |
1540 | 1540 | */ |
1541 | - $return = apply_filters( 'get_sample_permalink_html', $return, $post->ID, $new_title, $new_slug, $post ); |
|
1541 | + $return = apply_filters('get_sample_permalink_html', $return, $post->ID, $new_title, $new_slug, $post); |
|
1542 | 1542 | |
1543 | 1543 | return $return; |
1544 | 1544 | } |
@@ -1553,23 +1553,23 @@ discard block |
||
1553 | 1553 | * with the thumbnail. Defaults to global $post. |
1554 | 1554 | * @return string The post thumbnail HTML. |
1555 | 1555 | */ |
1556 | -function _wp_post_thumbnail_html( $thumbnail_id = null, $post = null ) { |
|
1556 | +function _wp_post_thumbnail_html($thumbnail_id = null, $post = null) { |
|
1557 | 1557 | $_wp_additional_image_sizes = wp_get_additional_image_sizes(); |
1558 | 1558 | |
1559 | - $post = get_post( $post ); |
|
1560 | - $post_type_object = get_post_type_object( $post->post_type ); |
|
1559 | + $post = get_post($post); |
|
1560 | + $post_type_object = get_post_type_object($post->post_type); |
|
1561 | 1561 | $set_thumbnail_link = '<p class="hide-if-no-js"><a href="%s" id="set-post-thumbnail"%s class="thickbox">%s</a></p>'; |
1562 | - $upload_iframe_src = get_upload_iframe_src( 'image', $post->ID ); |
|
1562 | + $upload_iframe_src = get_upload_iframe_src('image', $post->ID); |
|
1563 | 1563 | |
1564 | 1564 | $content = sprintf( |
1565 | 1565 | $set_thumbnail_link, |
1566 | - esc_url( $upload_iframe_src ), |
|
1566 | + esc_url($upload_iframe_src), |
|
1567 | 1567 | '', // Empty when there's no featured image set, `aria-describedby` attribute otherwise. |
1568 | - esc_html( $post_type_object->labels->set_featured_image ) |
|
1568 | + esc_html($post_type_object->labels->set_featured_image) |
|
1569 | 1569 | ); |
1570 | 1570 | |
1571 | - if ( $thumbnail_id && get_post( $thumbnail_id ) ) { |
|
1572 | - $size = isset( $_wp_additional_image_sizes['post-thumbnail'] ) ? 'post-thumbnail' : array( 266, 266 ); |
|
1571 | + if ($thumbnail_id && get_post($thumbnail_id)) { |
|
1572 | + $size = isset($_wp_additional_image_sizes['post-thumbnail']) ? 'post-thumbnail' : array(266, 266); |
|
1573 | 1573 | |
1574 | 1574 | /** |
1575 | 1575 | * Filters the size used to display the post thumbnail image in the 'Featured image' meta box. |
@@ -1585,23 +1585,23 @@ discard block |
||
1585 | 1585 | * @param int $thumbnail_id Post thumbnail attachment ID. |
1586 | 1586 | * @param WP_Post $post The post object associated with the thumbnail. |
1587 | 1587 | */ |
1588 | - $size = apply_filters( 'admin_post_thumbnail_size', $size, $thumbnail_id, $post ); |
|
1588 | + $size = apply_filters('admin_post_thumbnail_size', $size, $thumbnail_id, $post); |
|
1589 | 1589 | |
1590 | - $thumbnail_html = wp_get_attachment_image( $thumbnail_id, $size ); |
|
1590 | + $thumbnail_html = wp_get_attachment_image($thumbnail_id, $size); |
|
1591 | 1591 | |
1592 | - if ( ! empty( $thumbnail_html ) ) { |
|
1593 | - $content = sprintf( |
|
1592 | + if (!empty($thumbnail_html)) { |
|
1593 | + $content = sprintf( |
|
1594 | 1594 | $set_thumbnail_link, |
1595 | - esc_url( $upload_iframe_src ), |
|
1595 | + esc_url($upload_iframe_src), |
|
1596 | 1596 | ' aria-describedby="set-post-thumbnail-desc"', |
1597 | 1597 | $thumbnail_html |
1598 | 1598 | ); |
1599 | - $content .= '<p class="hide-if-no-js howto" id="set-post-thumbnail-desc">' . __( 'Click the image to edit or update' ) . '</p>'; |
|
1600 | - $content .= '<p class="hide-if-no-js"><a href="#" id="remove-post-thumbnail">' . esc_html( $post_type_object->labels->remove_featured_image ) . '</a></p>'; |
|
1599 | + $content .= '<p class="hide-if-no-js howto" id="set-post-thumbnail-desc">' . __('Click the image to edit or update') . '</p>'; |
|
1600 | + $content .= '<p class="hide-if-no-js"><a href="#" id="remove-post-thumbnail">' . esc_html($post_type_object->labels->remove_featured_image) . '</a></p>'; |
|
1601 | 1601 | } |
1602 | 1602 | } |
1603 | 1603 | |
1604 | - $content .= '<input type="hidden" id="_thumbnail_id" name="_thumbnail_id" value="' . esc_attr( $thumbnail_id ? $thumbnail_id : '-1' ) . '" />'; |
|
1604 | + $content .= '<input type="hidden" id="_thumbnail_id" name="_thumbnail_id" value="' . esc_attr($thumbnail_id ? $thumbnail_id : '-1') . '" />'; |
|
1605 | 1605 | |
1606 | 1606 | /** |
1607 | 1607 | * Filters the admin post thumbnail HTML markup to return. |
@@ -1614,7 +1614,7 @@ discard block |
||
1614 | 1614 | * @param int $post_id Post ID. |
1615 | 1615 | * @param int|null $thumbnail_id Thumbnail attachment ID, or null if there isn't one. |
1616 | 1616 | */ |
1617 | - return apply_filters( 'admin_post_thumbnail_html', $content, $post->ID, $thumbnail_id ); |
|
1617 | + return apply_filters('admin_post_thumbnail_html', $content, $post->ID, $thumbnail_id); |
|
1618 | 1618 | } |
1619 | 1619 | |
1620 | 1620 | /** |
@@ -1626,29 +1626,29 @@ discard block |
||
1626 | 1626 | * @return int|false ID of the user with lock. False if the post does not exist, post is not locked, |
1627 | 1627 | * the user with lock does not exist, or the post is locked by current user. |
1628 | 1628 | */ |
1629 | -function wp_check_post_lock( $post_id ) { |
|
1630 | - $post = get_post( $post_id ); |
|
1631 | - if ( ! $post ) { |
|
1629 | +function wp_check_post_lock($post_id) { |
|
1630 | + $post = get_post($post_id); |
|
1631 | + if (!$post) { |
|
1632 | 1632 | return false; |
1633 | 1633 | } |
1634 | 1634 | |
1635 | - $lock = get_post_meta( $post->ID, '_edit_lock', true ); |
|
1636 | - if ( ! $lock ) { |
|
1635 | + $lock = get_post_meta($post->ID, '_edit_lock', true); |
|
1636 | + if (!$lock) { |
|
1637 | 1637 | return false; |
1638 | 1638 | } |
1639 | 1639 | |
1640 | - $lock = explode( ':', $lock ); |
|
1640 | + $lock = explode(':', $lock); |
|
1641 | 1641 | $time = $lock[0]; |
1642 | - $user = isset( $lock[1] ) ? $lock[1] : get_post_meta( $post->ID, '_edit_last', true ); |
|
1642 | + $user = isset($lock[1]) ? $lock[1] : get_post_meta($post->ID, '_edit_last', true); |
|
1643 | 1643 | |
1644 | - if ( ! get_userdata( $user ) ) { |
|
1644 | + if (!get_userdata($user)) { |
|
1645 | 1645 | return false; |
1646 | 1646 | } |
1647 | 1647 | |
1648 | 1648 | /** This filter is documented in wp-admin/includes/ajax-actions.php */ |
1649 | - $time_window = apply_filters( 'wp_check_post_lock_window', 150 ); |
|
1649 | + $time_window = apply_filters('wp_check_post_lock_window', 150); |
|
1650 | 1650 | |
1651 | - if ( $time && $time > time() - $time_window && get_current_user_id() != $user ) { |
|
1651 | + if ($time && $time > time() - $time_window && get_current_user_id() != $user) { |
|
1652 | 1652 | return $user; |
1653 | 1653 | } |
1654 | 1654 | |
@@ -1669,23 +1669,23 @@ discard block |
||
1669 | 1669 | * @type int $1 The ID of the current user. |
1670 | 1670 | * } |
1671 | 1671 | */ |
1672 | -function wp_set_post_lock( $post_id ) { |
|
1673 | - $post = get_post( $post_id ); |
|
1674 | - if ( ! $post ) { |
|
1672 | +function wp_set_post_lock($post_id) { |
|
1673 | + $post = get_post($post_id); |
|
1674 | + if (!$post) { |
|
1675 | 1675 | return false; |
1676 | 1676 | } |
1677 | 1677 | |
1678 | 1678 | $user_id = get_current_user_id(); |
1679 | - if ( 0 == $user_id ) { |
|
1679 | + if (0 == $user_id) { |
|
1680 | 1680 | return false; |
1681 | 1681 | } |
1682 | 1682 | |
1683 | 1683 | $now = time(); |
1684 | 1684 | $lock = "$now:$user_id"; |
1685 | 1685 | |
1686 | - update_post_meta( $post->ID, '_edit_lock', $lock ); |
|
1686 | + update_post_meta($post->ID, '_edit_lock', $lock); |
|
1687 | 1687 | |
1688 | - return array( $now, $user_id ); |
|
1688 | + return array($now, $user_id); |
|
1689 | 1689 | } |
1690 | 1690 | |
1691 | 1691 | /** |
@@ -1695,17 +1695,17 @@ discard block |
||
1695 | 1695 | */ |
1696 | 1696 | function _admin_notice_post_locked() { |
1697 | 1697 | $post = get_post(); |
1698 | - if ( ! $post ) { |
|
1698 | + if (!$post) { |
|
1699 | 1699 | return; |
1700 | 1700 | } |
1701 | 1701 | |
1702 | 1702 | $user = null; |
1703 | - $user_id = wp_check_post_lock( $post->ID ); |
|
1704 | - if ( $user_id ) { |
|
1705 | - $user = get_userdata( $user_id ); |
|
1703 | + $user_id = wp_check_post_lock($post->ID); |
|
1704 | + if ($user_id) { |
|
1705 | + $user = get_userdata($user_id); |
|
1706 | 1706 | } |
1707 | 1707 | |
1708 | - if ( $user ) { |
|
1708 | + if ($user) { |
|
1709 | 1709 | /** |
1710 | 1710 | * Filters whether to show the post locked dialog. |
1711 | 1711 | * |
@@ -1717,7 +1717,7 @@ discard block |
||
1717 | 1717 | * @param WP_Post $post Post object. |
1718 | 1718 | * @param WP_User $user The user with the lock for the post. |
1719 | 1719 | */ |
1720 | - if ( ! apply_filters( 'show_post_locked_dialog', true, $post, $user ) ) { |
|
1720 | + if (!apply_filters('show_post_locked_dialog', true, $post, $user)) { |
|
1721 | 1721 | return; |
1722 | 1722 | } |
1723 | 1723 | |
@@ -1727,17 +1727,17 @@ discard block |
||
1727 | 1727 | } |
1728 | 1728 | |
1729 | 1729 | $sendback = wp_get_referer(); |
1730 | - if ( $locked && $sendback && false === strpos( $sendback, 'post.php' ) && false === strpos( $sendback, 'post-new.php' ) ) { |
|
1730 | + if ($locked && $sendback && false === strpos($sendback, 'post.php') && false === strpos($sendback, 'post-new.php')) { |
|
1731 | 1731 | |
1732 | - $sendback_text = __( 'Go back' ); |
|
1732 | + $sendback_text = __('Go back'); |
|
1733 | 1733 | } else { |
1734 | - $sendback = admin_url( 'edit.php' ); |
|
1734 | + $sendback = admin_url('edit.php'); |
|
1735 | 1735 | |
1736 | - if ( 'post' !== $post->post_type ) { |
|
1737 | - $sendback = add_query_arg( 'post_type', $post->post_type, $sendback ); |
|
1736 | + if ('post' !== $post->post_type) { |
|
1737 | + $sendback = add_query_arg('post_type', $post->post_type, $sendback); |
|
1738 | 1738 | } |
1739 | 1739 | |
1740 | - $sendback_text = get_post_type_object( $post->post_type )->labels->all_items; |
|
1740 | + $sendback_text = get_post_type_object($post->post_type)->labels->all_items; |
|
1741 | 1741 | } |
1742 | 1742 | |
1743 | 1743 | $hidden = $locked ? '' : ' hidden'; |
@@ -1748,18 +1748,18 @@ discard block |
||
1748 | 1748 | <div class="notification-dialog"> |
1749 | 1749 | <?php |
1750 | 1750 | |
1751 | - if ( $locked ) { |
|
1751 | + if ($locked) { |
|
1752 | 1752 | $query_args = array(); |
1753 | - if ( get_post_type_object( $post->post_type )->public ) { |
|
1754 | - if ( 'publish' === $post->post_status || $user->ID != $post->post_author ) { |
|
1753 | + if (get_post_type_object($post->post_type)->public) { |
|
1754 | + if ('publish' === $post->post_status || $user->ID != $post->post_author) { |
|
1755 | 1755 | // Latest content is in autosave. |
1756 | - $nonce = wp_create_nonce( 'post_preview_' . $post->ID ); |
|
1756 | + $nonce = wp_create_nonce('post_preview_' . $post->ID); |
|
1757 | 1757 | $query_args['preview_id'] = $post->ID; |
1758 | 1758 | $query_args['preview_nonce'] = $nonce; |
1759 | 1759 | } |
1760 | 1760 | } |
1761 | 1761 | |
1762 | - $preview_link = get_preview_post_link( $post->ID, $query_args ); |
|
1762 | + $preview_link = get_preview_post_link($post->ID, $query_args); |
|
1763 | 1763 | |
1764 | 1764 | /** |
1765 | 1765 | * Filters whether to allow the post lock to be overridden. |
@@ -1773,20 +1773,20 @@ discard block |
||
1773 | 1773 | * @param WP_Post $post Post object. |
1774 | 1774 | * @param WP_User $user The user with the lock for the post. |
1775 | 1775 | */ |
1776 | - $override = apply_filters( 'override_post_lock', true, $post, $user ); |
|
1776 | + $override = apply_filters('override_post_lock', true, $post, $user); |
|
1777 | 1777 | $tab_last = $override ? '' : ' wp-tab-last'; |
1778 | 1778 | |
1779 | 1779 | ?> |
1780 | 1780 | <div class="post-locked-message"> |
1781 | - <div class="post-locked-avatar"><?php echo get_avatar( $user->ID, 64 ); ?></div> |
|
1781 | + <div class="post-locked-avatar"><?php echo get_avatar($user->ID, 64); ?></div> |
|
1782 | 1782 | <p class="currently-editing wp-tab-first" tabindex="0"> |
1783 | 1783 | <?php |
1784 | - if ( $override ) { |
|
1784 | + if ($override) { |
|
1785 | 1785 | /* translators: %s: User's display name. */ |
1786 | - printf( __( '%s is currently editing this post. Do you want to take over?' ), esc_html( $user->display_name ) ); |
|
1786 | + printf(__('%s is currently editing this post. Do you want to take over?'), esc_html($user->display_name)); |
|
1787 | 1787 | } else { |
1788 | 1788 | /* translators: %s: User's display name. */ |
1789 | - printf( __( '%s is currently editing this post.' ), esc_html( $user->display_name ) ); |
|
1789 | + printf(__('%s is currently editing this post.'), esc_html($user->display_name)); |
|
1790 | 1790 | } |
1791 | 1791 | ?> |
1792 | 1792 | </p> |
@@ -1800,19 +1800,19 @@ discard block |
||
1800 | 1800 | * @param WP_Post $post Post object. |
1801 | 1801 | * @param WP_User $user The user with the lock for the post. |
1802 | 1802 | */ |
1803 | - do_action( 'post_locked_dialog', $post, $user ); |
|
1803 | + do_action('post_locked_dialog', $post, $user); |
|
1804 | 1804 | ?> |
1805 | 1805 | <p> |
1806 | - <a class="button" href="<?php echo esc_url( $sendback ); ?>"><?php echo $sendback_text; ?></a> |
|
1807 | - <?php if ( $preview_link ) { ?> |
|
1808 | - <a class="button<?php echo $tab_last; ?>" href="<?php echo esc_url( $preview_link ); ?>"><?php _e( 'Preview' ); ?></a> |
|
1806 | + <a class="button" href="<?php echo esc_url($sendback); ?>"><?php echo $sendback_text; ?></a> |
|
1807 | + <?php if ($preview_link) { ?> |
|
1808 | + <a class="button<?php echo $tab_last; ?>" href="<?php echo esc_url($preview_link); ?>"><?php _e('Preview'); ?></a> |
|
1809 | 1809 | <?php |
1810 | 1810 | } |
1811 | 1811 | |
1812 | 1812 | // Allow plugins to prevent some users overriding the post lock. |
1813 | - if ( $override ) { |
|
1813 | + if ($override) { |
|
1814 | 1814 | ?> |
1815 | - <a class="button button-primary wp-tab-last" href="<?php echo esc_url( add_query_arg( 'get-post-lock', '1', wp_nonce_url( get_edit_post_link( $post->ID, 'url' ), 'lock-post_' . $post->ID ) ) ); ?>"><?php _e( 'Take over' ); ?></a> |
|
1815 | + <a class="button button-primary wp-tab-last" href="<?php echo esc_url(add_query_arg('get-post-lock', '1', wp_nonce_url(get_edit_post_link($post->ID, 'url'), 'lock-post_' . $post->ID))); ?>"><?php _e('Take over'); ?></a> |
|
1816 | 1816 | <?php |
1817 | 1817 | } |
1818 | 1818 | |
@@ -1826,8 +1826,8 @@ discard block |
||
1826 | 1826 | <div class="post-locked-avatar"></div> |
1827 | 1827 | <p class="wp-tab-first" tabindex="0"> |
1828 | 1828 | <span class="currently-editing"></span><br /> |
1829 | - <span class="locked-saving hidden"><img src="<?php echo esc_url( admin_url( 'images/spinner-2x.gif' ) ); ?>" width="16" height="16" alt="" /> <?php _e( 'Saving revision…' ); ?></span> |
|
1830 | - <span class="locked-saved hidden"><?php _e( 'Your latest changes were saved as a revision.' ); ?></span> |
|
1829 | + <span class="locked-saving hidden"><img src="<?php echo esc_url(admin_url('images/spinner-2x.gif')); ?>" width="16" height="16" alt="" /> <?php _e('Saving revision…'); ?></span> |
|
1830 | + <span class="locked-saved hidden"><?php _e('Your latest changes were saved as a revision.'); ?></span> |
|
1831 | 1831 | </p> |
1832 | 1832 | <?php |
1833 | 1833 | /** |
@@ -1837,9 +1837,9 @@ discard block |
||
1837 | 1837 | * |
1838 | 1838 | * @param WP_Post $post Post object. |
1839 | 1839 | */ |
1840 | - do_action( 'post_lock_lost_dialog', $post ); |
|
1840 | + do_action('post_lock_lost_dialog', $post); |
|
1841 | 1841 | ?> |
1842 | - <p><a class="button button-primary wp-tab-last" href="<?php echo esc_url( $sendback ); ?>"><?php echo $sendback_text; ?></a></p> |
|
1842 | + <p><a class="button button-primary wp-tab-last" href="<?php echo esc_url($sendback); ?>"><?php echo $sendback_text; ?></a></p> |
|
1843 | 1843 | </div> |
1844 | 1844 | <?php |
1845 | 1845 | } |
@@ -1859,42 +1859,42 @@ discard block |
||
1859 | 1859 | * If a numeric post ID is provided, will use the `$_POST` superglobal. |
1860 | 1860 | * @return int|WP_Error The autosave revision ID. WP_Error or 0 on error. |
1861 | 1861 | */ |
1862 | -function wp_create_post_autosave( $post_data ) { |
|
1863 | - if ( is_numeric( $post_data ) ) { |
|
1862 | +function wp_create_post_autosave($post_data) { |
|
1863 | + if (is_numeric($post_data)) { |
|
1864 | 1864 | $post_id = $post_data; |
1865 | 1865 | $post_data = $_POST; |
1866 | 1866 | } else { |
1867 | 1867 | $post_id = (int) $post_data['post_ID']; |
1868 | 1868 | } |
1869 | 1869 | |
1870 | - $post_data = _wp_translate_postdata( true, $post_data ); |
|
1871 | - if ( is_wp_error( $post_data ) ) { |
|
1870 | + $post_data = _wp_translate_postdata(true, $post_data); |
|
1871 | + if (is_wp_error($post_data)) { |
|
1872 | 1872 | return $post_data; |
1873 | 1873 | } |
1874 | - $post_data = _wp_get_allowed_postdata( $post_data ); |
|
1874 | + $post_data = _wp_get_allowed_postdata($post_data); |
|
1875 | 1875 | |
1876 | 1876 | $post_author = get_current_user_id(); |
1877 | 1877 | |
1878 | 1878 | // Store one autosave per author. If there is already an autosave, overwrite it. |
1879 | - $old_autosave = wp_get_post_autosave( $post_id, $post_author ); |
|
1880 | - if ( $old_autosave ) { |
|
1881 | - $new_autosave = _wp_post_revision_data( $post_data, true ); |
|
1879 | + $old_autosave = wp_get_post_autosave($post_id, $post_author); |
|
1880 | + if ($old_autosave) { |
|
1881 | + $new_autosave = _wp_post_revision_data($post_data, true); |
|
1882 | 1882 | $new_autosave['ID'] = $old_autosave->ID; |
1883 | 1883 | $new_autosave['post_author'] = $post_author; |
1884 | 1884 | |
1885 | - $post = get_post( $post_id ); |
|
1885 | + $post = get_post($post_id); |
|
1886 | 1886 | |
1887 | 1887 | // If the new autosave has the same content as the post, delete the autosave. |
1888 | 1888 | $autosave_is_different = false; |
1889 | - foreach ( array_intersect( array_keys( $new_autosave ), array_keys( _wp_post_revision_fields( $post ) ) ) as $field ) { |
|
1890 | - if ( normalize_whitespace( $new_autosave[ $field ] ) !== normalize_whitespace( $post->$field ) ) { |
|
1889 | + foreach (array_intersect(array_keys($new_autosave), array_keys(_wp_post_revision_fields($post))) as $field) { |
|
1890 | + if (normalize_whitespace($new_autosave[$field]) !== normalize_whitespace($post->$field)) { |
|
1891 | 1891 | $autosave_is_different = true; |
1892 | 1892 | break; |
1893 | 1893 | } |
1894 | 1894 | } |
1895 | 1895 | |
1896 | - if ( ! $autosave_is_different ) { |
|
1897 | - wp_delete_post_revision( $old_autosave->ID ); |
|
1896 | + if (!$autosave_is_different) { |
|
1897 | + wp_delete_post_revision($old_autosave->ID); |
|
1898 | 1898 | return 0; |
1899 | 1899 | } |
1900 | 1900 | |
@@ -1905,16 +1905,16 @@ discard block |
||
1905 | 1905 | * |
1906 | 1906 | * @param array $new_autosave Post array - the autosave that is about to be saved. |
1907 | 1907 | */ |
1908 | - do_action( 'wp_creating_autosave', $new_autosave ); |
|
1908 | + do_action('wp_creating_autosave', $new_autosave); |
|
1909 | 1909 | |
1910 | - return wp_update_post( $new_autosave ); |
|
1910 | + return wp_update_post($new_autosave); |
|
1911 | 1911 | } |
1912 | 1912 | |
1913 | 1913 | // _wp_put_post_revision() expects unescaped. |
1914 | - $post_data = wp_unslash( $post_data ); |
|
1914 | + $post_data = wp_unslash($post_data); |
|
1915 | 1915 | |
1916 | 1916 | // Otherwise create the new autosave as a special post revision. |
1917 | - return _wp_put_post_revision( $post_data, true ); |
|
1917 | + return _wp_put_post_revision($post_data, true); |
|
1918 | 1918 | } |
1919 | 1919 | |
1920 | 1920 | /** |
@@ -1929,51 +1929,51 @@ discard block |
||
1929 | 1929 | $post_ID = (int) $_POST['post_ID']; |
1930 | 1930 | $_POST['ID'] = $post_ID; |
1931 | 1931 | |
1932 | - $post = get_post( $post_ID ); |
|
1933 | - if ( ! $post ) { |
|
1934 | - wp_die( __( 'Sorry, you are not allowed to edit this post.' ) ); |
|
1932 | + $post = get_post($post_ID); |
|
1933 | + if (!$post) { |
|
1934 | + wp_die(__('Sorry, you are not allowed to edit this post.')); |
|
1935 | 1935 | } |
1936 | 1936 | |
1937 | - if ( ! current_user_can( 'edit_post', $post->ID ) ) { |
|
1938 | - wp_die( __( 'Sorry, you are not allowed to edit this post.' ) ); |
|
1937 | + if (!current_user_can('edit_post', $post->ID)) { |
|
1938 | + wp_die(__('Sorry, you are not allowed to edit this post.')); |
|
1939 | 1939 | } |
1940 | 1940 | |
1941 | 1941 | $is_autosave = false; |
1942 | 1942 | |
1943 | - if ( ! wp_check_post_lock( $post->ID ) && get_current_user_id() == $post->post_author |
|
1944 | - && ( 'draft' === $post->post_status || 'auto-draft' === $post->post_status ) |
|
1943 | + if (!wp_check_post_lock($post->ID) && get_current_user_id() == $post->post_author |
|
1944 | + && ('draft' === $post->post_status || 'auto-draft' === $post->post_status) |
|
1945 | 1945 | ) { |
1946 | 1946 | $saved_post_id = edit_post(); |
1947 | 1947 | } else { |
1948 | 1948 | $is_autosave = true; |
1949 | 1949 | |
1950 | - if ( isset( $_POST['post_status'] ) && 'auto-draft' === $_POST['post_status'] ) { |
|
1950 | + if (isset($_POST['post_status']) && 'auto-draft' === $_POST['post_status']) { |
|
1951 | 1951 | $_POST['post_status'] = 'draft'; |
1952 | 1952 | } |
1953 | 1953 | |
1954 | - $saved_post_id = wp_create_post_autosave( $post->ID ); |
|
1954 | + $saved_post_id = wp_create_post_autosave($post->ID); |
|
1955 | 1955 | } |
1956 | 1956 | |
1957 | - if ( is_wp_error( $saved_post_id ) ) { |
|
1958 | - wp_die( $saved_post_id->get_error_message() ); |
|
1957 | + if (is_wp_error($saved_post_id)) { |
|
1958 | + wp_die($saved_post_id->get_error_message()); |
|
1959 | 1959 | } |
1960 | 1960 | |
1961 | 1961 | $query_args = array(); |
1962 | 1962 | |
1963 | - if ( $is_autosave && $saved_post_id ) { |
|
1963 | + if ($is_autosave && $saved_post_id) { |
|
1964 | 1964 | $query_args['preview_id'] = $post->ID; |
1965 | - $query_args['preview_nonce'] = wp_create_nonce( 'post_preview_' . $post->ID ); |
|
1965 | + $query_args['preview_nonce'] = wp_create_nonce('post_preview_' . $post->ID); |
|
1966 | 1966 | |
1967 | - if ( isset( $_POST['post_format'] ) ) { |
|
1968 | - $query_args['post_format'] = empty( $_POST['post_format'] ) ? 'standard' : sanitize_key( $_POST['post_format'] ); |
|
1967 | + if (isset($_POST['post_format'])) { |
|
1968 | + $query_args['post_format'] = empty($_POST['post_format']) ? 'standard' : sanitize_key($_POST['post_format']); |
|
1969 | 1969 | } |
1970 | 1970 | |
1971 | - if ( isset( $_POST['_thumbnail_id'] ) ) { |
|
1972 | - $query_args['_thumbnail_id'] = ( (int) $_POST['_thumbnail_id'] <= 0 ) ? '-1' : (int) $_POST['_thumbnail_id']; |
|
1971 | + if (isset($_POST['_thumbnail_id'])) { |
|
1972 | + $query_args['_thumbnail_id'] = ((int) $_POST['_thumbnail_id'] <= 0) ? '-1' : (int) $_POST['_thumbnail_id']; |
|
1973 | 1973 | } |
1974 | 1974 | } |
1975 | 1975 | |
1976 | - return get_preview_post_link( $post, $query_args ); |
|
1976 | + return get_preview_post_link($post, $query_args); |
|
1977 | 1977 | } |
1978 | 1978 | |
1979 | 1979 | /** |
@@ -1987,43 +1987,43 @@ discard block |
||
1987 | 1987 | * @return mixed The value 0 or WP_Error on failure. The saved post ID on success. |
1988 | 1988 | * The ID can be the draft post_id or the autosave revision post_id. |
1989 | 1989 | */ |
1990 | -function wp_autosave( $post_data ) { |
|
1990 | +function wp_autosave($post_data) { |
|
1991 | 1991 | // Back-compat. |
1992 | - if ( ! defined( 'DOING_AUTOSAVE' ) ) { |
|
1993 | - define( 'DOING_AUTOSAVE', true ); |
|
1992 | + if (!defined('DOING_AUTOSAVE')) { |
|
1993 | + define('DOING_AUTOSAVE', true); |
|
1994 | 1994 | } |
1995 | 1995 | |
1996 | 1996 | $post_id = (int) $post_data['post_id']; |
1997 | 1997 | $post_data['ID'] = $post_id; |
1998 | 1998 | $post_data['post_ID'] = $post_id; |
1999 | 1999 | |
2000 | - if ( false === wp_verify_nonce( $post_data['_wpnonce'], 'update-post_' . $post_id ) ) { |
|
2001 | - return new WP_Error( 'invalid_nonce', __( 'Error while saving.' ) ); |
|
2000 | + if (false === wp_verify_nonce($post_data['_wpnonce'], 'update-post_' . $post_id)) { |
|
2001 | + return new WP_Error('invalid_nonce', __('Error while saving.')); |
|
2002 | 2002 | } |
2003 | 2003 | |
2004 | - $post = get_post( $post_id ); |
|
2004 | + $post = get_post($post_id); |
|
2005 | 2005 | |
2006 | - if ( ! current_user_can( 'edit_post', $post->ID ) ) { |
|
2007 | - return new WP_Error( 'edit_posts', __( 'Sorry, you are not allowed to edit this item.' ) ); |
|
2006 | + if (!current_user_can('edit_post', $post->ID)) { |
|
2007 | + return new WP_Error('edit_posts', __('Sorry, you are not allowed to edit this item.')); |
|
2008 | 2008 | } |
2009 | 2009 | |
2010 | - if ( 'auto-draft' === $post->post_status ) { |
|
2010 | + if ('auto-draft' === $post->post_status) { |
|
2011 | 2011 | $post_data['post_status'] = 'draft'; |
2012 | 2012 | } |
2013 | 2013 | |
2014 | - if ( 'page' !== $post_data['post_type'] && ! empty( $post_data['catslist'] ) ) { |
|
2015 | - $post_data['post_category'] = explode( ',', $post_data['catslist'] ); |
|
2014 | + if ('page' !== $post_data['post_type'] && !empty($post_data['catslist'])) { |
|
2015 | + $post_data['post_category'] = explode(',', $post_data['catslist']); |
|
2016 | 2016 | } |
2017 | 2017 | |
2018 | - if ( ! wp_check_post_lock( $post->ID ) && get_current_user_id() == $post->post_author |
|
2019 | - && ( 'auto-draft' === $post->post_status || 'draft' === $post->post_status ) |
|
2018 | + if (!wp_check_post_lock($post->ID) && get_current_user_id() == $post->post_author |
|
2019 | + && ('auto-draft' === $post->post_status || 'draft' === $post->post_status) |
|
2020 | 2020 | ) { |
2021 | 2021 | // Drafts and auto-drafts are just overwritten by autosave for the same user if the post is not locked. |
2022 | - return edit_post( wp_slash( $post_data ) ); |
|
2022 | + return edit_post(wp_slash($post_data)); |
|
2023 | 2023 | } else { |
2024 | 2024 | // Non-drafts or other users' drafts are not overwritten. |
2025 | 2025 | // The autosave is stored in a special post revision for each user. |
2026 | - return wp_create_post_autosave( wp_slash( $post_data ) ); |
|
2026 | + return wp_create_post_autosave(wp_slash($post_data)); |
|
2027 | 2027 | } |
2028 | 2028 | } |
2029 | 2029 | |
@@ -2034,12 +2034,12 @@ discard block |
||
2034 | 2034 | * |
2035 | 2035 | * @param int $post_id Optional. Post ID. |
2036 | 2036 | */ |
2037 | -function redirect_post( $post_id = '' ) { |
|
2038 | - if ( isset( $_POST['save'] ) || isset( $_POST['publish'] ) ) { |
|
2039 | - $status = get_post_status( $post_id ); |
|
2037 | +function redirect_post($post_id = '') { |
|
2038 | + if (isset($_POST['save']) || isset($_POST['publish'])) { |
|
2039 | + $status = get_post_status($post_id); |
|
2040 | 2040 | |
2041 | - if ( isset( $_POST['publish'] ) ) { |
|
2042 | - switch ( $status ) { |
|
2041 | + if (isset($_POST['publish'])) { |
|
2042 | + switch ($status) { |
|
2043 | 2043 | case 'pending': |
2044 | 2044 | $message = 8; |
2045 | 2045 | break; |
@@ -2053,17 +2053,17 @@ discard block |
||
2053 | 2053 | $message = 'draft' === $status ? 10 : 1; |
2054 | 2054 | } |
2055 | 2055 | |
2056 | - $location = add_query_arg( 'message', $message, get_edit_post_link( $post_id, 'url' ) ); |
|
2057 | - } elseif ( isset( $_POST['addmeta'] ) && $_POST['addmeta'] ) { |
|
2058 | - $location = add_query_arg( 'message', 2, wp_get_referer() ); |
|
2059 | - $location = explode( '#', $location ); |
|
2056 | + $location = add_query_arg('message', $message, get_edit_post_link($post_id, 'url')); |
|
2057 | + } elseif (isset($_POST['addmeta']) && $_POST['addmeta']) { |
|
2058 | + $location = add_query_arg('message', 2, wp_get_referer()); |
|
2059 | + $location = explode('#', $location); |
|
2060 | 2060 | $location = $location[0] . '#postcustom'; |
2061 | - } elseif ( isset( $_POST['deletemeta'] ) && $_POST['deletemeta'] ) { |
|
2062 | - $location = add_query_arg( 'message', 3, wp_get_referer() ); |
|
2063 | - $location = explode( '#', $location ); |
|
2061 | + } elseif (isset($_POST['deletemeta']) && $_POST['deletemeta']) { |
|
2062 | + $location = add_query_arg('message', 3, wp_get_referer()); |
|
2063 | + $location = explode('#', $location); |
|
2064 | 2064 | $location = $location[0] . '#postcustom'; |
2065 | 2065 | } else { |
2066 | - $location = add_query_arg( 'message', 4, get_edit_post_link( $post_id, 'url' ) ); |
|
2066 | + $location = add_query_arg('message', 4, get_edit_post_link($post_id, 'url')); |
|
2067 | 2067 | } |
2068 | 2068 | |
2069 | 2069 | /** |
@@ -2074,7 +2074,7 @@ discard block |
||
2074 | 2074 | * @param string $location The destination URL. |
2075 | 2075 | * @param int $post_id The post ID. |
2076 | 2076 | */ |
2077 | - wp_redirect( apply_filters( 'redirect_post_location', $location, $post_id ) ); |
|
2077 | + wp_redirect(apply_filters('redirect_post_location', $location, $post_id)); |
|
2078 | 2078 | exit; |
2079 | 2079 | } |
2080 | 2080 | |
@@ -2087,8 +2087,8 @@ discard block |
||
2087 | 2087 | * @param array $terms Raw term data from the 'tax_input' field. |
2088 | 2088 | * @return int[] Array of sanitized term IDs. |
2089 | 2089 | */ |
2090 | -function taxonomy_meta_box_sanitize_cb_checkboxes( $taxonomy, $terms ) { |
|
2091 | - return array_map( 'intval', $terms ); |
|
2090 | +function taxonomy_meta_box_sanitize_cb_checkboxes($taxonomy, $terms) { |
|
2091 | + return array_map('intval', $terms); |
|
2092 | 2092 | } |
2093 | 2093 | |
2094 | 2094 | /** |
@@ -2100,24 +2100,24 @@ discard block |
||
2100 | 2100 | * @param array|string $terms Raw term data from the 'tax_input' field. |
2101 | 2101 | * @return array |
2102 | 2102 | */ |
2103 | -function taxonomy_meta_box_sanitize_cb_input( $taxonomy, $terms ) { |
|
2103 | +function taxonomy_meta_box_sanitize_cb_input($taxonomy, $terms) { |
|
2104 | 2104 | /* |
2105 | 2105 | * Assume that a 'tax_input' string is a comma-separated list of term names. |
2106 | 2106 | * Some languages may use a character other than a comma as a delimiter, so we standardize on |
2107 | 2107 | * commas before parsing the list. |
2108 | 2108 | */ |
2109 | - if ( ! is_array( $terms ) ) { |
|
2110 | - $comma = _x( ',', 'tag delimiter' ); |
|
2111 | - if ( ',' !== $comma ) { |
|
2112 | - $terms = str_replace( $comma, ',', $terms ); |
|
2109 | + if (!is_array($terms)) { |
|
2110 | + $comma = _x(',', 'tag delimiter'); |
|
2111 | + if (',' !== $comma) { |
|
2112 | + $terms = str_replace($comma, ',', $terms); |
|
2113 | 2113 | } |
2114 | - $terms = explode( ',', trim( $terms, " \n\t\r\0\x0B," ) ); |
|
2114 | + $terms = explode(',', trim($terms, " \n\t\r\0\x0B,")); |
|
2115 | 2115 | } |
2116 | 2116 | |
2117 | 2117 | $clean_terms = array(); |
2118 | - foreach ( $terms as $term ) { |
|
2118 | + foreach ($terms as $term) { |
|
2119 | 2119 | // Empty terms are invalid input. |
2120 | - if ( empty( $term ) ) { |
|
2120 | + if (empty($term)) { |
|
2121 | 2121 | continue; |
2122 | 2122 | } |
2123 | 2123 | |
@@ -2130,7 +2130,7 @@ discard block |
||
2130 | 2130 | ) |
2131 | 2131 | ); |
2132 | 2132 | |
2133 | - if ( ! empty( $_term ) ) { |
|
2133 | + if (!empty($_term)) { |
|
2134 | 2134 | $clean_terms[] = (int) $_term[0]; |
2135 | 2135 | } else { |
2136 | 2136 | // No existing term was found, so pass the string. A new term will be created. |
@@ -2149,20 +2149,20 @@ discard block |
||
2149 | 2149 | * @param int|WP_Post $post Post ID or WP_Post object. |
2150 | 2150 | * @return bool Whether the post can be edited in the block editor. |
2151 | 2151 | */ |
2152 | -function use_block_editor_for_post( $post ) { |
|
2153 | - $post = get_post( $post ); |
|
2152 | +function use_block_editor_for_post($post) { |
|
2153 | + $post = get_post($post); |
|
2154 | 2154 | |
2155 | - if ( ! $post ) { |
|
2155 | + if (!$post) { |
|
2156 | 2156 | return false; |
2157 | 2157 | } |
2158 | 2158 | |
2159 | 2159 | // We're in the meta box loader, so don't use the block editor. |
2160 | - if ( isset( $_GET['meta-box-loader'] ) ) { |
|
2161 | - check_admin_referer( 'meta-box-loader', 'meta-box-loader-nonce' ); |
|
2160 | + if (isset($_GET['meta-box-loader'])) { |
|
2161 | + check_admin_referer('meta-box-loader', 'meta-box-loader-nonce'); |
|
2162 | 2162 | return false; |
2163 | 2163 | } |
2164 | 2164 | |
2165 | - $use_block_editor = use_block_editor_for_post_type( $post->post_type ); |
|
2165 | + $use_block_editor = use_block_editor_for_post_type($post->post_type); |
|
2166 | 2166 | |
2167 | 2167 | /** |
2168 | 2168 | * Filters whether a post is able to be edited in the block editor. |
@@ -2172,7 +2172,7 @@ discard block |
||
2172 | 2172 | * @param bool $use_block_editor Whether the post can be edited or not. |
2173 | 2173 | * @param WP_Post $post The post being checked. |
2174 | 2174 | */ |
2175 | - return apply_filters( 'use_block_editor_for_post', $use_block_editor, $post ); |
|
2175 | + return apply_filters('use_block_editor_for_post', $use_block_editor, $post); |
|
2176 | 2176 | } |
2177 | 2177 | |
2178 | 2178 | /** |
@@ -2186,17 +2186,17 @@ discard block |
||
2186 | 2186 | * @param string $post_type The post type. |
2187 | 2187 | * @return bool Whether the post type can be edited with the block editor. |
2188 | 2188 | */ |
2189 | -function use_block_editor_for_post_type( $post_type ) { |
|
2190 | - if ( ! post_type_exists( $post_type ) ) { |
|
2189 | +function use_block_editor_for_post_type($post_type) { |
|
2190 | + if (!post_type_exists($post_type)) { |
|
2191 | 2191 | return false; |
2192 | 2192 | } |
2193 | 2193 | |
2194 | - if ( ! post_type_supports( $post_type, 'editor' ) ) { |
|
2194 | + if (!post_type_supports($post_type, 'editor')) { |
|
2195 | 2195 | return false; |
2196 | 2196 | } |
2197 | 2197 | |
2198 | - $post_type_object = get_post_type_object( $post_type ); |
|
2199 | - if ( $post_type_object && ! $post_type_object->show_in_rest ) { |
|
2198 | + $post_type_object = get_post_type_object($post_type); |
|
2199 | + if ($post_type_object && !$post_type_object->show_in_rest) { |
|
2200 | 2200 | return false; |
2201 | 2201 | } |
2202 | 2202 | |
@@ -2208,7 +2208,7 @@ discard block |
||
2208 | 2208 | * @param bool $use_block_editor Whether the post type can be edited or not. Default true. |
2209 | 2209 | * @param string $post_type The post type being checked. |
2210 | 2210 | */ |
2211 | - return apply_filters( 'use_block_editor_for_post_type', true, $post_type ); |
|
2211 | + return apply_filters('use_block_editor_for_post_type', true, $post_type); |
|
2212 | 2212 | } |
2213 | 2213 | |
2214 | 2214 | /** |
@@ -2243,17 +2243,17 @@ discard block |
||
2243 | 2243 | 'variations' => 'variations', |
2244 | 2244 | ); |
2245 | 2245 | |
2246 | - foreach ( $block_registry->get_all_registered() as $block_name => $block_type ) { |
|
2247 | - foreach ( $fields_to_pick as $field => $key ) { |
|
2248 | - if ( ! isset( $block_type->{ $field } ) ) { |
|
2246 | + foreach ($block_registry->get_all_registered() as $block_name => $block_type) { |
|
2247 | + foreach ($fields_to_pick as $field => $key) { |
|
2248 | + if (!isset($block_type->{ $field } )) { |
|
2249 | 2249 | continue; |
2250 | 2250 | } |
2251 | 2251 | |
2252 | - if ( ! isset( $blocks[ $block_name ] ) ) { |
|
2253 | - $blocks[ $block_name ] = array(); |
|
2252 | + if (!isset($blocks[$block_name])) { |
|
2253 | + $blocks[$block_name] = array(); |
|
2254 | 2254 | } |
2255 | 2255 | |
2256 | - $blocks[ $block_name ][ $key ] = $block_type->{ $field }; |
|
2256 | + $blocks[$block_name][$key] = $block_type->{ $field }; |
|
2257 | 2257 | } |
2258 | 2258 | } |
2259 | 2259 | |
@@ -2281,21 +2281,21 @@ discard block |
||
2281 | 2281 | * |
2282 | 2282 | * @param array $wp_meta_boxes Global meta box state. |
2283 | 2283 | */ |
2284 | - $wp_meta_boxes = apply_filters( 'filter_block_editor_meta_boxes', $wp_meta_boxes ); |
|
2285 | - $locations = array( 'side', 'normal', 'advanced' ); |
|
2286 | - $priorities = array( 'high', 'sorted', 'core', 'default', 'low' ); |
|
2284 | + $wp_meta_boxes = apply_filters('filter_block_editor_meta_boxes', $wp_meta_boxes); |
|
2285 | + $locations = array('side', 'normal', 'advanced'); |
|
2286 | + $priorities = array('high', 'sorted', 'core', 'default', 'low'); |
|
2287 | 2287 | |
2288 | 2288 | // Render meta boxes. |
2289 | 2289 | ?> |
2290 | 2290 | <form class="metabox-base-form"> |
2291 | - <?php the_block_editor_meta_box_post_form_hidden_fields( $post ); ?> |
|
2291 | + <?php the_block_editor_meta_box_post_form_hidden_fields($post); ?> |
|
2292 | 2292 | </form> |
2293 | - <form id="toggle-custom-fields-form" method="post" action="<?php echo esc_url( admin_url( 'post.php' ) ); ?>"> |
|
2294 | - <?php wp_nonce_field( 'toggle-custom-fields', 'toggle-custom-fields-nonce' ); ?> |
|
2293 | + <form id="toggle-custom-fields-form" method="post" action="<?php echo esc_url(admin_url('post.php')); ?>"> |
|
2294 | + <?php wp_nonce_field('toggle-custom-fields', 'toggle-custom-fields-nonce'); ?> |
|
2295 | 2295 | <input type="hidden" name="action" value="toggle-custom-fields" /> |
2296 | 2296 | </form> |
2297 | - <?php foreach ( $locations as $location ) : ?> |
|
2298 | - <form class="metabox-location-<?php echo esc_attr( $location ); ?>" onsubmit="return false;"> |
|
2297 | + <?php foreach ($locations as $location) : ?> |
|
2298 | + <form class="metabox-location-<?php echo esc_attr($location); ?>" onsubmit="return false;"> |
|
2299 | 2299 | <div id="poststuff" class="sidebar-open"> |
2300 | 2300 | <div id="postbox-container-2" class="postbox-container"> |
2301 | 2301 | <?php |
@@ -2312,30 +2312,30 @@ discard block |
||
2312 | 2312 | <?php |
2313 | 2313 | |
2314 | 2314 | $meta_boxes_per_location = array(); |
2315 | - foreach ( $locations as $location ) { |
|
2316 | - $meta_boxes_per_location[ $location ] = array(); |
|
2315 | + foreach ($locations as $location) { |
|
2316 | + $meta_boxes_per_location[$location] = array(); |
|
2317 | 2317 | |
2318 | - if ( ! isset( $wp_meta_boxes[ $current_screen->id ][ $location ] ) ) { |
|
2318 | + if (!isset($wp_meta_boxes[$current_screen->id][$location])) { |
|
2319 | 2319 | continue; |
2320 | 2320 | } |
2321 | 2321 | |
2322 | - foreach ( $priorities as $priority ) { |
|
2323 | - if ( ! isset( $wp_meta_boxes[ $current_screen->id ][ $location ][ $priority ] ) ) { |
|
2322 | + foreach ($priorities as $priority) { |
|
2323 | + if (!isset($wp_meta_boxes[$current_screen->id][$location][$priority])) { |
|
2324 | 2324 | continue; |
2325 | 2325 | } |
2326 | 2326 | |
2327 | - $meta_boxes = (array) $wp_meta_boxes[ $current_screen->id ][ $location ][ $priority ]; |
|
2328 | - foreach ( $meta_boxes as $meta_box ) { |
|
2329 | - if ( false == $meta_box || ! $meta_box['title'] ) { |
|
2327 | + $meta_boxes = (array) $wp_meta_boxes[$current_screen->id][$location][$priority]; |
|
2328 | + foreach ($meta_boxes as $meta_box) { |
|
2329 | + if (false == $meta_box || !$meta_box['title']) { |
|
2330 | 2330 | continue; |
2331 | 2331 | } |
2332 | 2332 | |
2333 | 2333 | // If a meta box is just here for back compat, don't show it in the block editor. |
2334 | - if ( isset( $meta_box['args']['__back_compat_meta_box'] ) && $meta_box['args']['__back_compat_meta_box'] ) { |
|
2334 | + if (isset($meta_box['args']['__back_compat_meta_box']) && $meta_box['args']['__back_compat_meta_box']) { |
|
2335 | 2335 | continue; |
2336 | 2336 | } |
2337 | 2337 | |
2338 | - $meta_boxes_per_location[ $location ][] = array( |
|
2338 | + $meta_boxes_per_location[$location][] = array( |
|
2339 | 2339 | 'id' => $meta_box['id'], |
2340 | 2340 | 'title' => $meta_box['title'], |
2341 | 2341 | ); |
@@ -2351,27 +2351,27 @@ discard block |
||
2351 | 2351 | * our editor instance. |
2352 | 2352 | */ |
2353 | 2353 | $script = 'window._wpLoadBlockEditor.then( function() { |
2354 | - wp.data.dispatch( \'core/edit-post\' ).setAvailableMetaBoxesPerLocation( ' . wp_json_encode( $meta_boxes_per_location ) . ' ); |
|
2354 | + wp.data.dispatch( \'core/edit-post\' ).setAvailableMetaBoxesPerLocation( ' . wp_json_encode($meta_boxes_per_location) . ' ); |
|
2355 | 2355 | } );'; |
2356 | 2356 | |
2357 | - wp_add_inline_script( 'wp-edit-post', $script ); |
|
2357 | + wp_add_inline_script('wp-edit-post', $script); |
|
2358 | 2358 | |
2359 | 2359 | /* |
2360 | 2360 | * When `wp-edit-post` is output in the `<head>`, the inline script needs to be manually printed. |
2361 | 2361 | * Otherwise, meta boxes will not display because inline scripts for `wp-edit-post` |
2362 | 2362 | * will not be printed again after this point. |
2363 | 2363 | */ |
2364 | - if ( wp_script_is( 'wp-edit-post', 'done' ) ) { |
|
2365 | - printf( "<script type='text/javascript'>\n%s\n</script>\n", trim( $script ) ); |
|
2364 | + if (wp_script_is('wp-edit-post', 'done')) { |
|
2365 | + printf("<script type='text/javascript'>\n%s\n</script>\n", trim($script)); |
|
2366 | 2366 | } |
2367 | 2367 | |
2368 | 2368 | /* |
2369 | 2369 | * If the 'postcustom' meta box is enabled, then we need to perform |
2370 | 2370 | * some extra initialization on it. |
2371 | 2371 | */ |
2372 | - $enable_custom_fields = (bool) get_user_meta( get_current_user_id(), 'enable_custom_fields', true ); |
|
2372 | + $enable_custom_fields = (bool) get_user_meta(get_current_user_id(), 'enable_custom_fields', true); |
|
2373 | 2373 | |
2374 | - if ( $enable_custom_fields ) { |
|
2374 | + if ($enable_custom_fields) { |
|
2375 | 2375 | $script = "( function( $ ) { |
2376 | 2376 | if ( $('#postcustom').length ) { |
2377 | 2377 | $( '#the-list' ).wpList( { |
@@ -2385,8 +2385,8 @@ discard block |
||
2385 | 2385 | }); |
2386 | 2386 | } |
2387 | 2387 | } )( jQuery );"; |
2388 | - wp_enqueue_script( 'wp-lists' ); |
|
2389 | - wp_add_inline_script( 'wp-lists', $script ); |
|
2388 | + wp_enqueue_script('wp-lists'); |
|
2389 | + wp_add_inline_script('wp-lists', $script); |
|
2390 | 2390 | } |
2391 | 2391 | |
2392 | 2392 | // Reset meta box data. |
@@ -2400,18 +2400,18 @@ discard block |
||
2400 | 2400 | * |
2401 | 2401 | * @param WP_Post $post Current post object. |
2402 | 2402 | */ |
2403 | -function the_block_editor_meta_box_post_form_hidden_fields( $post ) { |
|
2403 | +function the_block_editor_meta_box_post_form_hidden_fields($post) { |
|
2404 | 2404 | $form_extra = ''; |
2405 | - if ( 'auto-draft' === $post->post_status ) { |
|
2405 | + if ('auto-draft' === $post->post_status) { |
|
2406 | 2406 | $form_extra .= "<input type='hidden' id='auto_draft' name='auto_draft' value='1' />"; |
2407 | 2407 | } |
2408 | 2408 | $form_action = 'editpost'; |
2409 | 2409 | $nonce_action = 'update-post_' . $post->ID; |
2410 | - $form_extra .= "<input type='hidden' id='post_ID' name='post_ID' value='" . esc_attr( $post->ID ) . "' />"; |
|
2410 | + $form_extra .= "<input type='hidden' id='post_ID' name='post_ID' value='" . esc_attr($post->ID) . "' />"; |
|
2411 | 2411 | $referer = wp_get_referer(); |
2412 | 2412 | $current_user = wp_get_current_user(); |
2413 | 2413 | $user_id = $current_user->ID; |
2414 | - wp_nonce_field( $nonce_action ); |
|
2414 | + wp_nonce_field($nonce_action); |
|
2415 | 2415 | |
2416 | 2416 | /* |
2417 | 2417 | * Some meta boxes hook into these actions to add hidden input fields in the classic post form. |
@@ -2420,39 +2420,39 @@ discard block |
||
2420 | 2420 | */ |
2421 | 2421 | ob_start(); |
2422 | 2422 | /** This filter is documented in wp-admin/edit-form-advanced.php */ |
2423 | - do_action( 'edit_form_after_title', $post ); |
|
2423 | + do_action('edit_form_after_title', $post); |
|
2424 | 2424 | /** This filter is documented in wp-admin/edit-form-advanced.php */ |
2425 | - do_action( 'edit_form_advanced', $post ); |
|
2425 | + do_action('edit_form_advanced', $post); |
|
2426 | 2426 | $classic_output = ob_get_clean(); |
2427 | 2427 | |
2428 | - $classic_elements = wp_html_split( $classic_output ); |
|
2428 | + $classic_elements = wp_html_split($classic_output); |
|
2429 | 2429 | $hidden_inputs = ''; |
2430 | - foreach ( $classic_elements as $element ) { |
|
2431 | - if ( 0 !== strpos( $element, '<input ' ) ) { |
|
2430 | + foreach ($classic_elements as $element) { |
|
2431 | + if (0 !== strpos($element, '<input ')) { |
|
2432 | 2432 | continue; |
2433 | 2433 | } |
2434 | 2434 | |
2435 | - if ( preg_match( '/\stype=[\'"]hidden[\'"]\s/', $element ) ) { |
|
2435 | + if (preg_match('/\stype=[\'"]hidden[\'"]\s/', $element)) { |
|
2436 | 2436 | echo $element; |
2437 | 2437 | } |
2438 | 2438 | } |
2439 | 2439 | ?> |
2440 | 2440 | <input type="hidden" id="user-id" name="user_ID" value="<?php echo (int) $user_id; ?>" /> |
2441 | - <input type="hidden" id="hiddenaction" name="action" value="<?php echo esc_attr( $form_action ); ?>" /> |
|
2442 | - <input type="hidden" id="originalaction" name="originalaction" value="<?php echo esc_attr( $form_action ); ?>" /> |
|
2443 | - <input type="hidden" id="post_type" name="post_type" value="<?php echo esc_attr( $post->post_type ); ?>" /> |
|
2444 | - <input type="hidden" id="original_post_status" name="original_post_status" value="<?php echo esc_attr( $post->post_status ); ?>" /> |
|
2445 | - <input type="hidden" id="referredby" name="referredby" value="<?php echo $referer ? esc_url( $referer ) : ''; ?>" /> |
|
2441 | + <input type="hidden" id="hiddenaction" name="action" value="<?php echo esc_attr($form_action); ?>" /> |
|
2442 | + <input type="hidden" id="originalaction" name="originalaction" value="<?php echo esc_attr($form_action); ?>" /> |
|
2443 | + <input type="hidden" id="post_type" name="post_type" value="<?php echo esc_attr($post->post_type); ?>" /> |
|
2444 | + <input type="hidden" id="original_post_status" name="original_post_status" value="<?php echo esc_attr($post->post_status); ?>" /> |
|
2445 | + <input type="hidden" id="referredby" name="referredby" value="<?php echo $referer ? esc_url($referer) : ''; ?>" /> |
|
2446 | 2446 | |
2447 | 2447 | <?php |
2448 | - if ( 'draft' !== get_post_status( $post ) ) { |
|
2449 | - wp_original_referer_field( true, 'previous' ); |
|
2448 | + if ('draft' !== get_post_status($post)) { |
|
2449 | + wp_original_referer_field(true, 'previous'); |
|
2450 | 2450 | } |
2451 | 2451 | echo $form_extra; |
2452 | - wp_nonce_field( 'meta-box-order', 'meta-box-order-nonce', false ); |
|
2453 | - wp_nonce_field( 'closedpostboxes', 'closedpostboxesnonce', false ); |
|
2452 | + wp_nonce_field('meta-box-order', 'meta-box-order-nonce', false); |
|
2453 | + wp_nonce_field('closedpostboxes', 'closedpostboxesnonce', false); |
|
2454 | 2454 | // Permalink title nonce. |
2455 | - wp_nonce_field( 'samplepermalink', 'samplepermalinknonce', false ); |
|
2455 | + wp_nonce_field('samplepermalink', 'samplepermalinknonce', false); |
|
2456 | 2456 | |
2457 | 2457 | /** |
2458 | 2458 | * Adds hidden input fields to the meta box save form. |
@@ -2464,7 +2464,7 @@ discard block |
||
2464 | 2464 | * |
2465 | 2465 | * @param WP_Post $post The post that is being edited. |
2466 | 2466 | */ |
2467 | - do_action( 'block_editor_meta_box_hidden_fields', $post ); |
|
2467 | + do_action('block_editor_meta_box_hidden_fields', $post); |
|
2468 | 2468 | } |
2469 | 2469 | |
2470 | 2470 | /** |
@@ -2477,8 +2477,8 @@ discard block |
||
2477 | 2477 | * @param string $post_type Post type. |
2478 | 2478 | * @return bool Whether the block editor should be disabled or not. |
2479 | 2479 | */ |
2480 | -function _disable_block_editor_for_navigation_post_type( $value, $post_type ) { |
|
2481 | - if ( 'wp_navigation' === $post_type ) { |
|
2480 | +function _disable_block_editor_for_navigation_post_type($value, $post_type) { |
|
2481 | + if ('wp_navigation' === $post_type) { |
|
2482 | 2482 | return false; |
2483 | 2483 | } |
2484 | 2484 | |
@@ -2496,13 +2496,13 @@ discard block |
||
2496 | 2496 | * |
2497 | 2497 | * @param WP_Post $post An instance of WP_Post class. |
2498 | 2498 | */ |
2499 | -function _disable_content_editor_for_navigation_post_type( $post ) { |
|
2500 | - $post_type = get_post_type( $post ); |
|
2501 | - if ( 'wp_navigation' !== $post_type ) { |
|
2499 | +function _disable_content_editor_for_navigation_post_type($post) { |
|
2500 | + $post_type = get_post_type($post); |
|
2501 | + if ('wp_navigation' !== $post_type) { |
|
2502 | 2502 | return; |
2503 | 2503 | } |
2504 | 2504 | |
2505 | - remove_post_type_support( $post_type, 'editor' ); |
|
2505 | + remove_post_type_support($post_type, 'editor'); |
|
2506 | 2506 | } |
2507 | 2507 | |
2508 | 2508 | /** |
@@ -2517,11 +2517,11 @@ discard block |
||
2517 | 2517 | * |
2518 | 2518 | * @param WP_Post $post An instance of WP_Post class. |
2519 | 2519 | */ |
2520 | -function _enable_content_editor_for_navigation_post_type( $post ) { |
|
2521 | - $post_type = get_post_type( $post ); |
|
2522 | - if ( 'wp_navigation' !== $post_type ) { |
|
2520 | +function _enable_content_editor_for_navigation_post_type($post) { |
|
2521 | + $post_type = get_post_type($post); |
|
2522 | + if ('wp_navigation' !== $post_type) { |
|
2523 | 2523 | return; |
2524 | 2524 | } |
2525 | 2525 | |
2526 | - add_post_type_support( $post_type, 'editor' ); |
|
2526 | + add_post_type_support($post_type, 'editor'); |
|
2527 | 2527 | } |
@@ -37,18 +37,18 @@ discard block |
||
37 | 37 | * |
38 | 38 | * @param array $args An associative array of arguments. |
39 | 39 | */ |
40 | - public function __construct( $args = array() ) { |
|
41 | - $this->detached = ( isset( $_REQUEST['attachment-filter'] ) && 'detached' === $_REQUEST['attachment-filter'] ); |
|
40 | + public function __construct($args = array()) { |
|
41 | + $this->detached = (isset($_REQUEST['attachment-filter']) && 'detached' === $_REQUEST['attachment-filter']); |
|
42 | 42 | |
43 | 43 | $this->modes = array( |
44 | - 'list' => __( 'List view' ), |
|
45 | - 'grid' => __( 'Grid view' ), |
|
44 | + 'list' => __('List view'), |
|
45 | + 'grid' => __('Grid view'), |
|
46 | 46 | ); |
47 | 47 | |
48 | 48 | parent::__construct( |
49 | 49 | array( |
50 | 50 | 'plural' => 'media', |
51 | - 'screen' => isset( $args['screen'] ) ? $args['screen'] : null, |
|
51 | + 'screen' => isset($args['screen']) ? $args['screen'] : null, |
|
52 | 52 | ) |
53 | 53 | ); |
54 | 54 | } |
@@ -57,7 +57,7 @@ discard block |
||
57 | 57 | * @return bool |
58 | 58 | */ |
59 | 59 | public function ajax_user_can() { |
60 | - return current_user_can( 'upload_files' ); |
|
60 | + return current_user_can('upload_files'); |
|
61 | 61 | } |
62 | 62 | |
63 | 63 | /** |
@@ -69,7 +69,7 @@ discard block |
||
69 | 69 | public function prepare_items() { |
70 | 70 | global $mode, $wp_query, $post_mime_types, $avail_post_mime_types; |
71 | 71 | |
72 | - $mode = empty( $_REQUEST['mode'] ) ? 'list' : $_REQUEST['mode']; |
|
72 | + $mode = empty($_REQUEST['mode']) ? 'list' : $_REQUEST['mode']; |
|
73 | 73 | |
74 | 74 | /* |
75 | 75 | * Exclude attachments scheduled for deletion in the next two hours |
@@ -80,29 +80,29 @@ discard block |
||
80 | 80 | |
81 | 81 | $crons = _get_cron_array(); |
82 | 82 | |
83 | - if ( is_array( $crons ) ) { |
|
84 | - foreach ( $crons as $cron ) { |
|
85 | - if ( isset( $cron['upgrader_scheduled_cleanup'] ) ) { |
|
86 | - $details = reset( $cron['upgrader_scheduled_cleanup'] ); |
|
83 | + if (is_array($crons)) { |
|
84 | + foreach ($crons as $cron) { |
|
85 | + if (isset($cron['upgrader_scheduled_cleanup'])) { |
|
86 | + $details = reset($cron['upgrader_scheduled_cleanup']); |
|
87 | 87 | |
88 | - if ( ! empty( $details['args'][0] ) ) { |
|
88 | + if (!empty($details['args'][0])) { |
|
89 | 89 | $not_in[] = (int) $details['args'][0]; |
90 | 90 | } |
91 | 91 | } |
92 | 92 | } |
93 | 93 | } |
94 | 94 | |
95 | - if ( ! empty( $_REQUEST['post__not_in'] ) && is_array( $_REQUEST['post__not_in'] ) ) { |
|
96 | - $not_in = array_merge( array_values( $_REQUEST['post__not_in'] ), $not_in ); |
|
95 | + if (!empty($_REQUEST['post__not_in']) && is_array($_REQUEST['post__not_in'])) { |
|
96 | + $not_in = array_merge(array_values($_REQUEST['post__not_in']), $not_in); |
|
97 | 97 | } |
98 | 98 | |
99 | - if ( ! empty( $not_in ) ) { |
|
99 | + if (!empty($not_in)) { |
|
100 | 100 | $_REQUEST['post__not_in'] = $not_in; |
101 | 101 | } |
102 | 102 | |
103 | - list( $post_mime_types, $avail_post_mime_types ) = wp_edit_attachments_query( $_REQUEST ); |
|
103 | + list($post_mime_types, $avail_post_mime_types) = wp_edit_attachments_query($_REQUEST); |
|
104 | 104 | |
105 | - $this->is_trash = isset( $_REQUEST['attachment-filter'] ) && 'trash' === $_REQUEST['attachment-filter']; |
|
105 | + $this->is_trash = isset($_REQUEST['attachment-filter']) && 'trash' === $_REQUEST['attachment-filter']; |
|
106 | 106 | |
107 | 107 | $this->set_pagination_args( |
108 | 108 | array( |
@@ -123,47 +123,47 @@ discard block |
||
123 | 123 | |
124 | 124 | $type_links = array(); |
125 | 125 | |
126 | - $filter = empty( $_GET['attachment-filter'] ) ? '' : $_GET['attachment-filter']; |
|
126 | + $filter = empty($_GET['attachment-filter']) ? '' : $_GET['attachment-filter']; |
|
127 | 127 | |
128 | 128 | $type_links['all'] = sprintf( |
129 | 129 | '<option value=""%s>%s</option>', |
130 | - selected( $filter, true, false ), |
|
131 | - __( 'All media items' ) |
|
130 | + selected($filter, true, false), |
|
131 | + __('All media items') |
|
132 | 132 | ); |
133 | 133 | |
134 | - foreach ( $post_mime_types as $mime_type => $label ) { |
|
135 | - if ( ! wp_match_mime_types( $mime_type, $avail_post_mime_types ) ) { |
|
134 | + foreach ($post_mime_types as $mime_type => $label) { |
|
135 | + if (!wp_match_mime_types($mime_type, $avail_post_mime_types)) { |
|
136 | 136 | continue; |
137 | 137 | } |
138 | 138 | |
139 | 139 | $selected = selected( |
140 | - $filter && 0 === strpos( $filter, 'post_mime_type:' ) && |
|
141 | - wp_match_mime_types( $mime_type, str_replace( 'post_mime_type:', '', $filter ) ), |
|
140 | + $filter && 0 === strpos($filter, 'post_mime_type:') && |
|
141 | + wp_match_mime_types($mime_type, str_replace('post_mime_type:', '', $filter)), |
|
142 | 142 | true, |
143 | 143 | false |
144 | 144 | ); |
145 | 145 | |
146 | - $type_links[ $mime_type ] = sprintf( |
|
146 | + $type_links[$mime_type] = sprintf( |
|
147 | 147 | '<option value="post_mime_type:%s"%s>%s</option>', |
148 | - esc_attr( $mime_type ), |
|
148 | + esc_attr($mime_type), |
|
149 | 149 | $selected, |
150 | 150 | $label[0] |
151 | 151 | ); |
152 | 152 | } |
153 | 153 | |
154 | - $type_links['detached'] = '<option value="detached"' . ( $this->detached ? ' selected="selected"' : '' ) . '>' . _x( 'Unattached', 'media items' ) . '</option>'; |
|
154 | + $type_links['detached'] = '<option value="detached"' . ($this->detached ? ' selected="selected"' : '') . '>' . _x('Unattached', 'media items') . '</option>'; |
|
155 | 155 | |
156 | 156 | $type_links['mine'] = sprintf( |
157 | 157 | '<option value="mine"%s>%s</option>', |
158 | - selected( 'mine' === $filter, true, false ), |
|
159 | - _x( 'Mine', 'media items' ) |
|
158 | + selected('mine' === $filter, true, false), |
|
159 | + _x('Mine', 'media items') |
|
160 | 160 | ); |
161 | 161 | |
162 | - if ( $this->is_trash || ( defined( 'MEDIA_TRASH' ) && MEDIA_TRASH ) ) { |
|
162 | + if ($this->is_trash || (defined('MEDIA_TRASH') && MEDIA_TRASH)) { |
|
163 | 163 | $type_links['trash'] = sprintf( |
164 | 164 | '<option value="trash"%s>%s</option>', |
165 | - selected( 'trash' === $filter, true, false ), |
|
166 | - _x( 'Trash', 'attachment filter' ) |
|
165 | + selected('trash' === $filter, true, false), |
|
166 | + _x('Trash', 'attachment filter') |
|
167 | 167 | ); |
168 | 168 | } |
169 | 169 | |
@@ -176,19 +176,19 @@ discard block |
||
176 | 176 | protected function get_bulk_actions() { |
177 | 177 | $actions = array(); |
178 | 178 | |
179 | - if ( MEDIA_TRASH ) { |
|
180 | - if ( $this->is_trash ) { |
|
181 | - $actions['untrash'] = __( 'Restore' ); |
|
182 | - $actions['delete'] = __( 'Delete permanently' ); |
|
179 | + if (MEDIA_TRASH) { |
|
180 | + if ($this->is_trash) { |
|
181 | + $actions['untrash'] = __('Restore'); |
|
182 | + $actions['delete'] = __('Delete permanently'); |
|
183 | 183 | } else { |
184 | - $actions['trash'] = __( 'Move to Trash' ); |
|
184 | + $actions['trash'] = __('Move to Trash'); |
|
185 | 185 | } |
186 | 186 | } else { |
187 | - $actions['delete'] = __( 'Delete permanently' ); |
|
187 | + $actions['delete'] = __('Delete permanently'); |
|
188 | 188 | } |
189 | 189 | |
190 | - if ( $this->detached ) { |
|
191 | - $actions['attach'] = __( 'Attach' ); |
|
190 | + if ($this->detached) { |
|
191 | + $actions['attach'] = __('Attach'); |
|
192 | 192 | } |
193 | 193 | |
194 | 194 | return $actions; |
@@ -197,26 +197,26 @@ discard block |
||
197 | 197 | /** |
198 | 198 | * @param string $which |
199 | 199 | */ |
200 | - protected function extra_tablenav( $which ) { |
|
201 | - if ( 'bar' !== $which ) { |
|
200 | + protected function extra_tablenav($which) { |
|
201 | + if ('bar' !== $which) { |
|
202 | 202 | return; |
203 | 203 | } |
204 | 204 | ?> |
205 | 205 | <div class="actions"> |
206 | 206 | <?php |
207 | - if ( ! $this->is_trash ) { |
|
208 | - $this->months_dropdown( 'attachment' ); |
|
207 | + if (!$this->is_trash) { |
|
208 | + $this->months_dropdown('attachment'); |
|
209 | 209 | } |
210 | 210 | |
211 | 211 | /** This action is documented in wp-admin/includes/class-wp-posts-list-table.php */ |
212 | - do_action( 'restrict_manage_posts', $this->screen->post_type, $which ); |
|
212 | + do_action('restrict_manage_posts', $this->screen->post_type, $which); |
|
213 | 213 | |
214 | - submit_button( __( 'Filter' ), '', 'filter_action', false, array( 'id' => 'post-query-submit' ) ); |
|
214 | + submit_button(__('Filter'), '', 'filter_action', false, array('id' => 'post-query-submit')); |
|
215 | 215 | |
216 | - if ( $this->is_trash && $this->has_items() |
|
217 | - && current_user_can( 'edit_others_posts' ) |
|
216 | + if ($this->is_trash && $this->has_items() |
|
217 | + && current_user_can('edit_others_posts') |
|
218 | 218 | ) { |
219 | - submit_button( __( 'Empty Trash' ), 'apply', 'delete_all', false ); |
|
219 | + submit_button(__('Empty Trash'), 'apply', 'delete_all', false); |
|
220 | 220 | } |
221 | 221 | ?> |
222 | 222 | </div> |
@@ -227,15 +227,15 @@ discard block |
||
227 | 227 | * @return string |
228 | 228 | */ |
229 | 229 | public function current_action() { |
230 | - if ( isset( $_REQUEST['found_post_id'] ) && isset( $_REQUEST['media'] ) ) { |
|
230 | + if (isset($_REQUEST['found_post_id']) && isset($_REQUEST['media'])) { |
|
231 | 231 | return 'attach'; |
232 | 232 | } |
233 | 233 | |
234 | - if ( isset( $_REQUEST['parent_post_id'] ) && isset( $_REQUEST['media'] ) ) { |
|
234 | + if (isset($_REQUEST['parent_post_id']) && isset($_REQUEST['media'])) { |
|
235 | 235 | return 'detach'; |
236 | 236 | } |
237 | 237 | |
238 | - if ( isset( $_REQUEST['delete_all'] ) || isset( $_REQUEST['delete_all2'] ) ) { |
|
238 | + if (isset($_REQUEST['delete_all']) || isset($_REQUEST['delete_all2'])) { |
|
239 | 239 | return 'delete_all'; |
240 | 240 | } |
241 | 241 | |
@@ -252,10 +252,10 @@ discard block |
||
252 | 252 | /** |
253 | 253 | */ |
254 | 254 | public function no_items() { |
255 | - if ( $this->is_trash ) { |
|
256 | - _e( 'No media files found in Trash.' ); |
|
255 | + if ($this->is_trash) { |
|
256 | + _e('No media files found in Trash.'); |
|
257 | 257 | } else { |
258 | - _e( 'No media files found.' ); |
|
258 | + _e('No media files found.'); |
|
259 | 259 | } |
260 | 260 | } |
261 | 261 | |
@@ -269,17 +269,17 @@ discard block |
||
269 | 269 | |
270 | 270 | $views = $this->get_views(); |
271 | 271 | |
272 | - $this->screen->render_screen_reader_content( 'heading_views' ); |
|
272 | + $this->screen->render_screen_reader_content('heading_views'); |
|
273 | 273 | ?> |
274 | 274 | <div class="wp-filter"> |
275 | 275 | <div class="filter-items"> |
276 | - <?php $this->view_switcher( $mode ); ?> |
|
276 | + <?php $this->view_switcher($mode); ?> |
|
277 | 277 | |
278 | - <label for="attachment-filter" class="screen-reader-text"><?php _e( 'Filter by type' ); ?></label> |
|
278 | + <label for="attachment-filter" class="screen-reader-text"><?php _e('Filter by type'); ?></label> |
|
279 | 279 | <select class="attachment-filters" name="attachment-filter" id="attachment-filter"> |
280 | 280 | <?php |
281 | - if ( ! empty( $views ) ) { |
|
282 | - foreach ( $views as $class => $view ) { |
|
281 | + if (!empty($views)) { |
|
282 | + foreach ($views as $class => $view) { |
|
283 | 283 | echo "\t$view\n"; |
284 | 284 | } |
285 | 285 | } |
@@ -287,15 +287,15 @@ discard block |
||
287 | 287 | </select> |
288 | 288 | |
289 | 289 | <?php |
290 | - $this->extra_tablenav( 'bar' ); |
|
290 | + $this->extra_tablenav('bar'); |
|
291 | 291 | |
292 | 292 | /** This filter is documented in wp-admin/inclues/class-wp-list-table.php */ |
293 | - $views = apply_filters( "views_{$this->screen->id}", array() ); |
|
293 | + $views = apply_filters("views_{$this->screen->id}", array()); |
|
294 | 294 | |
295 | 295 | // Back compat for pre-4.0 view links. |
296 | - if ( ! empty( $views ) ) { |
|
296 | + if (!empty($views)) { |
|
297 | 297 | echo '<ul class="filter-links">'; |
298 | - foreach ( $views as $class => $view ) { |
|
298 | + foreach ($views as $class => $view) { |
|
299 | 299 | echo "<li class='$class'>$view</li>"; |
300 | 300 | } |
301 | 301 | echo '</ul>'; |
@@ -304,7 +304,7 @@ discard block |
||
304 | 304 | </div> |
305 | 305 | |
306 | 306 | <div class="search-form"> |
307 | - <label for="media-search-input" class="media-search-input-label"><?php esc_html_e( 'Search' ); ?></label> |
|
307 | + <label for="media-search-input" class="media-search-input-label"><?php esc_html_e('Search'); ?></label> |
|
308 | 308 | <input type="search" id="media-search-input" class="search" name="s" value="<?php _admin_search_query(); ?>"> |
309 | 309 | </div> |
310 | 310 | </div> |
@@ -318,11 +318,11 @@ discard block |
||
318 | 318 | $posts_columns = array(); |
319 | 319 | $posts_columns['cb'] = '<input type="checkbox" />'; |
320 | 320 | /* translators: Column name. */ |
321 | - $posts_columns['title'] = _x( 'File', 'column name' ); |
|
322 | - $posts_columns['author'] = __( 'Author' ); |
|
321 | + $posts_columns['title'] = _x('File', 'column name'); |
|
322 | + $posts_columns['author'] = __('Author'); |
|
323 | 323 | |
324 | - $taxonomies = get_taxonomies_for_attachments( 'objects' ); |
|
325 | - $taxonomies = wp_filter_object_list( $taxonomies, array( 'show_admin_column' => true ), 'and', 'name' ); |
|
324 | + $taxonomies = get_taxonomies_for_attachments('objects'); |
|
325 | + $taxonomies = wp_filter_object_list($taxonomies, array('show_admin_column' => true), 'and', 'name'); |
|
326 | 326 | |
327 | 327 | /** |
328 | 328 | * Filters the taxonomy columns for attachments in the Media list table. |
@@ -332,31 +332,31 @@ discard block |
||
332 | 332 | * @param string[] $taxonomies An array of registered taxonomy names to show for attachments. |
333 | 333 | * @param string $post_type The post type. Default 'attachment'. |
334 | 334 | */ |
335 | - $taxonomies = apply_filters( 'manage_taxonomies_for_attachment_columns', $taxonomies, 'attachment' ); |
|
336 | - $taxonomies = array_filter( $taxonomies, 'taxonomy_exists' ); |
|
335 | + $taxonomies = apply_filters('manage_taxonomies_for_attachment_columns', $taxonomies, 'attachment'); |
|
336 | + $taxonomies = array_filter($taxonomies, 'taxonomy_exists'); |
|
337 | 337 | |
338 | - foreach ( $taxonomies as $taxonomy ) { |
|
339 | - if ( 'category' === $taxonomy ) { |
|
338 | + foreach ($taxonomies as $taxonomy) { |
|
339 | + if ('category' === $taxonomy) { |
|
340 | 340 | $column_key = 'categories'; |
341 | - } elseif ( 'post_tag' === $taxonomy ) { |
|
341 | + } elseif ('post_tag' === $taxonomy) { |
|
342 | 342 | $column_key = 'tags'; |
343 | 343 | } else { |
344 | 344 | $column_key = 'taxonomy-' . $taxonomy; |
345 | 345 | } |
346 | 346 | |
347 | - $posts_columns[ $column_key ] = get_taxonomy( $taxonomy )->labels->name; |
|
347 | + $posts_columns[$column_key] = get_taxonomy($taxonomy)->labels->name; |
|
348 | 348 | } |
349 | 349 | |
350 | 350 | /* translators: Column name. */ |
351 | - if ( ! $this->detached ) { |
|
352 | - $posts_columns['parent'] = _x( 'Uploaded to', 'column name' ); |
|
353 | - if ( post_type_supports( 'attachment', 'comments' ) ) { |
|
354 | - $posts_columns['comments'] = '<span class="vers comment-grey-bubble" title="' . esc_attr__( 'Comments' ) . '"><span class="screen-reader-text">' . __( 'Comments' ) . '</span></span>'; |
|
351 | + if (!$this->detached) { |
|
352 | + $posts_columns['parent'] = _x('Uploaded to', 'column name'); |
|
353 | + if (post_type_supports('attachment', 'comments')) { |
|
354 | + $posts_columns['comments'] = '<span class="vers comment-grey-bubble" title="' . esc_attr__('Comments') . '"><span class="screen-reader-text">' . __('Comments') . '</span></span>'; |
|
355 | 355 | } |
356 | 356 | } |
357 | 357 | |
358 | 358 | /* translators: Column name. */ |
359 | - $posts_columns['date'] = _x( 'Date', 'column name' ); |
|
359 | + $posts_columns['date'] = _x('Date', 'column name'); |
|
360 | 360 | |
361 | 361 | /** |
362 | 362 | * Filters the Media list table columns. |
@@ -367,7 +367,7 @@ discard block |
||
367 | 367 | * @param bool $detached Whether the list table contains media not attached |
368 | 368 | * to any posts. Default true. |
369 | 369 | */ |
370 | - return apply_filters( 'manage_media_columns', $posts_columns, $this->detached ); |
|
370 | + return apply_filters('manage_media_columns', $posts_columns, $this->detached); |
|
371 | 371 | } |
372 | 372 | |
373 | 373 | /** |
@@ -379,7 +379,7 @@ discard block |
||
379 | 379 | 'author' => 'author', |
380 | 380 | 'parent' => 'parent', |
381 | 381 | 'comments' => 'comment_count', |
382 | - 'date' => array( 'date', true ), |
|
382 | + 'date' => array('date', true), |
|
383 | 383 | ); |
384 | 384 | } |
385 | 385 | |
@@ -391,16 +391,16 @@ discard block |
||
391 | 391 | * |
392 | 392 | * @param WP_Post $item The current WP_Post object. |
393 | 393 | */ |
394 | - public function column_cb( $item ) { |
|
394 | + public function column_cb($item) { |
|
395 | 395 | // Restores the more descriptive, specific name for use within this method. |
396 | 396 | $post = $item; |
397 | 397 | |
398 | - if ( current_user_can( 'edit_post', $post->ID ) ) { |
|
398 | + if (current_user_can('edit_post', $post->ID)) { |
|
399 | 399 | ?> |
400 | 400 | <label class="screen-reader-text" for="cb-select-<?php echo $post->ID; ?>"> |
401 | 401 | <?php |
402 | 402 | /* translators: %s: Attachment title. */ |
403 | - printf( __( 'Select %s' ), _draft_or_post_title() ); |
|
403 | + printf(__('Select %s'), _draft_or_post_title()); |
|
404 | 404 | ?> |
405 | 405 | </label> |
406 | 406 | <input type="checkbox" name="media[]" id="cb-select-<?php echo $post->ID; ?>" value="<?php echo $post->ID; ?>" /> |
@@ -415,20 +415,20 @@ discard block |
||
415 | 415 | * |
416 | 416 | * @param WP_Post $post The current WP_Post object. |
417 | 417 | */ |
418 | - public function column_title( $post ) { |
|
419 | - list( $mime ) = explode( '/', $post->post_mime_type ); |
|
418 | + public function column_title($post) { |
|
419 | + list($mime) = explode('/', $post->post_mime_type); |
|
420 | 420 | |
421 | 421 | $title = _draft_or_post_title(); |
422 | - $thumb = wp_get_attachment_image( $post->ID, array( 60, 60 ), true, array( 'alt' => '' ) ); |
|
422 | + $thumb = wp_get_attachment_image($post->ID, array(60, 60), true, array('alt' => '')); |
|
423 | 423 | $link_start = ''; |
424 | 424 | $link_end = ''; |
425 | 425 | |
426 | - if ( current_user_can( 'edit_post', $post->ID ) && ! $this->is_trash ) { |
|
426 | + if (current_user_can('edit_post', $post->ID) && !$this->is_trash) { |
|
427 | 427 | $link_start = sprintf( |
428 | 428 | '<a href="%s" aria-label="%s">', |
429 | - get_edit_post_link( $post->ID ), |
|
429 | + get_edit_post_link($post->ID), |
|
430 | 430 | /* translators: %s: Attachment title. */ |
431 | - esc_attr( sprintf( __( '“%s” (Edit)' ), $title ) ) |
|
431 | + esc_attr(sprintf(__('“%s” (Edit)'), $title)) |
|
432 | 432 | ); |
433 | 433 | $link_end = '</a>'; |
434 | 434 | } |
@@ -439,22 +439,22 @@ discard block |
||
439 | 439 | <?php |
440 | 440 | echo $link_start; |
441 | 441 | |
442 | - if ( $thumb ) : |
|
442 | + if ($thumb) : |
|
443 | 443 | ?> |
444 | - <span class="media-icon <?php echo sanitize_html_class( $mime . '-icon' ); ?>"><?php echo $thumb; ?></span> |
|
444 | + <span class="media-icon <?php echo sanitize_html_class($mime . '-icon'); ?>"><?php echo $thumb; ?></span> |
|
445 | 445 | <?php |
446 | 446 | endif; |
447 | 447 | |
448 | 448 | echo $title . $link_end; |
449 | 449 | |
450 | - _media_states( $post ); |
|
450 | + _media_states($post); |
|
451 | 451 | ?> |
452 | 452 | </strong> |
453 | 453 | <p class="filename"> |
454 | - <span class="screen-reader-text"><?php _e( 'File name:' ); ?> </span> |
|
454 | + <span class="screen-reader-text"><?php _e('File name:'); ?> </span> |
|
455 | 455 | <?php |
456 | - $file = get_attached_file( $post->ID ); |
|
457 | - echo esc_html( wp_basename( $file ) ); |
|
456 | + $file = get_attached_file($post->ID); |
|
457 | + echo esc_html(wp_basename($file)); |
|
458 | 458 | ?> |
459 | 459 | </p> |
460 | 460 | <?php |
@@ -467,10 +467,10 @@ discard block |
||
467 | 467 | * |
468 | 468 | * @param WP_Post $post The current WP_Post object. |
469 | 469 | */ |
470 | - public function column_author( $post ) { |
|
470 | + public function column_author($post) { |
|
471 | 471 | printf( |
472 | 472 | '<a href="%s">%s</a>', |
473 | - esc_url( add_query_arg( array( 'author' => get_the_author_meta( 'ID' ) ), 'upload.php' ) ), |
|
473 | + esc_url(add_query_arg(array('author' => get_the_author_meta('ID')), 'upload.php')), |
|
474 | 474 | get_the_author() |
475 | 475 | ); |
476 | 476 | } |
@@ -482,7 +482,7 @@ discard block |
||
482 | 482 | * |
483 | 483 | * @param WP_Post $post The current WP_Post object. |
484 | 484 | */ |
485 | - public function column_desc( $post ) { |
|
485 | + public function column_desc($post) { |
|
486 | 486 | echo has_excerpt() ? $post->post_excerpt : ''; |
487 | 487 | } |
488 | 488 | |
@@ -493,18 +493,18 @@ discard block |
||
493 | 493 | * |
494 | 494 | * @param WP_Post $post The current WP_Post object. |
495 | 495 | */ |
496 | - public function column_date( $post ) { |
|
497 | - if ( '0000-00-00 00:00:00' === $post->post_date ) { |
|
498 | - $h_time = __( 'Unpublished' ); |
|
496 | + public function column_date($post) { |
|
497 | + if ('0000-00-00 00:00:00' === $post->post_date) { |
|
498 | + $h_time = __('Unpublished'); |
|
499 | 499 | } else { |
500 | - $time = get_post_timestamp( $post ); |
|
500 | + $time = get_post_timestamp($post); |
|
501 | 501 | $time_diff = time() - $time; |
502 | 502 | |
503 | - if ( $time && $time_diff > 0 && $time_diff < DAY_IN_SECONDS ) { |
|
503 | + if ($time && $time_diff > 0 && $time_diff < DAY_IN_SECONDS) { |
|
504 | 504 | /* translators: %s: Human-readable time difference. */ |
505 | - $h_time = sprintf( __( '%s ago' ), human_time_diff( $time ) ); |
|
505 | + $h_time = sprintf(__('%s ago'), human_time_diff($time)); |
|
506 | 506 | } else { |
507 | - $h_time = get_the_time( __( 'Y/m/d' ), $post ); |
|
507 | + $h_time = get_the_time(__('Y/m/d'), $post); |
|
508 | 508 | } |
509 | 509 | } |
510 | 510 | |
@@ -517,7 +517,7 @@ discard block |
||
517 | 517 | * @param WP_Post $post Attachment object. |
518 | 518 | * @param string $column_name The column name. |
519 | 519 | */ |
520 | - echo apply_filters( 'media_date_column_time', $h_time, $post, 'date' ); |
|
520 | + echo apply_filters('media_date_column_time', $h_time, $post, 'date'); |
|
521 | 521 | } |
522 | 522 | |
523 | 523 | /** |
@@ -527,33 +527,33 @@ discard block |
||
527 | 527 | * |
528 | 528 | * @param WP_Post $post The current WP_Post object. |
529 | 529 | */ |
530 | - public function column_parent( $post ) { |
|
531 | - $user_can_edit = current_user_can( 'edit_post', $post->ID ); |
|
530 | + public function column_parent($post) { |
|
531 | + $user_can_edit = current_user_can('edit_post', $post->ID); |
|
532 | 532 | |
533 | - if ( $post->post_parent > 0 ) { |
|
534 | - $parent = get_post( $post->post_parent ); |
|
533 | + if ($post->post_parent > 0) { |
|
534 | + $parent = get_post($post->post_parent); |
|
535 | 535 | } else { |
536 | 536 | $parent = false; |
537 | 537 | } |
538 | 538 | |
539 | - if ( $parent ) { |
|
540 | - $title = _draft_or_post_title( $post->post_parent ); |
|
541 | - $parent_type = get_post_type_object( $parent->post_type ); |
|
539 | + if ($parent) { |
|
540 | + $title = _draft_or_post_title($post->post_parent); |
|
541 | + $parent_type = get_post_type_object($parent->post_type); |
|
542 | 542 | |
543 | - if ( $parent_type && $parent_type->show_ui && current_user_can( 'edit_post', $post->post_parent ) ) { |
|
544 | - printf( '<strong><a href="%s">%s</a></strong>', get_edit_post_link( $post->post_parent ), $title ); |
|
545 | - } elseif ( $parent_type && current_user_can( 'read_post', $post->post_parent ) ) { |
|
546 | - printf( '<strong>%s</strong>', $title ); |
|
543 | + if ($parent_type && $parent_type->show_ui && current_user_can('edit_post', $post->post_parent)) { |
|
544 | + printf('<strong><a href="%s">%s</a></strong>', get_edit_post_link($post->post_parent), $title); |
|
545 | + } elseif ($parent_type && current_user_can('read_post', $post->post_parent)) { |
|
546 | + printf('<strong>%s</strong>', $title); |
|
547 | 547 | } else { |
548 | - _e( '(Private post)' ); |
|
548 | + _e('(Private post)'); |
|
549 | 549 | } |
550 | 550 | |
551 | - if ( $user_can_edit ) : |
|
551 | + if ($user_can_edit) : |
|
552 | 552 | $detach_url = add_query_arg( |
553 | 553 | array( |
554 | 554 | 'parent_post_id' => $post->post_parent, |
555 | 555 | 'media[]' => $post->ID, |
556 | - '_wpnonce' => wp_create_nonce( 'bulk-' . $this->_args['plural'] ), |
|
556 | + '_wpnonce' => wp_create_nonce('bulk-' . $this->_args['plural']), |
|
557 | 557 | ), |
558 | 558 | 'upload.php' |
559 | 559 | ); |
@@ -561,22 +561,22 @@ discard block |
||
561 | 561 | '<br /><a href="%s" class="hide-if-no-js detach-from-parent" aria-label="%s">%s</a>', |
562 | 562 | $detach_url, |
563 | 563 | /* translators: %s: Title of the post the attachment is attached to. */ |
564 | - esc_attr( sprintf( __( 'Detach from “%s”' ), $title ) ), |
|
565 | - __( 'Detach' ) |
|
564 | + esc_attr(sprintf(__('Detach from “%s”'), $title)), |
|
565 | + __('Detach') |
|
566 | 566 | ); |
567 | 567 | endif; |
568 | 568 | } else { |
569 | - _e( '(Unattached)' ); |
|
569 | + _e('(Unattached)'); |
|
570 | 570 | ?> |
571 | 571 | <?php |
572 | - if ( $user_can_edit ) { |
|
573 | - $title = _draft_or_post_title( $post->post_parent ); |
|
572 | + if ($user_can_edit) { |
|
573 | + $title = _draft_or_post_title($post->post_parent); |
|
574 | 574 | printf( |
575 | 575 | '<br /><a href="#the-list" onclick="findPosts.open( \'media[]\', \'%s\' ); return false;" class="hide-if-no-js aria-button-if-js" aria-label="%s">%s</a>', |
576 | 576 | $post->ID, |
577 | 577 | /* translators: %s: Attachment title. */ |
578 | - esc_attr( sprintf( __( 'Attach “%s” to existing content' ), $title ) ), |
|
579 | - __( 'Attach' ) |
|
578 | + esc_attr(sprintf(__('Attach “%s” to existing content'), $title)), |
|
579 | + __('Attach') |
|
580 | 580 | ); |
581 | 581 | } |
582 | 582 | } |
@@ -589,16 +589,16 @@ discard block |
||
589 | 589 | * |
590 | 590 | * @param WP_Post $post The current WP_Post object. |
591 | 591 | */ |
592 | - public function column_comments( $post ) { |
|
592 | + public function column_comments($post) { |
|
593 | 593 | echo '<div class="post-com-count-wrapper">'; |
594 | 594 | |
595 | - if ( isset( $this->comment_pending_count[ $post->ID ] ) ) { |
|
596 | - $pending_comments = $this->comment_pending_count[ $post->ID ]; |
|
595 | + if (isset($this->comment_pending_count[$post->ID])) { |
|
596 | + $pending_comments = $this->comment_pending_count[$post->ID]; |
|
597 | 597 | } else { |
598 | - $pending_comments = get_pending_comments_num( $post->ID ); |
|
598 | + $pending_comments = get_pending_comments_num($post->ID); |
|
599 | 599 | } |
600 | 600 | |
601 | - $this->comments_bubble( $post->ID, $pending_comments ); |
|
601 | + $this->comments_bubble($post->ID, $pending_comments); |
|
602 | 602 | |
603 | 603 | echo '</div>'; |
604 | 604 | } |
@@ -612,39 +612,39 @@ discard block |
||
612 | 612 | * @param WP_Post $item The current WP_Post object. |
613 | 613 | * @param string $column_name Current column name. |
614 | 614 | */ |
615 | - public function column_default( $item, $column_name ) { |
|
615 | + public function column_default($item, $column_name) { |
|
616 | 616 | // Restores the more descriptive, specific name for use within this method. |
617 | 617 | $post = $item; |
618 | 618 | |
619 | - if ( 'categories' === $column_name ) { |
|
619 | + if ('categories' === $column_name) { |
|
620 | 620 | $taxonomy = 'category'; |
621 | - } elseif ( 'tags' === $column_name ) { |
|
621 | + } elseif ('tags' === $column_name) { |
|
622 | 622 | $taxonomy = 'post_tag'; |
623 | - } elseif ( 0 === strpos( $column_name, 'taxonomy-' ) ) { |
|
624 | - $taxonomy = substr( $column_name, 9 ); |
|
623 | + } elseif (0 === strpos($column_name, 'taxonomy-')) { |
|
624 | + $taxonomy = substr($column_name, 9); |
|
625 | 625 | } else { |
626 | 626 | $taxonomy = false; |
627 | 627 | } |
628 | 628 | |
629 | - if ( $taxonomy ) { |
|
630 | - $terms = get_the_terms( $post->ID, $taxonomy ); |
|
629 | + if ($taxonomy) { |
|
630 | + $terms = get_the_terms($post->ID, $taxonomy); |
|
631 | 631 | |
632 | - if ( is_array( $terms ) ) { |
|
632 | + if (is_array($terms)) { |
|
633 | 633 | $out = array(); |
634 | - foreach ( $terms as $t ) { |
|
634 | + foreach ($terms as $t) { |
|
635 | 635 | $posts_in_term_qv = array(); |
636 | 636 | $posts_in_term_qv['taxonomy'] = $taxonomy; |
637 | 637 | $posts_in_term_qv['term'] = $t->slug; |
638 | 638 | |
639 | 639 | $out[] = sprintf( |
640 | 640 | '<a href="%s">%s</a>', |
641 | - esc_url( add_query_arg( $posts_in_term_qv, 'upload.php' ) ), |
|
642 | - esc_html( sanitize_term_field( 'name', $t->name, $t->term_id, $taxonomy, 'display' ) ) |
|
641 | + esc_url(add_query_arg($posts_in_term_qv, 'upload.php')), |
|
642 | + esc_html(sanitize_term_field('name', $t->name, $t->term_id, $taxonomy, 'display')) |
|
643 | 643 | ); |
644 | 644 | } |
645 | - echo implode( wp_get_list_item_separator(), $out ); |
|
645 | + echo implode(wp_get_list_item_separator(), $out); |
|
646 | 646 | } else { |
647 | - echo '<span aria-hidden="true">—</span><span class="screen-reader-text">' . get_taxonomy( $taxonomy )->labels->no_terms . '</span>'; |
|
647 | + echo '<span aria-hidden="true">—</span><span class="screen-reader-text">' . get_taxonomy($taxonomy)->labels->no_terms . '</span>'; |
|
648 | 648 | } |
649 | 649 | |
650 | 650 | return; |
@@ -660,7 +660,7 @@ discard block |
||
660 | 660 | * @param string $column_name Name of the custom column. |
661 | 661 | * @param int $post_id Attachment ID. |
662 | 662 | */ |
663 | - do_action( 'manage_media_custom_column', $column_name, $post->ID ); |
|
663 | + do_action('manage_media_custom_column', $column_name, $post->ID); |
|
664 | 664 | } |
665 | 665 | |
666 | 666 | /** |
@@ -669,26 +669,26 @@ discard block |
||
669 | 669 | public function display_rows() { |
670 | 670 | global $post, $wp_query; |
671 | 671 | |
672 | - $post_ids = wp_list_pluck( $wp_query->posts, 'ID' ); |
|
673 | - reset( $wp_query->posts ); |
|
672 | + $post_ids = wp_list_pluck($wp_query->posts, 'ID'); |
|
673 | + reset($wp_query->posts); |
|
674 | 674 | |
675 | - $this->comment_pending_count = get_pending_comments_num( $post_ids ); |
|
675 | + $this->comment_pending_count = get_pending_comments_num($post_ids); |
|
676 | 676 | |
677 | - add_filter( 'the_title', 'esc_html' ); |
|
677 | + add_filter('the_title', 'esc_html'); |
|
678 | 678 | |
679 | - while ( have_posts() ) : |
|
679 | + while (have_posts()) : |
|
680 | 680 | the_post(); |
681 | 681 | |
682 | - if ( $this->is_trash && 'trash' !== $post->post_status |
|
683 | - || ! $this->is_trash && 'trash' === $post->post_status |
|
682 | + if ($this->is_trash && 'trash' !== $post->post_status |
|
683 | + || !$this->is_trash && 'trash' === $post->post_status |
|
684 | 684 | ) { |
685 | 685 | continue; |
686 | 686 | } |
687 | 687 | |
688 | - $post_owner = ( get_current_user_id() === (int) $post->post_author ) ? 'self' : 'other'; |
|
688 | + $post_owner = (get_current_user_id() === (int) $post->post_author) ? 'self' : 'other'; |
|
689 | 689 | ?> |
690 | - <tr id="post-<?php echo $post->ID; ?>" class="<?php echo trim( ' author-' . $post_owner . ' status-' . $post->post_status ); ?>"> |
|
691 | - <?php $this->single_row_columns( $post ); ?> |
|
690 | + <tr id="post-<?php echo $post->ID; ?>" class="<?php echo trim(' author-' . $post_owner . ' status-' . $post->post_status); ?>"> |
|
691 | + <?php $this->single_row_columns($post); ?> |
|
692 | 692 | </tr> |
693 | 693 | <?php |
694 | 694 | endwhile; |
@@ -710,118 +710,118 @@ discard block |
||
710 | 710 | * @param string $att_title |
711 | 711 | * @return array |
712 | 712 | */ |
713 | - private function _get_row_actions( $post, $att_title ) { |
|
713 | + private function _get_row_actions($post, $att_title) { |
|
714 | 714 | $actions = array(); |
715 | 715 | |
716 | - if ( $this->detached ) { |
|
717 | - if ( current_user_can( 'edit_post', $post->ID ) ) { |
|
716 | + if ($this->detached) { |
|
717 | + if (current_user_can('edit_post', $post->ID)) { |
|
718 | 718 | $actions['edit'] = sprintf( |
719 | 719 | '<a href="%s" aria-label="%s">%s</a>', |
720 | - get_edit_post_link( $post->ID ), |
|
720 | + get_edit_post_link($post->ID), |
|
721 | 721 | /* translators: %s: Attachment title. */ |
722 | - esc_attr( sprintf( __( 'Edit “%s”' ), $att_title ) ), |
|
723 | - __( 'Edit' ) |
|
722 | + esc_attr(sprintf(__('Edit “%s”'), $att_title)), |
|
723 | + __('Edit') |
|
724 | 724 | ); |
725 | 725 | } |
726 | 726 | |
727 | - if ( current_user_can( 'delete_post', $post->ID ) ) { |
|
728 | - if ( EMPTY_TRASH_DAYS && MEDIA_TRASH ) { |
|
727 | + if (current_user_can('delete_post', $post->ID)) { |
|
728 | + if (EMPTY_TRASH_DAYS && MEDIA_TRASH) { |
|
729 | 729 | $actions['trash'] = sprintf( |
730 | 730 | '<a href="%s" class="submitdelete aria-button-if-js" aria-label="%s">%s</a>', |
731 | - wp_nonce_url( "post.php?action=trash&post=$post->ID", 'trash-post_' . $post->ID ), |
|
731 | + wp_nonce_url("post.php?action=trash&post=$post->ID", 'trash-post_' . $post->ID), |
|
732 | 732 | /* translators: %s: Attachment title. */ |
733 | - esc_attr( sprintf( __( 'Move “%s” to the Trash' ), $att_title ) ), |
|
734 | - _x( 'Trash', 'verb' ) |
|
733 | + esc_attr(sprintf(__('Move “%s” to the Trash'), $att_title)), |
|
734 | + _x('Trash', 'verb') |
|
735 | 735 | ); |
736 | 736 | } else { |
737 | - $delete_ays = ! MEDIA_TRASH ? " onclick='return showNotice.warn();'" : ''; |
|
737 | + $delete_ays = !MEDIA_TRASH ? " onclick='return showNotice.warn();'" : ''; |
|
738 | 738 | $actions['delete'] = sprintf( |
739 | 739 | '<a href="%s" class="submitdelete aria-button-if-js"%s aria-label="%s">%s</a>', |
740 | - wp_nonce_url( "post.php?action=delete&post=$post->ID", 'delete-post_' . $post->ID ), |
|
740 | + wp_nonce_url("post.php?action=delete&post=$post->ID", 'delete-post_' . $post->ID), |
|
741 | 741 | $delete_ays, |
742 | 742 | /* translators: %s: Attachment title. */ |
743 | - esc_attr( sprintf( __( 'Delete “%s” permanently' ), $att_title ) ), |
|
744 | - __( 'Delete Permanently' ) |
|
743 | + esc_attr(sprintf(__('Delete “%s” permanently'), $att_title)), |
|
744 | + __('Delete Permanently') |
|
745 | 745 | ); |
746 | 746 | } |
747 | 747 | } |
748 | 748 | |
749 | 749 | $actions['view'] = sprintf( |
750 | 750 | '<a href="%s" aria-label="%s" rel="bookmark">%s</a>', |
751 | - get_permalink( $post->ID ), |
|
751 | + get_permalink($post->ID), |
|
752 | 752 | /* translators: %s: Attachment title. */ |
753 | - esc_attr( sprintf( __( 'View “%s”' ), $att_title ) ), |
|
754 | - __( 'View' ) |
|
753 | + esc_attr(sprintf(__('View “%s”'), $att_title)), |
|
754 | + __('View') |
|
755 | 755 | ); |
756 | 756 | |
757 | - if ( current_user_can( 'edit_post', $post->ID ) ) { |
|
757 | + if (current_user_can('edit_post', $post->ID)) { |
|
758 | 758 | $actions['attach'] = sprintf( |
759 | 759 | '<a href="#the-list" onclick="findPosts.open( \'media[]\', \'%s\' ); return false;" class="hide-if-no-js aria-button-if-js" aria-label="%s">%s</a>', |
760 | 760 | $post->ID, |
761 | 761 | /* translators: %s: Attachment title. */ |
762 | - esc_attr( sprintf( __( 'Attach “%s” to existing content' ), $att_title ) ), |
|
763 | - __( 'Attach' ) |
|
762 | + esc_attr(sprintf(__('Attach “%s” to existing content'), $att_title)), |
|
763 | + __('Attach') |
|
764 | 764 | ); |
765 | 765 | } |
766 | 766 | } else { |
767 | - if ( current_user_can( 'edit_post', $post->ID ) && ! $this->is_trash ) { |
|
767 | + if (current_user_can('edit_post', $post->ID) && !$this->is_trash) { |
|
768 | 768 | $actions['edit'] = sprintf( |
769 | 769 | '<a href="%s" aria-label="%s">%s</a>', |
770 | - get_edit_post_link( $post->ID ), |
|
770 | + get_edit_post_link($post->ID), |
|
771 | 771 | /* translators: %s: Attachment title. */ |
772 | - esc_attr( sprintf( __( 'Edit “%s”' ), $att_title ) ), |
|
773 | - __( 'Edit' ) |
|
772 | + esc_attr(sprintf(__('Edit “%s”'), $att_title)), |
|
773 | + __('Edit') |
|
774 | 774 | ); |
775 | 775 | } |
776 | 776 | |
777 | - if ( current_user_can( 'delete_post', $post->ID ) ) { |
|
778 | - if ( $this->is_trash ) { |
|
777 | + if (current_user_can('delete_post', $post->ID)) { |
|
778 | + if ($this->is_trash) { |
|
779 | 779 | $actions['untrash'] = sprintf( |
780 | 780 | '<a href="%s" class="submitdelete aria-button-if-js" aria-label="%s">%s</a>', |
781 | - wp_nonce_url( "post.php?action=untrash&post=$post->ID", 'untrash-post_' . $post->ID ), |
|
781 | + wp_nonce_url("post.php?action=untrash&post=$post->ID", 'untrash-post_' . $post->ID), |
|
782 | 782 | /* translators: %s: Attachment title. */ |
783 | - esc_attr( sprintf( __( 'Restore “%s” from the Trash' ), $att_title ) ), |
|
784 | - __( 'Restore' ) |
|
783 | + esc_attr(sprintf(__('Restore “%s” from the Trash'), $att_title)), |
|
784 | + __('Restore') |
|
785 | 785 | ); |
786 | - } elseif ( EMPTY_TRASH_DAYS && MEDIA_TRASH ) { |
|
786 | + } elseif (EMPTY_TRASH_DAYS && MEDIA_TRASH) { |
|
787 | 787 | $actions['trash'] = sprintf( |
788 | 788 | '<a href="%s" class="submitdelete aria-button-if-js" aria-label="%s">%s</a>', |
789 | - wp_nonce_url( "post.php?action=trash&post=$post->ID", 'trash-post_' . $post->ID ), |
|
789 | + wp_nonce_url("post.php?action=trash&post=$post->ID", 'trash-post_' . $post->ID), |
|
790 | 790 | /* translators: %s: Attachment title. */ |
791 | - esc_attr( sprintf( __( 'Move “%s” to the Trash' ), $att_title ) ), |
|
792 | - _x( 'Trash', 'verb' ) |
|
791 | + esc_attr(sprintf(__('Move “%s” to the Trash'), $att_title)), |
|
792 | + _x('Trash', 'verb') |
|
793 | 793 | ); |
794 | 794 | } |
795 | 795 | |
796 | - if ( $this->is_trash || ! EMPTY_TRASH_DAYS || ! MEDIA_TRASH ) { |
|
797 | - $delete_ays = ( ! $this->is_trash && ! MEDIA_TRASH ) ? " onclick='return showNotice.warn();'" : ''; |
|
796 | + if ($this->is_trash || !EMPTY_TRASH_DAYS || !MEDIA_TRASH) { |
|
797 | + $delete_ays = (!$this->is_trash && !MEDIA_TRASH) ? " onclick='return showNotice.warn();'" : ''; |
|
798 | 798 | $actions['delete'] = sprintf( |
799 | 799 | '<a href="%s" class="submitdelete aria-button-if-js"%s aria-label="%s">%s</a>', |
800 | - wp_nonce_url( "post.php?action=delete&post=$post->ID", 'delete-post_' . $post->ID ), |
|
800 | + wp_nonce_url("post.php?action=delete&post=$post->ID", 'delete-post_' . $post->ID), |
|
801 | 801 | $delete_ays, |
802 | 802 | /* translators: %s: Attachment title. */ |
803 | - esc_attr( sprintf( __( 'Delete “%s” permanently' ), $att_title ) ), |
|
804 | - __( 'Delete Permanently' ) |
|
803 | + esc_attr(sprintf(__('Delete “%s” permanently'), $att_title)), |
|
804 | + __('Delete Permanently') |
|
805 | 805 | ); |
806 | 806 | } |
807 | 807 | } |
808 | 808 | |
809 | - if ( ! $this->is_trash ) { |
|
809 | + if (!$this->is_trash) { |
|
810 | 810 | $actions['view'] = sprintf( |
811 | 811 | '<a href="%s" aria-label="%s" rel="bookmark">%s</a>', |
812 | - get_permalink( $post->ID ), |
|
812 | + get_permalink($post->ID), |
|
813 | 813 | /* translators: %s: Attachment title. */ |
814 | - esc_attr( sprintf( __( 'View “%s”' ), $att_title ) ), |
|
815 | - __( 'View' ) |
|
814 | + esc_attr(sprintf(__('View “%s”'), $att_title)), |
|
815 | + __('View') |
|
816 | 816 | ); |
817 | 817 | |
818 | 818 | $actions['copy'] = sprintf( |
819 | 819 | '<span class="copy-to-clipboard-container"><button type="button" class="button-link copy-attachment-url media-library" data-clipboard-text="%s" aria-label="%s">%s</button><span class="success hidden" aria-hidden="true">%s</span></span>', |
820 | - esc_url( wp_get_attachment_url( $post->ID ) ), |
|
820 | + esc_url(wp_get_attachment_url($post->ID)), |
|
821 | 821 | /* translators: %s: Attachment title. */ |
822 | - esc_attr( sprintf( __( 'Copy “%s” URL to clipboard' ), $att_title ) ), |
|
823 | - __( 'Copy URL to clipboard' ), |
|
824 | - __( 'Copied!' ) |
|
822 | + esc_attr(sprintf(__('Copy “%s” URL to clipboard'), $att_title)), |
|
823 | + __('Copy URL to clipboard'), |
|
824 | + __('Copied!') |
|
825 | 825 | ); |
826 | 826 | } |
827 | 827 | } |
@@ -837,7 +837,7 @@ discard block |
||
837 | 837 | * @param bool $detached Whether the list table contains media not attached |
838 | 838 | * to any posts. Default true. |
839 | 839 | */ |
840 | - return apply_filters( 'media_row_actions', $actions, $post, $this->detached ); |
|
840 | + return apply_filters('media_row_actions', $actions, $post, $this->detached); |
|
841 | 841 | } |
842 | 842 | |
843 | 843 | /** |
@@ -852,8 +852,8 @@ discard block |
||
852 | 852 | * @return string Row actions output for media attachments, or an empty string |
853 | 853 | * if the current column is not the primary column. |
854 | 854 | */ |
855 | - protected function handle_row_actions( $item, $column_name, $primary ) { |
|
856 | - if ( $primary !== $column_name ) { |
|
855 | + protected function handle_row_actions($item, $column_name, $primary) { |
|
856 | + if ($primary !== $column_name) { |
|
857 | 857 | return ''; |
858 | 858 | } |
859 | 859 | |
@@ -863,6 +863,6 @@ discard block |
||
863 | 863 | $att_title |
864 | 864 | ); |
865 | 865 | |
866 | - return $this->row_actions( $actions ); |
|
866 | + return $this->row_actions($actions); |
|
867 | 867 | } |
868 | 868 | } |
@@ -17,7 +17,7 @@ discard block |
||
17 | 17 | * @param string $blog_id |
18 | 18 | * @return array |
19 | 19 | */ |
20 | - public function get_imported_posts( $importer_name, $blog_id ) { |
|
20 | + public function get_imported_posts($importer_name, $blog_id) { |
|
21 | 21 | global $wpdb; |
22 | 22 | |
23 | 23 | $hashtable = array(); |
@@ -28,19 +28,19 @@ discard block |
||
28 | 28 | // Grab all posts in chunks. |
29 | 29 | do { |
30 | 30 | $meta_key = $importer_name . '_' . $blog_id . '_permalink'; |
31 | - $sql = $wpdb->prepare( "SELECT post_id, meta_value FROM $wpdb->postmeta WHERE meta_key = %s LIMIT %d,%d", $meta_key, $offset, $limit ); |
|
32 | - $results = $wpdb->get_results( $sql ); |
|
31 | + $sql = $wpdb->prepare("SELECT post_id, meta_value FROM $wpdb->postmeta WHERE meta_key = %s LIMIT %d,%d", $meta_key, $offset, $limit); |
|
32 | + $results = $wpdb->get_results($sql); |
|
33 | 33 | |
34 | 34 | // Increment offset. |
35 | - $offset = ( $limit + $offset ); |
|
35 | + $offset = ($limit + $offset); |
|
36 | 36 | |
37 | - if ( ! empty( $results ) ) { |
|
38 | - foreach ( $results as $r ) { |
|
37 | + if (!empty($results)) { |
|
38 | + foreach ($results as $r) { |
|
39 | 39 | // Set permalinks into array. |
40 | - $hashtable[ $r->meta_value ] = (int) $r->post_id; |
|
40 | + $hashtable[$r->meta_value] = (int) $r->post_id; |
|
41 | 41 | } |
42 | 42 | } |
43 | - } while ( count( $results ) == $limit ); |
|
43 | + } while (count($results) == $limit); |
|
44 | 44 | |
45 | 45 | return $hashtable; |
46 | 46 | } |
@@ -54,18 +54,18 @@ discard block |
||
54 | 54 | * @param string $blog_id |
55 | 55 | * @return int |
56 | 56 | */ |
57 | - public function count_imported_posts( $importer_name, $blog_id ) { |
|
57 | + public function count_imported_posts($importer_name, $blog_id) { |
|
58 | 58 | global $wpdb; |
59 | 59 | |
60 | 60 | $count = 0; |
61 | 61 | |
62 | 62 | // Get count of permalinks. |
63 | 63 | $meta_key = $importer_name . '_' . $blog_id . '_permalink'; |
64 | - $sql = $wpdb->prepare( "SELECT COUNT( post_id ) AS cnt FROM $wpdb->postmeta WHERE meta_key = %s", $meta_key ); |
|
64 | + $sql = $wpdb->prepare("SELECT COUNT( post_id ) AS cnt FROM $wpdb->postmeta WHERE meta_key = %s", $meta_key); |
|
65 | 65 | |
66 | - $result = $wpdb->get_results( $sql ); |
|
66 | + $result = $wpdb->get_results($sql); |
|
67 | 67 | |
68 | - if ( ! empty( $result ) ) { |
|
68 | + if (!empty($result)) { |
|
69 | 69 | $count = (int) $result[0]->cnt; |
70 | 70 | } |
71 | 71 | |
@@ -80,7 +80,7 @@ discard block |
||
80 | 80 | * @param string $blog_id |
81 | 81 | * @return array |
82 | 82 | */ |
83 | - public function get_imported_comments( $blog_id ) { |
|
83 | + public function get_imported_comments($blog_id) { |
|
84 | 84 | global $wpdb; |
85 | 85 | |
86 | 86 | $hashtable = array(); |
@@ -90,26 +90,26 @@ discard block |
||
90 | 90 | |
91 | 91 | // Grab all comments in chunks. |
92 | 92 | do { |
93 | - $sql = $wpdb->prepare( "SELECT comment_ID, comment_agent FROM $wpdb->comments LIMIT %d,%d", $offset, $limit ); |
|
94 | - $results = $wpdb->get_results( $sql ); |
|
93 | + $sql = $wpdb->prepare("SELECT comment_ID, comment_agent FROM $wpdb->comments LIMIT %d,%d", $offset, $limit); |
|
94 | + $results = $wpdb->get_results($sql); |
|
95 | 95 | |
96 | 96 | // Increment offset. |
97 | - $offset = ( $limit + $offset ); |
|
97 | + $offset = ($limit + $offset); |
|
98 | 98 | |
99 | - if ( ! empty( $results ) ) { |
|
100 | - foreach ( $results as $r ) { |
|
99 | + if (!empty($results)) { |
|
100 | + foreach ($results as $r) { |
|
101 | 101 | // Explode comment_agent key. |
102 | - list ( $comment_agent_blog_id, $source_comment_id ) = explode( '-', $r->comment_agent ); |
|
102 | + list ($comment_agent_blog_id, $source_comment_id) = explode('-', $r->comment_agent); |
|
103 | 103 | |
104 | 104 | $source_comment_id = (int) $source_comment_id; |
105 | 105 | |
106 | 106 | // Check if this comment came from this blog. |
107 | - if ( $blog_id == $comment_agent_blog_id ) { |
|
108 | - $hashtable[ $source_comment_id ] = (int) $r->comment_ID; |
|
107 | + if ($blog_id == $comment_agent_blog_id) { |
|
108 | + $hashtable[$source_comment_id] = (int) $r->comment_ID; |
|
109 | 109 | } |
110 | 110 | } |
111 | 111 | } |
112 | - } while ( count( $results ) == $limit ); |
|
112 | + } while (count($results) == $limit); |
|
113 | 113 | |
114 | 114 | return $hashtable; |
115 | 115 | } |
@@ -118,17 +118,17 @@ discard block |
||
118 | 118 | * @param int $blog_id |
119 | 119 | * @return int|void |
120 | 120 | */ |
121 | - public function set_blog( $blog_id ) { |
|
122 | - if ( is_numeric( $blog_id ) ) { |
|
121 | + public function set_blog($blog_id) { |
|
122 | + if (is_numeric($blog_id)) { |
|
123 | 123 | $blog_id = (int) $blog_id; |
124 | 124 | } else { |
125 | - $blog = 'http://' . preg_replace( '#^https?://#', '', $blog_id ); |
|
126 | - $parsed = parse_url( $blog ); |
|
127 | - if ( ! $parsed || empty( $parsed['host'] ) ) { |
|
128 | - fwrite( STDERR, "Error: can not determine blog_id from $blog_id\n" ); |
|
125 | + $blog = 'http://' . preg_replace('#^https?://#', '', $blog_id); |
|
126 | + $parsed = parse_url($blog); |
|
127 | + if (!$parsed || empty($parsed['host'])) { |
|
128 | + fwrite(STDERR, "Error: can not determine blog_id from $blog_id\n"); |
|
129 | 129 | exit; |
130 | 130 | } |
131 | - if ( empty( $parsed['path'] ) ) { |
|
131 | + if (empty($parsed['path'])) { |
|
132 | 132 | $parsed['path'] = '/'; |
133 | 133 | } |
134 | 134 | $blogs = get_sites( |
@@ -138,17 +138,17 @@ discard block |
||
138 | 138 | 'path' => $parsed['path'], |
139 | 139 | ) |
140 | 140 | ); |
141 | - if ( ! $blogs ) { |
|
142 | - fwrite( STDERR, "Error: Could not find blog\n" ); |
|
141 | + if (!$blogs) { |
|
142 | + fwrite(STDERR, "Error: Could not find blog\n"); |
|
143 | 143 | exit; |
144 | 144 | } |
145 | - $blog = array_shift( $blogs ); |
|
145 | + $blog = array_shift($blogs); |
|
146 | 146 | $blog_id = (int) $blog->blog_id; |
147 | 147 | } |
148 | 148 | |
149 | - if ( function_exists( 'is_multisite' ) ) { |
|
150 | - if ( is_multisite() ) { |
|
151 | - switch_to_blog( $blog_id ); |
|
149 | + if (function_exists('is_multisite')) { |
|
150 | + if (is_multisite()) { |
|
151 | + switch_to_blog($blog_id); |
|
152 | 152 | } |
153 | 153 | } |
154 | 154 | |
@@ -159,15 +159,15 @@ discard block |
||
159 | 159 | * @param int $user_id |
160 | 160 | * @return int|void |
161 | 161 | */ |
162 | - public function set_user( $user_id ) { |
|
163 | - if ( is_numeric( $user_id ) ) { |
|
162 | + public function set_user($user_id) { |
|
163 | + if (is_numeric($user_id)) { |
|
164 | 164 | $user_id = (int) $user_id; |
165 | 165 | } else { |
166 | - $user_id = (int) username_exists( $user_id ); |
|
166 | + $user_id = (int) username_exists($user_id); |
|
167 | 167 | } |
168 | 168 | |
169 | - if ( ! $user_id || ! wp_set_current_user( $user_id ) ) { |
|
170 | - fwrite( STDERR, "Error: can not find user\n" ); |
|
169 | + if (!$user_id || !wp_set_current_user($user_id)) { |
|
170 | + fwrite(STDERR, "Error: can not find user\n"); |
|
171 | 171 | exit; |
172 | 172 | } |
173 | 173 | |
@@ -181,8 +181,8 @@ discard block |
||
181 | 181 | * @param string $b |
182 | 182 | * @return int |
183 | 183 | */ |
184 | - public function cmpr_strlen( $a, $b ) { |
|
185 | - return strlen( $b ) - strlen( $a ); |
|
184 | + public function cmpr_strlen($a, $b) { |
|
185 | + return strlen($b) - strlen($a); |
|
186 | 186 | } |
187 | 187 | |
188 | 188 | /** |
@@ -194,22 +194,22 @@ discard block |
||
194 | 194 | * @param bool $head |
195 | 195 | * @return array |
196 | 196 | */ |
197 | - public function get_page( $url, $username = '', $password = '', $head = false ) { |
|
197 | + public function get_page($url, $username = '', $password = '', $head = false) { |
|
198 | 198 | // Increase the timeout. |
199 | - add_filter( 'http_request_timeout', array( $this, 'bump_request_timeout' ) ); |
|
199 | + add_filter('http_request_timeout', array($this, 'bump_request_timeout')); |
|
200 | 200 | |
201 | 201 | $headers = array(); |
202 | 202 | $args = array(); |
203 | - if ( true === $head ) { |
|
203 | + if (true === $head) { |
|
204 | 204 | $args['method'] = 'HEAD'; |
205 | 205 | } |
206 | - if ( ! empty( $username ) && ! empty( $password ) ) { |
|
207 | - $headers['Authorization'] = 'Basic ' . base64_encode( "$username:$password" ); |
|
206 | + if (!empty($username) && !empty($password)) { |
|
207 | + $headers['Authorization'] = 'Basic ' . base64_encode("$username:$password"); |
|
208 | 208 | } |
209 | 209 | |
210 | 210 | $args['headers'] = $headers; |
211 | 211 | |
212 | - return wp_safe_remote_request( $url, $args ); |
|
212 | + return wp_safe_remote_request($url, $args); |
|
213 | 213 | } |
214 | 214 | |
215 | 215 | /** |
@@ -218,7 +218,7 @@ discard block |
||
218 | 218 | * @param int $val |
219 | 219 | * @return int |
220 | 220 | */ |
221 | - public function bump_request_timeout( $val ) { |
|
221 | + public function bump_request_timeout($val) { |
|
222 | 222 | return 60; |
223 | 223 | } |
224 | 224 | |
@@ -228,8 +228,8 @@ discard block |
||
228 | 228 | * @return bool |
229 | 229 | */ |
230 | 230 | public function is_user_over_quota() { |
231 | - if ( function_exists( 'upload_is_user_over_quota' ) ) { |
|
232 | - if ( upload_is_user_over_quota() ) { |
|
231 | + if (function_exists('upload_is_user_over_quota')) { |
|
232 | + if (upload_is_user_over_quota()) { |
|
233 | 233 | return true; |
234 | 234 | } |
235 | 235 | } |
@@ -243,8 +243,8 @@ discard block |
||
243 | 243 | * @param string $text |
244 | 244 | * @return string |
245 | 245 | */ |
246 | - public function min_whitespace( $text ) { |
|
247 | - return preg_replace( '|[\r\n\t ]+|', ' ', $text ); |
|
246 | + public function min_whitespace($text) { |
|
247 | + return preg_replace('|[\r\n\t ]+|', ' ', $text); |
|
248 | 248 | } |
249 | 249 | |
250 | 250 | /** |
@@ -272,9 +272,9 @@ discard block |
||
272 | 272 | * @param bool $required |
273 | 273 | * @return mixed |
274 | 274 | */ |
275 | -function get_cli_args( $param, $required = false ) { |
|
275 | +function get_cli_args($param, $required = false) { |
|
276 | 276 | $args = $_SERVER['argv']; |
277 | - if ( ! is_array( $args ) ) { |
|
277 | + if (!is_array($args)) { |
|
278 | 278 | $args = array(); |
279 | 279 | } |
280 | 280 | |
@@ -283,40 +283,40 @@ discard block |
||
283 | 283 | $last_arg = null; |
284 | 284 | $return = null; |
285 | 285 | |
286 | - $il = count( $args ); |
|
286 | + $il = count($args); |
|
287 | 287 | |
288 | - for ( $i = 1, $il; $i < $il; $i++ ) { |
|
289 | - if ( (bool) preg_match( '/^--(.+)/', $args[ $i ], $match ) ) { |
|
290 | - $parts = explode( '=', $match[1] ); |
|
291 | - $key = preg_replace( '/[^a-z0-9]+/', '', $parts[0] ); |
|
288 | + for ($i = 1, $il; $i < $il; $i++) { |
|
289 | + if ((bool) preg_match('/^--(.+)/', $args[$i], $match)) { |
|
290 | + $parts = explode('=', $match[1]); |
|
291 | + $key = preg_replace('/[^a-z0-9]+/', '', $parts[0]); |
|
292 | 292 | |
293 | - if ( isset( $parts[1] ) ) { |
|
294 | - $out[ $key ] = $parts[1]; |
|
293 | + if (isset($parts[1])) { |
|
294 | + $out[$key] = $parts[1]; |
|
295 | 295 | } else { |
296 | - $out[ $key ] = true; |
|
296 | + $out[$key] = true; |
|
297 | 297 | } |
298 | 298 | |
299 | 299 | $last_arg = $key; |
300 | - } elseif ( (bool) preg_match( '/^-([a-zA-Z0-9]+)/', $args[ $i ], $match ) ) { |
|
301 | - for ( $j = 0, $jl = strlen( $match[1] ); $j < $jl; $j++ ) { |
|
302 | - $key = $match[1][ $j ]; |
|
303 | - $out[ $key ] = true; |
|
300 | + } elseif ((bool) preg_match('/^-([a-zA-Z0-9]+)/', $args[$i], $match)) { |
|
301 | + for ($j = 0, $jl = strlen($match[1]); $j < $jl; $j++) { |
|
302 | + $key = $match[1][$j]; |
|
303 | + $out[$key] = true; |
|
304 | 304 | } |
305 | 305 | |
306 | 306 | $last_arg = $key; |
307 | - } elseif ( null !== $last_arg ) { |
|
308 | - $out[ $last_arg ] = $args[ $i ]; |
|
307 | + } elseif (null !== $last_arg) { |
|
308 | + $out[$last_arg] = $args[$i]; |
|
309 | 309 | } |
310 | 310 | } |
311 | 311 | |
312 | 312 | // Check array for specified param. |
313 | - if ( isset( $out[ $param ] ) ) { |
|
313 | + if (isset($out[$param])) { |
|
314 | 314 | // Set return value. |
315 | - $return = $out[ $param ]; |
|
315 | + $return = $out[$param]; |
|
316 | 316 | } |
317 | 317 | |
318 | 318 | // Check for missing required param. |
319 | - if ( ! isset( $out[ $param ] ) && $required ) { |
|
319 | + if (!isset($out[$param]) && $required) { |
|
320 | 320 | // Display message and exit. |
321 | 321 | echo "\"$param\" parameter is required but was not specified\n"; |
322 | 322 | exit; |
@@ -54,16 +54,16 @@ discard block |
||
54 | 54 | * @since 2.8.0 |
55 | 55 | */ |
56 | 56 | public function upgrade_strings() { |
57 | - $this->strings['up_to_date'] = __( 'The plugin is at the latest version.' ); |
|
58 | - $this->strings['no_package'] = __( 'Update package not available.' ); |
|
57 | + $this->strings['up_to_date'] = __('The plugin is at the latest version.'); |
|
58 | + $this->strings['no_package'] = __('Update package not available.'); |
|
59 | 59 | /* translators: %s: Package URL. */ |
60 | - $this->strings['downloading_package'] = sprintf( __( 'Downloading update from %s…' ), '<span class="code">%s</span>' ); |
|
61 | - $this->strings['unpack_package'] = __( 'Unpacking the update…' ); |
|
62 | - $this->strings['remove_old'] = __( 'Removing the old version of the plugin…' ); |
|
63 | - $this->strings['remove_old_failed'] = __( 'Could not remove the old plugin.' ); |
|
64 | - $this->strings['process_failed'] = __( 'Plugin update failed.' ); |
|
65 | - $this->strings['process_success'] = __( 'Plugin updated successfully.' ); |
|
66 | - $this->strings['process_bulk_success'] = __( 'Plugins updated successfully.' ); |
|
60 | + $this->strings['downloading_package'] = sprintf(__('Downloading update from %s…'), '<span class="code">%s</span>'); |
|
61 | + $this->strings['unpack_package'] = __('Unpacking the update…'); |
|
62 | + $this->strings['remove_old'] = __('Removing the old version of the plugin…'); |
|
63 | + $this->strings['remove_old_failed'] = __('Could not remove the old plugin.'); |
|
64 | + $this->strings['process_failed'] = __('Plugin update failed.'); |
|
65 | + $this->strings['process_success'] = __('Plugin updated successfully.'); |
|
66 | + $this->strings['process_bulk_success'] = __('Plugins updated successfully.'); |
|
67 | 67 | } |
68 | 68 | |
69 | 69 | /** |
@@ -72,30 +72,30 @@ discard block |
||
72 | 72 | * @since 2.8.0 |
73 | 73 | */ |
74 | 74 | public function install_strings() { |
75 | - $this->strings['no_package'] = __( 'Installation package not available.' ); |
|
75 | + $this->strings['no_package'] = __('Installation package not available.'); |
|
76 | 76 | /* translators: %s: Package URL. */ |
77 | - $this->strings['downloading_package'] = sprintf( __( 'Downloading installation package from %s…' ), '<span class="code">%s</span>' ); |
|
78 | - $this->strings['unpack_package'] = __( 'Unpacking the package…' ); |
|
79 | - $this->strings['installing_package'] = __( 'Installing the plugin…' ); |
|
80 | - $this->strings['remove_old'] = __( 'Removing the current plugin…' ); |
|
81 | - $this->strings['remove_old_failed'] = __( 'Could not remove the current plugin.' ); |
|
82 | - $this->strings['no_files'] = __( 'The plugin contains no files.' ); |
|
83 | - $this->strings['process_failed'] = __( 'Plugin installation failed.' ); |
|
84 | - $this->strings['process_success'] = __( 'Plugin installed successfully.' ); |
|
77 | + $this->strings['downloading_package'] = sprintf(__('Downloading installation package from %s…'), '<span class="code">%s</span>'); |
|
78 | + $this->strings['unpack_package'] = __('Unpacking the package…'); |
|
79 | + $this->strings['installing_package'] = __('Installing the plugin…'); |
|
80 | + $this->strings['remove_old'] = __('Removing the current plugin…'); |
|
81 | + $this->strings['remove_old_failed'] = __('Could not remove the current plugin.'); |
|
82 | + $this->strings['no_files'] = __('The plugin contains no files.'); |
|
83 | + $this->strings['process_failed'] = __('Plugin installation failed.'); |
|
84 | + $this->strings['process_success'] = __('Plugin installed successfully.'); |
|
85 | 85 | /* translators: 1: Plugin name, 2: Plugin version. */ |
86 | - $this->strings['process_success_specific'] = __( 'Successfully installed the plugin <strong>%1$s %2$s</strong>.' ); |
|
86 | + $this->strings['process_success_specific'] = __('Successfully installed the plugin <strong>%1$s %2$s</strong>.'); |
|
87 | 87 | |
88 | - if ( ! empty( $this->skin->overwrite ) ) { |
|
89 | - if ( 'update-plugin' === $this->skin->overwrite ) { |
|
90 | - $this->strings['installing_package'] = __( 'Updating the plugin…' ); |
|
91 | - $this->strings['process_failed'] = __( 'Plugin update failed.' ); |
|
92 | - $this->strings['process_success'] = __( 'Plugin updated successfully.' ); |
|
88 | + if (!empty($this->skin->overwrite)) { |
|
89 | + if ('update-plugin' === $this->skin->overwrite) { |
|
90 | + $this->strings['installing_package'] = __('Updating the plugin…'); |
|
91 | + $this->strings['process_failed'] = __('Plugin update failed.'); |
|
92 | + $this->strings['process_success'] = __('Plugin updated successfully.'); |
|
93 | 93 | } |
94 | 94 | |
95 | - if ( 'downgrade-plugin' === $this->skin->overwrite ) { |
|
96 | - $this->strings['installing_package'] = __( 'Downgrading the plugin…' ); |
|
97 | - $this->strings['process_failed'] = __( 'Plugin downgrade failed.' ); |
|
98 | - $this->strings['process_success'] = __( 'Plugin downgraded successfully.' ); |
|
95 | + if ('downgrade-plugin' === $this->skin->overwrite) { |
|
96 | + $this->strings['installing_package'] = __('Downgrading the plugin…'); |
|
97 | + $this->strings['process_failed'] = __('Plugin downgrade failed.'); |
|
98 | + $this->strings['process_success'] = __('Plugin downgraded successfully.'); |
|
99 | 99 | } |
100 | 100 | } |
101 | 101 | } |
@@ -115,21 +115,21 @@ discard block |
||
115 | 115 | * } |
116 | 116 | * @return bool|WP_Error True if the installation was successful, false or a WP_Error otherwise. |
117 | 117 | */ |
118 | - public function install( $package, $args = array() ) { |
|
119 | - $defaults = array( |
|
118 | + public function install($package, $args = array()) { |
|
119 | + $defaults = array( |
|
120 | 120 | 'clear_update_cache' => true, |
121 | 121 | 'overwrite_package' => false, // Do not overwrite files. |
122 | 122 | ); |
123 | - $parsed_args = wp_parse_args( $args, $defaults ); |
|
123 | + $parsed_args = wp_parse_args($args, $defaults); |
|
124 | 124 | |
125 | 125 | $this->init(); |
126 | 126 | $this->install_strings(); |
127 | 127 | |
128 | - add_filter( 'upgrader_source_selection', array( $this, 'check_package' ) ); |
|
128 | + add_filter('upgrader_source_selection', array($this, 'check_package')); |
|
129 | 129 | |
130 | - if ( $parsed_args['clear_update_cache'] ) { |
|
130 | + if ($parsed_args['clear_update_cache']) { |
|
131 | 131 | // Clear cache so wp_update_plugins() knows about the new plugin. |
132 | - add_action( 'upgrader_process_complete', 'wp_clean_plugins_cache', 9, 0 ); |
|
132 | + add_action('upgrader_process_complete', 'wp_clean_plugins_cache', 9, 0); |
|
133 | 133 | } |
134 | 134 | |
135 | 135 | $this->run( |
@@ -145,17 +145,17 @@ discard block |
||
145 | 145 | ) |
146 | 146 | ); |
147 | 147 | |
148 | - remove_action( 'upgrader_process_complete', 'wp_clean_plugins_cache', 9 ); |
|
149 | - remove_filter( 'upgrader_source_selection', array( $this, 'check_package' ) ); |
|
148 | + remove_action('upgrader_process_complete', 'wp_clean_plugins_cache', 9); |
|
149 | + remove_filter('upgrader_source_selection', array($this, 'check_package')); |
|
150 | 150 | |
151 | - if ( ! $this->result || is_wp_error( $this->result ) ) { |
|
151 | + if (!$this->result || is_wp_error($this->result)) { |
|
152 | 152 | return $this->result; |
153 | 153 | } |
154 | 154 | |
155 | 155 | // Force refresh of plugin update information. |
156 | - wp_clean_plugins_cache( $parsed_args['clear_update_cache'] ); |
|
156 | + wp_clean_plugins_cache($parsed_args['clear_update_cache']); |
|
157 | 157 | |
158 | - if ( $parsed_args['overwrite_package'] ) { |
|
158 | + if ($parsed_args['overwrite_package']) { |
|
159 | 159 | /** |
160 | 160 | * Fires when the upgrader has successfully overwritten a currently installed |
161 | 161 | * plugin or theme with an uploaded zip package. |
@@ -166,7 +166,7 @@ discard block |
||
166 | 166 | * @param array $data The new plugin or theme data. |
167 | 167 | * @param string $package_type The package type ('plugin' or 'theme'). |
168 | 168 | */ |
169 | - do_action( 'upgrader_overwrote_package', $package, $this->new_plugin_data, 'plugin' ); |
|
169 | + do_action('upgrader_overwrote_package', $package, $this->new_plugin_data, 'plugin'); |
|
170 | 170 | } |
171 | 171 | |
172 | 172 | return true; |
@@ -187,36 +187,36 @@ discard block |
||
187 | 187 | * } |
188 | 188 | * @return bool|WP_Error True if the upgrade was successful, false or a WP_Error object otherwise. |
189 | 189 | */ |
190 | - public function upgrade( $plugin, $args = array() ) { |
|
190 | + public function upgrade($plugin, $args = array()) { |
|
191 | 191 | $defaults = array( |
192 | 192 | 'clear_update_cache' => true, |
193 | 193 | ); |
194 | - $parsed_args = wp_parse_args( $args, $defaults ); |
|
194 | + $parsed_args = wp_parse_args($args, $defaults); |
|
195 | 195 | |
196 | 196 | $this->init(); |
197 | 197 | $this->upgrade_strings(); |
198 | 198 | |
199 | - $current = get_site_transient( 'update_plugins' ); |
|
200 | - if ( ! isset( $current->response[ $plugin ] ) ) { |
|
199 | + $current = get_site_transient('update_plugins'); |
|
200 | + if (!isset($current->response[$plugin])) { |
|
201 | 201 | $this->skin->before(); |
202 | - $this->skin->set_result( false ); |
|
203 | - $this->skin->error( 'up_to_date' ); |
|
202 | + $this->skin->set_result(false); |
|
203 | + $this->skin->error('up_to_date'); |
|
204 | 204 | $this->skin->after(); |
205 | 205 | return false; |
206 | 206 | } |
207 | 207 | |
208 | 208 | // Get the URL to the zip file. |
209 | - $r = $current->response[ $plugin ]; |
|
209 | + $r = $current->response[$plugin]; |
|
210 | 210 | |
211 | - add_filter( 'upgrader_pre_install', array( $this, 'deactivate_plugin_before_upgrade' ), 10, 2 ); |
|
212 | - add_filter( 'upgrader_pre_install', array( $this, 'active_before' ), 10, 2 ); |
|
213 | - add_filter( 'upgrader_clear_destination', array( $this, 'delete_old_plugin' ), 10, 4 ); |
|
214 | - add_filter( 'upgrader_post_install', array( $this, 'active_after' ), 10, 2 ); |
|
211 | + add_filter('upgrader_pre_install', array($this, 'deactivate_plugin_before_upgrade'), 10, 2); |
|
212 | + add_filter('upgrader_pre_install', array($this, 'active_before'), 10, 2); |
|
213 | + add_filter('upgrader_clear_destination', array($this, 'delete_old_plugin'), 10, 4); |
|
214 | + add_filter('upgrader_post_install', array($this, 'active_after'), 10, 2); |
|
215 | 215 | // There's a Trac ticket to move up the directory for zips which are made a bit differently, useful for non-.org plugins. |
216 | 216 | // 'source_selection' => array( $this, 'source_selection' ), |
217 | - if ( $parsed_args['clear_update_cache'] ) { |
|
217 | + if ($parsed_args['clear_update_cache']) { |
|
218 | 218 | // Clear cache so wp_update_plugins() knows about the new plugin. |
219 | - add_action( 'upgrader_process_complete', 'wp_clean_plugins_cache', 9, 0 ); |
|
219 | + add_action('upgrader_process_complete', 'wp_clean_plugins_cache', 9, 0); |
|
220 | 220 | } |
221 | 221 | |
222 | 222 | $this->run( |
@@ -234,26 +234,26 @@ discard block |
||
234 | 234 | ); |
235 | 235 | |
236 | 236 | // Cleanup our hooks, in case something else does a upgrade on this connection. |
237 | - remove_action( 'upgrader_process_complete', 'wp_clean_plugins_cache', 9 ); |
|
238 | - remove_filter( 'upgrader_pre_install', array( $this, 'deactivate_plugin_before_upgrade' ) ); |
|
239 | - remove_filter( 'upgrader_pre_install', array( $this, 'active_before' ) ); |
|
240 | - remove_filter( 'upgrader_clear_destination', array( $this, 'delete_old_plugin' ) ); |
|
241 | - remove_filter( 'upgrader_post_install', array( $this, 'active_after' ) ); |
|
237 | + remove_action('upgrader_process_complete', 'wp_clean_plugins_cache', 9); |
|
238 | + remove_filter('upgrader_pre_install', array($this, 'deactivate_plugin_before_upgrade')); |
|
239 | + remove_filter('upgrader_pre_install', array($this, 'active_before')); |
|
240 | + remove_filter('upgrader_clear_destination', array($this, 'delete_old_plugin')); |
|
241 | + remove_filter('upgrader_post_install', array($this, 'active_after')); |
|
242 | 242 | |
243 | - if ( ! $this->result || is_wp_error( $this->result ) ) { |
|
243 | + if (!$this->result || is_wp_error($this->result)) { |
|
244 | 244 | return $this->result; |
245 | 245 | } |
246 | 246 | |
247 | 247 | // Force refresh of plugin update information. |
248 | - wp_clean_plugins_cache( $parsed_args['clear_update_cache'] ); |
|
248 | + wp_clean_plugins_cache($parsed_args['clear_update_cache']); |
|
249 | 249 | |
250 | 250 | // Ensure any future auto-update failures trigger a failure email by removing |
251 | 251 | // the last failure notification from the list when plugins update successfully. |
252 | - $past_failure_emails = get_option( 'auto_plugin_theme_update_emails', array() ); |
|
252 | + $past_failure_emails = get_option('auto_plugin_theme_update_emails', array()); |
|
253 | 253 | |
254 | - if ( isset( $past_failure_emails[ $plugin ] ) ) { |
|
255 | - unset( $past_failure_emails[ $plugin ] ); |
|
256 | - update_option( 'auto_plugin_theme_update_emails', $past_failure_emails ); |
|
254 | + if (isset($past_failure_emails[$plugin])) { |
|
255 | + unset($past_failure_emails[$plugin]); |
|
256 | + update_option('auto_plugin_theme_update_emails', $past_failure_emails); |
|
257 | 257 | } |
258 | 258 | |
259 | 259 | return true; |
@@ -273,25 +273,25 @@ discard block |
||
273 | 273 | * } |
274 | 274 | * @return array|false An array of results indexed by plugin file, or false if unable to connect to the filesystem. |
275 | 275 | */ |
276 | - public function bulk_upgrade( $plugins, $args = array() ) { |
|
276 | + public function bulk_upgrade($plugins, $args = array()) { |
|
277 | 277 | $defaults = array( |
278 | 278 | 'clear_update_cache' => true, |
279 | 279 | ); |
280 | - $parsed_args = wp_parse_args( $args, $defaults ); |
|
280 | + $parsed_args = wp_parse_args($args, $defaults); |
|
281 | 281 | |
282 | 282 | $this->init(); |
283 | 283 | $this->bulk = true; |
284 | 284 | $this->upgrade_strings(); |
285 | 285 | |
286 | - $current = get_site_transient( 'update_plugins' ); |
|
286 | + $current = get_site_transient('update_plugins'); |
|
287 | 287 | |
288 | - add_filter( 'upgrader_clear_destination', array( $this, 'delete_old_plugin' ), 10, 4 ); |
|
288 | + add_filter('upgrader_clear_destination', array($this, 'delete_old_plugin'), 10, 4); |
|
289 | 289 | |
290 | 290 | $this->skin->header(); |
291 | 291 | |
292 | 292 | // Connect to the filesystem first. |
293 | - $res = $this->fs_connect( array( WP_CONTENT_DIR, WP_PLUGIN_DIR ) ); |
|
294 | - if ( ! $res ) { |
|
293 | + $res = $this->fs_connect(array(WP_CONTENT_DIR, WP_PLUGIN_DIR)); |
|
294 | + if (!$res) { |
|
295 | 295 | $this->skin->footer(); |
296 | 296 | return false; |
297 | 297 | } |
@@ -304,35 +304,35 @@ discard block |
||
304 | 304 | * - a plugin with an update available is currently active. |
305 | 305 | * @todo For multisite, maintenance mode should only kick in for individual sites if at all possible. |
306 | 306 | */ |
307 | - $maintenance = ( is_multisite() && ! empty( $plugins ) ); |
|
308 | - foreach ( $plugins as $plugin ) { |
|
309 | - $maintenance = $maintenance || ( is_plugin_active( $plugin ) && isset( $current->response[ $plugin ] ) ); |
|
307 | + $maintenance = (is_multisite() && !empty($plugins)); |
|
308 | + foreach ($plugins as $plugin) { |
|
309 | + $maintenance = $maintenance || (is_plugin_active($plugin) && isset($current->response[$plugin])); |
|
310 | 310 | } |
311 | - if ( $maintenance ) { |
|
312 | - $this->maintenance_mode( true ); |
|
311 | + if ($maintenance) { |
|
312 | + $this->maintenance_mode(true); |
|
313 | 313 | } |
314 | 314 | |
315 | 315 | $results = array(); |
316 | 316 | |
317 | - $this->update_count = count( $plugins ); |
|
317 | + $this->update_count = count($plugins); |
|
318 | 318 | $this->update_current = 0; |
319 | - foreach ( $plugins as $plugin ) { |
|
319 | + foreach ($plugins as $plugin) { |
|
320 | 320 | $this->update_current++; |
321 | - $this->skin->plugin_info = get_plugin_data( WP_PLUGIN_DIR . '/' . $plugin, false, true ); |
|
321 | + $this->skin->plugin_info = get_plugin_data(WP_PLUGIN_DIR . '/' . $plugin, false, true); |
|
322 | 322 | |
323 | - if ( ! isset( $current->response[ $plugin ] ) ) { |
|
324 | - $this->skin->set_result( 'up_to_date' ); |
|
323 | + if (!isset($current->response[$plugin])) { |
|
324 | + $this->skin->set_result('up_to_date'); |
|
325 | 325 | $this->skin->before(); |
326 | - $this->skin->feedback( 'up_to_date' ); |
|
326 | + $this->skin->feedback('up_to_date'); |
|
327 | 327 | $this->skin->after(); |
328 | - $results[ $plugin ] = true; |
|
328 | + $results[$plugin] = true; |
|
329 | 329 | continue; |
330 | 330 | } |
331 | 331 | |
332 | 332 | // Get the URL to the zip file. |
333 | - $r = $current->response[ $plugin ]; |
|
333 | + $r = $current->response[$plugin]; |
|
334 | 334 | |
335 | - $this->skin->plugin_active = is_plugin_active( $plugin ); |
|
335 | + $this->skin->plugin_active = is_plugin_active($plugin); |
|
336 | 336 | |
337 | 337 | $result = $this->run( |
338 | 338 | array( |
@@ -347,18 +347,18 @@ discard block |
||
347 | 347 | ) |
348 | 348 | ); |
349 | 349 | |
350 | - $results[ $plugin ] = $result; |
|
350 | + $results[$plugin] = $result; |
|
351 | 351 | |
352 | 352 | // Prevent credentials auth screen from displaying multiple times. |
353 | - if ( false === $result ) { |
|
353 | + if (false === $result) { |
|
354 | 354 | break; |
355 | 355 | } |
356 | 356 | } // End foreach $plugins. |
357 | 357 | |
358 | - $this->maintenance_mode( false ); |
|
358 | + $this->maintenance_mode(false); |
|
359 | 359 | |
360 | 360 | // Force refresh of plugin update information. |
361 | - wp_clean_plugins_cache( $parsed_args['clear_update_cache'] ); |
|
361 | + wp_clean_plugins_cache($parsed_args['clear_update_cache']); |
|
362 | 362 | |
363 | 363 | /** This action is documented in wp-admin/includes/class-wp-upgrader.php */ |
364 | 364 | do_action( |
@@ -377,22 +377,22 @@ discard block |
||
377 | 377 | $this->skin->footer(); |
378 | 378 | |
379 | 379 | // Cleanup our hooks, in case something else does a upgrade on this connection. |
380 | - remove_filter( 'upgrader_clear_destination', array( $this, 'delete_old_plugin' ) ); |
|
380 | + remove_filter('upgrader_clear_destination', array($this, 'delete_old_plugin')); |
|
381 | 381 | |
382 | 382 | // Ensure any future auto-update failures trigger a failure email by removing |
383 | 383 | // the last failure notification from the list when plugins update successfully. |
384 | - $past_failure_emails = get_option( 'auto_plugin_theme_update_emails', array() ); |
|
384 | + $past_failure_emails = get_option('auto_plugin_theme_update_emails', array()); |
|
385 | 385 | |
386 | - foreach ( $results as $plugin => $result ) { |
|
386 | + foreach ($results as $plugin => $result) { |
|
387 | 387 | // Maintain last failure notification when plugins failed to update manually. |
388 | - if ( ! $result || is_wp_error( $result ) || ! isset( $past_failure_emails[ $plugin ] ) ) { |
|
388 | + if (!$result || is_wp_error($result) || !isset($past_failure_emails[$plugin])) { |
|
389 | 389 | continue; |
390 | 390 | } |
391 | 391 | |
392 | - unset( $past_failure_emails[ $plugin ] ); |
|
392 | + unset($past_failure_emails[$plugin]); |
|
393 | 393 | } |
394 | 394 | |
395 | - update_option( 'auto_plugin_theme_update_emails', $past_failure_emails ); |
|
395 | + update_option('auto_plugin_theme_update_emails', $past_failure_emails); |
|
396 | 396 | |
397 | 397 | return $results; |
398 | 398 | } |
@@ -410,59 +410,59 @@ discard block |
||
410 | 410 | * @param string $source The path to the downloaded package source. |
411 | 411 | * @return string|WP_Error The source as passed, or a WP_Error object on failure. |
412 | 412 | */ |
413 | - public function check_package( $source ) { |
|
413 | + public function check_package($source) { |
|
414 | 414 | global $wp_filesystem, $wp_version; |
415 | 415 | |
416 | 416 | $this->new_plugin_data = array(); |
417 | 417 | |
418 | - if ( is_wp_error( $source ) ) { |
|
418 | + if (is_wp_error($source)) { |
|
419 | 419 | return $source; |
420 | 420 | } |
421 | 421 | |
422 | - $working_directory = str_replace( $wp_filesystem->wp_content_dir(), trailingslashit( WP_CONTENT_DIR ), $source ); |
|
423 | - if ( ! is_dir( $working_directory ) ) { // Sanity check, if the above fails, let's not prevent installation. |
|
422 | + $working_directory = str_replace($wp_filesystem->wp_content_dir(), trailingslashit(WP_CONTENT_DIR), $source); |
|
423 | + if (!is_dir($working_directory)) { // Sanity check, if the above fails, let's not prevent installation. |
|
424 | 424 | return $source; |
425 | 425 | } |
426 | 426 | |
427 | 427 | // Check that the folder contains at least 1 valid plugin. |
428 | - $files = glob( $working_directory . '*.php' ); |
|
429 | - if ( $files ) { |
|
430 | - foreach ( $files as $file ) { |
|
431 | - $info = get_plugin_data( $file, false, false ); |
|
432 | - if ( ! empty( $info['Name'] ) ) { |
|
428 | + $files = glob($working_directory . '*.php'); |
|
429 | + if ($files) { |
|
430 | + foreach ($files as $file) { |
|
431 | + $info = get_plugin_data($file, false, false); |
|
432 | + if (!empty($info['Name'])) { |
|
433 | 433 | $this->new_plugin_data = $info; |
434 | 434 | break; |
435 | 435 | } |
436 | 436 | } |
437 | 437 | } |
438 | 438 | |
439 | - if ( empty( $this->new_plugin_data ) ) { |
|
440 | - return new WP_Error( 'incompatible_archive_no_plugins', $this->strings['incompatible_archive'], __( 'No valid plugins were found.' ) ); |
|
439 | + if (empty($this->new_plugin_data)) { |
|
440 | + return new WP_Error('incompatible_archive_no_plugins', $this->strings['incompatible_archive'], __('No valid plugins were found.')); |
|
441 | 441 | } |
442 | 442 | |
443 | - $requires_php = isset( $info['RequiresPHP'] ) ? $info['RequiresPHP'] : null; |
|
444 | - $requires_wp = isset( $info['RequiresWP'] ) ? $info['RequiresWP'] : null; |
|
443 | + $requires_php = isset($info['RequiresPHP']) ? $info['RequiresPHP'] : null; |
|
444 | + $requires_wp = isset($info['RequiresWP']) ? $info['RequiresWP'] : null; |
|
445 | 445 | |
446 | - if ( ! is_php_version_compatible( $requires_php ) ) { |
|
446 | + if (!is_php_version_compatible($requires_php)) { |
|
447 | 447 | $error = sprintf( |
448 | 448 | /* translators: 1: Current PHP version, 2: Version required by the uploaded plugin. */ |
449 | - __( 'The PHP version on your server is %1$s, however the uploaded plugin requires %2$s.' ), |
|
449 | + __('The PHP version on your server is %1$s, however the uploaded plugin requires %2$s.'), |
|
450 | 450 | phpversion(), |
451 | 451 | $requires_php |
452 | 452 | ); |
453 | 453 | |
454 | - return new WP_Error( 'incompatible_php_required_version', $this->strings['incompatible_archive'], $error ); |
|
454 | + return new WP_Error('incompatible_php_required_version', $this->strings['incompatible_archive'], $error); |
|
455 | 455 | } |
456 | 456 | |
457 | - if ( ! is_wp_version_compatible( $requires_wp ) ) { |
|
457 | + if (!is_wp_version_compatible($requires_wp)) { |
|
458 | 458 | $error = sprintf( |
459 | 459 | /* translators: 1: Current WordPress version, 2: Version required by the uploaded plugin. */ |
460 | - __( 'Your WordPress version is %1$s, however the uploaded plugin requires %2$s.' ), |
|
460 | + __('Your WordPress version is %1$s, however the uploaded plugin requires %2$s.'), |
|
461 | 461 | $wp_version, |
462 | 462 | $requires_wp |
463 | 463 | ); |
464 | 464 | |
465 | - return new WP_Error( 'incompatible_wp_required_version', $this->strings['incompatible_archive'], $error ); |
|
465 | + return new WP_Error('incompatible_wp_required_version', $this->strings['incompatible_archive'], $error); |
|
466 | 466 | } |
467 | 467 | |
468 | 468 | return $source; |
@@ -478,21 +478,21 @@ discard block |
||
478 | 478 | * @return string|false The full path to the main plugin file, or false. |
479 | 479 | */ |
480 | 480 | public function plugin_info() { |
481 | - if ( ! is_array( $this->result ) ) { |
|
481 | + if (!is_array($this->result)) { |
|
482 | 482 | return false; |
483 | 483 | } |
484 | - if ( empty( $this->result['destination_name'] ) ) { |
|
484 | + if (empty($this->result['destination_name'])) { |
|
485 | 485 | return false; |
486 | 486 | } |
487 | 487 | |
488 | 488 | // Ensure to pass with leading slash. |
489 | - $plugin = get_plugins( '/' . $this->result['destination_name'] ); |
|
490 | - if ( empty( $plugin ) ) { |
|
489 | + $plugin = get_plugins('/' . $this->result['destination_name']); |
|
490 | + if (empty($plugin)) { |
|
491 | 491 | return false; |
492 | 492 | } |
493 | 493 | |
494 | 494 | // Assume the requested plugin is the first in the list. |
495 | - $pluginfiles = array_keys( $plugin ); |
|
495 | + $pluginfiles = array_keys($plugin); |
|
496 | 496 | |
497 | 497 | return $this->result['destination_name'] . '/' . $pluginfiles[0]; |
498 | 498 | } |
@@ -509,25 +509,25 @@ discard block |
||
509 | 509 | * @param array $plugin Plugin package arguments. |
510 | 510 | * @return bool|WP_Error The original `$response` parameter or WP_Error. |
511 | 511 | */ |
512 | - public function deactivate_plugin_before_upgrade( $response, $plugin ) { |
|
512 | + public function deactivate_plugin_before_upgrade($response, $plugin) { |
|
513 | 513 | |
514 | - if ( is_wp_error( $response ) ) { // Bypass. |
|
514 | + if (is_wp_error($response)) { // Bypass. |
|
515 | 515 | return $response; |
516 | 516 | } |
517 | 517 | |
518 | 518 | // When in cron (background updates) don't deactivate the plugin, as we require a browser to reactivate it. |
519 | - if ( wp_doing_cron() ) { |
|
519 | + if (wp_doing_cron()) { |
|
520 | 520 | return $response; |
521 | 521 | } |
522 | 522 | |
523 | - $plugin = isset( $plugin['plugin'] ) ? $plugin['plugin'] : ''; |
|
524 | - if ( empty( $plugin ) ) { |
|
525 | - return new WP_Error( 'bad_request', $this->strings['bad_request'] ); |
|
523 | + $plugin = isset($plugin['plugin']) ? $plugin['plugin'] : ''; |
|
524 | + if (empty($plugin)) { |
|
525 | + return new WP_Error('bad_request', $this->strings['bad_request']); |
|
526 | 526 | } |
527 | 527 | |
528 | - if ( is_plugin_active( $plugin ) ) { |
|
528 | + if (is_plugin_active($plugin)) { |
|
529 | 529 | // Deactivate the plugin silently, Prevent deactivation hooks from running. |
530 | - deactivate_plugins( $plugin, true ); |
|
530 | + deactivate_plugins($plugin, true); |
|
531 | 531 | } |
532 | 532 | |
533 | 533 | return $response; |
@@ -544,26 +544,26 @@ discard block |
||
544 | 544 | * @param array $plugin Plugin package arguments. |
545 | 545 | * @return bool|WP_Error The original `$response` parameter or WP_Error. |
546 | 546 | */ |
547 | - public function active_before( $response, $plugin ) { |
|
548 | - if ( is_wp_error( $response ) ) { |
|
547 | + public function active_before($response, $plugin) { |
|
548 | + if (is_wp_error($response)) { |
|
549 | 549 | return $response; |
550 | 550 | } |
551 | 551 | |
552 | 552 | // Only enable maintenance mode when in cron (background update). |
553 | - if ( ! wp_doing_cron() ) { |
|
553 | + if (!wp_doing_cron()) { |
|
554 | 554 | return $response; |
555 | 555 | } |
556 | 556 | |
557 | - $plugin = isset( $plugin['plugin'] ) ? $plugin['plugin'] : ''; |
|
557 | + $plugin = isset($plugin['plugin']) ? $plugin['plugin'] : ''; |
|
558 | 558 | |
559 | 559 | // Only run if plugin is active. |
560 | - if ( ! is_plugin_active( $plugin ) ) { |
|
560 | + if (!is_plugin_active($plugin)) { |
|
561 | 561 | return $response; |
562 | 562 | } |
563 | 563 | |
564 | 564 | // Change to maintenance mode. Bulk edit handles this separately. |
565 | - if ( ! $this->bulk ) { |
|
566 | - $this->maintenance_mode( true ); |
|
565 | + if (!$this->bulk) { |
|
566 | + $this->maintenance_mode(true); |
|
567 | 567 | } |
568 | 568 | |
569 | 569 | return $response; |
@@ -580,26 +580,26 @@ discard block |
||
580 | 580 | * @param array $plugin Plugin package arguments. |
581 | 581 | * @return bool|WP_Error The original `$response` parameter or WP_Error. |
582 | 582 | */ |
583 | - public function active_after( $response, $plugin ) { |
|
584 | - if ( is_wp_error( $response ) ) { |
|
583 | + public function active_after($response, $plugin) { |
|
584 | + if (is_wp_error($response)) { |
|
585 | 585 | return $response; |
586 | 586 | } |
587 | 587 | |
588 | 588 | // Only disable maintenance mode when in cron (background update). |
589 | - if ( ! wp_doing_cron() ) { |
|
589 | + if (!wp_doing_cron()) { |
|
590 | 590 | return $response; |
591 | 591 | } |
592 | 592 | |
593 | - $plugin = isset( $plugin['plugin'] ) ? $plugin['plugin'] : ''; |
|
593 | + $plugin = isset($plugin['plugin']) ? $plugin['plugin'] : ''; |
|
594 | 594 | |
595 | 595 | // Only run if plugin is active. |
596 | - if ( ! is_plugin_active( $plugin ) ) { |
|
596 | + if (!is_plugin_active($plugin)) { |
|
597 | 597 | return $response; |
598 | 598 | } |
599 | 599 | |
600 | 600 | // Time to remove maintenance mode. Bulk edit handles this separately. |
601 | - if ( ! $this->bulk ) { |
|
602 | - $this->maintenance_mode( false ); |
|
601 | + if (!$this->bulk) { |
|
602 | + $this->maintenance_mode(false); |
|
603 | 603 | } |
604 | 604 | |
605 | 605 | return $response; |
@@ -622,35 +622,35 @@ discard block |
||
622 | 622 | * @param array $plugin Extra arguments passed to hooked filters. |
623 | 623 | * @return bool|WP_Error |
624 | 624 | */ |
625 | - public function delete_old_plugin( $removed, $local_destination, $remote_destination, $plugin ) { |
|
625 | + public function delete_old_plugin($removed, $local_destination, $remote_destination, $plugin) { |
|
626 | 626 | global $wp_filesystem; |
627 | 627 | |
628 | - if ( is_wp_error( $removed ) ) { |
|
628 | + if (is_wp_error($removed)) { |
|
629 | 629 | return $removed; // Pass errors through. |
630 | 630 | } |
631 | 631 | |
632 | - $plugin = isset( $plugin['plugin'] ) ? $plugin['plugin'] : ''; |
|
633 | - if ( empty( $plugin ) ) { |
|
634 | - return new WP_Error( 'bad_request', $this->strings['bad_request'] ); |
|
632 | + $plugin = isset($plugin['plugin']) ? $plugin['plugin'] : ''; |
|
633 | + if (empty($plugin)) { |
|
634 | + return new WP_Error('bad_request', $this->strings['bad_request']); |
|
635 | 635 | } |
636 | 636 | |
637 | 637 | $plugins_dir = $wp_filesystem->wp_plugins_dir(); |
638 | - $this_plugin_dir = trailingslashit( dirname( $plugins_dir . $plugin ) ); |
|
638 | + $this_plugin_dir = trailingslashit(dirname($plugins_dir . $plugin)); |
|
639 | 639 | |
640 | - if ( ! $wp_filesystem->exists( $this_plugin_dir ) ) { // If it's already vanished. |
|
640 | + if (!$wp_filesystem->exists($this_plugin_dir)) { // If it's already vanished. |
|
641 | 641 | return $removed; |
642 | 642 | } |
643 | 643 | |
644 | 644 | // If plugin is in its own directory, recursively delete the directory. |
645 | 645 | // Base check on if plugin includes directory separator AND that it's not the root plugin folder. |
646 | - if ( strpos( $plugin, '/' ) && $this_plugin_dir !== $plugins_dir ) { |
|
647 | - $deleted = $wp_filesystem->delete( $this_plugin_dir, true ); |
|
646 | + if (strpos($plugin, '/') && $this_plugin_dir !== $plugins_dir) { |
|
647 | + $deleted = $wp_filesystem->delete($this_plugin_dir, true); |
|
648 | 648 | } else { |
649 | - $deleted = $wp_filesystem->delete( $plugins_dir . $plugin ); |
|
649 | + $deleted = $wp_filesystem->delete($plugins_dir . $plugin); |
|
650 | 650 | } |
651 | 651 | |
652 | - if ( ! $deleted ) { |
|
653 | - return new WP_Error( 'remove_old_failed', $this->strings['remove_old_failed'] ); |
|
652 | + if (!$deleted) { |
|
653 | + return new WP_Error('remove_old_failed', $this->strings['remove_old_failed']); |
|
654 | 654 | } |
655 | 655 | |
656 | 656 | return true; |