@@ -16,7 +16,7 @@ discard block |
||
16 | 16 | */ |
17 | 17 | |
18 | 18 | /** WordPress Administration Bootstrap */ |
19 | -require_once( dirname( __FILE__ ) . '/admin.php' ); |
|
19 | +require_once(dirname(__FILE__).'/admin.php'); |
|
20 | 20 | |
21 | 21 | $title = __('Settings'); |
22 | 22 | $this_file = 'options.php'; |
@@ -27,7 +27,7 @@ discard block |
||
27 | 27 | $capability = 'manage_options'; |
28 | 28 | |
29 | 29 | // This is for back compat and will eventually be removed. |
30 | -if ( empty($option_page) ) { |
|
30 | +if (empty($option_page)) { |
|
31 | 31 | $option_page = 'options'; |
32 | 32 | } else { |
33 | 33 | |
@@ -41,69 +41,69 @@ discard block |
||
41 | 41 | * |
42 | 42 | * @param string $capability The capability used for the page, which is manage_options by default. |
43 | 43 | */ |
44 | - $capability = apply_filters( "option_page_capability_{$option_page}", $capability ); |
|
44 | + $capability = apply_filters("option_page_capability_{$option_page}", $capability); |
|
45 | 45 | } |
46 | 46 | |
47 | -if ( ! current_user_can( $capability ) ) { |
|
47 | +if ( ! current_user_can($capability)) { |
|
48 | 48 | wp_die( |
49 | - '<h1>' . __( 'Cheatin’ uh?' ) . '</h1>' . |
|
50 | - '<p>' . __( 'You are not allowed to manage these items.' ) . '</p>', |
|
49 | + '<h1>'.__('Cheatin’ uh?').'</h1>'. |
|
50 | + '<p>'.__('You are not allowed to manage these items.').'</p>', |
|
51 | 51 | 403 |
52 | 52 | ); |
53 | 53 | } |
54 | 54 | |
55 | 55 | // Handle admin email change requests |
56 | -if ( is_multisite() ) { |
|
57 | - if ( ! empty($_GET[ 'adminhash' ] ) ) { |
|
58 | - $new_admin_details = get_option( 'adminhash' ); |
|
56 | +if (is_multisite()) { |
|
57 | + if ( ! empty($_GET['adminhash'])) { |
|
58 | + $new_admin_details = get_option('adminhash'); |
|
59 | 59 | $redirect = 'options-general.php?updated=false'; |
60 | - if ( is_array( $new_admin_details ) && $new_admin_details[ 'hash' ] == $_GET[ 'adminhash' ] && !empty($new_admin_details[ 'newemail' ]) ) { |
|
61 | - update_option( 'admin_email', $new_admin_details[ 'newemail' ] ); |
|
62 | - delete_option( 'adminhash' ); |
|
63 | - delete_option( 'new_admin_email' ); |
|
60 | + if (is_array($new_admin_details) && $new_admin_details['hash'] == $_GET['adminhash'] && ! empty($new_admin_details['newemail'])) { |
|
61 | + update_option('admin_email', $new_admin_details['newemail']); |
|
62 | + delete_option('adminhash'); |
|
63 | + delete_option('new_admin_email'); |
|
64 | 64 | $redirect = 'options-general.php?updated=true'; |
65 | 65 | } |
66 | - wp_redirect( admin_url( $redirect ) ); |
|
66 | + wp_redirect(admin_url($redirect)); |
|
67 | 67 | exit; |
68 | - } elseif ( ! empty( $_GET['dismiss'] ) && 'new_admin_email' == $_GET['dismiss'] ) { |
|
69 | - delete_option( 'adminhash' ); |
|
70 | - delete_option( 'new_admin_email' ); |
|
71 | - wp_redirect( admin_url( 'options-general.php?updated=true' ) ); |
|
68 | + } elseif ( ! empty($_GET['dismiss']) && 'new_admin_email' == $_GET['dismiss']) { |
|
69 | + delete_option('adminhash'); |
|
70 | + delete_option('new_admin_email'); |
|
71 | + wp_redirect(admin_url('options-general.php?updated=true')); |
|
72 | 72 | exit; |
73 | 73 | } |
74 | 74 | } |
75 | 75 | |
76 | -if ( is_multisite() && ! is_super_admin() && 'update' != $action ) { |
|
76 | +if (is_multisite() && ! is_super_admin() && 'update' != $action) { |
|
77 | 77 | wp_die( |
78 | - '<h1>' . __( 'Cheatin’ uh?' ) . '</h1>' . |
|
79 | - '<p>' . __( 'You are not allowed to delete these items.' ) . '</p>', |
|
78 | + '<h1>'.__('Cheatin’ uh?').'</h1>'. |
|
79 | + '<p>'.__('You are not allowed to delete these items.').'</p>', |
|
80 | 80 | 403 |
81 | 81 | ); |
82 | 82 | } |
83 | 83 | |
84 | 84 | $whitelist_options = array( |
85 | - 'general' => array( 'blogname', 'blogdescription', 'gmt_offset', 'date_format', 'time_format', 'start_of_week', 'timezone_string', 'WPLANG' ), |
|
86 | - 'discussion' => array( 'default_pingback_flag', 'default_ping_status', 'default_comment_status', 'comments_notify', 'moderation_notify', 'comment_moderation', 'require_name_email', 'comment_whitelist', 'comment_max_links', 'moderation_keys', 'blacklist_keys', 'show_avatars', 'avatar_rating', 'avatar_default', 'close_comments_for_old_posts', 'close_comments_days_old', 'thread_comments', 'thread_comments_depth', 'page_comments', 'comments_per_page', 'default_comments_page', 'comment_order', 'comment_registration' ), |
|
87 | - 'media' => array( 'thumbnail_size_w', 'thumbnail_size_h', 'thumbnail_crop', 'medium_size_w', 'medium_size_h', 'medium_large_size_w', 'medium_large_size_h', 'large_size_w', 'large_size_h', 'image_default_size', 'image_default_align', 'image_default_link_type' ), |
|
88 | - 'reading' => array( 'posts_per_page', 'posts_per_rss', 'rss_use_excerpt', 'show_on_front', 'page_on_front', 'page_for_posts', 'blog_public' ), |
|
89 | - 'writing' => array( 'default_category', 'default_email_category', 'default_link_category', 'default_post_format' ) |
|
85 | + 'general' => array('blogname', 'blogdescription', 'gmt_offset', 'date_format', 'time_format', 'start_of_week', 'timezone_string', 'WPLANG'), |
|
86 | + 'discussion' => array('default_pingback_flag', 'default_ping_status', 'default_comment_status', 'comments_notify', 'moderation_notify', 'comment_moderation', 'require_name_email', 'comment_whitelist', 'comment_max_links', 'moderation_keys', 'blacklist_keys', 'show_avatars', 'avatar_rating', 'avatar_default', 'close_comments_for_old_posts', 'close_comments_days_old', 'thread_comments', 'thread_comments_depth', 'page_comments', 'comments_per_page', 'default_comments_page', 'comment_order', 'comment_registration'), |
|
87 | + 'media' => array('thumbnail_size_w', 'thumbnail_size_h', 'thumbnail_crop', 'medium_size_w', 'medium_size_h', 'medium_large_size_w', 'medium_large_size_h', 'large_size_w', 'large_size_h', 'image_default_size', 'image_default_align', 'image_default_link_type'), |
|
88 | + 'reading' => array('posts_per_page', 'posts_per_rss', 'rss_use_excerpt', 'show_on_front', 'page_on_front', 'page_for_posts', 'blog_public'), |
|
89 | + 'writing' => array('default_category', 'default_email_category', 'default_link_category', 'default_post_format') |
|
90 | 90 | ); |
91 | 91 | $whitelist_options['misc'] = $whitelist_options['options'] = $whitelist_options['privacy'] = array(); |
92 | 92 | |
93 | 93 | $mail_options = array('mailserver_url', 'mailserver_port', 'mailserver_login', 'mailserver_pass'); |
94 | 94 | |
95 | -if ( ! in_array( get_option( 'blog_charset' ), array( 'utf8', 'utf-8', 'UTF8', 'UTF-8' ) ) ) |
|
95 | +if ( ! in_array(get_option('blog_charset'), array('utf8', 'utf-8', 'UTF8', 'UTF-8'))) |
|
96 | 96 | $whitelist_options['reading'][] = 'blog_charset'; |
97 | 97 | |
98 | -if ( get_site_option( 'initial_db_version' ) < 32453 ) { |
|
98 | +if (get_site_option('initial_db_version') < 32453) { |
|
99 | 99 | $whitelist_options['writing'][] = 'use_smilies'; |
100 | 100 | $whitelist_options['writing'][] = 'use_balanceTags'; |
101 | 101 | } |
102 | 102 | |
103 | -if ( !is_multisite() ) { |
|
104 | - if ( !defined( 'WP_SITEURL' ) ) |
|
103 | +if ( ! is_multisite()) { |
|
104 | + if ( ! defined('WP_SITEURL')) |
|
105 | 105 | $whitelist_options['general'][] = 'siteurl'; |
106 | - if ( !defined( 'WP_HOME' ) ) |
|
106 | + if ( ! defined('WP_HOME')) |
|
107 | 107 | $whitelist_options['general'][] = 'home'; |
108 | 108 | |
109 | 109 | $whitelist_options['general'][] = 'admin_email'; |
@@ -116,7 +116,7 @@ discard block |
||
116 | 116 | $whitelist_options['media'][] = 'uploads_use_yearmonth_folders'; |
117 | 117 | |
118 | 118 | // If upload_url_path and upload_path are both default values, they're locked. |
119 | - if ( get_option( 'upload_url_path' ) || ( get_option('upload_path') != 'wp-content/uploads' && get_option('upload_path') ) ) { |
|
119 | + if (get_option('upload_url_path') || (get_option('upload_path') != 'wp-content/uploads' && get_option('upload_path'))) { |
|
120 | 120 | $whitelist_options['media'][] = 'upload_path'; |
121 | 121 | $whitelist_options['media'][] = 'upload_url_path'; |
122 | 122 | } |
@@ -130,7 +130,7 @@ discard block |
||
130 | 130 | * |
131 | 131 | * @param bool $enabled Whether post-by-email configuration is enabled. Default true. |
132 | 132 | */ |
133 | - if ( apply_filters( 'enable_post_by_email_configuration', true ) ) |
|
133 | + if (apply_filters('enable_post_by_email_configuration', true)) |
|
134 | 134 | $whitelist_options['writing'] = array_merge($whitelist_options['writing'], $mail_options); |
135 | 135 | } |
136 | 136 | |
@@ -141,86 +141,86 @@ discard block |
||
141 | 141 | * |
142 | 142 | * @param array White list options. |
143 | 143 | */ |
144 | -$whitelist_options = apply_filters( 'whitelist_options', $whitelist_options ); |
|
144 | +$whitelist_options = apply_filters('whitelist_options', $whitelist_options); |
|
145 | 145 | |
146 | 146 | /* |
147 | 147 | * If $_GET['action'] == 'update' we are saving settings sent from a settings page |
148 | 148 | */ |
149 | -if ( 'update' == $action ) { |
|
150 | - if ( 'options' == $option_page && !isset( $_POST['option_page'] ) ) { // This is for back compat and will eventually be removed. |
|
149 | +if ('update' == $action) { |
|
150 | + if ('options' == $option_page && ! isset($_POST['option_page'])) { // This is for back compat and will eventually be removed. |
|
151 | 151 | $unregistered = true; |
152 | - check_admin_referer( 'update-options' ); |
|
152 | + check_admin_referer('update-options'); |
|
153 | 153 | } else { |
154 | 154 | $unregistered = false; |
155 | - check_admin_referer( $option_page . '-options' ); |
|
155 | + check_admin_referer($option_page.'-options'); |
|
156 | 156 | } |
157 | 157 | |
158 | - if ( !isset( $whitelist_options[ $option_page ] ) ) |
|
159 | - wp_die( __( '<strong>ERROR</strong>: options page not found.' ) ); |
|
158 | + if ( ! isset($whitelist_options[$option_page])) |
|
159 | + wp_die(__('<strong>ERROR</strong>: options page not found.')); |
|
160 | 160 | |
161 | - if ( 'options' == $option_page ) { |
|
162 | - if ( is_multisite() && ! is_super_admin() ) |
|
163 | - wp_die( __( 'You do not have sufficient permissions to modify unregistered settings for this site.' ) ); |
|
164 | - $options = explode( ',', wp_unslash( $_POST[ 'page_options' ] ) ); |
|
161 | + if ('options' == $option_page) { |
|
162 | + if (is_multisite() && ! is_super_admin()) |
|
163 | + wp_die(__('You do not have sufficient permissions to modify unregistered settings for this site.')); |
|
164 | + $options = explode(',', wp_unslash($_POST['page_options'])); |
|
165 | 165 | } else { |
166 | - $options = $whitelist_options[ $option_page ]; |
|
166 | + $options = $whitelist_options[$option_page]; |
|
167 | 167 | } |
168 | 168 | |
169 | - if ( 'general' == $option_page ) { |
|
169 | + if ('general' == $option_page) { |
|
170 | 170 | // Handle custom date/time formats. |
171 | - if ( !empty($_POST['date_format']) && isset($_POST['date_format_custom']) && '\c\u\s\t\o\m' == wp_unslash( $_POST['date_format'] ) ) |
|
171 | + if ( ! empty($_POST['date_format']) && isset($_POST['date_format_custom']) && '\c\u\s\t\o\m' == wp_unslash($_POST['date_format'])) |
|
172 | 172 | $_POST['date_format'] = $_POST['date_format_custom']; |
173 | - if ( !empty($_POST['time_format']) && isset($_POST['time_format_custom']) && '\c\u\s\t\o\m' == wp_unslash( $_POST['time_format'] ) ) |
|
173 | + if ( ! empty($_POST['time_format']) && isset($_POST['time_format_custom']) && '\c\u\s\t\o\m' == wp_unslash($_POST['time_format'])) |
|
174 | 174 | $_POST['time_format'] = $_POST['time_format_custom']; |
175 | 175 | // Map UTC+- timezones to gmt_offsets and set timezone_string to empty. |
176 | - if ( !empty($_POST['timezone_string']) && preg_match('/^UTC[+-]/', $_POST['timezone_string']) ) { |
|
176 | + if ( ! empty($_POST['timezone_string']) && preg_match('/^UTC[+-]/', $_POST['timezone_string'])) { |
|
177 | 177 | $_POST['gmt_offset'] = $_POST['timezone_string']; |
178 | 178 | $_POST['gmt_offset'] = preg_replace('/UTC\+?/', '', $_POST['gmt_offset']); |
179 | 179 | $_POST['timezone_string'] = ''; |
180 | 180 | } |
181 | 181 | |
182 | 182 | // Handle translation install. |
183 | - if ( ! empty( $_POST['WPLANG'] ) && ( ! is_multisite() || is_super_admin() ) ) { // @todo: Skip if already installed |
|
184 | - require_once( ABSPATH . 'wp-admin/includes/translation-install.php' ); |
|
183 | + if ( ! empty($_POST['WPLANG']) && ( ! is_multisite() || is_super_admin())) { // @todo: Skip if already installed |
|
184 | + require_once(ABSPATH.'wp-admin/includes/translation-install.php'); |
|
185 | 185 | |
186 | - if ( wp_can_install_language_pack() ) { |
|
187 | - $language = wp_download_language_pack( $_POST['WPLANG'] ); |
|
188 | - if ( $language ) { |
|
186 | + if (wp_can_install_language_pack()) { |
|
187 | + $language = wp_download_language_pack($_POST['WPLANG']); |
|
188 | + if ($language) { |
|
189 | 189 | $_POST['WPLANG'] = $language; |
190 | 190 | } |
191 | 191 | } |
192 | 192 | } |
193 | 193 | } |
194 | 194 | |
195 | - if ( $options ) { |
|
196 | - foreach ( $options as $option ) { |
|
197 | - if ( $unregistered ) { |
|
198 | - _deprecated_argument( 'options.php', '2.7', |
|
195 | + if ($options) { |
|
196 | + foreach ($options as $option) { |
|
197 | + if ($unregistered) { |
|
198 | + _deprecated_argument('options.php', '2.7', |
|
199 | 199 | sprintf( |
200 | 200 | /* translators: %s: the option/setting */ |
201 | - __( 'The %s setting is unregistered. Unregistered settings are deprecated. See https://codex.wordpress.org/Settings_API' ), |
|
202 | - '<code>' . $option . '</code>' |
|
201 | + __('The %s setting is unregistered. Unregistered settings are deprecated. See https://codex.wordpress.org/Settings_API'), |
|
202 | + '<code>'.$option.'</code>' |
|
203 | 203 | ) |
204 | 204 | ); |
205 | 205 | } |
206 | 206 | |
207 | - $option = trim( $option ); |
|
207 | + $option = trim($option); |
|
208 | 208 | $value = null; |
209 | - if ( isset( $_POST[ $option ] ) ) { |
|
210 | - $value = $_POST[ $option ]; |
|
211 | - if ( ! is_array( $value ) ) |
|
212 | - $value = trim( $value ); |
|
213 | - $value = wp_unslash( $value ); |
|
209 | + if (isset($_POST[$option])) { |
|
210 | + $value = $_POST[$option]; |
|
211 | + if ( ! is_array($value)) |
|
212 | + $value = trim($value); |
|
213 | + $value = wp_unslash($value); |
|
214 | 214 | } |
215 | - update_option( $option, $value ); |
|
215 | + update_option($option, $value); |
|
216 | 216 | } |
217 | 217 | |
218 | 218 | // Switch translation in case WPLANG was changed. |
219 | - $language = get_option( 'WPLANG' ); |
|
220 | - if ( $language ) { |
|
221 | - load_default_textdomain( $language ); |
|
219 | + $language = get_option('WPLANG'); |
|
220 | + if ($language) { |
|
221 | + load_default_textdomain($language); |
|
222 | 222 | } else { |
223 | - unload_textdomain( 'default' ); |
|
223 | + unload_textdomain('default'); |
|
224 | 224 | } |
225 | 225 | } |
226 | 226 | |
@@ -228,38 +228,38 @@ discard block |
||
228 | 228 | * Handle settings errors and return to options page |
229 | 229 | */ |
230 | 230 | // If no settings errors were registered add a general 'updated' message. |
231 | - if ( !count( get_settings_errors() ) ) |
|
231 | + if ( ! count(get_settings_errors())) |
|
232 | 232 | add_settings_error('general', 'settings_updated', __('Settings saved.'), 'updated'); |
233 | 233 | set_transient('settings_errors', get_settings_errors(), 30); |
234 | 234 | |
235 | 235 | /** |
236 | 236 | * Redirect back to the settings page that was submitted |
237 | 237 | */ |
238 | - $goback = add_query_arg( 'settings-updated', 'true', wp_get_referer() ); |
|
239 | - wp_redirect( $goback ); |
|
238 | + $goback = add_query_arg('settings-updated', 'true', wp_get_referer()); |
|
239 | + wp_redirect($goback); |
|
240 | 240 | exit; |
241 | 241 | } |
242 | 242 | |
243 | -include( ABSPATH . 'wp-admin/admin-header.php' ); ?> |
|
243 | +include(ABSPATH.'wp-admin/admin-header.php'); ?> |
|
244 | 244 | |
245 | 245 | <div class="wrap"> |
246 | - <h1><?php esc_html_e( 'All Settings' ); ?></h1> |
|
246 | + <h1><?php esc_html_e('All Settings'); ?></h1> |
|
247 | 247 | <form name="form" action="options.php" method="post" id="all-options"> |
248 | 248 | <?php wp_nonce_field('options-options') ?> |
249 | 249 | <input type="hidden" name="action" value="update" /> |
250 | 250 | <input type="hidden" name="option_page" value="options" /> |
251 | 251 | <table class="form-table"> |
252 | 252 | <?php |
253 | -$options = $wpdb->get_results( "SELECT * FROM $wpdb->options ORDER BY option_name" ); |
|
253 | +$options = $wpdb->get_results("SELECT * FROM $wpdb->options ORDER BY option_name"); |
|
254 | 254 | |
255 | -foreach ( (array) $options as $option ) : |
|
255 | +foreach ((array) $options as $option) : |
|
256 | 256 | $disabled = false; |
257 | - if ( $option->option_name == '' ) |
|
257 | + if ($option->option_name == '') |
|
258 | 258 | continue; |
259 | - if ( is_serialized( $option->option_value ) ) { |
|
260 | - if ( is_serialized_string( $option->option_value ) ) { |
|
259 | + if (is_serialized($option->option_value)) { |
|
260 | + if (is_serialized_string($option->option_value)) { |
|
261 | 261 | // This is a serialized string, so we should display it. |
262 | - $value = maybe_unserialize( $option->option_value ); |
|
262 | + $value = maybe_unserialize($option->option_value); |
|
263 | 263 | $options_to_update[] = $option->option_name; |
264 | 264 | $class = 'all-options'; |
265 | 265 | } else { |
@@ -272,28 +272,28 @@ discard block |
||
272 | 272 | $options_to_update[] = $option->option_name; |
273 | 273 | $class = 'all-options'; |
274 | 274 | } |
275 | - $name = esc_attr( $option->option_name ); |
|
275 | + $name = esc_attr($option->option_name); |
|
276 | 276 | ?> |
277 | 277 | <tr> |
278 | - <th scope="row"><label for="<?php echo $name ?>"><?php echo esc_html( $option->option_name ); ?></label></th> |
|
278 | + <th scope="row"><label for="<?php echo $name ?>"><?php echo esc_html($option->option_name); ?></label></th> |
|
279 | 279 | <td> |
280 | -<?php if ( strpos( $value, "\n" ) !== false ) : ?> |
|
280 | +<?php if (strpos($value, "\n") !== false) : ?> |
|
281 | 281 | <textarea class="<?php echo $class ?>" name="<?php echo $name ?>" id="<?php echo $name ?>" cols="30" rows="5"><?php |
282 | - echo esc_textarea( $value ); |
|
282 | + echo esc_textarea($value); |
|
283 | 283 | ?></textarea> |
284 | 284 | <?php else: ?> |
285 | - <input class="regular-text <?php echo $class ?>" type="text" name="<?php echo $name ?>" id="<?php echo $name ?>" value="<?php echo esc_attr( $value ) ?>"<?php disabled( $disabled, true ) ?> /> |
|
285 | + <input class="regular-text <?php echo $class ?>" type="text" name="<?php echo $name ?>" id="<?php echo $name ?>" value="<?php echo esc_attr($value) ?>"<?php disabled($disabled, true) ?> /> |
|
286 | 286 | <?php endif ?></td> |
287 | 287 | </tr> |
288 | 288 | <?php endforeach; ?> |
289 | 289 | </table> |
290 | 290 | |
291 | -<input type="hidden" name="page_options" value="<?php echo esc_attr( implode( ',', $options_to_update ) ); ?>" /> |
|
291 | +<input type="hidden" name="page_options" value="<?php echo esc_attr(implode(',', $options_to_update)); ?>" /> |
|
292 | 292 | |
293 | -<?php submit_button( __( 'Save Changes' ), 'primary', 'Update' ); ?> |
|
293 | +<?php submit_button(__('Save Changes'), 'primary', 'Update'); ?> |
|
294 | 294 | |
295 | 295 | </form> |
296 | 296 | </div> |
297 | 297 | |
298 | 298 | <?php |
299 | -include( ABSPATH . 'wp-admin/admin-footer.php' ); |
|
299 | +include(ABSPATH.'wp-admin/admin-footer.php'); |
@@ -92,8 +92,9 @@ discard block |
||
92 | 92 | |
93 | 93 | $mail_options = array('mailserver_url', 'mailserver_port', 'mailserver_login', 'mailserver_pass'); |
94 | 94 | |
95 | -if ( ! in_array( get_option( 'blog_charset' ), array( 'utf8', 'utf-8', 'UTF8', 'UTF-8' ) ) ) |
|
95 | +if ( ! in_array( get_option( 'blog_charset' ), array( 'utf8', 'utf-8', 'UTF8', 'UTF-8' ) ) ) { |
|
96 | 96 | $whitelist_options['reading'][] = 'blog_charset'; |
97 | +} |
|
97 | 98 | |
98 | 99 | if ( get_site_option( 'initial_db_version' ) < 32453 ) { |
99 | 100 | $whitelist_options['writing'][] = 'use_smilies'; |
@@ -101,10 +102,12 @@ discard block |
||
101 | 102 | } |
102 | 103 | |
103 | 104 | if ( !is_multisite() ) { |
104 | - if ( !defined( 'WP_SITEURL' ) ) |
|
105 | - $whitelist_options['general'][] = 'siteurl'; |
|
106 | - if ( !defined( 'WP_HOME' ) ) |
|
107 | - $whitelist_options['general'][] = 'home'; |
|
105 | + if ( !defined( 'WP_SITEURL' ) ) { |
|
106 | + $whitelist_options['general'][] = 'siteurl'; |
|
107 | + } |
|
108 | + if ( !defined( 'WP_HOME' ) ) { |
|
109 | + $whitelist_options['general'][] = 'home'; |
|
110 | + } |
|
108 | 111 | |
109 | 112 | $whitelist_options['general'][] = 'admin_email'; |
110 | 113 | $whitelist_options['general'][] = 'users_can_register'; |
@@ -130,9 +133,10 @@ discard block |
||
130 | 133 | * |
131 | 134 | * @param bool $enabled Whether post-by-email configuration is enabled. Default true. |
132 | 135 | */ |
133 | - if ( apply_filters( 'enable_post_by_email_configuration', true ) ) |
|
134 | - $whitelist_options['writing'] = array_merge($whitelist_options['writing'], $mail_options); |
|
135 | -} |
|
136 | + if ( apply_filters( 'enable_post_by_email_configuration', true ) ) { |
|
137 | + $whitelist_options['writing'] = array_merge($whitelist_options['writing'], $mail_options); |
|
138 | + } |
|
139 | + } |
|
136 | 140 | |
137 | 141 | /** |
138 | 142 | * Filter the options white list. |
@@ -155,12 +159,14 @@ discard block |
||
155 | 159 | check_admin_referer( $option_page . '-options' ); |
156 | 160 | } |
157 | 161 | |
158 | - if ( !isset( $whitelist_options[ $option_page ] ) ) |
|
159 | - wp_die( __( '<strong>ERROR</strong>: options page not found.' ) ); |
|
162 | + if ( !isset( $whitelist_options[ $option_page ] ) ) { |
|
163 | + wp_die( __( '<strong>ERROR</strong>: options page not found.' ) ); |
|
164 | + } |
|
160 | 165 | |
161 | 166 | if ( 'options' == $option_page ) { |
162 | - if ( is_multisite() && ! is_super_admin() ) |
|
163 | - wp_die( __( 'You do not have sufficient permissions to modify unregistered settings for this site.' ) ); |
|
167 | + if ( is_multisite() && ! is_super_admin() ) { |
|
168 | + wp_die( __( 'You do not have sufficient permissions to modify unregistered settings for this site.' ) ); |
|
169 | + } |
|
164 | 170 | $options = explode( ',', wp_unslash( $_POST[ 'page_options' ] ) ); |
165 | 171 | } else { |
166 | 172 | $options = $whitelist_options[ $option_page ]; |
@@ -168,10 +174,12 @@ discard block |
||
168 | 174 | |
169 | 175 | if ( 'general' == $option_page ) { |
170 | 176 | // Handle custom date/time formats. |
171 | - if ( !empty($_POST['date_format']) && isset($_POST['date_format_custom']) && '\c\u\s\t\o\m' == wp_unslash( $_POST['date_format'] ) ) |
|
172 | - $_POST['date_format'] = $_POST['date_format_custom']; |
|
173 | - if ( !empty($_POST['time_format']) && isset($_POST['time_format_custom']) && '\c\u\s\t\o\m' == wp_unslash( $_POST['time_format'] ) ) |
|
174 | - $_POST['time_format'] = $_POST['time_format_custom']; |
|
177 | + if ( !empty($_POST['date_format']) && isset($_POST['date_format_custom']) && '\c\u\s\t\o\m' == wp_unslash( $_POST['date_format'] ) ) { |
|
178 | + $_POST['date_format'] = $_POST['date_format_custom']; |
|
179 | + } |
|
180 | + if ( !empty($_POST['time_format']) && isset($_POST['time_format_custom']) && '\c\u\s\t\o\m' == wp_unslash( $_POST['time_format'] ) ) { |
|
181 | + $_POST['time_format'] = $_POST['time_format_custom']; |
|
182 | + } |
|
175 | 183 | // Map UTC+- timezones to gmt_offsets and set timezone_string to empty. |
176 | 184 | if ( !empty($_POST['timezone_string']) && preg_match('/^UTC[+-]/', $_POST['timezone_string']) ) { |
177 | 185 | $_POST['gmt_offset'] = $_POST['timezone_string']; |
@@ -208,8 +216,9 @@ discard block |
||
208 | 216 | $value = null; |
209 | 217 | if ( isset( $_POST[ $option ] ) ) { |
210 | 218 | $value = $_POST[ $option ]; |
211 | - if ( ! is_array( $value ) ) |
|
212 | - $value = trim( $value ); |
|
219 | + if ( ! is_array( $value ) ) { |
|
220 | + $value = trim( $value ); |
|
221 | + } |
|
213 | 222 | $value = wp_unslash( $value ); |
214 | 223 | } |
215 | 224 | update_option( $option, $value ); |
@@ -228,8 +237,9 @@ discard block |
||
228 | 237 | * Handle settings errors and return to options page |
229 | 238 | */ |
230 | 239 | // If no settings errors were registered add a general 'updated' message. |
231 | - if ( !count( get_settings_errors() ) ) |
|
232 | - add_settings_error('general', 'settings_updated', __('Settings saved.'), 'updated'); |
|
240 | + if ( !count( get_settings_errors() ) ) { |
|
241 | + add_settings_error('general', 'settings_updated', __('Settings saved.'), 'updated'); |
|
242 | + } |
|
233 | 243 | set_transient('settings_errors', get_settings_errors(), 30); |
234 | 244 | |
235 | 245 | /** |
@@ -254,8 +264,9 @@ discard block |
||
254 | 264 | |
255 | 265 | foreach ( (array) $options as $option ) : |
256 | 266 | $disabled = false; |
257 | - if ( $option->option_name == '' ) |
|
258 | - continue; |
|
267 | + if ( $option->option_name == '' ) { |
|
268 | + continue; |
|
269 | + } |
|
259 | 270 | if ( is_serialized( $option->option_value ) ) { |
260 | 271 | if ( is_serialized_string( $option->option_value ) ) { |
261 | 272 | // This is a serialized string, so we should display it. |
@@ -281,11 +292,14 @@ discard block |
||
281 | 292 | <textarea class="<?php echo $class ?>" name="<?php echo $name ?>" id="<?php echo $name ?>" cols="30" rows="5"><?php |
282 | 293 | echo esc_textarea( $value ); |
283 | 294 | ?></textarea> |
284 | - <?php else: ?> |
|
295 | + <?php else { |
|
296 | + : ?> |
|
285 | 297 | <input class="regular-text <?php echo $class ?>" type="text" name="<?php echo $name ?>" id="<?php echo $name ?>" value="<?php echo esc_attr( $value ) ?>"<?php disabled( $disabled, true ) ?> /> |
286 | 298 | <?php endif ?></td> |
287 | 299 | </tr> |
288 | -<?php endforeach; ?> |
|
300 | +<?php endforeach; |
|
301 | +} |
|
302 | +?> |
|
289 | 303 | </table> |
290 | 304 | |
291 | 305 | <input type="hidden" name="page_options" value="<?php echo esc_attr( implode( ',', $options_to_update ) ); ?>" /> |
@@ -36,18 +36,18 @@ discard block |
||
36 | 36 | * |
37 | 37 | * @param array $args An associative array of arguments. |
38 | 38 | */ |
39 | - public function __construct( $args = array() ) { |
|
39 | + public function __construct($args = array()) { |
|
40 | 40 | $this->status_list = array( |
41 | - 'archived' => array( 'site-archived', __( 'Archived' ) ), |
|
42 | - 'spam' => array( 'site-spammed', _x( 'Spam', 'site' ) ), |
|
43 | - 'deleted' => array( 'site-deleted', __( 'Deleted' ) ), |
|
44 | - 'mature' => array( 'site-mature', __( 'Mature' ) ) |
|
41 | + 'archived' => array('site-archived', __('Archived')), |
|
42 | + 'spam' => array('site-spammed', _x('Spam', 'site')), |
|
43 | + 'deleted' => array('site-deleted', __('Deleted')), |
|
44 | + 'mature' => array('site-mature', __('Mature')) |
|
45 | 45 | ); |
46 | 46 | |
47 | - parent::__construct( array( |
|
47 | + parent::__construct(array( |
|
48 | 48 | 'plural' => 'sites', |
49 | - 'screen' => isset( $args['screen'] ) ? $args['screen'] : null, |
|
50 | - ) ); |
|
49 | + 'screen' => isset($args['screen']) ? $args['screen'] : null, |
|
50 | + )); |
|
51 | 51 | } |
52 | 52 | |
53 | 53 | /** |
@@ -55,7 +55,7 @@ discard block |
||
55 | 55 | * @return bool |
56 | 56 | */ |
57 | 57 | public function ajax_user_can() { |
58 | - return current_user_can( 'manage_sites' ); |
|
58 | + return current_user_can('manage_sites'); |
|
59 | 59 | } |
60 | 60 | |
61 | 61 | /** |
@@ -69,20 +69,20 @@ discard block |
||
69 | 69 | |
70 | 70 | $current_site = get_current_site(); |
71 | 71 | |
72 | - if ( ! empty( $_REQUEST['mode'] ) ) { |
|
72 | + if ( ! empty($_REQUEST['mode'])) { |
|
73 | 73 | $mode = $_REQUEST['mode'] === 'excerpt' ? 'excerpt' : 'list'; |
74 | - set_user_setting( 'sites_list_mode', $mode ); |
|
74 | + set_user_setting('sites_list_mode', $mode); |
|
75 | 75 | } else { |
76 | - $mode = get_user_setting( 'sites_list_mode', 'list' ); |
|
76 | + $mode = get_user_setting('sites_list_mode', 'list'); |
|
77 | 77 | } |
78 | 78 | |
79 | - $per_page = $this->get_items_per_page( 'sites_network_per_page' ); |
|
79 | + $per_page = $this->get_items_per_page('sites_network_per_page'); |
|
80 | 80 | |
81 | 81 | $pagenum = $this->get_pagenum(); |
82 | 82 | |
83 | - $s = isset( $_REQUEST['s'] ) ? wp_unslash( trim( $_REQUEST[ 's' ] ) ) : ''; |
|
83 | + $s = isset($_REQUEST['s']) ? wp_unslash(trim($_REQUEST['s'])) : ''; |
|
84 | 84 | $wild = ''; |
85 | - if ( false !== strpos($s, '*') ) { |
|
85 | + if (false !== strpos($s, '*')) { |
|
86 | 86 | $wild = '%'; |
87 | 87 | $s = trim($s, '*'); |
88 | 88 | } |
@@ -91,92 +91,92 @@ discard block |
||
91 | 91 | * If the network is large and a search is not being performed, show only |
92 | 92 | * the latest sites with no paging in order to avoid expensive count queries. |
93 | 93 | */ |
94 | - if ( !$s && wp_is_large_network() ) { |
|
95 | - if ( !isset($_REQUEST['orderby']) ) |
|
94 | + if ( ! $s && wp_is_large_network()) { |
|
95 | + if ( ! isset($_REQUEST['orderby'])) |
|
96 | 96 | $_GET['orderby'] = $_REQUEST['orderby'] = ''; |
97 | - if ( !isset($_REQUEST['order']) ) |
|
97 | + if ( ! isset($_REQUEST['order'])) |
|
98 | 98 | $_GET['order'] = $_REQUEST['order'] = 'DESC'; |
99 | 99 | } |
100 | 100 | |
101 | 101 | $query = "SELECT * FROM {$wpdb->blogs} WHERE site_id = '{$wpdb->siteid}' "; |
102 | 102 | |
103 | - if ( empty($s) ) { |
|
103 | + if (empty($s)) { |
|
104 | 104 | // Nothing to do. |
105 | - } elseif ( preg_match( '/^[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}$/', $s ) || |
|
106 | - preg_match( '/^[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.?$/', $s ) || |
|
107 | - preg_match( '/^[0-9]{1,3}\.[0-9]{1,3}\.?$/', $s ) || |
|
108 | - preg_match( '/^[0-9]{1,3}\.$/', $s ) ) { |
|
105 | + } elseif (preg_match('/^[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}$/', $s) || |
|
106 | + preg_match('/^[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.?$/', $s) || |
|
107 | + preg_match('/^[0-9]{1,3}\.[0-9]{1,3}\.?$/', $s) || |
|
108 | + preg_match('/^[0-9]{1,3}\.$/', $s)) { |
|
109 | 109 | // IPv4 address |
110 | - $sql = $wpdb->prepare( "SELECT blog_id FROM {$wpdb->registration_log} WHERE {$wpdb->registration_log}.IP LIKE %s", $wpdb->esc_like( $s ) . $wild ); |
|
111 | - $reg_blog_ids = $wpdb->get_col( $sql ); |
|
110 | + $sql = $wpdb->prepare("SELECT blog_id FROM {$wpdb->registration_log} WHERE {$wpdb->registration_log}.IP LIKE %s", $wpdb->esc_like($s).$wild); |
|
111 | + $reg_blog_ids = $wpdb->get_col($sql); |
|
112 | 112 | |
113 | - if ( !$reg_blog_ids ) |
|
114 | - $reg_blog_ids = array( 0 ); |
|
113 | + if ( ! $reg_blog_ids) |
|
114 | + $reg_blog_ids = array(0); |
|
115 | 115 | |
116 | 116 | $query = "SELECT * |
117 | 117 | FROM {$wpdb->blogs} |
118 | 118 | WHERE site_id = '{$wpdb->siteid}' |
119 | - AND {$wpdb->blogs}.blog_id IN (" . implode( ', ', $reg_blog_ids ) . ")"; |
|
119 | + AND {$wpdb->blogs}.blog_id IN (".implode(', ', $reg_blog_ids).")"; |
|
120 | 120 | } else { |
121 | - if ( is_numeric($s) && empty( $wild ) ) { |
|
122 | - $query .= $wpdb->prepare( " AND ( {$wpdb->blogs}.blog_id = %s )", $s ); |
|
123 | - } elseif ( is_subdomain_install() ) { |
|
124 | - $blog_s = str_replace( '.' . $current_site->domain, '', $s ); |
|
125 | - $blog_s = $wpdb->esc_like( $blog_s ) . $wild . $wpdb->esc_like( '.' . $current_site->domain ); |
|
126 | - $query .= $wpdb->prepare( " AND ( {$wpdb->blogs}.domain LIKE %s ) ", $blog_s ); |
|
121 | + if (is_numeric($s) && empty($wild)) { |
|
122 | + $query .= $wpdb->prepare(" AND ( {$wpdb->blogs}.blog_id = %s )", $s); |
|
123 | + } elseif (is_subdomain_install()) { |
|
124 | + $blog_s = str_replace('.'.$current_site->domain, '', $s); |
|
125 | + $blog_s = $wpdb->esc_like($blog_s).$wild.$wpdb->esc_like('.'.$current_site->domain); |
|
126 | + $query .= $wpdb->prepare(" AND ( {$wpdb->blogs}.domain LIKE %s ) ", $blog_s); |
|
127 | 127 | } else { |
128 | - if ( $s != trim('/', $current_site->path) ) { |
|
129 | - $blog_s = $wpdb->esc_like( $current_site->path . $s ) . $wild . $wpdb->esc_like( '/' ); |
|
128 | + if ($s != trim('/', $current_site->path)) { |
|
129 | + $blog_s = $wpdb->esc_like($current_site->path.$s).$wild.$wpdb->esc_like('/'); |
|
130 | 130 | } else { |
131 | - $blog_s = $wpdb->esc_like( $s ); |
|
131 | + $blog_s = $wpdb->esc_like($s); |
|
132 | 132 | } |
133 | - $query .= $wpdb->prepare( " AND ( {$wpdb->blogs}.path LIKE %s )", $blog_s ); |
|
133 | + $query .= $wpdb->prepare(" AND ( {$wpdb->blogs}.path LIKE %s )", $blog_s); |
|
134 | 134 | } |
135 | 135 | } |
136 | 136 | |
137 | - $order_by = isset( $_REQUEST['orderby'] ) ? $_REQUEST['orderby'] : ''; |
|
138 | - if ( $order_by === 'registered' ) { |
|
137 | + $order_by = isset($_REQUEST['orderby']) ? $_REQUEST['orderby'] : ''; |
|
138 | + if ($order_by === 'registered') { |
|
139 | 139 | $query .= ' ORDER BY registered '; |
140 | - } elseif ( $order_by === 'lastupdated' ) { |
|
140 | + } elseif ($order_by === 'lastupdated') { |
|
141 | 141 | $query .= ' ORDER BY last_updated '; |
142 | - } elseif ( $order_by === 'blogname' ) { |
|
143 | - if ( is_subdomain_install() ) { |
|
142 | + } elseif ($order_by === 'blogname') { |
|
143 | + if (is_subdomain_install()) { |
|
144 | 144 | $query .= ' ORDER BY domain '; |
145 | 145 | } else { |
146 | 146 | $query .= ' ORDER BY path '; |
147 | 147 | } |
148 | - } elseif ( $order_by === 'blog_id' ) { |
|
148 | + } elseif ($order_by === 'blog_id') { |
|
149 | 149 | $query .= ' ORDER BY blog_id '; |
150 | 150 | } else { |
151 | 151 | $order_by = null; |
152 | 152 | } |
153 | 153 | |
154 | - if ( isset( $order_by ) ) { |
|
155 | - $order = ( isset( $_REQUEST['order'] ) && 'DESC' === strtoupper( $_REQUEST['order'] ) ) ? "DESC" : "ASC"; |
|
154 | + if (isset($order_by)) { |
|
155 | + $order = (isset($_REQUEST['order']) && 'DESC' === strtoupper($_REQUEST['order'])) ? "DESC" : "ASC"; |
|
156 | 156 | $query .= $order; |
157 | 157 | } |
158 | 158 | |
159 | 159 | // Don't do an unbounded count on large networks |
160 | - if ( ! wp_is_large_network() ) |
|
161 | - $total = $wpdb->get_var( str_replace( 'SELECT *', 'SELECT COUNT( blog_id )', $query ) ); |
|
160 | + if ( ! wp_is_large_network()) |
|
161 | + $total = $wpdb->get_var(str_replace('SELECT *', 'SELECT COUNT( blog_id )', $query)); |
|
162 | 162 | |
163 | - $query .= " LIMIT " . intval( ( $pagenum - 1 ) * $per_page ) . ", " . intval( $per_page ); |
|
164 | - $this->items = $wpdb->get_results( $query, ARRAY_A ); |
|
163 | + $query .= " LIMIT ".intval(($pagenum - 1) * $per_page).", ".intval($per_page); |
|
164 | + $this->items = $wpdb->get_results($query, ARRAY_A); |
|
165 | 165 | |
166 | - if ( wp_is_large_network() ) |
|
166 | + if (wp_is_large_network()) |
|
167 | 167 | $total = count($this->items); |
168 | 168 | |
169 | - $this->set_pagination_args( array( |
|
169 | + $this->set_pagination_args(array( |
|
170 | 170 | 'total_items' => $total, |
171 | 171 | 'per_page' => $per_page, |
172 | - ) ); |
|
172 | + )); |
|
173 | 173 | } |
174 | 174 | |
175 | 175 | /** |
176 | 176 | * @access public |
177 | 177 | */ |
178 | 178 | public function no_items() { |
179 | - _e( 'No sites found.' ); |
|
179 | + _e('No sites found.'); |
|
180 | 180 | } |
181 | 181 | |
182 | 182 | /** |
@@ -185,10 +185,10 @@ discard block |
||
185 | 185 | */ |
186 | 186 | protected function get_bulk_actions() { |
187 | 187 | $actions = array(); |
188 | - if ( current_user_can( 'delete_sites' ) ) |
|
189 | - $actions['delete'] = __( 'Delete' ); |
|
190 | - $actions['spam'] = _x( 'Mark as Spam', 'site' ); |
|
191 | - $actions['notspam'] = _x( 'Not Spam', 'site' ); |
|
188 | + if (current_user_can('delete_sites')) |
|
189 | + $actions['delete'] = __('Delete'); |
|
190 | + $actions['spam'] = _x('Mark as Spam', 'site'); |
|
191 | + $actions['notspam'] = _x('Not Spam', 'site'); |
|
192 | 192 | |
193 | 193 | return $actions; |
194 | 194 | } |
@@ -198,13 +198,13 @@ discard block |
||
198 | 198 | * |
199 | 199 | * @param string $which |
200 | 200 | */ |
201 | - protected function pagination( $which ) { |
|
201 | + protected function pagination($which) { |
|
202 | 202 | global $mode; |
203 | 203 | |
204 | - parent::pagination( $which ); |
|
204 | + parent::pagination($which); |
|
205 | 205 | |
206 | - if ( 'top' === $which ) |
|
207 | - $this->view_switcher( $mode ); |
|
206 | + if ('top' === $which) |
|
207 | + $this->view_switcher($mode); |
|
208 | 208 | } |
209 | 209 | |
210 | 210 | /** |
@@ -213,14 +213,14 @@ discard block |
||
213 | 213 | public function get_columns() { |
214 | 214 | $sites_columns = array( |
215 | 215 | 'cb' => '<input type="checkbox" />', |
216 | - 'blogname' => __( 'URL' ), |
|
217 | - 'lastupdated' => __( 'Last Updated' ), |
|
218 | - 'registered' => _x( 'Registered', 'site' ), |
|
219 | - 'users' => __( 'Users' ), |
|
216 | + 'blogname' => __('URL'), |
|
217 | + 'lastupdated' => __('Last Updated'), |
|
218 | + 'registered' => _x('Registered', 'site'), |
|
219 | + 'users' => __('Users'), |
|
220 | 220 | ); |
221 | 221 | |
222 | - if ( has_filter( 'wpmublogsaction' ) ) { |
|
223 | - $sites_columns['plugins'] = __( 'Actions' ); |
|
222 | + if (has_filter('wpmublogsaction')) { |
|
223 | + $sites_columns['plugins'] = __('Actions'); |
|
224 | 224 | } |
225 | 225 | |
226 | 226 | /** |
@@ -231,7 +231,7 @@ discard block |
||
231 | 231 | * @param array $sites_columns An array of displayed site columns. Default 'cb', |
232 | 232 | * 'blogname', 'lastupdated', 'registered', 'users'. |
233 | 233 | */ |
234 | - return apply_filters( 'wpmu_blogs_columns', $sites_columns ); |
|
234 | + return apply_filters('wpmu_blogs_columns', $sites_columns); |
|
235 | 235 | } |
236 | 236 | |
237 | 237 | /** |
@@ -253,14 +253,14 @@ discard block |
||
253 | 253 | * |
254 | 254 | * @param array $blog Current site. |
255 | 255 | */ |
256 | - public function column_cb( $blog ) { |
|
257 | - if ( ! is_main_site( $blog['blog_id'] ) ) : |
|
258 | - $blogname = untrailingslashit( $blog['domain'] . $blog['path'] ); |
|
256 | + public function column_cb($blog) { |
|
257 | + if ( ! is_main_site($blog['blog_id'])) : |
|
258 | + $blogname = untrailingslashit($blog['domain'].$blog['path']); |
|
259 | 259 | ?> |
260 | 260 | <label class="screen-reader-text" for="blog_<?php echo $blog['blog_id']; ?>"><?php |
261 | - printf( __( 'Select %s' ), $blogname ); |
|
261 | + printf(__('Select %s'), $blogname); |
|
262 | 262 | ?></label> |
263 | - <input type="checkbox" id="blog_<?php echo $blog['blog_id'] ?>" name="allblogs[]" value="<?php echo esc_attr( $blog['blog_id'] ) ?>" /> |
|
263 | + <input type="checkbox" id="blog_<?php echo $blog['blog_id'] ?>" name="allblogs[]" value="<?php echo esc_attr($blog['blog_id']) ?>" /> |
|
264 | 264 | <?php endif; |
265 | 265 | } |
266 | 266 | |
@@ -272,7 +272,7 @@ discard block |
||
272 | 272 | * |
273 | 273 | * @param array $blog Current site. |
274 | 274 | */ |
275 | - public function column_id( $blog ) { |
|
275 | + public function column_id($blog) { |
|
276 | 276 | echo $blog['blog_id']; |
277 | 277 | } |
278 | 278 | |
@@ -286,41 +286,41 @@ discard block |
||
286 | 286 | * |
287 | 287 | * @param array $blog Current site. |
288 | 288 | */ |
289 | - public function column_blogname( $blog ) { |
|
289 | + public function column_blogname($blog) { |
|
290 | 290 | global $mode; |
291 | 291 | |
292 | - $blogname = untrailingslashit( $blog['domain'] . $blog['path'] ); |
|
292 | + $blogname = untrailingslashit($blog['domain'].$blog['path']); |
|
293 | 293 | $blog_states = array(); |
294 | - reset( $this->status_list ); |
|
294 | + reset($this->status_list); |
|
295 | 295 | |
296 | - foreach ( $this->status_list as $status => $col ) { |
|
297 | - if ( $blog[ $status ] == 1 ) { |
|
296 | + foreach ($this->status_list as $status => $col) { |
|
297 | + if ($blog[$status] == 1) { |
|
298 | 298 | $blog_states[] = $col[1]; |
299 | 299 | } |
300 | 300 | } |
301 | 301 | $blog_state = ''; |
302 | - if ( ! empty( $blog_states ) ) { |
|
303 | - $state_count = count( $blog_states ); |
|
302 | + if ( ! empty($blog_states)) { |
|
303 | + $state_count = count($blog_states); |
|
304 | 304 | $i = 0; |
305 | 305 | $blog_state .= ' - '; |
306 | - foreach ( $blog_states as $state ) { |
|
306 | + foreach ($blog_states as $state) { |
|
307 | 307 | ++$i; |
308 | - $sep = ( $i == $state_count ) ? '' : ', '; |
|
308 | + $sep = ($i == $state_count) ? '' : ', '; |
|
309 | 309 | $blog_state .= "<span class='post-state'>$state$sep</span>"; |
310 | 310 | } |
311 | 311 | } |
312 | 312 | |
313 | 313 | ?> |
314 | - <a href="<?php echo esc_url( network_admin_url( 'site-info.php?id=' . $blog['blog_id'] ) ); ?>" class="edit"><?php echo $blogname . $blog_state; ?></a> |
|
314 | + <a href="<?php echo esc_url(network_admin_url('site-info.php?id='.$blog['blog_id'])); ?>" class="edit"><?php echo $blogname.$blog_state; ?></a> |
|
315 | 315 | <?php |
316 | - if ( 'list' !== $mode ) { |
|
317 | - switch_to_blog( $blog['blog_id'] ); |
|
316 | + if ('list' !== $mode) { |
|
317 | + switch_to_blog($blog['blog_id']); |
|
318 | 318 | echo '<p>'; |
319 | 319 | printf( |
320 | 320 | /* translators: 1: site name, 2: site tagline. */ |
321 | - __( '%1$s – %2$s' ), |
|
322 | - get_option( 'blogname' ), |
|
323 | - '<em>' . get_option( 'blogdescription ' ) . '</em>' |
|
321 | + __('%1$s – %2$s'), |
|
322 | + get_option('blogname'), |
|
323 | + '<em>'.get_option('blogdescription ').'</em>' |
|
324 | 324 | ); |
325 | 325 | echo '</p>'; |
326 | 326 | restore_current_blog(); |
@@ -335,16 +335,16 @@ discard block |
||
335 | 335 | * |
336 | 336 | * @param array $blog Current site. |
337 | 337 | */ |
338 | - public function column_lastupdated( $blog ) { |
|
338 | + public function column_lastupdated($blog) { |
|
339 | 339 | global $mode; |
340 | 340 | |
341 | - if ( 'list' === $mode ) { |
|
342 | - $date = __( 'Y/m/d' ); |
|
341 | + if ('list' === $mode) { |
|
342 | + $date = __('Y/m/d'); |
|
343 | 343 | } else { |
344 | - $date = __( 'Y/m/d g:i:s a' ); |
|
344 | + $date = __('Y/m/d g:i:s a'); |
|
345 | 345 | } |
346 | 346 | |
347 | - echo ( $blog['last_updated'] === '0000-00-00 00:00:00' ) ? __( 'Never' ) : mysql2date( $date, $blog['last_updated'] ); |
|
347 | + echo ($blog['last_updated'] === '0000-00-00 00:00:00') ? __('Never') : mysql2date($date, $blog['last_updated']); |
|
348 | 348 | } |
349 | 349 | |
350 | 350 | /** |
@@ -355,19 +355,19 @@ discard block |
||
355 | 355 | * |
356 | 356 | * @param array $blog Current site. |
357 | 357 | */ |
358 | - public function column_registered( $blog ) { |
|
358 | + public function column_registered($blog) { |
|
359 | 359 | global $mode; |
360 | 360 | |
361 | - if ( 'list' === $mode ) { |
|
362 | - $date = __( 'Y/m/d' ); |
|
361 | + if ('list' === $mode) { |
|
362 | + $date = __('Y/m/d'); |
|
363 | 363 | } else { |
364 | - $date = __( 'Y/m/d g:i:s a' ); |
|
364 | + $date = __('Y/m/d g:i:s a'); |
|
365 | 365 | } |
366 | 366 | |
367 | - if ( $blog['registered'] === '0000-00-00 00:00:00' ) { |
|
367 | + if ($blog['registered'] === '0000-00-00 00:00:00') { |
|
368 | 368 | echo '—'; |
369 | 369 | } else { |
370 | - echo mysql2date( $date, $blog['registered'] ); |
|
370 | + echo mysql2date($date, $blog['registered']); |
|
371 | 371 | } |
372 | 372 | } |
373 | 373 | |
@@ -379,19 +379,19 @@ discard block |
||
379 | 379 | * |
380 | 380 | * @param array $blog Current site. |
381 | 381 | */ |
382 | - public function column_users( $blog ) { |
|
383 | - $user_count = wp_cache_get( $blog['blog_id'] . '_user_count', 'blog-details' ); |
|
384 | - if ( ! $user_count ) { |
|
385 | - $blog_users = get_users( array( 'blog_id' => $blog['blog_id'], 'fields' => 'ID' ) ); |
|
386 | - $user_count = count( $blog_users ); |
|
387 | - unset( $blog_users ); |
|
388 | - wp_cache_set( $blog['blog_id'] . '_user_count', $user_count, 'blog-details', 12 * HOUR_IN_SECONDS ); |
|
382 | + public function column_users($blog) { |
|
383 | + $user_count = wp_cache_get($blog['blog_id'].'_user_count', 'blog-details'); |
|
384 | + if ( ! $user_count) { |
|
385 | + $blog_users = get_users(array('blog_id' => $blog['blog_id'], 'fields' => 'ID')); |
|
386 | + $user_count = count($blog_users); |
|
387 | + unset($blog_users); |
|
388 | + wp_cache_set($blog['blog_id'].'_user_count', $user_count, 'blog-details', 12 * HOUR_IN_SECONDS); |
|
389 | 389 | } |
390 | 390 | |
391 | 391 | printf( |
392 | 392 | '<a href="%s">%s</a>', |
393 | - esc_url( network_admin_url( 'site-users.php?id=' . $blog['blog_id'] ) ), |
|
394 | - number_format_i18n( $user_count ) |
|
393 | + esc_url(network_admin_url('site-users.php?id='.$blog['blog_id'])), |
|
394 | + number_format_i18n($user_count) |
|
395 | 395 | ); |
396 | 396 | } |
397 | 397 | |
@@ -403,8 +403,8 @@ discard block |
||
403 | 403 | * |
404 | 404 | * @param array $blog Current site. |
405 | 405 | */ |
406 | - public function column_plugins( $blog ) { |
|
407 | - if ( has_filter( 'wpmublogsaction' ) ) { |
|
406 | + public function column_plugins($blog) { |
|
407 | + if (has_filter('wpmublogsaction')) { |
|
408 | 408 | /** |
409 | 409 | * Fires inside the auxiliary 'Actions' column of the Sites list table. |
410 | 410 | * |
@@ -414,7 +414,7 @@ discard block |
||
414 | 414 | * |
415 | 415 | * @param int $blog_id The site ID. |
416 | 416 | */ |
417 | - do_action( 'wpmublogsaction', $blog['blog_id'] ); |
|
417 | + do_action('wpmublogsaction', $blog['blog_id']); |
|
418 | 418 | } |
419 | 419 | } |
420 | 420 | |
@@ -427,7 +427,7 @@ discard block |
||
427 | 427 | * @param array $blog Current site. |
428 | 428 | * @param string $column_name Current column name. |
429 | 429 | */ |
430 | - public function column_default( $blog, $column_name ) { |
|
430 | + public function column_default($blog, $column_name) { |
|
431 | 431 | /** |
432 | 432 | * Fires for each registered custom column in the Sites list table. |
433 | 433 | * |
@@ -436,7 +436,7 @@ discard block |
||
436 | 436 | * @param string $column_name The name of the column to display. |
437 | 437 | * @param int $blog_id The site ID. |
438 | 438 | */ |
439 | - do_action( 'manage_sites_custom_column', $column_name, $blog['blog_id'] ); |
|
439 | + do_action('manage_sites_custom_column', $column_name, $blog['blog_id']); |
|
440 | 440 | } |
441 | 441 | |
442 | 442 | /** |
@@ -444,19 +444,19 @@ discard block |
||
444 | 444 | * @global string $mode |
445 | 445 | */ |
446 | 446 | public function display_rows() { |
447 | - foreach ( $this->items as $blog ) { |
|
447 | + foreach ($this->items as $blog) { |
|
448 | 448 | $class = ''; |
449 | - reset( $this->status_list ); |
|
449 | + reset($this->status_list); |
|
450 | 450 | |
451 | - foreach ( $this->status_list as $status => $col ) { |
|
452 | - if ( $blog[ $status ] == 1 ) { |
|
451 | + foreach ($this->status_list as $status => $col) { |
|
452 | + if ($blog[$status] == 1) { |
|
453 | 453 | $class = " class='{$col[0]}'"; |
454 | 454 | } |
455 | 455 | } |
456 | 456 | |
457 | 457 | echo "<tr{$class}>"; |
458 | 458 | |
459 | - $this->single_row_columns( $blog ); |
|
459 | + $this->single_row_columns($blog); |
|
460 | 460 | |
461 | 461 | echo '</tr>'; |
462 | 462 | } |
@@ -485,12 +485,12 @@ discard block |
||
485 | 485 | * @param string $primary Primary column name. |
486 | 486 | * @return string Row actions output. |
487 | 487 | */ |
488 | - protected function handle_row_actions( $blog, $column_name, $primary ) { |
|
489 | - if ( $primary !== $column_name ) { |
|
488 | + protected function handle_row_actions($blog, $column_name, $primary) { |
|
489 | + if ($primary !== $column_name) { |
|
490 | 490 | return; |
491 | 491 | } |
492 | 492 | |
493 | - $blogname = untrailingslashit( $blog['domain'] . $blog['path'] ); |
|
493 | + $blogname = untrailingslashit($blog['domain'].$blog['path']); |
|
494 | 494 | |
495 | 495 | // Preordered. |
496 | 496 | $actions = array( |
@@ -502,33 +502,33 @@ discard block |
||
502 | 502 | 'visit' => '', |
503 | 503 | ); |
504 | 504 | |
505 | - $actions['edit'] = '<a href="' . esc_url( network_admin_url( 'site-info.php?id=' . $blog['blog_id'] ) ) . '">' . __( 'Edit' ) . '</a>'; |
|
506 | - $actions['backend'] = "<a href='" . esc_url( get_admin_url( $blog['blog_id'] ) ) . "' class='edit'>" . __( 'Dashboard' ) . '</a>'; |
|
507 | - if ( get_current_site()->blog_id != $blog['blog_id'] ) { |
|
508 | - if ( $blog['deleted'] == '1' ) { |
|
509 | - $actions['activate'] = '<a href="' . esc_url( wp_nonce_url( network_admin_url( 'sites.php?action=confirm&action2=activateblog&id=' . $blog['blog_id'] ), 'activateblog_' . $blog['blog_id'] ) ) . '">' . __( 'Activate' ) . '</a>'; |
|
505 | + $actions['edit'] = '<a href="'.esc_url(network_admin_url('site-info.php?id='.$blog['blog_id'])).'">'.__('Edit').'</a>'; |
|
506 | + $actions['backend'] = "<a href='".esc_url(get_admin_url($blog['blog_id']))."' class='edit'>".__('Dashboard').'</a>'; |
|
507 | + if (get_current_site()->blog_id != $blog['blog_id']) { |
|
508 | + if ($blog['deleted'] == '1') { |
|
509 | + $actions['activate'] = '<a href="'.esc_url(wp_nonce_url(network_admin_url('sites.php?action=confirm&action2=activateblog&id='.$blog['blog_id']), 'activateblog_'.$blog['blog_id'])).'">'.__('Activate').'</a>'; |
|
510 | 510 | } else { |
511 | - $actions['deactivate'] = '<a href="' . esc_url( wp_nonce_url( network_admin_url( 'sites.php?action=confirm&action2=deactivateblog&id=' . $blog['blog_id'] ), 'deactivateblog_' . $blog['blog_id'] ) ) . '">' . __( 'Deactivate' ) . '</a>'; |
|
511 | + $actions['deactivate'] = '<a href="'.esc_url(wp_nonce_url(network_admin_url('sites.php?action=confirm&action2=deactivateblog&id='.$blog['blog_id']), 'deactivateblog_'.$blog['blog_id'])).'">'.__('Deactivate').'</a>'; |
|
512 | 512 | } |
513 | 513 | |
514 | - if ( $blog['archived'] == '1' ) { |
|
515 | - $actions['unarchive'] = '<a href="' . esc_url( wp_nonce_url( network_admin_url( 'sites.php?action=confirm&action2=unarchiveblog&id=' . $blog['blog_id'] ), 'unarchiveblog_' . $blog['blog_id'] ) ) . '">' . __( 'Unarchive' ) . '</a>'; |
|
514 | + if ($blog['archived'] == '1') { |
|
515 | + $actions['unarchive'] = '<a href="'.esc_url(wp_nonce_url(network_admin_url('sites.php?action=confirm&action2=unarchiveblog&id='.$blog['blog_id']), 'unarchiveblog_'.$blog['blog_id'])).'">'.__('Unarchive').'</a>'; |
|
516 | 516 | } else { |
517 | - $actions['archive'] = '<a href="' . esc_url( wp_nonce_url( network_admin_url( 'sites.php?action=confirm&action2=archiveblog&id=' . $blog['blog_id'] ), 'archiveblog_' . $blog['blog_id'] ) ) . '">' . _x( 'Archive', 'verb; site' ) . '</a>'; |
|
517 | + $actions['archive'] = '<a href="'.esc_url(wp_nonce_url(network_admin_url('sites.php?action=confirm&action2=archiveblog&id='.$blog['blog_id']), 'archiveblog_'.$blog['blog_id'])).'">'._x('Archive', 'verb; site').'</a>'; |
|
518 | 518 | } |
519 | 519 | |
520 | - if ( $blog['spam'] == '1' ) { |
|
521 | - $actions['unspam'] = '<a href="' . esc_url( wp_nonce_url( network_admin_url( 'sites.php?action=confirm&action2=unspamblog&id=' . $blog['blog_id'] ), 'unspamblog_' . $blog['blog_id'] ) ) . '">' . _x( 'Not Spam', 'site' ) . '</a>'; |
|
520 | + if ($blog['spam'] == '1') { |
|
521 | + $actions['unspam'] = '<a href="'.esc_url(wp_nonce_url(network_admin_url('sites.php?action=confirm&action2=unspamblog&id='.$blog['blog_id']), 'unspamblog_'.$blog['blog_id'])).'">'._x('Not Spam', 'site').'</a>'; |
|
522 | 522 | } else { |
523 | - $actions['spam'] = '<a href="' . esc_url( wp_nonce_url( network_admin_url( 'sites.php?action=confirm&action2=spamblog&id=' . $blog['blog_id'] ), 'spamblog_' . $blog['blog_id'] ) ) . '">' . _x( 'Spam', 'site' ) . '</a>'; |
|
523 | + $actions['spam'] = '<a href="'.esc_url(wp_nonce_url(network_admin_url('sites.php?action=confirm&action2=spamblog&id='.$blog['blog_id']), 'spamblog_'.$blog['blog_id'])).'">'._x('Spam', 'site').'</a>'; |
|
524 | 524 | } |
525 | 525 | |
526 | - if ( current_user_can( 'delete_site', $blog['blog_id'] ) ) { |
|
527 | - $actions['delete'] = '<a href="' . esc_url( wp_nonce_url( network_admin_url( 'sites.php?action=confirm&action2=deleteblog&id=' . $blog['blog_id'] ), 'deleteblog_' . $blog['blog_id'] ) ) . '">' . __( 'Delete' ) . '</a>'; |
|
526 | + if (current_user_can('delete_site', $blog['blog_id'])) { |
|
527 | + $actions['delete'] = '<a href="'.esc_url(wp_nonce_url(network_admin_url('sites.php?action=confirm&action2=deleteblog&id='.$blog['blog_id']), 'deleteblog_'.$blog['blog_id'])).'">'.__('Delete').'</a>'; |
|
528 | 528 | } |
529 | 529 | } |
530 | 530 | |
531 | - $actions['visit'] = "<a href='" . esc_url( get_home_url( $blog['blog_id'], '/' ) ) . "' rel='permalink'>" . __( 'Visit' ) . '</a>'; |
|
531 | + $actions['visit'] = "<a href='".esc_url(get_home_url($blog['blog_id'], '/'))."' rel='permalink'>".__('Visit').'</a>'; |
|
532 | 532 | |
533 | 533 | /** |
534 | 534 | * Filter the action links displayed for each site in the Sites list table. |
@@ -545,7 +545,7 @@ discard block |
||
545 | 545 | * @param string $blogname Site path, formatted depending on whether it is a sub-domain |
546 | 546 | * or subdirectory multisite install. |
547 | 547 | */ |
548 | - $actions = apply_filters( 'manage_sites_action_links', array_filter( $actions ), $blog['blog_id'], $blogname ); |
|
549 | - return $this->row_actions( $actions ); |
|
548 | + $actions = apply_filters('manage_sites_action_links', array_filter($actions), $blog['blog_id'], $blogname); |
|
549 | + return $this->row_actions($actions); |
|
550 | 550 | } |
551 | 551 | } |
@@ -92,10 +92,12 @@ discard block |
||
92 | 92 | * the latest sites with no paging in order to avoid expensive count queries. |
93 | 93 | */ |
94 | 94 | if ( !$s && wp_is_large_network() ) { |
95 | - if ( !isset($_REQUEST['orderby']) ) |
|
96 | - $_GET['orderby'] = $_REQUEST['orderby'] = ''; |
|
97 | - if ( !isset($_REQUEST['order']) ) |
|
98 | - $_GET['order'] = $_REQUEST['order'] = 'DESC'; |
|
95 | + if ( !isset($_REQUEST['orderby']) ) { |
|
96 | + $_GET['orderby'] = $_REQUEST['orderby'] = ''; |
|
97 | + } |
|
98 | + if ( !isset($_REQUEST['order']) ) { |
|
99 | + $_GET['order'] = $_REQUEST['order'] = 'DESC'; |
|
100 | + } |
|
99 | 101 | } |
100 | 102 | |
101 | 103 | $query = "SELECT * FROM {$wpdb->blogs} WHERE site_id = '{$wpdb->siteid}' "; |
@@ -110,8 +112,9 @@ discard block |
||
110 | 112 | $sql = $wpdb->prepare( "SELECT blog_id FROM {$wpdb->registration_log} WHERE {$wpdb->registration_log}.IP LIKE %s", $wpdb->esc_like( $s ) . $wild ); |
111 | 113 | $reg_blog_ids = $wpdb->get_col( $sql ); |
112 | 114 | |
113 | - if ( !$reg_blog_ids ) |
|
114 | - $reg_blog_ids = array( 0 ); |
|
115 | + if ( !$reg_blog_ids ) { |
|
116 | + $reg_blog_ids = array( 0 ); |
|
117 | + } |
|
115 | 118 | |
116 | 119 | $query = "SELECT * |
117 | 120 | FROM {$wpdb->blogs} |
@@ -157,14 +160,16 @@ discard block |
||
157 | 160 | } |
158 | 161 | |
159 | 162 | // Don't do an unbounded count on large networks |
160 | - if ( ! wp_is_large_network() ) |
|
161 | - $total = $wpdb->get_var( str_replace( 'SELECT *', 'SELECT COUNT( blog_id )', $query ) ); |
|
163 | + if ( ! wp_is_large_network() ) { |
|
164 | + $total = $wpdb->get_var( str_replace( 'SELECT *', 'SELECT COUNT( blog_id )', $query ) ); |
|
165 | + } |
|
162 | 166 | |
163 | 167 | $query .= " LIMIT " . intval( ( $pagenum - 1 ) * $per_page ) . ", " . intval( $per_page ); |
164 | 168 | $this->items = $wpdb->get_results( $query, ARRAY_A ); |
165 | 169 | |
166 | - if ( wp_is_large_network() ) |
|
167 | - $total = count($this->items); |
|
170 | + if ( wp_is_large_network() ) { |
|
171 | + $total = count($this->items); |
|
172 | + } |
|
168 | 173 | |
169 | 174 | $this->set_pagination_args( array( |
170 | 175 | 'total_items' => $total, |
@@ -185,8 +190,9 @@ discard block |
||
185 | 190 | */ |
186 | 191 | protected function get_bulk_actions() { |
187 | 192 | $actions = array(); |
188 | - if ( current_user_can( 'delete_sites' ) ) |
|
189 | - $actions['delete'] = __( 'Delete' ); |
|
193 | + if ( current_user_can( 'delete_sites' ) ) { |
|
194 | + $actions['delete'] = __( 'Delete' ); |
|
195 | + } |
|
190 | 196 | $actions['spam'] = _x( 'Mark as Spam', 'site' ); |
191 | 197 | $actions['notspam'] = _x( 'Not Spam', 'site' ); |
192 | 198 | |
@@ -203,8 +209,9 @@ discard block |
||
203 | 209 | |
204 | 210 | parent::pagination( $which ); |
205 | 211 | |
206 | - if ( 'top' === $which ) |
|
207 | - $this->view_switcher( $mode ); |
|
212 | + if ( 'top' === $which ) { |
|
213 | + $this->view_switcher( $mode ); |
|
214 | + } |
|
208 | 215 | } |
209 | 216 | |
210 | 217 | /** |
@@ -1,11 +1,11 @@ |
||
1 | 1 | <?php |
2 | 2 | /** |
3 | - * WordPress Options Administration API. |
|
4 | - * |
|
5 | - * @package WordPress |
|
6 | - * @subpackage Administration |
|
7 | - * @since 4.4.0 |
|
8 | - */ |
|
3 | + * WordPress Options Administration API. |
|
4 | + * |
|
5 | + * @package WordPress |
|
6 | + * @subpackage Administration |
|
7 | + * @since 4.4.0 |
|
8 | + */ |
|
9 | 9 | |
10 | 10 | /** |
11 | 11 | * Output JavaScript to toggle display of additional settings if avatars are disabled. |
@@ -36,7 +36,7 @@ discard block |
||
36 | 36 | <script type="text/javascript"> |
37 | 37 | jQuery(document).ready(function($){ |
38 | 38 | var $siteName = $( '#wp-admin-bar-site-name' ).children( 'a' ).first(), |
39 | - homeURL = ( <?php echo wp_json_encode( get_home_url() ); ?> || '' ).replace( /^(https?:\/\/)?(www\.)?/, '' ); |
|
39 | + homeURL = ( <?php echo wp_json_encode(get_home_url()); ?> || '' ).replace( /^(https?:\/\/)?(www\.)?/, '' ); |
|
40 | 40 | |
41 | 41 | $( '#blogname' ).on( 'input', function() { |
42 | 42 | var title = $.trim( $( this ).val() ) || homeURL; |
@@ -136,6 +136,6 @@ discard block |
||
136 | 136 | * @since 3.5.0 |
137 | 137 | */ |
138 | 138 | function options_reading_blog_charset() { |
139 | - echo '<input name="blog_charset" type="text" id="blog_charset" value="' . esc_attr( get_option( 'blog_charset' ) ) . '" class="regular-text" />'; |
|
140 | - echo '<p class="description">' . __( 'The <a href="https://codex.wordpress.org/Glossary#Character_set">character encoding</a> of your site (UTF-8 is recommended)' ) . '</p>'; |
|
139 | + echo '<input name="blog_charset" type="text" id="blog_charset" value="'.esc_attr(get_option('blog_charset')).'" class="regular-text" />'; |
|
140 | + echo '<p class="description">'.__('The <a href="https://codex.wordpress.org/Glossary#Character_set">character encoding</a> of your site (UTF-8 is recommended)').'</p>'; |
|
141 | 141 | } |
@@ -11,32 +11,32 @@ discard block |
||
11 | 11 | // 0 = unused. Messages start at index 1. |
12 | 12 | $messages['_item'] = array( |
13 | 13 | 0 => '', |
14 | - 1 => __( 'Item added.' ), |
|
15 | - 2 => __( 'Item deleted.' ), |
|
16 | - 3 => __( 'Item updated.' ), |
|
17 | - 4 => __( 'Item not added.' ), |
|
18 | - 5 => __( 'Item not updated.' ), |
|
19 | - 6 => __( 'Items deleted.' ), |
|
14 | + 1 => __('Item added.'), |
|
15 | + 2 => __('Item deleted.'), |
|
16 | + 3 => __('Item updated.'), |
|
17 | + 4 => __('Item not added.'), |
|
18 | + 5 => __('Item not updated.'), |
|
19 | + 6 => __('Items deleted.'), |
|
20 | 20 | ); |
21 | 21 | |
22 | 22 | $messages['category'] = array( |
23 | 23 | 0 => '', |
24 | - 1 => __( 'Category added.' ), |
|
25 | - 2 => __( 'Category deleted.' ), |
|
26 | - 3 => __( 'Category updated.' ), |
|
27 | - 4 => __( 'Category not added.' ), |
|
28 | - 5 => __( 'Category not updated.' ), |
|
29 | - 6 => __( 'Categories deleted.' ), |
|
24 | + 1 => __('Category added.'), |
|
25 | + 2 => __('Category deleted.'), |
|
26 | + 3 => __('Category updated.'), |
|
27 | + 4 => __('Category not added.'), |
|
28 | + 5 => __('Category not updated.'), |
|
29 | + 6 => __('Categories deleted.'), |
|
30 | 30 | ); |
31 | 31 | |
32 | 32 | $messages['post_tag'] = array( |
33 | 33 | 0 => '', |
34 | - 1 => __( 'Tag added.' ), |
|
35 | - 2 => __( 'Tag deleted.' ), |
|
36 | - 3 => __( 'Tag updated.' ), |
|
37 | - 4 => __( 'Tag not added.' ), |
|
38 | - 5 => __( 'Tag not updated.' ), |
|
39 | - 6 => __( 'Tags deleted.' ), |
|
34 | + 1 => __('Tag added.'), |
|
35 | + 2 => __('Tag deleted.'), |
|
36 | + 3 => __('Tag updated.'), |
|
37 | + 4 => __('Tag not added.'), |
|
38 | + 5 => __('Tag not updated.'), |
|
39 | + 6 => __('Tags deleted.'), |
|
40 | 40 | ); |
41 | 41 | |
42 | 42 | /** |
@@ -46,13 +46,13 @@ discard block |
||
46 | 46 | * |
47 | 47 | * @param array $messages The messages to be displayed. |
48 | 48 | */ |
49 | -$messages = apply_filters( 'term_updated_messages', $messages ); |
|
49 | +$messages = apply_filters('term_updated_messages', $messages); |
|
50 | 50 | |
51 | 51 | $message = false; |
52 | -if ( isset( $_REQUEST['message'] ) && ( $msg = (int) $_REQUEST['message'] ) ) { |
|
53 | - if ( isset( $messages[ $taxonomy ][ $msg ] ) ) { |
|
54 | - $message = $messages[ $taxonomy ][ $msg ]; |
|
55 | - } elseif ( ! isset( $messages[ $taxonomy ] ) && isset( $messages['_item'][ $msg ] ) ) { |
|
56 | - $message = $messages['_item'][ $msg ]; |
|
52 | +if (isset($_REQUEST['message']) && ($msg = (int) $_REQUEST['message'])) { |
|
53 | + if (isset($messages[$taxonomy][$msg])) { |
|
54 | + $message = $messages[$taxonomy][$msg]; |
|
55 | + } elseif ( ! isset($messages[$taxonomy]) && isset($messages['_item'][$msg])) { |
|
56 | + $message = $messages['_item'][$msg]; |
|
57 | 57 | } |
58 | 58 | } |
59 | 59 | \ No newline at end of file |
@@ -1,11 +1,11 @@ |
||
1 | 1 | <?php |
2 | 2 | /** |
3 | - * List Table API: WP_Terms_List_Table class |
|
4 | - * |
|
5 | - * @package WordPress |
|
6 | - * @subpackage Administration |
|
7 | - * @since 3.1.0 |
|
8 | - */ |
|
3 | + * List Table API: WP_Terms_List_Table class |
|
4 | + * |
|
5 | + * @package WordPress |
|
6 | + * @subpackage Administration |
|
7 | + * @since 3.1.0 |
|
8 | + */ |
|
9 | 9 | |
10 | 10 | /** |
11 | 11 | * Core class used to implement displaying terms in a list table. |
@@ -36,29 +36,29 @@ discard block |
||
36 | 36 | * |
37 | 37 | * @param array $args An associative array of arguments. |
38 | 38 | */ |
39 | - public function __construct( $args = array() ) { |
|
39 | + public function __construct($args = array()) { |
|
40 | 40 | global $post_type, $taxonomy, $action, $tax; |
41 | 41 | |
42 | - parent::__construct( array( |
|
42 | + parent::__construct(array( |
|
43 | 43 | 'plural' => 'tags', |
44 | 44 | 'singular' => 'tag', |
45 | - 'screen' => isset( $args['screen'] ) ? $args['screen'] : null, |
|
46 | - ) ); |
|
45 | + 'screen' => isset($args['screen']) ? $args['screen'] : null, |
|
46 | + )); |
|
47 | 47 | |
48 | 48 | $action = $this->screen->action; |
49 | 49 | $post_type = $this->screen->post_type; |
50 | 50 | $taxonomy = $this->screen->taxonomy; |
51 | 51 | |
52 | - if ( empty( $taxonomy ) ) |
|
52 | + if (empty($taxonomy)) |
|
53 | 53 | $taxonomy = 'post_tag'; |
54 | 54 | |
55 | - if ( ! taxonomy_exists( $taxonomy ) ) |
|
56 | - wp_die( __( 'Invalid taxonomy' ) ); |
|
55 | + if ( ! taxonomy_exists($taxonomy)) |
|
56 | + wp_die(__('Invalid taxonomy')); |
|
57 | 57 | |
58 | - $tax = get_taxonomy( $taxonomy ); |
|
58 | + $tax = get_taxonomy($taxonomy); |
|
59 | 59 | |
60 | 60 | // @todo Still needed? Maybe just the show_ui part. |
61 | - if ( empty( $post_type ) || !in_array( $post_type, get_post_types( array( 'show_ui' => true ) ) ) ) |
|
61 | + if (empty($post_type) || ! in_array($post_type, get_post_types(array('show_ui' => true)))) |
|
62 | 62 | $post_type = 'post'; |
63 | 63 | |
64 | 64 | } |
@@ -68,16 +68,16 @@ discard block |
||
68 | 68 | * @return bool |
69 | 69 | */ |
70 | 70 | public function ajax_user_can() { |
71 | - return current_user_can( get_taxonomy( $this->screen->taxonomy )->cap->manage_terms ); |
|
71 | + return current_user_can(get_taxonomy($this->screen->taxonomy)->cap->manage_terms); |
|
72 | 72 | } |
73 | 73 | |
74 | 74 | /** |
75 | 75 | * @access public |
76 | 76 | */ |
77 | 77 | public function prepare_items() { |
78 | - $tags_per_page = $this->get_items_per_page( 'edit_' . $this->screen->taxonomy . '_per_page' ); |
|
78 | + $tags_per_page = $this->get_items_per_page('edit_'.$this->screen->taxonomy.'_per_page'); |
|
79 | 79 | |
80 | - if ( 'post_tag' === $this->screen->taxonomy ) { |
|
80 | + if ('post_tag' === $this->screen->taxonomy) { |
|
81 | 81 | /** |
82 | 82 | * Filter the number of terms displayed per page for the Tags list table. |
83 | 83 | * |
@@ -85,7 +85,7 @@ discard block |
||
85 | 85 | * |
86 | 86 | * @param int $tags_per_page Number of tags to be displayed. Default 20. |
87 | 87 | */ |
88 | - $tags_per_page = apply_filters( 'edit_tags_per_page', $tags_per_page ); |
|
88 | + $tags_per_page = apply_filters('edit_tags_per_page', $tags_per_page); |
|
89 | 89 | |
90 | 90 | /** |
91 | 91 | * Filter the number of terms displayed per page for the Tags list table. |
@@ -95,8 +95,8 @@ discard block |
||
95 | 95 | * |
96 | 96 | * @param int $tags_per_page Number of tags to be displayed. Default 20. |
97 | 97 | */ |
98 | - $tags_per_page = apply_filters( 'tagsperpage', $tags_per_page ); |
|
99 | - } elseif ( 'category' === $this->screen->taxonomy ) { |
|
98 | + $tags_per_page = apply_filters('tagsperpage', $tags_per_page); |
|
99 | + } elseif ('category' === $this->screen->taxonomy) { |
|
100 | 100 | /** |
101 | 101 | * Filter the number of terms displayed per page for the Categories list table. |
102 | 102 | * |
@@ -104,10 +104,10 @@ discard block |
||
104 | 104 | * |
105 | 105 | * @param int $tags_per_page Number of categories to be displayed. Default 20. |
106 | 106 | */ |
107 | - $tags_per_page = apply_filters( 'edit_categories_per_page', $tags_per_page ); |
|
107 | + $tags_per_page = apply_filters('edit_categories_per_page', $tags_per_page); |
|
108 | 108 | } |
109 | 109 | |
110 | - $search = !empty( $_REQUEST['s'] ) ? trim( wp_unslash( $_REQUEST['s'] ) ) : ''; |
|
110 | + $search = ! empty($_REQUEST['s']) ? trim(wp_unslash($_REQUEST['s'])) : ''; |
|
111 | 111 | |
112 | 112 | $args = array( |
113 | 113 | 'search' => $search, |
@@ -115,18 +115,18 @@ discard block |
||
115 | 115 | 'number' => $tags_per_page, |
116 | 116 | ); |
117 | 117 | |
118 | - if ( !empty( $_REQUEST['orderby'] ) ) |
|
119 | - $args['orderby'] = trim( wp_unslash( $_REQUEST['orderby'] ) ); |
|
118 | + if ( ! empty($_REQUEST['orderby'])) |
|
119 | + $args['orderby'] = trim(wp_unslash($_REQUEST['orderby'])); |
|
120 | 120 | |
121 | - if ( !empty( $_REQUEST['order'] ) ) |
|
122 | - $args['order'] = trim( wp_unslash( $_REQUEST['order'] ) ); |
|
121 | + if ( ! empty($_REQUEST['order'])) |
|
122 | + $args['order'] = trim(wp_unslash($_REQUEST['order'])); |
|
123 | 123 | |
124 | 124 | $this->callback_args = $args; |
125 | 125 | |
126 | - $this->set_pagination_args( array( |
|
127 | - 'total_items' => wp_count_terms( $this->screen->taxonomy, compact( 'search' ) ), |
|
126 | + $this->set_pagination_args(array( |
|
127 | + 'total_items' => wp_count_terms($this->screen->taxonomy, compact('search')), |
|
128 | 128 | 'per_page' => $tags_per_page, |
129 | - ) ); |
|
129 | + )); |
|
130 | 130 | } |
131 | 131 | |
132 | 132 | /** |
@@ -142,7 +142,7 @@ discard block |
||
142 | 142 | * @access public |
143 | 143 | */ |
144 | 144 | public function no_items() { |
145 | - echo get_taxonomy( $this->screen->taxonomy )->labels->not_found; |
|
145 | + echo get_taxonomy($this->screen->taxonomy)->labels->not_found; |
|
146 | 146 | } |
147 | 147 | |
148 | 148 | /** |
@@ -151,7 +151,7 @@ discard block |
||
151 | 151 | */ |
152 | 152 | protected function get_bulk_actions() { |
153 | 153 | $actions = array(); |
154 | - $actions['delete'] = __( 'Delete' ); |
|
154 | + $actions['delete'] = __('Delete'); |
|
155 | 155 | |
156 | 156 | return $actions; |
157 | 157 | } |
@@ -161,7 +161,7 @@ discard block |
||
161 | 161 | * @return string |
162 | 162 | */ |
163 | 163 | public function current_action() { |
164 | - if ( isset( $_REQUEST['action'] ) && isset( $_REQUEST['delete_tags'] ) && ( 'delete' === $_REQUEST['action'] || 'delete' === $_REQUEST['action2'] ) ) |
|
164 | + if (isset($_REQUEST['action']) && isset($_REQUEST['delete_tags']) && ('delete' === $_REQUEST['action'] || 'delete' === $_REQUEST['action2'])) |
|
165 | 165 | return 'bulk-delete'; |
166 | 166 | |
167 | 167 | return parent::current_action(); |
@@ -174,15 +174,15 @@ discard block |
||
174 | 174 | public function get_columns() { |
175 | 175 | $columns = array( |
176 | 176 | 'cb' => '<input type="checkbox" />', |
177 | - 'name' => _x( 'Name', 'term name' ), |
|
178 | - 'description' => __( 'Description' ), |
|
179 | - 'slug' => __( 'Slug' ), |
|
177 | + 'name' => _x('Name', 'term name'), |
|
178 | + 'description' => __('Description'), |
|
179 | + 'slug' => __('Slug'), |
|
180 | 180 | ); |
181 | 181 | |
182 | - if ( 'link_category' === $this->screen->taxonomy ) { |
|
183 | - $columns['links'] = __( 'Links' ); |
|
182 | + if ('link_category' === $this->screen->taxonomy) { |
|
183 | + $columns['links'] = __('Links'); |
|
184 | 184 | } else { |
185 | - $columns['posts'] = _x( 'Count', 'Number/count of items' ); |
|
185 | + $columns['posts'] = _x('Count', 'Number/count of items'); |
|
186 | 186 | } |
187 | 187 | |
188 | 188 | return $columns; |
@@ -208,47 +208,47 @@ discard block |
||
208 | 208 | public function display_rows_or_placeholder() { |
209 | 209 | $taxonomy = $this->screen->taxonomy; |
210 | 210 | |
211 | - $args = wp_parse_args( $this->callback_args, array( |
|
211 | + $args = wp_parse_args($this->callback_args, array( |
|
212 | 212 | 'page' => 1, |
213 | 213 | 'number' => 20, |
214 | 214 | 'search' => '', |
215 | 215 | 'hide_empty' => 0 |
216 | - ) ); |
|
216 | + )); |
|
217 | 217 | |
218 | 218 | $page = $args['page']; |
219 | 219 | |
220 | 220 | // Set variable because $args['number'] can be subsequently overridden. |
221 | 221 | $number = $args['number']; |
222 | 222 | |
223 | - $args['offset'] = $offset = ( $page - 1 ) * $number; |
|
223 | + $args['offset'] = $offset = ($page - 1) * $number; |
|
224 | 224 | |
225 | 225 | // Convert it to table rows. |
226 | 226 | $count = 0; |
227 | 227 | |
228 | - if ( is_taxonomy_hierarchical( $taxonomy ) && ! isset( $args['orderby'] ) ) { |
|
228 | + if (is_taxonomy_hierarchical($taxonomy) && ! isset($args['orderby'])) { |
|
229 | 229 | // We'll need the full set of terms then. |
230 | 230 | $args['number'] = $args['offset'] = 0; |
231 | 231 | } |
232 | - $terms = get_terms( $taxonomy, $args ); |
|
232 | + $terms = get_terms($taxonomy, $args); |
|
233 | 233 | |
234 | - if ( empty( $terms ) || ! is_array( $terms ) ) { |
|
235 | - echo '<tr class="no-items"><td class="colspanchange" colspan="' . $this->get_column_count() . '">'; |
|
234 | + if (empty($terms) || ! is_array($terms)) { |
|
235 | + echo '<tr class="no-items"><td class="colspanchange" colspan="'.$this->get_column_count().'">'; |
|
236 | 236 | $this->no_items(); |
237 | 237 | echo '</td></tr>'; |
238 | 238 | return; |
239 | 239 | } |
240 | 240 | |
241 | - if ( is_taxonomy_hierarchical( $taxonomy ) && ! isset( $args['orderby'] ) ) { |
|
242 | - if ( ! empty( $args['search'] ) ) {// Ignore children on searches. |
|
241 | + if (is_taxonomy_hierarchical($taxonomy) && ! isset($args['orderby'])) { |
|
242 | + if ( ! empty($args['search'])) {// Ignore children on searches. |
|
243 | 243 | $children = array(); |
244 | 244 | } else { |
245 | - $children = _get_term_hierarchy( $taxonomy ); |
|
245 | + $children = _get_term_hierarchy($taxonomy); |
|
246 | 246 | } |
247 | 247 | // Some funky recursion to get the job done( Paging & parents mainly ) is contained within, Skip it for non-hierarchical taxonomies for performance sake |
248 | - $this->_rows( $taxonomy, $terms, $children, $offset, $number, $count ); |
|
248 | + $this->_rows($taxonomy, $terms, $children, $offset, $number, $count); |
|
249 | 249 | } else { |
250 | - foreach ( $terms as $term ) { |
|
251 | - $this->single_row( $term ); |
|
250 | + foreach ($terms as $term) { |
|
251 | + $this->single_row($term); |
|
252 | 252 | } |
253 | 253 | } |
254 | 254 | } |
@@ -263,51 +263,51 @@ discard block |
||
263 | 263 | * @param int $parent |
264 | 264 | * @param int $level |
265 | 265 | */ |
266 | - private function _rows( $taxonomy, $terms, &$children, $start, $per_page, &$count, $parent = 0, $level = 0 ) { |
|
266 | + private function _rows($taxonomy, $terms, &$children, $start, $per_page, &$count, $parent = 0, $level = 0) { |
|
267 | 267 | |
268 | 268 | $end = $start + $per_page; |
269 | 269 | |
270 | - foreach ( $terms as $key => $term ) { |
|
270 | + foreach ($terms as $key => $term) { |
|
271 | 271 | |
272 | - if ( $count >= $end ) |
|
272 | + if ($count >= $end) |
|
273 | 273 | break; |
274 | 274 | |
275 | - if ( $term->parent != $parent && empty( $_REQUEST['s'] ) ) |
|
275 | + if ($term->parent != $parent && empty($_REQUEST['s'])) |
|
276 | 276 | continue; |
277 | 277 | |
278 | 278 | // If the page starts in a subtree, print the parents. |
279 | - if ( $count == $start && $term->parent > 0 && empty( $_REQUEST['s'] ) ) { |
|
279 | + if ($count == $start && $term->parent > 0 && empty($_REQUEST['s'])) { |
|
280 | 280 | $my_parents = $parent_ids = array(); |
281 | 281 | $p = $term->parent; |
282 | - while ( $p ) { |
|
283 | - $my_parent = get_term( $p, $taxonomy ); |
|
282 | + while ($p) { |
|
283 | + $my_parent = get_term($p, $taxonomy); |
|
284 | 284 | $my_parents[] = $my_parent; |
285 | 285 | $p = $my_parent->parent; |
286 | - if ( in_array( $p, $parent_ids ) ) // Prevent parent loops. |
|
286 | + if (in_array($p, $parent_ids)) // Prevent parent loops. |
|
287 | 287 | break; |
288 | 288 | $parent_ids[] = $p; |
289 | 289 | } |
290 | - unset( $parent_ids ); |
|
290 | + unset($parent_ids); |
|
291 | 291 | |
292 | - $num_parents = count( $my_parents ); |
|
293 | - while ( $my_parent = array_pop( $my_parents ) ) { |
|
292 | + $num_parents = count($my_parents); |
|
293 | + while ($my_parent = array_pop($my_parents)) { |
|
294 | 294 | echo "\t"; |
295 | - $this->single_row( $my_parent, $level - $num_parents ); |
|
295 | + $this->single_row($my_parent, $level - $num_parents); |
|
296 | 296 | $num_parents--; |
297 | 297 | } |
298 | 298 | } |
299 | 299 | |
300 | - if ( $count >= $start ) { |
|
300 | + if ($count >= $start) { |
|
301 | 301 | echo "\t"; |
302 | - $this->single_row( $term, $level ); |
|
302 | + $this->single_row($term, $level); |
|
303 | 303 | } |
304 | 304 | |
305 | 305 | ++$count; |
306 | 306 | |
307 | - unset( $terms[$key] ); |
|
307 | + unset($terms[$key]); |
|
308 | 308 | |
309 | - if ( isset( $children[$term->term_id] ) && empty( $_REQUEST['s'] ) ) |
|
310 | - $this->_rows( $taxonomy, $terms, $children, $start, $per_page, $count, $term->term_id, $level + 1 ); |
|
309 | + if (isset($children[$term->term_id]) && empty($_REQUEST['s'])) |
|
310 | + $this->_rows($taxonomy, $terms, $children, $start, $per_page, $count, $term->term_id, $level + 1); |
|
311 | 311 | } |
312 | 312 | } |
313 | 313 | |
@@ -316,14 +316,14 @@ discard block |
||
316 | 316 | * @param object $tag |
317 | 317 | * @param int $level |
318 | 318 | */ |
319 | - public function single_row( $tag, $level = 0 ) { |
|
319 | + public function single_row($tag, $level = 0) { |
|
320 | 320 | global $taxonomy; |
321 | - $tag = sanitize_term( $tag, $taxonomy ); |
|
321 | + $tag = sanitize_term($tag, $taxonomy); |
|
322 | 322 | |
323 | 323 | $this->level = $level; |
324 | 324 | |
325 | - echo '<tr id="tag-' . $tag->term_id . '">'; |
|
326 | - $this->single_row_columns( $tag ); |
|
325 | + echo '<tr id="tag-'.$tag->term_id.'">'; |
|
326 | + $this->single_row_columns($tag); |
|
327 | 327 | echo '</tr>'; |
328 | 328 | } |
329 | 329 | |
@@ -331,12 +331,12 @@ discard block |
||
331 | 331 | * @param object $tag |
332 | 332 | * @return string |
333 | 333 | */ |
334 | - public function column_cb( $tag ) { |
|
335 | - $default_term = get_option( 'default_' . $this->screen->taxonomy ); |
|
334 | + public function column_cb($tag) { |
|
335 | + $default_term = get_option('default_'.$this->screen->taxonomy); |
|
336 | 336 | |
337 | - if ( current_user_can( get_taxonomy( $this->screen->taxonomy )->cap->delete_terms ) && $tag->term_id != $default_term ) |
|
338 | - return '<label class="screen-reader-text" for="cb-select-' . $tag->term_id . '">' . sprintf( __( 'Select %s' ), $tag->name ) . '</label>' |
|
339 | - . '<input type="checkbox" name="delete_tags[]" value="' . $tag->term_id . '" id="cb-select-' . $tag->term_id . '" />'; |
|
337 | + if (current_user_can(get_taxonomy($this->screen->taxonomy)->cap->delete_terms) && $tag->term_id != $default_term) |
|
338 | + return '<label class="screen-reader-text" for="cb-select-'.$tag->term_id.'">'.sprintf(__('Select %s'), $tag->name).'</label>' |
|
339 | + . '<input type="checkbox" name="delete_tags[]" value="'.$tag->term_id.'" id="cb-select-'.$tag->term_id.'" />'; |
|
340 | 340 | |
341 | 341 | return ' '; |
342 | 342 | } |
@@ -345,10 +345,10 @@ discard block |
||
345 | 345 | * @param object $tag |
346 | 346 | * @return string |
347 | 347 | */ |
348 | - public function column_name( $tag ) { |
|
348 | + public function column_name($tag) { |
|
349 | 349 | $taxonomy = $this->screen->taxonomy; |
350 | 350 | |
351 | - $pad = str_repeat( '— ', max( 0, $this->level ) ); |
|
351 | + $pad = str_repeat('— ', max(0, $this->level)); |
|
352 | 352 | |
353 | 353 | /** |
354 | 354 | * Filter display of the term name in the terms list table. |
@@ -363,32 +363,32 @@ discard block |
||
363 | 363 | * @param string $pad_tag_name The term name, padded if not top-level. |
364 | 364 | * @param object $tag Term object. |
365 | 365 | */ |
366 | - $name = apply_filters( 'term_name', $pad . ' ' . $tag->name, $tag ); |
|
366 | + $name = apply_filters('term_name', $pad.' '.$tag->name, $tag); |
|
367 | 367 | |
368 | - $qe_data = get_term( $tag->term_id, $taxonomy, OBJECT, 'edit' ); |
|
368 | + $qe_data = get_term($tag->term_id, $taxonomy, OBJECT, 'edit'); |
|
369 | 369 | |
370 | - $uri = ( defined( 'DOING_AJAX' ) && DOING_AJAX ) ? wp_get_referer() : $_SERVER['REQUEST_URI']; |
|
370 | + $uri = (defined('DOING_AJAX') && DOING_AJAX) ? wp_get_referer() : $_SERVER['REQUEST_URI']; |
|
371 | 371 | |
372 | 372 | $edit_link = add_query_arg( |
373 | 373 | 'wp_http_referer', |
374 | - urlencode( wp_unslash( $uri ) ), |
|
375 | - get_edit_term_link( $tag->term_id, $taxonomy, $this->screen->post_type ) |
|
374 | + urlencode(wp_unslash($uri)), |
|
375 | + get_edit_term_link($tag->term_id, $taxonomy, $this->screen->post_type) |
|
376 | 376 | ); |
377 | 377 | |
378 | 378 | $out = sprintf( |
379 | 379 | '<strong><a class="row-title" href="%s" aria-label="%s">%s</a></strong><br />', |
380 | - esc_url( $edit_link ), |
|
380 | + esc_url($edit_link), |
|
381 | 381 | /* translators: %s: taxonomy term name */ |
382 | - esc_attr( sprintf( __( '“%s” (Edit)' ), $tag->name ) ), |
|
382 | + esc_attr(sprintf(__('“%s” (Edit)'), $tag->name)), |
|
383 | 383 | $name |
384 | 384 | ); |
385 | 385 | |
386 | - $out .= '<div class="hidden" id="inline_' . $qe_data->term_id . '">'; |
|
387 | - $out .= '<div class="name">' . $qe_data->name . '</div>'; |
|
386 | + $out .= '<div class="hidden" id="inline_'.$qe_data->term_id.'">'; |
|
387 | + $out .= '<div class="name">'.$qe_data->name.'</div>'; |
|
388 | 388 | |
389 | 389 | /** This filter is documented in wp-admin/edit-tag-form.php */ |
390 | - $out .= '<div class="slug">' . apply_filters( 'editable_slug', $qe_data->slug, $qe_data ) . '</div>'; |
|
391 | - $out .= '<div class="parent">' . $qe_data->parent . '</div></div>'; |
|
390 | + $out .= '<div class="slug">'.apply_filters('editable_slug', $qe_data->slug, $qe_data).'</div>'; |
|
391 | + $out .= '<div class="parent">'.$qe_data->parent.'</div></div>'; |
|
392 | 392 | |
393 | 393 | return $out; |
394 | 394 | } |
@@ -416,55 +416,55 @@ discard block |
||
416 | 416 | * @param string $primary Primary column name. |
417 | 417 | * @return string Row actions output for terms. |
418 | 418 | */ |
419 | - protected function handle_row_actions( $tag, $column_name, $primary ) { |
|
420 | - if ( $primary !== $column_name ) { |
|
419 | + protected function handle_row_actions($tag, $column_name, $primary) { |
|
420 | + if ($primary !== $column_name) { |
|
421 | 421 | return ''; |
422 | 422 | } |
423 | 423 | |
424 | 424 | $taxonomy = $this->screen->taxonomy; |
425 | - $tax = get_taxonomy( $taxonomy ); |
|
426 | - $default_term = get_option( 'default_' . $taxonomy ); |
|
425 | + $tax = get_taxonomy($taxonomy); |
|
426 | + $default_term = get_option('default_'.$taxonomy); |
|
427 | 427 | |
428 | - $uri = ( defined( 'DOING_AJAX' ) && DOING_AJAX ) ? wp_get_referer() : $_SERVER['REQUEST_URI']; |
|
428 | + $uri = (defined('DOING_AJAX') && DOING_AJAX) ? wp_get_referer() : $_SERVER['REQUEST_URI']; |
|
429 | 429 | |
430 | 430 | $edit_link = add_query_arg( |
431 | 431 | 'wp_http_referer', |
432 | - urlencode( wp_unslash( $uri ) ), |
|
433 | - get_edit_term_link( $tag->term_id, $taxonomy, $this->screen->post_type ) |
|
432 | + urlencode(wp_unslash($uri)), |
|
433 | + get_edit_term_link($tag->term_id, $taxonomy, $this->screen->post_type) |
|
434 | 434 | ); |
435 | 435 | |
436 | 436 | $actions = array(); |
437 | - if ( current_user_can( $tax->cap->edit_terms ) ) { |
|
437 | + if (current_user_can($tax->cap->edit_terms)) { |
|
438 | 438 | $actions['edit'] = sprintf( |
439 | 439 | '<a href="%s" aria-label="%s">%s</a>', |
440 | - esc_url( $edit_link ), |
|
440 | + esc_url($edit_link), |
|
441 | 441 | /* translators: %s: taxonomy term name */ |
442 | - esc_attr( sprintf( __( 'Edit “%s”' ), $tag->name ) ), |
|
443 | - __( 'Edit' ) |
|
442 | + esc_attr(sprintf(__('Edit “%s”'), $tag->name)), |
|
443 | + __('Edit') |
|
444 | 444 | ); |
445 | 445 | $actions['inline hide-if-no-js'] = sprintf( |
446 | 446 | '<a href="#" class="editinline aria-button-if-js" aria-label="%s">%s</a>', |
447 | 447 | /* translators: %s: taxonomy term name */ |
448 | - esc_attr( sprintf( __( 'Quick edit “%s” inline' ), $tag->name ) ), |
|
449 | - __( 'Quick Edit' ) |
|
448 | + esc_attr(sprintf(__('Quick edit “%s” inline'), $tag->name)), |
|
449 | + __('Quick Edit') |
|
450 | 450 | ); |
451 | 451 | } |
452 | - if ( current_user_can( $tax->cap->delete_terms ) && $tag->term_id != $default_term ) { |
|
452 | + if (current_user_can($tax->cap->delete_terms) && $tag->term_id != $default_term) { |
|
453 | 453 | $actions['delete'] = sprintf( |
454 | 454 | '<a href="%s" class="delete-tag aria-button-if-js" aria-label="%s">%s</a>', |
455 | - wp_nonce_url( "edit-tags.php?action=delete&taxonomy=$taxonomy&tag_ID=$tag->term_id", 'delete-tag_' . $tag->term_id ), |
|
455 | + wp_nonce_url("edit-tags.php?action=delete&taxonomy=$taxonomy&tag_ID=$tag->term_id", 'delete-tag_'.$tag->term_id), |
|
456 | 456 | /* translators: %s: taxonomy term name */ |
457 | - esc_attr( sprintf( __( 'Delete “%s”' ), $tag->name ) ), |
|
458 | - __( 'Delete' ) |
|
457 | + esc_attr(sprintf(__('Delete “%s”'), $tag->name)), |
|
458 | + __('Delete') |
|
459 | 459 | ); |
460 | 460 | } |
461 | - if ( $tax->public ) { |
|
461 | + if ($tax->public) { |
|
462 | 462 | $actions['view'] = sprintf( |
463 | 463 | '<a href="%s" aria-label="%s">%s</a>', |
464 | - get_term_link( $tag ), |
|
464 | + get_term_link($tag), |
|
465 | 465 | /* translators: %s: taxonomy term name */ |
466 | - esc_attr( sprintf( __( 'View “%s” archive' ), $tag->name ) ), |
|
467 | - __( 'View' ) |
|
466 | + esc_attr(sprintf(__('View “%s” archive'), $tag->name)), |
|
467 | + __('View') |
|
468 | 468 | ); |
469 | 469 | } |
470 | 470 | |
@@ -478,7 +478,7 @@ discard block |
||
478 | 478 | * 'Edit', 'Quick Edit', 'Delete', and 'View'. |
479 | 479 | * @param object $tag Term object. |
480 | 480 | */ |
481 | - $actions = apply_filters( 'tag_row_actions', $actions, $tag ); |
|
481 | + $actions = apply_filters('tag_row_actions', $actions, $tag); |
|
482 | 482 | |
483 | 483 | /** |
484 | 484 | * Filter the action links displayed for each term in the terms list table. |
@@ -491,16 +491,16 @@ discard block |
||
491 | 491 | * 'Edit', 'Quick Edit', 'Delete', and 'View'. |
492 | 492 | * @param object $tag Term object. |
493 | 493 | */ |
494 | - $actions = apply_filters( "{$taxonomy}_row_actions", $actions, $tag ); |
|
494 | + $actions = apply_filters("{$taxonomy}_row_actions", $actions, $tag); |
|
495 | 495 | |
496 | - return $this->row_actions( $actions ); |
|
496 | + return $this->row_actions($actions); |
|
497 | 497 | } |
498 | 498 | |
499 | 499 | /** |
500 | 500 | * @param object $tag |
501 | 501 | * @return string |
502 | 502 | */ |
503 | - public function column_description( $tag ) { |
|
503 | + public function column_description($tag) { |
|
504 | 504 | return $tag->description; |
505 | 505 | } |
506 | 506 | |
@@ -508,46 +508,46 @@ discard block |
||
508 | 508 | * @param object $tag |
509 | 509 | * @return string |
510 | 510 | */ |
511 | - public function column_slug( $tag ) { |
|
511 | + public function column_slug($tag) { |
|
512 | 512 | /** This filter is documented in wp-admin/edit-tag-form.php */ |
513 | - return apply_filters( 'editable_slug', $tag->slug, $tag ); |
|
513 | + return apply_filters('editable_slug', $tag->slug, $tag); |
|
514 | 514 | } |
515 | 515 | |
516 | 516 | /** |
517 | 517 | * @param object $tag |
518 | 518 | * @return string |
519 | 519 | */ |
520 | - public function column_posts( $tag ) { |
|
521 | - $count = number_format_i18n( $tag->count ); |
|
520 | + public function column_posts($tag) { |
|
521 | + $count = number_format_i18n($tag->count); |
|
522 | 522 | |
523 | - $tax = get_taxonomy( $this->screen->taxonomy ); |
|
523 | + $tax = get_taxonomy($this->screen->taxonomy); |
|
524 | 524 | |
525 | - $ptype_object = get_post_type_object( $this->screen->post_type ); |
|
526 | - if ( ! $ptype_object->show_ui ) |
|
525 | + $ptype_object = get_post_type_object($this->screen->post_type); |
|
526 | + if ( ! $ptype_object->show_ui) |
|
527 | 527 | return $count; |
528 | 528 | |
529 | - if ( $tax->query_var ) { |
|
530 | - $args = array( $tax->query_var => $tag->slug ); |
|
529 | + if ($tax->query_var) { |
|
530 | + $args = array($tax->query_var => $tag->slug); |
|
531 | 531 | } else { |
532 | - $args = array( 'taxonomy' => $tax->name, 'term' => $tag->slug ); |
|
532 | + $args = array('taxonomy' => $tax->name, 'term' => $tag->slug); |
|
533 | 533 | } |
534 | 534 | |
535 | - if ( 'post' != $this->screen->post_type ) |
|
535 | + if ('post' != $this->screen->post_type) |
|
536 | 536 | $args['post_type'] = $this->screen->post_type; |
537 | 537 | |
538 | - if ( 'attachment' === $this->screen->post_type ) |
|
539 | - return "<a href='" . esc_url ( add_query_arg( $args, 'upload.php' ) ) . "'>$count</a>"; |
|
538 | + if ('attachment' === $this->screen->post_type) |
|
539 | + return "<a href='".esc_url(add_query_arg($args, 'upload.php'))."'>$count</a>"; |
|
540 | 540 | |
541 | - return "<a href='" . esc_url ( add_query_arg( $args, 'edit.php' ) ) . "'>$count</a>"; |
|
541 | + return "<a href='".esc_url(add_query_arg($args, 'edit.php'))."'>$count</a>"; |
|
542 | 542 | } |
543 | 543 | |
544 | 544 | /** |
545 | 545 | * @param object $tag |
546 | 546 | * @return string |
547 | 547 | */ |
548 | - public function column_links( $tag ) { |
|
549 | - $count = number_format_i18n( $tag->count ); |
|
550 | - if ( $count ) |
|
548 | + public function column_links($tag) { |
|
549 | + $count = number_format_i18n($tag->count); |
|
550 | + if ($count) |
|
551 | 551 | $count = "<a href='link-manager.php?cat_id=$tag->term_id'>$count</a>"; |
552 | 552 | return $count; |
553 | 553 | } |
@@ -557,7 +557,7 @@ discard block |
||
557 | 557 | * @param string $column_name |
558 | 558 | * @return string |
559 | 559 | */ |
560 | - public function column_default( $tag, $column_name ) { |
|
560 | + public function column_default($tag, $column_name) { |
|
561 | 561 | /** |
562 | 562 | * Filter the displayed columns in the terms list table. |
563 | 563 | * |
@@ -570,7 +570,7 @@ discard block |
||
570 | 570 | * @param string $column_name Name of the column. |
571 | 571 | * @param int $term_id Term ID. |
572 | 572 | */ |
573 | - return apply_filters( "manage_{$this->screen->taxonomy}_custom_column", '', $column_name, $tag->term_id ); |
|
573 | + return apply_filters("manage_{$this->screen->taxonomy}_custom_column", '', $column_name, $tag->term_id); |
|
574 | 574 | } |
575 | 575 | |
576 | 576 | /** |
@@ -579,9 +579,9 @@ discard block |
||
579 | 579 | * @since 3.1.0 |
580 | 580 | */ |
581 | 581 | public function inline_edit() { |
582 | - $tax = get_taxonomy( $this->screen->taxonomy ); |
|
582 | + $tax = get_taxonomy($this->screen->taxonomy); |
|
583 | 583 | |
584 | - if ( ! current_user_can( $tax->cap->edit_terms ) ) |
|
584 | + if ( ! current_user_can($tax->cap->edit_terms)) |
|
585 | 585 | return; |
586 | 586 | ?> |
587 | 587 | |
@@ -589,43 +589,43 @@ discard block |
||
589 | 589 | <tr id="inline-edit" class="inline-edit-row" style="display: none"><td colspan="<?php echo $this->get_column_count(); ?>" class="colspanchange"> |
590 | 590 | |
591 | 591 | <fieldset> |
592 | - <legend class="inline-edit-legend"><?php _e( 'Quick Edit' ); ?></legend> |
|
592 | + <legend class="inline-edit-legend"><?php _e('Quick Edit'); ?></legend> |
|
593 | 593 | <div class="inline-edit-col"> |
594 | 594 | <label> |
595 | - <span class="title"><?php _ex( 'Name', 'term name' ); ?></span> |
|
595 | + <span class="title"><?php _ex('Name', 'term name'); ?></span> |
|
596 | 596 | <span class="input-text-wrap"><input type="text" name="name" class="ptitle" value="" /></span> |
597 | 597 | </label> |
598 | - <?php if ( !global_terms_enabled() ) { ?> |
|
598 | + <?php if ( ! global_terms_enabled()) { ?> |
|
599 | 599 | <label> |
600 | - <span class="title"><?php _e( 'Slug' ); ?></span> |
|
600 | + <span class="title"><?php _e('Slug'); ?></span> |
|
601 | 601 | <span class="input-text-wrap"><input type="text" name="slug" class="ptitle" value="" /></span> |
602 | 602 | </label> |
603 | 603 | <?php } ?> |
604 | 604 | </div></fieldset> |
605 | 605 | <?php |
606 | 606 | |
607 | - $core_columns = array( 'cb' => true, 'description' => true, 'name' => true, 'slug' => true, 'posts' => true ); |
|
607 | + $core_columns = array('cb' => true, 'description' => true, 'name' => true, 'slug' => true, 'posts' => true); |
|
608 | 608 | |
609 | - list( $columns ) = $this->get_column_info(); |
|
609 | + list($columns) = $this->get_column_info(); |
|
610 | 610 | |
611 | - foreach ( $columns as $column_name => $column_display_name ) { |
|
612 | - if ( isset( $core_columns[$column_name] ) ) |
|
611 | + foreach ($columns as $column_name => $column_display_name) { |
|
612 | + if (isset($core_columns[$column_name])) |
|
613 | 613 | continue; |
614 | 614 | |
615 | 615 | /** This action is documented in wp-admin/includes/class-wp-posts-list-table.php */ |
616 | - do_action( 'quick_edit_custom_box', $column_name, 'edit-tags', $this->screen->taxonomy ); |
|
616 | + do_action('quick_edit_custom_box', $column_name, 'edit-tags', $this->screen->taxonomy); |
|
617 | 617 | } |
618 | 618 | |
619 | 619 | ?> |
620 | 620 | |
621 | 621 | <p class="inline-edit-save submit"> |
622 | - <button type="button" class="cancel button-secondary alignleft"><?php _e( 'Cancel' ); ?></button> |
|
622 | + <button type="button" class="cancel button-secondary alignleft"><?php _e('Cancel'); ?></button> |
|
623 | 623 | <button type="button" class="save button-primary alignright"><?php echo $tax->labels->update_item; ?></button> |
624 | 624 | <span class="spinner"></span> |
625 | 625 | <span class="error" style="display:none;"></span> |
626 | - <?php wp_nonce_field( 'taxinlineeditnonce', '_inline_edit', false ); ?> |
|
627 | - <input type="hidden" name="taxonomy" value="<?php echo esc_attr( $this->screen->taxonomy ); ?>" /> |
|
628 | - <input type="hidden" name="post_type" value="<?php echo esc_attr( $this->screen->post_type ); ?>" /> |
|
626 | + <?php wp_nonce_field('taxinlineeditnonce', '_inline_edit', false); ?> |
|
627 | + <input type="hidden" name="taxonomy" value="<?php echo esc_attr($this->screen->taxonomy); ?>" /> |
|
628 | + <input type="hidden" name="post_type" value="<?php echo esc_attr($this->screen->post_type); ?>" /> |
|
629 | 629 | <br class="clear" /> |
630 | 630 | </p> |
631 | 631 | </td></tr> |
@@ -49,17 +49,20 @@ discard block |
||
49 | 49 | $post_type = $this->screen->post_type; |
50 | 50 | $taxonomy = $this->screen->taxonomy; |
51 | 51 | |
52 | - if ( empty( $taxonomy ) ) |
|
53 | - $taxonomy = 'post_tag'; |
|
52 | + if ( empty( $taxonomy ) ) { |
|
53 | + $taxonomy = 'post_tag'; |
|
54 | + } |
|
54 | 55 | |
55 | - if ( ! taxonomy_exists( $taxonomy ) ) |
|
56 | - wp_die( __( 'Invalid taxonomy' ) ); |
|
56 | + if ( ! taxonomy_exists( $taxonomy ) ) { |
|
57 | + wp_die( __( 'Invalid taxonomy' ) ); |
|
58 | + } |
|
57 | 59 | |
58 | 60 | $tax = get_taxonomy( $taxonomy ); |
59 | 61 | |
60 | 62 | // @todo Still needed? Maybe just the show_ui part. |
61 | - if ( empty( $post_type ) || !in_array( $post_type, get_post_types( array( 'show_ui' => true ) ) ) ) |
|
62 | - $post_type = 'post'; |
|
63 | + if ( empty( $post_type ) || !in_array( $post_type, get_post_types( array( 'show_ui' => true ) ) ) ) { |
|
64 | + $post_type = 'post'; |
|
65 | + } |
|
63 | 66 | |
64 | 67 | } |
65 | 68 | |
@@ -115,11 +118,13 @@ discard block |
||
115 | 118 | 'number' => $tags_per_page, |
116 | 119 | ); |
117 | 120 | |
118 | - if ( !empty( $_REQUEST['orderby'] ) ) |
|
119 | - $args['orderby'] = trim( wp_unslash( $_REQUEST['orderby'] ) ); |
|
121 | + if ( !empty( $_REQUEST['orderby'] ) ) { |
|
122 | + $args['orderby'] = trim( wp_unslash( $_REQUEST['orderby'] ) ); |
|
123 | + } |
|
120 | 124 | |
121 | - if ( !empty( $_REQUEST['order'] ) ) |
|
122 | - $args['order'] = trim( wp_unslash( $_REQUEST['order'] ) ); |
|
125 | + if ( !empty( $_REQUEST['order'] ) ) { |
|
126 | + $args['order'] = trim( wp_unslash( $_REQUEST['order'] ) ); |
|
127 | + } |
|
123 | 128 | |
124 | 129 | $this->callback_args = $args; |
125 | 130 | |
@@ -161,8 +166,9 @@ discard block |
||
161 | 166 | * @return string |
162 | 167 | */ |
163 | 168 | public function current_action() { |
164 | - if ( isset( $_REQUEST['action'] ) && isset( $_REQUEST['delete_tags'] ) && ( 'delete' === $_REQUEST['action'] || 'delete' === $_REQUEST['action2'] ) ) |
|
165 | - return 'bulk-delete'; |
|
169 | + if ( isset( $_REQUEST['action'] ) && isset( $_REQUEST['delete_tags'] ) && ( 'delete' === $_REQUEST['action'] || 'delete' === $_REQUEST['action2'] ) ) { |
|
170 | + return 'bulk-delete'; |
|
171 | + } |
|
166 | 172 | |
167 | 173 | return parent::current_action(); |
168 | 174 | } |
@@ -269,11 +275,13 @@ discard block |
||
269 | 275 | |
270 | 276 | foreach ( $terms as $key => $term ) { |
271 | 277 | |
272 | - if ( $count >= $end ) |
|
273 | - break; |
|
278 | + if ( $count >= $end ) { |
|
279 | + break; |
|
280 | + } |
|
274 | 281 | |
275 | - if ( $term->parent != $parent && empty( $_REQUEST['s'] ) ) |
|
276 | - continue; |
|
282 | + if ( $term->parent != $parent && empty( $_REQUEST['s'] ) ) { |
|
283 | + continue; |
|
284 | + } |
|
277 | 285 | |
278 | 286 | // If the page starts in a subtree, print the parents. |
279 | 287 | if ( $count == $start && $term->parent > 0 && empty( $_REQUEST['s'] ) ) { |
@@ -283,8 +291,10 @@ discard block |
||
283 | 291 | $my_parent = get_term( $p, $taxonomy ); |
284 | 292 | $my_parents[] = $my_parent; |
285 | 293 | $p = $my_parent->parent; |
286 | - if ( in_array( $p, $parent_ids ) ) // Prevent parent loops. |
|
294 | + if ( in_array( $p, $parent_ids ) ) { |
|
295 | + // Prevent parent loops. |
|
287 | 296 | break; |
297 | + } |
|
288 | 298 | $parent_ids[] = $p; |
289 | 299 | } |
290 | 300 | unset( $parent_ids ); |
@@ -306,8 +316,9 @@ discard block |
||
306 | 316 | |
307 | 317 | unset( $terms[$key] ); |
308 | 318 | |
309 | - if ( isset( $children[$term->term_id] ) && empty( $_REQUEST['s'] ) ) |
|
310 | - $this->_rows( $taxonomy, $terms, $children, $start, $per_page, $count, $term->term_id, $level + 1 ); |
|
319 | + if ( isset( $children[$term->term_id] ) && empty( $_REQUEST['s'] ) ) { |
|
320 | + $this->_rows( $taxonomy, $terms, $children, $start, $per_page, $count, $term->term_id, $level + 1 ); |
|
321 | + } |
|
311 | 322 | } |
312 | 323 | } |
313 | 324 | |
@@ -334,9 +345,10 @@ discard block |
||
334 | 345 | public function column_cb( $tag ) { |
335 | 346 | $default_term = get_option( 'default_' . $this->screen->taxonomy ); |
336 | 347 | |
337 | - if ( current_user_can( get_taxonomy( $this->screen->taxonomy )->cap->delete_terms ) && $tag->term_id != $default_term ) |
|
338 | - return '<label class="screen-reader-text" for="cb-select-' . $tag->term_id . '">' . sprintf( __( 'Select %s' ), $tag->name ) . '</label>' |
|
348 | + if ( current_user_can( get_taxonomy( $this->screen->taxonomy )->cap->delete_terms ) && $tag->term_id != $default_term ) { |
|
349 | + return '<label class="screen-reader-text" for="cb-select-' . $tag->term_id . '">' . sprintf( __( 'Select %s' ), $tag->name ) . '</label>' |
|
339 | 350 | . '<input type="checkbox" name="delete_tags[]" value="' . $tag->term_id . '" id="cb-select-' . $tag->term_id . '" />'; |
351 | + } |
|
340 | 352 | |
341 | 353 | return ' '; |
342 | 354 | } |
@@ -523,8 +535,9 @@ discard block |
||
523 | 535 | $tax = get_taxonomy( $this->screen->taxonomy ); |
524 | 536 | |
525 | 537 | $ptype_object = get_post_type_object( $this->screen->post_type ); |
526 | - if ( ! $ptype_object->show_ui ) |
|
527 | - return $count; |
|
538 | + if ( ! $ptype_object->show_ui ) { |
|
539 | + return $count; |
|
540 | + } |
|
528 | 541 | |
529 | 542 | if ( $tax->query_var ) { |
530 | 543 | $args = array( $tax->query_var => $tag->slug ); |
@@ -532,11 +545,13 @@ discard block |
||
532 | 545 | $args = array( 'taxonomy' => $tax->name, 'term' => $tag->slug ); |
533 | 546 | } |
534 | 547 | |
535 | - if ( 'post' != $this->screen->post_type ) |
|
536 | - $args['post_type'] = $this->screen->post_type; |
|
548 | + if ( 'post' != $this->screen->post_type ) { |
|
549 | + $args['post_type'] = $this->screen->post_type; |
|
550 | + } |
|
537 | 551 | |
538 | - if ( 'attachment' === $this->screen->post_type ) |
|
539 | - return "<a href='" . esc_url ( add_query_arg( $args, 'upload.php' ) ) . "'>$count</a>"; |
|
552 | + if ( 'attachment' === $this->screen->post_type ) { |
|
553 | + return "<a href='" . esc_url ( add_query_arg( $args, 'upload.php' ) ) . "'>$count</a>"; |
|
554 | + } |
|
540 | 555 | |
541 | 556 | return "<a href='" . esc_url ( add_query_arg( $args, 'edit.php' ) ) . "'>$count</a>"; |
542 | 557 | } |
@@ -547,8 +562,9 @@ discard block |
||
547 | 562 | */ |
548 | 563 | public function column_links( $tag ) { |
549 | 564 | $count = number_format_i18n( $tag->count ); |
550 | - if ( $count ) |
|
551 | - $count = "<a href='link-manager.php?cat_id=$tag->term_id'>$count</a>"; |
|
565 | + if ( $count ) { |
|
566 | + $count = "<a href='link-manager.php?cat_id=$tag->term_id'>$count</a>"; |
|
567 | + } |
|
552 | 568 | return $count; |
553 | 569 | } |
554 | 570 | |
@@ -581,9 +597,10 @@ discard block |
||
581 | 597 | public function inline_edit() { |
582 | 598 | $tax = get_taxonomy( $this->screen->taxonomy ); |
583 | 599 | |
584 | - if ( ! current_user_can( $tax->cap->edit_terms ) ) |
|
585 | - return; |
|
586 | -?> |
|
600 | + if ( ! current_user_can( $tax->cap->edit_terms ) ) { |
|
601 | + return; |
|
602 | + } |
|
603 | + ?> |
|
587 | 604 | |
588 | 605 | <form method="get"><table style="display: none"><tbody id="inlineedit"> |
589 | 606 | <tr id="inline-edit" class="inline-edit-row" style="display: none"><td colspan="<?php echo $this->get_column_count(); ?>" class="colspanchange"> |
@@ -609,8 +626,9 @@ discard block |
||
609 | 626 | list( $columns ) = $this->get_column_info(); |
610 | 627 | |
611 | 628 | foreach ( $columns as $column_name => $column_display_name ) { |
612 | - if ( isset( $core_columns[$column_name] ) ) |
|
613 | - continue; |
|
629 | + if ( isset( $core_columns[$column_name] ) ) { |
|
630 | + continue; |
|
631 | + } |
|
614 | 632 | |
615 | 633 | /** This action is documented in wp-admin/includes/class-wp-posts-list-table.php */ |
616 | 634 | do_action( 'quick_edit_custom_box', $column_name, 'edit-tags', $this->screen->taxonomy ); |
@@ -23,13 +23,13 @@ discard block |
||
23 | 23 | $response = array(); |
24 | 24 | |
25 | 25 | // screen_id is the same as $current_screen->id and the JS global 'pagenow'. |
26 | - if ( ! empty($_POST['screen_id']) ) |
|
26 | + if ( ! empty($_POST['screen_id'])) |
|
27 | 27 | $screen_id = sanitize_key($_POST['screen_id']); |
28 | 28 | else |
29 | 29 | $screen_id = 'front'; |
30 | 30 | |
31 | - if ( ! empty($_POST['data']) ) { |
|
32 | - $data = wp_unslash( (array) $_POST['data'] ); |
|
31 | + if ( ! empty($_POST['data'])) { |
|
32 | + $data = wp_unslash((array) $_POST['data']); |
|
33 | 33 | |
34 | 34 | /** |
35 | 35 | * Filter Heartbeat AJAX response in no-privilege environments. |
@@ -40,7 +40,7 @@ discard block |
||
40 | 40 | * @param array $data An array of data passed via $_POST. |
41 | 41 | * @param string $screen_id The screen id. |
42 | 42 | */ |
43 | - $response = apply_filters( 'heartbeat_nopriv_received', $response, $data, $screen_id ); |
|
43 | + $response = apply_filters('heartbeat_nopriv_received', $response, $data, $screen_id); |
|
44 | 44 | } |
45 | 45 | |
46 | 46 | /** |
@@ -51,7 +51,7 @@ discard block |
||
51 | 51 | * @param array|object $response The Heartbeat response object or array. |
52 | 52 | * @param string $screen_id The screen id. |
53 | 53 | */ |
54 | - $response = apply_filters( 'heartbeat_nopriv_send', $response, $screen_id ); |
|
54 | + $response = apply_filters('heartbeat_nopriv_send', $response, $screen_id); |
|
55 | 55 | |
56 | 56 | /** |
57 | 57 | * Fires when Heartbeat ticks in no-privilege environments. |
@@ -63,7 +63,7 @@ discard block |
||
63 | 63 | * @param array|object $response The no-priv Heartbeat response. |
64 | 64 | * @param string $screen_id The screen id. |
65 | 65 | */ |
66 | - do_action( 'heartbeat_nopriv_tick', $response, $screen_id ); |
|
66 | + do_action('heartbeat_nopriv_tick', $response, $screen_id); |
|
67 | 67 | |
68 | 68 | // Send the current time according to the server. |
69 | 69 | $response['server_time'] = time(); |
@@ -86,18 +86,18 @@ discard block |
||
86 | 86 | global $wp_list_table; |
87 | 87 | |
88 | 88 | $list_class = $_GET['list_args']['class']; |
89 | - check_ajax_referer( "fetch-list-$list_class", '_ajax_fetch_list_nonce' ); |
|
89 | + check_ajax_referer("fetch-list-$list_class", '_ajax_fetch_list_nonce'); |
|
90 | 90 | |
91 | - $wp_list_table = _get_list_table( $list_class, array( 'screen' => $_GET['list_args']['screen']['id'] ) ); |
|
92 | - if ( ! $wp_list_table ) |
|
93 | - wp_die( 0 ); |
|
91 | + $wp_list_table = _get_list_table($list_class, array('screen' => $_GET['list_args']['screen']['id'])); |
|
92 | + if ( ! $wp_list_table) |
|
93 | + wp_die(0); |
|
94 | 94 | |
95 | - if ( ! $wp_list_table->ajax_user_can() ) |
|
95 | + if ( ! $wp_list_table->ajax_user_can()) |
|
96 | 96 | wp_die( -1 ); |
97 | 97 | |
98 | 98 | $wp_list_table->ajax_response(); |
99 | 99 | |
100 | - wp_die( 0 ); |
|
100 | + wp_die(0); |
|
101 | 101 | } |
102 | 102 | |
103 | 103 | /** |
@@ -106,30 +106,30 @@ discard block |
||
106 | 106 | * @since 3.1.0 |
107 | 107 | */ |
108 | 108 | function wp_ajax_ajax_tag_search() { |
109 | - if ( ! isset( $_GET['tax'] ) ) { |
|
110 | - wp_die( 0 ); |
|
109 | + if ( ! isset($_GET['tax'])) { |
|
110 | + wp_die(0); |
|
111 | 111 | } |
112 | 112 | |
113 | - $taxonomy = sanitize_key( $_GET['tax'] ); |
|
114 | - $tax = get_taxonomy( $taxonomy ); |
|
115 | - if ( ! $tax ) { |
|
116 | - wp_die( 0 ); |
|
113 | + $taxonomy = sanitize_key($_GET['tax']); |
|
114 | + $tax = get_taxonomy($taxonomy); |
|
115 | + if ( ! $tax) { |
|
116 | + wp_die(0); |
|
117 | 117 | } |
118 | 118 | |
119 | - if ( ! current_user_can( $tax->cap->assign_terms ) ) { |
|
119 | + if ( ! current_user_can($tax->cap->assign_terms)) { |
|
120 | 120 | wp_die( -1 ); |
121 | 121 | } |
122 | 122 | |
123 | - $s = wp_unslash( $_GET['q'] ); |
|
123 | + $s = wp_unslash($_GET['q']); |
|
124 | 124 | |
125 | - $comma = _x( ',', 'tag delimiter' ); |
|
126 | - if ( ',' !== $comma ) |
|
127 | - $s = str_replace( $comma, ',', $s ); |
|
128 | - if ( false !== strpos( $s, ',' ) ) { |
|
129 | - $s = explode( ',', $s ); |
|
130 | - $s = $s[count( $s ) - 1]; |
|
125 | + $comma = _x(',', 'tag delimiter'); |
|
126 | + if (',' !== $comma) |
|
127 | + $s = str_replace($comma, ',', $s); |
|
128 | + if (false !== strpos($s, ',')) { |
|
129 | + $s = explode(',', $s); |
|
130 | + $s = $s[count($s) - 1]; |
|
131 | 131 | } |
132 | - $s = trim( $s ); |
|
132 | + $s = trim($s); |
|
133 | 133 | |
134 | 134 | /** |
135 | 135 | * Filter the minimum number of characters required to fire a tag search via AJAX. |
@@ -140,19 +140,19 @@ discard block |
||
140 | 140 | * @param object $tax The taxonomy object. |
141 | 141 | * @param string $s The search term. |
142 | 142 | */ |
143 | - $term_search_min_chars = (int) apply_filters( 'term_search_min_chars', 2, $tax, $s ); |
|
143 | + $term_search_min_chars = (int) apply_filters('term_search_min_chars', 2, $tax, $s); |
|
144 | 144 | |
145 | 145 | /* |
146 | 146 | * Require $term_search_min_chars chars for matching (default: 2) |
147 | 147 | * ensure it's a non-negative, non-zero integer. |
148 | 148 | */ |
149 | - if ( ( $term_search_min_chars == 0 ) || ( strlen( $s ) < $term_search_min_chars ) ){ |
|
149 | + if (($term_search_min_chars == 0) || (strlen($s) < $term_search_min_chars)) { |
|
150 | 150 | wp_die(); |
151 | 151 | } |
152 | 152 | |
153 | - $results = get_terms( $taxonomy, array( 'name__like' => $s, 'fields' => 'names', 'hide_empty' => false ) ); |
|
153 | + $results = get_terms($taxonomy, array('name__like' => $s, 'fields' => 'names', 'hide_empty' => false)); |
|
154 | 154 | |
155 | - echo join( $results, "\n" ); |
|
155 | + echo join($results, "\n"); |
|
156 | 156 | wp_die(); |
157 | 157 | } |
158 | 158 | |
@@ -162,48 +162,48 @@ discard block |
||
162 | 162 | * @since 3.1.0 |
163 | 163 | */ |
164 | 164 | function wp_ajax_wp_compression_test() { |
165 | - if ( !current_user_can( 'manage_options' ) ) |
|
165 | + if ( ! current_user_can('manage_options')) |
|
166 | 166 | wp_die( -1 ); |
167 | 167 | |
168 | - if ( ini_get('zlib.output_compression') || 'ob_gzhandler' == ini_get('output_handler') ) { |
|
168 | + if (ini_get('zlib.output_compression') || 'ob_gzhandler' == ini_get('output_handler')) { |
|
169 | 169 | update_site_option('can_compress_scripts', 0); |
170 | - wp_die( 0 ); |
|
170 | + wp_die(0); |
|
171 | 171 | } |
172 | 172 | |
173 | - if ( isset($_GET['test']) ) { |
|
174 | - header( 'Expires: Wed, 11 Jan 1984 05:00:00 GMT' ); |
|
175 | - header( 'Last-Modified: ' . gmdate( 'D, d M Y H:i:s' ) . ' GMT' ); |
|
176 | - header( 'Cache-Control: no-cache, must-revalidate, max-age=0' ); |
|
177 | - header( 'Pragma: no-cache' ); |
|
173 | + if (isset($_GET['test'])) { |
|
174 | + header('Expires: Wed, 11 Jan 1984 05:00:00 GMT'); |
|
175 | + header('Last-Modified: '.gmdate('D, d M Y H:i:s').' GMT'); |
|
176 | + header('Cache-Control: no-cache, must-revalidate, max-age=0'); |
|
177 | + header('Pragma: no-cache'); |
|
178 | 178 | header('Content-Type: application/javascript; charset=UTF-8'); |
179 | - $force_gzip = ( defined('ENFORCE_GZIP') && ENFORCE_GZIP ); |
|
179 | + $force_gzip = (defined('ENFORCE_GZIP') && ENFORCE_GZIP); |
|
180 | 180 | $test_str = '"wpCompressionTest Lorem ipsum dolor sit amet consectetuer mollis sapien urna ut a. Eu nonummy condimentum fringilla tempor pretium platea vel nibh netus Maecenas. Hac molestie amet justo quis pellentesque est ultrices interdum nibh Morbi. Cras mattis pretium Phasellus ante ipsum ipsum ut sociis Suspendisse Lorem. Ante et non molestie. Porta urna Vestibulum egestas id congue nibh eu risus gravida sit. Ac augue auctor Ut et non a elit massa id sodales. Elit eu Nulla at nibh adipiscing mattis lacus mauris at tempus. Netus nibh quis suscipit nec feugiat eget sed lorem et urna. Pellentesque lacus at ut massa consectetuer ligula ut auctor semper Pellentesque. Ut metus massa nibh quam Curabitur molestie nec mauris congue. Volutpat molestie elit justo facilisis neque ac risus Ut nascetur tristique. Vitae sit lorem tellus et quis Phasellus lacus tincidunt nunc Fusce. Pharetra wisi Suspendisse mus sagittis libero lacinia Integer consequat ac Phasellus. Et urna ac cursus tortor aliquam Aliquam amet tellus volutpat Vestibulum. Justo interdum condimentum In augue congue tellus sollicitudin Quisque quis nibh."'; |
181 | 181 | |
182 | - if ( 1 == $_GET['test'] ) { |
|
182 | + if (1 == $_GET['test']) { |
|
183 | 183 | echo $test_str; |
184 | 184 | wp_die(); |
185 | - } elseif ( 2 == $_GET['test'] ) { |
|
186 | - if ( !isset($_SERVER['HTTP_ACCEPT_ENCODING']) ) |
|
185 | + } elseif (2 == $_GET['test']) { |
|
186 | + if ( ! isset($_SERVER['HTTP_ACCEPT_ENCODING'])) |
|
187 | 187 | wp_die( -1 ); |
188 | - if ( false !== stripos( $_SERVER['HTTP_ACCEPT_ENCODING'], 'deflate') && function_exists('gzdeflate') && ! $force_gzip ) { |
|
188 | + if (false !== stripos($_SERVER['HTTP_ACCEPT_ENCODING'], 'deflate') && function_exists('gzdeflate') && ! $force_gzip) { |
|
189 | 189 | header('Content-Encoding: deflate'); |
190 | - $out = gzdeflate( $test_str, 1 ); |
|
191 | - } elseif ( false !== stripos( $_SERVER['HTTP_ACCEPT_ENCODING'], 'gzip') && function_exists('gzencode') ) { |
|
190 | + $out = gzdeflate($test_str, 1); |
|
191 | + } elseif (false !== stripos($_SERVER['HTTP_ACCEPT_ENCODING'], 'gzip') && function_exists('gzencode')) { |
|
192 | 192 | header('Content-Encoding: gzip'); |
193 | - $out = gzencode( $test_str, 1 ); |
|
193 | + $out = gzencode($test_str, 1); |
|
194 | 194 | } else { |
195 | 195 | wp_die( -1 ); |
196 | 196 | } |
197 | 197 | echo $out; |
198 | 198 | wp_die(); |
199 | - } elseif ( 'no' == $_GET['test'] ) { |
|
199 | + } elseif ('no' == $_GET['test']) { |
|
200 | 200 | update_site_option('can_compress_scripts', 0); |
201 | - } elseif ( 'yes' == $_GET['test'] ) { |
|
201 | + } elseif ('yes' == $_GET['test']) { |
|
202 | 202 | update_site_option('can_compress_scripts', 1); |
203 | 203 | } |
204 | 204 | } |
205 | 205 | |
206 | - wp_die( 0 ); |
|
206 | + wp_die(0); |
|
207 | 207 | } |
208 | 208 | |
209 | 209 | /** |
@@ -213,13 +213,13 @@ discard block |
||
213 | 213 | */ |
214 | 214 | function wp_ajax_imgedit_preview() { |
215 | 215 | $post_id = intval($_GET['postid']); |
216 | - if ( empty($post_id) || !current_user_can('edit_post', $post_id) ) |
|
216 | + if (empty($post_id) || ! current_user_can('edit_post', $post_id)) |
|
217 | 217 | wp_die( -1 ); |
218 | 218 | |
219 | - check_ajax_referer( "image_editor-$post_id" ); |
|
219 | + check_ajax_referer("image_editor-$post_id"); |
|
220 | 220 | |
221 | - include_once( ABSPATH . 'wp-admin/includes/image-edit.php' ); |
|
222 | - if ( ! stream_preview_image($post_id) ) |
|
221 | + include_once(ABSPATH.'wp-admin/includes/image-edit.php'); |
|
222 | + if ( ! stream_preview_image($post_id)) |
|
223 | 223 | wp_die( -1 ); |
224 | 224 | |
225 | 225 | wp_die(); |
@@ -233,8 +233,8 @@ discard block |
||
233 | 233 | * @global WP_Embed $wp_embed |
234 | 234 | */ |
235 | 235 | function wp_ajax_oembed_cache() { |
236 | - $GLOBALS['wp_embed']->cache_oembed( $_GET['post'] ); |
|
237 | - wp_die( 0 ); |
|
236 | + $GLOBALS['wp_embed']->cache_oembed($_GET['post']); |
|
237 | + wp_die(0); |
|
238 | 238 | } |
239 | 239 | |
240 | 240 | /** |
@@ -243,18 +243,18 @@ discard block |
||
243 | 243 | * @since 3.4.0 |
244 | 244 | */ |
245 | 245 | function wp_ajax_autocomplete_user() { |
246 | - if ( ! is_multisite() || ! current_user_can( 'promote_users' ) || wp_is_large_network( 'users' ) ) |
|
246 | + if ( ! is_multisite() || ! current_user_can('promote_users') || wp_is_large_network('users')) |
|
247 | 247 | wp_die( -1 ); |
248 | 248 | |
249 | 249 | /** This filter is documented in wp-admin/user-new.php */ |
250 | - if ( ! is_super_admin() && ! apply_filters( 'autocomplete_users_for_site_admins', false ) ) |
|
250 | + if ( ! is_super_admin() && ! apply_filters('autocomplete_users_for_site_admins', false)) |
|
251 | 251 | wp_die( -1 ); |
252 | 252 | |
253 | 253 | $return = array(); |
254 | 254 | |
255 | 255 | // Check the type of request |
256 | 256 | // Current allowed values are `add` and `search` |
257 | - if ( isset( $_REQUEST['autocomplete_type'] ) && 'search' === $_REQUEST['autocomplete_type'] ) { |
|
257 | + if (isset($_REQUEST['autocomplete_type']) && 'search' === $_REQUEST['autocomplete_type']) { |
|
258 | 258 | $type = $_REQUEST['autocomplete_type']; |
259 | 259 | } else { |
260 | 260 | $type = 'add'; |
@@ -262,39 +262,39 @@ discard block |
||
262 | 262 | |
263 | 263 | // Check the desired field for value |
264 | 264 | // Current allowed values are `user_email` and `user_login` |
265 | - if ( isset( $_REQUEST['autocomplete_field'] ) && 'user_email' === $_REQUEST['autocomplete_field'] ) { |
|
265 | + if (isset($_REQUEST['autocomplete_field']) && 'user_email' === $_REQUEST['autocomplete_field']) { |
|
266 | 266 | $field = $_REQUEST['autocomplete_field']; |
267 | 267 | } else { |
268 | 268 | $field = 'user_login'; |
269 | 269 | } |
270 | 270 | |
271 | 271 | // Exclude current users of this blog |
272 | - if ( isset( $_REQUEST['site_id'] ) ) { |
|
273 | - $id = absint( $_REQUEST['site_id'] ); |
|
272 | + if (isset($_REQUEST['site_id'])) { |
|
273 | + $id = absint($_REQUEST['site_id']); |
|
274 | 274 | } else { |
275 | 275 | $id = get_current_blog_id(); |
276 | 276 | } |
277 | 277 | |
278 | - $include_blog_users = ( $type == 'search' ? get_users( array( 'blog_id' => $id, 'fields' => 'ID' ) ) : array() ); |
|
279 | - $exclude_blog_users = ( $type == 'add' ? get_users( array( 'blog_id' => $id, 'fields' => 'ID' ) ) : array() ); |
|
278 | + $include_blog_users = ($type == 'search' ? get_users(array('blog_id' => $id, 'fields' => 'ID')) : array()); |
|
279 | + $exclude_blog_users = ($type == 'add' ? get_users(array('blog_id' => $id, 'fields' => 'ID')) : array()); |
|
280 | 280 | |
281 | - $users = get_users( array( |
|
281 | + $users = get_users(array( |
|
282 | 282 | 'blog_id' => false, |
283 | - 'search' => '*' . $_REQUEST['term'] . '*', |
|
283 | + 'search' => '*'.$_REQUEST['term'].'*', |
|
284 | 284 | 'include' => $include_blog_users, |
285 | 285 | 'exclude' => $exclude_blog_users, |
286 | - 'search_columns' => array( 'user_login', 'user_nicename', 'user_email' ), |
|
287 | - ) ); |
|
286 | + 'search_columns' => array('user_login', 'user_nicename', 'user_email'), |
|
287 | + )); |
|
288 | 288 | |
289 | - foreach ( $users as $user ) { |
|
289 | + foreach ($users as $user) { |
|
290 | 290 | $return[] = array( |
291 | 291 | /* translators: 1: user_login, 2: user_email */ |
292 | - 'label' => sprintf( _x( '%1$s (%2$s)', 'user autocomplete result' ), $user->user_login, $user->user_email ), |
|
292 | + 'label' => sprintf(_x('%1$s (%2$s)', 'user autocomplete result'), $user->user_login, $user->user_email), |
|
293 | 293 | 'value' => $user->$field, |
294 | 294 | ); |
295 | 295 | } |
296 | 296 | |
297 | - wp_die( wp_json_encode( $return ) ); |
|
297 | + wp_die(wp_json_encode($return)); |
|
298 | 298 | } |
299 | 299 | |
300 | 300 | /** |
@@ -303,14 +303,14 @@ discard block |
||
303 | 303 | * @since 3.4.0 |
304 | 304 | */ |
305 | 305 | function wp_ajax_dashboard_widgets() { |
306 | - require_once ABSPATH . 'wp-admin/includes/dashboard.php'; |
|
306 | + require_once ABSPATH.'wp-admin/includes/dashboard.php'; |
|
307 | 307 | |
308 | 308 | $pagenow = $_GET['pagenow']; |
309 | - if ( $pagenow === 'dashboard-user' || $pagenow === 'dashboard-network' || $pagenow === 'dashboard' ) { |
|
310 | - set_current_screen( $pagenow ); |
|
309 | + if ($pagenow === 'dashboard-user' || $pagenow === 'dashboard-network' || $pagenow === 'dashboard') { |
|
310 | + set_current_screen($pagenow); |
|
311 | 311 | } |
312 | 312 | |
313 | - switch ( $_GET['widget'] ) { |
|
313 | + switch ($_GET['widget']) { |
|
314 | 314 | case 'dashboard_primary' : |
315 | 315 | wp_dashboard_primary(); |
316 | 316 | break; |
@@ -324,7 +324,7 @@ discard block |
||
324 | 324 | * @since 3.4.0 |
325 | 325 | */ |
326 | 326 | function wp_ajax_logged_in() { |
327 | - wp_die( 1 ); |
|
327 | + wp_die(1); |
|
328 | 328 | } |
329 | 329 | |
330 | 330 | // |
@@ -342,20 +342,20 @@ discard block |
||
342 | 342 | * @param int $comment_id |
343 | 343 | * @param int $delta |
344 | 344 | */ |
345 | -function _wp_ajax_delete_comment_response( $comment_id, $delta = -1 ) { |
|
346 | - $total = isset( $_POST['_total'] ) ? (int) $_POST['_total'] : 0; |
|
347 | - $per_page = isset( $_POST['_per_page'] ) ? (int) $_POST['_per_page'] : 0; |
|
348 | - $page = isset( $_POST['_page'] ) ? (int) $_POST['_page'] : 0; |
|
349 | - $url = isset( $_POST['_url'] ) ? esc_url_raw( $_POST['_url'] ) : ''; |
|
345 | +function _wp_ajax_delete_comment_response($comment_id, $delta = -1) { |
|
346 | + $total = isset($_POST['_total']) ? (int) $_POST['_total'] : 0; |
|
347 | + $per_page = isset($_POST['_per_page']) ? (int) $_POST['_per_page'] : 0; |
|
348 | + $page = isset($_POST['_page']) ? (int) $_POST['_page'] : 0; |
|
349 | + $url = isset($_POST['_url']) ? esc_url_raw($_POST['_url']) : ''; |
|
350 | 350 | |
351 | 351 | // JS didn't send us everything we need to know. Just die with success message |
352 | - if ( ! $total || ! $per_page || ! $page || ! $url ) { |
|
352 | + if ( ! $total || ! $per_page || ! $page || ! $url) { |
|
353 | 353 | $time = time(); |
354 | - $comment = get_comment( $comment_id ); |
|
354 | + $comment = get_comment($comment_id); |
|
355 | 355 | |
356 | 356 | $counts = wp_count_comments(); |
357 | 357 | |
358 | - $x = new WP_Ajax_Response( array( |
|
358 | + $x = new WP_Ajax_Response(array( |
|
359 | 359 | 'what' => 'comment', |
360 | 360 | // Here for completeness - not used. |
361 | 361 | 'id' => $comment_id, |
@@ -365,62 +365,62 @@ discard block |
||
365 | 365 | 'time' => $time, |
366 | 366 | 'in_moderation' => $counts->moderated, |
367 | 367 | 'i18n_comments_text' => sprintf( |
368 | - _n( '%s Comment', '%s Comments', $counts->approved ), |
|
369 | - number_format_i18n( $counts->approved ) |
|
368 | + _n('%s Comment', '%s Comments', $counts->approved), |
|
369 | + number_format_i18n($counts->approved) |
|
370 | 370 | ), |
371 | 371 | 'i18n_moderation_text' => sprintf( |
372 | - _nx( '%s in moderation', '%s in moderation', $counts->moderated, 'comments' ), |
|
373 | - number_format_i18n( $counts->moderated ) |
|
372 | + _nx('%s in moderation', '%s in moderation', $counts->moderated, 'comments'), |
|
373 | + number_format_i18n($counts->moderated) |
|
374 | 374 | ) |
375 | 375 | ) |
376 | - ) ); |
|
376 | + )); |
|
377 | 377 | $x->send(); |
378 | 378 | } |
379 | 379 | |
380 | 380 | $total += $delta; |
381 | - if ( $total < 0 ) |
|
381 | + if ($total < 0) |
|
382 | 382 | $total = 0; |
383 | 383 | |
384 | 384 | // Only do the expensive stuff on a page-break, and about 1 other time per page |
385 | - if ( 0 == $total % $per_page || 1 == mt_rand( 1, $per_page ) ) { |
|
385 | + if (0 == $total % $per_page || 1 == mt_rand(1, $per_page)) { |
|
386 | 386 | $post_id = 0; |
387 | 387 | // What type of comment count are we looking for? |
388 | 388 | $status = 'all'; |
389 | - $parsed = parse_url( $url ); |
|
390 | - if ( isset( $parsed['query'] ) ) { |
|
391 | - parse_str( $parsed['query'], $query_vars ); |
|
392 | - if ( !empty( $query_vars['comment_status'] ) ) |
|
389 | + $parsed = parse_url($url); |
|
390 | + if (isset($parsed['query'])) { |
|
391 | + parse_str($parsed['query'], $query_vars); |
|
392 | + if ( ! empty($query_vars['comment_status'])) |
|
393 | 393 | $status = $query_vars['comment_status']; |
394 | - if ( !empty( $query_vars['p'] ) ) |
|
394 | + if ( ! empty($query_vars['p'])) |
|
395 | 395 | $post_id = (int) $query_vars['p']; |
396 | 396 | } |
397 | 397 | |
398 | 398 | $comment_count = wp_count_comments($post_id); |
399 | 399 | |
400 | 400 | // We're looking for a known type of comment count. |
401 | - if ( isset( $comment_count->$status ) ) |
|
401 | + if (isset($comment_count->$status)) |
|
402 | 402 | $total = $comment_count->$status; |
403 | 403 | // Else use the decremented value from above. |
404 | 404 | } |
405 | 405 | |
406 | 406 | // The time since the last comment count. |
407 | 407 | $time = time(); |
408 | - $comment = get_comment( $comment_id ); |
|
408 | + $comment = get_comment($comment_id); |
|
409 | 409 | |
410 | - $x = new WP_Ajax_Response( array( |
|
410 | + $x = new WP_Ajax_Response(array( |
|
411 | 411 | 'what' => 'comment', |
412 | 412 | // Here for completeness - not used. |
413 | 413 | 'id' => $comment_id, |
414 | 414 | 'supplemental' => array( |
415 | 415 | 'status' => $comment ? $comment->comment_approved : '', |
416 | 416 | 'postId' => $comment ? $comment->comment_post_ID : '', |
417 | - 'total_items_i18n' => sprintf( _n( '%s item', '%s items', $total ), number_format_i18n( $total ) ), |
|
418 | - 'total_pages' => ceil( $total / $per_page ), |
|
419 | - 'total_pages_i18n' => number_format_i18n( ceil( $total / $per_page ) ), |
|
417 | + 'total_items_i18n' => sprintf(_n('%s item', '%s items', $total), number_format_i18n($total)), |
|
418 | + 'total_pages' => ceil($total / $per_page), |
|
419 | + 'total_pages_i18n' => number_format_i18n(ceil($total / $per_page)), |
|
420 | 420 | 'total' => $total, |
421 | 421 | 'time' => $time |
422 | 422 | ) |
423 | - ) ); |
|
423 | + )); |
|
424 | 424 | $x->send(); |
425 | 425 | } |
426 | 426 | |
@@ -437,87 +437,87 @@ discard block |
||
437 | 437 | function _wp_ajax_add_hierarchical_term() { |
438 | 438 | $action = $_POST['action']; |
439 | 439 | $taxonomy = get_taxonomy(substr($action, 4)); |
440 | - check_ajax_referer( $action, '_ajax_nonce-add-' . $taxonomy->name ); |
|
441 | - if ( !current_user_can( $taxonomy->cap->edit_terms ) ) |
|
440 | + check_ajax_referer($action, '_ajax_nonce-add-'.$taxonomy->name); |
|
441 | + if ( ! current_user_can($taxonomy->cap->edit_terms)) |
|
442 | 442 | wp_die( -1 ); |
443 | 443 | $names = explode(',', $_POST['new'.$taxonomy->name]); |
444 | 444 | $parent = isset($_POST['new'.$taxonomy->name.'_parent']) ? (int) $_POST['new'.$taxonomy->name.'_parent'] : 0; |
445 | - if ( 0 > $parent ) |
|
445 | + if (0 > $parent) |
|
446 | 446 | $parent = 0; |
447 | - if ( $taxonomy->name == 'category' ) |
|
447 | + if ($taxonomy->name == 'category') |
|
448 | 448 | $post_category = isset($_POST['post_category']) ? (array) $_POST['post_category'] : array(); |
449 | 449 | else |
450 | - $post_category = ( isset($_POST['tax_input']) && isset($_POST['tax_input'][$taxonomy->name]) ) ? (array) $_POST['tax_input'][$taxonomy->name] : array(); |
|
451 | - $checked_categories = array_map( 'absint', (array) $post_category ); |
|
450 | + $post_category = (isset($_POST['tax_input']) && isset($_POST['tax_input'][$taxonomy->name])) ? (array) $_POST['tax_input'][$taxonomy->name] : array(); |
|
451 | + $checked_categories = array_map('absint', (array) $post_category); |
|
452 | 452 | $popular_ids = wp_popular_terms_checklist($taxonomy->name, 0, 10, false); |
453 | 453 | |
454 | - foreach ( $names as $cat_name ) { |
|
454 | + foreach ($names as $cat_name) { |
|
455 | 455 | $cat_name = trim($cat_name); |
456 | 456 | $category_nicename = sanitize_title($cat_name); |
457 | - if ( '' === $category_nicename ) |
|
457 | + if ('' === $category_nicename) |
|
458 | 458 | continue; |
459 | - if ( !$cat_id = term_exists( $cat_name, $taxonomy->name, $parent ) ) |
|
460 | - $cat_id = wp_insert_term( $cat_name, $taxonomy->name, array( 'parent' => $parent ) ); |
|
461 | - if ( is_wp_error( $cat_id ) ) { |
|
459 | + if ( ! $cat_id = term_exists($cat_name, $taxonomy->name, $parent)) |
|
460 | + $cat_id = wp_insert_term($cat_name, $taxonomy->name, array('parent' => $parent)); |
|
461 | + if (is_wp_error($cat_id)) { |
|
462 | 462 | continue; |
463 | - } elseif ( is_array( $cat_id ) ) { |
|
463 | + } elseif (is_array($cat_id)) { |
|
464 | 464 | $cat_id = $cat_id['term_id']; |
465 | 465 | } |
466 | 466 | $checked_categories[] = $cat_id; |
467 | - if ( $parent ) // Do these all at once in a second |
|
467 | + if ($parent) // Do these all at once in a second |
|
468 | 468 | continue; |
469 | 469 | |
470 | 470 | ob_start(); |
471 | 471 | |
472 | - wp_terms_checklist( 0, array( 'taxonomy' => $taxonomy->name, 'descendants_and_self' => $cat_id, 'selected_cats' => $checked_categories, 'popular_cats' => $popular_ids )); |
|
472 | + wp_terms_checklist(0, array('taxonomy' => $taxonomy->name, 'descendants_and_self' => $cat_id, 'selected_cats' => $checked_categories, 'popular_cats' => $popular_ids)); |
|
473 | 473 | |
474 | 474 | $data = ob_get_clean(); |
475 | 475 | |
476 | 476 | $add = array( |
477 | 477 | 'what' => $taxonomy->name, |
478 | 478 | 'id' => $cat_id, |
479 | - 'data' => str_replace( array("\n", "\t"), '', $data), |
|
479 | + 'data' => str_replace(array("\n", "\t"), '', $data), |
|
480 | 480 | 'position' => -1 |
481 | 481 | ); |
482 | 482 | } |
483 | 483 | |
484 | - if ( $parent ) { // Foncy - replace the parent and all its children |
|
485 | - $parent = get_term( $parent, $taxonomy->name ); |
|
484 | + if ($parent) { // Foncy - replace the parent and all its children |
|
485 | + $parent = get_term($parent, $taxonomy->name); |
|
486 | 486 | $term_id = $parent->term_id; |
487 | 487 | |
488 | - while ( $parent->parent ) { // get the top parent |
|
489 | - $parent = get_term( $parent->parent, $taxonomy->name ); |
|
490 | - if ( is_wp_error( $parent ) ) |
|
488 | + while ($parent->parent) { // get the top parent |
|
489 | + $parent = get_term($parent->parent, $taxonomy->name); |
|
490 | + if (is_wp_error($parent)) |
|
491 | 491 | break; |
492 | 492 | $term_id = $parent->term_id; |
493 | 493 | } |
494 | 494 | |
495 | 495 | ob_start(); |
496 | 496 | |
497 | - wp_terms_checklist( 0, array('taxonomy' => $taxonomy->name, 'descendants_and_self' => $term_id, 'selected_cats' => $checked_categories, 'popular_cats' => $popular_ids)); |
|
497 | + wp_terms_checklist(0, array('taxonomy' => $taxonomy->name, 'descendants_and_self' => $term_id, 'selected_cats' => $checked_categories, 'popular_cats' => $popular_ids)); |
|
498 | 498 | |
499 | 499 | $data = ob_get_clean(); |
500 | 500 | |
501 | 501 | $add = array( |
502 | 502 | 'what' => $taxonomy->name, |
503 | 503 | 'id' => $term_id, |
504 | - 'data' => str_replace( array("\n", "\t"), '', $data), |
|
504 | + 'data' => str_replace(array("\n", "\t"), '', $data), |
|
505 | 505 | 'position' => -1 |
506 | 506 | ); |
507 | 507 | } |
508 | 508 | |
509 | 509 | ob_start(); |
510 | 510 | |
511 | - wp_dropdown_categories( array( |
|
511 | + wp_dropdown_categories(array( |
|
512 | 512 | 'taxonomy' => $taxonomy->name, 'hide_empty' => 0, 'name' => 'new'.$taxonomy->name.'_parent', 'orderby' => 'name', |
513 | 513 | 'hierarchical' => 1, 'show_option_none' => '— '.$taxonomy->labels->parent_item.' —' |
514 | - ) ); |
|
514 | + )); |
|
515 | 515 | |
516 | 516 | $sup = ob_get_clean(); |
517 | 517 | |
518 | - $add['supplemental'] = array( 'newcat_parent' => $sup ); |
|
518 | + $add['supplemental'] = array('newcat_parent' => $sup); |
|
519 | 519 | |
520 | - $x = new WP_Ajax_Response( $add ); |
|
520 | + $x = new WP_Ajax_Response($add); |
|
521 | 521 | $x->send(); |
522 | 522 | } |
523 | 523 | |
@@ -527,46 +527,46 @@ discard block |
||
527 | 527 | * @since 3.1.0 |
528 | 528 | */ |
529 | 529 | function wp_ajax_delete_comment() { |
530 | - $id = isset( $_POST['id'] ) ? (int) $_POST['id'] : 0; |
|
530 | + $id = isset($_POST['id']) ? (int) $_POST['id'] : 0; |
|
531 | 531 | |
532 | - if ( !$comment = get_comment( $id ) ) |
|
533 | - wp_die( time() ); |
|
534 | - if ( ! current_user_can( 'edit_comment', $comment->comment_ID ) ) |
|
532 | + if ( ! $comment = get_comment($id)) |
|
533 | + wp_die(time()); |
|
534 | + if ( ! current_user_can('edit_comment', $comment->comment_ID)) |
|
535 | 535 | wp_die( -1 ); |
536 | 536 | |
537 | - check_ajax_referer( "delete-comment_$id" ); |
|
538 | - $status = wp_get_comment_status( $comment ); |
|
537 | + check_ajax_referer("delete-comment_$id"); |
|
538 | + $status = wp_get_comment_status($comment); |
|
539 | 539 | |
540 | 540 | $delta = -1; |
541 | - if ( isset($_POST['trash']) && 1 == $_POST['trash'] ) { |
|
542 | - if ( 'trash' == $status ) |
|
543 | - wp_die( time() ); |
|
544 | - $r = wp_trash_comment( $comment ); |
|
545 | - } elseif ( isset($_POST['untrash']) && 1 == $_POST['untrash'] ) { |
|
546 | - if ( 'trash' != $status ) |
|
547 | - wp_die( time() ); |
|
548 | - $r = wp_untrash_comment( $comment ); |
|
549 | - if ( ! isset( $_POST['comment_status'] ) || $_POST['comment_status'] != 'trash' ) // undo trash, not in trash |
|
541 | + if (isset($_POST['trash']) && 1 == $_POST['trash']) { |
|
542 | + if ('trash' == $status) |
|
543 | + wp_die(time()); |
|
544 | + $r = wp_trash_comment($comment); |
|
545 | + } elseif (isset($_POST['untrash']) && 1 == $_POST['untrash']) { |
|
546 | + if ('trash' != $status) |
|
547 | + wp_die(time()); |
|
548 | + $r = wp_untrash_comment($comment); |
|
549 | + if ( ! isset($_POST['comment_status']) || $_POST['comment_status'] != 'trash') // undo trash, not in trash |
|
550 | 550 | $delta = 1; |
551 | - } elseif ( isset($_POST['spam']) && 1 == $_POST['spam'] ) { |
|
552 | - if ( 'spam' == $status ) |
|
553 | - wp_die( time() ); |
|
554 | - $r = wp_spam_comment( $comment ); |
|
555 | - } elseif ( isset($_POST['unspam']) && 1 == $_POST['unspam'] ) { |
|
556 | - if ( 'spam' != $status ) |
|
557 | - wp_die( time() ); |
|
558 | - $r = wp_unspam_comment( $comment ); |
|
559 | - if ( ! isset( $_POST['comment_status'] ) || $_POST['comment_status'] != 'spam' ) // undo spam, not in spam |
|
551 | + } elseif (isset($_POST['spam']) && 1 == $_POST['spam']) { |
|
552 | + if ('spam' == $status) |
|
553 | + wp_die(time()); |
|
554 | + $r = wp_spam_comment($comment); |
|
555 | + } elseif (isset($_POST['unspam']) && 1 == $_POST['unspam']) { |
|
556 | + if ('spam' != $status) |
|
557 | + wp_die(time()); |
|
558 | + $r = wp_unspam_comment($comment); |
|
559 | + if ( ! isset($_POST['comment_status']) || $_POST['comment_status'] != 'spam') // undo spam, not in spam |
|
560 | 560 | $delta = 1; |
561 | - } elseif ( isset($_POST['delete']) && 1 == $_POST['delete'] ) { |
|
562 | - $r = wp_delete_comment( $comment ); |
|
561 | + } elseif (isset($_POST['delete']) && 1 == $_POST['delete']) { |
|
562 | + $r = wp_delete_comment($comment); |
|
563 | 563 | } else { |
564 | 564 | wp_die( -1 ); |
565 | 565 | } |
566 | 566 | |
567 | - if ( $r ) // Decide if we need to send back '1' or a more complicated response including page links and comment counts |
|
568 | - _wp_ajax_delete_comment_response( $comment->comment_ID, $delta ); |
|
569 | - wp_die( 0 ); |
|
567 | + if ($r) // Decide if we need to send back '1' or a more complicated response including page links and comment counts |
|
568 | + _wp_ajax_delete_comment_response($comment->comment_ID, $delta); |
|
569 | + wp_die(0); |
|
570 | 570 | } |
571 | 571 | |
572 | 572 | /** |
@@ -576,22 +576,22 @@ discard block |
||
576 | 576 | */ |
577 | 577 | function wp_ajax_delete_tag() { |
578 | 578 | $tag_id = (int) $_POST['tag_ID']; |
579 | - check_ajax_referer( "delete-tag_$tag_id" ); |
|
579 | + check_ajax_referer("delete-tag_$tag_id"); |
|
580 | 580 | |
581 | - $taxonomy = !empty($_POST['taxonomy']) ? $_POST['taxonomy'] : 'post_tag'; |
|
581 | + $taxonomy = ! empty($_POST['taxonomy']) ? $_POST['taxonomy'] : 'post_tag'; |
|
582 | 582 | $tax = get_taxonomy($taxonomy); |
583 | 583 | |
584 | - if ( !current_user_can( $tax->cap->delete_terms ) ) |
|
584 | + if ( ! current_user_can($tax->cap->delete_terms)) |
|
585 | 585 | wp_die( -1 ); |
586 | 586 | |
587 | - $tag = get_term( $tag_id, $taxonomy ); |
|
588 | - if ( !$tag || is_wp_error( $tag ) ) |
|
589 | - wp_die( 1 ); |
|
587 | + $tag = get_term($tag_id, $taxonomy); |
|
588 | + if ( ! $tag || is_wp_error($tag)) |
|
589 | + wp_die(1); |
|
590 | 590 | |
591 | - if ( wp_delete_term($tag_id, $taxonomy)) |
|
592 | - wp_die( 1 ); |
|
591 | + if (wp_delete_term($tag_id, $taxonomy)) |
|
592 | + wp_die(1); |
|
593 | 593 | else |
594 | - wp_die( 0 ); |
|
594 | + wp_die(0); |
|
595 | 595 | } |
596 | 596 | |
597 | 597 | /** |
@@ -600,20 +600,20 @@ discard block |
||
600 | 600 | * @since 3.1.0 |
601 | 601 | */ |
602 | 602 | function wp_ajax_delete_link() { |
603 | - $id = isset( $_POST['id'] ) ? (int) $_POST['id'] : 0; |
|
603 | + $id = isset($_POST['id']) ? (int) $_POST['id'] : 0; |
|
604 | 604 | |
605 | - check_ajax_referer( "delete-bookmark_$id" ); |
|
606 | - if ( !current_user_can( 'manage_links' ) ) |
|
605 | + check_ajax_referer("delete-bookmark_$id"); |
|
606 | + if ( ! current_user_can('manage_links')) |
|
607 | 607 | wp_die( -1 ); |
608 | 608 | |
609 | - $link = get_bookmark( $id ); |
|
610 | - if ( !$link || is_wp_error( $link ) ) |
|
611 | - wp_die( 1 ); |
|
609 | + $link = get_bookmark($id); |
|
610 | + if ( ! $link || is_wp_error($link)) |
|
611 | + wp_die(1); |
|
612 | 612 | |
613 | - if ( wp_delete_link( $id ) ) |
|
614 | - wp_die( 1 ); |
|
613 | + if (wp_delete_link($id)) |
|
614 | + wp_die(1); |
|
615 | 615 | else |
616 | - wp_die( 0 ); |
|
616 | + wp_die(0); |
|
617 | 617 | } |
618 | 618 | |
619 | 619 | /** |
@@ -622,17 +622,17 @@ discard block |
||
622 | 622 | * @since 3.1.0 |
623 | 623 | */ |
624 | 624 | function wp_ajax_delete_meta() { |
625 | - $id = isset( $_POST['id'] ) ? (int) $_POST['id'] : 0; |
|
625 | + $id = isset($_POST['id']) ? (int) $_POST['id'] : 0; |
|
626 | 626 | |
627 | - check_ajax_referer( "delete-meta_$id" ); |
|
628 | - if ( !$meta = get_metadata_by_mid( 'post', $id ) ) |
|
629 | - wp_die( 1 ); |
|
627 | + check_ajax_referer("delete-meta_$id"); |
|
628 | + if ( ! $meta = get_metadata_by_mid('post', $id)) |
|
629 | + wp_die(1); |
|
630 | 630 | |
631 | - if ( is_protected_meta( $meta->meta_key, 'post' ) || ! current_user_can( 'delete_post_meta', $meta->post_id, $meta->meta_key ) ) |
|
631 | + if (is_protected_meta($meta->meta_key, 'post') || ! current_user_can('delete_post_meta', $meta->post_id, $meta->meta_key)) |
|
632 | 632 | wp_die( -1 ); |
633 | - if ( delete_meta( $meta->meta_id ) ) |
|
634 | - wp_die( 1 ); |
|
635 | - wp_die( 0 ); |
|
633 | + if (delete_meta($meta->meta_id)) |
|
634 | + wp_die(1); |
|
635 | + wp_die(0); |
|
636 | 636 | } |
637 | 637 | |
638 | 638 | /** |
@@ -642,22 +642,22 @@ discard block |
||
642 | 642 | * |
643 | 643 | * @param string $action Action to perform. |
644 | 644 | */ |
645 | -function wp_ajax_delete_post( $action ) { |
|
646 | - if ( empty( $action ) ) |
|
645 | +function wp_ajax_delete_post($action) { |
|
646 | + if (empty($action)) |
|
647 | 647 | $action = 'delete-post'; |
648 | - $id = isset( $_POST['id'] ) ? (int) $_POST['id'] : 0; |
|
648 | + $id = isset($_POST['id']) ? (int) $_POST['id'] : 0; |
|
649 | 649 | |
650 | - check_ajax_referer( "{$action}_$id" ); |
|
651 | - if ( !current_user_can( 'delete_post', $id ) ) |
|
650 | + check_ajax_referer("{$action}_$id"); |
|
651 | + if ( ! current_user_can('delete_post', $id)) |
|
652 | 652 | wp_die( -1 ); |
653 | 653 | |
654 | - if ( !get_post( $id ) ) |
|
655 | - wp_die( 1 ); |
|
654 | + if ( ! get_post($id)) |
|
655 | + wp_die(1); |
|
656 | 656 | |
657 | - if ( wp_delete_post( $id ) ) |
|
658 | - wp_die( 1 ); |
|
657 | + if (wp_delete_post($id)) |
|
658 | + wp_die(1); |
|
659 | 659 | else |
660 | - wp_die( 0 ); |
|
660 | + wp_die(0); |
|
661 | 661 | } |
662 | 662 | |
663 | 663 | /** |
@@ -667,27 +667,27 @@ discard block |
||
667 | 667 | * |
668 | 668 | * @param string $action Action to perform. |
669 | 669 | */ |
670 | -function wp_ajax_trash_post( $action ) { |
|
671 | - if ( empty( $action ) ) |
|
670 | +function wp_ajax_trash_post($action) { |
|
671 | + if (empty($action)) |
|
672 | 672 | $action = 'trash-post'; |
673 | - $id = isset( $_POST['id'] ) ? (int) $_POST['id'] : 0; |
|
673 | + $id = isset($_POST['id']) ? (int) $_POST['id'] : 0; |
|
674 | 674 | |
675 | - check_ajax_referer( "{$action}_$id" ); |
|
676 | - if ( !current_user_can( 'delete_post', $id ) ) |
|
675 | + check_ajax_referer("{$action}_$id"); |
|
676 | + if ( ! current_user_can('delete_post', $id)) |
|
677 | 677 | wp_die( -1 ); |
678 | 678 | |
679 | - if ( !get_post( $id ) ) |
|
680 | - wp_die( 1 ); |
|
679 | + if ( ! get_post($id)) |
|
680 | + wp_die(1); |
|
681 | 681 | |
682 | - if ( 'trash-post' == $action ) |
|
683 | - $done = wp_trash_post( $id ); |
|
682 | + if ('trash-post' == $action) |
|
683 | + $done = wp_trash_post($id); |
|
684 | 684 | else |
685 | - $done = wp_untrash_post( $id ); |
|
685 | + $done = wp_untrash_post($id); |
|
686 | 686 | |
687 | - if ( $done ) |
|
688 | - wp_die( 1 ); |
|
687 | + if ($done) |
|
688 | + wp_die(1); |
|
689 | 689 | |
690 | - wp_die( 0 ); |
|
690 | + wp_die(0); |
|
691 | 691 | } |
692 | 692 | |
693 | 693 | /** |
@@ -697,10 +697,10 @@ discard block |
||
697 | 697 | * |
698 | 698 | * @param string $action Action to perform. |
699 | 699 | */ |
700 | -function wp_ajax_untrash_post( $action ) { |
|
701 | - if ( empty( $action ) ) |
|
700 | +function wp_ajax_untrash_post($action) { |
|
701 | + if (empty($action)) |
|
702 | 702 | $action = 'untrash-post'; |
703 | - wp_ajax_trash_post( $action ); |
|
703 | + wp_ajax_trash_post($action); |
|
704 | 704 | } |
705 | 705 | |
706 | 706 | /** |
@@ -708,22 +708,22 @@ discard block |
||
708 | 708 | * |
709 | 709 | * @param string $action |
710 | 710 | */ |
711 | -function wp_ajax_delete_page( $action ) { |
|
712 | - if ( empty( $action ) ) |
|
711 | +function wp_ajax_delete_page($action) { |
|
712 | + if (empty($action)) |
|
713 | 713 | $action = 'delete-page'; |
714 | - $id = isset( $_POST['id'] ) ? (int) $_POST['id'] : 0; |
|
714 | + $id = isset($_POST['id']) ? (int) $_POST['id'] : 0; |
|
715 | 715 | |
716 | - check_ajax_referer( "{$action}_$id" ); |
|
717 | - if ( !current_user_can( 'delete_page', $id ) ) |
|
716 | + check_ajax_referer("{$action}_$id"); |
|
717 | + if ( ! current_user_can('delete_page', $id)) |
|
718 | 718 | wp_die( -1 ); |
719 | 719 | |
720 | - if ( ! get_post( $id ) ) |
|
721 | - wp_die( 1 ); |
|
720 | + if ( ! get_post($id)) |
|
721 | + wp_die(1); |
|
722 | 722 | |
723 | - if ( wp_delete_post( $id ) ) |
|
724 | - wp_die( 1 ); |
|
723 | + if (wp_delete_post($id)) |
|
724 | + wp_die(1); |
|
725 | 725 | else |
726 | - wp_die( 0 ); |
|
726 | + wp_die(0); |
|
727 | 727 | } |
728 | 728 | |
729 | 729 | /** |
@@ -732,41 +732,41 @@ discard block |
||
732 | 732 | * @since 3.1.0 |
733 | 733 | */ |
734 | 734 | function wp_ajax_dim_comment() { |
735 | - $id = isset( $_POST['id'] ) ? (int) $_POST['id'] : 0; |
|
735 | + $id = isset($_POST['id']) ? (int) $_POST['id'] : 0; |
|
736 | 736 | |
737 | - if ( !$comment = get_comment( $id ) ) { |
|
738 | - $x = new WP_Ajax_Response( array( |
|
737 | + if ( ! $comment = get_comment($id)) { |
|
738 | + $x = new WP_Ajax_Response(array( |
|
739 | 739 | 'what' => 'comment', |
740 | 740 | 'id' => new WP_Error('invalid_comment', sprintf(__('Comment %d does not exist'), $id)) |
741 | - ) ); |
|
741 | + )); |
|
742 | 742 | $x->send(); |
743 | 743 | } |
744 | 744 | |
745 | - if ( ! current_user_can( 'edit_comment', $comment->comment_ID ) && ! current_user_can( 'moderate_comments' ) ) |
|
745 | + if ( ! current_user_can('edit_comment', $comment->comment_ID) && ! current_user_can('moderate_comments')) |
|
746 | 746 | wp_die( -1 ); |
747 | 747 | |
748 | - $current = wp_get_comment_status( $comment ); |
|
749 | - if ( isset( $_POST['new'] ) && $_POST['new'] == $current ) |
|
750 | - wp_die( time() ); |
|
748 | + $current = wp_get_comment_status($comment); |
|
749 | + if (isset($_POST['new']) && $_POST['new'] == $current) |
|
750 | + wp_die(time()); |
|
751 | 751 | |
752 | - check_ajax_referer( "approve-comment_$id" ); |
|
753 | - if ( in_array( $current, array( 'unapproved', 'spam' ) ) ) { |
|
754 | - $result = wp_set_comment_status( $comment, 'approve', true ); |
|
752 | + check_ajax_referer("approve-comment_$id"); |
|
753 | + if (in_array($current, array('unapproved', 'spam'))) { |
|
754 | + $result = wp_set_comment_status($comment, 'approve', true); |
|
755 | 755 | } else { |
756 | - $result = wp_set_comment_status( $comment, 'hold', true ); |
|
756 | + $result = wp_set_comment_status($comment, 'hold', true); |
|
757 | 757 | } |
758 | 758 | |
759 | - if ( is_wp_error($result) ) { |
|
760 | - $x = new WP_Ajax_Response( array( |
|
759 | + if (is_wp_error($result)) { |
|
760 | + $x = new WP_Ajax_Response(array( |
|
761 | 761 | 'what' => 'comment', |
762 | 762 | 'id' => $result |
763 | - ) ); |
|
763 | + )); |
|
764 | 764 | $x->send(); |
765 | 765 | } |
766 | 766 | |
767 | 767 | // Decide if we need to send back '1' or a more complicated response including page links and comment counts |
768 | - _wp_ajax_delete_comment_response( $comment->comment_ID ); |
|
769 | - wp_die( 0 ); |
|
768 | + _wp_ajax_delete_comment_response($comment->comment_ID); |
|
769 | + wp_die(0); |
|
770 | 770 | } |
771 | 771 | |
772 | 772 | /** |
@@ -776,33 +776,33 @@ discard block |
||
776 | 776 | * |
777 | 777 | * @param string $action Action to perform. |
778 | 778 | */ |
779 | -function wp_ajax_add_link_category( $action ) { |
|
780 | - if ( empty( $action ) ) |
|
779 | +function wp_ajax_add_link_category($action) { |
|
780 | + if (empty($action)) |
|
781 | 781 | $action = 'add-link-category'; |
782 | - check_ajax_referer( $action ); |
|
783 | - if ( !current_user_can( 'manage_categories' ) ) |
|
782 | + check_ajax_referer($action); |
|
783 | + if ( ! current_user_can('manage_categories')) |
|
784 | 784 | wp_die( -1 ); |
785 | - $names = explode(',', wp_unslash( $_POST['newcat'] ) ); |
|
785 | + $names = explode(',', wp_unslash($_POST['newcat'])); |
|
786 | 786 | $x = new WP_Ajax_Response(); |
787 | - foreach ( $names as $cat_name ) { |
|
787 | + foreach ($names as $cat_name) { |
|
788 | 788 | $cat_name = trim($cat_name); |
789 | 789 | $slug = sanitize_title($cat_name); |
790 | - if ( '' === $slug ) |
|
790 | + if ('' === $slug) |
|
791 | 791 | continue; |
792 | - if ( !$cat_id = term_exists( $cat_name, 'link_category' ) ) |
|
793 | - $cat_id = wp_insert_term( $cat_name, 'link_category' ); |
|
794 | - if ( is_wp_error( $cat_id ) ) { |
|
792 | + if ( ! $cat_id = term_exists($cat_name, 'link_category')) |
|
793 | + $cat_id = wp_insert_term($cat_name, 'link_category'); |
|
794 | + if (is_wp_error($cat_id)) { |
|
795 | 795 | continue; |
796 | - } elseif ( is_array( $cat_id ) ) { |
|
796 | + } elseif (is_array($cat_id)) { |
|
797 | 797 | $cat_id = $cat_id['term_id']; |
798 | 798 | } |
799 | - $cat_name = esc_html( $cat_name ); |
|
800 | - $x->add( array( |
|
799 | + $cat_name = esc_html($cat_name); |
|
800 | + $x->add(array( |
|
801 | 801 | 'what' => 'link-category', |
802 | 802 | 'id' => $cat_id, |
803 | - 'data' => "<li id='link-category-$cat_id'><label for='in-link-category-$cat_id' class='selectit'><input value='" . esc_attr($cat_id) . "' type='checkbox' checked='checked' name='link_category[]' id='in-link-category-$cat_id'/> $cat_name</label></li>", |
|
803 | + 'data' => "<li id='link-category-$cat_id'><label for='in-link-category-$cat_id' class='selectit'><input value='".esc_attr($cat_id)."' type='checkbox' checked='checked' name='link_category[]' id='in-link-category-$cat_id'/> $cat_name</label></li>", |
|
804 | 804 | 'position' => -1 |
805 | - ) ); |
|
805 | + )); |
|
806 | 806 | } |
807 | 807 | $x->send(); |
808 | 808 | } |
@@ -817,52 +817,52 @@ discard block |
||
817 | 817 | function wp_ajax_add_tag() { |
818 | 818 | global $wp_list_table; |
819 | 819 | |
820 | - check_ajax_referer( 'add-tag', '_wpnonce_add-tag' ); |
|
821 | - $taxonomy = !empty($_POST['taxonomy']) ? $_POST['taxonomy'] : 'post_tag'; |
|
820 | + check_ajax_referer('add-tag', '_wpnonce_add-tag'); |
|
821 | + $taxonomy = ! empty($_POST['taxonomy']) ? $_POST['taxonomy'] : 'post_tag'; |
|
822 | 822 | $tax = get_taxonomy($taxonomy); |
823 | 823 | |
824 | - if ( !current_user_can( $tax->cap->edit_terms ) ) |
|
824 | + if ( ! current_user_can($tax->cap->edit_terms)) |
|
825 | 825 | wp_die( -1 ); |
826 | 826 | |
827 | 827 | $x = new WP_Ajax_Response(); |
828 | 828 | |
829 | - $tag = wp_insert_term($_POST['tag-name'], $taxonomy, $_POST ); |
|
829 | + $tag = wp_insert_term($_POST['tag-name'], $taxonomy, $_POST); |
|
830 | 830 | |
831 | - if ( !$tag || is_wp_error($tag) || (!$tag = get_term( $tag['term_id'], $taxonomy )) ) { |
|
831 | + if ( ! $tag || is_wp_error($tag) || ( ! $tag = get_term($tag['term_id'], $taxonomy))) { |
|
832 | 832 | $message = __('An error has occurred. Please reload the page and try again.'); |
833 | - if ( is_wp_error($tag) && $tag->get_error_message() ) |
|
833 | + if (is_wp_error($tag) && $tag->get_error_message()) |
|
834 | 834 | $message = $tag->get_error_message(); |
835 | 835 | |
836 | - $x->add( array( |
|
836 | + $x->add(array( |
|
837 | 837 | 'what' => 'taxonomy', |
838 | - 'data' => new WP_Error('error', $message ) |
|
839 | - ) ); |
|
838 | + 'data' => new WP_Error('error', $message) |
|
839 | + )); |
|
840 | 840 | $x->send(); |
841 | 841 | } |
842 | 842 | |
843 | - $wp_list_table = _get_list_table( 'WP_Terms_List_Table', array( 'screen' => $_POST['screen'] ) ); |
|
843 | + $wp_list_table = _get_list_table('WP_Terms_List_Table', array('screen' => $_POST['screen'])); |
|
844 | 844 | |
845 | 845 | $level = 0; |
846 | - if ( is_taxonomy_hierarchical($taxonomy) ) { |
|
847 | - $level = count( get_ancestors( $tag->term_id, $taxonomy, 'taxonomy' ) ); |
|
846 | + if (is_taxonomy_hierarchical($taxonomy)) { |
|
847 | + $level = count(get_ancestors($tag->term_id, $taxonomy, 'taxonomy')); |
|
848 | 848 | ob_start(); |
849 | - $wp_list_table->single_row( $tag, $level ); |
|
849 | + $wp_list_table->single_row($tag, $level); |
|
850 | 850 | $noparents = ob_get_clean(); |
851 | 851 | } |
852 | 852 | |
853 | 853 | ob_start(); |
854 | - $wp_list_table->single_row( $tag ); |
|
854 | + $wp_list_table->single_row($tag); |
|
855 | 855 | $parents = ob_get_clean(); |
856 | 856 | |
857 | - $x->add( array( |
|
857 | + $x->add(array( |
|
858 | 858 | 'what' => 'taxonomy', |
859 | 859 | 'supplemental' => compact('parents', 'noparents') |
860 | - ) ); |
|
861 | - $x->add( array( |
|
860 | + )); |
|
861 | + $x->add(array( |
|
862 | 862 | 'what' => 'term', |
863 | 863 | 'position' => $level, |
864 | 864 | 'supplemental' => (array) $tag |
865 | - ) ); |
|
865 | + )); |
|
866 | 866 | $x->send(); |
867 | 867 | } |
868 | 868 | |
@@ -872,38 +872,38 @@ discard block |
||
872 | 872 | * @since 3.1.0 |
873 | 873 | */ |
874 | 874 | function wp_ajax_get_tagcloud() { |
875 | - if ( ! isset( $_POST['tax'] ) ) { |
|
876 | - wp_die( 0 ); |
|
875 | + if ( ! isset($_POST['tax'])) { |
|
876 | + wp_die(0); |
|
877 | 877 | } |
878 | 878 | |
879 | - $taxonomy = sanitize_key( $_POST['tax'] ); |
|
880 | - $tax = get_taxonomy( $taxonomy ); |
|
881 | - if ( ! $tax ) { |
|
882 | - wp_die( 0 ); |
|
879 | + $taxonomy = sanitize_key($_POST['tax']); |
|
880 | + $tax = get_taxonomy($taxonomy); |
|
881 | + if ( ! $tax) { |
|
882 | + wp_die(0); |
|
883 | 883 | } |
884 | 884 | |
885 | - if ( ! current_user_can( $tax->cap->assign_terms ) ) { |
|
885 | + if ( ! current_user_can($tax->cap->assign_terms)) { |
|
886 | 886 | wp_die( -1 ); |
887 | 887 | } |
888 | 888 | |
889 | - $tags = get_terms( $taxonomy, array( 'number' => 45, 'orderby' => 'count', 'order' => 'DESC' ) ); |
|
889 | + $tags = get_terms($taxonomy, array('number' => 45, 'orderby' => 'count', 'order' => 'DESC')); |
|
890 | 890 | |
891 | - if ( empty( $tags ) ) |
|
892 | - wp_die( $tax->labels->not_found ); |
|
891 | + if (empty($tags)) |
|
892 | + wp_die($tax->labels->not_found); |
|
893 | 893 | |
894 | - if ( is_wp_error( $tags ) ) |
|
895 | - wp_die( $tags->get_error_message() ); |
|
894 | + if (is_wp_error($tags)) |
|
895 | + wp_die($tags->get_error_message()); |
|
896 | 896 | |
897 | - foreach ( $tags as $key => $tag ) { |
|
898 | - $tags[ $key ]->link = '#'; |
|
899 | - $tags[ $key ]->id = $tag->term_id; |
|
897 | + foreach ($tags as $key => $tag) { |
|
898 | + $tags[$key]->link = '#'; |
|
899 | + $tags[$key]->id = $tag->term_id; |
|
900 | 900 | } |
901 | 901 | |
902 | 902 | // We need raw tag names here, so don't filter the output |
903 | - $return = wp_generate_tag_cloud( $tags, array('filter' => 0) ); |
|
903 | + $return = wp_generate_tag_cloud($tags, array('filter' => 0)); |
|
904 | 904 | |
905 | - if ( empty($return) ) |
|
906 | - wp_die( 0 ); |
|
905 | + if (empty($return)) |
|
906 | + wp_die(0); |
|
907 | 907 | |
908 | 908 | echo $return; |
909 | 909 | |
@@ -920,46 +920,46 @@ discard block |
||
920 | 920 | * |
921 | 921 | * @param string $action Action to perform. |
922 | 922 | */ |
923 | -function wp_ajax_get_comments( $action ) { |
|
923 | +function wp_ajax_get_comments($action) { |
|
924 | 924 | global $wp_list_table, $post_id; |
925 | - if ( empty( $action ) ) |
|
925 | + if (empty($action)) |
|
926 | 926 | $action = 'get-comments'; |
927 | 927 | |
928 | - check_ajax_referer( $action ); |
|
928 | + check_ajax_referer($action); |
|
929 | 929 | |
930 | - if ( empty( $post_id ) && ! empty( $_REQUEST['p'] ) ) { |
|
931 | - $id = absint( $_REQUEST['p'] ); |
|
932 | - if ( ! empty( $id ) ) |
|
930 | + if (empty($post_id) && ! empty($_REQUEST['p'])) { |
|
931 | + $id = absint($_REQUEST['p']); |
|
932 | + if ( ! empty($id)) |
|
933 | 933 | $post_id = $id; |
934 | 934 | } |
935 | 935 | |
936 | - if ( empty( $post_id ) ) |
|
936 | + if (empty($post_id)) |
|
937 | 937 | wp_die( -1 ); |
938 | 938 | |
939 | - $wp_list_table = _get_list_table( 'WP_Post_Comments_List_Table', array( 'screen' => 'edit-comments' ) ); |
|
939 | + $wp_list_table = _get_list_table('WP_Post_Comments_List_Table', array('screen' => 'edit-comments')); |
|
940 | 940 | |
941 | - if ( ! current_user_can( 'edit_post', $post_id ) ) |
|
941 | + if ( ! current_user_can('edit_post', $post_id)) |
|
942 | 942 | wp_die( -1 ); |
943 | 943 | |
944 | 944 | $wp_list_table->prepare_items(); |
945 | 945 | |
946 | - if ( !$wp_list_table->has_items() ) |
|
947 | - wp_die( 1 ); |
|
946 | + if ( ! $wp_list_table->has_items()) |
|
947 | + wp_die(1); |
|
948 | 948 | |
949 | 949 | $x = new WP_Ajax_Response(); |
950 | 950 | ob_start(); |
951 | - foreach ( $wp_list_table->items as $comment ) { |
|
952 | - if ( ! current_user_can( 'edit_comment', $comment->comment_ID ) ) |
|
951 | + foreach ($wp_list_table->items as $comment) { |
|
952 | + if ( ! current_user_can('edit_comment', $comment->comment_ID)) |
|
953 | 953 | continue; |
954 | - get_comment( $comment ); |
|
955 | - $wp_list_table->single_row( $comment ); |
|
954 | + get_comment($comment); |
|
955 | + $wp_list_table->single_row($comment); |
|
956 | 956 | } |
957 | 957 | $comment_list_item = ob_get_clean(); |
958 | 958 | |
959 | - $x->add( array( |
|
959 | + $x->add(array( |
|
960 | 960 | 'what' => 'comments', |
961 | 961 | 'data' => $comment_list_item |
962 | - ) ); |
|
962 | + )); |
|
963 | 963 | $x->send(); |
964 | 964 | } |
965 | 965 | |
@@ -972,91 +972,91 @@ discard block |
||
972 | 972 | * |
973 | 973 | * @param string $action Action to perform. |
974 | 974 | */ |
975 | -function wp_ajax_replyto_comment( $action ) { |
|
975 | +function wp_ajax_replyto_comment($action) { |
|
976 | 976 | global $wp_list_table; |
977 | - if ( empty( $action ) ) |
|
977 | + if (empty($action)) |
|
978 | 978 | $action = 'replyto-comment'; |
979 | 979 | |
980 | - check_ajax_referer( $action, '_ajax_nonce-replyto-comment' ); |
|
980 | + check_ajax_referer($action, '_ajax_nonce-replyto-comment'); |
|
981 | 981 | |
982 | 982 | $comment_post_ID = (int) $_POST['comment_post_ID']; |
983 | - $post = get_post( $comment_post_ID ); |
|
984 | - if ( ! $post ) |
|
983 | + $post = get_post($comment_post_ID); |
|
984 | + if ( ! $post) |
|
985 | 985 | wp_die( -1 ); |
986 | 986 | |
987 | - if ( !current_user_can( 'edit_post', $comment_post_ID ) ) |
|
987 | + if ( ! current_user_can('edit_post', $comment_post_ID)) |
|
988 | 988 | wp_die( -1 ); |
989 | 989 | |
990 | - if ( empty( $post->post_status ) ) |
|
991 | - wp_die( 1 ); |
|
992 | - elseif ( in_array($post->post_status, array('draft', 'pending', 'trash') ) ) |
|
993 | - wp_die( __('ERROR: you are replying to a comment on a draft post.') ); |
|
990 | + if (empty($post->post_status)) |
|
991 | + wp_die(1); |
|
992 | + elseif (in_array($post->post_status, array('draft', 'pending', 'trash'))) |
|
993 | + wp_die(__('ERROR: you are replying to a comment on a draft post.')); |
|
994 | 994 | |
995 | 995 | $user = wp_get_current_user(); |
996 | - if ( $user->exists() ) { |
|
996 | + if ($user->exists()) { |
|
997 | 997 | $user_ID = $user->ID; |
998 | - $comment_author = wp_slash( $user->display_name ); |
|
999 | - $comment_author_email = wp_slash( $user->user_email ); |
|
1000 | - $comment_author_url = wp_slash( $user->user_url ); |
|
1001 | - $comment_content = trim( $_POST['content'] ); |
|
1002 | - $comment_type = isset( $_POST['comment_type'] ) ? trim( $_POST['comment_type'] ) : ''; |
|
1003 | - if ( current_user_can( 'unfiltered_html' ) ) { |
|
1004 | - if ( ! isset( $_POST['_wp_unfiltered_html_comment'] ) ) |
|
998 | + $comment_author = wp_slash($user->display_name); |
|
999 | + $comment_author_email = wp_slash($user->user_email); |
|
1000 | + $comment_author_url = wp_slash($user->user_url); |
|
1001 | + $comment_content = trim($_POST['content']); |
|
1002 | + $comment_type = isset($_POST['comment_type']) ? trim($_POST['comment_type']) : ''; |
|
1003 | + if (current_user_can('unfiltered_html')) { |
|
1004 | + if ( ! isset($_POST['_wp_unfiltered_html_comment'])) |
|
1005 | 1005 | $_POST['_wp_unfiltered_html_comment'] = ''; |
1006 | 1006 | |
1007 | - if ( wp_create_nonce( 'unfiltered-html-comment' ) != $_POST['_wp_unfiltered_html_comment'] ) { |
|
1007 | + if (wp_create_nonce('unfiltered-html-comment') != $_POST['_wp_unfiltered_html_comment']) { |
|
1008 | 1008 | kses_remove_filters(); // start with a clean slate |
1009 | 1009 | kses_init_filters(); // set up the filters |
1010 | 1010 | } |
1011 | 1011 | } |
1012 | 1012 | } else { |
1013 | - wp_die( __( 'Sorry, you must be logged in to reply to a comment.' ) ); |
|
1013 | + wp_die(__('Sorry, you must be logged in to reply to a comment.')); |
|
1014 | 1014 | } |
1015 | 1015 | |
1016 | - if ( '' == $comment_content ) |
|
1017 | - wp_die( __( 'ERROR: please type a comment.' ) ); |
|
1016 | + if ('' == $comment_content) |
|
1017 | + wp_die(__('ERROR: please type a comment.')); |
|
1018 | 1018 | |
1019 | 1019 | $comment_parent = 0; |
1020 | - if ( isset( $_POST['comment_ID'] ) ) |
|
1021 | - $comment_parent = absint( $_POST['comment_ID'] ); |
|
1020 | + if (isset($_POST['comment_ID'])) |
|
1021 | + $comment_parent = absint($_POST['comment_ID']); |
|
1022 | 1022 | $comment_auto_approved = false; |
1023 | 1023 | $commentdata = compact('comment_post_ID', 'comment_author', 'comment_author_email', 'comment_author_url', 'comment_content', 'comment_type', 'comment_parent', 'user_ID'); |
1024 | 1024 | |
1025 | 1025 | // Automatically approve parent comment. |
1026 | - if ( !empty($_POST['approve_parent']) ) { |
|
1027 | - $parent = get_comment( $comment_parent ); |
|
1026 | + if ( ! empty($_POST['approve_parent'])) { |
|
1027 | + $parent = get_comment($comment_parent); |
|
1028 | 1028 | |
1029 | - if ( $parent && $parent->comment_approved === '0' && $parent->comment_post_ID == $comment_post_ID ) { |
|
1030 | - if ( ! current_user_can( 'edit_comment', $parent->comment_ID ) ) { |
|
1029 | + if ($parent && $parent->comment_approved === '0' && $parent->comment_post_ID == $comment_post_ID) { |
|
1030 | + if ( ! current_user_can('edit_comment', $parent->comment_ID)) { |
|
1031 | 1031 | wp_die( -1 ); |
1032 | 1032 | } |
1033 | 1033 | |
1034 | - if ( wp_set_comment_status( $parent, 'approve' ) ) |
|
1034 | + if (wp_set_comment_status($parent, 'approve')) |
|
1035 | 1035 | $comment_auto_approved = true; |
1036 | 1036 | } |
1037 | 1037 | } |
1038 | 1038 | |
1039 | - $comment_id = wp_new_comment( $commentdata ); |
|
1039 | + $comment_id = wp_new_comment($commentdata); |
|
1040 | 1040 | $comment = get_comment($comment_id); |
1041 | - if ( ! $comment ) wp_die( 1 ); |
|
1041 | + if ( ! $comment) wp_die(1); |
|
1042 | 1042 | |
1043 | - $position = ( isset($_POST['position']) && (int) $_POST['position'] ) ? (int) $_POST['position'] : '-1'; |
|
1043 | + $position = (isset($_POST['position']) && (int) $_POST['position']) ? (int) $_POST['position'] : '-1'; |
|
1044 | 1044 | |
1045 | 1045 | ob_start(); |
1046 | - if ( isset( $_REQUEST['mode'] ) && 'dashboard' == $_REQUEST['mode'] ) { |
|
1047 | - require_once( ABSPATH . 'wp-admin/includes/dashboard.php' ); |
|
1048 | - _wp_dashboard_recent_comments_row( $comment ); |
|
1046 | + if (isset($_REQUEST['mode']) && 'dashboard' == $_REQUEST['mode']) { |
|
1047 | + require_once(ABSPATH.'wp-admin/includes/dashboard.php'); |
|
1048 | + _wp_dashboard_recent_comments_row($comment); |
|
1049 | 1049 | } else { |
1050 | - if ( isset( $_REQUEST['mode'] ) && 'single' == $_REQUEST['mode'] ) { |
|
1051 | - $wp_list_table = _get_list_table('WP_Post_Comments_List_Table', array( 'screen' => 'edit-comments' ) ); |
|
1050 | + if (isset($_REQUEST['mode']) && 'single' == $_REQUEST['mode']) { |
|
1051 | + $wp_list_table = _get_list_table('WP_Post_Comments_List_Table', array('screen' => 'edit-comments')); |
|
1052 | 1052 | } else { |
1053 | - $wp_list_table = _get_list_table('WP_Comments_List_Table', array( 'screen' => 'edit-comments' ) ); |
|
1053 | + $wp_list_table = _get_list_table('WP_Comments_List_Table', array('screen' => 'edit-comments')); |
|
1054 | 1054 | } |
1055 | - $wp_list_table->single_row( $comment ); |
|
1055 | + $wp_list_table->single_row($comment); |
|
1056 | 1056 | } |
1057 | 1057 | $comment_list_item = ob_get_clean(); |
1058 | 1058 | |
1059 | - $response = array( |
|
1059 | + $response = array( |
|
1060 | 1060 | 'what' => 'comment', |
1061 | 1061 | 'id' => $comment->comment_ID, |
1062 | 1062 | 'data' => $comment_list_item, |
@@ -1067,22 +1067,22 @@ discard block |
||
1067 | 1067 | $response['supplemental'] = array( |
1068 | 1068 | 'in_moderation' => $counts->moderated, |
1069 | 1069 | 'i18n_comments_text' => sprintf( |
1070 | - _n( '%s Comment', '%s Comments', $counts->approved ), |
|
1071 | - number_format_i18n( $counts->approved ) |
|
1070 | + _n('%s Comment', '%s Comments', $counts->approved), |
|
1071 | + number_format_i18n($counts->approved) |
|
1072 | 1072 | ), |
1073 | 1073 | 'i18n_moderation_text' => sprintf( |
1074 | - _nx( '%s in moderation', '%s in moderation', $counts->moderated, 'comments' ), |
|
1075 | - number_format_i18n( $counts->moderated ) |
|
1074 | + _nx('%s in moderation', '%s in moderation', $counts->moderated, 'comments'), |
|
1075 | + number_format_i18n($counts->moderated) |
|
1076 | 1076 | ) |
1077 | 1077 | ); |
1078 | 1078 | |
1079 | - if ( $comment_auto_approved ) { |
|
1079 | + if ($comment_auto_approved) { |
|
1080 | 1080 | $response['supplemental']['parent_approved'] = $parent->comment_ID; |
1081 | 1081 | $response['supplemental']['parent_post_id'] = $parent->comment_post_ID; |
1082 | 1082 | } |
1083 | 1083 | |
1084 | 1084 | $x = new WP_Ajax_Response(); |
1085 | - $x->add( $response ); |
|
1085 | + $x->add($response); |
|
1086 | 1086 | $x->send(); |
1087 | 1087 | } |
1088 | 1088 | |
@@ -1096,34 +1096,34 @@ discard block |
||
1096 | 1096 | function wp_ajax_edit_comment() { |
1097 | 1097 | global $wp_list_table; |
1098 | 1098 | |
1099 | - check_ajax_referer( 'replyto-comment', '_ajax_nonce-replyto-comment' ); |
|
1099 | + check_ajax_referer('replyto-comment', '_ajax_nonce-replyto-comment'); |
|
1100 | 1100 | |
1101 | 1101 | $comment_id = (int) $_POST['comment_ID']; |
1102 | - if ( ! current_user_can( 'edit_comment', $comment_id ) ) |
|
1102 | + if ( ! current_user_can('edit_comment', $comment_id)) |
|
1103 | 1103 | wp_die( -1 ); |
1104 | 1104 | |
1105 | - if ( '' == $_POST['content'] ) |
|
1106 | - wp_die( __( 'ERROR: please type a comment.' ) ); |
|
1105 | + if ('' == $_POST['content']) |
|
1106 | + wp_die(__('ERROR: please type a comment.')); |
|
1107 | 1107 | |
1108 | - if ( isset( $_POST['status'] ) ) |
|
1108 | + if (isset($_POST['status'])) |
|
1109 | 1109 | $_POST['comment_status'] = $_POST['status']; |
1110 | 1110 | edit_comment(); |
1111 | 1111 | |
1112 | - $position = ( isset($_POST['position']) && (int) $_POST['position']) ? (int) $_POST['position'] : '-1'; |
|
1113 | - $checkbox = ( isset($_POST['checkbox']) && true == $_POST['checkbox'] ) ? 1 : 0; |
|
1114 | - $wp_list_table = _get_list_table( $checkbox ? 'WP_Comments_List_Table' : 'WP_Post_Comments_List_Table', array( 'screen' => 'edit-comments' ) ); |
|
1112 | + $position = (isset($_POST['position']) && (int) $_POST['position']) ? (int) $_POST['position'] : '-1'; |
|
1113 | + $checkbox = (isset($_POST['checkbox']) && true == $_POST['checkbox']) ? 1 : 0; |
|
1114 | + $wp_list_table = _get_list_table($checkbox ? 'WP_Comments_List_Table' : 'WP_Post_Comments_List_Table', array('screen' => 'edit-comments')); |
|
1115 | 1115 | |
1116 | - $comment = get_comment( $comment_id ); |
|
1117 | - if ( empty( $comment->comment_ID ) ) |
|
1116 | + $comment = get_comment($comment_id); |
|
1117 | + if (empty($comment->comment_ID)) |
|
1118 | 1118 | wp_die( -1 ); |
1119 | 1119 | |
1120 | 1120 | ob_start(); |
1121 | - $wp_list_table->single_row( $comment ); |
|
1121 | + $wp_list_table->single_row($comment); |
|
1122 | 1122 | $comment_list_item = ob_get_clean(); |
1123 | 1123 | |
1124 | 1124 | $x = new WP_Ajax_Response(); |
1125 | 1125 | |
1126 | - $x->add( array( |
|
1126 | + $x->add(array( |
|
1127 | 1127 | 'what' => 'edit_comment', |
1128 | 1128 | 'id' => $comment->comment_ID, |
1129 | 1129 | 'data' => $comment_list_item, |
@@ -1139,39 +1139,39 @@ discard block |
||
1139 | 1139 | * @since 3.1.0 |
1140 | 1140 | */ |
1141 | 1141 | function wp_ajax_add_menu_item() { |
1142 | - check_ajax_referer( 'add-menu_item', 'menu-settings-column-nonce' ); |
|
1142 | + check_ajax_referer('add-menu_item', 'menu-settings-column-nonce'); |
|
1143 | 1143 | |
1144 | - if ( ! current_user_can( 'edit_theme_options' ) ) |
|
1144 | + if ( ! current_user_can('edit_theme_options')) |
|
1145 | 1145 | wp_die( -1 ); |
1146 | 1146 | |
1147 | - require_once ABSPATH . 'wp-admin/includes/nav-menu.php'; |
|
1147 | + require_once ABSPATH.'wp-admin/includes/nav-menu.php'; |
|
1148 | 1148 | |
1149 | 1149 | // For performance reasons, we omit some object properties from the checklist. |
1150 | 1150 | // The following is a hacky way to restore them when adding non-custom items. |
1151 | 1151 | |
1152 | 1152 | $menu_items_data = array(); |
1153 | - foreach ( (array) $_POST['menu-item'] as $menu_item_data ) { |
|
1153 | + foreach ((array) $_POST['menu-item'] as $menu_item_data) { |
|
1154 | 1154 | if ( |
1155 | - ! empty( $menu_item_data['menu-item-type'] ) && |
|
1155 | + ! empty($menu_item_data['menu-item-type']) && |
|
1156 | 1156 | 'custom' != $menu_item_data['menu-item-type'] && |
1157 | - ! empty( $menu_item_data['menu-item-object-id'] ) |
|
1157 | + ! empty($menu_item_data['menu-item-object-id']) |
|
1158 | 1158 | ) { |
1159 | - switch( $menu_item_data['menu-item-type'] ) { |
|
1159 | + switch ($menu_item_data['menu-item-type']) { |
|
1160 | 1160 | case 'post_type' : |
1161 | - $_object = get_post( $menu_item_data['menu-item-object-id'] ); |
|
1161 | + $_object = get_post($menu_item_data['menu-item-object-id']); |
|
1162 | 1162 | break; |
1163 | 1163 | |
1164 | 1164 | case 'post_type_archive' : |
1165 | - $_object = get_post_type_object( $menu_item_data['menu-item-object'] ); |
|
1165 | + $_object = get_post_type_object($menu_item_data['menu-item-object']); |
|
1166 | 1166 | break; |
1167 | 1167 | |
1168 | 1168 | case 'taxonomy' : |
1169 | - $_object = get_term( $menu_item_data['menu-item-object-id'], $menu_item_data['menu-item-object'] ); |
|
1169 | + $_object = get_term($menu_item_data['menu-item-object-id'], $menu_item_data['menu-item-object']); |
|
1170 | 1170 | break; |
1171 | 1171 | } |
1172 | 1172 | |
1173 | - $_menu_items = array_map( 'wp_setup_nav_menu_item', array( $_object ) ); |
|
1174 | - $_menu_item = reset( $_menu_items ); |
|
1173 | + $_menu_items = array_map('wp_setup_nav_menu_item', array($_object)); |
|
1174 | + $_menu_item = reset($_menu_items); |
|
1175 | 1175 | |
1176 | 1176 | // Restore the missing menu item properties |
1177 | 1177 | $menu_item_data['menu-item-description'] = $_menu_item->description; |
@@ -1180,28 +1180,28 @@ discard block |
||
1180 | 1180 | $menu_items_data[] = $menu_item_data; |
1181 | 1181 | } |
1182 | 1182 | |
1183 | - $item_ids = wp_save_nav_menu_items( 0, $menu_items_data ); |
|
1184 | - if ( is_wp_error( $item_ids ) ) |
|
1185 | - wp_die( 0 ); |
|
1183 | + $item_ids = wp_save_nav_menu_items(0, $menu_items_data); |
|
1184 | + if (is_wp_error($item_ids)) |
|
1185 | + wp_die(0); |
|
1186 | 1186 | |
1187 | 1187 | $menu_items = array(); |
1188 | 1188 | |
1189 | - foreach ( (array) $item_ids as $menu_item_id ) { |
|
1190 | - $menu_obj = get_post( $menu_item_id ); |
|
1191 | - if ( ! empty( $menu_obj->ID ) ) { |
|
1192 | - $menu_obj = wp_setup_nav_menu_item( $menu_obj ); |
|
1189 | + foreach ((array) $item_ids as $menu_item_id) { |
|
1190 | + $menu_obj = get_post($menu_item_id); |
|
1191 | + if ( ! empty($menu_obj->ID)) { |
|
1192 | + $menu_obj = wp_setup_nav_menu_item($menu_obj); |
|
1193 | 1193 | $menu_obj->label = $menu_obj->title; // don't show "(pending)" in ajax-added items |
1194 | 1194 | $menu_items[] = $menu_obj; |
1195 | 1195 | } |
1196 | 1196 | } |
1197 | 1197 | |
1198 | 1198 | /** This filter is documented in wp-admin/includes/nav-menu.php */ |
1199 | - $walker_class_name = apply_filters( 'wp_edit_nav_menu_walker', 'Walker_Nav_Menu_Edit', $_POST['menu'] ); |
|
1199 | + $walker_class_name = apply_filters('wp_edit_nav_menu_walker', 'Walker_Nav_Menu_Edit', $_POST['menu']); |
|
1200 | 1200 | |
1201 | - if ( ! class_exists( $walker_class_name ) ) |
|
1202 | - wp_die( 0 ); |
|
1201 | + if ( ! class_exists($walker_class_name)) |
|
1202 | + wp_die(0); |
|
1203 | 1203 | |
1204 | - if ( ! empty( $menu_items ) ) { |
|
1204 | + if ( ! empty($menu_items)) { |
|
1205 | 1205 | $args = array( |
1206 | 1206 | 'after' => '', |
1207 | 1207 | 'before' => '', |
@@ -1209,7 +1209,7 @@ discard block |
||
1209 | 1209 | 'link_before' => '', |
1210 | 1210 | 'walker' => new $walker_class_name, |
1211 | 1211 | ); |
1212 | - echo walk_nav_menu_tree( $menu_items, 0, (object) $args ); |
|
1212 | + echo walk_nav_menu_tree($menu_items, 0, (object) $args); |
|
1213 | 1213 | } |
1214 | 1214 | wp_die(); |
1215 | 1215 | } |
@@ -1220,86 +1220,86 @@ discard block |
||
1220 | 1220 | * @since 3.1.0 |
1221 | 1221 | */ |
1222 | 1222 | function wp_ajax_add_meta() { |
1223 | - check_ajax_referer( 'add-meta', '_ajax_nonce-add-meta' ); |
|
1223 | + check_ajax_referer('add-meta', '_ajax_nonce-add-meta'); |
|
1224 | 1224 | $c = 0; |
1225 | 1225 | $pid = (int) $_POST['post_id']; |
1226 | - $post = get_post( $pid ); |
|
1226 | + $post = get_post($pid); |
|
1227 | 1227 | |
1228 | - if ( isset($_POST['metakeyselect']) || isset($_POST['metakeyinput']) ) { |
|
1229 | - if ( !current_user_can( 'edit_post', $pid ) ) |
|
1228 | + if (isset($_POST['metakeyselect']) || isset($_POST['metakeyinput'])) { |
|
1229 | + if ( ! current_user_can('edit_post', $pid)) |
|
1230 | 1230 | wp_die( -1 ); |
1231 | - if ( isset($_POST['metakeyselect']) && '#NONE#' == $_POST['metakeyselect'] && empty($_POST['metakeyinput']) ) |
|
1232 | - wp_die( 1 ); |
|
1231 | + if (isset($_POST['metakeyselect']) && '#NONE#' == $_POST['metakeyselect'] && empty($_POST['metakeyinput'])) |
|
1232 | + wp_die(1); |
|
1233 | 1233 | |
1234 | 1234 | // If the post is an autodraft, save the post as a draft and then attempt to save the meta. |
1235 | - if ( $post->post_status == 'auto-draft' ) { |
|
1235 | + if ($post->post_status == 'auto-draft') { |
|
1236 | 1236 | $post_data = array(); |
1237 | 1237 | $post_data['action'] = 'draft'; // Warning fix |
1238 | 1238 | $post_data['post_ID'] = $pid; |
1239 | 1239 | $post_data['post_type'] = $post->post_type; |
1240 | 1240 | $post_data['post_status'] = 'draft'; |
1241 | 1241 | $now = current_time('timestamp', 1); |
1242 | - $post_data['post_title'] = sprintf( __( 'Draft created on %1$s at %2$s' ), date( __( 'F j, Y' ), $now ), date( __( 'g:i a' ), $now ) ); |
|
1242 | + $post_data['post_title'] = sprintf(__('Draft created on %1$s at %2$s'), date(__('F j, Y'), $now), date(__('g:i a'), $now)); |
|
1243 | 1243 | |
1244 | - $pid = edit_post( $post_data ); |
|
1245 | - if ( $pid ) { |
|
1246 | - if ( is_wp_error( $pid ) ) { |
|
1247 | - $x = new WP_Ajax_Response( array( |
|
1244 | + $pid = edit_post($post_data); |
|
1245 | + if ($pid) { |
|
1246 | + if (is_wp_error($pid)) { |
|
1247 | + $x = new WP_Ajax_Response(array( |
|
1248 | 1248 | 'what' => 'meta', |
1249 | 1249 | 'data' => $pid |
1250 | - ) ); |
|
1250 | + )); |
|
1251 | 1251 | $x->send(); |
1252 | 1252 | } |
1253 | 1253 | |
1254 | - if ( !$mid = add_meta( $pid ) ) |
|
1255 | - wp_die( __( 'Please provide a custom field value.' ) ); |
|
1254 | + if ( ! $mid = add_meta($pid)) |
|
1255 | + wp_die(__('Please provide a custom field value.')); |
|
1256 | 1256 | } else { |
1257 | - wp_die( 0 ); |
|
1257 | + wp_die(0); |
|
1258 | 1258 | } |
1259 | - } elseif ( ! $mid = add_meta( $pid ) ) { |
|
1260 | - wp_die( __( 'Please provide a custom field value.' ) ); |
|
1259 | + } elseif ( ! $mid = add_meta($pid)) { |
|
1260 | + wp_die(__('Please provide a custom field value.')); |
|
1261 | 1261 | } |
1262 | 1262 | |
1263 | - $meta = get_metadata_by_mid( 'post', $mid ); |
|
1263 | + $meta = get_metadata_by_mid('post', $mid); |
|
1264 | 1264 | $pid = (int) $meta->post_id; |
1265 | - $meta = get_object_vars( $meta ); |
|
1266 | - $x = new WP_Ajax_Response( array( |
|
1265 | + $meta = get_object_vars($meta); |
|
1266 | + $x = new WP_Ajax_Response(array( |
|
1267 | 1267 | 'what' => 'meta', |
1268 | 1268 | 'id' => $mid, |
1269 | - 'data' => _list_meta_row( $meta, $c ), |
|
1269 | + 'data' => _list_meta_row($meta, $c), |
|
1270 | 1270 | 'position' => 1, |
1271 | 1271 | 'supplemental' => array('postid' => $pid) |
1272 | - ) ); |
|
1272 | + )); |
|
1273 | 1273 | } else { // Update? |
1274 | - $mid = (int) key( $_POST['meta'] ); |
|
1275 | - $key = wp_unslash( $_POST['meta'][$mid]['key'] ); |
|
1276 | - $value = wp_unslash( $_POST['meta'][$mid]['value'] ); |
|
1277 | - if ( '' == trim($key) ) |
|
1278 | - wp_die( __( 'Please provide a custom field name.' ) ); |
|
1279 | - if ( '' == trim($value) ) |
|
1280 | - wp_die( __( 'Please provide a custom field value.' ) ); |
|
1281 | - if ( ! $meta = get_metadata_by_mid( 'post', $mid ) ) |
|
1282 | - wp_die( 0 ); // if meta doesn't exist |
|
1283 | - if ( is_protected_meta( $meta->meta_key, 'post' ) || is_protected_meta( $key, 'post' ) || |
|
1284 | - ! current_user_can( 'edit_post_meta', $meta->post_id, $meta->meta_key ) || |
|
1285 | - ! current_user_can( 'edit_post_meta', $meta->post_id, $key ) ) |
|
1274 | + $mid = (int) key($_POST['meta']); |
|
1275 | + $key = wp_unslash($_POST['meta'][$mid]['key']); |
|
1276 | + $value = wp_unslash($_POST['meta'][$mid]['value']); |
|
1277 | + if ('' == trim($key)) |
|
1278 | + wp_die(__('Please provide a custom field name.')); |
|
1279 | + if ('' == trim($value)) |
|
1280 | + wp_die(__('Please provide a custom field value.')); |
|
1281 | + if ( ! $meta = get_metadata_by_mid('post', $mid)) |
|
1282 | + wp_die(0); // if meta doesn't exist |
|
1283 | + if (is_protected_meta($meta->meta_key, 'post') || is_protected_meta($key, 'post') || |
|
1284 | + ! current_user_can('edit_post_meta', $meta->post_id, $meta->meta_key) || |
|
1285 | + ! current_user_can('edit_post_meta', $meta->post_id, $key)) |
|
1286 | 1286 | wp_die( -1 ); |
1287 | - if ( $meta->meta_value != $value || $meta->meta_key != $key ) { |
|
1288 | - if ( !$u = update_metadata_by_mid( 'post', $mid, $value, $key ) ) |
|
1289 | - wp_die( 0 ); // We know meta exists; we also know it's unchanged (or DB error, in which case there are bigger problems). |
|
1287 | + if ($meta->meta_value != $value || $meta->meta_key != $key) { |
|
1288 | + if ( ! $u = update_metadata_by_mid('post', $mid, $value, $key)) |
|
1289 | + wp_die(0); // We know meta exists; we also know it's unchanged (or DB error, in which case there are bigger problems). |
|
1290 | 1290 | } |
1291 | 1291 | |
1292 | - $x = new WP_Ajax_Response( array( |
|
1292 | + $x = new WP_Ajax_Response(array( |
|
1293 | 1293 | 'what' => 'meta', |
1294 | 1294 | 'id' => $mid, 'old_id' => $mid, |
1295 | - 'data' => _list_meta_row( array( |
|
1295 | + 'data' => _list_meta_row(array( |
|
1296 | 1296 | 'meta_key' => $key, |
1297 | 1297 | 'meta_value' => $value, |
1298 | 1298 | 'meta_id' => $mid |
1299 | - ), $c ), |
|
1299 | + ), $c), |
|
1300 | 1300 | 'position' => 0, |
1301 | 1301 | 'supplemental' => array('postid' => $meta->post_id) |
1302 | - ) ); |
|
1302 | + )); |
|
1303 | 1303 | } |
1304 | 1304 | $x->send(); |
1305 | 1305 | } |
@@ -1313,42 +1313,42 @@ discard block |
||
1313 | 1313 | * |
1314 | 1314 | * @param string $action Action to perform. |
1315 | 1315 | */ |
1316 | -function wp_ajax_add_user( $action ) { |
|
1316 | +function wp_ajax_add_user($action) { |
|
1317 | 1317 | global $wp_list_table; |
1318 | - if ( empty( $action ) ) |
|
1318 | + if (empty($action)) |
|
1319 | 1319 | $action = 'add-user'; |
1320 | 1320 | |
1321 | - check_ajax_referer( $action ); |
|
1322 | - if ( ! current_user_can('create_users') ) |
|
1321 | + check_ajax_referer($action); |
|
1322 | + if ( ! current_user_can('create_users')) |
|
1323 | 1323 | wp_die( -1 ); |
1324 | - if ( ! $user_id = edit_user() ) { |
|
1325 | - wp_die( 0 ); |
|
1326 | - } elseif ( is_wp_error( $user_id ) ) { |
|
1327 | - $x = new WP_Ajax_Response( array( |
|
1324 | + if ( ! $user_id = edit_user()) { |
|
1325 | + wp_die(0); |
|
1326 | + } elseif (is_wp_error($user_id)) { |
|
1327 | + $x = new WP_Ajax_Response(array( |
|
1328 | 1328 | 'what' => 'user', |
1329 | 1329 | 'id' => $user_id |
1330 | - ) ); |
|
1330 | + )); |
|
1331 | 1331 | $x->send(); |
1332 | 1332 | } |
1333 | - $user_object = get_userdata( $user_id ); |
|
1333 | + $user_object = get_userdata($user_id); |
|
1334 | 1334 | |
1335 | 1335 | $wp_list_table = _get_list_table('WP_Users_List_Table'); |
1336 | 1336 | |
1337 | - $role = current( $user_object->roles ); |
|
1337 | + $role = current($user_object->roles); |
|
1338 | 1338 | |
1339 | - $x = new WP_Ajax_Response( array( |
|
1339 | + $x = new WP_Ajax_Response(array( |
|
1340 | 1340 | 'what' => 'user', |
1341 | 1341 | 'id' => $user_id, |
1342 | - 'data' => $wp_list_table->single_row( $user_object, '', $role ), |
|
1342 | + 'data' => $wp_list_table->single_row($user_object, '', $role), |
|
1343 | 1343 | 'supplemental' => array( |
1344 | 1344 | 'show-link' => sprintf( |
1345 | 1345 | /* translators: %s: the new user */ |
1346 | - __( 'User %s added' ), |
|
1347 | - '<a href="#user-' . $user_id . '">' . $user_object->user_login . '</a>' |
|
1346 | + __('User %s added'), |
|
1347 | + '<a href="#user-'.$user_id.'">'.$user_object->user_login.'</a>' |
|
1348 | 1348 | ), |
1349 | 1349 | 'role' => $role, |
1350 | 1350 | ) |
1351 | - ) ); |
|
1351 | + )); |
|
1352 | 1352 | $x->send(); |
1353 | 1353 | } |
1354 | 1354 | |
@@ -1358,30 +1358,30 @@ discard block |
||
1358 | 1358 | * @since 3.1.0 |
1359 | 1359 | */ |
1360 | 1360 | function wp_ajax_closed_postboxes() { |
1361 | - check_ajax_referer( 'closedpostboxes', 'closedpostboxesnonce' ); |
|
1362 | - $closed = isset( $_POST['closed'] ) ? explode( ',', $_POST['closed']) : array(); |
|
1361 | + check_ajax_referer('closedpostboxes', 'closedpostboxesnonce'); |
|
1362 | + $closed = isset($_POST['closed']) ? explode(',', $_POST['closed']) : array(); |
|
1363 | 1363 | $closed = array_filter($closed); |
1364 | 1364 | |
1365 | - $hidden = isset( $_POST['hidden'] ) ? explode( ',', $_POST['hidden']) : array(); |
|
1365 | + $hidden = isset($_POST['hidden']) ? explode(',', $_POST['hidden']) : array(); |
|
1366 | 1366 | $hidden = array_filter($hidden); |
1367 | 1367 | |
1368 | - $page = isset( $_POST['page'] ) ? $_POST['page'] : ''; |
|
1368 | + $page = isset($_POST['page']) ? $_POST['page'] : ''; |
|
1369 | 1369 | |
1370 | - if ( $page != sanitize_key( $page ) ) |
|
1371 | - wp_die( 0 ); |
|
1370 | + if ($page != sanitize_key($page)) |
|
1371 | + wp_die(0); |
|
1372 | 1372 | |
1373 | - if ( ! $user = wp_get_current_user() ) |
|
1373 | + if ( ! $user = wp_get_current_user()) |
|
1374 | 1374 | wp_die( -1 ); |
1375 | 1375 | |
1376 | - if ( is_array($closed) ) |
|
1376 | + if (is_array($closed)) |
|
1377 | 1377 | update_user_option($user->ID, "closedpostboxes_$page", $closed, true); |
1378 | 1378 | |
1379 | - if ( is_array($hidden) ) { |
|
1380 | - $hidden = array_diff( $hidden, array('submitdiv', 'linksubmitdiv', 'manage-menu', 'create-menu') ); // postboxes that are always shown |
|
1379 | + if (is_array($hidden)) { |
|
1380 | + $hidden = array_diff($hidden, array('submitdiv', 'linksubmitdiv', 'manage-menu', 'create-menu')); // postboxes that are always shown |
|
1381 | 1381 | update_user_option($user->ID, "metaboxhidden_$page", $hidden, true); |
1382 | 1382 | } |
1383 | 1383 | |
1384 | - wp_die( 1 ); |
|
1384 | + wp_die(1); |
|
1385 | 1385 | } |
1386 | 1386 | |
1387 | 1387 | /** |
@@ -1390,19 +1390,19 @@ discard block |
||
1390 | 1390 | * @since 3.1.0 |
1391 | 1391 | */ |
1392 | 1392 | function wp_ajax_hidden_columns() { |
1393 | - check_ajax_referer( 'screen-options-nonce', 'screenoptionnonce' ); |
|
1394 | - $page = isset( $_POST['page'] ) ? $_POST['page'] : ''; |
|
1393 | + check_ajax_referer('screen-options-nonce', 'screenoptionnonce'); |
|
1394 | + $page = isset($_POST['page']) ? $_POST['page'] : ''; |
|
1395 | 1395 | |
1396 | - if ( $page != sanitize_key( $page ) ) |
|
1397 | - wp_die( 0 ); |
|
1396 | + if ($page != sanitize_key($page)) |
|
1397 | + wp_die(0); |
|
1398 | 1398 | |
1399 | - if ( ! $user = wp_get_current_user() ) |
|
1399 | + if ( ! $user = wp_get_current_user()) |
|
1400 | 1400 | wp_die( -1 ); |
1401 | 1401 | |
1402 | - $hidden = ! empty( $_POST['hidden'] ) ? explode( ',', $_POST['hidden'] ) : array(); |
|
1403 | - update_user_option( $user->ID, "manage{$page}columnshidden", $hidden, true ); |
|
1402 | + $hidden = ! empty($_POST['hidden']) ? explode(',', $_POST['hidden']) : array(); |
|
1403 | + update_user_option($user->ID, "manage{$page}columnshidden", $hidden, true); |
|
1404 | 1404 | |
1405 | - wp_die( 1 ); |
|
1405 | + wp_die(1); |
|
1406 | 1406 | } |
1407 | 1407 | |
1408 | 1408 | /** |
@@ -1411,14 +1411,14 @@ discard block |
||
1411 | 1411 | * @since 3.1.0 |
1412 | 1412 | */ |
1413 | 1413 | function wp_ajax_update_welcome_panel() { |
1414 | - check_ajax_referer( 'welcome-panel-nonce', 'welcomepanelnonce' ); |
|
1414 | + check_ajax_referer('welcome-panel-nonce', 'welcomepanelnonce'); |
|
1415 | 1415 | |
1416 | - if ( ! current_user_can( 'edit_theme_options' ) ) |
|
1416 | + if ( ! current_user_can('edit_theme_options')) |
|
1417 | 1417 | wp_die( -1 ); |
1418 | 1418 | |
1419 | - update_user_meta( get_current_user_id(), 'show_welcome_panel', empty( $_POST['visible'] ) ? 0 : 1 ); |
|
1419 | + update_user_meta(get_current_user_id(), 'show_welcome_panel', empty($_POST['visible']) ? 0 : 1); |
|
1420 | 1420 | |
1421 | - wp_die( 1 ); |
|
1421 | + wp_die(1); |
|
1422 | 1422 | } |
1423 | 1423 | |
1424 | 1424 | /** |
@@ -1427,31 +1427,31 @@ discard block |
||
1427 | 1427 | * @since 3.1.0 |
1428 | 1428 | */ |
1429 | 1429 | function wp_ajax_menu_get_metabox() { |
1430 | - if ( ! current_user_can( 'edit_theme_options' ) ) |
|
1430 | + if ( ! current_user_can('edit_theme_options')) |
|
1431 | 1431 | wp_die( -1 ); |
1432 | 1432 | |
1433 | - require_once ABSPATH . 'wp-admin/includes/nav-menu.php'; |
|
1433 | + require_once ABSPATH.'wp-admin/includes/nav-menu.php'; |
|
1434 | 1434 | |
1435 | - if ( isset( $_POST['item-type'] ) && 'post_type' == $_POST['item-type'] ) { |
|
1435 | + if (isset($_POST['item-type']) && 'post_type' == $_POST['item-type']) { |
|
1436 | 1436 | $type = 'posttype'; |
1437 | 1437 | $callback = 'wp_nav_menu_item_post_type_meta_box'; |
1438 | - $items = (array) get_post_types( array( 'show_in_nav_menus' => true ), 'object' ); |
|
1439 | - } elseif ( isset( $_POST['item-type'] ) && 'taxonomy' == $_POST['item-type'] ) { |
|
1438 | + $items = (array) get_post_types(array('show_in_nav_menus' => true), 'object'); |
|
1439 | + } elseif (isset($_POST['item-type']) && 'taxonomy' == $_POST['item-type']) { |
|
1440 | 1440 | $type = 'taxonomy'; |
1441 | 1441 | $callback = 'wp_nav_menu_item_taxonomy_meta_box'; |
1442 | - $items = (array) get_taxonomies( array( 'show_ui' => true ), 'object' ); |
|
1442 | + $items = (array) get_taxonomies(array('show_ui' => true), 'object'); |
|
1443 | 1443 | } |
1444 | 1444 | |
1445 | - if ( ! empty( $_POST['item-object'] ) && isset( $items[$_POST['item-object']] ) ) { |
|
1446 | - $menus_meta_box_object = $items[ $_POST['item-object'] ]; |
|
1445 | + if ( ! empty($_POST['item-object']) && isset($items[$_POST['item-object']])) { |
|
1446 | + $menus_meta_box_object = $items[$_POST['item-object']]; |
|
1447 | 1447 | |
1448 | 1448 | /** This filter is documented in wp-admin/includes/nav-menu.php */ |
1449 | - $item = apply_filters( 'nav_menu_meta_box_object', $menus_meta_box_object ); |
|
1449 | + $item = apply_filters('nav_menu_meta_box_object', $menus_meta_box_object); |
|
1450 | 1450 | ob_start(); |
1451 | 1451 | call_user_func_array($callback, array( |
1452 | 1452 | null, |
1453 | 1453 | array( |
1454 | - 'id' => 'add-' . $item->name, |
|
1454 | + 'id' => 'add-'.$item->name, |
|
1455 | 1455 | 'title' => $item->labels->name, |
1456 | 1456 | 'callback' => $callback, |
1457 | 1457 | 'args' => $item, |
@@ -1461,7 +1461,7 @@ discard block |
||
1461 | 1461 | $markup = ob_get_clean(); |
1462 | 1462 | |
1463 | 1463 | echo wp_json_encode(array( |
1464 | - 'replace-id' => $type . '-' . $item->name, |
|
1464 | + 'replace-id' => $type.'-'.$item->name, |
|
1465 | 1465 | 'markup' => $markup, |
1466 | 1466 | )); |
1467 | 1467 | } |
@@ -1475,27 +1475,27 @@ discard block |
||
1475 | 1475 | * @since 3.1.0 |
1476 | 1476 | */ |
1477 | 1477 | function wp_ajax_wp_link_ajax() { |
1478 | - check_ajax_referer( 'internal-linking', '_ajax_linking_nonce' ); |
|
1478 | + check_ajax_referer('internal-linking', '_ajax_linking_nonce'); |
|
1479 | 1479 | |
1480 | 1480 | $args = array(); |
1481 | 1481 | |
1482 | - if ( isset( $_POST['search'] ) ) { |
|
1483 | - $args['s'] = wp_unslash( $_POST['search'] ); |
|
1482 | + if (isset($_POST['search'])) { |
|
1483 | + $args['s'] = wp_unslash($_POST['search']); |
|
1484 | 1484 | } |
1485 | 1485 | |
1486 | - if ( isset( $_POST['term'] ) ) { |
|
1487 | - $args['s'] = wp_unslash( $_POST['term'] ); |
|
1486 | + if (isset($_POST['term'])) { |
|
1487 | + $args['s'] = wp_unslash($_POST['term']); |
|
1488 | 1488 | } |
1489 | 1489 | |
1490 | - $args['pagenum'] = ! empty( $_POST['page'] ) ? absint( $_POST['page'] ) : 1; |
|
1490 | + $args['pagenum'] = ! empty($_POST['page']) ? absint($_POST['page']) : 1; |
|
1491 | 1491 | |
1492 | - require(ABSPATH . WPINC . '/class-wp-editor.php'); |
|
1493 | - $results = _WP_Editors::wp_link_query( $args ); |
|
1492 | + require(ABSPATH.WPINC.'/class-wp-editor.php'); |
|
1493 | + $results = _WP_Editors::wp_link_query($args); |
|
1494 | 1494 | |
1495 | - if ( ! isset( $results ) ) |
|
1496 | - wp_die( 0 ); |
|
1495 | + if ( ! isset($results)) |
|
1496 | + wp_die(0); |
|
1497 | 1497 | |
1498 | - echo wp_json_encode( $results ); |
|
1498 | + echo wp_json_encode($results); |
|
1499 | 1499 | echo "\n"; |
1500 | 1500 | |
1501 | 1501 | wp_die(); |
@@ -1507,13 +1507,13 @@ discard block |
||
1507 | 1507 | * @since 3.1.0 |
1508 | 1508 | */ |
1509 | 1509 | function wp_ajax_menu_locations_save() { |
1510 | - if ( ! current_user_can( 'edit_theme_options' ) ) |
|
1510 | + if ( ! current_user_can('edit_theme_options')) |
|
1511 | 1511 | wp_die( -1 ); |
1512 | - check_ajax_referer( 'add-menu_item', 'menu-settings-column-nonce' ); |
|
1513 | - if ( ! isset( $_POST['menu-locations'] ) ) |
|
1514 | - wp_die( 0 ); |
|
1515 | - set_theme_mod( 'nav_menu_locations', array_map( 'absint', $_POST['menu-locations'] ) ); |
|
1516 | - wp_die( 1 ); |
|
1512 | + check_ajax_referer('add-menu_item', 'menu-settings-column-nonce'); |
|
1513 | + if ( ! isset($_POST['menu-locations'])) |
|
1514 | + wp_die(0); |
|
1515 | + set_theme_mod('nav_menu_locations', array_map('absint', $_POST['menu-locations'])); |
|
1516 | + wp_die(1); |
|
1517 | 1517 | } |
1518 | 1518 | |
1519 | 1519 | /** |
@@ -1522,28 +1522,28 @@ discard block |
||
1522 | 1522 | * @since 3.1.0 |
1523 | 1523 | */ |
1524 | 1524 | function wp_ajax_meta_box_order() { |
1525 | - check_ajax_referer( 'meta-box-order' ); |
|
1526 | - $order = isset( $_POST['order'] ) ? (array) $_POST['order'] : false; |
|
1527 | - $page_columns = isset( $_POST['page_columns'] ) ? $_POST['page_columns'] : 'auto'; |
|
1525 | + check_ajax_referer('meta-box-order'); |
|
1526 | + $order = isset($_POST['order']) ? (array) $_POST['order'] : false; |
|
1527 | + $page_columns = isset($_POST['page_columns']) ? $_POST['page_columns'] : 'auto'; |
|
1528 | 1528 | |
1529 | - if ( $page_columns != 'auto' ) |
|
1529 | + if ($page_columns != 'auto') |
|
1530 | 1530 | $page_columns = (int) $page_columns; |
1531 | 1531 | |
1532 | - $page = isset( $_POST['page'] ) ? $_POST['page'] : ''; |
|
1532 | + $page = isset($_POST['page']) ? $_POST['page'] : ''; |
|
1533 | 1533 | |
1534 | - if ( $page != sanitize_key( $page ) ) |
|
1535 | - wp_die( 0 ); |
|
1534 | + if ($page != sanitize_key($page)) |
|
1535 | + wp_die(0); |
|
1536 | 1536 | |
1537 | - if ( ! $user = wp_get_current_user() ) |
|
1537 | + if ( ! $user = wp_get_current_user()) |
|
1538 | 1538 | wp_die( -1 ); |
1539 | 1539 | |
1540 | - if ( $order ) |
|
1540 | + if ($order) |
|
1541 | 1541 | update_user_option($user->ID, "meta-box-order_$page", $order, true); |
1542 | 1542 | |
1543 | - if ( $page_columns ) |
|
1543 | + if ($page_columns) |
|
1544 | 1544 | update_user_option($user->ID, "screen_layout_$page", $page_columns, true); |
1545 | 1545 | |
1546 | - wp_die( 1 ); |
|
1546 | + wp_die(1); |
|
1547 | 1547 | } |
1548 | 1548 | |
1549 | 1549 | /** |
@@ -1552,12 +1552,12 @@ discard block |
||
1552 | 1552 | * @since 3.1.0 |
1553 | 1553 | */ |
1554 | 1554 | function wp_ajax_menu_quick_search() { |
1555 | - if ( ! current_user_can( 'edit_theme_options' ) ) |
|
1555 | + if ( ! current_user_can('edit_theme_options')) |
|
1556 | 1556 | wp_die( -1 ); |
1557 | 1557 | |
1558 | - require_once ABSPATH . 'wp-admin/includes/nav-menu.php'; |
|
1558 | + require_once ABSPATH.'wp-admin/includes/nav-menu.php'; |
|
1559 | 1559 | |
1560 | - _wp_ajax_menu_quick_search( $_POST ); |
|
1560 | + _wp_ajax_menu_quick_search($_POST); |
|
1561 | 1561 | |
1562 | 1562 | wp_die(); |
1563 | 1563 | } |
@@ -1568,9 +1568,9 @@ discard block |
||
1568 | 1568 | * @since 3.1.0 |
1569 | 1569 | */ |
1570 | 1570 | function wp_ajax_get_permalink() { |
1571 | - check_ajax_referer( 'getpermalink', 'getpermalinknonce' ); |
|
1572 | - $post_id = isset($_POST['post_id'])? intval($_POST['post_id']) : 0; |
|
1573 | - wp_die( get_preview_post_link( $post_id ) ); |
|
1571 | + check_ajax_referer('getpermalink', 'getpermalinknonce'); |
|
1572 | + $post_id = isset($_POST['post_id']) ? intval($_POST['post_id']) : 0; |
|
1573 | + wp_die(get_preview_post_link($post_id)); |
|
1574 | 1574 | } |
1575 | 1575 | |
1576 | 1576 | /** |
@@ -1579,11 +1579,11 @@ discard block |
||
1579 | 1579 | * @since 3.1.0 |
1580 | 1580 | */ |
1581 | 1581 | function wp_ajax_sample_permalink() { |
1582 | - check_ajax_referer( 'samplepermalink', 'samplepermalinknonce' ); |
|
1583 | - $post_id = isset($_POST['post_id'])? intval($_POST['post_id']) : 0; |
|
1584 | - $title = isset($_POST['new_title'])? $_POST['new_title'] : ''; |
|
1585 | - $slug = isset($_POST['new_slug'])? $_POST['new_slug'] : null; |
|
1586 | - wp_die( get_sample_permalink_html( $post_id, $title, $slug ) ); |
|
1582 | + check_ajax_referer('samplepermalink', 'samplepermalinknonce'); |
|
1583 | + $post_id = isset($_POST['post_id']) ? intval($_POST['post_id']) : 0; |
|
1584 | + $title = isset($_POST['new_title']) ? $_POST['new_title'] : ''; |
|
1585 | + $slug = isset($_POST['new_slug']) ? $_POST['new_slug'] : null; |
|
1586 | + wp_die(get_sample_permalink_html($post_id, $title, $slug)); |
|
1587 | 1587 | } |
1588 | 1588 | |
1589 | 1589 | /** |
@@ -1596,29 +1596,29 @@ discard block |
||
1596 | 1596 | function wp_ajax_inline_save() { |
1597 | 1597 | global $wp_list_table, $mode; |
1598 | 1598 | |
1599 | - check_ajax_referer( 'inlineeditnonce', '_inline_edit' ); |
|
1599 | + check_ajax_referer('inlineeditnonce', '_inline_edit'); |
|
1600 | 1600 | |
1601 | - if ( ! isset($_POST['post_ID']) || ! ( $post_ID = (int) $_POST['post_ID'] ) ) |
|
1601 | + if ( ! isset($_POST['post_ID']) || ! ($post_ID = (int) $_POST['post_ID'])) |
|
1602 | 1602 | wp_die(); |
1603 | 1603 | |
1604 | - if ( 'page' == $_POST['post_type'] ) { |
|
1605 | - if ( ! current_user_can( 'edit_page', $post_ID ) ) |
|
1606 | - wp_die( __( 'You are not allowed to edit this page.' ) ); |
|
1604 | + if ('page' == $_POST['post_type']) { |
|
1605 | + if ( ! current_user_can('edit_page', $post_ID)) |
|
1606 | + wp_die(__('You are not allowed to edit this page.')); |
|
1607 | 1607 | } else { |
1608 | - if ( ! current_user_can( 'edit_post', $post_ID ) ) |
|
1609 | - wp_die( __( 'You are not allowed to edit this post.' ) ); |
|
1608 | + if ( ! current_user_can('edit_post', $post_ID)) |
|
1609 | + wp_die(__('You are not allowed to edit this post.')); |
|
1610 | 1610 | } |
1611 | 1611 | |
1612 | - if ( $last = wp_check_post_lock( $post_ID ) ) { |
|
1613 | - $last_user = get_userdata( $last ); |
|
1614 | - $last_user_name = $last_user ? $last_user->display_name : __( 'Someone' ); |
|
1615 | - printf( $_POST['post_type'] == 'page' ? __( 'Saving is disabled: %s is currently editing this page.' ) : __( 'Saving is disabled: %s is currently editing this post.' ), esc_html( $last_user_name ) ); |
|
1612 | + if ($last = wp_check_post_lock($post_ID)) { |
|
1613 | + $last_user = get_userdata($last); |
|
1614 | + $last_user_name = $last_user ? $last_user->display_name : __('Someone'); |
|
1615 | + printf($_POST['post_type'] == 'page' ? __('Saving is disabled: %s is currently editing this page.') : __('Saving is disabled: %s is currently editing this post.'), esc_html($last_user_name)); |
|
1616 | 1616 | wp_die(); |
1617 | 1617 | } |
1618 | 1618 | |
1619 | 1619 | $data = &$_POST; |
1620 | 1620 | |
1621 | - $post = get_post( $post_ID, ARRAY_A ); |
|
1621 | + $post = get_post($post_ID, ARRAY_A); |
|
1622 | 1622 | |
1623 | 1623 | // Since it's coming from the database. |
1624 | 1624 | $post = wp_slash($post); |
@@ -1629,57 +1629,57 @@ discard block |
||
1629 | 1629 | // Rename. |
1630 | 1630 | $data['user_ID'] = get_current_user_id(); |
1631 | 1631 | |
1632 | - if ( isset($data['post_parent']) ) |
|
1632 | + if (isset($data['post_parent'])) |
|
1633 | 1633 | $data['parent_id'] = $data['post_parent']; |
1634 | 1634 | |
1635 | 1635 | // Status. |
1636 | - if ( isset( $data['keep_private'] ) && 'private' == $data['keep_private'] ) { |
|
1636 | + if (isset($data['keep_private']) && 'private' == $data['keep_private']) { |
|
1637 | 1637 | $data['visibility'] = 'private'; |
1638 | 1638 | $data['post_status'] = 'private'; |
1639 | 1639 | } else { |
1640 | 1640 | $data['post_status'] = $data['_status']; |
1641 | 1641 | } |
1642 | 1642 | |
1643 | - if ( empty($data['comment_status']) ) |
|
1643 | + if (empty($data['comment_status'])) |
|
1644 | 1644 | $data['comment_status'] = 'closed'; |
1645 | - if ( empty($data['ping_status']) ) |
|
1645 | + if (empty($data['ping_status'])) |
|
1646 | 1646 | $data['ping_status'] = 'closed'; |
1647 | 1647 | |
1648 | 1648 | // Exclude terms from taxonomies that are not supposed to appear in Quick Edit. |
1649 | - if ( ! empty( $data['tax_input'] ) ) { |
|
1650 | - foreach ( $data['tax_input'] as $taxonomy => $terms ) { |
|
1651 | - $tax_object = get_taxonomy( $taxonomy ); |
|
1649 | + if ( ! empty($data['tax_input'])) { |
|
1650 | + foreach ($data['tax_input'] as $taxonomy => $terms) { |
|
1651 | + $tax_object = get_taxonomy($taxonomy); |
|
1652 | 1652 | /** This filter is documented in wp-admin/includes/class-wp-posts-list-table.php */ |
1653 | - if ( ! apply_filters( 'quick_edit_show_taxonomy', $tax_object->show_in_quick_edit, $taxonomy, $post['post_type'] ) ) { |
|
1654 | - unset( $data['tax_input'][ $taxonomy ] ); |
|
1653 | + if ( ! apply_filters('quick_edit_show_taxonomy', $tax_object->show_in_quick_edit, $taxonomy, $post['post_type'])) { |
|
1654 | + unset($data['tax_input'][$taxonomy]); |
|
1655 | 1655 | } |
1656 | 1656 | } |
1657 | 1657 | } |
1658 | 1658 | |
1659 | 1659 | // Hack: wp_unique_post_slug() doesn't work for drafts, so we will fake that our post is published. |
1660 | - if ( ! empty( $data['post_name'] ) && in_array( $post['post_status'], array( 'draft', 'pending' ) ) ) { |
|
1660 | + if ( ! empty($data['post_name']) && in_array($post['post_status'], array('draft', 'pending'))) { |
|
1661 | 1661 | $post['post_status'] = 'publish'; |
1662 | - $data['post_name'] = wp_unique_post_slug( $data['post_name'], $post['ID'], $post['post_status'], $post['post_type'], $post['post_parent'] ); |
|
1662 | + $data['post_name'] = wp_unique_post_slug($data['post_name'], $post['ID'], $post['post_status'], $post['post_type'], $post['post_parent']); |
|
1663 | 1663 | } |
1664 | 1664 | |
1665 | 1665 | // Update the post. |
1666 | 1666 | edit_post(); |
1667 | 1667 | |
1668 | - $wp_list_table = _get_list_table( 'WP_Posts_List_Table', array( 'screen' => $_POST['screen'] ) ); |
|
1668 | + $wp_list_table = _get_list_table('WP_Posts_List_Table', array('screen' => $_POST['screen'])); |
|
1669 | 1669 | |
1670 | 1670 | $mode = $_POST['post_view'] === 'excerpt' ? 'excerpt' : 'list'; |
1671 | 1671 | |
1672 | 1672 | $level = 0; |
1673 | - $request_post = array( get_post( $_POST['post_ID'] ) ); |
|
1673 | + $request_post = array(get_post($_POST['post_ID'])); |
|
1674 | 1674 | $parent = $request_post[0]->post_parent; |
1675 | 1675 | |
1676 | - while ( $parent > 0 ) { |
|
1677 | - $parent_post = get_post( $parent ); |
|
1676 | + while ($parent > 0) { |
|
1677 | + $parent_post = get_post($parent); |
|
1678 | 1678 | $parent = $parent_post->post_parent; |
1679 | 1679 | $level++; |
1680 | 1680 | } |
1681 | 1681 | |
1682 | - $wp_list_table->display_rows( array( get_post( $_POST['post_ID'] ) ), $level ); |
|
1682 | + $wp_list_table->display_rows(array(get_post($_POST['post_ID'])), $level); |
|
1683 | 1683 | |
1684 | 1684 | wp_die(); |
1685 | 1685 | } |
@@ -1694,45 +1694,45 @@ discard block |
||
1694 | 1694 | function wp_ajax_inline_save_tax() { |
1695 | 1695 | global $wp_list_table; |
1696 | 1696 | |
1697 | - check_ajax_referer( 'taxinlineeditnonce', '_inline_edit' ); |
|
1697 | + check_ajax_referer('taxinlineeditnonce', '_inline_edit'); |
|
1698 | 1698 | |
1699 | - $taxonomy = sanitize_key( $_POST['taxonomy'] ); |
|
1700 | - $tax = get_taxonomy( $taxonomy ); |
|
1701 | - if ( ! $tax ) |
|
1702 | - wp_die( 0 ); |
|
1699 | + $taxonomy = sanitize_key($_POST['taxonomy']); |
|
1700 | + $tax = get_taxonomy($taxonomy); |
|
1701 | + if ( ! $tax) |
|
1702 | + wp_die(0); |
|
1703 | 1703 | |
1704 | - if ( ! current_user_can( $tax->cap->edit_terms ) ) |
|
1704 | + if ( ! current_user_can($tax->cap->edit_terms)) |
|
1705 | 1705 | wp_die( -1 ); |
1706 | 1706 | |
1707 | - $wp_list_table = _get_list_table( 'WP_Terms_List_Table', array( 'screen' => 'edit-' . $taxonomy ) ); |
|
1707 | + $wp_list_table = _get_list_table('WP_Terms_List_Table', array('screen' => 'edit-'.$taxonomy)); |
|
1708 | 1708 | |
1709 | - if ( ! isset($_POST['tax_ID']) || ! ( $id = (int) $_POST['tax_ID'] ) ) |
|
1709 | + if ( ! isset($_POST['tax_ID']) || ! ($id = (int) $_POST['tax_ID'])) |
|
1710 | 1710 | wp_die( -1 ); |
1711 | 1711 | |
1712 | - $tag = get_term( $id, $taxonomy ); |
|
1712 | + $tag = get_term($id, $taxonomy); |
|
1713 | 1713 | $_POST['description'] = $tag->description; |
1714 | 1714 | |
1715 | 1715 | $updated = wp_update_term($id, $taxonomy, $_POST); |
1716 | - if ( $updated && !is_wp_error($updated) ) { |
|
1717 | - $tag = get_term( $updated['term_id'], $taxonomy ); |
|
1718 | - if ( !$tag || is_wp_error( $tag ) ) { |
|
1719 | - if ( is_wp_error($tag) && $tag->get_error_message() ) |
|
1720 | - wp_die( $tag->get_error_message() ); |
|
1721 | - wp_die( __( 'Item not updated.' ) ); |
|
1716 | + if ($updated && ! is_wp_error($updated)) { |
|
1717 | + $tag = get_term($updated['term_id'], $taxonomy); |
|
1718 | + if ( ! $tag || is_wp_error($tag)) { |
|
1719 | + if (is_wp_error($tag) && $tag->get_error_message()) |
|
1720 | + wp_die($tag->get_error_message()); |
|
1721 | + wp_die(__('Item not updated.')); |
|
1722 | 1722 | } |
1723 | 1723 | } else { |
1724 | - if ( is_wp_error($updated) && $updated->get_error_message() ) |
|
1725 | - wp_die( $updated->get_error_message() ); |
|
1726 | - wp_die( __( 'Item not updated.' ) ); |
|
1724 | + if (is_wp_error($updated) && $updated->get_error_message()) |
|
1725 | + wp_die($updated->get_error_message()); |
|
1726 | + wp_die(__('Item not updated.')); |
|
1727 | 1727 | } |
1728 | 1728 | $level = 0; |
1729 | 1729 | $parent = $tag->parent; |
1730 | - while ( $parent > 0 ) { |
|
1731 | - $parent_tag = get_term( $parent, $taxonomy ); |
|
1730 | + while ($parent > 0) { |
|
1731 | + $parent_tag = get_term($parent, $taxonomy); |
|
1732 | 1732 | $parent = $parent_tag->parent; |
1733 | 1733 | $level++; |
1734 | 1734 | } |
1735 | - $wp_list_table->single_row( $tag, $level ); |
|
1735 | + $wp_list_table->single_row($tag, $level); |
|
1736 | 1736 | wp_die(); |
1737 | 1737 | } |
1738 | 1738 | |
@@ -1744,33 +1744,33 @@ discard block |
||
1744 | 1744 | * @since 3.1.0 |
1745 | 1745 | */ |
1746 | 1746 | function wp_ajax_find_posts() { |
1747 | - check_ajax_referer( 'find-posts' ); |
|
1747 | + check_ajax_referer('find-posts'); |
|
1748 | 1748 | |
1749 | - $post_types = get_post_types( array( 'public' => true ), 'objects' ); |
|
1750 | - unset( $post_types['attachment'] ); |
|
1749 | + $post_types = get_post_types(array('public' => true), 'objects'); |
|
1750 | + unset($post_types['attachment']); |
|
1751 | 1751 | |
1752 | - $s = wp_unslash( $_POST['ps'] ); |
|
1752 | + $s = wp_unslash($_POST['ps']); |
|
1753 | 1753 | $args = array( |
1754 | - 'post_type' => array_keys( $post_types ), |
|
1754 | + 'post_type' => array_keys($post_types), |
|
1755 | 1755 | 'post_status' => 'any', |
1756 | 1756 | 'posts_per_page' => 50, |
1757 | 1757 | ); |
1758 | - if ( '' !== $s ) |
|
1758 | + if ('' !== $s) |
|
1759 | 1759 | $args['s'] = $s; |
1760 | 1760 | |
1761 | - $posts = get_posts( $args ); |
|
1761 | + $posts = get_posts($args); |
|
1762 | 1762 | |
1763 | - if ( ! $posts ) { |
|
1764 | - wp_send_json_error( __( 'No items found.' ) ); |
|
1763 | + if ( ! $posts) { |
|
1764 | + wp_send_json_error(__('No items found.')); |
|
1765 | 1765 | } |
1766 | 1766 | |
1767 | 1767 | $html = '<table class="widefat"><thead><tr><th class="found-radio"><br /></th><th>'.__('Title').'</th><th class="no-break">'.__('Type').'</th><th class="no-break">'.__('Date').'</th><th class="no-break">'.__('Status').'</th></tr></thead><tbody>'; |
1768 | 1768 | $alt = ''; |
1769 | - foreach ( $posts as $post ) { |
|
1770 | - $title = trim( $post->post_title ) ? $post->post_title : __( '(no title)' ); |
|
1771 | - $alt = ( 'alternate' == $alt ) ? '' : 'alternate'; |
|
1769 | + foreach ($posts as $post) { |
|
1770 | + $title = trim($post->post_title) ? $post->post_title : __('(no title)'); |
|
1771 | + $alt = ('alternate' == $alt) ? '' : 'alternate'; |
|
1772 | 1772 | |
1773 | - switch ( $post->post_status ) { |
|
1773 | + switch ($post->post_status) { |
|
1774 | 1774 | case 'publish' : |
1775 | 1775 | case 'private' : |
1776 | 1776 | $stat = __('Published'); |
@@ -1786,20 +1786,20 @@ discard block |
||
1786 | 1786 | break; |
1787 | 1787 | } |
1788 | 1788 | |
1789 | - if ( '0000-00-00 00:00:00' == $post->post_date ) { |
|
1789 | + if ('0000-00-00 00:00:00' == $post->post_date) { |
|
1790 | 1790 | $time = ''; |
1791 | 1791 | } else { |
1792 | 1792 | /* translators: date format in table columns, see http://php.net/date */ |
1793 | 1793 | $time = mysql2date(__('Y/m/d'), $post->post_date); |
1794 | 1794 | } |
1795 | 1795 | |
1796 | - $html .= '<tr class="' . trim( 'found-posts ' . $alt ) . '"><td class="found-radio"><input type="radio" id="found-'.$post->ID.'" name="found_post_id" value="' . esc_attr($post->ID) . '"></td>'; |
|
1797 | - $html .= '<td><label for="found-'.$post->ID.'">' . esc_html( $title ) . '</label></td><td class="no-break">' . esc_html( $post_types[$post->post_type]->labels->singular_name ) . '</td><td class="no-break">'.esc_html( $time ) . '</td><td class="no-break">' . esc_html( $stat ). ' </td></tr>' . "\n\n"; |
|
1796 | + $html .= '<tr class="'.trim('found-posts '.$alt).'"><td class="found-radio"><input type="radio" id="found-'.$post->ID.'" name="found_post_id" value="'.esc_attr($post->ID).'"></td>'; |
|
1797 | + $html .= '<td><label for="found-'.$post->ID.'">'.esc_html($title).'</label></td><td class="no-break">'.esc_html($post_types[$post->post_type]->labels->singular_name).'</td><td class="no-break">'.esc_html($time).'</td><td class="no-break">'.esc_html($stat).' </td></tr>'."\n\n"; |
|
1798 | 1798 | } |
1799 | 1799 | |
1800 | 1800 | $html .= '</tbody></table>'; |
1801 | 1801 | |
1802 | - wp_send_json_success( $html ); |
|
1802 | + wp_send_json_success($html); |
|
1803 | 1803 | } |
1804 | 1804 | |
1805 | 1805 | /** |
@@ -1808,22 +1808,22 @@ discard block |
||
1808 | 1808 | * @since 3.1.0 |
1809 | 1809 | */ |
1810 | 1810 | function wp_ajax_widgets_order() { |
1811 | - check_ajax_referer( 'save-sidebar-widgets', 'savewidgets' ); |
|
1811 | + check_ajax_referer('save-sidebar-widgets', 'savewidgets'); |
|
1812 | 1812 | |
1813 | - if ( !current_user_can('edit_theme_options') ) |
|
1813 | + if ( ! current_user_can('edit_theme_options')) |
|
1814 | 1814 | wp_die( -1 ); |
1815 | 1815 | |
1816 | - unset( $_POST['savewidgets'], $_POST['action'] ); |
|
1816 | + unset($_POST['savewidgets'], $_POST['action']); |
|
1817 | 1817 | |
1818 | 1818 | // Save widgets order for all sidebars. |
1819 | - if ( is_array($_POST['sidebars']) ) { |
|
1819 | + if (is_array($_POST['sidebars'])) { |
|
1820 | 1820 | $sidebars = array(); |
1821 | - foreach ( $_POST['sidebars'] as $key => $val ) { |
|
1821 | + foreach ($_POST['sidebars'] as $key => $val) { |
|
1822 | 1822 | $sb = array(); |
1823 | - if ( !empty($val) ) { |
|
1823 | + if ( ! empty($val)) { |
|
1824 | 1824 | $val = explode(',', $val); |
1825 | - foreach ( $val as $k => $v ) { |
|
1826 | - if ( strpos($v, 'widget-') === false ) |
|
1825 | + foreach ($val as $k => $v) { |
|
1826 | + if (strpos($v, 'widget-') === false) |
|
1827 | 1827 | continue; |
1828 | 1828 | |
1829 | 1829 | $sb[$k] = substr($v, strpos($v, '_') + 1); |
@@ -1832,7 +1832,7 @@ discard block |
||
1832 | 1832 | $sidebars[$key] = $sb; |
1833 | 1833 | } |
1834 | 1834 | wp_set_sidebars_widgets($sidebars); |
1835 | - wp_die( 1 ); |
|
1835 | + wp_die(1); |
|
1836 | 1836 | } |
1837 | 1837 | |
1838 | 1838 | wp_die( -1 ); |
@@ -1850,87 +1850,87 @@ discard block |
||
1850 | 1850 | function wp_ajax_save_widget() { |
1851 | 1851 | global $wp_registered_widgets, $wp_registered_widget_controls, $wp_registered_widget_updates; |
1852 | 1852 | |
1853 | - check_ajax_referer( 'save-sidebar-widgets', 'savewidgets' ); |
|
1853 | + check_ajax_referer('save-sidebar-widgets', 'savewidgets'); |
|
1854 | 1854 | |
1855 | - if ( !current_user_can('edit_theme_options') || !isset($_POST['id_base']) ) |
|
1855 | + if ( ! current_user_can('edit_theme_options') || ! isset($_POST['id_base'])) |
|
1856 | 1856 | wp_die( -1 ); |
1857 | 1857 | |
1858 | - unset( $_POST['savewidgets'], $_POST['action'] ); |
|
1858 | + unset($_POST['savewidgets'], $_POST['action']); |
|
1859 | 1859 | |
1860 | 1860 | /** |
1861 | 1861 | * Fires early when editing the widgets displayed in sidebars. |
1862 | 1862 | * |
1863 | 1863 | * @since 2.8.0 |
1864 | 1864 | */ |
1865 | - do_action( 'load-widgets.php' ); |
|
1865 | + do_action('load-widgets.php'); |
|
1866 | 1866 | |
1867 | 1867 | /** |
1868 | 1868 | * Fires early when editing the widgets displayed in sidebars. |
1869 | 1869 | * |
1870 | 1870 | * @since 2.8.0 |
1871 | 1871 | */ |
1872 | - do_action( 'widgets.php' ); |
|
1872 | + do_action('widgets.php'); |
|
1873 | 1873 | |
1874 | 1874 | /** This action is documented in wp-admin/widgets.php */ |
1875 | - do_action( 'sidebar_admin_setup' ); |
|
1875 | + do_action('sidebar_admin_setup'); |
|
1876 | 1876 | |
1877 | 1877 | $id_base = $_POST['id_base']; |
1878 | 1878 | $widget_id = $_POST['widget-id']; |
1879 | 1879 | $sidebar_id = $_POST['sidebar']; |
1880 | - $multi_number = !empty($_POST['multi_number']) ? (int) $_POST['multi_number'] : 0; |
|
1881 | - $settings = isset($_POST['widget-' . $id_base]) && is_array($_POST['widget-' . $id_base]) ? $_POST['widget-' . $id_base] : false; |
|
1882 | - $error = '<p>' . __('An error has occurred. Please reload the page and try again.') . '</p>'; |
|
1880 | + $multi_number = ! empty($_POST['multi_number']) ? (int) $_POST['multi_number'] : 0; |
|
1881 | + $settings = isset($_POST['widget-'.$id_base]) && is_array($_POST['widget-'.$id_base]) ? $_POST['widget-'.$id_base] : false; |
|
1882 | + $error = '<p>'.__('An error has occurred. Please reload the page and try again.').'</p>'; |
|
1883 | 1883 | |
1884 | 1884 | $sidebars = wp_get_sidebars_widgets(); |
1885 | 1885 | $sidebar = isset($sidebars[$sidebar_id]) ? $sidebars[$sidebar_id] : array(); |
1886 | 1886 | |
1887 | 1887 | // Delete. |
1888 | - if ( isset($_POST['delete_widget']) && $_POST['delete_widget'] ) { |
|
1888 | + if (isset($_POST['delete_widget']) && $_POST['delete_widget']) { |
|
1889 | 1889 | |
1890 | - if ( !isset($wp_registered_widgets[$widget_id]) ) |
|
1891 | - wp_die( $error ); |
|
1890 | + if ( ! isset($wp_registered_widgets[$widget_id])) |
|
1891 | + wp_die($error); |
|
1892 | 1892 | |
1893 | - $sidebar = array_diff( $sidebar, array($widget_id) ); |
|
1894 | - $_POST = array('sidebar' => $sidebar_id, 'widget-' . $id_base => array(), 'the-widget-id' => $widget_id, 'delete_widget' => '1'); |
|
1893 | + $sidebar = array_diff($sidebar, array($widget_id)); |
|
1894 | + $_POST = array('sidebar' => $sidebar_id, 'widget-'.$id_base => array(), 'the-widget-id' => $widget_id, 'delete_widget' => '1'); |
|
1895 | 1895 | |
1896 | 1896 | /** This action is documented in wp-admin/widgets.php */ |
1897 | - do_action( 'delete_widget', $widget_id, $sidebar_id, $id_base ); |
|
1897 | + do_action('delete_widget', $widget_id, $sidebar_id, $id_base); |
|
1898 | 1898 | |
1899 | - } elseif ( $settings && preg_match( '/__i__|%i%/', key($settings) ) ) { |
|
1900 | - if ( !$multi_number ) |
|
1901 | - wp_die( $error ); |
|
1899 | + } elseif ($settings && preg_match('/__i__|%i%/', key($settings))) { |
|
1900 | + if ( ! $multi_number) |
|
1901 | + wp_die($error); |
|
1902 | 1902 | |
1903 | - $_POST[ 'widget-' . $id_base ] = array( $multi_number => reset( $settings ) ); |
|
1904 | - $widget_id = $id_base . '-' . $multi_number; |
|
1903 | + $_POST['widget-'.$id_base] = array($multi_number => reset($settings)); |
|
1904 | + $widget_id = $id_base.'-'.$multi_number; |
|
1905 | 1905 | $sidebar[] = $widget_id; |
1906 | 1906 | } |
1907 | 1907 | $_POST['widget-id'] = $sidebar; |
1908 | 1908 | |
1909 | - foreach ( (array) $wp_registered_widget_updates as $name => $control ) { |
|
1909 | + foreach ((array) $wp_registered_widget_updates as $name => $control) { |
|
1910 | 1910 | |
1911 | - if ( $name == $id_base ) { |
|
1912 | - if ( !is_callable( $control['callback'] ) ) |
|
1911 | + if ($name == $id_base) { |
|
1912 | + if ( ! is_callable($control['callback'])) |
|
1913 | 1913 | continue; |
1914 | 1914 | |
1915 | 1915 | ob_start(); |
1916 | - call_user_func_array( $control['callback'], $control['params'] ); |
|
1916 | + call_user_func_array($control['callback'], $control['params']); |
|
1917 | 1917 | ob_end_clean(); |
1918 | 1918 | break; |
1919 | 1919 | } |
1920 | 1920 | } |
1921 | 1921 | |
1922 | - if ( isset($_POST['delete_widget']) && $_POST['delete_widget'] ) { |
|
1922 | + if (isset($_POST['delete_widget']) && $_POST['delete_widget']) { |
|
1923 | 1923 | $sidebars[$sidebar_id] = $sidebar; |
1924 | 1924 | wp_set_sidebars_widgets($sidebars); |
1925 | 1925 | echo "deleted:$widget_id"; |
1926 | 1926 | wp_die(); |
1927 | 1927 | } |
1928 | 1928 | |
1929 | - if ( !empty($_POST['add_new']) ) |
|
1929 | + if ( ! empty($_POST['add_new'])) |
|
1930 | 1930 | wp_die(); |
1931 | 1931 | |
1932 | - if ( $form = $wp_registered_widget_controls[$widget_id] ) |
|
1933 | - call_user_func_array( $form['callback'], $form['params'] ); |
|
1932 | + if ($form = $wp_registered_widget_controls[$widget_id]) |
|
1933 | + call_user_func_array($form['callback'], $form['params']); |
|
1934 | 1934 | |
1935 | 1935 | wp_die(); |
1936 | 1936 | } |
@@ -1953,31 +1953,31 @@ discard block |
||
1953 | 1953 | * @since 4.4.0 |
1954 | 1954 | */ |
1955 | 1955 | function wp_ajax_delete_inactive_widgets() { |
1956 | - check_ajax_referer( 'remove-inactive-widgets', 'removeinactivewidgets' ); |
|
1956 | + check_ajax_referer('remove-inactive-widgets', 'removeinactivewidgets'); |
|
1957 | 1957 | |
1958 | - if ( ! current_user_can( 'edit_theme_options' ) ) { |
|
1958 | + if ( ! current_user_can('edit_theme_options')) { |
|
1959 | 1959 | wp_die( -1 ); |
1960 | 1960 | } |
1961 | 1961 | |
1962 | - unset( $_POST['removeinactivewidgets'], $_POST['action'] ); |
|
1962 | + unset($_POST['removeinactivewidgets'], $_POST['action']); |
|
1963 | 1963 | |
1964 | - do_action( 'load-widgets.php' ); |
|
1965 | - do_action( 'widgets.php' ); |
|
1966 | - do_action( 'sidebar_admin_setup' ); |
|
1964 | + do_action('load-widgets.php'); |
|
1965 | + do_action('widgets.php'); |
|
1966 | + do_action('sidebar_admin_setup'); |
|
1967 | 1967 | |
1968 | 1968 | $sidebars_widgets = wp_get_sidebars_widgets(); |
1969 | 1969 | |
1970 | - foreach ( $sidebars_widgets['wp_inactive_widgets'] as $key => $widget_id ) { |
|
1971 | - $pieces = explode( '-', $widget_id ); |
|
1972 | - $multi_number = array_pop( $pieces ); |
|
1973 | - $id_base = implode( '-', $pieces ); |
|
1974 | - $widget = get_option( 'widget_' . $id_base ); |
|
1975 | - unset( $widget[$multi_number] ); |
|
1976 | - update_option( 'widget_' . $id_base, $widget ); |
|
1977 | - unset( $sidebars_widgets['wp_inactive_widgets'][$key] ); |
|
1970 | + foreach ($sidebars_widgets['wp_inactive_widgets'] as $key => $widget_id) { |
|
1971 | + $pieces = explode('-', $widget_id); |
|
1972 | + $multi_number = array_pop($pieces); |
|
1973 | + $id_base = implode('-', $pieces); |
|
1974 | + $widget = get_option('widget_'.$id_base); |
|
1975 | + unset($widget[$multi_number]); |
|
1976 | + update_option('widget_'.$id_base, $widget); |
|
1977 | + unset($sidebars_widgets['wp_inactive_widgets'][$key]); |
|
1978 | 1978 | } |
1979 | 1979 | |
1980 | - wp_set_sidebars_widgets( $sidebars_widgets ); |
|
1980 | + wp_set_sidebars_widgets($sidebars_widgets); |
|
1981 | 1981 | |
1982 | 1982 | wp_die(); |
1983 | 1983 | } |
@@ -1988,35 +1988,35 @@ discard block |
||
1988 | 1988 | * @since 3.3.0 |
1989 | 1989 | */ |
1990 | 1990 | function wp_ajax_upload_attachment() { |
1991 | - check_ajax_referer( 'media-form' ); |
|
1991 | + check_ajax_referer('media-form'); |
|
1992 | 1992 | /* |
1993 | 1993 | * This function does not use wp_send_json_success() / wp_send_json_error() |
1994 | 1994 | * as the html4 Plupload handler requires a text/html content-type for older IE. |
1995 | 1995 | * See https://core.trac.wordpress.org/ticket/31037 |
1996 | 1996 | */ |
1997 | 1997 | |
1998 | - if ( ! current_user_can( 'upload_files' ) ) { |
|
1999 | - echo wp_json_encode( array( |
|
1998 | + if ( ! current_user_can('upload_files')) { |
|
1999 | + echo wp_json_encode(array( |
|
2000 | 2000 | 'success' => false, |
2001 | 2001 | 'data' => array( |
2002 | - 'message' => __( 'You do not have permission to upload files.' ), |
|
2002 | + 'message' => __('You do not have permission to upload files.'), |
|
2003 | 2003 | 'filename' => $_FILES['async-upload']['name'], |
2004 | 2004 | ) |
2005 | - ) ); |
|
2005 | + )); |
|
2006 | 2006 | |
2007 | 2007 | wp_die(); |
2008 | 2008 | } |
2009 | 2009 | |
2010 | - if ( isset( $_REQUEST['post_id'] ) ) { |
|
2010 | + if (isset($_REQUEST['post_id'])) { |
|
2011 | 2011 | $post_id = $_REQUEST['post_id']; |
2012 | - if ( ! current_user_can( 'edit_post', $post_id ) ) { |
|
2013 | - echo wp_json_encode( array( |
|
2012 | + if ( ! current_user_can('edit_post', $post_id)) { |
|
2013 | + echo wp_json_encode(array( |
|
2014 | 2014 | 'success' => false, |
2015 | 2015 | 'data' => array( |
2016 | - 'message' => __( "You don't have permission to attach files to this post." ), |
|
2016 | + 'message' => __("You don't have permission to attach files to this post."), |
|
2017 | 2017 | 'filename' => $_FILES['async-upload']['name'], |
2018 | 2018 | ) |
2019 | - ) ); |
|
2019 | + )); |
|
2020 | 2020 | |
2021 | 2021 | wp_die(); |
2022 | 2022 | } |
@@ -2024,53 +2024,53 @@ discard block |
||
2024 | 2024 | $post_id = null; |
2025 | 2025 | } |
2026 | 2026 | |
2027 | - $post_data = isset( $_REQUEST['post_data'] ) ? $_REQUEST['post_data'] : array(); |
|
2027 | + $post_data = isset($_REQUEST['post_data']) ? $_REQUEST['post_data'] : array(); |
|
2028 | 2028 | |
2029 | 2029 | // If the context is custom header or background, make sure the uploaded file is an image. |
2030 | - if ( isset( $post_data['context'] ) && in_array( $post_data['context'], array( 'custom-header', 'custom-background' ) ) ) { |
|
2031 | - $wp_filetype = wp_check_filetype_and_ext( $_FILES['async-upload']['tmp_name'], $_FILES['async-upload']['name'] ); |
|
2032 | - if ( ! wp_match_mime_types( 'image', $wp_filetype['type'] ) ) { |
|
2033 | - echo wp_json_encode( array( |
|
2030 | + if (isset($post_data['context']) && in_array($post_data['context'], array('custom-header', 'custom-background'))) { |
|
2031 | + $wp_filetype = wp_check_filetype_and_ext($_FILES['async-upload']['tmp_name'], $_FILES['async-upload']['name']); |
|
2032 | + if ( ! wp_match_mime_types('image', $wp_filetype['type'])) { |
|
2033 | + echo wp_json_encode(array( |
|
2034 | 2034 | 'success' => false, |
2035 | 2035 | 'data' => array( |
2036 | - 'message' => __( 'The uploaded file is not a valid image. Please try again.' ), |
|
2036 | + 'message' => __('The uploaded file is not a valid image. Please try again.'), |
|
2037 | 2037 | 'filename' => $_FILES['async-upload']['name'], |
2038 | 2038 | ) |
2039 | - ) ); |
|
2039 | + )); |
|
2040 | 2040 | |
2041 | 2041 | wp_die(); |
2042 | 2042 | } |
2043 | 2043 | } |
2044 | 2044 | |
2045 | - $attachment_id = media_handle_upload( 'async-upload', $post_id, $post_data ); |
|
2045 | + $attachment_id = media_handle_upload('async-upload', $post_id, $post_data); |
|
2046 | 2046 | |
2047 | - if ( is_wp_error( $attachment_id ) ) { |
|
2048 | - echo wp_json_encode( array( |
|
2047 | + if (is_wp_error($attachment_id)) { |
|
2048 | + echo wp_json_encode(array( |
|
2049 | 2049 | 'success' => false, |
2050 | 2050 | 'data' => array( |
2051 | 2051 | 'message' => $attachment_id->get_error_message(), |
2052 | 2052 | 'filename' => $_FILES['async-upload']['name'], |
2053 | 2053 | ) |
2054 | - ) ); |
|
2054 | + )); |
|
2055 | 2055 | |
2056 | 2056 | wp_die(); |
2057 | 2057 | } |
2058 | 2058 | |
2059 | - if ( isset( $post_data['context'] ) && isset( $post_data['theme'] ) ) { |
|
2060 | - if ( 'custom-background' === $post_data['context'] ) |
|
2061 | - update_post_meta( $attachment_id, '_wp_attachment_is_custom_background', $post_data['theme'] ); |
|
2059 | + if (isset($post_data['context']) && isset($post_data['theme'])) { |
|
2060 | + if ('custom-background' === $post_data['context']) |
|
2061 | + update_post_meta($attachment_id, '_wp_attachment_is_custom_background', $post_data['theme']); |
|
2062 | 2062 | |
2063 | - if ( 'custom-header' === $post_data['context'] ) |
|
2064 | - update_post_meta( $attachment_id, '_wp_attachment_is_custom_header', $post_data['theme'] ); |
|
2063 | + if ('custom-header' === $post_data['context']) |
|
2064 | + update_post_meta($attachment_id, '_wp_attachment_is_custom_header', $post_data['theme']); |
|
2065 | 2065 | } |
2066 | 2066 | |
2067 | - if ( ! $attachment = wp_prepare_attachment_for_js( $attachment_id ) ) |
|
2067 | + if ( ! $attachment = wp_prepare_attachment_for_js($attachment_id)) |
|
2068 | 2068 | wp_die(); |
2069 | 2069 | |
2070 | - echo wp_json_encode( array( |
|
2070 | + echo wp_json_encode(array( |
|
2071 | 2071 | 'success' => true, |
2072 | 2072 | 'data' => $attachment, |
2073 | - ) ); |
|
2073 | + )); |
|
2074 | 2074 | |
2075 | 2075 | wp_die(); |
2076 | 2076 | } |
@@ -2082,18 +2082,18 @@ discard block |
||
2082 | 2082 | */ |
2083 | 2083 | function wp_ajax_image_editor() { |
2084 | 2084 | $attachment_id = intval($_POST['postid']); |
2085 | - if ( empty($attachment_id) || !current_user_can('edit_post', $attachment_id) ) |
|
2085 | + if (empty($attachment_id) || ! current_user_can('edit_post', $attachment_id)) |
|
2086 | 2086 | wp_die( -1 ); |
2087 | 2087 | |
2088 | - check_ajax_referer( "image_editor-$attachment_id" ); |
|
2089 | - include_once( ABSPATH . 'wp-admin/includes/image-edit.php' ); |
|
2088 | + check_ajax_referer("image_editor-$attachment_id"); |
|
2089 | + include_once(ABSPATH.'wp-admin/includes/image-edit.php'); |
|
2090 | 2090 | |
2091 | 2091 | $msg = false; |
2092 | - switch ( $_POST['do'] ) { |
|
2092 | + switch ($_POST['do']) { |
|
2093 | 2093 | case 'save' : |
2094 | 2094 | $msg = wp_save_image($attachment_id); |
2095 | 2095 | $msg = wp_json_encode($msg); |
2096 | - wp_die( $msg ); |
|
2096 | + wp_die($msg); |
|
2097 | 2097 | break; |
2098 | 2098 | case 'scale' : |
2099 | 2099 | $msg = wp_save_image($attachment_id); |
@@ -2113,34 +2113,34 @@ discard block |
||
2113 | 2113 | * @since 3.1.0 |
2114 | 2114 | */ |
2115 | 2115 | function wp_ajax_set_post_thumbnail() { |
2116 | - $json = ! empty( $_REQUEST['json'] ); // New-style request |
|
2116 | + $json = ! empty($_REQUEST['json']); // New-style request |
|
2117 | 2117 | |
2118 | - $post_ID = intval( $_POST['post_id'] ); |
|
2119 | - if ( ! current_user_can( 'edit_post', $post_ID ) ) |
|
2118 | + $post_ID = intval($_POST['post_id']); |
|
2119 | + if ( ! current_user_can('edit_post', $post_ID)) |
|
2120 | 2120 | wp_die( -1 ); |
2121 | 2121 | |
2122 | - $thumbnail_id = intval( $_POST['thumbnail_id'] ); |
|
2122 | + $thumbnail_id = intval($_POST['thumbnail_id']); |
|
2123 | 2123 | |
2124 | - if ( $json ) |
|
2125 | - check_ajax_referer( "update-post_$post_ID" ); |
|
2124 | + if ($json) |
|
2125 | + check_ajax_referer("update-post_$post_ID"); |
|
2126 | 2126 | else |
2127 | - check_ajax_referer( "set_post_thumbnail-$post_ID" ); |
|
2127 | + check_ajax_referer("set_post_thumbnail-$post_ID"); |
|
2128 | 2128 | |
2129 | - if ( $thumbnail_id == '-1' ) { |
|
2130 | - if ( delete_post_thumbnail( $post_ID ) ) { |
|
2131 | - $return = _wp_post_thumbnail_html( null, $post_ID ); |
|
2132 | - $json ? wp_send_json_success( $return ) : wp_die( $return ); |
|
2129 | + if ($thumbnail_id == '-1') { |
|
2130 | + if (delete_post_thumbnail($post_ID)) { |
|
2131 | + $return = _wp_post_thumbnail_html(null, $post_ID); |
|
2132 | + $json ? wp_send_json_success($return) : wp_die($return); |
|
2133 | 2133 | } else { |
2134 | - wp_die( 0 ); |
|
2134 | + wp_die(0); |
|
2135 | 2135 | } |
2136 | 2136 | } |
2137 | 2137 | |
2138 | - if ( set_post_thumbnail( $post_ID, $thumbnail_id ) ) { |
|
2139 | - $return = _wp_post_thumbnail_html( $thumbnail_id, $post_ID ); |
|
2140 | - $json ? wp_send_json_success( $return ) : wp_die( $return ); |
|
2138 | + if (set_post_thumbnail($post_ID, $thumbnail_id)) { |
|
2139 | + $return = _wp_post_thumbnail_html($thumbnail_id, $post_ID); |
|
2140 | + $json ? wp_send_json_success($return) : wp_die($return); |
|
2141 | 2141 | } |
2142 | 2142 | |
2143 | - wp_die( 0 ); |
|
2143 | + wp_die(0); |
|
2144 | 2144 | } |
2145 | 2145 | |
2146 | 2146 | /** |
@@ -2151,41 +2151,41 @@ discard block |
||
2151 | 2151 | * @see set_post_thumbnail() |
2152 | 2152 | */ |
2153 | 2153 | function wp_ajax_set_attachment_thumbnail() { |
2154 | - if ( empty( $_POST['urls'] ) || ! is_array( $_POST['urls'] ) ) { |
|
2154 | + if (empty($_POST['urls']) || ! is_array($_POST['urls'])) { |
|
2155 | 2155 | wp_send_json_error(); |
2156 | 2156 | } |
2157 | 2157 | |
2158 | 2158 | $thumbnail_id = (int) $_POST['thumbnail_id']; |
2159 | - if ( empty( $thumbnail_id ) ) { |
|
2159 | + if (empty($thumbnail_id)) { |
|
2160 | 2160 | wp_send_json_error(); |
2161 | 2161 | } |
2162 | 2162 | |
2163 | 2163 | $post_ids = array(); |
2164 | 2164 | // For each URL, try to find its corresponding post ID. |
2165 | - foreach ( $_POST['urls'] as $url ) { |
|
2166 | - $post_id = attachment_url_to_postid( $url ); |
|
2167 | - if ( ! empty( $post_id ) ) { |
|
2165 | + foreach ($_POST['urls'] as $url) { |
|
2166 | + $post_id = attachment_url_to_postid($url); |
|
2167 | + if ( ! empty($post_id)) { |
|
2168 | 2168 | $post_ids[] = $post_id; |
2169 | 2169 | } |
2170 | 2170 | } |
2171 | 2171 | |
2172 | - if ( empty( $post_ids ) ) { |
|
2172 | + if (empty($post_ids)) { |
|
2173 | 2173 | wp_send_json_error(); |
2174 | 2174 | } |
2175 | 2175 | |
2176 | 2176 | $success = 0; |
2177 | 2177 | // For each found attachment, set its thumbnail. |
2178 | - foreach ( $post_ids as $post_id ) { |
|
2179 | - if ( ! current_user_can( 'edit_post', $post_id ) ) { |
|
2178 | + foreach ($post_ids as $post_id) { |
|
2179 | + if ( ! current_user_can('edit_post', $post_id)) { |
|
2180 | 2180 | continue; |
2181 | 2181 | } |
2182 | 2182 | |
2183 | - if ( set_post_thumbnail( $post_id, $thumbnail_id ) ) { |
|
2183 | + if (set_post_thumbnail($post_id, $thumbnail_id)) { |
|
2184 | 2184 | $success++; |
2185 | 2185 | } |
2186 | 2186 | } |
2187 | 2187 | |
2188 | - if ( 0 === $success ) { |
|
2188 | + if (0 === $success) { |
|
2189 | 2189 | wp_send_json_error(); |
2190 | 2190 | } else { |
2191 | 2191 | wp_send_json_success(); |
@@ -2200,7 +2200,7 @@ discard block |
||
2200 | 2200 | * @since 3.1.0 |
2201 | 2201 | */ |
2202 | 2202 | function wp_ajax_date_format() { |
2203 | - wp_die( date_i18n( sanitize_option( 'date_format', wp_unslash( $_POST['date'] ) ) ) ); |
|
2203 | + wp_die(date_i18n(sanitize_option('date_format', wp_unslash($_POST['date'])))); |
|
2204 | 2204 | } |
2205 | 2205 | |
2206 | 2206 | /** |
@@ -2209,7 +2209,7 @@ discard block |
||
2209 | 2209 | * @since 3.1.0 |
2210 | 2210 | */ |
2211 | 2211 | function wp_ajax_time_format() { |
2212 | - wp_die( date_i18n( sanitize_option( 'time_format', wp_unslash( $_POST['date'] ) ) ) ); |
|
2212 | + wp_die(date_i18n(sanitize_option('time_format', wp_unslash($_POST['date'])))); |
|
2213 | 2213 | } |
2214 | 2214 | |
2215 | 2215 | /** |
@@ -2219,37 +2219,37 @@ discard block |
||
2219 | 2219 | * @deprecated 4.3.0 |
2220 | 2220 | */ |
2221 | 2221 | function wp_ajax_wp_fullscreen_save_post() { |
2222 | - $post_id = isset( $_POST['post_ID'] ) ? (int) $_POST['post_ID'] : 0; |
|
2222 | + $post_id = isset($_POST['post_ID']) ? (int) $_POST['post_ID'] : 0; |
|
2223 | 2223 | |
2224 | 2224 | $post = null; |
2225 | 2225 | |
2226 | - if ( $post_id ) |
|
2227 | - $post = get_post( $post_id ); |
|
2226 | + if ($post_id) |
|
2227 | + $post = get_post($post_id); |
|
2228 | 2228 | |
2229 | - check_ajax_referer('update-post_' . $post_id, '_wpnonce'); |
|
2229 | + check_ajax_referer('update-post_'.$post_id, '_wpnonce'); |
|
2230 | 2230 | |
2231 | 2231 | $post_id = edit_post(); |
2232 | 2232 | |
2233 | - if ( is_wp_error( $post_id ) ) { |
|
2233 | + if (is_wp_error($post_id)) { |
|
2234 | 2234 | wp_send_json_error(); |
2235 | 2235 | } |
2236 | 2236 | |
2237 | - if ( $post ) { |
|
2238 | - $last_date = mysql2date( __( 'F j, Y' ), $post->post_modified ); |
|
2239 | - $last_time = mysql2date( __( 'g:i a' ), $post->post_modified ); |
|
2237 | + if ($post) { |
|
2238 | + $last_date = mysql2date(__('F j, Y'), $post->post_modified); |
|
2239 | + $last_time = mysql2date(__('g:i a'), $post->post_modified); |
|
2240 | 2240 | } else { |
2241 | - $last_date = date_i18n( __( 'F j, Y' ) ); |
|
2242 | - $last_time = date_i18n( __( 'g:i a' ) ); |
|
2241 | + $last_date = date_i18n(__('F j, Y')); |
|
2242 | + $last_time = date_i18n(__('g:i a')); |
|
2243 | 2243 | } |
2244 | 2244 | |
2245 | - if ( $last_id = get_post_meta( $post_id, '_edit_last', true ) ) { |
|
2246 | - $last_user = get_userdata( $last_id ); |
|
2247 | - $last_edited = sprintf( __('Last edited by %1$s on %2$s at %3$s'), esc_html( $last_user->display_name ), $last_date, $last_time ); |
|
2245 | + if ($last_id = get_post_meta($post_id, '_edit_last', true)) { |
|
2246 | + $last_user = get_userdata($last_id); |
|
2247 | + $last_edited = sprintf(__('Last edited by %1$s on %2$s at %3$s'), esc_html($last_user->display_name), $last_date, $last_time); |
|
2248 | 2248 | } else { |
2249 | - $last_edited = sprintf( __('Last edited on %1$s at %2$s'), $last_date, $last_time ); |
|
2249 | + $last_edited = sprintf(__('Last edited on %1$s at %2$s'), $last_date, $last_time); |
|
2250 | 2250 | } |
2251 | 2251 | |
2252 | - wp_send_json_success( array( 'last_edited' => $last_edited ) ); |
|
2252 | + wp_send_json_success(array('last_edited' => $last_edited)); |
|
2253 | 2253 | } |
2254 | 2254 | |
2255 | 2255 | /** |
@@ -2258,20 +2258,20 @@ discard block |
||
2258 | 2258 | * @since 3.1.0 |
2259 | 2259 | */ |
2260 | 2260 | function wp_ajax_wp_remove_post_lock() { |
2261 | - if ( empty( $_POST['post_ID'] ) || empty( $_POST['active_post_lock'] ) ) |
|
2262 | - wp_die( 0 ); |
|
2261 | + if (empty($_POST['post_ID']) || empty($_POST['active_post_lock'])) |
|
2262 | + wp_die(0); |
|
2263 | 2263 | $post_id = (int) $_POST['post_ID']; |
2264 | - if ( ! $post = get_post( $post_id ) ) |
|
2265 | - wp_die( 0 ); |
|
2264 | + if ( ! $post = get_post($post_id)) |
|
2265 | + wp_die(0); |
|
2266 | 2266 | |
2267 | - check_ajax_referer( 'update-post_' . $post_id ); |
|
2267 | + check_ajax_referer('update-post_'.$post_id); |
|
2268 | 2268 | |
2269 | - if ( ! current_user_can( 'edit_post', $post_id ) ) |
|
2269 | + if ( ! current_user_can('edit_post', $post_id)) |
|
2270 | 2270 | wp_die( -1 ); |
2271 | 2271 | |
2272 | - $active_lock = array_map( 'absint', explode( ':', $_POST['active_post_lock'] ) ); |
|
2273 | - if ( $active_lock[1] != get_current_user_id() ) |
|
2274 | - wp_die( 0 ); |
|
2272 | + $active_lock = array_map('absint', explode(':', $_POST['active_post_lock'])); |
|
2273 | + if ($active_lock[1] != get_current_user_id()) |
|
2274 | + wp_die(0); |
|
2275 | 2275 | |
2276 | 2276 | /** |
2277 | 2277 | * Filter the post lock window duration. |
@@ -2281,9 +2281,9 @@ discard block |
||
2281 | 2281 | * @param int $interval The interval in seconds the post lock duration |
2282 | 2282 | * should last, plus 5 seconds. Default 150. |
2283 | 2283 | */ |
2284 | - $new_lock = ( time() - apply_filters( 'wp_check_post_lock_window', 150 ) + 5 ) . ':' . $active_lock[1]; |
|
2285 | - update_post_meta( $post_id, '_edit_lock', $new_lock, implode( ':', $active_lock ) ); |
|
2286 | - wp_die( 1 ); |
|
2284 | + $new_lock = (time() - apply_filters('wp_check_post_lock_window', 150) + 5).':'.$active_lock[1]; |
|
2285 | + update_post_meta($post_id, '_edit_lock', $new_lock, implode(':', $active_lock)); |
|
2286 | + wp_die(1); |
|
2287 | 2287 | } |
2288 | 2288 | |
2289 | 2289 | /** |
@@ -2293,21 +2293,21 @@ discard block |
||
2293 | 2293 | */ |
2294 | 2294 | function wp_ajax_dismiss_wp_pointer() { |
2295 | 2295 | $pointer = $_POST['pointer']; |
2296 | - if ( $pointer != sanitize_key( $pointer ) ) |
|
2297 | - wp_die( 0 ); |
|
2296 | + if ($pointer != sanitize_key($pointer)) |
|
2297 | + wp_die(0); |
|
2298 | 2298 | |
2299 | 2299 | // check_ajax_referer( 'dismiss-pointer_' . $pointer ); |
2300 | 2300 | |
2301 | - $dismissed = array_filter( explode( ',', (string) get_user_meta( get_current_user_id(), 'dismissed_wp_pointers', true ) ) ); |
|
2301 | + $dismissed = array_filter(explode(',', (string) get_user_meta(get_current_user_id(), 'dismissed_wp_pointers', true))); |
|
2302 | 2302 | |
2303 | - if ( in_array( $pointer, $dismissed ) ) |
|
2304 | - wp_die( 0 ); |
|
2303 | + if (in_array($pointer, $dismissed)) |
|
2304 | + wp_die(0); |
|
2305 | 2305 | |
2306 | 2306 | $dismissed[] = $pointer; |
2307 | - $dismissed = implode( ',', $dismissed ); |
|
2307 | + $dismissed = implode(',', $dismissed); |
|
2308 | 2308 | |
2309 | - update_user_meta( get_current_user_id(), 'dismissed_wp_pointers', $dismissed ); |
|
2310 | - wp_die( 1 ); |
|
2309 | + update_user_meta(get_current_user_id(), 'dismissed_wp_pointers', $dismissed); |
|
2310 | + wp_die(1); |
|
2311 | 2311 | } |
2312 | 2312 | |
2313 | 2313 | /** |
@@ -2316,25 +2316,25 @@ discard block |
||
2316 | 2316 | * @since 3.5.0 |
2317 | 2317 | */ |
2318 | 2318 | function wp_ajax_get_attachment() { |
2319 | - if ( ! isset( $_REQUEST['id'] ) ) |
|
2319 | + if ( ! isset($_REQUEST['id'])) |
|
2320 | 2320 | wp_send_json_error(); |
2321 | 2321 | |
2322 | - if ( ! $id = absint( $_REQUEST['id'] ) ) |
|
2322 | + if ( ! $id = absint($_REQUEST['id'])) |
|
2323 | 2323 | wp_send_json_error(); |
2324 | 2324 | |
2325 | - if ( ! $post = get_post( $id ) ) |
|
2325 | + if ( ! $post = get_post($id)) |
|
2326 | 2326 | wp_send_json_error(); |
2327 | 2327 | |
2328 | - if ( 'attachment' != $post->post_type ) |
|
2328 | + if ('attachment' != $post->post_type) |
|
2329 | 2329 | wp_send_json_error(); |
2330 | 2330 | |
2331 | - if ( ! current_user_can( 'upload_files' ) ) |
|
2331 | + if ( ! current_user_can('upload_files')) |
|
2332 | 2332 | wp_send_json_error(); |
2333 | 2333 | |
2334 | - if ( ! $attachment = wp_prepare_attachment_for_js( $id ) ) |
|
2334 | + if ( ! $attachment = wp_prepare_attachment_for_js($id)) |
|
2335 | 2335 | wp_send_json_error(); |
2336 | 2336 | |
2337 | - wp_send_json_success( $attachment ); |
|
2337 | + wp_send_json_success($attachment); |
|
2338 | 2338 | } |
2339 | 2339 | |
2340 | 2340 | /** |
@@ -2343,31 +2343,31 @@ discard block |
||
2343 | 2343 | * @since 3.5.0 |
2344 | 2344 | */ |
2345 | 2345 | function wp_ajax_query_attachments() { |
2346 | - if ( ! current_user_can( 'upload_files' ) ) |
|
2346 | + if ( ! current_user_can('upload_files')) |
|
2347 | 2347 | wp_send_json_error(); |
2348 | 2348 | |
2349 | - $query = isset( $_REQUEST['query'] ) ? (array) $_REQUEST['query'] : array(); |
|
2349 | + $query = isset($_REQUEST['query']) ? (array) $_REQUEST['query'] : array(); |
|
2350 | 2350 | $keys = array( |
2351 | 2351 | 's', 'order', 'orderby', 'posts_per_page', 'paged', 'post_mime_type', |
2352 | 2352 | 'post_parent', 'post__in', 'post__not_in', 'year', 'monthnum' |
2353 | 2353 | ); |
2354 | - foreach ( get_taxonomies_for_attachments( 'objects' ) as $t ) { |
|
2355 | - if ( $t->query_var && isset( $query[ $t->query_var ] ) ) { |
|
2354 | + foreach (get_taxonomies_for_attachments('objects') as $t) { |
|
2355 | + if ($t->query_var && isset($query[$t->query_var])) { |
|
2356 | 2356 | $keys[] = $t->query_var; |
2357 | 2357 | } |
2358 | 2358 | } |
2359 | 2359 | |
2360 | - $query = array_intersect_key( $query, array_flip( $keys ) ); |
|
2360 | + $query = array_intersect_key($query, array_flip($keys)); |
|
2361 | 2361 | $query['post_type'] = 'attachment'; |
2362 | - if ( MEDIA_TRASH |
|
2363 | - && ! empty( $_REQUEST['query']['post_status'] ) |
|
2364 | - && 'trash' === $_REQUEST['query']['post_status'] ) { |
|
2362 | + if (MEDIA_TRASH |
|
2363 | + && ! empty($_REQUEST['query']['post_status']) |
|
2364 | + && 'trash' === $_REQUEST['query']['post_status']) { |
|
2365 | 2365 | $query['post_status'] = 'trash'; |
2366 | 2366 | } else { |
2367 | 2367 | $query['post_status'] = 'inherit'; |
2368 | 2368 | } |
2369 | 2369 | |
2370 | - if ( current_user_can( get_post_type_object( 'attachment' )->cap->read_private_posts ) ) |
|
2370 | + if (current_user_can(get_post_type_object('attachment')->cap->read_private_posts)) |
|
2371 | 2371 | $query['post_status'] .= ',private'; |
2372 | 2372 | |
2373 | 2373 | /** |
@@ -2380,13 +2380,13 @@ discard block |
||
2380 | 2380 | * |
2381 | 2381 | * @param array $query An array of query variables. |
2382 | 2382 | */ |
2383 | - $query = apply_filters( 'ajax_query_attachments_args', $query ); |
|
2384 | - $query = new WP_Query( $query ); |
|
2383 | + $query = apply_filters('ajax_query_attachments_args', $query); |
|
2384 | + $query = new WP_Query($query); |
|
2385 | 2385 | |
2386 | - $posts = array_map( 'wp_prepare_attachment_for_js', $query->posts ); |
|
2387 | - $posts = array_filter( $posts ); |
|
2386 | + $posts = array_map('wp_prepare_attachment_for_js', $query->posts); |
|
2387 | + $posts = array_filter($posts); |
|
2388 | 2388 | |
2389 | - wp_send_json_success( $posts ); |
|
2389 | + wp_send_json_success($posts); |
|
2390 | 2390 | } |
2391 | 2391 | |
2392 | 2392 | /** |
@@ -2395,69 +2395,69 @@ discard block |
||
2395 | 2395 | * @since 3.5.0 |
2396 | 2396 | */ |
2397 | 2397 | function wp_ajax_save_attachment() { |
2398 | - if ( ! isset( $_REQUEST['id'] ) || ! isset( $_REQUEST['changes'] ) ) |
|
2398 | + if ( ! isset($_REQUEST['id']) || ! isset($_REQUEST['changes'])) |
|
2399 | 2399 | wp_send_json_error(); |
2400 | 2400 | |
2401 | - if ( ! $id = absint( $_REQUEST['id'] ) ) |
|
2401 | + if ( ! $id = absint($_REQUEST['id'])) |
|
2402 | 2402 | wp_send_json_error(); |
2403 | 2403 | |
2404 | - check_ajax_referer( 'update-post_' . $id, 'nonce' ); |
|
2404 | + check_ajax_referer('update-post_'.$id, 'nonce'); |
|
2405 | 2405 | |
2406 | - if ( ! current_user_can( 'edit_post', $id ) ) |
|
2406 | + if ( ! current_user_can('edit_post', $id)) |
|
2407 | 2407 | wp_send_json_error(); |
2408 | 2408 | |
2409 | 2409 | $changes = $_REQUEST['changes']; |
2410 | - $post = get_post( $id, ARRAY_A ); |
|
2410 | + $post = get_post($id, ARRAY_A); |
|
2411 | 2411 | |
2412 | - if ( 'attachment' != $post['post_type'] ) |
|
2412 | + if ('attachment' != $post['post_type']) |
|
2413 | 2413 | wp_send_json_error(); |
2414 | 2414 | |
2415 | - if ( isset( $changes['parent'] ) ) |
|
2415 | + if (isset($changes['parent'])) |
|
2416 | 2416 | $post['post_parent'] = $changes['parent']; |
2417 | 2417 | |
2418 | - if ( isset( $changes['title'] ) ) |
|
2418 | + if (isset($changes['title'])) |
|
2419 | 2419 | $post['post_title'] = $changes['title']; |
2420 | 2420 | |
2421 | - if ( isset( $changes['caption'] ) ) |
|
2421 | + if (isset($changes['caption'])) |
|
2422 | 2422 | $post['post_excerpt'] = $changes['caption']; |
2423 | 2423 | |
2424 | - if ( isset( $changes['description'] ) ) |
|
2424 | + if (isset($changes['description'])) |
|
2425 | 2425 | $post['post_content'] = $changes['description']; |
2426 | 2426 | |
2427 | - if ( MEDIA_TRASH && isset( $changes['status'] ) ) |
|
2427 | + if (MEDIA_TRASH && isset($changes['status'])) |
|
2428 | 2428 | $post['post_status'] = $changes['status']; |
2429 | 2429 | |
2430 | - if ( isset( $changes['alt'] ) ) { |
|
2431 | - $alt = wp_unslash( $changes['alt'] ); |
|
2432 | - if ( $alt != get_post_meta( $id, '_wp_attachment_image_alt', true ) ) { |
|
2433 | - $alt = wp_strip_all_tags( $alt, true ); |
|
2434 | - update_post_meta( $id, '_wp_attachment_image_alt', wp_slash( $alt ) ); |
|
2430 | + if (isset($changes['alt'])) { |
|
2431 | + $alt = wp_unslash($changes['alt']); |
|
2432 | + if ($alt != get_post_meta($id, '_wp_attachment_image_alt', true)) { |
|
2433 | + $alt = wp_strip_all_tags($alt, true); |
|
2434 | + update_post_meta($id, '_wp_attachment_image_alt', wp_slash($alt)); |
|
2435 | 2435 | } |
2436 | 2436 | } |
2437 | 2437 | |
2438 | - if ( wp_attachment_is( 'audio', $post['ID'] ) ) { |
|
2438 | + if (wp_attachment_is('audio', $post['ID'])) { |
|
2439 | 2439 | $changed = false; |
2440 | - $id3data = wp_get_attachment_metadata( $post['ID'] ); |
|
2441 | - if ( ! is_array( $id3data ) ) { |
|
2440 | + $id3data = wp_get_attachment_metadata($post['ID']); |
|
2441 | + if ( ! is_array($id3data)) { |
|
2442 | 2442 | $changed = true; |
2443 | 2443 | $id3data = array(); |
2444 | 2444 | } |
2445 | - foreach ( wp_get_attachment_id3_keys( (object) $post, 'edit' ) as $key => $label ) { |
|
2446 | - if ( isset( $changes[ $key ] ) ) { |
|
2445 | + foreach (wp_get_attachment_id3_keys((object) $post, 'edit') as $key => $label) { |
|
2446 | + if (isset($changes[$key])) { |
|
2447 | 2447 | $changed = true; |
2448 | - $id3data[ $key ] = sanitize_text_field( wp_unslash( $changes[ $key ] ) ); |
|
2448 | + $id3data[$key] = sanitize_text_field(wp_unslash($changes[$key])); |
|
2449 | 2449 | } |
2450 | 2450 | } |
2451 | 2451 | |
2452 | - if ( $changed ) { |
|
2453 | - wp_update_attachment_metadata( $id, $id3data ); |
|
2452 | + if ($changed) { |
|
2453 | + wp_update_attachment_metadata($id, $id3data); |
|
2454 | 2454 | } |
2455 | 2455 | } |
2456 | 2456 | |
2457 | - if ( MEDIA_TRASH && isset( $changes['status'] ) && 'trash' === $changes['status'] ) { |
|
2458 | - wp_delete_post( $id ); |
|
2457 | + if (MEDIA_TRASH && isset($changes['status']) && 'trash' === $changes['status']) { |
|
2458 | + wp_delete_post($id); |
|
2459 | 2459 | } else { |
2460 | - wp_update_post( $post ); |
|
2460 | + wp_update_post($post); |
|
2461 | 2461 | } |
2462 | 2462 | |
2463 | 2463 | wp_send_json_success(); |
@@ -2469,45 +2469,45 @@ discard block |
||
2469 | 2469 | * @since 3.5.0 |
2470 | 2470 | */ |
2471 | 2471 | function wp_ajax_save_attachment_compat() { |
2472 | - if ( ! isset( $_REQUEST['id'] ) ) |
|
2472 | + if ( ! isset($_REQUEST['id'])) |
|
2473 | 2473 | wp_send_json_error(); |
2474 | 2474 | |
2475 | - if ( ! $id = absint( $_REQUEST['id'] ) ) |
|
2475 | + if ( ! $id = absint($_REQUEST['id'])) |
|
2476 | 2476 | wp_send_json_error(); |
2477 | 2477 | |
2478 | - if ( empty( $_REQUEST['attachments'] ) || empty( $_REQUEST['attachments'][ $id ] ) ) |
|
2478 | + if (empty($_REQUEST['attachments']) || empty($_REQUEST['attachments'][$id])) |
|
2479 | 2479 | wp_send_json_error(); |
2480 | - $attachment_data = $_REQUEST['attachments'][ $id ]; |
|
2480 | + $attachment_data = $_REQUEST['attachments'][$id]; |
|
2481 | 2481 | |
2482 | - check_ajax_referer( 'update-post_' . $id, 'nonce' ); |
|
2482 | + check_ajax_referer('update-post_'.$id, 'nonce'); |
|
2483 | 2483 | |
2484 | - if ( ! current_user_can( 'edit_post', $id ) ) |
|
2484 | + if ( ! current_user_can('edit_post', $id)) |
|
2485 | 2485 | wp_send_json_error(); |
2486 | 2486 | |
2487 | - $post = get_post( $id, ARRAY_A ); |
|
2487 | + $post = get_post($id, ARRAY_A); |
|
2488 | 2488 | |
2489 | - if ( 'attachment' != $post['post_type'] ) |
|
2489 | + if ('attachment' != $post['post_type']) |
|
2490 | 2490 | wp_send_json_error(); |
2491 | 2491 | |
2492 | 2492 | /** This filter is documented in wp-admin/includes/media.php */ |
2493 | - $post = apply_filters( 'attachment_fields_to_save', $post, $attachment_data ); |
|
2493 | + $post = apply_filters('attachment_fields_to_save', $post, $attachment_data); |
|
2494 | 2494 | |
2495 | - if ( isset( $post['errors'] ) ) { |
|
2495 | + if (isset($post['errors'])) { |
|
2496 | 2496 | $errors = $post['errors']; // @todo return me and display me! |
2497 | - unset( $post['errors'] ); |
|
2497 | + unset($post['errors']); |
|
2498 | 2498 | } |
2499 | 2499 | |
2500 | - wp_update_post( $post ); |
|
2500 | + wp_update_post($post); |
|
2501 | 2501 | |
2502 | - foreach ( get_attachment_taxonomies( $post ) as $taxonomy ) { |
|
2503 | - if ( isset( $attachment_data[ $taxonomy ] ) ) |
|
2504 | - wp_set_object_terms( $id, array_map( 'trim', preg_split( '/,+/', $attachment_data[ $taxonomy ] ) ), $taxonomy, false ); |
|
2502 | + foreach (get_attachment_taxonomies($post) as $taxonomy) { |
|
2503 | + if (isset($attachment_data[$taxonomy])) |
|
2504 | + wp_set_object_terms($id, array_map('trim', preg_split('/,+/', $attachment_data[$taxonomy])), $taxonomy, false); |
|
2505 | 2505 | } |
2506 | 2506 | |
2507 | - if ( ! $attachment = wp_prepare_attachment_for_js( $id ) ) |
|
2507 | + if ( ! $attachment = wp_prepare_attachment_for_js($id)) |
|
2508 | 2508 | wp_send_json_error(); |
2509 | 2509 | |
2510 | - wp_send_json_success( $attachment ); |
|
2510 | + wp_send_json_success($attachment); |
|
2511 | 2511 | } |
2512 | 2512 | |
2513 | 2513 | /** |
@@ -2516,31 +2516,31 @@ discard block |
||
2516 | 2516 | * @since 3.5.0 |
2517 | 2517 | */ |
2518 | 2518 | function wp_ajax_save_attachment_order() { |
2519 | - if ( ! isset( $_REQUEST['post_id'] ) ) |
|
2519 | + if ( ! isset($_REQUEST['post_id'])) |
|
2520 | 2520 | wp_send_json_error(); |
2521 | 2521 | |
2522 | - if ( ! $post_id = absint( $_REQUEST['post_id'] ) ) |
|
2522 | + if ( ! $post_id = absint($_REQUEST['post_id'])) |
|
2523 | 2523 | wp_send_json_error(); |
2524 | 2524 | |
2525 | - if ( empty( $_REQUEST['attachments'] ) ) |
|
2525 | + if (empty($_REQUEST['attachments'])) |
|
2526 | 2526 | wp_send_json_error(); |
2527 | 2527 | |
2528 | - check_ajax_referer( 'update-post_' . $post_id, 'nonce' ); |
|
2528 | + check_ajax_referer('update-post_'.$post_id, 'nonce'); |
|
2529 | 2529 | |
2530 | 2530 | $attachments = $_REQUEST['attachments']; |
2531 | 2531 | |
2532 | - if ( ! current_user_can( 'edit_post', $post_id ) ) |
|
2532 | + if ( ! current_user_can('edit_post', $post_id)) |
|
2533 | 2533 | wp_send_json_error(); |
2534 | 2534 | |
2535 | - foreach ( $attachments as $attachment_id => $menu_order ) { |
|
2536 | - if ( ! current_user_can( 'edit_post', $attachment_id ) ) |
|
2535 | + foreach ($attachments as $attachment_id => $menu_order) { |
|
2536 | + if ( ! current_user_can('edit_post', $attachment_id)) |
|
2537 | 2537 | continue; |
2538 | - if ( ! $attachment = get_post( $attachment_id ) ) |
|
2538 | + if ( ! $attachment = get_post($attachment_id)) |
|
2539 | 2539 | continue; |
2540 | - if ( 'attachment' != $attachment->post_type ) |
|
2540 | + if ('attachment' != $attachment->post_type) |
|
2541 | 2541 | continue; |
2542 | 2542 | |
2543 | - wp_update_post( array( 'ID' => $attachment_id, 'menu_order' => $menu_order ) ); |
|
2543 | + wp_update_post(array('ID' => $attachment_id, 'menu_order' => $menu_order)); |
|
2544 | 2544 | } |
2545 | 2545 | |
2546 | 2546 | wp_send_json_success(); |
@@ -2556,59 +2556,59 @@ discard block |
||
2556 | 2556 | * @since 3.5.0 |
2557 | 2557 | */ |
2558 | 2558 | function wp_ajax_send_attachment_to_editor() { |
2559 | - check_ajax_referer( 'media-send-to-editor', 'nonce' ); |
|
2559 | + check_ajax_referer('media-send-to-editor', 'nonce'); |
|
2560 | 2560 | |
2561 | - $attachment = wp_unslash( $_POST['attachment'] ); |
|
2561 | + $attachment = wp_unslash($_POST['attachment']); |
|
2562 | 2562 | |
2563 | - $id = intval( $attachment['id'] ); |
|
2563 | + $id = intval($attachment['id']); |
|
2564 | 2564 | |
2565 | - if ( ! $post = get_post( $id ) ) |
|
2565 | + if ( ! $post = get_post($id)) |
|
2566 | 2566 | wp_send_json_error(); |
2567 | 2567 | |
2568 | - if ( 'attachment' != $post->post_type ) |
|
2568 | + if ('attachment' != $post->post_type) |
|
2569 | 2569 | wp_send_json_error(); |
2570 | 2570 | |
2571 | - if ( current_user_can( 'edit_post', $id ) ) { |
|
2571 | + if (current_user_can('edit_post', $id)) { |
|
2572 | 2572 | // If this attachment is unattached, attach it. Primarily a back compat thing. |
2573 | - if ( 0 == $post->post_parent && $insert_into_post_id = intval( $_POST['post_id'] ) ) { |
|
2574 | - wp_update_post( array( 'ID' => $id, 'post_parent' => $insert_into_post_id ) ); |
|
2573 | + if (0 == $post->post_parent && $insert_into_post_id = intval($_POST['post_id'])) { |
|
2574 | + wp_update_post(array('ID' => $id, 'post_parent' => $insert_into_post_id)); |
|
2575 | 2575 | } |
2576 | 2576 | } |
2577 | 2577 | |
2578 | 2578 | $rel = ''; |
2579 | - $url = empty( $attachment['url'] ) ? '' : $attachment['url']; |
|
2580 | - if ( strpos( $url, 'attachment_id') || get_attachment_link( $id ) == $url ) { |
|
2581 | - $rel = 'attachment wp-att-' . $id; |
|
2579 | + $url = empty($attachment['url']) ? '' : $attachment['url']; |
|
2580 | + if (strpos($url, 'attachment_id') || get_attachment_link($id) == $url) { |
|
2581 | + $rel = 'attachment wp-att-'.$id; |
|
2582 | 2582 | } |
2583 | 2583 | |
2584 | - remove_filter( 'media_send_to_editor', 'image_media_send_to_editor' ); |
|
2584 | + remove_filter('media_send_to_editor', 'image_media_send_to_editor'); |
|
2585 | 2585 | |
2586 | - if ( 'image' === substr( $post->post_mime_type, 0, 5 ) ) { |
|
2587 | - $align = isset( $attachment['align'] ) ? $attachment['align'] : 'none'; |
|
2588 | - $size = isset( $attachment['image-size'] ) ? $attachment['image-size'] : 'medium'; |
|
2589 | - $alt = isset( $attachment['image_alt'] ) ? $attachment['image_alt'] : ''; |
|
2586 | + if ('image' === substr($post->post_mime_type, 0, 5)) { |
|
2587 | + $align = isset($attachment['align']) ? $attachment['align'] : 'none'; |
|
2588 | + $size = isset($attachment['image-size']) ? $attachment['image-size'] : 'medium'; |
|
2589 | + $alt = isset($attachment['image_alt']) ? $attachment['image_alt'] : ''; |
|
2590 | 2590 | |
2591 | 2591 | // No whitespace-only captions. |
2592 | - $caption = isset( $attachment['post_excerpt'] ) ? $attachment['post_excerpt'] : ''; |
|
2593 | - if ( '' === trim( $caption ) ) { |
|
2592 | + $caption = isset($attachment['post_excerpt']) ? $attachment['post_excerpt'] : ''; |
|
2593 | + if ('' === trim($caption)) { |
|
2594 | 2594 | $caption = ''; |
2595 | 2595 | } |
2596 | 2596 | |
2597 | 2597 | $title = ''; // We no longer insert title tags into <img> tags, as they are redundant. |
2598 | - $html = get_image_send_to_editor( $id, $caption, $title, $align, $url, $rel, $size, $alt ); |
|
2599 | - } elseif ( wp_attachment_is( 'video', $post ) || wp_attachment_is( 'audio', $post ) ) { |
|
2600 | - $html = stripslashes_deep( $_POST['html'] ); |
|
2598 | + $html = get_image_send_to_editor($id, $caption, $title, $align, $url, $rel, $size, $alt); |
|
2599 | + } elseif (wp_attachment_is('video', $post) || wp_attachment_is('audio', $post)) { |
|
2600 | + $html = stripslashes_deep($_POST['html']); |
|
2601 | 2601 | } else { |
2602 | - $html = isset( $attachment['post_title'] ) ? $attachment['post_title'] : ''; |
|
2603 | - if ( ! empty( $url ) ) { |
|
2604 | - $html = '<a href="' . esc_url( $url ) . '"' . 'rel="' . esc_attr( $rel ) . '">' . $html . '</a>'; |
|
2602 | + $html = isset($attachment['post_title']) ? $attachment['post_title'] : ''; |
|
2603 | + if ( ! empty($url)) { |
|
2604 | + $html = '<a href="'.esc_url($url).'"'.'rel="'.esc_attr($rel).'">'.$html.'</a>'; |
|
2605 | 2605 | } |
2606 | 2606 | } |
2607 | 2607 | |
2608 | 2608 | /** This filter is documented in wp-admin/includes/media.php */ |
2609 | - $html = apply_filters( 'media_send_to_editor', $html, $id, $attachment ); |
|
2609 | + $html = apply_filters('media_send_to_editor', $html, $id, $attachment); |
|
2610 | 2610 | |
2611 | - wp_send_json_success( $html ); |
|
2611 | + wp_send_json_success($html); |
|
2612 | 2612 | } |
2613 | 2613 | |
2614 | 2614 | /** |
@@ -2629,47 +2629,47 @@ discard block |
||
2629 | 2629 | function wp_ajax_send_link_to_editor() { |
2630 | 2630 | global $post, $wp_embed; |
2631 | 2631 | |
2632 | - check_ajax_referer( 'media-send-to-editor', 'nonce' ); |
|
2632 | + check_ajax_referer('media-send-to-editor', 'nonce'); |
|
2633 | 2633 | |
2634 | - if ( ! $src = wp_unslash( $_POST['src'] ) ) |
|
2634 | + if ( ! $src = wp_unslash($_POST['src'])) |
|
2635 | 2635 | wp_send_json_error(); |
2636 | 2636 | |
2637 | - if ( ! strpos( $src, '://' ) ) |
|
2638 | - $src = 'http://' . $src; |
|
2637 | + if ( ! strpos($src, '://')) |
|
2638 | + $src = 'http://'.$src; |
|
2639 | 2639 | |
2640 | - if ( ! $src = esc_url_raw( $src ) ) |
|
2640 | + if ( ! $src = esc_url_raw($src)) |
|
2641 | 2641 | wp_send_json_error(); |
2642 | 2642 | |
2643 | - if ( ! $link_text = trim( wp_unslash( $_POST['link_text'] ) ) ) |
|
2644 | - $link_text = wp_basename( $src ); |
|
2643 | + if ( ! $link_text = trim(wp_unslash($_POST['link_text']))) |
|
2644 | + $link_text = wp_basename($src); |
|
2645 | 2645 | |
2646 | - $post = get_post( isset( $_POST['post_id'] ) ? $_POST['post_id'] : 0 ); |
|
2646 | + $post = get_post(isset($_POST['post_id']) ? $_POST['post_id'] : 0); |
|
2647 | 2647 | |
2648 | 2648 | // Ping WordPress for an embed. |
2649 | - $check_embed = $wp_embed->run_shortcode( '[embed]'. $src .'[/embed]' ); |
|
2649 | + $check_embed = $wp_embed->run_shortcode('[embed]'.$src.'[/embed]'); |
|
2650 | 2650 | |
2651 | 2651 | // Fallback that WordPress creates when no oEmbed was found. |
2652 | - $fallback = $wp_embed->maybe_make_link( $src ); |
|
2652 | + $fallback = $wp_embed->maybe_make_link($src); |
|
2653 | 2653 | |
2654 | - if ( $check_embed !== $fallback ) { |
|
2654 | + if ($check_embed !== $fallback) { |
|
2655 | 2655 | // TinyMCE view for [embed] will parse this |
2656 | - $html = '[embed]' . $src . '[/embed]'; |
|
2657 | - } elseif ( $link_text ) { |
|
2658 | - $html = '<a href="' . esc_url( $src ) . '">' . $link_text . '</a>'; |
|
2656 | + $html = '[embed]'.$src.'[/embed]'; |
|
2657 | + } elseif ($link_text) { |
|
2658 | + $html = '<a href="'.esc_url($src).'">'.$link_text.'</a>'; |
|
2659 | 2659 | } else { |
2660 | 2660 | $html = ''; |
2661 | 2661 | } |
2662 | 2662 | |
2663 | 2663 | // Figure out what filter to run: |
2664 | 2664 | $type = 'file'; |
2665 | - if ( ( $ext = preg_replace( '/^.+?\.([^.]+)$/', '$1', $src ) ) && ( $ext_type = wp_ext2type( $ext ) ) |
|
2666 | - && ( 'audio' == $ext_type || 'video' == $ext_type ) ) |
|
2665 | + if (($ext = preg_replace('/^.+?\.([^.]+)$/', '$1', $src)) && ($ext_type = wp_ext2type($ext)) |
|
2666 | + && ('audio' == $ext_type || 'video' == $ext_type)) |
|
2667 | 2667 | $type = $ext_type; |
2668 | 2668 | |
2669 | 2669 | /** This filter is documented in wp-admin/includes/media.php */ |
2670 | - $html = apply_filters( $type . '_send_to_editor_url', $html, $src, $link_text ); |
|
2670 | + $html = apply_filters($type.'_send_to_editor_url', $html, $src, $link_text); |
|
2671 | 2671 | |
2672 | - wp_send_json_success( $html ); |
|
2672 | + wp_send_json_success($html); |
|
2673 | 2673 | } |
2674 | 2674 | |
2675 | 2675 | /** |
@@ -2680,35 +2680,35 @@ discard block |
||
2680 | 2680 | * @since 3.6.0 |
2681 | 2681 | */ |
2682 | 2682 | function wp_ajax_heartbeat() { |
2683 | - if ( empty( $_POST['_nonce'] ) ) { |
|
2683 | + if (empty($_POST['_nonce'])) { |
|
2684 | 2684 | wp_send_json_error(); |
2685 | 2685 | } |
2686 | 2686 | |
2687 | 2687 | $response = $data = array(); |
2688 | - $nonce_state = wp_verify_nonce( $_POST['_nonce'], 'heartbeat-nonce' ); |
|
2688 | + $nonce_state = wp_verify_nonce($_POST['_nonce'], 'heartbeat-nonce'); |
|
2689 | 2689 | |
2690 | 2690 | // screen_id is the same as $current_screen->id and the JS global 'pagenow'. |
2691 | - if ( ! empty( $_POST['screen_id'] ) ) { |
|
2691 | + if ( ! empty($_POST['screen_id'])) { |
|
2692 | 2692 | $screen_id = sanitize_key($_POST['screen_id']); |
2693 | 2693 | } else { |
2694 | 2694 | $screen_id = 'front'; |
2695 | 2695 | } |
2696 | 2696 | |
2697 | - if ( ! empty( $_POST['data'] ) ) { |
|
2698 | - $data = wp_unslash( (array) $_POST['data'] ); |
|
2697 | + if ( ! empty($_POST['data'])) { |
|
2698 | + $data = wp_unslash((array) $_POST['data']); |
|
2699 | 2699 | } |
2700 | 2700 | |
2701 | - if ( 1 !== $nonce_state ) { |
|
2702 | - $response = apply_filters( 'wp_refresh_nonces', $response, $data, $screen_id ); |
|
2701 | + if (1 !== $nonce_state) { |
|
2702 | + $response = apply_filters('wp_refresh_nonces', $response, $data, $screen_id); |
|
2703 | 2703 | |
2704 | - if ( false === $nonce_state ) { |
|
2704 | + if (false === $nonce_state) { |
|
2705 | 2705 | // User is logged in but nonces have expired. |
2706 | 2706 | $response['nonces_expired'] = true; |
2707 | - wp_send_json( $response ); |
|
2707 | + wp_send_json($response); |
|
2708 | 2708 | } |
2709 | 2709 | } |
2710 | 2710 | |
2711 | - if ( ! empty( $data ) ) { |
|
2711 | + if ( ! empty($data)) { |
|
2712 | 2712 | /** |
2713 | 2713 | * Filter the Heartbeat response received. |
2714 | 2714 | * |
@@ -2718,7 +2718,7 @@ discard block |
||
2718 | 2718 | * @param array $data The $_POST data sent. |
2719 | 2719 | * @param string $screen_id The screen id. |
2720 | 2720 | */ |
2721 | - $response = apply_filters( 'heartbeat_received', $response, $data, $screen_id ); |
|
2721 | + $response = apply_filters('heartbeat_received', $response, $data, $screen_id); |
|
2722 | 2722 | } |
2723 | 2723 | |
2724 | 2724 | /** |
@@ -2729,7 +2729,7 @@ discard block |
||
2729 | 2729 | * @param array $response The Heartbeat response. |
2730 | 2730 | * @param string $screen_id The screen id. |
2731 | 2731 | */ |
2732 | - $response = apply_filters( 'heartbeat_send', $response, $screen_id ); |
|
2732 | + $response = apply_filters('heartbeat_send', $response, $screen_id); |
|
2733 | 2733 | |
2734 | 2734 | /** |
2735 | 2735 | * Fires when Heartbeat ticks in logged-in environments. |
@@ -2741,12 +2741,12 @@ discard block |
||
2741 | 2741 | * @param array $response The Heartbeat response. |
2742 | 2742 | * @param string $screen_id The screen id. |
2743 | 2743 | */ |
2744 | - do_action( 'heartbeat_tick', $response, $screen_id ); |
|
2744 | + do_action('heartbeat_tick', $response, $screen_id); |
|
2745 | 2745 | |
2746 | 2746 | // Send the current time according to the server |
2747 | 2747 | $response['server_time'] = time(); |
2748 | 2748 | |
2749 | - wp_send_json( $response ); |
|
2749 | + wp_send_json($response); |
|
2750 | 2750 | } |
2751 | 2751 | |
2752 | 2752 | /** |
@@ -2755,30 +2755,30 @@ discard block |
||
2755 | 2755 | * @since 3.6.0 |
2756 | 2756 | */ |
2757 | 2757 | function wp_ajax_get_revision_diffs() { |
2758 | - require ABSPATH . 'wp-admin/includes/revision.php'; |
|
2758 | + require ABSPATH.'wp-admin/includes/revision.php'; |
|
2759 | 2759 | |
2760 | - if ( ! $post = get_post( (int) $_REQUEST['post_id'] ) ) |
|
2760 | + if ( ! $post = get_post((int) $_REQUEST['post_id'])) |
|
2761 | 2761 | wp_send_json_error(); |
2762 | 2762 | |
2763 | - if ( ! current_user_can( 'read_post', $post->ID ) ) |
|
2763 | + if ( ! current_user_can('read_post', $post->ID)) |
|
2764 | 2764 | wp_send_json_error(); |
2765 | 2765 | |
2766 | 2766 | // Really just pre-loading the cache here. |
2767 | - if ( ! $revisions = wp_get_post_revisions( $post->ID, array( 'check_enabled' => false ) ) ) |
|
2767 | + if ( ! $revisions = wp_get_post_revisions($post->ID, array('check_enabled' => false))) |
|
2768 | 2768 | wp_send_json_error(); |
2769 | 2769 | |
2770 | 2770 | $return = array(); |
2771 | - @set_time_limit( 0 ); |
|
2771 | + @set_time_limit(0); |
|
2772 | 2772 | |
2773 | - foreach ( $_REQUEST['compare'] as $compare_key ) { |
|
2774 | - list( $compare_from, $compare_to ) = explode( ':', $compare_key ); // from:to |
|
2773 | + foreach ($_REQUEST['compare'] as $compare_key) { |
|
2774 | + list($compare_from, $compare_to) = explode(':', $compare_key); // from:to |
|
2775 | 2775 | |
2776 | 2776 | $return[] = array( |
2777 | 2777 | 'id' => $compare_key, |
2778 | - 'fields' => wp_get_revision_ui_diff( $post, $compare_from, $compare_to ), |
|
2778 | + 'fields' => wp_get_revision_ui_diff($post, $compare_from, $compare_to), |
|
2779 | 2779 | ); |
2780 | 2780 | } |
2781 | - wp_send_json_success( $return ); |
|
2781 | + wp_send_json_success($return); |
|
2782 | 2782 | } |
2783 | 2783 | |
2784 | 2784 | /** |
@@ -2792,21 +2792,21 @@ discard block |
||
2792 | 2792 | function wp_ajax_save_user_color_scheme() { |
2793 | 2793 | global $_wp_admin_css_colors; |
2794 | 2794 | |
2795 | - check_ajax_referer( 'save-color-scheme', 'nonce' ); |
|
2795 | + check_ajax_referer('save-color-scheme', 'nonce'); |
|
2796 | 2796 | |
2797 | - $color_scheme = sanitize_key( $_POST['color_scheme'] ); |
|
2797 | + $color_scheme = sanitize_key($_POST['color_scheme']); |
|
2798 | 2798 | |
2799 | - if ( ! isset( $_wp_admin_css_colors[ $color_scheme ] ) ) { |
|
2799 | + if ( ! isset($_wp_admin_css_colors[$color_scheme])) { |
|
2800 | 2800 | wp_send_json_error(); |
2801 | 2801 | } |
2802 | 2802 | |
2803 | - $previous_color_scheme = get_user_meta( get_current_user_id(), 'admin_color', true ); |
|
2804 | - update_user_meta( get_current_user_id(), 'admin_color', $color_scheme ); |
|
2803 | + $previous_color_scheme = get_user_meta(get_current_user_id(), 'admin_color', true); |
|
2804 | + update_user_meta(get_current_user_id(), 'admin_color', $color_scheme); |
|
2805 | 2805 | |
2806 | - wp_send_json_success( array( |
|
2807 | - 'previousScheme' => 'admin-color-' . $previous_color_scheme, |
|
2808 | - 'currentScheme' => 'admin-color-' . $color_scheme |
|
2809 | - ) ); |
|
2806 | + wp_send_json_success(array( |
|
2807 | + 'previousScheme' => 'admin-color-'.$previous_color_scheme, |
|
2808 | + 'currentScheme' => 'admin-color-'.$color_scheme |
|
2809 | + )); |
|
2810 | 2810 | } |
2811 | 2811 | |
2812 | 2812 | /** |
@@ -2820,50 +2820,50 @@ discard block |
||
2820 | 2820 | function wp_ajax_query_themes() { |
2821 | 2821 | global $themes_allowedtags, $theme_field_defaults; |
2822 | 2822 | |
2823 | - if ( ! current_user_can( 'install_themes' ) ) { |
|
2823 | + if ( ! current_user_can('install_themes')) { |
|
2824 | 2824 | wp_send_json_error(); |
2825 | 2825 | } |
2826 | 2826 | |
2827 | - $args = wp_parse_args( wp_unslash( $_REQUEST['request'] ), array( |
|
2827 | + $args = wp_parse_args(wp_unslash($_REQUEST['request']), array( |
|
2828 | 2828 | 'per_page' => 20, |
2829 | 2829 | 'fields' => $theme_field_defaults |
2830 | - ) ); |
|
2830 | + )); |
|
2831 | 2831 | |
2832 | - if ( isset( $args['browse'] ) && 'favorites' === $args['browse'] && ! isset( $args['user'] ) ) { |
|
2833 | - $user = get_user_option( 'wporg_favorites' ); |
|
2834 | - if ( $user ) { |
|
2832 | + if (isset($args['browse']) && 'favorites' === $args['browse'] && ! isset($args['user'])) { |
|
2833 | + $user = get_user_option('wporg_favorites'); |
|
2834 | + if ($user) { |
|
2835 | 2835 | $args['user'] = $user; |
2836 | 2836 | } |
2837 | 2837 | } |
2838 | 2838 | |
2839 | - $old_filter = isset( $args['browse'] ) ? $args['browse'] : 'search'; |
|
2839 | + $old_filter = isset($args['browse']) ? $args['browse'] : 'search'; |
|
2840 | 2840 | |
2841 | 2841 | /** This filter is documented in wp-admin/includes/class-wp-theme-install-list-table.php */ |
2842 | - $args = apply_filters( 'install_themes_table_api_args_' . $old_filter, $args ); |
|
2842 | + $args = apply_filters('install_themes_table_api_args_'.$old_filter, $args); |
|
2843 | 2843 | |
2844 | - $api = themes_api( 'query_themes', $args ); |
|
2844 | + $api = themes_api('query_themes', $args); |
|
2845 | 2845 | |
2846 | - if ( is_wp_error( $api ) ) { |
|
2846 | + if (is_wp_error($api)) { |
|
2847 | 2847 | wp_send_json_error(); |
2848 | 2848 | } |
2849 | 2849 | |
2850 | - $update_php = network_admin_url( 'update.php?action=install-theme' ); |
|
2851 | - foreach ( $api->themes as &$theme ) { |
|
2852 | - $theme->install_url = add_query_arg( array( |
|
2850 | + $update_php = network_admin_url('update.php?action=install-theme'); |
|
2851 | + foreach ($api->themes as &$theme) { |
|
2852 | + $theme->install_url = add_query_arg(array( |
|
2853 | 2853 | 'theme' => $theme->slug, |
2854 | - '_wpnonce' => wp_create_nonce( 'install-theme_' . $theme->slug ) |
|
2855 | - ), $update_php ); |
|
2854 | + '_wpnonce' => wp_create_nonce('install-theme_'.$theme->slug) |
|
2855 | + ), $update_php); |
|
2856 | 2856 | |
2857 | - $theme->name = wp_kses( $theme->name, $themes_allowedtags ); |
|
2858 | - $theme->author = wp_kses( $theme->author, $themes_allowedtags ); |
|
2859 | - $theme->version = wp_kses( $theme->version, $themes_allowedtags ); |
|
2860 | - $theme->description = wp_kses( $theme->description, $themes_allowedtags ); |
|
2861 | - $theme->stars = wp_star_rating( array( 'rating' => $theme->rating, 'type' => 'percent', 'number' => $theme->num_ratings, 'echo' => false ) ); |
|
2862 | - $theme->num_ratings = number_format_i18n( $theme->num_ratings ); |
|
2863 | - $theme->preview_url = set_url_scheme( $theme->preview_url ); |
|
2857 | + $theme->name = wp_kses($theme->name, $themes_allowedtags); |
|
2858 | + $theme->author = wp_kses($theme->author, $themes_allowedtags); |
|
2859 | + $theme->version = wp_kses($theme->version, $themes_allowedtags); |
|
2860 | + $theme->description = wp_kses($theme->description, $themes_allowedtags); |
|
2861 | + $theme->stars = wp_star_rating(array('rating' => $theme->rating, 'type' => 'percent', 'number' => $theme->num_ratings, 'echo' => false)); |
|
2862 | + $theme->num_ratings = number_format_i18n($theme->num_ratings); |
|
2863 | + $theme->preview_url = set_url_scheme($theme->preview_url); |
|
2864 | 2864 | } |
2865 | 2865 | |
2866 | - wp_send_json_success( $api ); |
|
2866 | + wp_send_json_success($api); |
|
2867 | 2867 | } |
2868 | 2868 | |
2869 | 2869 | /** |
@@ -2878,87 +2878,87 @@ discard block |
||
2878 | 2878 | function wp_ajax_parse_embed() { |
2879 | 2879 | global $post, $wp_embed; |
2880 | 2880 | |
2881 | - if ( ! $post = get_post( (int) $_POST['post_ID'] ) ) { |
|
2881 | + if ( ! $post = get_post((int) $_POST['post_ID'])) { |
|
2882 | 2882 | wp_send_json_error(); |
2883 | 2883 | } |
2884 | 2884 | |
2885 | - if ( empty( $_POST['shortcode'] ) || ! current_user_can( 'edit_post', $post->ID ) ) { |
|
2885 | + if (empty($_POST['shortcode']) || ! current_user_can('edit_post', $post->ID)) { |
|
2886 | 2886 | wp_send_json_error(); |
2887 | 2887 | } |
2888 | 2888 | |
2889 | - $shortcode = wp_unslash( $_POST['shortcode'] ); |
|
2889 | + $shortcode = wp_unslash($_POST['shortcode']); |
|
2890 | 2890 | |
2891 | - preg_match( '/' . get_shortcode_regex() . '/s', $shortcode, $matches ); |
|
2892 | - $atts = shortcode_parse_atts( $matches[3] ); |
|
2893 | - if ( ! empty( $matches[5] ) ) { |
|
2891 | + preg_match('/'.get_shortcode_regex().'/s', $shortcode, $matches); |
|
2892 | + $atts = shortcode_parse_atts($matches[3]); |
|
2893 | + if ( ! empty($matches[5])) { |
|
2894 | 2894 | $url = $matches[5]; |
2895 | - } elseif ( ! empty( $atts['src'] ) ) { |
|
2895 | + } elseif ( ! empty($atts['src'])) { |
|
2896 | 2896 | $url = $atts['src']; |
2897 | 2897 | } else { |
2898 | 2898 | $url = ''; |
2899 | 2899 | } |
2900 | 2900 | |
2901 | 2901 | $parsed = false; |
2902 | - setup_postdata( $post ); |
|
2902 | + setup_postdata($post); |
|
2903 | 2903 | |
2904 | 2904 | $wp_embed->return_false_on_fail = true; |
2905 | 2905 | |
2906 | - if ( is_ssl() && 0 === strpos( $url, 'http://' ) ) { |
|
2906 | + if (is_ssl() && 0 === strpos($url, 'http://')) { |
|
2907 | 2907 | // Admin is ssl and the user pasted non-ssl URL. |
2908 | 2908 | // Check if the provider supports ssl embeds and use that for the preview. |
2909 | - $ssl_shortcode = preg_replace( '%^(\\[embed[^\\]]*\\])http://%i', '$1https://', $shortcode ); |
|
2910 | - $parsed = $wp_embed->run_shortcode( $ssl_shortcode ); |
|
2909 | + $ssl_shortcode = preg_replace('%^(\\[embed[^\\]]*\\])http://%i', '$1https://', $shortcode); |
|
2910 | + $parsed = $wp_embed->run_shortcode($ssl_shortcode); |
|
2911 | 2911 | |
2912 | - if ( ! $parsed ) { |
|
2912 | + if ( ! $parsed) { |
|
2913 | 2913 | $no_ssl_support = true; |
2914 | 2914 | } |
2915 | 2915 | } |
2916 | 2916 | |
2917 | - if ( $url && ! $parsed ) { |
|
2918 | - $parsed = $wp_embed->run_shortcode( $shortcode ); |
|
2917 | + if ($url && ! $parsed) { |
|
2918 | + $parsed = $wp_embed->run_shortcode($shortcode); |
|
2919 | 2919 | } |
2920 | 2920 | |
2921 | - if ( ! $parsed ) { |
|
2922 | - wp_send_json_error( array( |
|
2921 | + if ( ! $parsed) { |
|
2922 | + wp_send_json_error(array( |
|
2923 | 2923 | 'type' => 'not-embeddable', |
2924 | - 'message' => sprintf( __( '%s failed to embed.' ), '<code>' . esc_html( $url ) . '</code>' ), |
|
2925 | - ) ); |
|
2924 | + 'message' => sprintf(__('%s failed to embed.'), '<code>'.esc_html($url).'</code>'), |
|
2925 | + )); |
|
2926 | 2926 | } |
2927 | 2927 | |
2928 | - if ( has_shortcode( $parsed, 'audio' ) || has_shortcode( $parsed, 'video' ) ) { |
|
2928 | + if (has_shortcode($parsed, 'audio') || has_shortcode($parsed, 'video')) { |
|
2929 | 2929 | $styles = ''; |
2930 | 2930 | $mce_styles = wpview_media_sandbox_styles(); |
2931 | - foreach ( $mce_styles as $style ) { |
|
2932 | - $styles .= sprintf( '<link rel="stylesheet" href="%s"/>', $style ); |
|
2931 | + foreach ($mce_styles as $style) { |
|
2932 | + $styles .= sprintf('<link rel="stylesheet" href="%s"/>', $style); |
|
2933 | 2933 | } |
2934 | 2934 | |
2935 | - $html = do_shortcode( $parsed ); |
|
2935 | + $html = do_shortcode($parsed); |
|
2936 | 2936 | |
2937 | 2937 | global $wp_scripts; |
2938 | - if ( ! empty( $wp_scripts ) ) { |
|
2938 | + if ( ! empty($wp_scripts)) { |
|
2939 | 2939 | $wp_scripts->done = array(); |
2940 | 2940 | } |
2941 | 2941 | ob_start(); |
2942 | - wp_print_scripts( 'wp-mediaelement' ); |
|
2942 | + wp_print_scripts('wp-mediaelement'); |
|
2943 | 2943 | $scripts = ob_get_clean(); |
2944 | 2944 | |
2945 | - $parsed = $styles . $html . $scripts; |
|
2945 | + $parsed = $styles.$html.$scripts; |
|
2946 | 2946 | } |
2947 | 2947 | |
2948 | 2948 | |
2949 | - if ( ! empty( $no_ssl_support ) || ( is_ssl() && ( preg_match( '%<(iframe|script|embed) [^>]*src="http://%', $parsed ) || |
|
2950 | - preg_match( '%<link [^>]*href="http://%', $parsed ) ) ) ) { |
|
2949 | + if ( ! empty($no_ssl_support) || (is_ssl() && (preg_match('%<(iframe|script|embed) [^>]*src="http://%', $parsed) || |
|
2950 | + preg_match('%<link [^>]*href="http://%', $parsed)))) { |
|
2951 | 2951 | // Admin is ssl and the embed is not. Iframes, scripts, and other "active content" will be blocked. |
2952 | - wp_send_json_error( array( |
|
2952 | + wp_send_json_error(array( |
|
2953 | 2953 | 'type' => 'not-ssl', |
2954 | - 'message' => __( 'This preview is unavailable in the editor.' ), |
|
2955 | - ) ); |
|
2954 | + 'message' => __('This preview is unavailable in the editor.'), |
|
2955 | + )); |
|
2956 | 2956 | } |
2957 | 2957 | |
2958 | - wp_send_json_success( array( |
|
2958 | + wp_send_json_success(array( |
|
2959 | 2959 | 'body' => $parsed, |
2960 | 2960 | 'attr' => $wp_embed->last_attr |
2961 | - ) ); |
|
2961 | + )); |
|
2962 | 2962 | } |
2963 | 2963 | |
2964 | 2964 | /** |
@@ -2970,42 +2970,42 @@ discard block |
||
2970 | 2970 | function wp_ajax_parse_media_shortcode() { |
2971 | 2971 | global $post, $wp_scripts; |
2972 | 2972 | |
2973 | - if ( empty( $_POST['shortcode'] ) ) { |
|
2973 | + if (empty($_POST['shortcode'])) { |
|
2974 | 2974 | wp_send_json_error(); |
2975 | 2975 | } |
2976 | 2976 | |
2977 | - $shortcode = wp_unslash( $_POST['shortcode'] ); |
|
2977 | + $shortcode = wp_unslash($_POST['shortcode']); |
|
2978 | 2978 | |
2979 | - if ( ! empty( $_POST['post_ID'] ) ) { |
|
2980 | - $post = get_post( (int) $_POST['post_ID'] ); |
|
2979 | + if ( ! empty($_POST['post_ID'])) { |
|
2980 | + $post = get_post((int) $_POST['post_ID']); |
|
2981 | 2981 | } |
2982 | 2982 | |
2983 | 2983 | // the embed shortcode requires a post |
2984 | - if ( ! $post || ! current_user_can( 'edit_post', $post->ID ) ) { |
|
2985 | - if ( 'embed' === $shortcode ) { |
|
2984 | + if ( ! $post || ! current_user_can('edit_post', $post->ID)) { |
|
2985 | + if ('embed' === $shortcode) { |
|
2986 | 2986 | wp_send_json_error(); |
2987 | 2987 | } |
2988 | 2988 | } else { |
2989 | - setup_postdata( $post ); |
|
2989 | + setup_postdata($post); |
|
2990 | 2990 | } |
2991 | 2991 | |
2992 | - $parsed = do_shortcode( $shortcode ); |
|
2992 | + $parsed = do_shortcode($shortcode); |
|
2993 | 2993 | |
2994 | - if ( empty( $parsed ) ) { |
|
2995 | - wp_send_json_error( array( |
|
2994 | + if (empty($parsed)) { |
|
2995 | + wp_send_json_error(array( |
|
2996 | 2996 | 'type' => 'no-items', |
2997 | - 'message' => __( 'No items found.' ), |
|
2998 | - ) ); |
|
2997 | + 'message' => __('No items found.'), |
|
2998 | + )); |
|
2999 | 2999 | } |
3000 | 3000 | |
3001 | 3001 | $head = ''; |
3002 | 3002 | $styles = wpview_media_sandbox_styles(); |
3003 | 3003 | |
3004 | - foreach ( $styles as $style ) { |
|
3005 | - $head .= '<link type="text/css" rel="stylesheet" href="' . $style . '">'; |
|
3004 | + foreach ($styles as $style) { |
|
3005 | + $head .= '<link type="text/css" rel="stylesheet" href="'.$style.'">'; |
|
3006 | 3006 | } |
3007 | 3007 | |
3008 | - if ( ! empty( $wp_scripts ) ) { |
|
3008 | + if ( ! empty($wp_scripts)) { |
|
3009 | 3009 | $wp_scripts->done = array(); |
3010 | 3010 | } |
3011 | 3011 | |
@@ -3013,18 +3013,18 @@ discard block |
||
3013 | 3013 | |
3014 | 3014 | echo $parsed; |
3015 | 3015 | |
3016 | - if ( 'playlist' === $_REQUEST['type'] ) { |
|
3016 | + if ('playlist' === $_REQUEST['type']) { |
|
3017 | 3017 | wp_underscore_playlist_templates(); |
3018 | 3018 | |
3019 | - wp_print_scripts( 'wp-playlist' ); |
|
3019 | + wp_print_scripts('wp-playlist'); |
|
3020 | 3020 | } else { |
3021 | - wp_print_scripts( array( 'froogaloop', 'wp-mediaelement' ) ); |
|
3021 | + wp_print_scripts(array('froogaloop', 'wp-mediaelement')); |
|
3022 | 3022 | } |
3023 | 3023 | |
3024 | - wp_send_json_success( array( |
|
3024 | + wp_send_json_success(array( |
|
3025 | 3025 | 'head' => $head, |
3026 | 3026 | 'body' => ob_get_clean() |
3027 | - ) ); |
|
3027 | + )); |
|
3028 | 3028 | } |
3029 | 3029 | |
3030 | 3030 | /** |
@@ -3033,33 +3033,33 @@ discard block |
||
3033 | 3033 | * @since 4.1.0 |
3034 | 3034 | */ |
3035 | 3035 | function wp_ajax_destroy_sessions() { |
3036 | - $user = get_userdata( (int) $_POST['user_id'] ); |
|
3037 | - if ( $user ) { |
|
3038 | - if ( ! current_user_can( 'edit_user', $user->ID ) ) { |
|
3036 | + $user = get_userdata((int) $_POST['user_id']); |
|
3037 | + if ($user) { |
|
3038 | + if ( ! current_user_can('edit_user', $user->ID)) { |
|
3039 | 3039 | $user = false; |
3040 | - } elseif ( ! wp_verify_nonce( $_POST['nonce'], 'update-user_' . $user->ID ) ) { |
|
3040 | + } elseif ( ! wp_verify_nonce($_POST['nonce'], 'update-user_'.$user->ID)) { |
|
3041 | 3041 | $user = false; |
3042 | 3042 | } |
3043 | 3043 | } |
3044 | 3044 | |
3045 | - if ( ! $user ) { |
|
3046 | - wp_send_json_error( array( |
|
3047 | - 'message' => __( 'Could not log out user sessions. Please try again.' ), |
|
3048 | - ) ); |
|
3045 | + if ( ! $user) { |
|
3046 | + wp_send_json_error(array( |
|
3047 | + 'message' => __('Could not log out user sessions. Please try again.'), |
|
3048 | + )); |
|
3049 | 3049 | } |
3050 | 3050 | |
3051 | - $sessions = WP_Session_Tokens::get_instance( $user->ID ); |
|
3051 | + $sessions = WP_Session_Tokens::get_instance($user->ID); |
|
3052 | 3052 | |
3053 | - if ( $user->ID === get_current_user_id() ) { |
|
3054 | - $sessions->destroy_others( wp_get_session_token() ); |
|
3055 | - $message = __( 'You are now logged out everywhere else.' ); |
|
3053 | + if ($user->ID === get_current_user_id()) { |
|
3054 | + $sessions->destroy_others(wp_get_session_token()); |
|
3055 | + $message = __('You are now logged out everywhere else.'); |
|
3056 | 3056 | } else { |
3057 | 3057 | $sessions->destroy_all(); |
3058 | 3058 | /* translators: 1: User's display name. */ |
3059 | - $message = sprintf( __( '%s has been logged out.' ), $user->display_name ); |
|
3059 | + $message = sprintf(__('%s has been logged out.'), $user->display_name); |
|
3060 | 3060 | } |
3061 | 3061 | |
3062 | - wp_send_json_success( array( 'message' => $message ) ); |
|
3062 | + wp_send_json_success(array('message' => $message)); |
|
3063 | 3063 | } |
3064 | 3064 | |
3065 | 3065 | |
@@ -3073,42 +3073,42 @@ discard block |
||
3073 | 3073 | function wp_ajax_update_plugin() { |
3074 | 3074 | global $wp_filesystem; |
3075 | 3075 | |
3076 | - $plugin = urldecode( $_POST['plugin'] ); |
|
3076 | + $plugin = urldecode($_POST['plugin']); |
|
3077 | 3077 | |
3078 | 3078 | $status = array( |
3079 | 3079 | 'update' => 'plugin', |
3080 | 3080 | 'plugin' => $plugin, |
3081 | - 'slug' => sanitize_key( $_POST['slug'] ), |
|
3081 | + 'slug' => sanitize_key($_POST['slug']), |
|
3082 | 3082 | 'oldVersion' => '', |
3083 | 3083 | 'newVersion' => '', |
3084 | 3084 | ); |
3085 | 3085 | |
3086 | - $plugin_data = get_plugin_data( WP_PLUGIN_DIR . '/' . $plugin ); |
|
3087 | - if ( $plugin_data['Version'] ) { |
|
3088 | - $status['oldVersion'] = sprintf( __( 'Version %s' ), $plugin_data['Version'] ); |
|
3086 | + $plugin_data = get_plugin_data(WP_PLUGIN_DIR.'/'.$plugin); |
|
3087 | + if ($plugin_data['Version']) { |
|
3088 | + $status['oldVersion'] = sprintf(__('Version %s'), $plugin_data['Version']); |
|
3089 | 3089 | } |
3090 | 3090 | |
3091 | - if ( ! current_user_can( 'update_plugins' ) ) { |
|
3092 | - $status['error'] = __( 'You do not have sufficient permissions to update plugins for this site.' ); |
|
3093 | - wp_send_json_error( $status ); |
|
3091 | + if ( ! current_user_can('update_plugins')) { |
|
3092 | + $status['error'] = __('You do not have sufficient permissions to update plugins for this site.'); |
|
3093 | + wp_send_json_error($status); |
|
3094 | 3094 | } |
3095 | 3095 | |
3096 | - check_ajax_referer( 'updates' ); |
|
3096 | + check_ajax_referer('updates'); |
|
3097 | 3097 | |
3098 | - include_once( ABSPATH . 'wp-admin/includes/class-wp-upgrader.php' ); |
|
3098 | + include_once(ABSPATH.'wp-admin/includes/class-wp-upgrader.php'); |
|
3099 | 3099 | |
3100 | 3100 | wp_update_plugins(); |
3101 | 3101 | |
3102 | 3102 | $skin = new Automatic_Upgrader_Skin(); |
3103 | - $upgrader = new Plugin_Upgrader( $skin ); |
|
3104 | - $result = $upgrader->bulk_upgrade( array( $plugin ) ); |
|
3103 | + $upgrader = new Plugin_Upgrader($skin); |
|
3104 | + $result = $upgrader->bulk_upgrade(array($plugin)); |
|
3105 | 3105 | |
3106 | - if ( is_array( $result ) && empty( $result[$plugin] ) && is_wp_error( $skin->result ) ) { |
|
3106 | + if (is_array($result) && empty($result[$plugin]) && is_wp_error($skin->result)) { |
|
3107 | 3107 | $result = $skin->result; |
3108 | 3108 | } |
3109 | 3109 | |
3110 | - if ( is_array( $result ) && !empty( $result[ $plugin ] ) ) { |
|
3111 | - $plugin_update_data = current( $result ); |
|
3110 | + if (is_array($result) && ! empty($result[$plugin])) { |
|
3111 | + $plugin_update_data = current($result); |
|
3112 | 3112 | |
3113 | 3113 | /* |
3114 | 3114 | * If the `update_plugins` site transient is empty (e.g. when you update |
@@ -3118,38 +3118,38 @@ discard block |
||
3118 | 3118 | * Preferably something can be done to ensure `update_plugins` isn't empty. |
3119 | 3119 | * For now, surface some sort of error here. |
3120 | 3120 | */ |
3121 | - if ( $plugin_update_data === true ) { |
|
3122 | - $status['error'] = __( 'Plugin update failed.' ); |
|
3123 | - wp_send_json_error( $status ); |
|
3121 | + if ($plugin_update_data === true) { |
|
3122 | + $status['error'] = __('Plugin update failed.'); |
|
3123 | + wp_send_json_error($status); |
|
3124 | 3124 | } |
3125 | 3125 | |
3126 | - $plugin_data = get_plugins( '/' . $result[ $plugin ]['destination_name'] ); |
|
3127 | - $plugin_data = reset( $plugin_data ); |
|
3126 | + $plugin_data = get_plugins('/'.$result[$plugin]['destination_name']); |
|
3127 | + $plugin_data = reset($plugin_data); |
|
3128 | 3128 | |
3129 | - if ( $plugin_data['Version'] ) { |
|
3130 | - $status['newVersion'] = sprintf( __( 'Version %s' ), $plugin_data['Version'] ); |
|
3129 | + if ($plugin_data['Version']) { |
|
3130 | + $status['newVersion'] = sprintf(__('Version %s'), $plugin_data['Version']); |
|
3131 | 3131 | } |
3132 | 3132 | |
3133 | - wp_send_json_success( $status ); |
|
3134 | - } else if ( is_wp_error( $result ) ) { |
|
3133 | + wp_send_json_success($status); |
|
3134 | + } else if (is_wp_error($result)) { |
|
3135 | 3135 | $status['error'] = $result->get_error_message(); |
3136 | - wp_send_json_error( $status ); |
|
3136 | + wp_send_json_error($status); |
|
3137 | 3137 | |
3138 | - } else if ( is_bool( $result ) && ! $result ) { |
|
3138 | + } else if (is_bool($result) && ! $result) { |
|
3139 | 3139 | $status['errorCode'] = 'unable_to_connect_to_filesystem'; |
3140 | - $status['error'] = __( 'Unable to connect to the filesystem. Please confirm your credentials.' ); |
|
3140 | + $status['error'] = __('Unable to connect to the filesystem. Please confirm your credentials.'); |
|
3141 | 3141 | |
3142 | 3142 | // Pass through the error from WP_Filesystem if one was raised |
3143 | - if ( is_wp_error( $wp_filesystem->errors ) && $wp_filesystem->errors->get_error_code() ) { |
|
3143 | + if (is_wp_error($wp_filesystem->errors) && $wp_filesystem->errors->get_error_code()) { |
|
3144 | 3144 | $status['error'] = $wp_filesystem->errors->get_error_message(); |
3145 | 3145 | } |
3146 | 3146 | |
3147 | - wp_send_json_error( $status ); |
|
3147 | + wp_send_json_error($status); |
|
3148 | 3148 | |
3149 | 3149 | } else { |
3150 | 3150 | // An unhandled error occured |
3151 | - $status['error'] = __( 'Plugin update failed.' ); |
|
3152 | - wp_send_json_error( $status ); |
|
3151 | + $status['error'] = __('Plugin update failed.'); |
|
3152 | + wp_send_json_error($status); |
|
3153 | 3153 | } |
3154 | 3154 | } |
3155 | 3155 | |
@@ -3161,8 +3161,8 @@ discard block |
||
3161 | 3161 | * @global WP_Press_This $wp_press_this |
3162 | 3162 | */ |
3163 | 3163 | function wp_ajax_press_this_save_post() { |
3164 | - if ( empty( $GLOBALS['wp_press_this'] ) ) { |
|
3165 | - include( ABSPATH . 'wp-admin/includes/class-wp-press-this.php' ); |
|
3164 | + if (empty($GLOBALS['wp_press_this'])) { |
|
3165 | + include(ABSPATH.'wp-admin/includes/class-wp-press-this.php'); |
|
3166 | 3166 | } |
3167 | 3167 | |
3168 | 3168 | $GLOBALS['wp_press_this']->save_post(); |
@@ -3176,8 +3176,8 @@ discard block |
||
3176 | 3176 | * @global WP_Press_This $wp_press_this |
3177 | 3177 | */ |
3178 | 3178 | function wp_ajax_press_this_add_category() { |
3179 | - if ( empty( $GLOBALS['wp_press_this'] ) ) { |
|
3180 | - include( ABSPATH . 'wp-admin/includes/class-wp-press-this.php' ); |
|
3179 | + if (empty($GLOBALS['wp_press_this'])) { |
|
3180 | + include(ABSPATH.'wp-admin/includes/class-wp-press-this.php'); |
|
3181 | 3181 | } |
3182 | 3182 | |
3183 | 3183 | $GLOBALS['wp_press_this']->add_category(); |
@@ -3191,49 +3191,49 @@ discard block |
||
3191 | 3191 | * @global WP_Site_Icon $wp_site_icon |
3192 | 3192 | */ |
3193 | 3193 | function wp_ajax_crop_image() { |
3194 | - $attachment_id = absint( $_POST['id'] ); |
|
3194 | + $attachment_id = absint($_POST['id']); |
|
3195 | 3195 | |
3196 | - check_ajax_referer( 'image_editor-' . $attachment_id, 'nonce' ); |
|
3197 | - if ( ! current_user_can( 'customize' ) ) { |
|
3196 | + check_ajax_referer('image_editor-'.$attachment_id, 'nonce'); |
|
3197 | + if ( ! current_user_can('customize')) { |
|
3198 | 3198 | wp_send_json_error(); |
3199 | 3199 | } |
3200 | 3200 | |
3201 | - $context = str_replace( '_', '-', $_POST['context'] ); |
|
3202 | - $data = array_map( 'absint', $_POST['cropDetails'] ); |
|
3203 | - $cropped = wp_crop_image( $attachment_id, $data['x1'], $data['y1'], $data['width'], $data['height'], $data['dst_width'], $data['dst_height'] ); |
|
3201 | + $context = str_replace('_', '-', $_POST['context']); |
|
3202 | + $data = array_map('absint', $_POST['cropDetails']); |
|
3203 | + $cropped = wp_crop_image($attachment_id, $data['x1'], $data['y1'], $data['width'], $data['height'], $data['dst_width'], $data['dst_height']); |
|
3204 | 3204 | |
3205 | - if ( ! $cropped || is_wp_error( $cropped ) ) { |
|
3206 | - wp_send_json_error( array( 'message' => __( 'Image could not be processed.' ) ) ); |
|
3205 | + if ( ! $cropped || is_wp_error($cropped)) { |
|
3206 | + wp_send_json_error(array('message' => __('Image could not be processed.'))); |
|
3207 | 3207 | } |
3208 | 3208 | |
3209 | - switch ( $context ) { |
|
3209 | + switch ($context) { |
|
3210 | 3210 | case 'site-icon': |
3211 | - require_once ABSPATH . '/wp-admin/includes/class-wp-site-icon.php'; |
|
3211 | + require_once ABSPATH.'/wp-admin/includes/class-wp-site-icon.php'; |
|
3212 | 3212 | global $wp_site_icon; |
3213 | 3213 | |
3214 | 3214 | // Skip creating a new attachment if the attachment is a Site Icon. |
3215 | - if ( get_post_meta( $attachment_id, '_wp_attachment_context', true ) == $context ) { |
|
3215 | + if (get_post_meta($attachment_id, '_wp_attachment_context', true) == $context) { |
|
3216 | 3216 | |
3217 | 3217 | // Delete the temporary cropped file, we don't need it. |
3218 | - wp_delete_file( $cropped ); |
|
3218 | + wp_delete_file($cropped); |
|
3219 | 3219 | |
3220 | 3220 | // Additional sizes in wp_prepare_attachment_for_js(). |
3221 | - add_filter( 'image_size_names_choose', array( $wp_site_icon, 'additional_sizes' ) ); |
|
3221 | + add_filter('image_size_names_choose', array($wp_site_icon, 'additional_sizes')); |
|
3222 | 3222 | break; |
3223 | 3223 | } |
3224 | 3224 | |
3225 | 3225 | /** This filter is documented in wp-admin/custom-header.php */ |
3226 | - $cropped = apply_filters( 'wp_create_file_in_uploads', $cropped, $attachment_id ); // For replication. |
|
3227 | - $object = $wp_site_icon->create_attachment_object( $cropped, $attachment_id ); |
|
3228 | - unset( $object['ID'] ); |
|
3226 | + $cropped = apply_filters('wp_create_file_in_uploads', $cropped, $attachment_id); // For replication. |
|
3227 | + $object = $wp_site_icon->create_attachment_object($cropped, $attachment_id); |
|
3228 | + unset($object['ID']); |
|
3229 | 3229 | |
3230 | 3230 | // Update the attachment. |
3231 | - add_filter( 'intermediate_image_sizes_advanced', array( $wp_site_icon, 'additional_sizes' ) ); |
|
3232 | - $attachment_id = $wp_site_icon->insert_attachment( $object, $cropped ); |
|
3233 | - remove_filter( 'intermediate_image_sizes_advanced', array( $wp_site_icon, 'additional_sizes' ) ); |
|
3231 | + add_filter('intermediate_image_sizes_advanced', array($wp_site_icon, 'additional_sizes')); |
|
3232 | + $attachment_id = $wp_site_icon->insert_attachment($object, $cropped); |
|
3233 | + remove_filter('intermediate_image_sizes_advanced', array($wp_site_icon, 'additional_sizes')); |
|
3234 | 3234 | |
3235 | 3235 | // Additional sizes in wp_prepare_attachment_for_js(). |
3236 | - add_filter( 'image_size_names_choose', array( $wp_site_icon, 'additional_sizes' ) ); |
|
3236 | + add_filter('image_size_names_choose', array($wp_site_icon, 'additional_sizes')); |
|
3237 | 3237 | break; |
3238 | 3238 | |
3239 | 3239 | default: |
@@ -3249,27 +3249,27 @@ discard block |
||
3249 | 3249 | * @param int $attachment_id The attachment ID of the original image. |
3250 | 3250 | * @param string $cropped Path to the cropped image file. |
3251 | 3251 | */ |
3252 | - do_action( 'wp_ajax_crop_image_pre_save', $context, $attachment_id, $cropped ); |
|
3252 | + do_action('wp_ajax_crop_image_pre_save', $context, $attachment_id, $cropped); |
|
3253 | 3253 | |
3254 | 3254 | /** This filter is documented in wp-admin/custom-header.php */ |
3255 | - $cropped = apply_filters( 'wp_create_file_in_uploads', $cropped, $attachment_id ); // For replication. |
|
3255 | + $cropped = apply_filters('wp_create_file_in_uploads', $cropped, $attachment_id); // For replication. |
|
3256 | 3256 | |
3257 | - $parent_url = wp_get_attachment_url( $attachment_id ); |
|
3258 | - $url = str_replace( basename( $parent_url ), basename( $cropped ), $parent_url ); |
|
3257 | + $parent_url = wp_get_attachment_url($attachment_id); |
|
3258 | + $url = str_replace(basename($parent_url), basename($cropped), $parent_url); |
|
3259 | 3259 | |
3260 | - $size = @getimagesize( $cropped ); |
|
3261 | - $image_type = ( $size ) ? $size['mime'] : 'image/jpeg'; |
|
3260 | + $size = @getimagesize($cropped); |
|
3261 | + $image_type = ($size) ? $size['mime'] : 'image/jpeg'; |
|
3262 | 3262 | |
3263 | 3263 | $object = array( |
3264 | - 'post_title' => basename( $cropped ), |
|
3264 | + 'post_title' => basename($cropped), |
|
3265 | 3265 | 'post_content' => $url, |
3266 | 3266 | 'post_mime_type' => $image_type, |
3267 | 3267 | 'guid' => $url, |
3268 | 3268 | 'context' => $context, |
3269 | 3269 | ); |
3270 | 3270 | |
3271 | - $attachment_id = wp_insert_attachment( $object, $cropped ); |
|
3272 | - $metadata = wp_generate_attachment_metadata( $attachment_id, $cropped ); |
|
3271 | + $attachment_id = wp_insert_attachment($object, $cropped); |
|
3272 | + $metadata = wp_generate_attachment_metadata($attachment_id, $cropped); |
|
3273 | 3273 | |
3274 | 3274 | /** |
3275 | 3275 | * Filter the cropped image attachment metadata. |
@@ -3280,8 +3280,8 @@ discard block |
||
3280 | 3280 | * |
3281 | 3281 | * @param array $metadata Attachment metadata. |
3282 | 3282 | */ |
3283 | - $metadata = apply_filters( 'wp_ajax_cropped_attachment_metadata', $metadata ); |
|
3284 | - wp_update_attachment_metadata( $attachment_id, $metadata ); |
|
3283 | + $metadata = apply_filters('wp_ajax_cropped_attachment_metadata', $metadata); |
|
3284 | + wp_update_attachment_metadata($attachment_id, $metadata); |
|
3285 | 3285 | |
3286 | 3286 | /** |
3287 | 3287 | * Filter the attachment ID for a cropped image. |
@@ -3291,10 +3291,10 @@ discard block |
||
3291 | 3291 | * @param int $attachment_id The attachment ID of the cropped image. |
3292 | 3292 | * @param string $context The Customizer control requesting the cropped image. |
3293 | 3293 | */ |
3294 | - $attachment_id = apply_filters( 'wp_ajax_cropped_attachment_id', $attachment_id, $context ); |
|
3294 | + $attachment_id = apply_filters('wp_ajax_cropped_attachment_id', $attachment_id, $context); |
|
3295 | 3295 | } |
3296 | 3296 | |
3297 | - wp_send_json_success( wp_prepare_attachment_for_js( $attachment_id ) ); |
|
3297 | + wp_send_json_success(wp_prepare_attachment_for_js($attachment_id)); |
|
3298 | 3298 | } |
3299 | 3299 | |
3300 | 3300 | /** |
@@ -3303,7 +3303,7 @@ discard block |
||
3303 | 3303 | * @since 4.4.0 |
3304 | 3304 | */ |
3305 | 3305 | function wp_ajax_generate_password() { |
3306 | - wp_send_json_success( wp_generate_password( 24 ) ); |
|
3306 | + wp_send_json_success(wp_generate_password(24)); |
|
3307 | 3307 | } |
3308 | 3308 | |
3309 | 3309 | /** |
@@ -3312,15 +3312,15 @@ discard block |
||
3312 | 3312 | * @since 4.4.0 |
3313 | 3313 | */ |
3314 | 3314 | function wp_ajax_save_wporg_username() { |
3315 | - if ( ! current_user_can( 'install_themes' ) && ! current_user_can( 'install_plugins' ) ) { |
|
3315 | + if ( ! current_user_can('install_themes') && ! current_user_can('install_plugins')) { |
|
3316 | 3316 | wp_send_json_error(); |
3317 | 3317 | } |
3318 | 3318 | |
3319 | - $username = isset( $_REQUEST['username'] ) ? wp_unslash( $_REQUEST['username'] ) : false; |
|
3319 | + $username = isset($_REQUEST['username']) ? wp_unslash($_REQUEST['username']) : false; |
|
3320 | 3320 | |
3321 | - if ( ! $username ) { |
|
3321 | + if ( ! $username) { |
|
3322 | 3322 | wp_send_json_error(); |
3323 | 3323 | } |
3324 | 3324 | |
3325 | - wp_send_json_success( update_user_meta( get_current_user_id(), 'wporg_favorites', $username ) ); |
|
3325 | + wp_send_json_success(update_user_meta(get_current_user_id(), 'wporg_favorites', $username)); |
|
3326 | 3326 | } |
@@ -23,10 +23,11 @@ discard block |
||
23 | 23 | $response = array(); |
24 | 24 | |
25 | 25 | // screen_id is the same as $current_screen->id and the JS global 'pagenow'. |
26 | - if ( ! empty($_POST['screen_id']) ) |
|
27 | - $screen_id = sanitize_key($_POST['screen_id']); |
|
28 | - else |
|
29 | - $screen_id = 'front'; |
|
26 | + if ( ! empty($_POST['screen_id']) ) { |
|
27 | + $screen_id = sanitize_key($_POST['screen_id']); |
|
28 | + } else { |
|
29 | + $screen_id = 'front'; |
|
30 | + } |
|
30 | 31 | |
31 | 32 | if ( ! empty($_POST['data']) ) { |
32 | 33 | $data = wp_unslash( (array) $_POST['data'] ); |
@@ -89,11 +90,13 @@ discard block |
||
89 | 90 | check_ajax_referer( "fetch-list-$list_class", '_ajax_fetch_list_nonce' ); |
90 | 91 | |
91 | 92 | $wp_list_table = _get_list_table( $list_class, array( 'screen' => $_GET['list_args']['screen']['id'] ) ); |
92 | - if ( ! $wp_list_table ) |
|
93 | - wp_die( 0 ); |
|
93 | + if ( ! $wp_list_table ) { |
|
94 | + wp_die( 0 ); |
|
95 | + } |
|
94 | 96 | |
95 | - if ( ! $wp_list_table->ajax_user_can() ) |
|
96 | - wp_die( -1 ); |
|
97 | + if ( ! $wp_list_table->ajax_user_can() ) { |
|
98 | + wp_die( -1 ); |
|
99 | + } |
|
97 | 100 | |
98 | 101 | $wp_list_table->ajax_response(); |
99 | 102 | |
@@ -123,8 +126,9 @@ discard block |
||
123 | 126 | $s = wp_unslash( $_GET['q'] ); |
124 | 127 | |
125 | 128 | $comma = _x( ',', 'tag delimiter' ); |
126 | - if ( ',' !== $comma ) |
|
127 | - $s = str_replace( $comma, ',', $s ); |
|
129 | + if ( ',' !== $comma ) { |
|
130 | + $s = str_replace( $comma, ',', $s ); |
|
131 | + } |
|
128 | 132 | if ( false !== strpos( $s, ',' ) ) { |
129 | 133 | $s = explode( ',', $s ); |
130 | 134 | $s = $s[count( $s ) - 1]; |
@@ -162,8 +166,9 @@ discard block |
||
162 | 166 | * @since 3.1.0 |
163 | 167 | */ |
164 | 168 | function wp_ajax_wp_compression_test() { |
165 | - if ( !current_user_can( 'manage_options' ) ) |
|
166 | - wp_die( -1 ); |
|
169 | + if ( !current_user_can( 'manage_options' ) ) { |
|
170 | + wp_die( -1 ); |
|
171 | + } |
|
167 | 172 | |
168 | 173 | if ( ini_get('zlib.output_compression') || 'ob_gzhandler' == ini_get('output_handler') ) { |
169 | 174 | update_site_option('can_compress_scripts', 0); |
@@ -183,8 +188,9 @@ discard block |
||
183 | 188 | echo $test_str; |
184 | 189 | wp_die(); |
185 | 190 | } elseif ( 2 == $_GET['test'] ) { |
186 | - if ( !isset($_SERVER['HTTP_ACCEPT_ENCODING']) ) |
|
187 | - wp_die( -1 ); |
|
191 | + if ( !isset($_SERVER['HTTP_ACCEPT_ENCODING']) ) { |
|
192 | + wp_die( -1 ); |
|
193 | + } |
|
188 | 194 | if ( false !== stripos( $_SERVER['HTTP_ACCEPT_ENCODING'], 'deflate') && function_exists('gzdeflate') && ! $force_gzip ) { |
189 | 195 | header('Content-Encoding: deflate'); |
190 | 196 | $out = gzdeflate( $test_str, 1 ); |
@@ -213,14 +219,16 @@ discard block |
||
213 | 219 | */ |
214 | 220 | function wp_ajax_imgedit_preview() { |
215 | 221 | $post_id = intval($_GET['postid']); |
216 | - if ( empty($post_id) || !current_user_can('edit_post', $post_id) ) |
|
217 | - wp_die( -1 ); |
|
222 | + if ( empty($post_id) || !current_user_can('edit_post', $post_id) ) { |
|
223 | + wp_die( -1 ); |
|
224 | + } |
|
218 | 225 | |
219 | 226 | check_ajax_referer( "image_editor-$post_id" ); |
220 | 227 | |
221 | 228 | include_once( ABSPATH . 'wp-admin/includes/image-edit.php' ); |
222 | - if ( ! stream_preview_image($post_id) ) |
|
223 | - wp_die( -1 ); |
|
229 | + if ( ! stream_preview_image($post_id) ) { |
|
230 | + wp_die( -1 ); |
|
231 | + } |
|
224 | 232 | |
225 | 233 | wp_die(); |
226 | 234 | } |
@@ -243,12 +251,14 @@ discard block |
||
243 | 251 | * @since 3.4.0 |
244 | 252 | */ |
245 | 253 | function wp_ajax_autocomplete_user() { |
246 | - if ( ! is_multisite() || ! current_user_can( 'promote_users' ) || wp_is_large_network( 'users' ) ) |
|
247 | - wp_die( -1 ); |
|
254 | + if ( ! is_multisite() || ! current_user_can( 'promote_users' ) || wp_is_large_network( 'users' ) ) { |
|
255 | + wp_die( -1 ); |
|
256 | + } |
|
248 | 257 | |
249 | 258 | /** This filter is documented in wp-admin/user-new.php */ |
250 | - if ( ! is_super_admin() && ! apply_filters( 'autocomplete_users_for_site_admins', false ) ) |
|
251 | - wp_die( -1 ); |
|
259 | + if ( ! is_super_admin() && ! apply_filters( 'autocomplete_users_for_site_admins', false ) ) { |
|
260 | + wp_die( -1 ); |
|
261 | + } |
|
252 | 262 | |
253 | 263 | $return = array(); |
254 | 264 | |
@@ -378,8 +388,9 @@ discard block |
||
378 | 388 | } |
379 | 389 | |
380 | 390 | $total += $delta; |
381 | - if ( $total < 0 ) |
|
382 | - $total = 0; |
|
391 | + if ( $total < 0 ) { |
|
392 | + $total = 0; |
|
393 | + } |
|
383 | 394 | |
384 | 395 | // Only do the expensive stuff on a page-break, and about 1 other time per page |
385 | 396 | if ( 0 == $total % $per_page || 1 == mt_rand( 1, $per_page ) ) { |
@@ -389,17 +400,20 @@ discard block |
||
389 | 400 | $parsed = parse_url( $url ); |
390 | 401 | if ( isset( $parsed['query'] ) ) { |
391 | 402 | parse_str( $parsed['query'], $query_vars ); |
392 | - if ( !empty( $query_vars['comment_status'] ) ) |
|
393 | - $status = $query_vars['comment_status']; |
|
394 | - if ( !empty( $query_vars['p'] ) ) |
|
395 | - $post_id = (int) $query_vars['p']; |
|
403 | + if ( !empty( $query_vars['comment_status'] ) ) { |
|
404 | + $status = $query_vars['comment_status']; |
|
405 | + } |
|
406 | + if ( !empty( $query_vars['p'] ) ) { |
|
407 | + $post_id = (int) $query_vars['p']; |
|
408 | + } |
|
396 | 409 | } |
397 | 410 | |
398 | 411 | $comment_count = wp_count_comments($post_id); |
399 | 412 | |
400 | 413 | // We're looking for a known type of comment count. |
401 | - if ( isset( $comment_count->$status ) ) |
|
402 | - $total = $comment_count->$status; |
|
414 | + if ( isset( $comment_count->$status ) ) { |
|
415 | + $total = $comment_count->$status; |
|
416 | + } |
|
403 | 417 | // Else use the decremented value from above. |
404 | 418 | } |
405 | 419 | |
@@ -438,34 +452,41 @@ discard block |
||
438 | 452 | $action = $_POST['action']; |
439 | 453 | $taxonomy = get_taxonomy(substr($action, 4)); |
440 | 454 | check_ajax_referer( $action, '_ajax_nonce-add-' . $taxonomy->name ); |
441 | - if ( !current_user_can( $taxonomy->cap->edit_terms ) ) |
|
442 | - wp_die( -1 ); |
|
455 | + if ( !current_user_can( $taxonomy->cap->edit_terms ) ) { |
|
456 | + wp_die( -1 ); |
|
457 | + } |
|
443 | 458 | $names = explode(',', $_POST['new'.$taxonomy->name]); |
444 | 459 | $parent = isset($_POST['new'.$taxonomy->name.'_parent']) ? (int) $_POST['new'.$taxonomy->name.'_parent'] : 0; |
445 | - if ( 0 > $parent ) |
|
446 | - $parent = 0; |
|
447 | - if ( $taxonomy->name == 'category' ) |
|
448 | - $post_category = isset($_POST['post_category']) ? (array) $_POST['post_category'] : array(); |
|
449 | - else |
|
450 | - $post_category = ( isset($_POST['tax_input']) && isset($_POST['tax_input'][$taxonomy->name]) ) ? (array) $_POST['tax_input'][$taxonomy->name] : array(); |
|
460 | + if ( 0 > $parent ) { |
|
461 | + $parent = 0; |
|
462 | + } |
|
463 | + if ( $taxonomy->name == 'category' ) { |
|
464 | + $post_category = isset($_POST['post_category']) ? (array) $_POST['post_category'] : array(); |
|
465 | + } else { |
|
466 | + $post_category = ( isset($_POST['tax_input']) && isset($_POST['tax_input'][$taxonomy->name]) ) ? (array) $_POST['tax_input'][$taxonomy->name] : array(); |
|
467 | + } |
|
451 | 468 | $checked_categories = array_map( 'absint', (array) $post_category ); |
452 | 469 | $popular_ids = wp_popular_terms_checklist($taxonomy->name, 0, 10, false); |
453 | 470 | |
454 | 471 | foreach ( $names as $cat_name ) { |
455 | 472 | $cat_name = trim($cat_name); |
456 | 473 | $category_nicename = sanitize_title($cat_name); |
457 | - if ( '' === $category_nicename ) |
|
458 | - continue; |
|
459 | - if ( !$cat_id = term_exists( $cat_name, $taxonomy->name, $parent ) ) |
|
460 | - $cat_id = wp_insert_term( $cat_name, $taxonomy->name, array( 'parent' => $parent ) ); |
|
474 | + if ( '' === $category_nicename ) { |
|
475 | + continue; |
|
476 | + } |
|
477 | + if ( !$cat_id = term_exists( $cat_name, $taxonomy->name, $parent ) ) { |
|
478 | + $cat_id = wp_insert_term( $cat_name, $taxonomy->name, array( 'parent' => $parent ) ); |
|
479 | + } |
|
461 | 480 | if ( is_wp_error( $cat_id ) ) { |
462 | 481 | continue; |
463 | 482 | } elseif ( is_array( $cat_id ) ) { |
464 | 483 | $cat_id = $cat_id['term_id']; |
465 | 484 | } |
466 | 485 | $checked_categories[] = $cat_id; |
467 | - if ( $parent ) // Do these all at once in a second |
|
486 | + if ( $parent ) { |
|
487 | + // Do these all at once in a second |
|
468 | 488 | continue; |
489 | + } |
|
469 | 490 | |
470 | 491 | ob_start(); |
471 | 492 | |
@@ -487,8 +508,9 @@ discard block |
||
487 | 508 | |
488 | 509 | while ( $parent->parent ) { // get the top parent |
489 | 510 | $parent = get_term( $parent->parent, $taxonomy->name ); |
490 | - if ( is_wp_error( $parent ) ) |
|
491 | - break; |
|
511 | + if ( is_wp_error( $parent ) ) { |
|
512 | + break; |
|
513 | + } |
|
492 | 514 | $term_id = $parent->term_id; |
493 | 515 | } |
494 | 516 | |
@@ -529,43 +551,55 @@ discard block |
||
529 | 551 | function wp_ajax_delete_comment() { |
530 | 552 | $id = isset( $_POST['id'] ) ? (int) $_POST['id'] : 0; |
531 | 553 | |
532 | - if ( !$comment = get_comment( $id ) ) |
|
533 | - wp_die( time() ); |
|
534 | - if ( ! current_user_can( 'edit_comment', $comment->comment_ID ) ) |
|
535 | - wp_die( -1 ); |
|
554 | + if ( !$comment = get_comment( $id ) ) { |
|
555 | + wp_die( time() ); |
|
556 | + } |
|
557 | + if ( ! current_user_can( 'edit_comment', $comment->comment_ID ) ) { |
|
558 | + wp_die( -1 ); |
|
559 | + } |
|
536 | 560 | |
537 | 561 | check_ajax_referer( "delete-comment_$id" ); |
538 | 562 | $status = wp_get_comment_status( $comment ); |
539 | 563 | |
540 | 564 | $delta = -1; |
541 | 565 | if ( isset($_POST['trash']) && 1 == $_POST['trash'] ) { |
542 | - if ( 'trash' == $status ) |
|
543 | - wp_die( time() ); |
|
566 | + if ( 'trash' == $status ) { |
|
567 | + wp_die( time() ); |
|
568 | + } |
|
544 | 569 | $r = wp_trash_comment( $comment ); |
545 | 570 | } elseif ( isset($_POST['untrash']) && 1 == $_POST['untrash'] ) { |
546 | - if ( 'trash' != $status ) |
|
547 | - wp_die( time() ); |
|
571 | + if ( 'trash' != $status ) { |
|
572 | + wp_die( time() ); |
|
573 | + } |
|
548 | 574 | $r = wp_untrash_comment( $comment ); |
549 | - if ( ! isset( $_POST['comment_status'] ) || $_POST['comment_status'] != 'trash' ) // undo trash, not in trash |
|
575 | + if ( ! isset( $_POST['comment_status'] ) || $_POST['comment_status'] != 'trash' ) { |
|
576 | + // undo trash, not in trash |
|
550 | 577 | $delta = 1; |
578 | + } |
|
551 | 579 | } elseif ( isset($_POST['spam']) && 1 == $_POST['spam'] ) { |
552 | - if ( 'spam' == $status ) |
|
553 | - wp_die( time() ); |
|
580 | + if ( 'spam' == $status ) { |
|
581 | + wp_die( time() ); |
|
582 | + } |
|
554 | 583 | $r = wp_spam_comment( $comment ); |
555 | 584 | } elseif ( isset($_POST['unspam']) && 1 == $_POST['unspam'] ) { |
556 | - if ( 'spam' != $status ) |
|
557 | - wp_die( time() ); |
|
585 | + if ( 'spam' != $status ) { |
|
586 | + wp_die( time() ); |
|
587 | + } |
|
558 | 588 | $r = wp_unspam_comment( $comment ); |
559 | - if ( ! isset( $_POST['comment_status'] ) || $_POST['comment_status'] != 'spam' ) // undo spam, not in spam |
|
589 | + if ( ! isset( $_POST['comment_status'] ) || $_POST['comment_status'] != 'spam' ) { |
|
590 | + // undo spam, not in spam |
|
560 | 591 | $delta = 1; |
592 | + } |
|
561 | 593 | } elseif ( isset($_POST['delete']) && 1 == $_POST['delete'] ) { |
562 | 594 | $r = wp_delete_comment( $comment ); |
563 | 595 | } else { |
564 | 596 | wp_die( -1 ); |
565 | 597 | } |
566 | 598 | |
567 | - if ( $r ) // Decide if we need to send back '1' or a more complicated response including page links and comment counts |
|
599 | + if ( $r ) { |
|
600 | + // Decide if we need to send back '1' or a more complicated response including page links and comment counts |
|
568 | 601 | _wp_ajax_delete_comment_response( $comment->comment_ID, $delta ); |
602 | + } |
|
569 | 603 | wp_die( 0 ); |
570 | 604 | } |
571 | 605 | |
@@ -581,18 +615,21 @@ discard block |
||
581 | 615 | $taxonomy = !empty($_POST['taxonomy']) ? $_POST['taxonomy'] : 'post_tag'; |
582 | 616 | $tax = get_taxonomy($taxonomy); |
583 | 617 | |
584 | - if ( !current_user_can( $tax->cap->delete_terms ) ) |
|
585 | - wp_die( -1 ); |
|
618 | + if ( !current_user_can( $tax->cap->delete_terms ) ) { |
|
619 | + wp_die( -1 ); |
|
620 | + } |
|
586 | 621 | |
587 | 622 | $tag = get_term( $tag_id, $taxonomy ); |
588 | - if ( !$tag || is_wp_error( $tag ) ) |
|
589 | - wp_die( 1 ); |
|
623 | + if ( !$tag || is_wp_error( $tag ) ) { |
|
624 | + wp_die( 1 ); |
|
625 | + } |
|
590 | 626 | |
591 | - if ( wp_delete_term($tag_id, $taxonomy)) |
|
592 | - wp_die( 1 ); |
|
593 | - else |
|
594 | - wp_die( 0 ); |
|
595 | -} |
|
627 | + if ( wp_delete_term($tag_id, $taxonomy)) { |
|
628 | + wp_die( 1 ); |
|
629 | + } else { |
|
630 | + wp_die( 0 ); |
|
631 | + } |
|
632 | + } |
|
596 | 633 | |
597 | 634 | /** |
598 | 635 | * Ajax handler for deleting a link. |
@@ -603,18 +640,21 @@ discard block |
||
603 | 640 | $id = isset( $_POST['id'] ) ? (int) $_POST['id'] : 0; |
604 | 641 | |
605 | 642 | check_ajax_referer( "delete-bookmark_$id" ); |
606 | - if ( !current_user_can( 'manage_links' ) ) |
|
607 | - wp_die( -1 ); |
|
643 | + if ( !current_user_can( 'manage_links' ) ) { |
|
644 | + wp_die( -1 ); |
|
645 | + } |
|
608 | 646 | |
609 | 647 | $link = get_bookmark( $id ); |
610 | - if ( !$link || is_wp_error( $link ) ) |
|
611 | - wp_die( 1 ); |
|
648 | + if ( !$link || is_wp_error( $link ) ) { |
|
649 | + wp_die( 1 ); |
|
650 | + } |
|
612 | 651 | |
613 | - if ( wp_delete_link( $id ) ) |
|
614 | - wp_die( 1 ); |
|
615 | - else |
|
616 | - wp_die( 0 ); |
|
617 | -} |
|
652 | + if ( wp_delete_link( $id ) ) { |
|
653 | + wp_die( 1 ); |
|
654 | + } else { |
|
655 | + wp_die( 0 ); |
|
656 | + } |
|
657 | + } |
|
618 | 658 | |
619 | 659 | /** |
620 | 660 | * Ajax handler for deleting meta. |
@@ -625,13 +665,16 @@ discard block |
||
625 | 665 | $id = isset( $_POST['id'] ) ? (int) $_POST['id'] : 0; |
626 | 666 | |
627 | 667 | check_ajax_referer( "delete-meta_$id" ); |
628 | - if ( !$meta = get_metadata_by_mid( 'post', $id ) ) |
|
629 | - wp_die( 1 ); |
|
668 | + if ( !$meta = get_metadata_by_mid( 'post', $id ) ) { |
|
669 | + wp_die( 1 ); |
|
670 | + } |
|
630 | 671 | |
631 | - if ( is_protected_meta( $meta->meta_key, 'post' ) || ! current_user_can( 'delete_post_meta', $meta->post_id, $meta->meta_key ) ) |
|
632 | - wp_die( -1 ); |
|
633 | - if ( delete_meta( $meta->meta_id ) ) |
|
634 | - wp_die( 1 ); |
|
672 | + if ( is_protected_meta( $meta->meta_key, 'post' ) || ! current_user_can( 'delete_post_meta', $meta->post_id, $meta->meta_key ) ) { |
|
673 | + wp_die( -1 ); |
|
674 | + } |
|
675 | + if ( delete_meta( $meta->meta_id ) ) { |
|
676 | + wp_die( 1 ); |
|
677 | + } |
|
635 | 678 | wp_die( 0 ); |
636 | 679 | } |
637 | 680 | |
@@ -643,22 +686,26 @@ discard block |
||
643 | 686 | * @param string $action Action to perform. |
644 | 687 | */ |
645 | 688 | function wp_ajax_delete_post( $action ) { |
646 | - if ( empty( $action ) ) |
|
647 | - $action = 'delete-post'; |
|
689 | + if ( empty( $action ) ) { |
|
690 | + $action = 'delete-post'; |
|
691 | + } |
|
648 | 692 | $id = isset( $_POST['id'] ) ? (int) $_POST['id'] : 0; |
649 | 693 | |
650 | 694 | check_ajax_referer( "{$action}_$id" ); |
651 | - if ( !current_user_can( 'delete_post', $id ) ) |
|
652 | - wp_die( -1 ); |
|
695 | + if ( !current_user_can( 'delete_post', $id ) ) { |
|
696 | + wp_die( -1 ); |
|
697 | + } |
|
653 | 698 | |
654 | - if ( !get_post( $id ) ) |
|
655 | - wp_die( 1 ); |
|
699 | + if ( !get_post( $id ) ) { |
|
700 | + wp_die( 1 ); |
|
701 | + } |
|
656 | 702 | |
657 | - if ( wp_delete_post( $id ) ) |
|
658 | - wp_die( 1 ); |
|
659 | - else |
|
660 | - wp_die( 0 ); |
|
661 | -} |
|
703 | + if ( wp_delete_post( $id ) ) { |
|
704 | + wp_die( 1 ); |
|
705 | + } else { |
|
706 | + wp_die( 0 ); |
|
707 | + } |
|
708 | + } |
|
662 | 709 | |
663 | 710 | /** |
664 | 711 | * Ajax handler for sending a post to the trash. |
@@ -668,24 +715,29 @@ discard block |
||
668 | 715 | * @param string $action Action to perform. |
669 | 716 | */ |
670 | 717 | function wp_ajax_trash_post( $action ) { |
671 | - if ( empty( $action ) ) |
|
672 | - $action = 'trash-post'; |
|
718 | + if ( empty( $action ) ) { |
|
719 | + $action = 'trash-post'; |
|
720 | + } |
|
673 | 721 | $id = isset( $_POST['id'] ) ? (int) $_POST['id'] : 0; |
674 | 722 | |
675 | 723 | check_ajax_referer( "{$action}_$id" ); |
676 | - if ( !current_user_can( 'delete_post', $id ) ) |
|
677 | - wp_die( -1 ); |
|
724 | + if ( !current_user_can( 'delete_post', $id ) ) { |
|
725 | + wp_die( -1 ); |
|
726 | + } |
|
678 | 727 | |
679 | - if ( !get_post( $id ) ) |
|
680 | - wp_die( 1 ); |
|
728 | + if ( !get_post( $id ) ) { |
|
729 | + wp_die( 1 ); |
|
730 | + } |
|
681 | 731 | |
682 | - if ( 'trash-post' == $action ) |
|
683 | - $done = wp_trash_post( $id ); |
|
684 | - else |
|
685 | - $done = wp_untrash_post( $id ); |
|
732 | + if ( 'trash-post' == $action ) { |
|
733 | + $done = wp_trash_post( $id ); |
|
734 | + } else { |
|
735 | + $done = wp_untrash_post( $id ); |
|
736 | + } |
|
686 | 737 | |
687 | - if ( $done ) |
|
688 | - wp_die( 1 ); |
|
738 | + if ( $done ) { |
|
739 | + wp_die( 1 ); |
|
740 | + } |
|
689 | 741 | |
690 | 742 | wp_die( 0 ); |
691 | 743 | } |
@@ -698,8 +750,9 @@ discard block |
||
698 | 750 | * @param string $action Action to perform. |
699 | 751 | */ |
700 | 752 | function wp_ajax_untrash_post( $action ) { |
701 | - if ( empty( $action ) ) |
|
702 | - $action = 'untrash-post'; |
|
753 | + if ( empty( $action ) ) { |
|
754 | + $action = 'untrash-post'; |
|
755 | + } |
|
703 | 756 | wp_ajax_trash_post( $action ); |
704 | 757 | } |
705 | 758 | |
@@ -709,22 +762,26 @@ discard block |
||
709 | 762 | * @param string $action |
710 | 763 | */ |
711 | 764 | function wp_ajax_delete_page( $action ) { |
712 | - if ( empty( $action ) ) |
|
713 | - $action = 'delete-page'; |
|
765 | + if ( empty( $action ) ) { |
|
766 | + $action = 'delete-page'; |
|
767 | + } |
|
714 | 768 | $id = isset( $_POST['id'] ) ? (int) $_POST['id'] : 0; |
715 | 769 | |
716 | 770 | check_ajax_referer( "{$action}_$id" ); |
717 | - if ( !current_user_can( 'delete_page', $id ) ) |
|
718 | - wp_die( -1 ); |
|
771 | + if ( !current_user_can( 'delete_page', $id ) ) { |
|
772 | + wp_die( -1 ); |
|
773 | + } |
|
719 | 774 | |
720 | - if ( ! get_post( $id ) ) |
|
721 | - wp_die( 1 ); |
|
775 | + if ( ! get_post( $id ) ) { |
|
776 | + wp_die( 1 ); |
|
777 | + } |
|
722 | 778 | |
723 | - if ( wp_delete_post( $id ) ) |
|
724 | - wp_die( 1 ); |
|
725 | - else |
|
726 | - wp_die( 0 ); |
|
727 | -} |
|
779 | + if ( wp_delete_post( $id ) ) { |
|
780 | + wp_die( 1 ); |
|
781 | + } else { |
|
782 | + wp_die( 0 ); |
|
783 | + } |
|
784 | + } |
|
728 | 785 | |
729 | 786 | /** |
730 | 787 | * Ajax handler to dim a comment. |
@@ -742,12 +799,14 @@ discard block |
||
742 | 799 | $x->send(); |
743 | 800 | } |
744 | 801 | |
745 | - if ( ! current_user_can( 'edit_comment', $comment->comment_ID ) && ! current_user_can( 'moderate_comments' ) ) |
|
746 | - wp_die( -1 ); |
|
802 | + if ( ! current_user_can( 'edit_comment', $comment->comment_ID ) && ! current_user_can( 'moderate_comments' ) ) { |
|
803 | + wp_die( -1 ); |
|
804 | + } |
|
747 | 805 | |
748 | 806 | $current = wp_get_comment_status( $comment ); |
749 | - if ( isset( $_POST['new'] ) && $_POST['new'] == $current ) |
|
750 | - wp_die( time() ); |
|
807 | + if ( isset( $_POST['new'] ) && $_POST['new'] == $current ) { |
|
808 | + wp_die( time() ); |
|
809 | + } |
|
751 | 810 | |
752 | 811 | check_ajax_referer( "approve-comment_$id" ); |
753 | 812 | if ( in_array( $current, array( 'unapproved', 'spam' ) ) ) { |
@@ -777,20 +836,24 @@ discard block |
||
777 | 836 | * @param string $action Action to perform. |
778 | 837 | */ |
779 | 838 | function wp_ajax_add_link_category( $action ) { |
780 | - if ( empty( $action ) ) |
|
781 | - $action = 'add-link-category'; |
|
839 | + if ( empty( $action ) ) { |
|
840 | + $action = 'add-link-category'; |
|
841 | + } |
|
782 | 842 | check_ajax_referer( $action ); |
783 | - if ( !current_user_can( 'manage_categories' ) ) |
|
784 | - wp_die( -1 ); |
|
843 | + if ( !current_user_can( 'manage_categories' ) ) { |
|
844 | + wp_die( -1 ); |
|
845 | + } |
|
785 | 846 | $names = explode(',', wp_unslash( $_POST['newcat'] ) ); |
786 | 847 | $x = new WP_Ajax_Response(); |
787 | 848 | foreach ( $names as $cat_name ) { |
788 | 849 | $cat_name = trim($cat_name); |
789 | 850 | $slug = sanitize_title($cat_name); |
790 | - if ( '' === $slug ) |
|
791 | - continue; |
|
792 | - if ( !$cat_id = term_exists( $cat_name, 'link_category' ) ) |
|
793 | - $cat_id = wp_insert_term( $cat_name, 'link_category' ); |
|
851 | + if ( '' === $slug ) { |
|
852 | + continue; |
|
853 | + } |
|
854 | + if ( !$cat_id = term_exists( $cat_name, 'link_category' ) ) { |
|
855 | + $cat_id = wp_insert_term( $cat_name, 'link_category' ); |
|
856 | + } |
|
794 | 857 | if ( is_wp_error( $cat_id ) ) { |
795 | 858 | continue; |
796 | 859 | } elseif ( is_array( $cat_id ) ) { |
@@ -821,8 +884,9 @@ discard block |
||
821 | 884 | $taxonomy = !empty($_POST['taxonomy']) ? $_POST['taxonomy'] : 'post_tag'; |
822 | 885 | $tax = get_taxonomy($taxonomy); |
823 | 886 | |
824 | - if ( !current_user_can( $tax->cap->edit_terms ) ) |
|
825 | - wp_die( -1 ); |
|
887 | + if ( !current_user_can( $tax->cap->edit_terms ) ) { |
|
888 | + wp_die( -1 ); |
|
889 | + } |
|
826 | 890 | |
827 | 891 | $x = new WP_Ajax_Response(); |
828 | 892 | |
@@ -830,8 +894,9 @@ discard block |
||
830 | 894 | |
831 | 895 | if ( !$tag || is_wp_error($tag) || (!$tag = get_term( $tag['term_id'], $taxonomy )) ) { |
832 | 896 | $message = __('An error has occurred. Please reload the page and try again.'); |
833 | - if ( is_wp_error($tag) && $tag->get_error_message() ) |
|
834 | - $message = $tag->get_error_message(); |
|
897 | + if ( is_wp_error($tag) && $tag->get_error_message() ) { |
|
898 | + $message = $tag->get_error_message(); |
|
899 | + } |
|
835 | 900 | |
836 | 901 | $x->add( array( |
837 | 902 | 'what' => 'taxonomy', |
@@ -888,11 +953,13 @@ discard block |
||
888 | 953 | |
889 | 954 | $tags = get_terms( $taxonomy, array( 'number' => 45, 'orderby' => 'count', 'order' => 'DESC' ) ); |
890 | 955 | |
891 | - if ( empty( $tags ) ) |
|
892 | - wp_die( $tax->labels->not_found ); |
|
956 | + if ( empty( $tags ) ) { |
|
957 | + wp_die( $tax->labels->not_found ); |
|
958 | + } |
|
893 | 959 | |
894 | - if ( is_wp_error( $tags ) ) |
|
895 | - wp_die( $tags->get_error_message() ); |
|
960 | + if ( is_wp_error( $tags ) ) { |
|
961 | + wp_die( $tags->get_error_message() ); |
|
962 | + } |
|
896 | 963 | |
897 | 964 | foreach ( $tags as $key => $tag ) { |
898 | 965 | $tags[ $key ]->link = '#'; |
@@ -902,8 +969,9 @@ discard block |
||
902 | 969 | // We need raw tag names here, so don't filter the output |
903 | 970 | $return = wp_generate_tag_cloud( $tags, array('filter' => 0) ); |
904 | 971 | |
905 | - if ( empty($return) ) |
|
906 | - wp_die( 0 ); |
|
972 | + if ( empty($return) ) { |
|
973 | + wp_die( 0 ); |
|
974 | + } |
|
907 | 975 | |
908 | 976 | echo $return; |
909 | 977 | |
@@ -922,35 +990,41 @@ discard block |
||
922 | 990 | */ |
923 | 991 | function wp_ajax_get_comments( $action ) { |
924 | 992 | global $wp_list_table, $post_id; |
925 | - if ( empty( $action ) ) |
|
926 | - $action = 'get-comments'; |
|
993 | + if ( empty( $action ) ) { |
|
994 | + $action = 'get-comments'; |
|
995 | + } |
|
927 | 996 | |
928 | 997 | check_ajax_referer( $action ); |
929 | 998 | |
930 | 999 | if ( empty( $post_id ) && ! empty( $_REQUEST['p'] ) ) { |
931 | 1000 | $id = absint( $_REQUEST['p'] ); |
932 | - if ( ! empty( $id ) ) |
|
933 | - $post_id = $id; |
|
1001 | + if ( ! empty( $id ) ) { |
|
1002 | + $post_id = $id; |
|
1003 | + } |
|
934 | 1004 | } |
935 | 1005 | |
936 | - if ( empty( $post_id ) ) |
|
937 | - wp_die( -1 ); |
|
1006 | + if ( empty( $post_id ) ) { |
|
1007 | + wp_die( -1 ); |
|
1008 | + } |
|
938 | 1009 | |
939 | 1010 | $wp_list_table = _get_list_table( 'WP_Post_Comments_List_Table', array( 'screen' => 'edit-comments' ) ); |
940 | 1011 | |
941 | - if ( ! current_user_can( 'edit_post', $post_id ) ) |
|
942 | - wp_die( -1 ); |
|
1012 | + if ( ! current_user_can( 'edit_post', $post_id ) ) { |
|
1013 | + wp_die( -1 ); |
|
1014 | + } |
|
943 | 1015 | |
944 | 1016 | $wp_list_table->prepare_items(); |
945 | 1017 | |
946 | - if ( !$wp_list_table->has_items() ) |
|
947 | - wp_die( 1 ); |
|
1018 | + if ( !$wp_list_table->has_items() ) { |
|
1019 | + wp_die( 1 ); |
|
1020 | + } |
|
948 | 1021 | |
949 | 1022 | $x = new WP_Ajax_Response(); |
950 | 1023 | ob_start(); |
951 | 1024 | foreach ( $wp_list_table->items as $comment ) { |
952 | - if ( ! current_user_can( 'edit_comment', $comment->comment_ID ) ) |
|
953 | - continue; |
|
1025 | + if ( ! current_user_can( 'edit_comment', $comment->comment_ID ) ) { |
|
1026 | + continue; |
|
1027 | + } |
|
954 | 1028 | get_comment( $comment ); |
955 | 1029 | $wp_list_table->single_row( $comment ); |
956 | 1030 | } |
@@ -974,23 +1048,27 @@ discard block |
||
974 | 1048 | */ |
975 | 1049 | function wp_ajax_replyto_comment( $action ) { |
976 | 1050 | global $wp_list_table; |
977 | - if ( empty( $action ) ) |
|
978 | - $action = 'replyto-comment'; |
|
1051 | + if ( empty( $action ) ) { |
|
1052 | + $action = 'replyto-comment'; |
|
1053 | + } |
|
979 | 1054 | |
980 | 1055 | check_ajax_referer( $action, '_ajax_nonce-replyto-comment' ); |
981 | 1056 | |
982 | 1057 | $comment_post_ID = (int) $_POST['comment_post_ID']; |
983 | 1058 | $post = get_post( $comment_post_ID ); |
984 | - if ( ! $post ) |
|
985 | - wp_die( -1 ); |
|
1059 | + if ( ! $post ) { |
|
1060 | + wp_die( -1 ); |
|
1061 | + } |
|
986 | 1062 | |
987 | - if ( !current_user_can( 'edit_post', $comment_post_ID ) ) |
|
988 | - wp_die( -1 ); |
|
1063 | + if ( !current_user_can( 'edit_post', $comment_post_ID ) ) { |
|
1064 | + wp_die( -1 ); |
|
1065 | + } |
|
989 | 1066 | |
990 | - if ( empty( $post->post_status ) ) |
|
991 | - wp_die( 1 ); |
|
992 | - elseif ( in_array($post->post_status, array('draft', 'pending', 'trash') ) ) |
|
993 | - wp_die( __('ERROR: you are replying to a comment on a draft post.') ); |
|
1067 | + if ( empty( $post->post_status ) ) { |
|
1068 | + wp_die( 1 ); |
|
1069 | + } elseif ( in_array($post->post_status, array('draft', 'pending', 'trash') ) ) { |
|
1070 | + wp_die( __('ERROR: you are replying to a comment on a draft post.') ); |
|
1071 | + } |
|
994 | 1072 | |
995 | 1073 | $user = wp_get_current_user(); |
996 | 1074 | if ( $user->exists() ) { |
@@ -1001,8 +1079,9 @@ discard block |
||
1001 | 1079 | $comment_content = trim( $_POST['content'] ); |
1002 | 1080 | $comment_type = isset( $_POST['comment_type'] ) ? trim( $_POST['comment_type'] ) : ''; |
1003 | 1081 | if ( current_user_can( 'unfiltered_html' ) ) { |
1004 | - if ( ! isset( $_POST['_wp_unfiltered_html_comment'] ) ) |
|
1005 | - $_POST['_wp_unfiltered_html_comment'] = ''; |
|
1082 | + if ( ! isset( $_POST['_wp_unfiltered_html_comment'] ) ) { |
|
1083 | + $_POST['_wp_unfiltered_html_comment'] = ''; |
|
1084 | + } |
|
1006 | 1085 | |
1007 | 1086 | if ( wp_create_nonce( 'unfiltered-html-comment' ) != $_POST['_wp_unfiltered_html_comment'] ) { |
1008 | 1087 | kses_remove_filters(); // start with a clean slate |
@@ -1013,12 +1092,14 @@ discard block |
||
1013 | 1092 | wp_die( __( 'Sorry, you must be logged in to reply to a comment.' ) ); |
1014 | 1093 | } |
1015 | 1094 | |
1016 | - if ( '' == $comment_content ) |
|
1017 | - wp_die( __( 'ERROR: please type a comment.' ) ); |
|
1095 | + if ( '' == $comment_content ) { |
|
1096 | + wp_die( __( 'ERROR: please type a comment.' ) ); |
|
1097 | + } |
|
1018 | 1098 | |
1019 | 1099 | $comment_parent = 0; |
1020 | - if ( isset( $_POST['comment_ID'] ) ) |
|
1021 | - $comment_parent = absint( $_POST['comment_ID'] ); |
|
1100 | + if ( isset( $_POST['comment_ID'] ) ) { |
|
1101 | + $comment_parent = absint( $_POST['comment_ID'] ); |
|
1102 | + } |
|
1022 | 1103 | $comment_auto_approved = false; |
1023 | 1104 | $commentdata = compact('comment_post_ID', 'comment_author', 'comment_author_email', 'comment_author_url', 'comment_content', 'comment_type', 'comment_parent', 'user_ID'); |
1024 | 1105 | |
@@ -1031,14 +1112,17 @@ discard block |
||
1031 | 1112 | wp_die( -1 ); |
1032 | 1113 | } |
1033 | 1114 | |
1034 | - if ( wp_set_comment_status( $parent, 'approve' ) ) |
|
1035 | - $comment_auto_approved = true; |
|
1115 | + if ( wp_set_comment_status( $parent, 'approve' ) ) { |
|
1116 | + $comment_auto_approved = true; |
|
1117 | + } |
|
1036 | 1118 | } |
1037 | 1119 | } |
1038 | 1120 | |
1039 | 1121 | $comment_id = wp_new_comment( $commentdata ); |
1040 | 1122 | $comment = get_comment($comment_id); |
1041 | - if ( ! $comment ) wp_die( 1 ); |
|
1123 | + if ( ! $comment ) { |
|
1124 | + wp_die( 1 ); |
|
1125 | + } |
|
1042 | 1126 | |
1043 | 1127 | $position = ( isset($_POST['position']) && (int) $_POST['position'] ) ? (int) $_POST['position'] : '-1'; |
1044 | 1128 | |
@@ -1099,14 +1183,17 @@ discard block |
||
1099 | 1183 | check_ajax_referer( 'replyto-comment', '_ajax_nonce-replyto-comment' ); |
1100 | 1184 | |
1101 | 1185 | $comment_id = (int) $_POST['comment_ID']; |
1102 | - if ( ! current_user_can( 'edit_comment', $comment_id ) ) |
|
1103 | - wp_die( -1 ); |
|
1186 | + if ( ! current_user_can( 'edit_comment', $comment_id ) ) { |
|
1187 | + wp_die( -1 ); |
|
1188 | + } |
|
1104 | 1189 | |
1105 | - if ( '' == $_POST['content'] ) |
|
1106 | - wp_die( __( 'ERROR: please type a comment.' ) ); |
|
1190 | + if ( '' == $_POST['content'] ) { |
|
1191 | + wp_die( __( 'ERROR: please type a comment.' ) ); |
|
1192 | + } |
|
1107 | 1193 | |
1108 | - if ( isset( $_POST['status'] ) ) |
|
1109 | - $_POST['comment_status'] = $_POST['status']; |
|
1194 | + if ( isset( $_POST['status'] ) ) { |
|
1195 | + $_POST['comment_status'] = $_POST['status']; |
|
1196 | + } |
|
1110 | 1197 | edit_comment(); |
1111 | 1198 | |
1112 | 1199 | $position = ( isset($_POST['position']) && (int) $_POST['position']) ? (int) $_POST['position'] : '-1'; |
@@ -1114,8 +1201,9 @@ discard block |
||
1114 | 1201 | $wp_list_table = _get_list_table( $checkbox ? 'WP_Comments_List_Table' : 'WP_Post_Comments_List_Table', array( 'screen' => 'edit-comments' ) ); |
1115 | 1202 | |
1116 | 1203 | $comment = get_comment( $comment_id ); |
1117 | - if ( empty( $comment->comment_ID ) ) |
|
1118 | - wp_die( -1 ); |
|
1204 | + if ( empty( $comment->comment_ID ) ) { |
|
1205 | + wp_die( -1 ); |
|
1206 | + } |
|
1119 | 1207 | |
1120 | 1208 | ob_start(); |
1121 | 1209 | $wp_list_table->single_row( $comment ); |
@@ -1141,8 +1229,9 @@ discard block |
||
1141 | 1229 | function wp_ajax_add_menu_item() { |
1142 | 1230 | check_ajax_referer( 'add-menu_item', 'menu-settings-column-nonce' ); |
1143 | 1231 | |
1144 | - if ( ! current_user_can( 'edit_theme_options' ) ) |
|
1145 | - wp_die( -1 ); |
|
1232 | + if ( ! current_user_can( 'edit_theme_options' ) ) { |
|
1233 | + wp_die( -1 ); |
|
1234 | + } |
|
1146 | 1235 | |
1147 | 1236 | require_once ABSPATH . 'wp-admin/includes/nav-menu.php'; |
1148 | 1237 | |
@@ -1181,8 +1270,9 @@ discard block |
||
1181 | 1270 | } |
1182 | 1271 | |
1183 | 1272 | $item_ids = wp_save_nav_menu_items( 0, $menu_items_data ); |
1184 | - if ( is_wp_error( $item_ids ) ) |
|
1185 | - wp_die( 0 ); |
|
1273 | + if ( is_wp_error( $item_ids ) ) { |
|
1274 | + wp_die( 0 ); |
|
1275 | + } |
|
1186 | 1276 | |
1187 | 1277 | $menu_items = array(); |
1188 | 1278 | |
@@ -1198,8 +1288,9 @@ discard block |
||
1198 | 1288 | /** This filter is documented in wp-admin/includes/nav-menu.php */ |
1199 | 1289 | $walker_class_name = apply_filters( 'wp_edit_nav_menu_walker', 'Walker_Nav_Menu_Edit', $_POST['menu'] ); |
1200 | 1290 | |
1201 | - if ( ! class_exists( $walker_class_name ) ) |
|
1202 | - wp_die( 0 ); |
|
1291 | + if ( ! class_exists( $walker_class_name ) ) { |
|
1292 | + wp_die( 0 ); |
|
1293 | + } |
|
1203 | 1294 | |
1204 | 1295 | if ( ! empty( $menu_items ) ) { |
1205 | 1296 | $args = array( |
@@ -1226,10 +1317,12 @@ discard block |
||
1226 | 1317 | $post = get_post( $pid ); |
1227 | 1318 | |
1228 | 1319 | if ( isset($_POST['metakeyselect']) || isset($_POST['metakeyinput']) ) { |
1229 | - if ( !current_user_can( 'edit_post', $pid ) ) |
|
1230 | - wp_die( -1 ); |
|
1231 | - if ( isset($_POST['metakeyselect']) && '#NONE#' == $_POST['metakeyselect'] && empty($_POST['metakeyinput']) ) |
|
1232 | - wp_die( 1 ); |
|
1320 | + if ( !current_user_can( 'edit_post', $pid ) ) { |
|
1321 | + wp_die( -1 ); |
|
1322 | + } |
|
1323 | + if ( isset($_POST['metakeyselect']) && '#NONE#' == $_POST['metakeyselect'] && empty($_POST['metakeyinput']) ) { |
|
1324 | + wp_die( 1 ); |
|
1325 | + } |
|
1233 | 1326 | |
1234 | 1327 | // If the post is an autodraft, save the post as a draft and then attempt to save the meta. |
1235 | 1328 | if ( $post->post_status == 'auto-draft' ) { |
@@ -1251,8 +1344,9 @@ discard block |
||
1251 | 1344 | $x->send(); |
1252 | 1345 | } |
1253 | 1346 | |
1254 | - if ( !$mid = add_meta( $pid ) ) |
|
1255 | - wp_die( __( 'Please provide a custom field value.' ) ); |
|
1347 | + if ( !$mid = add_meta( $pid ) ) { |
|
1348 | + wp_die( __( 'Please provide a custom field value.' ) ); |
|
1349 | + } |
|
1256 | 1350 | } else { |
1257 | 1351 | wp_die( 0 ); |
1258 | 1352 | } |
@@ -1274,19 +1368,26 @@ discard block |
||
1274 | 1368 | $mid = (int) key( $_POST['meta'] ); |
1275 | 1369 | $key = wp_unslash( $_POST['meta'][$mid]['key'] ); |
1276 | 1370 | $value = wp_unslash( $_POST['meta'][$mid]['value'] ); |
1277 | - if ( '' == trim($key) ) |
|
1278 | - wp_die( __( 'Please provide a custom field name.' ) ); |
|
1279 | - if ( '' == trim($value) ) |
|
1280 | - wp_die( __( 'Please provide a custom field value.' ) ); |
|
1281 | - if ( ! $meta = get_metadata_by_mid( 'post', $mid ) ) |
|
1282 | - wp_die( 0 ); // if meta doesn't exist |
|
1371 | + if ( '' == trim($key) ) { |
|
1372 | + wp_die( __( 'Please provide a custom field name.' ) ); |
|
1373 | + } |
|
1374 | + if ( '' == trim($value) ) { |
|
1375 | + wp_die( __( 'Please provide a custom field value.' ) ); |
|
1376 | + } |
|
1377 | + if ( ! $meta = get_metadata_by_mid( 'post', $mid ) ) { |
|
1378 | + wp_die( 0 ); |
|
1379 | + } |
|
1380 | + // if meta doesn't exist |
|
1283 | 1381 | if ( is_protected_meta( $meta->meta_key, 'post' ) || is_protected_meta( $key, 'post' ) || |
1284 | 1382 | ! current_user_can( 'edit_post_meta', $meta->post_id, $meta->meta_key ) || |
1285 | - ! current_user_can( 'edit_post_meta', $meta->post_id, $key ) ) |
|
1286 | - wp_die( -1 ); |
|
1383 | + ! current_user_can( 'edit_post_meta', $meta->post_id, $key ) ) { |
|
1384 | + wp_die( -1 ); |
|
1385 | + } |
|
1287 | 1386 | if ( $meta->meta_value != $value || $meta->meta_key != $key ) { |
1288 | - if ( !$u = update_metadata_by_mid( 'post', $mid, $value, $key ) ) |
|
1289 | - wp_die( 0 ); // We know meta exists; we also know it's unchanged (or DB error, in which case there are bigger problems). |
|
1387 | + if ( !$u = update_metadata_by_mid( 'post', $mid, $value, $key ) ) { |
|
1388 | + wp_die( 0 ); |
|
1389 | + } |
|
1390 | + // We know meta exists; we also know it's unchanged (or DB error, in which case there are bigger problems). |
|
1290 | 1391 | } |
1291 | 1392 | |
1292 | 1393 | $x = new WP_Ajax_Response( array( |
@@ -1315,12 +1416,14 @@ discard block |
||
1315 | 1416 | */ |
1316 | 1417 | function wp_ajax_add_user( $action ) { |
1317 | 1418 | global $wp_list_table; |
1318 | - if ( empty( $action ) ) |
|
1319 | - $action = 'add-user'; |
|
1419 | + if ( empty( $action ) ) { |
|
1420 | + $action = 'add-user'; |
|
1421 | + } |
|
1320 | 1422 | |
1321 | 1423 | check_ajax_referer( $action ); |
1322 | - if ( ! current_user_can('create_users') ) |
|
1323 | - wp_die( -1 ); |
|
1424 | + if ( ! current_user_can('create_users') ) { |
|
1425 | + wp_die( -1 ); |
|
1426 | + } |
|
1324 | 1427 | if ( ! $user_id = edit_user() ) { |
1325 | 1428 | wp_die( 0 ); |
1326 | 1429 | } elseif ( is_wp_error( $user_id ) ) { |
@@ -1367,14 +1470,17 @@ discard block |
||
1367 | 1470 | |
1368 | 1471 | $page = isset( $_POST['page'] ) ? $_POST['page'] : ''; |
1369 | 1472 | |
1370 | - if ( $page != sanitize_key( $page ) ) |
|
1371 | - wp_die( 0 ); |
|
1473 | + if ( $page != sanitize_key( $page ) ) { |
|
1474 | + wp_die( 0 ); |
|
1475 | + } |
|
1372 | 1476 | |
1373 | - if ( ! $user = wp_get_current_user() ) |
|
1374 | - wp_die( -1 ); |
|
1477 | + if ( ! $user = wp_get_current_user() ) { |
|
1478 | + wp_die( -1 ); |
|
1479 | + } |
|
1375 | 1480 | |
1376 | - if ( is_array($closed) ) |
|
1377 | - update_user_option($user->ID, "closedpostboxes_$page", $closed, true); |
|
1481 | + if ( is_array($closed) ) { |
|
1482 | + update_user_option($user->ID, "closedpostboxes_$page", $closed, true); |
|
1483 | + } |
|
1378 | 1484 | |
1379 | 1485 | if ( is_array($hidden) ) { |
1380 | 1486 | $hidden = array_diff( $hidden, array('submitdiv', 'linksubmitdiv', 'manage-menu', 'create-menu') ); // postboxes that are always shown |
@@ -1393,11 +1499,13 @@ discard block |
||
1393 | 1499 | check_ajax_referer( 'screen-options-nonce', 'screenoptionnonce' ); |
1394 | 1500 | $page = isset( $_POST['page'] ) ? $_POST['page'] : ''; |
1395 | 1501 | |
1396 | - if ( $page != sanitize_key( $page ) ) |
|
1397 | - wp_die( 0 ); |
|
1502 | + if ( $page != sanitize_key( $page ) ) { |
|
1503 | + wp_die( 0 ); |
|
1504 | + } |
|
1398 | 1505 | |
1399 | - if ( ! $user = wp_get_current_user() ) |
|
1400 | - wp_die( -1 ); |
|
1506 | + if ( ! $user = wp_get_current_user() ) { |
|
1507 | + wp_die( -1 ); |
|
1508 | + } |
|
1401 | 1509 | |
1402 | 1510 | $hidden = ! empty( $_POST['hidden'] ) ? explode( ',', $_POST['hidden'] ) : array(); |
1403 | 1511 | update_user_option( $user->ID, "manage{$page}columnshidden", $hidden, true ); |
@@ -1413,8 +1521,9 @@ discard block |
||
1413 | 1521 | function wp_ajax_update_welcome_panel() { |
1414 | 1522 | check_ajax_referer( 'welcome-panel-nonce', 'welcomepanelnonce' ); |
1415 | 1523 | |
1416 | - if ( ! current_user_can( 'edit_theme_options' ) ) |
|
1417 | - wp_die( -1 ); |
|
1524 | + if ( ! current_user_can( 'edit_theme_options' ) ) { |
|
1525 | + wp_die( -1 ); |
|
1526 | + } |
|
1418 | 1527 | |
1419 | 1528 | update_user_meta( get_current_user_id(), 'show_welcome_panel', empty( $_POST['visible'] ) ? 0 : 1 ); |
1420 | 1529 | |
@@ -1427,8 +1536,9 @@ discard block |
||
1427 | 1536 | * @since 3.1.0 |
1428 | 1537 | */ |
1429 | 1538 | function wp_ajax_menu_get_metabox() { |
1430 | - if ( ! current_user_can( 'edit_theme_options' ) ) |
|
1431 | - wp_die( -1 ); |
|
1539 | + if ( ! current_user_can( 'edit_theme_options' ) ) { |
|
1540 | + wp_die( -1 ); |
|
1541 | + } |
|
1432 | 1542 | |
1433 | 1543 | require_once ABSPATH . 'wp-admin/includes/nav-menu.php'; |
1434 | 1544 | |
@@ -1492,8 +1602,9 @@ discard block |
||
1492 | 1602 | require(ABSPATH . WPINC . '/class-wp-editor.php'); |
1493 | 1603 | $results = _WP_Editors::wp_link_query( $args ); |
1494 | 1604 | |
1495 | - if ( ! isset( $results ) ) |
|
1496 | - wp_die( 0 ); |
|
1605 | + if ( ! isset( $results ) ) { |
|
1606 | + wp_die( 0 ); |
|
1607 | + } |
|
1497 | 1608 | |
1498 | 1609 | echo wp_json_encode( $results ); |
1499 | 1610 | echo "\n"; |
@@ -1507,11 +1618,13 @@ discard block |
||
1507 | 1618 | * @since 3.1.0 |
1508 | 1619 | */ |
1509 | 1620 | function wp_ajax_menu_locations_save() { |
1510 | - if ( ! current_user_can( 'edit_theme_options' ) ) |
|
1511 | - wp_die( -1 ); |
|
1621 | + if ( ! current_user_can( 'edit_theme_options' ) ) { |
|
1622 | + wp_die( -1 ); |
|
1623 | + } |
|
1512 | 1624 | check_ajax_referer( 'add-menu_item', 'menu-settings-column-nonce' ); |
1513 | - if ( ! isset( $_POST['menu-locations'] ) ) |
|
1514 | - wp_die( 0 ); |
|
1625 | + if ( ! isset( $_POST['menu-locations'] ) ) { |
|
1626 | + wp_die( 0 ); |
|
1627 | + } |
|
1515 | 1628 | set_theme_mod( 'nav_menu_locations', array_map( 'absint', $_POST['menu-locations'] ) ); |
1516 | 1629 | wp_die( 1 ); |
1517 | 1630 | } |
@@ -1526,22 +1639,27 @@ discard block |
||
1526 | 1639 | $order = isset( $_POST['order'] ) ? (array) $_POST['order'] : false; |
1527 | 1640 | $page_columns = isset( $_POST['page_columns'] ) ? $_POST['page_columns'] : 'auto'; |
1528 | 1641 | |
1529 | - if ( $page_columns != 'auto' ) |
|
1530 | - $page_columns = (int) $page_columns; |
|
1642 | + if ( $page_columns != 'auto' ) { |
|
1643 | + $page_columns = (int) $page_columns; |
|
1644 | + } |
|
1531 | 1645 | |
1532 | 1646 | $page = isset( $_POST['page'] ) ? $_POST['page'] : ''; |
1533 | 1647 | |
1534 | - if ( $page != sanitize_key( $page ) ) |
|
1535 | - wp_die( 0 ); |
|
1648 | + if ( $page != sanitize_key( $page ) ) { |
|
1649 | + wp_die( 0 ); |
|
1650 | + } |
|
1536 | 1651 | |
1537 | - if ( ! $user = wp_get_current_user() ) |
|
1538 | - wp_die( -1 ); |
|
1652 | + if ( ! $user = wp_get_current_user() ) { |
|
1653 | + wp_die( -1 ); |
|
1654 | + } |
|
1539 | 1655 | |
1540 | - if ( $order ) |
|
1541 | - update_user_option($user->ID, "meta-box-order_$page", $order, true); |
|
1656 | + if ( $order ) { |
|
1657 | + update_user_option($user->ID, "meta-box-order_$page", $order, true); |
|
1658 | + } |
|
1542 | 1659 | |
1543 | - if ( $page_columns ) |
|
1544 | - update_user_option($user->ID, "screen_layout_$page", $page_columns, true); |
|
1660 | + if ( $page_columns ) { |
|
1661 | + update_user_option($user->ID, "screen_layout_$page", $page_columns, true); |
|
1662 | + } |
|
1545 | 1663 | |
1546 | 1664 | wp_die( 1 ); |
1547 | 1665 | } |
@@ -1552,8 +1670,9 @@ discard block |
||
1552 | 1670 | * @since 3.1.0 |
1553 | 1671 | */ |
1554 | 1672 | function wp_ajax_menu_quick_search() { |
1555 | - if ( ! current_user_can( 'edit_theme_options' ) ) |
|
1556 | - wp_die( -1 ); |
|
1673 | + if ( ! current_user_can( 'edit_theme_options' ) ) { |
|
1674 | + wp_die( -1 ); |
|
1675 | + } |
|
1557 | 1676 | |
1558 | 1677 | require_once ABSPATH . 'wp-admin/includes/nav-menu.php'; |
1559 | 1678 | |
@@ -1598,15 +1717,18 @@ discard block |
||
1598 | 1717 | |
1599 | 1718 | check_ajax_referer( 'inlineeditnonce', '_inline_edit' ); |
1600 | 1719 | |
1601 | - if ( ! isset($_POST['post_ID']) || ! ( $post_ID = (int) $_POST['post_ID'] ) ) |
|
1602 | - wp_die(); |
|
1720 | + if ( ! isset($_POST['post_ID']) || ! ( $post_ID = (int) $_POST['post_ID'] ) ) { |
|
1721 | + wp_die(); |
|
1722 | + } |
|
1603 | 1723 | |
1604 | 1724 | if ( 'page' == $_POST['post_type'] ) { |
1605 | - if ( ! current_user_can( 'edit_page', $post_ID ) ) |
|
1606 | - wp_die( __( 'You are not allowed to edit this page.' ) ); |
|
1725 | + if ( ! current_user_can( 'edit_page', $post_ID ) ) { |
|
1726 | + wp_die( __( 'You are not allowed to edit this page.' ) ); |
|
1727 | + } |
|
1607 | 1728 | } else { |
1608 | - if ( ! current_user_can( 'edit_post', $post_ID ) ) |
|
1609 | - wp_die( __( 'You are not allowed to edit this post.' ) ); |
|
1729 | + if ( ! current_user_can( 'edit_post', $post_ID ) ) { |
|
1730 | + wp_die( __( 'You are not allowed to edit this post.' ) ); |
|
1731 | + } |
|
1610 | 1732 | } |
1611 | 1733 | |
1612 | 1734 | if ( $last = wp_check_post_lock( $post_ID ) ) { |
@@ -1629,8 +1751,9 @@ discard block |
||
1629 | 1751 | // Rename. |
1630 | 1752 | $data['user_ID'] = get_current_user_id(); |
1631 | 1753 | |
1632 | - if ( isset($data['post_parent']) ) |
|
1633 | - $data['parent_id'] = $data['post_parent']; |
|
1754 | + if ( isset($data['post_parent']) ) { |
|
1755 | + $data['parent_id'] = $data['post_parent']; |
|
1756 | + } |
|
1634 | 1757 | |
1635 | 1758 | // Status. |
1636 | 1759 | if ( isset( $data['keep_private'] ) && 'private' == $data['keep_private'] ) { |
@@ -1640,10 +1763,12 @@ discard block |
||
1640 | 1763 | $data['post_status'] = $data['_status']; |
1641 | 1764 | } |
1642 | 1765 | |
1643 | - if ( empty($data['comment_status']) ) |
|
1644 | - $data['comment_status'] = 'closed'; |
|
1645 | - if ( empty($data['ping_status']) ) |
|
1646 | - $data['ping_status'] = 'closed'; |
|
1766 | + if ( empty($data['comment_status']) ) { |
|
1767 | + $data['comment_status'] = 'closed'; |
|
1768 | + } |
|
1769 | + if ( empty($data['ping_status']) ) { |
|
1770 | + $data['ping_status'] = 'closed'; |
|
1771 | + } |
|
1647 | 1772 | |
1648 | 1773 | // Exclude terms from taxonomies that are not supposed to appear in Quick Edit. |
1649 | 1774 | if ( ! empty( $data['tax_input'] ) ) { |
@@ -1698,16 +1823,19 @@ discard block |
||
1698 | 1823 | |
1699 | 1824 | $taxonomy = sanitize_key( $_POST['taxonomy'] ); |
1700 | 1825 | $tax = get_taxonomy( $taxonomy ); |
1701 | - if ( ! $tax ) |
|
1702 | - wp_die( 0 ); |
|
1826 | + if ( ! $tax ) { |
|
1827 | + wp_die( 0 ); |
|
1828 | + } |
|
1703 | 1829 | |
1704 | - if ( ! current_user_can( $tax->cap->edit_terms ) ) |
|
1705 | - wp_die( -1 ); |
|
1830 | + if ( ! current_user_can( $tax->cap->edit_terms ) ) { |
|
1831 | + wp_die( -1 ); |
|
1832 | + } |
|
1706 | 1833 | |
1707 | 1834 | $wp_list_table = _get_list_table( 'WP_Terms_List_Table', array( 'screen' => 'edit-' . $taxonomy ) ); |
1708 | 1835 | |
1709 | - if ( ! isset($_POST['tax_ID']) || ! ( $id = (int) $_POST['tax_ID'] ) ) |
|
1710 | - wp_die( -1 ); |
|
1836 | + if ( ! isset($_POST['tax_ID']) || ! ( $id = (int) $_POST['tax_ID'] ) ) { |
|
1837 | + wp_die( -1 ); |
|
1838 | + } |
|
1711 | 1839 | |
1712 | 1840 | $tag = get_term( $id, $taxonomy ); |
1713 | 1841 | $_POST['description'] = $tag->description; |
@@ -1716,13 +1844,15 @@ discard block |
||
1716 | 1844 | if ( $updated && !is_wp_error($updated) ) { |
1717 | 1845 | $tag = get_term( $updated['term_id'], $taxonomy ); |
1718 | 1846 | if ( !$tag || is_wp_error( $tag ) ) { |
1719 | - if ( is_wp_error($tag) && $tag->get_error_message() ) |
|
1720 | - wp_die( $tag->get_error_message() ); |
|
1847 | + if ( is_wp_error($tag) && $tag->get_error_message() ) { |
|
1848 | + wp_die( $tag->get_error_message() ); |
|
1849 | + } |
|
1721 | 1850 | wp_die( __( 'Item not updated.' ) ); |
1722 | 1851 | } |
1723 | 1852 | } else { |
1724 | - if ( is_wp_error($updated) && $updated->get_error_message() ) |
|
1725 | - wp_die( $updated->get_error_message() ); |
|
1853 | + if ( is_wp_error($updated) && $updated->get_error_message() ) { |
|
1854 | + wp_die( $updated->get_error_message() ); |
|
1855 | + } |
|
1726 | 1856 | wp_die( __( 'Item not updated.' ) ); |
1727 | 1857 | } |
1728 | 1858 | $level = 0; |
@@ -1755,8 +1885,9 @@ discard block |
||
1755 | 1885 | 'post_status' => 'any', |
1756 | 1886 | 'posts_per_page' => 50, |
1757 | 1887 | ); |
1758 | - if ( '' !== $s ) |
|
1759 | - $args['s'] = $s; |
|
1888 | + if ( '' !== $s ) { |
|
1889 | + $args['s'] = $s; |
|
1890 | + } |
|
1760 | 1891 | |
1761 | 1892 | $posts = get_posts( $args ); |
1762 | 1893 | |
@@ -1810,8 +1941,9 @@ discard block |
||
1810 | 1941 | function wp_ajax_widgets_order() { |
1811 | 1942 | check_ajax_referer( 'save-sidebar-widgets', 'savewidgets' ); |
1812 | 1943 | |
1813 | - if ( !current_user_can('edit_theme_options') ) |
|
1814 | - wp_die( -1 ); |
|
1944 | + if ( !current_user_can('edit_theme_options') ) { |
|
1945 | + wp_die( -1 ); |
|
1946 | + } |
|
1815 | 1947 | |
1816 | 1948 | unset( $_POST['savewidgets'], $_POST['action'] ); |
1817 | 1949 | |
@@ -1823,8 +1955,9 @@ discard block |
||
1823 | 1955 | if ( !empty($val) ) { |
1824 | 1956 | $val = explode(',', $val); |
1825 | 1957 | foreach ( $val as $k => $v ) { |
1826 | - if ( strpos($v, 'widget-') === false ) |
|
1827 | - continue; |
|
1958 | + if ( strpos($v, 'widget-') === false ) { |
|
1959 | + continue; |
|
1960 | + } |
|
1828 | 1961 | |
1829 | 1962 | $sb[$k] = substr($v, strpos($v, '_') + 1); |
1830 | 1963 | } |
@@ -1852,8 +1985,9 @@ discard block |
||
1852 | 1985 | |
1853 | 1986 | check_ajax_referer( 'save-sidebar-widgets', 'savewidgets' ); |
1854 | 1987 | |
1855 | - if ( !current_user_can('edit_theme_options') || !isset($_POST['id_base']) ) |
|
1856 | - wp_die( -1 ); |
|
1988 | + if ( !current_user_can('edit_theme_options') || !isset($_POST['id_base']) ) { |
|
1989 | + wp_die( -1 ); |
|
1990 | + } |
|
1857 | 1991 | |
1858 | 1992 | unset( $_POST['savewidgets'], $_POST['action'] ); |
1859 | 1993 | |
@@ -1887,8 +2021,9 @@ discard block |
||
1887 | 2021 | // Delete. |
1888 | 2022 | if ( isset($_POST['delete_widget']) && $_POST['delete_widget'] ) { |
1889 | 2023 | |
1890 | - if ( !isset($wp_registered_widgets[$widget_id]) ) |
|
1891 | - wp_die( $error ); |
|
2024 | + if ( !isset($wp_registered_widgets[$widget_id]) ) { |
|
2025 | + wp_die( $error ); |
|
2026 | + } |
|
1892 | 2027 | |
1893 | 2028 | $sidebar = array_diff( $sidebar, array($widget_id) ); |
1894 | 2029 | $_POST = array('sidebar' => $sidebar_id, 'widget-' . $id_base => array(), 'the-widget-id' => $widget_id, 'delete_widget' => '1'); |
@@ -1897,8 +2032,9 @@ discard block |
||
1897 | 2032 | do_action( 'delete_widget', $widget_id, $sidebar_id, $id_base ); |
1898 | 2033 | |
1899 | 2034 | } elseif ( $settings && preg_match( '/__i__|%i%/', key($settings) ) ) { |
1900 | - if ( !$multi_number ) |
|
1901 | - wp_die( $error ); |
|
2035 | + if ( !$multi_number ) { |
|
2036 | + wp_die( $error ); |
|
2037 | + } |
|
1902 | 2038 | |
1903 | 2039 | $_POST[ 'widget-' . $id_base ] = array( $multi_number => reset( $settings ) ); |
1904 | 2040 | $widget_id = $id_base . '-' . $multi_number; |
@@ -1909,8 +2045,9 @@ discard block |
||
1909 | 2045 | foreach ( (array) $wp_registered_widget_updates as $name => $control ) { |
1910 | 2046 | |
1911 | 2047 | if ( $name == $id_base ) { |
1912 | - if ( !is_callable( $control['callback'] ) ) |
|
1913 | - continue; |
|
2048 | + if ( !is_callable( $control['callback'] ) ) { |
|
2049 | + continue; |
|
2050 | + } |
|
1914 | 2051 | |
1915 | 2052 | ob_start(); |
1916 | 2053 | call_user_func_array( $control['callback'], $control['params'] ); |
@@ -1926,11 +2063,13 @@ discard block |
||
1926 | 2063 | wp_die(); |
1927 | 2064 | } |
1928 | 2065 | |
1929 | - if ( !empty($_POST['add_new']) ) |
|
1930 | - wp_die(); |
|
2066 | + if ( !empty($_POST['add_new']) ) { |
|
2067 | + wp_die(); |
|
2068 | + } |
|
1931 | 2069 | |
1932 | - if ( $form = $wp_registered_widget_controls[$widget_id] ) |
|
1933 | - call_user_func_array( $form['callback'], $form['params'] ); |
|
2070 | + if ( $form = $wp_registered_widget_controls[$widget_id] ) { |
|
2071 | + call_user_func_array( $form['callback'], $form['params'] ); |
|
2072 | + } |
|
1934 | 2073 | |
1935 | 2074 | wp_die(); |
1936 | 2075 | } |
@@ -2057,15 +2196,18 @@ discard block |
||
2057 | 2196 | } |
2058 | 2197 | |
2059 | 2198 | if ( isset( $post_data['context'] ) && isset( $post_data['theme'] ) ) { |
2060 | - if ( 'custom-background' === $post_data['context'] ) |
|
2061 | - update_post_meta( $attachment_id, '_wp_attachment_is_custom_background', $post_data['theme'] ); |
|
2199 | + if ( 'custom-background' === $post_data['context'] ) { |
|
2200 | + update_post_meta( $attachment_id, '_wp_attachment_is_custom_background', $post_data['theme'] ); |
|
2201 | + } |
|
2062 | 2202 | |
2063 | - if ( 'custom-header' === $post_data['context'] ) |
|
2064 | - update_post_meta( $attachment_id, '_wp_attachment_is_custom_header', $post_data['theme'] ); |
|
2203 | + if ( 'custom-header' === $post_data['context'] ) { |
|
2204 | + update_post_meta( $attachment_id, '_wp_attachment_is_custom_header', $post_data['theme'] ); |
|
2205 | + } |
|
2065 | 2206 | } |
2066 | 2207 | |
2067 | - if ( ! $attachment = wp_prepare_attachment_for_js( $attachment_id ) ) |
|
2068 | - wp_die(); |
|
2208 | + if ( ! $attachment = wp_prepare_attachment_for_js( $attachment_id ) ) { |
|
2209 | + wp_die(); |
|
2210 | + } |
|
2069 | 2211 | |
2070 | 2212 | echo wp_json_encode( array( |
2071 | 2213 | 'success' => true, |
@@ -2082,8 +2224,9 @@ discard block |
||
2082 | 2224 | */ |
2083 | 2225 | function wp_ajax_image_editor() { |
2084 | 2226 | $attachment_id = intval($_POST['postid']); |
2085 | - if ( empty($attachment_id) || !current_user_can('edit_post', $attachment_id) ) |
|
2086 | - wp_die( -1 ); |
|
2227 | + if ( empty($attachment_id) || !current_user_can('edit_post', $attachment_id) ) { |
|
2228 | + wp_die( -1 ); |
|
2229 | + } |
|
2087 | 2230 | |
2088 | 2231 | check_ajax_referer( "image_editor-$attachment_id" ); |
2089 | 2232 | include_once( ABSPATH . 'wp-admin/includes/image-edit.php' ); |
@@ -2116,15 +2259,17 @@ discard block |
||
2116 | 2259 | $json = ! empty( $_REQUEST['json'] ); // New-style request |
2117 | 2260 | |
2118 | 2261 | $post_ID = intval( $_POST['post_id'] ); |
2119 | - if ( ! current_user_can( 'edit_post', $post_ID ) ) |
|
2120 | - wp_die( -1 ); |
|
2262 | + if ( ! current_user_can( 'edit_post', $post_ID ) ) { |
|
2263 | + wp_die( -1 ); |
|
2264 | + } |
|
2121 | 2265 | |
2122 | 2266 | $thumbnail_id = intval( $_POST['thumbnail_id'] ); |
2123 | 2267 | |
2124 | - if ( $json ) |
|
2125 | - check_ajax_referer( "update-post_$post_ID" ); |
|
2126 | - else |
|
2127 | - check_ajax_referer( "set_post_thumbnail-$post_ID" ); |
|
2268 | + if ( $json ) { |
|
2269 | + check_ajax_referer( "update-post_$post_ID" ); |
|
2270 | + } else { |
|
2271 | + check_ajax_referer( "set_post_thumbnail-$post_ID" ); |
|
2272 | + } |
|
2128 | 2273 | |
2129 | 2274 | if ( $thumbnail_id == '-1' ) { |
2130 | 2275 | if ( delete_post_thumbnail( $post_ID ) ) { |
@@ -2223,8 +2368,9 @@ discard block |
||
2223 | 2368 | |
2224 | 2369 | $post = null; |
2225 | 2370 | |
2226 | - if ( $post_id ) |
|
2227 | - $post = get_post( $post_id ); |
|
2371 | + if ( $post_id ) { |
|
2372 | + $post = get_post( $post_id ); |
|
2373 | + } |
|
2228 | 2374 | |
2229 | 2375 | check_ajax_referer('update-post_' . $post_id, '_wpnonce'); |
2230 | 2376 | |
@@ -2258,20 +2404,24 @@ discard block |
||
2258 | 2404 | * @since 3.1.0 |
2259 | 2405 | */ |
2260 | 2406 | function wp_ajax_wp_remove_post_lock() { |
2261 | - if ( empty( $_POST['post_ID'] ) || empty( $_POST['active_post_lock'] ) ) |
|
2262 | - wp_die( 0 ); |
|
2407 | + if ( empty( $_POST['post_ID'] ) || empty( $_POST['active_post_lock'] ) ) { |
|
2408 | + wp_die( 0 ); |
|
2409 | + } |
|
2263 | 2410 | $post_id = (int) $_POST['post_ID']; |
2264 | - if ( ! $post = get_post( $post_id ) ) |
|
2265 | - wp_die( 0 ); |
|
2411 | + if ( ! $post = get_post( $post_id ) ) { |
|
2412 | + wp_die( 0 ); |
|
2413 | + } |
|
2266 | 2414 | |
2267 | 2415 | check_ajax_referer( 'update-post_' . $post_id ); |
2268 | 2416 | |
2269 | - if ( ! current_user_can( 'edit_post', $post_id ) ) |
|
2270 | - wp_die( -1 ); |
|
2417 | + if ( ! current_user_can( 'edit_post', $post_id ) ) { |
|
2418 | + wp_die( -1 ); |
|
2419 | + } |
|
2271 | 2420 | |
2272 | 2421 | $active_lock = array_map( 'absint', explode( ':', $_POST['active_post_lock'] ) ); |
2273 | - if ( $active_lock[1] != get_current_user_id() ) |
|
2274 | - wp_die( 0 ); |
|
2422 | + if ( $active_lock[1] != get_current_user_id() ) { |
|
2423 | + wp_die( 0 ); |
|
2424 | + } |
|
2275 | 2425 | |
2276 | 2426 | /** |
2277 | 2427 | * Filter the post lock window duration. |
@@ -2293,15 +2443,17 @@ discard block |
||
2293 | 2443 | */ |
2294 | 2444 | function wp_ajax_dismiss_wp_pointer() { |
2295 | 2445 | $pointer = $_POST['pointer']; |
2296 | - if ( $pointer != sanitize_key( $pointer ) ) |
|
2297 | - wp_die( 0 ); |
|
2446 | + if ( $pointer != sanitize_key( $pointer ) ) { |
|
2447 | + wp_die( 0 ); |
|
2448 | + } |
|
2298 | 2449 | |
2299 | 2450 | // check_ajax_referer( 'dismiss-pointer_' . $pointer ); |
2300 | 2451 | |
2301 | 2452 | $dismissed = array_filter( explode( ',', (string) get_user_meta( get_current_user_id(), 'dismissed_wp_pointers', true ) ) ); |
2302 | 2453 | |
2303 | - if ( in_array( $pointer, $dismissed ) ) |
|
2304 | - wp_die( 0 ); |
|
2454 | + if ( in_array( $pointer, $dismissed ) ) { |
|
2455 | + wp_die( 0 ); |
|
2456 | + } |
|
2305 | 2457 | |
2306 | 2458 | $dismissed[] = $pointer; |
2307 | 2459 | $dismissed = implode( ',', $dismissed ); |
@@ -2316,23 +2468,29 @@ discard block |
||
2316 | 2468 | * @since 3.5.0 |
2317 | 2469 | */ |
2318 | 2470 | function wp_ajax_get_attachment() { |
2319 | - if ( ! isset( $_REQUEST['id'] ) ) |
|
2320 | - wp_send_json_error(); |
|
2471 | + if ( ! isset( $_REQUEST['id'] ) ) { |
|
2472 | + wp_send_json_error(); |
|
2473 | + } |
|
2321 | 2474 | |
2322 | - if ( ! $id = absint( $_REQUEST['id'] ) ) |
|
2323 | - wp_send_json_error(); |
|
2475 | + if ( ! $id = absint( $_REQUEST['id'] ) ) { |
|
2476 | + wp_send_json_error(); |
|
2477 | + } |
|
2324 | 2478 | |
2325 | - if ( ! $post = get_post( $id ) ) |
|
2326 | - wp_send_json_error(); |
|
2479 | + if ( ! $post = get_post( $id ) ) { |
|
2480 | + wp_send_json_error(); |
|
2481 | + } |
|
2327 | 2482 | |
2328 | - if ( 'attachment' != $post->post_type ) |
|
2329 | - wp_send_json_error(); |
|
2483 | + if ( 'attachment' != $post->post_type ) { |
|
2484 | + wp_send_json_error(); |
|
2485 | + } |
|
2330 | 2486 | |
2331 | - if ( ! current_user_can( 'upload_files' ) ) |
|
2332 | - wp_send_json_error(); |
|
2487 | + if ( ! current_user_can( 'upload_files' ) ) { |
|
2488 | + wp_send_json_error(); |
|
2489 | + } |
|
2333 | 2490 | |
2334 | - if ( ! $attachment = wp_prepare_attachment_for_js( $id ) ) |
|
2335 | - wp_send_json_error(); |
|
2491 | + if ( ! $attachment = wp_prepare_attachment_for_js( $id ) ) { |
|
2492 | + wp_send_json_error(); |
|
2493 | + } |
|
2336 | 2494 | |
2337 | 2495 | wp_send_json_success( $attachment ); |
2338 | 2496 | } |
@@ -2343,8 +2501,9 @@ discard block |
||
2343 | 2501 | * @since 3.5.0 |
2344 | 2502 | */ |
2345 | 2503 | function wp_ajax_query_attachments() { |
2346 | - if ( ! current_user_can( 'upload_files' ) ) |
|
2347 | - wp_send_json_error(); |
|
2504 | + if ( ! current_user_can( 'upload_files' ) ) { |
|
2505 | + wp_send_json_error(); |
|
2506 | + } |
|
2348 | 2507 | |
2349 | 2508 | $query = isset( $_REQUEST['query'] ) ? (array) $_REQUEST['query'] : array(); |
2350 | 2509 | $keys = array( |
@@ -2367,8 +2526,9 @@ discard block |
||
2367 | 2526 | $query['post_status'] = 'inherit'; |
2368 | 2527 | } |
2369 | 2528 | |
2370 | - if ( current_user_can( get_post_type_object( 'attachment' )->cap->read_private_posts ) ) |
|
2371 | - $query['post_status'] .= ',private'; |
|
2529 | + if ( current_user_can( get_post_type_object( 'attachment' )->cap->read_private_posts ) ) { |
|
2530 | + $query['post_status'] .= ',private'; |
|
2531 | + } |
|
2372 | 2532 | |
2373 | 2533 | /** |
2374 | 2534 | * Filter the arguments passed to WP_Query during an AJAX |
@@ -2395,37 +2555,46 @@ discard block |
||
2395 | 2555 | * @since 3.5.0 |
2396 | 2556 | */ |
2397 | 2557 | function wp_ajax_save_attachment() { |
2398 | - if ( ! isset( $_REQUEST['id'] ) || ! isset( $_REQUEST['changes'] ) ) |
|
2399 | - wp_send_json_error(); |
|
2558 | + if ( ! isset( $_REQUEST['id'] ) || ! isset( $_REQUEST['changes'] ) ) { |
|
2559 | + wp_send_json_error(); |
|
2560 | + } |
|
2400 | 2561 | |
2401 | - if ( ! $id = absint( $_REQUEST['id'] ) ) |
|
2402 | - wp_send_json_error(); |
|
2562 | + if ( ! $id = absint( $_REQUEST['id'] ) ) { |
|
2563 | + wp_send_json_error(); |
|
2564 | + } |
|
2403 | 2565 | |
2404 | 2566 | check_ajax_referer( 'update-post_' . $id, 'nonce' ); |
2405 | 2567 | |
2406 | - if ( ! current_user_can( 'edit_post', $id ) ) |
|
2407 | - wp_send_json_error(); |
|
2568 | + if ( ! current_user_can( 'edit_post', $id ) ) { |
|
2569 | + wp_send_json_error(); |
|
2570 | + } |
|
2408 | 2571 | |
2409 | 2572 | $changes = $_REQUEST['changes']; |
2410 | 2573 | $post = get_post( $id, ARRAY_A ); |
2411 | 2574 | |
2412 | - if ( 'attachment' != $post['post_type'] ) |
|
2413 | - wp_send_json_error(); |
|
2575 | + if ( 'attachment' != $post['post_type'] ) { |
|
2576 | + wp_send_json_error(); |
|
2577 | + } |
|
2414 | 2578 | |
2415 | - if ( isset( $changes['parent'] ) ) |
|
2416 | - $post['post_parent'] = $changes['parent']; |
|
2579 | + if ( isset( $changes['parent'] ) ) { |
|
2580 | + $post['post_parent'] = $changes['parent']; |
|
2581 | + } |
|
2417 | 2582 | |
2418 | - if ( isset( $changes['title'] ) ) |
|
2419 | - $post['post_title'] = $changes['title']; |
|
2583 | + if ( isset( $changes['title'] ) ) { |
|
2584 | + $post['post_title'] = $changes['title']; |
|
2585 | + } |
|
2420 | 2586 | |
2421 | - if ( isset( $changes['caption'] ) ) |
|
2422 | - $post['post_excerpt'] = $changes['caption']; |
|
2587 | + if ( isset( $changes['caption'] ) ) { |
|
2588 | + $post['post_excerpt'] = $changes['caption']; |
|
2589 | + } |
|
2423 | 2590 | |
2424 | - if ( isset( $changes['description'] ) ) |
|
2425 | - $post['post_content'] = $changes['description']; |
|
2591 | + if ( isset( $changes['description'] ) ) { |
|
2592 | + $post['post_content'] = $changes['description']; |
|
2593 | + } |
|
2426 | 2594 | |
2427 | - if ( MEDIA_TRASH && isset( $changes['status'] ) ) |
|
2428 | - $post['post_status'] = $changes['status']; |
|
2595 | + if ( MEDIA_TRASH && isset( $changes['status'] ) ) { |
|
2596 | + $post['post_status'] = $changes['status']; |
|
2597 | + } |
|
2429 | 2598 | |
2430 | 2599 | if ( isset( $changes['alt'] ) ) { |
2431 | 2600 | $alt = wp_unslash( $changes['alt'] ); |
@@ -2469,25 +2638,30 @@ discard block |
||
2469 | 2638 | * @since 3.5.0 |
2470 | 2639 | */ |
2471 | 2640 | function wp_ajax_save_attachment_compat() { |
2472 | - if ( ! isset( $_REQUEST['id'] ) ) |
|
2473 | - wp_send_json_error(); |
|
2641 | + if ( ! isset( $_REQUEST['id'] ) ) { |
|
2642 | + wp_send_json_error(); |
|
2643 | + } |
|
2474 | 2644 | |
2475 | - if ( ! $id = absint( $_REQUEST['id'] ) ) |
|
2476 | - wp_send_json_error(); |
|
2645 | + if ( ! $id = absint( $_REQUEST['id'] ) ) { |
|
2646 | + wp_send_json_error(); |
|
2647 | + } |
|
2477 | 2648 | |
2478 | - if ( empty( $_REQUEST['attachments'] ) || empty( $_REQUEST['attachments'][ $id ] ) ) |
|
2479 | - wp_send_json_error(); |
|
2649 | + if ( empty( $_REQUEST['attachments'] ) || empty( $_REQUEST['attachments'][ $id ] ) ) { |
|
2650 | + wp_send_json_error(); |
|
2651 | + } |
|
2480 | 2652 | $attachment_data = $_REQUEST['attachments'][ $id ]; |
2481 | 2653 | |
2482 | 2654 | check_ajax_referer( 'update-post_' . $id, 'nonce' ); |
2483 | 2655 | |
2484 | - if ( ! current_user_can( 'edit_post', $id ) ) |
|
2485 | - wp_send_json_error(); |
|
2656 | + if ( ! current_user_can( 'edit_post', $id ) ) { |
|
2657 | + wp_send_json_error(); |
|
2658 | + } |
|
2486 | 2659 | |
2487 | 2660 | $post = get_post( $id, ARRAY_A ); |
2488 | 2661 | |
2489 | - if ( 'attachment' != $post['post_type'] ) |
|
2490 | - wp_send_json_error(); |
|
2662 | + if ( 'attachment' != $post['post_type'] ) { |
|
2663 | + wp_send_json_error(); |
|
2664 | + } |
|
2491 | 2665 | |
2492 | 2666 | /** This filter is documented in wp-admin/includes/media.php */ |
2493 | 2667 | $post = apply_filters( 'attachment_fields_to_save', $post, $attachment_data ); |
@@ -2500,12 +2674,14 @@ discard block |
||
2500 | 2674 | wp_update_post( $post ); |
2501 | 2675 | |
2502 | 2676 | foreach ( get_attachment_taxonomies( $post ) as $taxonomy ) { |
2503 | - if ( isset( $attachment_data[ $taxonomy ] ) ) |
|
2504 | - wp_set_object_terms( $id, array_map( 'trim', preg_split( '/,+/', $attachment_data[ $taxonomy ] ) ), $taxonomy, false ); |
|
2677 | + if ( isset( $attachment_data[ $taxonomy ] ) ) { |
|
2678 | + wp_set_object_terms( $id, array_map( 'trim', preg_split( '/,+/', $attachment_data[ $taxonomy ] ) ), $taxonomy, false ); |
|
2679 | + } |
|
2505 | 2680 | } |
2506 | 2681 | |
2507 | - if ( ! $attachment = wp_prepare_attachment_for_js( $id ) ) |
|
2508 | - wp_send_json_error(); |
|
2682 | + if ( ! $attachment = wp_prepare_attachment_for_js( $id ) ) { |
|
2683 | + wp_send_json_error(); |
|
2684 | + } |
|
2509 | 2685 | |
2510 | 2686 | wp_send_json_success( $attachment ); |
2511 | 2687 | } |
@@ -2516,29 +2692,36 @@ discard block |
||
2516 | 2692 | * @since 3.5.0 |
2517 | 2693 | */ |
2518 | 2694 | function wp_ajax_save_attachment_order() { |
2519 | - if ( ! isset( $_REQUEST['post_id'] ) ) |
|
2520 | - wp_send_json_error(); |
|
2695 | + if ( ! isset( $_REQUEST['post_id'] ) ) { |
|
2696 | + wp_send_json_error(); |
|
2697 | + } |
|
2521 | 2698 | |
2522 | - if ( ! $post_id = absint( $_REQUEST['post_id'] ) ) |
|
2523 | - wp_send_json_error(); |
|
2699 | + if ( ! $post_id = absint( $_REQUEST['post_id'] ) ) { |
|
2700 | + wp_send_json_error(); |
|
2701 | + } |
|
2524 | 2702 | |
2525 | - if ( empty( $_REQUEST['attachments'] ) ) |
|
2526 | - wp_send_json_error(); |
|
2703 | + if ( empty( $_REQUEST['attachments'] ) ) { |
|
2704 | + wp_send_json_error(); |
|
2705 | + } |
|
2527 | 2706 | |
2528 | 2707 | check_ajax_referer( 'update-post_' . $post_id, 'nonce' ); |
2529 | 2708 | |
2530 | 2709 | $attachments = $_REQUEST['attachments']; |
2531 | 2710 | |
2532 | - if ( ! current_user_can( 'edit_post', $post_id ) ) |
|
2533 | - wp_send_json_error(); |
|
2711 | + if ( ! current_user_can( 'edit_post', $post_id ) ) { |
|
2712 | + wp_send_json_error(); |
|
2713 | + } |
|
2534 | 2714 | |
2535 | 2715 | foreach ( $attachments as $attachment_id => $menu_order ) { |
2536 | - if ( ! current_user_can( 'edit_post', $attachment_id ) ) |
|
2537 | - continue; |
|
2538 | - if ( ! $attachment = get_post( $attachment_id ) ) |
|
2539 | - continue; |
|
2540 | - if ( 'attachment' != $attachment->post_type ) |
|
2541 | - continue; |
|
2716 | + if ( ! current_user_can( 'edit_post', $attachment_id ) ) { |
|
2717 | + continue; |
|
2718 | + } |
|
2719 | + if ( ! $attachment = get_post( $attachment_id ) ) { |
|
2720 | + continue; |
|
2721 | + } |
|
2722 | + if ( 'attachment' != $attachment->post_type ) { |
|
2723 | + continue; |
|
2724 | + } |
|
2542 | 2725 | |
2543 | 2726 | wp_update_post( array( 'ID' => $attachment_id, 'menu_order' => $menu_order ) ); |
2544 | 2727 | } |
@@ -2562,11 +2745,13 @@ discard block |
||
2562 | 2745 | |
2563 | 2746 | $id = intval( $attachment['id'] ); |
2564 | 2747 | |
2565 | - if ( ! $post = get_post( $id ) ) |
|
2566 | - wp_send_json_error(); |
|
2748 | + if ( ! $post = get_post( $id ) ) { |
|
2749 | + wp_send_json_error(); |
|
2750 | + } |
|
2567 | 2751 | |
2568 | - if ( 'attachment' != $post->post_type ) |
|
2569 | - wp_send_json_error(); |
|
2752 | + if ( 'attachment' != $post->post_type ) { |
|
2753 | + wp_send_json_error(); |
|
2754 | + } |
|
2570 | 2755 | |
2571 | 2756 | if ( current_user_can( 'edit_post', $id ) ) { |
2572 | 2757 | // If this attachment is unattached, attach it. Primarily a back compat thing. |
@@ -2631,17 +2816,21 @@ discard block |
||
2631 | 2816 | |
2632 | 2817 | check_ajax_referer( 'media-send-to-editor', 'nonce' ); |
2633 | 2818 | |
2634 | - if ( ! $src = wp_unslash( $_POST['src'] ) ) |
|
2635 | - wp_send_json_error(); |
|
2819 | + if ( ! $src = wp_unslash( $_POST['src'] ) ) { |
|
2820 | + wp_send_json_error(); |
|
2821 | + } |
|
2636 | 2822 | |
2637 | - if ( ! strpos( $src, '://' ) ) |
|
2638 | - $src = 'http://' . $src; |
|
2823 | + if ( ! strpos( $src, '://' ) ) { |
|
2824 | + $src = 'http://' . $src; |
|
2825 | + } |
|
2639 | 2826 | |
2640 | - if ( ! $src = esc_url_raw( $src ) ) |
|
2641 | - wp_send_json_error(); |
|
2827 | + if ( ! $src = esc_url_raw( $src ) ) { |
|
2828 | + wp_send_json_error(); |
|
2829 | + } |
|
2642 | 2830 | |
2643 | - if ( ! $link_text = trim( wp_unslash( $_POST['link_text'] ) ) ) |
|
2644 | - $link_text = wp_basename( $src ); |
|
2831 | + if ( ! $link_text = trim( wp_unslash( $_POST['link_text'] ) ) ) { |
|
2832 | + $link_text = wp_basename( $src ); |
|
2833 | + } |
|
2645 | 2834 | |
2646 | 2835 | $post = get_post( isset( $_POST['post_id'] ) ? $_POST['post_id'] : 0 ); |
2647 | 2836 | |
@@ -2663,8 +2852,9 @@ discard block |
||
2663 | 2852 | // Figure out what filter to run: |
2664 | 2853 | $type = 'file'; |
2665 | 2854 | if ( ( $ext = preg_replace( '/^.+?\.([^.]+)$/', '$1', $src ) ) && ( $ext_type = wp_ext2type( $ext ) ) |
2666 | - && ( 'audio' == $ext_type || 'video' == $ext_type ) ) |
|
2667 | - $type = $ext_type; |
|
2855 | + && ( 'audio' == $ext_type || 'video' == $ext_type ) ) { |
|
2856 | + $type = $ext_type; |
|
2857 | + } |
|
2668 | 2858 | |
2669 | 2859 | /** This filter is documented in wp-admin/includes/media.php */ |
2670 | 2860 | $html = apply_filters( $type . '_send_to_editor_url', $html, $src, $link_text ); |
@@ -2757,15 +2947,18 @@ discard block |
||
2757 | 2947 | function wp_ajax_get_revision_diffs() { |
2758 | 2948 | require ABSPATH . 'wp-admin/includes/revision.php'; |
2759 | 2949 | |
2760 | - if ( ! $post = get_post( (int) $_REQUEST['post_id'] ) ) |
|
2761 | - wp_send_json_error(); |
|
2950 | + if ( ! $post = get_post( (int) $_REQUEST['post_id'] ) ) { |
|
2951 | + wp_send_json_error(); |
|
2952 | + } |
|
2762 | 2953 | |
2763 | - if ( ! current_user_can( 'read_post', $post->ID ) ) |
|
2764 | - wp_send_json_error(); |
|
2954 | + if ( ! current_user_can( 'read_post', $post->ID ) ) { |
|
2955 | + wp_send_json_error(); |
|
2956 | + } |
|
2765 | 2957 | |
2766 | 2958 | // Really just pre-loading the cache here. |
2767 | - if ( ! $revisions = wp_get_post_revisions( $post->ID, array( 'check_enabled' => false ) ) ) |
|
2768 | - wp_send_json_error(); |
|
2959 | + if ( ! $revisions = wp_get_post_revisions( $post->ID, array( 'check_enabled' => false ) ) ) { |
|
2960 | + wp_send_json_error(); |
|
2961 | + } |
|
2769 | 2962 | |
2770 | 2963 | $return = array(); |
2771 | 2964 | @set_time_limit( 0 ); |
@@ -1,11 +1,11 @@ |
||
1 | 1 | <?php |
2 | 2 | /** |
3 | - * WordPress Credits Administration API. |
|
4 | - * |
|
5 | - * @package WordPress |
|
6 | - * @subpackage Administration |
|
7 | - * @since 4.4.0 |
|
8 | - */ |
|
3 | + * WordPress Credits Administration API. |
|
4 | + * |
|
5 | + * @package WordPress |
|
6 | + * @subpackage Administration |
|
7 | + * @since 4.4.0 |
|
8 | + */ |
|
9 | 9 | |
10 | 10 | /** |
11 | 11 | * Retrieve the contributor credits. |
@@ -20,23 +20,23 @@ discard block |
||
20 | 20 | global $wp_version; |
21 | 21 | $locale = get_locale(); |
22 | 22 | |
23 | - $results = get_site_transient( 'wordpress_credits_' . $locale ); |
|
23 | + $results = get_site_transient('wordpress_credits_'.$locale); |
|
24 | 24 | |
25 | - if ( ! is_array( $results ) |
|
26 | - || false !== strpos( $wp_version, '-' ) |
|
27 | - || ( isset( $results['data']['version'] ) && strpos( $wp_version, $results['data']['version'] ) !== 0 ) |
|
25 | + if ( ! is_array($results) |
|
26 | + || false !== strpos($wp_version, '-') |
|
27 | + || (isset($results['data']['version']) && strpos($wp_version, $results['data']['version']) !== 0) |
|
28 | 28 | ) { |
29 | - $response = wp_remote_get( "http://api.wordpress.org/core/credits/1.1/?version=$wp_version&locale=$locale" ); |
|
29 | + $response = wp_remote_get("http://api.wordpress.org/core/credits/1.1/?version=$wp_version&locale=$locale"); |
|
30 | 30 | |
31 | - if ( is_wp_error( $response ) || 200 != wp_remote_retrieve_response_code( $response ) ) |
|
31 | + if (is_wp_error($response) || 200 != wp_remote_retrieve_response_code($response)) |
|
32 | 32 | return false; |
33 | 33 | |
34 | - $results = json_decode( wp_remote_retrieve_body( $response ), true ); |
|
34 | + $results = json_decode(wp_remote_retrieve_body($response), true); |
|
35 | 35 | |
36 | - if ( ! is_array( $results ) ) |
|
36 | + if ( ! is_array($results)) |
|
37 | 37 | return false; |
38 | 38 | |
39 | - set_site_transient( 'wordpress_credits_' . $locale, $results, DAY_IN_SECONDS ); |
|
39 | + set_site_transient('wordpress_credits_'.$locale, $results, DAY_IN_SECONDS); |
|
40 | 40 | } |
41 | 41 | |
42 | 42 | return $results; |
@@ -52,8 +52,8 @@ discard block |
||
52 | 52 | * @param string $username The contributor's username. |
53 | 53 | * @param string $profiles URL to the contributor's WordPress.org profile page. |
54 | 54 | */ |
55 | -function _wp_credits_add_profile_link( &$display_name, $username, $profiles ) { |
|
56 | - $display_name = '<a href="' . esc_url( sprintf( $profiles, $username ) ) . '">' . esc_html( $display_name ) . '</a>'; |
|
55 | +function _wp_credits_add_profile_link(&$display_name, $username, $profiles) { |
|
56 | + $display_name = '<a href="'.esc_url(sprintf($profiles, $username)).'">'.esc_html($display_name).'</a>'; |
|
57 | 57 | } |
58 | 58 | |
59 | 59 | /** |
@@ -64,6 +64,6 @@ discard block |
||
64 | 64 | * |
65 | 65 | * @param string $data External library data, passed by reference. |
66 | 66 | */ |
67 | -function _wp_credits_build_object_link( &$data ) { |
|
68 | - $data = '<a href="' . esc_url( $data[1] ) . '">' . esc_html( $data[0] ) . '</a>'; |
|
67 | +function _wp_credits_build_object_link(&$data) { |
|
68 | + $data = '<a href="'.esc_url($data[1]).'">'.esc_html($data[0]).'</a>'; |
|
69 | 69 | } |
@@ -28,13 +28,15 @@ |
||
28 | 28 | ) { |
29 | 29 | $response = wp_remote_get( "http://api.wordpress.org/core/credits/1.1/?version=$wp_version&locale=$locale" ); |
30 | 30 | |
31 | - if ( is_wp_error( $response ) || 200 != wp_remote_retrieve_response_code( $response ) ) |
|
32 | - return false; |
|
31 | + if ( is_wp_error( $response ) || 200 != wp_remote_retrieve_response_code( $response ) ) { |
|
32 | + return false; |
|
33 | + } |
|
33 | 34 | |
34 | 35 | $results = json_decode( wp_remote_retrieve_body( $response ), true ); |
35 | 36 | |
36 | - if ( ! is_array( $results ) ) |
|
37 | - return false; |
|
37 | + if ( ! is_array( $results ) ) { |
|
38 | + return false; |
|
39 | + } |
|
38 | 40 | |
39 | 41 | set_site_transient( 'wordpress_credits_' . $locale, $results, DAY_IN_SECONDS ); |
40 | 42 | } |
@@ -1,10 +1,10 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | /** |
3 | - * WordPress user administration API. |
|
4 | - * |
|
5 | - * @package WordPress |
|
6 | - * @subpackage Administration |
|
7 | - */ |
|
3 | + * WordPress user administration API. |
|
4 | + * |
|
5 | + * @package WordPress |
|
6 | + * @subpackage Administration |
|
7 | + */ |
|
8 | 8 | |
9 | 9 | /** |
10 | 10 | * Creates a new user from the "Users" form using $_POST information. |
@@ -179,14 +179,14 @@ discard block |
||
179 | 179 | $notify = isset( $_POST['send_user_notification'] ) ? 'both' : 'admin'; |
180 | 180 | |
181 | 181 | /** |
182 | - * Fires after a new user has been created. |
|
183 | - * |
|
184 | - * @since 4.4.0 |
|
185 | - * |
|
186 | - * @param int $user_id ID of the newly created user. |
|
187 | - * @param string $notify Type of notification that should happen. See {@see wp_send_new_user_notifications()} |
|
188 | - * for more information on possible values. |
|
189 | - */ |
|
182 | + * Fires after a new user has been created. |
|
183 | + * |
|
184 | + * @since 4.4.0 |
|
185 | + * |
|
186 | + * @param int $user_id ID of the newly created user. |
|
187 | + * @param string $notify Type of notification that should happen. See {@see wp_send_new_user_notifications()} |
|
188 | + * for more information on possible values. |
|
189 | + */ |
|
190 | 190 | do_action( 'edit_user_created_user', $user_id, $notify ); |
191 | 191 | } |
192 | 192 | return $user_id; |
@@ -27,90 +27,90 @@ discard block |
||
27 | 27 | * @param int $user_id Optional. User ID. |
28 | 28 | * @return int|WP_Error user id of the updated user |
29 | 29 | */ |
30 | -function edit_user( $user_id = 0 ) { |
|
30 | +function edit_user($user_id = 0) { |
|
31 | 31 | $wp_roles = wp_roles(); |
32 | 32 | $user = new stdClass; |
33 | - if ( $user_id ) { |
|
33 | + if ($user_id) { |
|
34 | 34 | $update = true; |
35 | 35 | $user->ID = (int) $user_id; |
36 | - $userdata = get_userdata( $user_id ); |
|
37 | - $user->user_login = wp_slash( $userdata->user_login ); |
|
36 | + $userdata = get_userdata($user_id); |
|
37 | + $user->user_login = wp_slash($userdata->user_login); |
|
38 | 38 | } else { |
39 | 39 | $update = false; |
40 | 40 | } |
41 | 41 | |
42 | - if ( !$update && isset( $_POST['user_login'] ) ) |
|
42 | + if ( ! $update && isset($_POST['user_login'])) |
|
43 | 43 | $user->user_login = sanitize_user($_POST['user_login'], true); |
44 | 44 | |
45 | 45 | $pass1 = $pass2 = ''; |
46 | - if ( isset( $_POST['pass1'] ) ) |
|
46 | + if (isset($_POST['pass1'])) |
|
47 | 47 | $pass1 = $_POST['pass1']; |
48 | - if ( isset( $_POST['pass2'] ) ) |
|
48 | + if (isset($_POST['pass2'])) |
|
49 | 49 | $pass2 = $_POST['pass2']; |
50 | 50 | |
51 | - if ( isset( $_POST['role'] ) && current_user_can( 'edit_users' ) ) { |
|
52 | - $new_role = sanitize_text_field( $_POST['role'] ); |
|
51 | + if (isset($_POST['role']) && current_user_can('edit_users')) { |
|
52 | + $new_role = sanitize_text_field($_POST['role']); |
|
53 | 53 | $potential_role = isset($wp_roles->role_objects[$new_role]) ? $wp_roles->role_objects[$new_role] : false; |
54 | 54 | // Don't let anyone with 'edit_users' (admins) edit their own role to something without it. |
55 | 55 | // Multisite super admins can freely edit their blog roles -- they possess all caps. |
56 | - if ( ( is_multisite() && current_user_can( 'manage_sites' ) ) || $user_id != get_current_user_id() || ($potential_role && $potential_role->has_cap( 'edit_users' ) ) ) |
|
56 | + if ((is_multisite() && current_user_can('manage_sites')) || $user_id != get_current_user_id() || ($potential_role && $potential_role->has_cap('edit_users'))) |
|
57 | 57 | $user->role = $new_role; |
58 | 58 | |
59 | 59 | // If the new role isn't editable by the logged-in user die with error |
60 | 60 | $editable_roles = get_editable_roles(); |
61 | - if ( ! empty( $new_role ) && empty( $editable_roles[$new_role] ) ) |
|
61 | + if ( ! empty($new_role) && empty($editable_roles[$new_role])) |
|
62 | 62 | wp_die(__('You can’t give users that role.')); |
63 | 63 | } |
64 | 64 | |
65 | - if ( isset( $_POST['email'] )) |
|
66 | - $user->user_email = sanitize_text_field( wp_unslash( $_POST['email'] ) ); |
|
67 | - if ( isset( $_POST['url'] ) ) { |
|
68 | - if ( empty ( $_POST['url'] ) || $_POST['url'] == 'http://' ) { |
|
65 | + if (isset($_POST['email'])) |
|
66 | + $user->user_email = sanitize_text_field(wp_unslash($_POST['email'])); |
|
67 | + if (isset($_POST['url'])) { |
|
68 | + if (empty ($_POST['url']) || $_POST['url'] == 'http://') { |
|
69 | 69 | $user->user_url = ''; |
70 | 70 | } else { |
71 | - $user->user_url = esc_url_raw( $_POST['url'] ); |
|
72 | - $protocols = implode( '|', array_map( 'preg_quote', wp_allowed_protocols() ) ); |
|
73 | - $user->user_url = preg_match('/^(' . $protocols . '):/is', $user->user_url) ? $user->user_url : 'http://'.$user->user_url; |
|
71 | + $user->user_url = esc_url_raw($_POST['url']); |
|
72 | + $protocols = implode('|', array_map('preg_quote', wp_allowed_protocols())); |
|
73 | + $user->user_url = preg_match('/^('.$protocols.'):/is', $user->user_url) ? $user->user_url : 'http://'.$user->user_url; |
|
74 | 74 | } |
75 | 75 | } |
76 | - if ( isset( $_POST['first_name'] ) ) |
|
77 | - $user->first_name = sanitize_text_field( $_POST['first_name'] ); |
|
78 | - if ( isset( $_POST['last_name'] ) ) |
|
79 | - $user->last_name = sanitize_text_field( $_POST['last_name'] ); |
|
80 | - if ( isset( $_POST['nickname'] ) ) |
|
81 | - $user->nickname = sanitize_text_field( $_POST['nickname'] ); |
|
82 | - if ( isset( $_POST['display_name'] ) ) |
|
83 | - $user->display_name = sanitize_text_field( $_POST['display_name'] ); |
|
84 | - |
|
85 | - if ( isset( $_POST['description'] ) ) |
|
86 | - $user->description = trim( $_POST['description'] ); |
|
87 | - |
|
88 | - foreach ( wp_get_user_contact_methods( $user ) as $method => $name ) { |
|
89 | - if ( isset( $_POST[$method] )) |
|
90 | - $user->$method = sanitize_text_field( $_POST[$method] ); |
|
76 | + if (isset($_POST['first_name'])) |
|
77 | + $user->first_name = sanitize_text_field($_POST['first_name']); |
|
78 | + if (isset($_POST['last_name'])) |
|
79 | + $user->last_name = sanitize_text_field($_POST['last_name']); |
|
80 | + if (isset($_POST['nickname'])) |
|
81 | + $user->nickname = sanitize_text_field($_POST['nickname']); |
|
82 | + if (isset($_POST['display_name'])) |
|
83 | + $user->display_name = sanitize_text_field($_POST['display_name']); |
|
84 | + |
|
85 | + if (isset($_POST['description'])) |
|
86 | + $user->description = trim($_POST['description']); |
|
87 | + |
|
88 | + foreach (wp_get_user_contact_methods($user) as $method => $name) { |
|
89 | + if (isset($_POST[$method])) |
|
90 | + $user->$method = sanitize_text_field($_POST[$method]); |
|
91 | 91 | } |
92 | 92 | |
93 | - if ( $update ) { |
|
94 | - $user->rich_editing = isset( $_POST['rich_editing'] ) && 'false' == $_POST['rich_editing'] ? 'false' : 'true'; |
|
95 | - $user->admin_color = isset( $_POST['admin_color'] ) ? sanitize_text_field( $_POST['admin_color'] ) : 'fresh'; |
|
96 | - $user->show_admin_bar_front = isset( $_POST['admin_bar_front'] ) ? 'true' : 'false'; |
|
93 | + if ($update) { |
|
94 | + $user->rich_editing = isset($_POST['rich_editing']) && 'false' == $_POST['rich_editing'] ? 'false' : 'true'; |
|
95 | + $user->admin_color = isset($_POST['admin_color']) ? sanitize_text_field($_POST['admin_color']) : 'fresh'; |
|
96 | + $user->show_admin_bar_front = isset($_POST['admin_bar_front']) ? 'true' : 'false'; |
|
97 | 97 | } |
98 | 98 | |
99 | - $user->comment_shortcuts = isset( $_POST['comment_shortcuts'] ) && 'true' == $_POST['comment_shortcuts'] ? 'true' : ''; |
|
99 | + $user->comment_shortcuts = isset($_POST['comment_shortcuts']) && 'true' == $_POST['comment_shortcuts'] ? 'true' : ''; |
|
100 | 100 | |
101 | 101 | $user->use_ssl = 0; |
102 | - if ( !empty($_POST['use_ssl']) ) |
|
102 | + if ( ! empty($_POST['use_ssl'])) |
|
103 | 103 | $user->use_ssl = 1; |
104 | 104 | |
105 | 105 | $errors = new WP_Error(); |
106 | 106 | |
107 | 107 | /* checking that username has been typed */ |
108 | - if ( $user->user_login == '' ) |
|
109 | - $errors->add( 'user_login', __( '<strong>ERROR</strong>: Please enter a username.' ) ); |
|
108 | + if ($user->user_login == '') |
|
109 | + $errors->add('user_login', __('<strong>ERROR</strong>: Please enter a username.')); |
|
110 | 110 | |
111 | 111 | /* checking that nickname has been typed */ |
112 | - if ( $update && empty( $user->nickname ) ) { |
|
113 | - $errors->add( 'nickname', __( '<strong>ERROR</strong>: Please enter a nickname.' ) ); |
|
112 | + if ($update && empty($user->nickname)) { |
|
113 | + $errors->add('nickname', __('<strong>ERROR</strong>: Please enter a nickname.')); |
|
114 | 114 | } |
115 | 115 | |
116 | 116 | /* checking the password has been typed twice */ |
@@ -123,39 +123,39 @@ discard block |
||
123 | 123 | * @param string &$pass1 The password, passed by reference. |
124 | 124 | * @param string &$pass2 The confirmed password, passed by reference. |
125 | 125 | */ |
126 | - do_action_ref_array( 'check_passwords', array( $user->user_login, &$pass1, &$pass2 ) ); |
|
126 | + do_action_ref_array('check_passwords', array($user->user_login, &$pass1, &$pass2)); |
|
127 | 127 | |
128 | 128 | /* Check for "\" in password */ |
129 | - if ( false !== strpos( wp_unslash( $pass1 ), "\\" ) ) |
|
130 | - $errors->add( 'pass', __( '<strong>ERROR</strong>: Passwords may not contain the character "\\".' ), array( 'form-field' => 'pass1' ) ); |
|
129 | + if (false !== strpos(wp_unslash($pass1), "\\")) |
|
130 | + $errors->add('pass', __('<strong>ERROR</strong>: Passwords may not contain the character "\\".'), array('form-field' => 'pass1')); |
|
131 | 131 | |
132 | 132 | /* checking the password has been typed twice the same */ |
133 | - if ( $pass1 != $pass2 ) |
|
134 | - $errors->add( 'pass', __( '<strong>ERROR</strong>: Please enter the same password in both password fields.' ), array( 'form-field' => 'pass1' ) ); |
|
133 | + if ($pass1 != $pass2) |
|
134 | + $errors->add('pass', __('<strong>ERROR</strong>: Please enter the same password in both password fields.'), array('form-field' => 'pass1')); |
|
135 | 135 | |
136 | - if ( !empty( $pass1 ) ) |
|
136 | + if ( ! empty($pass1)) |
|
137 | 137 | $user->user_pass = $pass1; |
138 | 138 | |
139 | - if ( !$update && isset( $_POST['user_login'] ) && !validate_username( $_POST['user_login'] ) ) |
|
140 | - $errors->add( 'user_login', __( '<strong>ERROR</strong>: This username is invalid because it uses illegal characters. Please enter a valid username.' )); |
|
139 | + if ( ! $update && isset($_POST['user_login']) && ! validate_username($_POST['user_login'])) |
|
140 | + $errors->add('user_login', __('<strong>ERROR</strong>: This username is invalid because it uses illegal characters. Please enter a valid username.')); |
|
141 | 141 | |
142 | - if ( !$update && username_exists( $user->user_login ) ) |
|
143 | - $errors->add( 'user_login', __( '<strong>ERROR</strong>: This username is already registered. Please choose another one.' )); |
|
142 | + if ( ! $update && username_exists($user->user_login)) |
|
143 | + $errors->add('user_login', __('<strong>ERROR</strong>: This username is already registered. Please choose another one.')); |
|
144 | 144 | |
145 | 145 | /** This filter is documented in wp-includes/user.php */ |
146 | - $illegal_logins = (array) apply_filters( 'illegal_user_logins', array() ); |
|
146 | + $illegal_logins = (array) apply_filters('illegal_user_logins', array()); |
|
147 | 147 | |
148 | - if ( in_array( strtolower( $user->user_login ), array_map( 'strtolower', $illegal_logins ) ) ) { |
|
149 | - $errors->add( 'invalid_username', __( '<strong>ERROR</strong>: Sorry, that username is not allowed.' ) ); |
|
148 | + if (in_array(strtolower($user->user_login), array_map('strtolower', $illegal_logins))) { |
|
149 | + $errors->add('invalid_username', __('<strong>ERROR</strong>: Sorry, that username is not allowed.')); |
|
150 | 150 | } |
151 | 151 | |
152 | 152 | /* checking email address */ |
153 | - if ( empty( $user->user_email ) ) { |
|
154 | - $errors->add( 'empty_email', __( '<strong>ERROR</strong>: Please enter an email address.' ), array( 'form-field' => 'email' ) ); |
|
155 | - } elseif ( !is_email( $user->user_email ) ) { |
|
156 | - $errors->add( 'invalid_email', __( '<strong>ERROR</strong>: The email address isn’t correct.' ), array( 'form-field' => 'email' ) ); |
|
157 | - } elseif ( ( $owner_id = email_exists($user->user_email) ) && ( !$update || ( $owner_id != $user->ID ) ) ) { |
|
158 | - $errors->add( 'email_exists', __('<strong>ERROR</strong>: This email is already registered, please choose another one.'), array( 'form-field' => 'email' ) ); |
|
153 | + if (empty($user->user_email)) { |
|
154 | + $errors->add('empty_email', __('<strong>ERROR</strong>: Please enter an email address.'), array('form-field' => 'email')); |
|
155 | + } elseif ( ! is_email($user->user_email)) { |
|
156 | + $errors->add('invalid_email', __('<strong>ERROR</strong>: The email address isn’t correct.'), array('form-field' => 'email')); |
|
157 | + } elseif (($owner_id = email_exists($user->user_email)) && ( ! $update || ($owner_id != $user->ID))) { |
|
158 | + $errors->add('email_exists', __('<strong>ERROR</strong>: This email is already registered, please choose another one.'), array('form-field' => 'email')); |
|
159 | 159 | } |
160 | 160 | |
161 | 161 | /** |
@@ -167,16 +167,16 @@ discard block |
||
167 | 167 | * @param bool $update Whether this is a user update. |
168 | 168 | * @param WP_User &$user WP_User object, passed by reference. |
169 | 169 | */ |
170 | - do_action_ref_array( 'user_profile_update_errors', array( &$errors, $update, &$user ) ); |
|
170 | + do_action_ref_array('user_profile_update_errors', array(&$errors, $update, &$user)); |
|
171 | 171 | |
172 | - if ( $errors->get_error_codes() ) |
|
172 | + if ($errors->get_error_codes()) |
|
173 | 173 | return $errors; |
174 | 174 | |
175 | - if ( $update ) { |
|
176 | - $user_id = wp_update_user( $user ); |
|
175 | + if ($update) { |
|
176 | + $user_id = wp_update_user($user); |
|
177 | 177 | } else { |
178 | - $user_id = wp_insert_user( $user ); |
|
179 | - $notify = isset( $_POST['send_user_notification'] ) ? 'both' : 'admin'; |
|
178 | + $user_id = wp_insert_user($user); |
|
179 | + $notify = isset($_POST['send_user_notification']) ? 'both' : 'admin'; |
|
180 | 180 | |
181 | 181 | /** |
182 | 182 | * Fires after a new user has been created. |
@@ -187,7 +187,7 @@ discard block |
||
187 | 187 | * @param string $notify Type of notification that should happen. See {@see wp_send_new_user_notifications()} |
188 | 188 | * for more information on possible values. |
189 | 189 | */ |
190 | - do_action( 'edit_user_created_user', $user_id, $notify ); |
|
190 | + do_action('edit_user_created_user', $user_id, $notify); |
|
191 | 191 | } |
192 | 192 | return $user_id; |
193 | 193 | } |
@@ -218,7 +218,7 @@ discard block |
||
218 | 218 | * |
219 | 219 | * @param array $all_roles List of roles. |
220 | 220 | */ |
221 | - $editable_roles = apply_filters( 'editable_roles', $all_roles ); |
|
221 | + $editable_roles = apply_filters('editable_roles', $all_roles); |
|
222 | 222 | |
223 | 223 | return $editable_roles; |
224 | 224 | } |
@@ -231,10 +231,10 @@ discard block |
||
231 | 231 | * @param int $user_id User ID. |
232 | 232 | * @return WP_User|bool WP_User object on success, false on failure. |
233 | 233 | */ |
234 | -function get_user_to_edit( $user_id ) { |
|
235 | - $user = get_userdata( $user_id ); |
|
234 | +function get_user_to_edit($user_id) { |
|
235 | + $user = get_userdata($user_id); |
|
236 | 236 | |
237 | - if ( $user ) |
|
237 | + if ($user) |
|
238 | 238 | $user->filter = 'edit'; |
239 | 239 | |
240 | 240 | return $user; |
@@ -250,7 +250,7 @@ discard block |
||
250 | 250 | * @param int $user_id User ID. |
251 | 251 | * @return array |
252 | 252 | */ |
253 | -function get_users_drafts( $user_id ) { |
|
253 | +function get_users_drafts($user_id) { |
|
254 | 254 | global $wpdb; |
255 | 255 | $query = $wpdb->prepare("SELECT ID, post_title FROM $wpdb->posts WHERE post_type = 'post' AND post_status = 'draft' AND post_author = %d ORDER BY post_modified DESC", $user_id); |
256 | 256 | |
@@ -261,8 +261,8 @@ discard block |
||
261 | 261 | * |
262 | 262 | * @param string $query The user's drafts query string. |
263 | 263 | */ |
264 | - $query = apply_filters( 'get_users_drafts', $query ); |
|
265 | - return $wpdb->get_results( $query ); |
|
264 | + $query = apply_filters('get_users_drafts', $query); |
|
265 | + return $wpdb->get_results($query); |
|
266 | 266 | } |
267 | 267 | |
268 | 268 | /** |
@@ -281,23 +281,23 @@ discard block |
||
281 | 281 | * @param int $reassign Optional. Reassign posts and links to new User ID. |
282 | 282 | * @return bool True when finished. |
283 | 283 | */ |
284 | -function wp_delete_user( $id, $reassign = null ) { |
|
284 | +function wp_delete_user($id, $reassign = null) { |
|
285 | 285 | global $wpdb; |
286 | 286 | |
287 | - if ( ! is_numeric( $id ) ) { |
|
287 | + if ( ! is_numeric($id)) { |
|
288 | 288 | return false; |
289 | 289 | } |
290 | 290 | |
291 | 291 | $id = (int) $id; |
292 | - $user = new WP_User( $id ); |
|
292 | + $user = new WP_User($id); |
|
293 | 293 | |
294 | - if ( !$user->exists() ) |
|
294 | + if ( ! $user->exists()) |
|
295 | 295 | return false; |
296 | 296 | |
297 | 297 | // Normalize $reassign to null or a user ID. 'novalue' was an older default. |
298 | - if ( 'novalue' === $reassign ) { |
|
298 | + if ('novalue' === $reassign) { |
|
299 | 299 | $reassign = null; |
300 | - } elseif ( null !== $reassign ) { |
|
300 | + } elseif (null !== $reassign) { |
|
301 | 301 | $reassign = (int) $reassign; |
302 | 302 | } |
303 | 303 | |
@@ -310,14 +310,14 @@ discard block |
||
310 | 310 | * @param int|null $reassign ID of the user to reassign posts and links to. |
311 | 311 | * Default null, for no reassignment. |
312 | 312 | */ |
313 | - do_action( 'delete_user', $id, $reassign ); |
|
313 | + do_action('delete_user', $id, $reassign); |
|
314 | 314 | |
315 | - if ( null === $reassign ) { |
|
315 | + if (null === $reassign) { |
|
316 | 316 | $post_types_to_delete = array(); |
317 | - foreach ( get_post_types( array(), 'objects' ) as $post_type ) { |
|
318 | - if ( $post_type->delete_with_user ) { |
|
317 | + foreach (get_post_types(array(), 'objects') as $post_type) { |
|
318 | + if ($post_type->delete_with_user) { |
|
319 | 319 | $post_types_to_delete[] = $post_type->name; |
320 | - } elseif ( null === $post_type->delete_with_user && post_type_supports( $post_type->name, 'author' ) ) { |
|
320 | + } elseif (null === $post_type->delete_with_user && post_type_supports($post_type->name, 'author')) { |
|
321 | 321 | $post_types_to_delete[] = $post_type->name; |
322 | 322 | } |
323 | 323 | } |
@@ -330,48 +330,48 @@ discard block |
||
330 | 330 | * @param array $post_types_to_delete Post types to delete. |
331 | 331 | * @param int $id User ID. |
332 | 332 | */ |
333 | - $post_types_to_delete = apply_filters( 'post_types_to_delete_with_user', $post_types_to_delete, $id ); |
|
334 | - $post_types_to_delete = implode( "', '", $post_types_to_delete ); |
|
335 | - $post_ids = $wpdb->get_col( $wpdb->prepare( "SELECT ID FROM $wpdb->posts WHERE post_author = %d AND post_type IN ('$post_types_to_delete')", $id ) ); |
|
336 | - if ( $post_ids ) { |
|
337 | - foreach ( $post_ids as $post_id ) |
|
338 | - wp_delete_post( $post_id ); |
|
333 | + $post_types_to_delete = apply_filters('post_types_to_delete_with_user', $post_types_to_delete, $id); |
|
334 | + $post_types_to_delete = implode("', '", $post_types_to_delete); |
|
335 | + $post_ids = $wpdb->get_col($wpdb->prepare("SELECT ID FROM $wpdb->posts WHERE post_author = %d AND post_type IN ('$post_types_to_delete')", $id)); |
|
336 | + if ($post_ids) { |
|
337 | + foreach ($post_ids as $post_id) |
|
338 | + wp_delete_post($post_id); |
|
339 | 339 | } |
340 | 340 | |
341 | 341 | // Clean links |
342 | - $link_ids = $wpdb->get_col( $wpdb->prepare("SELECT link_id FROM $wpdb->links WHERE link_owner = %d", $id) ); |
|
342 | + $link_ids = $wpdb->get_col($wpdb->prepare("SELECT link_id FROM $wpdb->links WHERE link_owner = %d", $id)); |
|
343 | 343 | |
344 | - if ( $link_ids ) { |
|
345 | - foreach ( $link_ids as $link_id ) |
|
344 | + if ($link_ids) { |
|
345 | + foreach ($link_ids as $link_id) |
|
346 | 346 | wp_delete_link($link_id); |
347 | 347 | } |
348 | 348 | } else { |
349 | - $post_ids = $wpdb->get_col( $wpdb->prepare( "SELECT ID FROM $wpdb->posts WHERE post_author = %d", $id ) ); |
|
350 | - $wpdb->update( $wpdb->posts, array('post_author' => $reassign), array('post_author' => $id) ); |
|
351 | - if ( ! empty( $post_ids ) ) { |
|
352 | - foreach ( $post_ids as $post_id ) |
|
353 | - clean_post_cache( $post_id ); |
|
349 | + $post_ids = $wpdb->get_col($wpdb->prepare("SELECT ID FROM $wpdb->posts WHERE post_author = %d", $id)); |
|
350 | + $wpdb->update($wpdb->posts, array('post_author' => $reassign), array('post_author' => $id)); |
|
351 | + if ( ! empty($post_ids)) { |
|
352 | + foreach ($post_ids as $post_id) |
|
353 | + clean_post_cache($post_id); |
|
354 | 354 | } |
355 | - $link_ids = $wpdb->get_col( $wpdb->prepare("SELECT link_id FROM $wpdb->links WHERE link_owner = %d", $id) ); |
|
356 | - $wpdb->update( $wpdb->links, array('link_owner' => $reassign), array('link_owner' => $id) ); |
|
357 | - if ( ! empty( $link_ids ) ) { |
|
358 | - foreach ( $link_ids as $link_id ) |
|
359 | - clean_bookmark_cache( $link_id ); |
|
355 | + $link_ids = $wpdb->get_col($wpdb->prepare("SELECT link_id FROM $wpdb->links WHERE link_owner = %d", $id)); |
|
356 | + $wpdb->update($wpdb->links, array('link_owner' => $reassign), array('link_owner' => $id)); |
|
357 | + if ( ! empty($link_ids)) { |
|
358 | + foreach ($link_ids as $link_id) |
|
359 | + clean_bookmark_cache($link_id); |
|
360 | 360 | } |
361 | 361 | } |
362 | 362 | |
363 | 363 | // FINALLY, delete user |
364 | - if ( is_multisite() ) { |
|
365 | - remove_user_from_blog( $id, get_current_blog_id() ); |
|
364 | + if (is_multisite()) { |
|
365 | + remove_user_from_blog($id, get_current_blog_id()); |
|
366 | 366 | } else { |
367 | - $meta = $wpdb->get_col( $wpdb->prepare( "SELECT umeta_id FROM $wpdb->usermeta WHERE user_id = %d", $id ) ); |
|
368 | - foreach ( $meta as $mid ) |
|
369 | - delete_metadata_by_mid( 'user', $mid ); |
|
367 | + $meta = $wpdb->get_col($wpdb->prepare("SELECT umeta_id FROM $wpdb->usermeta WHERE user_id = %d", $id)); |
|
368 | + foreach ($meta as $mid) |
|
369 | + delete_metadata_by_mid('user', $mid); |
|
370 | 370 | |
371 | - $wpdb->delete( $wpdb->users, array( 'ID' => $id ) ); |
|
371 | + $wpdb->delete($wpdb->users, array('ID' => $id)); |
|
372 | 372 | } |
373 | 373 | |
374 | - clean_user_cache( $user ); |
|
374 | + clean_user_cache($user); |
|
375 | 375 | |
376 | 376 | /** |
377 | 377 | * Fires immediately after a user is deleted from the database. |
@@ -382,7 +382,7 @@ discard block |
||
382 | 382 | * @param int|null $reassign ID of the user to reassign posts and links to. |
383 | 383 | * Default null, for no reassignment. |
384 | 384 | */ |
385 | - do_action( 'deleted_user', $id, $reassign ); |
|
385 | + do_action('deleted_user', $id, $reassign); |
|
386 | 386 | |
387 | 387 | return true; |
388 | 388 | } |
@@ -411,11 +411,11 @@ discard block |
||
411 | 411 | function default_password_nag_handler($errors = false) { |
412 | 412 | global $user_ID; |
413 | 413 | // Short-circuit it. |
414 | - if ( ! get_user_option('default_password_nag') ) |
|
414 | + if ( ! get_user_option('default_password_nag')) |
|
415 | 415 | return; |
416 | 416 | |
417 | 417 | // get_user_setting = JS saved UI setting. else no-js-fallback code. |
418 | - if ( 'hide' == get_user_setting('default_password_nag') || isset($_GET['default_password_nag']) && '0' == $_GET['default_password_nag'] ) { |
|
418 | + if ('hide' == get_user_setting('default_password_nag') || isset($_GET['default_password_nag']) && '0' == $_GET['default_password_nag']) { |
|
419 | 419 | delete_user_setting('default_password_nag'); |
420 | 420 | update_user_option($user_ID, 'default_password_nag', false, true); |
421 | 421 | } |
@@ -429,13 +429,13 @@ discard block |
||
429 | 429 | */ |
430 | 430 | function default_password_nag_edit_user($user_ID, $old_data) { |
431 | 431 | // Short-circuit it. |
432 | - if ( ! get_user_option('default_password_nag', $user_ID) ) |
|
432 | + if ( ! get_user_option('default_password_nag', $user_ID)) |
|
433 | 433 | return; |
434 | 434 | |
435 | 435 | $new_data = get_userdata($user_ID); |
436 | 436 | |
437 | 437 | // Remove the nag if the password has been changed. |
438 | - if ( $new_data->user_pass != $old_data->user_pass ) { |
|
438 | + if ($new_data->user_pass != $old_data->user_pass) { |
|
439 | 439 | delete_user_setting('default_password_nag'); |
440 | 440 | update_user_option($user_ID, 'default_password_nag', false, true); |
441 | 441 | } |
@@ -449,16 +449,16 @@ discard block |
||
449 | 449 | function default_password_nag() { |
450 | 450 | global $pagenow; |
451 | 451 | // Short-circuit it. |
452 | - if ( 'profile.php' == $pagenow || ! get_user_option('default_password_nag') ) |
|
452 | + if ('profile.php' == $pagenow || ! get_user_option('default_password_nag')) |
|
453 | 453 | return; |
454 | 454 | |
455 | 455 | echo '<div class="error default-password-nag">'; |
456 | 456 | echo '<p>'; |
457 | - echo '<strong>' . __('Notice:') . '</strong> '; |
|
457 | + echo '<strong>'.__('Notice:').'</strong> '; |
|
458 | 458 | _e('You’re using the auto-generated password for your account. Would you like to change it?'); |
459 | 459 | echo '</p><p>'; |
460 | - printf( '<a href="%s">' . __('Yes, take me to my profile page') . '</a> | ', get_edit_profile_url() . '#password' ); |
|
461 | - printf( '<a href="%s" id="default-password-nag-no">' . __('No thanks, do not remind me again') . '</a>', '?default_password_nag=0' ); |
|
460 | + printf('<a href="%s">'.__('Yes, take me to my profile page').'</a> | ', get_edit_profile_url().'#password'); |
|
461 | + printf('<a href="%s" id="default-password-nag-no">'.__('No thanks, do not remind me again').'</a>', '?default_password_nag=0'); |
|
462 | 462 | echo '</p></div>'; |
463 | 463 | } |
464 | 464 | |
@@ -502,16 +502,16 @@ discard block |
||
502 | 502 | * @param string $text |
503 | 503 | * @return string |
504 | 504 | */ |
505 | -function admin_created_user_email( $text ) { |
|
505 | +function admin_created_user_email($text) { |
|
506 | 506 | $roles = get_editable_roles(); |
507 | - $role = $roles[ $_REQUEST['role'] ]; |
|
507 | + $role = $roles[$_REQUEST['role']]; |
|
508 | 508 | /* translators: 1: Site name, 2: site URL, 3: role */ |
509 | - return sprintf( __( 'Hi, |
|
509 | + return sprintf(__('Hi, |
|
510 | 510 | You\'ve been invited to join \'%1$s\' at |
511 | 511 | %2$s with the role of %3$s. |
512 | 512 | If you do not want to join this site please ignore |
513 | 513 | this email. This invitation will expire in a few days. |
514 | 514 | |
515 | 515 | Please click the following link to activate your user account: |
516 | -%%s' ), get_bloginfo( 'name' ), home_url(), wp_specialchars_decode( translate_user_role( $role['name'] ) ) ); |
|
516 | +%%s' ), get_bloginfo('name'), home_url(), wp_specialchars_decode(translate_user_role($role['name']))); |
|
517 | 517 | } |
@@ -39,31 +39,37 @@ discard block |
||
39 | 39 | $update = false; |
40 | 40 | } |
41 | 41 | |
42 | - if ( !$update && isset( $_POST['user_login'] ) ) |
|
43 | - $user->user_login = sanitize_user($_POST['user_login'], true); |
|
42 | + if ( !$update && isset( $_POST['user_login'] ) ) { |
|
43 | + $user->user_login = sanitize_user($_POST['user_login'], true); |
|
44 | + } |
|
44 | 45 | |
45 | 46 | $pass1 = $pass2 = ''; |
46 | - if ( isset( $_POST['pass1'] ) ) |
|
47 | - $pass1 = $_POST['pass1']; |
|
48 | - if ( isset( $_POST['pass2'] ) ) |
|
49 | - $pass2 = $_POST['pass2']; |
|
47 | + if ( isset( $_POST['pass1'] ) ) { |
|
48 | + $pass1 = $_POST['pass1']; |
|
49 | + } |
|
50 | + if ( isset( $_POST['pass2'] ) ) { |
|
51 | + $pass2 = $_POST['pass2']; |
|
52 | + } |
|
50 | 53 | |
51 | 54 | if ( isset( $_POST['role'] ) && current_user_can( 'edit_users' ) ) { |
52 | 55 | $new_role = sanitize_text_field( $_POST['role'] ); |
53 | 56 | $potential_role = isset($wp_roles->role_objects[$new_role]) ? $wp_roles->role_objects[$new_role] : false; |
54 | 57 | // Don't let anyone with 'edit_users' (admins) edit their own role to something without it. |
55 | 58 | // Multisite super admins can freely edit their blog roles -- they possess all caps. |
56 | - if ( ( is_multisite() && current_user_can( 'manage_sites' ) ) || $user_id != get_current_user_id() || ($potential_role && $potential_role->has_cap( 'edit_users' ) ) ) |
|
57 | - $user->role = $new_role; |
|
59 | + if ( ( is_multisite() && current_user_can( 'manage_sites' ) ) || $user_id != get_current_user_id() || ($potential_role && $potential_role->has_cap( 'edit_users' ) ) ) { |
|
60 | + $user->role = $new_role; |
|
61 | + } |
|
58 | 62 | |
59 | 63 | // If the new role isn't editable by the logged-in user die with error |
60 | 64 | $editable_roles = get_editable_roles(); |
61 | - if ( ! empty( $new_role ) && empty( $editable_roles[$new_role] ) ) |
|
62 | - wp_die(__('You can’t give users that role.')); |
|
65 | + if ( ! empty( $new_role ) && empty( $editable_roles[$new_role] ) ) { |
|
66 | + wp_die(__('You can’t give users that role.')); |
|
67 | + } |
|
63 | 68 | } |
64 | 69 | |
65 | - if ( isset( $_POST['email'] )) |
|
66 | - $user->user_email = sanitize_text_field( wp_unslash( $_POST['email'] ) ); |
|
70 | + if ( isset( $_POST['email'] )) { |
|
71 | + $user->user_email = sanitize_text_field( wp_unslash( $_POST['email'] ) ); |
|
72 | + } |
|
67 | 73 | if ( isset( $_POST['url'] ) ) { |
68 | 74 | if ( empty ( $_POST['url'] ) || $_POST['url'] == 'http://' ) { |
69 | 75 | $user->user_url = ''; |
@@ -73,21 +79,27 @@ discard block |
||
73 | 79 | $user->user_url = preg_match('/^(' . $protocols . '):/is', $user->user_url) ? $user->user_url : 'http://'.$user->user_url; |
74 | 80 | } |
75 | 81 | } |
76 | - if ( isset( $_POST['first_name'] ) ) |
|
77 | - $user->first_name = sanitize_text_field( $_POST['first_name'] ); |
|
78 | - if ( isset( $_POST['last_name'] ) ) |
|
79 | - $user->last_name = sanitize_text_field( $_POST['last_name'] ); |
|
80 | - if ( isset( $_POST['nickname'] ) ) |
|
81 | - $user->nickname = sanitize_text_field( $_POST['nickname'] ); |
|
82 | - if ( isset( $_POST['display_name'] ) ) |
|
83 | - $user->display_name = sanitize_text_field( $_POST['display_name'] ); |
|
82 | + if ( isset( $_POST['first_name'] ) ) { |
|
83 | + $user->first_name = sanitize_text_field( $_POST['first_name'] ); |
|
84 | + } |
|
85 | + if ( isset( $_POST['last_name'] ) ) { |
|
86 | + $user->last_name = sanitize_text_field( $_POST['last_name'] ); |
|
87 | + } |
|
88 | + if ( isset( $_POST['nickname'] ) ) { |
|
89 | + $user->nickname = sanitize_text_field( $_POST['nickname'] ); |
|
90 | + } |
|
91 | + if ( isset( $_POST['display_name'] ) ) { |
|
92 | + $user->display_name = sanitize_text_field( $_POST['display_name'] ); |
|
93 | + } |
|
84 | 94 | |
85 | - if ( isset( $_POST['description'] ) ) |
|
86 | - $user->description = trim( $_POST['description'] ); |
|
95 | + if ( isset( $_POST['description'] ) ) { |
|
96 | + $user->description = trim( $_POST['description'] ); |
|
97 | + } |
|
87 | 98 | |
88 | 99 | foreach ( wp_get_user_contact_methods( $user ) as $method => $name ) { |
89 | - if ( isset( $_POST[$method] )) |
|
90 | - $user->$method = sanitize_text_field( $_POST[$method] ); |
|
100 | + if ( isset( $_POST[$method] )) { |
|
101 | + $user->$method = sanitize_text_field( $_POST[$method] ); |
|
102 | + } |
|
91 | 103 | } |
92 | 104 | |
93 | 105 | if ( $update ) { |
@@ -99,14 +111,16 @@ discard block |
||
99 | 111 | $user->comment_shortcuts = isset( $_POST['comment_shortcuts'] ) && 'true' == $_POST['comment_shortcuts'] ? 'true' : ''; |
100 | 112 | |
101 | 113 | $user->use_ssl = 0; |
102 | - if ( !empty($_POST['use_ssl']) ) |
|
103 | - $user->use_ssl = 1; |
|
114 | + if ( !empty($_POST['use_ssl']) ) { |
|
115 | + $user->use_ssl = 1; |
|
116 | + } |
|
104 | 117 | |
105 | 118 | $errors = new WP_Error(); |
106 | 119 | |
107 | 120 | /* checking that username has been typed */ |
108 | - if ( $user->user_login == '' ) |
|
109 | - $errors->add( 'user_login', __( '<strong>ERROR</strong>: Please enter a username.' ) ); |
|
121 | + if ( $user->user_login == '' ) { |
|
122 | + $errors->add( 'user_login', __( '<strong>ERROR</strong>: Please enter a username.' ) ); |
|
123 | + } |
|
110 | 124 | |
111 | 125 | /* checking that nickname has been typed */ |
112 | 126 | if ( $update && empty( $user->nickname ) ) { |
@@ -126,21 +140,26 @@ discard block |
||
126 | 140 | do_action_ref_array( 'check_passwords', array( $user->user_login, &$pass1, &$pass2 ) ); |
127 | 141 | |
128 | 142 | /* Check for "\" in password */ |
129 | - if ( false !== strpos( wp_unslash( $pass1 ), "\\" ) ) |
|
130 | - $errors->add( 'pass', __( '<strong>ERROR</strong>: Passwords may not contain the character "\\".' ), array( 'form-field' => 'pass1' ) ); |
|
143 | + if ( false !== strpos( wp_unslash( $pass1 ), "\\" ) ) { |
|
144 | + $errors->add( 'pass', __( '<strong>ERROR</strong>: Passwords may not contain the character "\\".' ), array( 'form-field' => 'pass1' ) ); |
|
145 | + } |
|
131 | 146 | |
132 | 147 | /* checking the password has been typed twice the same */ |
133 | - if ( $pass1 != $pass2 ) |
|
134 | - $errors->add( 'pass', __( '<strong>ERROR</strong>: Please enter the same password in both password fields.' ), array( 'form-field' => 'pass1' ) ); |
|
148 | + if ( $pass1 != $pass2 ) { |
|
149 | + $errors->add( 'pass', __( '<strong>ERROR</strong>: Please enter the same password in both password fields.' ), array( 'form-field' => 'pass1' ) ); |
|
150 | + } |
|
135 | 151 | |
136 | - if ( !empty( $pass1 ) ) |
|
137 | - $user->user_pass = $pass1; |
|
152 | + if ( !empty( $pass1 ) ) { |
|
153 | + $user->user_pass = $pass1; |
|
154 | + } |
|
138 | 155 | |
139 | - if ( !$update && isset( $_POST['user_login'] ) && !validate_username( $_POST['user_login'] ) ) |
|
140 | - $errors->add( 'user_login', __( '<strong>ERROR</strong>: This username is invalid because it uses illegal characters. Please enter a valid username.' )); |
|
156 | + if ( !$update && isset( $_POST['user_login'] ) && !validate_username( $_POST['user_login'] ) ) { |
|
157 | + $errors->add( 'user_login', __( '<strong>ERROR</strong>: This username is invalid because it uses illegal characters. Please enter a valid username.' )); |
|
158 | + } |
|
141 | 159 | |
142 | - if ( !$update && username_exists( $user->user_login ) ) |
|
143 | - $errors->add( 'user_login', __( '<strong>ERROR</strong>: This username is already registered. Please choose another one.' )); |
|
160 | + if ( !$update && username_exists( $user->user_login ) ) { |
|
161 | + $errors->add( 'user_login', __( '<strong>ERROR</strong>: This username is already registered. Please choose another one.' )); |
|
162 | + } |
|
144 | 163 | |
145 | 164 | /** This filter is documented in wp-includes/user.php */ |
146 | 165 | $illegal_logins = (array) apply_filters( 'illegal_user_logins', array() ); |
@@ -169,8 +188,9 @@ discard block |
||
169 | 188 | */ |
170 | 189 | do_action_ref_array( 'user_profile_update_errors', array( &$errors, $update, &$user ) ); |
171 | 190 | |
172 | - if ( $errors->get_error_codes() ) |
|
173 | - return $errors; |
|
191 | + if ( $errors->get_error_codes() ) { |
|
192 | + return $errors; |
|
193 | + } |
|
174 | 194 | |
175 | 195 | if ( $update ) { |
176 | 196 | $user_id = wp_update_user( $user ); |
@@ -234,8 +254,9 @@ discard block |
||
234 | 254 | function get_user_to_edit( $user_id ) { |
235 | 255 | $user = get_userdata( $user_id ); |
236 | 256 | |
237 | - if ( $user ) |
|
238 | - $user->filter = 'edit'; |
|
257 | + if ( $user ) { |
|
258 | + $user->filter = 'edit'; |
|
259 | + } |
|
239 | 260 | |
240 | 261 | return $user; |
241 | 262 | } |
@@ -291,8 +312,9 @@ discard block |
||
291 | 312 | $id = (int) $id; |
292 | 313 | $user = new WP_User( $id ); |
293 | 314 | |
294 | - if ( !$user->exists() ) |
|
295 | - return false; |
|
315 | + if ( !$user->exists() ) { |
|
316 | + return false; |
|
317 | + } |
|
296 | 318 | |
297 | 319 | // Normalize $reassign to null or a user ID. 'novalue' was an older default. |
298 | 320 | if ( 'novalue' === $reassign ) { |
@@ -334,29 +356,33 @@ discard block |
||
334 | 356 | $post_types_to_delete = implode( "', '", $post_types_to_delete ); |
335 | 357 | $post_ids = $wpdb->get_col( $wpdb->prepare( "SELECT ID FROM $wpdb->posts WHERE post_author = %d AND post_type IN ('$post_types_to_delete')", $id ) ); |
336 | 358 | if ( $post_ids ) { |
337 | - foreach ( $post_ids as $post_id ) |
|
338 | - wp_delete_post( $post_id ); |
|
359 | + foreach ( $post_ids as $post_id ) { |
|
360 | + wp_delete_post( $post_id ); |
|
361 | + } |
|
339 | 362 | } |
340 | 363 | |
341 | 364 | // Clean links |
342 | 365 | $link_ids = $wpdb->get_col( $wpdb->prepare("SELECT link_id FROM $wpdb->links WHERE link_owner = %d", $id) ); |
343 | 366 | |
344 | 367 | if ( $link_ids ) { |
345 | - foreach ( $link_ids as $link_id ) |
|
346 | - wp_delete_link($link_id); |
|
368 | + foreach ( $link_ids as $link_id ) { |
|
369 | + wp_delete_link($link_id); |
|
370 | + } |
|
347 | 371 | } |
348 | 372 | } else { |
349 | 373 | $post_ids = $wpdb->get_col( $wpdb->prepare( "SELECT ID FROM $wpdb->posts WHERE post_author = %d", $id ) ); |
350 | 374 | $wpdb->update( $wpdb->posts, array('post_author' => $reassign), array('post_author' => $id) ); |
351 | 375 | if ( ! empty( $post_ids ) ) { |
352 | - foreach ( $post_ids as $post_id ) |
|
353 | - clean_post_cache( $post_id ); |
|
376 | + foreach ( $post_ids as $post_id ) { |
|
377 | + clean_post_cache( $post_id ); |
|
378 | + } |
|
354 | 379 | } |
355 | 380 | $link_ids = $wpdb->get_col( $wpdb->prepare("SELECT link_id FROM $wpdb->links WHERE link_owner = %d", $id) ); |
356 | 381 | $wpdb->update( $wpdb->links, array('link_owner' => $reassign), array('link_owner' => $id) ); |
357 | 382 | if ( ! empty( $link_ids ) ) { |
358 | - foreach ( $link_ids as $link_id ) |
|
359 | - clean_bookmark_cache( $link_id ); |
|
383 | + foreach ( $link_ids as $link_id ) { |
|
384 | + clean_bookmark_cache( $link_id ); |
|
385 | + } |
|
360 | 386 | } |
361 | 387 | } |
362 | 388 | |
@@ -365,8 +391,9 @@ discard block |
||
365 | 391 | remove_user_from_blog( $id, get_current_blog_id() ); |
366 | 392 | } else { |
367 | 393 | $meta = $wpdb->get_col( $wpdb->prepare( "SELECT umeta_id FROM $wpdb->usermeta WHERE user_id = %d", $id ) ); |
368 | - foreach ( $meta as $mid ) |
|
369 | - delete_metadata_by_mid( 'user', $mid ); |
|
394 | + foreach ( $meta as $mid ) { |
|
395 | + delete_metadata_by_mid( 'user', $mid ); |
|
396 | + } |
|
370 | 397 | |
371 | 398 | $wpdb->delete( $wpdb->users, array( 'ID' => $id ) ); |
372 | 399 | } |
@@ -411,8 +438,9 @@ discard block |
||
411 | 438 | function default_password_nag_handler($errors = false) { |
412 | 439 | global $user_ID; |
413 | 440 | // Short-circuit it. |
414 | - if ( ! get_user_option('default_password_nag') ) |
|
415 | - return; |
|
441 | + if ( ! get_user_option('default_password_nag') ) { |
|
442 | + return; |
|
443 | + } |
|
416 | 444 | |
417 | 445 | // get_user_setting = JS saved UI setting. else no-js-fallback code. |
418 | 446 | if ( 'hide' == get_user_setting('default_password_nag') || isset($_GET['default_password_nag']) && '0' == $_GET['default_password_nag'] ) { |
@@ -429,8 +457,9 @@ discard block |
||
429 | 457 | */ |
430 | 458 | function default_password_nag_edit_user($user_ID, $old_data) { |
431 | 459 | // Short-circuit it. |
432 | - if ( ! get_user_option('default_password_nag', $user_ID) ) |
|
433 | - return; |
|
460 | + if ( ! get_user_option('default_password_nag', $user_ID) ) { |
|
461 | + return; |
|
462 | + } |
|
434 | 463 | |
435 | 464 | $new_data = get_userdata($user_ID); |
436 | 465 | |
@@ -449,8 +478,9 @@ discard block |
||
449 | 478 | function default_password_nag() { |
450 | 479 | global $pagenow; |
451 | 480 | // Short-circuit it. |
452 | - if ( 'profile.php' == $pagenow || ! get_user_option('default_password_nag') ) |
|
453 | - return; |
|
481 | + if ( 'profile.php' == $pagenow || ! get_user_option('default_password_nag') ) { |
|
482 | + return; |
|
483 | + } |
|
454 | 484 | |
455 | 485 | echo '<div class="error default-password-nag">'; |
456 | 486 | echo '<p>'; |
@@ -1,11 +1,11 @@ |
||
1 | 1 | <?php |
2 | 2 | /** |
3 | - * Navigation Menu API: Walker_Nav_Menu_Edit class |
|
4 | - * |
|
5 | - * @package WordPress |
|
6 | - * @subpackage Administration |
|
7 | - * @since 4.4.0 |
|
8 | - */ |
|
3 | + * Navigation Menu API: Walker_Nav_Menu_Edit class |
|
4 | + * |
|
5 | + * @package WordPress |
|
6 | + * @subpackage Administration |
|
7 | + * @since 4.4.0 |
|
8 | + */ |
|
9 | 9 | |
10 | 10 | /** |
11 | 11 | * Create HTML list of nav menu input items. |
@@ -26,7 +26,7 @@ discard block |
||
26 | 26 | * @param int $depth Depth of menu item. Used for padding. |
27 | 27 | * @param array $args Not used. |
28 | 28 | */ |
29 | - public function start_lvl( &$output, $depth = 0, $args = array() ) {} |
|
29 | + public function start_lvl(&$output, $depth = 0, $args = array()) {} |
|
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 array $args Not used. |
41 | 41 | */ |
42 | - public function end_lvl( &$output, $depth = 0, $args = array() ) {} |
|
42 | + public function end_lvl(&$output, $depth = 0, $args = array()) {} |
|
43 | 43 | |
44 | 44 | /** |
45 | 45 | * Start the element output. |
@@ -55,12 +55,12 @@ discard block |
||
55 | 55 | * @param array $args Not used. |
56 | 56 | * @param int $id Not used. |
57 | 57 | */ |
58 | - public function start_el( &$output, $item, $depth = 0, $args = array(), $id = 0 ) { |
|
58 | + public function start_el(&$output, $item, $depth = 0, $args = array(), $id = 0) { |
|
59 | 59 | global $_wp_nav_menu_max_depth; |
60 | 60 | $_wp_nav_menu_max_depth = $depth > $_wp_nav_menu_max_depth ? $depth : $_wp_nav_menu_max_depth; |
61 | 61 | |
62 | 62 | ob_start(); |
63 | - $item_id = esc_attr( $item->ID ); |
|
63 | + $item_id = esc_attr($item->ID); |
|
64 | 64 | $removed_args = array( |
65 | 65 | 'action', |
66 | 66 | 'customlink-tab', |
@@ -71,51 +71,51 @@ discard block |
||
71 | 71 | ); |
72 | 72 | |
73 | 73 | $original_title = ''; |
74 | - if ( 'taxonomy' == $item->type ) { |
|
75 | - $original_title = get_term_field( 'name', $item->object_id, $item->object, 'raw' ); |
|
76 | - if ( is_wp_error( $original_title ) ) |
|
74 | + if ('taxonomy' == $item->type) { |
|
75 | + $original_title = get_term_field('name', $item->object_id, $item->object, 'raw'); |
|
76 | + if (is_wp_error($original_title)) |
|
77 | 77 | $original_title = false; |
78 | - } elseif ( 'post_type' == $item->type ) { |
|
79 | - $original_object = get_post( $item->object_id ); |
|
80 | - $original_title = get_the_title( $original_object->ID ); |
|
81 | - } elseif ( 'post_type_archive' == $item->type ) { |
|
82 | - $original_object = get_post_type_object( $item->object ); |
|
83 | - if ( $original_object ) { |
|
78 | + } elseif ('post_type' == $item->type) { |
|
79 | + $original_object = get_post($item->object_id); |
|
80 | + $original_title = get_the_title($original_object->ID); |
|
81 | + } elseif ('post_type_archive' == $item->type) { |
|
82 | + $original_object = get_post_type_object($item->object); |
|
83 | + if ($original_object) { |
|
84 | 84 | $original_title = $original_object->labels->archives; |
85 | 85 | } |
86 | 86 | } |
87 | 87 | |
88 | 88 | $classes = array( |
89 | - 'menu-item menu-item-depth-' . $depth, |
|
90 | - 'menu-item-' . esc_attr( $item->object ), |
|
91 | - 'menu-item-edit-' . ( ( isset( $_GET['edit-menu-item'] ) && $item_id == $_GET['edit-menu-item'] ) ? 'active' : 'inactive'), |
|
89 | + 'menu-item menu-item-depth-'.$depth, |
|
90 | + 'menu-item-'.esc_attr($item->object), |
|
91 | + 'menu-item-edit-'.((isset($_GET['edit-menu-item']) && $item_id == $_GET['edit-menu-item']) ? 'active' : 'inactive'), |
|
92 | 92 | ); |
93 | 93 | |
94 | 94 | $title = $item->title; |
95 | 95 | |
96 | - if ( ! empty( $item->_invalid ) ) { |
|
96 | + if ( ! empty($item->_invalid)) { |
|
97 | 97 | $classes[] = 'menu-item-invalid'; |
98 | 98 | /* translators: %s: title of menu item which is invalid */ |
99 | - $title = sprintf( __( '%s (Invalid)' ), $item->title ); |
|
100 | - } elseif ( isset( $item->post_status ) && 'draft' == $item->post_status ) { |
|
99 | + $title = sprintf(__('%s (Invalid)'), $item->title); |
|
100 | + } elseif (isset($item->post_status) && 'draft' == $item->post_status) { |
|
101 | 101 | $classes[] = 'pending'; |
102 | 102 | /* translators: %s: title of menu item in draft status */ |
103 | - $title = sprintf( __('%s (Pending)'), $item->title ); |
|
103 | + $title = sprintf(__('%s (Pending)'), $item->title); |
|
104 | 104 | } |
105 | 105 | |
106 | - $title = ( ! isset( $item->label ) || '' == $item->label ) ? $title : $item->label; |
|
106 | + $title = ( ! isset($item->label) || '' == $item->label) ? $title : $item->label; |
|
107 | 107 | |
108 | 108 | $submenu_text = ''; |
109 | - if ( 0 == $depth ) |
|
109 | + if (0 == $depth) |
|
110 | 110 | $submenu_text = 'style="display: none;"'; |
111 | 111 | |
112 | 112 | ?> |
113 | - <li id="menu-item-<?php echo $item_id; ?>" class="<?php echo implode(' ', $classes ); ?>"> |
|
113 | + <li id="menu-item-<?php echo $item_id; ?>" class="<?php echo implode(' ', $classes); ?>"> |
|
114 | 114 | <div class="menu-item-bar"> |
115 | 115 | <div class="menu-item-handle"> |
116 | - <span class="item-title"><span class="menu-item-title"><?php echo esc_html( $title ); ?></span> <span class="is-submenu" <?php echo $submenu_text; ?>><?php _e( 'sub item' ); ?></span></span> |
|
116 | + <span class="item-title"><span class="menu-item-title"><?php echo esc_html($title); ?></span> <span class="is-submenu" <?php echo $submenu_text; ?>><?php _e('sub item'); ?></span></span> |
|
117 | 117 | <span class="item-controls"> |
118 | - <span class="item-type"><?php echo esc_html( $item->type_label ); ?></span> |
|
118 | + <span class="item-type"><?php echo esc_html($item->type_label); ?></span> |
|
119 | 119 | <span class="item-order hide-if-js"> |
120 | 120 | <a href="<?php |
121 | 121 | echo wp_nonce_url( |
@@ -124,11 +124,11 @@ discard block |
||
124 | 124 | 'action' => 'move-up-menu-item', |
125 | 125 | 'menu-item' => $item_id, |
126 | 126 | ), |
127 | - remove_query_arg($removed_args, admin_url( 'nav-menus.php' ) ) |
|
127 | + remove_query_arg($removed_args, admin_url('nav-menus.php')) |
|
128 | 128 | ), |
129 | 129 | 'move-menu_item' |
130 | 130 | ); |
131 | - ?>" class="item-move-up" aria-label="<?php esc_attr_e( 'Move up' ) ?>">↑</a> |
|
131 | + ?>" class="item-move-up" aria-label="<?php esc_attr_e('Move up') ?>">↑</a> |
|
132 | 132 | | |
133 | 133 | <a href="<?php |
134 | 134 | echo wp_nonce_url( |
@@ -137,81 +137,81 @@ discard block |
||
137 | 137 | 'action' => 'move-down-menu-item', |
138 | 138 | 'menu-item' => $item_id, |
139 | 139 | ), |
140 | - remove_query_arg($removed_args, admin_url( 'nav-menus.php' ) ) |
|
140 | + remove_query_arg($removed_args, admin_url('nav-menus.php')) |
|
141 | 141 | ), |
142 | 142 | 'move-menu_item' |
143 | 143 | ); |
144 | - ?>" class="item-move-down" aria-label="<?php esc_attr_e( 'Move down' ) ?>">↓</a> |
|
144 | + ?>" class="item-move-down" aria-label="<?php esc_attr_e('Move down') ?>">↓</a> |
|
145 | 145 | </span> |
146 | 146 | <a class="item-edit" id="edit-<?php echo $item_id; ?>" href="<?php |
147 | - echo ( isset( $_GET['edit-menu-item'] ) && $item_id == $_GET['edit-menu-item'] ) ? admin_url( 'nav-menus.php' ) : add_query_arg( 'edit-menu-item', $item_id, remove_query_arg( $removed_args, admin_url( 'nav-menus.php#menu-item-settings-' . $item_id ) ) ); |
|
148 | - ?>" aria-label="<?php esc_attr_e( 'Edit menu item' ); ?>"><?php _e( 'Edit' ); ?></a> |
|
147 | + echo (isset($_GET['edit-menu-item']) && $item_id == $_GET['edit-menu-item']) ? admin_url('nav-menus.php') : add_query_arg('edit-menu-item', $item_id, remove_query_arg($removed_args, admin_url('nav-menus.php#menu-item-settings-'.$item_id))); |
|
148 | + ?>" aria-label="<?php esc_attr_e('Edit menu item'); ?>"><?php _e('Edit'); ?></a> |
|
149 | 149 | </span> |
150 | 150 | </div> |
151 | 151 | </div> |
152 | 152 | |
153 | 153 | <div class="menu-item-settings wp-clearfix" id="menu-item-settings-<?php echo $item_id; ?>"> |
154 | - <?php if ( 'custom' == $item->type ) : ?> |
|
154 | + <?php if ('custom' == $item->type) : ?> |
|
155 | 155 | <p class="field-url description description-wide"> |
156 | 156 | <label for="edit-menu-item-url-<?php echo $item_id; ?>"> |
157 | - <?php _e( 'URL' ); ?><br /> |
|
158 | - <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( $item->url ); ?>" /> |
|
157 | + <?php _e('URL'); ?><br /> |
|
158 | + <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($item->url); ?>" /> |
|
159 | 159 | </label> |
160 | 160 | </p> |
161 | 161 | <?php endif; ?> |
162 | 162 | <p class="description description-wide"> |
163 | 163 | <label for="edit-menu-item-title-<?php echo $item_id; ?>"> |
164 | - <?php _e( 'Navigation Label' ); ?><br /> |
|
165 | - <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( $item->title ); ?>" /> |
|
164 | + <?php _e('Navigation Label'); ?><br /> |
|
165 | + <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($item->title); ?>" /> |
|
166 | 166 | </label> |
167 | 167 | </p> |
168 | 168 | <p class="field-title-attribute description description-wide"> |
169 | 169 | <label for="edit-menu-item-attr-title-<?php echo $item_id; ?>"> |
170 | - <?php _e( 'Title Attribute' ); ?><br /> |
|
171 | - <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( $item->post_excerpt ); ?>" /> |
|
170 | + <?php _e('Title Attribute'); ?><br /> |
|
171 | + <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($item->post_excerpt); ?>" /> |
|
172 | 172 | </label> |
173 | 173 | </p> |
174 | 174 | <p class="field-link-target description"> |
175 | 175 | <label for="edit-menu-item-target-<?php echo $item_id; ?>"> |
176 | - <input type="checkbox" id="edit-menu-item-target-<?php echo $item_id; ?>" value="_blank" name="menu-item-target[<?php echo $item_id; ?>]"<?php checked( $item->target, '_blank' ); ?> /> |
|
177 | - <?php _e( 'Open link in a new tab' ); ?> |
|
176 | + <input type="checkbox" id="edit-menu-item-target-<?php echo $item_id; ?>" value="_blank" name="menu-item-target[<?php echo $item_id; ?>]"<?php checked($item->target, '_blank'); ?> /> |
|
177 | + <?php _e('Open link in a new tab'); ?> |
|
178 | 178 | </label> |
179 | 179 | </p> |
180 | 180 | <p class="field-css-classes description description-thin"> |
181 | 181 | <label for="edit-menu-item-classes-<?php echo $item_id; ?>"> |
182 | - <?php _e( 'CSS Classes (optional)' ); ?><br /> |
|
183 | - <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(' ', $item->classes ) ); ?>" /> |
|
182 | + <?php _e('CSS Classes (optional)'); ?><br /> |
|
183 | + <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(' ', $item->classes)); ?>" /> |
|
184 | 184 | </label> |
185 | 185 | </p> |
186 | 186 | <p class="field-xfn description description-thin"> |
187 | 187 | <label for="edit-menu-item-xfn-<?php echo $item_id; ?>"> |
188 | - <?php _e( 'Link Relationship (XFN)' ); ?><br /> |
|
189 | - <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( $item->xfn ); ?>" /> |
|
188 | + <?php _e('Link Relationship (XFN)'); ?><br /> |
|
189 | + <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($item->xfn); ?>" /> |
|
190 | 190 | </label> |
191 | 191 | </p> |
192 | 192 | <p class="field-description description description-wide"> |
193 | 193 | <label for="edit-menu-item-description-<?php echo $item_id; ?>"> |
194 | - <?php _e( 'Description' ); ?><br /> |
|
195 | - <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( $item->description ); // textarea_escaped ?></textarea> |
|
194 | + <?php _e('Description'); ?><br /> |
|
195 | + <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($item->description); // textarea_escaped ?></textarea> |
|
196 | 196 | <span class="description"><?php _e('The description will be displayed in the menu if the current theme supports it.'); ?></span> |
197 | 197 | </label> |
198 | 198 | </p> |
199 | 199 | |
200 | 200 | <p class="field-move hide-if-no-js description description-wide"> |
201 | 201 | <label> |
202 | - <span><?php _e( 'Move' ); ?></span> |
|
203 | - <a href="#" class="menus-move menus-move-up" data-dir="up"><?php _e( 'Up one' ); ?></a> |
|
204 | - <a href="#" class="menus-move menus-move-down" data-dir="down"><?php _e( 'Down one' ); ?></a> |
|
202 | + <span><?php _e('Move'); ?></span> |
|
203 | + <a href="#" class="menus-move menus-move-up" data-dir="up"><?php _e('Up one'); ?></a> |
|
204 | + <a href="#" class="menus-move menus-move-down" data-dir="down"><?php _e('Down one'); ?></a> |
|
205 | 205 | <a href="#" class="menus-move menus-move-left" data-dir="left"></a> |
206 | 206 | <a href="#" class="menus-move menus-move-right" data-dir="right"></a> |
207 | - <a href="#" class="menus-move menus-move-top" data-dir="top"><?php _e( 'To the top' ); ?></a> |
|
207 | + <a href="#" class="menus-move menus-move-top" data-dir="top"><?php _e('To the top'); ?></a> |
|
208 | 208 | </label> |
209 | 209 | </p> |
210 | 210 | |
211 | 211 | <div class="menu-item-actions description-wide submitbox"> |
212 | - <?php if ( 'custom' != $item->type && $original_title !== false ) : ?> |
|
212 | + <?php if ('custom' != $item->type && $original_title !== false) : ?> |
|
213 | 213 | <p class="link-to-original"> |
214 | - <?php printf( __('Original: %s'), '<a href="' . esc_attr( $item->url ) . '">' . esc_html( $original_title ) . '</a>' ); ?> |
|
214 | + <?php printf(__('Original: %s'), '<a href="'.esc_attr($item->url).'">'.esc_html($original_title).'</a>'); ?> |
|
215 | 215 | </p> |
216 | 216 | <?php endif; ?> |
217 | 217 | <a class="item-delete submitdelete deletion" id="delete-<?php echo $item_id; ?>" href="<?php |
@@ -221,19 +221,19 @@ discard block |
||
221 | 221 | 'action' => 'delete-menu-item', |
222 | 222 | 'menu-item' => $item_id, |
223 | 223 | ), |
224 | - admin_url( 'nav-menus.php' ) |
|
224 | + admin_url('nav-menus.php') |
|
225 | 225 | ), |
226 | - 'delete-menu_item_' . $item_id |
|
227 | - ); ?>"><?php _e( 'Remove' ); ?></a> <span class="meta-sep hide-if-no-js"> | </span> <a class="item-cancel submitcancel hide-if-no-js" id="cancel-<?php echo $item_id; ?>" href="<?php echo esc_url( add_query_arg( array( 'edit-menu-item' => $item_id, 'cancel' => time() ), admin_url( 'nav-menus.php' ) ) ); |
|
226 | + 'delete-menu_item_'.$item_id |
|
227 | + ); ?>"><?php _e('Remove'); ?></a> <span class="meta-sep hide-if-no-js"> | </span> <a class="item-cancel submitcancel hide-if-no-js" id="cancel-<?php echo $item_id; ?>" href="<?php echo esc_url(add_query_arg(array('edit-menu-item' => $item_id, 'cancel' => time()), admin_url('nav-menus.php'))); |
|
228 | 228 | ?>#menu-item-settings-<?php echo $item_id; ?>"><?php _e('Cancel'); ?></a> |
229 | 229 | </div> |
230 | 230 | |
231 | 231 | <input class="menu-item-data-db-id" type="hidden" name="menu-item-db-id[<?php echo $item_id; ?>]" value="<?php echo $item_id; ?>" /> |
232 | - <input class="menu-item-data-object-id" type="hidden" name="menu-item-object-id[<?php echo $item_id; ?>]" value="<?php echo esc_attr( $item->object_id ); ?>" /> |
|
233 | - <input class="menu-item-data-object" type="hidden" name="menu-item-object[<?php echo $item_id; ?>]" value="<?php echo esc_attr( $item->object ); ?>" /> |
|
234 | - <input class="menu-item-data-parent-id" type="hidden" name="menu-item-parent-id[<?php echo $item_id; ?>]" value="<?php echo esc_attr( $item->menu_item_parent ); ?>" /> |
|
235 | - <input class="menu-item-data-position" type="hidden" name="menu-item-position[<?php echo $item_id; ?>]" value="<?php echo esc_attr( $item->menu_order ); ?>" /> |
|
236 | - <input class="menu-item-data-type" type="hidden" name="menu-item-type[<?php echo $item_id; ?>]" value="<?php echo esc_attr( $item->type ); ?>" /> |
|
232 | + <input class="menu-item-data-object-id" type="hidden" name="menu-item-object-id[<?php echo $item_id; ?>]" value="<?php echo esc_attr($item->object_id); ?>" /> |
|
233 | + <input class="menu-item-data-object" type="hidden" name="menu-item-object[<?php echo $item_id; ?>]" value="<?php echo esc_attr($item->object); ?>" /> |
|
234 | + <input class="menu-item-data-parent-id" type="hidden" name="menu-item-parent-id[<?php echo $item_id; ?>]" value="<?php echo esc_attr($item->menu_item_parent); ?>" /> |
|
235 | + <input class="menu-item-data-position" type="hidden" name="menu-item-position[<?php echo $item_id; ?>]" value="<?php echo esc_attr($item->menu_order); ?>" /> |
|
236 | + <input class="menu-item-data-type" type="hidden" name="menu-item-type[<?php echo $item_id; ?>]" value="<?php echo esc_attr($item->type); ?>" /> |
|
237 | 237 | </div><!-- .menu-item-settings--> |
238 | 238 | <ul class="menu-item-transport"></ul> |
239 | 239 | <?php |
@@ -73,8 +73,9 @@ discard block |
||
73 | 73 | $original_title = ''; |
74 | 74 | if ( 'taxonomy' == $item->type ) { |
75 | 75 | $original_title = get_term_field( 'name', $item->object_id, $item->object, 'raw' ); |
76 | - if ( is_wp_error( $original_title ) ) |
|
77 | - $original_title = false; |
|
76 | + if ( is_wp_error( $original_title ) ) { |
|
77 | + $original_title = false; |
|
78 | + } |
|
78 | 79 | } elseif ( 'post_type' == $item->type ) { |
79 | 80 | $original_object = get_post( $item->object_id ); |
80 | 81 | $original_title = get_the_title( $original_object->ID ); |
@@ -106,8 +107,9 @@ discard block |
||
106 | 107 | $title = ( ! isset( $item->label ) || '' == $item->label ) ? $title : $item->label; |
107 | 108 | |
108 | 109 | $submenu_text = ''; |
109 | - if ( 0 == $depth ) |
|
110 | - $submenu_text = 'style="display: none;"'; |
|
110 | + if ( 0 == $depth ) { |
|
111 | + $submenu_text = 'style="display: none;"'; |
|
112 | + } |
|
111 | 113 | |
112 | 114 | ?> |
113 | 115 | <li id="menu-item-<?php echo $item_id; ?>" class="<?php echo implode(' ', $classes ); ?>"> |