@@ -54,21 +54,21 @@ discard block |
||
54 | 54 | * @param array $args Optional. The plugin upgrader skin arguments to |
55 | 55 | * override default options. Default empty array. |
56 | 56 | */ |
57 | - public function __construct( $args = array() ) { |
|
57 | + public function __construct($args = array()) { |
|
58 | 58 | $defaults = array( |
59 | 59 | 'url' => '', |
60 | 60 | 'plugin' => '', |
61 | 61 | 'nonce' => '', |
62 | - 'title' => __( 'Update Plugin' ), |
|
62 | + 'title' => __('Update Plugin'), |
|
63 | 63 | ); |
64 | - $args = wp_parse_args( $args, $defaults ); |
|
64 | + $args = wp_parse_args($args, $defaults); |
|
65 | 65 | |
66 | 66 | $this->plugin = $args['plugin']; |
67 | 67 | |
68 | - $this->plugin_active = is_plugin_active( $this->plugin ); |
|
69 | - $this->plugin_network_active = is_plugin_active_for_network( $this->plugin ); |
|
68 | + $this->plugin_active = is_plugin_active($this->plugin); |
|
69 | + $this->plugin_network_active = is_plugin_active_for_network($this->plugin); |
|
70 | 70 | |
71 | - parent::__construct( $args ); |
|
71 | + parent::__construct($args); |
|
72 | 72 | } |
73 | 73 | |
74 | 74 | /** |
@@ -78,32 +78,32 @@ discard block |
||
78 | 78 | */ |
79 | 79 | public function after() { |
80 | 80 | $this->plugin = $this->upgrader->plugin_info(); |
81 | - if ( ! empty( $this->plugin ) && ! is_wp_error( $this->result ) && $this->plugin_active ) { |
|
81 | + if (!empty($this->plugin) && !is_wp_error($this->result) && $this->plugin_active) { |
|
82 | 82 | // Currently used only when JS is off for a single plugin update? |
83 | 83 | printf( |
84 | 84 | '<iframe title="%s" style="border:0;overflow:hidden" width="100%%" height="170" src="%s"></iframe>', |
85 | - esc_attr__( 'Update progress' ), |
|
86 | - wp_nonce_url( 'update.php?action=activate-plugin&networkwide=' . $this->plugin_network_active . '&plugin=' . urlencode( $this->plugin ), 'activate-plugin_' . $this->plugin ) |
|
85 | + esc_attr__('Update progress'), |
|
86 | + wp_nonce_url('update.php?action=activate-plugin&networkwide=' . $this->plugin_network_active . '&plugin=' . urlencode($this->plugin), 'activate-plugin_' . $this->plugin) |
|
87 | 87 | ); |
88 | 88 | } |
89 | 89 | |
90 | - $this->decrement_update_count( 'plugin' ); |
|
90 | + $this->decrement_update_count('plugin'); |
|
91 | 91 | |
92 | 92 | $update_actions = array( |
93 | 93 | 'activate_plugin' => sprintf( |
94 | 94 | '<a href="%s" target="_parent">%s</a>', |
95 | - wp_nonce_url( 'plugins.php?action=activate&plugin=' . urlencode( $this->plugin ), 'activate-plugin_' . $this->plugin ), |
|
96 | - __( 'Activate Plugin' ) |
|
95 | + wp_nonce_url('plugins.php?action=activate&plugin=' . urlencode($this->plugin), 'activate-plugin_' . $this->plugin), |
|
96 | + __('Activate Plugin') |
|
97 | 97 | ), |
98 | 98 | 'plugins_page' => sprintf( |
99 | 99 | '<a href="%s" target="_parent">%s</a>', |
100 | - self_admin_url( 'plugins.php' ), |
|
101 | - __( 'Go to Plugins page' ) |
|
100 | + self_admin_url('plugins.php'), |
|
101 | + __('Go to Plugins page') |
|
102 | 102 | ), |
103 | 103 | ); |
104 | 104 | |
105 | - if ( $this->plugin_active || ! $this->result || is_wp_error( $this->result ) || ! current_user_can( 'activate_plugin', $this->plugin ) ) { |
|
106 | - unset( $update_actions['activate_plugin'] ); |
|
105 | + if ($this->plugin_active || !$this->result || is_wp_error($this->result) || !current_user_can('activate_plugin', $this->plugin)) { |
|
106 | + unset($update_actions['activate_plugin']); |
|
107 | 107 | } |
108 | 108 | |
109 | 109 | /** |
@@ -114,10 +114,10 @@ discard block |
||
114 | 114 | * @param string[] $update_actions Array of plugin action links. |
115 | 115 | * @param string $plugin Path to the plugin file relative to the plugins directory. |
116 | 116 | */ |
117 | - $update_actions = apply_filters( 'update_plugin_complete_actions', $update_actions, $this->plugin ); |
|
117 | + $update_actions = apply_filters('update_plugin_complete_actions', $update_actions, $this->plugin); |
|
118 | 118 | |
119 | - if ( ! empty( $update_actions ) ) { |
|
120 | - $this->feedback( implode( ' | ', (array) $update_actions ) ); |
|
119 | + if (!empty($update_actions)) { |
|
120 | + $this->feedback(implode(' | ', (array) $update_actions)); |
|
121 | 121 | } |
122 | 122 | } |
123 | 123 | } |
@@ -26,16 +26,16 @@ discard block |
||
26 | 26 | * @since 2.8.0 |
27 | 27 | */ |
28 | 28 | public function upgrade_strings() { |
29 | - $this->strings['up_to_date'] = __( 'WordPress is at the latest version.' ); |
|
30 | - $this->strings['locked'] = __( 'Another update is currently in progress.' ); |
|
31 | - $this->strings['no_package'] = __( 'Update package not available.' ); |
|
29 | + $this->strings['up_to_date'] = __('WordPress is at the latest version.'); |
|
30 | + $this->strings['locked'] = __('Another update is currently in progress.'); |
|
31 | + $this->strings['no_package'] = __('Update package not available.'); |
|
32 | 32 | /* translators: %s: Package URL. */ |
33 | - $this->strings['downloading_package'] = sprintf( __( 'Downloading update from %s…' ), '<span class="code">%s</span>' ); |
|
34 | - $this->strings['unpack_package'] = __( 'Unpacking the update…' ); |
|
35 | - $this->strings['copy_failed'] = __( 'Could not copy files.' ); |
|
36 | - $this->strings['copy_failed_space'] = __( 'Could not copy files. You may have run out of disk space.' ); |
|
37 | - $this->strings['start_rollback'] = __( 'Attempting to roll back to previous version.' ); |
|
38 | - $this->strings['rollback_was_required'] = __( 'Due to an error during updating, WordPress has rolled back to your previous version.' ); |
|
33 | + $this->strings['downloading_package'] = sprintf(__('Downloading update from %s…'), '<span class="code">%s</span>'); |
|
34 | + $this->strings['unpack_package'] = __('Unpacking the update…'); |
|
35 | + $this->strings['copy_failed'] = __('Could not copy files.'); |
|
36 | + $this->strings['copy_failed_space'] = __('Could not copy files. You may have run out of disk space.'); |
|
37 | + $this->strings['start_rollback'] = __('Attempting to roll back to previous version.'); |
|
38 | + $this->strings['rollback_was_required'] = __('Due to an error during updating, WordPress has rolled back to your previous version.'); |
|
39 | 39 | } |
40 | 40 | |
41 | 41 | /** |
@@ -59,40 +59,40 @@ discard block |
||
59 | 59 | * } |
60 | 60 | * @return string|false|WP_Error New WordPress version on success, false or WP_Error on failure. |
61 | 61 | */ |
62 | - public function upgrade( $current, $args = array() ) { |
|
62 | + public function upgrade($current, $args = array()) { |
|
63 | 63 | global $wp_filesystem; |
64 | 64 | |
65 | 65 | require ABSPATH . WPINC . '/version.php'; // $wp_version; |
66 | 66 | |
67 | 67 | $start_time = time(); |
68 | 68 | |
69 | - $defaults = array( |
|
69 | + $defaults = array( |
|
70 | 70 | 'pre_check_md5' => true, |
71 | 71 | 'attempt_rollback' => false, |
72 | 72 | 'do_rollback' => false, |
73 | 73 | 'allow_relaxed_file_ownership' => false, |
74 | 74 | ); |
75 | - $parsed_args = wp_parse_args( $args, $defaults ); |
|
75 | + $parsed_args = wp_parse_args($args, $defaults); |
|
76 | 76 | |
77 | 77 | $this->init(); |
78 | 78 | $this->upgrade_strings(); |
79 | 79 | |
80 | 80 | // Is an update available? |
81 | - if ( ! isset( $current->response ) || 'latest' === $current->response ) { |
|
82 | - return new WP_Error( 'up_to_date', $this->strings['up_to_date'] ); |
|
81 | + if (!isset($current->response) || 'latest' === $current->response) { |
|
82 | + return new WP_Error('up_to_date', $this->strings['up_to_date']); |
|
83 | 83 | } |
84 | 84 | |
85 | - $res = $this->fs_connect( array( ABSPATH, WP_CONTENT_DIR ), $parsed_args['allow_relaxed_file_ownership'] ); |
|
86 | - if ( ! $res || is_wp_error( $res ) ) { |
|
85 | + $res = $this->fs_connect(array(ABSPATH, WP_CONTENT_DIR), $parsed_args['allow_relaxed_file_ownership']); |
|
86 | + if (!$res || is_wp_error($res)) { |
|
87 | 87 | return $res; |
88 | 88 | } |
89 | 89 | |
90 | - $wp_dir = trailingslashit( $wp_filesystem->abspath() ); |
|
90 | + $wp_dir = trailingslashit($wp_filesystem->abspath()); |
|
91 | 91 | |
92 | 92 | $partial = true; |
93 | - if ( $parsed_args['do_rollback'] ) { |
|
93 | + if ($parsed_args['do_rollback']) { |
|
94 | 94 | $partial = false; |
95 | - } elseif ( $parsed_args['pre_check_md5'] && ! $this->check_files() ) { |
|
95 | + } elseif ($parsed_args['pre_check_md5'] && !$this->check_files()) { |
|
96 | 96 | $partial = false; |
97 | 97 | } |
98 | 98 | |
@@ -102,33 +102,33 @@ discard block |
||
102 | 102 | * the new_bundled zip. Don't though if the constant is set to skip bundled items. |
103 | 103 | * If the API returns a no_content zip, go with it. Finally, default to the full zip. |
104 | 104 | */ |
105 | - if ( $parsed_args['do_rollback'] && $current->packages->rollback ) { |
|
105 | + if ($parsed_args['do_rollback'] && $current->packages->rollback) { |
|
106 | 106 | $to_download = 'rollback'; |
107 | - } elseif ( $current->packages->partial && 'reinstall' !== $current->response && $wp_version === $current->partial_version && $partial ) { |
|
107 | + } elseif ($current->packages->partial && 'reinstall' !== $current->response && $wp_version === $current->partial_version && $partial) { |
|
108 | 108 | $to_download = 'partial'; |
109 | - } elseif ( $current->packages->new_bundled && version_compare( $wp_version, $current->new_bundled, '<' ) |
|
110 | - && ( ! defined( 'CORE_UPGRADE_SKIP_NEW_BUNDLED' ) || ! CORE_UPGRADE_SKIP_NEW_BUNDLED ) ) { |
|
109 | + } elseif ($current->packages->new_bundled && version_compare($wp_version, $current->new_bundled, '<') |
|
110 | + && (!defined('CORE_UPGRADE_SKIP_NEW_BUNDLED') || !CORE_UPGRADE_SKIP_NEW_BUNDLED)) { |
|
111 | 111 | $to_download = 'new_bundled'; |
112 | - } elseif ( $current->packages->no_content ) { |
|
112 | + } elseif ($current->packages->no_content) { |
|
113 | 113 | $to_download = 'no_content'; |
114 | 114 | } else { |
115 | 115 | $to_download = 'full'; |
116 | 116 | } |
117 | 117 | |
118 | 118 | // Lock to prevent multiple Core Updates occurring. |
119 | - $lock = WP_Upgrader::create_lock( 'core_updater', 15 * MINUTE_IN_SECONDS ); |
|
120 | - if ( ! $lock ) { |
|
121 | - return new WP_Error( 'locked', $this->strings['locked'] ); |
|
119 | + $lock = WP_Upgrader::create_lock('core_updater', 15 * MINUTE_IN_SECONDS); |
|
120 | + if (!$lock) { |
|
121 | + return new WP_Error('locked', $this->strings['locked']); |
|
122 | 122 | } |
123 | 123 | |
124 | - $download = $this->download_package( $current->packages->$to_download, true ); |
|
124 | + $download = $this->download_package($current->packages->$to_download, true); |
|
125 | 125 | |
126 | 126 | // Allow for signature soft-fail. |
127 | 127 | // WARNING: This may be removed in the future. |
128 | - if ( is_wp_error( $download ) && $download->get_error_data( 'softfail-filename' ) ) { |
|
128 | + if (is_wp_error($download) && $download->get_error_data('softfail-filename')) { |
|
129 | 129 | // Output the failure error as a normal feedback, and not as an error: |
130 | 130 | /** This filter is documented in wp-admin/includes/update-core.php */ |
131 | - apply_filters( 'update_feedback', $download->get_error_message() ); |
|
131 | + apply_filters('update_feedback', $download->get_error_message()); |
|
132 | 132 | |
133 | 133 | // Report this failure back to WordPress.org for debugging purposes. |
134 | 134 | wp_version_check( |
@@ -139,65 +139,65 @@ discard block |
||
139 | 139 | ); |
140 | 140 | |
141 | 141 | // Pretend this error didn't happen. |
142 | - $download = $download->get_error_data( 'softfail-filename' ); |
|
142 | + $download = $download->get_error_data('softfail-filename'); |
|
143 | 143 | } |
144 | 144 | |
145 | - if ( is_wp_error( $download ) ) { |
|
146 | - WP_Upgrader::release_lock( 'core_updater' ); |
|
145 | + if (is_wp_error($download)) { |
|
146 | + WP_Upgrader::release_lock('core_updater'); |
|
147 | 147 | return $download; |
148 | 148 | } |
149 | 149 | |
150 | - $working_dir = $this->unpack_package( $download ); |
|
151 | - if ( is_wp_error( $working_dir ) ) { |
|
152 | - WP_Upgrader::release_lock( 'core_updater' ); |
|
150 | + $working_dir = $this->unpack_package($download); |
|
151 | + if (is_wp_error($working_dir)) { |
|
152 | + WP_Upgrader::release_lock('core_updater'); |
|
153 | 153 | return $working_dir; |
154 | 154 | } |
155 | 155 | |
156 | 156 | // Copy update-core.php from the new version into place. |
157 | - if ( ! $wp_filesystem->copy( $working_dir . '/wordpress/wp-admin/includes/update-core.php', $wp_dir . 'wp-admin/includes/update-core.php', true ) ) { |
|
158 | - $wp_filesystem->delete( $working_dir, true ); |
|
159 | - WP_Upgrader::release_lock( 'core_updater' ); |
|
160 | - return new WP_Error( 'copy_failed_for_update_core_file', __( 'The update cannot be installed because some files could not be copied. This is usually due to inconsistent file permissions.' ), 'wp-admin/includes/update-core.php' ); |
|
157 | + if (!$wp_filesystem->copy($working_dir . '/wordpress/wp-admin/includes/update-core.php', $wp_dir . 'wp-admin/includes/update-core.php', true)) { |
|
158 | + $wp_filesystem->delete($working_dir, true); |
|
159 | + WP_Upgrader::release_lock('core_updater'); |
|
160 | + return new WP_Error('copy_failed_for_update_core_file', __('The update cannot be installed because some files could not be copied. This is usually due to inconsistent file permissions.'), 'wp-admin/includes/update-core.php'); |
|
161 | 161 | } |
162 | - $wp_filesystem->chmod( $wp_dir . 'wp-admin/includes/update-core.php', FS_CHMOD_FILE ); |
|
162 | + $wp_filesystem->chmod($wp_dir . 'wp-admin/includes/update-core.php', FS_CHMOD_FILE); |
|
163 | 163 | |
164 | - wp_opcache_invalidate( ABSPATH . 'wp-admin/includes/update-core.php' ); |
|
164 | + wp_opcache_invalidate(ABSPATH . 'wp-admin/includes/update-core.php'); |
|
165 | 165 | require_once ABSPATH . 'wp-admin/includes/update-core.php'; |
166 | 166 | |
167 | - if ( ! function_exists( 'update_core' ) ) { |
|
168 | - WP_Upgrader::release_lock( 'core_updater' ); |
|
169 | - return new WP_Error( 'copy_failed_space', $this->strings['copy_failed_space'] ); |
|
167 | + if (!function_exists('update_core')) { |
|
168 | + WP_Upgrader::release_lock('core_updater'); |
|
169 | + return new WP_Error('copy_failed_space', $this->strings['copy_failed_space']); |
|
170 | 170 | } |
171 | 171 | |
172 | - $result = update_core( $working_dir, $wp_dir ); |
|
172 | + $result = update_core($working_dir, $wp_dir); |
|
173 | 173 | |
174 | 174 | // In the event of an issue, we may be able to roll back. |
175 | - if ( $parsed_args['attempt_rollback'] && $current->packages->rollback && ! $parsed_args['do_rollback'] ) { |
|
175 | + if ($parsed_args['attempt_rollback'] && $current->packages->rollback && !$parsed_args['do_rollback']) { |
|
176 | 176 | $try_rollback = false; |
177 | - if ( is_wp_error( $result ) ) { |
|
177 | + if (is_wp_error($result)) { |
|
178 | 178 | $error_code = $result->get_error_code(); |
179 | 179 | /* |
180 | 180 | * Not all errors are equal. These codes are critical: copy_failed__copy_dir, |
181 | 181 | * mkdir_failed__copy_dir, copy_failed__copy_dir_retry, and disk_full. |
182 | 182 | * do_rollback allows for update_core() to trigger a rollback if needed. |
183 | 183 | */ |
184 | - if ( false !== strpos( $error_code, 'do_rollback' ) ) { |
|
184 | + if (false !== strpos($error_code, 'do_rollback')) { |
|
185 | 185 | $try_rollback = true; |
186 | - } elseif ( false !== strpos( $error_code, '__copy_dir' ) ) { |
|
186 | + } elseif (false !== strpos($error_code, '__copy_dir')) { |
|
187 | 187 | $try_rollback = true; |
188 | - } elseif ( 'disk_full' === $error_code ) { |
|
188 | + } elseif ('disk_full' === $error_code) { |
|
189 | 189 | $try_rollback = true; |
190 | 190 | } |
191 | 191 | } |
192 | 192 | |
193 | - if ( $try_rollback ) { |
|
193 | + if ($try_rollback) { |
|
194 | 194 | /** This filter is documented in wp-admin/includes/update-core.php */ |
195 | - apply_filters( 'update_feedback', $result ); |
|
195 | + apply_filters('update_feedback', $result); |
|
196 | 196 | |
197 | 197 | /** This filter is documented in wp-admin/includes/update-core.php */ |
198 | - apply_filters( 'update_feedback', $this->strings['start_rollback'] ); |
|
198 | + apply_filters('update_feedback', $this->strings['start_rollback']); |
|
199 | 199 | |
200 | - $rollback_result = $this->upgrade( $current, array_merge( $parsed_args, array( 'do_rollback' => true ) ) ); |
|
200 | + $rollback_result = $this->upgrade($current, array_merge($parsed_args, array('do_rollback' => true))); |
|
201 | 201 | |
202 | 202 | $original_result = $result; |
203 | 203 | $result = new WP_Error( |
@@ -222,29 +222,29 @@ discard block |
||
222 | 222 | ); |
223 | 223 | |
224 | 224 | // Clear the current updates. |
225 | - delete_site_transient( 'update_core' ); |
|
225 | + delete_site_transient('update_core'); |
|
226 | 226 | |
227 | - if ( ! $parsed_args['do_rollback'] ) { |
|
227 | + if (!$parsed_args['do_rollback']) { |
|
228 | 228 | $stats = array( |
229 | 229 | 'update_type' => $current->response, |
230 | 230 | 'success' => true, |
231 | 231 | 'fs_method' => $wp_filesystem->method, |
232 | - 'fs_method_forced' => defined( 'FS_METHOD' ) || has_filter( 'filesystem_method' ), |
|
233 | - 'fs_method_direct' => ! empty( $GLOBALS['_wp_filesystem_direct_method'] ) ? $GLOBALS['_wp_filesystem_direct_method'] : '', |
|
232 | + 'fs_method_forced' => defined('FS_METHOD') || has_filter('filesystem_method'), |
|
233 | + 'fs_method_direct' => !empty($GLOBALS['_wp_filesystem_direct_method']) ? $GLOBALS['_wp_filesystem_direct_method'] : '', |
|
234 | 234 | 'time_taken' => time() - $start_time, |
235 | 235 | 'reported' => $wp_version, |
236 | 236 | 'attempted' => $current->version, |
237 | 237 | ); |
238 | 238 | |
239 | - if ( is_wp_error( $result ) ) { |
|
239 | + if (is_wp_error($result)) { |
|
240 | 240 | $stats['success'] = false; |
241 | 241 | // Did a rollback occur? |
242 | - if ( ! empty( $try_rollback ) ) { |
|
242 | + if (!empty($try_rollback)) { |
|
243 | 243 | $stats['error_code'] = $original_result->get_error_code(); |
244 | 244 | $stats['error_data'] = $original_result->get_error_data(); |
245 | 245 | // Was the rollback successful? If not, collect its error too. |
246 | - $stats['rollback'] = ! is_wp_error( $rollback_result ); |
|
247 | - if ( is_wp_error( $rollback_result ) ) { |
|
246 | + $stats['rollback'] = !is_wp_error($rollback_result); |
|
247 | + if (is_wp_error($rollback_result)) { |
|
248 | 248 | $stats['rollback_code'] = $rollback_result->get_error_code(); |
249 | 249 | $stats['rollback_data'] = $rollback_result->get_error_data(); |
250 | 250 | } |
@@ -254,10 +254,10 @@ discard block |
||
254 | 254 | } |
255 | 255 | } |
256 | 256 | |
257 | - wp_version_check( $stats ); |
|
257 | + wp_version_check($stats); |
|
258 | 258 | } |
259 | 259 | |
260 | - WP_Upgrader::release_lock( 'core_updater' ); |
|
260 | + WP_Upgrader::release_lock('core_updater'); |
|
261 | 261 | |
262 | 262 | return $result; |
263 | 263 | } |
@@ -270,34 +270,34 @@ discard block |
||
270 | 270 | * @param string $offered_ver The offered version, of the format x.y.z. |
271 | 271 | * @return bool True if we should update to the offered version, otherwise false. |
272 | 272 | */ |
273 | - public static function should_update_to_version( $offered_ver ) { |
|
273 | + public static function should_update_to_version($offered_ver) { |
|
274 | 274 | require ABSPATH . WPINC . '/version.php'; // $wp_version; // x.y.z |
275 | 275 | |
276 | - $current_branch = implode( '.', array_slice( preg_split( '/[.-]/', $wp_version ), 0, 2 ) ); // x.y |
|
277 | - $new_branch = implode( '.', array_slice( preg_split( '/[.-]/', $offered_ver ), 0, 2 ) ); // x.y |
|
276 | + $current_branch = implode('.', array_slice(preg_split('/[.-]/', $wp_version), 0, 2)); // x.y |
|
277 | + $new_branch = implode('.', array_slice(preg_split('/[.-]/', $offered_ver), 0, 2)); // x.y |
|
278 | 278 | |
279 | - $current_is_development_version = (bool) strpos( $wp_version, '-' ); |
|
279 | + $current_is_development_version = (bool) strpos($wp_version, '-'); |
|
280 | 280 | |
281 | 281 | // Defaults: |
282 | - $upgrade_dev = get_site_option( 'auto_update_core_dev', 'enabled' ) === 'enabled'; |
|
283 | - $upgrade_minor = get_site_option( 'auto_update_core_minor', 'enabled' ) === 'enabled'; |
|
284 | - $upgrade_major = get_site_option( 'auto_update_core_major', 'unset' ) === 'enabled'; |
|
282 | + $upgrade_dev = get_site_option('auto_update_core_dev', 'enabled') === 'enabled'; |
|
283 | + $upgrade_minor = get_site_option('auto_update_core_minor', 'enabled') === 'enabled'; |
|
284 | + $upgrade_major = get_site_option('auto_update_core_major', 'unset') === 'enabled'; |
|
285 | 285 | |
286 | 286 | // WP_AUTO_UPDATE_CORE = true (all), 'beta', 'rc', 'development', 'branch-development', 'minor', false. |
287 | - if ( defined( 'WP_AUTO_UPDATE_CORE' ) ) { |
|
288 | - if ( false === WP_AUTO_UPDATE_CORE ) { |
|
287 | + if (defined('WP_AUTO_UPDATE_CORE')) { |
|
288 | + if (false === WP_AUTO_UPDATE_CORE) { |
|
289 | 289 | // Defaults to turned off, unless a filter allows it. |
290 | 290 | $upgrade_dev = false; |
291 | 291 | $upgrade_minor = false; |
292 | 292 | $upgrade_major = false; |
293 | - } elseif ( true === WP_AUTO_UPDATE_CORE |
|
294 | - || in_array( WP_AUTO_UPDATE_CORE, array( 'beta', 'rc', 'development', 'branch-development' ), true ) |
|
293 | + } elseif (true === WP_AUTO_UPDATE_CORE |
|
294 | + || in_array(WP_AUTO_UPDATE_CORE, array('beta', 'rc', 'development', 'branch-development'), true) |
|
295 | 295 | ) { |
296 | 296 | // ALL updates for core. |
297 | 297 | $upgrade_dev = true; |
298 | 298 | $upgrade_minor = true; |
299 | 299 | $upgrade_major = true; |
300 | - } elseif ( 'minor' === WP_AUTO_UPDATE_CORE ) { |
|
300 | + } elseif ('minor' === WP_AUTO_UPDATE_CORE) { |
|
301 | 301 | // Only minor updates for core. |
302 | 302 | $upgrade_dev = false; |
303 | 303 | $upgrade_minor = true; |
@@ -306,24 +306,24 @@ discard block |
||
306 | 306 | } |
307 | 307 | |
308 | 308 | // 1: If we're already on that version, not much point in updating? |
309 | - if ( $offered_ver === $wp_version ) { |
|
309 | + if ($offered_ver === $wp_version) { |
|
310 | 310 | return false; |
311 | 311 | } |
312 | 312 | |
313 | 313 | // 2: If we're running a newer version, that's a nope. |
314 | - if ( version_compare( $wp_version, $offered_ver, '>' ) ) { |
|
314 | + if (version_compare($wp_version, $offered_ver, '>')) { |
|
315 | 315 | return false; |
316 | 316 | } |
317 | 317 | |
318 | - $failure_data = get_site_option( 'auto_core_update_failed' ); |
|
319 | - if ( $failure_data ) { |
|
318 | + $failure_data = get_site_option('auto_core_update_failed'); |
|
319 | + if ($failure_data) { |
|
320 | 320 | // If this was a critical update failure, cannot update. |
321 | - if ( ! empty( $failure_data['critical'] ) ) { |
|
321 | + if (!empty($failure_data['critical'])) { |
|
322 | 322 | return false; |
323 | 323 | } |
324 | 324 | |
325 | 325 | // Don't claim we can update on update-core.php if we have a non-critical failure logged. |
326 | - if ( $wp_version === $failure_data['current'] && false !== strpos( $offered_ver, '.1.next.minor' ) ) { |
|
326 | + if ($wp_version === $failure_data['current'] && false !== strpos($offered_ver, '.1.next.minor')) { |
|
327 | 327 | return false; |
328 | 328 | } |
329 | 329 | |
@@ -332,13 +332,13 @@ discard block |
||
332 | 332 | * Some non-critical failures do allow retries, like download_failed. |
333 | 333 | * 3.7.1 => 3.7.2 resulted in files_not_writable, if we are still on 3.7.1 and still trying to update to 3.7.2. |
334 | 334 | */ |
335 | - if ( empty( $failure_data['retry'] ) && $wp_version === $failure_data['current'] && $offered_ver === $failure_data['attempted'] ) { |
|
335 | + if (empty($failure_data['retry']) && $wp_version === $failure_data['current'] && $offered_ver === $failure_data['attempted']) { |
|
336 | 336 | return false; |
337 | 337 | } |
338 | 338 | } |
339 | 339 | |
340 | 340 | // 3: 3.7-alpha-25000 -> 3.7-alpha-25678 -> 3.7-beta1 -> 3.7-beta2. |
341 | - if ( $current_is_development_version ) { |
|
341 | + if ($current_is_development_version) { |
|
342 | 342 | |
343 | 343 | /** |
344 | 344 | * Filters whether to enable automatic core updates for development versions. |
@@ -348,14 +348,14 @@ discard block |
||
348 | 348 | * @param bool $upgrade_dev Whether to enable automatic updates for |
349 | 349 | * development versions. |
350 | 350 | */ |
351 | - if ( ! apply_filters( 'allow_dev_auto_core_updates', $upgrade_dev ) ) { |
|
351 | + if (!apply_filters('allow_dev_auto_core_updates', $upgrade_dev)) { |
|
352 | 352 | return false; |
353 | 353 | } |
354 | 354 | // Else fall through to minor + major branches below. |
355 | 355 | } |
356 | 356 | |
357 | 357 | // 4: Minor in-branch updates (3.7.0 -> 3.7.1 -> 3.7.2 -> 3.7.4). |
358 | - if ( $current_branch === $new_branch ) { |
|
358 | + if ($current_branch === $new_branch) { |
|
359 | 359 | |
360 | 360 | /** |
361 | 361 | * Filters whether to enable minor automatic core updates. |
@@ -364,11 +364,11 @@ discard block |
||
364 | 364 | * |
365 | 365 | * @param bool $upgrade_minor Whether to enable minor automatic core updates. |
366 | 366 | */ |
367 | - return apply_filters( 'allow_minor_auto_core_updates', $upgrade_minor ); |
|
367 | + return apply_filters('allow_minor_auto_core_updates', $upgrade_minor); |
|
368 | 368 | } |
369 | 369 | |
370 | 370 | // 5: Major version updates (3.7.0 -> 3.8.0 -> 3.9.1). |
371 | - if ( version_compare( $new_branch, $current_branch, '>' ) ) { |
|
371 | + if (version_compare($new_branch, $current_branch, '>')) { |
|
372 | 372 | |
373 | 373 | /** |
374 | 374 | * Filters whether to enable major automatic core updates. |
@@ -377,7 +377,7 @@ discard block |
||
377 | 377 | * |
378 | 378 | * @param bool $upgrade_major Whether to enable major automatic core updates. |
379 | 379 | */ |
380 | - return apply_filters( 'allow_major_auto_core_updates', $upgrade_major ); |
|
380 | + return apply_filters('allow_major_auto_core_updates', $upgrade_major); |
|
381 | 381 | } |
382 | 382 | |
383 | 383 | // If we're not sure, we don't want it. |
@@ -397,18 +397,18 @@ discard block |
||
397 | 397 | public function check_files() { |
398 | 398 | global $wp_version, $wp_local_package; |
399 | 399 | |
400 | - $checksums = get_core_checksums( $wp_version, isset( $wp_local_package ) ? $wp_local_package : 'en_US' ); |
|
400 | + $checksums = get_core_checksums($wp_version, isset($wp_local_package) ? $wp_local_package : 'en_US'); |
|
401 | 401 | |
402 | - if ( ! is_array( $checksums ) ) { |
|
402 | + if (!is_array($checksums)) { |
|
403 | 403 | return false; |
404 | 404 | } |
405 | 405 | |
406 | - foreach ( $checksums as $file => $checksum ) { |
|
406 | + foreach ($checksums as $file => $checksum) { |
|
407 | 407 | // Skip files which get updated. |
408 | - if ( 'wp-content' === substr( $file, 0, 10 ) ) { |
|
408 | + if ('wp-content' === substr($file, 0, 10)) { |
|
409 | 409 | continue; |
410 | 410 | } |
411 | - if ( ! file_exists( ABSPATH . $file ) || md5_file( ABSPATH . $file ) !== $checksum ) { |
|
411 | + if (!file_exists(ABSPATH . $file) || md5_file(ABSPATH . $file) !== $checksum) { |
|
412 | 412 | return false; |
413 | 413 | } |
414 | 414 | } |
@@ -84,7 +84,7 @@ discard block |
||
84 | 84 | * |
85 | 85 | * @var array |
86 | 86 | */ |
87 | - protected $compat_fields = array( '_args', '_pagination_args', 'screen', '_actions', '_pagination' ); |
|
87 | + protected $compat_fields = array('_args', '_pagination_args', 'screen', '_actions', '_pagination'); |
|
88 | 88 | |
89 | 89 | /** |
90 | 90 | * {@internal Missing Summary} |
@@ -135,7 +135,7 @@ discard block |
||
135 | 135 | * Default null. |
136 | 136 | * } |
137 | 137 | */ |
138 | - public function __construct( $args = array() ) { |
|
138 | + public function __construct($args = array()) { |
|
139 | 139 | $args = wp_parse_args( |
140 | 140 | $args, |
141 | 141 | array( |
@@ -146,28 +146,28 @@ discard block |
||
146 | 146 | ) |
147 | 147 | ); |
148 | 148 | |
149 | - $this->screen = convert_to_screen( $args['screen'] ); |
|
149 | + $this->screen = convert_to_screen($args['screen']); |
|
150 | 150 | |
151 | - add_filter( "manage_{$this->screen->id}_columns", array( $this, 'get_columns' ), 0 ); |
|
151 | + add_filter("manage_{$this->screen->id}_columns", array($this, 'get_columns'), 0); |
|
152 | 152 | |
153 | - if ( ! $args['plural'] ) { |
|
153 | + if (!$args['plural']) { |
|
154 | 154 | $args['plural'] = $this->screen->base; |
155 | 155 | } |
156 | 156 | |
157 | - $args['plural'] = sanitize_key( $args['plural'] ); |
|
158 | - $args['singular'] = sanitize_key( $args['singular'] ); |
|
157 | + $args['plural'] = sanitize_key($args['plural']); |
|
158 | + $args['singular'] = sanitize_key($args['singular']); |
|
159 | 159 | |
160 | 160 | $this->_args = $args; |
161 | 161 | |
162 | - if ( $args['ajax'] ) { |
|
162 | + if ($args['ajax']) { |
|
163 | 163 | // wp_enqueue_script( 'list-table' ); |
164 | - add_action( 'admin_footer', array( $this, '_js_vars' ) ); |
|
164 | + add_action('admin_footer', array($this, '_js_vars')); |
|
165 | 165 | } |
166 | 166 | |
167 | - if ( empty( $this->modes ) ) { |
|
167 | + if (empty($this->modes)) { |
|
168 | 168 | $this->modes = array( |
169 | - 'list' => __( 'Compact view' ), |
|
170 | - 'excerpt' => __( 'Extended view' ), |
|
169 | + 'list' => __('Compact view'), |
|
170 | + 'excerpt' => __('Extended view'), |
|
171 | 171 | ); |
172 | 172 | } |
173 | 173 | } |
@@ -180,8 +180,8 @@ discard block |
||
180 | 180 | * @param string $name Property to get. |
181 | 181 | * @return mixed Property. |
182 | 182 | */ |
183 | - public function __get( $name ) { |
|
184 | - if ( in_array( $name, $this->compat_fields, true ) ) { |
|
183 | + public function __get($name) { |
|
184 | + if (in_array($name, $this->compat_fields, true)) { |
|
185 | 185 | return $this->$name; |
186 | 186 | } |
187 | 187 | } |
@@ -195,8 +195,8 @@ discard block |
||
195 | 195 | * @param mixed $value Property value. |
196 | 196 | * @return mixed Newly-set property. |
197 | 197 | */ |
198 | - public function __set( $name, $value ) { |
|
199 | - if ( in_array( $name, $this->compat_fields, true ) ) { |
|
198 | + public function __set($name, $value) { |
|
199 | + if (in_array($name, $this->compat_fields, true)) { |
|
200 | 200 | return $this->$name = $value; |
201 | 201 | } |
202 | 202 | } |
@@ -209,9 +209,9 @@ discard block |
||
209 | 209 | * @param string $name Property to check if set. |
210 | 210 | * @return bool Whether the property is a back-compat property and it is set. |
211 | 211 | */ |
212 | - public function __isset( $name ) { |
|
213 | - if ( in_array( $name, $this->compat_fields, true ) ) { |
|
214 | - return isset( $this->$name ); |
|
212 | + public function __isset($name) { |
|
213 | + if (in_array($name, $this->compat_fields, true)) { |
|
214 | + return isset($this->$name); |
|
215 | 215 | } |
216 | 216 | |
217 | 217 | return false; |
@@ -224,9 +224,9 @@ discard block |
||
224 | 224 | * |
225 | 225 | * @param string $name Property to unset. |
226 | 226 | */ |
227 | - public function __unset( $name ) { |
|
228 | - if ( in_array( $name, $this->compat_fields, true ) ) { |
|
229 | - unset( $this->$name ); |
|
227 | + public function __unset($name) { |
|
228 | + if (in_array($name, $this->compat_fields, true)) { |
|
229 | + unset($this->$name); |
|
230 | 230 | } |
231 | 231 | } |
232 | 232 | |
@@ -239,9 +239,9 @@ discard block |
||
239 | 239 | * @param array $arguments Arguments to pass when calling. |
240 | 240 | * @return mixed|bool Return value of the callback, false otherwise. |
241 | 241 | */ |
242 | - public function __call( $name, $arguments ) { |
|
243 | - if ( in_array( $name, $this->compat_methods, true ) ) { |
|
244 | - return $this->$name( ...$arguments ); |
|
242 | + public function __call($name, $arguments) { |
|
243 | + if (in_array($name, $this->compat_methods, true)) { |
|
244 | + return $this->$name(...$arguments); |
|
245 | 245 | } |
246 | 246 | return false; |
247 | 247 | } |
@@ -253,7 +253,7 @@ discard block |
||
253 | 253 | * @abstract |
254 | 254 | */ |
255 | 255 | public function ajax_user_can() { |
256 | - die( 'function WP_List_Table::ajax_user_can() must be overridden in a subclass.' ); |
|
256 | + die('function WP_List_Table::ajax_user_can() must be overridden in a subclass.'); |
|
257 | 257 | } |
258 | 258 | |
259 | 259 | /** |
@@ -265,7 +265,7 @@ discard block |
||
265 | 265 | * @abstract |
266 | 266 | */ |
267 | 267 | public function prepare_items() { |
268 | - die( 'function WP_List_Table::prepare_items() must be overridden in a subclass.' ); |
|
268 | + die('function WP_List_Table::prepare_items() must be overridden in a subclass.'); |
|
269 | 269 | } |
270 | 270 | |
271 | 271 | /** |
@@ -275,7 +275,7 @@ discard block |
||
275 | 275 | * |
276 | 276 | * @param array|string $args Array or string of arguments with information about the pagination. |
277 | 277 | */ |
278 | - protected function set_pagination_args( $args ) { |
|
278 | + protected function set_pagination_args($args) { |
|
279 | 279 | $args = wp_parse_args( |
280 | 280 | $args, |
281 | 281 | array( |
@@ -285,13 +285,13 @@ discard block |
||
285 | 285 | ) |
286 | 286 | ); |
287 | 287 | |
288 | - if ( ! $args['total_pages'] && $args['per_page'] > 0 ) { |
|
289 | - $args['total_pages'] = ceil( $args['total_items'] / $args['per_page'] ); |
|
288 | + if (!$args['total_pages'] && $args['per_page'] > 0) { |
|
289 | + $args['total_pages'] = ceil($args['total_items'] / $args['per_page']); |
|
290 | 290 | } |
291 | 291 | |
292 | 292 | // Redirect if page number is invalid and headers are not already sent. |
293 | - if ( ! headers_sent() && ! wp_doing_ajax() && $args['total_pages'] > 0 && $this->get_pagenum() > $args['total_pages'] ) { |
|
294 | - wp_redirect( add_query_arg( 'paged', $args['total_pages'] ) ); |
|
293 | + if (!headers_sent() && !wp_doing_ajax() && $args['total_pages'] > 0 && $this->get_pagenum() > $args['total_pages']) { |
|
294 | + wp_redirect(add_query_arg('paged', $args['total_pages'])); |
|
295 | 295 | exit; |
296 | 296 | } |
297 | 297 | |
@@ -307,13 +307,13 @@ discard block |
||
307 | 307 | * 'total_pages', 'per_page', or 'infinite_scroll'. |
308 | 308 | * @return int Number of items that correspond to the given pagination argument. |
309 | 309 | */ |
310 | - public function get_pagination_arg( $key ) { |
|
311 | - if ( 'page' === $key ) { |
|
310 | + public function get_pagination_arg($key) { |
|
311 | + if ('page' === $key) { |
|
312 | 312 | return $this->get_pagenum(); |
313 | 313 | } |
314 | 314 | |
315 | - if ( isset( $this->_pagination_args[ $key ] ) ) { |
|
316 | - return $this->_pagination_args[ $key ]; |
|
315 | + if (isset($this->_pagination_args[$key])) { |
|
316 | + return $this->_pagination_args[$key]; |
|
317 | 317 | } |
318 | 318 | |
319 | 319 | return 0; |
@@ -327,7 +327,7 @@ discard block |
||
327 | 327 | * @return bool |
328 | 328 | */ |
329 | 329 | public function has_items() { |
330 | - return ! empty( $this->items ); |
|
330 | + return !empty($this->items); |
|
331 | 331 | } |
332 | 332 | |
333 | 333 | /** |
@@ -336,7 +336,7 @@ discard block |
||
336 | 336 | * @since 3.1.0 |
337 | 337 | */ |
338 | 338 | public function no_items() { |
339 | - _e( 'No items found.' ); |
|
339 | + _e('No items found.'); |
|
340 | 340 | } |
341 | 341 | |
342 | 342 | /** |
@@ -347,30 +347,30 @@ discard block |
||
347 | 347 | * @param string $text The 'submit' button label. |
348 | 348 | * @param string $input_id ID attribute value for the search input field. |
349 | 349 | */ |
350 | - public function search_box( $text, $input_id ) { |
|
351 | - if ( empty( $_REQUEST['s'] ) && ! $this->has_items() ) { |
|
350 | + public function search_box($text, $input_id) { |
|
351 | + if (empty($_REQUEST['s']) && !$this->has_items()) { |
|
352 | 352 | return; |
353 | 353 | } |
354 | 354 | |
355 | 355 | $input_id = $input_id . '-search-input'; |
356 | 356 | |
357 | - if ( ! empty( $_REQUEST['orderby'] ) ) { |
|
358 | - echo '<input type="hidden" name="orderby" value="' . esc_attr( $_REQUEST['orderby'] ) . '" />'; |
|
357 | + if (!empty($_REQUEST['orderby'])) { |
|
358 | + echo '<input type="hidden" name="orderby" value="' . esc_attr($_REQUEST['orderby']) . '" />'; |
|
359 | 359 | } |
360 | - if ( ! empty( $_REQUEST['order'] ) ) { |
|
361 | - echo '<input type="hidden" name="order" value="' . esc_attr( $_REQUEST['order'] ) . '" />'; |
|
360 | + if (!empty($_REQUEST['order'])) { |
|
361 | + echo '<input type="hidden" name="order" value="' . esc_attr($_REQUEST['order']) . '" />'; |
|
362 | 362 | } |
363 | - if ( ! empty( $_REQUEST['post_mime_type'] ) ) { |
|
364 | - echo '<input type="hidden" name="post_mime_type" value="' . esc_attr( $_REQUEST['post_mime_type'] ) . '" />'; |
|
363 | + if (!empty($_REQUEST['post_mime_type'])) { |
|
364 | + echo '<input type="hidden" name="post_mime_type" value="' . esc_attr($_REQUEST['post_mime_type']) . '" />'; |
|
365 | 365 | } |
366 | - if ( ! empty( $_REQUEST['detached'] ) ) { |
|
367 | - echo '<input type="hidden" name="detached" value="' . esc_attr( $_REQUEST['detached'] ) . '" />'; |
|
366 | + if (!empty($_REQUEST['detached'])) { |
|
367 | + echo '<input type="hidden" name="detached" value="' . esc_attr($_REQUEST['detached']) . '" />'; |
|
368 | 368 | } |
369 | 369 | ?> |
370 | 370 | <p class="search-box"> |
371 | - <label class="screen-reader-text" for="<?php echo esc_attr( $input_id ); ?>"><?php echo $text; ?>:</label> |
|
372 | - <input type="search" id="<?php echo esc_attr( $input_id ); ?>" name="s" value="<?php _admin_search_query(); ?>" /> |
|
373 | - <?php submit_button( $text, '', '', false, array( 'id' => 'search-submit' ) ); ?> |
|
371 | + <label class="screen-reader-text" for="<?php echo esc_attr($input_id); ?>"><?php echo $text; ?>:</label> |
|
372 | + <input type="search" id="<?php echo esc_attr($input_id); ?>" name="s" value="<?php _admin_search_query(); ?>" /> |
|
373 | + <?php submit_button($text, '', '', false, array('id' => 'search-submit')); ?> |
|
374 | 374 | </p> |
375 | 375 | <?php |
376 | 376 | } |
@@ -406,19 +406,19 @@ discard block |
||
406 | 406 | * |
407 | 407 | * @param string[] $views An array of available list table views. |
408 | 408 | */ |
409 | - $views = apply_filters( "views_{$this->screen->id}", $views ); |
|
409 | + $views = apply_filters("views_{$this->screen->id}", $views); |
|
410 | 410 | |
411 | - if ( empty( $views ) ) { |
|
411 | + if (empty($views)) { |
|
412 | 412 | return; |
413 | 413 | } |
414 | 414 | |
415 | - $this->screen->render_screen_reader_content( 'heading_views' ); |
|
415 | + $this->screen->render_screen_reader_content('heading_views'); |
|
416 | 416 | |
417 | 417 | echo "<ul class='subsubsub'>\n"; |
418 | - foreach ( $views as $class => $view ) { |
|
419 | - $views[ $class ] = "\t<li class='$class'>$view"; |
|
418 | + foreach ($views as $class => $view) { |
|
419 | + $views[$class] = "\t<li class='$class'>$view"; |
|
420 | 420 | } |
421 | - echo implode( " |</li>\n", $views ) . "</li>\n"; |
|
421 | + echo implode(" |</li>\n", $views) . "</li>\n"; |
|
422 | 422 | echo '</ul>'; |
423 | 423 | } |
424 | 424 | |
@@ -461,8 +461,8 @@ discard block |
||
461 | 461 | * @param string $which The location of the bulk actions: 'top' or 'bottom'. |
462 | 462 | * This is designated as optional for backward compatibility. |
463 | 463 | */ |
464 | - protected function bulk_actions( $which = '' ) { |
|
465 | - if ( is_null( $this->_actions ) ) { |
|
464 | + protected function bulk_actions($which = '') { |
|
465 | + if (is_null($this->_actions)) { |
|
466 | 466 | $this->_actions = $this->get_bulk_actions(); |
467 | 467 | |
468 | 468 | /** |
@@ -476,41 +476,41 @@ discard block |
||
476 | 476 | * |
477 | 477 | * @param array $actions An array of the available bulk actions. |
478 | 478 | */ |
479 | - $this->_actions = apply_filters( "bulk_actions-{$this->screen->id}", $this->_actions ); // phpcs:ignore WordPress.NamingConventions.ValidHookName.UseUnderscores |
|
479 | + $this->_actions = apply_filters("bulk_actions-{$this->screen->id}", $this->_actions); // phpcs:ignore WordPress.NamingConventions.ValidHookName.UseUnderscores |
|
480 | 480 | |
481 | 481 | $two = ''; |
482 | 482 | } else { |
483 | 483 | $two = '2'; |
484 | 484 | } |
485 | 485 | |
486 | - if ( empty( $this->_actions ) ) { |
|
486 | + if (empty($this->_actions)) { |
|
487 | 487 | return; |
488 | 488 | } |
489 | 489 | |
490 | - echo '<label for="bulk-action-selector-' . esc_attr( $which ) . '" class="screen-reader-text">' . __( 'Select bulk action' ) . '</label>'; |
|
491 | - echo '<select name="action' . $two . '" id="bulk-action-selector-' . esc_attr( $which ) . "\">\n"; |
|
492 | - echo '<option value="-1">' . __( 'Bulk actions' ) . "</option>\n"; |
|
490 | + echo '<label for="bulk-action-selector-' . esc_attr($which) . '" class="screen-reader-text">' . __('Select bulk action') . '</label>'; |
|
491 | + echo '<select name="action' . $two . '" id="bulk-action-selector-' . esc_attr($which) . "\">\n"; |
|
492 | + echo '<option value="-1">' . __('Bulk actions') . "</option>\n"; |
|
493 | 493 | |
494 | - foreach ( $this->_actions as $key => $value ) { |
|
495 | - if ( is_array( $value ) ) { |
|
496 | - echo "\t" . '<optgroup label="' . esc_attr( $key ) . '">' . "\n"; |
|
494 | + foreach ($this->_actions as $key => $value) { |
|
495 | + if (is_array($value)) { |
|
496 | + echo "\t" . '<optgroup label="' . esc_attr($key) . '">' . "\n"; |
|
497 | 497 | |
498 | - foreach ( $value as $name => $title ) { |
|
499 | - $class = ( 'edit' === $name ) ? ' class="hide-if-no-js"' : ''; |
|
498 | + foreach ($value as $name => $title) { |
|
499 | + $class = ('edit' === $name) ? ' class="hide-if-no-js"' : ''; |
|
500 | 500 | |
501 | - echo "\t\t" . '<option value="' . esc_attr( $name ) . '"' . $class . '>' . $title . "</option>\n"; |
|
501 | + echo "\t\t" . '<option value="' . esc_attr($name) . '"' . $class . '>' . $title . "</option>\n"; |
|
502 | 502 | } |
503 | 503 | echo "\t" . "</optgroup>\n"; |
504 | 504 | } else { |
505 | - $class = ( 'edit' === $key ) ? ' class="hide-if-no-js"' : ''; |
|
505 | + $class = ('edit' === $key) ? ' class="hide-if-no-js"' : ''; |
|
506 | 506 | |
507 | - echo "\t" . '<option value="' . esc_attr( $key ) . '"' . $class . '>' . $value . "</option>\n"; |
|
507 | + echo "\t" . '<option value="' . esc_attr($key) . '"' . $class . '>' . $value . "</option>\n"; |
|
508 | 508 | } |
509 | 509 | } |
510 | 510 | |
511 | 511 | echo "</select>\n"; |
512 | 512 | |
513 | - submit_button( __( 'Apply' ), 'action', '', false, array( 'id' => "doaction$two" ) ); |
|
513 | + submit_button(__('Apply'), 'action', '', false, array('id' => "doaction$two")); |
|
514 | 514 | echo "\n"; |
515 | 515 | } |
516 | 516 | |
@@ -522,11 +522,11 @@ discard block |
||
522 | 522 | * @return string|false The action name. False if no action was selected. |
523 | 523 | */ |
524 | 524 | public function current_action() { |
525 | - if ( isset( $_REQUEST['filter_action'] ) && ! empty( $_REQUEST['filter_action'] ) ) { |
|
525 | + if (isset($_REQUEST['filter_action']) && !empty($_REQUEST['filter_action'])) { |
|
526 | 526 | return false; |
527 | 527 | } |
528 | 528 | |
529 | - if ( isset( $_REQUEST['action'] ) && -1 != $_REQUEST['action'] ) { |
|
529 | + if (isset($_REQUEST['action']) && -1 != $_REQUEST['action']) { |
|
530 | 530 | return $_REQUEST['action']; |
531 | 531 | } |
532 | 532 | |
@@ -542,34 +542,34 @@ discard block |
||
542 | 542 | * @param bool $always_visible Whether the actions should be always visible. |
543 | 543 | * @return string The HTML for the row actions. |
544 | 544 | */ |
545 | - protected function row_actions( $actions, $always_visible = false ) { |
|
546 | - $action_count = count( $actions ); |
|
545 | + protected function row_actions($actions, $always_visible = false) { |
|
546 | + $action_count = count($actions); |
|
547 | 547 | |
548 | - if ( ! $action_count ) { |
|
548 | + if (!$action_count) { |
|
549 | 549 | return ''; |
550 | 550 | } |
551 | 551 | |
552 | - $mode = get_user_setting( 'posts_list_mode', 'list' ); |
|
552 | + $mode = get_user_setting('posts_list_mode', 'list'); |
|
553 | 553 | |
554 | - if ( 'excerpt' === $mode ) { |
|
554 | + if ('excerpt' === $mode) { |
|
555 | 555 | $always_visible = true; |
556 | 556 | } |
557 | 557 | |
558 | - $out = '<div class="' . ( $always_visible ? 'row-actions visible' : 'row-actions' ) . '">'; |
|
558 | + $out = '<div class="' . ($always_visible ? 'row-actions visible' : 'row-actions') . '">'; |
|
559 | 559 | |
560 | 560 | $i = 0; |
561 | 561 | |
562 | - foreach ( $actions as $action => $link ) { |
|
562 | + foreach ($actions as $action => $link) { |
|
563 | 563 | ++$i; |
564 | 564 | |
565 | - $sep = ( $i < $action_count ) ? ' | ' : ''; |
|
565 | + $sep = ($i < $action_count) ? ' | ' : ''; |
|
566 | 566 | |
567 | 567 | $out .= "<span class='$action'>$link$sep</span>"; |
568 | 568 | } |
569 | 569 | |
570 | 570 | $out .= '</div>'; |
571 | 571 | |
572 | - $out .= '<button type="button" class="toggle-row"><span class="screen-reader-text">' . __( 'Show more details' ) . '</span></button>'; |
|
572 | + $out .= '<button type="button" class="toggle-row"><span class="screen-reader-text">' . __('Show more details') . '</span></button>'; |
|
573 | 573 | |
574 | 574 | return $out; |
575 | 575 | } |
@@ -584,7 +584,7 @@ discard block |
||
584 | 584 | * |
585 | 585 | * @param string $post_type The post type. |
586 | 586 | */ |
587 | - protected function months_dropdown( $post_type ) { |
|
587 | + protected function months_dropdown($post_type) { |
|
588 | 588 | global $wpdb, $wp_locale; |
589 | 589 | |
590 | 590 | /** |
@@ -595,7 +595,7 @@ discard block |
||
595 | 595 | * @param bool $disable Whether to disable the drop-down. Default false. |
596 | 596 | * @param string $post_type The post type. |
597 | 597 | */ |
598 | - if ( apply_filters( 'disable_months_dropdown', false, $post_type ) ) { |
|
598 | + if (apply_filters('disable_months_dropdown', false, $post_type)) { |
|
599 | 599 | return; |
600 | 600 | } |
601 | 601 | |
@@ -607,14 +607,14 @@ discard block |
||
607 | 607 | * @param object[]|false $months 'Months' drop-down results. Default false. |
608 | 608 | * @param string $post_type The post type. |
609 | 609 | */ |
610 | - $months = apply_filters( 'pre_months_dropdown_query', false, $post_type ); |
|
610 | + $months = apply_filters('pre_months_dropdown_query', false, $post_type); |
|
611 | 611 | |
612 | - if ( ! is_array( $months ) ) { |
|
612 | + if (!is_array($months)) { |
|
613 | 613 | $extra_checks = "AND post_status != 'auto-draft'"; |
614 | - if ( ! isset( $_GET['post_status'] ) || 'trash' !== $_GET['post_status'] ) { |
|
614 | + if (!isset($_GET['post_status']) || 'trash' !== $_GET['post_status']) { |
|
615 | 615 | $extra_checks .= " AND post_status != 'trash'"; |
616 | - } elseif ( isset( $_GET['post_status'] ) ) { |
|
617 | - $extra_checks = $wpdb->prepare( ' AND post_status = %s', $_GET['post_status'] ); |
|
616 | + } elseif (isset($_GET['post_status'])) { |
|
617 | + $extra_checks = $wpdb->prepare(' AND post_status = %s', $_GET['post_status']); |
|
618 | 618 | } |
619 | 619 | |
620 | 620 | $months = $wpdb->get_results( |
@@ -639,34 +639,34 @@ discard block |
||
639 | 639 | * @param object[] $months Array of the months drop-down query results. |
640 | 640 | * @param string $post_type The post type. |
641 | 641 | */ |
642 | - $months = apply_filters( 'months_dropdown_results', $months, $post_type ); |
|
642 | + $months = apply_filters('months_dropdown_results', $months, $post_type); |
|
643 | 643 | |
644 | - $month_count = count( $months ); |
|
644 | + $month_count = count($months); |
|
645 | 645 | |
646 | - if ( ! $month_count || ( 1 == $month_count && 0 == $months[0]->month ) ) { |
|
646 | + if (!$month_count || (1 == $month_count && 0 == $months[0]->month)) { |
|
647 | 647 | return; |
648 | 648 | } |
649 | 649 | |
650 | - $m = isset( $_GET['m'] ) ? (int) $_GET['m'] : 0; |
|
650 | + $m = isset($_GET['m']) ? (int) $_GET['m'] : 0; |
|
651 | 651 | ?> |
652 | - <label for="filter-by-date" class="screen-reader-text"><?php echo get_post_type_object( $post_type )->labels->filter_by_date; ?></label> |
|
652 | + <label for="filter-by-date" class="screen-reader-text"><?php echo get_post_type_object($post_type)->labels->filter_by_date; ?></label> |
|
653 | 653 | <select name="m" id="filter-by-date"> |
654 | - <option<?php selected( $m, 0 ); ?> value="0"><?php _e( 'All dates' ); ?></option> |
|
654 | + <option<?php selected($m, 0); ?> value="0"><?php _e('All dates'); ?></option> |
|
655 | 655 | <?php |
656 | - foreach ( $months as $arc_row ) { |
|
657 | - if ( 0 == $arc_row->year ) { |
|
656 | + foreach ($months as $arc_row) { |
|
657 | + if (0 == $arc_row->year) { |
|
658 | 658 | continue; |
659 | 659 | } |
660 | 660 | |
661 | - $month = zeroise( $arc_row->month, 2 ); |
|
661 | + $month = zeroise($arc_row->month, 2); |
|
662 | 662 | $year = $arc_row->year; |
663 | 663 | |
664 | 664 | printf( |
665 | 665 | "<option %s value='%s'>%s</option>\n", |
666 | - selected( $m, $year . $month, false ), |
|
667 | - esc_attr( $arc_row->year . $month ), |
|
666 | + selected($m, $year . $month, false), |
|
667 | + esc_attr($arc_row->year . $month), |
|
668 | 668 | /* translators: 1: Month name, 2: 4-digit year. */ |
669 | - sprintf( __( '%1$s %2$d' ), $wp_locale->get_month( $month ), $year ) |
|
669 | + sprintf(__('%1$s %2$d'), $wp_locale->get_month($month), $year) |
|
670 | 670 | ); |
671 | 671 | } |
672 | 672 | ?> |
@@ -681,24 +681,24 @@ discard block |
||
681 | 681 | * |
682 | 682 | * @param string $current_mode |
683 | 683 | */ |
684 | - protected function view_switcher( $current_mode ) { |
|
684 | + protected function view_switcher($current_mode) { |
|
685 | 685 | ?> |
686 | - <input type="hidden" name="mode" value="<?php echo esc_attr( $current_mode ); ?>" /> |
|
686 | + <input type="hidden" name="mode" value="<?php echo esc_attr($current_mode); ?>" /> |
|
687 | 687 | <div class="view-switch"> |
688 | 688 | <?php |
689 | - foreach ( $this->modes as $mode => $title ) { |
|
690 | - $classes = array( 'view-' . $mode ); |
|
689 | + foreach ($this->modes as $mode => $title) { |
|
690 | + $classes = array('view-' . $mode); |
|
691 | 691 | $aria_current = ''; |
692 | 692 | |
693 | - if ( $current_mode === $mode ) { |
|
693 | + if ($current_mode === $mode) { |
|
694 | 694 | $classes[] = 'current'; |
695 | 695 | $aria_current = ' aria-current="page"'; |
696 | 696 | } |
697 | 697 | |
698 | 698 | printf( |
699 | 699 | "<a href='%s' class='%s' id='view-switch-$mode'$aria_current><span class='screen-reader-text'>%s</span></a>\n", |
700 | - esc_url( remove_query_arg( 'attachment-filter', add_query_arg( 'mode', $mode ) ) ), |
|
701 | - implode( ' ', $classes ), |
|
700 | + esc_url(remove_query_arg('attachment-filter', add_query_arg('mode', $mode))), |
|
701 | + implode(' ', $classes), |
|
702 | 702 | $title |
703 | 703 | ); |
704 | 704 | } |
@@ -715,44 +715,44 @@ discard block |
||
715 | 715 | * @param int $post_id The post ID. |
716 | 716 | * @param int $pending_comments Number of pending comments. |
717 | 717 | */ |
718 | - protected function comments_bubble( $post_id, $pending_comments ) { |
|
718 | + protected function comments_bubble($post_id, $pending_comments) { |
|
719 | 719 | $approved_comments = get_comments_number(); |
720 | 720 | |
721 | - $approved_comments_number = number_format_i18n( $approved_comments ); |
|
722 | - $pending_comments_number = number_format_i18n( $pending_comments ); |
|
721 | + $approved_comments_number = number_format_i18n($approved_comments); |
|
722 | + $pending_comments_number = number_format_i18n($pending_comments); |
|
723 | 723 | |
724 | 724 | $approved_only_phrase = sprintf( |
725 | 725 | /* translators: %s: Number of comments. */ |
726 | - _n( '%s comment', '%s comments', $approved_comments ), |
|
726 | + _n('%s comment', '%s comments', $approved_comments), |
|
727 | 727 | $approved_comments_number |
728 | 728 | ); |
729 | 729 | |
730 | 730 | $approved_phrase = sprintf( |
731 | 731 | /* translators: %s: Number of comments. */ |
732 | - _n( '%s approved comment', '%s approved comments', $approved_comments ), |
|
732 | + _n('%s approved comment', '%s approved comments', $approved_comments), |
|
733 | 733 | $approved_comments_number |
734 | 734 | ); |
735 | 735 | |
736 | 736 | $pending_phrase = sprintf( |
737 | 737 | /* translators: %s: Number of comments. */ |
738 | - _n( '%s pending comment', '%s pending comments', $pending_comments ), |
|
738 | + _n('%s pending comment', '%s pending comments', $pending_comments), |
|
739 | 739 | $pending_comments_number |
740 | 740 | ); |
741 | 741 | |
742 | - if ( ! $approved_comments && ! $pending_comments ) { |
|
742 | + if (!$approved_comments && !$pending_comments) { |
|
743 | 743 | // No comments at all. |
744 | 744 | printf( |
745 | 745 | '<span aria-hidden="true">—</span><span class="screen-reader-text">%s</span>', |
746 | - __( 'No comments' ) |
|
746 | + __('No comments') |
|
747 | 747 | ); |
748 | - } elseif ( $approved_comments && 'trash' === get_post_status( $post_id ) ) { |
|
748 | + } elseif ($approved_comments && 'trash' === get_post_status($post_id)) { |
|
749 | 749 | // Don't link the comment bubble for a trashed post. |
750 | 750 | printf( |
751 | 751 | '<span class="post-com-count post-com-count-approved"><span class="comment-count-approved" aria-hidden="true">%s</span><span class="screen-reader-text">%s</span></span>', |
752 | 752 | $approved_comments_number, |
753 | 753 | $pending_comments ? $approved_phrase : $approved_only_phrase |
754 | 754 | ); |
755 | - } elseif ( $approved_comments ) { |
|
755 | + } elseif ($approved_comments) { |
|
756 | 756 | // Link the comment bubble to approved comments. |
757 | 757 | printf( |
758 | 758 | '<a href="%s" class="post-com-count post-com-count-approved"><span class="comment-count-approved" aria-hidden="true">%s</span><span class="screen-reader-text">%s</span></a>', |
@@ -762,7 +762,7 @@ discard block |
||
762 | 762 | 'p' => $post_id, |
763 | 763 | 'comment_status' => 'approved', |
764 | 764 | ), |
765 | - admin_url( 'edit-comments.php' ) |
|
765 | + admin_url('edit-comments.php') |
|
766 | 766 | ) |
767 | 767 | ), |
768 | 768 | $approved_comments_number, |
@@ -773,11 +773,11 @@ discard block |
||
773 | 773 | printf( |
774 | 774 | '<span class="post-com-count post-com-count-no-comments"><span class="comment-count comment-count-no-comments" aria-hidden="true">%s</span><span class="screen-reader-text">%s</span></span>', |
775 | 775 | $approved_comments_number, |
776 | - $pending_comments ? __( 'No approved comments' ) : __( 'No comments' ) |
|
776 | + $pending_comments ? __('No approved comments') : __('No comments') |
|
777 | 777 | ); |
778 | 778 | } |
779 | 779 | |
780 | - if ( $pending_comments ) { |
|
780 | + if ($pending_comments) { |
|
781 | 781 | printf( |
782 | 782 | '<a href="%s" class="post-com-count post-com-count-pending"><span class="comment-count-pending" aria-hidden="true">%s</span><span class="screen-reader-text">%s</span></a>', |
783 | 783 | esc_url( |
@@ -786,7 +786,7 @@ discard block |
||
786 | 786 | 'p' => $post_id, |
787 | 787 | 'comment_status' => 'moderated', |
788 | 788 | ), |
789 | - admin_url( 'edit-comments.php' ) |
|
789 | + admin_url('edit-comments.php') |
|
790 | 790 | ) |
791 | 791 | ), |
792 | 792 | $pending_comments_number, |
@@ -796,7 +796,7 @@ discard block |
||
796 | 796 | printf( |
797 | 797 | '<span class="post-com-count post-com-count-pending post-com-count-no-pending"><span class="comment-count comment-count-no-pending" aria-hidden="true">%s</span><span class="screen-reader-text">%s</span></span>', |
798 | 798 | $pending_comments_number, |
799 | - $approved_comments ? __( 'No pending comments' ) : __( 'No comments' ) |
|
799 | + $approved_comments ? __('No pending comments') : __('No comments') |
|
800 | 800 | ); |
801 | 801 | } |
802 | 802 | } |
@@ -809,13 +809,13 @@ discard block |
||
809 | 809 | * @return int |
810 | 810 | */ |
811 | 811 | public function get_pagenum() { |
812 | - $pagenum = isset( $_REQUEST['paged'] ) ? absint( $_REQUEST['paged'] ) : 0; |
|
812 | + $pagenum = isset($_REQUEST['paged']) ? absint($_REQUEST['paged']) : 0; |
|
813 | 813 | |
814 | - if ( isset( $this->_pagination_args['total_pages'] ) && $pagenum > $this->_pagination_args['total_pages'] ) { |
|
814 | + if (isset($this->_pagination_args['total_pages']) && $pagenum > $this->_pagination_args['total_pages']) { |
|
815 | 815 | $pagenum = $this->_pagination_args['total_pages']; |
816 | 816 | } |
817 | 817 | |
818 | - return max( 1, $pagenum ); |
|
818 | + return max(1, $pagenum); |
|
819 | 819 | } |
820 | 820 | |
821 | 821 | /** |
@@ -827,9 +827,9 @@ discard block |
||
827 | 827 | * @param int $default_value Optional. The number of items to display. Default 20. |
828 | 828 | * @return int |
829 | 829 | */ |
830 | - protected function get_items_per_page( $option, $default_value = 20 ) { |
|
831 | - $per_page = (int) get_user_option( $option ); |
|
832 | - if ( empty( $per_page ) || $per_page < 1 ) { |
|
830 | + protected function get_items_per_page($option, $default_value = 20) { |
|
831 | + $per_page = (int) get_user_option($option); |
|
832 | + if (empty($per_page) || $per_page < 1) { |
|
833 | 833 | $per_page = $default_value; |
834 | 834 | } |
835 | 835 | |
@@ -857,7 +857,7 @@ discard block |
||
857 | 857 | * |
858 | 858 | * @param int $per_page Number of items to be displayed. Default 20. |
859 | 859 | */ |
860 | - return (int) apply_filters( "{$option}", $per_page ); |
|
860 | + return (int) apply_filters("{$option}", $per_page); |
|
861 | 861 | } |
862 | 862 | |
863 | 863 | /** |
@@ -867,34 +867,34 @@ discard block |
||
867 | 867 | * |
868 | 868 | * @param string $which |
869 | 869 | */ |
870 | - protected function pagination( $which ) { |
|
871 | - if ( empty( $this->_pagination_args ) ) { |
|
870 | + protected function pagination($which) { |
|
871 | + if (empty($this->_pagination_args)) { |
|
872 | 872 | return; |
873 | 873 | } |
874 | 874 | |
875 | 875 | $total_items = $this->_pagination_args['total_items']; |
876 | 876 | $total_pages = $this->_pagination_args['total_pages']; |
877 | 877 | $infinite_scroll = false; |
878 | - if ( isset( $this->_pagination_args['infinite_scroll'] ) ) { |
|
878 | + if (isset($this->_pagination_args['infinite_scroll'])) { |
|
879 | 879 | $infinite_scroll = $this->_pagination_args['infinite_scroll']; |
880 | 880 | } |
881 | 881 | |
882 | - if ( 'top' === $which && $total_pages > 1 ) { |
|
883 | - $this->screen->render_screen_reader_content( 'heading_pagination' ); |
|
882 | + if ('top' === $which && $total_pages > 1) { |
|
883 | + $this->screen->render_screen_reader_content('heading_pagination'); |
|
884 | 884 | } |
885 | 885 | |
886 | 886 | $output = '<span class="displaying-num">' . sprintf( |
887 | 887 | /* translators: %s: Number of items. */ |
888 | - _n( '%s item', '%s items', $total_items ), |
|
889 | - number_format_i18n( $total_items ) |
|
888 | + _n('%s item', '%s items', $total_items), |
|
889 | + number_format_i18n($total_items) |
|
890 | 890 | ) . '</span>'; |
891 | 891 | |
892 | 892 | $current = $this->get_pagenum(); |
893 | 893 | $removable_query_args = wp_removable_query_args(); |
894 | 894 | |
895 | - $current_url = set_url_scheme( 'http://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'] ); |
|
895 | + $current_url = set_url_scheme('http://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']); |
|
896 | 896 | |
897 | - $current_url = remove_query_arg( $removable_query_args, $current_url ); |
|
897 | + $current_url = remove_query_arg($removable_query_args, $current_url); |
|
898 | 898 | |
899 | 899 | $page_links = array(); |
900 | 900 | |
@@ -906,85 +906,85 @@ discard block |
||
906 | 906 | $disable_prev = false; |
907 | 907 | $disable_next = false; |
908 | 908 | |
909 | - if ( 1 == $current ) { |
|
909 | + if (1 == $current) { |
|
910 | 910 | $disable_first = true; |
911 | 911 | $disable_prev = true; |
912 | 912 | } |
913 | - if ( $total_pages == $current ) { |
|
913 | + if ($total_pages == $current) { |
|
914 | 914 | $disable_last = true; |
915 | 915 | $disable_next = true; |
916 | 916 | } |
917 | 917 | |
918 | - if ( $disable_first ) { |
|
918 | + if ($disable_first) { |
|
919 | 919 | $page_links[] = '<span class="tablenav-pages-navspan button disabled" aria-hidden="true">«</span>'; |
920 | 920 | } else { |
921 | 921 | $page_links[] = sprintf( |
922 | 922 | "<a class='first-page button' href='%s'><span class='screen-reader-text'>%s</span><span aria-hidden='true'>%s</span></a>", |
923 | - esc_url( remove_query_arg( 'paged', $current_url ) ), |
|
924 | - __( 'First page' ), |
|
923 | + esc_url(remove_query_arg('paged', $current_url)), |
|
924 | + __('First page'), |
|
925 | 925 | '«' |
926 | 926 | ); |
927 | 927 | } |
928 | 928 | |
929 | - if ( $disable_prev ) { |
|
929 | + if ($disable_prev) { |
|
930 | 930 | $page_links[] = '<span class="tablenav-pages-navspan button disabled" aria-hidden="true">‹</span>'; |
931 | 931 | } else { |
932 | 932 | $page_links[] = sprintf( |
933 | 933 | "<a class='prev-page button' href='%s'><span class='screen-reader-text'>%s</span><span aria-hidden='true'>%s</span></a>", |
934 | - esc_url( add_query_arg( 'paged', max( 1, $current - 1 ), $current_url ) ), |
|
935 | - __( 'Previous page' ), |
|
934 | + esc_url(add_query_arg('paged', max(1, $current - 1), $current_url)), |
|
935 | + __('Previous page'), |
|
936 | 936 | '‹' |
937 | 937 | ); |
938 | 938 | } |
939 | 939 | |
940 | - if ( 'bottom' === $which ) { |
|
940 | + if ('bottom' === $which) { |
|
941 | 941 | $html_current_page = $current; |
942 | - $total_pages_before = '<span class="screen-reader-text">' . __( 'Current Page' ) . '</span><span id="table-paging" class="paging-input"><span class="tablenav-paging-text">'; |
|
942 | + $total_pages_before = '<span class="screen-reader-text">' . __('Current Page') . '</span><span id="table-paging" class="paging-input"><span class="tablenav-paging-text">'; |
|
943 | 943 | } else { |
944 | 944 | $html_current_page = sprintf( |
945 | 945 | "%s<input class='current-page' id='current-page-selector' type='text' name='paged' value='%s' size='%d' aria-describedby='table-paging' /><span class='tablenav-paging-text'>", |
946 | - '<label for="current-page-selector" class="screen-reader-text">' . __( 'Current Page' ) . '</label>', |
|
946 | + '<label for="current-page-selector" class="screen-reader-text">' . __('Current Page') . '</label>', |
|
947 | 947 | $current, |
948 | - strlen( $total_pages ) |
|
948 | + strlen($total_pages) |
|
949 | 949 | ); |
950 | 950 | } |
951 | - $html_total_pages = sprintf( "<span class='total-pages'>%s</span>", number_format_i18n( $total_pages ) ); |
|
951 | + $html_total_pages = sprintf("<span class='total-pages'>%s</span>", number_format_i18n($total_pages)); |
|
952 | 952 | $page_links[] = $total_pages_before . sprintf( |
953 | 953 | /* translators: 1: Current page, 2: Total pages. */ |
954 | - _x( '%1$s of %2$s', 'paging' ), |
|
954 | + _x('%1$s of %2$s', 'paging'), |
|
955 | 955 | $html_current_page, |
956 | 956 | $html_total_pages |
957 | 957 | ) . $total_pages_after; |
958 | 958 | |
959 | - if ( $disable_next ) { |
|
959 | + if ($disable_next) { |
|
960 | 960 | $page_links[] = '<span class="tablenav-pages-navspan button disabled" aria-hidden="true">›</span>'; |
961 | 961 | } else { |
962 | 962 | $page_links[] = sprintf( |
963 | 963 | "<a class='next-page button' href='%s'><span class='screen-reader-text'>%s</span><span aria-hidden='true'>%s</span></a>", |
964 | - esc_url( add_query_arg( 'paged', min( $total_pages, $current + 1 ), $current_url ) ), |
|
965 | - __( 'Next page' ), |
|
964 | + esc_url(add_query_arg('paged', min($total_pages, $current + 1), $current_url)), |
|
965 | + __('Next page'), |
|
966 | 966 | '›' |
967 | 967 | ); |
968 | 968 | } |
969 | 969 | |
970 | - if ( $disable_last ) { |
|
970 | + if ($disable_last) { |
|
971 | 971 | $page_links[] = '<span class="tablenav-pages-navspan button disabled" aria-hidden="true">»</span>'; |
972 | 972 | } else { |
973 | 973 | $page_links[] = sprintf( |
974 | 974 | "<a class='last-page button' href='%s'><span class='screen-reader-text'>%s</span><span aria-hidden='true'>%s</span></a>", |
975 | - esc_url( add_query_arg( 'paged', $total_pages, $current_url ) ), |
|
976 | - __( 'Last page' ), |
|
975 | + esc_url(add_query_arg('paged', $total_pages, $current_url)), |
|
976 | + __('Last page'), |
|
977 | 977 | '»' |
978 | 978 | ); |
979 | 979 | } |
980 | 980 | |
981 | 981 | $pagination_links_class = 'pagination-links'; |
982 | - if ( ! empty( $infinite_scroll ) ) { |
|
982 | + if (!empty($infinite_scroll)) { |
|
983 | 983 | $pagination_links_class .= ' hide-if-js'; |
984 | 984 | } |
985 | - $output .= "\n<span class='$pagination_links_class'>" . implode( "\n", $page_links ) . '</span>'; |
|
985 | + $output .= "\n<span class='$pagination_links_class'>" . implode("\n", $page_links) . '</span>'; |
|
986 | 986 | |
987 | - if ( $total_pages ) { |
|
987 | + if ($total_pages) { |
|
988 | 988 | $page_class = $total_pages < 2 ? ' one-page' : ''; |
989 | 989 | } else { |
990 | 990 | $page_class = ' no-pages'; |
@@ -1006,7 +1006,7 @@ discard block |
||
1006 | 1006 | * @return array |
1007 | 1007 | */ |
1008 | 1008 | public function get_columns() { |
1009 | - die( 'function WP_List_Table::get_columns() must be overridden in a subclass.' ); |
|
1009 | + die('function WP_List_Table::get_columns() must be overridden in a subclass.'); |
|
1010 | 1010 | } |
1011 | 1011 | |
1012 | 1012 | /** |
@@ -1036,14 +1036,14 @@ discard block |
||
1036 | 1036 | $columns = $this->get_columns(); |
1037 | 1037 | $column = ''; |
1038 | 1038 | |
1039 | - if ( empty( $columns ) ) { |
|
1039 | + if (empty($columns)) { |
|
1040 | 1040 | return $column; |
1041 | 1041 | } |
1042 | 1042 | |
1043 | 1043 | // We need a primary defined so responsive views show something, |
1044 | 1044 | // so let's fall back to the first non-checkbox column. |
1045 | - foreach ( $columns as $col => $column_name ) { |
|
1046 | - if ( 'cb' === $col ) { |
|
1045 | + foreach ($columns as $col => $column_name) { |
|
1046 | + if ('cb' === $col) { |
|
1047 | 1047 | continue; |
1048 | 1048 | } |
1049 | 1049 | |
@@ -1073,12 +1073,12 @@ discard block |
||
1073 | 1073 | * @return string The name of the primary column. |
1074 | 1074 | */ |
1075 | 1075 | protected function get_primary_column_name() { |
1076 | - $columns = get_column_headers( $this->screen ); |
|
1076 | + $columns = get_column_headers($this->screen); |
|
1077 | 1077 | $default = $this->get_default_primary_column_name(); |
1078 | 1078 | |
1079 | 1079 | // If the primary column doesn't exist, |
1080 | 1080 | // fall back to the first non-checkbox column. |
1081 | - if ( ! isset( $columns[ $default ] ) ) { |
|
1081 | + if (!isset($columns[$default])) { |
|
1082 | 1082 | $default = self::get_default_primary_column_name(); |
1083 | 1083 | } |
1084 | 1084 | |
@@ -1090,9 +1090,9 @@ discard block |
||
1090 | 1090 | * @param string $default Column name default for the specific list table, e.g. 'name'. |
1091 | 1091 | * @param string $context Screen ID for specific list table, e.g. 'plugins'. |
1092 | 1092 | */ |
1093 | - $column = apply_filters( 'list_table_primary_column', $default, $this->screen->id ); |
|
1093 | + $column = apply_filters('list_table_primary_column', $default, $this->screen->id); |
|
1094 | 1094 | |
1095 | - if ( empty( $column ) || ! isset( $columns[ $column ] ) ) { |
|
1095 | + if (empty($column) || !isset($columns[$column])) { |
|
1096 | 1096 | $column = $default; |
1097 | 1097 | } |
1098 | 1098 | |
@@ -1108,7 +1108,7 @@ discard block |
||
1108 | 1108 | */ |
1109 | 1109 | protected function get_column_info() { |
1110 | 1110 | // $_column_headers is already set / cached. |
1111 | - if ( isset( $this->_column_headers ) && is_array( $this->_column_headers ) ) { |
|
1111 | + if (isset($this->_column_headers) && is_array($this->_column_headers)) { |
|
1112 | 1112 | /* |
1113 | 1113 | * Backward compatibility for `$_column_headers` format prior to WordPress 4.3. |
1114 | 1114 | * |
@@ -1116,16 +1116,16 @@ discard block |
||
1116 | 1116 | * column headers property. This ensures the primary column name is included |
1117 | 1117 | * in plugins setting the property directly in the three item format. |
1118 | 1118 | */ |
1119 | - $column_headers = array( array(), array(), array(), $this->get_primary_column_name() ); |
|
1120 | - foreach ( $this->_column_headers as $key => $value ) { |
|
1121 | - $column_headers[ $key ] = $value; |
|
1119 | + $column_headers = array(array(), array(), array(), $this->get_primary_column_name()); |
|
1120 | + foreach ($this->_column_headers as $key => $value) { |
|
1121 | + $column_headers[$key] = $value; |
|
1122 | 1122 | } |
1123 | 1123 | |
1124 | 1124 | return $column_headers; |
1125 | 1125 | } |
1126 | 1126 | |
1127 | - $columns = get_column_headers( $this->screen ); |
|
1128 | - $hidden = get_hidden_columns( $this->screen ); |
|
1127 | + $columns = get_column_headers($this->screen); |
|
1128 | + $hidden = get_hidden_columns($this->screen); |
|
1129 | 1129 | |
1130 | 1130 | $sortable_columns = $this->get_sortable_columns(); |
1131 | 1131 | /** |
@@ -1138,24 +1138,24 @@ discard block |
||
1138 | 1138 | * |
1139 | 1139 | * @param array $sortable_columns An array of sortable columns. |
1140 | 1140 | */ |
1141 | - $_sortable = apply_filters( "manage_{$this->screen->id}_sortable_columns", $sortable_columns ); |
|
1141 | + $_sortable = apply_filters("manage_{$this->screen->id}_sortable_columns", $sortable_columns); |
|
1142 | 1142 | |
1143 | 1143 | $sortable = array(); |
1144 | - foreach ( $_sortable as $id => $data ) { |
|
1145 | - if ( empty( $data ) ) { |
|
1144 | + foreach ($_sortable as $id => $data) { |
|
1145 | + if (empty($data)) { |
|
1146 | 1146 | continue; |
1147 | 1147 | } |
1148 | 1148 | |
1149 | 1149 | $data = (array) $data; |
1150 | - if ( ! isset( $data[1] ) ) { |
|
1150 | + if (!isset($data[1])) { |
|
1151 | 1151 | $data[1] = false; |
1152 | 1152 | } |
1153 | 1153 | |
1154 | - $sortable[ $id ] = $data; |
|
1154 | + $sortable[$id] = $data; |
|
1155 | 1155 | } |
1156 | 1156 | |
1157 | 1157 | $primary = $this->get_primary_column_name(); |
1158 | - $this->_column_headers = array( $columns, $hidden, $sortable, $primary ); |
|
1158 | + $this->_column_headers = array($columns, $hidden, $sortable, $primary); |
|
1159 | 1159 | |
1160 | 1160 | return $this->_column_headers; |
1161 | 1161 | } |
@@ -1168,9 +1168,9 @@ discard block |
||
1168 | 1168 | * @return int |
1169 | 1169 | */ |
1170 | 1170 | public function get_column_count() { |
1171 | - list ( $columns, $hidden ) = $this->get_column_info(); |
|
1172 | - $hidden = array_intersect( array_keys( $columns ), array_filter( $hidden ) ); |
|
1173 | - return count( $columns ) - count( $hidden ); |
|
1171 | + list ($columns, $hidden) = $this->get_column_info(); |
|
1172 | + $hidden = array_intersect(array_keys($columns), array_filter($hidden)); |
|
1173 | + return count($columns) - count($hidden); |
|
1174 | 1174 | } |
1175 | 1175 | |
1176 | 1176 | /** |
@@ -1180,60 +1180,60 @@ discard block |
||
1180 | 1180 | * |
1181 | 1181 | * @param bool $with_id Whether to set the ID attribute or not |
1182 | 1182 | */ |
1183 | - public function print_column_headers( $with_id = true ) { |
|
1184 | - list( $columns, $hidden, $sortable, $primary ) = $this->get_column_info(); |
|
1183 | + public function print_column_headers($with_id = true) { |
|
1184 | + list($columns, $hidden, $sortable, $primary) = $this->get_column_info(); |
|
1185 | 1185 | |
1186 | - $current_url = set_url_scheme( 'http://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'] ); |
|
1187 | - $current_url = remove_query_arg( 'paged', $current_url ); |
|
1186 | + $current_url = set_url_scheme('http://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']); |
|
1187 | + $current_url = remove_query_arg('paged', $current_url); |
|
1188 | 1188 | |
1189 | - if ( isset( $_GET['orderby'] ) ) { |
|
1189 | + if (isset($_GET['orderby'])) { |
|
1190 | 1190 | $current_orderby = $_GET['orderby']; |
1191 | 1191 | } else { |
1192 | 1192 | $current_orderby = ''; |
1193 | 1193 | } |
1194 | 1194 | |
1195 | - if ( isset( $_GET['order'] ) && 'desc' === $_GET['order'] ) { |
|
1195 | + if (isset($_GET['order']) && 'desc' === $_GET['order']) { |
|
1196 | 1196 | $current_order = 'desc'; |
1197 | 1197 | } else { |
1198 | 1198 | $current_order = 'asc'; |
1199 | 1199 | } |
1200 | 1200 | |
1201 | - if ( ! empty( $columns['cb'] ) ) { |
|
1201 | + if (!empty($columns['cb'])) { |
|
1202 | 1202 | static $cb_counter = 1; |
1203 | - $columns['cb'] = '<label class="screen-reader-text" for="cb-select-all-' . $cb_counter . '">' . __( 'Select All' ) . '</label>' |
|
1203 | + $columns['cb'] = '<label class="screen-reader-text" for="cb-select-all-' . $cb_counter . '">' . __('Select All') . '</label>' |
|
1204 | 1204 | . '<input id="cb-select-all-' . $cb_counter . '" type="checkbox" />'; |
1205 | 1205 | $cb_counter++; |
1206 | 1206 | } |
1207 | 1207 | |
1208 | - foreach ( $columns as $column_key => $column_display_name ) { |
|
1209 | - $class = array( 'manage-column', "column-$column_key" ); |
|
1208 | + foreach ($columns as $column_key => $column_display_name) { |
|
1209 | + $class = array('manage-column', "column-$column_key"); |
|
1210 | 1210 | |
1211 | - if ( in_array( $column_key, $hidden, true ) ) { |
|
1211 | + if (in_array($column_key, $hidden, true)) { |
|
1212 | 1212 | $class[] = 'hidden'; |
1213 | 1213 | } |
1214 | 1214 | |
1215 | - if ( 'cb' === $column_key ) { |
|
1215 | + if ('cb' === $column_key) { |
|
1216 | 1216 | $class[] = 'check-column'; |
1217 | - } elseif ( in_array( $column_key, array( 'posts', 'comments', 'links' ), true ) ) { |
|
1217 | + } elseif (in_array($column_key, array('posts', 'comments', 'links'), true)) { |
|
1218 | 1218 | $class[] = 'num'; |
1219 | 1219 | } |
1220 | 1220 | |
1221 | - if ( $column_key === $primary ) { |
|
1221 | + if ($column_key === $primary) { |
|
1222 | 1222 | $class[] = 'column-primary'; |
1223 | 1223 | } |
1224 | 1224 | |
1225 | - if ( isset( $sortable[ $column_key ] ) ) { |
|
1226 | - list( $orderby, $desc_first ) = $sortable[ $column_key ]; |
|
1225 | + if (isset($sortable[$column_key])) { |
|
1226 | + list($orderby, $desc_first) = $sortable[$column_key]; |
|
1227 | 1227 | |
1228 | - if ( $current_orderby === $orderby ) { |
|
1228 | + if ($current_orderby === $orderby) { |
|
1229 | 1229 | $order = 'asc' === $current_order ? 'desc' : 'asc'; |
1230 | 1230 | |
1231 | 1231 | $class[] = 'sorted'; |
1232 | 1232 | $class[] = $current_order; |
1233 | 1233 | } else { |
1234 | - $order = strtolower( $desc_first ); |
|
1234 | + $order = strtolower($desc_first); |
|
1235 | 1235 | |
1236 | - if ( ! in_array( $order, array( 'desc', 'asc' ), true ) ) { |
|
1236 | + if (!in_array($order, array('desc', 'asc'), true)) { |
|
1237 | 1237 | $order = $desc_first ? 'desc' : 'asc'; |
1238 | 1238 | } |
1239 | 1239 | |
@@ -1243,17 +1243,17 @@ discard block |
||
1243 | 1243 | |
1244 | 1244 | $column_display_name = sprintf( |
1245 | 1245 | '<a href="%s"><span>%s</span><span class="sorting-indicator"></span></a>', |
1246 | - esc_url( add_query_arg( compact( 'orderby', 'order' ), $current_url ) ), |
|
1246 | + esc_url(add_query_arg(compact('orderby', 'order'), $current_url)), |
|
1247 | 1247 | $column_display_name |
1248 | 1248 | ); |
1249 | 1249 | } |
1250 | 1250 | |
1251 | - $tag = ( 'cb' === $column_key ) ? 'td' : 'th'; |
|
1252 | - $scope = ( 'th' === $tag ) ? 'scope="col"' : ''; |
|
1251 | + $tag = ('cb' === $column_key) ? 'td' : 'th'; |
|
1252 | + $scope = ('th' === $tag) ? 'scope="col"' : ''; |
|
1253 | 1253 | $id = $with_id ? "id='$column_key'" : ''; |
1254 | 1254 | |
1255 | - if ( ! empty( $class ) ) { |
|
1256 | - $class = "class='" . implode( ' ', $class ) . "'"; |
|
1255 | + if (!empty($class)) { |
|
1256 | + $class = "class='" . implode(' ', $class) . "'"; |
|
1257 | 1257 | } |
1258 | 1258 | |
1259 | 1259 | echo "<$tag $scope $id $class>$column_display_name</$tag>"; |
@@ -1268,11 +1268,11 @@ discard block |
||
1268 | 1268 | public function display() { |
1269 | 1269 | $singular = $this->_args['singular']; |
1270 | 1270 | |
1271 | - $this->display_tablenav( 'top' ); |
|
1271 | + $this->display_tablenav('top'); |
|
1272 | 1272 | |
1273 | - $this->screen->render_screen_reader_content( 'heading_list' ); |
|
1273 | + $this->screen->render_screen_reader_content('heading_list'); |
|
1274 | 1274 | ?> |
1275 | -<table class="wp-list-table <?php echo implode( ' ', $this->get_table_classes() ); ?>"> |
|
1275 | +<table class="wp-list-table <?php echo implode(' ', $this->get_table_classes()); ?>"> |
|
1276 | 1276 | <thead> |
1277 | 1277 | <tr> |
1278 | 1278 | <?php $this->print_column_headers(); ?> |
@@ -1281,7 +1281,7 @@ discard block |
||
1281 | 1281 | |
1282 | 1282 | <tbody id="the-list" |
1283 | 1283 | <?php |
1284 | - if ( $singular ) { |
|
1284 | + if ($singular) { |
|
1285 | 1285 | echo " data-wp-lists='list:$singular'"; |
1286 | 1286 | } |
1287 | 1287 | ?> |
@@ -1291,13 +1291,13 @@ discard block |
||
1291 | 1291 | |
1292 | 1292 | <tfoot> |
1293 | 1293 | <tr> |
1294 | - <?php $this->print_column_headers( false ); ?> |
|
1294 | + <?php $this->print_column_headers(false); ?> |
|
1295 | 1295 | </tr> |
1296 | 1296 | </tfoot> |
1297 | 1297 | |
1298 | 1298 | </table> |
1299 | 1299 | <?php |
1300 | - $this->display_tablenav( 'bottom' ); |
|
1300 | + $this->display_tablenav('bottom'); |
|
1301 | 1301 | } |
1302 | 1302 | |
1303 | 1303 | /** |
@@ -1308,11 +1308,11 @@ discard block |
||
1308 | 1308 | * @return string[] Array of CSS classes for the table tag. |
1309 | 1309 | */ |
1310 | 1310 | protected function get_table_classes() { |
1311 | - $mode = get_user_setting( 'posts_list_mode', 'list' ); |
|
1311 | + $mode = get_user_setting('posts_list_mode', 'list'); |
|
1312 | 1312 | |
1313 | - $mode_class = esc_attr( 'table-view-' . $mode ); |
|
1313 | + $mode_class = esc_attr('table-view-' . $mode); |
|
1314 | 1314 | |
1315 | - return array( 'widefat', 'fixed', 'striped', $mode_class, $this->_args['plural'] ); |
|
1315 | + return array('widefat', 'fixed', 'striped', $mode_class, $this->_args['plural']); |
|
1316 | 1316 | } |
1317 | 1317 | |
1318 | 1318 | /** |
@@ -1321,21 +1321,21 @@ discard block |
||
1321 | 1321 | * @since 3.1.0 |
1322 | 1322 | * @param string $which |
1323 | 1323 | */ |
1324 | - protected function display_tablenav( $which ) { |
|
1325 | - if ( 'top' === $which ) { |
|
1326 | - wp_nonce_field( 'bulk-' . $this->_args['plural'] ); |
|
1324 | + protected function display_tablenav($which) { |
|
1325 | + if ('top' === $which) { |
|
1326 | + wp_nonce_field('bulk-' . $this->_args['plural']); |
|
1327 | 1327 | } |
1328 | 1328 | ?> |
1329 | - <div class="tablenav <?php echo esc_attr( $which ); ?>"> |
|
1329 | + <div class="tablenav <?php echo esc_attr($which); ?>"> |
|
1330 | 1330 | |
1331 | - <?php if ( $this->has_items() ) : ?> |
|
1331 | + <?php if ($this->has_items()) : ?> |
|
1332 | 1332 | <div class="alignleft actions bulkactions"> |
1333 | - <?php $this->bulk_actions( $which ); ?> |
|
1333 | + <?php $this->bulk_actions($which); ?> |
|
1334 | 1334 | </div> |
1335 | 1335 | <?php |
1336 | 1336 | endif; |
1337 | - $this->extra_tablenav( $which ); |
|
1338 | - $this->pagination( $which ); |
|
1337 | + $this->extra_tablenav($which); |
|
1338 | + $this->pagination($which); |
|
1339 | 1339 | ?> |
1340 | 1340 | |
1341 | 1341 | <br class="clear" /> |
@@ -1350,7 +1350,7 @@ discard block |
||
1350 | 1350 | * |
1351 | 1351 | * @param string $which |
1352 | 1352 | */ |
1353 | - protected function extra_tablenav( $which ) {} |
|
1353 | + protected function extra_tablenav($which) {} |
|
1354 | 1354 | |
1355 | 1355 | /** |
1356 | 1356 | * Generates the tbody element for the list table. |
@@ -1358,7 +1358,7 @@ discard block |
||
1358 | 1358 | * @since 3.1.0 |
1359 | 1359 | */ |
1360 | 1360 | public function display_rows_or_placeholder() { |
1361 | - if ( $this->has_items() ) { |
|
1361 | + if ($this->has_items()) { |
|
1362 | 1362 | $this->display_rows(); |
1363 | 1363 | } else { |
1364 | 1364 | echo '<tr class="no-items"><td class="colspanchange" colspan="' . $this->get_column_count() . '">'; |
@@ -1373,8 +1373,8 @@ discard block |
||
1373 | 1373 | * @since 3.1.0 |
1374 | 1374 | */ |
1375 | 1375 | public function display_rows() { |
1376 | - foreach ( $this->items as $item ) { |
|
1377 | - $this->single_row( $item ); |
|
1376 | + foreach ($this->items as $item) { |
|
1377 | + $this->single_row($item); |
|
1378 | 1378 | } |
1379 | 1379 | } |
1380 | 1380 | |
@@ -1385,9 +1385,9 @@ discard block |
||
1385 | 1385 | * |
1386 | 1386 | * @param object|array $item The current item |
1387 | 1387 | */ |
1388 | - public function single_row( $item ) { |
|
1388 | + public function single_row($item) { |
|
1389 | 1389 | echo '<tr>'; |
1390 | - $this->single_row_columns( $item ); |
|
1390 | + $this->single_row_columns($item); |
|
1391 | 1391 | echo '</tr>'; |
1392 | 1392 | } |
1393 | 1393 | |
@@ -1395,12 +1395,12 @@ discard block |
||
1395 | 1395 | * @param object|array $item |
1396 | 1396 | * @param string $column_name |
1397 | 1397 | */ |
1398 | - protected function column_default( $item, $column_name ) {} |
|
1398 | + protected function column_default($item, $column_name) {} |
|
1399 | 1399 | |
1400 | 1400 | /** |
1401 | 1401 | * @param object|array $item |
1402 | 1402 | */ |
1403 | - protected function column_cb( $item ) {} |
|
1403 | + protected function column_cb($item) {} |
|
1404 | 1404 | |
1405 | 1405 | /** |
1406 | 1406 | * Generates the columns for a single row of the table. |
@@ -1409,46 +1409,46 @@ discard block |
||
1409 | 1409 | * |
1410 | 1410 | * @param object|array $item The current item. |
1411 | 1411 | */ |
1412 | - protected function single_row_columns( $item ) { |
|
1413 | - list( $columns, $hidden, $sortable, $primary ) = $this->get_column_info(); |
|
1412 | + protected function single_row_columns($item) { |
|
1413 | + list($columns, $hidden, $sortable, $primary) = $this->get_column_info(); |
|
1414 | 1414 | |
1415 | - foreach ( $columns as $column_name => $column_display_name ) { |
|
1415 | + foreach ($columns as $column_name => $column_display_name) { |
|
1416 | 1416 | $classes = "$column_name column-$column_name"; |
1417 | - if ( $primary === $column_name ) { |
|
1417 | + if ($primary === $column_name) { |
|
1418 | 1418 | $classes .= ' has-row-actions column-primary'; |
1419 | 1419 | } |
1420 | 1420 | |
1421 | - if ( in_array( $column_name, $hidden, true ) ) { |
|
1421 | + if (in_array($column_name, $hidden, true)) { |
|
1422 | 1422 | $classes .= ' hidden'; |
1423 | 1423 | } |
1424 | 1424 | |
1425 | 1425 | // Comments column uses HTML in the display name with screen reader text. |
1426 | 1426 | // Strip tags to get closer to a user-friendly string. |
1427 | - $data = 'data-colname="' . esc_attr( wp_strip_all_tags( $column_display_name ) ) . '"'; |
|
1427 | + $data = 'data-colname="' . esc_attr(wp_strip_all_tags($column_display_name)) . '"'; |
|
1428 | 1428 | |
1429 | 1429 | $attributes = "class='$classes' $data"; |
1430 | 1430 | |
1431 | - if ( 'cb' === $column_name ) { |
|
1431 | + if ('cb' === $column_name) { |
|
1432 | 1432 | echo '<th scope="row" class="check-column">'; |
1433 | - echo $this->column_cb( $item ); |
|
1433 | + echo $this->column_cb($item); |
|
1434 | 1434 | echo '</th>'; |
1435 | - } elseif ( method_exists( $this, '_column_' . $column_name ) ) { |
|
1435 | + } elseif (method_exists($this, '_column_' . $column_name)) { |
|
1436 | 1436 | echo call_user_func( |
1437 | - array( $this, '_column_' . $column_name ), |
|
1437 | + array($this, '_column_' . $column_name), |
|
1438 | 1438 | $item, |
1439 | 1439 | $classes, |
1440 | 1440 | $data, |
1441 | 1441 | $primary |
1442 | 1442 | ); |
1443 | - } elseif ( method_exists( $this, 'column_' . $column_name ) ) { |
|
1443 | + } elseif (method_exists($this, 'column_' . $column_name)) { |
|
1444 | 1444 | echo "<td $attributes>"; |
1445 | - echo call_user_func( array( $this, 'column_' . $column_name ), $item ); |
|
1446 | - echo $this->handle_row_actions( $item, $column_name, $primary ); |
|
1445 | + echo call_user_func(array($this, 'column_' . $column_name), $item); |
|
1446 | + echo $this->handle_row_actions($item, $column_name, $primary); |
|
1447 | 1447 | echo '</td>'; |
1448 | 1448 | } else { |
1449 | 1449 | echo "<td $attributes>"; |
1450 | - echo $this->column_default( $item, $column_name ); |
|
1451 | - echo $this->handle_row_actions( $item, $column_name, $primary ); |
|
1450 | + echo $this->column_default($item, $column_name); |
|
1451 | + echo $this->handle_row_actions($item, $column_name, $primary); |
|
1452 | 1452 | echo '</td>'; |
1453 | 1453 | } |
1454 | 1454 | } |
@@ -1465,8 +1465,8 @@ discard block |
||
1465 | 1465 | * @return string The row actions HTML, or an empty string |
1466 | 1466 | * if the current column is not the primary column. |
1467 | 1467 | */ |
1468 | - protected function handle_row_actions( $item, $column_name, $primary ) { |
|
1469 | - return $column_name === $primary ? '<button type="button" class="toggle-row"><span class="screen-reader-text">' . __( 'Show more details' ) . '</span></button>' : ''; |
|
1468 | + protected function handle_row_actions($item, $column_name, $primary) { |
|
1469 | + return $column_name === $primary ? '<button type="button" class="toggle-row"><span class="screen-reader-text">' . __('Show more details') . '</span></button>' : ''; |
|
1470 | 1470 | } |
1471 | 1471 | |
1472 | 1472 | /** |
@@ -1478,7 +1478,7 @@ discard block |
||
1478 | 1478 | $this->prepare_items(); |
1479 | 1479 | |
1480 | 1480 | ob_start(); |
1481 | - if ( ! empty( $_REQUEST['no_placeholder'] ) ) { |
|
1481 | + if (!empty($_REQUEST['no_placeholder'])) { |
|
1482 | 1482 | $this->display_rows(); |
1483 | 1483 | } else { |
1484 | 1484 | $this->display_rows_or_placeholder(); |
@@ -1486,21 +1486,21 @@ discard block |
||
1486 | 1486 | |
1487 | 1487 | $rows = ob_get_clean(); |
1488 | 1488 | |
1489 | - $response = array( 'rows' => $rows ); |
|
1489 | + $response = array('rows' => $rows); |
|
1490 | 1490 | |
1491 | - if ( isset( $this->_pagination_args['total_items'] ) ) { |
|
1491 | + if (isset($this->_pagination_args['total_items'])) { |
|
1492 | 1492 | $response['total_items_i18n'] = sprintf( |
1493 | 1493 | /* translators: Number of items. */ |
1494 | - _n( '%s item', '%s items', $this->_pagination_args['total_items'] ), |
|
1495 | - number_format_i18n( $this->_pagination_args['total_items'] ) |
|
1494 | + _n('%s item', '%s items', $this->_pagination_args['total_items']), |
|
1495 | + number_format_i18n($this->_pagination_args['total_items']) |
|
1496 | 1496 | ); |
1497 | 1497 | } |
1498 | - if ( isset( $this->_pagination_args['total_pages'] ) ) { |
|
1498 | + if (isset($this->_pagination_args['total_pages'])) { |
|
1499 | 1499 | $response['total_pages'] = $this->_pagination_args['total_pages']; |
1500 | - $response['total_pages_i18n'] = number_format_i18n( $this->_pagination_args['total_pages'] ); |
|
1500 | + $response['total_pages_i18n'] = number_format_i18n($this->_pagination_args['total_pages']); |
|
1501 | 1501 | } |
1502 | 1502 | |
1503 | - die( wp_json_encode( $response ) ); |
|
1503 | + die(wp_json_encode($response)); |
|
1504 | 1504 | } |
1505 | 1505 | |
1506 | 1506 | /** |
@@ -1510,13 +1510,13 @@ discard block |
||
1510 | 1510 | */ |
1511 | 1511 | public function _js_vars() { |
1512 | 1512 | $args = array( |
1513 | - 'class' => get_class( $this ), |
|
1513 | + 'class' => get_class($this), |
|
1514 | 1514 | 'screen' => array( |
1515 | 1515 | 'id' => $this->screen->id, |
1516 | 1516 | 'base' => $this->screen->base, |
1517 | 1517 | ), |
1518 | 1518 | ); |
1519 | 1519 | |
1520 | - printf( "<script type='text/javascript'>list_args = %s;</script>\n", wp_json_encode( $args ) ); |
|
1520 | + printf("<script type='text/javascript'>list_args = %s;</script>\n", wp_json_encode($args)); |
|
1521 | 1521 | } |
1522 | 1522 | } |
@@ -14,14 +14,14 @@ discard block |
||
14 | 14 | * @param string|WP_Screen $screen The screen you want the headers for |
15 | 15 | * @return string[] The column header labels keyed by column ID. |
16 | 16 | */ |
17 | -function get_column_headers( $screen ) { |
|
17 | +function get_column_headers($screen) { |
|
18 | 18 | static $column_headers = array(); |
19 | 19 | |
20 | - if ( is_string( $screen ) ) { |
|
21 | - $screen = convert_to_screen( $screen ); |
|
20 | + if (is_string($screen)) { |
|
21 | + $screen = convert_to_screen($screen); |
|
22 | 22 | } |
23 | 23 | |
24 | - if ( ! isset( $column_headers[ $screen->id ] ) ) { |
|
24 | + if (!isset($column_headers[$screen->id])) { |
|
25 | 25 | /** |
26 | 26 | * Filters the column headers for a list table on a specific screen. |
27 | 27 | * |
@@ -34,10 +34,10 @@ discard block |
||
34 | 34 | * |
35 | 35 | * @param string[] $columns The column header labels keyed by column ID. |
36 | 36 | */ |
37 | - $column_headers[ $screen->id ] = apply_filters( "manage_{$screen->id}_columns", array() ); |
|
37 | + $column_headers[$screen->id] = apply_filters("manage_{$screen->id}_columns", array()); |
|
38 | 38 | } |
39 | 39 | |
40 | - return $column_headers[ $screen->id ]; |
|
40 | + return $column_headers[$screen->id]; |
|
41 | 41 | } |
42 | 42 | |
43 | 43 | /** |
@@ -48,16 +48,16 @@ discard block |
||
48 | 48 | * @param string|WP_Screen $screen The screen you want the hidden columns for |
49 | 49 | * @return string[] Array of IDs of hidden columns. |
50 | 50 | */ |
51 | -function get_hidden_columns( $screen ) { |
|
52 | - if ( is_string( $screen ) ) { |
|
53 | - $screen = convert_to_screen( $screen ); |
|
51 | +function get_hidden_columns($screen) { |
|
52 | + if (is_string($screen)) { |
|
53 | + $screen = convert_to_screen($screen); |
|
54 | 54 | } |
55 | 55 | |
56 | - $hidden = get_user_option( 'manage' . $screen->id . 'columnshidden' ); |
|
56 | + $hidden = get_user_option('manage' . $screen->id . 'columnshidden'); |
|
57 | 57 | |
58 | - $use_defaults = ! is_array( $hidden ); |
|
58 | + $use_defaults = !is_array($hidden); |
|
59 | 59 | |
60 | - if ( $use_defaults ) { |
|
60 | + if ($use_defaults) { |
|
61 | 61 | $hidden = array(); |
62 | 62 | |
63 | 63 | /** |
@@ -68,7 +68,7 @@ discard block |
||
68 | 68 | * @param string[] $hidden Array of IDs of columns hidden by default. |
69 | 69 | * @param WP_Screen $screen WP_Screen object of the current screen. |
70 | 70 | */ |
71 | - $hidden = apply_filters( 'default_hidden_columns', $hidden, $screen ); |
|
71 | + $hidden = apply_filters('default_hidden_columns', $hidden, $screen); |
|
72 | 72 | } |
73 | 73 | |
74 | 74 | /** |
@@ -81,7 +81,7 @@ discard block |
||
81 | 81 | * @param WP_Screen $screen WP_Screen object of the current screen. |
82 | 82 | * @param bool $use_defaults Whether to show the default columns. |
83 | 83 | */ |
84 | - return apply_filters( 'hidden_columns', $hidden, $screen, $use_defaults ); |
|
84 | + return apply_filters('hidden_columns', $hidden, $screen, $use_defaults); |
|
85 | 85 | } |
86 | 86 | |
87 | 87 | /** |
@@ -93,47 +93,47 @@ discard block |
||
93 | 93 | * |
94 | 94 | * @param WP_Screen $screen |
95 | 95 | */ |
96 | -function meta_box_prefs( $screen ) { |
|
96 | +function meta_box_prefs($screen) { |
|
97 | 97 | global $wp_meta_boxes; |
98 | 98 | |
99 | - if ( is_string( $screen ) ) { |
|
100 | - $screen = convert_to_screen( $screen ); |
|
99 | + if (is_string($screen)) { |
|
100 | + $screen = convert_to_screen($screen); |
|
101 | 101 | } |
102 | 102 | |
103 | - if ( empty( $wp_meta_boxes[ $screen->id ] ) ) { |
|
103 | + if (empty($wp_meta_boxes[$screen->id])) { |
|
104 | 104 | return; |
105 | 105 | } |
106 | 106 | |
107 | - $hidden = get_hidden_meta_boxes( $screen ); |
|
107 | + $hidden = get_hidden_meta_boxes($screen); |
|
108 | 108 | |
109 | - foreach ( array_keys( $wp_meta_boxes[ $screen->id ] ) as $context ) { |
|
110 | - foreach ( array( 'high', 'core', 'default', 'low' ) as $priority ) { |
|
111 | - if ( ! isset( $wp_meta_boxes[ $screen->id ][ $context ][ $priority ] ) ) { |
|
109 | + foreach (array_keys($wp_meta_boxes[$screen->id]) as $context) { |
|
110 | + foreach (array('high', 'core', 'default', 'low') as $priority) { |
|
111 | + if (!isset($wp_meta_boxes[$screen->id][$context][$priority])) { |
|
112 | 112 | continue; |
113 | 113 | } |
114 | 114 | |
115 | - foreach ( $wp_meta_boxes[ $screen->id ][ $context ][ $priority ] as $box ) { |
|
116 | - if ( false === $box || ! $box['title'] ) { |
|
115 | + foreach ($wp_meta_boxes[$screen->id][$context][$priority] as $box) { |
|
116 | + if (false === $box || !$box['title']) { |
|
117 | 117 | continue; |
118 | 118 | } |
119 | 119 | |
120 | 120 | // Submit box cannot be hidden. |
121 | - if ( 'submitdiv' === $box['id'] || 'linksubmitdiv' === $box['id'] ) { |
|
121 | + if ('submitdiv' === $box['id'] || 'linksubmitdiv' === $box['id']) { |
|
122 | 122 | continue; |
123 | 123 | } |
124 | 124 | |
125 | 125 | $widget_title = $box['title']; |
126 | 126 | |
127 | - if ( is_array( $box['args'] ) && isset( $box['args']['__widget_basename'] ) ) { |
|
127 | + if (is_array($box['args']) && isset($box['args']['__widget_basename'])) { |
|
128 | 128 | $widget_title = $box['args']['__widget_basename']; |
129 | 129 | } |
130 | 130 | |
131 | - $is_hidden = in_array( $box['id'], $hidden, true ); |
|
131 | + $is_hidden = in_array($box['id'], $hidden, true); |
|
132 | 132 | |
133 | 133 | printf( |
134 | 134 | '<label for="%1$s-hide"><input class="hide-postbox-tog" name="%1$s-hide" type="checkbox" id="%1$s-hide" value="%1$s" %2$s />%3$s</label>', |
135 | - esc_attr( $box['id'] ), |
|
136 | - checked( $is_hidden, false, false ), |
|
135 | + esc_attr($box['id']), |
|
136 | + checked($is_hidden, false, false), |
|
137 | 137 | $widget_title |
138 | 138 | ); |
139 | 139 | } |
@@ -149,24 +149,24 @@ discard block |
||
149 | 149 | * @param string|WP_Screen $screen Screen identifier |
150 | 150 | * @return string[] IDs of hidden meta boxes. |
151 | 151 | */ |
152 | -function get_hidden_meta_boxes( $screen ) { |
|
153 | - if ( is_string( $screen ) ) { |
|
154 | - $screen = convert_to_screen( $screen ); |
|
152 | +function get_hidden_meta_boxes($screen) { |
|
153 | + if (is_string($screen)) { |
|
154 | + $screen = convert_to_screen($screen); |
|
155 | 155 | } |
156 | 156 | |
157 | - $hidden = get_user_option( "metaboxhidden_{$screen->id}" ); |
|
157 | + $hidden = get_user_option("metaboxhidden_{$screen->id}"); |
|
158 | 158 | |
159 | - $use_defaults = ! is_array( $hidden ); |
|
159 | + $use_defaults = !is_array($hidden); |
|
160 | 160 | |
161 | 161 | // Hide slug boxes by default. |
162 | - if ( $use_defaults ) { |
|
162 | + if ($use_defaults) { |
|
163 | 163 | $hidden = array(); |
164 | 164 | |
165 | - if ( 'post' === $screen->base ) { |
|
166 | - if ( in_array( $screen->post_type, array( 'post', 'page', 'attachment' ), true ) ) { |
|
167 | - $hidden = array( 'slugdiv', 'trackbacksdiv', 'postcustom', 'postexcerpt', 'commentstatusdiv', 'commentsdiv', 'authordiv', 'revisionsdiv' ); |
|
165 | + if ('post' === $screen->base) { |
|
166 | + if (in_array($screen->post_type, array('post', 'page', 'attachment'), true)) { |
|
167 | + $hidden = array('slugdiv', 'trackbacksdiv', 'postcustom', 'postexcerpt', 'commentstatusdiv', 'commentsdiv', 'authordiv', 'revisionsdiv'); |
|
168 | 168 | } else { |
169 | - $hidden = array( 'slugdiv' ); |
|
169 | + $hidden = array('slugdiv'); |
|
170 | 170 | } |
171 | 171 | } |
172 | 172 | |
@@ -178,7 +178,7 @@ discard block |
||
178 | 178 | * @param string[] $hidden An array of IDs of meta boxes hidden by default. |
179 | 179 | * @param WP_Screen $screen WP_Screen object of the current screen. |
180 | 180 | */ |
181 | - $hidden = apply_filters( 'default_hidden_meta_boxes', $hidden, $screen ); |
|
181 | + $hidden = apply_filters('default_hidden_meta_boxes', $hidden, $screen); |
|
182 | 182 | } |
183 | 183 | |
184 | 184 | /** |
@@ -191,7 +191,7 @@ discard block |
||
191 | 191 | * @param bool $use_defaults Whether to show the default meta boxes. |
192 | 192 | * Default true. |
193 | 193 | */ |
194 | - return apply_filters( 'hidden_meta_boxes', $hidden, $screen, $use_defaults ); |
|
194 | + return apply_filters('hidden_meta_boxes', $hidden, $screen, $use_defaults); |
|
195 | 195 | } |
196 | 196 | |
197 | 197 | /** |
@@ -202,14 +202,14 @@ discard block |
||
202 | 202 | * @param string $option An option name. |
203 | 203 | * @param mixed $args Option-dependent arguments. |
204 | 204 | */ |
205 | -function add_screen_option( $option, $args = array() ) { |
|
205 | +function add_screen_option($option, $args = array()) { |
|
206 | 206 | $current_screen = get_current_screen(); |
207 | 207 | |
208 | - if ( ! $current_screen ) { |
|
208 | + if (!$current_screen) { |
|
209 | 209 | return; |
210 | 210 | } |
211 | 211 | |
212 | - $current_screen->add_option( $option, $args ); |
|
212 | + $current_screen->add_option($option, $args); |
|
213 | 213 | } |
214 | 214 | |
215 | 215 | /** |
@@ -224,7 +224,7 @@ discard block |
||
224 | 224 | function get_current_screen() { |
225 | 225 | global $current_screen; |
226 | 226 | |
227 | - if ( ! isset( $current_screen ) ) { |
|
227 | + if (!isset($current_screen)) { |
|
228 | 228 | return null; |
229 | 229 | } |
230 | 230 | |
@@ -239,6 +239,6 @@ discard block |
||
239 | 239 | * @param string|WP_Screen $hook_name Optional. The hook name (also known as the hook suffix) used to determine the screen, |
240 | 240 | * or an existing screen object. |
241 | 241 | */ |
242 | -function set_current_screen( $hook_name = '' ) { |
|
243 | - WP_Screen::get( $hook_name )->set_current_screen(); |
|
242 | +function set_current_screen($hook_name = '') { |
|
243 | + WP_Screen::get($hook_name)->set_current_screen(); |
|
244 | 244 | } |
@@ -71,18 +71,18 @@ discard block |
||
71 | 71 | * |
72 | 72 | * @param array $args An associative array of arguments. |
73 | 73 | */ |
74 | - public function __construct( $args = array() ) { |
|
74 | + public function __construct($args = array()) { |
|
75 | 75 | global $post_type_object, $wpdb; |
76 | 76 | |
77 | 77 | parent::__construct( |
78 | 78 | array( |
79 | 79 | 'plural' => 'posts', |
80 | - 'screen' => isset( $args['screen'] ) ? $args['screen'] : null, |
|
80 | + 'screen' => isset($args['screen']) ? $args['screen'] : null, |
|
81 | 81 | ) |
82 | 82 | ); |
83 | 83 | |
84 | 84 | $post_type = $this->screen->post_type; |
85 | - $post_type_object = get_post_type_object( $post_type ); |
|
85 | + $post_type_object = get_post_type_object($post_type); |
|
86 | 86 | |
87 | 87 | $exclude_states = get_post_stati( |
88 | 88 | array( |
@@ -95,25 +95,25 @@ discard block |
||
95 | 95 | "SELECT COUNT( 1 ) |
96 | 96 | FROM $wpdb->posts |
97 | 97 | WHERE post_type = %s |
98 | - AND post_status NOT IN ( '" . implode( "','", $exclude_states ) . "' ) |
|
98 | + AND post_status NOT IN ( '" . implode("','", $exclude_states) . "' ) |
|
99 | 99 | AND post_author = %d", |
100 | 100 | $post_type, |
101 | 101 | get_current_user_id() |
102 | 102 | ) |
103 | 103 | ); |
104 | 104 | |
105 | - if ( $this->user_posts_count |
|
106 | - && ! current_user_can( $post_type_object->cap->edit_others_posts ) |
|
107 | - && empty( $_REQUEST['post_status'] ) && empty( $_REQUEST['all_posts'] ) |
|
108 | - && empty( $_REQUEST['author'] ) && empty( $_REQUEST['show_sticky'] ) |
|
105 | + if ($this->user_posts_count |
|
106 | + && !current_user_can($post_type_object->cap->edit_others_posts) |
|
107 | + && empty($_REQUEST['post_status']) && empty($_REQUEST['all_posts']) |
|
108 | + && empty($_REQUEST['author']) && empty($_REQUEST['show_sticky']) |
|
109 | 109 | ) { |
110 | 110 | $_GET['author'] = get_current_user_id(); |
111 | 111 | } |
112 | 112 | |
113 | - $sticky_posts = get_option( 'sticky_posts' ); |
|
113 | + $sticky_posts = get_option('sticky_posts'); |
|
114 | 114 | |
115 | - if ( 'post' === $post_type && $sticky_posts ) { |
|
116 | - $sticky_posts = implode( ', ', array_map( 'absint', (array) $sticky_posts ) ); |
|
115 | + if ('post' === $post_type && $sticky_posts) { |
|
116 | + $sticky_posts = implode(', ', array_map('absint', (array) $sticky_posts)); |
|
117 | 117 | |
118 | 118 | $this->sticky_posts_count = (int) $wpdb->get_var( |
119 | 119 | $wpdb->prepare( |
@@ -135,7 +135,7 @@ discard block |
||
135 | 135 | * |
136 | 136 | * @param bool $display Whether the table layout should be hierarchical. |
137 | 137 | */ |
138 | - public function set_hierarchical_display( $display ) { |
|
138 | + public function set_hierarchical_display($display) { |
|
139 | 139 | $this->hierarchical_display = $display; |
140 | 140 | } |
141 | 141 | |
@@ -143,7 +143,7 @@ discard block |
||
143 | 143 | * @return bool |
144 | 144 | */ |
145 | 145 | public function ajax_user_can() { |
146 | - return current_user_can( get_post_type_object( $this->screen->post_type )->cap->edit_posts ); |
|
146 | + return current_user_can(get_post_type_object($this->screen->post_type)->cap->edit_posts); |
|
147 | 147 | } |
148 | 148 | |
149 | 149 | /** |
@@ -155,51 +155,51 @@ discard block |
||
155 | 155 | public function prepare_items() { |
156 | 156 | global $mode, $avail_post_stati, $wp_query, $per_page; |
157 | 157 | |
158 | - if ( ! empty( $_REQUEST['mode'] ) ) { |
|
158 | + if (!empty($_REQUEST['mode'])) { |
|
159 | 159 | $mode = 'excerpt' === $_REQUEST['mode'] ? 'excerpt' : 'list'; |
160 | - set_user_setting( 'posts_list_mode', $mode ); |
|
160 | + set_user_setting('posts_list_mode', $mode); |
|
161 | 161 | } else { |
162 | - $mode = get_user_setting( 'posts_list_mode', 'list' ); |
|
162 | + $mode = get_user_setting('posts_list_mode', 'list'); |
|
163 | 163 | } |
164 | 164 | |
165 | 165 | // Is going to call wp(). |
166 | 166 | $avail_post_stati = wp_edit_posts_query(); |
167 | 167 | |
168 | 168 | $this->set_hierarchical_display( |
169 | - is_post_type_hierarchical( $this->screen->post_type ) |
|
169 | + is_post_type_hierarchical($this->screen->post_type) |
|
170 | 170 | && 'menu_order title' === $wp_query->query['orderby'] |
171 | 171 | ); |
172 | 172 | |
173 | 173 | $post_type = $this->screen->post_type; |
174 | - $per_page = $this->get_items_per_page( 'edit_' . $post_type . '_per_page' ); |
|
174 | + $per_page = $this->get_items_per_page('edit_' . $post_type . '_per_page'); |
|
175 | 175 | |
176 | 176 | /** This filter is documented in wp-admin/includes/post.php */ |
177 | - $per_page = apply_filters( 'edit_posts_per_page', $per_page, $post_type ); |
|
177 | + $per_page = apply_filters('edit_posts_per_page', $per_page, $post_type); |
|
178 | 178 | |
179 | - if ( $this->hierarchical_display ) { |
|
179 | + if ($this->hierarchical_display) { |
|
180 | 180 | $total_items = $wp_query->post_count; |
181 | - } elseif ( $wp_query->found_posts || $this->get_pagenum() === 1 ) { |
|
181 | + } elseif ($wp_query->found_posts || $this->get_pagenum() === 1) { |
|
182 | 182 | $total_items = $wp_query->found_posts; |
183 | 183 | } else { |
184 | - $post_counts = (array) wp_count_posts( $post_type, 'readable' ); |
|
184 | + $post_counts = (array) wp_count_posts($post_type, 'readable'); |
|
185 | 185 | |
186 | - if ( isset( $_REQUEST['post_status'] ) && in_array( $_REQUEST['post_status'], $avail_post_stati, true ) ) { |
|
187 | - $total_items = $post_counts[ $_REQUEST['post_status'] ]; |
|
188 | - } elseif ( isset( $_REQUEST['show_sticky'] ) && $_REQUEST['show_sticky'] ) { |
|
186 | + if (isset($_REQUEST['post_status']) && in_array($_REQUEST['post_status'], $avail_post_stati, true)) { |
|
187 | + $total_items = $post_counts[$_REQUEST['post_status']]; |
|
188 | + } elseif (isset($_REQUEST['show_sticky']) && $_REQUEST['show_sticky']) { |
|
189 | 189 | $total_items = $this->sticky_posts_count; |
190 | - } elseif ( isset( $_GET['author'] ) && get_current_user_id() === (int) $_GET['author'] ) { |
|
190 | + } elseif (isset($_GET['author']) && get_current_user_id() === (int) $_GET['author']) { |
|
191 | 191 | $total_items = $this->user_posts_count; |
192 | 192 | } else { |
193 | - $total_items = array_sum( $post_counts ); |
|
193 | + $total_items = array_sum($post_counts); |
|
194 | 194 | |
195 | 195 | // Subtract post types that are not included in the admin all list. |
196 | - foreach ( get_post_stati( array( 'show_in_admin_all_list' => false ) ) as $state ) { |
|
197 | - $total_items -= $post_counts[ $state ]; |
|
196 | + foreach (get_post_stati(array('show_in_admin_all_list' => false)) as $state) { |
|
197 | + $total_items -= $post_counts[$state]; |
|
198 | 198 | } |
199 | 199 | } |
200 | 200 | } |
201 | 201 | |
202 | - $this->is_trash = isset( $_REQUEST['post_status'] ) && 'trash' === $_REQUEST['post_status']; |
|
202 | + $this->is_trash = isset($_REQUEST['post_status']) && 'trash' === $_REQUEST['post_status']; |
|
203 | 203 | |
204 | 204 | $this->set_pagination_args( |
205 | 205 | array( |
@@ -219,10 +219,10 @@ discard block |
||
219 | 219 | /** |
220 | 220 | */ |
221 | 221 | public function no_items() { |
222 | - if ( isset( $_REQUEST['post_status'] ) && 'trash' === $_REQUEST['post_status'] ) { |
|
223 | - echo get_post_type_object( $this->screen->post_type )->labels->not_found_in_trash; |
|
222 | + if (isset($_REQUEST['post_status']) && 'trash' === $_REQUEST['post_status']) { |
|
223 | + echo get_post_type_object($this->screen->post_type)->labels->not_found_in_trash; |
|
224 | 224 | } else { |
225 | - echo get_post_type_object( $this->screen->post_type )->labels->not_found; |
|
225 | + echo get_post_type_object($this->screen->post_type)->labels->not_found; |
|
226 | 226 | } |
227 | 227 | } |
228 | 228 | |
@@ -235,15 +235,15 @@ discard block |
||
235 | 235 | */ |
236 | 236 | protected function is_base_request() { |
237 | 237 | $vars = $_GET; |
238 | - unset( $vars['paged'] ); |
|
238 | + unset($vars['paged']); |
|
239 | 239 | |
240 | - if ( empty( $vars ) ) { |
|
240 | + if (empty($vars)) { |
|
241 | 241 | return true; |
242 | - } elseif ( 1 === count( $vars ) && ! empty( $vars['post_type'] ) ) { |
|
242 | + } elseif (1 === count($vars) && !empty($vars['post_type'])) { |
|
243 | 243 | return $this->screen->post_type === $vars['post_type']; |
244 | 244 | } |
245 | 245 | |
246 | - return 1 === count( $vars ) && ! empty( $vars['mode'] ); |
|
246 | + return 1 === count($vars) && !empty($vars['mode']); |
|
247 | 247 | } |
248 | 248 | |
249 | 249 | /** |
@@ -256,26 +256,26 @@ discard block |
||
256 | 256 | * @param string $css_class Optional. Class attribute. Default empty string. |
257 | 257 | * @return string The formatted link string. |
258 | 258 | */ |
259 | - protected function get_edit_link( $args, $link_text, $css_class = '' ) { |
|
260 | - $url = add_query_arg( $args, 'edit.php' ); |
|
259 | + protected function get_edit_link($args, $link_text, $css_class = '') { |
|
260 | + $url = add_query_arg($args, 'edit.php'); |
|
261 | 261 | |
262 | 262 | $class_html = ''; |
263 | 263 | $aria_current = ''; |
264 | 264 | |
265 | - if ( ! empty( $css_class ) ) { |
|
265 | + if (!empty($css_class)) { |
|
266 | 266 | $class_html = sprintf( |
267 | 267 | ' class="%s"', |
268 | - esc_attr( $css_class ) |
|
268 | + esc_attr($css_class) |
|
269 | 269 | ); |
270 | 270 | |
271 | - if ( 'current' === $css_class ) { |
|
271 | + if ('current' === $css_class) { |
|
272 | 272 | $aria_current = ' aria-current="page"'; |
273 | 273 | } |
274 | 274 | } |
275 | 275 | |
276 | 276 | return sprintf( |
277 | 277 | '<a href="%s"%s%s>%s</a>', |
278 | - esc_url( $url ), |
|
278 | + esc_url($url), |
|
279 | 279 | $class_html, |
280 | 280 | $aria_current, |
281 | 281 | $link_text |
@@ -292,26 +292,26 @@ discard block |
||
292 | 292 | |
293 | 293 | $post_type = $this->screen->post_type; |
294 | 294 | |
295 | - if ( ! empty( $locked_post_status ) ) { |
|
295 | + if (!empty($locked_post_status)) { |
|
296 | 296 | return array(); |
297 | 297 | } |
298 | 298 | |
299 | 299 | $status_links = array(); |
300 | - $num_posts = wp_count_posts( $post_type, 'readable' ); |
|
301 | - $total_posts = array_sum( (array) $num_posts ); |
|
300 | + $num_posts = wp_count_posts($post_type, 'readable'); |
|
301 | + $total_posts = array_sum((array) $num_posts); |
|
302 | 302 | $class = ''; |
303 | 303 | |
304 | 304 | $current_user_id = get_current_user_id(); |
305 | - $all_args = array( 'post_type' => $post_type ); |
|
305 | + $all_args = array('post_type' => $post_type); |
|
306 | 306 | $mine = ''; |
307 | 307 | |
308 | 308 | // Subtract post types that are not included in the admin all list. |
309 | - foreach ( get_post_stati( array( 'show_in_admin_all_list' => false ) ) as $state ) { |
|
309 | + foreach (get_post_stati(array('show_in_admin_all_list' => false)) as $state) { |
|
310 | 310 | $total_posts -= $num_posts->$state; |
311 | 311 | } |
312 | 312 | |
313 | - if ( $this->user_posts_count && $this->user_posts_count !== $total_posts ) { |
|
314 | - if ( isset( $_GET['author'] ) && ( $current_user_id === (int) $_GET['author'] ) ) { |
|
313 | + if ($this->user_posts_count && $this->user_posts_count !== $total_posts) { |
|
314 | + if (isset($_GET['author']) && ($current_user_id === (int) $_GET['author'])) { |
|
315 | 315 | $class = 'current'; |
316 | 316 | } |
317 | 317 | |
@@ -328,16 +328,16 @@ discard block |
||
328 | 328 | $this->user_posts_count, |
329 | 329 | 'posts' |
330 | 330 | ), |
331 | - number_format_i18n( $this->user_posts_count ) |
|
331 | + number_format_i18n($this->user_posts_count) |
|
332 | 332 | ); |
333 | 333 | |
334 | - $mine = $this->get_edit_link( $mine_args, $mine_inner_html, $class ); |
|
334 | + $mine = $this->get_edit_link($mine_args, $mine_inner_html, $class); |
|
335 | 335 | |
336 | 336 | $all_args['all_posts'] = 1; |
337 | 337 | $class = ''; |
338 | 338 | } |
339 | 339 | |
340 | - if ( empty( $class ) && ( $this->is_base_request() || isset( $_REQUEST['all_posts'] ) ) ) { |
|
340 | + if (empty($class) && ($this->is_base_request() || isset($_REQUEST['all_posts']))) { |
|
341 | 341 | $class = 'current'; |
342 | 342 | } |
343 | 343 | |
@@ -349,25 +349,25 @@ discard block |
||
349 | 349 | $total_posts, |
350 | 350 | 'posts' |
351 | 351 | ), |
352 | - number_format_i18n( $total_posts ) |
|
352 | + number_format_i18n($total_posts) |
|
353 | 353 | ); |
354 | 354 | |
355 | - $status_links['all'] = $this->get_edit_link( $all_args, $all_inner_html, $class ); |
|
355 | + $status_links['all'] = $this->get_edit_link($all_args, $all_inner_html, $class); |
|
356 | 356 | |
357 | - if ( $mine ) { |
|
357 | + if ($mine) { |
|
358 | 358 | $status_links['mine'] = $mine; |
359 | 359 | } |
360 | 360 | |
361 | - foreach ( get_post_stati( array( 'show_in_admin_status_list' => true ), 'objects' ) as $status ) { |
|
361 | + foreach (get_post_stati(array('show_in_admin_status_list' => true), 'objects') as $status) { |
|
362 | 362 | $class = ''; |
363 | 363 | |
364 | 364 | $status_name = $status->name; |
365 | 365 | |
366 | - if ( ! in_array( $status_name, $avail_post_stati, true ) || empty( $num_posts->$status_name ) ) { |
|
366 | + if (!in_array($status_name, $avail_post_stati, true) || empty($num_posts->$status_name)) { |
|
367 | 367 | continue; |
368 | 368 | } |
369 | 369 | |
370 | - if ( isset( $_REQUEST['post_status'] ) && $status_name === $_REQUEST['post_status'] ) { |
|
370 | + if (isset($_REQUEST['post_status']) && $status_name === $_REQUEST['post_status']) { |
|
371 | 371 | $class = 'current'; |
372 | 372 | } |
373 | 373 | |
@@ -377,15 +377,15 @@ discard block |
||
377 | 377 | ); |
378 | 378 | |
379 | 379 | $status_label = sprintf( |
380 | - translate_nooped_plural( $status->label_count, $num_posts->$status_name ), |
|
381 | - number_format_i18n( $num_posts->$status_name ) |
|
380 | + translate_nooped_plural($status->label_count, $num_posts->$status_name), |
|
381 | + number_format_i18n($num_posts->$status_name) |
|
382 | 382 | ); |
383 | 383 | |
384 | - $status_links[ $status_name ] = $this->get_edit_link( $status_args, $status_label, $class ); |
|
384 | + $status_links[$status_name] = $this->get_edit_link($status_args, $status_label, $class); |
|
385 | 385 | } |
386 | 386 | |
387 | - if ( ! empty( $this->sticky_posts_count ) ) { |
|
388 | - $class = ! empty( $_REQUEST['show_sticky'] ) ? 'current' : ''; |
|
387 | + if (!empty($this->sticky_posts_count)) { |
|
388 | + $class = !empty($_REQUEST['show_sticky']) ? 'current' : ''; |
|
389 | 389 | |
390 | 390 | $sticky_args = array( |
391 | 391 | 'post_type' => $post_type, |
@@ -400,16 +400,16 @@ discard block |
||
400 | 400 | $this->sticky_posts_count, |
401 | 401 | 'posts' |
402 | 402 | ), |
403 | - number_format_i18n( $this->sticky_posts_count ) |
|
403 | + number_format_i18n($this->sticky_posts_count) |
|
404 | 404 | ); |
405 | 405 | |
406 | 406 | $sticky_link = array( |
407 | - 'sticky' => $this->get_edit_link( $sticky_args, $sticky_inner_html, $class ), |
|
407 | + 'sticky' => $this->get_edit_link($sticky_args, $sticky_inner_html, $class), |
|
408 | 408 | ); |
409 | 409 | |
410 | 410 | // Sticky comes after Publish, or if not listed, after All. |
411 | - $split = 1 + array_search( ( isset( $status_links['publish'] ) ? 'publish' : 'all' ), array_keys( $status_links ), true ); |
|
412 | - $status_links = array_merge( array_slice( $status_links, 0, $split ), $sticky_link, array_slice( $status_links, $split ) ); |
|
411 | + $split = 1 + array_search((isset($status_links['publish']) ? 'publish' : 'all'), array_keys($status_links), true); |
|
412 | + $status_links = array_merge(array_slice($status_links, 0, $split), $sticky_link, array_slice($status_links, $split)); |
|
413 | 413 | } |
414 | 414 | |
415 | 415 | return $status_links; |
@@ -420,21 +420,21 @@ discard block |
||
420 | 420 | */ |
421 | 421 | protected function get_bulk_actions() { |
422 | 422 | $actions = array(); |
423 | - $post_type_obj = get_post_type_object( $this->screen->post_type ); |
|
423 | + $post_type_obj = get_post_type_object($this->screen->post_type); |
|
424 | 424 | |
425 | - if ( current_user_can( $post_type_obj->cap->edit_posts ) ) { |
|
426 | - if ( $this->is_trash ) { |
|
427 | - $actions['untrash'] = __( 'Restore' ); |
|
425 | + if (current_user_can($post_type_obj->cap->edit_posts)) { |
|
426 | + if ($this->is_trash) { |
|
427 | + $actions['untrash'] = __('Restore'); |
|
428 | 428 | } else { |
429 | - $actions['edit'] = __( 'Edit' ); |
|
429 | + $actions['edit'] = __('Edit'); |
|
430 | 430 | } |
431 | 431 | } |
432 | 432 | |
433 | - if ( current_user_can( $post_type_obj->cap->delete_posts ) ) { |
|
434 | - if ( $this->is_trash || ! EMPTY_TRASH_DAYS ) { |
|
435 | - $actions['delete'] = __( 'Delete permanently' ); |
|
433 | + if (current_user_can($post_type_obj->cap->delete_posts)) { |
|
434 | + if ($this->is_trash || !EMPTY_TRASH_DAYS) { |
|
435 | + $actions['delete'] = __('Delete permanently'); |
|
436 | 436 | } else { |
437 | - $actions['trash'] = __( 'Move to Trash' ); |
|
437 | + $actions['trash'] = __('Move to Trash'); |
|
438 | 438 | } |
439 | 439 | } |
440 | 440 | |
@@ -450,7 +450,7 @@ discard block |
||
450 | 450 | * |
451 | 451 | * @param string $post_type Post type slug. |
452 | 452 | */ |
453 | - protected function categories_dropdown( $post_type ) { |
|
453 | + protected function categories_dropdown($post_type) { |
|
454 | 454 | global $cat; |
455 | 455 | |
456 | 456 | /** |
@@ -461,13 +461,13 @@ discard block |
||
461 | 461 | * @param bool $disable Whether to disable the categories drop-down. Default false. |
462 | 462 | * @param string $post_type Post type slug. |
463 | 463 | */ |
464 | - if ( false !== apply_filters( 'disable_categories_dropdown', false, $post_type ) ) { |
|
464 | + if (false !== apply_filters('disable_categories_dropdown', false, $post_type)) { |
|
465 | 465 | return; |
466 | 466 | } |
467 | 467 | |
468 | - if ( is_object_in_taxonomy( $post_type, 'category' ) ) { |
|
468 | + if (is_object_in_taxonomy($post_type, 'category')) { |
|
469 | 469 | $dropdown_options = array( |
470 | - 'show_option_all' => get_taxonomy( 'category' )->labels->all_items, |
|
470 | + 'show_option_all' => get_taxonomy('category')->labels->all_items, |
|
471 | 471 | 'hide_empty' => 0, |
472 | 472 | 'hierarchical' => 1, |
473 | 473 | 'show_count' => 0, |
@@ -475,9 +475,9 @@ discard block |
||
475 | 475 | 'selected' => $cat, |
476 | 476 | ); |
477 | 477 | |
478 | - echo '<label class="screen-reader-text" for="cat">' . get_taxonomy( 'category' )->labels->filter_by_item . '</label>'; |
|
478 | + echo '<label class="screen-reader-text" for="cat">' . get_taxonomy('category')->labels->filter_by_item . '</label>'; |
|
479 | 479 | |
480 | - wp_dropdown_categories( $dropdown_options ); |
|
480 | + wp_dropdown_categories($dropdown_options); |
|
481 | 481 | } |
482 | 482 | } |
483 | 483 | |
@@ -489,7 +489,7 @@ discard block |
||
489 | 489 | * |
490 | 490 | * @param string $post_type Post type slug. |
491 | 491 | */ |
492 | - protected function formats_dropdown( $post_type ) { |
|
492 | + protected function formats_dropdown($post_type) { |
|
493 | 493 | /** |
494 | 494 | * Filters whether to remove the 'Formats' drop-down from the post list table. |
495 | 495 | * |
@@ -499,12 +499,12 @@ discard block |
||
499 | 499 | * @param bool $disable Whether to disable the drop-down. Default false. |
500 | 500 | * @param string $post_type Post type slug. |
501 | 501 | */ |
502 | - if ( apply_filters( 'disable_formats_dropdown', false, $post_type ) ) { |
|
502 | + if (apply_filters('disable_formats_dropdown', false, $post_type)) { |
|
503 | 503 | return; |
504 | 504 | } |
505 | 505 | |
506 | 506 | // Return if the post type doesn't have post formats or if we're in the Trash. |
507 | - if ( ! is_object_in_taxonomy( $post_type, 'post_format' ) || $this->is_trash ) { |
|
507 | + if (!is_object_in_taxonomy($post_type, 'post_format') || $this->is_trash) { |
|
508 | 508 | return; |
509 | 509 | } |
510 | 510 | |
@@ -517,28 +517,28 @@ discard block |
||
517 | 517 | ); |
518 | 518 | |
519 | 519 | // Return if there are no posts using formats. |
520 | - if ( ! $used_post_formats ) { |
|
520 | + if (!$used_post_formats) { |
|
521 | 521 | return; |
522 | 522 | } |
523 | 523 | |
524 | - $displayed_post_format = isset( $_GET['post_format'] ) ? $_GET['post_format'] : ''; |
|
524 | + $displayed_post_format = isset($_GET['post_format']) ? $_GET['post_format'] : ''; |
|
525 | 525 | ?> |
526 | - <label for="filter-by-format" class="screen-reader-text"><?php _e( 'Filter by post format' ); ?></label> |
|
526 | + <label for="filter-by-format" class="screen-reader-text"><?php _e('Filter by post format'); ?></label> |
|
527 | 527 | <select name="post_format" id="filter-by-format"> |
528 | - <option<?php selected( $displayed_post_format, '' ); ?> value=""><?php _e( 'All formats' ); ?></option> |
|
528 | + <option<?php selected($displayed_post_format, ''); ?> value=""><?php _e('All formats'); ?></option> |
|
529 | 529 | <?php |
530 | - foreach ( $used_post_formats as $used_post_format ) { |
|
530 | + foreach ($used_post_formats as $used_post_format) { |
|
531 | 531 | // Post format slug. |
532 | - $slug = str_replace( 'post-format-', '', $used_post_format->slug ); |
|
532 | + $slug = str_replace('post-format-', '', $used_post_format->slug); |
|
533 | 533 | // Pretty, translated version of the post format slug. |
534 | - $pretty_name = get_post_format_string( $slug ); |
|
534 | + $pretty_name = get_post_format_string($slug); |
|
535 | 535 | |
536 | 536 | // Skip the standard post format. |
537 | - if ( 'standard' === $slug ) { |
|
537 | + if ('standard' === $slug) { |
|
538 | 538 | continue; |
539 | 539 | } |
540 | 540 | ?> |
541 | - <option<?php selected( $displayed_post_format, $slug ); ?> value="<?php echo esc_attr( $slug ); ?>"><?php echo esc_html( $pretty_name ); ?></option> |
|
541 | + <option<?php selected($displayed_post_format, $slug); ?> value="<?php echo esc_attr($slug); ?>"><?php echo esc_html($pretty_name); ?></option> |
|
542 | 542 | <?php |
543 | 543 | } |
544 | 544 | ?> |
@@ -549,16 +549,16 @@ discard block |
||
549 | 549 | /** |
550 | 550 | * @param string $which |
551 | 551 | */ |
552 | - protected function extra_tablenav( $which ) { |
|
552 | + protected function extra_tablenav($which) { |
|
553 | 553 | ?> |
554 | 554 | <div class="alignleft actions"> |
555 | 555 | <?php |
556 | - if ( 'top' === $which ) { |
|
556 | + if ('top' === $which) { |
|
557 | 557 | ob_start(); |
558 | 558 | |
559 | - $this->months_dropdown( $this->screen->post_type ); |
|
560 | - $this->categories_dropdown( $this->screen->post_type ); |
|
561 | - $this->formats_dropdown( $this->screen->post_type ); |
|
559 | + $this->months_dropdown($this->screen->post_type); |
|
560 | + $this->categories_dropdown($this->screen->post_type); |
|
561 | + $this->formats_dropdown($this->screen->post_type); |
|
562 | 562 | |
563 | 563 | /** |
564 | 564 | * Fires before the Filter button on the Posts and Pages list tables. |
@@ -575,20 +575,20 @@ discard block |
||
575 | 575 | * 'top' or 'bottom' for WP_Posts_List_Table, |
576 | 576 | * 'bar' for WP_Media_List_Table. |
577 | 577 | */ |
578 | - do_action( 'restrict_manage_posts', $this->screen->post_type, $which ); |
|
578 | + do_action('restrict_manage_posts', $this->screen->post_type, $which); |
|
579 | 579 | |
580 | 580 | $output = ob_get_clean(); |
581 | 581 | |
582 | - if ( ! empty( $output ) ) { |
|
582 | + if (!empty($output)) { |
|
583 | 583 | echo $output; |
584 | - submit_button( __( 'Filter' ), '', 'filter_action', false, array( 'id' => 'post-query-submit' ) ); |
|
584 | + submit_button(__('Filter'), '', 'filter_action', false, array('id' => 'post-query-submit')); |
|
585 | 585 | } |
586 | 586 | } |
587 | 587 | |
588 | - if ( $this->is_trash && $this->has_items() |
|
589 | - && current_user_can( get_post_type_object( $this->screen->post_type )->cap->edit_others_posts ) |
|
588 | + if ($this->is_trash && $this->has_items() |
|
589 | + && current_user_can(get_post_type_object($this->screen->post_type)->cap->edit_others_posts) |
|
590 | 590 | ) { |
591 | - submit_button( __( 'Empty Trash' ), 'apply', 'delete_all', false ); |
|
591 | + submit_button(__('Empty Trash'), 'apply', 'delete_all', false); |
|
592 | 592 | } |
593 | 593 | ?> |
594 | 594 | </div> |
@@ -601,14 +601,14 @@ discard block |
||
601 | 601 | * |
602 | 602 | * @param string $which The location of the extra table nav markup: 'top' or 'bottom'. |
603 | 603 | */ |
604 | - do_action( 'manage_posts_extra_tablenav', $which ); |
|
604 | + do_action('manage_posts_extra_tablenav', $which); |
|
605 | 605 | } |
606 | 606 | |
607 | 607 | /** |
608 | 608 | * @return string |
609 | 609 | */ |
610 | 610 | public function current_action() { |
611 | - if ( isset( $_REQUEST['delete_all'] ) || isset( $_REQUEST['delete_all2'] ) ) { |
|
611 | + if (isset($_REQUEST['delete_all']) || isset($_REQUEST['delete_all2'])) { |
|
612 | 612 | return 'delete_all'; |
613 | 613 | } |
614 | 614 | |
@@ -623,14 +623,14 @@ discard block |
||
623 | 623 | protected function get_table_classes() { |
624 | 624 | global $mode; |
625 | 625 | |
626 | - $mode_class = esc_attr( 'table-view-' . $mode ); |
|
626 | + $mode_class = esc_attr('table-view-' . $mode); |
|
627 | 627 | |
628 | 628 | return array( |
629 | 629 | 'widefat', |
630 | 630 | 'fixed', |
631 | 631 | 'striped', |
632 | 632 | $mode_class, |
633 | - is_post_type_hierarchical( $this->screen->post_type ) ? 'pages' : 'posts', |
|
633 | + is_post_type_hierarchical($this->screen->post_type) ? 'pages' : 'posts', |
|
634 | 634 | ); |
635 | 635 | } |
636 | 636 | |
@@ -645,14 +645,14 @@ discard block |
||
645 | 645 | $posts_columns['cb'] = '<input type="checkbox" />'; |
646 | 646 | |
647 | 647 | /* translators: Posts screen column name. */ |
648 | - $posts_columns['title'] = _x( 'Title', 'column name' ); |
|
648 | + $posts_columns['title'] = _x('Title', 'column name'); |
|
649 | 649 | |
650 | - if ( post_type_supports( $post_type, 'author' ) ) { |
|
651 | - $posts_columns['author'] = __( 'Author' ); |
|
650 | + if (post_type_supports($post_type, 'author')) { |
|
651 | + $posts_columns['author'] = __('Author'); |
|
652 | 652 | } |
653 | 653 | |
654 | - $taxonomies = get_object_taxonomies( $post_type, 'objects' ); |
|
655 | - $taxonomies = wp_filter_object_list( $taxonomies, array( 'show_admin_column' => true ), 'and', 'name' ); |
|
654 | + $taxonomies = get_object_taxonomies($post_type, 'objects'); |
|
655 | + $taxonomies = wp_filter_object_list($taxonomies, array('show_admin_column' => true), 'and', 'name'); |
|
656 | 656 | |
657 | 657 | /** |
658 | 658 | * Filters the taxonomy columns in the Posts list table. |
@@ -670,36 +670,36 @@ discard block |
||
670 | 670 | * @param string[] $taxonomies Array of taxonomy names to show columns for. |
671 | 671 | * @param string $post_type The post type. |
672 | 672 | */ |
673 | - $taxonomies = apply_filters( "manage_taxonomies_for_{$post_type}_columns", $taxonomies, $post_type ); |
|
674 | - $taxonomies = array_filter( $taxonomies, 'taxonomy_exists' ); |
|
673 | + $taxonomies = apply_filters("manage_taxonomies_for_{$post_type}_columns", $taxonomies, $post_type); |
|
674 | + $taxonomies = array_filter($taxonomies, 'taxonomy_exists'); |
|
675 | 675 | |
676 | - foreach ( $taxonomies as $taxonomy ) { |
|
677 | - if ( 'category' === $taxonomy ) { |
|
676 | + foreach ($taxonomies as $taxonomy) { |
|
677 | + if ('category' === $taxonomy) { |
|
678 | 678 | $column_key = 'categories'; |
679 | - } elseif ( 'post_tag' === $taxonomy ) { |
|
679 | + } elseif ('post_tag' === $taxonomy) { |
|
680 | 680 | $column_key = 'tags'; |
681 | 681 | } else { |
682 | 682 | $column_key = 'taxonomy-' . $taxonomy; |
683 | 683 | } |
684 | 684 | |
685 | - $posts_columns[ $column_key ] = get_taxonomy( $taxonomy )->labels->name; |
|
685 | + $posts_columns[$column_key] = get_taxonomy($taxonomy)->labels->name; |
|
686 | 686 | } |
687 | 687 | |
688 | - $post_status = ! empty( $_REQUEST['post_status'] ) ? $_REQUEST['post_status'] : 'all'; |
|
688 | + $post_status = !empty($_REQUEST['post_status']) ? $_REQUEST['post_status'] : 'all'; |
|
689 | 689 | |
690 | - if ( post_type_supports( $post_type, 'comments' ) |
|
691 | - && ! in_array( $post_status, array( 'pending', 'draft', 'future' ), true ) |
|
690 | + if (post_type_supports($post_type, 'comments') |
|
691 | + && !in_array($post_status, array('pending', 'draft', 'future'), true) |
|
692 | 692 | ) { |
693 | 693 | $posts_columns['comments'] = sprintf( |
694 | 694 | '<span class="vers comment-grey-bubble" title="%1$s"><span class="screen-reader-text">%2$s</span></span>', |
695 | - esc_attr__( 'Comments' ), |
|
696 | - __( 'Comments' ) |
|
695 | + esc_attr__('Comments'), |
|
696 | + __('Comments') |
|
697 | 697 | ); |
698 | 698 | } |
699 | 699 | |
700 | - $posts_columns['date'] = __( 'Date' ); |
|
700 | + $posts_columns['date'] = __('Date'); |
|
701 | 701 | |
702 | - if ( 'page' === $post_type ) { |
|
702 | + if ('page' === $post_type) { |
|
703 | 703 | |
704 | 704 | /** |
705 | 705 | * Filters the columns displayed in the Pages list table. |
@@ -708,7 +708,7 @@ discard block |
||
708 | 708 | * |
709 | 709 | * @param string[] $post_columns An associative array of column headings. |
710 | 710 | */ |
711 | - $posts_columns = apply_filters( 'manage_pages_columns', $posts_columns ); |
|
711 | + $posts_columns = apply_filters('manage_pages_columns', $posts_columns); |
|
712 | 712 | } else { |
713 | 713 | |
714 | 714 | /** |
@@ -719,7 +719,7 @@ discard block |
||
719 | 719 | * @param string[] $post_columns An associative array of column headings. |
720 | 720 | * @param string $post_type The post type slug. |
721 | 721 | */ |
722 | - $posts_columns = apply_filters( 'manage_posts_columns', $posts_columns, $post_type ); |
|
722 | + $posts_columns = apply_filters('manage_posts_columns', $posts_columns, $post_type); |
|
723 | 723 | } |
724 | 724 | |
725 | 725 | /** |
@@ -736,7 +736,7 @@ discard block |
||
736 | 736 | * |
737 | 737 | * @param string[] $post_columns An associative array of column headings. |
738 | 738 | */ |
739 | - return apply_filters( "manage_{$post_type}_posts_columns", $posts_columns ); |
|
739 | + return apply_filters("manage_{$post_type}_posts_columns", $posts_columns); |
|
740 | 740 | } |
741 | 741 | |
742 | 742 | /** |
@@ -747,7 +747,7 @@ discard block |
||
747 | 747 | 'title' => 'title', |
748 | 748 | 'parent' => 'parent', |
749 | 749 | 'comments' => 'comment_count', |
750 | - 'date' => array( 'date', true ), |
|
750 | + 'date' => array('date', true), |
|
751 | 751 | ); |
752 | 752 | } |
753 | 753 | |
@@ -757,19 +757,19 @@ discard block |
||
757 | 757 | * @param array $posts |
758 | 758 | * @param int $level |
759 | 759 | */ |
760 | - public function display_rows( $posts = array(), $level = 0 ) { |
|
760 | + public function display_rows($posts = array(), $level = 0) { |
|
761 | 761 | global $wp_query, $per_page; |
762 | 762 | |
763 | - if ( empty( $posts ) ) { |
|
763 | + if (empty($posts)) { |
|
764 | 764 | $posts = $wp_query->posts; |
765 | 765 | } |
766 | 766 | |
767 | - add_filter( 'the_title', 'esc_html' ); |
|
767 | + add_filter('the_title', 'esc_html'); |
|
768 | 768 | |
769 | - if ( $this->hierarchical_display ) { |
|
770 | - $this->_display_rows_hierarchical( $posts, $this->get_pagenum(), $per_page ); |
|
769 | + if ($this->hierarchical_display) { |
|
770 | + $this->_display_rows_hierarchical($posts, $this->get_pagenum(), $per_page); |
|
771 | 771 | } else { |
772 | - $this->_display_rows( $posts, $level ); |
|
772 | + $this->_display_rows($posts, $level); |
|
773 | 773 | } |
774 | 774 | } |
775 | 775 | |
@@ -777,22 +777,22 @@ discard block |
||
777 | 777 | * @param array $posts |
778 | 778 | * @param int $level |
779 | 779 | */ |
780 | - private function _display_rows( $posts, $level = 0 ) { |
|
780 | + private function _display_rows($posts, $level = 0) { |
|
781 | 781 | $post_type = $this->screen->post_type; |
782 | 782 | |
783 | 783 | // Create array of post IDs. |
784 | 784 | $post_ids = array(); |
785 | 785 | |
786 | - foreach ( $posts as $a_post ) { |
|
786 | + foreach ($posts as $a_post) { |
|
787 | 787 | $post_ids[] = $a_post->ID; |
788 | 788 | } |
789 | 789 | |
790 | - if ( post_type_supports( $post_type, 'comments' ) ) { |
|
791 | - $this->comment_pending_count = get_pending_comments_num( $post_ids ); |
|
790 | + if (post_type_supports($post_type, 'comments')) { |
|
791 | + $this->comment_pending_count = get_pending_comments_num($post_ids); |
|
792 | 792 | } |
793 | 793 | |
794 | - foreach ( $posts as $post ) { |
|
795 | - $this->single_row( $post, $level ); |
|
794 | + foreach ($posts as $post) { |
|
795 | + $this->single_row($post, $level); |
|
796 | 796 | } |
797 | 797 | } |
798 | 798 | |
@@ -803,15 +803,15 @@ discard block |
||
803 | 803 | * @param int $pagenum |
804 | 804 | * @param int $per_page |
805 | 805 | */ |
806 | - private function _display_rows_hierarchical( $pages, $pagenum = 1, $per_page = 20 ) { |
|
806 | + private function _display_rows_hierarchical($pages, $pagenum = 1, $per_page = 20) { |
|
807 | 807 | global $wpdb; |
808 | 808 | |
809 | 809 | $level = 0; |
810 | 810 | |
811 | - if ( ! $pages ) { |
|
812 | - $pages = get_pages( array( 'sort_column' => 'menu_order' ) ); |
|
811 | + if (!$pages) { |
|
812 | + $pages = get_pages(array('sort_column' => 'menu_order')); |
|
813 | 813 | |
814 | - if ( ! $pages ) { |
|
814 | + if (!$pages) { |
|
815 | 815 | return; |
816 | 816 | } |
817 | 817 | } |
@@ -823,20 +823,20 @@ discard block |
||
823 | 823 | * It only takes O( N ) to arrange this and it takes O( 1 ) for subsequent lookup operations |
824 | 824 | * If searching, ignore hierarchy and treat everything as top level |
825 | 825 | */ |
826 | - if ( empty( $_REQUEST['s'] ) ) { |
|
826 | + if (empty($_REQUEST['s'])) { |
|
827 | 827 | $top_level_pages = array(); |
828 | 828 | $children_pages = array(); |
829 | 829 | |
830 | - foreach ( $pages as $page ) { |
|
830 | + foreach ($pages as $page) { |
|
831 | 831 | // Catch and repair bad pages. |
832 | - if ( $page->post_parent === $page->ID ) { |
|
832 | + if ($page->post_parent === $page->ID) { |
|
833 | 833 | $page->post_parent = 0; |
834 | - $wpdb->update( $wpdb->posts, array( 'post_parent' => 0 ), array( 'ID' => $page->ID ) ); |
|
835 | - clean_post_cache( $page ); |
|
834 | + $wpdb->update($wpdb->posts, array('post_parent' => 0), array('ID' => $page->ID)); |
|
835 | + clean_post_cache($page); |
|
836 | 836 | } |
837 | 837 | |
838 | - if ( $page->post_parent > 0 ) { |
|
839 | - $children_pages[ $page->post_parent ][] = $page; |
|
838 | + if ($page->post_parent > 0) { |
|
839 | + $children_pages[$page->post_parent][] = $page; |
|
840 | 840 | } else { |
841 | 841 | $top_level_pages[] = $page; |
842 | 842 | } |
@@ -846,36 +846,36 @@ discard block |
||
846 | 846 | } |
847 | 847 | |
848 | 848 | $count = 0; |
849 | - $start = ( $pagenum - 1 ) * $per_page; |
|
849 | + $start = ($pagenum - 1) * $per_page; |
|
850 | 850 | $end = $start + $per_page; |
851 | 851 | $to_display = array(); |
852 | 852 | |
853 | - foreach ( $pages as $page ) { |
|
854 | - if ( $count >= $end ) { |
|
853 | + foreach ($pages as $page) { |
|
854 | + if ($count >= $end) { |
|
855 | 855 | break; |
856 | 856 | } |
857 | 857 | |
858 | - if ( $count >= $start ) { |
|
859 | - $to_display[ $page->ID ] = $level; |
|
858 | + if ($count >= $start) { |
|
859 | + $to_display[$page->ID] = $level; |
|
860 | 860 | } |
861 | 861 | |
862 | 862 | $count++; |
863 | 863 | |
864 | - if ( isset( $children_pages ) ) { |
|
865 | - $this->_page_rows( $children_pages, $count, $page->ID, $level + 1, $pagenum, $per_page, $to_display ); |
|
864 | + if (isset($children_pages)) { |
|
865 | + $this->_page_rows($children_pages, $count, $page->ID, $level + 1, $pagenum, $per_page, $to_display); |
|
866 | 866 | } |
867 | 867 | } |
868 | 868 | |
869 | 869 | // If it is the last pagenum and there are orphaned pages, display them with paging as well. |
870 | - if ( isset( $children_pages ) && $count < $end ) { |
|
871 | - foreach ( $children_pages as $orphans ) { |
|
872 | - foreach ( $orphans as $op ) { |
|
873 | - if ( $count >= $end ) { |
|
870 | + if (isset($children_pages) && $count < $end) { |
|
871 | + foreach ($children_pages as $orphans) { |
|
872 | + foreach ($orphans as $op) { |
|
873 | + if ($count >= $end) { |
|
874 | 874 | break; |
875 | 875 | } |
876 | 876 | |
877 | - if ( $count >= $start ) { |
|
878 | - $to_display[ $op->ID ] = 0; |
|
877 | + if ($count >= $start) { |
|
878 | + $to_display[$op->ID] = 0; |
|
879 | 879 | } |
880 | 880 | |
881 | 881 | $count++; |
@@ -883,16 +883,16 @@ discard block |
||
883 | 883 | } |
884 | 884 | } |
885 | 885 | |
886 | - $ids = array_keys( $to_display ); |
|
887 | - _prime_post_caches( $ids ); |
|
886 | + $ids = array_keys($to_display); |
|
887 | + _prime_post_caches($ids); |
|
888 | 888 | |
889 | - if ( ! isset( $GLOBALS['post'] ) ) { |
|
890 | - $GLOBALS['post'] = reset( $ids ); |
|
889 | + if (!isset($GLOBALS['post'])) { |
|
890 | + $GLOBALS['post'] = reset($ids); |
|
891 | 891 | } |
892 | 892 | |
893 | - foreach ( $to_display as $page_id => $level ) { |
|
893 | + foreach ($to_display as $page_id => $level) { |
|
894 | 894 | echo "\t"; |
895 | - $this->single_row( $page_id, $level ); |
|
895 | + $this->single_row($page_id, $level); |
|
896 | 896 | } |
897 | 897 | } |
898 | 898 | |
@@ -911,60 +911,60 @@ discard block |
||
911 | 911 | * @param int $per_page |
912 | 912 | * @param array $to_display List of pages to be displayed. Passed by reference. |
913 | 913 | */ |
914 | - private function _page_rows( &$children_pages, &$count, $parent_page, $level, $pagenum, $per_page, &$to_display ) { |
|
915 | - if ( ! isset( $children_pages[ $parent_page ] ) ) { |
|
914 | + private function _page_rows(&$children_pages, &$count, $parent_page, $level, $pagenum, $per_page, &$to_display) { |
|
915 | + if (!isset($children_pages[$parent_page])) { |
|
916 | 916 | return; |
917 | 917 | } |
918 | 918 | |
919 | - $start = ( $pagenum - 1 ) * $per_page; |
|
919 | + $start = ($pagenum - 1) * $per_page; |
|
920 | 920 | $end = $start + $per_page; |
921 | 921 | |
922 | - foreach ( $children_pages[ $parent_page ] as $page ) { |
|
923 | - if ( $count >= $end ) { |
|
922 | + foreach ($children_pages[$parent_page] as $page) { |
|
923 | + if ($count >= $end) { |
|
924 | 924 | break; |
925 | 925 | } |
926 | 926 | |
927 | 927 | // If the page starts in a subtree, print the parents. |
928 | - if ( $count === $start && $page->post_parent > 0 ) { |
|
928 | + if ($count === $start && $page->post_parent > 0) { |
|
929 | 929 | $my_parents = array(); |
930 | 930 | $my_parent = $page->post_parent; |
931 | 931 | |
932 | - while ( $my_parent ) { |
|
932 | + while ($my_parent) { |
|
933 | 933 | // Get the ID from the list or the attribute if my_parent is an object. |
934 | 934 | $parent_id = $my_parent; |
935 | 935 | |
936 | - if ( is_object( $my_parent ) ) { |
|
936 | + if (is_object($my_parent)) { |
|
937 | 937 | $parent_id = $my_parent->ID; |
938 | 938 | } |
939 | 939 | |
940 | - $my_parent = get_post( $parent_id ); |
|
940 | + $my_parent = get_post($parent_id); |
|
941 | 941 | $my_parents[] = $my_parent; |
942 | 942 | |
943 | - if ( ! $my_parent->post_parent ) { |
|
943 | + if (!$my_parent->post_parent) { |
|
944 | 944 | break; |
945 | 945 | } |
946 | 946 | |
947 | 947 | $my_parent = $my_parent->post_parent; |
948 | 948 | } |
949 | 949 | |
950 | - $num_parents = count( $my_parents ); |
|
950 | + $num_parents = count($my_parents); |
|
951 | 951 | |
952 | - while ( $my_parent = array_pop( $my_parents ) ) { |
|
953 | - $to_display[ $my_parent->ID ] = $level - $num_parents; |
|
952 | + while ($my_parent = array_pop($my_parents)) { |
|
953 | + $to_display[$my_parent->ID] = $level - $num_parents; |
|
954 | 954 | $num_parents--; |
955 | 955 | } |
956 | 956 | } |
957 | 957 | |
958 | - if ( $count >= $start ) { |
|
959 | - $to_display[ $page->ID ] = $level; |
|
958 | + if ($count >= $start) { |
|
959 | + $to_display[$page->ID] = $level; |
|
960 | 960 | } |
961 | 961 | |
962 | 962 | $count++; |
963 | 963 | |
964 | - $this->_page_rows( $children_pages, $count, $page->ID, $level + 1, $pagenum, $per_page, $to_display ); |
|
964 | + $this->_page_rows($children_pages, $count, $page->ID, $level + 1, $pagenum, $per_page, $to_display); |
|
965 | 965 | } |
966 | 966 | |
967 | - unset( $children_pages[ $parent_page ] ); // Required in order to keep track of orphans. |
|
967 | + unset($children_pages[$parent_page]); // Required in order to keep track of orphans. |
|
968 | 968 | } |
969 | 969 | |
970 | 970 | /** |
@@ -975,10 +975,10 @@ discard block |
||
975 | 975 | * |
976 | 976 | * @param WP_Post $item The current WP_Post object. |
977 | 977 | */ |
978 | - public function column_cb( $item ) { |
|
978 | + public function column_cb($item) { |
|
979 | 979 | // Restores the more descriptive, specific name for use within this method. |
980 | 980 | $post = $item; |
981 | - $show = current_user_can( 'edit_post', $post->ID ); |
|
981 | + $show = current_user_can('edit_post', $post->ID); |
|
982 | 982 | |
983 | 983 | /** |
984 | 984 | * Filters whether to show the bulk edit checkbox for a post in its list table. |
@@ -990,12 +990,12 @@ discard block |
||
990 | 990 | * @param bool $show Whether to show the checkbox. |
991 | 991 | * @param WP_Post $post The current WP_Post object. |
992 | 992 | */ |
993 | - if ( apply_filters( 'wp_list_table_show_post_checkbox', $show, $post ) ) : |
|
993 | + if (apply_filters('wp_list_table_show_post_checkbox', $show, $post)) : |
|
994 | 994 | ?> |
995 | 995 | <label class="screen-reader-text" for="cb-select-<?php the_ID(); ?>"> |
996 | 996 | <?php |
997 | 997 | /* translators: %s: Post title. */ |
998 | - printf( __( 'Select %s' ), _draft_or_post_title() ); |
|
998 | + printf(__('Select %s'), _draft_or_post_title()); |
|
999 | 999 | ?> |
1000 | 1000 | </label> |
1001 | 1001 | <input id="cb-select-<?php the_ID(); ?>" type="checkbox" name="post[]" value="<?php the_ID(); ?>" /> |
@@ -1005,7 +1005,7 @@ discard block |
||
1005 | 1005 | <?php |
1006 | 1006 | printf( |
1007 | 1007 | /* translators: %s: Post title. */ |
1008 | - __( '“%s” is locked' ), |
|
1008 | + __('“%s” is locked'), |
|
1009 | 1009 | _draft_or_post_title() |
1010 | 1010 | ); |
1011 | 1011 | ?> |
@@ -1023,10 +1023,10 @@ discard block |
||
1023 | 1023 | * @param string $data |
1024 | 1024 | * @param string $primary |
1025 | 1025 | */ |
1026 | - protected function _column_title( $post, $classes, $data, $primary ) { |
|
1026 | + protected function _column_title($post, $classes, $data, $primary) { |
|
1027 | 1027 | echo '<td class="' . $classes . ' page-title" ', $data, '>'; |
1028 | - echo $this->column_title( $post ); |
|
1029 | - echo $this->handle_row_actions( $post, 'title', $primary ); |
|
1028 | + echo $this->column_title($post); |
|
1029 | + echo $this->handle_row_actions($post, 'title', $primary); |
|
1030 | 1030 | echo '</td>'; |
1031 | 1031 | } |
1032 | 1032 | |
@@ -1039,42 +1039,42 @@ discard block |
||
1039 | 1039 | * |
1040 | 1040 | * @param WP_Post $post The current WP_Post object. |
1041 | 1041 | */ |
1042 | - public function column_title( $post ) { |
|
1042 | + public function column_title($post) { |
|
1043 | 1043 | global $mode; |
1044 | 1044 | |
1045 | - if ( $this->hierarchical_display ) { |
|
1046 | - if ( 0 === $this->current_level && (int) $post->post_parent > 0 ) { |
|
1045 | + if ($this->hierarchical_display) { |
|
1046 | + if (0 === $this->current_level && (int) $post->post_parent > 0) { |
|
1047 | 1047 | // Sent level 0 by accident, by default, or because we don't know the actual level. |
1048 | 1048 | $find_main_page = (int) $post->post_parent; |
1049 | 1049 | |
1050 | - while ( $find_main_page > 0 ) { |
|
1051 | - $parent = get_post( $find_main_page ); |
|
1050 | + while ($find_main_page > 0) { |
|
1051 | + $parent = get_post($find_main_page); |
|
1052 | 1052 | |
1053 | - if ( is_null( $parent ) ) { |
|
1053 | + if (is_null($parent)) { |
|
1054 | 1054 | break; |
1055 | 1055 | } |
1056 | 1056 | |
1057 | 1057 | $this->current_level++; |
1058 | 1058 | $find_main_page = (int) $parent->post_parent; |
1059 | 1059 | |
1060 | - if ( ! isset( $parent_name ) ) { |
|
1060 | + if (!isset($parent_name)) { |
|
1061 | 1061 | /** This filter is documented in wp-includes/post-template.php */ |
1062 | - $parent_name = apply_filters( 'the_title', $parent->post_title, $parent->ID ); |
|
1062 | + $parent_name = apply_filters('the_title', $parent->post_title, $parent->ID); |
|
1063 | 1063 | } |
1064 | 1064 | } |
1065 | 1065 | } |
1066 | 1066 | } |
1067 | 1067 | |
1068 | - $can_edit_post = current_user_can( 'edit_post', $post->ID ); |
|
1068 | + $can_edit_post = current_user_can('edit_post', $post->ID); |
|
1069 | 1069 | |
1070 | - if ( $can_edit_post && 'trash' !== $post->post_status ) { |
|
1071 | - $lock_holder = wp_check_post_lock( $post->ID ); |
|
1070 | + if ($can_edit_post && 'trash' !== $post->post_status) { |
|
1071 | + $lock_holder = wp_check_post_lock($post->ID); |
|
1072 | 1072 | |
1073 | - if ( $lock_holder ) { |
|
1074 | - $lock_holder = get_userdata( $lock_holder ); |
|
1075 | - $locked_avatar = get_avatar( $lock_holder->ID, 18 ); |
|
1073 | + if ($lock_holder) { |
|
1074 | + $lock_holder = get_userdata($lock_holder); |
|
1075 | + $locked_avatar = get_avatar($lock_holder->ID, 18); |
|
1076 | 1076 | /* translators: %s: User's display name. */ |
1077 | - $locked_text = esc_html( sprintf( __( '%s is currently editing' ), $lock_holder->display_name ) ); |
|
1077 | + $locked_text = esc_html(sprintf(__('%s is currently editing'), $lock_holder->display_name)); |
|
1078 | 1078 | } else { |
1079 | 1079 | $locked_avatar = ''; |
1080 | 1080 | $locked_text = ''; |
@@ -1083,17 +1083,17 @@ discard block |
||
1083 | 1083 | echo '<div class="locked-info"><span class="locked-avatar">' . $locked_avatar . '</span> <span class="locked-text">' . $locked_text . "</span></div>\n"; |
1084 | 1084 | } |
1085 | 1085 | |
1086 | - $pad = str_repeat( '— ', $this->current_level ); |
|
1086 | + $pad = str_repeat('— ', $this->current_level); |
|
1087 | 1087 | echo '<strong>'; |
1088 | 1088 | |
1089 | 1089 | $title = _draft_or_post_title(); |
1090 | 1090 | |
1091 | - if ( $can_edit_post && 'trash' !== $post->post_status ) { |
|
1091 | + if ($can_edit_post && 'trash' !== $post->post_status) { |
|
1092 | 1092 | printf( |
1093 | 1093 | '<a class="row-title" href="%s" aria-label="%s">%s%s</a>', |
1094 | - get_edit_post_link( $post->ID ), |
|
1094 | + get_edit_post_link($post->ID), |
|
1095 | 1095 | /* translators: %s: Post title. */ |
1096 | - esc_attr( sprintf( __( '“%s” (Edit)' ), $title ) ), |
|
1096 | + esc_attr(sprintf(__('“%s” (Edit)'), $title)), |
|
1097 | 1097 | $pad, |
1098 | 1098 | $title |
1099 | 1099 | ); |
@@ -1104,27 +1104,27 @@ discard block |
||
1104 | 1104 | $title |
1105 | 1105 | ); |
1106 | 1106 | } |
1107 | - _post_states( $post ); |
|
1107 | + _post_states($post); |
|
1108 | 1108 | |
1109 | - if ( isset( $parent_name ) ) { |
|
1110 | - $post_type_object = get_post_type_object( $post->post_type ); |
|
1111 | - echo ' | ' . $post_type_object->labels->parent_item_colon . ' ' . esc_html( $parent_name ); |
|
1109 | + if (isset($parent_name)) { |
|
1110 | + $post_type_object = get_post_type_object($post->post_type); |
|
1111 | + echo ' | ' . $post_type_object->labels->parent_item_colon . ' ' . esc_html($parent_name); |
|
1112 | 1112 | } |
1113 | 1113 | |
1114 | 1114 | echo "</strong>\n"; |
1115 | 1115 | |
1116 | - if ( 'excerpt' === $mode |
|
1117 | - && ! is_post_type_hierarchical( $this->screen->post_type ) |
|
1118 | - && current_user_can( 'read_post', $post->ID ) |
|
1116 | + if ('excerpt' === $mode |
|
1117 | + && !is_post_type_hierarchical($this->screen->post_type) |
|
1118 | + && current_user_can('read_post', $post->ID) |
|
1119 | 1119 | ) { |
1120 | - if ( post_password_required( $post ) ) { |
|
1121 | - echo '<span class="protected-post-excerpt">' . esc_html( get_the_excerpt() ) . '</span>'; |
|
1120 | + if (post_password_required($post)) { |
|
1121 | + echo '<span class="protected-post-excerpt">' . esc_html(get_the_excerpt()) . '</span>'; |
|
1122 | 1122 | } else { |
1123 | - echo esc_html( get_the_excerpt() ); |
|
1123 | + echo esc_html(get_the_excerpt()); |
|
1124 | 1124 | } |
1125 | 1125 | } |
1126 | 1126 | |
1127 | - get_inline_data( $post ); |
|
1127 | + get_inline_data($post); |
|
1128 | 1128 | } |
1129 | 1129 | |
1130 | 1130 | /** |
@@ -1136,36 +1136,36 @@ discard block |
||
1136 | 1136 | * |
1137 | 1137 | * @param WP_Post $post The current WP_Post object. |
1138 | 1138 | */ |
1139 | - public function column_date( $post ) { |
|
1139 | + public function column_date($post) { |
|
1140 | 1140 | global $mode; |
1141 | 1141 | |
1142 | - if ( '0000-00-00 00:00:00' === $post->post_date ) { |
|
1143 | - $t_time = __( 'Unpublished' ); |
|
1142 | + if ('0000-00-00 00:00:00' === $post->post_date) { |
|
1143 | + $t_time = __('Unpublished'); |
|
1144 | 1144 | $time_diff = 0; |
1145 | 1145 | } else { |
1146 | 1146 | $t_time = sprintf( |
1147 | 1147 | /* translators: 1: Post date, 2: Post time. */ |
1148 | - __( '%1$s at %2$s' ), |
|
1148 | + __('%1$s at %2$s'), |
|
1149 | 1149 | /* translators: Post date format. See https://www.php.net/manual/datetime.format.php */ |
1150 | - get_the_time( __( 'Y/m/d' ), $post ), |
|
1150 | + get_the_time(__('Y/m/d'), $post), |
|
1151 | 1151 | /* translators: Post time format. See https://www.php.net/manual/datetime.format.php */ |
1152 | - get_the_time( __( 'g:i a' ), $post ) |
|
1152 | + get_the_time(__('g:i a'), $post) |
|
1153 | 1153 | ); |
1154 | 1154 | |
1155 | - $time = get_post_timestamp( $post ); |
|
1155 | + $time = get_post_timestamp($post); |
|
1156 | 1156 | $time_diff = time() - $time; |
1157 | 1157 | } |
1158 | 1158 | |
1159 | - if ( 'publish' === $post->post_status ) { |
|
1160 | - $status = __( 'Published' ); |
|
1161 | - } elseif ( 'future' === $post->post_status ) { |
|
1162 | - if ( $time_diff > 0 ) { |
|
1163 | - $status = '<strong class="error-message">' . __( 'Missed schedule' ) . '</strong>'; |
|
1159 | + if ('publish' === $post->post_status) { |
|
1160 | + $status = __('Published'); |
|
1161 | + } elseif ('future' === $post->post_status) { |
|
1162 | + if ($time_diff > 0) { |
|
1163 | + $status = '<strong class="error-message">' . __('Missed schedule') . '</strong>'; |
|
1164 | 1164 | } else { |
1165 | - $status = __( 'Scheduled' ); |
|
1165 | + $status = __('Scheduled'); |
|
1166 | 1166 | } |
1167 | 1167 | } else { |
1168 | - $status = __( 'Last Modified' ); |
|
1168 | + $status = __('Last Modified'); |
|
1169 | 1169 | } |
1170 | 1170 | |
1171 | 1171 | /** |
@@ -1178,9 +1178,9 @@ discard block |
||
1178 | 1178 | * @param string $column_name The column name. |
1179 | 1179 | * @param string $mode The list display mode ('excerpt' or 'list'). |
1180 | 1180 | */ |
1181 | - $status = apply_filters( 'post_date_column_status', $status, $post, 'date', $mode ); |
|
1181 | + $status = apply_filters('post_date_column_status', $status, $post, 'date', $mode); |
|
1182 | 1182 | |
1183 | - if ( $status ) { |
|
1183 | + if ($status) { |
|
1184 | 1184 | echo $status . '<br />'; |
1185 | 1185 | } |
1186 | 1186 | |
@@ -1197,7 +1197,7 @@ discard block |
||
1197 | 1197 | * @param string $column_name The column name. |
1198 | 1198 | * @param string $mode The list display mode ('excerpt' or 'list'). |
1199 | 1199 | */ |
1200 | - echo apply_filters( 'post_date_column_time', $t_time, $post, 'date', $mode ); |
|
1200 | + echo apply_filters('post_date_column_time', $t_time, $post, 'date', $mode); |
|
1201 | 1201 | } |
1202 | 1202 | |
1203 | 1203 | /** |
@@ -1207,13 +1207,13 @@ discard block |
||
1207 | 1207 | * |
1208 | 1208 | * @param WP_Post $post The current WP_Post object. |
1209 | 1209 | */ |
1210 | - public function column_comments( $post ) { |
|
1210 | + public function column_comments($post) { |
|
1211 | 1211 | ?> |
1212 | 1212 | <div class="post-com-count-wrapper"> |
1213 | 1213 | <?php |
1214 | - $pending_comments = isset( $this->comment_pending_count[ $post->ID ] ) ? $this->comment_pending_count[ $post->ID ] : 0; |
|
1214 | + $pending_comments = isset($this->comment_pending_count[$post->ID]) ? $this->comment_pending_count[$post->ID] : 0; |
|
1215 | 1215 | |
1216 | - $this->comments_bubble( $post->ID, $pending_comments ); |
|
1216 | + $this->comments_bubble($post->ID, $pending_comments); |
|
1217 | 1217 | ?> |
1218 | 1218 | </div> |
1219 | 1219 | <?php |
@@ -1226,12 +1226,12 @@ discard block |
||
1226 | 1226 | * |
1227 | 1227 | * @param WP_Post $post The current WP_Post object. |
1228 | 1228 | */ |
1229 | - public function column_author( $post ) { |
|
1229 | + public function column_author($post) { |
|
1230 | 1230 | $args = array( |
1231 | 1231 | 'post_type' => $post->post_type, |
1232 | - 'author' => get_the_author_meta( 'ID' ), |
|
1232 | + 'author' => get_the_author_meta('ID'), |
|
1233 | 1233 | ); |
1234 | - echo $this->get_edit_link( $args, get_the_author() ); |
|
1234 | + echo $this->get_edit_link($args, get_the_author()); |
|
1235 | 1235 | } |
1236 | 1236 | |
1237 | 1237 | /** |
@@ -1243,44 +1243,44 @@ discard block |
||
1243 | 1243 | * @param WP_Post $item The current WP_Post object. |
1244 | 1244 | * @param string $column_name The current column name. |
1245 | 1245 | */ |
1246 | - public function column_default( $item, $column_name ) { |
|
1246 | + public function column_default($item, $column_name) { |
|
1247 | 1247 | // Restores the more descriptive, specific name for use within this method. |
1248 | 1248 | $post = $item; |
1249 | 1249 | |
1250 | - if ( 'categories' === $column_name ) { |
|
1250 | + if ('categories' === $column_name) { |
|
1251 | 1251 | $taxonomy = 'category'; |
1252 | - } elseif ( 'tags' === $column_name ) { |
|
1252 | + } elseif ('tags' === $column_name) { |
|
1253 | 1253 | $taxonomy = 'post_tag'; |
1254 | - } elseif ( 0 === strpos( $column_name, 'taxonomy-' ) ) { |
|
1255 | - $taxonomy = substr( $column_name, 9 ); |
|
1254 | + } elseif (0 === strpos($column_name, 'taxonomy-')) { |
|
1255 | + $taxonomy = substr($column_name, 9); |
|
1256 | 1256 | } else { |
1257 | 1257 | $taxonomy = false; |
1258 | 1258 | } |
1259 | 1259 | |
1260 | - if ( $taxonomy ) { |
|
1261 | - $taxonomy_object = get_taxonomy( $taxonomy ); |
|
1262 | - $terms = get_the_terms( $post->ID, $taxonomy ); |
|
1260 | + if ($taxonomy) { |
|
1261 | + $taxonomy_object = get_taxonomy($taxonomy); |
|
1262 | + $terms = get_the_terms($post->ID, $taxonomy); |
|
1263 | 1263 | |
1264 | - if ( is_array( $terms ) ) { |
|
1264 | + if (is_array($terms)) { |
|
1265 | 1265 | $term_links = array(); |
1266 | 1266 | |
1267 | - foreach ( $terms as $t ) { |
|
1267 | + foreach ($terms as $t) { |
|
1268 | 1268 | $posts_in_term_qv = array(); |
1269 | 1269 | |
1270 | - if ( 'post' !== $post->post_type ) { |
|
1270 | + if ('post' !== $post->post_type) { |
|
1271 | 1271 | $posts_in_term_qv['post_type'] = $post->post_type; |
1272 | 1272 | } |
1273 | 1273 | |
1274 | - if ( $taxonomy_object->query_var ) { |
|
1275 | - $posts_in_term_qv[ $taxonomy_object->query_var ] = $t->slug; |
|
1274 | + if ($taxonomy_object->query_var) { |
|
1275 | + $posts_in_term_qv[$taxonomy_object->query_var] = $t->slug; |
|
1276 | 1276 | } else { |
1277 | 1277 | $posts_in_term_qv['taxonomy'] = $taxonomy; |
1278 | 1278 | $posts_in_term_qv['term'] = $t->slug; |
1279 | 1279 | } |
1280 | 1280 | |
1281 | - $label = esc_html( sanitize_term_field( 'name', $t->name, $t->term_id, $taxonomy, 'display' ) ); |
|
1281 | + $label = esc_html(sanitize_term_field('name', $t->name, $t->term_id, $taxonomy, 'display')); |
|
1282 | 1282 | |
1283 | - $term_links[] = $this->get_edit_link( $posts_in_term_qv, $label ); |
|
1283 | + $term_links[] = $this->get_edit_link($posts_in_term_qv, $label); |
|
1284 | 1284 | } |
1285 | 1285 | |
1286 | 1286 | /** |
@@ -1292,16 +1292,16 @@ discard block |
||
1292 | 1292 | * @param string $taxonomy Taxonomy name. |
1293 | 1293 | * @param WP_Term[] $terms Array of term objects appearing in the post row. |
1294 | 1294 | */ |
1295 | - $term_links = apply_filters( 'post_column_taxonomy_links', $term_links, $taxonomy, $terms ); |
|
1295 | + $term_links = apply_filters('post_column_taxonomy_links', $term_links, $taxonomy, $terms); |
|
1296 | 1296 | |
1297 | - echo implode( wp_get_list_item_separator(), $term_links ); |
|
1297 | + echo implode(wp_get_list_item_separator(), $term_links); |
|
1298 | 1298 | } else { |
1299 | 1299 | echo '<span aria-hidden="true">—</span><span class="screen-reader-text">' . $taxonomy_object->labels->no_terms . '</span>'; |
1300 | 1300 | } |
1301 | 1301 | return; |
1302 | 1302 | } |
1303 | 1303 | |
1304 | - if ( is_post_type_hierarchical( $post->post_type ) ) { |
|
1304 | + if (is_post_type_hierarchical($post->post_type)) { |
|
1305 | 1305 | |
1306 | 1306 | /** |
1307 | 1307 | * Fires in each custom column on the Posts list table. |
@@ -1314,7 +1314,7 @@ discard block |
||
1314 | 1314 | * @param string $column_name The name of the column to display. |
1315 | 1315 | * @param int $post_id The current post ID. |
1316 | 1316 | */ |
1317 | - do_action( 'manage_pages_custom_column', $column_name, $post->ID ); |
|
1317 | + do_action('manage_pages_custom_column', $column_name, $post->ID); |
|
1318 | 1318 | } else { |
1319 | 1319 | |
1320 | 1320 | /** |
@@ -1328,7 +1328,7 @@ discard block |
||
1328 | 1328 | * @param string $column_name The name of the column to display. |
1329 | 1329 | * @param int $post_id The current post ID. |
1330 | 1330 | */ |
1331 | - do_action( 'manage_posts_custom_column', $column_name, $post->ID ); |
|
1331 | + do_action('manage_posts_custom_column', $column_name, $post->ID); |
|
1332 | 1332 | } |
1333 | 1333 | |
1334 | 1334 | /** |
@@ -1346,7 +1346,7 @@ discard block |
||
1346 | 1346 | * @param string $column_name The name of the column to display. |
1347 | 1347 | * @param int $post_id The current post ID. |
1348 | 1348 | */ |
1349 | - do_action( "manage_{$post->post_type}_posts_custom_column", $column_name, $post->ID ); |
|
1349 | + do_action("manage_{$post->post_type}_posts_custom_column", $column_name, $post->ID); |
|
1350 | 1350 | } |
1351 | 1351 | |
1352 | 1352 | /** |
@@ -1355,32 +1355,32 @@ discard block |
||
1355 | 1355 | * @param int|WP_Post $post |
1356 | 1356 | * @param int $level |
1357 | 1357 | */ |
1358 | - public function single_row( $post, $level = 0 ) { |
|
1358 | + public function single_row($post, $level = 0) { |
|
1359 | 1359 | $global_post = get_post(); |
1360 | 1360 | |
1361 | - $post = get_post( $post ); |
|
1361 | + $post = get_post($post); |
|
1362 | 1362 | $this->current_level = $level; |
1363 | 1363 | |
1364 | 1364 | $GLOBALS['post'] = $post; |
1365 | - setup_postdata( $post ); |
|
1365 | + setup_postdata($post); |
|
1366 | 1366 | |
1367 | - $classes = 'iedit author-' . ( get_current_user_id() === (int) $post->post_author ? 'self' : 'other' ); |
|
1367 | + $classes = 'iedit author-' . (get_current_user_id() === (int) $post->post_author ? 'self' : 'other'); |
|
1368 | 1368 | |
1369 | - $lock_holder = wp_check_post_lock( $post->ID ); |
|
1369 | + $lock_holder = wp_check_post_lock($post->ID); |
|
1370 | 1370 | |
1371 | - if ( $lock_holder ) { |
|
1371 | + if ($lock_holder) { |
|
1372 | 1372 | $classes .= ' wp-locked'; |
1373 | 1373 | } |
1374 | 1374 | |
1375 | - if ( $post->post_parent ) { |
|
1376 | - $count = count( get_post_ancestors( $post->ID ) ); |
|
1375 | + if ($post->post_parent) { |
|
1376 | + $count = count(get_post_ancestors($post->ID)); |
|
1377 | 1377 | $classes .= ' level-' . $count; |
1378 | 1378 | } else { |
1379 | 1379 | $classes .= ' level-0'; |
1380 | 1380 | } |
1381 | 1381 | ?> |
1382 | - <tr id="post-<?php echo $post->ID; ?>" class="<?php echo implode( ' ', get_post_class( $classes, $post->ID ) ); ?>"> |
|
1383 | - <?php $this->single_row_columns( $post ); ?> |
|
1382 | + <tr id="post-<?php echo $post->ID; ?>" class="<?php echo implode(' ', get_post_class($classes, $post->ID)); ?>"> |
|
1383 | + <?php $this->single_row_columns($post); ?> |
|
1384 | 1384 | </tr> |
1385 | 1385 | <?php |
1386 | 1386 | $GLOBALS['post'] = $global_post; |
@@ -1409,101 +1409,101 @@ discard block |
||
1409 | 1409 | * @return string Row actions output for posts, or an empty string |
1410 | 1410 | * if the current column is not the primary column. |
1411 | 1411 | */ |
1412 | - protected function handle_row_actions( $item, $column_name, $primary ) { |
|
1413 | - if ( $primary !== $column_name ) { |
|
1412 | + protected function handle_row_actions($item, $column_name, $primary) { |
|
1413 | + if ($primary !== $column_name) { |
|
1414 | 1414 | return ''; |
1415 | 1415 | } |
1416 | 1416 | |
1417 | 1417 | // Restores the more descriptive, specific name for use within this method. |
1418 | 1418 | $post = $item; |
1419 | - $post_type_object = get_post_type_object( $post->post_type ); |
|
1420 | - $can_edit_post = current_user_can( 'edit_post', $post->ID ); |
|
1419 | + $post_type_object = get_post_type_object($post->post_type); |
|
1420 | + $can_edit_post = current_user_can('edit_post', $post->ID); |
|
1421 | 1421 | $actions = array(); |
1422 | 1422 | $title = _draft_or_post_title(); |
1423 | 1423 | |
1424 | - if ( $can_edit_post && 'trash' !== $post->post_status ) { |
|
1424 | + if ($can_edit_post && 'trash' !== $post->post_status) { |
|
1425 | 1425 | $actions['edit'] = sprintf( |
1426 | 1426 | '<a href="%s" aria-label="%s">%s</a>', |
1427 | - get_edit_post_link( $post->ID ), |
|
1427 | + get_edit_post_link($post->ID), |
|
1428 | 1428 | /* translators: %s: Post title. */ |
1429 | - esc_attr( sprintf( __( 'Edit “%s”' ), $title ) ), |
|
1430 | - __( 'Edit' ) |
|
1429 | + esc_attr(sprintf(__('Edit “%s”'), $title)), |
|
1430 | + __('Edit') |
|
1431 | 1431 | ); |
1432 | 1432 | |
1433 | - if ( 'wp_block' !== $post->post_type ) { |
|
1433 | + if ('wp_block' !== $post->post_type) { |
|
1434 | 1434 | $actions['inline hide-if-no-js'] = sprintf( |
1435 | 1435 | '<button type="button" class="button-link editinline" aria-label="%s" aria-expanded="false">%s</button>', |
1436 | 1436 | /* translators: %s: Post title. */ |
1437 | - esc_attr( sprintf( __( 'Quick edit “%s” inline' ), $title ) ), |
|
1438 | - __( 'Quick Edit' ) |
|
1437 | + esc_attr(sprintf(__('Quick edit “%s” inline'), $title)), |
|
1438 | + __('Quick Edit') |
|
1439 | 1439 | ); |
1440 | 1440 | } |
1441 | 1441 | } |
1442 | 1442 | |
1443 | - if ( current_user_can( 'delete_post', $post->ID ) ) { |
|
1444 | - if ( 'trash' === $post->post_status ) { |
|
1443 | + if (current_user_can('delete_post', $post->ID)) { |
|
1444 | + if ('trash' === $post->post_status) { |
|
1445 | 1445 | $actions['untrash'] = sprintf( |
1446 | 1446 | '<a href="%s" aria-label="%s">%s</a>', |
1447 | - wp_nonce_url( admin_url( sprintf( $post_type_object->_edit_link . '&action=untrash', $post->ID ) ), 'untrash-post_' . $post->ID ), |
|
1447 | + wp_nonce_url(admin_url(sprintf($post_type_object->_edit_link . '&action=untrash', $post->ID)), 'untrash-post_' . $post->ID), |
|
1448 | 1448 | /* translators: %s: Post title. */ |
1449 | - esc_attr( sprintf( __( 'Restore “%s” from the Trash' ), $title ) ), |
|
1450 | - __( 'Restore' ) |
|
1449 | + esc_attr(sprintf(__('Restore “%s” from the Trash'), $title)), |
|
1450 | + __('Restore') |
|
1451 | 1451 | ); |
1452 | - } elseif ( EMPTY_TRASH_DAYS ) { |
|
1452 | + } elseif (EMPTY_TRASH_DAYS) { |
|
1453 | 1453 | $actions['trash'] = sprintf( |
1454 | 1454 | '<a href="%s" class="submitdelete" aria-label="%s">%s</a>', |
1455 | - get_delete_post_link( $post->ID ), |
|
1455 | + get_delete_post_link($post->ID), |
|
1456 | 1456 | /* translators: %s: Post title. */ |
1457 | - esc_attr( sprintf( __( 'Move “%s” to the Trash' ), $title ) ), |
|
1458 | - _x( 'Trash', 'verb' ) |
|
1457 | + esc_attr(sprintf(__('Move “%s” to the Trash'), $title)), |
|
1458 | + _x('Trash', 'verb') |
|
1459 | 1459 | ); |
1460 | 1460 | } |
1461 | 1461 | |
1462 | - if ( 'trash' === $post->post_status || ! EMPTY_TRASH_DAYS ) { |
|
1462 | + if ('trash' === $post->post_status || !EMPTY_TRASH_DAYS) { |
|
1463 | 1463 | $actions['delete'] = sprintf( |
1464 | 1464 | '<a href="%s" class="submitdelete" aria-label="%s">%s</a>', |
1465 | - get_delete_post_link( $post->ID, '', true ), |
|
1465 | + get_delete_post_link($post->ID, '', true), |
|
1466 | 1466 | /* translators: %s: Post title. */ |
1467 | - esc_attr( sprintf( __( 'Delete “%s” permanently' ), $title ) ), |
|
1468 | - __( 'Delete Permanently' ) |
|
1467 | + esc_attr(sprintf(__('Delete “%s” permanently'), $title)), |
|
1468 | + __('Delete Permanently') |
|
1469 | 1469 | ); |
1470 | 1470 | } |
1471 | 1471 | } |
1472 | 1472 | |
1473 | - if ( is_post_type_viewable( $post_type_object ) ) { |
|
1474 | - if ( in_array( $post->post_status, array( 'pending', 'draft', 'future' ), true ) ) { |
|
1475 | - if ( $can_edit_post ) { |
|
1476 | - $preview_link = get_preview_post_link( $post ); |
|
1473 | + if (is_post_type_viewable($post_type_object)) { |
|
1474 | + if (in_array($post->post_status, array('pending', 'draft', 'future'), true)) { |
|
1475 | + if ($can_edit_post) { |
|
1476 | + $preview_link = get_preview_post_link($post); |
|
1477 | 1477 | $actions['view'] = sprintf( |
1478 | 1478 | '<a href="%s" rel="bookmark" aria-label="%s">%s</a>', |
1479 | - esc_url( $preview_link ), |
|
1479 | + esc_url($preview_link), |
|
1480 | 1480 | /* translators: %s: Post title. */ |
1481 | - esc_attr( sprintf( __( 'Preview “%s”' ), $title ) ), |
|
1482 | - __( 'Preview' ) |
|
1481 | + esc_attr(sprintf(__('Preview “%s”'), $title)), |
|
1482 | + __('Preview') |
|
1483 | 1483 | ); |
1484 | 1484 | } |
1485 | - } elseif ( 'trash' !== $post->post_status ) { |
|
1485 | + } elseif ('trash' !== $post->post_status) { |
|
1486 | 1486 | $actions['view'] = sprintf( |
1487 | 1487 | '<a href="%s" rel="bookmark" aria-label="%s">%s</a>', |
1488 | - get_permalink( $post->ID ), |
|
1488 | + get_permalink($post->ID), |
|
1489 | 1489 | /* translators: %s: Post title. */ |
1490 | - esc_attr( sprintf( __( 'View “%s”' ), $title ) ), |
|
1491 | - __( 'View' ) |
|
1490 | + esc_attr(sprintf(__('View “%s”'), $title)), |
|
1491 | + __('View') |
|
1492 | 1492 | ); |
1493 | 1493 | } |
1494 | 1494 | } |
1495 | 1495 | |
1496 | - if ( 'wp_block' === $post->post_type ) { |
|
1496 | + if ('wp_block' === $post->post_type) { |
|
1497 | 1497 | $actions['export'] = sprintf( |
1498 | 1498 | '<button type="button" class="wp-list-reusable-blocks__export button-link" data-id="%s" aria-label="%s">%s</button>', |
1499 | 1499 | $post->ID, |
1500 | 1500 | /* translators: %s: Post title. */ |
1501 | - esc_attr( sprintf( __( 'Export “%s” as JSON' ), $title ) ), |
|
1502 | - __( 'Export as JSON' ) |
|
1501 | + esc_attr(sprintf(__('Export “%s” as JSON'), $title)), |
|
1502 | + __('Export as JSON') |
|
1503 | 1503 | ); |
1504 | 1504 | } |
1505 | 1505 | |
1506 | - if ( is_post_type_hierarchical( $post->post_type ) ) { |
|
1506 | + if (is_post_type_hierarchical($post->post_type)) { |
|
1507 | 1507 | |
1508 | 1508 | /** |
1509 | 1509 | * Filters the array of row action links on the Pages list table. |
@@ -1517,7 +1517,7 @@ discard block |
||
1517 | 1517 | * 'Delete Permanently', 'Preview', and 'View'. |
1518 | 1518 | * @param WP_Post $post The post object. |
1519 | 1519 | */ |
1520 | - $actions = apply_filters( 'page_row_actions', $actions, $post ); |
|
1520 | + $actions = apply_filters('page_row_actions', $actions, $post); |
|
1521 | 1521 | } else { |
1522 | 1522 | |
1523 | 1523 | /** |
@@ -1532,10 +1532,10 @@ discard block |
||
1532 | 1532 | * 'Delete Permanently', 'Preview', and 'View'. |
1533 | 1533 | * @param WP_Post $post The post object. |
1534 | 1534 | */ |
1535 | - $actions = apply_filters( 'post_row_actions', $actions, $post ); |
|
1535 | + $actions = apply_filters('post_row_actions', $actions, $post); |
|
1536 | 1536 | } |
1537 | 1537 | |
1538 | - return $this->row_actions( $actions ); |
|
1538 | + return $this->row_actions($actions); |
|
1539 | 1539 | } |
1540 | 1540 | |
1541 | 1541 | /** |
@@ -1550,15 +1550,15 @@ discard block |
||
1550 | 1550 | |
1551 | 1551 | $screen = $this->screen; |
1552 | 1552 | |
1553 | - $post = get_default_post_to_edit( $screen->post_type ); |
|
1554 | - $post_type_object = get_post_type_object( $screen->post_type ); |
|
1553 | + $post = get_default_post_to_edit($screen->post_type); |
|
1554 | + $post_type_object = get_post_type_object($screen->post_type); |
|
1555 | 1555 | |
1556 | - $taxonomy_names = get_object_taxonomies( $screen->post_type ); |
|
1556 | + $taxonomy_names = get_object_taxonomies($screen->post_type); |
|
1557 | 1557 | $hierarchical_taxonomies = array(); |
1558 | 1558 | $flat_taxonomies = array(); |
1559 | 1559 | |
1560 | - foreach ( $taxonomy_names as $taxonomy_name ) { |
|
1561 | - $taxonomy = get_taxonomy( $taxonomy_name ); |
|
1560 | + foreach ($taxonomy_names as $taxonomy_name) { |
|
1561 | + $taxonomy = get_taxonomy($taxonomy_name); |
|
1562 | 1562 | |
1563 | 1563 | $show_in_quick_edit = $taxonomy->show_in_quick_edit; |
1564 | 1564 | |
@@ -1571,19 +1571,19 @@ discard block |
||
1571 | 1571 | * @param string $taxonomy_name Taxonomy name. |
1572 | 1572 | * @param string $post_type Post type of current Quick Edit post. |
1573 | 1573 | */ |
1574 | - if ( ! apply_filters( 'quick_edit_show_taxonomy', $show_in_quick_edit, $taxonomy_name, $screen->post_type ) ) { |
|
1574 | + if (!apply_filters('quick_edit_show_taxonomy', $show_in_quick_edit, $taxonomy_name, $screen->post_type)) { |
|
1575 | 1575 | continue; |
1576 | 1576 | } |
1577 | 1577 | |
1578 | - if ( $taxonomy->hierarchical ) { |
|
1578 | + if ($taxonomy->hierarchical) { |
|
1579 | 1579 | $hierarchical_taxonomies[] = $taxonomy; |
1580 | 1580 | } else { |
1581 | 1581 | $flat_taxonomies[] = $taxonomy; |
1582 | 1582 | } |
1583 | 1583 | } |
1584 | 1584 | |
1585 | - $m = ( isset( $mode ) && 'excerpt' === $mode ) ? 'excerpt' : 'list'; |
|
1586 | - $can_publish = current_user_can( $post_type_object->cap->publish_posts ); |
|
1585 | + $m = (isset($mode) && 'excerpt' === $mode) ? 'excerpt' : 'list'; |
|
1586 | + $can_publish = current_user_can($post_type_object->cap->publish_posts); |
|
1587 | 1587 | $core_columns = array( |
1588 | 1588 | 'cb' => true, |
1589 | 1589 | 'date' => true, |
@@ -1598,14 +1598,14 @@ discard block |
||
1598 | 1598 | <form method="get"> |
1599 | 1599 | <table style="display: none"><tbody id="inlineedit"> |
1600 | 1600 | <?php |
1601 | - $hclass = count( $hierarchical_taxonomies ) ? 'post' : 'page'; |
|
1601 | + $hclass = count($hierarchical_taxonomies) ? 'post' : 'page'; |
|
1602 | 1602 | $inline_edit_classes = "inline-edit-row inline-edit-row-$hclass"; |
1603 | 1603 | $bulk_edit_classes = "bulk-edit-row bulk-edit-row-$hclass bulk-edit-{$screen->post_type}"; |
1604 | 1604 | $quick_edit_classes = "quick-edit-row quick-edit-row-$hclass inline-edit-{$screen->post_type}"; |
1605 | 1605 | |
1606 | 1606 | $bulk = 0; |
1607 | 1607 | |
1608 | - while ( $bulk < 2 ) : |
|
1608 | + while ($bulk < 2) : |
|
1609 | 1609 | $classes = $inline_edit_classes . ' '; |
1610 | 1610 | $classes .= $bulk ? $bulk_edit_classes : $quick_edit_classes; |
1611 | 1611 | ?> |
@@ -1613,12 +1613,12 @@ discard block |
||
1613 | 1613 | <td colspan="<?php echo $this->get_column_count(); ?>" class="colspanchange"> |
1614 | 1614 | <div class="inline-edit-wrapper" role="region" aria-labelledby="<?php echo $bulk ? 'bulk' : 'quick'; ?>-edit-legend"> |
1615 | 1615 | <fieldset class="inline-edit-col-left"> |
1616 | - <legend class="inline-edit-legend" id="<?php echo $bulk ? 'bulk' : 'quick'; ?>-edit-legend"><?php echo $bulk ? __( 'Bulk Edit' ) : __( 'Quick Edit' ); ?></legend> |
|
1616 | + <legend class="inline-edit-legend" id="<?php echo $bulk ? 'bulk' : 'quick'; ?>-edit-legend"><?php echo $bulk ? __('Bulk Edit') : __('Quick Edit'); ?></legend> |
|
1617 | 1617 | <div class="inline-edit-col"> |
1618 | 1618 | |
1619 | - <?php if ( post_type_supports( $screen->post_type, 'title' ) ) : ?> |
|
1619 | + <?php if (post_type_supports($screen->post_type, 'title')) : ?> |
|
1620 | 1620 | |
1621 | - <?php if ( $bulk ) : ?> |
|
1621 | + <?php if ($bulk) : ?> |
|
1622 | 1622 | |
1623 | 1623 | <div id="bulk-title-div"> |
1624 | 1624 | <div id="bulk-titles"></div> |
@@ -1627,14 +1627,14 @@ discard block |
||
1627 | 1627 | <?php else : // $bulk ?> |
1628 | 1628 | |
1629 | 1629 | <label> |
1630 | - <span class="title"><?php _e( 'Title' ); ?></span> |
|
1630 | + <span class="title"><?php _e('Title'); ?></span> |
|
1631 | 1631 | <span class="input-text-wrap"><input type="text" name="post_title" class="ptitle" value="" /></span> |
1632 | 1632 | </label> |
1633 | 1633 | |
1634 | - <?php if ( is_post_type_viewable( $screen->post_type ) ) : ?> |
|
1634 | + <?php if (is_post_type_viewable($screen->post_type)) : ?> |
|
1635 | 1635 | |
1636 | 1636 | <label> |
1637 | - <span class="title"><?php _e( 'Slug' ); ?></span> |
|
1637 | + <span class="title"><?php _e('Slug'); ?></span> |
|
1638 | 1638 | <span class="input-text-wrap"><input type="text" name="post_name" value="" autocomplete="off" spellcheck="false" /></span> |
1639 | 1639 | </label> |
1640 | 1640 | |
@@ -1644,27 +1644,27 @@ discard block |
||
1644 | 1644 | |
1645 | 1645 | <?php endif; // post_type_supports( ... 'title' ) ?> |
1646 | 1646 | |
1647 | - <?php if ( ! $bulk ) : ?> |
|
1647 | + <?php if (!$bulk) : ?> |
|
1648 | 1648 | <fieldset class="inline-edit-date"> |
1649 | - <legend><span class="title"><?php _e( 'Date' ); ?></span></legend> |
|
1650 | - <?php touch_time( 1, 1, 0, 1 ); ?> |
|
1649 | + <legend><span class="title"><?php _e('Date'); ?></span></legend> |
|
1650 | + <?php touch_time(1, 1, 0, 1); ?> |
|
1651 | 1651 | </fieldset> |
1652 | 1652 | <br class="clear" /> |
1653 | 1653 | <?php endif; // $bulk ?> |
1654 | 1654 | |
1655 | 1655 | <?php |
1656 | - if ( post_type_supports( $screen->post_type, 'author' ) ) { |
|
1656 | + if (post_type_supports($screen->post_type, 'author')) { |
|
1657 | 1657 | $authors_dropdown = ''; |
1658 | 1658 | |
1659 | - if ( current_user_can( $post_type_object->cap->edit_others_posts ) ) { |
|
1659 | + if (current_user_can($post_type_object->cap->edit_others_posts)) { |
|
1660 | 1660 | $dropdown_name = 'post_author'; |
1661 | 1661 | $dropdown_class = 'authors'; |
1662 | - if ( wp_is_large_user_count() ) { |
|
1663 | - $authors_dropdown = sprintf( '<select name="%s" class="%s hidden"></select>', esc_attr( $dropdown_name ), esc_attr( $dropdown_class ) ); |
|
1662 | + if (wp_is_large_user_count()) { |
|
1663 | + $authors_dropdown = sprintf('<select name="%s" class="%s hidden"></select>', esc_attr($dropdown_name), esc_attr($dropdown_class)); |
|
1664 | 1664 | } else { |
1665 | 1665 | $users_opt = array( |
1666 | 1666 | 'hide_if_only_one_author' => false, |
1667 | - 'capability' => array( $post_type_object->cap->edit_posts ), |
|
1667 | + 'capability' => array($post_type_object->cap->edit_posts), |
|
1668 | 1668 | 'name' => $dropdown_name, |
1669 | 1669 | 'class' => $dropdown_class, |
1670 | 1670 | 'multi' => 1, |
@@ -1672,8 +1672,8 @@ discard block |
||
1672 | 1672 | 'show' => 'display_name_with_login', |
1673 | 1673 | ); |
1674 | 1674 | |
1675 | - if ( $bulk ) { |
|
1676 | - $users_opt['show_option_none'] = __( '— No Change —' ); |
|
1675 | + if ($bulk) { |
|
1676 | + $users_opt['show_option_none'] = __('— No Change —'); |
|
1677 | 1677 | } |
1678 | 1678 | |
1679 | 1679 | /** |
@@ -1686,42 +1686,42 @@ discard block |
||
1686 | 1686 | * @param array $users_opt An array of arguments passed to wp_dropdown_users(). |
1687 | 1687 | * @param bool $bulk A flag to denote if it's a bulk action. |
1688 | 1688 | */ |
1689 | - $users_opt = apply_filters( 'quick_edit_dropdown_authors_args', $users_opt, $bulk ); |
|
1689 | + $users_opt = apply_filters('quick_edit_dropdown_authors_args', $users_opt, $bulk); |
|
1690 | 1690 | |
1691 | - $authors = wp_dropdown_users( $users_opt ); |
|
1691 | + $authors = wp_dropdown_users($users_opt); |
|
1692 | 1692 | |
1693 | - if ( $authors ) { |
|
1693 | + if ($authors) { |
|
1694 | 1694 | $authors_dropdown = '<label class="inline-edit-author">'; |
1695 | - $authors_dropdown .= '<span class="title">' . __( 'Author' ) . '</span>'; |
|
1695 | + $authors_dropdown .= '<span class="title">' . __('Author') . '</span>'; |
|
1696 | 1696 | $authors_dropdown .= $authors; |
1697 | 1697 | $authors_dropdown .= '</label>'; |
1698 | 1698 | } |
1699 | 1699 | } |
1700 | 1700 | } // current_user_can( 'edit_others_posts' ) |
1701 | 1701 | |
1702 | - if ( ! $bulk ) { |
|
1702 | + if (!$bulk) { |
|
1703 | 1703 | echo $authors_dropdown; |
1704 | 1704 | } |
1705 | 1705 | } // post_type_supports( ... 'author' ) |
1706 | 1706 | ?> |
1707 | 1707 | |
1708 | - <?php if ( ! $bulk && $can_publish ) : ?> |
|
1708 | + <?php if (!$bulk && $can_publish) : ?> |
|
1709 | 1709 | |
1710 | 1710 | <div class="inline-edit-group wp-clearfix"> |
1711 | 1711 | <label class="alignleft"> |
1712 | - <span class="title"><?php _e( 'Password' ); ?></span> |
|
1712 | + <span class="title"><?php _e('Password'); ?></span> |
|
1713 | 1713 | <span class="input-text-wrap"><input type="text" name="post_password" class="inline-edit-password-input" value="" /></span> |
1714 | 1714 | </label> |
1715 | 1715 | |
1716 | 1716 | <span class="alignleft inline-edit-or"> |
1717 | 1717 | <?php |
1718 | 1718 | /* translators: Between password field and private checkbox on post quick edit interface. */ |
1719 | - _e( '–OR–' ); |
|
1719 | + _e('–OR–'); |
|
1720 | 1720 | ?> |
1721 | 1721 | </span> |
1722 | 1722 | <label class="alignleft inline-edit-private"> |
1723 | 1723 | <input type="checkbox" name="keep_private" value="private" /> |
1724 | - <span class="checkbox-title"><?php _e( 'Private' ); ?></span> |
|
1724 | + <span class="checkbox-title"><?php _e('Private'); ?></span> |
|
1725 | 1725 | </label> |
1726 | 1726 | </div> |
1727 | 1727 | |
@@ -1730,17 +1730,17 @@ discard block |
||
1730 | 1730 | </div> |
1731 | 1731 | </fieldset> |
1732 | 1732 | |
1733 | - <?php if ( count( $hierarchical_taxonomies ) && ! $bulk ) : ?> |
|
1733 | + <?php if (count($hierarchical_taxonomies) && !$bulk) : ?> |
|
1734 | 1734 | |
1735 | 1735 | <fieldset class="inline-edit-col-center inline-edit-categories"> |
1736 | 1736 | <div class="inline-edit-col"> |
1737 | 1737 | |
1738 | - <?php foreach ( $hierarchical_taxonomies as $taxonomy ) : ?> |
|
1738 | + <?php foreach ($hierarchical_taxonomies as $taxonomy) : ?> |
|
1739 | 1739 | |
1740 | - <span class="title inline-edit-categories-label"><?php echo esc_html( $taxonomy->labels->name ); ?></span> |
|
1741 | - <input type="hidden" name="<?php echo ( 'category' === $taxonomy->name ) ? 'post_category[]' : 'tax_input[' . esc_attr( $taxonomy->name ) . '][]'; ?>" value="0" /> |
|
1742 | - <ul class="cat-checklist <?php echo esc_attr( $taxonomy->name ); ?>-checklist"> |
|
1743 | - <?php wp_terms_checklist( 0, array( 'taxonomy' => $taxonomy->name ) ); ?> |
|
1740 | + <span class="title inline-edit-categories-label"><?php echo esc_html($taxonomy->labels->name); ?></span> |
|
1741 | + <input type="hidden" name="<?php echo ('category' === $taxonomy->name) ? 'post_category[]' : 'tax_input[' . esc_attr($taxonomy->name) . '][]'; ?>" value="0" /> |
|
1742 | + <ul class="cat-checklist <?php echo esc_attr($taxonomy->name); ?>-checklist"> |
|
1743 | + <?php wp_terms_checklist(0, array('taxonomy' => $taxonomy->name)); ?> |
|
1744 | 1744 | </ul> |
1745 | 1745 | |
1746 | 1746 | <?php endforeach; // $hierarchical_taxonomies as $taxonomy ?> |
@@ -1754,29 +1754,29 @@ discard block |
||
1754 | 1754 | <div class="inline-edit-col"> |
1755 | 1755 | |
1756 | 1756 | <?php |
1757 | - if ( post_type_supports( $screen->post_type, 'author' ) && $bulk ) { |
|
1757 | + if (post_type_supports($screen->post_type, 'author') && $bulk) { |
|
1758 | 1758 | echo $authors_dropdown; |
1759 | 1759 | } |
1760 | 1760 | ?> |
1761 | 1761 | |
1762 | - <?php if ( post_type_supports( $screen->post_type, 'page-attributes' ) ) : ?> |
|
1762 | + <?php if (post_type_supports($screen->post_type, 'page-attributes')) : ?> |
|
1763 | 1763 | |
1764 | - <?php if ( $post_type_object->hierarchical ) : ?> |
|
1764 | + <?php if ($post_type_object->hierarchical) : ?> |
|
1765 | 1765 | |
1766 | 1766 | <label> |
1767 | - <span class="title"><?php _e( 'Parent' ); ?></span> |
|
1767 | + <span class="title"><?php _e('Parent'); ?></span> |
|
1768 | 1768 | <?php |
1769 | 1769 | $dropdown_args = array( |
1770 | 1770 | 'post_type' => $post_type_object->name, |
1771 | 1771 | 'selected' => $post->post_parent, |
1772 | 1772 | 'name' => 'post_parent', |
1773 | - 'show_option_none' => __( 'Main Page (no parent)' ), |
|
1773 | + 'show_option_none' => __('Main Page (no parent)'), |
|
1774 | 1774 | 'option_none_value' => 0, |
1775 | 1775 | 'sort_column' => 'menu_order, post_title', |
1776 | 1776 | ); |
1777 | 1777 | |
1778 | - if ( $bulk ) { |
|
1779 | - $dropdown_args['show_option_no_change'] = __( '— No Change —' ); |
|
1778 | + if ($bulk) { |
|
1779 | + $dropdown_args['show_option_no_change'] = __('— No Change —'); |
|
1780 | 1780 | } |
1781 | 1781 | |
1782 | 1782 | /** |
@@ -1790,18 +1790,18 @@ discard block |
||
1790 | 1790 | * @param array $dropdown_args An array of arguments passed to wp_dropdown_pages(). |
1791 | 1791 | * @param bool $bulk A flag to denote if it's a bulk action. |
1792 | 1792 | */ |
1793 | - $dropdown_args = apply_filters( 'quick_edit_dropdown_pages_args', $dropdown_args, $bulk ); |
|
1793 | + $dropdown_args = apply_filters('quick_edit_dropdown_pages_args', $dropdown_args, $bulk); |
|
1794 | 1794 | |
1795 | - wp_dropdown_pages( $dropdown_args ); |
|
1795 | + wp_dropdown_pages($dropdown_args); |
|
1796 | 1796 | ?> |
1797 | 1797 | </label> |
1798 | 1798 | |
1799 | 1799 | <?php endif; // hierarchical ?> |
1800 | 1800 | |
1801 | - <?php if ( ! $bulk ) : ?> |
|
1801 | + <?php if (!$bulk) : ?> |
|
1802 | 1802 | |
1803 | 1803 | <label> |
1804 | - <span class="title"><?php _e( 'Order' ); ?></span> |
|
1804 | + <span class="title"><?php _e('Order'); ?></span> |
|
1805 | 1805 | <span class="input-text-wrap"><input type="text" name="menu_order" class="inline-edit-menu-order-input" value="<?php echo $post->menu_order; ?>" /></span> |
1806 | 1806 | </label> |
1807 | 1807 | |
@@ -1809,37 +1809,37 @@ discard block |
||
1809 | 1809 | |
1810 | 1810 | <?php endif; // post_type_supports( ... 'page-attributes' ) ?> |
1811 | 1811 | |
1812 | - <?php if ( 0 < count( get_page_templates( null, $screen->post_type ) ) ) : ?> |
|
1812 | + <?php if (0 < count(get_page_templates(null, $screen->post_type))) : ?> |
|
1813 | 1813 | |
1814 | 1814 | <label> |
1815 | - <span class="title"><?php _e( 'Template' ); ?></span> |
|
1815 | + <span class="title"><?php _e('Template'); ?></span> |
|
1816 | 1816 | <select name="page_template"> |
1817 | - <?php if ( $bulk ) : ?> |
|
1818 | - <option value="-1"><?php _e( '— No Change —' ); ?></option> |
|
1817 | + <?php if ($bulk) : ?> |
|
1818 | + <option value="-1"><?php _e('— No Change —'); ?></option> |
|
1819 | 1819 | <?php endif; // $bulk ?> |
1820 | 1820 | <?php |
1821 | 1821 | /** This filter is documented in wp-admin/includes/meta-boxes.php */ |
1822 | - $default_title = apply_filters( 'default_page_template_title', __( 'Default template' ), 'quick-edit' ); |
|
1822 | + $default_title = apply_filters('default_page_template_title', __('Default template'), 'quick-edit'); |
|
1823 | 1823 | ?> |
1824 | - <option value="default"><?php echo esc_html( $default_title ); ?></option> |
|
1825 | - <?php page_template_dropdown( '', $screen->post_type ); ?> |
|
1824 | + <option value="default"><?php echo esc_html($default_title); ?></option> |
|
1825 | + <?php page_template_dropdown('', $screen->post_type); ?> |
|
1826 | 1826 | </select> |
1827 | 1827 | </label> |
1828 | 1828 | |
1829 | 1829 | <?php endif; ?> |
1830 | 1830 | |
1831 | - <?php if ( count( $flat_taxonomies ) && ! $bulk ) : ?> |
|
1831 | + <?php if (count($flat_taxonomies) && !$bulk) : ?> |
|
1832 | 1832 | |
1833 | - <?php foreach ( $flat_taxonomies as $taxonomy ) : ?> |
|
1833 | + <?php foreach ($flat_taxonomies as $taxonomy) : ?> |
|
1834 | 1834 | |
1835 | - <?php if ( current_user_can( $taxonomy->cap->assign_terms ) ) : ?> |
|
1836 | - <?php $taxonomy_name = esc_attr( $taxonomy->name ); ?> |
|
1835 | + <?php if (current_user_can($taxonomy->cap->assign_terms)) : ?> |
|
1836 | + <?php $taxonomy_name = esc_attr($taxonomy->name); ?> |
|
1837 | 1837 | <div class="inline-edit-tags-wrap"> |
1838 | 1838 | <label class="inline-edit-tags"> |
1839 | - <span class="title"><?php echo esc_html( $taxonomy->labels->name ); ?></span> |
|
1840 | - <textarea data-wp-taxonomy="<?php echo $taxonomy_name; ?>" cols="22" rows="1" name="tax_input[<?php echo esc_attr( $taxonomy->name ); ?>]" class="tax_input_<?php echo esc_attr( $taxonomy->name ); ?>" aria-describedby="inline-edit-<?php echo esc_attr( $taxonomy->name ); ?>-desc"></textarea> |
|
1839 | + <span class="title"><?php echo esc_html($taxonomy->labels->name); ?></span> |
|
1840 | + <textarea data-wp-taxonomy="<?php echo $taxonomy_name; ?>" cols="22" rows="1" name="tax_input[<?php echo esc_attr($taxonomy->name); ?>]" class="tax_input_<?php echo esc_attr($taxonomy->name); ?>" aria-describedby="inline-edit-<?php echo esc_attr($taxonomy->name); ?>-desc"></textarea> |
|
1841 | 1841 | </label> |
1842 | - <p class="howto" id="inline-edit-<?php echo esc_attr( $taxonomy->name ); ?>-desc"><?php echo esc_html( $taxonomy->labels->separate_items_with_commas ); ?></p> |
|
1842 | + <p class="howto" id="inline-edit-<?php echo esc_attr($taxonomy->name); ?>-desc"><?php echo esc_html($taxonomy->labels->separate_items_with_commas); ?></p> |
|
1843 | 1843 | </div> |
1844 | 1844 | <?php endif; // current_user_can( 'assign_terms' ) ?> |
1845 | 1845 | |
@@ -1847,33 +1847,33 @@ discard block |
||
1847 | 1847 | |
1848 | 1848 | <?php endif; // count( $flat_taxonomies ) && ! $bulk ?> |
1849 | 1849 | |
1850 | - <?php if ( post_type_supports( $screen->post_type, 'comments' ) || post_type_supports( $screen->post_type, 'trackbacks' ) ) : ?> |
|
1850 | + <?php if (post_type_supports($screen->post_type, 'comments') || post_type_supports($screen->post_type, 'trackbacks')) : ?> |
|
1851 | 1851 | |
1852 | - <?php if ( $bulk ) : ?> |
|
1852 | + <?php if ($bulk) : ?> |
|
1853 | 1853 | |
1854 | 1854 | <div class="inline-edit-group wp-clearfix"> |
1855 | 1855 | |
1856 | - <?php if ( post_type_supports( $screen->post_type, 'comments' ) ) : ?> |
|
1856 | + <?php if (post_type_supports($screen->post_type, 'comments')) : ?> |
|
1857 | 1857 | |
1858 | 1858 | <label class="alignleft"> |
1859 | - <span class="title"><?php _e( 'Comments' ); ?></span> |
|
1859 | + <span class="title"><?php _e('Comments'); ?></span> |
|
1860 | 1860 | <select name="comment_status"> |
1861 | - <option value=""><?php _e( '— No Change —' ); ?></option> |
|
1862 | - <option value="open"><?php _e( 'Allow' ); ?></option> |
|
1863 | - <option value="closed"><?php _e( 'Do not allow' ); ?></option> |
|
1861 | + <option value=""><?php _e('— No Change —'); ?></option> |
|
1862 | + <option value="open"><?php _e('Allow'); ?></option> |
|
1863 | + <option value="closed"><?php _e('Do not allow'); ?></option> |
|
1864 | 1864 | </select> |
1865 | 1865 | </label> |
1866 | 1866 | |
1867 | 1867 | <?php endif; ?> |
1868 | 1868 | |
1869 | - <?php if ( post_type_supports( $screen->post_type, 'trackbacks' ) ) : ?> |
|
1869 | + <?php if (post_type_supports($screen->post_type, 'trackbacks')) : ?> |
|
1870 | 1870 | |
1871 | 1871 | <label class="alignright"> |
1872 | - <span class="title"><?php _e( 'Pings' ); ?></span> |
|
1872 | + <span class="title"><?php _e('Pings'); ?></span> |
|
1873 | 1873 | <select name="ping_status"> |
1874 | - <option value=""><?php _e( '— No Change —' ); ?></option> |
|
1875 | - <option value="open"><?php _e( 'Allow' ); ?></option> |
|
1876 | - <option value="closed"><?php _e( 'Do not allow' ); ?></option> |
|
1874 | + <option value=""><?php _e('— No Change —'); ?></option> |
|
1875 | + <option value="open"><?php _e('Allow'); ?></option> |
|
1876 | + <option value="closed"><?php _e('Do not allow'); ?></option> |
|
1877 | 1877 | </select> |
1878 | 1878 | </label> |
1879 | 1879 | |
@@ -1885,20 +1885,20 @@ discard block |
||
1885 | 1885 | |
1886 | 1886 | <div class="inline-edit-group wp-clearfix"> |
1887 | 1887 | |
1888 | - <?php if ( post_type_supports( $screen->post_type, 'comments' ) ) : ?> |
|
1888 | + <?php if (post_type_supports($screen->post_type, 'comments')) : ?> |
|
1889 | 1889 | |
1890 | 1890 | <label class="alignleft"> |
1891 | 1891 | <input type="checkbox" name="comment_status" value="open" /> |
1892 | - <span class="checkbox-title"><?php _e( 'Allow Comments' ); ?></span> |
|
1892 | + <span class="checkbox-title"><?php _e('Allow Comments'); ?></span> |
|
1893 | 1893 | </label> |
1894 | 1894 | |
1895 | 1895 | <?php endif; ?> |
1896 | 1896 | |
1897 | - <?php if ( post_type_supports( $screen->post_type, 'trackbacks' ) ) : ?> |
|
1897 | + <?php if (post_type_supports($screen->post_type, 'trackbacks')) : ?> |
|
1898 | 1898 | |
1899 | 1899 | <label class="alignleft"> |
1900 | 1900 | <input type="checkbox" name="ping_status" value="open" /> |
1901 | - <span class="checkbox-title"><?php _e( 'Allow Pings' ); ?></span> |
|
1901 | + <span class="checkbox-title"><?php _e('Allow Pings'); ?></span> |
|
1902 | 1902 | </label> |
1903 | 1903 | |
1904 | 1904 | <?php endif; ?> |
@@ -1912,35 +1912,35 @@ discard block |
||
1912 | 1912 | <div class="inline-edit-group wp-clearfix"> |
1913 | 1913 | |
1914 | 1914 | <label class="inline-edit-status alignleft"> |
1915 | - <span class="title"><?php _e( 'Status' ); ?></span> |
|
1915 | + <span class="title"><?php _e('Status'); ?></span> |
|
1916 | 1916 | <select name="_status"> |
1917 | - <?php if ( $bulk ) : ?> |
|
1918 | - <option value="-1"><?php _e( '— No Change —' ); ?></option> |
|
1917 | + <?php if ($bulk) : ?> |
|
1918 | + <option value="-1"><?php _e('— No Change —'); ?></option> |
|
1919 | 1919 | <?php endif; // $bulk ?> |
1920 | 1920 | |
1921 | - <?php if ( $can_publish ) : // Contributors only get "Unpublished" and "Pending Review". ?> |
|
1922 | - <option value="publish"><?php _e( 'Published' ); ?></option> |
|
1923 | - <option value="future"><?php _e( 'Scheduled' ); ?></option> |
|
1924 | - <?php if ( $bulk ) : ?> |
|
1925 | - <option value="private"><?php _e( 'Private' ); ?></option> |
|
1921 | + <?php if ($can_publish) : // Contributors only get "Unpublished" and "Pending Review". ?> |
|
1922 | + <option value="publish"><?php _e('Published'); ?></option> |
|
1923 | + <option value="future"><?php _e('Scheduled'); ?></option> |
|
1924 | + <?php if ($bulk) : ?> |
|
1925 | + <option value="private"><?php _e('Private'); ?></option> |
|
1926 | 1926 | <?php endif; // $bulk ?> |
1927 | 1927 | <?php endif; ?> |
1928 | 1928 | |
1929 | - <option value="pending"><?php _e( 'Pending Review' ); ?></option> |
|
1930 | - <option value="draft"><?php _e( 'Draft' ); ?></option> |
|
1929 | + <option value="pending"><?php _e('Pending Review'); ?></option> |
|
1930 | + <option value="draft"><?php _e('Draft'); ?></option> |
|
1931 | 1931 | </select> |
1932 | 1932 | </label> |
1933 | 1933 | |
1934 | - <?php if ( 'post' === $screen->post_type && $can_publish && current_user_can( $post_type_object->cap->edit_others_posts ) ) : ?> |
|
1934 | + <?php if ('post' === $screen->post_type && $can_publish && current_user_can($post_type_object->cap->edit_others_posts)) : ?> |
|
1935 | 1935 | |
1936 | - <?php if ( $bulk ) : ?> |
|
1936 | + <?php if ($bulk) : ?> |
|
1937 | 1937 | |
1938 | 1938 | <label class="alignright"> |
1939 | - <span class="title"><?php _e( 'Sticky' ); ?></span> |
|
1939 | + <span class="title"><?php _e('Sticky'); ?></span> |
|
1940 | 1940 | <select name="sticky"> |
1941 | - <option value="-1"><?php _e( '— No Change —' ); ?></option> |
|
1942 | - <option value="sticky"><?php _e( 'Sticky' ); ?></option> |
|
1943 | - <option value="unsticky"><?php _e( 'Not Sticky' ); ?></option> |
|
1941 | + <option value="-1"><?php _e('— No Change —'); ?></option> |
|
1942 | + <option value="sticky"><?php _e('Sticky'); ?></option> |
|
1943 | + <option value="unsticky"><?php _e('Not Sticky'); ?></option> |
|
1944 | 1944 | </select> |
1945 | 1945 | </label> |
1946 | 1946 | |
@@ -1948,7 +1948,7 @@ discard block |
||
1948 | 1948 | |
1949 | 1949 | <label class="alignleft"> |
1950 | 1950 | <input type="checkbox" name="sticky" value="sticky" /> |
1951 | - <span class="checkbox-title"><?php _e( 'Make this post sticky' ); ?></span> |
|
1951 | + <span class="checkbox-title"><?php _e('Make this post sticky'); ?></span> |
|
1952 | 1952 | </label> |
1953 | 1953 | |
1954 | 1954 | <?php endif; // $bulk ?> |
@@ -1957,17 +1957,17 @@ discard block |
||
1957 | 1957 | |
1958 | 1958 | </div> |
1959 | 1959 | |
1960 | - <?php if ( $bulk && current_theme_supports( 'post-formats' ) && post_type_supports( $screen->post_type, 'post-formats' ) ) : ?> |
|
1961 | - <?php $post_formats = get_theme_support( 'post-formats' ); ?> |
|
1960 | + <?php if ($bulk && current_theme_supports('post-formats') && post_type_supports($screen->post_type, 'post-formats')) : ?> |
|
1961 | + <?php $post_formats = get_theme_support('post-formats'); ?> |
|
1962 | 1962 | |
1963 | 1963 | <label class="alignleft"> |
1964 | - <span class="title"><?php _ex( 'Format', 'post format' ); ?></span> |
|
1964 | + <span class="title"><?php _ex('Format', 'post format'); ?></span> |
|
1965 | 1965 | <select name="post_format"> |
1966 | - <option value="-1"><?php _e( '— No Change —' ); ?></option> |
|
1967 | - <option value="0"><?php echo get_post_format_string( 'standard' ); ?></option> |
|
1968 | - <?php if ( is_array( $post_formats[0] ) ) : ?> |
|
1969 | - <?php foreach ( $post_formats[0] as $format ) : ?> |
|
1970 | - <option value="<?php echo esc_attr( $format ); ?>"><?php echo esc_html( get_post_format_string( $format ) ); ?></option> |
|
1966 | + <option value="-1"><?php _e('— No Change —'); ?></option> |
|
1967 | + <option value="0"><?php echo get_post_format_string('standard'); ?></option> |
|
1968 | + <?php if (is_array($post_formats[0])) : ?> |
|
1969 | + <?php foreach ($post_formats[0] as $format) : ?> |
|
1970 | + <option value="<?php echo esc_attr($format); ?>"><?php echo esc_html(get_post_format_string($format)); ?></option> |
|
1971 | 1971 | <?php endforeach; ?> |
1972 | 1972 | <?php endif; ?> |
1973 | 1973 | </select> |
@@ -1979,14 +1979,14 @@ discard block |
||
1979 | 1979 | </fieldset> |
1980 | 1980 | |
1981 | 1981 | <?php |
1982 | - list( $columns ) = $this->get_column_info(); |
|
1982 | + list($columns) = $this->get_column_info(); |
|
1983 | 1983 | |
1984 | - foreach ( $columns as $column_name => $column_display_name ) { |
|
1985 | - if ( isset( $core_columns[ $column_name ] ) ) { |
|
1984 | + foreach ($columns as $column_name => $column_display_name) { |
|
1985 | + if (isset($core_columns[$column_name])) { |
|
1986 | 1986 | continue; |
1987 | 1987 | } |
1988 | 1988 | |
1989 | - if ( $bulk ) { |
|
1989 | + if ($bulk) { |
|
1990 | 1990 | |
1991 | 1991 | /** |
1992 | 1992 | * Fires once for each column in Bulk Edit mode. |
@@ -1996,7 +1996,7 @@ discard block |
||
1996 | 1996 | * @param string $column_name Name of the column to edit. |
1997 | 1997 | * @param string $post_type The post type slug. |
1998 | 1998 | */ |
1999 | - do_action( 'bulk_edit_custom_box', $column_name, $screen->post_type ); |
|
1999 | + do_action('bulk_edit_custom_box', $column_name, $screen->post_type); |
|
2000 | 2000 | } else { |
2001 | 2001 | |
2002 | 2002 | /** |
@@ -2008,29 +2008,29 @@ discard block |
||
2008 | 2008 | * @param string $post_type The post type slug, or current screen name if this is a taxonomy list table. |
2009 | 2009 | * @param string $taxonomy The taxonomy name, if any. |
2010 | 2010 | */ |
2011 | - do_action( 'quick_edit_custom_box', $column_name, $screen->post_type, '' ); |
|
2011 | + do_action('quick_edit_custom_box', $column_name, $screen->post_type, ''); |
|
2012 | 2012 | } |
2013 | 2013 | } |
2014 | 2014 | ?> |
2015 | 2015 | |
2016 | 2016 | <div class="submit inline-edit-save"> |
2017 | - <?php if ( ! $bulk ) : ?> |
|
2018 | - <?php wp_nonce_field( 'inlineeditnonce', '_inline_edit', false ); ?> |
|
2019 | - <button type="button" class="button button-primary save"><?php _e( 'Update' ); ?></button> |
|
2017 | + <?php if (!$bulk) : ?> |
|
2018 | + <?php wp_nonce_field('inlineeditnonce', '_inline_edit', false); ?> |
|
2019 | + <button type="button" class="button button-primary save"><?php _e('Update'); ?></button> |
|
2020 | 2020 | <?php else : ?> |
2021 | - <?php submit_button( __( 'Update' ), 'primary', 'bulk_edit', false ); ?> |
|
2021 | + <?php submit_button(__('Update'), 'primary', 'bulk_edit', false); ?> |
|
2022 | 2022 | <?php endif; ?> |
2023 | 2023 | |
2024 | - <button type="button" class="button cancel"><?php _e( 'Cancel' ); ?></button> |
|
2024 | + <button type="button" class="button cancel"><?php _e('Cancel'); ?></button> |
|
2025 | 2025 | |
2026 | - <?php if ( ! $bulk ) : ?> |
|
2026 | + <?php if (!$bulk) : ?> |
|
2027 | 2027 | <span class="spinner"></span> |
2028 | 2028 | <?php endif; ?> |
2029 | 2029 | |
2030 | - <input type="hidden" name="post_view" value="<?php echo esc_attr( $m ); ?>" /> |
|
2031 | - <input type="hidden" name="screen" value="<?php echo esc_attr( $screen->id ); ?>" /> |
|
2032 | - <?php if ( ! $bulk && ! post_type_supports( $screen->post_type, 'author' ) ) : ?> |
|
2033 | - <input type="hidden" name="post_author" value="<?php echo esc_attr( $post->post_author ); ?>" /> |
|
2030 | + <input type="hidden" name="post_view" value="<?php echo esc_attr($m); ?>" /> |
|
2031 | + <input type="hidden" name="screen" value="<?php echo esc_attr($screen->id); ?>" /> |
|
2032 | + <?php if (!$bulk && !post_type_supports($screen->post_type, 'author')) : ?> |
|
2033 | + <input type="hidden" name="post_author" value="<?php echo esc_attr($post->post_author); ?>" /> |
|
2034 | 2034 | <?php endif; ?> |
2035 | 2035 | |
2036 | 2036 | <div class="notice notice-error notice-alt inline hidden"> |
@@ -26,7 +26,7 @@ discard block |
||
26 | 26 | * @param int $depth Depth of menu item. Used for padding. |
27 | 27 | * @param stdClass $args Not used. |
28 | 28 | */ |
29 | - public function start_lvl( &$output, $depth = 0, $args = null ) {} |
|
29 | + public function start_lvl(&$output, $depth = 0, $args = null) {} |
|
30 | 30 | |
31 | 31 | /** |
32 | 32 | * Ends the list of after the elements are added. |
@@ -39,7 +39,7 @@ discard block |
||
39 | 39 | * @param int $depth Depth of menu item. Used for padding. |
40 | 40 | * @param stdClass $args Not used. |
41 | 41 | */ |
42 | - public function end_lvl( &$output, $depth = 0, $args = null ) {} |
|
42 | + public function end_lvl(&$output, $depth = 0, $args = null) {} |
|
43 | 43 | |
44 | 44 | /** |
45 | 45 | * Start the element output. |
@@ -57,7 +57,7 @@ discard block |
||
57 | 57 | * @param stdClass $args Not used. |
58 | 58 | * @param int $current_object_id Optional. ID of the current menu item. Default 0. |
59 | 59 | */ |
60 | - public function start_el( &$output, $data_object, $depth = 0, $args = null, $current_object_id = 0 ) { |
|
60 | + public function start_el(&$output, $data_object, $depth = 0, $args = null, $current_object_id = 0) { |
|
61 | 61 | global $_wp_nav_menu_max_depth; |
62 | 62 | |
63 | 63 | // Restores the more descriptive, specific name for use within this method. |
@@ -65,7 +65,7 @@ discard block |
||
65 | 65 | $_wp_nav_menu_max_depth = $depth > $_wp_nav_menu_max_depth ? $depth : $_wp_nav_menu_max_depth; |
66 | 66 | |
67 | 67 | ob_start(); |
68 | - $item_id = esc_attr( $menu_item->ID ); |
|
68 | + $item_id = esc_attr($menu_item->ID); |
|
69 | 69 | $removed_args = array( |
70 | 70 | 'action', |
71 | 71 | 'customlink-tab', |
@@ -77,59 +77,59 @@ discard block |
||
77 | 77 | |
78 | 78 | $original_title = false; |
79 | 79 | |
80 | - if ( 'taxonomy' === $menu_item->type ) { |
|
81 | - $original_object = get_term( (int) $menu_item->object_id, $menu_item->object ); |
|
82 | - if ( $original_object && ! is_wp_error( $original_object ) ) { |
|
80 | + if ('taxonomy' === $menu_item->type) { |
|
81 | + $original_object = get_term((int) $menu_item->object_id, $menu_item->object); |
|
82 | + if ($original_object && !is_wp_error($original_object)) { |
|
83 | 83 | $original_title = $original_object->name; |
84 | 84 | } |
85 | - } elseif ( 'post_type' === $menu_item->type ) { |
|
86 | - $original_object = get_post( $menu_item->object_id ); |
|
87 | - if ( $original_object ) { |
|
88 | - $original_title = get_the_title( $original_object->ID ); |
|
85 | + } elseif ('post_type' === $menu_item->type) { |
|
86 | + $original_object = get_post($menu_item->object_id); |
|
87 | + if ($original_object) { |
|
88 | + $original_title = get_the_title($original_object->ID); |
|
89 | 89 | } |
90 | - } elseif ( 'post_type_archive' === $menu_item->type ) { |
|
91 | - $original_object = get_post_type_object( $menu_item->object ); |
|
92 | - if ( $original_object ) { |
|
90 | + } elseif ('post_type_archive' === $menu_item->type) { |
|
91 | + $original_object = get_post_type_object($menu_item->object); |
|
92 | + if ($original_object) { |
|
93 | 93 | $original_title = $original_object->labels->archives; |
94 | 94 | } |
95 | 95 | } |
96 | 96 | |
97 | 97 | $classes = array( |
98 | 98 | 'menu-item menu-item-depth-' . $depth, |
99 | - 'menu-item-' . esc_attr( $menu_item->object ), |
|
100 | - 'menu-item-edit-' . ( ( isset( $_GET['edit-menu-item'] ) && $item_id === $_GET['edit-menu-item'] ) ? 'active' : 'inactive' ), |
|
99 | + 'menu-item-' . esc_attr($menu_item->object), |
|
100 | + 'menu-item-edit-' . ((isset($_GET['edit-menu-item']) && $item_id === $_GET['edit-menu-item']) ? 'active' : 'inactive'), |
|
101 | 101 | ); |
102 | 102 | |
103 | 103 | $title = $menu_item->title; |
104 | 104 | |
105 | - if ( ! empty( $menu_item->_invalid ) ) { |
|
105 | + if (!empty($menu_item->_invalid)) { |
|
106 | 106 | $classes[] = 'menu-item-invalid'; |
107 | 107 | /* translators: %s: Title of an invalid menu item. */ |
108 | - $title = sprintf( __( '%s (Invalid)' ), $menu_item->title ); |
|
109 | - } elseif ( isset( $menu_item->post_status ) && 'draft' === $menu_item->post_status ) { |
|
108 | + $title = sprintf(__('%s (Invalid)'), $menu_item->title); |
|
109 | + } elseif (isset($menu_item->post_status) && 'draft' === $menu_item->post_status) { |
|
110 | 110 | $classes[] = 'pending'; |
111 | 111 | /* translators: %s: Title of a menu item in draft status. */ |
112 | - $title = sprintf( __( '%s (Pending)' ), $menu_item->title ); |
|
112 | + $title = sprintf(__('%s (Pending)'), $menu_item->title); |
|
113 | 113 | } |
114 | 114 | |
115 | - $title = ( ! isset( $menu_item->label ) || '' === $menu_item->label ) ? $title : $menu_item->label; |
|
115 | + $title = (!isset($menu_item->label) || '' === $menu_item->label) ? $title : $menu_item->label; |
|
116 | 116 | |
117 | 117 | $submenu_text = ''; |
118 | - if ( 0 === $depth ) { |
|
118 | + if (0 === $depth) { |
|
119 | 119 | $submenu_text = 'style="display: none;"'; |
120 | 120 | } |
121 | 121 | |
122 | 122 | ?> |
123 | - <li id="menu-item-<?php echo $item_id; ?>" class="<?php echo implode( ' ', $classes ); ?>"> |
|
123 | + <li id="menu-item-<?php echo $item_id; ?>" class="<?php echo implode(' ', $classes); ?>"> |
|
124 | 124 | <div class="menu-item-bar"> |
125 | 125 | <div class="menu-item-handle"> |
126 | 126 | <label class="item-title" for="menu-item-checkbox-<?php echo $item_id; ?>"> |
127 | 127 | <input id="menu-item-checkbox-<?php echo $item_id; ?>" type="checkbox" class="menu-item-checkbox" data-menu-item-id="<?php echo $item_id; ?>" disabled="disabled" /> |
128 | - <span class="menu-item-title"><?php echo esc_html( $title ); ?></span> |
|
129 | - <span class="is-submenu" <?php echo $submenu_text; ?>><?php _e( 'sub item' ); ?></span> |
|
128 | + <span class="menu-item-title"><?php echo esc_html($title); ?></span> |
|
129 | + <span class="is-submenu" <?php echo $submenu_text; ?>><?php _e('sub item'); ?></span> |
|
130 | 130 | </label> |
131 | 131 | <span class="item-controls"> |
132 | - <span class="item-type"><?php echo esc_html( $menu_item->type_label ); ?></span> |
|
132 | + <span class="item-type"><?php echo esc_html($menu_item->type_label); ?></span> |
|
133 | 133 | <span class="item-order hide-if-js"> |
134 | 134 | <?php |
135 | 135 | printf( |
@@ -140,11 +140,11 @@ discard block |
||
140 | 140 | 'action' => 'move-up-menu-item', |
141 | 141 | 'menu-item' => $item_id, |
142 | 142 | ), |
143 | - remove_query_arg( $removed_args, admin_url( 'nav-menus.php' ) ) |
|
143 | + remove_query_arg($removed_args, admin_url('nav-menus.php')) |
|
144 | 144 | ), |
145 | 145 | 'move-menu_item' |
146 | 146 | ), |
147 | - esc_attr__( 'Move up' ) |
|
147 | + esc_attr__('Move up') |
|
148 | 148 | ); |
149 | 149 | ?> |
150 | 150 | | |
@@ -157,23 +157,23 @@ discard block |
||
157 | 157 | 'action' => 'move-down-menu-item', |
158 | 158 | 'menu-item' => $item_id, |
159 | 159 | ), |
160 | - remove_query_arg( $removed_args, admin_url( 'nav-menus.php' ) ) |
|
160 | + remove_query_arg($removed_args, admin_url('nav-menus.php')) |
|
161 | 161 | ), |
162 | 162 | 'move-menu_item' |
163 | 163 | ), |
164 | - esc_attr__( 'Move down' ) |
|
164 | + esc_attr__('Move down') |
|
165 | 165 | ); |
166 | 166 | ?> |
167 | 167 | </span> |
168 | 168 | <?php |
169 | - if ( isset( $_GET['edit-menu-item'] ) && $item_id === $_GET['edit-menu-item'] ) { |
|
170 | - $edit_url = admin_url( 'nav-menus.php' ); |
|
169 | + if (isset($_GET['edit-menu-item']) && $item_id === $_GET['edit-menu-item']) { |
|
170 | + $edit_url = admin_url('nav-menus.php'); |
|
171 | 171 | } else { |
172 | 172 | $edit_url = add_query_arg( |
173 | 173 | array( |
174 | 174 | 'edit-menu-item' => $item_id, |
175 | 175 | ), |
176 | - remove_query_arg( $removed_args, admin_url( 'nav-menus.php#menu-item-settings-' . $item_id ) ) |
|
176 | + remove_query_arg($removed_args, admin_url('nav-menus.php#menu-item-settings-' . $item_id)) |
|
177 | 177 | ); |
178 | 178 | } |
179 | 179 | |
@@ -181,8 +181,8 @@ discard block |
||
181 | 181 | '<a class="item-edit" id="edit-%s" href="%s" aria-label="%s"><span class="screen-reader-text">%s</span></a>', |
182 | 182 | $item_id, |
183 | 183 | $edit_url, |
184 | - esc_attr__( 'Edit menu item' ), |
|
185 | - __( 'Edit' ) |
|
184 | + esc_attr__('Edit menu item'), |
|
185 | + __('Edit') |
|
186 | 186 | ); |
187 | 187 | ?> |
188 | 188 | </span> |
@@ -190,49 +190,49 @@ discard block |
||
190 | 190 | </div> |
191 | 191 | |
192 | 192 | <div class="menu-item-settings wp-clearfix" id="menu-item-settings-<?php echo $item_id; ?>"> |
193 | - <?php if ( 'custom' === $menu_item->type ) : ?> |
|
193 | + <?php if ('custom' === $menu_item->type) : ?> |
|
194 | 194 | <p class="field-url description description-wide"> |
195 | 195 | <label for="edit-menu-item-url-<?php echo $item_id; ?>"> |
196 | - <?php _e( 'URL' ); ?><br /> |
|
197 | - <input type="text" id="edit-menu-item-url-<?php echo $item_id; ?>" class="widefat code edit-menu-item-url" name="menu-item-url[<?php echo $item_id; ?>]" value="<?php echo esc_attr( $menu_item->url ); ?>" /> |
|
196 | + <?php _e('URL'); ?><br /> |
|
197 | + <input type="text" id="edit-menu-item-url-<?php echo $item_id; ?>" class="widefat code edit-menu-item-url" name="menu-item-url[<?php echo $item_id; ?>]" value="<?php echo esc_attr($menu_item->url); ?>" /> |
|
198 | 198 | </label> |
199 | 199 | </p> |
200 | 200 | <?php endif; ?> |
201 | 201 | <p class="description description-wide"> |
202 | 202 | <label for="edit-menu-item-title-<?php echo $item_id; ?>"> |
203 | - <?php _e( 'Navigation Label' ); ?><br /> |
|
204 | - <input type="text" id="edit-menu-item-title-<?php echo $item_id; ?>" class="widefat edit-menu-item-title" name="menu-item-title[<?php echo $item_id; ?>]" value="<?php echo esc_attr( $menu_item->title ); ?>" /> |
|
203 | + <?php _e('Navigation Label'); ?><br /> |
|
204 | + <input type="text" id="edit-menu-item-title-<?php echo $item_id; ?>" class="widefat edit-menu-item-title" name="menu-item-title[<?php echo $item_id; ?>]" value="<?php echo esc_attr($menu_item->title); ?>" /> |
|
205 | 205 | </label> |
206 | 206 | </p> |
207 | 207 | <p class="field-title-attribute field-attr-title description description-wide"> |
208 | 208 | <label for="edit-menu-item-attr-title-<?php echo $item_id; ?>"> |
209 | - <?php _e( 'Title Attribute' ); ?><br /> |
|
210 | - <input type="text" id="edit-menu-item-attr-title-<?php echo $item_id; ?>" class="widefat edit-menu-item-attr-title" name="menu-item-attr-title[<?php echo $item_id; ?>]" value="<?php echo esc_attr( $menu_item->post_excerpt ); ?>" /> |
|
209 | + <?php _e('Title Attribute'); ?><br /> |
|
210 | + <input type="text" id="edit-menu-item-attr-title-<?php echo $item_id; ?>" class="widefat edit-menu-item-attr-title" name="menu-item-attr-title[<?php echo $item_id; ?>]" value="<?php echo esc_attr($menu_item->post_excerpt); ?>" /> |
|
211 | 211 | </label> |
212 | 212 | </p> |
213 | 213 | <p class="field-link-target description"> |
214 | 214 | <label for="edit-menu-item-target-<?php echo $item_id; ?>"> |
215 | - <input type="checkbox" id="edit-menu-item-target-<?php echo $item_id; ?>" value="_blank" name="menu-item-target[<?php echo $item_id; ?>]"<?php checked( $menu_item->target, '_blank' ); ?> /> |
|
216 | - <?php _e( 'Open link in a new tab' ); ?> |
|
215 | + <input type="checkbox" id="edit-menu-item-target-<?php echo $item_id; ?>" value="_blank" name="menu-item-target[<?php echo $item_id; ?>]"<?php checked($menu_item->target, '_blank'); ?> /> |
|
216 | + <?php _e('Open link in a new tab'); ?> |
|
217 | 217 | </label> |
218 | 218 | </p> |
219 | 219 | <p class="field-css-classes description description-thin"> |
220 | 220 | <label for="edit-menu-item-classes-<?php echo $item_id; ?>"> |
221 | - <?php _e( 'CSS Classes (optional)' ); ?><br /> |
|
222 | - <input type="text" id="edit-menu-item-classes-<?php echo $item_id; ?>" class="widefat code edit-menu-item-classes" name="menu-item-classes[<?php echo $item_id; ?>]" value="<?php echo esc_attr( implode( ' ', $menu_item->classes ) ); ?>" /> |
|
221 | + <?php _e('CSS Classes (optional)'); ?><br /> |
|
222 | + <input type="text" id="edit-menu-item-classes-<?php echo $item_id; ?>" class="widefat code edit-menu-item-classes" name="menu-item-classes[<?php echo $item_id; ?>]" value="<?php echo esc_attr(implode(' ', $menu_item->classes)); ?>" /> |
|
223 | 223 | </label> |
224 | 224 | </p> |
225 | 225 | <p class="field-xfn description description-thin"> |
226 | 226 | <label for="edit-menu-item-xfn-<?php echo $item_id; ?>"> |
227 | - <?php _e( 'Link Relationship (XFN)' ); ?><br /> |
|
228 | - <input type="text" id="edit-menu-item-xfn-<?php echo $item_id; ?>" class="widefat code edit-menu-item-xfn" name="menu-item-xfn[<?php echo $item_id; ?>]" value="<?php echo esc_attr( $menu_item->xfn ); ?>" /> |
|
227 | + <?php _e('Link Relationship (XFN)'); ?><br /> |
|
228 | + <input type="text" id="edit-menu-item-xfn-<?php echo $item_id; ?>" class="widefat code edit-menu-item-xfn" name="menu-item-xfn[<?php echo $item_id; ?>]" value="<?php echo esc_attr($menu_item->xfn); ?>" /> |
|
229 | 229 | </label> |
230 | 230 | </p> |
231 | 231 | <p class="field-description description description-wide"> |
232 | 232 | <label for="edit-menu-item-description-<?php echo $item_id; ?>"> |
233 | - <?php _e( 'Description' ); ?><br /> |
|
234 | - <textarea id="edit-menu-item-description-<?php echo $item_id; ?>" class="widefat edit-menu-item-description" rows="3" cols="20" name="menu-item-description[<?php echo $item_id; ?>]"><?php echo esc_html( $menu_item->description ); // textarea_escaped ?></textarea> |
|
235 | - <span class="description"><?php _e( 'The description will be displayed in the menu if the active theme supports it.' ); ?></span> |
|
233 | + <?php _e('Description'); ?><br /> |
|
234 | + <textarea id="edit-menu-item-description-<?php echo $item_id; ?>" class="widefat edit-menu-item-description" rows="3" cols="20" name="menu-item-description[<?php echo $item_id; ?>]"><?php echo esc_html($menu_item->description); // textarea_escaped ?></textarea> |
|
235 | + <span class="description"><?php _e('The description will be displayed in the menu if the active theme supports it.'); ?></span> |
|
236 | 236 | </label> |
237 | 237 | </p> |
238 | 238 | |
@@ -248,24 +248,24 @@ discard block |
||
248 | 248 | * @param stdClass|null $args An object of menu item arguments. |
249 | 249 | * @param int $current_object_id Nav menu ID. |
250 | 250 | */ |
251 | - do_action( 'wp_nav_menu_item_custom_fields', $item_id, $menu_item, $depth, $args, $current_object_id ); |
|
251 | + do_action('wp_nav_menu_item_custom_fields', $item_id, $menu_item, $depth, $args, $current_object_id); |
|
252 | 252 | ?> |
253 | 253 | |
254 | 254 | <fieldset class="field-move hide-if-no-js description description-wide"> |
255 | - <span class="field-move-visual-label" aria-hidden="true"><?php _e( 'Move' ); ?></span> |
|
256 | - <button type="button" class="button-link menus-move menus-move-up" data-dir="up"><?php _e( 'Up one' ); ?></button> |
|
257 | - <button type="button" class="button-link menus-move menus-move-down" data-dir="down"><?php _e( 'Down one' ); ?></button> |
|
255 | + <span class="field-move-visual-label" aria-hidden="true"><?php _e('Move'); ?></span> |
|
256 | + <button type="button" class="button-link menus-move menus-move-up" data-dir="up"><?php _e('Up one'); ?></button> |
|
257 | + <button type="button" class="button-link menus-move menus-move-down" data-dir="down"><?php _e('Down one'); ?></button> |
|
258 | 258 | <button type="button" class="button-link menus-move menus-move-left" data-dir="left"></button> |
259 | 259 | <button type="button" class="button-link menus-move menus-move-right" data-dir="right"></button> |
260 | - <button type="button" class="button-link menus-move menus-move-top" data-dir="top"><?php _e( 'To the top' ); ?></button> |
|
260 | + <button type="button" class="button-link menus-move menus-move-top" data-dir="top"><?php _e('To the top'); ?></button> |
|
261 | 261 | </fieldset> |
262 | 262 | |
263 | 263 | <div class="menu-item-actions description-wide submitbox"> |
264 | - <?php if ( 'custom' !== $menu_item->type && false !== $original_title ) : ?> |
|
264 | + <?php if ('custom' !== $menu_item->type && false !== $original_title) : ?> |
|
265 | 265 | <p class="link-to-original"> |
266 | 266 | <?php |
267 | 267 | /* translators: %s: Link to menu item's original object. */ |
268 | - printf( __( 'Original: %s' ), '<a href="' . esc_attr( $menu_item->url ) . '">' . esc_html( $original_title ) . '</a>' ); |
|
268 | + printf(__('Original: %s'), '<a href="' . esc_attr($menu_item->url) . '">' . esc_html($original_title) . '</a>'); |
|
269 | 269 | ?> |
270 | 270 | </p> |
271 | 271 | <?php endif; ?> |
@@ -280,11 +280,11 @@ discard block |
||
280 | 280 | 'action' => 'delete-menu-item', |
281 | 281 | 'menu-item' => $item_id, |
282 | 282 | ), |
283 | - admin_url( 'nav-menus.php' ) |
|
283 | + admin_url('nav-menus.php') |
|
284 | 284 | ), |
285 | 285 | 'delete-menu_item_' . $item_id |
286 | 286 | ), |
287 | - __( 'Remove' ) |
|
287 | + __('Remove') |
|
288 | 288 | ); |
289 | 289 | ?> |
290 | 290 | <span class="meta-sep hide-if-no-js"> | </span> |
@@ -298,21 +298,21 @@ discard block |
||
298 | 298 | 'edit-menu-item' => $item_id, |
299 | 299 | 'cancel' => time(), |
300 | 300 | ), |
301 | - admin_url( 'nav-menus.php' ) |
|
301 | + admin_url('nav-menus.php') |
|
302 | 302 | ) |
303 | 303 | ), |
304 | 304 | $item_id, |
305 | - __( 'Cancel' ) |
|
305 | + __('Cancel') |
|
306 | 306 | ); |
307 | 307 | ?> |
308 | 308 | </div> |
309 | 309 | |
310 | 310 | <input class="menu-item-data-db-id" type="hidden" name="menu-item-db-id[<?php echo $item_id; ?>]" value="<?php echo $item_id; ?>" /> |
311 | - <input class="menu-item-data-object-id" type="hidden" name="menu-item-object-id[<?php echo $item_id; ?>]" value="<?php echo esc_attr( $menu_item->object_id ); ?>" /> |
|
312 | - <input class="menu-item-data-object" type="hidden" name="menu-item-object[<?php echo $item_id; ?>]" value="<?php echo esc_attr( $menu_item->object ); ?>" /> |
|
313 | - <input class="menu-item-data-parent-id" type="hidden" name="menu-item-parent-id[<?php echo $item_id; ?>]" value="<?php echo esc_attr( $menu_item->menu_item_parent ); ?>" /> |
|
314 | - <input class="menu-item-data-position" type="hidden" name="menu-item-position[<?php echo $item_id; ?>]" value="<?php echo esc_attr( $menu_item->menu_order ); ?>" /> |
|
315 | - <input class="menu-item-data-type" type="hidden" name="menu-item-type[<?php echo $item_id; ?>]" value="<?php echo esc_attr( $menu_item->type ); ?>" /> |
|
311 | + <input class="menu-item-data-object-id" type="hidden" name="menu-item-object-id[<?php echo $item_id; ?>]" value="<?php echo esc_attr($menu_item->object_id); ?>" /> |
|
312 | + <input class="menu-item-data-object" type="hidden" name="menu-item-object[<?php echo $item_id; ?>]" value="<?php echo esc_attr($menu_item->object); ?>" /> |
|
313 | + <input class="menu-item-data-parent-id" type="hidden" name="menu-item-parent-id[<?php echo $item_id; ?>]" value="<?php echo esc_attr($menu_item->menu_item_parent); ?>" /> |
|
314 | + <input class="menu-item-data-position" type="hidden" name="menu-item-position[<?php echo $item_id; ?>]" value="<?php echo esc_attr($menu_item->menu_order); ?>" /> |
|
315 | + <input class="menu-item-data-type" type="hidden" name="menu-item-type[<?php echo $item_id; ?>]" value="<?php echo esc_attr($menu_item->type); ?>" /> |
|
316 | 316 | </div><!-- .menu-item-settings--> |
317 | 317 | <ul class="menu-item-transport"></ul> |
318 | 318 | <?php |
@@ -43,31 +43,31 @@ discard block |
||
43 | 43 | * |
44 | 44 | * @param array $args An associative array of arguments. |
45 | 45 | */ |
46 | - public function __construct( $args = array() ) { |
|
46 | + public function __construct($args = array()) { |
|
47 | 47 | global $status, $page; |
48 | 48 | |
49 | 49 | parent::__construct( |
50 | 50 | array( |
51 | 51 | 'plural' => 'themes', |
52 | - 'screen' => isset( $args['screen'] ) ? $args['screen'] : null, |
|
52 | + 'screen' => isset($args['screen']) ? $args['screen'] : null, |
|
53 | 53 | ) |
54 | 54 | ); |
55 | 55 | |
56 | - $status = isset( $_REQUEST['theme_status'] ) ? $_REQUEST['theme_status'] : 'all'; |
|
57 | - if ( ! in_array( $status, array( 'all', 'enabled', 'disabled', 'upgrade', 'search', 'broken', 'auto-update-enabled', 'auto-update-disabled' ), true ) ) { |
|
56 | + $status = isset($_REQUEST['theme_status']) ? $_REQUEST['theme_status'] : 'all'; |
|
57 | + if (!in_array($status, array('all', 'enabled', 'disabled', 'upgrade', 'search', 'broken', 'auto-update-enabled', 'auto-update-disabled'), true)) { |
|
58 | 58 | $status = 'all'; |
59 | 59 | } |
60 | 60 | |
61 | 61 | $page = $this->get_pagenum(); |
62 | 62 | |
63 | - $this->is_site_themes = ( 'site-themes-network' === $this->screen->id ) ? true : false; |
|
63 | + $this->is_site_themes = ('site-themes-network' === $this->screen->id) ? true : false; |
|
64 | 64 | |
65 | - if ( $this->is_site_themes ) { |
|
66 | - $this->site_id = isset( $_REQUEST['id'] ) ? (int) $_REQUEST['id'] : 0; |
|
65 | + if ($this->is_site_themes) { |
|
66 | + $this->site_id = isset($_REQUEST['id']) ? (int) $_REQUEST['id'] : 0; |
|
67 | 67 | } |
68 | 68 | |
69 | - $this->show_autoupdates = wp_is_auto_update_enabled_for_type( 'theme' ) && |
|
70 | - ! $this->is_site_themes && current_user_can( 'update_themes' ); |
|
69 | + $this->show_autoupdates = wp_is_auto_update_enabled_for_type('theme') && |
|
70 | + !$this->is_site_themes && current_user_can('update_themes'); |
|
71 | 71 | } |
72 | 72 | |
73 | 73 | /** |
@@ -75,17 +75,17 @@ discard block |
||
75 | 75 | */ |
76 | 76 | protected function get_table_classes() { |
77 | 77 | // @todo Remove and add CSS for .themes. |
78 | - return array( 'widefat', 'plugins' ); |
|
78 | + return array('widefat', 'plugins'); |
|
79 | 79 | } |
80 | 80 | |
81 | 81 | /** |
82 | 82 | * @return bool |
83 | 83 | */ |
84 | 84 | public function ajax_user_can() { |
85 | - if ( $this->is_site_themes ) { |
|
86 | - return current_user_can( 'manage_sites' ); |
|
85 | + if ($this->is_site_themes) { |
|
86 | + return current_user_can('manage_sites'); |
|
87 | 87 | } else { |
88 | - return current_user_can( 'manage_network_themes' ); |
|
88 | + return current_user_can('manage_network_themes'); |
|
89 | 89 | } |
90 | 90 | } |
91 | 91 | |
@@ -100,7 +100,7 @@ discard block |
||
100 | 100 | public function prepare_items() { |
101 | 101 | global $status, $totals, $page, $orderby, $order, $s; |
102 | 102 | |
103 | - wp_reset_vars( array( 'orderby', 'order', 's' ) ); |
|
103 | + wp_reset_vars(array('orderby', 'order', 's')); |
|
104 | 104 | |
105 | 105 | $themes = array( |
106 | 106 | /** |
@@ -111,55 +111,55 @@ discard block |
||
111 | 111 | * |
112 | 112 | * @param WP_Theme[] $all Array of WP_Theme objects to display in the list table. |
113 | 113 | */ |
114 | - 'all' => apply_filters( 'all_themes', wp_get_themes() ), |
|
114 | + 'all' => apply_filters('all_themes', wp_get_themes()), |
|
115 | 115 | 'search' => array(), |
116 | 116 | 'enabled' => array(), |
117 | 117 | 'disabled' => array(), |
118 | 118 | 'upgrade' => array(), |
119 | - 'broken' => $this->is_site_themes ? array() : wp_get_themes( array( 'errors' => true ) ), |
|
119 | + 'broken' => $this->is_site_themes ? array() : wp_get_themes(array('errors' => true)), |
|
120 | 120 | ); |
121 | 121 | |
122 | - if ( $this->show_autoupdates ) { |
|
123 | - $auto_updates = (array) get_site_option( 'auto_update_themes', array() ); |
|
122 | + if ($this->show_autoupdates) { |
|
123 | + $auto_updates = (array) get_site_option('auto_update_themes', array()); |
|
124 | 124 | |
125 | 125 | $themes['auto-update-enabled'] = array(); |
126 | 126 | $themes['auto-update-disabled'] = array(); |
127 | 127 | } |
128 | 128 | |
129 | - if ( $this->is_site_themes ) { |
|
130 | - $themes_per_page = $this->get_items_per_page( 'site_themes_network_per_page' ); |
|
129 | + if ($this->is_site_themes) { |
|
130 | + $themes_per_page = $this->get_items_per_page('site_themes_network_per_page'); |
|
131 | 131 | $allowed_where = 'site'; |
132 | 132 | } else { |
133 | - $themes_per_page = $this->get_items_per_page( 'themes_network_per_page' ); |
|
133 | + $themes_per_page = $this->get_items_per_page('themes_network_per_page'); |
|
134 | 134 | $allowed_where = 'network'; |
135 | 135 | } |
136 | 136 | |
137 | - $current = get_site_transient( 'update_themes' ); |
|
138 | - $maybe_update = current_user_can( 'update_themes' ) && ! $this->is_site_themes && $current; |
|
137 | + $current = get_site_transient('update_themes'); |
|
138 | + $maybe_update = current_user_can('update_themes') && !$this->is_site_themes && $current; |
|
139 | 139 | |
140 | - foreach ( (array) $themes['all'] as $key => $theme ) { |
|
141 | - if ( $this->is_site_themes && $theme->is_allowed( 'network' ) ) { |
|
142 | - unset( $themes['all'][ $key ] ); |
|
140 | + foreach ((array) $themes['all'] as $key => $theme) { |
|
141 | + if ($this->is_site_themes && $theme->is_allowed('network')) { |
|
142 | + unset($themes['all'][$key]); |
|
143 | 143 | continue; |
144 | 144 | } |
145 | 145 | |
146 | - if ( $maybe_update && isset( $current->response[ $key ] ) ) { |
|
147 | - $themes['all'][ $key ]->update = true; |
|
148 | - $themes['upgrade'][ $key ] = $themes['all'][ $key ]; |
|
146 | + if ($maybe_update && isset($current->response[$key])) { |
|
147 | + $themes['all'][$key]->update = true; |
|
148 | + $themes['upgrade'][$key] = $themes['all'][$key]; |
|
149 | 149 | } |
150 | 150 | |
151 | - $filter = $theme->is_allowed( $allowed_where, $this->site_id ) ? 'enabled' : 'disabled'; |
|
152 | - $themes[ $filter ][ $key ] = $themes['all'][ $key ]; |
|
151 | + $filter = $theme->is_allowed($allowed_where, $this->site_id) ? 'enabled' : 'disabled'; |
|
152 | + $themes[$filter][$key] = $themes['all'][$key]; |
|
153 | 153 | |
154 | 154 | $theme_data = array( |
155 | - 'update_supported' => isset( $theme->update_supported ) ? $theme->update_supported : true, |
|
155 | + 'update_supported' => isset($theme->update_supported) ? $theme->update_supported : true, |
|
156 | 156 | ); |
157 | 157 | |
158 | 158 | // Extra info if known. array_merge() ensures $theme_data has precedence if keys collide. |
159 | - if ( isset( $current->response[ $key ] ) ) { |
|
160 | - $theme_data = array_merge( (array) $current->response[ $key ], $theme_data ); |
|
161 | - } elseif ( isset( $current->no_update[ $key ] ) ) { |
|
162 | - $theme_data = array_merge( (array) $current->no_update[ $key ], $theme_data ); |
|
159 | + if (isset($current->response[$key])) { |
|
160 | + $theme_data = array_merge((array) $current->response[$key], $theme_data); |
|
161 | + } elseif (isset($current->no_update[$key])) { |
|
162 | + $theme_data = array_merge((array) $current->no_update[$key], $theme_data); |
|
163 | 163 | } else { |
164 | 164 | $theme_data['update_supported'] = false; |
165 | 165 | } |
@@ -179,49 +179,49 @@ discard block |
||
179 | 179 | 'requires_php' => '', |
180 | 180 | ); |
181 | 181 | |
182 | - $filter_payload = (object) array_merge( $filter_payload, array_intersect_key( $theme_data, $filter_payload ) ); |
|
182 | + $filter_payload = (object) array_merge($filter_payload, array_intersect_key($theme_data, $filter_payload)); |
|
183 | 183 | |
184 | - $auto_update_forced = wp_is_auto_update_forced_for_item( 'theme', null, $filter_payload ); |
|
184 | + $auto_update_forced = wp_is_auto_update_forced_for_item('theme', null, $filter_payload); |
|
185 | 185 | |
186 | - if ( ! is_null( $auto_update_forced ) ) { |
|
186 | + if (!is_null($auto_update_forced)) { |
|
187 | 187 | $theme->auto_update_forced = $auto_update_forced; |
188 | 188 | } |
189 | 189 | |
190 | - if ( $this->show_autoupdates ) { |
|
191 | - $enabled = in_array( $key, $auto_updates, true ) && $theme->update_supported; |
|
192 | - if ( isset( $theme->auto_update_forced ) ) { |
|
190 | + if ($this->show_autoupdates) { |
|
191 | + $enabled = in_array($key, $auto_updates, true) && $theme->update_supported; |
|
192 | + if (isset($theme->auto_update_forced)) { |
|
193 | 193 | $enabled = (bool) $theme->auto_update_forced; |
194 | 194 | } |
195 | 195 | |
196 | - if ( $enabled ) { |
|
197 | - $themes['auto-update-enabled'][ $key ] = $theme; |
|
196 | + if ($enabled) { |
|
197 | + $themes['auto-update-enabled'][$key] = $theme; |
|
198 | 198 | } else { |
199 | - $themes['auto-update-disabled'][ $key ] = $theme; |
|
199 | + $themes['auto-update-disabled'][$key] = $theme; |
|
200 | 200 | } |
201 | 201 | } |
202 | 202 | } |
203 | 203 | |
204 | - if ( $s ) { |
|
204 | + if ($s) { |
|
205 | 205 | $status = 'search'; |
206 | - $themes['search'] = array_filter( array_merge( $themes['all'], $themes['broken'] ), array( $this, '_search_callback' ) ); |
|
206 | + $themes['search'] = array_filter(array_merge($themes['all'], $themes['broken']), array($this, '_search_callback')); |
|
207 | 207 | } |
208 | 208 | |
209 | 209 | $totals = array(); |
210 | 210 | $js_themes = array(); |
211 | - foreach ( $themes as $type => $list ) { |
|
212 | - $totals[ $type ] = count( $list ); |
|
213 | - $js_themes[ $type ] = array_keys( $list ); |
|
211 | + foreach ($themes as $type => $list) { |
|
212 | + $totals[$type] = count($list); |
|
213 | + $js_themes[$type] = array_keys($list); |
|
214 | 214 | } |
215 | 215 | |
216 | - if ( empty( $themes[ $status ] ) && ! in_array( $status, array( 'all', 'search' ), true ) ) { |
|
216 | + if (empty($themes[$status]) && !in_array($status, array('all', 'search'), true)) { |
|
217 | 217 | $status = 'all'; |
218 | 218 | } |
219 | 219 | |
220 | - $this->items = $themes[ $status ]; |
|
221 | - WP_Theme::sort_by_name( $this->items ); |
|
220 | + $this->items = $themes[$status]; |
|
221 | + WP_Theme::sort_by_name($this->items); |
|
222 | 222 | |
223 | - $this->has_items = ! empty( $themes['all'] ); |
|
224 | - $total_this_page = $totals[ $status ]; |
|
223 | + $this->has_items = !empty($themes['all']); |
|
224 | + $total_this_page = $totals[$status]; |
|
225 | 225 | |
226 | 226 | wp_localize_script( |
227 | 227 | 'updates', |
@@ -232,23 +232,23 @@ discard block |
||
232 | 232 | ) |
233 | 233 | ); |
234 | 234 | |
235 | - if ( $orderby ) { |
|
236 | - $orderby = ucfirst( $orderby ); |
|
237 | - $order = strtoupper( $order ); |
|
235 | + if ($orderby) { |
|
236 | + $orderby = ucfirst($orderby); |
|
237 | + $order = strtoupper($order); |
|
238 | 238 | |
239 | - if ( 'Name' === $orderby ) { |
|
240 | - if ( 'ASC' === $order ) { |
|
241 | - $this->items = array_reverse( $this->items ); |
|
239 | + if ('Name' === $orderby) { |
|
240 | + if ('ASC' === $order) { |
|
241 | + $this->items = array_reverse($this->items); |
|
242 | 242 | } |
243 | 243 | } else { |
244 | - uasort( $this->items, array( $this, '_order_callback' ) ); |
|
244 | + uasort($this->items, array($this, '_order_callback')); |
|
245 | 245 | } |
246 | 246 | } |
247 | 247 | |
248 | - $start = ( $page - 1 ) * $themes_per_page; |
|
248 | + $start = ($page - 1) * $themes_per_page; |
|
249 | 249 | |
250 | - if ( $total_this_page > $themes_per_page ) { |
|
251 | - $this->items = array_slice( $this->items, $start, $themes_per_page, true ); |
|
250 | + if ($total_this_page > $themes_per_page) { |
|
251 | + $this->items = array_slice($this->items, $start, $themes_per_page, true); |
|
252 | 252 | } |
253 | 253 | |
254 | 254 | $this->set_pagination_args( |
@@ -263,24 +263,24 @@ discard block |
||
263 | 263 | * @param WP_Theme $theme |
264 | 264 | * @return bool |
265 | 265 | */ |
266 | - public function _search_callback( $theme ) { |
|
266 | + public function _search_callback($theme) { |
|
267 | 267 | static $term = null; |
268 | - if ( is_null( $term ) ) { |
|
269 | - $term = wp_unslash( $_REQUEST['s'] ); |
|
268 | + if (is_null($term)) { |
|
269 | + $term = wp_unslash($_REQUEST['s']); |
|
270 | 270 | } |
271 | 271 | |
272 | - foreach ( array( 'Name', 'Description', 'Author', 'Author', 'AuthorURI' ) as $field ) { |
|
272 | + foreach (array('Name', 'Description', 'Author', 'Author', 'AuthorURI') as $field) { |
|
273 | 273 | // Don't mark up; Do translate. |
274 | - if ( false !== stripos( $theme->display( $field, false, true ), $term ) ) { |
|
274 | + if (false !== stripos($theme->display($field, false, true), $term)) { |
|
275 | 275 | return true; |
276 | 276 | } |
277 | 277 | } |
278 | 278 | |
279 | - if ( false !== stripos( $theme->get_stylesheet(), $term ) ) { |
|
279 | + if (false !== stripos($theme->get_stylesheet(), $term)) { |
|
280 | 280 | return true; |
281 | 281 | } |
282 | 282 | |
283 | - if ( false !== stripos( $theme->get_template(), $term ) ) { |
|
283 | + if (false !== stripos($theme->get_template(), $term)) { |
|
284 | 284 | return true; |
285 | 285 | } |
286 | 286 | |
@@ -295,30 +295,30 @@ discard block |
||
295 | 295 | * @param array $theme_b |
296 | 296 | * @return int |
297 | 297 | */ |
298 | - public function _order_callback( $theme_a, $theme_b ) { |
|
298 | + public function _order_callback($theme_a, $theme_b) { |
|
299 | 299 | global $orderby, $order; |
300 | 300 | |
301 | - $a = $theme_a[ $orderby ]; |
|
302 | - $b = $theme_b[ $orderby ]; |
|
301 | + $a = $theme_a[$orderby]; |
|
302 | + $b = $theme_b[$orderby]; |
|
303 | 303 | |
304 | - if ( $a === $b ) { |
|
304 | + if ($a === $b) { |
|
305 | 305 | return 0; |
306 | 306 | } |
307 | 307 | |
308 | - if ( 'DESC' === $order ) { |
|
309 | - return ( $a < $b ) ? 1 : -1; |
|
308 | + if ('DESC' === $order) { |
|
309 | + return ($a < $b) ? 1 : -1; |
|
310 | 310 | } else { |
311 | - return ( $a < $b ) ? -1 : 1; |
|
311 | + return ($a < $b) ? -1 : 1; |
|
312 | 312 | } |
313 | 313 | } |
314 | 314 | |
315 | 315 | /** |
316 | 316 | */ |
317 | 317 | public function no_items() { |
318 | - if ( $this->has_items ) { |
|
319 | - _e( 'No themes found.' ); |
|
318 | + if ($this->has_items) { |
|
319 | + _e('No themes found.'); |
|
320 | 320 | } else { |
321 | - _e( 'No themes are currently available.' ); |
|
321 | + _e('No themes are currently available.'); |
|
322 | 322 | } |
323 | 323 | } |
324 | 324 | |
@@ -328,12 +328,12 @@ discard block |
||
328 | 328 | public function get_columns() { |
329 | 329 | $columns = array( |
330 | 330 | 'cb' => '<input type="checkbox" />', |
331 | - 'name' => __( 'Theme' ), |
|
332 | - 'description' => __( 'Description' ), |
|
331 | + 'name' => __('Theme'), |
|
332 | + 'description' => __('Description'), |
|
333 | 333 | ); |
334 | 334 | |
335 | - if ( $this->show_autoupdates ) { |
|
336 | - $columns['auto-updates'] = __( 'Automatic Updates' ); |
|
335 | + if ($this->show_autoupdates) { |
|
336 | + $columns['auto-updates'] = __('Automatic Updates'); |
|
337 | 337 | } |
338 | 338 | |
339 | 339 | return $columns; |
@@ -368,12 +368,12 @@ discard block |
||
368 | 368 | global $totals, $status; |
369 | 369 | |
370 | 370 | $status_links = array(); |
371 | - foreach ( $totals as $type => $count ) { |
|
372 | - if ( ! $count ) { |
|
371 | + foreach ($totals as $type => $count) { |
|
372 | + if (!$count) { |
|
373 | 373 | continue; |
374 | 374 | } |
375 | 375 | |
376 | - switch ( $type ) { |
|
376 | + switch ($type) { |
|
377 | 377 | case 'all': |
378 | 378 | /* translators: %s: Number of themes. */ |
379 | 379 | $text = _nx( |
@@ -437,18 +437,18 @@ discard block |
||
437 | 437 | break; |
438 | 438 | } |
439 | 439 | |
440 | - if ( $this->is_site_themes ) { |
|
440 | + if ($this->is_site_themes) { |
|
441 | 441 | $url = 'site-themes.php?id=' . $this->site_id; |
442 | 442 | } else { |
443 | 443 | $url = 'themes.php'; |
444 | 444 | } |
445 | 445 | |
446 | - if ( 'search' !== $type ) { |
|
447 | - $status_links[ $type ] = sprintf( |
|
446 | + if ('search' !== $type) { |
|
447 | + $status_links[$type] = sprintf( |
|
448 | 448 | "<a href='%s'%s>%s</a>", |
449 | - esc_url( add_query_arg( 'theme_status', $type, $url ) ), |
|
450 | - ( $type === $status ) ? ' class="current" aria-current="page"' : '', |
|
451 | - sprintf( $text, number_format_i18n( $count ) ) |
|
449 | + esc_url(add_query_arg('theme_status', $type, $url)), |
|
450 | + ($type === $status) ? ' class="current" aria-current="page"' : '', |
|
451 | + sprintf($text, number_format_i18n($count)) |
|
452 | 452 | ); |
453 | 453 | } |
454 | 454 | } |
@@ -465,28 +465,28 @@ discard block |
||
465 | 465 | global $status; |
466 | 466 | |
467 | 467 | $actions = array(); |
468 | - if ( 'enabled' !== $status ) { |
|
469 | - $actions['enable-selected'] = $this->is_site_themes ? __( 'Enable' ) : __( 'Network Enable' ); |
|
468 | + if ('enabled' !== $status) { |
|
469 | + $actions['enable-selected'] = $this->is_site_themes ? __('Enable') : __('Network Enable'); |
|
470 | 470 | } |
471 | - if ( 'disabled' !== $status ) { |
|
472 | - $actions['disable-selected'] = $this->is_site_themes ? __( 'Disable' ) : __( 'Network Disable' ); |
|
471 | + if ('disabled' !== $status) { |
|
472 | + $actions['disable-selected'] = $this->is_site_themes ? __('Disable') : __('Network Disable'); |
|
473 | 473 | } |
474 | - if ( ! $this->is_site_themes ) { |
|
475 | - if ( current_user_can( 'update_themes' ) ) { |
|
476 | - $actions['update-selected'] = __( 'Update' ); |
|
474 | + if (!$this->is_site_themes) { |
|
475 | + if (current_user_can('update_themes')) { |
|
476 | + $actions['update-selected'] = __('Update'); |
|
477 | 477 | } |
478 | - if ( current_user_can( 'delete_themes' ) ) { |
|
479 | - $actions['delete-selected'] = __( 'Delete' ); |
|
478 | + if (current_user_can('delete_themes')) { |
|
479 | + $actions['delete-selected'] = __('Delete'); |
|
480 | 480 | } |
481 | 481 | } |
482 | 482 | |
483 | - if ( $this->show_autoupdates ) { |
|
484 | - if ( 'auto-update-enabled' !== $status ) { |
|
485 | - $actions['enable-auto-update-selected'] = __( 'Enable Auto-updates' ); |
|
483 | + if ($this->show_autoupdates) { |
|
484 | + if ('auto-update-enabled' !== $status) { |
|
485 | + $actions['enable-auto-update-selected'] = __('Enable Auto-updates'); |
|
486 | 486 | } |
487 | 487 | |
488 | - if ( 'auto-update-disabled' !== $status ) { |
|
489 | - $actions['disable-auto-update-selected'] = __( 'Disable Auto-updates' ); |
|
488 | + if ('auto-update-disabled' !== $status) { |
|
489 | + $actions['disable-auto-update-selected'] = __('Disable Auto-updates'); |
|
490 | 490 | } |
491 | 491 | } |
492 | 492 | |
@@ -496,8 +496,8 @@ discard block |
||
496 | 496 | /** |
497 | 497 | */ |
498 | 498 | public function display_rows() { |
499 | - foreach ( $this->items as $theme ) { |
|
500 | - $this->single_row( $theme ); |
|
499 | + foreach ($this->items as $theme) { |
|
500 | + $this->single_row($theme); |
|
501 | 501 | } |
502 | 502 | } |
503 | 503 | |
@@ -509,13 +509,13 @@ discard block |
||
509 | 509 | * |
510 | 510 | * @param WP_Theme $item The current WP_Theme object. |
511 | 511 | */ |
512 | - public function column_cb( $item ) { |
|
512 | + public function column_cb($item) { |
|
513 | 513 | // Restores the more descriptive, specific name for use within this method. |
514 | 514 | $theme = $item; |
515 | - $checkbox_id = 'checkbox_' . md5( $theme->get( 'Name' ) ); |
|
515 | + $checkbox_id = 'checkbox_' . md5($theme->get('Name')); |
|
516 | 516 | ?> |
517 | - <input type="checkbox" name="checked[]" value="<?php echo esc_attr( $theme->get_stylesheet() ); ?>" id="<?php echo $checkbox_id; ?>" /> |
|
518 | - <label class="screen-reader-text" for="<?php echo $checkbox_id; ?>" ><?php _e( 'Select' ); ?> <?php echo $theme->display( 'Name' ); ?></label> |
|
517 | + <input type="checkbox" name="checked[]" value="<?php echo esc_attr($theme->get_stylesheet()); ?>" id="<?php echo $checkbox_id; ?>" /> |
|
518 | + <label class="screen-reader-text" for="<?php echo $checkbox_id; ?>" ><?php _e('Select'); ?> <?php echo $theme->display('Name'); ?></label> |
|
519 | 519 | <?php |
520 | 520 | } |
521 | 521 | |
@@ -530,17 +530,17 @@ discard block |
||
530 | 530 | * |
531 | 531 | * @param WP_Theme $theme The current WP_Theme object. |
532 | 532 | */ |
533 | - public function column_name( $theme ) { |
|
533 | + public function column_name($theme) { |
|
534 | 534 | global $status, $page, $s; |
535 | 535 | |
536 | 536 | $context = $status; |
537 | 537 | |
538 | - if ( $this->is_site_themes ) { |
|
538 | + if ($this->is_site_themes) { |
|
539 | 539 | $url = "site-themes.php?id={$this->site_id}&"; |
540 | - $allowed = $theme->is_allowed( 'site', $this->site_id ); |
|
540 | + $allowed = $theme->is_allowed('site', $this->site_id); |
|
541 | 541 | } else { |
542 | 542 | $url = 'themes.php?'; |
543 | - $allowed = $theme->is_allowed( 'network' ); |
|
543 | + $allowed = $theme->is_allowed('network'); |
|
544 | 544 | } |
545 | 545 | |
546 | 546 | // Pre-order. |
@@ -551,10 +551,10 @@ discard block |
||
551 | 551 | ); |
552 | 552 | |
553 | 553 | $stylesheet = $theme->get_stylesheet(); |
554 | - $theme_key = urlencode( $stylesheet ); |
|
554 | + $theme_key = urlencode($stylesheet); |
|
555 | 555 | |
556 | - if ( ! $allowed ) { |
|
557 | - if ( ! $theme->errors() ) { |
|
556 | + if (!$allowed) { |
|
557 | + if (!$theme->errors()) { |
|
558 | 558 | $url = add_query_arg( |
559 | 559 | array( |
560 | 560 | 'action' => 'enable', |
@@ -565,19 +565,19 @@ discard block |
||
565 | 565 | $url |
566 | 566 | ); |
567 | 567 | |
568 | - if ( $this->is_site_themes ) { |
|
568 | + if ($this->is_site_themes) { |
|
569 | 569 | /* translators: %s: Theme name. */ |
570 | - $aria_label = sprintf( __( 'Enable %s' ), $theme->display( 'Name' ) ); |
|
570 | + $aria_label = sprintf(__('Enable %s'), $theme->display('Name')); |
|
571 | 571 | } else { |
572 | 572 | /* translators: %s: Theme name. */ |
573 | - $aria_label = sprintf( __( 'Network Enable %s' ), $theme->display( 'Name' ) ); |
|
573 | + $aria_label = sprintf(__('Network Enable %s'), $theme->display('Name')); |
|
574 | 574 | } |
575 | 575 | |
576 | 576 | $actions['enable'] = sprintf( |
577 | 577 | '<a href="%s" class="edit" aria-label="%s">%s</a>', |
578 | - esc_url( wp_nonce_url( $url, 'enable-theme_' . $stylesheet ) ), |
|
579 | - esc_attr( $aria_label ), |
|
580 | - ( $this->is_site_themes ? __( 'Enable' ) : __( 'Network Enable' ) ) |
|
578 | + esc_url(wp_nonce_url($url, 'enable-theme_' . $stylesheet)), |
|
579 | + esc_attr($aria_label), |
|
580 | + ($this->is_site_themes ? __('Enable') : __('Network Enable')) |
|
581 | 581 | ); |
582 | 582 | } |
583 | 583 | } else { |
@@ -591,26 +591,26 @@ discard block |
||
591 | 591 | $url |
592 | 592 | ); |
593 | 593 | |
594 | - if ( $this->is_site_themes ) { |
|
594 | + if ($this->is_site_themes) { |
|
595 | 595 | /* translators: %s: Theme name. */ |
596 | - $aria_label = sprintf( __( 'Disable %s' ), $theme->display( 'Name' ) ); |
|
596 | + $aria_label = sprintf(__('Disable %s'), $theme->display('Name')); |
|
597 | 597 | } else { |
598 | 598 | /* translators: %s: Theme name. */ |
599 | - $aria_label = sprintf( __( 'Network Disable %s' ), $theme->display( 'Name' ) ); |
|
599 | + $aria_label = sprintf(__('Network Disable %s'), $theme->display('Name')); |
|
600 | 600 | } |
601 | 601 | |
602 | 602 | $actions['disable'] = sprintf( |
603 | 603 | '<a href="%s" aria-label="%s">%s</a>', |
604 | - esc_url( wp_nonce_url( $url, 'disable-theme_' . $stylesheet ) ), |
|
605 | - esc_attr( $aria_label ), |
|
606 | - ( $this->is_site_themes ? __( 'Disable' ) : __( 'Network Disable' ) ) |
|
604 | + esc_url(wp_nonce_url($url, 'disable-theme_' . $stylesheet)), |
|
605 | + esc_attr($aria_label), |
|
606 | + ($this->is_site_themes ? __('Disable') : __('Network Disable')) |
|
607 | 607 | ); |
608 | 608 | } |
609 | 609 | |
610 | - if ( ! $allowed && ! $this->is_site_themes |
|
611 | - && current_user_can( 'delete_themes' ) |
|
612 | - && get_option( 'stylesheet' ) !== $stylesheet |
|
613 | - && get_option( 'template' ) !== $stylesheet |
|
610 | + if (!$allowed && !$this->is_site_themes |
|
611 | + && current_user_can('delete_themes') |
|
612 | + && get_option('stylesheet') !== $stylesheet |
|
613 | + && get_option('template') !== $stylesheet |
|
614 | 614 | ) { |
615 | 615 | $url = add_query_arg( |
616 | 616 | array( |
@@ -624,13 +624,13 @@ discard block |
||
624 | 624 | ); |
625 | 625 | |
626 | 626 | /* translators: %s: Theme name. */ |
627 | - $aria_label = sprintf( _x( 'Delete %s', 'theme' ), $theme->display( 'Name' ) ); |
|
627 | + $aria_label = sprintf(_x('Delete %s', 'theme'), $theme->display('Name')); |
|
628 | 628 | |
629 | 629 | $actions['delete'] = sprintf( |
630 | 630 | '<a href="%s" class="delete" aria-label="%s">%s</a>', |
631 | - esc_url( wp_nonce_url( $url, 'bulk-themes' ) ), |
|
632 | - esc_attr( $aria_label ), |
|
633 | - __( 'Delete' ) |
|
631 | + esc_url(wp_nonce_url($url, 'bulk-themes')), |
|
632 | + esc_attr($aria_label), |
|
633 | + __('Delete') |
|
634 | 634 | ); |
635 | 635 | } |
636 | 636 | /** |
@@ -655,7 +655,7 @@ discard block |
||
655 | 655 | * @param WP_Theme $theme The current WP_Theme object. |
656 | 656 | * @param string $context Status of the theme, one of 'all', 'enabled', or 'disabled'. |
657 | 657 | */ |
658 | - $actions = apply_filters( 'theme_action_links', array_filter( $actions ), $theme, $context ); |
|
658 | + $actions = apply_filters('theme_action_links', array_filter($actions), $theme, $context); |
|
659 | 659 | |
660 | 660 | /** |
661 | 661 | * Filters the action links of a specific theme in the Multisite themes |
@@ -671,9 +671,9 @@ discard block |
||
671 | 671 | * @param WP_Theme $theme The current WP_Theme object. |
672 | 672 | * @param string $context Status of the theme, one of 'all', 'enabled', or 'disabled'. |
673 | 673 | */ |
674 | - $actions = apply_filters( "theme_action_links_{$stylesheet}", $actions, $theme, $context ); |
|
674 | + $actions = apply_filters("theme_action_links_{$stylesheet}", $actions, $theme, $context); |
|
675 | 675 | |
676 | - echo $this->row_actions( $actions, true ); |
|
676 | + echo $this->row_actions($actions, true); |
|
677 | 677 | } |
678 | 678 | |
679 | 679 | /** |
@@ -686,56 +686,56 @@ discard block |
||
686 | 686 | * |
687 | 687 | * @param WP_Theme $theme The current WP_Theme object. |
688 | 688 | */ |
689 | - public function column_description( $theme ) { |
|
689 | + public function column_description($theme) { |
|
690 | 690 | global $status, $totals; |
691 | 691 | |
692 | - if ( $theme->errors() ) { |
|
693 | - $pre = 'broken' === $status ? __( 'Broken Theme:' ) . ' ' : ''; |
|
692 | + if ($theme->errors()) { |
|
693 | + $pre = 'broken' === $status ? __('Broken Theme:') . ' ' : ''; |
|
694 | 694 | echo '<p><strong class="error-message">' . $pre . $theme->errors()->get_error_message() . '</strong></p>'; |
695 | 695 | } |
696 | 696 | |
697 | - if ( $this->is_site_themes ) { |
|
698 | - $allowed = $theme->is_allowed( 'site', $this->site_id ); |
|
697 | + if ($this->is_site_themes) { |
|
698 | + $allowed = $theme->is_allowed('site', $this->site_id); |
|
699 | 699 | } else { |
700 | - $allowed = $theme->is_allowed( 'network' ); |
|
700 | + $allowed = $theme->is_allowed('network'); |
|
701 | 701 | } |
702 | 702 | |
703 | - $class = ! $allowed ? 'inactive' : 'active'; |
|
704 | - if ( ! empty( $totals['upgrade'] ) && ! empty( $theme->update ) ) { |
|
703 | + $class = !$allowed ? 'inactive' : 'active'; |
|
704 | + if (!empty($totals['upgrade']) && !empty($theme->update)) { |
|
705 | 705 | $class .= ' update'; |
706 | 706 | } |
707 | 707 | |
708 | - echo "<div class='theme-description'><p>" . $theme->display( 'Description' ) . "</p></div> |
|
708 | + echo "<div class='theme-description'><p>" . $theme->display('Description') . "</p></div> |
|
709 | 709 | <div class='$class second theme-version-author-uri'>"; |
710 | 710 | |
711 | 711 | $stylesheet = $theme->get_stylesheet(); |
712 | 712 | $theme_meta = array(); |
713 | 713 | |
714 | - if ( $theme->get( 'Version' ) ) { |
|
714 | + if ($theme->get('Version')) { |
|
715 | 715 | /* translators: %s: Theme version. */ |
716 | - $theme_meta[] = sprintf( __( 'Version %s' ), $theme->display( 'Version' ) ); |
|
716 | + $theme_meta[] = sprintf(__('Version %s'), $theme->display('Version')); |
|
717 | 717 | } |
718 | 718 | |
719 | 719 | /* translators: %s: Theme author. */ |
720 | - $theme_meta[] = sprintf( __( 'By %s' ), $theme->display( 'Author' ) ); |
|
720 | + $theme_meta[] = sprintf(__('By %s'), $theme->display('Author')); |
|
721 | 721 | |
722 | - if ( $theme->get( 'ThemeURI' ) ) { |
|
722 | + if ($theme->get('ThemeURI')) { |
|
723 | 723 | /* translators: %s: Theme name. */ |
724 | - $aria_label = sprintf( __( 'Visit theme site for %s' ), $theme->display( 'Name' ) ); |
|
724 | + $aria_label = sprintf(__('Visit theme site for %s'), $theme->display('Name')); |
|
725 | 725 | |
726 | 726 | $theme_meta[] = sprintf( |
727 | 727 | '<a href="%s" aria-label="%s">%s</a>', |
728 | - $theme->display( 'ThemeURI' ), |
|
729 | - esc_attr( $aria_label ), |
|
730 | - __( 'Visit Theme Site' ) |
|
728 | + $theme->display('ThemeURI'), |
|
729 | + esc_attr($aria_label), |
|
730 | + __('Visit Theme Site') |
|
731 | 731 | ); |
732 | 732 | } |
733 | 733 | |
734 | - if ( $theme->parent() ) { |
|
734 | + if ($theme->parent()) { |
|
735 | 735 | $theme_meta[] = sprintf( |
736 | 736 | /* translators: %s: Theme name. */ |
737 | - __( 'Child theme of %s' ), |
|
738 | - '<strong>' . $theme->parent()->display( 'Name' ) . '</strong>' |
|
737 | + __('Child theme of %s'), |
|
738 | + '<strong>' . $theme->parent()->display('Name') . '</strong>' |
|
739 | 739 | ); |
740 | 740 | } |
741 | 741 | |
@@ -751,9 +751,9 @@ discard block |
||
751 | 751 | * @param WP_Theme $theme WP_Theme object. |
752 | 752 | * @param string $status Status of the theme. |
753 | 753 | */ |
754 | - $theme_meta = apply_filters( 'theme_row_meta', $theme_meta, $stylesheet, $theme, $status ); |
|
754 | + $theme_meta = apply_filters('theme_row_meta', $theme_meta, $stylesheet, $theme, $status); |
|
755 | 755 | |
756 | - echo implode( ' | ', $theme_meta ); |
|
756 | + echo implode(' | ', $theme_meta); |
|
757 | 757 | |
758 | 758 | echo '</div>'; |
759 | 759 | } |
@@ -768,39 +768,39 @@ discard block |
||
768 | 768 | * |
769 | 769 | * @param WP_Theme $theme The current WP_Theme object. |
770 | 770 | */ |
771 | - public function column_autoupdates( $theme ) { |
|
771 | + public function column_autoupdates($theme) { |
|
772 | 772 | global $status, $page; |
773 | 773 | |
774 | 774 | static $auto_updates, $available_updates; |
775 | 775 | |
776 | - if ( ! $auto_updates ) { |
|
777 | - $auto_updates = (array) get_site_option( 'auto_update_themes', array() ); |
|
776 | + if (!$auto_updates) { |
|
777 | + $auto_updates = (array) get_site_option('auto_update_themes', array()); |
|
778 | 778 | } |
779 | - if ( ! $available_updates ) { |
|
780 | - $available_updates = get_site_transient( 'update_themes' ); |
|
779 | + if (!$available_updates) { |
|
780 | + $available_updates = get_site_transient('update_themes'); |
|
781 | 781 | } |
782 | 782 | |
783 | 783 | $stylesheet = $theme->get_stylesheet(); |
784 | 784 | |
785 | - if ( isset( $theme->auto_update_forced ) ) { |
|
786 | - if ( $theme->auto_update_forced ) { |
|
785 | + if (isset($theme->auto_update_forced)) { |
|
786 | + if ($theme->auto_update_forced) { |
|
787 | 787 | // Forced on. |
788 | - $text = __( 'Auto-updates enabled' ); |
|
788 | + $text = __('Auto-updates enabled'); |
|
789 | 789 | } else { |
790 | - $text = __( 'Auto-updates disabled' ); |
|
790 | + $text = __('Auto-updates disabled'); |
|
791 | 791 | } |
792 | 792 | $action = 'unavailable'; |
793 | 793 | $time_class = ' hidden'; |
794 | - } elseif ( empty( $theme->update_supported ) ) { |
|
794 | + } elseif (empty($theme->update_supported)) { |
|
795 | 795 | $text = ''; |
796 | 796 | $action = 'unavailable'; |
797 | 797 | $time_class = ' hidden'; |
798 | - } elseif ( in_array( $stylesheet, $auto_updates, true ) ) { |
|
799 | - $text = __( 'Disable auto-updates' ); |
|
798 | + } elseif (in_array($stylesheet, $auto_updates, true)) { |
|
799 | + $text = __('Disable auto-updates'); |
|
800 | 800 | $action = 'disable'; |
801 | 801 | $time_class = ''; |
802 | 802 | } else { |
803 | - $text = __( 'Enable auto-updates' ); |
|
803 | + $text = __('Enable auto-updates'); |
|
804 | 804 | $action = 'enable'; |
805 | 805 | $time_class = ' hidden'; |
806 | 806 | } |
@@ -812,14 +812,14 @@ discard block |
||
812 | 812 | 'theme_status' => $status, |
813 | 813 | ); |
814 | 814 | |
815 | - $url = add_query_arg( $query_args, 'themes.php' ); |
|
815 | + $url = add_query_arg($query_args, 'themes.php'); |
|
816 | 816 | |
817 | - if ( 'unavailable' === $action ) { |
|
817 | + if ('unavailable' === $action) { |
|
818 | 818 | $html[] = '<span class="label">' . $text . '</span>'; |
819 | 819 | } else { |
820 | 820 | $html[] = sprintf( |
821 | 821 | '<a href="%s" class="toggle-auto-update aria-button-if-js" data-wp-action="%s">', |
822 | - wp_nonce_url( $url, 'updates' ), |
|
822 | + wp_nonce_url($url, 'updates'), |
|
823 | 823 | $action |
824 | 824 | ); |
825 | 825 | |
@@ -829,7 +829,7 @@ discard block |
||
829 | 829 | |
830 | 830 | } |
831 | 831 | |
832 | - if ( isset( $available_updates->response[ $stylesheet ] ) ) { |
|
832 | + if (isset($available_updates->response[$stylesheet])) { |
|
833 | 833 | $html[] = sprintf( |
834 | 834 | '<div class="auto-update-time%s">%s</div>', |
835 | 835 | $time_class, |
@@ -837,7 +837,7 @@ discard block |
||
837 | 837 | ); |
838 | 838 | } |
839 | 839 | |
840 | - $html = implode( '', $html ); |
|
840 | + $html = implode('', $html); |
|
841 | 841 | |
842 | 842 | /** |
843 | 843 | * Filters the HTML of the auto-updates setting for each theme in the Themes list table. |
@@ -849,7 +849,7 @@ discard block |
||
849 | 849 | * @param string $stylesheet Directory name of the theme. |
850 | 850 | * @param WP_Theme $theme WP_Theme object. |
851 | 851 | */ |
852 | - echo apply_filters( 'theme_auto_update_setting_html', $html, $stylesheet, $theme ); |
|
852 | + echo apply_filters('theme_auto_update_setting_html', $html, $stylesheet, $theme); |
|
853 | 853 | |
854 | 854 | echo '<div class="notice notice-error notice-alt inline hidden"><p></p></div>'; |
855 | 855 | } |
@@ -863,7 +863,7 @@ discard block |
||
863 | 863 | * @param WP_Theme $item The current WP_Theme object. |
864 | 864 | * @param string $column_name The current column name. |
865 | 865 | */ |
866 | - public function column_default( $item, $column_name ) { |
|
866 | + public function column_default($item, $column_name) { |
|
867 | 867 | /** |
868 | 868 | * Fires inside each custom column of the Multisite themes list table. |
869 | 869 | * |
@@ -888,20 +888,20 @@ discard block |
||
888 | 888 | * |
889 | 889 | * @param WP_Theme $item The current WP_Theme object. |
890 | 890 | */ |
891 | - public function single_row_columns( $item ) { |
|
892 | - list( $columns, $hidden, $sortable, $primary ) = $this->get_column_info(); |
|
891 | + public function single_row_columns($item) { |
|
892 | + list($columns, $hidden, $sortable, $primary) = $this->get_column_info(); |
|
893 | 893 | |
894 | - foreach ( $columns as $column_name => $column_display_name ) { |
|
894 | + foreach ($columns as $column_name => $column_display_name) { |
|
895 | 895 | $extra_classes = ''; |
896 | - if ( in_array( $column_name, $hidden, true ) ) { |
|
896 | + if (in_array($column_name, $hidden, true)) { |
|
897 | 897 | $extra_classes .= ' hidden'; |
898 | 898 | } |
899 | 899 | |
900 | - switch ( $column_name ) { |
|
900 | + switch ($column_name) { |
|
901 | 901 | case 'cb': |
902 | 902 | echo '<th scope="row" class="check-column">'; |
903 | 903 | |
904 | - $this->column_cb( $item ); |
|
904 | + $this->column_cb($item); |
|
905 | 905 | |
906 | 906 | echo '</th>'; |
907 | 907 | break; |
@@ -910,24 +910,24 @@ discard block |
||
910 | 910 | $active_theme_label = ''; |
911 | 911 | |
912 | 912 | /* The presence of the site_id property means that this is a subsite view and a label for the active theme needs to be added */ |
913 | - if ( ! empty( $this->site_id ) ) { |
|
914 | - $stylesheet = get_blog_option( $this->site_id, 'stylesheet' ); |
|
915 | - $template = get_blog_option( $this->site_id, 'template' ); |
|
913 | + if (!empty($this->site_id)) { |
|
914 | + $stylesheet = get_blog_option($this->site_id, 'stylesheet'); |
|
915 | + $template = get_blog_option($this->site_id, 'template'); |
|
916 | 916 | |
917 | 917 | /* Add a label for the active template */ |
918 | - if ( $item->get_template() === $template ) { |
|
919 | - $active_theme_label = ' — ' . __( 'Active Theme' ); |
|
918 | + if ($item->get_template() === $template) { |
|
919 | + $active_theme_label = ' — ' . __('Active Theme'); |
|
920 | 920 | } |
921 | 921 | |
922 | 922 | /* In case this is a child theme, label it properly */ |
923 | - if ( $stylesheet !== $template && $item->get_stylesheet() === $stylesheet ) { |
|
924 | - $active_theme_label = ' — ' . __( 'Active Child Theme' ); |
|
923 | + if ($stylesheet !== $template && $item->get_stylesheet() === $stylesheet) { |
|
924 | + $active_theme_label = ' — ' . __('Active Child Theme'); |
|
925 | 925 | } |
926 | 926 | } |
927 | 927 | |
928 | - echo "<td class='theme-title column-primary{$extra_classes}'><strong>" . $item->display( 'Name' ) . $active_theme_label . '</strong>'; |
|
928 | + echo "<td class='theme-title column-primary{$extra_classes}'><strong>" . $item->display('Name') . $active_theme_label . '</strong>'; |
|
929 | 929 | |
930 | - $this->column_name( $item ); |
|
930 | + $this->column_name($item); |
|
931 | 931 | |
932 | 932 | echo '</td>'; |
933 | 933 | break; |
@@ -935,7 +935,7 @@ discard block |
||
935 | 935 | case 'description': |
936 | 936 | echo "<td class='column-description desc{$extra_classes}'>"; |
937 | 937 | |
938 | - $this->column_description( $item ); |
|
938 | + $this->column_description($item); |
|
939 | 939 | |
940 | 940 | echo '</td>'; |
941 | 941 | break; |
@@ -943,14 +943,14 @@ discard block |
||
943 | 943 | case 'auto-updates': |
944 | 944 | echo "<td class='column-auto-updates{$extra_classes}'>"; |
945 | 945 | |
946 | - $this->column_autoupdates( $item ); |
|
946 | + $this->column_autoupdates($item); |
|
947 | 947 | |
948 | 948 | echo '</td>'; |
949 | 949 | break; |
950 | 950 | default: |
951 | 951 | echo "<td class='$column_name column-$column_name{$extra_classes}'>"; |
952 | 952 | |
953 | - $this->column_default( $item, $column_name ); |
|
953 | + $this->column_default($item, $column_name); |
|
954 | 954 | |
955 | 955 | echo '</td>'; |
956 | 956 | break; |
@@ -964,34 +964,34 @@ discard block |
||
964 | 964 | * |
965 | 965 | * @param WP_Theme $theme |
966 | 966 | */ |
967 | - public function single_row( $theme ) { |
|
967 | + public function single_row($theme) { |
|
968 | 968 | global $status, $totals; |
969 | 969 | |
970 | - if ( $this->is_site_themes ) { |
|
971 | - $allowed = $theme->is_allowed( 'site', $this->site_id ); |
|
970 | + if ($this->is_site_themes) { |
|
971 | + $allowed = $theme->is_allowed('site', $this->site_id); |
|
972 | 972 | } else { |
973 | - $allowed = $theme->is_allowed( 'network' ); |
|
973 | + $allowed = $theme->is_allowed('network'); |
|
974 | 974 | } |
975 | 975 | |
976 | 976 | $stylesheet = $theme->get_stylesheet(); |
977 | 977 | |
978 | - $class = ! $allowed ? 'inactive' : 'active'; |
|
979 | - if ( ! empty( $totals['upgrade'] ) && ! empty( $theme->update ) ) { |
|
978 | + $class = !$allowed ? 'inactive' : 'active'; |
|
979 | + if (!empty($totals['upgrade']) && !empty($theme->update)) { |
|
980 | 980 | $class .= ' update'; |
981 | 981 | } |
982 | 982 | |
983 | 983 | printf( |
984 | 984 | '<tr class="%s" data-slug="%s">', |
985 | - esc_attr( $class ), |
|
986 | - esc_attr( $stylesheet ) |
|
985 | + esc_attr($class), |
|
986 | + esc_attr($stylesheet) |
|
987 | 987 | ); |
988 | 988 | |
989 | - $this->single_row_columns( $theme ); |
|
989 | + $this->single_row_columns($theme); |
|
990 | 990 | |
991 | 991 | echo '</tr>'; |
992 | 992 | |
993 | - if ( $this->is_site_themes ) { |
|
994 | - remove_action( "after_theme_row_$stylesheet", 'wp_theme_update_row' ); |
|
993 | + if ($this->is_site_themes) { |
|
994 | + remove_action("after_theme_row_$stylesheet", 'wp_theme_update_row'); |
|
995 | 995 | } |
996 | 996 | |
997 | 997 | /** |
@@ -1003,7 +1003,7 @@ discard block |
||
1003 | 1003 | * @param WP_Theme $theme Current WP_Theme object. |
1004 | 1004 | * @param string $status Status of the theme. |
1005 | 1005 | */ |
1006 | - do_action( 'after_theme_row', $stylesheet, $theme, $status ); |
|
1006 | + do_action('after_theme_row', $stylesheet, $theme, $status); |
|
1007 | 1007 | |
1008 | 1008 | /** |
1009 | 1009 | * Fires after each specific row in the Multisite themes list table. |
@@ -1018,6 +1018,6 @@ discard block |
||
1018 | 1018 | * @param WP_Theme $theme Current WP_Theme object. |
1019 | 1019 | * @param string $status Status of the theme. |
1020 | 1020 | */ |
1021 | - do_action( "after_theme_row_{$stylesheet}", $stylesheet, $theme, $status ); |
|
1021 | + do_action("after_theme_row_{$stylesheet}", $stylesheet, $theme, $status); |
|
1022 | 1022 | } |
1023 | 1023 | } |
@@ -60,49 +60,49 @@ discard block |
||
60 | 60 | * |
61 | 61 | * @param array $opt |
62 | 62 | */ |
63 | - public function __construct( $opt = '' ) { |
|
63 | + public function __construct($opt = '') { |
|
64 | 64 | $this->method = 'ssh2'; |
65 | 65 | $this->errors = new WP_Error(); |
66 | 66 | |
67 | 67 | // Check if possible to use ssh2 functions. |
68 | - if ( ! extension_loaded( 'ssh2' ) ) { |
|
69 | - $this->errors->add( 'no_ssh2_ext', __( 'The ssh2 PHP extension is not available' ) ); |
|
68 | + if (!extension_loaded('ssh2')) { |
|
69 | + $this->errors->add('no_ssh2_ext', __('The ssh2 PHP extension is not available')); |
|
70 | 70 | return; |
71 | 71 | } |
72 | 72 | |
73 | 73 | // Set defaults: |
74 | - if ( empty( $opt['port'] ) ) { |
|
74 | + if (empty($opt['port'])) { |
|
75 | 75 | $this->options['port'] = 22; |
76 | 76 | } else { |
77 | 77 | $this->options['port'] = $opt['port']; |
78 | 78 | } |
79 | 79 | |
80 | - if ( empty( $opt['hostname'] ) ) { |
|
81 | - $this->errors->add( 'empty_hostname', __( 'SSH2 hostname is required' ) ); |
|
80 | + if (empty($opt['hostname'])) { |
|
81 | + $this->errors->add('empty_hostname', __('SSH2 hostname is required')); |
|
82 | 82 | } else { |
83 | 83 | $this->options['hostname'] = $opt['hostname']; |
84 | 84 | } |
85 | 85 | |
86 | 86 | // Check if the options provided are OK. |
87 | - if ( ! empty( $opt['public_key'] ) && ! empty( $opt['private_key'] ) ) { |
|
87 | + if (!empty($opt['public_key']) && !empty($opt['private_key'])) { |
|
88 | 88 | $this->options['public_key'] = $opt['public_key']; |
89 | 89 | $this->options['private_key'] = $opt['private_key']; |
90 | 90 | |
91 | - $this->options['hostkey'] = array( 'hostkey' => 'ssh-rsa,ssh-ed25519' ); |
|
91 | + $this->options['hostkey'] = array('hostkey' => 'ssh-rsa,ssh-ed25519'); |
|
92 | 92 | |
93 | 93 | $this->keys = true; |
94 | - } elseif ( empty( $opt['username'] ) ) { |
|
95 | - $this->errors->add( 'empty_username', __( 'SSH2 username is required' ) ); |
|
94 | + } elseif (empty($opt['username'])) { |
|
95 | + $this->errors->add('empty_username', __('SSH2 username is required')); |
|
96 | 96 | } |
97 | 97 | |
98 | - if ( ! empty( $opt['username'] ) ) { |
|
98 | + if (!empty($opt['username'])) { |
|
99 | 99 | $this->options['username'] = $opt['username']; |
100 | 100 | } |
101 | 101 | |
102 | - if ( empty( $opt['password'] ) ) { |
|
102 | + if (empty($opt['password'])) { |
|
103 | 103 | // Password can be blank if we are using keys. |
104 | - if ( ! $this->keys ) { |
|
105 | - $this->errors->add( 'empty_password', __( 'SSH2 password is required' ) ); |
|
104 | + if (!$this->keys) { |
|
105 | + $this->errors->add('empty_password', __('SSH2 password is required')); |
|
106 | 106 | } |
107 | 107 | } else { |
108 | 108 | $this->options['password'] = $opt['password']; |
@@ -117,18 +117,18 @@ discard block |
||
117 | 117 | * @return bool True on success, false on failure. |
118 | 118 | */ |
119 | 119 | public function connect() { |
120 | - if ( ! $this->keys ) { |
|
121 | - $this->link = @ssh2_connect( $this->options['hostname'], $this->options['port'] ); |
|
120 | + if (!$this->keys) { |
|
121 | + $this->link = @ssh2_connect($this->options['hostname'], $this->options['port']); |
|
122 | 122 | } else { |
123 | - $this->link = @ssh2_connect( $this->options['hostname'], $this->options['port'], $this->options['hostkey'] ); |
|
123 | + $this->link = @ssh2_connect($this->options['hostname'], $this->options['port'], $this->options['hostkey']); |
|
124 | 124 | } |
125 | 125 | |
126 | - if ( ! $this->link ) { |
|
126 | + if (!$this->link) { |
|
127 | 127 | $this->errors->add( |
128 | 128 | 'connect', |
129 | 129 | sprintf( |
130 | 130 | /* translators: %s: hostname:port */ |
131 | - __( 'Failed to connect to SSH2 Server %s' ), |
|
131 | + __('Failed to connect to SSH2 Server %s'), |
|
132 | 132 | $this->options['hostname'] . ':' . $this->options['port'] |
133 | 133 | ) |
134 | 134 | ); |
@@ -136,13 +136,13 @@ discard block |
||
136 | 136 | return false; |
137 | 137 | } |
138 | 138 | |
139 | - if ( ! $this->keys ) { |
|
140 | - if ( ! @ssh2_auth_password( $this->link, $this->options['username'], $this->options['password'] ) ) { |
|
139 | + if (!$this->keys) { |
|
140 | + if (!@ssh2_auth_password($this->link, $this->options['username'], $this->options['password'])) { |
|
141 | 141 | $this->errors->add( |
142 | 142 | 'auth', |
143 | 143 | sprintf( |
144 | 144 | /* translators: %s: Username. */ |
145 | - __( 'Username/Password incorrect for %s' ), |
|
145 | + __('Username/Password incorrect for %s'), |
|
146 | 146 | $this->options['username'] |
147 | 147 | ) |
148 | 148 | ); |
@@ -150,12 +150,12 @@ discard block |
||
150 | 150 | return false; |
151 | 151 | } |
152 | 152 | } else { |
153 | - if ( ! @ssh2_auth_pubkey_file( $this->link, $this->options['username'], $this->options['public_key'], $this->options['private_key'], $this->options['password'] ) ) { |
|
153 | + if (!@ssh2_auth_pubkey_file($this->link, $this->options['username'], $this->options['public_key'], $this->options['private_key'], $this->options['password'])) { |
|
154 | 154 | $this->errors->add( |
155 | 155 | 'auth', |
156 | 156 | sprintf( |
157 | 157 | /* translators: %s: Username. */ |
158 | - __( 'Public and Private keys incorrect for %s' ), |
|
158 | + __('Public and Private keys incorrect for %s'), |
|
159 | 159 | $this->options['username'] |
160 | 160 | ) |
161 | 161 | ); |
@@ -164,14 +164,14 @@ discard block |
||
164 | 164 | } |
165 | 165 | } |
166 | 166 | |
167 | - $this->sftp_link = ssh2_sftp( $this->link ); |
|
167 | + $this->sftp_link = ssh2_sftp($this->link); |
|
168 | 168 | |
169 | - if ( ! $this->sftp_link ) { |
|
169 | + if (!$this->sftp_link) { |
|
170 | 170 | $this->errors->add( |
171 | 171 | 'connect', |
172 | 172 | sprintf( |
173 | 173 | /* translators: %s: hostname:port */ |
174 | - __( 'Failed to initialize a SFTP subsystem session with the SSH2 Server %s' ), |
|
174 | + __('Failed to initialize a SFTP subsystem session with the SSH2 Server %s'), |
|
175 | 175 | $this->options['hostname'] . ':' . $this->options['port'] |
176 | 176 | ) |
177 | 177 | ); |
@@ -195,12 +195,12 @@ discard block |
||
195 | 195 | * @param string $path The File/Directory path on the remote server to return |
196 | 196 | * @return string The ssh2.sftp:// wrapped path to use. |
197 | 197 | */ |
198 | - public function sftp_path( $path ) { |
|
199 | - if ( '/' === $path ) { |
|
198 | + public function sftp_path($path) { |
|
199 | + if ('/' === $path) { |
|
200 | 200 | $path = '/./'; |
201 | 201 | } |
202 | 202 | |
203 | - return 'ssh2.sftp://' . $this->sftp_link . '/' . ltrim( $path, '/' ); |
|
203 | + return 'ssh2.sftp://' . $this->sftp_link . '/' . ltrim($path, '/'); |
|
204 | 204 | } |
205 | 205 | |
206 | 206 | /** |
@@ -211,30 +211,30 @@ discard block |
||
211 | 211 | * @return bool|string True on success, false on failure. String if the command was executed, `$returnbool` |
212 | 212 | * is false (default), and data from the resulting stream was retrieved. |
213 | 213 | */ |
214 | - public function run_command( $command, $returnbool = false ) { |
|
215 | - if ( ! $this->link ) { |
|
214 | + public function run_command($command, $returnbool = false) { |
|
215 | + if (!$this->link) { |
|
216 | 216 | return false; |
217 | 217 | } |
218 | 218 | |
219 | - $stream = ssh2_exec( $this->link, $command ); |
|
219 | + $stream = ssh2_exec($this->link, $command); |
|
220 | 220 | |
221 | - if ( ! $stream ) { |
|
221 | + if (!$stream) { |
|
222 | 222 | $this->errors->add( |
223 | 223 | 'command', |
224 | 224 | sprintf( |
225 | 225 | /* translators: %s: Command. */ |
226 | - __( 'Unable to perform command: %s' ), |
|
226 | + __('Unable to perform command: %s'), |
|
227 | 227 | $command |
228 | 228 | ) |
229 | 229 | ); |
230 | 230 | } else { |
231 | - stream_set_blocking( $stream, true ); |
|
232 | - stream_set_timeout( $stream, FS_TIMEOUT ); |
|
233 | - $data = stream_get_contents( $stream ); |
|
234 | - fclose( $stream ); |
|
231 | + stream_set_blocking($stream, true); |
|
232 | + stream_set_timeout($stream, FS_TIMEOUT); |
|
233 | + $data = stream_get_contents($stream); |
|
234 | + fclose($stream); |
|
235 | 235 | |
236 | - if ( $returnbool ) { |
|
237 | - return ( false === $data ) ? false : '' !== trim( $data ); |
|
236 | + if ($returnbool) { |
|
237 | + return (false === $data) ? false : '' !== trim($data); |
|
238 | 238 | } else { |
239 | 239 | return $data; |
240 | 240 | } |
@@ -252,8 +252,8 @@ discard block |
||
252 | 252 | * @return string|false Read data on success, false if no temporary file could be opened, |
253 | 253 | * or if the file couldn't be retrieved. |
254 | 254 | */ |
255 | - public function get_contents( $file ) { |
|
256 | - return file_get_contents( $this->sftp_path( $file ) ); |
|
255 | + public function get_contents($file) { |
|
256 | + return file_get_contents($this->sftp_path($file)); |
|
257 | 257 | } |
258 | 258 | |
259 | 259 | /** |
@@ -264,8 +264,8 @@ discard block |
||
264 | 264 | * @param string $file Path to the file. |
265 | 265 | * @return array|false File contents in an array on success, false on failure. |
266 | 266 | */ |
267 | - public function get_contents_array( $file ) { |
|
268 | - return file( $this->sftp_path( $file ) ); |
|
267 | + public function get_contents_array($file) { |
|
268 | + return file($this->sftp_path($file)); |
|
269 | 269 | } |
270 | 270 | |
271 | 271 | /** |
@@ -279,14 +279,14 @@ discard block |
||
279 | 279 | * Default false. |
280 | 280 | * @return bool True on success, false on failure. |
281 | 281 | */ |
282 | - public function put_contents( $file, $contents, $mode = false ) { |
|
283 | - $ret = file_put_contents( $this->sftp_path( $file ), $contents ); |
|
282 | + public function put_contents($file, $contents, $mode = false) { |
|
283 | + $ret = file_put_contents($this->sftp_path($file), $contents); |
|
284 | 284 | |
285 | - if ( strlen( $contents ) !== $ret ) { |
|
285 | + if (strlen($contents) !== $ret) { |
|
286 | 286 | return false; |
287 | 287 | } |
288 | 288 | |
289 | - $this->chmod( $file, $mode ); |
|
289 | + $this->chmod($file, $mode); |
|
290 | 290 | |
291 | 291 | return true; |
292 | 292 | } |
@@ -299,10 +299,10 @@ discard block |
||
299 | 299 | * @return string|false The current working directory on success, false on failure. |
300 | 300 | */ |
301 | 301 | public function cwd() { |
302 | - $cwd = ssh2_sftp_realpath( $this->sftp_link, '.' ); |
|
302 | + $cwd = ssh2_sftp_realpath($this->sftp_link, '.'); |
|
303 | 303 | |
304 | - if ( $cwd ) { |
|
305 | - $cwd = trailingslashit( trim( $cwd ) ); |
|
304 | + if ($cwd) { |
|
305 | + $cwd = trailingslashit(trim($cwd)); |
|
306 | 306 | } |
307 | 307 | |
308 | 308 | return $cwd; |
@@ -316,8 +316,8 @@ discard block |
||
316 | 316 | * @param string $dir The new current directory. |
317 | 317 | * @return bool True on success, false on failure. |
318 | 318 | */ |
319 | - public function chdir( $dir ) { |
|
320 | - return $this->run_command( 'cd ' . $dir, true ); |
|
319 | + public function chdir($dir) { |
|
320 | + return $this->run_command('cd ' . $dir, true); |
|
321 | 321 | } |
322 | 322 | |
323 | 323 | /** |
@@ -331,16 +331,16 @@ discard block |
||
331 | 331 | * Default false. |
332 | 332 | * @return bool True on success, false on failure. |
333 | 333 | */ |
334 | - public function chgrp( $file, $group, $recursive = false ) { |
|
335 | - if ( ! $this->exists( $file ) ) { |
|
334 | + public function chgrp($file, $group, $recursive = false) { |
|
335 | + if (!$this->exists($file)) { |
|
336 | 336 | return false; |
337 | 337 | } |
338 | 338 | |
339 | - if ( ! $recursive || ! $this->is_dir( $file ) ) { |
|
340 | - return $this->run_command( sprintf( 'chgrp %s %s', escapeshellarg( $group ), escapeshellarg( $file ) ), true ); |
|
339 | + if (!$recursive || !$this->is_dir($file)) { |
|
340 | + return $this->run_command(sprintf('chgrp %s %s', escapeshellarg($group), escapeshellarg($file)), true); |
|
341 | 341 | } |
342 | 342 | |
343 | - return $this->run_command( sprintf( 'chgrp -R %s %s', escapeshellarg( $group ), escapeshellarg( $file ) ), true ); |
|
343 | + return $this->run_command(sprintf('chgrp -R %s %s', escapeshellarg($group), escapeshellarg($file)), true); |
|
344 | 344 | } |
345 | 345 | |
346 | 346 | /** |
@@ -355,26 +355,26 @@ discard block |
||
355 | 355 | * Default false. |
356 | 356 | * @return bool True on success, false on failure. |
357 | 357 | */ |
358 | - public function chmod( $file, $mode = false, $recursive = false ) { |
|
359 | - if ( ! $this->exists( $file ) ) { |
|
358 | + public function chmod($file, $mode = false, $recursive = false) { |
|
359 | + if (!$this->exists($file)) { |
|
360 | 360 | return false; |
361 | 361 | } |
362 | 362 | |
363 | - if ( ! $mode ) { |
|
364 | - if ( $this->is_file( $file ) ) { |
|
363 | + if (!$mode) { |
|
364 | + if ($this->is_file($file)) { |
|
365 | 365 | $mode = FS_CHMOD_FILE; |
366 | - } elseif ( $this->is_dir( $file ) ) { |
|
366 | + } elseif ($this->is_dir($file)) { |
|
367 | 367 | $mode = FS_CHMOD_DIR; |
368 | 368 | } else { |
369 | 369 | return false; |
370 | 370 | } |
371 | 371 | } |
372 | 372 | |
373 | - if ( ! $recursive || ! $this->is_dir( $file ) ) { |
|
374 | - return $this->run_command( sprintf( 'chmod %o %s', $mode, escapeshellarg( $file ) ), true ); |
|
373 | + if (!$recursive || !$this->is_dir($file)) { |
|
374 | + return $this->run_command(sprintf('chmod %o %s', $mode, escapeshellarg($file)), true); |
|
375 | 375 | } |
376 | 376 | |
377 | - return $this->run_command( sprintf( 'chmod -R %o %s', $mode, escapeshellarg( $file ) ), true ); |
|
377 | + return $this->run_command(sprintf('chmod -R %o %s', $mode, escapeshellarg($file)), true); |
|
378 | 378 | } |
379 | 379 | |
380 | 380 | /** |
@@ -388,16 +388,16 @@ discard block |
||
388 | 388 | * Default false. |
389 | 389 | * @return bool True on success, false on failure. |
390 | 390 | */ |
391 | - public function chown( $file, $owner, $recursive = false ) { |
|
392 | - if ( ! $this->exists( $file ) ) { |
|
391 | + public function chown($file, $owner, $recursive = false) { |
|
392 | + if (!$this->exists($file)) { |
|
393 | 393 | return false; |
394 | 394 | } |
395 | 395 | |
396 | - if ( ! $recursive || ! $this->is_dir( $file ) ) { |
|
397 | - return $this->run_command( sprintf( 'chown %s %s', escapeshellarg( $owner ), escapeshellarg( $file ) ), true ); |
|
396 | + if (!$recursive || !$this->is_dir($file)) { |
|
397 | + return $this->run_command(sprintf('chown %s %s', escapeshellarg($owner), escapeshellarg($file)), true); |
|
398 | 398 | } |
399 | 399 | |
400 | - return $this->run_command( sprintf( 'chown -R %s %s', escapeshellarg( $owner ), escapeshellarg( $file ) ), true ); |
|
400 | + return $this->run_command(sprintf('chown -R %s %s', escapeshellarg($owner), escapeshellarg($file)), true); |
|
401 | 401 | } |
402 | 402 | |
403 | 403 | /** |
@@ -408,20 +408,20 @@ discard block |
||
408 | 408 | * @param string $file Path to the file. |
409 | 409 | * @return string|false Username of the owner on success, false on failure. |
410 | 410 | */ |
411 | - public function owner( $file ) { |
|
412 | - $owneruid = @fileowner( $this->sftp_path( $file ) ); |
|
411 | + public function owner($file) { |
|
412 | + $owneruid = @fileowner($this->sftp_path($file)); |
|
413 | 413 | |
414 | - if ( ! $owneruid ) { |
|
414 | + if (!$owneruid) { |
|
415 | 415 | return false; |
416 | 416 | } |
417 | 417 | |
418 | - if ( ! function_exists( 'posix_getpwuid' ) ) { |
|
418 | + if (!function_exists('posix_getpwuid')) { |
|
419 | 419 | return $owneruid; |
420 | 420 | } |
421 | 421 | |
422 | - $ownerarray = posix_getpwuid( $owneruid ); |
|
422 | + $ownerarray = posix_getpwuid($owneruid); |
|
423 | 423 | |
424 | - if ( ! $ownerarray ) { |
|
424 | + if (!$ownerarray) { |
|
425 | 425 | return false; |
426 | 426 | } |
427 | 427 | |
@@ -436,8 +436,8 @@ discard block |
||
436 | 436 | * @param string $file Path to the file. |
437 | 437 | * @return string Mode of the file (the last 3 digits). |
438 | 438 | */ |
439 | - public function getchmod( $file ) { |
|
440 | - return substr( decoct( @fileperms( $this->sftp_path( $file ) ) ), -3 ); |
|
439 | + public function getchmod($file) { |
|
440 | + return substr(decoct(@fileperms($this->sftp_path($file))), -3); |
|
441 | 441 | } |
442 | 442 | |
443 | 443 | /** |
@@ -448,20 +448,20 @@ discard block |
||
448 | 448 | * @param string $file Path to the file. |
449 | 449 | * @return string|false The group on success, false on failure. |
450 | 450 | */ |
451 | - public function group( $file ) { |
|
452 | - $gid = @filegroup( $this->sftp_path( $file ) ); |
|
451 | + public function group($file) { |
|
452 | + $gid = @filegroup($this->sftp_path($file)); |
|
453 | 453 | |
454 | - if ( ! $gid ) { |
|
454 | + if (!$gid) { |
|
455 | 455 | return false; |
456 | 456 | } |
457 | 457 | |
458 | - if ( ! function_exists( 'posix_getgrgid' ) ) { |
|
458 | + if (!function_exists('posix_getgrgid')) { |
|
459 | 459 | return $gid; |
460 | 460 | } |
461 | 461 | |
462 | - $grouparray = posix_getgrgid( $gid ); |
|
462 | + $grouparray = posix_getgrgid($gid); |
|
463 | 463 | |
464 | - if ( ! $grouparray ) { |
|
464 | + if (!$grouparray) { |
|
465 | 465 | return false; |
466 | 466 | } |
467 | 467 | |
@@ -481,18 +481,18 @@ discard block |
||
481 | 481 | * 0755 for dirs. Default false. |
482 | 482 | * @return bool True on success, false on failure. |
483 | 483 | */ |
484 | - public function copy( $source, $destination, $overwrite = false, $mode = false ) { |
|
485 | - if ( ! $overwrite && $this->exists( $destination ) ) { |
|
484 | + public function copy($source, $destination, $overwrite = false, $mode = false) { |
|
485 | + if (!$overwrite && $this->exists($destination)) { |
|
486 | 486 | return false; |
487 | 487 | } |
488 | 488 | |
489 | - $content = $this->get_contents( $source ); |
|
489 | + $content = $this->get_contents($source); |
|
490 | 490 | |
491 | - if ( false === $content ) { |
|
491 | + if (false === $content) { |
|
492 | 492 | return false; |
493 | 493 | } |
494 | 494 | |
495 | - return $this->put_contents( $destination, $content, $mode ); |
|
495 | + return $this->put_contents($destination, $content, $mode); |
|
496 | 496 | } |
497 | 497 | |
498 | 498 | /** |
@@ -506,18 +506,18 @@ discard block |
||
506 | 506 | * Default false. |
507 | 507 | * @return bool True on success, false on failure. |
508 | 508 | */ |
509 | - public function move( $source, $destination, $overwrite = false ) { |
|
510 | - if ( $this->exists( $destination ) ) { |
|
511 | - if ( $overwrite ) { |
|
509 | + public function move($source, $destination, $overwrite = false) { |
|
510 | + if ($this->exists($destination)) { |
|
511 | + if ($overwrite) { |
|
512 | 512 | // We need to remove the destination file before we can rename the source. |
513 | - $this->delete( $destination, false, 'f' ); |
|
513 | + $this->delete($destination, false, 'f'); |
|
514 | 514 | } else { |
515 | 515 | // If we're not overwriting, the rename will fail, so return early. |
516 | 516 | return false; |
517 | 517 | } |
518 | 518 | } |
519 | 519 | |
520 | - return ssh2_sftp_rename( $this->sftp_link, $source, $destination ); |
|
520 | + return ssh2_sftp_rename($this->sftp_link, $source, $destination); |
|
521 | 521 | } |
522 | 522 | |
523 | 523 | /** |
@@ -532,24 +532,24 @@ discard block |
||
532 | 532 | * Default false. |
533 | 533 | * @return bool True on success, false on failure. |
534 | 534 | */ |
535 | - public function delete( $file, $recursive = false, $type = false ) { |
|
536 | - if ( 'f' === $type || $this->is_file( $file ) ) { |
|
537 | - return ssh2_sftp_unlink( $this->sftp_link, $file ); |
|
535 | + public function delete($file, $recursive = false, $type = false) { |
|
536 | + if ('f' === $type || $this->is_file($file)) { |
|
537 | + return ssh2_sftp_unlink($this->sftp_link, $file); |
|
538 | 538 | } |
539 | 539 | |
540 | - if ( ! $recursive ) { |
|
541 | - return ssh2_sftp_rmdir( $this->sftp_link, $file ); |
|
540 | + if (!$recursive) { |
|
541 | + return ssh2_sftp_rmdir($this->sftp_link, $file); |
|
542 | 542 | } |
543 | 543 | |
544 | - $filelist = $this->dirlist( $file ); |
|
544 | + $filelist = $this->dirlist($file); |
|
545 | 545 | |
546 | - if ( is_array( $filelist ) ) { |
|
547 | - foreach ( $filelist as $filename => $fileinfo ) { |
|
548 | - $this->delete( $file . '/' . $filename, $recursive, $fileinfo['type'] ); |
|
546 | + if (is_array($filelist)) { |
|
547 | + foreach ($filelist as $filename => $fileinfo) { |
|
548 | + $this->delete($file . '/' . $filename, $recursive, $fileinfo['type']); |
|
549 | 549 | } |
550 | 550 | } |
551 | 551 | |
552 | - return ssh2_sftp_rmdir( $this->sftp_link, $file ); |
|
552 | + return ssh2_sftp_rmdir($this->sftp_link, $file); |
|
553 | 553 | } |
554 | 554 | |
555 | 555 | /** |
@@ -560,8 +560,8 @@ discard block |
||
560 | 560 | * @param string $file Path to file or directory. |
561 | 561 | * @return bool Whether $file exists or not. |
562 | 562 | */ |
563 | - public function exists( $file ) { |
|
564 | - return file_exists( $this->sftp_path( $file ) ); |
|
563 | + public function exists($file) { |
|
564 | + return file_exists($this->sftp_path($file)); |
|
565 | 565 | } |
566 | 566 | |
567 | 567 | /** |
@@ -572,8 +572,8 @@ discard block |
||
572 | 572 | * @param string $file File path. |
573 | 573 | * @return bool Whether $file is a file. |
574 | 574 | */ |
575 | - public function is_file( $file ) { |
|
576 | - return is_file( $this->sftp_path( $file ) ); |
|
575 | + public function is_file($file) { |
|
576 | + return is_file($this->sftp_path($file)); |
|
577 | 577 | } |
578 | 578 | |
579 | 579 | /** |
@@ -584,8 +584,8 @@ discard block |
||
584 | 584 | * @param string $path Directory path. |
585 | 585 | * @return bool Whether $path is a directory. |
586 | 586 | */ |
587 | - public function is_dir( $path ) { |
|
588 | - return is_dir( $this->sftp_path( $path ) ); |
|
587 | + public function is_dir($path) { |
|
588 | + return is_dir($this->sftp_path($path)); |
|
589 | 589 | } |
590 | 590 | |
591 | 591 | /** |
@@ -596,8 +596,8 @@ discard block |
||
596 | 596 | * @param string $file Path to file. |
597 | 597 | * @return bool Whether $file is readable. |
598 | 598 | */ |
599 | - public function is_readable( $file ) { |
|
600 | - return is_readable( $this->sftp_path( $file ) ); |
|
599 | + public function is_readable($file) { |
|
600 | + return is_readable($this->sftp_path($file)); |
|
601 | 601 | } |
602 | 602 | |
603 | 603 | /** |
@@ -608,7 +608,7 @@ discard block |
||
608 | 608 | * @param string $file Path to file or directory. |
609 | 609 | * @return bool Whether $file is writable. |
610 | 610 | */ |
611 | - public function is_writable( $file ) { |
|
611 | + public function is_writable($file) { |
|
612 | 612 | // PHP will base its writable checks on system_user === file_owner, not ssh_user === file_owner. |
613 | 613 | return true; |
614 | 614 | } |
@@ -621,8 +621,8 @@ discard block |
||
621 | 621 | * @param string $file Path to file. |
622 | 622 | * @return int|false Unix timestamp representing last access time, false on failure. |
623 | 623 | */ |
624 | - public function atime( $file ) { |
|
625 | - return fileatime( $this->sftp_path( $file ) ); |
|
624 | + public function atime($file) { |
|
625 | + return fileatime($this->sftp_path($file)); |
|
626 | 626 | } |
627 | 627 | |
628 | 628 | /** |
@@ -633,8 +633,8 @@ discard block |
||
633 | 633 | * @param string $file Path to file. |
634 | 634 | * @return int|false Unix timestamp representing modification time, false on failure. |
635 | 635 | */ |
636 | - public function mtime( $file ) { |
|
637 | - return filemtime( $this->sftp_path( $file ) ); |
|
636 | + public function mtime($file) { |
|
637 | + return filemtime($this->sftp_path($file)); |
|
638 | 638 | } |
639 | 639 | |
640 | 640 | /** |
@@ -645,8 +645,8 @@ discard block |
||
645 | 645 | * @param string $file Path to file. |
646 | 646 | * @return int|false Size of the file in bytes on success, false on failure. |
647 | 647 | */ |
648 | - public function size( $file ) { |
|
649 | - return filesize( $this->sftp_path( $file ) ); |
|
648 | + public function size($file) { |
|
649 | + return filesize($this->sftp_path($file)); |
|
650 | 650 | } |
651 | 651 | |
652 | 652 | /** |
@@ -662,7 +662,7 @@ discard block |
||
662 | 662 | * @param int $atime Optional. Access time to set for file. |
663 | 663 | * Default 0. |
664 | 664 | */ |
665 | - public function touch( $file, $time = 0, $atime = 0 ) { |
|
665 | + public function touch($file, $time = 0, $atime = 0) { |
|
666 | 666 | // Not implemented. |
667 | 667 | } |
668 | 668 | |
@@ -680,30 +680,30 @@ discard block |
||
680 | 680 | * Default false. |
681 | 681 | * @return bool True on success, false on failure. |
682 | 682 | */ |
683 | - public function mkdir( $path, $chmod = false, $chown = false, $chgrp = false ) { |
|
684 | - $path = untrailingslashit( $path ); |
|
683 | + public function mkdir($path, $chmod = false, $chown = false, $chgrp = false) { |
|
684 | + $path = untrailingslashit($path); |
|
685 | 685 | |
686 | - if ( empty( $path ) ) { |
|
686 | + if (empty($path)) { |
|
687 | 687 | return false; |
688 | 688 | } |
689 | 689 | |
690 | - if ( ! $chmod ) { |
|
690 | + if (!$chmod) { |
|
691 | 691 | $chmod = FS_CHMOD_DIR; |
692 | 692 | } |
693 | 693 | |
694 | - if ( ! ssh2_sftp_mkdir( $this->sftp_link, $path, $chmod, true ) ) { |
|
694 | + if (!ssh2_sftp_mkdir($this->sftp_link, $path, $chmod, true)) { |
|
695 | 695 | return false; |
696 | 696 | } |
697 | 697 | |
698 | 698 | // Set directory permissions. |
699 | - ssh2_sftp_chmod( $this->sftp_link, $path, $chmod ); |
|
699 | + ssh2_sftp_chmod($this->sftp_link, $path, $chmod); |
|
700 | 700 | |
701 | - if ( $chown ) { |
|
702 | - $this->chown( $path, $chown ); |
|
701 | + if ($chown) { |
|
702 | + $this->chown($path, $chown); |
|
703 | 703 | } |
704 | 704 | |
705 | - if ( $chgrp ) { |
|
706 | - $this->chgrp( $path, $chgrp ); |
|
705 | + if ($chgrp) { |
|
706 | + $this->chgrp($path, $chgrp); |
|
707 | 707 | } |
708 | 708 | |
709 | 709 | return true; |
@@ -719,8 +719,8 @@ discard block |
||
719 | 719 | * Default false. |
720 | 720 | * @return bool True on success, false on failure. |
721 | 721 | */ |
722 | - public function rmdir( $path, $recursive = false ) { |
|
723 | - return $this->delete( $path, $recursive ); |
|
722 | + public function rmdir($path, $recursive = false) { |
|
723 | + return $this->delete($path, $recursive); |
|
724 | 724 | } |
725 | 725 | |
726 | 726 | /** |
@@ -748,65 +748,65 @@ discard block |
||
748 | 748 | * @type mixed $files If a directory and `$recursive` is true, contains another array of files. |
749 | 749 | * } |
750 | 750 | */ |
751 | - public function dirlist( $path, $include_hidden = true, $recursive = false ) { |
|
752 | - if ( $this->is_file( $path ) ) { |
|
753 | - $limit_file = basename( $path ); |
|
754 | - $path = dirname( $path ); |
|
751 | + public function dirlist($path, $include_hidden = true, $recursive = false) { |
|
752 | + if ($this->is_file($path)) { |
|
753 | + $limit_file = basename($path); |
|
754 | + $path = dirname($path); |
|
755 | 755 | } else { |
756 | 756 | $limit_file = false; |
757 | 757 | } |
758 | 758 | |
759 | - if ( ! $this->is_dir( $path ) || ! $this->is_readable( $path ) ) { |
|
759 | + if (!$this->is_dir($path) || !$this->is_readable($path)) { |
|
760 | 760 | return false; |
761 | 761 | } |
762 | 762 | |
763 | 763 | $ret = array(); |
764 | - $dir = dir( $this->sftp_path( $path ) ); |
|
764 | + $dir = dir($this->sftp_path($path)); |
|
765 | 765 | |
766 | - if ( ! $dir ) { |
|
766 | + if (!$dir) { |
|
767 | 767 | return false; |
768 | 768 | } |
769 | 769 | |
770 | - while ( false !== ( $entry = $dir->read() ) ) { |
|
770 | + while (false !== ($entry = $dir->read())) { |
|
771 | 771 | $struc = array(); |
772 | 772 | $struc['name'] = $entry; |
773 | 773 | |
774 | - if ( '.' === $struc['name'] || '..' === $struc['name'] ) { |
|
774 | + if ('.' === $struc['name'] || '..' === $struc['name']) { |
|
775 | 775 | continue; // Do not care about these folders. |
776 | 776 | } |
777 | 777 | |
778 | - if ( ! $include_hidden && '.' === $struc['name'][0] ) { |
|
778 | + if (!$include_hidden && '.' === $struc['name'][0]) { |
|
779 | 779 | continue; |
780 | 780 | } |
781 | 781 | |
782 | - if ( $limit_file && $struc['name'] !== $limit_file ) { |
|
782 | + if ($limit_file && $struc['name'] !== $limit_file) { |
|
783 | 783 | continue; |
784 | 784 | } |
785 | 785 | |
786 | - $struc['perms'] = $this->gethchmod( $path . '/' . $entry ); |
|
787 | - $struc['permsn'] = $this->getnumchmodfromh( $struc['perms'] ); |
|
786 | + $struc['perms'] = $this->gethchmod($path . '/' . $entry); |
|
787 | + $struc['permsn'] = $this->getnumchmodfromh($struc['perms']); |
|
788 | 788 | $struc['number'] = false; |
789 | - $struc['owner'] = $this->owner( $path . '/' . $entry ); |
|
790 | - $struc['group'] = $this->group( $path . '/' . $entry ); |
|
791 | - $struc['size'] = $this->size( $path . '/' . $entry ); |
|
792 | - $struc['lastmodunix'] = $this->mtime( $path . '/' . $entry ); |
|
793 | - $struc['lastmod'] = gmdate( 'M j', $struc['lastmodunix'] ); |
|
794 | - $struc['time'] = gmdate( 'h:i:s', $struc['lastmodunix'] ); |
|
795 | - $struc['type'] = $this->is_dir( $path . '/' . $entry ) ? 'd' : 'f'; |
|
796 | - |
|
797 | - if ( 'd' === $struc['type'] ) { |
|
798 | - if ( $recursive ) { |
|
799 | - $struc['files'] = $this->dirlist( $path . '/' . $struc['name'], $include_hidden, $recursive ); |
|
789 | + $struc['owner'] = $this->owner($path . '/' . $entry); |
|
790 | + $struc['group'] = $this->group($path . '/' . $entry); |
|
791 | + $struc['size'] = $this->size($path . '/' . $entry); |
|
792 | + $struc['lastmodunix'] = $this->mtime($path . '/' . $entry); |
|
793 | + $struc['lastmod'] = gmdate('M j', $struc['lastmodunix']); |
|
794 | + $struc['time'] = gmdate('h:i:s', $struc['lastmodunix']); |
|
795 | + $struc['type'] = $this->is_dir($path . '/' . $entry) ? 'd' : 'f'; |
|
796 | + |
|
797 | + if ('d' === $struc['type']) { |
|
798 | + if ($recursive) { |
|
799 | + $struc['files'] = $this->dirlist($path . '/' . $struc['name'], $include_hidden, $recursive); |
|
800 | 800 | } else { |
801 | 801 | $struc['files'] = array(); |
802 | 802 | } |
803 | 803 | } |
804 | 804 | |
805 | - $ret[ $struc['name'] ] = $struc; |
|
805 | + $ret[$struc['name']] = $struc; |
|
806 | 806 | } |
807 | 807 | |
808 | 808 | $dir->close(); |
809 | - unset( $dir ); |
|
809 | + unset($dir); |
|
810 | 810 | |
811 | 811 | return $ret; |
812 | 812 | } |
@@ -9,7 +9,7 @@ discard block |
||
9 | 9 | */ |
10 | 10 | |
11 | 11 | /** Include user installation customization script. */ |
12 | -if ( file_exists( WP_CONTENT_DIR . '/install.php' ) ) { |
|
12 | +if (file_exists(WP_CONTENT_DIR . '/install.php')) { |
|
13 | 13 | require WP_CONTENT_DIR . '/install.php'; |
14 | 14 | } |
15 | 15 | |
@@ -19,7 +19,7 @@ discard block |
||
19 | 19 | /** WordPress Schema API */ |
20 | 20 | require_once ABSPATH . 'wp-admin/includes/schema.php'; |
21 | 21 | |
22 | -if ( ! function_exists( 'wp_install' ) ) : |
|
22 | +if (!function_exists('wp_install')) : |
|
23 | 23 | /** |
24 | 24 | * Installs the site. |
25 | 25 | * |
@@ -44,9 +44,9 @@ discard block |
||
44 | 44 | * @type string $password_message The explanatory message regarding the password. |
45 | 45 | * } |
46 | 46 | */ |
47 | - function wp_install( $blog_title, $user_name, $user_email, $is_public, $deprecated = '', $user_password = '', $language = '' ) { |
|
48 | - if ( ! empty( $deprecated ) ) { |
|
49 | - _deprecated_argument( __FUNCTION__, '2.6.0' ); |
|
47 | + function wp_install($blog_title, $user_name, $user_email, $is_public, $deprecated = '', $user_password = '', $language = '') { |
|
48 | + if (!empty($deprecated)) { |
|
49 | + _deprecated_argument(__FUNCTION__, '2.6.0'); |
|
50 | 50 | } |
51 | 51 | |
52 | 52 | wp_check_mysql_version(); |
@@ -55,66 +55,66 @@ discard block |
||
55 | 55 | populate_options(); |
56 | 56 | populate_roles(); |
57 | 57 | |
58 | - update_option( 'blogname', $blog_title ); |
|
59 | - update_option( 'admin_email', $user_email ); |
|
60 | - update_option( 'blog_public', $is_public ); |
|
58 | + update_option('blogname', $blog_title); |
|
59 | + update_option('admin_email', $user_email); |
|
60 | + update_option('blog_public', $is_public); |
|
61 | 61 | |
62 | 62 | // Freshness of site - in the future, this could get more specific about actions taken, perhaps. |
63 | - update_option( 'fresh_site', 1 ); |
|
63 | + update_option('fresh_site', 1); |
|
64 | 64 | |
65 | - if ( $language ) { |
|
66 | - update_option( 'WPLANG', $language ); |
|
65 | + if ($language) { |
|
66 | + update_option('WPLANG', $language); |
|
67 | 67 | } |
68 | 68 | |
69 | 69 | $guessurl = wp_guess_url(); |
70 | 70 | |
71 | - update_option( 'siteurl', $guessurl ); |
|
71 | + update_option('siteurl', $guessurl); |
|
72 | 72 | |
73 | 73 | // If not a public site, don't ping. |
74 | - if ( ! $is_public ) { |
|
75 | - update_option( 'default_pingback_flag', 0 ); |
|
74 | + if (!$is_public) { |
|
75 | + update_option('default_pingback_flag', 0); |
|
76 | 76 | } |
77 | 77 | |
78 | 78 | /* |
79 | 79 | * Create default user. If the user already exists, the user tables are |
80 | 80 | * being shared among sites. Just set the role in that case. |
81 | 81 | */ |
82 | - $user_id = username_exists( $user_name ); |
|
83 | - $user_password = trim( $user_password ); |
|
82 | + $user_id = username_exists($user_name); |
|
83 | + $user_password = trim($user_password); |
|
84 | 84 | $email_password = false; |
85 | 85 | $user_created = false; |
86 | 86 | |
87 | - if ( ! $user_id && empty( $user_password ) ) { |
|
88 | - $user_password = wp_generate_password( 12, false ); |
|
89 | - $message = __( '<strong><em>Note that password</em></strong> carefully! It is a <em>random</em> password that was generated just for you.' ); |
|
90 | - $user_id = wp_create_user( $user_name, $user_password, $user_email ); |
|
91 | - update_user_meta( $user_id, 'default_password_nag', true ); |
|
87 | + if (!$user_id && empty($user_password)) { |
|
88 | + $user_password = wp_generate_password(12, false); |
|
89 | + $message = __('<strong><em>Note that password</em></strong> carefully! It is a <em>random</em> password that was generated just for you.'); |
|
90 | + $user_id = wp_create_user($user_name, $user_password, $user_email); |
|
91 | + update_user_meta($user_id, 'default_password_nag', true); |
|
92 | 92 | $email_password = true; |
93 | 93 | $user_created = true; |
94 | - } elseif ( ! $user_id ) { |
|
94 | + } elseif (!$user_id) { |
|
95 | 95 | // Password has been provided. |
96 | - $message = '<em>' . __( 'Your chosen password.' ) . '</em>'; |
|
97 | - $user_id = wp_create_user( $user_name, $user_password, $user_email ); |
|
96 | + $message = '<em>' . __('Your chosen password.') . '</em>'; |
|
97 | + $user_id = wp_create_user($user_name, $user_password, $user_email); |
|
98 | 98 | $user_created = true; |
99 | 99 | } else { |
100 | - $message = __( 'User already exists. Password inherited.' ); |
|
100 | + $message = __('User already exists. Password inherited.'); |
|
101 | 101 | } |
102 | 102 | |
103 | - $user = new WP_User( $user_id ); |
|
104 | - $user->set_role( 'administrator' ); |
|
103 | + $user = new WP_User($user_id); |
|
104 | + $user->set_role('administrator'); |
|
105 | 105 | |
106 | - if ( $user_created ) { |
|
106 | + if ($user_created) { |
|
107 | 107 | $user->user_url = $guessurl; |
108 | - wp_update_user( $user ); |
|
108 | + wp_update_user($user); |
|
109 | 109 | } |
110 | 110 | |
111 | - wp_install_defaults( $user_id ); |
|
111 | + wp_install_defaults($user_id); |
|
112 | 112 | |
113 | 113 | wp_install_maybe_enable_pretty_permalinks(); |
114 | 114 | |
115 | 115 | flush_rewrite_rules(); |
116 | 116 | |
117 | - wp_new_blog_notification( $blog_title, $guessurl, $user_id, ( $email_password ? $user_password : __( 'The password you chose during installation.' ) ) ); |
|
117 | + wp_new_blog_notification($blog_title, $guessurl, $user_id, ($email_password ? $user_password : __('The password you chose during installation.'))); |
|
118 | 118 | |
119 | 119 | wp_cache_flush(); |
120 | 120 | |
@@ -125,7 +125,7 @@ discard block |
||
125 | 125 | * |
126 | 126 | * @param WP_User $user The site owner. |
127 | 127 | */ |
128 | - do_action( 'wp_install', $user ); |
|
128 | + do_action('wp_install', $user); |
|
129 | 129 | |
130 | 130 | return array( |
131 | 131 | 'url' => $guessurl, |
@@ -136,7 +136,7 @@ discard block |
||
136 | 136 | } |
137 | 137 | endif; |
138 | 138 | |
139 | -if ( ! function_exists( 'wp_install_defaults' ) ) : |
|
139 | +if (!function_exists('wp_install_defaults')) : |
|
140 | 140 | /** |
141 | 141 | * Creates the initial content for a newly-installed site. |
142 | 142 | * |
@@ -151,29 +151,29 @@ discard block |
||
151 | 151 | * |
152 | 152 | * @param int $user_id User ID. |
153 | 153 | */ |
154 | - function wp_install_defaults( $user_id ) { |
|
154 | + function wp_install_defaults($user_id) { |
|
155 | 155 | global $wpdb, $wp_rewrite, $table_prefix; |
156 | 156 | |
157 | 157 | // Default category. |
158 | - $cat_name = __( 'Uncategorized' ); |
|
158 | + $cat_name = __('Uncategorized'); |
|
159 | 159 | /* translators: Default category slug. */ |
160 | - $cat_slug = sanitize_title( _x( 'Uncategorized', 'Default category slug' ) ); |
|
160 | + $cat_slug = sanitize_title(_x('Uncategorized', 'Default category slug')); |
|
161 | 161 | |
162 | - if ( global_terms_enabled() ) { |
|
163 | - $cat_id = $wpdb->get_var( $wpdb->prepare( "SELECT cat_ID FROM {$wpdb->sitecategories} WHERE category_nicename = %s", $cat_slug ) ); |
|
164 | - if ( null == $cat_id ) { |
|
162 | + if (global_terms_enabled()) { |
|
163 | + $cat_id = $wpdb->get_var($wpdb->prepare("SELECT cat_ID FROM {$wpdb->sitecategories} WHERE category_nicename = %s", $cat_slug)); |
|
164 | + if (null == $cat_id) { |
|
165 | 165 | $wpdb->insert( |
166 | 166 | $wpdb->sitecategories, |
167 | 167 | array( |
168 | 168 | 'cat_ID' => 0, |
169 | 169 | 'cat_name' => $cat_name, |
170 | 170 | 'category_nicename' => $cat_slug, |
171 | - 'last_updated' => current_time( 'mysql', true ), |
|
171 | + 'last_updated' => current_time('mysql', true), |
|
172 | 172 | ) |
173 | 173 | ); |
174 | 174 | $cat_id = $wpdb->insert_id; |
175 | 175 | } |
176 | - update_option( 'default_category', $cat_id ); |
|
176 | + update_option('default_category', $cat_id); |
|
177 | 177 | } else { |
178 | 178 | $cat_id = 1; |
179 | 179 | } |
@@ -200,32 +200,32 @@ discard block |
||
200 | 200 | $cat_tt_id = $wpdb->insert_id; |
201 | 201 | |
202 | 202 | // First post. |
203 | - $now = current_time( 'mysql' ); |
|
204 | - $now_gmt = current_time( 'mysql', 1 ); |
|
205 | - $first_post_guid = get_option( 'home' ) . '/?p=1'; |
|
203 | + $now = current_time('mysql'); |
|
204 | + $now_gmt = current_time('mysql', 1); |
|
205 | + $first_post_guid = get_option('home') . '/?p=1'; |
|
206 | 206 | |
207 | - if ( is_multisite() ) { |
|
208 | - $first_post = get_site_option( 'first_post' ); |
|
207 | + if (is_multisite()) { |
|
208 | + $first_post = get_site_option('first_post'); |
|
209 | 209 | |
210 | - if ( ! $first_post ) { |
|
210 | + if (!$first_post) { |
|
211 | 211 | $first_post = "<!-- wp:paragraph -->\n<p>" . |
212 | 212 | /* translators: First post content. %s: Site link. */ |
213 | - __( 'Welcome to %s. This is your first post. Edit or delete it, then start writing!' ) . |
|
213 | + __('Welcome to %s. This is your first post. Edit or delete it, then start writing!') . |
|
214 | 214 | "</p>\n<!-- /wp:paragraph -->"; |
215 | 215 | } |
216 | 216 | |
217 | 217 | $first_post = sprintf( |
218 | 218 | $first_post, |
219 | - sprintf( '<a href="%s">%s</a>', esc_url( network_home_url() ), get_network()->site_name ) |
|
219 | + sprintf('<a href="%s">%s</a>', esc_url(network_home_url()), get_network()->site_name) |
|
220 | 220 | ); |
221 | 221 | |
222 | 222 | // Back-compat for pre-4.4. |
223 | - $first_post = str_replace( 'SITE_URL', esc_url( network_home_url() ), $first_post ); |
|
224 | - $first_post = str_replace( 'SITE_NAME', get_network()->site_name, $first_post ); |
|
223 | + $first_post = str_replace('SITE_URL', esc_url(network_home_url()), $first_post); |
|
224 | + $first_post = str_replace('SITE_NAME', get_network()->site_name, $first_post); |
|
225 | 225 | } else { |
226 | 226 | $first_post = "<!-- wp:paragraph -->\n<p>" . |
227 | 227 | /* translators: First post content. %s: Site link. */ |
228 | - __( 'Welcome to WordPress. This is your first post. Edit or delete it, then start writing!' ) . |
|
228 | + __('Welcome to WordPress. This is your first post. Edit or delete it, then start writing!') . |
|
229 | 229 | "</p>\n<!-- /wp:paragraph -->"; |
230 | 230 | } |
231 | 231 | |
@@ -237,9 +237,9 @@ discard block |
||
237 | 237 | 'post_date_gmt' => $now_gmt, |
238 | 238 | 'post_content' => $first_post, |
239 | 239 | 'post_excerpt' => '', |
240 | - 'post_title' => __( 'Hello world!' ), |
|
240 | + 'post_title' => __('Hello world!'), |
|
241 | 241 | /* translators: Default post slug. */ |
242 | - 'post_name' => sanitize_title( _x( 'hello-world', 'Default post slug' ) ), |
|
242 | + 'post_name' => sanitize_title(_x('hello-world', 'Default post slug')), |
|
243 | 243 | 'post_modified' => $now, |
244 | 244 | 'post_modified_gmt' => $now_gmt, |
245 | 245 | 'guid' => $first_post_guid, |
@@ -250,7 +250,7 @@ discard block |
||
250 | 250 | ) |
251 | 251 | ); |
252 | 252 | |
253 | - if ( is_multisite() ) { |
|
253 | + if (is_multisite()) { |
|
254 | 254 | update_posts_count(); |
255 | 255 | } |
256 | 256 | |
@@ -263,24 +263,24 @@ discard block |
||
263 | 263 | ); |
264 | 264 | |
265 | 265 | // Default comment. |
266 | - if ( is_multisite() ) { |
|
267 | - $first_comment_author = get_site_option( 'first_comment_author' ); |
|
268 | - $first_comment_email = get_site_option( 'first_comment_email' ); |
|
269 | - $first_comment_url = get_site_option( 'first_comment_url', network_home_url() ); |
|
270 | - $first_comment = get_site_option( 'first_comment' ); |
|
266 | + if (is_multisite()) { |
|
267 | + $first_comment_author = get_site_option('first_comment_author'); |
|
268 | + $first_comment_email = get_site_option('first_comment_email'); |
|
269 | + $first_comment_url = get_site_option('first_comment_url', network_home_url()); |
|
270 | + $first_comment = get_site_option('first_comment'); |
|
271 | 271 | } |
272 | 272 | |
273 | - $first_comment_author = ! empty( $first_comment_author ) ? $first_comment_author : __( 'A WordPress Commenter' ); |
|
274 | - $first_comment_email = ! empty( $first_comment_email ) ? $first_comment_email : '[email protected]'; |
|
275 | - $first_comment_url = ! empty( $first_comment_url ) ? $first_comment_url : esc_url( __( 'https://wordpress.org/' ) ); |
|
276 | - $first_comment = ! empty( $first_comment ) ? $first_comment : sprintf( |
|
273 | + $first_comment_author = !empty($first_comment_author) ? $first_comment_author : __('A WordPress Commenter'); |
|
274 | + $first_comment_email = !empty($first_comment_email) ? $first_comment_email : '[email protected]'; |
|
275 | + $first_comment_url = !empty($first_comment_url) ? $first_comment_url : esc_url(__('https://wordpress.org/')); |
|
276 | + $first_comment = !empty($first_comment) ? $first_comment : sprintf( |
|
277 | 277 | /* translators: %s: Gravatar URL. */ |
278 | 278 | __( |
279 | 279 | 'Hi, this is a comment. |
280 | 280 | To get started with moderating, editing, and deleting comments, please visit the Comments screen in the dashboard. |
281 | 281 | Commenter avatars come from <a href="%s">Gravatar</a>.' |
282 | 282 | ), |
283 | - esc_url( __( 'https://en.gravatar.com/' ) ) |
|
283 | + esc_url(__('https://en.gravatar.com/')) |
|
284 | 284 | ); |
285 | 285 | $wpdb->insert( |
286 | 286 | $wpdb->comments, |
@@ -297,41 +297,41 @@ discard block |
||
297 | 297 | ); |
298 | 298 | |
299 | 299 | // First page. |
300 | - if ( is_multisite() ) { |
|
301 | - $first_page = get_site_option( 'first_page' ); |
|
300 | + if (is_multisite()) { |
|
301 | + $first_page = get_site_option('first_page'); |
|
302 | 302 | } |
303 | 303 | |
304 | - if ( empty( $first_page ) ) { |
|
304 | + if (empty($first_page)) { |
|
305 | 305 | $first_page = "<!-- wp:paragraph -->\n<p>"; |
306 | 306 | /* translators: First page content. */ |
307 | - $first_page .= __( "This is an example page. It's different from a blog post because it will stay in one place and will show up in your site navigation (in most themes). Most people start with an About page that introduces them to potential site visitors. It might say something like this:" ); |
|
307 | + $first_page .= __("This is an example page. It's different from a blog post because it will stay in one place and will show up in your site navigation (in most themes). Most people start with an About page that introduces them to potential site visitors. It might say something like this:"); |
|
308 | 308 | $first_page .= "</p>\n<!-- /wp:paragraph -->\n\n"; |
309 | 309 | |
310 | 310 | $first_page .= "<!-- wp:quote -->\n<blockquote class=\"wp-block-quote\"><p>"; |
311 | 311 | /* translators: First page content. */ |
312 | - $first_page .= __( "Hi there! I'm a bike messenger by day, aspiring actor by night, and this is my website. I live in Los Angeles, have a great dog named Jack, and I like piña coladas. (And gettin' caught in the rain.)" ); |
|
312 | + $first_page .= __("Hi there! I'm a bike messenger by day, aspiring actor by night, and this is my website. I live in Los Angeles, have a great dog named Jack, and I like piña coladas. (And gettin' caught in the rain.)"); |
|
313 | 313 | $first_page .= "</p></blockquote>\n<!-- /wp:quote -->\n\n"; |
314 | 314 | |
315 | 315 | $first_page .= "<!-- wp:paragraph -->\n<p>"; |
316 | 316 | /* translators: First page content. */ |
317 | - $first_page .= __( '...or something like this:' ); |
|
317 | + $first_page .= __('...or something like this:'); |
|
318 | 318 | $first_page .= "</p>\n<!-- /wp:paragraph -->\n\n"; |
319 | 319 | |
320 | 320 | $first_page .= "<!-- wp:quote -->\n<blockquote class=\"wp-block-quote\"><p>"; |
321 | 321 | /* translators: First page content. */ |
322 | - $first_page .= __( 'The XYZ Doohickey Company was founded in 1971, and has been providing quality doohickeys to the public ever since. Located in Gotham City, XYZ employs over 2,000 people and does all kinds of awesome things for the Gotham community.' ); |
|
322 | + $first_page .= __('The XYZ Doohickey Company was founded in 1971, and has been providing quality doohickeys to the public ever since. Located in Gotham City, XYZ employs over 2,000 people and does all kinds of awesome things for the Gotham community.'); |
|
323 | 323 | $first_page .= "</p></blockquote>\n<!-- /wp:quote -->\n\n"; |
324 | 324 | |
325 | 325 | $first_page .= "<!-- wp:paragraph -->\n<p>"; |
326 | 326 | $first_page .= sprintf( |
327 | 327 | /* translators: First page content. %s: Site admin URL. */ |
328 | - __( 'As a new WordPress user, you should go to <a href="%s">your dashboard</a> to delete this page and create new pages for your content. Have fun!' ), |
|
328 | + __('As a new WordPress user, you should go to <a href="%s">your dashboard</a> to delete this page and create new pages for your content. Have fun!'), |
|
329 | 329 | admin_url() |
330 | 330 | ); |
331 | 331 | $first_page .= "</p>\n<!-- /wp:paragraph -->"; |
332 | 332 | } |
333 | 333 | |
334 | - $first_post_guid = get_option( 'home' ) . '/?page_id=2'; |
|
334 | + $first_post_guid = get_option('home') . '/?page_id=2'; |
|
335 | 335 | $wpdb->insert( |
336 | 336 | $wpdb->posts, |
337 | 337 | array( |
@@ -341,9 +341,9 @@ discard block |
||
341 | 341 | 'post_content' => $first_page, |
342 | 342 | 'post_excerpt' => '', |
343 | 343 | 'comment_status' => 'closed', |
344 | - 'post_title' => __( 'Sample Page' ), |
|
344 | + 'post_title' => __('Sample Page'), |
|
345 | 345 | /* translators: Default page slug. */ |
346 | - 'post_name' => __( 'sample-page' ), |
|
346 | + 'post_name' => __('sample-page'), |
|
347 | 347 | 'post_modified' => $now, |
348 | 348 | 'post_modified_gmt' => $now_gmt, |
349 | 349 | 'guid' => $first_post_guid, |
@@ -363,19 +363,19 @@ discard block |
||
363 | 363 | ); |
364 | 364 | |
365 | 365 | // Privacy Policy page. |
366 | - if ( is_multisite() ) { |
|
366 | + if (is_multisite()) { |
|
367 | 367 | // Disable by default unless the suggested content is provided. |
368 | - $privacy_policy_content = get_site_option( 'default_privacy_policy_content' ); |
|
368 | + $privacy_policy_content = get_site_option('default_privacy_policy_content'); |
|
369 | 369 | } else { |
370 | - if ( ! class_exists( 'WP_Privacy_Policy_Content' ) ) { |
|
370 | + if (!class_exists('WP_Privacy_Policy_Content')) { |
|
371 | 371 | include_once ABSPATH . 'wp-admin/includes/class-wp-privacy-policy-content.php'; |
372 | 372 | } |
373 | 373 | |
374 | 374 | $privacy_policy_content = WP_Privacy_Policy_Content::get_default_content(); |
375 | 375 | } |
376 | 376 | |
377 | - if ( ! empty( $privacy_policy_content ) ) { |
|
378 | - $privacy_policy_guid = get_option( 'home' ) . '/?page_id=3'; |
|
377 | + if (!empty($privacy_policy_content)) { |
|
378 | + $privacy_policy_guid = get_option('home') . '/?page_id=3'; |
|
379 | 379 | |
380 | 380 | $wpdb->insert( |
381 | 381 | $wpdb->posts, |
@@ -386,9 +386,9 @@ discard block |
||
386 | 386 | 'post_content' => $privacy_policy_content, |
387 | 387 | 'post_excerpt' => '', |
388 | 388 | 'comment_status' => 'closed', |
389 | - 'post_title' => __( 'Privacy Policy' ), |
|
389 | + 'post_title' => __('Privacy Policy'), |
|
390 | 390 | /* translators: Privacy Policy page slug. */ |
391 | - 'post_name' => __( 'privacy-policy' ), |
|
391 | + 'post_name' => __('privacy-policy'), |
|
392 | 392 | 'post_modified' => $now, |
393 | 393 | 'post_modified_gmt' => $now_gmt, |
394 | 394 | 'guid' => $privacy_policy_guid, |
@@ -407,18 +407,18 @@ discard block |
||
407 | 407 | 'meta_value' => 'default', |
408 | 408 | ) |
409 | 409 | ); |
410 | - update_option( 'wp_page_for_privacy_policy', 3 ); |
|
410 | + update_option('wp_page_for_privacy_policy', 3); |
|
411 | 411 | } |
412 | 412 | |
413 | 413 | // Set up default widgets for default theme. |
414 | 414 | update_option( |
415 | 415 | 'widget_block', |
416 | 416 | array( |
417 | - 2 => array( 'content' => '<!-- wp:search /-->' ), |
|
418 | - 3 => array( 'content' => '<!-- wp:group --><div class="wp-block-group"><!-- wp:heading --><h2>' . __( 'Recent Posts' ) . '</h2><!-- /wp:heading --><!-- wp:latest-posts /--></div><!-- /wp:group -->' ), |
|
419 | - 4 => array( 'content' => '<!-- wp:group --><div class="wp-block-group"><!-- wp:heading --><h2>' . __( 'Recent Comments' ) . '</h2><!-- /wp:heading --><!-- wp:latest-comments {"displayAvatar":false,"displayDate":false,"displayExcerpt":false} /--></div><!-- /wp:group -->' ), |
|
420 | - 5 => array( 'content' => '<!-- wp:group --><div class="wp-block-group"><!-- wp:heading --><h2>' . __( 'Archives' ) . '</h2><!-- /wp:heading --><!-- wp:archives /--></div><!-- /wp:group -->' ), |
|
421 | - 6 => array( 'content' => '<!-- wp:group --><div class="wp-block-group"><!-- wp:heading --><h2>' . __( 'Categories' ) . '</h2><!-- /wp:heading --><!-- wp:categories /--></div><!-- /wp:group -->' ), |
|
417 | + 2 => array('content' => '<!-- wp:search /-->'), |
|
418 | + 3 => array('content' => '<!-- wp:group --><div class="wp-block-group"><!-- wp:heading --><h2>' . __('Recent Posts') . '</h2><!-- /wp:heading --><!-- wp:latest-posts /--></div><!-- /wp:group -->'), |
|
419 | + 4 => array('content' => '<!-- wp:group --><div class="wp-block-group"><!-- wp:heading --><h2>' . __('Recent Comments') . '</h2><!-- /wp:heading --><!-- wp:latest-comments {"displayAvatar":false,"displayDate":false,"displayExcerpt":false} /--></div><!-- /wp:group -->'), |
|
420 | + 5 => array('content' => '<!-- wp:group --><div class="wp-block-group"><!-- wp:heading --><h2>' . __('Archives') . '</h2><!-- /wp:heading --><!-- wp:archives /--></div><!-- /wp:group -->'), |
|
421 | + 6 => array('content' => '<!-- wp:group --><div class="wp-block-group"><!-- wp:heading --><h2>' . __('Categories') . '</h2><!-- /wp:heading --><!-- wp:categories /--></div><!-- /wp:group -->'), |
|
422 | 422 | '_multiwidget' => 1, |
423 | 423 | ) |
424 | 424 | ); |
@@ -439,27 +439,27 @@ discard block |
||
439 | 439 | ) |
440 | 440 | ); |
441 | 441 | |
442 | - if ( ! is_multisite() ) { |
|
443 | - update_user_meta( $user_id, 'show_welcome_panel', 1 ); |
|
444 | - } elseif ( ! is_super_admin( $user_id ) && ! metadata_exists( 'user', $user_id, 'show_welcome_panel' ) ) { |
|
445 | - update_user_meta( $user_id, 'show_welcome_panel', 2 ); |
|
442 | + if (!is_multisite()) { |
|
443 | + update_user_meta($user_id, 'show_welcome_panel', 1); |
|
444 | + } elseif (!is_super_admin($user_id) && !metadata_exists('user', $user_id, 'show_welcome_panel')) { |
|
445 | + update_user_meta($user_id, 'show_welcome_panel', 2); |
|
446 | 446 | } |
447 | 447 | |
448 | - if ( is_multisite() ) { |
|
448 | + if (is_multisite()) { |
|
449 | 449 | // Flush rules to pick up the new page. |
450 | 450 | $wp_rewrite->init(); |
451 | 451 | $wp_rewrite->flush_rules(); |
452 | 452 | |
453 | - $user = new WP_User( $user_id ); |
|
454 | - $wpdb->update( $wpdb->options, array( 'option_value' => $user->user_email ), array( 'option_name' => 'admin_email' ) ); |
|
453 | + $user = new WP_User($user_id); |
|
454 | + $wpdb->update($wpdb->options, array('option_value' => $user->user_email), array('option_name' => 'admin_email')); |
|
455 | 455 | |
456 | 456 | // Remove all perms except for the login user. |
457 | - $wpdb->query( $wpdb->prepare( "DELETE FROM $wpdb->usermeta WHERE user_id != %d AND meta_key = %s", $user_id, $table_prefix . 'user_level' ) ); |
|
458 | - $wpdb->query( $wpdb->prepare( "DELETE FROM $wpdb->usermeta WHERE user_id != %d AND meta_key = %s", $user_id, $table_prefix . 'capabilities' ) ); |
|
457 | + $wpdb->query($wpdb->prepare("DELETE FROM $wpdb->usermeta WHERE user_id != %d AND meta_key = %s", $user_id, $table_prefix . 'user_level')); |
|
458 | + $wpdb->query($wpdb->prepare("DELETE FROM $wpdb->usermeta WHERE user_id != %d AND meta_key = %s", $user_id, $table_prefix . 'capabilities')); |
|
459 | 459 | |
460 | 460 | // Delete any caps that snuck into the previously active blog. (Hardcoded to blog 1 for now.) |
461 | 461 | // TODO: Get previous_blog_id. |
462 | - if ( ! is_super_admin( $user_id ) && 1 != $user_id ) { |
|
462 | + if (!is_super_admin($user_id) && 1 != $user_id) { |
|
463 | 463 | $wpdb->delete( |
464 | 464 | $wpdb->usermeta, |
465 | 465 | array( |
@@ -487,7 +487,7 @@ discard block |
||
487 | 487 | global $wp_rewrite; |
488 | 488 | |
489 | 489 | // Bail if a permalink structure is already enabled. |
490 | - if ( get_option( 'permalink_structure' ) ) { |
|
490 | + if (get_option('permalink_structure')) { |
|
491 | 491 | return true; |
492 | 492 | } |
493 | 493 | |
@@ -504,21 +504,21 @@ discard block |
||
504 | 504 | '/index.php/%year%/%monthnum%/%day%/%postname%/', |
505 | 505 | ); |
506 | 506 | |
507 | - foreach ( (array) $permalink_structures as $permalink_structure ) { |
|
508 | - $wp_rewrite->set_permalink_structure( $permalink_structure ); |
|
507 | + foreach ((array) $permalink_structures as $permalink_structure) { |
|
508 | + $wp_rewrite->set_permalink_structure($permalink_structure); |
|
509 | 509 | |
510 | 510 | /* |
511 | 511 | * Flush rules with the hard option to force refresh of the web-server's |
512 | 512 | * rewrite config file (e.g. .htaccess or web.config). |
513 | 513 | */ |
514 | - $wp_rewrite->flush_rules( true ); |
|
514 | + $wp_rewrite->flush_rules(true); |
|
515 | 515 | |
516 | 516 | $test_url = ''; |
517 | 517 | |
518 | 518 | // Test against a real WordPress post. |
519 | - $first_post = get_page_by_path( sanitize_title( _x( 'hello-world', 'Default post slug' ) ), OBJECT, 'post' ); |
|
520 | - if ( $first_post ) { |
|
521 | - $test_url = get_permalink( $first_post->ID ); |
|
519 | + $first_post = get_page_by_path(sanitize_title(_x('hello-world', 'Default post slug')), OBJECT, 'post'); |
|
520 | + if ($first_post) { |
|
521 | + $test_url = get_permalink($first_post->ID); |
|
522 | 522 | } |
523 | 523 | |
524 | 524 | /* |
@@ -528,11 +528,11 @@ discard block |
||
528 | 528 | * Uses wp_remote_get() instead of wp_remote_head() because web servers |
529 | 529 | * can block head requests. |
530 | 530 | */ |
531 | - $response = wp_remote_get( $test_url, array( 'timeout' => 5 ) ); |
|
532 | - $x_pingback_header = wp_remote_retrieve_header( $response, 'x-pingback' ); |
|
533 | - $pretty_permalinks = $x_pingback_header && get_bloginfo( 'pingback_url' ) === $x_pingback_header; |
|
531 | + $response = wp_remote_get($test_url, array('timeout' => 5)); |
|
532 | + $x_pingback_header = wp_remote_retrieve_header($response, 'x-pingback'); |
|
533 | + $pretty_permalinks = $x_pingback_header && get_bloginfo('pingback_url') === $x_pingback_header; |
|
534 | 534 | |
535 | - if ( $pretty_permalinks ) { |
|
535 | + if ($pretty_permalinks) { |
|
536 | 536 | return true; |
537 | 537 | } |
538 | 538 | } |
@@ -541,13 +541,13 @@ discard block |
||
541 | 541 | * If it makes it this far, pretty permalinks failed. |
542 | 542 | * Fallback to query-string permalinks. |
543 | 543 | */ |
544 | - $wp_rewrite->set_permalink_structure( '' ); |
|
545 | - $wp_rewrite->flush_rules( true ); |
|
544 | + $wp_rewrite->set_permalink_structure(''); |
|
545 | + $wp_rewrite->flush_rules(true); |
|
546 | 546 | |
547 | 547 | return false; |
548 | 548 | } |
549 | 549 | |
550 | -if ( ! function_exists( 'wp_new_blog_notification' ) ) : |
|
550 | +if (!function_exists('wp_new_blog_notification')) : |
|
551 | 551 | /** |
552 | 552 | * Notifies the site admin that the installation of WordPress is complete. |
553 | 553 | * |
@@ -562,8 +562,8 @@ discard block |
||
562 | 562 | * @param string $password Administrator's password. Note that a placeholder message is |
563 | 563 | * usually passed instead of the actual password. |
564 | 564 | */ |
565 | - function wp_new_blog_notification( $blog_title, $blog_url, $user_id, $password ) { |
|
566 | - $user = new WP_User( $user_id ); |
|
565 | + function wp_new_blog_notification($blog_title, $blog_url, $user_id, $password) { |
|
566 | + $user = new WP_User($user_id); |
|
567 | 567 | $email = $user->user_email; |
568 | 568 | $name = $user->user_login; |
569 | 569 | $login_url = wp_login_url(); |
@@ -595,7 +595,7 @@ discard block |
||
595 | 595 | |
596 | 596 | $installed_email = array( |
597 | 597 | 'to' => $email, |
598 | - 'subject' => __( 'New WordPress Site' ), |
|
598 | + 'subject' => __('New WordPress Site'), |
|
599 | 599 | 'message' => $message, |
600 | 600 | 'headers' => '', |
601 | 601 | ); |
@@ -619,7 +619,7 @@ discard block |
||
619 | 619 | * @param string $password The site administrator's password. Note that a placeholder message |
620 | 620 | * is usually passed instead of the user's actual password. |
621 | 621 | */ |
622 | - $installed_email = apply_filters( 'wp_installed_email', $installed_email, $user, $blog_title, $blog_url, $password ); |
|
622 | + $installed_email = apply_filters('wp_installed_email', $installed_email, $user, $blog_title, $blog_url, $password); |
|
623 | 623 | |
624 | 624 | wp_mail( |
625 | 625 | $installed_email['to'], |
@@ -630,7 +630,7 @@ discard block |
||
630 | 630 | } |
631 | 631 | endif; |
632 | 632 | |
633 | -if ( ! function_exists( 'wp_upgrade' ) ) : |
|
633 | +if (!function_exists('wp_upgrade')) : |
|
634 | 634 | /** |
635 | 635 | * Runs WordPress Upgrade functions. |
636 | 636 | * |
@@ -645,14 +645,14 @@ discard block |
||
645 | 645 | function wp_upgrade() { |
646 | 646 | global $wp_current_db_version, $wp_db_version, $wpdb; |
647 | 647 | |
648 | - $wp_current_db_version = __get_option( 'db_version' ); |
|
648 | + $wp_current_db_version = __get_option('db_version'); |
|
649 | 649 | |
650 | 650 | // We are up to date. Nothing to do. |
651 | - if ( $wp_db_version == $wp_current_db_version ) { |
|
651 | + if ($wp_db_version == $wp_current_db_version) { |
|
652 | 652 | return; |
653 | 653 | } |
654 | 654 | |
655 | - if ( ! is_blog_installed() ) { |
|
655 | + if (!is_blog_installed()) { |
|
656 | 656 | return; |
657 | 657 | } |
658 | 658 | |
@@ -661,14 +661,14 @@ discard block |
||
661 | 661 | pre_schema_upgrade(); |
662 | 662 | make_db_current_silent(); |
663 | 663 | upgrade_all(); |
664 | - if ( is_multisite() && is_main_site() ) { |
|
664 | + if (is_multisite() && is_main_site()) { |
|
665 | 665 | upgrade_network(); |
666 | 666 | } |
667 | 667 | wp_cache_flush(); |
668 | 668 | |
669 | - if ( is_multisite() ) { |
|
670 | - update_site_meta( get_current_blog_id(), 'db_version', $wp_db_version ); |
|
671 | - update_site_meta( get_current_blog_id(), 'db_last_updated', microtime() ); |
|
669 | + if (is_multisite()) { |
|
670 | + update_site_meta(get_current_blog_id(), 'db_version', $wp_db_version); |
|
671 | + update_site_meta(get_current_blog_id(), 'db_last_updated', microtime()); |
|
672 | 672 | } |
673 | 673 | |
674 | 674 | /** |
@@ -679,7 +679,7 @@ discard block |
||
679 | 679 | * @param int $wp_db_version The new $wp_db_version. |
680 | 680 | * @param int $wp_current_db_version The old (current) $wp_db_version. |
681 | 681 | */ |
682 | - do_action( 'wp_upgrade', $wp_db_version, $wp_current_db_version ); |
|
682 | + do_action('wp_upgrade', $wp_db_version, $wp_current_db_version); |
|
683 | 683 | } |
684 | 684 | endif; |
685 | 685 | |
@@ -698,154 +698,154 @@ discard block |
||
698 | 698 | function upgrade_all() { |
699 | 699 | global $wp_current_db_version, $wp_db_version; |
700 | 700 | |
701 | - $wp_current_db_version = __get_option( 'db_version' ); |
|
701 | + $wp_current_db_version = __get_option('db_version'); |
|
702 | 702 | |
703 | 703 | // We are up to date. Nothing to do. |
704 | - if ( $wp_db_version == $wp_current_db_version ) { |
|
704 | + if ($wp_db_version == $wp_current_db_version) { |
|
705 | 705 | return; |
706 | 706 | } |
707 | 707 | |
708 | 708 | // If the version is not set in the DB, try to guess the version. |
709 | - if ( empty( $wp_current_db_version ) ) { |
|
709 | + if (empty($wp_current_db_version)) { |
|
710 | 710 | $wp_current_db_version = 0; |
711 | 711 | |
712 | 712 | // If the template option exists, we have 1.5. |
713 | - $template = __get_option( 'template' ); |
|
714 | - if ( ! empty( $template ) ) { |
|
713 | + $template = __get_option('template'); |
|
714 | + if (!empty($template)) { |
|
715 | 715 | $wp_current_db_version = 2541; |
716 | 716 | } |
717 | 717 | } |
718 | 718 | |
719 | - if ( $wp_current_db_version < 6039 ) { |
|
719 | + if ($wp_current_db_version < 6039) { |
|
720 | 720 | upgrade_230_options_table(); |
721 | 721 | } |
722 | 722 | |
723 | 723 | populate_options(); |
724 | 724 | |
725 | - if ( $wp_current_db_version < 2541 ) { |
|
725 | + if ($wp_current_db_version < 2541) { |
|
726 | 726 | upgrade_100(); |
727 | 727 | upgrade_101(); |
728 | 728 | upgrade_110(); |
729 | 729 | upgrade_130(); |
730 | 730 | } |
731 | 731 | |
732 | - if ( $wp_current_db_version < 3308 ) { |
|
732 | + if ($wp_current_db_version < 3308) { |
|
733 | 733 | upgrade_160(); |
734 | 734 | } |
735 | 735 | |
736 | - if ( $wp_current_db_version < 4772 ) { |
|
736 | + if ($wp_current_db_version < 4772) { |
|
737 | 737 | upgrade_210(); |
738 | 738 | } |
739 | 739 | |
740 | - if ( $wp_current_db_version < 4351 ) { |
|
740 | + if ($wp_current_db_version < 4351) { |
|
741 | 741 | upgrade_old_slugs(); |
742 | 742 | } |
743 | 743 | |
744 | - if ( $wp_current_db_version < 5539 ) { |
|
744 | + if ($wp_current_db_version < 5539) { |
|
745 | 745 | upgrade_230(); |
746 | 746 | } |
747 | 747 | |
748 | - if ( $wp_current_db_version < 6124 ) { |
|
748 | + if ($wp_current_db_version < 6124) { |
|
749 | 749 | upgrade_230_old_tables(); |
750 | 750 | } |
751 | 751 | |
752 | - if ( $wp_current_db_version < 7499 ) { |
|
752 | + if ($wp_current_db_version < 7499) { |
|
753 | 753 | upgrade_250(); |
754 | 754 | } |
755 | 755 | |
756 | - if ( $wp_current_db_version < 7935 ) { |
|
756 | + if ($wp_current_db_version < 7935) { |
|
757 | 757 | upgrade_252(); |
758 | 758 | } |
759 | 759 | |
760 | - if ( $wp_current_db_version < 8201 ) { |
|
760 | + if ($wp_current_db_version < 8201) { |
|
761 | 761 | upgrade_260(); |
762 | 762 | } |
763 | 763 | |
764 | - if ( $wp_current_db_version < 8989 ) { |
|
764 | + if ($wp_current_db_version < 8989) { |
|
765 | 765 | upgrade_270(); |
766 | 766 | } |
767 | 767 | |
768 | - if ( $wp_current_db_version < 10360 ) { |
|
768 | + if ($wp_current_db_version < 10360) { |
|
769 | 769 | upgrade_280(); |
770 | 770 | } |
771 | 771 | |
772 | - if ( $wp_current_db_version < 11958 ) { |
|
772 | + if ($wp_current_db_version < 11958) { |
|
773 | 773 | upgrade_290(); |
774 | 774 | } |
775 | 775 | |
776 | - if ( $wp_current_db_version < 15260 ) { |
|
776 | + if ($wp_current_db_version < 15260) { |
|
777 | 777 | upgrade_300(); |
778 | 778 | } |
779 | 779 | |
780 | - if ( $wp_current_db_version < 19389 ) { |
|
780 | + if ($wp_current_db_version < 19389) { |
|
781 | 781 | upgrade_330(); |
782 | 782 | } |
783 | 783 | |
784 | - if ( $wp_current_db_version < 20080 ) { |
|
784 | + if ($wp_current_db_version < 20080) { |
|
785 | 785 | upgrade_340(); |
786 | 786 | } |
787 | 787 | |
788 | - if ( $wp_current_db_version < 22422 ) { |
|
788 | + if ($wp_current_db_version < 22422) { |
|
789 | 789 | upgrade_350(); |
790 | 790 | } |
791 | 791 | |
792 | - if ( $wp_current_db_version < 25824 ) { |
|
792 | + if ($wp_current_db_version < 25824) { |
|
793 | 793 | upgrade_370(); |
794 | 794 | } |
795 | 795 | |
796 | - if ( $wp_current_db_version < 26148 ) { |
|
796 | + if ($wp_current_db_version < 26148) { |
|
797 | 797 | upgrade_372(); |
798 | 798 | } |
799 | 799 | |
800 | - if ( $wp_current_db_version < 26691 ) { |
|
800 | + if ($wp_current_db_version < 26691) { |
|
801 | 801 | upgrade_380(); |
802 | 802 | } |
803 | 803 | |
804 | - if ( $wp_current_db_version < 29630 ) { |
|
804 | + if ($wp_current_db_version < 29630) { |
|
805 | 805 | upgrade_400(); |
806 | 806 | } |
807 | 807 | |
808 | - if ( $wp_current_db_version < 33055 ) { |
|
808 | + if ($wp_current_db_version < 33055) { |
|
809 | 809 | upgrade_430(); |
810 | 810 | } |
811 | 811 | |
812 | - if ( $wp_current_db_version < 33056 ) { |
|
812 | + if ($wp_current_db_version < 33056) { |
|
813 | 813 | upgrade_431(); |
814 | 814 | } |
815 | 815 | |
816 | - if ( $wp_current_db_version < 35700 ) { |
|
816 | + if ($wp_current_db_version < 35700) { |
|
817 | 817 | upgrade_440(); |
818 | 818 | } |
819 | 819 | |
820 | - if ( $wp_current_db_version < 36686 ) { |
|
820 | + if ($wp_current_db_version < 36686) { |
|
821 | 821 | upgrade_450(); |
822 | 822 | } |
823 | 823 | |
824 | - if ( $wp_current_db_version < 37965 ) { |
|
824 | + if ($wp_current_db_version < 37965) { |
|
825 | 825 | upgrade_460(); |
826 | 826 | } |
827 | 827 | |
828 | - if ( $wp_current_db_version < 44719 ) { |
|
828 | + if ($wp_current_db_version < 44719) { |
|
829 | 829 | upgrade_510(); |
830 | 830 | } |
831 | 831 | |
832 | - if ( $wp_current_db_version < 45744 ) { |
|
832 | + if ($wp_current_db_version < 45744) { |
|
833 | 833 | upgrade_530(); |
834 | 834 | } |
835 | 835 | |
836 | - if ( $wp_current_db_version < 48575 ) { |
|
836 | + if ($wp_current_db_version < 48575) { |
|
837 | 837 | upgrade_550(); |
838 | 838 | } |
839 | 839 | |
840 | - if ( $wp_current_db_version < 49752 ) { |
|
840 | + if ($wp_current_db_version < 49752) { |
|
841 | 841 | upgrade_560(); |
842 | 842 | } |
843 | 843 | |
844 | - if ( $wp_current_db_version < 51917 ) { |
|
844 | + if ($wp_current_db_version < 51917) { |
|
845 | 845 | upgrade_590(); |
846 | 846 | } |
847 | 847 | |
848 | - if ( $wp_current_db_version < 53011 ) { |
|
848 | + if ($wp_current_db_version < 53011) { |
|
849 | 849 | upgrade_600(); |
850 | 850 | } |
851 | 851 | |
@@ -853,8 +853,8 @@ discard block |
||
853 | 853 | |
854 | 854 | maybe_disable_automattic_widgets(); |
855 | 855 | |
856 | - update_option( 'db_version', $wp_db_version ); |
|
857 | - update_option( 'db_upgraded', true ); |
|
856 | + update_option('db_version', $wp_db_version); |
|
857 | + update_option('db_upgraded', true); |
|
858 | 858 | } |
859 | 859 | |
860 | 860 | /** |
@@ -869,21 +869,21 @@ discard block |
||
869 | 869 | global $wpdb; |
870 | 870 | |
871 | 871 | // Get the title and ID of every post, post_name to check if it already has a value. |
872 | - $posts = $wpdb->get_results( "SELECT ID, post_title, post_name FROM $wpdb->posts WHERE post_name = ''" ); |
|
873 | - if ( $posts ) { |
|
874 | - foreach ( $posts as $post ) { |
|
875 | - if ( '' === $post->post_name ) { |
|
876 | - $newtitle = sanitize_title( $post->post_title ); |
|
877 | - $wpdb->query( $wpdb->prepare( "UPDATE $wpdb->posts SET post_name = %s WHERE ID = %d", $newtitle, $post->ID ) ); |
|
872 | + $posts = $wpdb->get_results("SELECT ID, post_title, post_name FROM $wpdb->posts WHERE post_name = ''"); |
|
873 | + if ($posts) { |
|
874 | + foreach ($posts as $post) { |
|
875 | + if ('' === $post->post_name) { |
|
876 | + $newtitle = sanitize_title($post->post_title); |
|
877 | + $wpdb->query($wpdb->prepare("UPDATE $wpdb->posts SET post_name = %s WHERE ID = %d", $newtitle, $post->ID)); |
|
878 | 878 | } |
879 | 879 | } |
880 | 880 | } |
881 | 881 | |
882 | - $categories = $wpdb->get_results( "SELECT cat_ID, cat_name, category_nicename FROM $wpdb->categories" ); |
|
883 | - foreach ( $categories as $category ) { |
|
884 | - if ( '' === $category->category_nicename ) { |
|
885 | - $newtitle = sanitize_title( $category->cat_name ); |
|
886 | - $wpdb->update( $wpdb->categories, array( 'category_nicename' => $newtitle ), array( 'cat_ID' => $category->cat_ID ) ); |
|
882 | + $categories = $wpdb->get_results("SELECT cat_ID, cat_name, category_nicename FROM $wpdb->categories"); |
|
883 | + foreach ($categories as $category) { |
|
884 | + if ('' === $category->category_nicename) { |
|
885 | + $newtitle = sanitize_title($category->cat_name); |
|
886 | + $wpdb->update($wpdb->categories, array('category_nicename' => $newtitle), array('cat_ID' => $category->cat_ID)); |
|
887 | 887 | } |
888 | 888 | } |
889 | 889 | |
@@ -891,25 +891,25 @@ discard block |
||
891 | 891 | SET option_value = REPLACE(option_value, 'wp-links/links-images/', 'wp-images/links/') |
892 | 892 | WHERE option_name LIKE %s |
893 | 893 | AND option_value LIKE %s"; |
894 | - $wpdb->query( $wpdb->prepare( $sql, $wpdb->esc_like( 'links_rating_image' ) . '%', $wpdb->esc_like( 'wp-links/links-images/' ) . '%' ) ); |
|
894 | + $wpdb->query($wpdb->prepare($sql, $wpdb->esc_like('links_rating_image') . '%', $wpdb->esc_like('wp-links/links-images/') . '%')); |
|
895 | 895 | |
896 | - $done_ids = $wpdb->get_results( "SELECT DISTINCT post_id FROM $wpdb->post2cat" ); |
|
897 | - if ( $done_ids ) : |
|
896 | + $done_ids = $wpdb->get_results("SELECT DISTINCT post_id FROM $wpdb->post2cat"); |
|
897 | + if ($done_ids) : |
|
898 | 898 | $done_posts = array(); |
899 | - foreach ( $done_ids as $done_id ) : |
|
899 | + foreach ($done_ids as $done_id) : |
|
900 | 900 | $done_posts[] = $done_id->post_id; |
901 | 901 | endforeach; |
902 | - $catwhere = ' AND ID NOT IN (' . implode( ',', $done_posts ) . ')'; |
|
902 | + $catwhere = ' AND ID NOT IN (' . implode(',', $done_posts) . ')'; |
|
903 | 903 | else : |
904 | 904 | $catwhere = ''; |
905 | 905 | endif; |
906 | 906 | |
907 | - $allposts = $wpdb->get_results( "SELECT ID, post_category FROM $wpdb->posts WHERE post_category != '0' $catwhere" ); |
|
908 | - if ( $allposts ) : |
|
909 | - foreach ( $allposts as $post ) { |
|
907 | + $allposts = $wpdb->get_results("SELECT ID, post_category FROM $wpdb->posts WHERE post_category != '0' $catwhere"); |
|
908 | + if ($allposts) : |
|
909 | + foreach ($allposts as $post) { |
|
910 | 910 | // Check to see if it's already been imported. |
911 | - $cat = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM $wpdb->post2cat WHERE post_id = %d AND category_id = %d", $post->ID, $post->post_category ) ); |
|
912 | - if ( ! $cat && 0 != $post->post_category ) { // If there's no result. |
|
911 | + $cat = $wpdb->get_row($wpdb->prepare("SELECT * FROM $wpdb->post2cat WHERE post_id = %d AND category_id = %d", $post->ID, $post->post_category)); |
|
912 | + if (!$cat && 0 != $post->post_category) { // If there's no result. |
|
913 | 913 | $wpdb->insert( |
914 | 914 | $wpdb->post2cat, |
915 | 915 | array( |
@@ -934,13 +934,13 @@ discard block |
||
934 | 934 | global $wpdb; |
935 | 935 | |
936 | 936 | // Clean up indices, add a few. |
937 | - add_clean_index( $wpdb->posts, 'post_name' ); |
|
938 | - add_clean_index( $wpdb->posts, 'post_status' ); |
|
939 | - add_clean_index( $wpdb->categories, 'category_nicename' ); |
|
940 | - add_clean_index( $wpdb->comments, 'comment_approved' ); |
|
941 | - add_clean_index( $wpdb->comments, 'comment_post_ID' ); |
|
942 | - add_clean_index( $wpdb->links, 'link_category' ); |
|
943 | - add_clean_index( $wpdb->links, 'link_visible' ); |
|
937 | + add_clean_index($wpdb->posts, 'post_name'); |
|
938 | + add_clean_index($wpdb->posts, 'post_status'); |
|
939 | + add_clean_index($wpdb->categories, 'category_nicename'); |
|
940 | + add_clean_index($wpdb->comments, 'comment_approved'); |
|
941 | + add_clean_index($wpdb->comments, 'comment_post_ID'); |
|
942 | + add_clean_index($wpdb->links, 'link_category'); |
|
943 | + add_clean_index($wpdb->links, 'link_visible'); |
|
944 | 944 | } |
945 | 945 | |
946 | 946 | /** |
@@ -955,18 +955,18 @@ discard block |
||
955 | 955 | global $wpdb; |
956 | 956 | |
957 | 957 | // Set user_nicename. |
958 | - $users = $wpdb->get_results( "SELECT ID, user_nickname, user_nicename FROM $wpdb->users" ); |
|
959 | - foreach ( $users as $user ) { |
|
960 | - if ( '' === $user->user_nicename ) { |
|
961 | - $newname = sanitize_title( $user->user_nickname ); |
|
962 | - $wpdb->update( $wpdb->users, array( 'user_nicename' => $newname ), array( 'ID' => $user->ID ) ); |
|
958 | + $users = $wpdb->get_results("SELECT ID, user_nickname, user_nicename FROM $wpdb->users"); |
|
959 | + foreach ($users as $user) { |
|
960 | + if ('' === $user->user_nicename) { |
|
961 | + $newname = sanitize_title($user->user_nickname); |
|
962 | + $wpdb->update($wpdb->users, array('user_nicename' => $newname), array('ID' => $user->ID)); |
|
963 | 963 | } |
964 | 964 | } |
965 | 965 | |
966 | - $users = $wpdb->get_results( "SELECT ID, user_pass from $wpdb->users" ); |
|
967 | - foreach ( $users as $row ) { |
|
968 | - if ( ! preg_match( '/^[A-Fa-f0-9]{32}$/', $row->user_pass ) ) { |
|
969 | - $wpdb->update( $wpdb->users, array( 'user_pass' => md5( $row->user_pass ) ), array( 'ID' => $row->ID ) ); |
|
966 | + $users = $wpdb->get_results("SELECT ID, user_pass from $wpdb->users"); |
|
967 | + foreach ($users as $row) { |
|
968 | + if (!preg_match('/^[A-Fa-f0-9]{32}$/', $row->user_pass)) { |
|
969 | + $wpdb->update($wpdb->users, array('user_pass' => md5($row->user_pass)), array('ID' => $row->ID)); |
|
970 | 970 | } |
971 | 971 | } |
972 | 972 | |
@@ -975,35 +975,35 @@ discard block |
||
975 | 975 | |
976 | 976 | $time_difference = $all_options->time_difference; |
977 | 977 | |
978 | - $server_time = time() + gmdate( 'Z' ); |
|
978 | + $server_time = time() + gmdate('Z'); |
|
979 | 979 | $weblogger_time = $server_time + $time_difference * HOUR_IN_SECONDS; |
980 | 980 | $gmt_time = time(); |
981 | 981 | |
982 | - $diff_gmt_server = ( $gmt_time - $server_time ) / HOUR_IN_SECONDS; |
|
983 | - $diff_weblogger_server = ( $weblogger_time - $server_time ) / HOUR_IN_SECONDS; |
|
982 | + $diff_gmt_server = ($gmt_time - $server_time) / HOUR_IN_SECONDS; |
|
983 | + $diff_weblogger_server = ($weblogger_time - $server_time) / HOUR_IN_SECONDS; |
|
984 | 984 | $diff_gmt_weblogger = $diff_gmt_server - $diff_weblogger_server; |
985 | 985 | $gmt_offset = -$diff_gmt_weblogger; |
986 | 986 | |
987 | 987 | // Add a gmt_offset option, with value $gmt_offset. |
988 | - add_option( 'gmt_offset', $gmt_offset ); |
|
988 | + add_option('gmt_offset', $gmt_offset); |
|
989 | 989 | |
990 | 990 | /* |
991 | 991 | * Check if we already set the GMT fields. If we did, then |
992 | 992 | * MAX(post_date_gmt) can't be '0000-00-00 00:00:00'. |
993 | 993 | * <michel_v> I just slapped myself silly for not thinking about it earlier. |
994 | 994 | */ |
995 | - $got_gmt_fields = ( '0000-00-00 00:00:00' !== $wpdb->get_var( "SELECT MAX(post_date_gmt) FROM $wpdb->posts" ) ); |
|
995 | + $got_gmt_fields = ('0000-00-00 00:00:00' !== $wpdb->get_var("SELECT MAX(post_date_gmt) FROM $wpdb->posts")); |
|
996 | 996 | |
997 | - if ( ! $got_gmt_fields ) { |
|
997 | + if (!$got_gmt_fields) { |
|
998 | 998 | |
999 | 999 | // Add or subtract time to all dates, to get GMT dates. |
1000 | 1000 | $add_hours = (int) $diff_gmt_weblogger; |
1001 | - $add_minutes = (int) ( 60 * ( $diff_gmt_weblogger - $add_hours ) ); |
|
1002 | - $wpdb->query( "UPDATE $wpdb->posts SET post_date_gmt = DATE_ADD(post_date, INTERVAL '$add_hours:$add_minutes' HOUR_MINUTE)" ); |
|
1003 | - $wpdb->query( "UPDATE $wpdb->posts SET post_modified = post_date" ); |
|
1004 | - $wpdb->query( "UPDATE $wpdb->posts SET post_modified_gmt = DATE_ADD(post_modified, INTERVAL '$add_hours:$add_minutes' HOUR_MINUTE) WHERE post_modified != '0000-00-00 00:00:00'" ); |
|
1005 | - $wpdb->query( "UPDATE $wpdb->comments SET comment_date_gmt = DATE_ADD(comment_date, INTERVAL '$add_hours:$add_minutes' HOUR_MINUTE)" ); |
|
1006 | - $wpdb->query( "UPDATE $wpdb->users SET user_registered = DATE_ADD(user_registered, INTERVAL '$add_hours:$add_minutes' HOUR_MINUTE)" ); |
|
1001 | + $add_minutes = (int) (60 * ($diff_gmt_weblogger - $add_hours)); |
|
1002 | + $wpdb->query("UPDATE $wpdb->posts SET post_date_gmt = DATE_ADD(post_date, INTERVAL '$add_hours:$add_minutes' HOUR_MINUTE)"); |
|
1003 | + $wpdb->query("UPDATE $wpdb->posts SET post_modified = post_date"); |
|
1004 | + $wpdb->query("UPDATE $wpdb->posts SET post_modified_gmt = DATE_ADD(post_modified, INTERVAL '$add_hours:$add_minutes' HOUR_MINUTE) WHERE post_modified != '0000-00-00 00:00:00'"); |
|
1005 | + $wpdb->query("UPDATE $wpdb->comments SET comment_date_gmt = DATE_ADD(comment_date, INTERVAL '$add_hours:$add_minutes' HOUR_MINUTE)"); |
|
1006 | + $wpdb->query("UPDATE $wpdb->users SET user_registered = DATE_ADD(user_registered, INTERVAL '$add_hours:$add_minutes' HOUR_MINUTE)"); |
|
1007 | 1007 | } |
1008 | 1008 | |
1009 | 1009 | } |
@@ -1020,75 +1020,75 @@ discard block |
||
1020 | 1020 | global $wpdb; |
1021 | 1021 | |
1022 | 1022 | // Remove extraneous backslashes. |
1023 | - $posts = $wpdb->get_results( "SELECT ID, post_title, post_content, post_excerpt, guid, post_date, post_name, post_status, post_author FROM $wpdb->posts" ); |
|
1024 | - if ( $posts ) { |
|
1025 | - foreach ( $posts as $post ) { |
|
1026 | - $post_content = addslashes( deslash( $post->post_content ) ); |
|
1027 | - $post_title = addslashes( deslash( $post->post_title ) ); |
|
1028 | - $post_excerpt = addslashes( deslash( $post->post_excerpt ) ); |
|
1029 | - if ( empty( $post->guid ) ) { |
|
1030 | - $guid = get_permalink( $post->ID ); |
|
1023 | + $posts = $wpdb->get_results("SELECT ID, post_title, post_content, post_excerpt, guid, post_date, post_name, post_status, post_author FROM $wpdb->posts"); |
|
1024 | + if ($posts) { |
|
1025 | + foreach ($posts as $post) { |
|
1026 | + $post_content = addslashes(deslash($post->post_content)); |
|
1027 | + $post_title = addslashes(deslash($post->post_title)); |
|
1028 | + $post_excerpt = addslashes(deslash($post->post_excerpt)); |
|
1029 | + if (empty($post->guid)) { |
|
1030 | + $guid = get_permalink($post->ID); |
|
1031 | 1031 | } else { |
1032 | 1032 | $guid = $post->guid; |
1033 | 1033 | } |
1034 | 1034 | |
1035 | - $wpdb->update( $wpdb->posts, compact( 'post_title', 'post_content', 'post_excerpt', 'guid' ), array( 'ID' => $post->ID ) ); |
|
1035 | + $wpdb->update($wpdb->posts, compact('post_title', 'post_content', 'post_excerpt', 'guid'), array('ID' => $post->ID)); |
|
1036 | 1036 | |
1037 | 1037 | } |
1038 | 1038 | } |
1039 | 1039 | |
1040 | 1040 | // Remove extraneous backslashes. |
1041 | - $comments = $wpdb->get_results( "SELECT comment_ID, comment_author, comment_content FROM $wpdb->comments" ); |
|
1042 | - if ( $comments ) { |
|
1043 | - foreach ( $comments as $comment ) { |
|
1044 | - $comment_content = deslash( $comment->comment_content ); |
|
1045 | - $comment_author = deslash( $comment->comment_author ); |
|
1041 | + $comments = $wpdb->get_results("SELECT comment_ID, comment_author, comment_content FROM $wpdb->comments"); |
|
1042 | + if ($comments) { |
|
1043 | + foreach ($comments as $comment) { |
|
1044 | + $comment_content = deslash($comment->comment_content); |
|
1045 | + $comment_author = deslash($comment->comment_author); |
|
1046 | 1046 | |
1047 | - $wpdb->update( $wpdb->comments, compact( 'comment_content', 'comment_author' ), array( 'comment_ID' => $comment->comment_ID ) ); |
|
1047 | + $wpdb->update($wpdb->comments, compact('comment_content', 'comment_author'), array('comment_ID' => $comment->comment_ID)); |
|
1048 | 1048 | } |
1049 | 1049 | } |
1050 | 1050 | |
1051 | 1051 | // Remove extraneous backslashes. |
1052 | - $links = $wpdb->get_results( "SELECT link_id, link_name, link_description FROM $wpdb->links" ); |
|
1053 | - if ( $links ) { |
|
1054 | - foreach ( $links as $link ) { |
|
1055 | - $link_name = deslash( $link->link_name ); |
|
1056 | - $link_description = deslash( $link->link_description ); |
|
1052 | + $links = $wpdb->get_results("SELECT link_id, link_name, link_description FROM $wpdb->links"); |
|
1053 | + if ($links) { |
|
1054 | + foreach ($links as $link) { |
|
1055 | + $link_name = deslash($link->link_name); |
|
1056 | + $link_description = deslash($link->link_description); |
|
1057 | 1057 | |
1058 | - $wpdb->update( $wpdb->links, compact( 'link_name', 'link_description' ), array( 'link_id' => $link->link_id ) ); |
|
1058 | + $wpdb->update($wpdb->links, compact('link_name', 'link_description'), array('link_id' => $link->link_id)); |
|
1059 | 1059 | } |
1060 | 1060 | } |
1061 | 1061 | |
1062 | - $active_plugins = __get_option( 'active_plugins' ); |
|
1062 | + $active_plugins = __get_option('active_plugins'); |
|
1063 | 1063 | |
1064 | 1064 | /* |
1065 | 1065 | * If plugins are not stored in an array, they're stored in the old |
1066 | 1066 | * newline separated format. Convert to new format. |
1067 | 1067 | */ |
1068 | - if ( ! is_array( $active_plugins ) ) { |
|
1069 | - $active_plugins = explode( "\n", trim( $active_plugins ) ); |
|
1070 | - update_option( 'active_plugins', $active_plugins ); |
|
1068 | + if (!is_array($active_plugins)) { |
|
1069 | + $active_plugins = explode("\n", trim($active_plugins)); |
|
1070 | + update_option('active_plugins', $active_plugins); |
|
1071 | 1071 | } |
1072 | 1072 | |
1073 | 1073 | // Obsolete tables. |
1074 | - $wpdb->query( 'DROP TABLE IF EXISTS ' . $wpdb->prefix . 'optionvalues' ); |
|
1075 | - $wpdb->query( 'DROP TABLE IF EXISTS ' . $wpdb->prefix . 'optiontypes' ); |
|
1076 | - $wpdb->query( 'DROP TABLE IF EXISTS ' . $wpdb->prefix . 'optiongroups' ); |
|
1077 | - $wpdb->query( 'DROP TABLE IF EXISTS ' . $wpdb->prefix . 'optiongroup_options' ); |
|
1074 | + $wpdb->query('DROP TABLE IF EXISTS ' . $wpdb->prefix . 'optionvalues'); |
|
1075 | + $wpdb->query('DROP TABLE IF EXISTS ' . $wpdb->prefix . 'optiontypes'); |
|
1076 | + $wpdb->query('DROP TABLE IF EXISTS ' . $wpdb->prefix . 'optiongroups'); |
|
1077 | + $wpdb->query('DROP TABLE IF EXISTS ' . $wpdb->prefix . 'optiongroup_options'); |
|
1078 | 1078 | |
1079 | 1079 | // Update comments table to use comment_type. |
1080 | - $wpdb->query( "UPDATE $wpdb->comments SET comment_type='trackback', comment_content = REPLACE(comment_content, '<trackback />', '') WHERE comment_content LIKE '<trackback />%'" ); |
|
1081 | - $wpdb->query( "UPDATE $wpdb->comments SET comment_type='pingback', comment_content = REPLACE(comment_content, '<pingback />', '') WHERE comment_content LIKE '<pingback />%'" ); |
|
1080 | + $wpdb->query("UPDATE $wpdb->comments SET comment_type='trackback', comment_content = REPLACE(comment_content, '<trackback />', '') WHERE comment_content LIKE '<trackback />%'"); |
|
1081 | + $wpdb->query("UPDATE $wpdb->comments SET comment_type='pingback', comment_content = REPLACE(comment_content, '<pingback />', '') WHERE comment_content LIKE '<pingback />%'"); |
|
1082 | 1082 | |
1083 | 1083 | // Some versions have multiple duplicate option_name rows with the same values. |
1084 | - $options = $wpdb->get_results( "SELECT option_name, COUNT(option_name) AS dupes FROM `$wpdb->options` GROUP BY option_name" ); |
|
1085 | - foreach ( $options as $option ) { |
|
1086 | - if ( 1 != $option->dupes ) { // Could this be done in the query? |
|
1084 | + $options = $wpdb->get_results("SELECT option_name, COUNT(option_name) AS dupes FROM `$wpdb->options` GROUP BY option_name"); |
|
1085 | + foreach ($options as $option) { |
|
1086 | + if (1 != $option->dupes) { // Could this be done in the query? |
|
1087 | 1087 | $limit = $option->dupes - 1; |
1088 | - $dupe_ids = $wpdb->get_col( $wpdb->prepare( "SELECT option_id FROM $wpdb->options WHERE option_name = %s LIMIT %d", $option->option_name, $limit ) ); |
|
1089 | - if ( $dupe_ids ) { |
|
1090 | - $dupe_ids = implode( ',', $dupe_ids ); |
|
1091 | - $wpdb->query( "DELETE FROM $wpdb->options WHERE option_id IN ($dupe_ids)" ); |
|
1088 | + $dupe_ids = $wpdb->get_col($wpdb->prepare("SELECT option_id FROM $wpdb->options WHERE option_name = %s LIMIT %d", $option->option_name, $limit)); |
|
1089 | + if ($dupe_ids) { |
|
1090 | + $dupe_ids = implode(',', $dupe_ids); |
|
1091 | + $wpdb->query("DELETE FROM $wpdb->options WHERE option_id IN ($dupe_ids)"); |
|
1092 | 1092 | } |
1093 | 1093 | } |
1094 | 1094 | } |
@@ -1110,83 +1110,83 @@ discard block |
||
1110 | 1110 | |
1111 | 1111 | populate_roles_160(); |
1112 | 1112 | |
1113 | - $users = $wpdb->get_results( "SELECT * FROM $wpdb->users" ); |
|
1114 | - foreach ( $users as $user ) : |
|
1115 | - if ( ! empty( $user->user_firstname ) ) { |
|
1116 | - update_user_meta( $user->ID, 'first_name', wp_slash( $user->user_firstname ) ); |
|
1113 | + $users = $wpdb->get_results("SELECT * FROM $wpdb->users"); |
|
1114 | + foreach ($users as $user) : |
|
1115 | + if (!empty($user->user_firstname)) { |
|
1116 | + update_user_meta($user->ID, 'first_name', wp_slash($user->user_firstname)); |
|
1117 | 1117 | } |
1118 | - if ( ! empty( $user->user_lastname ) ) { |
|
1119 | - update_user_meta( $user->ID, 'last_name', wp_slash( $user->user_lastname ) ); |
|
1118 | + if (!empty($user->user_lastname)) { |
|
1119 | + update_user_meta($user->ID, 'last_name', wp_slash($user->user_lastname)); |
|
1120 | 1120 | } |
1121 | - if ( ! empty( $user->user_nickname ) ) { |
|
1122 | - update_user_meta( $user->ID, 'nickname', wp_slash( $user->user_nickname ) ); |
|
1121 | + if (!empty($user->user_nickname)) { |
|
1122 | + update_user_meta($user->ID, 'nickname', wp_slash($user->user_nickname)); |
|
1123 | 1123 | } |
1124 | - if ( ! empty( $user->user_level ) ) { |
|
1125 | - update_user_meta( $user->ID, $wpdb->prefix . 'user_level', $user->user_level ); |
|
1124 | + if (!empty($user->user_level)) { |
|
1125 | + update_user_meta($user->ID, $wpdb->prefix . 'user_level', $user->user_level); |
|
1126 | 1126 | } |
1127 | - if ( ! empty( $user->user_icq ) ) { |
|
1128 | - update_user_meta( $user->ID, 'icq', wp_slash( $user->user_icq ) ); |
|
1127 | + if (!empty($user->user_icq)) { |
|
1128 | + update_user_meta($user->ID, 'icq', wp_slash($user->user_icq)); |
|
1129 | 1129 | } |
1130 | - if ( ! empty( $user->user_aim ) ) { |
|
1131 | - update_user_meta( $user->ID, 'aim', wp_slash( $user->user_aim ) ); |
|
1130 | + if (!empty($user->user_aim)) { |
|
1131 | + update_user_meta($user->ID, 'aim', wp_slash($user->user_aim)); |
|
1132 | 1132 | } |
1133 | - if ( ! empty( $user->user_msn ) ) { |
|
1134 | - update_user_meta( $user->ID, 'msn', wp_slash( $user->user_msn ) ); |
|
1133 | + if (!empty($user->user_msn)) { |
|
1134 | + update_user_meta($user->ID, 'msn', wp_slash($user->user_msn)); |
|
1135 | 1135 | } |
1136 | - if ( ! empty( $user->user_yim ) ) { |
|
1137 | - update_user_meta( $user->ID, 'yim', wp_slash( $user->user_icq ) ); |
|
1136 | + if (!empty($user->user_yim)) { |
|
1137 | + update_user_meta($user->ID, 'yim', wp_slash($user->user_icq)); |
|
1138 | 1138 | } |
1139 | - if ( ! empty( $user->user_description ) ) { |
|
1140 | - update_user_meta( $user->ID, 'description', wp_slash( $user->user_description ) ); |
|
1139 | + if (!empty($user->user_description)) { |
|
1140 | + update_user_meta($user->ID, 'description', wp_slash($user->user_description)); |
|
1141 | 1141 | } |
1142 | 1142 | |
1143 | - if ( isset( $user->user_idmode ) ) : |
|
1143 | + if (isset($user->user_idmode)) : |
|
1144 | 1144 | $idmode = $user->user_idmode; |
1145 | - if ( 'nickname' === $idmode ) { |
|
1145 | + if ('nickname' === $idmode) { |
|
1146 | 1146 | $id = $user->user_nickname; |
1147 | 1147 | } |
1148 | - if ( 'login' === $idmode ) { |
|
1148 | + if ('login' === $idmode) { |
|
1149 | 1149 | $id = $user->user_login; |
1150 | 1150 | } |
1151 | - if ( 'firstname' === $idmode ) { |
|
1151 | + if ('firstname' === $idmode) { |
|
1152 | 1152 | $id = $user->user_firstname; |
1153 | 1153 | } |
1154 | - if ( 'lastname' === $idmode ) { |
|
1154 | + if ('lastname' === $idmode) { |
|
1155 | 1155 | $id = $user->user_lastname; |
1156 | 1156 | } |
1157 | - if ( 'namefl' === $idmode ) { |
|
1157 | + if ('namefl' === $idmode) { |
|
1158 | 1158 | $id = $user->user_firstname . ' ' . $user->user_lastname; |
1159 | 1159 | } |
1160 | - if ( 'namelf' === $idmode ) { |
|
1160 | + if ('namelf' === $idmode) { |
|
1161 | 1161 | $id = $user->user_lastname . ' ' . $user->user_firstname; |
1162 | 1162 | } |
1163 | - if ( ! $idmode ) { |
|
1163 | + if (!$idmode) { |
|
1164 | 1164 | $id = $user->user_nickname; |
1165 | 1165 | } |
1166 | - $wpdb->update( $wpdb->users, array( 'display_name' => $id ), array( 'ID' => $user->ID ) ); |
|
1166 | + $wpdb->update($wpdb->users, array('display_name' => $id), array('ID' => $user->ID)); |
|
1167 | 1167 | endif; |
1168 | 1168 | |
1169 | 1169 | // FIXME: RESET_CAPS is temporary code to reset roles and caps if flag is set. |
1170 | - $caps = get_user_meta( $user->ID, $wpdb->prefix . 'capabilities' ); |
|
1171 | - if ( empty( $caps ) || defined( 'RESET_CAPS' ) ) { |
|
1172 | - $level = get_user_meta( $user->ID, $wpdb->prefix . 'user_level', true ); |
|
1173 | - $role = translate_level_to_role( $level ); |
|
1174 | - update_user_meta( $user->ID, $wpdb->prefix . 'capabilities', array( $role => true ) ); |
|
1170 | + $caps = get_user_meta($user->ID, $wpdb->prefix . 'capabilities'); |
|
1171 | + if (empty($caps) || defined('RESET_CAPS')) { |
|
1172 | + $level = get_user_meta($user->ID, $wpdb->prefix . 'user_level', true); |
|
1173 | + $role = translate_level_to_role($level); |
|
1174 | + update_user_meta($user->ID, $wpdb->prefix . 'capabilities', array($role => true)); |
|
1175 | 1175 | } |
1176 | 1176 | |
1177 | 1177 | endforeach; |
1178 | - $old_user_fields = array( 'user_firstname', 'user_lastname', 'user_icq', 'user_aim', 'user_msn', 'user_yim', 'user_idmode', 'user_ip', 'user_domain', 'user_browser', 'user_description', 'user_nickname', 'user_level' ); |
|
1178 | + $old_user_fields = array('user_firstname', 'user_lastname', 'user_icq', 'user_aim', 'user_msn', 'user_yim', 'user_idmode', 'user_ip', 'user_domain', 'user_browser', 'user_description', 'user_nickname', 'user_level'); |
|
1179 | 1179 | $wpdb->hide_errors(); |
1180 | - foreach ( $old_user_fields as $old ) { |
|
1181 | - $wpdb->query( "ALTER TABLE $wpdb->users DROP $old" ); |
|
1180 | + foreach ($old_user_fields as $old) { |
|
1181 | + $wpdb->query("ALTER TABLE $wpdb->users DROP $old"); |
|
1182 | 1182 | } |
1183 | 1183 | $wpdb->show_errors(); |
1184 | 1184 | |
1185 | 1185 | // Populate comment_count field of posts table. |
1186 | - $comments = $wpdb->get_results( "SELECT comment_post_ID, COUNT(*) as c FROM $wpdb->comments WHERE comment_approved = '1' GROUP BY comment_post_ID" ); |
|
1187 | - if ( is_array( $comments ) ) { |
|
1188 | - foreach ( $comments as $comment ) { |
|
1189 | - $wpdb->update( $wpdb->posts, array( 'comment_count' => $comment->c ), array( 'ID' => $comment->comment_post_ID ) ); |
|
1186 | + $comments = $wpdb->get_results("SELECT comment_post_ID, COUNT(*) as c FROM $wpdb->comments WHERE comment_approved = '1' GROUP BY comment_post_ID"); |
|
1187 | + if (is_array($comments)) { |
|
1188 | + foreach ($comments as $comment) { |
|
1189 | + $wpdb->update($wpdb->posts, array('comment_count' => $comment->c), array('ID' => $comment->comment_post_ID)); |
|
1190 | 1190 | } |
1191 | 1191 | } |
1192 | 1192 | |
@@ -1194,9 +1194,9 @@ discard block |
||
1194 | 1194 | * Some alpha versions used a post status of object instead of attachment |
1195 | 1195 | * and put the mime type in post_type instead of post_mime_type. |
1196 | 1196 | */ |
1197 | - if ( $wp_current_db_version > 2541 && $wp_current_db_version <= 3091 ) { |
|
1198 | - $objects = $wpdb->get_results( "SELECT ID, post_type FROM $wpdb->posts WHERE post_status = 'object'" ); |
|
1199 | - foreach ( $objects as $object ) { |
|
1197 | + if ($wp_current_db_version > 2541 && $wp_current_db_version <= 3091) { |
|
1198 | + $objects = $wpdb->get_results("SELECT ID, post_type FROM $wpdb->posts WHERE post_status = 'object'"); |
|
1199 | + foreach ($objects as $object) { |
|
1200 | 1200 | $wpdb->update( |
1201 | 1201 | $wpdb->posts, |
1202 | 1202 | array( |
@@ -1204,12 +1204,12 @@ discard block |
||
1204 | 1204 | 'post_mime_type' => $object->post_type, |
1205 | 1205 | 'post_type' => '', |
1206 | 1206 | ), |
1207 | - array( 'ID' => $object->ID ) |
|
1207 | + array('ID' => $object->ID) |
|
1208 | 1208 | ); |
1209 | 1209 | |
1210 | - $meta = get_post_meta( $object->ID, 'imagedata', true ); |
|
1211 | - if ( ! empty( $meta['file'] ) ) { |
|
1212 | - update_attached_file( $object->ID, $meta['file'] ); |
|
1210 | + $meta = get_post_meta($object->ID, 'imagedata', true); |
|
1211 | + if (!empty($meta['file'])) { |
|
1212 | + update_attached_file($object->ID, $meta['file']); |
|
1213 | 1213 | } |
1214 | 1214 | } |
1215 | 1215 | } |
@@ -1227,41 +1227,41 @@ discard block |
||
1227 | 1227 | function upgrade_210() { |
1228 | 1228 | global $wp_current_db_version, $wpdb; |
1229 | 1229 | |
1230 | - if ( $wp_current_db_version < 3506 ) { |
|
1230 | + if ($wp_current_db_version < 3506) { |
|
1231 | 1231 | // Update status and type. |
1232 | - $posts = $wpdb->get_results( "SELECT ID, post_status FROM $wpdb->posts" ); |
|
1232 | + $posts = $wpdb->get_results("SELECT ID, post_status FROM $wpdb->posts"); |
|
1233 | 1233 | |
1234 | - if ( ! empty( $posts ) ) { |
|
1235 | - foreach ( $posts as $post ) { |
|
1234 | + if (!empty($posts)) { |
|
1235 | + foreach ($posts as $post) { |
|
1236 | 1236 | $status = $post->post_status; |
1237 | 1237 | $type = 'post'; |
1238 | 1238 | |
1239 | - if ( 'static' === $status ) { |
|
1239 | + if ('static' === $status) { |
|
1240 | 1240 | $status = 'publish'; |
1241 | 1241 | $type = 'page'; |
1242 | - } elseif ( 'attachment' === $status ) { |
|
1242 | + } elseif ('attachment' === $status) { |
|
1243 | 1243 | $status = 'inherit'; |
1244 | 1244 | $type = 'attachment'; |
1245 | 1245 | } |
1246 | 1246 | |
1247 | - $wpdb->query( $wpdb->prepare( "UPDATE $wpdb->posts SET post_status = %s, post_type = %s WHERE ID = %d", $status, $type, $post->ID ) ); |
|
1247 | + $wpdb->query($wpdb->prepare("UPDATE $wpdb->posts SET post_status = %s, post_type = %s WHERE ID = %d", $status, $type, $post->ID)); |
|
1248 | 1248 | } |
1249 | 1249 | } |
1250 | 1250 | } |
1251 | 1251 | |
1252 | - if ( $wp_current_db_version < 3845 ) { |
|
1252 | + if ($wp_current_db_version < 3845) { |
|
1253 | 1253 | populate_roles_210(); |
1254 | 1254 | } |
1255 | 1255 | |
1256 | - if ( $wp_current_db_version < 3531 ) { |
|
1256 | + if ($wp_current_db_version < 3531) { |
|
1257 | 1257 | // Give future posts a post_status of future. |
1258 | - $now = gmdate( 'Y-m-d H:i:59' ); |
|
1259 | - $wpdb->query( "UPDATE $wpdb->posts SET post_status = 'future' WHERE post_status = 'publish' AND post_date_gmt > '$now'" ); |
|
1258 | + $now = gmdate('Y-m-d H:i:59'); |
|
1259 | + $wpdb->query("UPDATE $wpdb->posts SET post_status = 'future' WHERE post_status = 'publish' AND post_date_gmt > '$now'"); |
|
1260 | 1260 | |
1261 | - $posts = $wpdb->get_results( "SELECT ID, post_date FROM $wpdb->posts WHERE post_status ='future'" ); |
|
1262 | - if ( ! empty( $posts ) ) { |
|
1263 | - foreach ( $posts as $post ) { |
|
1264 | - wp_schedule_single_event( mysql2date( 'U', $post->post_date, false ), 'publish_future_post', array( $post->ID ) ); |
|
1261 | + $posts = $wpdb->get_results("SELECT ID, post_date FROM $wpdb->posts WHERE post_status ='future'"); |
|
1262 | + if (!empty($posts)) { |
|
1263 | + foreach ($posts as $post) { |
|
1264 | + wp_schedule_single_event(mysql2date('U', $post->post_date, false), 'publish_future_post', array($post->ID)); |
|
1265 | 1265 | } |
1266 | 1266 | } |
1267 | 1267 | } |
@@ -1279,15 +1279,15 @@ discard block |
||
1279 | 1279 | function upgrade_230() { |
1280 | 1280 | global $wp_current_db_version, $wpdb; |
1281 | 1281 | |
1282 | - if ( $wp_current_db_version < 5200 ) { |
|
1282 | + if ($wp_current_db_version < 5200) { |
|
1283 | 1283 | populate_roles_230(); |
1284 | 1284 | } |
1285 | 1285 | |
1286 | 1286 | // Convert categories to terms. |
1287 | 1287 | $tt_ids = array(); |
1288 | 1288 | $have_tags = false; |
1289 | - $categories = $wpdb->get_results( "SELECT * FROM $wpdb->categories ORDER BY cat_ID" ); |
|
1290 | - foreach ( $categories as $category ) { |
|
1289 | + $categories = $wpdb->get_results("SELECT * FROM $wpdb->categories ORDER BY cat_ID"); |
|
1290 | + foreach ($categories as $category) { |
|
1291 | 1291 | $term_id = (int) $category->cat_ID; |
1292 | 1292 | $name = $category->cat_name; |
1293 | 1293 | $description = $category->category_description; |
@@ -1296,22 +1296,22 @@ discard block |
||
1296 | 1296 | $term_group = 0; |
1297 | 1297 | |
1298 | 1298 | // Associate terms with the same slug in a term group and make slugs unique. |
1299 | - $exists = $wpdb->get_results( $wpdb->prepare( "SELECT term_id, term_group FROM $wpdb->terms WHERE slug = %s", $slug ) ); |
|
1300 | - if ( $exists ) { |
|
1299 | + $exists = $wpdb->get_results($wpdb->prepare("SELECT term_id, term_group FROM $wpdb->terms WHERE slug = %s", $slug)); |
|
1300 | + if ($exists) { |
|
1301 | 1301 | $term_group = $exists[0]->term_group; |
1302 | 1302 | $id = $exists[0]->term_id; |
1303 | 1303 | $num = 2; |
1304 | 1304 | do { |
1305 | 1305 | $alt_slug = $slug . "-$num"; |
1306 | 1306 | $num++; |
1307 | - $slug_check = $wpdb->get_var( $wpdb->prepare( "SELECT slug FROM $wpdb->terms WHERE slug = %s", $alt_slug ) ); |
|
1308 | - } while ( $slug_check ); |
|
1307 | + $slug_check = $wpdb->get_var($wpdb->prepare("SELECT slug FROM $wpdb->terms WHERE slug = %s", $alt_slug)); |
|
1308 | + } while ($slug_check); |
|
1309 | 1309 | |
1310 | 1310 | $slug = $alt_slug; |
1311 | 1311 | |
1312 | - if ( empty( $term_group ) ) { |
|
1313 | - $term_group = $wpdb->get_var( "SELECT MAX(term_group) FROM $wpdb->terms GROUP BY term_group" ) + 1; |
|
1314 | - $wpdb->query( $wpdb->prepare( "UPDATE $wpdb->terms SET term_group = %d WHERE term_id = %d", $term_group, $id ) ); |
|
1312 | + if (empty($term_group)) { |
|
1313 | + $term_group = $wpdb->get_var("SELECT MAX(term_group) FROM $wpdb->terms GROUP BY term_group") + 1; |
|
1314 | + $wpdb->query($wpdb->prepare("UPDATE $wpdb->terms SET term_group = %d WHERE term_id = %d", $term_group, $id)); |
|
1315 | 1315 | } |
1316 | 1316 | } |
1317 | 1317 | |
@@ -1327,51 +1327,51 @@ discard block |
||
1327 | 1327 | ); |
1328 | 1328 | |
1329 | 1329 | $count = 0; |
1330 | - if ( ! empty( $category->category_count ) ) { |
|
1330 | + if (!empty($category->category_count)) { |
|
1331 | 1331 | $count = (int) $category->category_count; |
1332 | 1332 | $taxonomy = 'category'; |
1333 | - $wpdb->query( $wpdb->prepare( "INSERT INTO $wpdb->term_taxonomy (term_id, taxonomy, description, parent, count) VALUES ( %d, %s, %s, %d, %d)", $term_id, $taxonomy, $description, $parent, $count ) ); |
|
1334 | - $tt_ids[ $term_id ][ $taxonomy ] = (int) $wpdb->insert_id; |
|
1333 | + $wpdb->query($wpdb->prepare("INSERT INTO $wpdb->term_taxonomy (term_id, taxonomy, description, parent, count) VALUES ( %d, %s, %s, %d, %d)", $term_id, $taxonomy, $description, $parent, $count)); |
|
1334 | + $tt_ids[$term_id][$taxonomy] = (int) $wpdb->insert_id; |
|
1335 | 1335 | } |
1336 | 1336 | |
1337 | - if ( ! empty( $category->link_count ) ) { |
|
1337 | + if (!empty($category->link_count)) { |
|
1338 | 1338 | $count = (int) $category->link_count; |
1339 | 1339 | $taxonomy = 'link_category'; |
1340 | - $wpdb->query( $wpdb->prepare( "INSERT INTO $wpdb->term_taxonomy (term_id, taxonomy, description, parent, count) VALUES ( %d, %s, %s, %d, %d)", $term_id, $taxonomy, $description, $parent, $count ) ); |
|
1341 | - $tt_ids[ $term_id ][ $taxonomy ] = (int) $wpdb->insert_id; |
|
1340 | + $wpdb->query($wpdb->prepare("INSERT INTO $wpdb->term_taxonomy (term_id, taxonomy, description, parent, count) VALUES ( %d, %s, %s, %d, %d)", $term_id, $taxonomy, $description, $parent, $count)); |
|
1341 | + $tt_ids[$term_id][$taxonomy] = (int) $wpdb->insert_id; |
|
1342 | 1342 | } |
1343 | 1343 | |
1344 | - if ( ! empty( $category->tag_count ) ) { |
|
1344 | + if (!empty($category->tag_count)) { |
|
1345 | 1345 | $have_tags = true; |
1346 | 1346 | $count = (int) $category->tag_count; |
1347 | 1347 | $taxonomy = 'post_tag'; |
1348 | - $wpdb->insert( $wpdb->term_taxonomy, compact( 'term_id', 'taxonomy', 'description', 'parent', 'count' ) ); |
|
1349 | - $tt_ids[ $term_id ][ $taxonomy ] = (int) $wpdb->insert_id; |
|
1348 | + $wpdb->insert($wpdb->term_taxonomy, compact('term_id', 'taxonomy', 'description', 'parent', 'count')); |
|
1349 | + $tt_ids[$term_id][$taxonomy] = (int) $wpdb->insert_id; |
|
1350 | 1350 | } |
1351 | 1351 | |
1352 | - if ( empty( $count ) ) { |
|
1352 | + if (empty($count)) { |
|
1353 | 1353 | $count = 0; |
1354 | 1354 | $taxonomy = 'category'; |
1355 | - $wpdb->insert( $wpdb->term_taxonomy, compact( 'term_id', 'taxonomy', 'description', 'parent', 'count' ) ); |
|
1356 | - $tt_ids[ $term_id ][ $taxonomy ] = (int) $wpdb->insert_id; |
|
1355 | + $wpdb->insert($wpdb->term_taxonomy, compact('term_id', 'taxonomy', 'description', 'parent', 'count')); |
|
1356 | + $tt_ids[$term_id][$taxonomy] = (int) $wpdb->insert_id; |
|
1357 | 1357 | } |
1358 | 1358 | } |
1359 | 1359 | |
1360 | 1360 | $select = 'post_id, category_id'; |
1361 | - if ( $have_tags ) { |
|
1361 | + if ($have_tags) { |
|
1362 | 1362 | $select .= ', rel_type'; |
1363 | 1363 | } |
1364 | 1364 | |
1365 | - $posts = $wpdb->get_results( "SELECT $select FROM $wpdb->post2cat GROUP BY post_id, category_id" ); |
|
1366 | - foreach ( $posts as $post ) { |
|
1365 | + $posts = $wpdb->get_results("SELECT $select FROM $wpdb->post2cat GROUP BY post_id, category_id"); |
|
1366 | + foreach ($posts as $post) { |
|
1367 | 1367 | $post_id = (int) $post->post_id; |
1368 | 1368 | $term_id = (int) $post->category_id; |
1369 | 1369 | $taxonomy = 'category'; |
1370 | - if ( ! empty( $post->rel_type ) && 'tag' === $post->rel_type ) { |
|
1370 | + if (!empty($post->rel_type) && 'tag' === $post->rel_type) { |
|
1371 | 1371 | $taxonomy = 'tag'; |
1372 | 1372 | } |
1373 | - $tt_id = $tt_ids[ $term_id ][ $taxonomy ]; |
|
1374 | - if ( empty( $tt_id ) ) { |
|
1373 | + $tt_id = $tt_ids[$term_id][$taxonomy]; |
|
1374 | + if (empty($tt_id)) { |
|
1375 | 1375 | continue; |
1376 | 1376 | } |
1377 | 1377 | |
@@ -1385,7 +1385,7 @@ discard block |
||
1385 | 1385 | } |
1386 | 1386 | |
1387 | 1387 | // < 3570 we used linkcategories. >= 3570 we used categories and link2cat. |
1388 | - if ( $wp_current_db_version < 3570 ) { |
|
1388 | + if ($wp_current_db_version < 3570) { |
|
1389 | 1389 | /* |
1390 | 1390 | * Create link_category terms for link categories. Create a map of link |
1391 | 1391 | * category IDs to link_category terms. |
@@ -1393,27 +1393,27 @@ discard block |
||
1393 | 1393 | $link_cat_id_map = array(); |
1394 | 1394 | $default_link_cat = 0; |
1395 | 1395 | $tt_ids = array(); |
1396 | - $link_cats = $wpdb->get_results( 'SELECT cat_id, cat_name FROM ' . $wpdb->prefix . 'linkcategories' ); |
|
1397 | - foreach ( $link_cats as $category ) { |
|
1396 | + $link_cats = $wpdb->get_results('SELECT cat_id, cat_name FROM ' . $wpdb->prefix . 'linkcategories'); |
|
1397 | + foreach ($link_cats as $category) { |
|
1398 | 1398 | $cat_id = (int) $category->cat_id; |
1399 | 1399 | $term_id = 0; |
1400 | - $name = wp_slash( $category->cat_name ); |
|
1401 | - $slug = sanitize_title( $name ); |
|
1400 | + $name = wp_slash($category->cat_name); |
|
1401 | + $slug = sanitize_title($name); |
|
1402 | 1402 | $term_group = 0; |
1403 | 1403 | |
1404 | 1404 | // Associate terms with the same slug in a term group and make slugs unique. |
1405 | - $exists = $wpdb->get_results( $wpdb->prepare( "SELECT term_id, term_group FROM $wpdb->terms WHERE slug = %s", $slug ) ); |
|
1406 | - if ( $exists ) { |
|
1405 | + $exists = $wpdb->get_results($wpdb->prepare("SELECT term_id, term_group FROM $wpdb->terms WHERE slug = %s", $slug)); |
|
1406 | + if ($exists) { |
|
1407 | 1407 | $term_group = $exists[0]->term_group; |
1408 | 1408 | $term_id = $exists[0]->term_id; |
1409 | 1409 | } |
1410 | 1410 | |
1411 | - if ( empty( $term_id ) ) { |
|
1412 | - $wpdb->insert( $wpdb->terms, compact( 'name', 'slug', 'term_group' ) ); |
|
1411 | + if (empty($term_id)) { |
|
1412 | + $wpdb->insert($wpdb->terms, compact('name', 'slug', 'term_group')); |
|
1413 | 1413 | $term_id = (int) $wpdb->insert_id; |
1414 | 1414 | } |
1415 | 1415 | |
1416 | - $link_cat_id_map[ $cat_id ] = $term_id; |
|
1416 | + $link_cat_id_map[$cat_id] = $term_id; |
|
1417 | 1417 | $default_link_cat = $term_id; |
1418 | 1418 | |
1419 | 1419 | $wpdb->insert( |
@@ -1426,22 +1426,22 @@ discard block |
||
1426 | 1426 | 'count' => 0, |
1427 | 1427 | ) |
1428 | 1428 | ); |
1429 | - $tt_ids[ $term_id ] = (int) $wpdb->insert_id; |
|
1429 | + $tt_ids[$term_id] = (int) $wpdb->insert_id; |
|
1430 | 1430 | } |
1431 | 1431 | |
1432 | 1432 | // Associate links to categories. |
1433 | - $links = $wpdb->get_results( "SELECT link_id, link_category FROM $wpdb->links" ); |
|
1434 | - if ( ! empty( $links ) ) { |
|
1435 | - foreach ( $links as $link ) { |
|
1436 | - if ( 0 == $link->link_category ) { |
|
1433 | + $links = $wpdb->get_results("SELECT link_id, link_category FROM $wpdb->links"); |
|
1434 | + if (!empty($links)) { |
|
1435 | + foreach ($links as $link) { |
|
1436 | + if (0 == $link->link_category) { |
|
1437 | 1437 | continue; |
1438 | 1438 | } |
1439 | - if ( ! isset( $link_cat_id_map[ $link->link_category ] ) ) { |
|
1439 | + if (!isset($link_cat_id_map[$link->link_category])) { |
|
1440 | 1440 | continue; |
1441 | 1441 | } |
1442 | - $term_id = $link_cat_id_map[ $link->link_category ]; |
|
1443 | - $tt_id = $tt_ids[ $term_id ]; |
|
1444 | - if ( empty( $tt_id ) ) { |
|
1442 | + $term_id = $link_cat_id_map[$link->link_category]; |
|
1443 | + $tt_id = $tt_ids[$term_id]; |
|
1444 | + if (empty($tt_id)) { |
|
1445 | 1445 | continue; |
1446 | 1446 | } |
1447 | 1447 | |
@@ -1456,15 +1456,15 @@ discard block |
||
1456 | 1456 | } |
1457 | 1457 | |
1458 | 1458 | // Set default to the last category we grabbed during the upgrade loop. |
1459 | - update_option( 'default_link_category', $default_link_cat ); |
|
1459 | + update_option('default_link_category', $default_link_cat); |
|
1460 | 1460 | } else { |
1461 | - $links = $wpdb->get_results( "SELECT link_id, category_id FROM $wpdb->link2cat GROUP BY link_id, category_id" ); |
|
1462 | - foreach ( $links as $link ) { |
|
1461 | + $links = $wpdb->get_results("SELECT link_id, category_id FROM $wpdb->link2cat GROUP BY link_id, category_id"); |
|
1462 | + foreach ($links as $link) { |
|
1463 | 1463 | $link_id = (int) $link->link_id; |
1464 | 1464 | $term_id = (int) $link->category_id; |
1465 | 1465 | $taxonomy = 'link_category'; |
1466 | - $tt_id = $tt_ids[ $term_id ][ $taxonomy ]; |
|
1467 | - if ( empty( $tt_id ) ) { |
|
1466 | + $tt_id = $tt_ids[$term_id][$taxonomy]; |
|
1467 | + if (empty($tt_id)) { |
|
1468 | 1468 | continue; |
1469 | 1469 | } |
1470 | 1470 | $wpdb->insert( |
@@ -1477,20 +1477,20 @@ discard block |
||
1477 | 1477 | } |
1478 | 1478 | } |
1479 | 1479 | |
1480 | - if ( $wp_current_db_version < 4772 ) { |
|
1480 | + if ($wp_current_db_version < 4772) { |
|
1481 | 1481 | // Obsolete linkcategories table. |
1482 | - $wpdb->query( 'DROP TABLE IF EXISTS ' . $wpdb->prefix . 'linkcategories' ); |
|
1482 | + $wpdb->query('DROP TABLE IF EXISTS ' . $wpdb->prefix . 'linkcategories'); |
|
1483 | 1483 | } |
1484 | 1484 | |
1485 | 1485 | // Recalculate all counts. |
1486 | - $terms = $wpdb->get_results( "SELECT term_taxonomy_id, taxonomy FROM $wpdb->term_taxonomy" ); |
|
1487 | - foreach ( (array) $terms as $term ) { |
|
1488 | - if ( 'post_tag' === $term->taxonomy || 'category' === $term->taxonomy ) { |
|
1489 | - $count = $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(*) FROM $wpdb->term_relationships, $wpdb->posts WHERE $wpdb->posts.ID = $wpdb->term_relationships.object_id AND post_status = 'publish' AND post_type = 'post' AND term_taxonomy_id = %d", $term->term_taxonomy_id ) ); |
|
1486 | + $terms = $wpdb->get_results("SELECT term_taxonomy_id, taxonomy FROM $wpdb->term_taxonomy"); |
|
1487 | + foreach ((array) $terms as $term) { |
|
1488 | + if ('post_tag' === $term->taxonomy || 'category' === $term->taxonomy) { |
|
1489 | + $count = $wpdb->get_var($wpdb->prepare("SELECT COUNT(*) FROM $wpdb->term_relationships, $wpdb->posts WHERE $wpdb->posts.ID = $wpdb->term_relationships.object_id AND post_status = 'publish' AND post_type = 'post' AND term_taxonomy_id = %d", $term->term_taxonomy_id)); |
|
1490 | 1490 | } else { |
1491 | - $count = $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(*) FROM $wpdb->term_relationships WHERE term_taxonomy_id = %d", $term->term_taxonomy_id ) ); |
|
1491 | + $count = $wpdb->get_var($wpdb->prepare("SELECT COUNT(*) FROM $wpdb->term_relationships WHERE term_taxonomy_id = %d", $term->term_taxonomy_id)); |
|
1492 | 1492 | } |
1493 | - $wpdb->update( $wpdb->term_taxonomy, array( 'count' => $count ), array( 'term_taxonomy_id' => $term->term_taxonomy_id ) ); |
|
1493 | + $wpdb->update($wpdb->term_taxonomy, array('count' => $count), array('term_taxonomy_id' => $term->term_taxonomy_id)); |
|
1494 | 1494 | } |
1495 | 1495 | } |
1496 | 1496 | |
@@ -1504,10 +1504,10 @@ discard block |
||
1504 | 1504 | */ |
1505 | 1505 | function upgrade_230_options_table() { |
1506 | 1506 | global $wpdb; |
1507 | - $old_options_fields = array( 'option_can_override', 'option_type', 'option_width', 'option_height', 'option_description', 'option_admin_level' ); |
|
1507 | + $old_options_fields = array('option_can_override', 'option_type', 'option_width', 'option_height', 'option_description', 'option_admin_level'); |
|
1508 | 1508 | $wpdb->hide_errors(); |
1509 | - foreach ( $old_options_fields as $old ) { |
|
1510 | - $wpdb->query( "ALTER TABLE $wpdb->options DROP $old" ); |
|
1509 | + foreach ($old_options_fields as $old) { |
|
1510 | + $wpdb->query("ALTER TABLE $wpdb->options DROP $old"); |
|
1511 | 1511 | } |
1512 | 1512 | $wpdb->show_errors(); |
1513 | 1513 | } |
@@ -1522,9 +1522,9 @@ discard block |
||
1522 | 1522 | */ |
1523 | 1523 | function upgrade_230_old_tables() { |
1524 | 1524 | global $wpdb; |
1525 | - $wpdb->query( 'DROP TABLE IF EXISTS ' . $wpdb->prefix . 'categories' ); |
|
1526 | - $wpdb->query( 'DROP TABLE IF EXISTS ' . $wpdb->prefix . 'link2cat' ); |
|
1527 | - $wpdb->query( 'DROP TABLE IF EXISTS ' . $wpdb->prefix . 'post2cat' ); |
|
1525 | + $wpdb->query('DROP TABLE IF EXISTS ' . $wpdb->prefix . 'categories'); |
|
1526 | + $wpdb->query('DROP TABLE IF EXISTS ' . $wpdb->prefix . 'link2cat'); |
|
1527 | + $wpdb->query('DROP TABLE IF EXISTS ' . $wpdb->prefix . 'post2cat'); |
|
1528 | 1528 | } |
1529 | 1529 | |
1530 | 1530 | /** |
@@ -1538,7 +1538,7 @@ discard block |
||
1538 | 1538 | function upgrade_old_slugs() { |
1539 | 1539 | // Upgrade people who were using the Redirect Old Slugs plugin. |
1540 | 1540 | global $wpdb; |
1541 | - $wpdb->query( "UPDATE $wpdb->postmeta SET meta_key = '_wp_old_slug' WHERE meta_key = 'old_slug'" ); |
|
1541 | + $wpdb->query("UPDATE $wpdb->postmeta SET meta_key = '_wp_old_slug' WHERE meta_key = 'old_slug'"); |
|
1542 | 1542 | } |
1543 | 1543 | |
1544 | 1544 | /** |
@@ -1552,7 +1552,7 @@ discard block |
||
1552 | 1552 | function upgrade_250() { |
1553 | 1553 | global $wp_current_db_version; |
1554 | 1554 | |
1555 | - if ( $wp_current_db_version < 6689 ) { |
|
1555 | + if ($wp_current_db_version < 6689) { |
|
1556 | 1556 | populate_roles_250(); |
1557 | 1557 | } |
1558 | 1558 | |
@@ -1569,7 +1569,7 @@ discard block |
||
1569 | 1569 | function upgrade_252() { |
1570 | 1570 | global $wpdb; |
1571 | 1571 | |
1572 | - $wpdb->query( "UPDATE $wpdb->users SET user_activation_key = ''" ); |
|
1572 | + $wpdb->query("UPDATE $wpdb->users SET user_activation_key = ''"); |
|
1573 | 1573 | } |
1574 | 1574 | |
1575 | 1575 | /** |
@@ -1583,7 +1583,7 @@ discard block |
||
1583 | 1583 | function upgrade_260() { |
1584 | 1584 | global $wp_current_db_version; |
1585 | 1585 | |
1586 | - if ( $wp_current_db_version < 8000 ) { |
|
1586 | + if ($wp_current_db_version < 8000) { |
|
1587 | 1587 | populate_roles_260(); |
1588 | 1588 | } |
1589 | 1589 | } |
@@ -1600,13 +1600,13 @@ discard block |
||
1600 | 1600 | function upgrade_270() { |
1601 | 1601 | global $wp_current_db_version, $wpdb; |
1602 | 1602 | |
1603 | - if ( $wp_current_db_version < 8980 ) { |
|
1603 | + if ($wp_current_db_version < 8980) { |
|
1604 | 1604 | populate_roles_270(); |
1605 | 1605 | } |
1606 | 1606 | |
1607 | 1607 | // Update post_date for unpublished posts with empty timestamp. |
1608 | - if ( $wp_current_db_version < 8921 ) { |
|
1609 | - $wpdb->query( "UPDATE $wpdb->posts SET post_date = post_modified WHERE post_date = '0000-00-00 00:00:00'" ); |
|
1608 | + if ($wp_current_db_version < 8921) { |
|
1609 | + $wpdb->query("UPDATE $wpdb->posts SET post_date = post_modified WHERE post_date = '0000-00-00 00:00:00'"); |
|
1610 | 1610 | } |
1611 | 1611 | } |
1612 | 1612 | |
@@ -1622,24 +1622,24 @@ discard block |
||
1622 | 1622 | function upgrade_280() { |
1623 | 1623 | global $wp_current_db_version, $wpdb; |
1624 | 1624 | |
1625 | - if ( $wp_current_db_version < 10360 ) { |
|
1625 | + if ($wp_current_db_version < 10360) { |
|
1626 | 1626 | populate_roles_280(); |
1627 | 1627 | } |
1628 | - if ( is_multisite() ) { |
|
1628 | + if (is_multisite()) { |
|
1629 | 1629 | $start = 0; |
1630 | - while ( $rows = $wpdb->get_results( "SELECT option_name, option_value FROM $wpdb->options ORDER BY option_id LIMIT $start, 20" ) ) { |
|
1631 | - foreach ( $rows as $row ) { |
|
1632 | - $value = maybe_unserialize( $row->option_value ); |
|
1633 | - if ( $value === $row->option_value ) { |
|
1634 | - $value = stripslashes( $value ); |
|
1630 | + while ($rows = $wpdb->get_results("SELECT option_name, option_value FROM $wpdb->options ORDER BY option_id LIMIT $start, 20")) { |
|
1631 | + foreach ($rows as $row) { |
|
1632 | + $value = maybe_unserialize($row->option_value); |
|
1633 | + if ($value === $row->option_value) { |
|
1634 | + $value = stripslashes($value); |
|
1635 | 1635 | } |
1636 | - if ( $value !== $row->option_value ) { |
|
1637 | - update_option( $row->option_name, $value ); |
|
1636 | + if ($value !== $row->option_value) { |
|
1637 | + update_option($row->option_name, $value); |
|
1638 | 1638 | } |
1639 | 1639 | } |
1640 | 1640 | $start += 20; |
1641 | 1641 | } |
1642 | - clean_blog_cache( get_current_blog_id() ); |
|
1642 | + clean_blog_cache(get_current_blog_id()); |
|
1643 | 1643 | } |
1644 | 1644 | } |
1645 | 1645 | |
@@ -1654,12 +1654,12 @@ discard block |
||
1654 | 1654 | function upgrade_290() { |
1655 | 1655 | global $wp_current_db_version; |
1656 | 1656 | |
1657 | - if ( $wp_current_db_version < 11958 ) { |
|
1657 | + if ($wp_current_db_version < 11958) { |
|
1658 | 1658 | // Previously, setting depth to 1 would redundantly disable threading, |
1659 | 1659 | // but now 2 is the minimum depth to avoid confusion. |
1660 | - if ( get_option( 'thread_comments_depth' ) == '1' ) { |
|
1661 | - update_option( 'thread_comments_depth', 2 ); |
|
1662 | - update_option( 'thread_comments', 0 ); |
|
1660 | + if (get_option('thread_comments_depth') == '1') { |
|
1661 | + update_option('thread_comments_depth', 2); |
|
1662 | + update_option('thread_comments', 0); |
|
1663 | 1663 | } |
1664 | 1664 | } |
1665 | 1665 | } |
@@ -1676,17 +1676,17 @@ discard block |
||
1676 | 1676 | function upgrade_300() { |
1677 | 1677 | global $wp_current_db_version, $wpdb; |
1678 | 1678 | |
1679 | - if ( $wp_current_db_version < 15093 ) { |
|
1679 | + if ($wp_current_db_version < 15093) { |
|
1680 | 1680 | populate_roles_300(); |
1681 | 1681 | } |
1682 | 1682 | |
1683 | - if ( $wp_current_db_version < 14139 && is_multisite() && is_main_site() && ! defined( 'MULTISITE' ) && get_site_option( 'siteurl' ) === false ) { |
|
1684 | - add_site_option( 'siteurl', '' ); |
|
1683 | + if ($wp_current_db_version < 14139 && is_multisite() && is_main_site() && !defined('MULTISITE') && get_site_option('siteurl') === false) { |
|
1684 | + add_site_option('siteurl', ''); |
|
1685 | 1685 | } |
1686 | 1686 | |
1687 | 1687 | // 3.0 screen options key name changes. |
1688 | - if ( wp_should_upgrade_global_tables() ) { |
|
1689 | - $sql = "DELETE FROM $wpdb->usermeta |
|
1688 | + if (wp_should_upgrade_global_tables()) { |
|
1689 | + $sql = "DELETE FROM $wpdb->usermeta |
|
1690 | 1690 | WHERE meta_key LIKE %s |
1691 | 1691 | OR meta_key LIKE %s |
1692 | 1692 | OR meta_key LIKE %s |
@@ -1699,16 +1699,16 @@ discard block |
||
1699 | 1699 | OR meta_key = 'manageeditcolumnshidden' |
1700 | 1700 | OR meta_key = 'categories_per_page' |
1701 | 1701 | OR meta_key = 'edit_tags_per_page'"; |
1702 | - $prefix = $wpdb->esc_like( $wpdb->base_prefix ); |
|
1702 | + $prefix = $wpdb->esc_like($wpdb->base_prefix); |
|
1703 | 1703 | $wpdb->query( |
1704 | 1704 | $wpdb->prepare( |
1705 | 1705 | $sql, |
1706 | - $prefix . '%' . $wpdb->esc_like( 'meta-box-hidden' ) . '%', |
|
1707 | - $prefix . '%' . $wpdb->esc_like( 'closedpostboxes' ) . '%', |
|
1708 | - $prefix . '%' . $wpdb->esc_like( 'manage-' ) . '%' . $wpdb->esc_like( '-columns-hidden' ) . '%', |
|
1709 | - $prefix . '%' . $wpdb->esc_like( 'meta-box-order' ) . '%', |
|
1710 | - $prefix . '%' . $wpdb->esc_like( 'metaboxorder' ) . '%', |
|
1711 | - $prefix . '%' . $wpdb->esc_like( 'screen_layout' ) . '%' |
|
1706 | + $prefix . '%' . $wpdb->esc_like('meta-box-hidden') . '%', |
|
1707 | + $prefix . '%' . $wpdb->esc_like('closedpostboxes') . '%', |
|
1708 | + $prefix . '%' . $wpdb->esc_like('manage-') . '%' . $wpdb->esc_like('-columns-hidden') . '%', |
|
1709 | + $prefix . '%' . $wpdb->esc_like('meta-box-order') . '%', |
|
1710 | + $prefix . '%' . $wpdb->esc_like('metaboxorder') . '%', |
|
1711 | + $prefix . '%' . $wpdb->esc_like('screen_layout') . '%' |
|
1712 | 1712 | ) |
1713 | 1713 | ); |
1714 | 1714 | } |
@@ -1729,70 +1729,70 @@ discard block |
||
1729 | 1729 | function upgrade_330() { |
1730 | 1730 | global $wp_current_db_version, $wpdb, $wp_registered_widgets, $sidebars_widgets; |
1731 | 1731 | |
1732 | - if ( $wp_current_db_version < 19061 && wp_should_upgrade_global_tables() ) { |
|
1733 | - $wpdb->query( "DELETE FROM $wpdb->usermeta WHERE meta_key IN ('show_admin_bar_admin', 'plugins_last_view')" ); |
|
1732 | + if ($wp_current_db_version < 19061 && wp_should_upgrade_global_tables()) { |
|
1733 | + $wpdb->query("DELETE FROM $wpdb->usermeta WHERE meta_key IN ('show_admin_bar_admin', 'plugins_last_view')"); |
|
1734 | 1734 | } |
1735 | 1735 | |
1736 | - if ( $wp_current_db_version >= 11548 ) { |
|
1736 | + if ($wp_current_db_version >= 11548) { |
|
1737 | 1737 | return; |
1738 | 1738 | } |
1739 | 1739 | |
1740 | - $sidebars_widgets = get_option( 'sidebars_widgets', array() ); |
|
1740 | + $sidebars_widgets = get_option('sidebars_widgets', array()); |
|
1741 | 1741 | $_sidebars_widgets = array(); |
1742 | 1742 | |
1743 | - if ( isset( $sidebars_widgets['wp_inactive_widgets'] ) || empty( $sidebars_widgets ) ) { |
|
1743 | + if (isset($sidebars_widgets['wp_inactive_widgets']) || empty($sidebars_widgets)) { |
|
1744 | 1744 | $sidebars_widgets['array_version'] = 3; |
1745 | - } elseif ( ! isset( $sidebars_widgets['array_version'] ) ) { |
|
1745 | + } elseif (!isset($sidebars_widgets['array_version'])) { |
|
1746 | 1746 | $sidebars_widgets['array_version'] = 1; |
1747 | 1747 | } |
1748 | 1748 | |
1749 | - switch ( $sidebars_widgets['array_version'] ) { |
|
1749 | + switch ($sidebars_widgets['array_version']) { |
|
1750 | 1750 | case 1: |
1751 | - foreach ( (array) $sidebars_widgets as $index => $sidebar ) { |
|
1752 | - if ( is_array( $sidebar ) ) { |
|
1753 | - foreach ( (array) $sidebar as $i => $name ) { |
|
1754 | - $id = strtolower( $name ); |
|
1755 | - if ( isset( $wp_registered_widgets[ $id ] ) ) { |
|
1756 | - $_sidebars_widgets[ $index ][ $i ] = $id; |
|
1751 | + foreach ((array) $sidebars_widgets as $index => $sidebar) { |
|
1752 | + if (is_array($sidebar)) { |
|
1753 | + foreach ((array) $sidebar as $i => $name) { |
|
1754 | + $id = strtolower($name); |
|
1755 | + if (isset($wp_registered_widgets[$id])) { |
|
1756 | + $_sidebars_widgets[$index][$i] = $id; |
|
1757 | 1757 | continue; |
1758 | 1758 | } |
1759 | - $id = sanitize_title( $name ); |
|
1760 | - if ( isset( $wp_registered_widgets[ $id ] ) ) { |
|
1761 | - $_sidebars_widgets[ $index ][ $i ] = $id; |
|
1759 | + $id = sanitize_title($name); |
|
1760 | + if (isset($wp_registered_widgets[$id])) { |
|
1761 | + $_sidebars_widgets[$index][$i] = $id; |
|
1762 | 1762 | continue; |
1763 | 1763 | } |
1764 | 1764 | |
1765 | 1765 | $found = false; |
1766 | 1766 | |
1767 | - foreach ( $wp_registered_widgets as $widget_id => $widget ) { |
|
1768 | - if ( strtolower( $widget['name'] ) == strtolower( $name ) ) { |
|
1769 | - $_sidebars_widgets[ $index ][ $i ] = $widget['id']; |
|
1767 | + foreach ($wp_registered_widgets as $widget_id => $widget) { |
|
1768 | + if (strtolower($widget['name']) == strtolower($name)) { |
|
1769 | + $_sidebars_widgets[$index][$i] = $widget['id']; |
|
1770 | 1770 | $found = true; |
1771 | 1771 | break; |
1772 | - } elseif ( sanitize_title( $widget['name'] ) == sanitize_title( $name ) ) { |
|
1773 | - $_sidebars_widgets[ $index ][ $i ] = $widget['id']; |
|
1772 | + } elseif (sanitize_title($widget['name']) == sanitize_title($name)) { |
|
1773 | + $_sidebars_widgets[$index][$i] = $widget['id']; |
|
1774 | 1774 | $found = true; |
1775 | 1775 | break; |
1776 | 1776 | } |
1777 | 1777 | } |
1778 | 1778 | |
1779 | - if ( $found ) { |
|
1779 | + if ($found) { |
|
1780 | 1780 | continue; |
1781 | 1781 | } |
1782 | 1782 | |
1783 | - unset( $_sidebars_widgets[ $index ][ $i ] ); |
|
1783 | + unset($_sidebars_widgets[$index][$i]); |
|
1784 | 1784 | } |
1785 | 1785 | } |
1786 | 1786 | } |
1787 | 1787 | $_sidebars_widgets['array_version'] = 2; |
1788 | 1788 | $sidebars_widgets = $_sidebars_widgets; |
1789 | - unset( $_sidebars_widgets ); |
|
1789 | + unset($_sidebars_widgets); |
|
1790 | 1790 | |
1791 | 1791 | // Intentional fall-through to upgrade to the next version. |
1792 | 1792 | case 2: |
1793 | 1793 | $sidebars_widgets = retrieve_widgets(); |
1794 | 1794 | $sidebars_widgets['array_version'] = 3; |
1795 | - update_option( 'sidebars_widgets', $sidebars_widgets ); |
|
1795 | + update_option('sidebars_widgets', $sidebars_widgets); |
|
1796 | 1796 | } |
1797 | 1797 | } |
1798 | 1798 | |
@@ -1808,27 +1808,27 @@ discard block |
||
1808 | 1808 | function upgrade_340() { |
1809 | 1809 | global $wp_current_db_version, $wpdb; |
1810 | 1810 | |
1811 | - if ( $wp_current_db_version < 19798 ) { |
|
1811 | + if ($wp_current_db_version < 19798) { |
|
1812 | 1812 | $wpdb->hide_errors(); |
1813 | - $wpdb->query( "ALTER TABLE $wpdb->options DROP COLUMN blog_id" ); |
|
1813 | + $wpdb->query("ALTER TABLE $wpdb->options DROP COLUMN blog_id"); |
|
1814 | 1814 | $wpdb->show_errors(); |
1815 | 1815 | } |
1816 | 1816 | |
1817 | - if ( $wp_current_db_version < 19799 ) { |
|
1817 | + if ($wp_current_db_version < 19799) { |
|
1818 | 1818 | $wpdb->hide_errors(); |
1819 | - $wpdb->query( "ALTER TABLE $wpdb->comments DROP INDEX comment_approved" ); |
|
1819 | + $wpdb->query("ALTER TABLE $wpdb->comments DROP INDEX comment_approved"); |
|
1820 | 1820 | $wpdb->show_errors(); |
1821 | 1821 | } |
1822 | 1822 | |
1823 | - if ( $wp_current_db_version < 20022 && wp_should_upgrade_global_tables() ) { |
|
1824 | - $wpdb->query( "DELETE FROM $wpdb->usermeta WHERE meta_key = 'themes_last_view'" ); |
|
1823 | + if ($wp_current_db_version < 20022 && wp_should_upgrade_global_tables()) { |
|
1824 | + $wpdb->query("DELETE FROM $wpdb->usermeta WHERE meta_key = 'themes_last_view'"); |
|
1825 | 1825 | } |
1826 | 1826 | |
1827 | - if ( $wp_current_db_version < 20080 ) { |
|
1828 | - if ( 'yes' === $wpdb->get_var( "SELECT autoload FROM $wpdb->options WHERE option_name = 'uninstall_plugins'" ) ) { |
|
1829 | - $uninstall_plugins = get_option( 'uninstall_plugins' ); |
|
1830 | - delete_option( 'uninstall_plugins' ); |
|
1831 | - add_option( 'uninstall_plugins', $uninstall_plugins, null, 'no' ); |
|
1827 | + if ($wp_current_db_version < 20080) { |
|
1828 | + if ('yes' === $wpdb->get_var("SELECT autoload FROM $wpdb->options WHERE option_name = 'uninstall_plugins'")) { |
|
1829 | + $uninstall_plugins = get_option('uninstall_plugins'); |
|
1830 | + delete_option('uninstall_plugins'); |
|
1831 | + add_option('uninstall_plugins', $uninstall_plugins, null, 'no'); |
|
1832 | 1832 | } |
1833 | 1833 | } |
1834 | 1834 | } |
@@ -1845,27 +1845,27 @@ discard block |
||
1845 | 1845 | function upgrade_350() { |
1846 | 1846 | global $wp_current_db_version, $wpdb; |
1847 | 1847 | |
1848 | - if ( $wp_current_db_version < 22006 && $wpdb->get_var( "SELECT link_id FROM $wpdb->links LIMIT 1" ) ) { |
|
1849 | - update_option( 'link_manager_enabled', 1 ); // Previously set to 0 by populate_options(). |
|
1848 | + if ($wp_current_db_version < 22006 && $wpdb->get_var("SELECT link_id FROM $wpdb->links LIMIT 1")) { |
|
1849 | + update_option('link_manager_enabled', 1); // Previously set to 0 by populate_options(). |
|
1850 | 1850 | } |
1851 | 1851 | |
1852 | - if ( $wp_current_db_version < 21811 && wp_should_upgrade_global_tables() ) { |
|
1852 | + if ($wp_current_db_version < 21811 && wp_should_upgrade_global_tables()) { |
|
1853 | 1853 | $meta_keys = array(); |
1854 | - foreach ( array_merge( get_post_types(), get_taxonomies() ) as $name ) { |
|
1855 | - if ( false !== strpos( $name, '-' ) ) { |
|
1856 | - $meta_keys[] = 'edit_' . str_replace( '-', '_', $name ) . '_per_page'; |
|
1854 | + foreach (array_merge(get_post_types(), get_taxonomies()) as $name) { |
|
1855 | + if (false !== strpos($name, '-')) { |
|
1856 | + $meta_keys[] = 'edit_' . str_replace('-', '_', $name) . '_per_page'; |
|
1857 | 1857 | } |
1858 | 1858 | } |
1859 | - if ( $meta_keys ) { |
|
1860 | - $meta_keys = implode( "', '", $meta_keys ); |
|
1861 | - $wpdb->query( "DELETE FROM $wpdb->usermeta WHERE meta_key IN ('$meta_keys')" ); |
|
1859 | + if ($meta_keys) { |
|
1860 | + $meta_keys = implode("', '", $meta_keys); |
|
1861 | + $wpdb->query("DELETE FROM $wpdb->usermeta WHERE meta_key IN ('$meta_keys')"); |
|
1862 | 1862 | } |
1863 | 1863 | } |
1864 | 1864 | |
1865 | - if ( $wp_current_db_version < 22422 ) { |
|
1866 | - $term = get_term_by( 'slug', 'post-format-standard', 'post_format' ); |
|
1867 | - if ( $term ) { |
|
1868 | - wp_delete_term( $term->term_id, 'post_format' ); |
|
1865 | + if ($wp_current_db_version < 22422) { |
|
1866 | + $term = get_term_by('slug', 'post-format-standard', 'post_format'); |
|
1867 | + if ($term) { |
|
1868 | + wp_delete_term($term->term_id, 'post_format'); |
|
1869 | 1869 | } |
1870 | 1870 | } |
1871 | 1871 | } |
@@ -1881,8 +1881,8 @@ discard block |
||
1881 | 1881 | function upgrade_370() { |
1882 | 1882 | global $wp_current_db_version; |
1883 | 1883 | |
1884 | - if ( $wp_current_db_version < 25824 ) { |
|
1885 | - wp_clear_scheduled_hook( 'wp_auto_updates_maybe_update' ); |
|
1884 | + if ($wp_current_db_version < 25824) { |
|
1885 | + wp_clear_scheduled_hook('wp_auto_updates_maybe_update'); |
|
1886 | 1886 | } |
1887 | 1887 | } |
1888 | 1888 | |
@@ -1897,8 +1897,8 @@ discard block |
||
1897 | 1897 | function upgrade_372() { |
1898 | 1898 | global $wp_current_db_version; |
1899 | 1899 | |
1900 | - if ( $wp_current_db_version < 26148 ) { |
|
1901 | - wp_clear_scheduled_hook( 'wp_maybe_auto_update' ); |
|
1900 | + if ($wp_current_db_version < 26148) { |
|
1901 | + wp_clear_scheduled_hook('wp_maybe_auto_update'); |
|
1902 | 1902 | } |
1903 | 1903 | } |
1904 | 1904 | |
@@ -1913,8 +1913,8 @@ discard block |
||
1913 | 1913 | function upgrade_380() { |
1914 | 1914 | global $wp_current_db_version; |
1915 | 1915 | |
1916 | - if ( $wp_current_db_version < 26691 ) { |
|
1917 | - deactivate_plugins( array( 'mp6/mp6.php' ), true ); |
|
1916 | + if ($wp_current_db_version < 26691) { |
|
1917 | + deactivate_plugins(array('mp6/mp6.php'), true); |
|
1918 | 1918 | } |
1919 | 1919 | } |
1920 | 1920 | |
@@ -1929,12 +1929,12 @@ discard block |
||
1929 | 1929 | function upgrade_400() { |
1930 | 1930 | global $wp_current_db_version; |
1931 | 1931 | |
1932 | - if ( $wp_current_db_version < 29630 ) { |
|
1933 | - if ( ! is_multisite() && false === get_option( 'WPLANG' ) ) { |
|
1934 | - if ( defined( 'WPLANG' ) && ( '' !== WPLANG ) && in_array( WPLANG, get_available_languages(), true ) ) { |
|
1935 | - update_option( 'WPLANG', WPLANG ); |
|
1932 | + if ($wp_current_db_version < 29630) { |
|
1933 | + if (!is_multisite() && false === get_option('WPLANG')) { |
|
1934 | + if (defined('WPLANG') && ('' !== WPLANG) && in_array(WPLANG, get_available_languages(), true)) { |
|
1935 | + update_option('WPLANG', WPLANG); |
|
1936 | 1936 | } else { |
1937 | - update_option( 'WPLANG', '' ); |
|
1937 | + update_option('WPLANG', ''); |
|
1938 | 1938 | } |
1939 | 1939 | } |
1940 | 1940 | } |
@@ -1960,29 +1960,29 @@ discard block |
||
1960 | 1960 | function upgrade_430() { |
1961 | 1961 | global $wp_current_db_version, $wpdb; |
1962 | 1962 | |
1963 | - if ( $wp_current_db_version < 32364 ) { |
|
1963 | + if ($wp_current_db_version < 32364) { |
|
1964 | 1964 | upgrade_430_fix_comments(); |
1965 | 1965 | } |
1966 | 1966 | |
1967 | 1967 | // Shared terms are split in a separate process. |
1968 | - if ( $wp_current_db_version < 32814 ) { |
|
1969 | - update_option( 'finished_splitting_shared_terms', 0 ); |
|
1970 | - wp_schedule_single_event( time() + ( 1 * MINUTE_IN_SECONDS ), 'wp_split_shared_term_batch' ); |
|
1968 | + if ($wp_current_db_version < 32814) { |
|
1969 | + update_option('finished_splitting_shared_terms', 0); |
|
1970 | + wp_schedule_single_event(time() + (1 * MINUTE_IN_SECONDS), 'wp_split_shared_term_batch'); |
|
1971 | 1971 | } |
1972 | 1972 | |
1973 | - if ( $wp_current_db_version < 33055 && 'utf8mb4' === $wpdb->charset ) { |
|
1974 | - if ( is_multisite() ) { |
|
1975 | - $tables = $wpdb->tables( 'blog' ); |
|
1973 | + if ($wp_current_db_version < 33055 && 'utf8mb4' === $wpdb->charset) { |
|
1974 | + if (is_multisite()) { |
|
1975 | + $tables = $wpdb->tables('blog'); |
|
1976 | 1976 | } else { |
1977 | - $tables = $wpdb->tables( 'all' ); |
|
1978 | - if ( ! wp_should_upgrade_global_tables() ) { |
|
1979 | - $global_tables = $wpdb->tables( 'global' ); |
|
1980 | - $tables = array_diff_assoc( $tables, $global_tables ); |
|
1977 | + $tables = $wpdb->tables('all'); |
|
1978 | + if (!wp_should_upgrade_global_tables()) { |
|
1979 | + $global_tables = $wpdb->tables('global'); |
|
1980 | + $tables = array_diff_assoc($tables, $global_tables); |
|
1981 | 1981 | } |
1982 | 1982 | } |
1983 | 1983 | |
1984 | - foreach ( $tables as $table ) { |
|
1985 | - maybe_convert_table_to_utf8mb4( $table ); |
|
1984 | + foreach ($tables as $table) { |
|
1985 | + maybe_convert_table_to_utf8mb4($table); |
|
1986 | 1986 | } |
1987 | 1987 | } |
1988 | 1988 | } |
@@ -1998,18 +1998,18 @@ discard block |
||
1998 | 1998 | function upgrade_430_fix_comments() { |
1999 | 1999 | global $wpdb; |
2000 | 2000 | |
2001 | - $content_length = $wpdb->get_col_length( $wpdb->comments, 'comment_content' ); |
|
2001 | + $content_length = $wpdb->get_col_length($wpdb->comments, 'comment_content'); |
|
2002 | 2002 | |
2003 | - if ( is_wp_error( $content_length ) ) { |
|
2003 | + if (is_wp_error($content_length)) { |
|
2004 | 2004 | return; |
2005 | 2005 | } |
2006 | 2006 | |
2007 | - if ( false === $content_length ) { |
|
2007 | + if (false === $content_length) { |
|
2008 | 2008 | $content_length = array( |
2009 | 2009 | 'type' => 'byte', |
2010 | 2010 | 'length' => 65535, |
2011 | 2011 | ); |
2012 | - } elseif ( ! is_array( $content_length ) ) { |
|
2012 | + } elseif (!is_array($content_length)) { |
|
2013 | 2013 | $length = (int) $content_length > 0 ? (int) $content_length : 65535; |
2014 | 2014 | $content_length = array( |
2015 | 2015 | 'type' => 'byte', |
@@ -2017,7 +2017,7 @@ discard block |
||
2017 | 2017 | ); |
2018 | 2018 | } |
2019 | 2019 | |
2020 | - if ( 'byte' !== $content_length['type'] || 0 === $content_length['length'] ) { |
|
2020 | + if ('byte' !== $content_length['type'] || 0 === $content_length['length']) { |
|
2021 | 2021 | // Sites with malformed DB schemas are on their own. |
2022 | 2022 | return; |
2023 | 2023 | } |
@@ -2031,8 +2031,8 @@ discard block |
||
2031 | 2031 | AND ( `comment_content` LIKE '%<%' OR `comment_content` LIKE '%>%' )" |
2032 | 2032 | ); |
2033 | 2033 | |
2034 | - foreach ( $comments as $comment ) { |
|
2035 | - wp_delete_comment( $comment->comment_ID, true ); |
|
2034 | + foreach ($comments as $comment) { |
|
2035 | + wp_delete_comment($comment->comment_ID, true); |
|
2036 | 2036 | } |
2037 | 2037 | } |
2038 | 2038 | |
@@ -2045,9 +2045,9 @@ discard block |
||
2045 | 2045 | function upgrade_431() { |
2046 | 2046 | // Fix incorrect cron entries for term splitting. |
2047 | 2047 | $cron_array = _get_cron_array(); |
2048 | - if ( isset( $cron_array['wp_batch_split_terms'] ) ) { |
|
2049 | - unset( $cron_array['wp_batch_split_terms'] ); |
|
2050 | - _set_cron_array( $cron_array ); |
|
2048 | + if (isset($cron_array['wp_batch_split_terms'])) { |
|
2049 | + unset($cron_array['wp_batch_split_terms']); |
|
2050 | + _set_cron_array($cron_array); |
|
2051 | 2051 | } |
2052 | 2052 | } |
2053 | 2053 | |
@@ -2063,15 +2063,15 @@ discard block |
||
2063 | 2063 | function upgrade_440() { |
2064 | 2064 | global $wp_current_db_version, $wpdb; |
2065 | 2065 | |
2066 | - if ( $wp_current_db_version < 34030 ) { |
|
2067 | - $wpdb->query( "ALTER TABLE {$wpdb->options} MODIFY option_name VARCHAR(191)" ); |
|
2066 | + if ($wp_current_db_version < 34030) { |
|
2067 | + $wpdb->query("ALTER TABLE {$wpdb->options} MODIFY option_name VARCHAR(191)"); |
|
2068 | 2068 | } |
2069 | 2069 | |
2070 | 2070 | // Remove the unused 'add_users' role. |
2071 | 2071 | $roles = wp_roles(); |
2072 | - foreach ( $roles->role_objects as $role ) { |
|
2073 | - if ( $role->has_cap( 'add_users' ) ) { |
|
2074 | - $role->remove_cap( 'add_users' ); |
|
2072 | + foreach ($roles->role_objects as $role) { |
|
2073 | + if ($role->has_cap('add_users')) { |
|
2074 | + $role->remove_cap('add_users'); |
|
2075 | 2075 | } |
2076 | 2076 | } |
2077 | 2077 | } |
@@ -2088,17 +2088,17 @@ discard block |
||
2088 | 2088 | function upgrade_450() { |
2089 | 2089 | global $wp_current_db_version, $wpdb; |
2090 | 2090 | |
2091 | - if ( $wp_current_db_version < 36180 ) { |
|
2092 | - wp_clear_scheduled_hook( 'wp_maybe_auto_update' ); |
|
2091 | + if ($wp_current_db_version < 36180) { |
|
2092 | + wp_clear_scheduled_hook('wp_maybe_auto_update'); |
|
2093 | 2093 | } |
2094 | 2094 | |
2095 | 2095 | // Remove unused email confirmation options, moved to usermeta. |
2096 | - if ( $wp_current_db_version < 36679 && is_multisite() ) { |
|
2097 | - $wpdb->query( "DELETE FROM $wpdb->options WHERE option_name REGEXP '^[0-9]+_new_email$'" ); |
|
2096 | + if ($wp_current_db_version < 36679 && is_multisite()) { |
|
2097 | + $wpdb->query("DELETE FROM $wpdb->options WHERE option_name REGEXP '^[0-9]+_new_email$'"); |
|
2098 | 2098 | } |
2099 | 2099 | |
2100 | 2100 | // Remove unused user setting for wpLink. |
2101 | - delete_user_setting( 'wplink' ); |
|
2101 | + delete_user_setting('wplink'); |
|
2102 | 2102 | } |
2103 | 2103 | |
2104 | 2104 | /** |
@@ -2113,22 +2113,22 @@ discard block |
||
2113 | 2113 | global $wp_current_db_version; |
2114 | 2114 | |
2115 | 2115 | // Remove unused post meta. |
2116 | - if ( $wp_current_db_version < 37854 ) { |
|
2117 | - delete_post_meta_by_key( '_post_restored_from' ); |
|
2116 | + if ($wp_current_db_version < 37854) { |
|
2117 | + delete_post_meta_by_key('_post_restored_from'); |
|
2118 | 2118 | } |
2119 | 2119 | |
2120 | 2120 | // Remove plugins with callback as an array object/method as the uninstall hook, see #13786. |
2121 | - if ( $wp_current_db_version < 37965 ) { |
|
2122 | - $uninstall_plugins = get_option( 'uninstall_plugins', array() ); |
|
2121 | + if ($wp_current_db_version < 37965) { |
|
2122 | + $uninstall_plugins = get_option('uninstall_plugins', array()); |
|
2123 | 2123 | |
2124 | - if ( ! empty( $uninstall_plugins ) ) { |
|
2125 | - foreach ( $uninstall_plugins as $basename => $callback ) { |
|
2126 | - if ( is_array( $callback ) && is_object( $callback[0] ) ) { |
|
2127 | - unset( $uninstall_plugins[ $basename ] ); |
|
2124 | + if (!empty($uninstall_plugins)) { |
|
2125 | + foreach ($uninstall_plugins as $basename => $callback) { |
|
2126 | + if (is_array($callback) && is_object($callback[0])) { |
|
2127 | + unset($uninstall_plugins[$basename]); |
|
2128 | 2128 | } |
2129 | 2129 | } |
2130 | 2130 | |
2131 | - update_option( 'uninstall_plugins', $uninstall_plugins ); |
|
2131 | + update_option('uninstall_plugins', $uninstall_plugins); |
|
2132 | 2132 | } |
2133 | 2133 | } |
2134 | 2134 | } |
@@ -2150,7 +2150,7 @@ discard block |
||
2150 | 2150 | * @since 5.1.0 |
2151 | 2151 | */ |
2152 | 2152 | function upgrade_510() { |
2153 | - delete_site_option( 'upgrade_500_was_gutenberg_active' ); |
|
2153 | + delete_site_option('upgrade_500_was_gutenberg_active'); |
|
2154 | 2154 | } |
2155 | 2155 | |
2156 | 2156 | /** |
@@ -2167,8 +2167,8 @@ discard block |
||
2167 | 2167 | * In the second case `admin_email_lifespan` should be reset so the verification screen |
2168 | 2168 | * is shown next time an admin logs in. |
2169 | 2169 | */ |
2170 | - if ( function_exists( 'current_user_can' ) && ! current_user_can( 'manage_options' ) ) { |
|
2171 | - update_option( 'admin_email_lifespan', 0 ); |
|
2170 | + if (function_exists('current_user_can') && !current_user_can('manage_options')) { |
|
2171 | + update_option('admin_email_lifespan', 0); |
|
2172 | 2172 | } |
2173 | 2173 | } |
2174 | 2174 | |
@@ -2181,32 +2181,32 @@ discard block |
||
2181 | 2181 | function upgrade_550() { |
2182 | 2182 | global $wp_current_db_version; |
2183 | 2183 | |
2184 | - if ( $wp_current_db_version < 48121 ) { |
|
2185 | - $comment_previously_approved = get_option( 'comment_whitelist', '' ); |
|
2186 | - update_option( 'comment_previously_approved', $comment_previously_approved ); |
|
2187 | - delete_option( 'comment_whitelist' ); |
|
2184 | + if ($wp_current_db_version < 48121) { |
|
2185 | + $comment_previously_approved = get_option('comment_whitelist', ''); |
|
2186 | + update_option('comment_previously_approved', $comment_previously_approved); |
|
2187 | + delete_option('comment_whitelist'); |
|
2188 | 2188 | } |
2189 | 2189 | |
2190 | - if ( $wp_current_db_version < 48575 ) { |
|
2190 | + if ($wp_current_db_version < 48575) { |
|
2191 | 2191 | // Use more clear and inclusive language. |
2192 | - $disallowed_list = get_option( 'blacklist_keys' ); |
|
2192 | + $disallowed_list = get_option('blacklist_keys'); |
|
2193 | 2193 | |
2194 | 2194 | /* |
2195 | 2195 | * This option key was briefly renamed `blocklist_keys`. |
2196 | 2196 | * Account for sites that have this key present when the original key does not exist. |
2197 | 2197 | */ |
2198 | - if ( false === $disallowed_list ) { |
|
2199 | - $disallowed_list = get_option( 'blocklist_keys' ); |
|
2198 | + if (false === $disallowed_list) { |
|
2199 | + $disallowed_list = get_option('blocklist_keys'); |
|
2200 | 2200 | } |
2201 | 2201 | |
2202 | - update_option( 'disallowed_keys', $disallowed_list ); |
|
2203 | - delete_option( 'blacklist_keys' ); |
|
2204 | - delete_option( 'blocklist_keys' ); |
|
2202 | + update_option('disallowed_keys', $disallowed_list); |
|
2203 | + delete_option('blacklist_keys'); |
|
2204 | + delete_option('blocklist_keys'); |
|
2205 | 2205 | } |
2206 | 2206 | |
2207 | - if ( $wp_current_db_version < 48748 ) { |
|
2208 | - update_option( 'finished_updating_comment_type', 0 ); |
|
2209 | - wp_schedule_single_event( time() + ( 1 * MINUTE_IN_SECONDS ), 'wp_update_comment_type_batch' ); |
|
2207 | + if ($wp_current_db_version < 48748) { |
|
2208 | + update_option('finished_updating_comment_type', 0); |
|
2209 | + wp_schedule_single_event(time() + (1 * MINUTE_IN_SECONDS), 'wp_update_comment_type_batch'); |
|
2210 | 2210 | } |
2211 | 2211 | } |
2212 | 2212 | |
@@ -2219,14 +2219,14 @@ discard block |
||
2219 | 2219 | function upgrade_560() { |
2220 | 2220 | global $wp_current_db_version, $wpdb; |
2221 | 2221 | |
2222 | - if ( $wp_current_db_version < 49572 ) { |
|
2222 | + if ($wp_current_db_version < 49572) { |
|
2223 | 2223 | /* |
2224 | 2224 | * Clean up the `post_category` column removed from schema in version 2.8.0. |
2225 | 2225 | * Its presence may conflict with `WP_Post::__get()`. |
2226 | 2226 | */ |
2227 | - $post_category_exists = $wpdb->get_var( "SHOW COLUMNS FROM $wpdb->posts LIKE 'post_category'" ); |
|
2228 | - if ( ! is_null( $post_category_exists ) ) { |
|
2229 | - $wpdb->query( "ALTER TABLE $wpdb->posts DROP COLUMN `post_category`" ); |
|
2227 | + $post_category_exists = $wpdb->get_var("SHOW COLUMNS FROM $wpdb->posts LIKE 'post_category'"); |
|
2228 | + if (!is_null($post_category_exists)) { |
|
2229 | + $wpdb->query("ALTER TABLE $wpdb->posts DROP COLUMN `post_category`"); |
|
2230 | 2230 | } |
2231 | 2231 | |
2232 | 2232 | /* |
@@ -2234,10 +2234,10 @@ discard block |
||
2234 | 2234 | * This overrides the same option from populate_options() that is intended for new installs. |
2235 | 2235 | * See https://core.trac.wordpress.org/ticket/51742. |
2236 | 2236 | */ |
2237 | - update_option( 'auto_update_core_major', 'unset' ); |
|
2237 | + update_option('auto_update_core_major', 'unset'); |
|
2238 | 2238 | } |
2239 | 2239 | |
2240 | - if ( $wp_current_db_version < 49632 ) { |
|
2240 | + if ($wp_current_db_version < 49632) { |
|
2241 | 2241 | /* |
2242 | 2242 | * Regenerate the .htaccess file to add the `HTTP_AUTHORIZATION` rewrite rule. |
2243 | 2243 | * See https://core.trac.wordpress.org/ticket/51723. |
@@ -2245,11 +2245,11 @@ discard block |
||
2245 | 2245 | save_mod_rewrite_rules(); |
2246 | 2246 | } |
2247 | 2247 | |
2248 | - if ( $wp_current_db_version < 49735 ) { |
|
2249 | - delete_transient( 'dirsize_cache' ); |
|
2248 | + if ($wp_current_db_version < 49735) { |
|
2249 | + delete_transient('dirsize_cache'); |
|
2250 | 2250 | } |
2251 | 2251 | |
2252 | - if ( $wp_current_db_version < 49752 ) { |
|
2252 | + if ($wp_current_db_version < 49752) { |
|
2253 | 2253 | $results = $wpdb->get_results( |
2254 | 2254 | $wpdb->prepare( |
2255 | 2255 | "SELECT 1 FROM {$wpdb->usermeta} WHERE meta_key = %s LIMIT 1", |
@@ -2257,9 +2257,9 @@ discard block |
||
2257 | 2257 | ) |
2258 | 2258 | ); |
2259 | 2259 | |
2260 | - if ( ! empty( $results ) ) { |
|
2260 | + if (!empty($results)) { |
|
2261 | 2261 | $network_id = get_main_network_id(); |
2262 | - update_network_option( $network_id, WP_Application_Passwords::OPTION_KEY_IN_USE, 1 ); |
|
2262 | + update_network_option($network_id, WP_Application_Passwords::OPTION_KEY_IN_USE, 1); |
|
2263 | 2263 | } |
2264 | 2264 | } |
2265 | 2265 | } |
@@ -2275,13 +2275,13 @@ discard block |
||
2275 | 2275 | function upgrade_590() { |
2276 | 2276 | global $wp_current_db_version; |
2277 | 2277 | |
2278 | - if ( $wp_current_db_version < 51917 ) { |
|
2278 | + if ($wp_current_db_version < 51917) { |
|
2279 | 2279 | $crons = _get_cron_array(); |
2280 | 2280 | |
2281 | - if ( $crons && is_array( $crons ) ) { |
|
2281 | + if ($crons && is_array($crons)) { |
|
2282 | 2282 | // Remove errant `false` values, see #53950, #54906. |
2283 | - $crons = array_filter( $crons ); |
|
2284 | - _set_cron_array( $crons ); |
|
2283 | + $crons = array_filter($crons); |
|
2284 | + _set_cron_array($crons); |
|
2285 | 2285 | } |
2286 | 2286 | } |
2287 | 2287 | } |
@@ -2297,7 +2297,7 @@ discard block |
||
2297 | 2297 | function upgrade_600() { |
2298 | 2298 | global $wp_current_db_version; |
2299 | 2299 | |
2300 | - if ( $wp_current_db_version < 53011 ) { |
|
2300 | + if ($wp_current_db_version < 53011) { |
|
2301 | 2301 | wp_update_user_counts(); |
2302 | 2302 | } |
2303 | 2303 | } |
@@ -2314,33 +2314,33 @@ discard block |
||
2314 | 2314 | global $wp_current_db_version, $wpdb; |
2315 | 2315 | |
2316 | 2316 | // Always clear expired transients. |
2317 | - delete_expired_transients( true ); |
|
2317 | + delete_expired_transients(true); |
|
2318 | 2318 | |
2319 | 2319 | // 2.8.0 |
2320 | - if ( $wp_current_db_version < 11549 ) { |
|
2321 | - $wpmu_sitewide_plugins = get_site_option( 'wpmu_sitewide_plugins' ); |
|
2322 | - $active_sitewide_plugins = get_site_option( 'active_sitewide_plugins' ); |
|
2323 | - if ( $wpmu_sitewide_plugins ) { |
|
2324 | - if ( ! $active_sitewide_plugins ) { |
|
2320 | + if ($wp_current_db_version < 11549) { |
|
2321 | + $wpmu_sitewide_plugins = get_site_option('wpmu_sitewide_plugins'); |
|
2322 | + $active_sitewide_plugins = get_site_option('active_sitewide_plugins'); |
|
2323 | + if ($wpmu_sitewide_plugins) { |
|
2324 | + if (!$active_sitewide_plugins) { |
|
2325 | 2325 | $sitewide_plugins = (array) $wpmu_sitewide_plugins; |
2326 | 2326 | } else { |
2327 | - $sitewide_plugins = array_merge( (array) $active_sitewide_plugins, (array) $wpmu_sitewide_plugins ); |
|
2327 | + $sitewide_plugins = array_merge((array) $active_sitewide_plugins, (array) $wpmu_sitewide_plugins); |
|
2328 | 2328 | } |
2329 | 2329 | |
2330 | - update_site_option( 'active_sitewide_plugins', $sitewide_plugins ); |
|
2330 | + update_site_option('active_sitewide_plugins', $sitewide_plugins); |
|
2331 | 2331 | } |
2332 | - delete_site_option( 'wpmu_sitewide_plugins' ); |
|
2333 | - delete_site_option( 'deactivated_sitewide_plugins' ); |
|
2332 | + delete_site_option('wpmu_sitewide_plugins'); |
|
2333 | + delete_site_option('deactivated_sitewide_plugins'); |
|
2334 | 2334 | |
2335 | 2335 | $start = 0; |
2336 | - while ( $rows = $wpdb->get_results( "SELECT meta_key, meta_value FROM {$wpdb->sitemeta} ORDER BY meta_id LIMIT $start, 20" ) ) { |
|
2337 | - foreach ( $rows as $row ) { |
|
2336 | + while ($rows = $wpdb->get_results("SELECT meta_key, meta_value FROM {$wpdb->sitemeta} ORDER BY meta_id LIMIT $start, 20")) { |
|
2337 | + foreach ($rows as $row) { |
|
2338 | 2338 | $value = $row->meta_value; |
2339 | - if ( ! @unserialize( $value ) ) { |
|
2340 | - $value = stripslashes( $value ); |
|
2339 | + if (!@unserialize($value)) { |
|
2340 | + $value = stripslashes($value); |
|
2341 | 2341 | } |
2342 | - if ( $value !== $row->meta_value ) { |
|
2343 | - update_site_option( $row->meta_key, $value ); |
|
2342 | + if ($value !== $row->meta_value) { |
|
2343 | + update_site_option($row->meta_key, $value); |
|
2344 | 2344 | } |
2345 | 2345 | } |
2346 | 2346 | $start += 20; |
@@ -2348,108 +2348,108 @@ discard block |
||
2348 | 2348 | } |
2349 | 2349 | |
2350 | 2350 | // 3.0.0 |
2351 | - if ( $wp_current_db_version < 13576 ) { |
|
2352 | - update_site_option( 'global_terms_enabled', '1' ); |
|
2351 | + if ($wp_current_db_version < 13576) { |
|
2352 | + update_site_option('global_terms_enabled', '1'); |
|
2353 | 2353 | } |
2354 | 2354 | |
2355 | 2355 | // 3.3.0 |
2356 | - if ( $wp_current_db_version < 19390 ) { |
|
2357 | - update_site_option( 'initial_db_version', $wp_current_db_version ); |
|
2356 | + if ($wp_current_db_version < 19390) { |
|
2357 | + update_site_option('initial_db_version', $wp_current_db_version); |
|
2358 | 2358 | } |
2359 | 2359 | |
2360 | - if ( $wp_current_db_version < 19470 ) { |
|
2361 | - if ( false === get_site_option( 'active_sitewide_plugins' ) ) { |
|
2362 | - update_site_option( 'active_sitewide_plugins', array() ); |
|
2360 | + if ($wp_current_db_version < 19470) { |
|
2361 | + if (false === get_site_option('active_sitewide_plugins')) { |
|
2362 | + update_site_option('active_sitewide_plugins', array()); |
|
2363 | 2363 | } |
2364 | 2364 | } |
2365 | 2365 | |
2366 | 2366 | // 3.4.0 |
2367 | - if ( $wp_current_db_version < 20148 ) { |
|
2367 | + if ($wp_current_db_version < 20148) { |
|
2368 | 2368 | // 'allowedthemes' keys things by stylesheet. 'allowed_themes' keyed things by name. |
2369 | - $allowedthemes = get_site_option( 'allowedthemes' ); |
|
2370 | - $allowed_themes = get_site_option( 'allowed_themes' ); |
|
2371 | - if ( false === $allowedthemes && is_array( $allowed_themes ) && $allowed_themes ) { |
|
2369 | + $allowedthemes = get_site_option('allowedthemes'); |
|
2370 | + $allowed_themes = get_site_option('allowed_themes'); |
|
2371 | + if (false === $allowedthemes && is_array($allowed_themes) && $allowed_themes) { |
|
2372 | 2372 | $converted = array(); |
2373 | 2373 | $themes = wp_get_themes(); |
2374 | - foreach ( $themes as $stylesheet => $theme_data ) { |
|
2375 | - if ( isset( $allowed_themes[ $theme_data->get( 'Name' ) ] ) ) { |
|
2376 | - $converted[ $stylesheet ] = true; |
|
2374 | + foreach ($themes as $stylesheet => $theme_data) { |
|
2375 | + if (isset($allowed_themes[$theme_data->get('Name')])) { |
|
2376 | + $converted[$stylesheet] = true; |
|
2377 | 2377 | } |
2378 | 2378 | } |
2379 | - update_site_option( 'allowedthemes', $converted ); |
|
2380 | - delete_site_option( 'allowed_themes' ); |
|
2379 | + update_site_option('allowedthemes', $converted); |
|
2380 | + delete_site_option('allowed_themes'); |
|
2381 | 2381 | } |
2382 | 2382 | } |
2383 | 2383 | |
2384 | 2384 | // 3.5.0 |
2385 | - if ( $wp_current_db_version < 21823 ) { |
|
2386 | - update_site_option( 'ms_files_rewriting', '1' ); |
|
2385 | + if ($wp_current_db_version < 21823) { |
|
2386 | + update_site_option('ms_files_rewriting', '1'); |
|
2387 | 2387 | } |
2388 | 2388 | |
2389 | 2389 | // 3.5.2 |
2390 | - if ( $wp_current_db_version < 24448 ) { |
|
2391 | - $illegal_names = get_site_option( 'illegal_names' ); |
|
2392 | - if ( is_array( $illegal_names ) && count( $illegal_names ) === 1 ) { |
|
2393 | - $illegal_name = reset( $illegal_names ); |
|
2394 | - $illegal_names = explode( ' ', $illegal_name ); |
|
2395 | - update_site_option( 'illegal_names', $illegal_names ); |
|
2390 | + if ($wp_current_db_version < 24448) { |
|
2391 | + $illegal_names = get_site_option('illegal_names'); |
|
2392 | + if (is_array($illegal_names) && count($illegal_names) === 1) { |
|
2393 | + $illegal_name = reset($illegal_names); |
|
2394 | + $illegal_names = explode(' ', $illegal_name); |
|
2395 | + update_site_option('illegal_names', $illegal_names); |
|
2396 | 2396 | } |
2397 | 2397 | } |
2398 | 2398 | |
2399 | 2399 | // 4.2.0 |
2400 | - if ( $wp_current_db_version < 31351 && 'utf8mb4' === $wpdb->charset ) { |
|
2401 | - if ( wp_should_upgrade_global_tables() ) { |
|
2402 | - $wpdb->query( "ALTER TABLE $wpdb->usermeta DROP INDEX meta_key, ADD INDEX meta_key(meta_key(191))" ); |
|
2403 | - $wpdb->query( "ALTER TABLE $wpdb->site DROP INDEX domain, ADD INDEX domain(domain(140),path(51))" ); |
|
2404 | - $wpdb->query( "ALTER TABLE $wpdb->sitemeta DROP INDEX meta_key, ADD INDEX meta_key(meta_key(191))" ); |
|
2405 | - $wpdb->query( "ALTER TABLE $wpdb->signups DROP INDEX domain_path, ADD INDEX domain_path(domain(140),path(51))" ); |
|
2400 | + if ($wp_current_db_version < 31351 && 'utf8mb4' === $wpdb->charset) { |
|
2401 | + if (wp_should_upgrade_global_tables()) { |
|
2402 | + $wpdb->query("ALTER TABLE $wpdb->usermeta DROP INDEX meta_key, ADD INDEX meta_key(meta_key(191))"); |
|
2403 | + $wpdb->query("ALTER TABLE $wpdb->site DROP INDEX domain, ADD INDEX domain(domain(140),path(51))"); |
|
2404 | + $wpdb->query("ALTER TABLE $wpdb->sitemeta DROP INDEX meta_key, ADD INDEX meta_key(meta_key(191))"); |
|
2405 | + $wpdb->query("ALTER TABLE $wpdb->signups DROP INDEX domain_path, ADD INDEX domain_path(domain(140),path(51))"); |
|
2406 | 2406 | |
2407 | - $tables = $wpdb->tables( 'global' ); |
|
2407 | + $tables = $wpdb->tables('global'); |
|
2408 | 2408 | |
2409 | 2409 | // sitecategories may not exist. |
2410 | - if ( ! $wpdb->get_var( "SHOW TABLES LIKE '{$tables['sitecategories']}'" ) ) { |
|
2411 | - unset( $tables['sitecategories'] ); |
|
2410 | + if (!$wpdb->get_var("SHOW TABLES LIKE '{$tables['sitecategories']}'")) { |
|
2411 | + unset($tables['sitecategories']); |
|
2412 | 2412 | } |
2413 | 2413 | |
2414 | - foreach ( $tables as $table ) { |
|
2415 | - maybe_convert_table_to_utf8mb4( $table ); |
|
2414 | + foreach ($tables as $table) { |
|
2415 | + maybe_convert_table_to_utf8mb4($table); |
|
2416 | 2416 | } |
2417 | 2417 | } |
2418 | 2418 | } |
2419 | 2419 | |
2420 | 2420 | // 4.3.0 |
2421 | - if ( $wp_current_db_version < 33055 && 'utf8mb4' === $wpdb->charset ) { |
|
2422 | - if ( wp_should_upgrade_global_tables() ) { |
|
2421 | + if ($wp_current_db_version < 33055 && 'utf8mb4' === $wpdb->charset) { |
|
2422 | + if (wp_should_upgrade_global_tables()) { |
|
2423 | 2423 | $upgrade = false; |
2424 | - $indexes = $wpdb->get_results( "SHOW INDEXES FROM $wpdb->signups" ); |
|
2425 | - foreach ( $indexes as $index ) { |
|
2426 | - if ( 'domain_path' === $index->Key_name && 'domain' === $index->Column_name && 140 != $index->Sub_part ) { |
|
2424 | + $indexes = $wpdb->get_results("SHOW INDEXES FROM $wpdb->signups"); |
|
2425 | + foreach ($indexes as $index) { |
|
2426 | + if ('domain_path' === $index->Key_name && 'domain' === $index->Column_name && 140 != $index->Sub_part) { |
|
2427 | 2427 | $upgrade = true; |
2428 | 2428 | break; |
2429 | 2429 | } |
2430 | 2430 | } |
2431 | 2431 | |
2432 | - if ( $upgrade ) { |
|
2433 | - $wpdb->query( "ALTER TABLE $wpdb->signups DROP INDEX domain_path, ADD INDEX domain_path(domain(140),path(51))" ); |
|
2432 | + if ($upgrade) { |
|
2433 | + $wpdb->query("ALTER TABLE $wpdb->signups DROP INDEX domain_path, ADD INDEX domain_path(domain(140),path(51))"); |
|
2434 | 2434 | } |
2435 | 2435 | |
2436 | - $tables = $wpdb->tables( 'global' ); |
|
2436 | + $tables = $wpdb->tables('global'); |
|
2437 | 2437 | |
2438 | 2438 | // sitecategories may not exist. |
2439 | - if ( ! $wpdb->get_var( "SHOW TABLES LIKE '{$tables['sitecategories']}'" ) ) { |
|
2440 | - unset( $tables['sitecategories'] ); |
|
2439 | + if (!$wpdb->get_var("SHOW TABLES LIKE '{$tables['sitecategories']}'")) { |
|
2440 | + unset($tables['sitecategories']); |
|
2441 | 2441 | } |
2442 | 2442 | |
2443 | - foreach ( $tables as $table ) { |
|
2444 | - maybe_convert_table_to_utf8mb4( $table ); |
|
2443 | + foreach ($tables as $table) { |
|
2444 | + maybe_convert_table_to_utf8mb4($table); |
|
2445 | 2445 | } |
2446 | 2446 | } |
2447 | 2447 | } |
2448 | 2448 | |
2449 | 2449 | // 5.1.0 |
2450 | - if ( $wp_current_db_version < 44467 ) { |
|
2450 | + if ($wp_current_db_version < 44467) { |
|
2451 | 2451 | $network_id = get_main_network_id(); |
2452 | - delete_network_option( $network_id, 'site_meta_supported' ); |
|
2452 | + delete_network_option($network_id, 'site_meta_supported'); |
|
2453 | 2453 | is_site_meta_supported(); |
2454 | 2454 | } |
2455 | 2455 | } |
@@ -2473,20 +2473,20 @@ discard block |
||
2473 | 2473 | * @param string $create_ddl SQL statement to create table. |
2474 | 2474 | * @return bool True on success or if the table already exists. False on failure. |
2475 | 2475 | */ |
2476 | -function maybe_create_table( $table_name, $create_ddl ) { |
|
2476 | +function maybe_create_table($table_name, $create_ddl) { |
|
2477 | 2477 | global $wpdb; |
2478 | 2478 | |
2479 | - $query = $wpdb->prepare( 'SHOW TABLES LIKE %s', $wpdb->esc_like( $table_name ) ); |
|
2479 | + $query = $wpdb->prepare('SHOW TABLES LIKE %s', $wpdb->esc_like($table_name)); |
|
2480 | 2480 | |
2481 | - if ( $wpdb->get_var( $query ) === $table_name ) { |
|
2481 | + if ($wpdb->get_var($query) === $table_name) { |
|
2482 | 2482 | return true; |
2483 | 2483 | } |
2484 | 2484 | |
2485 | 2485 | // Didn't find it, so try to create it. |
2486 | - $wpdb->query( $create_ddl ); |
|
2486 | + $wpdb->query($create_ddl); |
|
2487 | 2487 | |
2488 | 2488 | // We cannot directly tell that whether this succeeded! |
2489 | - if ( $wpdb->get_var( $query ) === $table_name ) { |
|
2489 | + if ($wpdb->get_var($query) === $table_name) { |
|
2490 | 2490 | return true; |
2491 | 2491 | } |
2492 | 2492 | |
@@ -2504,16 +2504,16 @@ discard block |
||
2504 | 2504 | * @param string $index Index name to drop. |
2505 | 2505 | * @return true True, when finished. |
2506 | 2506 | */ |
2507 | -function drop_index( $table, $index ) { |
|
2507 | +function drop_index($table, $index) { |
|
2508 | 2508 | global $wpdb; |
2509 | 2509 | |
2510 | 2510 | $wpdb->hide_errors(); |
2511 | 2511 | |
2512 | - $wpdb->query( "ALTER TABLE `$table` DROP INDEX `$index`" ); |
|
2512 | + $wpdb->query("ALTER TABLE `$table` DROP INDEX `$index`"); |
|
2513 | 2513 | |
2514 | 2514 | // Now we need to take out all the extra ones we may have created. |
2515 | - for ( $i = 0; $i < 25; $i++ ) { |
|
2516 | - $wpdb->query( "ALTER TABLE `$table` DROP INDEX `{$index}_$i`" ); |
|
2515 | + for ($i = 0; $i < 25; $i++) { |
|
2516 | + $wpdb->query("ALTER TABLE `$table` DROP INDEX `{$index}_$i`"); |
|
2517 | 2517 | } |
2518 | 2518 | |
2519 | 2519 | $wpdb->show_errors(); |
@@ -2532,11 +2532,11 @@ discard block |
||
2532 | 2532 | * @param string $index Database table index column. |
2533 | 2533 | * @return true True, when done with execution. |
2534 | 2534 | */ |
2535 | -function add_clean_index( $table, $index ) { |
|
2535 | +function add_clean_index($table, $index) { |
|
2536 | 2536 | global $wpdb; |
2537 | 2537 | |
2538 | - drop_index( $table, $index ); |
|
2539 | - $wpdb->query( "ALTER TABLE `$table` ADD INDEX ( `$index` )" ); |
|
2538 | + drop_index($table, $index); |
|
2539 | + $wpdb->query("ALTER TABLE `$table` ADD INDEX ( `$index` )"); |
|
2540 | 2540 | |
2541 | 2541 | return true; |
2542 | 2542 | } |
@@ -2553,21 +2553,21 @@ discard block |
||
2553 | 2553 | * @param string $create_ddl SQL statement to add column. |
2554 | 2554 | * @return bool True on success or if the column already exists. False on failure. |
2555 | 2555 | */ |
2556 | -function maybe_add_column( $table_name, $column_name, $create_ddl ) { |
|
2556 | +function maybe_add_column($table_name, $column_name, $create_ddl) { |
|
2557 | 2557 | global $wpdb; |
2558 | 2558 | |
2559 | - foreach ( $wpdb->get_col( "DESC $table_name", 0 ) as $column ) { |
|
2560 | - if ( $column === $column_name ) { |
|
2559 | + foreach ($wpdb->get_col("DESC $table_name", 0) as $column) { |
|
2560 | + if ($column === $column_name) { |
|
2561 | 2561 | return true; |
2562 | 2562 | } |
2563 | 2563 | } |
2564 | 2564 | |
2565 | 2565 | // Didn't find it, so try to create it. |
2566 | - $wpdb->query( $create_ddl ); |
|
2566 | + $wpdb->query($create_ddl); |
|
2567 | 2567 | |
2568 | 2568 | // We cannot directly tell that whether this succeeded! |
2569 | - foreach ( $wpdb->get_col( "DESC $table_name", 0 ) as $column ) { |
|
2570 | - if ( $column === $column_name ) { |
|
2569 | + foreach ($wpdb->get_col("DESC $table_name", 0) as $column) { |
|
2570 | + if ($column === $column_name) { |
|
2571 | 2571 | return true; |
2572 | 2572 | } |
2573 | 2573 | } |
@@ -2585,37 +2585,37 @@ discard block |
||
2585 | 2585 | * @param string $table The table to convert. |
2586 | 2586 | * @return bool True if the table was converted, false if it wasn't. |
2587 | 2587 | */ |
2588 | -function maybe_convert_table_to_utf8mb4( $table ) { |
|
2588 | +function maybe_convert_table_to_utf8mb4($table) { |
|
2589 | 2589 | global $wpdb; |
2590 | 2590 | |
2591 | - $results = $wpdb->get_results( "SHOW FULL COLUMNS FROM `$table`" ); |
|
2592 | - if ( ! $results ) { |
|
2591 | + $results = $wpdb->get_results("SHOW FULL COLUMNS FROM `$table`"); |
|
2592 | + if (!$results) { |
|
2593 | 2593 | return false; |
2594 | 2594 | } |
2595 | 2595 | |
2596 | - foreach ( $results as $column ) { |
|
2597 | - if ( $column->Collation ) { |
|
2598 | - list( $charset ) = explode( '_', $column->Collation ); |
|
2599 | - $charset = strtolower( $charset ); |
|
2600 | - if ( 'utf8' !== $charset && 'utf8mb4' !== $charset ) { |
|
2596 | + foreach ($results as $column) { |
|
2597 | + if ($column->Collation) { |
|
2598 | + list($charset) = explode('_', $column->Collation); |
|
2599 | + $charset = strtolower($charset); |
|
2600 | + if ('utf8' !== $charset && 'utf8mb4' !== $charset) { |
|
2601 | 2601 | // Don't upgrade tables that have non-utf8 columns. |
2602 | 2602 | return false; |
2603 | 2603 | } |
2604 | 2604 | } |
2605 | 2605 | } |
2606 | 2606 | |
2607 | - $table_details = $wpdb->get_row( "SHOW TABLE STATUS LIKE '$table'" ); |
|
2608 | - if ( ! $table_details ) { |
|
2607 | + $table_details = $wpdb->get_row("SHOW TABLE STATUS LIKE '$table'"); |
|
2608 | + if (!$table_details) { |
|
2609 | 2609 | return false; |
2610 | 2610 | } |
2611 | 2611 | |
2612 | - list( $table_charset ) = explode( '_', $table_details->Collation ); |
|
2613 | - $table_charset = strtolower( $table_charset ); |
|
2614 | - if ( 'utf8mb4' === $table_charset ) { |
|
2612 | + list($table_charset) = explode('_', $table_details->Collation); |
|
2613 | + $table_charset = strtolower($table_charset); |
|
2614 | + if ('utf8mb4' === $table_charset) { |
|
2615 | 2615 | return true; |
2616 | 2616 | } |
2617 | 2617 | |
2618 | - return $wpdb->query( "ALTER TABLE $table CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci" ); |
|
2618 | + return $wpdb->query("ALTER TABLE $table CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci"); |
|
2619 | 2619 | } |
2620 | 2620 | |
2621 | 2621 | /** |
@@ -2630,13 +2630,13 @@ discard block |
||
2630 | 2630 | function get_alloptions_110() { |
2631 | 2631 | global $wpdb; |
2632 | 2632 | $all_options = new stdClass; |
2633 | - $options = $wpdb->get_results( "SELECT option_name, option_value FROM $wpdb->options" ); |
|
2634 | - if ( $options ) { |
|
2635 | - foreach ( $options as $option ) { |
|
2636 | - if ( 'siteurl' === $option->option_name || 'home' === $option->option_name || 'category_base' === $option->option_name ) { |
|
2637 | - $option->option_value = untrailingslashit( $option->option_value ); |
|
2633 | + $options = $wpdb->get_results("SELECT option_name, option_value FROM $wpdb->options"); |
|
2634 | + if ($options) { |
|
2635 | + foreach ($options as $option) { |
|
2636 | + if ('siteurl' === $option->option_name || 'home' === $option->option_name || 'category_base' === $option->option_name) { |
|
2637 | + $option->option_value = untrailingslashit($option->option_value); |
|
2638 | 2638 | } |
2639 | - $all_options->{$option->option_name} = stripslashes( $option->option_value ); |
|
2639 | + $all_options->{$option->option_name} = stripslashes($option->option_value); |
|
2640 | 2640 | } |
2641 | 2641 | } |
2642 | 2642 | return $all_options; |
@@ -2654,28 +2654,28 @@ discard block |
||
2654 | 2654 | * @param string $setting Option name. |
2655 | 2655 | * @return mixed |
2656 | 2656 | */ |
2657 | -function __get_option( $setting ) { // phpcs:ignore WordPress.NamingConventions.ValidFunctionName.FunctionDoubleUnderscore,PHPCompatibility.FunctionNameRestrictions.ReservedFunctionNames.FunctionDoubleUnderscore |
|
2657 | +function __get_option($setting) { // phpcs:ignore WordPress.NamingConventions.ValidFunctionName.FunctionDoubleUnderscore,PHPCompatibility.FunctionNameRestrictions.ReservedFunctionNames.FunctionDoubleUnderscore |
|
2658 | 2658 | global $wpdb; |
2659 | 2659 | |
2660 | - if ( 'home' === $setting && defined( 'WP_HOME' ) ) { |
|
2661 | - return untrailingslashit( WP_HOME ); |
|
2660 | + if ('home' === $setting && defined('WP_HOME')) { |
|
2661 | + return untrailingslashit(WP_HOME); |
|
2662 | 2662 | } |
2663 | 2663 | |
2664 | - if ( 'siteurl' === $setting && defined( 'WP_SITEURL' ) ) { |
|
2665 | - return untrailingslashit( WP_SITEURL ); |
|
2664 | + if ('siteurl' === $setting && defined('WP_SITEURL')) { |
|
2665 | + return untrailingslashit(WP_SITEURL); |
|
2666 | 2666 | } |
2667 | 2667 | |
2668 | - $option = $wpdb->get_var( $wpdb->prepare( "SELECT option_value FROM $wpdb->options WHERE option_name = %s", $setting ) ); |
|
2668 | + $option = $wpdb->get_var($wpdb->prepare("SELECT option_value FROM $wpdb->options WHERE option_name = %s", $setting)); |
|
2669 | 2669 | |
2670 | - if ( 'home' === $setting && ! $option ) { |
|
2671 | - return __get_option( 'siteurl' ); |
|
2670 | + if ('home' === $setting && !$option) { |
|
2671 | + return __get_option('siteurl'); |
|
2672 | 2672 | } |
2673 | 2673 | |
2674 | - if ( in_array( $setting, array( 'siteurl', 'home', 'category_base', 'tag_base' ), true ) ) { |
|
2675 | - $option = untrailingslashit( $option ); |
|
2674 | + if (in_array($setting, array('siteurl', 'home', 'category_base', 'tag_base'), true)) { |
|
2675 | + $option = untrailingslashit($option); |
|
2676 | 2676 | } |
2677 | 2677 | |
2678 | - return maybe_unserialize( $option ); |
|
2678 | + return maybe_unserialize($option); |
|
2679 | 2679 | } |
2680 | 2680 | |
2681 | 2681 | /** |
@@ -2686,23 +2686,23 @@ discard block |
||
2686 | 2686 | * @param string $content The content to modify. |
2687 | 2687 | * @return string The de-slashed content. |
2688 | 2688 | */ |
2689 | -function deslash( $content ) { |
|
2689 | +function deslash($content) { |
|
2690 | 2690 | // Note: \\\ inside a regex denotes a single backslash. |
2691 | 2691 | |
2692 | 2692 | /* |
2693 | 2693 | * Replace one or more backslashes followed by a single quote with |
2694 | 2694 | * a single quote. |
2695 | 2695 | */ |
2696 | - $content = preg_replace( "/\\\+'/", "'", $content ); |
|
2696 | + $content = preg_replace("/\\\+'/", "'", $content); |
|
2697 | 2697 | |
2698 | 2698 | /* |
2699 | 2699 | * Replace one or more backslashes followed by a double quote with |
2700 | 2700 | * a double quote. |
2701 | 2701 | */ |
2702 | - $content = preg_replace( '/\\\+"/', '"', $content ); |
|
2702 | + $content = preg_replace('/\\\+"/', '"', $content); |
|
2703 | 2703 | |
2704 | 2704 | // Replace one or more backslashes with one backslash. |
2705 | - $content = preg_replace( '/\\\+/', '\\', $content ); |
|
2705 | + $content = preg_replace('/\\\+/', '\\', $content); |
|
2706 | 2706 | |
2707 | 2707 | return $content; |
2708 | 2708 | } |
@@ -2723,17 +2723,17 @@ discard block |
||
2723 | 2723 | * Default true. |
2724 | 2724 | * @return array Strings containing the results of the various update queries. |
2725 | 2725 | */ |
2726 | -function dbDelta( $queries = '', $execute = true ) { // phpcs:ignore WordPress.NamingConventions.ValidFunctionName.FunctionNameInvalid |
|
2726 | +function dbDelta($queries = '', $execute = true) { // phpcs:ignore WordPress.NamingConventions.ValidFunctionName.FunctionNameInvalid |
|
2727 | 2727 | global $wpdb; |
2728 | 2728 | |
2729 | - if ( in_array( $queries, array( '', 'all', 'blog', 'global', 'ms_global' ), true ) ) { |
|
2730 | - $queries = wp_get_db_schema( $queries ); |
|
2729 | + if (in_array($queries, array('', 'all', 'blog', 'global', 'ms_global'), true)) { |
|
2730 | + $queries = wp_get_db_schema($queries); |
|
2731 | 2731 | } |
2732 | 2732 | |
2733 | 2733 | // Separate individual queries into an array. |
2734 | - if ( ! is_array( $queries ) ) { |
|
2735 | - $queries = explode( ';', $queries ); |
|
2736 | - $queries = array_filter( $queries ); |
|
2734 | + if (!is_array($queries)) { |
|
2735 | + $queries = explode(';', $queries); |
|
2736 | + $queries = array_filter($queries); |
|
2737 | 2737 | } |
2738 | 2738 | |
2739 | 2739 | /** |
@@ -2743,22 +2743,22 @@ discard block |
||
2743 | 2743 | * |
2744 | 2744 | * @param string[] $queries An array of dbDelta SQL queries. |
2745 | 2745 | */ |
2746 | - $queries = apply_filters( 'dbdelta_queries', $queries ); |
|
2746 | + $queries = apply_filters('dbdelta_queries', $queries); |
|
2747 | 2747 | |
2748 | 2748 | $cqueries = array(); // Creation queries. |
2749 | 2749 | $iqueries = array(); // Insertion queries. |
2750 | 2750 | $for_update = array(); |
2751 | 2751 | |
2752 | 2752 | // Create a tablename index for an array ($cqueries) of queries. |
2753 | - foreach ( $queries as $qry ) { |
|
2754 | - if ( preg_match( '|CREATE TABLE ([^ ]*)|', $qry, $matches ) ) { |
|
2755 | - $cqueries[ trim( $matches[1], '`' ) ] = $qry; |
|
2756 | - $for_update[ $matches[1] ] = 'Created table ' . $matches[1]; |
|
2757 | - } elseif ( preg_match( '|CREATE DATABASE ([^ ]*)|', $qry, $matches ) ) { |
|
2758 | - array_unshift( $cqueries, $qry ); |
|
2759 | - } elseif ( preg_match( '|INSERT INTO ([^ ]*)|', $qry, $matches ) ) { |
|
2753 | + foreach ($queries as $qry) { |
|
2754 | + if (preg_match('|CREATE TABLE ([^ ]*)|', $qry, $matches)) { |
|
2755 | + $cqueries[trim($matches[1], '`')] = $qry; |
|
2756 | + $for_update[$matches[1]] = 'Created table ' . $matches[1]; |
|
2757 | + } elseif (preg_match('|CREATE DATABASE ([^ ]*)|', $qry, $matches)) { |
|
2758 | + array_unshift($cqueries, $qry); |
|
2759 | + } elseif (preg_match('|INSERT INTO ([^ ]*)|', $qry, $matches)) { |
|
2760 | 2760 | $iqueries[] = $qry; |
2761 | - } elseif ( preg_match( '|UPDATE ([^ ]*)|', $qry, $matches ) ) { |
|
2761 | + } elseif (preg_match('|UPDATE ([^ ]*)|', $qry, $matches)) { |
|
2762 | 2762 | $iqueries[] = $qry; |
2763 | 2763 | } else { |
2764 | 2764 | // Unrecognized query type. |
@@ -2774,7 +2774,7 @@ discard block |
||
2774 | 2774 | * |
2775 | 2775 | * @param string[] $cqueries An array of dbDelta create SQL queries. |
2776 | 2776 | */ |
2777 | - $cqueries = apply_filters( 'dbdelta_create_queries', $cqueries ); |
|
2777 | + $cqueries = apply_filters('dbdelta_create_queries', $cqueries); |
|
2778 | 2778 | |
2779 | 2779 | /** |
2780 | 2780 | * Filters the dbDelta SQL queries for inserting or updating. |
@@ -2785,25 +2785,25 @@ discard block |
||
2785 | 2785 | * |
2786 | 2786 | * @param string[] $iqueries An array of dbDelta insert or update SQL queries. |
2787 | 2787 | */ |
2788 | - $iqueries = apply_filters( 'dbdelta_insert_queries', $iqueries ); |
|
2788 | + $iqueries = apply_filters('dbdelta_insert_queries', $iqueries); |
|
2789 | 2789 | |
2790 | - $text_fields = array( 'tinytext', 'text', 'mediumtext', 'longtext' ); |
|
2791 | - $blob_fields = array( 'tinyblob', 'blob', 'mediumblob', 'longblob' ); |
|
2790 | + $text_fields = array('tinytext', 'text', 'mediumtext', 'longtext'); |
|
2791 | + $blob_fields = array('tinyblob', 'blob', 'mediumblob', 'longblob'); |
|
2792 | 2792 | |
2793 | - $global_tables = $wpdb->tables( 'global' ); |
|
2794 | - foreach ( $cqueries as $table => $qry ) { |
|
2793 | + $global_tables = $wpdb->tables('global'); |
|
2794 | + foreach ($cqueries as $table => $qry) { |
|
2795 | 2795 | // Upgrade global tables only for the main site. Don't upgrade at all if conditions are not optimal. |
2796 | - if ( in_array( $table, $global_tables, true ) && ! wp_should_upgrade_global_tables() ) { |
|
2797 | - unset( $cqueries[ $table ], $for_update[ $table ] ); |
|
2796 | + if (in_array($table, $global_tables, true) && !wp_should_upgrade_global_tables()) { |
|
2797 | + unset($cqueries[$table], $for_update[$table]); |
|
2798 | 2798 | continue; |
2799 | 2799 | } |
2800 | 2800 | |
2801 | 2801 | // Fetch the table column structure from the database. |
2802 | 2802 | $suppress = $wpdb->suppress_errors(); |
2803 | - $tablefields = $wpdb->get_results( "DESCRIBE {$table};" ); |
|
2804 | - $wpdb->suppress_errors( $suppress ); |
|
2803 | + $tablefields = $wpdb->get_results("DESCRIBE {$table};"); |
|
2804 | + $wpdb->suppress_errors($suppress); |
|
2805 | 2805 | |
2806 | - if ( ! $tablefields ) { |
|
2806 | + if (!$tablefields) { |
|
2807 | 2807 | continue; |
2808 | 2808 | } |
2809 | 2809 | |
@@ -2813,24 +2813,24 @@ discard block |
||
2813 | 2813 | $indices_without_subparts = array(); |
2814 | 2814 | |
2815 | 2815 | // Get all of the field names in the query from between the parentheses. |
2816 | - preg_match( '|\((.*)\)|ms', $qry, $match2 ); |
|
2817 | - $qryline = trim( $match2[1] ); |
|
2816 | + preg_match('|\((.*)\)|ms', $qry, $match2); |
|
2817 | + $qryline = trim($match2[1]); |
|
2818 | 2818 | |
2819 | 2819 | // Separate field lines into an array. |
2820 | - $flds = explode( "\n", $qryline ); |
|
2820 | + $flds = explode("\n", $qryline); |
|
2821 | 2821 | |
2822 | 2822 | // For every field line specified in the query. |
2823 | - foreach ( $flds as $fld ) { |
|
2824 | - $fld = trim( $fld, " \t\n\r\0\x0B," ); // Default trim characters, plus ','. |
|
2823 | + foreach ($flds as $fld) { |
|
2824 | + $fld = trim($fld, " \t\n\r\0\x0B,"); // Default trim characters, plus ','. |
|
2825 | 2825 | |
2826 | 2826 | // Extract the field name. |
2827 | - preg_match( '|^([^ ]*)|', $fld, $fvals ); |
|
2828 | - $fieldname = trim( $fvals[1], '`' ); |
|
2829 | - $fieldname_lowercased = strtolower( $fieldname ); |
|
2827 | + preg_match('|^([^ ]*)|', $fld, $fvals); |
|
2828 | + $fieldname = trim($fvals[1], '`'); |
|
2829 | + $fieldname_lowercased = strtolower($fieldname); |
|
2830 | 2830 | |
2831 | 2831 | // Verify the found field name. |
2832 | 2832 | $validfield = true; |
2833 | - switch ( $fieldname_lowercased ) { |
|
2833 | + switch ($fieldname_lowercased) { |
|
2834 | 2834 | case '': |
2835 | 2835 | case 'primary': |
2836 | 2836 | case 'index': |
@@ -2876,20 +2876,20 @@ discard block |
||
2876 | 2876 | // phpcs:enable |
2877 | 2877 | |
2878 | 2878 | // Uppercase the index type and normalize space characters. |
2879 | - $index_type = strtoupper( preg_replace( '/\s+/', ' ', trim( $index_matches['index_type'] ) ) ); |
|
2879 | + $index_type = strtoupper(preg_replace('/\s+/', ' ', trim($index_matches['index_type']))); |
|
2880 | 2880 | |
2881 | 2881 | // 'INDEX' is a synonym for 'KEY', standardize on 'KEY'. |
2882 | - $index_type = str_replace( 'INDEX', 'KEY', $index_type ); |
|
2882 | + $index_type = str_replace('INDEX', 'KEY', $index_type); |
|
2883 | 2883 | |
2884 | 2884 | // Escape the index name with backticks. An index for a primary key has no name. |
2885 | - $index_name = ( 'PRIMARY KEY' === $index_type ) ? '' : '`' . strtolower( $index_matches['index_name'] ) . '`'; |
|
2885 | + $index_name = ('PRIMARY KEY' === $index_type) ? '' : '`' . strtolower($index_matches['index_name']) . '`'; |
|
2886 | 2886 | |
2887 | 2887 | // Parse the columns. Multiple columns are separated by a comma. |
2888 | - $index_columns = array_map( 'trim', explode( ',', $index_matches['index_columns'] ) ); |
|
2888 | + $index_columns = array_map('trim', explode(',', $index_matches['index_columns'])); |
|
2889 | 2889 | $index_columns_without_subparts = $index_columns; |
2890 | 2890 | |
2891 | 2891 | // Normalize columns. |
2892 | - foreach ( $index_columns as $id => &$index_column ) { |
|
2892 | + foreach ($index_columns as $id => &$index_column) { |
|
2893 | 2893 | // Extract column name and number of indexed characters (sub_part). |
2894 | 2894 | preg_match( |
2895 | 2895 | '/' |
@@ -2917,137 +2917,137 @@ discard block |
||
2917 | 2917 | $index_column = '`' . $index_column_matches['column_name'] . '`'; |
2918 | 2918 | |
2919 | 2919 | // We don't need to add the subpart to $index_columns_without_subparts |
2920 | - $index_columns_without_subparts[ $id ] = $index_column; |
|
2920 | + $index_columns_without_subparts[$id] = $index_column; |
|
2921 | 2921 | |
2922 | 2922 | // Append the optional sup part with the number of indexed characters. |
2923 | - if ( isset( $index_column_matches['sub_part'] ) ) { |
|
2923 | + if (isset($index_column_matches['sub_part'])) { |
|
2924 | 2924 | $index_column .= '(' . $index_column_matches['sub_part'] . ')'; |
2925 | 2925 | } |
2926 | 2926 | } |
2927 | 2927 | |
2928 | 2928 | // Build the normalized index definition and add it to the list of indices. |
2929 | - $indices[] = "{$index_type} {$index_name} (" . implode( ',', $index_columns ) . ')'; |
|
2930 | - $indices_without_subparts[] = "{$index_type} {$index_name} (" . implode( ',', $index_columns_without_subparts ) . ')'; |
|
2929 | + $indices[] = "{$index_type} {$index_name} (" . implode(',', $index_columns) . ')'; |
|
2930 | + $indices_without_subparts[] = "{$index_type} {$index_name} (" . implode(',', $index_columns_without_subparts) . ')'; |
|
2931 | 2931 | |
2932 | 2932 | // Destroy no longer needed variables. |
2933 | - unset( $index_column, $index_column_matches, $index_matches, $index_type, $index_name, $index_columns, $index_columns_without_subparts ); |
|
2933 | + unset($index_column, $index_column_matches, $index_matches, $index_type, $index_name, $index_columns, $index_columns_without_subparts); |
|
2934 | 2934 | |
2935 | 2935 | break; |
2936 | 2936 | } |
2937 | 2937 | |
2938 | 2938 | // If it's a valid field, add it to the field array. |
2939 | - if ( $validfield ) { |
|
2940 | - $cfields[ $fieldname_lowercased ] = $fld; |
|
2939 | + if ($validfield) { |
|
2940 | + $cfields[$fieldname_lowercased] = $fld; |
|
2941 | 2941 | } |
2942 | 2942 | } |
2943 | 2943 | |
2944 | 2944 | // For every field in the table. |
2945 | - foreach ( $tablefields as $tablefield ) { |
|
2946 | - $tablefield_field_lowercased = strtolower( $tablefield->Field ); |
|
2947 | - $tablefield_type_lowercased = strtolower( $tablefield->Type ); |
|
2945 | + foreach ($tablefields as $tablefield) { |
|
2946 | + $tablefield_field_lowercased = strtolower($tablefield->Field); |
|
2947 | + $tablefield_type_lowercased = strtolower($tablefield->Type); |
|
2948 | 2948 | |
2949 | 2949 | // If the table field exists in the field array... |
2950 | - if ( array_key_exists( $tablefield_field_lowercased, $cfields ) ) { |
|
2950 | + if (array_key_exists($tablefield_field_lowercased, $cfields)) { |
|
2951 | 2951 | |
2952 | 2952 | // Get the field type from the query. |
2953 | - preg_match( '|`?' . $tablefield->Field . '`? ([^ ]*( unsigned)?)|i', $cfields[ $tablefield_field_lowercased ], $matches ); |
|
2953 | + preg_match('|`?' . $tablefield->Field . '`? ([^ ]*( unsigned)?)|i', $cfields[$tablefield_field_lowercased], $matches); |
|
2954 | 2954 | $fieldtype = $matches[1]; |
2955 | - $fieldtype_lowercased = strtolower( $fieldtype ); |
|
2955 | + $fieldtype_lowercased = strtolower($fieldtype); |
|
2956 | 2956 | |
2957 | 2957 | // Is actual field type different from the field type in query? |
2958 | - if ( $tablefield->Type != $fieldtype ) { |
|
2958 | + if ($tablefield->Type != $fieldtype) { |
|
2959 | 2959 | $do_change = true; |
2960 | - if ( in_array( $fieldtype_lowercased, $text_fields, true ) && in_array( $tablefield_type_lowercased, $text_fields, true ) ) { |
|
2961 | - if ( array_search( $fieldtype_lowercased, $text_fields, true ) < array_search( $tablefield_type_lowercased, $text_fields, true ) ) { |
|
2960 | + if (in_array($fieldtype_lowercased, $text_fields, true) && in_array($tablefield_type_lowercased, $text_fields, true)) { |
|
2961 | + if (array_search($fieldtype_lowercased, $text_fields, true) < array_search($tablefield_type_lowercased, $text_fields, true)) { |
|
2962 | 2962 | $do_change = false; |
2963 | 2963 | } |
2964 | 2964 | } |
2965 | 2965 | |
2966 | - if ( in_array( $fieldtype_lowercased, $blob_fields, true ) && in_array( $tablefield_type_lowercased, $blob_fields, true ) ) { |
|
2967 | - if ( array_search( $fieldtype_lowercased, $blob_fields, true ) < array_search( $tablefield_type_lowercased, $blob_fields, true ) ) { |
|
2966 | + if (in_array($fieldtype_lowercased, $blob_fields, true) && in_array($tablefield_type_lowercased, $blob_fields, true)) { |
|
2967 | + if (array_search($fieldtype_lowercased, $blob_fields, true) < array_search($tablefield_type_lowercased, $blob_fields, true)) { |
|
2968 | 2968 | $do_change = false; |
2969 | 2969 | } |
2970 | 2970 | } |
2971 | 2971 | |
2972 | - if ( $do_change ) { |
|
2972 | + if ($do_change) { |
|
2973 | 2973 | // Add a query to change the column type. |
2974 | - $cqueries[] = "ALTER TABLE {$table} CHANGE COLUMN `{$tablefield->Field}` " . $cfields[ $tablefield_field_lowercased ]; |
|
2974 | + $cqueries[] = "ALTER TABLE {$table} CHANGE COLUMN `{$tablefield->Field}` " . $cfields[$tablefield_field_lowercased]; |
|
2975 | 2975 | |
2976 | - $for_update[ $table . '.' . $tablefield->Field ] = "Changed type of {$table}.{$tablefield->Field} from {$tablefield->Type} to {$fieldtype}"; |
|
2976 | + $for_update[$table . '.' . $tablefield->Field] = "Changed type of {$table}.{$tablefield->Field} from {$tablefield->Type} to {$fieldtype}"; |
|
2977 | 2977 | } |
2978 | 2978 | } |
2979 | 2979 | |
2980 | 2980 | // Get the default value from the array. |
2981 | - if ( preg_match( "| DEFAULT '(.*?)'|i", $cfields[ $tablefield_field_lowercased ], $matches ) ) { |
|
2981 | + if (preg_match("| DEFAULT '(.*?)'|i", $cfields[$tablefield_field_lowercased], $matches)) { |
|
2982 | 2982 | $default_value = $matches[1]; |
2983 | - if ( $tablefield->Default != $default_value ) { |
|
2983 | + if ($tablefield->Default != $default_value) { |
|
2984 | 2984 | // Add a query to change the column's default value |
2985 | 2985 | $cqueries[] = "ALTER TABLE {$table} ALTER COLUMN `{$tablefield->Field}` SET DEFAULT '{$default_value}'"; |
2986 | 2986 | |
2987 | - $for_update[ $table . '.' . $tablefield->Field ] = "Changed default value of {$table}.{$tablefield->Field} from {$tablefield->Default} to {$default_value}"; |
|
2987 | + $for_update[$table . '.' . $tablefield->Field] = "Changed default value of {$table}.{$tablefield->Field} from {$tablefield->Default} to {$default_value}"; |
|
2988 | 2988 | } |
2989 | 2989 | } |
2990 | 2990 | |
2991 | 2991 | // Remove the field from the array (so it's not added). |
2992 | - unset( $cfields[ $tablefield_field_lowercased ] ); |
|
2992 | + unset($cfields[$tablefield_field_lowercased]); |
|
2993 | 2993 | } else { |
2994 | 2994 | // This field exists in the table, but not in the creation queries? |
2995 | 2995 | } |
2996 | 2996 | } |
2997 | 2997 | |
2998 | 2998 | // For every remaining field specified for the table. |
2999 | - foreach ( $cfields as $fieldname => $fielddef ) { |
|
2999 | + foreach ($cfields as $fieldname => $fielddef) { |
|
3000 | 3000 | // Push a query line into $cqueries that adds the field to that table. |
3001 | 3001 | $cqueries[] = "ALTER TABLE {$table} ADD COLUMN $fielddef"; |
3002 | 3002 | |
3003 | - $for_update[ $table . '.' . $fieldname ] = 'Added column ' . $table . '.' . $fieldname; |
|
3003 | + $for_update[$table . '.' . $fieldname] = 'Added column ' . $table . '.' . $fieldname; |
|
3004 | 3004 | } |
3005 | 3005 | |
3006 | 3006 | // Index stuff goes here. Fetch the table index structure from the database. |
3007 | - $tableindices = $wpdb->get_results( "SHOW INDEX FROM {$table};" ); |
|
3007 | + $tableindices = $wpdb->get_results("SHOW INDEX FROM {$table};"); |
|
3008 | 3008 | |
3009 | - if ( $tableindices ) { |
|
3009 | + if ($tableindices) { |
|
3010 | 3010 | // Clear the index array. |
3011 | 3011 | $index_ary = array(); |
3012 | 3012 | |
3013 | 3013 | // For every index in the table. |
3014 | - foreach ( $tableindices as $tableindex ) { |
|
3015 | - $keyname = strtolower( $tableindex->Key_name ); |
|
3014 | + foreach ($tableindices as $tableindex) { |
|
3015 | + $keyname = strtolower($tableindex->Key_name); |
|
3016 | 3016 | |
3017 | 3017 | // Add the index to the index data array. |
3018 | - $index_ary[ $keyname ]['columns'][] = array( |
|
3018 | + $index_ary[$keyname]['columns'][] = array( |
|
3019 | 3019 | 'fieldname' => $tableindex->Column_name, |
3020 | 3020 | 'subpart' => $tableindex->Sub_part, |
3021 | 3021 | ); |
3022 | - $index_ary[ $keyname ]['unique'] = ( 0 == $tableindex->Non_unique ) ? true : false; |
|
3023 | - $index_ary[ $keyname ]['index_type'] = $tableindex->Index_type; |
|
3022 | + $index_ary[$keyname]['unique'] = (0 == $tableindex->Non_unique) ? true : false; |
|
3023 | + $index_ary[$keyname]['index_type'] = $tableindex->Index_type; |
|
3024 | 3024 | } |
3025 | 3025 | |
3026 | 3026 | // For each actual index in the index array. |
3027 | - foreach ( $index_ary as $index_name => $index_data ) { |
|
3027 | + foreach ($index_ary as $index_name => $index_data) { |
|
3028 | 3028 | |
3029 | 3029 | // Build a create string to compare to the query. |
3030 | 3030 | $index_string = ''; |
3031 | - if ( 'primary' === $index_name ) { |
|
3031 | + if ('primary' === $index_name) { |
|
3032 | 3032 | $index_string .= 'PRIMARY '; |
3033 | - } elseif ( $index_data['unique'] ) { |
|
3033 | + } elseif ($index_data['unique']) { |
|
3034 | 3034 | $index_string .= 'UNIQUE '; |
3035 | 3035 | } |
3036 | - if ( 'FULLTEXT' === strtoupper( $index_data['index_type'] ) ) { |
|
3036 | + if ('FULLTEXT' === strtoupper($index_data['index_type'])) { |
|
3037 | 3037 | $index_string .= 'FULLTEXT '; |
3038 | 3038 | } |
3039 | - if ( 'SPATIAL' === strtoupper( $index_data['index_type'] ) ) { |
|
3039 | + if ('SPATIAL' === strtoupper($index_data['index_type'])) { |
|
3040 | 3040 | $index_string .= 'SPATIAL '; |
3041 | 3041 | } |
3042 | 3042 | $index_string .= 'KEY '; |
3043 | - if ( 'primary' !== $index_name ) { |
|
3043 | + if ('primary' !== $index_name) { |
|
3044 | 3044 | $index_string .= '`' . $index_name . '`'; |
3045 | 3045 | } |
3046 | 3046 | $index_columns = ''; |
3047 | 3047 | |
3048 | 3048 | // For each column in the index. |
3049 | - foreach ( $index_data['columns'] as $column_data ) { |
|
3050 | - if ( '' !== $index_columns ) { |
|
3049 | + foreach ($index_data['columns'] as $column_data) { |
|
3050 | + if ('' !== $index_columns) { |
|
3051 | 3051 | $index_columns .= ','; |
3052 | 3052 | } |
3053 | 3053 | |
@@ -3059,17 +3059,17 @@ discard block |
||
3059 | 3059 | $index_string .= " ($index_columns)"; |
3060 | 3060 | |
3061 | 3061 | // Check if the index definition exists, ignoring subparts. |
3062 | - $aindex = array_search( $index_string, $indices_without_subparts, true ); |
|
3063 | - if ( false !== $aindex ) { |
|
3062 | + $aindex = array_search($index_string, $indices_without_subparts, true); |
|
3063 | + if (false !== $aindex) { |
|
3064 | 3064 | // If the index already exists (even with different subparts), we don't need to create it. |
3065 | - unset( $indices_without_subparts[ $aindex ] ); |
|
3066 | - unset( $indices[ $aindex ] ); |
|
3065 | + unset($indices_without_subparts[$aindex]); |
|
3066 | + unset($indices[$aindex]); |
|
3067 | 3067 | } |
3068 | 3068 | } |
3069 | 3069 | } |
3070 | 3070 | |
3071 | 3071 | // For every remaining index specified for the table. |
3072 | - foreach ( (array) $indices as $index ) { |
|
3072 | + foreach ((array) $indices as $index) { |
|
3073 | 3073 | // Push a query line into $cqueries that adds the index to that table. |
3074 | 3074 | $cqueries[] = "ALTER TABLE {$table} ADD $index"; |
3075 | 3075 | |
@@ -3077,13 +3077,13 @@ discard block |
||
3077 | 3077 | } |
3078 | 3078 | |
3079 | 3079 | // Remove the original table creation query from processing. |
3080 | - unset( $cqueries[ $table ], $for_update[ $table ] ); |
|
3080 | + unset($cqueries[$table], $for_update[$table]); |
|
3081 | 3081 | } |
3082 | 3082 | |
3083 | - $allqueries = array_merge( $cqueries, $iqueries ); |
|
3084 | - if ( $execute ) { |
|
3085 | - foreach ( $allqueries as $query ) { |
|
3086 | - $wpdb->query( $query ); |
|
3083 | + $allqueries = array_merge($cqueries, $iqueries); |
|
3084 | + if ($execute) { |
|
3085 | + foreach ($allqueries as $query) { |
|
3086 | + $wpdb->query($query); |
|
3087 | 3087 | } |
3088 | 3088 | } |
3089 | 3089 | |
@@ -3102,10 +3102,10 @@ discard block |
||
3102 | 3102 | * |
3103 | 3103 | * @param string $tables Optional. Which set of tables to update. Default is 'all'. |
3104 | 3104 | */ |
3105 | -function make_db_current( $tables = 'all' ) { |
|
3106 | - $alterations = dbDelta( $tables ); |
|
3105 | +function make_db_current($tables = 'all') { |
|
3106 | + $alterations = dbDelta($tables); |
|
3107 | 3107 | echo "<ol>\n"; |
3108 | - foreach ( $alterations as $alteration ) { |
|
3108 | + foreach ($alterations as $alteration) { |
|
3109 | 3109 | echo "<li>$alteration</li>\n"; |
3110 | 3110 | } |
3111 | 3111 | echo "</ol>\n"; |
@@ -3123,8 +3123,8 @@ discard block |
||
3123 | 3123 | * |
3124 | 3124 | * @param string $tables Optional. Which set of tables to update. Default is 'all'. |
3125 | 3125 | */ |
3126 | -function make_db_current_silent( $tables = 'all' ) { |
|
3127 | - dbDelta( $tables ); |
|
3126 | +function make_db_current_silent($tables = 'all') { |
|
3127 | + dbDelta($tables); |
|
3128 | 3128 | } |
3129 | 3129 | |
3130 | 3130 | /** |
@@ -3138,11 +3138,11 @@ discard block |
||
3138 | 3138 | * @param string $template The directory name of the theme. |
3139 | 3139 | * @return bool |
3140 | 3140 | */ |
3141 | -function make_site_theme_from_oldschool( $theme_name, $template ) { |
|
3141 | +function make_site_theme_from_oldschool($theme_name, $template) { |
|
3142 | 3142 | $home_path = get_home_path(); |
3143 | 3143 | $site_dir = WP_CONTENT_DIR . "/themes/$template"; |
3144 | 3144 | |
3145 | - if ( ! file_exists( "$home_path/index.php" ) ) { |
|
3145 | + if (!file_exists("$home_path/index.php")) { |
|
3146 | 3146 | return false; |
3147 | 3147 | } |
3148 | 3148 | |
@@ -3157,18 +3157,18 @@ discard block |
||
3157 | 3157 | 'wp-comments-popup.php' => 'comments-popup.php', |
3158 | 3158 | ); |
3159 | 3159 | |
3160 | - foreach ( $files as $oldfile => $newfile ) { |
|
3161 | - if ( 'index.php' === $oldfile ) { |
|
3160 | + foreach ($files as $oldfile => $newfile) { |
|
3161 | + if ('index.php' === $oldfile) { |
|
3162 | 3162 | $oldpath = $home_path; |
3163 | 3163 | } else { |
3164 | 3164 | $oldpath = ABSPATH; |
3165 | 3165 | } |
3166 | 3166 | |
3167 | 3167 | // Check to make sure it's not a new index. |
3168 | - if ( 'index.php' === $oldfile ) { |
|
3169 | - $index = implode( '', file( "$oldpath/$oldfile" ) ); |
|
3170 | - if ( strpos( $index, 'WP_USE_THEMES' ) !== false ) { |
|
3171 | - if ( ! copy( WP_CONTENT_DIR . '/themes/' . WP_DEFAULT_THEME . '/index.php', "$site_dir/$newfile" ) ) { |
|
3168 | + if ('index.php' === $oldfile) { |
|
3169 | + $index = implode('', file("$oldpath/$oldfile")); |
|
3170 | + if (strpos($index, 'WP_USE_THEMES') !== false) { |
|
3171 | + if (!copy(WP_CONTENT_DIR . '/themes/' . WP_DEFAULT_THEME . '/index.php', "$site_dir/$newfile")) { |
|
3172 | 3172 | return false; |
3173 | 3173 | } |
3174 | 3174 | |
@@ -3177,44 +3177,44 @@ discard block |
||
3177 | 3177 | } |
3178 | 3178 | } |
3179 | 3179 | |
3180 | - if ( ! copy( "$oldpath/$oldfile", "$site_dir/$newfile" ) ) { |
|
3180 | + if (!copy("$oldpath/$oldfile", "$site_dir/$newfile")) { |
|
3181 | 3181 | return false; |
3182 | 3182 | } |
3183 | 3183 | |
3184 | - chmod( "$site_dir/$newfile", 0777 ); |
|
3184 | + chmod("$site_dir/$newfile", 0777); |
|
3185 | 3185 | |
3186 | 3186 | // Update the blog header include in each file. |
3187 | - $lines = explode( "\n", implode( '', file( "$site_dir/$newfile" ) ) ); |
|
3188 | - if ( $lines ) { |
|
3189 | - $f = fopen( "$site_dir/$newfile", 'w' ); |
|
3187 | + $lines = explode("\n", implode('', file("$site_dir/$newfile"))); |
|
3188 | + if ($lines) { |
|
3189 | + $f = fopen("$site_dir/$newfile", 'w'); |
|
3190 | 3190 | |
3191 | - foreach ( $lines as $line ) { |
|
3192 | - if ( preg_match( '/require.*wp-blog-header/', $line ) ) { |
|
3191 | + foreach ($lines as $line) { |
|
3192 | + if (preg_match('/require.*wp-blog-header/', $line)) { |
|
3193 | 3193 | $line = '//' . $line; |
3194 | 3194 | } |
3195 | 3195 | |
3196 | 3196 | // Update stylesheet references. |
3197 | - $line = str_replace( "<?php echo __get_option('siteurl'); ?>/wp-layout.css", "<?php bloginfo('stylesheet_url'); ?>", $line ); |
|
3197 | + $line = str_replace("<?php echo __get_option('siteurl'); ?>/wp-layout.css", "<?php bloginfo('stylesheet_url'); ?>", $line); |
|
3198 | 3198 | |
3199 | 3199 | // Update comments template inclusion. |
3200 | - $line = str_replace( "<?php include(ABSPATH . 'wp-comments.php'); ?>", '<?php comments_template(); ?>', $line ); |
|
3200 | + $line = str_replace("<?php include(ABSPATH . 'wp-comments.php'); ?>", '<?php comments_template(); ?>', $line); |
|
3201 | 3201 | |
3202 | - fwrite( $f, "{$line}\n" ); |
|
3202 | + fwrite($f, "{$line}\n"); |
|
3203 | 3203 | } |
3204 | - fclose( $f ); |
|
3204 | + fclose($f); |
|
3205 | 3205 | } |
3206 | 3206 | } |
3207 | 3207 | |
3208 | 3208 | // Add a theme header. |
3209 | - $header = "/*\nTheme Name: $theme_name\nTheme URI: " . __get_option( 'siteurl' ) . "\nDescription: A theme automatically created by the update.\nVersion: 1.0\nAuthor: Moi\n*/\n"; |
|
3209 | + $header = "/*\nTheme Name: $theme_name\nTheme URI: " . __get_option('siteurl') . "\nDescription: A theme automatically created by the update.\nVersion: 1.0\nAuthor: Moi\n*/\n"; |
|
3210 | 3210 | |
3211 | - $stylelines = file_get_contents( "$site_dir/style.css" ); |
|
3212 | - if ( $stylelines ) { |
|
3213 | - $f = fopen( "$site_dir/style.css", 'w' ); |
|
3211 | + $stylelines = file_get_contents("$site_dir/style.css"); |
|
3212 | + if ($stylelines) { |
|
3213 | + $f = fopen("$site_dir/style.css", 'w'); |
|
3214 | 3214 | |
3215 | - fwrite( $f, $header ); |
|
3216 | - fwrite( $f, $stylelines ); |
|
3217 | - fclose( $f ); |
|
3215 | + fwrite($f, $header); |
|
3216 | + fwrite($f, $stylelines); |
|
3217 | + fclose($f); |
|
3218 | 3218 | } |
3219 | 3219 | |
3220 | 3220 | return true; |
@@ -3231,69 +3231,69 @@ discard block |
||
3231 | 3231 | * @param string $template The directory name of the theme. |
3232 | 3232 | * @return void|false |
3233 | 3233 | */ |
3234 | -function make_site_theme_from_default( $theme_name, $template ) { |
|
3234 | +function make_site_theme_from_default($theme_name, $template) { |
|
3235 | 3235 | $site_dir = WP_CONTENT_DIR . "/themes/$template"; |
3236 | 3236 | $default_dir = WP_CONTENT_DIR . '/themes/' . WP_DEFAULT_THEME; |
3237 | 3237 | |
3238 | 3238 | // Copy files from the default theme to the site theme. |
3239 | 3239 | // $files = array( 'index.php', 'comments.php', 'comments-popup.php', 'footer.php', 'header.php', 'sidebar.php', 'style.css' ); |
3240 | 3240 | |
3241 | - $theme_dir = @opendir( $default_dir ); |
|
3242 | - if ( $theme_dir ) { |
|
3243 | - while ( ( $theme_file = readdir( $theme_dir ) ) !== false ) { |
|
3244 | - if ( is_dir( "$default_dir/$theme_file" ) ) { |
|
3241 | + $theme_dir = @opendir($default_dir); |
|
3242 | + if ($theme_dir) { |
|
3243 | + while (($theme_file = readdir($theme_dir)) !== false) { |
|
3244 | + if (is_dir("$default_dir/$theme_file")) { |
|
3245 | 3245 | continue; |
3246 | 3246 | } |
3247 | - if ( ! copy( "$default_dir/$theme_file", "$site_dir/$theme_file" ) ) { |
|
3247 | + if (!copy("$default_dir/$theme_file", "$site_dir/$theme_file")) { |
|
3248 | 3248 | return; |
3249 | 3249 | } |
3250 | - chmod( "$site_dir/$theme_file", 0777 ); |
|
3250 | + chmod("$site_dir/$theme_file", 0777); |
|
3251 | 3251 | } |
3252 | 3252 | |
3253 | - closedir( $theme_dir ); |
|
3253 | + closedir($theme_dir); |
|
3254 | 3254 | } |
3255 | 3255 | |
3256 | 3256 | // Rewrite the theme header. |
3257 | - $stylelines = explode( "\n", implode( '', file( "$site_dir/style.css" ) ) ); |
|
3258 | - if ( $stylelines ) { |
|
3259 | - $f = fopen( "$site_dir/style.css", 'w' ); |
|
3257 | + $stylelines = explode("\n", implode('', file("$site_dir/style.css"))); |
|
3258 | + if ($stylelines) { |
|
3259 | + $f = fopen("$site_dir/style.css", 'w'); |
|
3260 | 3260 | |
3261 | - foreach ( $stylelines as $line ) { |
|
3262 | - if ( strpos( $line, 'Theme Name:' ) !== false ) { |
|
3261 | + foreach ($stylelines as $line) { |
|
3262 | + if (strpos($line, 'Theme Name:') !== false) { |
|
3263 | 3263 | $line = 'Theme Name: ' . $theme_name; |
3264 | - } elseif ( strpos( $line, 'Theme URI:' ) !== false ) { |
|
3265 | - $line = 'Theme URI: ' . __get_option( 'url' ); |
|
3266 | - } elseif ( strpos( $line, 'Description:' ) !== false ) { |
|
3264 | + } elseif (strpos($line, 'Theme URI:') !== false) { |
|
3265 | + $line = 'Theme URI: ' . __get_option('url'); |
|
3266 | + } elseif (strpos($line, 'Description:') !== false) { |
|
3267 | 3267 | $line = 'Description: Your theme.'; |
3268 | - } elseif ( strpos( $line, 'Version:' ) !== false ) { |
|
3268 | + } elseif (strpos($line, 'Version:') !== false) { |
|
3269 | 3269 | $line = 'Version: 1'; |
3270 | - } elseif ( strpos( $line, 'Author:' ) !== false ) { |
|
3270 | + } elseif (strpos($line, 'Author:') !== false) { |
|
3271 | 3271 | $line = 'Author: You'; |
3272 | 3272 | } |
3273 | - fwrite( $f, $line . "\n" ); |
|
3273 | + fwrite($f, $line . "\n"); |
|
3274 | 3274 | } |
3275 | - fclose( $f ); |
|
3275 | + fclose($f); |
|
3276 | 3276 | } |
3277 | 3277 | |
3278 | 3278 | // Copy the images. |
3279 | - umask( 0 ); |
|
3280 | - if ( ! mkdir( "$site_dir/images", 0777 ) ) { |
|
3279 | + umask(0); |
|
3280 | + if (!mkdir("$site_dir/images", 0777)) { |
|
3281 | 3281 | return false; |
3282 | 3282 | } |
3283 | 3283 | |
3284 | - $images_dir = @opendir( "$default_dir/images" ); |
|
3285 | - if ( $images_dir ) { |
|
3286 | - while ( ( $image = readdir( $images_dir ) ) !== false ) { |
|
3287 | - if ( is_dir( "$default_dir/images/$image" ) ) { |
|
3284 | + $images_dir = @opendir("$default_dir/images"); |
|
3285 | + if ($images_dir) { |
|
3286 | + while (($image = readdir($images_dir)) !== false) { |
|
3287 | + if (is_dir("$default_dir/images/$image")) { |
|
3288 | 3288 | continue; |
3289 | 3289 | } |
3290 | - if ( ! copy( "$default_dir/images/$image", "$site_dir/images/$image" ) ) { |
|
3290 | + if (!copy("$default_dir/images/$image", "$site_dir/images/$image")) { |
|
3291 | 3291 | return; |
3292 | 3292 | } |
3293 | - chmod( "$site_dir/images/$image", 0777 ); |
|
3293 | + chmod("$site_dir/images/$image", 0777); |
|
3294 | 3294 | } |
3295 | 3295 | |
3296 | - closedir( $images_dir ); |
|
3296 | + closedir($images_dir); |
|
3297 | 3297 | } |
3298 | 3298 | } |
3299 | 3299 | |
@@ -3308,42 +3308,42 @@ discard block |
||
3308 | 3308 | */ |
3309 | 3309 | function make_site_theme() { |
3310 | 3310 | // Name the theme after the blog. |
3311 | - $theme_name = __get_option( 'blogname' ); |
|
3312 | - $template = sanitize_title( $theme_name ); |
|
3311 | + $theme_name = __get_option('blogname'); |
|
3312 | + $template = sanitize_title($theme_name); |
|
3313 | 3313 | $site_dir = WP_CONTENT_DIR . "/themes/$template"; |
3314 | 3314 | |
3315 | 3315 | // If the theme already exists, nothing to do. |
3316 | - if ( is_dir( $site_dir ) ) { |
|
3316 | + if (is_dir($site_dir)) { |
|
3317 | 3317 | return false; |
3318 | 3318 | } |
3319 | 3319 | |
3320 | 3320 | // We must be able to write to the themes dir. |
3321 | - if ( ! is_writable( WP_CONTENT_DIR . '/themes' ) ) { |
|
3321 | + if (!is_writable(WP_CONTENT_DIR . '/themes')) { |
|
3322 | 3322 | return false; |
3323 | 3323 | } |
3324 | 3324 | |
3325 | - umask( 0 ); |
|
3326 | - if ( ! mkdir( $site_dir, 0777 ) ) { |
|
3325 | + umask(0); |
|
3326 | + if (!mkdir($site_dir, 0777)) { |
|
3327 | 3327 | return false; |
3328 | 3328 | } |
3329 | 3329 | |
3330 | - if ( file_exists( ABSPATH . 'wp-layout.css' ) ) { |
|
3331 | - if ( ! make_site_theme_from_oldschool( $theme_name, $template ) ) { |
|
3330 | + if (file_exists(ABSPATH . 'wp-layout.css')) { |
|
3331 | + if (!make_site_theme_from_oldschool($theme_name, $template)) { |
|
3332 | 3332 | // TODO: rm -rf the site theme directory. |
3333 | 3333 | return false; |
3334 | 3334 | } |
3335 | 3335 | } else { |
3336 | - if ( ! make_site_theme_from_default( $theme_name, $template ) ) { |
|
3336 | + if (!make_site_theme_from_default($theme_name, $template)) { |
|
3337 | 3337 | // TODO: rm -rf the site theme directory. |
3338 | 3338 | return false; |
3339 | 3339 | } |
3340 | 3340 | } |
3341 | 3341 | |
3342 | 3342 | // Make the new site theme active. |
3343 | - $current_template = __get_option( 'template' ); |
|
3344 | - if ( WP_DEFAULT_THEME == $current_template ) { |
|
3345 | - update_option( 'template', $template ); |
|
3346 | - update_option( 'stylesheet', $template ); |
|
3343 | + $current_template = __get_option('template'); |
|
3344 | + if (WP_DEFAULT_THEME == $current_template) { |
|
3345 | + update_option('template', $template); |
|
3346 | + update_option('stylesheet', $template); |
|
3347 | 3347 | } |
3348 | 3348 | return $template; |
3349 | 3349 | } |
@@ -3356,8 +3356,8 @@ discard block |
||
3356 | 3356 | * @param int $level User level. |
3357 | 3357 | * @return string User role name. |
3358 | 3358 | */ |
3359 | -function translate_level_to_role( $level ) { |
|
3360 | - switch ( $level ) { |
|
3359 | +function translate_level_to_role($level) { |
|
3360 | + switch ($level) { |
|
3361 | 3361 | case 10: |
3362 | 3362 | case 9: |
3363 | 3363 | case 8: |
@@ -3388,8 +3388,8 @@ discard block |
||
3388 | 3388 | function wp_check_mysql_version() { |
3389 | 3389 | global $wpdb; |
3390 | 3390 | $result = $wpdb->check_database_version(); |
3391 | - if ( is_wp_error( $result ) ) { |
|
3392 | - wp_die( $result ); |
|
3391 | + if (is_wp_error($result)) { |
|
3392 | + wp_die($result); |
|
3393 | 3393 | } |
3394 | 3394 | } |
3395 | 3395 | |
@@ -3399,12 +3399,12 @@ discard block |
||
3399 | 3399 | * @since 2.2.0 |
3400 | 3400 | */ |
3401 | 3401 | function maybe_disable_automattic_widgets() { |
3402 | - $plugins = __get_option( 'active_plugins' ); |
|
3402 | + $plugins = __get_option('active_plugins'); |
|
3403 | 3403 | |
3404 | - foreach ( (array) $plugins as $plugin ) { |
|
3405 | - if ( 'widgets.php' === basename( $plugin ) ) { |
|
3406 | - array_splice( $plugins, array_search( $plugin, $plugins, true ), 1 ); |
|
3407 | - update_option( 'active_plugins', $plugins ); |
|
3404 | + foreach ((array) $plugins as $plugin) { |
|
3405 | + if ('widgets.php' === basename($plugin)) { |
|
3406 | + array_splice($plugins, array_search($plugin, $plugins, true), 1); |
|
3407 | + update_option('active_plugins', $plugins); |
|
3408 | 3408 | break; |
3409 | 3409 | } |
3410 | 3410 | } |
@@ -3421,8 +3421,8 @@ discard block |
||
3421 | 3421 | function maybe_disable_link_manager() { |
3422 | 3422 | global $wp_current_db_version, $wpdb; |
3423 | 3423 | |
3424 | - if ( $wp_current_db_version >= 22006 && get_option( 'link_manager_enabled' ) && ! $wpdb->get_var( "SELECT link_id FROM $wpdb->links LIMIT 1" ) ) { |
|
3425 | - update_option( 'link_manager_enabled', 0 ); |
|
3424 | + if ($wp_current_db_version >= 22006 && get_option('link_manager_enabled') && !$wpdb->get_var("SELECT link_id FROM $wpdb->links LIMIT 1")) { |
|
3425 | + update_option('link_manager_enabled', 0); |
|
3426 | 3426 | } |
3427 | 3427 | } |
3428 | 3428 | |
@@ -3438,57 +3438,57 @@ discard block |
||
3438 | 3438 | global $wp_current_db_version, $wpdb; |
3439 | 3439 | |
3440 | 3440 | // Upgrade versions prior to 2.9. |
3441 | - if ( $wp_current_db_version < 11557 ) { |
|
3441 | + if ($wp_current_db_version < 11557) { |
|
3442 | 3442 | // Delete duplicate options. Keep the option with the highest option_id. |
3443 | - $wpdb->query( "DELETE o1 FROM $wpdb->options AS o1 JOIN $wpdb->options AS o2 USING (`option_name`) WHERE o2.option_id > o1.option_id" ); |
|
3443 | + $wpdb->query("DELETE o1 FROM $wpdb->options AS o1 JOIN $wpdb->options AS o2 USING (`option_name`) WHERE o2.option_id > o1.option_id"); |
|
3444 | 3444 | |
3445 | 3445 | // Drop the old primary key and add the new. |
3446 | - $wpdb->query( "ALTER TABLE $wpdb->options DROP PRIMARY KEY, ADD PRIMARY KEY(option_id)" ); |
|
3446 | + $wpdb->query("ALTER TABLE $wpdb->options DROP PRIMARY KEY, ADD PRIMARY KEY(option_id)"); |
|
3447 | 3447 | |
3448 | 3448 | // Drop the old option_name index. dbDelta() doesn't do the drop. |
3449 | - $wpdb->query( "ALTER TABLE $wpdb->options DROP INDEX option_name" ); |
|
3449 | + $wpdb->query("ALTER TABLE $wpdb->options DROP INDEX option_name"); |
|
3450 | 3450 | } |
3451 | 3451 | |
3452 | 3452 | // Multisite schema upgrades. |
3453 | - if ( $wp_current_db_version < 25448 && is_multisite() && wp_should_upgrade_global_tables() ) { |
|
3453 | + if ($wp_current_db_version < 25448 && is_multisite() && wp_should_upgrade_global_tables()) { |
|
3454 | 3454 | |
3455 | 3455 | // Upgrade versions prior to 3.7. |
3456 | - if ( $wp_current_db_version < 25179 ) { |
|
3456 | + if ($wp_current_db_version < 25179) { |
|
3457 | 3457 | // New primary key for signups. |
3458 | - $wpdb->query( "ALTER TABLE $wpdb->signups ADD signup_id BIGINT(20) NOT NULL AUTO_INCREMENT PRIMARY KEY FIRST" ); |
|
3459 | - $wpdb->query( "ALTER TABLE $wpdb->signups DROP INDEX domain" ); |
|
3458 | + $wpdb->query("ALTER TABLE $wpdb->signups ADD signup_id BIGINT(20) NOT NULL AUTO_INCREMENT PRIMARY KEY FIRST"); |
|
3459 | + $wpdb->query("ALTER TABLE $wpdb->signups DROP INDEX domain"); |
|
3460 | 3460 | } |
3461 | 3461 | |
3462 | - if ( $wp_current_db_version < 25448 ) { |
|
3462 | + if ($wp_current_db_version < 25448) { |
|
3463 | 3463 | // Convert archived from enum to tinyint. |
3464 | - $wpdb->query( "ALTER TABLE $wpdb->blogs CHANGE COLUMN archived archived varchar(1) NOT NULL default '0'" ); |
|
3465 | - $wpdb->query( "ALTER TABLE $wpdb->blogs CHANGE COLUMN archived archived tinyint(2) NOT NULL default 0" ); |
|
3464 | + $wpdb->query("ALTER TABLE $wpdb->blogs CHANGE COLUMN archived archived varchar(1) NOT NULL default '0'"); |
|
3465 | + $wpdb->query("ALTER TABLE $wpdb->blogs CHANGE COLUMN archived archived tinyint(2) NOT NULL default 0"); |
|
3466 | 3466 | } |
3467 | 3467 | } |
3468 | 3468 | |
3469 | 3469 | // Upgrade versions prior to 4.2. |
3470 | - if ( $wp_current_db_version < 31351 ) { |
|
3471 | - if ( ! is_multisite() && wp_should_upgrade_global_tables() ) { |
|
3472 | - $wpdb->query( "ALTER TABLE $wpdb->usermeta DROP INDEX meta_key, ADD INDEX meta_key(meta_key(191))" ); |
|
3470 | + if ($wp_current_db_version < 31351) { |
|
3471 | + if (!is_multisite() && wp_should_upgrade_global_tables()) { |
|
3472 | + $wpdb->query("ALTER TABLE $wpdb->usermeta DROP INDEX meta_key, ADD INDEX meta_key(meta_key(191))"); |
|
3473 | 3473 | } |
3474 | - $wpdb->query( "ALTER TABLE $wpdb->terms DROP INDEX slug, ADD INDEX slug(slug(191))" ); |
|
3475 | - $wpdb->query( "ALTER TABLE $wpdb->terms DROP INDEX name, ADD INDEX name(name(191))" ); |
|
3476 | - $wpdb->query( "ALTER TABLE $wpdb->commentmeta DROP INDEX meta_key, ADD INDEX meta_key(meta_key(191))" ); |
|
3477 | - $wpdb->query( "ALTER TABLE $wpdb->postmeta DROP INDEX meta_key, ADD INDEX meta_key(meta_key(191))" ); |
|
3478 | - $wpdb->query( "ALTER TABLE $wpdb->posts DROP INDEX post_name, ADD INDEX post_name(post_name(191))" ); |
|
3474 | + $wpdb->query("ALTER TABLE $wpdb->terms DROP INDEX slug, ADD INDEX slug(slug(191))"); |
|
3475 | + $wpdb->query("ALTER TABLE $wpdb->terms DROP INDEX name, ADD INDEX name(name(191))"); |
|
3476 | + $wpdb->query("ALTER TABLE $wpdb->commentmeta DROP INDEX meta_key, ADD INDEX meta_key(meta_key(191))"); |
|
3477 | + $wpdb->query("ALTER TABLE $wpdb->postmeta DROP INDEX meta_key, ADD INDEX meta_key(meta_key(191))"); |
|
3478 | + $wpdb->query("ALTER TABLE $wpdb->posts DROP INDEX post_name, ADD INDEX post_name(post_name(191))"); |
|
3479 | 3479 | } |
3480 | 3480 | |
3481 | 3481 | // Upgrade versions prior to 4.4. |
3482 | - if ( $wp_current_db_version < 34978 ) { |
|
3482 | + if ($wp_current_db_version < 34978) { |
|
3483 | 3483 | // If compatible termmeta table is found, use it, but enforce a proper index and update collation. |
3484 | - if ( $wpdb->get_var( "SHOW TABLES LIKE '{$wpdb->termmeta}'" ) && $wpdb->get_results( "SHOW INDEX FROM {$wpdb->termmeta} WHERE Column_name = 'meta_key'" ) ) { |
|
3485 | - $wpdb->query( "ALTER TABLE $wpdb->termmeta DROP INDEX meta_key, ADD INDEX meta_key(meta_key(191))" ); |
|
3486 | - maybe_convert_table_to_utf8mb4( $wpdb->termmeta ); |
|
3484 | + if ($wpdb->get_var("SHOW TABLES LIKE '{$wpdb->termmeta}'") && $wpdb->get_results("SHOW INDEX FROM {$wpdb->termmeta} WHERE Column_name = 'meta_key'")) { |
|
3485 | + $wpdb->query("ALTER TABLE $wpdb->termmeta DROP INDEX meta_key, ADD INDEX meta_key(meta_key(191))"); |
|
3486 | + maybe_convert_table_to_utf8mb4($wpdb->termmeta); |
|
3487 | 3487 | } |
3488 | 3488 | } |
3489 | 3489 | } |
3490 | 3490 | |
3491 | -if ( ! function_exists( 'install_global_terms' ) ) : |
|
3491 | +if (!function_exists('install_global_terms')) : |
|
3492 | 3492 | /** |
3493 | 3493 | * Install global terms. |
3494 | 3494 | * |
@@ -3511,7 +3511,7 @@ discard block |
||
3511 | 3511 | ) $charset_collate; |
3512 | 3512 | "; |
3513 | 3513 | // Now create tables. |
3514 | - dbDelta( $ms_queries ); |
|
3514 | + dbDelta($ms_queries); |
|
3515 | 3515 | } |
3516 | 3516 | endif; |
3517 | 3517 | |
@@ -3536,7 +3536,7 @@ discard block |
||
3536 | 3536 | function wp_should_upgrade_global_tables() { |
3537 | 3537 | |
3538 | 3538 | // Return false early if explicitly not upgrading. |
3539 | - if ( defined( 'DO_NOT_UPGRADE_GLOBAL_TABLES' ) ) { |
|
3539 | + if (defined('DO_NOT_UPGRADE_GLOBAL_TABLES')) { |
|
3540 | 3540 | return false; |
3541 | 3541 | } |
3542 | 3542 | |
@@ -3544,12 +3544,12 @@ discard block |
||
3544 | 3544 | $should_upgrade = true; |
3545 | 3545 | |
3546 | 3546 | // Set to false if not on main network (does not matter if not multi-network). |
3547 | - if ( ! is_main_network() ) { |
|
3547 | + if (!is_main_network()) { |
|
3548 | 3548 | $should_upgrade = false; |
3549 | 3549 | } |
3550 | 3550 | |
3551 | 3551 | // Set to false if not on main site of current network (does not matter if not multi-site). |
3552 | - if ( ! is_main_site() ) { |
|
3552 | + if (!is_main_site()) { |
|
3553 | 3553 | $should_upgrade = false; |
3554 | 3554 | } |
3555 | 3555 | |
@@ -3560,5 +3560,5 @@ discard block |
||
3560 | 3560 | * |
3561 | 3561 | * @param bool $should_upgrade Whether to run the upgrade routines on global tables. |
3562 | 3562 | */ |
3563 | - return apply_filters( 'wp_should_upgrade_global_tables', $should_upgrade ); |
|
3563 | + return apply_filters('wp_should_upgrade_global_tables', $should_upgrade); |
|
3564 | 3564 | } |