@@ -1,11 +1,11 @@ |
||
1 | 1 | <?php |
2 | 2 | /** |
3 | - * Helper functions for displaying a list of items in an ajaxified HTML table. |
|
4 | - * |
|
5 | - * @package WordPress |
|
6 | - * @subpackage List_Table |
|
7 | - * @since 3.1.0 |
|
8 | - */ |
|
3 | + * Helper functions for displaying a list of items in an ajaxified HTML table. |
|
4 | + * |
|
5 | + * @package WordPress |
|
6 | + * @subpackage List_Table |
|
7 | + * @since 3.1.0 |
|
8 | + */ |
|
9 | 9 | |
10 | 10 | /** |
11 | 11 | * Fetch an instance of a WP_List_Table class. |
@@ -19,7 +19,7 @@ discard block |
||
19 | 19 | * @param array $args Optional. Arguments to pass to the class. Accepts 'screen'. |
20 | 20 | * @return object|bool Object on success, false if the class does not exist. |
21 | 21 | */ |
22 | -function _get_list_table( $class, $args = array() ) { |
|
22 | +function _get_list_table($class, $args = array()) { |
|
23 | 23 | $core_classes = array( |
24 | 24 | //Site Admin |
25 | 25 | 'WP_Posts_List_Table' => 'posts', |
@@ -31,7 +31,7 @@ discard block |
||
31 | 31 | 'WP_Links_List_Table' => 'links', |
32 | 32 | 'WP_Plugin_Install_List_Table' => 'plugin-install', |
33 | 33 | 'WP_Themes_List_Table' => 'themes', |
34 | - 'WP_Theme_Install_List_Table' => array( 'themes', 'theme-install' ), |
|
34 | + 'WP_Theme_Install_List_Table' => array('themes', 'theme-install'), |
|
35 | 35 | 'WP_Plugins_List_Table' => 'plugins', |
36 | 36 | // Network Admin |
37 | 37 | 'WP_MS_Sites_List_Table' => 'ms-sites', |
@@ -39,18 +39,18 @@ discard block |
||
39 | 39 | 'WP_MS_Themes_List_Table' => 'ms-themes', |
40 | 40 | ); |
41 | 41 | |
42 | - if ( isset( $core_classes[ $class ] ) ) { |
|
43 | - foreach ( (array) $core_classes[ $class ] as $required ) |
|
44 | - require_once( ABSPATH . 'wp-admin/includes/class-wp-' . $required . '-list-table.php' ); |
|
42 | + if (isset($core_classes[$class])) { |
|
43 | + foreach ((array) $core_classes[$class] as $required) |
|
44 | + require_once(ABSPATH.'wp-admin/includes/class-wp-'.$required.'-list-table.php'); |
|
45 | 45 | |
46 | - if ( isset( $args['screen'] ) ) |
|
47 | - $args['screen'] = convert_to_screen( $args['screen'] ); |
|
48 | - elseif ( isset( $GLOBALS['hook_suffix'] ) ) |
|
46 | + if (isset($args['screen'])) |
|
47 | + $args['screen'] = convert_to_screen($args['screen']); |
|
48 | + elseif (isset($GLOBALS['hook_suffix'])) |
|
49 | 49 | $args['screen'] = get_current_screen(); |
50 | 50 | else |
51 | 51 | $args['screen'] = null; |
52 | 52 | |
53 | - return new $class( $args ); |
|
53 | + return new $class($args); |
|
54 | 54 | } |
55 | 55 | |
56 | 56 | return false; |
@@ -89,15 +89,15 @@ discard block |
||
89 | 89 | public $_screen; |
90 | 90 | public $_columns; |
91 | 91 | |
92 | - public function __construct( $screen, $columns = array() ) { |
|
93 | - if ( is_string( $screen ) ) |
|
94 | - $screen = convert_to_screen( $screen ); |
|
92 | + public function __construct($screen, $columns = array()) { |
|
93 | + if (is_string($screen)) |
|
94 | + $screen = convert_to_screen($screen); |
|
95 | 95 | |
96 | 96 | $this->_screen = $screen; |
97 | 97 | |
98 | - if ( !empty( $columns ) ) { |
|
98 | + if ( ! empty($columns)) { |
|
99 | 99 | $this->_columns = $columns; |
100 | - add_filter( 'manage_' . $screen->id . '_columns', array( $this, 'get_columns' ), 0 ); |
|
100 | + add_filter('manage_'.$screen->id.'_columns', array($this, 'get_columns'), 0); |
|
101 | 101 | } |
102 | 102 | } |
103 | 103 | |
@@ -107,11 +107,11 @@ discard block |
||
107 | 107 | * @return array |
108 | 108 | */ |
109 | 109 | protected function get_column_info() { |
110 | - $columns = get_column_headers( $this->_screen ); |
|
111 | - $hidden = get_hidden_columns( $this->_screen ); |
|
110 | + $columns = get_column_headers($this->_screen); |
|
111 | + $hidden = get_hidden_columns($this->_screen); |
|
112 | 112 | $sortable = array(); |
113 | 113 | |
114 | - return array( $columns, $hidden, $sortable ); |
|
114 | + return array($columns, $hidden, $sortable); |
|
115 | 115 | } |
116 | 116 | |
117 | 117 | /** |
@@ -40,15 +40,17 @@ discard block |
||
40 | 40 | ); |
41 | 41 | |
42 | 42 | if ( isset( $core_classes[ $class ] ) ) { |
43 | - foreach ( (array) $core_classes[ $class ] as $required ) |
|
44 | - require_once( ABSPATH . 'wp-admin/includes/class-wp-' . $required . '-list-table.php' ); |
|
43 | + foreach ( (array) $core_classes[ $class ] as $required ) { |
|
44 | + require_once( ABSPATH . 'wp-admin/includes/class-wp-' . $required . '-list-table.php' ); |
|
45 | + } |
|
45 | 46 | |
46 | - if ( isset( $args['screen'] ) ) |
|
47 | - $args['screen'] = convert_to_screen( $args['screen'] ); |
|
48 | - elseif ( isset( $GLOBALS['hook_suffix'] ) ) |
|
49 | - $args['screen'] = get_current_screen(); |
|
50 | - else |
|
51 | - $args['screen'] = null; |
|
47 | + if ( isset( $args['screen'] ) ) { |
|
48 | + $args['screen'] = convert_to_screen( $args['screen'] ); |
|
49 | + } elseif ( isset( $GLOBALS['hook_suffix'] ) ) { |
|
50 | + $args['screen'] = get_current_screen(); |
|
51 | + } else { |
|
52 | + $args['screen'] = null; |
|
53 | + } |
|
52 | 54 | |
53 | 55 | return new $class( $args ); |
54 | 56 | } |
@@ -90,8 +92,9 @@ discard block |
||
90 | 92 | public $_columns; |
91 | 93 | |
92 | 94 | public function __construct( $screen, $columns = array() ) { |
93 | - if ( is_string( $screen ) ) |
|
94 | - $screen = convert_to_screen( $screen ); |
|
95 | + if ( is_string( $screen ) ) { |
|
96 | + $screen = convert_to_screen( $screen ); |
|
97 | + } |
|
95 | 98 | |
96 | 99 | $this->_screen = $screen; |
97 | 100 |
@@ -1,10 +1,10 @@ |
||
1 | 1 | <?php |
2 | 2 | /** |
3 | - * WordPress Administration Revisions API |
|
4 | - * |
|
5 | - * @package WordPress |
|
6 | - * @subpackage Administration |
|
7 | - */ |
|
3 | + * WordPress Administration Revisions API |
|
4 | + * |
|
5 | + * @package WordPress |
|
6 | + * @subpackage Administration |
|
7 | + */ |
|
8 | 8 | |
9 | 9 | /** |
10 | 10 | * Get the revision UI diff. |
@@ -18,43 +18,43 @@ discard block |
||
18 | 18 | * @return array|bool Associative array of a post's revisioned fields and their diffs. |
19 | 19 | * Or, false on failure. |
20 | 20 | */ |
21 | -function wp_get_revision_ui_diff( $post, $compare_from, $compare_to ) { |
|
22 | - if ( ! $post = get_post( $post ) ) |
|
21 | +function wp_get_revision_ui_diff($post, $compare_from, $compare_to) { |
|
22 | + if ( ! $post = get_post($post)) |
|
23 | 23 | return false; |
24 | 24 | |
25 | - if ( $compare_from ) { |
|
26 | - if ( ! $compare_from = get_post( $compare_from ) ) |
|
25 | + if ($compare_from) { |
|
26 | + if ( ! $compare_from = get_post($compare_from)) |
|
27 | 27 | return false; |
28 | 28 | } else { |
29 | 29 | // If we're dealing with the first revision... |
30 | 30 | $compare_from = false; |
31 | 31 | } |
32 | 32 | |
33 | - if ( ! $compare_to = get_post( $compare_to ) ) |
|
33 | + if ( ! $compare_to = get_post($compare_to)) |
|
34 | 34 | return false; |
35 | 35 | |
36 | 36 | // If comparing revisions, make sure we're dealing with the right post parent. |
37 | 37 | // The parent post may be a 'revision' when revisions are disabled and we're looking at autosaves. |
38 | - if ( $compare_from && $compare_from->post_parent !== $post->ID && $compare_from->ID !== $post->ID ) |
|
38 | + if ($compare_from && $compare_from->post_parent !== $post->ID && $compare_from->ID !== $post->ID) |
|
39 | 39 | return false; |
40 | - if ( $compare_to->post_parent !== $post->ID && $compare_to->ID !== $post->ID ) |
|
40 | + if ($compare_to->post_parent !== $post->ID && $compare_to->ID !== $post->ID) |
|
41 | 41 | return false; |
42 | 42 | |
43 | - if ( $compare_from && strtotime( $compare_from->post_date_gmt ) > strtotime( $compare_to->post_date_gmt ) ) { |
|
43 | + if ($compare_from && strtotime($compare_from->post_date_gmt) > strtotime($compare_to->post_date_gmt)) { |
|
44 | 44 | $temp = $compare_from; |
45 | 45 | $compare_from = $compare_to; |
46 | 46 | $compare_to = $temp; |
47 | 47 | } |
48 | 48 | |
49 | 49 | // Add default title if title field is empty |
50 | - if ( $compare_from && empty( $compare_from->post_title ) ) |
|
51 | - $compare_from->post_title = __( '(no title)' ); |
|
52 | - if ( empty( $compare_to->post_title ) ) |
|
53 | - $compare_to->post_title = __( '(no title)' ); |
|
50 | + if ($compare_from && empty($compare_from->post_title)) |
|
51 | + $compare_from->post_title = __('(no title)'); |
|
52 | + if (empty($compare_to->post_title)) |
|
53 | + $compare_to->post_title = __('(no title)'); |
|
54 | 54 | |
55 | 55 | $return = array(); |
56 | 56 | |
57 | - foreach ( _wp_post_revision_fields() as $field => $name ) { |
|
57 | + foreach (_wp_post_revision_fields() as $field => $name) { |
|
58 | 58 | /** |
59 | 59 | * Contextually filter a post revision field. |
60 | 60 | * |
@@ -69,10 +69,10 @@ discard block |
||
69 | 69 | * @param string null The context of whether the current revision is the old |
70 | 70 | * or the new one. Values are 'to' or 'from'. |
71 | 71 | */ |
72 | - $content_from = $compare_from ? apply_filters( "_wp_post_revision_field_$field", $compare_from->$field, $field, $compare_from, 'from' ) : ''; |
|
72 | + $content_from = $compare_from ? apply_filters("_wp_post_revision_field_$field", $compare_from->$field, $field, $compare_from, 'from') : ''; |
|
73 | 73 | |
74 | 74 | /** This filter is documented in wp-admin/includes/revision.php */ |
75 | - $content_to = apply_filters( "_wp_post_revision_field_$field", $compare_to->$field, $field, $compare_to, 'to' ); |
|
75 | + $content_to = apply_filters("_wp_post_revision_field_$field", $compare_to->$field, $field, $compare_to, 'to'); |
|
76 | 76 | |
77 | 77 | $args = array( |
78 | 78 | 'show_split_view' => true |
@@ -95,20 +95,20 @@ discard block |
||
95 | 95 | * @param WP_Post $compare_from The revision post to compare from. |
96 | 96 | * @param WP_Post $compare_to The revision post to compare to. |
97 | 97 | */ |
98 | - $args = apply_filters( 'revision_text_diff_options', $args, $field, $compare_from, $compare_to ); |
|
98 | + $args = apply_filters('revision_text_diff_options', $args, $field, $compare_from, $compare_to); |
|
99 | 99 | |
100 | - $diff = wp_text_diff( $content_from, $content_to, $args ); |
|
100 | + $diff = wp_text_diff($content_from, $content_to, $args); |
|
101 | 101 | |
102 | - if ( ! $diff && 'post_title' === $field ) { |
|
102 | + if ( ! $diff && 'post_title' === $field) { |
|
103 | 103 | // It's a better user experience to still show the Title, even if it didn't change. |
104 | 104 | // No, you didn't see this. |
105 | 105 | $diff = '<table class="diff"><colgroup><col class="content diffsplit left"><col class="content diffsplit middle"><col class="content diffsplit right"></colgroup><tbody><tr>'; |
106 | - $diff .= '<td>' . esc_html( $compare_from->post_title ) . '</td><td></td><td>' . esc_html( $compare_to->post_title ) . '</td>'; |
|
106 | + $diff .= '<td>'.esc_html($compare_from->post_title).'</td><td></td><td>'.esc_html($compare_to->post_title).'</td>'; |
|
107 | 107 | $diff .= '</tr></tbody>'; |
108 | 108 | $diff .= '</table>'; |
109 | 109 | } |
110 | 110 | |
111 | - if ( $diff ) { |
|
111 | + if ($diff) { |
|
112 | 112 | $return[] = array( |
113 | 113 | 'id' => $field, |
114 | 114 | 'name' => $name, |
@@ -126,7 +126,7 @@ discard block |
||
126 | 126 | * @param WP_Post $compare_from The revision post to compare from. |
127 | 127 | * @param WP_Post $compare_to The revision post to compare to. |
128 | 128 | */ |
129 | - return apply_filters( 'wp_get_revision_ui_diff', $return, $compare_from, $compare_to ); |
|
129 | + return apply_filters('wp_get_revision_ui_diff', $return, $compare_from, $compare_to); |
|
130 | 130 | |
131 | 131 | } |
132 | 132 | |
@@ -141,71 +141,71 @@ discard block |
||
141 | 141 | * |
142 | 142 | * @return array An associative array of revision data and related settings. |
143 | 143 | */ |
144 | -function wp_prepare_revisions_for_js( $post, $selected_revision_id, $from = null ) { |
|
145 | - $post = get_post( $post ); |
|
144 | +function wp_prepare_revisions_for_js($post, $selected_revision_id, $from = null) { |
|
145 | + $post = get_post($post); |
|
146 | 146 | $authors = array(); |
147 | 147 | $now_gmt = time(); |
148 | 148 | |
149 | - $revisions = wp_get_post_revisions( $post->ID, array( 'order' => 'ASC', 'check_enabled' => false ) ); |
|
149 | + $revisions = wp_get_post_revisions($post->ID, array('order' => 'ASC', 'check_enabled' => false)); |
|
150 | 150 | // If revisions are disabled, we only want autosaves and the current post. |
151 | - if ( ! wp_revisions_enabled( $post ) ) { |
|
152 | - foreach ( $revisions as $revision_id => $revision ) { |
|
153 | - if ( ! wp_is_post_autosave( $revision ) ) |
|
154 | - unset( $revisions[ $revision_id ] ); |
|
151 | + if ( ! wp_revisions_enabled($post)) { |
|
152 | + foreach ($revisions as $revision_id => $revision) { |
|
153 | + if ( ! wp_is_post_autosave($revision)) |
|
154 | + unset($revisions[$revision_id]); |
|
155 | 155 | } |
156 | - $revisions = array( $post->ID => $post ) + $revisions; |
|
156 | + $revisions = array($post->ID => $post) + $revisions; |
|
157 | 157 | } |
158 | 158 | |
159 | - $show_avatars = get_option( 'show_avatars' ); |
|
159 | + $show_avatars = get_option('show_avatars'); |
|
160 | 160 | |
161 | - cache_users( wp_list_pluck( $revisions, 'post_author' ) ); |
|
161 | + cache_users(wp_list_pluck($revisions, 'post_author')); |
|
162 | 162 | |
163 | - $can_restore = current_user_can( 'edit_post', $post->ID ); |
|
163 | + $can_restore = current_user_can('edit_post', $post->ID); |
|
164 | 164 | $current_id = false; |
165 | 165 | |
166 | - foreach ( $revisions as $revision ) { |
|
167 | - $modified = strtotime( $revision->post_modified ); |
|
168 | - $modified_gmt = strtotime( $revision->post_modified_gmt ); |
|
169 | - if ( $can_restore ) { |
|
170 | - $restore_link = str_replace( '&', '&', wp_nonce_url( |
|
166 | + foreach ($revisions as $revision) { |
|
167 | + $modified = strtotime($revision->post_modified); |
|
168 | + $modified_gmt = strtotime($revision->post_modified_gmt); |
|
169 | + if ($can_restore) { |
|
170 | + $restore_link = str_replace('&', '&', wp_nonce_url( |
|
171 | 171 | add_query_arg( |
172 | - array( 'revision' => $revision->ID, |
|
173 | - 'action' => 'restore' ), |
|
174 | - admin_url( 'revision.php' ) |
|
172 | + array('revision' => $revision->ID, |
|
173 | + 'action' => 'restore'), |
|
174 | + admin_url('revision.php') |
|
175 | 175 | ), |
176 | 176 | "restore-post_{$revision->ID}" |
177 | - ) ); |
|
177 | + )); |
|
178 | 178 | } |
179 | 179 | |
180 | - if ( ! isset( $authors[ $revision->post_author ] ) ) { |
|
181 | - $authors[ $revision->post_author ] = array( |
|
180 | + if ( ! isset($authors[$revision->post_author])) { |
|
181 | + $authors[$revision->post_author] = array( |
|
182 | 182 | 'id' => (int) $revision->post_author, |
183 | - 'avatar' => $show_avatars ? get_avatar( $revision->post_author, 32 ) : '', |
|
184 | - 'name' => get_the_author_meta( 'display_name', $revision->post_author ), |
|
183 | + 'avatar' => $show_avatars ? get_avatar($revision->post_author, 32) : '', |
|
184 | + 'name' => get_the_author_meta('display_name', $revision->post_author), |
|
185 | 185 | ); |
186 | 186 | } |
187 | 187 | |
188 | - $autosave = (bool) wp_is_post_autosave( $revision ); |
|
188 | + $autosave = (bool) wp_is_post_autosave($revision); |
|
189 | 189 | $current = ! $autosave && $revision->post_modified_gmt === $post->post_modified_gmt; |
190 | - if ( $current && ! empty( $current_id ) ) { |
|
190 | + if ($current && ! empty($current_id)) { |
|
191 | 191 | // If multiple revisions have the same post_modified_gmt, highest ID is current. |
192 | - if ( $current_id < $revision->ID ) { |
|
193 | - $revisions[ $current_id ]['current'] = false; |
|
192 | + if ($current_id < $revision->ID) { |
|
193 | + $revisions[$current_id]['current'] = false; |
|
194 | 194 | $current_id = $revision->ID; |
195 | 195 | } else { |
196 | 196 | $current = false; |
197 | 197 | } |
198 | - } elseif ( $current ) { |
|
198 | + } elseif ($current) { |
|
199 | 199 | $current_id = $revision->ID; |
200 | 200 | } |
201 | 201 | |
202 | - $revisions[ $revision->ID ] = array( |
|
202 | + $revisions[$revision->ID] = array( |
|
203 | 203 | 'id' => $revision->ID, |
204 | - 'title' => get_the_title( $post->ID ), |
|
205 | - 'author' => $authors[ $revision->post_author ], |
|
206 | - 'date' => date_i18n( __( 'M j, Y @ H:i' ), $modified ), |
|
207 | - 'dateShort' => date_i18n( _x( 'j M @ H:i', 'revision date short format' ), $modified ), |
|
208 | - 'timeAgo' => sprintf( __( '%s ago' ), human_time_diff( $modified_gmt, $now_gmt ) ), |
|
204 | + 'title' => get_the_title($post->ID), |
|
205 | + 'author' => $authors[$revision->post_author], |
|
206 | + 'date' => date_i18n(__('M j, Y @ H:i'), $modified), |
|
207 | + 'dateShort' => date_i18n(_x('j M @ H:i', 'revision date short format'), $modified), |
|
208 | + 'timeAgo' => sprintf(__('%s ago'), human_time_diff($modified_gmt, $now_gmt)), |
|
209 | 209 | 'autosave' => $autosave, |
210 | 210 | 'current' => $current, |
211 | 211 | 'restoreUrl' => $can_restore ? $restore_link : false, |
@@ -216,14 +216,14 @@ discard block |
||
216 | 216 | * If we only have one revision, the initial revision is missing; This happens |
217 | 217 | * when we have an autsosave and the user has clicked 'View the Autosave' |
218 | 218 | */ |
219 | - if ( 1 === sizeof( $revisions ) ) { |
|
220 | - $revisions[ $post->ID ] = array( |
|
219 | + if (1 === sizeof($revisions)) { |
|
220 | + $revisions[$post->ID] = array( |
|
221 | 221 | 'id' => $post->ID, |
222 | - 'title' => get_the_title( $post->ID ), |
|
223 | - 'author' => $authors[ $post->post_author ], |
|
224 | - 'date' => date_i18n( __( 'M j, Y @ H:i' ), strtotime( $post->post_modified ) ), |
|
225 | - 'dateShort' => date_i18n( _x( 'j M @ H:i', 'revision date short format' ), strtotime( $post->post_modified ) ), |
|
226 | - 'timeAgo' => sprintf( __( '%s ago' ), human_time_diff( strtotime( $post->post_modified_gmt ), $now_gmt ) ), |
|
222 | + 'title' => get_the_title($post->ID), |
|
223 | + 'author' => $authors[$post->post_author], |
|
224 | + 'date' => date_i18n(__('M j, Y @ H:i'), strtotime($post->post_modified)), |
|
225 | + 'dateShort' => date_i18n(_x('j M @ H:i', 'revision date short format'), strtotime($post->post_modified)), |
|
226 | + 'timeAgo' => sprintf(__('%s ago'), human_time_diff(strtotime($post->post_modified_gmt), $now_gmt)), |
|
227 | 227 | 'autosave' => false, |
228 | 228 | 'current' => true, |
229 | 229 | 'restoreUrl' => false, |
@@ -236,48 +236,48 @@ discard block |
||
236 | 236 | * were changed), we may not have a "current" revision. Mark the latest |
237 | 237 | * revision as "current". |
238 | 238 | */ |
239 | - if ( empty( $current_id ) ) { |
|
240 | - if ( $revisions[ $revision->ID ]['autosave'] ) { |
|
241 | - $revision = end( $revisions ); |
|
242 | - while ( $revision['autosave'] ) { |
|
243 | - $revision = prev( $revisions ); |
|
239 | + if (empty($current_id)) { |
|
240 | + if ($revisions[$revision->ID]['autosave']) { |
|
241 | + $revision = end($revisions); |
|
242 | + while ($revision['autosave']) { |
|
243 | + $revision = prev($revisions); |
|
244 | 244 | } |
245 | 245 | $current_id = $revision['id']; |
246 | 246 | } else { |
247 | 247 | $current_id = $revision->ID; |
248 | 248 | } |
249 | - $revisions[ $current_id ]['current'] = true; |
|
249 | + $revisions[$current_id]['current'] = true; |
|
250 | 250 | } |
251 | 251 | |
252 | 252 | // Now, grab the initial diff. |
253 | - $compare_two_mode = is_numeric( $from ); |
|
254 | - if ( ! $compare_two_mode ) { |
|
255 | - $found = array_search( $selected_revision_id, array_keys( $revisions ) ); |
|
256 | - if ( $found ) { |
|
257 | - $from = array_keys( array_slice( $revisions, $found - 1, 1, true ) ); |
|
258 | - $from = reset( $from ); |
|
253 | + $compare_two_mode = is_numeric($from); |
|
254 | + if ( ! $compare_two_mode) { |
|
255 | + $found = array_search($selected_revision_id, array_keys($revisions)); |
|
256 | + if ($found) { |
|
257 | + $from = array_keys(array_slice($revisions, $found - 1, 1, true)); |
|
258 | + $from = reset($from); |
|
259 | 259 | } else { |
260 | 260 | $from = 0; |
261 | 261 | } |
262 | 262 | } |
263 | 263 | |
264 | - $from = absint( $from ); |
|
264 | + $from = absint($from); |
|
265 | 265 | |
266 | - $diffs = array( array( |
|
267 | - 'id' => $from . ':' . $selected_revision_id, |
|
268 | - 'fields' => wp_get_revision_ui_diff( $post->ID, $from, $selected_revision_id ), |
|
266 | + $diffs = array(array( |
|
267 | + 'id' => $from.':'.$selected_revision_id, |
|
268 | + 'fields' => wp_get_revision_ui_diff($post->ID, $from, $selected_revision_id), |
|
269 | 269 | )); |
270 | 270 | |
271 | 271 | return array( |
272 | 272 | 'postId' => $post->ID, |
273 | - 'nonce' => wp_create_nonce( 'revisions-ajax-nonce' ), |
|
274 | - 'revisionData' => array_values( $revisions ), |
|
273 | + 'nonce' => wp_create_nonce('revisions-ajax-nonce'), |
|
274 | + 'revisionData' => array_values($revisions), |
|
275 | 275 | 'to' => $selected_revision_id, |
276 | 276 | 'from' => $from, |
277 | 277 | 'diffData' => $diffs, |
278 | - 'baseUrl' => parse_url( admin_url( 'revision.php' ), PHP_URL_PATH ), |
|
279 | - 'compareTwoMode' => absint( $compare_two_mode ), // Apparently booleans are not allowed |
|
280 | - 'revisionIds' => array_keys( $revisions ), |
|
278 | + 'baseUrl' => parse_url(admin_url('revision.php'), PHP_URL_PATH), |
|
279 | + 'compareTwoMode' => absint($compare_two_mode), // Apparently booleans are not allowed |
|
280 | + 'revisionIds' => array_keys($revisions), |
|
281 | 281 | ); |
282 | 282 | } |
283 | 283 | |
@@ -297,11 +297,11 @@ discard block |
||
297 | 297 | |
298 | 298 | <script id="tmpl-revisions-buttons" type="text/html"> |
299 | 299 | <div class="revisions-previous"> |
300 | - <input class="button" type="button" value="<?php echo esc_attr_x( 'Previous', 'Button label for a previous revision' ); ?>" /> |
|
300 | + <input class="button" type="button" value="<?php echo esc_attr_x('Previous', 'Button label for a previous revision'); ?>" /> |
|
301 | 301 | </div> |
302 | 302 | |
303 | 303 | <div class="revisions-next"> |
304 | - <input class="button" type="button" value="<?php echo esc_attr_x( 'Next', 'Button label for a next revision' ); ?>" /> |
|
304 | + <input class="button" type="button" value="<?php echo esc_attr_x('Next', 'Button label for a next revision'); ?>" /> |
|
305 | 305 | </div> |
306 | 306 | </script> |
307 | 307 | |
@@ -315,7 +315,7 @@ discard block |
||
315 | 315 | } |
316 | 316 | #> |
317 | 317 | /> |
318 | - <?php esc_attr_e( 'Compare any two revisions' ); ?> |
|
318 | + <?php esc_attr_e('Compare any two revisions'); ?> |
|
319 | 319 | </label> |
320 | 320 | </div> |
321 | 321 | </script> |
@@ -324,28 +324,28 @@ discard block |
||
324 | 324 | <# if ( ! _.isUndefined( data.attributes ) ) { #> |
325 | 325 | <div class="diff-title"> |
326 | 326 | <# if ( 'from' === data.type ) { #> |
327 | - <strong><?php _ex( 'From:', 'Followed by post revision info' ); ?></strong> |
|
327 | + <strong><?php _ex('From:', 'Followed by post revision info'); ?></strong> |
|
328 | 328 | <# } else if ( 'to' === data.type ) { #> |
329 | - <strong><?php _ex( 'To:', 'Followed by post revision info' ); ?></strong> |
|
329 | + <strong><?php _ex('To:', 'Followed by post revision info'); ?></strong> |
|
330 | 330 | <# } #> |
331 | 331 | <div class="author-card<# if ( data.attributes.autosave ) { #> autosave<# } #>"> |
332 | 332 | {{{ data.attributes.author.avatar }}} |
333 | 333 | <div class="author-info"> |
334 | 334 | <# if ( data.attributes.autosave ) { #> |
335 | - <span class="byline"><?php printf( __( 'Autosave by %s' ), |
|
336 | - '<span class="author-name">{{ data.attributes.author.name }}</span>' ); ?></span> |
|
335 | + <span class="byline"><?php printf(__('Autosave by %s'), |
|
336 | + '<span class="author-name">{{ data.attributes.author.name }}</span>'); ?></span> |
|
337 | 337 | <# } else if ( data.attributes.current ) { #> |
338 | - <span class="byline"><?php printf( __( 'Current Revision by %s' ), |
|
339 | - '<span class="author-name">{{ data.attributes.author.name }}</span>' ); ?></span> |
|
338 | + <span class="byline"><?php printf(__('Current Revision by %s'), |
|
339 | + '<span class="author-name">{{ data.attributes.author.name }}</span>'); ?></span> |
|
340 | 340 | <# } else { #> |
341 | - <span class="byline"><?php printf( __( 'Revision by %s' ), |
|
342 | - '<span class="author-name">{{ data.attributes.author.name }}</span>' ); ?></span> |
|
341 | + <span class="byline"><?php printf(__('Revision by %s'), |
|
342 | + '<span class="author-name">{{ data.attributes.author.name }}</span>'); ?></span> |
|
343 | 343 | <# } #> |
344 | 344 | <span class="time-ago">{{ data.attributes.timeAgo }}</span> |
345 | 345 | <span class="date">({{ data.attributes.dateShort }})</span> |
346 | 346 | </div> |
347 | 347 | <# if ( 'to' === data.type && data.attributes.restoreUrl ) { #> |
348 | - <input <?php if ( wp_check_post_lock( $post->ID ) ) { ?> |
|
348 | + <input <?php if (wp_check_post_lock($post->ID)) { ?> |
|
349 | 349 | disabled="disabled" |
350 | 350 | <?php } else { ?> |
351 | 351 | <# if ( data.attributes.current ) { #> |
@@ -353,9 +353,9 @@ discard block |
||
353 | 353 | <# } #> |
354 | 354 | <?php } ?> |
355 | 355 | <# if ( data.attributes.autosave ) { #> |
356 | - type="button" class="restore-revision button button-primary" value="<?php esc_attr_e( 'Restore This Autosave' ); ?>" /> |
|
356 | + type="button" class="restore-revision button button-primary" value="<?php esc_attr_e('Restore This Autosave'); ?>" /> |
|
357 | 357 | <# } else { #> |
358 | - type="button" class="restore-revision button button-primary" value="<?php esc_attr_e( 'Restore This Revision' ); ?>" /> |
|
358 | + type="button" class="restore-revision button button-primary" value="<?php esc_attr_e('Restore This Revision'); ?>" /> |
|
359 | 359 | <# } #> |
360 | 360 | <# } #> |
361 | 361 | </div> |
@@ -367,7 +367,7 @@ discard block |
||
367 | 367 | |
368 | 368 | <script id="tmpl-revisions-diff" type="text/html"> |
369 | 369 | <div class="loading-indicator"><span class="spinner"></span></div> |
370 | - <div class="diff-error"><?php _e( 'Sorry, something went wrong. The requested comparison could not be loaded.' ); ?></div> |
|
370 | + <div class="diff-error"><?php _e('Sorry, something went wrong. The requested comparison could not be loaded.'); ?></div> |
|
371 | 371 | <div class="diff"> |
372 | 372 | <# _.each( data.fields, function( field ) { #> |
373 | 373 | <h3>{{ field.name }}</h3> |
@@ -19,26 +19,31 @@ discard block |
||
19 | 19 | * Or, false on failure. |
20 | 20 | */ |
21 | 21 | function wp_get_revision_ui_diff( $post, $compare_from, $compare_to ) { |
22 | - if ( ! $post = get_post( $post ) ) |
|
23 | - return false; |
|
22 | + if ( ! $post = get_post( $post ) ) { |
|
23 | + return false; |
|
24 | + } |
|
24 | 25 | |
25 | 26 | if ( $compare_from ) { |
26 | - if ( ! $compare_from = get_post( $compare_from ) ) |
|
27 | - return false; |
|
27 | + if ( ! $compare_from = get_post( $compare_from ) ) { |
|
28 | + return false; |
|
29 | + } |
|
28 | 30 | } else { |
29 | 31 | // If we're dealing with the first revision... |
30 | 32 | $compare_from = false; |
31 | 33 | } |
32 | 34 | |
33 | - if ( ! $compare_to = get_post( $compare_to ) ) |
|
34 | - return false; |
|
35 | + if ( ! $compare_to = get_post( $compare_to ) ) { |
|
36 | + return false; |
|
37 | + } |
|
35 | 38 | |
36 | 39 | // If comparing revisions, make sure we're dealing with the right post parent. |
37 | 40 | // The parent post may be a 'revision' when revisions are disabled and we're looking at autosaves. |
38 | - if ( $compare_from && $compare_from->post_parent !== $post->ID && $compare_from->ID !== $post->ID ) |
|
39 | - return false; |
|
40 | - if ( $compare_to->post_parent !== $post->ID && $compare_to->ID !== $post->ID ) |
|
41 | - return false; |
|
41 | + if ( $compare_from && $compare_from->post_parent !== $post->ID && $compare_from->ID !== $post->ID ) { |
|
42 | + return false; |
|
43 | + } |
|
44 | + if ( $compare_to->post_parent !== $post->ID && $compare_to->ID !== $post->ID ) { |
|
45 | + return false; |
|
46 | + } |
|
42 | 47 | |
43 | 48 | if ( $compare_from && strtotime( $compare_from->post_date_gmt ) > strtotime( $compare_to->post_date_gmt ) ) { |
44 | 49 | $temp = $compare_from; |
@@ -47,10 +52,12 @@ discard block |
||
47 | 52 | } |
48 | 53 | |
49 | 54 | // Add default title if title field is empty |
50 | - if ( $compare_from && empty( $compare_from->post_title ) ) |
|
51 | - $compare_from->post_title = __( '(no title)' ); |
|
52 | - if ( empty( $compare_to->post_title ) ) |
|
53 | - $compare_to->post_title = __( '(no title)' ); |
|
55 | + if ( $compare_from && empty( $compare_from->post_title ) ) { |
|
56 | + $compare_from->post_title = __( '(no title)' ); |
|
57 | + } |
|
58 | + if ( empty( $compare_to->post_title ) ) { |
|
59 | + $compare_to->post_title = __( '(no title)' ); |
|
60 | + } |
|
54 | 61 | |
55 | 62 | $return = array(); |
56 | 63 | |
@@ -150,8 +157,9 @@ discard block |
||
150 | 157 | // If revisions are disabled, we only want autosaves and the current post. |
151 | 158 | if ( ! wp_revisions_enabled( $post ) ) { |
152 | 159 | foreach ( $revisions as $revision_id => $revision ) { |
153 | - if ( ! wp_is_post_autosave( $revision ) ) |
|
154 | - unset( $revisions[ $revision_id ] ); |
|
160 | + if ( ! wp_is_post_autosave( $revision ) ) { |
|
161 | + unset( $revisions[ $revision_id ] ); |
|
162 | + } |
|
155 | 163 | } |
156 | 164 | $revisions = array( $post->ID => $post ) + $revisions; |
157 | 165 | } |
@@ -1,12 +1,12 @@ |
||
1 | 1 | <?php |
2 | 2 | /** |
3 | - * Administration hooks |
|
4 | - * |
|
5 | - * @package WordPress |
|
6 | - * @subpackage Hooks |
|
7 | - * |
|
8 | - * @since 4.3.0 |
|
9 | - */ |
|
3 | + * Administration hooks |
|
4 | + * |
|
5 | + * @package WordPress |
|
6 | + * @subpackage Hooks |
|
7 | + * |
|
8 | + * @since 4.3.0 |
|
9 | + */ |
|
10 | 10 | |
11 | 11 | // Bookmark hooks. |
12 | 12 | add_action( 'admin_page_access_denied', 'wp_link_manager_disabled_message' ); |
@@ -9,77 +9,77 @@ discard block |
||
9 | 9 | */ |
10 | 10 | |
11 | 11 | // Bookmark hooks. |
12 | -add_action( 'admin_page_access_denied', 'wp_link_manager_disabled_message' ); |
|
12 | +add_action('admin_page_access_denied', 'wp_link_manager_disabled_message'); |
|
13 | 13 | |
14 | 14 | // Dashboard hooks. |
15 | -add_action( 'activity_box_end', 'wp_dashboard_quota' ); |
|
15 | +add_action('activity_box_end', 'wp_dashboard_quota'); |
|
16 | 16 | |
17 | 17 | // Media hooks. |
18 | -add_action( 'attachment_submitbox_misc_actions', 'attachment_submitbox_metadata' ); |
|
18 | +add_action('attachment_submitbox_misc_actions', 'attachment_submitbox_metadata'); |
|
19 | 19 | |
20 | -add_action( 'media_upload_image', 'wp_media_upload_handler' ); |
|
21 | -add_action( 'media_upload_audio', 'wp_media_upload_handler' ); |
|
22 | -add_action( 'media_upload_video', 'wp_media_upload_handler' ); |
|
23 | -add_action( 'media_upload_file', 'wp_media_upload_handler' ); |
|
20 | +add_action('media_upload_image', 'wp_media_upload_handler'); |
|
21 | +add_action('media_upload_audio', 'wp_media_upload_handler'); |
|
22 | +add_action('media_upload_video', 'wp_media_upload_handler'); |
|
23 | +add_action('media_upload_file', 'wp_media_upload_handler'); |
|
24 | 24 | |
25 | -add_action( 'post-plupload-upload-ui', 'media_upload_flash_bypass' ); |
|
25 | +add_action('post-plupload-upload-ui', 'media_upload_flash_bypass'); |
|
26 | 26 | |
27 | -add_action( 'post-html-upload-ui', 'media_upload_html_bypass' ); |
|
27 | +add_action('post-html-upload-ui', 'media_upload_html_bypass'); |
|
28 | 28 | |
29 | -add_filter( 'async_upload_image', 'get_media_item', 10, 2 ); |
|
30 | -add_filter( 'async_upload_audio', 'get_media_item', 10, 2 ); |
|
31 | -add_filter( 'async_upload_video', 'get_media_item', 10, 2 ); |
|
32 | -add_filter( 'async_upload_file', 'get_media_item', 10, 2 ); |
|
29 | +add_filter('async_upload_image', 'get_media_item', 10, 2); |
|
30 | +add_filter('async_upload_audio', 'get_media_item', 10, 2); |
|
31 | +add_filter('async_upload_video', 'get_media_item', 10, 2); |
|
32 | +add_filter('async_upload_file', 'get_media_item', 10, 2); |
|
33 | 33 | |
34 | -add_filter( 'attachment_fields_to_save', 'image_attachment_fields_to_save', 10, 2 ); |
|
34 | +add_filter('attachment_fields_to_save', 'image_attachment_fields_to_save', 10, 2); |
|
35 | 35 | |
36 | -add_filter( 'media_upload_gallery', 'media_upload_gallery' ); |
|
37 | -add_filter( 'media_upload_library', 'media_upload_library' ); |
|
36 | +add_filter('media_upload_gallery', 'media_upload_gallery'); |
|
37 | +add_filter('media_upload_library', 'media_upload_library'); |
|
38 | 38 | |
39 | -add_filter( 'media_upload_tabs', 'update_gallery_tab' ); |
|
39 | +add_filter('media_upload_tabs', 'update_gallery_tab'); |
|
40 | 40 | |
41 | 41 | // Misc hooks. |
42 | -add_action( 'admin_head', 'wp_admin_canonical_url' ); |
|
43 | -add_action( 'admin_head', 'wp_color_scheme_settings' ); |
|
44 | -add_action( 'admin_head', 'wp_site_icon' ); |
|
45 | -add_action( 'admin_head', '_ipad_meta' ); |
|
42 | +add_action('admin_head', 'wp_admin_canonical_url'); |
|
43 | +add_action('admin_head', 'wp_color_scheme_settings'); |
|
44 | +add_action('admin_head', 'wp_site_icon'); |
|
45 | +add_action('admin_head', '_ipad_meta'); |
|
46 | 46 | |
47 | -add_action( 'post_edit_form_tag', 'post_form_autocomplete_off' ); |
|
47 | +add_action('post_edit_form_tag', 'post_form_autocomplete_off'); |
|
48 | 48 | |
49 | -add_action( 'update_option_home', 'update_home_siteurl', 10, 2 ); |
|
50 | -add_action( 'update_option_siteurl', 'update_home_siteurl', 10, 2 ); |
|
51 | -add_action( 'update_option_page_on_front', 'update_home_siteurl', 10, 2 ); |
|
49 | +add_action('update_option_home', 'update_home_siteurl', 10, 2); |
|
50 | +add_action('update_option_siteurl', 'update_home_siteurl', 10, 2); |
|
51 | +add_action('update_option_page_on_front', 'update_home_siteurl', 10, 2); |
|
52 | 52 | |
53 | -add_filter( 'heartbeat_received', 'wp_check_locked_posts', 10, 3 ); |
|
54 | -add_filter( 'heartbeat_received', 'wp_refresh_post_lock', 10, 3 ); |
|
55 | -add_filter( 'wp_refresh_nonces', 'wp_refresh_post_nonces', 10, 3 ); |
|
56 | -add_filter( 'heartbeat_received', 'heartbeat_autosave', 500, 2 ); |
|
53 | +add_filter('heartbeat_received', 'wp_check_locked_posts', 10, 3); |
|
54 | +add_filter('heartbeat_received', 'wp_refresh_post_lock', 10, 3); |
|
55 | +add_filter('wp_refresh_nonces', 'wp_refresh_post_nonces', 10, 3); |
|
56 | +add_filter('heartbeat_received', 'heartbeat_autosave', 500, 2); |
|
57 | 57 | |
58 | -add_filter( 'heartbeat_settings', 'wp_heartbeat_set_suspension' ); |
|
58 | +add_filter('heartbeat_settings', 'wp_heartbeat_set_suspension'); |
|
59 | 59 | |
60 | 60 | // Nav Menu hooks. |
61 | -add_action( 'admin_head-nav-menus.php', '_wp_delete_orphaned_draft_menu_items' ); |
|
61 | +add_action('admin_head-nav-menus.php', '_wp_delete_orphaned_draft_menu_items'); |
|
62 | 62 | |
63 | 63 | // Plugin hooks. |
64 | -add_filter( 'whitelist_options', 'option_update_filter' ); |
|
64 | +add_filter('whitelist_options', 'option_update_filter'); |
|
65 | 65 | |
66 | 66 | // Plugin Install hooks. |
67 | -add_action( 'install_plugins_featured', 'install_dashboard' ); |
|
68 | -add_action( 'install_plugins_upload', 'install_plugins_upload' ); |
|
69 | -add_action( 'install_plugins_search', 'display_plugins_table' ); |
|
70 | -add_action( 'install_plugins_popular', 'display_plugins_table' ); |
|
71 | -add_action( 'install_plugins_recommended', 'display_plugins_table' ); |
|
72 | -add_action( 'install_plugins_new', 'display_plugins_table' ); |
|
73 | -add_action( 'install_plugins_beta', 'display_plugins_table' ); |
|
74 | -add_action( 'install_plugins_favorites', 'display_plugins_table' ); |
|
75 | -add_action( 'install_plugins_pre_plugin-information', 'install_plugin_information' ); |
|
67 | +add_action('install_plugins_featured', 'install_dashboard'); |
|
68 | +add_action('install_plugins_upload', 'install_plugins_upload'); |
|
69 | +add_action('install_plugins_search', 'display_plugins_table'); |
|
70 | +add_action('install_plugins_popular', 'display_plugins_table'); |
|
71 | +add_action('install_plugins_recommended', 'display_plugins_table'); |
|
72 | +add_action('install_plugins_new', 'display_plugins_table'); |
|
73 | +add_action('install_plugins_beta', 'display_plugins_table'); |
|
74 | +add_action('install_plugins_favorites', 'display_plugins_table'); |
|
75 | +add_action('install_plugins_pre_plugin-information', 'install_plugin_information'); |
|
76 | 76 | |
77 | 77 | // Template hooks. |
78 | -add_action( 'admin_enqueue_scripts', array( 'WP_Internal_Pointers', 'enqueue_scripts' ) ); |
|
79 | -add_action( 'user_register', array( 'WP_Internal_Pointers', 'dismiss_pointers_for_new_users' ) ); |
|
78 | +add_action('admin_enqueue_scripts', array('WP_Internal_Pointers', 'enqueue_scripts')); |
|
79 | +add_action('user_register', array('WP_Internal_Pointers', 'dismiss_pointers_for_new_users')); |
|
80 | 80 | |
81 | 81 | // Theme hooks. |
82 | -add_action( 'customize_controls_print_footer_scripts', 'customize_themes_print_templates' ); |
|
82 | +add_action('customize_controls_print_footer_scripts', 'customize_themes_print_templates'); |
|
83 | 83 | |
84 | 84 | // Theme Install hooks. |
85 | 85 | // add_action('install_themes_dashboard', 'install_themes_dashboard'); |
@@ -88,26 +88,26 @@ discard block |
||
88 | 88 | // add_action('install_themes_featured', 'display_themes'); |
89 | 89 | // add_action('install_themes_new', 'display_themes'); |
90 | 90 | // add_action('install_themes_updated', 'display_themes'); |
91 | -add_action( 'install_themes_pre_theme-information', 'install_theme_information' ); |
|
91 | +add_action('install_themes_pre_theme-information', 'install_theme_information'); |
|
92 | 92 | |
93 | 93 | // User hooks. |
94 | -add_action( 'admin_init', 'default_password_nag_handler' ); |
|
94 | +add_action('admin_init', 'default_password_nag_handler'); |
|
95 | 95 | |
96 | -add_action( 'admin_notices', 'default_password_nag' ); |
|
96 | +add_action('admin_notices', 'default_password_nag'); |
|
97 | 97 | |
98 | -add_action( 'profile_update', 'default_password_nag_edit_user', 10, 2 ); |
|
98 | +add_action('profile_update', 'default_password_nag_edit_user', 10, 2); |
|
99 | 99 | |
100 | 100 | // Update hooks. |
101 | -add_action( 'admin_init', 'wp_plugin_update_rows' ); |
|
102 | -add_action( 'admin_init', 'wp_theme_update_rows' ); |
|
101 | +add_action('admin_init', 'wp_plugin_update_rows'); |
|
102 | +add_action('admin_init', 'wp_theme_update_rows'); |
|
103 | 103 | |
104 | -add_action( 'admin_notices', 'update_nag', 3 ); |
|
105 | -add_action( 'admin_notices', 'maintenance_nag', 10 ); |
|
104 | +add_action('admin_notices', 'update_nag', 3); |
|
105 | +add_action('admin_notices', 'maintenance_nag', 10); |
|
106 | 106 | |
107 | -add_filter( 'update_footer', 'core_update_footer' ); |
|
107 | +add_filter('update_footer', 'core_update_footer'); |
|
108 | 108 | |
109 | 109 | // Update Core hooks. |
110 | -add_action( '_core_updated_successfully', '_redirect_to_about_wordpress' ); |
|
110 | +add_action('_core_updated_successfully', '_redirect_to_about_wordpress'); |
|
111 | 111 | |
112 | 112 | // Upgrade hooks. |
113 | -add_action( 'upgrader_process_complete', array( 'Language_Pack_Upgrader', 'async_upgrade' ), 20 ); |
|
113 | +add_action('upgrader_process_complete', array('Language_Pack_Upgrader', 'async_upgrade'), 20); |
@@ -54,7 +54,7 @@ |
||
54 | 54 | /** |
55 | 55 | * Check the current user's permissions. |
56 | 56 | * |
57 | - * @since 3.1.0 |
|
57 | + * @since 3.1.0 |
|
58 | 58 | * @access public |
59 | 59 | * |
60 | 60 | * @return bool |
@@ -38,17 +38,17 @@ discard block |
||
38 | 38 | * |
39 | 39 | * @param array $args An associative array of arguments. |
40 | 40 | */ |
41 | - public function __construct( $args = array() ) { |
|
42 | - parent::__construct( array( |
|
41 | + public function __construct($args = array()) { |
|
42 | + parent::__construct(array( |
|
43 | 43 | 'singular' => 'user', |
44 | 44 | 'plural' => 'users', |
45 | - 'screen' => isset( $args['screen'] ) ? $args['screen'] : null, |
|
46 | - ) ); |
|
45 | + 'screen' => isset($args['screen']) ? $args['screen'] : null, |
|
46 | + )); |
|
47 | 47 | |
48 | 48 | $this->is_site_users = 'site-users-network' == $this->screen->id; |
49 | 49 | |
50 | - if ( $this->is_site_users ) |
|
51 | - $this->site_id = isset( $_REQUEST['id'] ) ? intval( $_REQUEST['id'] ) : 0; |
|
50 | + if ($this->is_site_users) |
|
51 | + $this->site_id = isset($_REQUEST['id']) ? intval($_REQUEST['id']) : 0; |
|
52 | 52 | } |
53 | 53 | |
54 | 54 | /** |
@@ -60,10 +60,10 @@ discard block |
||
60 | 60 | * @return bool |
61 | 61 | */ |
62 | 62 | public function ajax_user_can() { |
63 | - if ( $this->is_site_users ) |
|
64 | - return current_user_can( 'manage_sites' ); |
|
63 | + if ($this->is_site_users) |
|
64 | + return current_user_can('manage_sites'); |
|
65 | 65 | else |
66 | - return current_user_can( 'list_users' ); |
|
66 | + return current_user_can('list_users'); |
|
67 | 67 | } |
68 | 68 | |
69 | 69 | /** |
@@ -78,44 +78,44 @@ discard block |
||
78 | 78 | public function prepare_items() { |
79 | 79 | global $role, $usersearch; |
80 | 80 | |
81 | - $usersearch = isset( $_REQUEST['s'] ) ? wp_unslash( trim( $_REQUEST['s'] ) ) : ''; |
|
81 | + $usersearch = isset($_REQUEST['s']) ? wp_unslash(trim($_REQUEST['s'])) : ''; |
|
82 | 82 | |
83 | - $role = isset( $_REQUEST['role'] ) ? $_REQUEST['role'] : ''; |
|
83 | + $role = isset($_REQUEST['role']) ? $_REQUEST['role'] : ''; |
|
84 | 84 | |
85 | - $per_page = ( $this->is_site_users ) ? 'site_users_network_per_page' : 'users_per_page'; |
|
86 | - $users_per_page = $this->get_items_per_page( $per_page ); |
|
85 | + $per_page = ($this->is_site_users) ? 'site_users_network_per_page' : 'users_per_page'; |
|
86 | + $users_per_page = $this->get_items_per_page($per_page); |
|
87 | 87 | |
88 | 88 | $paged = $this->get_pagenum(); |
89 | 89 | |
90 | 90 | $args = array( |
91 | 91 | 'number' => $users_per_page, |
92 | - 'offset' => ( $paged-1 ) * $users_per_page, |
|
92 | + 'offset' => ($paged - 1) * $users_per_page, |
|
93 | 93 | 'role' => $role, |
94 | 94 | 'search' => $usersearch, |
95 | 95 | 'fields' => 'all_with_meta' |
96 | 96 | ); |
97 | 97 | |
98 | - if ( '' !== $args['search'] ) |
|
99 | - $args['search'] = '*' . $args['search'] . '*'; |
|
98 | + if ('' !== $args['search']) |
|
99 | + $args['search'] = '*'.$args['search'].'*'; |
|
100 | 100 | |
101 | - if ( $this->is_site_users ) |
|
101 | + if ($this->is_site_users) |
|
102 | 102 | $args['blog_id'] = $this->site_id; |
103 | 103 | |
104 | - if ( isset( $_REQUEST['orderby'] ) ) |
|
104 | + if (isset($_REQUEST['orderby'])) |
|
105 | 105 | $args['orderby'] = $_REQUEST['orderby']; |
106 | 106 | |
107 | - if ( isset( $_REQUEST['order'] ) ) |
|
107 | + if (isset($_REQUEST['order'])) |
|
108 | 108 | $args['order'] = $_REQUEST['order']; |
109 | 109 | |
110 | 110 | // Query the user IDs for this page |
111 | - $wp_user_search = new WP_User_Query( $args ); |
|
111 | + $wp_user_search = new WP_User_Query($args); |
|
112 | 112 | |
113 | 113 | $this->items = $wp_user_search->get_results(); |
114 | 114 | |
115 | - $this->set_pagination_args( array( |
|
115 | + $this->set_pagination_args(array( |
|
116 | 116 | 'total_items' => $wp_user_search->get_total(), |
117 | 117 | 'per_page' => $users_per_page, |
118 | - ) ); |
|
118 | + )); |
|
119 | 119 | } |
120 | 120 | |
121 | 121 | /** |
@@ -125,7 +125,7 @@ discard block |
||
125 | 125 | * @access public |
126 | 126 | */ |
127 | 127 | public function no_items() { |
128 | - _e( 'No users found.' ); |
|
128 | + _e('No users found.'); |
|
129 | 129 | } |
130 | 130 | |
131 | 131 | /** |
@@ -147,9 +147,9 @@ discard block |
||
147 | 147 | |
148 | 148 | $wp_roles = wp_roles(); |
149 | 149 | |
150 | - if ( $this->is_site_users ) { |
|
151 | - $url = 'site-users.php?id=' . $this->site_id; |
|
152 | - switch_to_blog( $this->site_id ); |
|
150 | + if ($this->is_site_users) { |
|
151 | + $url = 'site-users.php?id='.$this->site_id; |
|
152 | + switch_to_blog($this->site_id); |
|
153 | 153 | $users_of_blog = count_users(); |
154 | 154 | restore_current_blog(); |
155 | 155 | } else { |
@@ -157,26 +157,26 @@ discard block |
||
157 | 157 | $users_of_blog = count_users(); |
158 | 158 | } |
159 | 159 | $total_users = $users_of_blog['total_users']; |
160 | - $avail_roles =& $users_of_blog['avail_roles']; |
|
160 | + $avail_roles = & $users_of_blog['avail_roles']; |
|
161 | 161 | unset($users_of_blog); |
162 | 162 | |
163 | 163 | $class = empty($role) ? ' class="current"' : ''; |
164 | 164 | $role_links = array(); |
165 | - $role_links['all'] = "<a href='$url'$class>" . sprintf( _nx( 'All <span class="count">(%s)</span>', 'All <span class="count">(%s)</span>', $total_users, 'users' ), number_format_i18n( $total_users ) ) . '</a>'; |
|
166 | - foreach ( $wp_roles->get_names() as $this_role => $name ) { |
|
167 | - if ( !isset($avail_roles[$this_role]) ) |
|
165 | + $role_links['all'] = "<a href='$url'$class>".sprintf(_nx('All <span class="count">(%s)</span>', 'All <span class="count">(%s)</span>', $total_users, 'users'), number_format_i18n($total_users)).'</a>'; |
|
166 | + foreach ($wp_roles->get_names() as $this_role => $name) { |
|
167 | + if ( ! isset($avail_roles[$this_role])) |
|
168 | 168 | continue; |
169 | 169 | |
170 | 170 | $class = ''; |
171 | 171 | |
172 | - if ( $this_role == $role ) { |
|
172 | + if ($this_role == $role) { |
|
173 | 173 | $class = ' class="current"'; |
174 | 174 | } |
175 | 175 | |
176 | - $name = translate_user_role( $name ); |
|
176 | + $name = translate_user_role($name); |
|
177 | 177 | /* translators: User role name with count */ |
178 | - $name = sprintf( __('%1$s <span class="count">(%2$s)</span>'), $name, number_format_i18n( $avail_roles[$this_role] ) ); |
|
179 | - $role_links[$this_role] = "<a href='" . esc_url( add_query_arg( 'role', $this_role, $url ) ) . "'$class>$name</a>"; |
|
178 | + $name = sprintf(__('%1$s <span class="count">(%2$s)</span>'), $name, number_format_i18n($avail_roles[$this_role])); |
|
179 | + $role_links[$this_role] = "<a href='".esc_url(add_query_arg('role', $this_role, $url))."'$class>$name</a>"; |
|
180 | 180 | } |
181 | 181 | |
182 | 182 | return $role_links; |
@@ -193,12 +193,12 @@ discard block |
||
193 | 193 | protected function get_bulk_actions() { |
194 | 194 | $actions = array(); |
195 | 195 | |
196 | - if ( is_multisite() ) { |
|
197 | - if ( current_user_can( 'remove_users' ) ) |
|
198 | - $actions['remove'] = __( 'Remove' ); |
|
196 | + if (is_multisite()) { |
|
197 | + if (current_user_can('remove_users')) |
|
198 | + $actions['remove'] = __('Remove'); |
|
199 | 199 | } else { |
200 | - if ( current_user_can( 'delete_users' ) ) |
|
201 | - $actions['delete'] = __( 'Delete' ); |
|
200 | + if (current_user_can('delete_users')) |
|
201 | + $actions['delete'] = __('Delete'); |
|
202 | 202 | } |
203 | 203 | |
204 | 204 | return $actions; |
@@ -213,19 +213,19 @@ discard block |
||
213 | 213 | * @param string $which Whether this is being invoked above ("top") |
214 | 214 | * or below the table ("bottom"). |
215 | 215 | */ |
216 | - protected function extra_tablenav( $which ) { |
|
217 | - if ( 'top' != $which ) |
|
216 | + protected function extra_tablenav($which) { |
|
217 | + if ('top' != $which) |
|
218 | 218 | return; |
219 | 219 | ?> |
220 | 220 | <div class="alignleft actions"> |
221 | - <?php if ( current_user_can( 'promote_users' ) ) : ?> |
|
222 | - <label class="screen-reader-text" for="new_role"><?php _e( 'Change role to…' ) ?></label> |
|
221 | + <?php if (current_user_can('promote_users')) : ?> |
|
222 | + <label class="screen-reader-text" for="new_role"><?php _e('Change role to…') ?></label> |
|
223 | 223 | <select name="new_role" id="new_role"> |
224 | - <option value=""><?php _e( 'Change role to…' ) ?></option> |
|
224 | + <option value=""><?php _e('Change role to…') ?></option> |
|
225 | 225 | <?php wp_dropdown_roles(); ?> |
226 | 226 | </select> |
227 | 227 | <?php |
228 | - submit_button( __( 'Change' ), 'button', 'changeit', false ); |
|
228 | + submit_button(__('Change'), 'button', 'changeit', false); |
|
229 | 229 | endif; |
230 | 230 | |
231 | 231 | /** |
@@ -234,7 +234,7 @@ discard block |
||
234 | 234 | * |
235 | 235 | * @since 3.5.0 |
236 | 236 | */ |
237 | - do_action( 'restrict_manage_users' ); |
|
237 | + do_action('restrict_manage_users'); |
|
238 | 238 | echo '</div>'; |
239 | 239 | } |
240 | 240 | |
@@ -250,7 +250,7 @@ discard block |
||
250 | 250 | * @return string The bulk action required. |
251 | 251 | */ |
252 | 252 | public function current_action() { |
253 | - if ( isset($_REQUEST['changeit']) && !empty($_REQUEST['new_role']) ) |
|
253 | + if (isset($_REQUEST['changeit']) && ! empty($_REQUEST['new_role'])) |
|
254 | 254 | return 'promote'; |
255 | 255 | |
256 | 256 | return parent::current_action(); |
@@ -268,15 +268,15 @@ discard block |
||
268 | 268 | public function get_columns() { |
269 | 269 | $c = array( |
270 | 270 | 'cb' => '<input type="checkbox" />', |
271 | - 'username' => __( 'Username' ), |
|
272 | - 'name' => __( 'Name' ), |
|
273 | - 'email' => __( 'E-mail' ), |
|
274 | - 'role' => __( 'Role' ), |
|
275 | - 'posts' => __( 'Posts' ) |
|
271 | + 'username' => __('Username'), |
|
272 | + 'name' => __('Name'), |
|
273 | + 'email' => __('E-mail'), |
|
274 | + 'role' => __('Role'), |
|
275 | + 'posts' => __('Posts') |
|
276 | 276 | ); |
277 | 277 | |
278 | - if ( $this->is_site_users ) |
|
279 | - unset( $c['posts'] ); |
|
278 | + if ($this->is_site_users) |
|
279 | + unset($c['posts']); |
|
280 | 280 | |
281 | 281 | return $c; |
282 | 282 | } |
@@ -296,8 +296,8 @@ discard block |
||
296 | 296 | 'email' => 'email', |
297 | 297 | ); |
298 | 298 | |
299 | - if ( $this->is_site_users ) |
|
300 | - unset( $c['posts'] ); |
|
299 | + if ($this->is_site_users) |
|
300 | + unset($c['posts']); |
|
301 | 301 | |
302 | 302 | return $c; |
303 | 303 | } |
@@ -310,24 +310,24 @@ discard block |
||
310 | 310 | */ |
311 | 311 | public function display_rows() { |
312 | 312 | // Query the post counts for this page |
313 | - if ( ! $this->is_site_users ) |
|
314 | - $post_counts = count_many_users_posts( array_keys( $this->items ) ); |
|
313 | + if ( ! $this->is_site_users) |
|
314 | + $post_counts = count_many_users_posts(array_keys($this->items)); |
|
315 | 315 | |
316 | - $editable_roles = array_keys( get_editable_roles() ); |
|
316 | + $editable_roles = array_keys(get_editable_roles()); |
|
317 | 317 | |
318 | - foreach ( $this->items as $userid => $user_object ) { |
|
319 | - if ( count( $user_object->roles ) <= 1 ) { |
|
320 | - $role = reset( $user_object->roles ); |
|
321 | - } elseif ( $roles = array_intersect( array_values( $user_object->roles ), $editable_roles ) ) { |
|
322 | - $role = reset( $roles ); |
|
318 | + foreach ($this->items as $userid => $user_object) { |
|
319 | + if (count($user_object->roles) <= 1) { |
|
320 | + $role = reset($user_object->roles); |
|
321 | + } elseif ($roles = array_intersect(array_values($user_object->roles), $editable_roles)) { |
|
322 | + $role = reset($roles); |
|
323 | 323 | } else { |
324 | - $role = reset( $user_object->roles ); |
|
324 | + $role = reset($user_object->roles); |
|
325 | 325 | } |
326 | 326 | |
327 | - if ( is_multisite() && empty( $user_object->allcaps ) ) |
|
327 | + if (is_multisite() && empty($user_object->allcaps)) |
|
328 | 328 | continue; |
329 | 329 | |
330 | - echo "\n\t" . $this->single_row( $user_object, $style = '', $role, isset( $post_counts ) ? $post_counts[ $userid ] : 0 ); |
|
330 | + echo "\n\t".$this->single_row($user_object, $style = '', $role, isset($post_counts) ? $post_counts[$userid] : 0); |
|
331 | 331 | } |
332 | 332 | } |
333 | 333 | |
@@ -345,40 +345,40 @@ discard block |
||
345 | 345 | * to zero, as in, a new user has made zero posts. |
346 | 346 | * @return string Output for a single row. |
347 | 347 | */ |
348 | - public function single_row( $user_object, $style = '', $role = '', $numposts = 0 ) { |
|
348 | + public function single_row($user_object, $style = '', $role = '', $numposts = 0) { |
|
349 | 349 | $wp_roles = wp_roles(); |
350 | 350 | |
351 | - if ( ! ( $user_object instanceof WP_User ) ) { |
|
352 | - $user_object = get_userdata( (int) $user_object ); |
|
351 | + if ( ! ($user_object instanceof WP_User)) { |
|
352 | + $user_object = get_userdata((int) $user_object); |
|
353 | 353 | } |
354 | 354 | $user_object->filter = 'display'; |
355 | 355 | $email = $user_object->user_email; |
356 | 356 | |
357 | - if ( $this->is_site_users ) |
|
357 | + if ($this->is_site_users) |
|
358 | 358 | $url = "site-users.php?id={$this->site_id}&"; |
359 | 359 | else |
360 | 360 | $url = 'users.php?'; |
361 | 361 | |
362 | 362 | $checkbox = ''; |
363 | 363 | // Check if the user for this row is editable |
364 | - if ( current_user_can( 'list_users' ) ) { |
|
364 | + if (current_user_can('list_users')) { |
|
365 | 365 | // Set up the user editing link |
366 | - $edit_link = esc_url( add_query_arg( 'wp_http_referer', urlencode( wp_unslash( $_SERVER['REQUEST_URI'] ) ), get_edit_user_link( $user_object->ID ) ) ); |
|
366 | + $edit_link = esc_url(add_query_arg('wp_http_referer', urlencode(wp_unslash($_SERVER['REQUEST_URI'])), get_edit_user_link($user_object->ID))); |
|
367 | 367 | |
368 | 368 | // Set up the hover actions for this user |
369 | 369 | $actions = array(); |
370 | 370 | |
371 | - if ( current_user_can( 'edit_user', $user_object->ID ) ) { |
|
371 | + if (current_user_can('edit_user', $user_object->ID)) { |
|
372 | 372 | $edit = "<strong><a href=\"$edit_link\">$user_object->user_login</a></strong><br />"; |
373 | - $actions['edit'] = '<a href="' . $edit_link . '">' . __( 'Edit' ) . '</a>'; |
|
373 | + $actions['edit'] = '<a href="'.$edit_link.'">'.__('Edit').'</a>'; |
|
374 | 374 | } else { |
375 | 375 | $edit = "<strong>$user_object->user_login</strong><br />"; |
376 | 376 | } |
377 | 377 | |
378 | - if ( !is_multisite() && get_current_user_id() != $user_object->ID && current_user_can( 'delete_user', $user_object->ID ) ) |
|
379 | - $actions['delete'] = "<a class='submitdelete' href='" . wp_nonce_url( "users.php?action=delete&user=$user_object->ID", 'bulk-users' ) . "'>" . __( 'Delete' ) . "</a>"; |
|
380 | - if ( is_multisite() && get_current_user_id() != $user_object->ID && current_user_can( 'remove_user', $user_object->ID ) ) |
|
381 | - $actions['remove'] = "<a class='submitdelete' href='" . wp_nonce_url( $url."action=remove&user=$user_object->ID", 'bulk-users' ) . "'>" . __( 'Remove' ) . "</a>"; |
|
378 | + if ( ! is_multisite() && get_current_user_id() != $user_object->ID && current_user_can('delete_user', $user_object->ID)) |
|
379 | + $actions['delete'] = "<a class='submitdelete' href='".wp_nonce_url("users.php?action=delete&user=$user_object->ID", 'bulk-users')."'>".__('Delete')."</a>"; |
|
380 | + if (is_multisite() && get_current_user_id() != $user_object->ID && current_user_can('remove_user', $user_object->ID)) |
|
381 | + $actions['remove'] = "<a class='submitdelete' href='".wp_nonce_url($url."action=remove&user=$user_object->ID", 'bulk-users')."'>".__('Remove')."</a>"; |
|
382 | 382 | |
383 | 383 | /** |
384 | 384 | * Filter the action links displayed under each user in the Users list table. |
@@ -390,44 +390,44 @@ discard block |
||
390 | 390 | * 'Edit', 'Remove' for Multisite. |
391 | 391 | * @param WP_User $user_object WP_User object for the currently-listed user. |
392 | 392 | */ |
393 | - $actions = apply_filters( 'user_row_actions', $actions, $user_object ); |
|
393 | + $actions = apply_filters('user_row_actions', $actions, $user_object); |
|
394 | 394 | |
395 | 395 | // Set up the checkbox ( because the user is editable, otherwise it's empty ) |
396 | - $checkbox = '<label class="screen-reader-text" for="user_' . $user_object->ID . '">' . sprintf( __( 'Select %s' ), $user_object->user_login ) . '</label>' |
|
396 | + $checkbox = '<label class="screen-reader-text" for="user_'.$user_object->ID.'">'.sprintf(__('Select %s'), $user_object->user_login).'</label>' |
|
397 | 397 | . "<input type='checkbox' name='users[]' id='user_{$user_object->ID}' class='$role' value='{$user_object->ID}' />"; |
398 | 398 | |
399 | 399 | } else { |
400 | - $edit = '<strong>' . $user_object->user_login . '</strong>'; |
|
400 | + $edit = '<strong>'.$user_object->user_login.'</strong>'; |
|
401 | 401 | } |
402 | - $role_name = isset( $wp_roles->role_names[$role] ) ? translate_user_role( $wp_roles->role_names[$role] ) : __( 'None' ); |
|
403 | - $avatar = get_avatar( $user_object->ID, 32 ); |
|
402 | + $role_name = isset($wp_roles->role_names[$role]) ? translate_user_role($wp_roles->role_names[$role]) : __('None'); |
|
403 | + $avatar = get_avatar($user_object->ID, 32); |
|
404 | 404 | |
405 | 405 | $r = "<tr id='user-$user_object->ID'>"; |
406 | 406 | |
407 | - list( $columns, $hidden, $sortable, $primary ) = $this->get_column_info(); |
|
407 | + list($columns, $hidden, $sortable, $primary) = $this->get_column_info(); |
|
408 | 408 | |
409 | - foreach ( $columns as $column_name => $column_display_name ) { |
|
409 | + foreach ($columns as $column_name => $column_display_name) { |
|
410 | 410 | $classes = "$column_name column-$column_name"; |
411 | - if ( $primary === $column_name ) { |
|
411 | + if ($primary === $column_name) { |
|
412 | 412 | $classes .= ' has-row-actions column-primary'; |
413 | 413 | } |
414 | - if ( 'posts' === $column_name ) { |
|
414 | + if ('posts' === $column_name) { |
|
415 | 415 | $classes .= ' num'; // Special case for that column |
416 | 416 | } |
417 | 417 | |
418 | - if ( in_array( $column_name, $hidden ) ) { |
|
418 | + if (in_array($column_name, $hidden)) { |
|
419 | 419 | $classes .= ' hidden'; |
420 | 420 | } |
421 | 421 | |
422 | - $data = 'data-colname="' . wp_strip_all_tags( $column_display_name ) . '"'; |
|
422 | + $data = 'data-colname="'.wp_strip_all_tags($column_display_name).'"'; |
|
423 | 423 | |
424 | 424 | $attributes = "class='$classes' $data"; |
425 | 425 | |
426 | - if ( 'cb' === $column_name ) { |
|
426 | + if ('cb' === $column_name) { |
|
427 | 427 | $r .= "<th scope='row' class='check-column'>$checkbox</th>"; |
428 | 428 | } else { |
429 | 429 | $r .= "<td $attributes>"; |
430 | - switch ( $column_name ) { |
|
430 | + switch ($column_name) { |
|
431 | 431 | case 'username': |
432 | 432 | $r .= "$avatar $edit"; |
433 | 433 | break; |
@@ -441,10 +441,10 @@ discard block |
||
441 | 441 | $r .= $role_name; |
442 | 442 | break; |
443 | 443 | case 'posts': |
444 | - if ( $numposts > 0 ) { |
|
444 | + if ($numposts > 0) { |
|
445 | 445 | $r .= "<a href='edit.php?author=$user_object->ID' class='edit'>"; |
446 | - $r .= '<span aria-hidden="true">' . $numposts . '</span>'; |
|
447 | - $r .= '<span class="screen-reader-text">' . sprintf( _n( '%s post by this author', '%s posts by this author', $numposts ), number_format_i18n( $numposts ) ) . '</span>'; |
|
446 | + $r .= '<span aria-hidden="true">'.$numposts.'</span>'; |
|
447 | + $r .= '<span class="screen-reader-text">'.sprintf(_n('%s post by this author', '%s posts by this author', $numposts), number_format_i18n($numposts)).'</span>'; |
|
448 | 448 | $r .= '</a>'; |
449 | 449 | } else { |
450 | 450 | $r .= 0; |
@@ -460,11 +460,11 @@ discard block |
||
460 | 460 | * @param string $column_name Column name. |
461 | 461 | * @param int $user_id ID of the currently-listed user. |
462 | 462 | */ |
463 | - $r .= apply_filters( 'manage_users_custom_column', '', $column_name, $user_object->ID ); |
|
463 | + $r .= apply_filters('manage_users_custom_column', '', $column_name, $user_object->ID); |
|
464 | 464 | } |
465 | 465 | |
466 | - if ( $primary === $column_name ) { |
|
467 | - $r .= $this->row_actions( $actions ); |
|
466 | + if ($primary === $column_name) { |
|
467 | + $r .= $this->row_actions($actions); |
|
468 | 468 | } |
469 | 469 | $r .= "</td>"; |
470 | 470 | } |
@@ -47,8 +47,9 @@ discard block |
||
47 | 47 | |
48 | 48 | $this->is_site_users = 'site-users-network' == $this->screen->id; |
49 | 49 | |
50 | - if ( $this->is_site_users ) |
|
51 | - $this->site_id = isset( $_REQUEST['id'] ) ? intval( $_REQUEST['id'] ) : 0; |
|
50 | + if ( $this->is_site_users ) { |
|
51 | + $this->site_id = isset( $_REQUEST['id'] ) ? intval( $_REQUEST['id'] ) : 0; |
|
52 | + } |
|
52 | 53 | } |
53 | 54 | |
54 | 55 | /** |
@@ -60,10 +61,11 @@ discard block |
||
60 | 61 | * @return bool |
61 | 62 | */ |
62 | 63 | public function ajax_user_can() { |
63 | - if ( $this->is_site_users ) |
|
64 | - return current_user_can( 'manage_sites' ); |
|
65 | - else |
|
66 | - return current_user_can( 'list_users' ); |
|
64 | + if ( $this->is_site_users ) { |
|
65 | + return current_user_can( 'manage_sites' ); |
|
66 | + } else { |
|
67 | + return current_user_can( 'list_users' ); |
|
68 | + } |
|
67 | 69 | } |
68 | 70 | |
69 | 71 | /** |
@@ -95,17 +97,21 @@ discard block |
||
95 | 97 | 'fields' => 'all_with_meta' |
96 | 98 | ); |
97 | 99 | |
98 | - if ( '' !== $args['search'] ) |
|
99 | - $args['search'] = '*' . $args['search'] . '*'; |
|
100 | + if ( '' !== $args['search'] ) { |
|
101 | + $args['search'] = '*' . $args['search'] . '*'; |
|
102 | + } |
|
100 | 103 | |
101 | - if ( $this->is_site_users ) |
|
102 | - $args['blog_id'] = $this->site_id; |
|
104 | + if ( $this->is_site_users ) { |
|
105 | + $args['blog_id'] = $this->site_id; |
|
106 | + } |
|
103 | 107 | |
104 | - if ( isset( $_REQUEST['orderby'] ) ) |
|
105 | - $args['orderby'] = $_REQUEST['orderby']; |
|
108 | + if ( isset( $_REQUEST['orderby'] ) ) { |
|
109 | + $args['orderby'] = $_REQUEST['orderby']; |
|
110 | + } |
|
106 | 111 | |
107 | - if ( isset( $_REQUEST['order'] ) ) |
|
108 | - $args['order'] = $_REQUEST['order']; |
|
112 | + if ( isset( $_REQUEST['order'] ) ) { |
|
113 | + $args['order'] = $_REQUEST['order']; |
|
114 | + } |
|
109 | 115 | |
110 | 116 | // Query the user IDs for this page |
111 | 117 | $wp_user_search = new WP_User_Query( $args ); |
@@ -164,8 +170,9 @@ discard block |
||
164 | 170 | $role_links = array(); |
165 | 171 | $role_links['all'] = "<a href='$url'$class>" . sprintf( _nx( 'All <span class="count">(%s)</span>', 'All <span class="count">(%s)</span>', $total_users, 'users' ), number_format_i18n( $total_users ) ) . '</a>'; |
166 | 172 | foreach ( $wp_roles->get_names() as $this_role => $name ) { |
167 | - if ( !isset($avail_roles[$this_role]) ) |
|
168 | - continue; |
|
173 | + if ( !isset($avail_roles[$this_role]) ) { |
|
174 | + continue; |
|
175 | + } |
|
169 | 176 | |
170 | 177 | $class = ''; |
171 | 178 | |
@@ -194,11 +201,13 @@ discard block |
||
194 | 201 | $actions = array(); |
195 | 202 | |
196 | 203 | if ( is_multisite() ) { |
197 | - if ( current_user_can( 'remove_users' ) ) |
|
198 | - $actions['remove'] = __( 'Remove' ); |
|
204 | + if ( current_user_can( 'remove_users' ) ) { |
|
205 | + $actions['remove'] = __( 'Remove' ); |
|
206 | + } |
|
199 | 207 | } else { |
200 | - if ( current_user_can( 'delete_users' ) ) |
|
201 | - $actions['delete'] = __( 'Delete' ); |
|
208 | + if ( current_user_can( 'delete_users' ) ) { |
|
209 | + $actions['delete'] = __( 'Delete' ); |
|
210 | + } |
|
202 | 211 | } |
203 | 212 | |
204 | 213 | return $actions; |
@@ -214,8 +223,9 @@ discard block |
||
214 | 223 | * or below the table ("bottom"). |
215 | 224 | */ |
216 | 225 | protected function extra_tablenav( $which ) { |
217 | - if ( 'top' != $which ) |
|
218 | - return; |
|
226 | + if ( 'top' != $which ) { |
|
227 | + return; |
|
228 | + } |
|
219 | 229 | ?> |
220 | 230 | <div class="alignleft actions"> |
221 | 231 | <?php if ( current_user_can( 'promote_users' ) ) : ?> |
@@ -250,8 +260,9 @@ discard block |
||
250 | 260 | * @return string The bulk action required. |
251 | 261 | */ |
252 | 262 | public function current_action() { |
253 | - if ( isset($_REQUEST['changeit']) && !empty($_REQUEST['new_role']) ) |
|
254 | - return 'promote'; |
|
263 | + if ( isset($_REQUEST['changeit']) && !empty($_REQUEST['new_role']) ) { |
|
264 | + return 'promote'; |
|
265 | + } |
|
255 | 266 | |
256 | 267 | return parent::current_action(); |
257 | 268 | } |
@@ -275,8 +286,9 @@ discard block |
||
275 | 286 | 'posts' => __( 'Posts' ) |
276 | 287 | ); |
277 | 288 | |
278 | - if ( $this->is_site_users ) |
|
279 | - unset( $c['posts'] ); |
|
289 | + if ( $this->is_site_users ) { |
|
290 | + unset( $c['posts'] ); |
|
291 | + } |
|
280 | 292 | |
281 | 293 | return $c; |
282 | 294 | } |
@@ -296,8 +308,9 @@ discard block |
||
296 | 308 | 'email' => 'email', |
297 | 309 | ); |
298 | 310 | |
299 | - if ( $this->is_site_users ) |
|
300 | - unset( $c['posts'] ); |
|
311 | + if ( $this->is_site_users ) { |
|
312 | + unset( $c['posts'] ); |
|
313 | + } |
|
301 | 314 | |
302 | 315 | return $c; |
303 | 316 | } |
@@ -310,8 +323,9 @@ discard block |
||
310 | 323 | */ |
311 | 324 | public function display_rows() { |
312 | 325 | // Query the post counts for this page |
313 | - if ( ! $this->is_site_users ) |
|
314 | - $post_counts = count_many_users_posts( array_keys( $this->items ) ); |
|
326 | + if ( ! $this->is_site_users ) { |
|
327 | + $post_counts = count_many_users_posts( array_keys( $this->items ) ); |
|
328 | + } |
|
315 | 329 | |
316 | 330 | $editable_roles = array_keys( get_editable_roles() ); |
317 | 331 | |
@@ -324,8 +338,9 @@ discard block |
||
324 | 338 | $role = reset( $user_object->roles ); |
325 | 339 | } |
326 | 340 | |
327 | - if ( is_multisite() && empty( $user_object->allcaps ) ) |
|
328 | - continue; |
|
341 | + if ( is_multisite() && empty( $user_object->allcaps ) ) { |
|
342 | + continue; |
|
343 | + } |
|
329 | 344 | |
330 | 345 | echo "\n\t" . $this->single_row( $user_object, $style = '', $role, isset( $post_counts ) ? $post_counts[ $userid ] : 0 ); |
331 | 346 | } |
@@ -354,10 +369,11 @@ discard block |
||
354 | 369 | $user_object->filter = 'display'; |
355 | 370 | $email = $user_object->user_email; |
356 | 371 | |
357 | - if ( $this->is_site_users ) |
|
358 | - $url = "site-users.php?id={$this->site_id}&"; |
|
359 | - else |
|
360 | - $url = 'users.php?'; |
|
372 | + if ( $this->is_site_users ) { |
|
373 | + $url = "site-users.php?id={$this->site_id}&"; |
|
374 | + } else { |
|
375 | + $url = 'users.php?'; |
|
376 | + } |
|
361 | 377 | |
362 | 378 | $checkbox = ''; |
363 | 379 | // Check if the user for this row is editable |
@@ -375,10 +391,12 @@ discard block |
||
375 | 391 | $edit = "<strong>$user_object->user_login</strong><br />"; |
376 | 392 | } |
377 | 393 | |
378 | - if ( !is_multisite() && get_current_user_id() != $user_object->ID && current_user_can( 'delete_user', $user_object->ID ) ) |
|
379 | - $actions['delete'] = "<a class='submitdelete' href='" . wp_nonce_url( "users.php?action=delete&user=$user_object->ID", 'bulk-users' ) . "'>" . __( 'Delete' ) . "</a>"; |
|
380 | - if ( is_multisite() && get_current_user_id() != $user_object->ID && current_user_can( 'remove_user', $user_object->ID ) ) |
|
381 | - $actions['remove'] = "<a class='submitdelete' href='" . wp_nonce_url( $url."action=remove&user=$user_object->ID", 'bulk-users' ) . "'>" . __( 'Remove' ) . "</a>"; |
|
394 | + if ( !is_multisite() && get_current_user_id() != $user_object->ID && current_user_can( 'delete_user', $user_object->ID ) ) { |
|
395 | + $actions['delete'] = "<a class='submitdelete' href='" . wp_nonce_url( "users.php?action=delete&user=$user_object->ID", 'bulk-users' ) . "'>" . __( 'Delete' ) . "</a>"; |
|
396 | + } |
|
397 | + if ( is_multisite() && get_current_user_id() != $user_object->ID && current_user_can( 'remove_user', $user_object->ID ) ) { |
|
398 | + $actions['remove'] = "<a class='submitdelete' href='" . wp_nonce_url( $url."action=remove&user=$user_object->ID", 'bulk-users' ) . "'>" . __( 'Remove' ) . "</a>"; |
|
399 | + } |
|
382 | 400 | |
383 | 401 | /** |
384 | 402 | * Filter the action links displayed under each user in the Users list table. |
@@ -1,10 +1,10 @@ |
||
1 | 1 | <?php |
2 | 2 | /** |
3 | - * WordPress Theme Administration API |
|
4 | - * |
|
5 | - * @package WordPress |
|
6 | - * @subpackage Administration |
|
7 | - */ |
|
3 | + * WordPress Theme Administration API |
|
4 | + * |
|
5 | + * @package WordPress |
|
6 | + * @subpackage Administration |
|
7 | + */ |
|
8 | 8 | |
9 | 9 | /** |
10 | 10 | * Remove a theme |
@@ -20,71 +20,71 @@ discard block |
||
20 | 20 | function delete_theme($stylesheet, $redirect = '') { |
21 | 21 | global $wp_filesystem; |
22 | 22 | |
23 | - if ( empty($stylesheet) ) |
|
23 | + if (empty($stylesheet)) |
|
24 | 24 | return false; |
25 | 25 | |
26 | 26 | ob_start(); |
27 | - if ( empty( $redirect ) ) |
|
28 | - $redirect = wp_nonce_url('themes.php?action=delete&stylesheet=' . urlencode( $stylesheet ), 'delete-theme_' . $stylesheet); |
|
29 | - if ( false === ($credentials = request_filesystem_credentials($redirect)) ) { |
|
27 | + if (empty($redirect)) |
|
28 | + $redirect = wp_nonce_url('themes.php?action=delete&stylesheet='.urlencode($stylesheet), 'delete-theme_'.$stylesheet); |
|
29 | + if (false === ($credentials = request_filesystem_credentials($redirect))) { |
|
30 | 30 | $data = ob_get_clean(); |
31 | 31 | |
32 | - if ( ! empty($data) ){ |
|
33 | - include_once( ABSPATH . 'wp-admin/admin-header.php'); |
|
32 | + if ( ! empty($data)) { |
|
33 | + include_once(ABSPATH.'wp-admin/admin-header.php'); |
|
34 | 34 | echo $data; |
35 | - include( ABSPATH . 'wp-admin/admin-footer.php'); |
|
35 | + include(ABSPATH.'wp-admin/admin-footer.php'); |
|
36 | 36 | exit; |
37 | 37 | } |
38 | 38 | return; |
39 | 39 | } |
40 | 40 | |
41 | - if ( ! WP_Filesystem($credentials) ) { |
|
41 | + if ( ! WP_Filesystem($credentials)) { |
|
42 | 42 | request_filesystem_credentials($redirect, '', true); // Failed to connect, Error and request again |
43 | 43 | $data = ob_get_clean(); |
44 | 44 | |
45 | - if ( ! empty($data) ) { |
|
46 | - include_once( ABSPATH . 'wp-admin/admin-header.php'); |
|
45 | + if ( ! empty($data)) { |
|
46 | + include_once(ABSPATH.'wp-admin/admin-header.php'); |
|
47 | 47 | echo $data; |
48 | - include( ABSPATH . 'wp-admin/admin-footer.php'); |
|
48 | + include(ABSPATH.'wp-admin/admin-footer.php'); |
|
49 | 49 | exit; |
50 | 50 | } |
51 | 51 | return; |
52 | 52 | } |
53 | 53 | |
54 | - if ( ! is_object($wp_filesystem) ) |
|
54 | + if ( ! is_object($wp_filesystem)) |
|
55 | 55 | return new WP_Error('fs_unavailable', __('Could not access filesystem.')); |
56 | 56 | |
57 | - if ( is_wp_error($wp_filesystem->errors) && $wp_filesystem->errors->get_error_code() ) |
|
57 | + if (is_wp_error($wp_filesystem->errors) && $wp_filesystem->errors->get_error_code()) |
|
58 | 58 | return new WP_Error('fs_error', __('Filesystem error.'), $wp_filesystem->errors); |
59 | 59 | |
60 | 60 | // Get the base plugin folder. |
61 | 61 | $themes_dir = $wp_filesystem->wp_themes_dir(); |
62 | - if ( empty( $themes_dir ) ) { |
|
63 | - return new WP_Error( 'fs_no_themes_dir', __( 'Unable to locate WordPress theme directory.' ) ); |
|
62 | + if (empty($themes_dir)) { |
|
63 | + return new WP_Error('fs_no_themes_dir', __('Unable to locate WordPress theme directory.')); |
|
64 | 64 | } |
65 | 65 | |
66 | - $themes_dir = trailingslashit( $themes_dir ); |
|
67 | - $theme_dir = trailingslashit( $themes_dir . $stylesheet ); |
|
68 | - $deleted = $wp_filesystem->delete( $theme_dir, true ); |
|
66 | + $themes_dir = trailingslashit($themes_dir); |
|
67 | + $theme_dir = trailingslashit($themes_dir.$stylesheet); |
|
68 | + $deleted = $wp_filesystem->delete($theme_dir, true); |
|
69 | 69 | |
70 | - if ( ! $deleted ) { |
|
71 | - return new WP_Error( 'could_not_remove_theme', sprintf( __( 'Could not fully remove the theme %s.' ), $stylesheet ) ); |
|
70 | + if ( ! $deleted) { |
|
71 | + return new WP_Error('could_not_remove_theme', sprintf(__('Could not fully remove the theme %s.'), $stylesheet)); |
|
72 | 72 | } |
73 | 73 | |
74 | - $theme_translations = wp_get_installed_translations( 'themes' ); |
|
74 | + $theme_translations = wp_get_installed_translations('themes'); |
|
75 | 75 | |
76 | 76 | // Remove language files, silently. |
77 | - if ( ! empty( $theme_translations[ $stylesheet ] ) ) { |
|
78 | - $translations = $theme_translations[ $stylesheet ]; |
|
77 | + if ( ! empty($theme_translations[$stylesheet])) { |
|
78 | + $translations = $theme_translations[$stylesheet]; |
|
79 | 79 | |
80 | - foreach ( $translations as $translation => $data ) { |
|
81 | - $wp_filesystem->delete( WP_LANG_DIR . '/themes/' . $stylesheet . '-' . $translation . '.po' ); |
|
82 | - $wp_filesystem->delete( WP_LANG_DIR . '/themes/' . $stylesheet . '-' . $translation . '.mo' ); |
|
80 | + foreach ($translations as $translation => $data) { |
|
81 | + $wp_filesystem->delete(WP_LANG_DIR.'/themes/'.$stylesheet.'-'.$translation.'.po'); |
|
82 | + $wp_filesystem->delete(WP_LANG_DIR.'/themes/'.$stylesheet.'-'.$translation.'.mo'); |
|
83 | 83 | } |
84 | 84 | } |
85 | 85 | |
86 | 86 | // Force refresh of theme update information. |
87 | - delete_site_transient( 'update_themes' ); |
|
87 | + delete_site_transient('update_themes'); |
|
88 | 88 | |
89 | 89 | return true; |
90 | 90 | } |
@@ -97,8 +97,8 @@ discard block |
||
97 | 97 | * @param WP_Post|null $post Optional. The post being edited, provided for context. |
98 | 98 | * @return array Key is the template name, value is the filename of the template |
99 | 99 | */ |
100 | -function get_page_templates( $post = null ) { |
|
101 | - return array_flip( wp_get_theme()->get_page_templates( $post ) ); |
|
100 | +function get_page_templates($post = null) { |
|
101 | + return array_flip(wp_get_theme()->get_page_templates($post)); |
|
102 | 102 | } |
103 | 103 | |
104 | 104 | /** |
@@ -112,7 +112,7 @@ discard block |
||
112 | 112 | * @return string |
113 | 113 | */ |
114 | 114 | function _get_template_edit_filename($fullpath, $containingfolder) { |
115 | - return str_replace(dirname(dirname( $containingfolder )) , '', $fullpath); |
|
115 | + return str_replace(dirname(dirname($containingfolder)), '', $fullpath); |
|
116 | 116 | } |
117 | 117 | |
118 | 118 | /** |
@@ -125,8 +125,8 @@ discard block |
||
125 | 125 | * |
126 | 126 | * @param WP_Theme $theme Theme data object. |
127 | 127 | */ |
128 | -function theme_update_available( $theme ) { |
|
129 | - echo get_theme_update_available( $theme ); |
|
128 | +function theme_update_available($theme) { |
|
129 | + echo get_theme_update_available($theme); |
|
130 | 130 | } |
131 | 131 | |
132 | 132 | /** |
@@ -141,16 +141,16 @@ discard block |
||
141 | 141 | * @param WP_Theme $theme WP_Theme object. |
142 | 142 | * @return false|string HTML for the update link, or false if invalid info was passed. |
143 | 143 | */ |
144 | -function get_theme_update_available( $theme ) { |
|
144 | +function get_theme_update_available($theme) { |
|
145 | 145 | static $themes_update = null; |
146 | 146 | |
147 | - if ( !current_user_can('update_themes' ) ) |
|
147 | + if ( ! current_user_can('update_themes')) |
|
148 | 148 | return false; |
149 | 149 | |
150 | - if ( !isset($themes_update) ) |
|
150 | + if ( ! isset($themes_update)) |
|
151 | 151 | $themes_update = get_site_transient('update_themes'); |
152 | 152 | |
153 | - if ( ! ( $theme instanceof WP_Theme ) ) { |
|
153 | + if ( ! ($theme instanceof WP_Theme)) { |
|
154 | 154 | return false; |
155 | 155 | } |
156 | 156 | |
@@ -158,23 +158,23 @@ discard block |
||
158 | 158 | |
159 | 159 | $html = ''; |
160 | 160 | |
161 | - if ( isset($themes_update->response[ $stylesheet ]) ) { |
|
162 | - $update = $themes_update->response[ $stylesheet ]; |
|
161 | + if (isset($themes_update->response[$stylesheet])) { |
|
162 | + $update = $themes_update->response[$stylesheet]; |
|
163 | 163 | $theme_name = $theme->display('Name'); |
164 | 164 | $details_url = add_query_arg(array('TB_iframe' => 'true', 'width' => 1024, 'height' => 800), $update['url']); //Theme browser inside WP? replace this, Also, theme preview JS will override this on the available list. |
165 | - $update_url = wp_nonce_url( admin_url( 'update.php?action=upgrade-theme&theme=' . urlencode( $stylesheet ) ), 'upgrade-theme_' . $stylesheet ); |
|
166 | - $update_onclick = 'onclick="if ( confirm(\'' . esc_js( __("Updating this theme will lose any customizations you have made. 'Cancel' to stop, 'OK' to update.") ) . '\') ) {return true;}return false;"'; |
|
167 | - |
|
168 | - if ( !is_multisite() ) { |
|
169 | - if ( ! current_user_can('update_themes') ) { |
|
170 | - $html = sprintf( '<p><strong>' . __( 'There is a new version of %1$s available. <a href="%2$s" class="thickbox" title="%3$s">View version %4$s details</a>.' ) . '</strong></p>', |
|
171 | - $theme_name, esc_url( $details_url ), esc_attr( $theme['Name'] ), $update['new_version'] ); |
|
172 | - } elseif ( empty( $update['package'] ) ) { |
|
173 | - $html = sprintf( '<p><strong>' . __( 'There is a new version of %1$s available. <a href="%2$s" class="thickbox" title="%3$s">View version %4$s details</a>. <em>Automatic update is unavailable for this theme.</em>' ) . '</strong></p>', |
|
174 | - $theme_name, esc_url( $details_url ), esc_attr( $theme['Name'] ), $update['new_version'] ); |
|
165 | + $update_url = wp_nonce_url(admin_url('update.php?action=upgrade-theme&theme='.urlencode($stylesheet)), 'upgrade-theme_'.$stylesheet); |
|
166 | + $update_onclick = 'onclick="if ( confirm(\''.esc_js(__("Updating this theme will lose any customizations you have made. 'Cancel' to stop, 'OK' to update.")).'\') ) {return true;}return false;"'; |
|
167 | + |
|
168 | + if ( ! is_multisite()) { |
|
169 | + if ( ! current_user_can('update_themes')) { |
|
170 | + $html = sprintf('<p><strong>'.__('There is a new version of %1$s available. <a href="%2$s" class="thickbox" title="%3$s">View version %4$s details</a>.').'</strong></p>', |
|
171 | + $theme_name, esc_url($details_url), esc_attr($theme['Name']), $update['new_version']); |
|
172 | + } elseif (empty($update['package'])) { |
|
173 | + $html = sprintf('<p><strong>'.__('There is a new version of %1$s available. <a href="%2$s" class="thickbox" title="%3$s">View version %4$s details</a>. <em>Automatic update is unavailable for this theme.</em>').'</strong></p>', |
|
174 | + $theme_name, esc_url($details_url), esc_attr($theme['Name']), $update['new_version']); |
|
175 | 175 | } else { |
176 | - $html = sprintf( '<p><strong>' . __( 'There is a new version of %1$s available. <a href="%2$s" class="thickbox" title="%3$s">View version %4$s details</a> or <a href="%5$s">update now</a>.' ) . '</strong></p>', |
|
177 | - $theme_name, esc_url( $details_url ), esc_attr( $theme['Name'] ), $update['new_version'], $update_url, $update_onclick ); |
|
176 | + $html = sprintf('<p><strong>'.__('There is a new version of %1$s available. <a href="%2$s" class="thickbox" title="%3$s">View version %4$s details</a> or <a href="%5$s">update now</a>.').'</strong></p>', |
|
177 | + $theme_name, esc_url($details_url), esc_attr($theme['Name']), $update['new_version'], $update_url, $update_onclick); |
|
178 | 178 | } |
179 | 179 | } |
180 | 180 | } |
@@ -190,102 +190,102 @@ discard block |
||
190 | 190 | * @param bool $api Optional. Whether try to fetch tags from the WP.org API. Defaults to true. |
191 | 191 | * @return array Array of features keyed by category with translations keyed by slug. |
192 | 192 | */ |
193 | -function get_theme_feature_list( $api = true ) { |
|
193 | +function get_theme_feature_list($api = true) { |
|
194 | 194 | // Hard-coded list is used if api not accessible. |
195 | 195 | $features = array( |
196 | - __( 'Colors' ) => array( |
|
197 | - 'black' => __( 'Black' ), |
|
198 | - 'blue' => __( 'Blue' ), |
|
199 | - 'brown' => __( 'Brown' ), |
|
200 | - 'gray' => __( 'Gray' ), |
|
201 | - 'green' => __( 'Green' ), |
|
202 | - 'orange' => __( 'Orange' ), |
|
203 | - 'pink' => __( 'Pink' ), |
|
204 | - 'purple' => __( 'Purple' ), |
|
205 | - 'red' => __( 'Red' ), |
|
206 | - 'silver' => __( 'Silver' ), |
|
207 | - 'tan' => __( 'Tan' ), |
|
208 | - 'white' => __( 'White' ), |
|
209 | - 'yellow' => __( 'Yellow' ), |
|
210 | - 'dark' => __( 'Dark' ), |
|
211 | - 'light' => __( 'Light' ), |
|
196 | + __('Colors') => array( |
|
197 | + 'black' => __('Black'), |
|
198 | + 'blue' => __('Blue'), |
|
199 | + 'brown' => __('Brown'), |
|
200 | + 'gray' => __('Gray'), |
|
201 | + 'green' => __('Green'), |
|
202 | + 'orange' => __('Orange'), |
|
203 | + 'pink' => __('Pink'), |
|
204 | + 'purple' => __('Purple'), |
|
205 | + 'red' => __('Red'), |
|
206 | + 'silver' => __('Silver'), |
|
207 | + 'tan' => __('Tan'), |
|
208 | + 'white' => __('White'), |
|
209 | + 'yellow' => __('Yellow'), |
|
210 | + 'dark' => __('Dark'), |
|
211 | + 'light' => __('Light'), |
|
212 | 212 | ), |
213 | 213 | |
214 | - __( 'Layout' ) => array( |
|
215 | - 'fixed-layout' => __( 'Fixed Layout' ), |
|
216 | - 'fluid-layout' => __( 'Fluid Layout' ), |
|
217 | - 'responsive-layout' => __( 'Responsive Layout' ), |
|
218 | - 'one-column' => __( 'One Column' ), |
|
219 | - 'two-columns' => __( 'Two Columns' ), |
|
220 | - 'three-columns' => __( 'Three Columns' ), |
|
221 | - 'four-columns' => __( 'Four Columns' ), |
|
222 | - 'left-sidebar' => __( 'Left Sidebar' ), |
|
223 | - 'right-sidebar' => __( 'Right Sidebar' ), |
|
214 | + __('Layout') => array( |
|
215 | + 'fixed-layout' => __('Fixed Layout'), |
|
216 | + 'fluid-layout' => __('Fluid Layout'), |
|
217 | + 'responsive-layout' => __('Responsive Layout'), |
|
218 | + 'one-column' => __('One Column'), |
|
219 | + 'two-columns' => __('Two Columns'), |
|
220 | + 'three-columns' => __('Three Columns'), |
|
221 | + 'four-columns' => __('Four Columns'), |
|
222 | + 'left-sidebar' => __('Left Sidebar'), |
|
223 | + 'right-sidebar' => __('Right Sidebar'), |
|
224 | 224 | ), |
225 | 225 | |
226 | - __( 'Features' ) => array( |
|
227 | - 'accessibility-ready' => __( 'Accessibility Ready' ), |
|
228 | - 'blavatar' => __( 'Blavatar' ), |
|
229 | - 'buddypress' => __( 'BuddyPress' ), |
|
230 | - 'custom-background' => __( 'Custom Background' ), |
|
231 | - 'custom-colors' => __( 'Custom Colors' ), |
|
232 | - 'custom-header' => __( 'Custom Header' ), |
|
233 | - 'custom-menu' => __( 'Custom Menu' ), |
|
234 | - 'editor-style' => __( 'Editor Style' ), |
|
235 | - 'featured-image-header' => __( 'Featured Image Header' ), |
|
236 | - 'featured-images' => __( 'Featured Images' ), |
|
237 | - 'flexible-header' => __( 'Flexible Header' ), |
|
238 | - 'front-page-post-form' => __( 'Front Page Posting' ), |
|
239 | - 'full-width-template' => __( 'Full Width Template' ), |
|
240 | - 'microformats' => __( 'Microformats' ), |
|
241 | - 'post-formats' => __( 'Post Formats' ), |
|
242 | - 'rtl-language-support' => __( 'RTL Language Support' ), |
|
243 | - 'sticky-post' => __( 'Sticky Post' ), |
|
244 | - 'theme-options' => __( 'Theme Options' ), |
|
245 | - 'threaded-comments' => __( 'Threaded Comments' ), |
|
246 | - 'translation-ready' => __( 'Translation Ready' ), |
|
226 | + __('Features') => array( |
|
227 | + 'accessibility-ready' => __('Accessibility Ready'), |
|
228 | + 'blavatar' => __('Blavatar'), |
|
229 | + 'buddypress' => __('BuddyPress'), |
|
230 | + 'custom-background' => __('Custom Background'), |
|
231 | + 'custom-colors' => __('Custom Colors'), |
|
232 | + 'custom-header' => __('Custom Header'), |
|
233 | + 'custom-menu' => __('Custom Menu'), |
|
234 | + 'editor-style' => __('Editor Style'), |
|
235 | + 'featured-image-header' => __('Featured Image Header'), |
|
236 | + 'featured-images' => __('Featured Images'), |
|
237 | + 'flexible-header' => __('Flexible Header'), |
|
238 | + 'front-page-post-form' => __('Front Page Posting'), |
|
239 | + 'full-width-template' => __('Full Width Template'), |
|
240 | + 'microformats' => __('Microformats'), |
|
241 | + 'post-formats' => __('Post Formats'), |
|
242 | + 'rtl-language-support' => __('RTL Language Support'), |
|
243 | + 'sticky-post' => __('Sticky Post'), |
|
244 | + 'theme-options' => __('Theme Options'), |
|
245 | + 'threaded-comments' => __('Threaded Comments'), |
|
246 | + 'translation-ready' => __('Translation Ready'), |
|
247 | 247 | ), |
248 | 248 | |
249 | - __( 'Subject' ) => array( |
|
250 | - 'holiday' => __( 'Holiday' ), |
|
251 | - 'photoblogging' => __( 'Photoblogging' ), |
|
252 | - 'seasonal' => __( 'Seasonal' ), |
|
249 | + __('Subject') => array( |
|
250 | + 'holiday' => __('Holiday'), |
|
251 | + 'photoblogging' => __('Photoblogging'), |
|
252 | + 'seasonal' => __('Seasonal'), |
|
253 | 253 | ) |
254 | 254 | ); |
255 | 255 | |
256 | - if ( ! $api || ! current_user_can( 'install_themes' ) ) |
|
256 | + if ( ! $api || ! current_user_can('install_themes')) |
|
257 | 257 | return $features; |
258 | 258 | |
259 | - if ( !$feature_list = get_site_transient( 'wporg_theme_feature_list' ) ) |
|
260 | - set_site_transient( 'wporg_theme_feature_list', array(), 3 * HOUR_IN_SECONDS ); |
|
259 | + if ( ! $feature_list = get_site_transient('wporg_theme_feature_list')) |
|
260 | + set_site_transient('wporg_theme_feature_list', array(), 3 * HOUR_IN_SECONDS); |
|
261 | 261 | |
262 | - if ( !$feature_list ) { |
|
263 | - $feature_list = themes_api( 'feature_list', array() ); |
|
264 | - if ( is_wp_error( $feature_list ) ) |
|
262 | + if ( ! $feature_list) { |
|
263 | + $feature_list = themes_api('feature_list', array()); |
|
264 | + if (is_wp_error($feature_list)) |
|
265 | 265 | return $features; |
266 | 266 | } |
267 | 267 | |
268 | - if ( !$feature_list ) |
|
268 | + if ( ! $feature_list) |
|
269 | 269 | return $features; |
270 | 270 | |
271 | - set_site_transient( 'wporg_theme_feature_list', $feature_list, 3 * HOUR_IN_SECONDS ); |
|
271 | + set_site_transient('wporg_theme_feature_list', $feature_list, 3 * HOUR_IN_SECONDS); |
|
272 | 272 | |
273 | 273 | $category_translations = array( |
274 | - 'Colors' => __( 'Colors' ), |
|
275 | - 'Layout' => __( 'Layout' ), |
|
276 | - 'Features' => __( 'Features' ), |
|
277 | - 'Subject' => __( 'Subject' ) |
|
274 | + 'Colors' => __('Colors'), |
|
275 | + 'Layout' => __('Layout'), |
|
276 | + 'Features' => __('Features'), |
|
277 | + 'Subject' => __('Subject') |
|
278 | 278 | ); |
279 | 279 | |
280 | 280 | // Loop over the wporg canonical list and apply translations |
281 | 281 | $wporg_features = array(); |
282 | - foreach ( (array) $feature_list as $feature_category => $feature_items ) { |
|
283 | - if ( isset($category_translations[$feature_category]) ) |
|
282 | + foreach ((array) $feature_list as $feature_category => $feature_items) { |
|
283 | + if (isset($category_translations[$feature_category])) |
|
284 | 284 | $feature_category = $category_translations[$feature_category]; |
285 | 285 | $wporg_features[$feature_category] = array(); |
286 | 286 | |
287 | - foreach ( $feature_items as $feature ) { |
|
288 | - if ( isset($features[$feature_category][$feature]) ) |
|
287 | + foreach ($feature_items as $feature) { |
|
288 | + if (isset($features[$feature_category][$feature])) |
|
289 | 289 | $wporg_features[$feature_category][$feature] = $features[$feature_category][$feature]; |
290 | 290 | else |
291 | 291 | $wporg_features[$feature_category][$feature] = $feature; |
@@ -316,17 +316,17 @@ discard block |
||
316 | 316 | * @param array|object $args Optional. Arguments to serialize for the Theme Info API. |
317 | 317 | * @return mixed |
318 | 318 | */ |
319 | -function themes_api( $action, $args = null ) { |
|
319 | +function themes_api($action, $args = null) { |
|
320 | 320 | |
321 | - if ( is_array( $args ) ) { |
|
321 | + if (is_array($args)) { |
|
322 | 322 | $args = (object) $args; |
323 | 323 | } |
324 | 324 | |
325 | - if ( ! isset( $args->per_page ) ) { |
|
325 | + if ( ! isset($args->per_page)) { |
|
326 | 326 | $args->per_page = 24; |
327 | 327 | } |
328 | 328 | |
329 | - if ( ! isset( $args->locale ) ) { |
|
329 | + if ( ! isset($args->locale)) { |
|
330 | 330 | $args->locale = get_locale(); |
331 | 331 | } |
332 | 332 | |
@@ -341,7 +341,7 @@ discard block |
||
341 | 341 | * @param string $action Requested action. Likely values are 'theme_information', |
342 | 342 | * 'feature_list', or 'query_themes'. |
343 | 343 | */ |
344 | - $args = apply_filters( 'themes_api_args', $args, $action ); |
|
344 | + $args = apply_filters('themes_api_args', $args, $action); |
|
345 | 345 | |
346 | 346 | /** |
347 | 347 | * Filter whether to override the WordPress.org Themes API. |
@@ -356,34 +356,34 @@ discard block |
||
356 | 356 | * 'feature_list', or 'query_themes'. |
357 | 357 | * @param object $args Arguments used to query for installer pages from the Themes API. |
358 | 358 | */ |
359 | - $res = apply_filters( 'themes_api', false, $action, $args ); |
|
359 | + $res = apply_filters('themes_api', false, $action, $args); |
|
360 | 360 | |
361 | - if ( ! $res ) { |
|
361 | + if ( ! $res) { |
|
362 | 362 | $url = $http_url = 'http://api.wordpress.org/themes/info/1.0/'; |
363 | - if ( $ssl = wp_http_supports( array( 'ssl' ) ) ) |
|
364 | - $url = set_url_scheme( $url, 'https' ); |
|
363 | + if ($ssl = wp_http_supports(array('ssl'))) |
|
364 | + $url = set_url_scheme($url, 'https'); |
|
365 | 365 | |
366 | 366 | $http_args = array( |
367 | 367 | 'body' => array( |
368 | 368 | 'action' => $action, |
369 | - 'request' => serialize( $args ) |
|
369 | + 'request' => serialize($args) |
|
370 | 370 | ) |
371 | 371 | ); |
372 | - $request = wp_remote_post( $url, $http_args ); |
|
372 | + $request = wp_remote_post($url, $http_args); |
|
373 | 373 | |
374 | - if ( $ssl && is_wp_error( $request ) ) { |
|
375 | - if ( ! defined( 'DOING_AJAX' ) || ! DOING_AJAX ) { |
|
376 | - trigger_error( __( 'An unexpected error occurred. Something may be wrong with WordPress.org or this server’s configuration. If you continue to have problems, please try the <a href="https://wordpress.org/support/">support forums</a>.' ) . ' ' . __( '(WordPress could not establish a secure connection to WordPress.org. Please contact your server administrator.)' ), headers_sent() || WP_DEBUG ? E_USER_WARNING : E_USER_NOTICE ); |
|
374 | + if ($ssl && is_wp_error($request)) { |
|
375 | + if ( ! defined('DOING_AJAX') || ! DOING_AJAX) { |
|
376 | + trigger_error(__('An unexpected error occurred. Something may be wrong with WordPress.org or this server’s configuration. If you continue to have problems, please try the <a href="https://wordpress.org/support/">support forums</a>.').' '.__('(WordPress could not establish a secure connection to WordPress.org. Please contact your server administrator.)'), headers_sent() || WP_DEBUG ? E_USER_WARNING : E_USER_NOTICE); |
|
377 | 377 | } |
378 | - $request = wp_remote_post( $http_url, $http_args ); |
|
378 | + $request = wp_remote_post($http_url, $http_args); |
|
379 | 379 | } |
380 | 380 | |
381 | - if ( is_wp_error($request) ) { |
|
382 | - $res = new WP_Error('themes_api_failed', __( 'An unexpected error occurred. Something may be wrong with WordPress.org or this server’s configuration. If you continue to have problems, please try the <a href="https://wordpress.org/support/">support forums</a>.' ), $request->get_error_message() ); |
|
381 | + if (is_wp_error($request)) { |
|
382 | + $res = new WP_Error('themes_api_failed', __('An unexpected error occurred. Something may be wrong with WordPress.org or this server’s configuration. If you continue to have problems, please try the <a href="https://wordpress.org/support/">support forums</a>.'), $request->get_error_message()); |
|
383 | 383 | } else { |
384 | - $res = maybe_unserialize( wp_remote_retrieve_body( $request ) ); |
|
385 | - if ( ! is_object( $res ) && ! is_array( $res ) ) |
|
386 | - $res = new WP_Error('themes_api_failed', __( 'An unexpected error occurred. Something may be wrong with WordPress.org or this server’s configuration. If you continue to have problems, please try the <a href="https://wordpress.org/support/">support forums</a>.' ), wp_remote_retrieve_body( $request ) ); |
|
384 | + $res = maybe_unserialize(wp_remote_retrieve_body($request)); |
|
385 | + if ( ! is_object($res) && ! is_array($res)) |
|
386 | + $res = new WP_Error('themes_api_failed', __('An unexpected error occurred. Something may be wrong with WordPress.org or this server’s configuration. If you continue to have problems, please try the <a href="https://wordpress.org/support/">support forums</a>.'), wp_remote_retrieve_body($request)); |
|
387 | 387 | } |
388 | 388 | } |
389 | 389 | |
@@ -397,7 +397,7 @@ discard block |
||
397 | 397 | * 'feature_list', or 'query_themes'. |
398 | 398 | * @param object $args Arguments used to query for installer pages from the WordPress.org Themes API. |
399 | 399 | */ |
400 | - return apply_filters( 'themes_api_result', $res, $action, $args ); |
|
400 | + return apply_filters('themes_api_result', $res, $action, $args); |
|
401 | 401 | } |
402 | 402 | |
403 | 403 | /** |
@@ -410,7 +410,7 @@ discard block |
||
410 | 410 | * |
411 | 411 | * @return array An associative array of theme data, sorted by name. |
412 | 412 | */ |
413 | -function wp_prepare_themes_for_js( $themes = null ) { |
|
413 | +function wp_prepare_themes_for_js($themes = null) { |
|
414 | 414 | $current_theme = get_stylesheet(); |
415 | 415 | |
416 | 416 | /** |
@@ -425,68 +425,68 @@ discard block |
||
425 | 425 | * @param null|array $themes An array of WP_Theme objects to prepare, if any. |
426 | 426 | * @param string $current_theme The current theme slug. |
427 | 427 | */ |
428 | - $prepared_themes = (array) apply_filters( 'pre_prepare_themes_for_js', array(), $themes, $current_theme ); |
|
428 | + $prepared_themes = (array) apply_filters('pre_prepare_themes_for_js', array(), $themes, $current_theme); |
|
429 | 429 | |
430 | - if ( ! empty( $prepared_themes ) ) { |
|
430 | + if ( ! empty($prepared_themes)) { |
|
431 | 431 | return $prepared_themes; |
432 | 432 | } |
433 | 433 | |
434 | 434 | // Make sure the current theme is listed first. |
435 | - $prepared_themes[ $current_theme ] = array(); |
|
435 | + $prepared_themes[$current_theme] = array(); |
|
436 | 436 | |
437 | - if ( null === $themes ) { |
|
438 | - $themes = wp_get_themes( array( 'allowed' => true ) ); |
|
439 | - if ( ! isset( $themes[ $current_theme ] ) ) { |
|
440 | - $themes[ $current_theme ] = wp_get_theme(); |
|
437 | + if (null === $themes) { |
|
438 | + $themes = wp_get_themes(array('allowed' => true)); |
|
439 | + if ( ! isset($themes[$current_theme])) { |
|
440 | + $themes[$current_theme] = wp_get_theme(); |
|
441 | 441 | } |
442 | 442 | } |
443 | 443 | |
444 | 444 | $updates = array(); |
445 | - if ( current_user_can( 'update_themes' ) ) { |
|
446 | - $updates_transient = get_site_transient( 'update_themes' ); |
|
447 | - if ( isset( $updates_transient->response ) ) { |
|
445 | + if (current_user_can('update_themes')) { |
|
446 | + $updates_transient = get_site_transient('update_themes'); |
|
447 | + if (isset($updates_transient->response)) { |
|
448 | 448 | $updates = $updates_transient->response; |
449 | 449 | } |
450 | 450 | } |
451 | 451 | |
452 | - WP_Theme::sort_by_name( $themes ); |
|
452 | + WP_Theme::sort_by_name($themes); |
|
453 | 453 | |
454 | 454 | $parents = array(); |
455 | 455 | |
456 | - foreach ( $themes as $theme ) { |
|
456 | + foreach ($themes as $theme) { |
|
457 | 457 | $slug = $theme->get_stylesheet(); |
458 | - $encoded_slug = urlencode( $slug ); |
|
458 | + $encoded_slug = urlencode($slug); |
|
459 | 459 | |
460 | 460 | $parent = false; |
461 | - if ( $theme->parent() ) { |
|
462 | - $parent = $theme->parent()->display( 'Name' ); |
|
463 | - $parents[ $slug ] = $theme->parent()->get_stylesheet(); |
|
461 | + if ($theme->parent()) { |
|
462 | + $parent = $theme->parent()->display('Name'); |
|
463 | + $parents[$slug] = $theme->parent()->get_stylesheet(); |
|
464 | 464 | } |
465 | 465 | |
466 | - $prepared_themes[ $slug ] = array( |
|
466 | + $prepared_themes[$slug] = array( |
|
467 | 467 | 'id' => $slug, |
468 | - 'name' => $theme->display( 'Name' ), |
|
469 | - 'screenshot' => array( $theme->get_screenshot() ), // @todo multiple |
|
470 | - 'description' => $theme->display( 'Description' ), |
|
471 | - 'author' => $theme->display( 'Author', false, true ), |
|
472 | - 'authorAndUri' => $theme->display( 'Author' ), |
|
473 | - 'version' => $theme->display( 'Version' ), |
|
474 | - 'tags' => $theme->display( 'Tags' ), |
|
468 | + 'name' => $theme->display('Name'), |
|
469 | + 'screenshot' => array($theme->get_screenshot()), // @todo multiple |
|
470 | + 'description' => $theme->display('Description'), |
|
471 | + 'author' => $theme->display('Author', false, true), |
|
472 | + 'authorAndUri' => $theme->display('Author'), |
|
473 | + 'version' => $theme->display('Version'), |
|
474 | + 'tags' => $theme->display('Tags'), |
|
475 | 475 | 'parent' => $parent, |
476 | 476 | 'active' => $slug === $current_theme, |
477 | - 'hasUpdate' => isset( $updates[ $slug ] ), |
|
478 | - 'update' => get_theme_update_available( $theme ), |
|
477 | + 'hasUpdate' => isset($updates[$slug]), |
|
478 | + 'update' => get_theme_update_available($theme), |
|
479 | 479 | 'actions' => array( |
480 | - 'activate' => current_user_can( 'switch_themes' ) ? wp_nonce_url( admin_url( 'themes.php?action=activate&stylesheet=' . $encoded_slug ), 'switch-theme_' . $slug ) : null, |
|
481 | - 'customize' => ( current_user_can( 'edit_theme_options' ) && current_user_can( 'customize' ) ) ? wp_customize_url( $slug ) : null, |
|
482 | - 'delete' => current_user_can( 'delete_themes' ) ? wp_nonce_url( admin_url( 'themes.php?action=delete&stylesheet=' . $encoded_slug ), 'delete-theme_' . $slug ) : null, |
|
480 | + 'activate' => current_user_can('switch_themes') ? wp_nonce_url(admin_url('themes.php?action=activate&stylesheet='.$encoded_slug), 'switch-theme_'.$slug) : null, |
|
481 | + 'customize' => (current_user_can('edit_theme_options') && current_user_can('customize')) ? wp_customize_url($slug) : null, |
|
482 | + 'delete' => current_user_can('delete_themes') ? wp_nonce_url(admin_url('themes.php?action=delete&stylesheet='.$encoded_slug), 'delete-theme_'.$slug) : null, |
|
483 | 483 | ), |
484 | 484 | ); |
485 | 485 | } |
486 | 486 | |
487 | 487 | // Remove 'delete' action if theme has an active child |
488 | - if ( ! empty( $parents ) && array_key_exists( $current_theme, $parents ) ) { |
|
489 | - unset( $prepared_themes[ $parents[ $current_theme ] ]['actions']['delete'] ); |
|
488 | + if ( ! empty($parents) && array_key_exists($current_theme, $parents)) { |
|
489 | + unset($prepared_themes[$parents[$current_theme]]['actions']['delete']); |
|
490 | 490 | } |
491 | 491 | |
492 | 492 | /** |
@@ -498,9 +498,9 @@ discard block |
||
498 | 498 | * |
499 | 499 | * @param array $prepared_themes Array of themes. |
500 | 500 | */ |
501 | - $prepared_themes = apply_filters( 'wp_prepare_themes_for_js', $prepared_themes ); |
|
502 | - $prepared_themes = array_values( $prepared_themes ); |
|
503 | - return array_filter( $prepared_themes ); |
|
501 | + $prepared_themes = apply_filters('wp_prepare_themes_for_js', $prepared_themes); |
|
502 | + $prepared_themes = array_values($prepared_themes); |
|
503 | + return array_filter($prepared_themes); |
|
504 | 504 | } |
505 | 505 | |
506 | 506 | /** |
@@ -509,16 +509,16 @@ discard block |
||
509 | 509 | * @since 4.2.0 |
510 | 510 | */ |
511 | 511 | function customize_themes_print_templates() { |
512 | - $preview_url = esc_url( add_query_arg( 'theme', '__THEME__' ) ); // Token because esc_url() strips curly braces. |
|
513 | - $preview_url = str_replace( '__THEME__', '{{ data.id }}', $preview_url ); |
|
512 | + $preview_url = esc_url(add_query_arg('theme', '__THEME__')); // Token because esc_url() strips curly braces. |
|
513 | + $preview_url = str_replace('__THEME__', '{{ data.id }}', $preview_url); |
|
514 | 514 | ?> |
515 | 515 | <script type="text/html" id="tmpl-customize-themes-details-view"> |
516 | 516 | <div class="theme-backdrop"></div> |
517 | 517 | <div class="theme-wrap"> |
518 | 518 | <div class="theme-header"> |
519 | - <button type="button" class="left dashicons dashicons-no"><span class="screen-reader-text"><?php _e( 'Show previous theme' ); ?></span></button> |
|
520 | - <button type="button" class="right dashicons dashicons-no"><span class="screen-reader-text"><?php _e( 'Show next theme' ); ?></span></button> |
|
521 | - <button type="button" class="close dashicons dashicons-no"><span class="screen-reader-text"><?php _e( 'Close details dialog' ); ?></span></button> |
|
519 | + <button type="button" class="left dashicons dashicons-no"><span class="screen-reader-text"><?php _e('Show previous theme'); ?></span></button> |
|
520 | + <button type="button" class="right dashicons dashicons-no"><span class="screen-reader-text"><?php _e('Show next theme'); ?></span></button> |
|
521 | + <button type="button" class="close dashicons dashicons-no"><span class="screen-reader-text"><?php _e('Close details dialog'); ?></span></button> |
|
522 | 522 | </div> |
523 | 523 | <div class="theme-about"> |
524 | 524 | <div class="theme-screenshots"> |
@@ -531,18 +531,18 @@ discard block |
||
531 | 531 | |
532 | 532 | <div class="theme-info"> |
533 | 533 | <# if ( data.active ) { #> |
534 | - <span class="current-label"><?php _e( 'Current Theme' ); ?></span> |
|
534 | + <span class="current-label"><?php _e('Current Theme'); ?></span> |
|
535 | 535 | <# } #> |
536 | - <h3 class="theme-name">{{{ data.name }}}<span class="theme-version"><?php printf( __( 'Version: %s' ), '{{ data.version }}' ); ?></span></h3> |
|
537 | - <h4 class="theme-author"><?php printf( __( 'By %s' ), '{{{ data.authorAndUri }}}' ); ?></h4> |
|
536 | + <h3 class="theme-name">{{{ data.name }}}<span class="theme-version"><?php printf(__('Version: %s'), '{{ data.version }}'); ?></span></h3> |
|
537 | + <h4 class="theme-author"><?php printf(__('By %s'), '{{{ data.authorAndUri }}}'); ?></h4> |
|
538 | 538 | <p class="theme-description">{{{ data.description }}}</p> |
539 | 539 | |
540 | 540 | <# if ( data.parent ) { #> |
541 | - <p class="parent-theme"><?php printf( __( 'This is a child theme of %s.' ), '<strong>{{{ data.parent }}}</strong>' ); ?></p> |
|
541 | + <p class="parent-theme"><?php printf(__('This is a child theme of %s.'), '<strong>{{{ data.parent }}}</strong>'); ?></p> |
|
542 | 542 | <# } #> |
543 | 543 | |
544 | 544 | <# if ( data.tags ) { #> |
545 | - <p class="theme-tags"><span><?php _e( 'Tags:' ); ?></span> {{ data.tags }}</p> |
|
545 | + <p class="theme-tags"><span><?php _e('Tags:'); ?></span> {{ data.tags }}</p> |
|
546 | 546 | <# } #> |
547 | 547 | </div> |
548 | 548 | </div> |
@@ -550,7 +550,7 @@ discard block |
||
550 | 550 | <# if ( ! data.active ) { #> |
551 | 551 | <div class="theme-actions"> |
552 | 552 | <div class="inactive-theme"> |
553 | - <a href="<?php echo $preview_url; ?>" target="_top" class="button button-primary"><?php _e( 'Live Preview' ); ?></a> |
|
553 | + <a href="<?php echo $preview_url; ?>" target="_top" class="button button-primary"><?php _e('Live Preview'); ?></a> |
|
554 | 554 | </div> |
555 | 555 | </div> |
556 | 556 | <# } #> |
@@ -20,12 +20,14 @@ discard block |
||
20 | 20 | function delete_theme($stylesheet, $redirect = '') { |
21 | 21 | global $wp_filesystem; |
22 | 22 | |
23 | - if ( empty($stylesheet) ) |
|
24 | - return false; |
|
23 | + if ( empty($stylesheet) ) { |
|
24 | + return false; |
|
25 | + } |
|
25 | 26 | |
26 | 27 | ob_start(); |
27 | - if ( empty( $redirect ) ) |
|
28 | - $redirect = wp_nonce_url('themes.php?action=delete&stylesheet=' . urlencode( $stylesheet ), 'delete-theme_' . $stylesheet); |
|
28 | + if ( empty( $redirect ) ) { |
|
29 | + $redirect = wp_nonce_url('themes.php?action=delete&stylesheet=' . urlencode( $stylesheet ), 'delete-theme_' . $stylesheet); |
|
30 | + } |
|
29 | 31 | if ( false === ($credentials = request_filesystem_credentials($redirect)) ) { |
30 | 32 | $data = ob_get_clean(); |
31 | 33 | |
@@ -51,11 +53,13 @@ discard block |
||
51 | 53 | return; |
52 | 54 | } |
53 | 55 | |
54 | - if ( ! is_object($wp_filesystem) ) |
|
55 | - return new WP_Error('fs_unavailable', __('Could not access filesystem.')); |
|
56 | + if ( ! is_object($wp_filesystem) ) { |
|
57 | + return new WP_Error('fs_unavailable', __('Could not access filesystem.')); |
|
58 | + } |
|
56 | 59 | |
57 | - if ( is_wp_error($wp_filesystem->errors) && $wp_filesystem->errors->get_error_code() ) |
|
58 | - return new WP_Error('fs_error', __('Filesystem error.'), $wp_filesystem->errors); |
|
60 | + if ( is_wp_error($wp_filesystem->errors) && $wp_filesystem->errors->get_error_code() ) { |
|
61 | + return new WP_Error('fs_error', __('Filesystem error.'), $wp_filesystem->errors); |
|
62 | + } |
|
59 | 63 | |
60 | 64 | // Get the base plugin folder. |
61 | 65 | $themes_dir = $wp_filesystem->wp_themes_dir(); |
@@ -144,11 +148,13 @@ discard block |
||
144 | 148 | function get_theme_update_available( $theme ) { |
145 | 149 | static $themes_update = null; |
146 | 150 | |
147 | - if ( !current_user_can('update_themes' ) ) |
|
148 | - return false; |
|
151 | + if ( !current_user_can('update_themes' ) ) { |
|
152 | + return false; |
|
153 | + } |
|
149 | 154 | |
150 | - if ( !isset($themes_update) ) |
|
151 | - $themes_update = get_site_transient('update_themes'); |
|
155 | + if ( !isset($themes_update) ) { |
|
156 | + $themes_update = get_site_transient('update_themes'); |
|
157 | + } |
|
152 | 158 | |
153 | 159 | if ( ! ( $theme instanceof WP_Theme ) ) { |
154 | 160 | return false; |
@@ -253,20 +259,24 @@ discard block |
||
253 | 259 | ) |
254 | 260 | ); |
255 | 261 | |
256 | - if ( ! $api || ! current_user_can( 'install_themes' ) ) |
|
257 | - return $features; |
|
262 | + if ( ! $api || ! current_user_can( 'install_themes' ) ) { |
|
263 | + return $features; |
|
264 | + } |
|
258 | 265 | |
259 | - if ( !$feature_list = get_site_transient( 'wporg_theme_feature_list' ) ) |
|
260 | - set_site_transient( 'wporg_theme_feature_list', array(), 3 * HOUR_IN_SECONDS ); |
|
266 | + if ( !$feature_list = get_site_transient( 'wporg_theme_feature_list' ) ) { |
|
267 | + set_site_transient( 'wporg_theme_feature_list', array(), 3 * HOUR_IN_SECONDS ); |
|
268 | + } |
|
261 | 269 | |
262 | 270 | if ( !$feature_list ) { |
263 | 271 | $feature_list = themes_api( 'feature_list', array() ); |
264 | - if ( is_wp_error( $feature_list ) ) |
|
265 | - return $features; |
|
272 | + if ( is_wp_error( $feature_list ) ) { |
|
273 | + return $features; |
|
274 | + } |
|
266 | 275 | } |
267 | 276 | |
268 | - if ( !$feature_list ) |
|
269 | - return $features; |
|
277 | + if ( !$feature_list ) { |
|
278 | + return $features; |
|
279 | + } |
|
270 | 280 | |
271 | 281 | set_site_transient( 'wporg_theme_feature_list', $feature_list, 3 * HOUR_IN_SECONDS ); |
272 | 282 | |
@@ -280,15 +290,17 @@ discard block |
||
280 | 290 | // Loop over the wporg canonical list and apply translations |
281 | 291 | $wporg_features = array(); |
282 | 292 | foreach ( (array) $feature_list as $feature_category => $feature_items ) { |
283 | - if ( isset($category_translations[$feature_category]) ) |
|
284 | - $feature_category = $category_translations[$feature_category]; |
|
293 | + if ( isset($category_translations[$feature_category]) ) { |
|
294 | + $feature_category = $category_translations[$feature_category]; |
|
295 | + } |
|
285 | 296 | $wporg_features[$feature_category] = array(); |
286 | 297 | |
287 | 298 | foreach ( $feature_items as $feature ) { |
288 | - if ( isset($features[$feature_category][$feature]) ) |
|
289 | - $wporg_features[$feature_category][$feature] = $features[$feature_category][$feature]; |
|
290 | - else |
|
291 | - $wporg_features[$feature_category][$feature] = $feature; |
|
299 | + if ( isset($features[$feature_category][$feature]) ) { |
|
300 | + $wporg_features[$feature_category][$feature] = $features[$feature_category][$feature]; |
|
301 | + } else { |
|
302 | + $wporg_features[$feature_category][$feature] = $feature; |
|
303 | + } |
|
292 | 304 | } |
293 | 305 | } |
294 | 306 | |
@@ -360,8 +372,9 @@ discard block |
||
360 | 372 | |
361 | 373 | if ( ! $res ) { |
362 | 374 | $url = $http_url = 'http://api.wordpress.org/themes/info/1.0/'; |
363 | - if ( $ssl = wp_http_supports( array( 'ssl' ) ) ) |
|
364 | - $url = set_url_scheme( $url, 'https' ); |
|
375 | + if ( $ssl = wp_http_supports( array( 'ssl' ) ) ) { |
|
376 | + $url = set_url_scheme( $url, 'https' ); |
|
377 | + } |
|
365 | 378 | |
366 | 379 | $http_args = array( |
367 | 380 | 'body' => array( |
@@ -382,8 +395,9 @@ discard block |
||
382 | 395 | $res = new WP_Error('themes_api_failed', __( 'An unexpected error occurred. Something may be wrong with WordPress.org or this server’s configuration. If you continue to have problems, please try the <a href="https://wordpress.org/support/">support forums</a>.' ), $request->get_error_message() ); |
383 | 396 | } else { |
384 | 397 | $res = maybe_unserialize( wp_remote_retrieve_body( $request ) ); |
385 | - if ( ! is_object( $res ) && ! is_array( $res ) ) |
|
386 | - $res = new WP_Error('themes_api_failed', __( 'An unexpected error occurred. Something may be wrong with WordPress.org or this server’s configuration. If you continue to have problems, please try the <a href="https://wordpress.org/support/">support forums</a>.' ), wp_remote_retrieve_body( $request ) ); |
|
398 | + if ( ! is_object( $res ) && ! is_array( $res ) ) { |
|
399 | + $res = new WP_Error('themes_api_failed', __( 'An unexpected error occurred. Something may be wrong with WordPress.org or this server’s configuration. If you continue to have problems, please try the <a href="https://wordpress.org/support/">support forums</a>.' ), wp_remote_retrieve_body( $request ) ); |
|
400 | + } |
|
387 | 401 | } |
388 | 402 | } |
389 | 403 |
@@ -1,9 +1,9 @@ |
||
1 | 1 | <?php |
2 | 2 | /** |
3 | - * Class for implementing site icon functionality. |
|
4 | - * |
|
5 | - * @since 4.3.0 |
|
6 | - */ |
|
3 | + * Class for implementing site icon functionality. |
|
4 | + * |
|
5 | + * @since 4.3.0 |
|
6 | + */ |
|
7 | 7 | class WP_Site_Icon { |
8 | 8 | |
9 | 9 | /** |
@@ -13,7 +13,7 @@ discard block |
||
13 | 13 | * @access public |
14 | 14 | * @var int |
15 | 15 | */ |
16 | - public $min_size = 512; |
|
16 | + public $min_size = 512; |
|
17 | 17 | |
18 | 18 | /** |
19 | 19 | * The size to which to crop the image so that we can display it in the UI nicely. |
@@ -65,8 +65,8 @@ discard block |
||
65 | 65 | * @access public |
66 | 66 | */ |
67 | 67 | public function __construct() { |
68 | - add_action( 'delete_attachment', array( $this, 'delete_attachment_data' ) ); |
|
69 | - add_filter( 'get_post_metadata', array( $this, 'get_post_metadata' ), 10, 4 ); |
|
68 | + add_action('delete_attachment', array($this, 'delete_attachment_data')); |
|
69 | + add_filter('get_post_metadata', array($this, 'get_post_metadata'), 10, 4); |
|
70 | 70 | } |
71 | 71 | |
72 | 72 | /** |
@@ -78,17 +78,17 @@ discard block |
||
78 | 78 | * @param int $parent_attachment_id Attachment ID of parent image. |
79 | 79 | * @return array Attachment object. |
80 | 80 | */ |
81 | - public function create_attachment_object( $cropped, $parent_attachment_id ) { |
|
82 | - $parent = get_post( $parent_attachment_id ); |
|
81 | + public function create_attachment_object($cropped, $parent_attachment_id) { |
|
82 | + $parent = get_post($parent_attachment_id); |
|
83 | 83 | $parent_url = $parent->guid; |
84 | - $url = str_replace( basename( $parent_url ), basename( $cropped ), $parent_url ); |
|
84 | + $url = str_replace(basename($parent_url), basename($cropped), $parent_url); |
|
85 | 85 | |
86 | - $size = @getimagesize( $cropped ); |
|
87 | - $image_type = ( $size ) ? $size['mime'] : 'image/jpeg'; |
|
86 | + $size = @getimagesize($cropped); |
|
87 | + $image_type = ($size) ? $size['mime'] : 'image/jpeg'; |
|
88 | 88 | |
89 | 89 | $object = array( |
90 | 90 | 'ID' => $parent_attachment_id, |
91 | - 'post_title' => basename( $cropped ), |
|
91 | + 'post_title' => basename($cropped), |
|
92 | 92 | 'post_content' => $url, |
93 | 93 | 'post_mime_type' => $image_type, |
94 | 94 | 'guid' => $url, |
@@ -108,9 +108,9 @@ discard block |
||
108 | 108 | * @param string $file File path of the attached image. |
109 | 109 | * @return int Attachment ID |
110 | 110 | */ |
111 | - public function insert_attachment( $object, $file ) { |
|
112 | - $attachment_id = wp_insert_attachment( $object, $file ); |
|
113 | - $metadata = wp_generate_attachment_metadata( $attachment_id, $file ); |
|
111 | + public function insert_attachment($object, $file) { |
|
112 | + $attachment_id = wp_insert_attachment($object, $file); |
|
113 | + $metadata = wp_generate_attachment_metadata($attachment_id, $file); |
|
114 | 114 | |
115 | 115 | /** |
116 | 116 | * Filter the site icon attachment metadata. |
@@ -121,8 +121,8 @@ discard block |
||
121 | 121 | * |
122 | 122 | * @param array $metadata Attachment metadata. |
123 | 123 | */ |
124 | - $metadata = apply_filters( 'site_icon_attachment_metadata', $metadata ); |
|
125 | - wp_update_attachment_metadata( $attachment_id, $metadata ); |
|
124 | + $metadata = apply_filters('site_icon_attachment_metadata', $metadata); |
|
125 | + wp_update_attachment_metadata($attachment_id, $metadata); |
|
126 | 126 | |
127 | 127 | return $attachment_id; |
128 | 128 | } |
@@ -136,7 +136,7 @@ discard block |
||
136 | 136 | * @param array $sizes List of additional sizes. |
137 | 137 | * @return array Additional image sizes. |
138 | 138 | */ |
139 | - public function additional_sizes( $sizes = array() ) { |
|
139 | + public function additional_sizes($sizes = array()) { |
|
140 | 140 | $only_crop_sizes = array(); |
141 | 141 | |
142 | 142 | /** |
@@ -146,22 +146,22 @@ discard block |
||
146 | 146 | * |
147 | 147 | * @param array $site_icon_sizes Sizes available for the Site Icon. |
148 | 148 | */ |
149 | - $this->site_icon_sizes = apply_filters( 'site_icon_image_sizes', $this->site_icon_sizes ); |
|
149 | + $this->site_icon_sizes = apply_filters('site_icon_image_sizes', $this->site_icon_sizes); |
|
150 | 150 | |
151 | 151 | // Use a natural sort of numbers. |
152 | - natsort( $this->site_icon_sizes ); |
|
153 | - $this->site_icon_sizes = array_reverse( $this->site_icon_sizes ); |
|
152 | + natsort($this->site_icon_sizes); |
|
153 | + $this->site_icon_sizes = array_reverse($this->site_icon_sizes); |
|
154 | 154 | |
155 | 155 | // ensure that we only resize the image into |
156 | - foreach ( $sizes as $name => $size_array ) { |
|
157 | - if ( isset( $size_array['crop'] ) ) { |
|
158 | - $only_crop_sizes[ $name ] = $size_array; |
|
156 | + foreach ($sizes as $name => $size_array) { |
|
157 | + if (isset($size_array['crop'])) { |
|
158 | + $only_crop_sizes[$name] = $size_array; |
|
159 | 159 | } |
160 | 160 | } |
161 | 161 | |
162 | - foreach ( $this->site_icon_sizes as $size ) { |
|
163 | - if ( $size < $this->min_size ) { |
|
164 | - $only_crop_sizes[ 'site_icon-' . $size ] = array( |
|
162 | + foreach ($this->site_icon_sizes as $size) { |
|
163 | + if ($size < $this->min_size) { |
|
164 | + $only_crop_sizes['site_icon-'.$size] = array( |
|
165 | 165 | 'width ' => $size, |
166 | 166 | 'height' => $size, |
167 | 167 | 'crop' => true, |
@@ -181,11 +181,11 @@ discard block |
||
181 | 181 | * @param array $sizes List of image sizes. |
182 | 182 | * @return array List of intermediate image sizes. |
183 | 183 | */ |
184 | - public function intermediate_image_sizes( $sizes = array() ) { |
|
184 | + public function intermediate_image_sizes($sizes = array()) { |
|
185 | 185 | /** This filter is documented in wp-admin/includes/class-wp-site-icon.php */ |
186 | - $this->site_icon_sizes = apply_filters( 'site_icon_image_sizes', $this->site_icon_sizes ); |
|
187 | - foreach ( $this->site_icon_sizes as $size ) { |
|
188 | - $sizes[] = 'site_icon-' . $size; |
|
186 | + $this->site_icon_sizes = apply_filters('site_icon_image_sizes', $this->site_icon_sizes); |
|
187 | + foreach ($this->site_icon_sizes as $size) { |
|
188 | + $sizes[] = 'site_icon-'.$size; |
|
189 | 189 | } |
190 | 190 | |
191 | 191 | return $sizes; |
@@ -199,11 +199,11 @@ discard block |
||
199 | 199 | * |
200 | 200 | * @param int $post_id Attachment ID. |
201 | 201 | */ |
202 | - public function delete_attachment_data( $post_id ) { |
|
203 | - $site_icon_id = get_option( 'site_icon' ); |
|
202 | + public function delete_attachment_data($post_id) { |
|
203 | + $site_icon_id = get_option('site_icon'); |
|
204 | 204 | |
205 | - if ( $site_icon_id && $post_id == $site_icon_id ) { |
|
206 | - delete_option( 'site_icon' ); |
|
205 | + if ($site_icon_id && $post_id == $site_icon_id) { |
|
206 | + delete_option('site_icon'); |
|
207 | 207 | } |
208 | 208 | } |
209 | 209 | |
@@ -220,11 +220,11 @@ discard block |
||
220 | 220 | * @param string|array $single Meta value, or an array of values. |
221 | 221 | * @return array|null|string The attachment metadata value, array of values, or null. |
222 | 222 | */ |
223 | - public function get_post_metadata( $value, $post_id, $meta_key, $single ) { |
|
224 | - $site_icon_id = get_option( 'site_icon' ); |
|
223 | + public function get_post_metadata($value, $post_id, $meta_key, $single) { |
|
224 | + $site_icon_id = get_option('site_icon'); |
|
225 | 225 | |
226 | - if ( $post_id == $site_icon_id && '_wp_attachment_backup_sizes' == $meta_key && $single ) { |
|
227 | - add_filter( 'intermediate_image_sizes', array( $this, 'intermediate_image_sizes' ) ); |
|
226 | + if ($post_id == $site_icon_id && '_wp_attachment_backup_sizes' == $meta_key && $single) { |
|
227 | + add_filter('intermediate_image_sizes', array($this, 'intermediate_image_sizes')); |
|
228 | 228 | } |
229 | 229 | |
230 | 230 | return $value; |
@@ -1,12 +1,12 @@ |
||
1 | 1 | <?php |
2 | 2 | /** |
3 | - * Sites List Table class. |
|
4 | - * |
|
5 | - * @package WordPress |
|
6 | - * @subpackage List_Table |
|
7 | - * @since 3.1.0 |
|
8 | - * @access private |
|
9 | - */ |
|
3 | + * Sites List Table class. |
|
4 | + * |
|
5 | + * @package WordPress |
|
6 | + * @subpackage List_Table |
|
7 | + * @since 3.1.0 |
|
8 | + * @access private |
|
9 | + */ |
|
10 | 10 | class WP_MS_Sites_List_Table extends WP_List_Table { |
11 | 11 | |
12 | 12 | /** |
@@ -28,18 +28,18 @@ discard block |
||
28 | 28 | * |
29 | 29 | * @param array $args An associative array of arguments. |
30 | 30 | */ |
31 | - public function __construct( $args = array() ) { |
|
31 | + public function __construct($args = array()) { |
|
32 | 32 | $this->status_list = array( |
33 | - 'archived' => array( 'site-archived', __( 'Archived' ) ), |
|
34 | - 'spam' => array( 'site-spammed', _x( 'Spam', 'site' ) ), |
|
35 | - 'deleted' => array( 'site-deleted', __( 'Deleted' ) ), |
|
36 | - 'mature' => array( 'site-mature', __( 'Mature' ) ) |
|
33 | + 'archived' => array('site-archived', __('Archived')), |
|
34 | + 'spam' => array('site-spammed', _x('Spam', 'site')), |
|
35 | + 'deleted' => array('site-deleted', __('Deleted')), |
|
36 | + 'mature' => array('site-mature', __('Mature')) |
|
37 | 37 | ); |
38 | 38 | |
39 | - parent::__construct( array( |
|
39 | + parent::__construct(array( |
|
40 | 40 | 'plural' => 'sites', |
41 | - 'screen' => isset( $args['screen'] ) ? $args['screen'] : null, |
|
42 | - ) ); |
|
41 | + 'screen' => isset($args['screen']) ? $args['screen'] : null, |
|
42 | + )); |
|
43 | 43 | } |
44 | 44 | |
45 | 45 | /** |
@@ -47,7 +47,7 @@ discard block |
||
47 | 47 | * @return bool |
48 | 48 | */ |
49 | 49 | public function ajax_user_can() { |
50 | - return current_user_can( 'manage_sites' ); |
|
50 | + return current_user_can('manage_sites'); |
|
51 | 51 | } |
52 | 52 | |
53 | 53 | /** |
@@ -61,15 +61,15 @@ discard block |
||
61 | 61 | |
62 | 62 | $current_site = get_current_site(); |
63 | 63 | |
64 | - $mode = ( empty( $_REQUEST['mode'] ) ) ? 'list' : $_REQUEST['mode']; |
|
64 | + $mode = (empty($_REQUEST['mode'])) ? 'list' : $_REQUEST['mode']; |
|
65 | 65 | |
66 | - $per_page = $this->get_items_per_page( 'sites_network_per_page' ); |
|
66 | + $per_page = $this->get_items_per_page('sites_network_per_page'); |
|
67 | 67 | |
68 | 68 | $pagenum = $this->get_pagenum(); |
69 | 69 | |
70 | - $s = isset( $_REQUEST['s'] ) ? wp_unslash( trim( $_REQUEST[ 's' ] ) ) : ''; |
|
70 | + $s = isset($_REQUEST['s']) ? wp_unslash(trim($_REQUEST['s'])) : ''; |
|
71 | 71 | $wild = ''; |
72 | - if ( false !== strpos($s, '*') ) { |
|
72 | + if (false !== strpos($s, '*')) { |
|
73 | 73 | $wild = '%'; |
74 | 74 | $s = trim($s, '*'); |
75 | 75 | } |
@@ -78,92 +78,92 @@ discard block |
||
78 | 78 | * If the network is large and a search is not being performed, show only |
79 | 79 | * the latest blogs with no paging in order to avoid expensive count queries. |
80 | 80 | */ |
81 | - if ( !$s && wp_is_large_network() ) { |
|
82 | - if ( !isset($_REQUEST['orderby']) ) |
|
81 | + if ( ! $s && wp_is_large_network()) { |
|
82 | + if ( ! isset($_REQUEST['orderby'])) |
|
83 | 83 | $_GET['orderby'] = $_REQUEST['orderby'] = ''; |
84 | - if ( !isset($_REQUEST['order']) ) |
|
84 | + if ( ! isset($_REQUEST['order'])) |
|
85 | 85 | $_GET['order'] = $_REQUEST['order'] = 'DESC'; |
86 | 86 | } |
87 | 87 | |
88 | 88 | $query = "SELECT * FROM {$wpdb->blogs} WHERE site_id = '{$wpdb->siteid}' "; |
89 | 89 | |
90 | - if ( empty($s) ) { |
|
90 | + if (empty($s)) { |
|
91 | 91 | // Nothing to do. |
92 | - } elseif ( preg_match( '/^[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}$/', $s ) || |
|
93 | - preg_match( '/^[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.?$/', $s ) || |
|
94 | - preg_match( '/^[0-9]{1,3}\.[0-9]{1,3}\.?$/', $s ) || |
|
95 | - preg_match( '/^[0-9]{1,3}\.$/', $s ) ) { |
|
92 | + } elseif (preg_match('/^[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}$/', $s) || |
|
93 | + preg_match('/^[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.?$/', $s) || |
|
94 | + preg_match('/^[0-9]{1,3}\.[0-9]{1,3}\.?$/', $s) || |
|
95 | + preg_match('/^[0-9]{1,3}\.$/', $s)) { |
|
96 | 96 | // IPv4 address |
97 | - $sql = $wpdb->prepare( "SELECT blog_id FROM {$wpdb->registration_log} WHERE {$wpdb->registration_log}.IP LIKE %s", $wpdb->esc_like( $s ) . $wild ); |
|
98 | - $reg_blog_ids = $wpdb->get_col( $sql ); |
|
97 | + $sql = $wpdb->prepare("SELECT blog_id FROM {$wpdb->registration_log} WHERE {$wpdb->registration_log}.IP LIKE %s", $wpdb->esc_like($s).$wild); |
|
98 | + $reg_blog_ids = $wpdb->get_col($sql); |
|
99 | 99 | |
100 | - if ( !$reg_blog_ids ) |
|
101 | - $reg_blog_ids = array( 0 ); |
|
100 | + if ( ! $reg_blog_ids) |
|
101 | + $reg_blog_ids = array(0); |
|
102 | 102 | |
103 | 103 | $query = "SELECT * |
104 | 104 | FROM {$wpdb->blogs} |
105 | 105 | WHERE site_id = '{$wpdb->siteid}' |
106 | - AND {$wpdb->blogs}.blog_id IN (" . implode( ', ', $reg_blog_ids ) . ")"; |
|
106 | + AND {$wpdb->blogs}.blog_id IN (".implode(', ', $reg_blog_ids).")"; |
|
107 | 107 | } else { |
108 | - if ( is_numeric($s) && empty( $wild ) ) { |
|
109 | - $query .= $wpdb->prepare( " AND ( {$wpdb->blogs}.blog_id = %s )", $s ); |
|
110 | - } elseif ( is_subdomain_install() ) { |
|
111 | - $blog_s = str_replace( '.' . $current_site->domain, '', $s ); |
|
112 | - $blog_s = $wpdb->esc_like( $blog_s ) . $wild . $wpdb->esc_like( '.' . $current_site->domain ); |
|
113 | - $query .= $wpdb->prepare( " AND ( {$wpdb->blogs}.domain LIKE %s ) ", $blog_s ); |
|
108 | + if (is_numeric($s) && empty($wild)) { |
|
109 | + $query .= $wpdb->prepare(" AND ( {$wpdb->blogs}.blog_id = %s )", $s); |
|
110 | + } elseif (is_subdomain_install()) { |
|
111 | + $blog_s = str_replace('.'.$current_site->domain, '', $s); |
|
112 | + $blog_s = $wpdb->esc_like($blog_s).$wild.$wpdb->esc_like('.'.$current_site->domain); |
|
113 | + $query .= $wpdb->prepare(" AND ( {$wpdb->blogs}.domain LIKE %s ) ", $blog_s); |
|
114 | 114 | } else { |
115 | - if ( $s != trim('/', $current_site->path) ) { |
|
116 | - $blog_s = $wpdb->esc_like( $current_site->path . $s ) . $wild . $wpdb->esc_like( '/' ); |
|
115 | + if ($s != trim('/', $current_site->path)) { |
|
116 | + $blog_s = $wpdb->esc_like($current_site->path.$s).$wild.$wpdb->esc_like('/'); |
|
117 | 117 | } else { |
118 | - $blog_s = $wpdb->esc_like( $s ); |
|
118 | + $blog_s = $wpdb->esc_like($s); |
|
119 | 119 | } |
120 | - $query .= $wpdb->prepare( " AND ( {$wpdb->blogs}.path LIKE %s )", $blog_s ); |
|
120 | + $query .= $wpdb->prepare(" AND ( {$wpdb->blogs}.path LIKE %s )", $blog_s); |
|
121 | 121 | } |
122 | 122 | } |
123 | 123 | |
124 | - $order_by = isset( $_REQUEST['orderby'] ) ? $_REQUEST['orderby'] : ''; |
|
125 | - if ( $order_by == 'registered' ) { |
|
124 | + $order_by = isset($_REQUEST['orderby']) ? $_REQUEST['orderby'] : ''; |
|
125 | + if ($order_by == 'registered') { |
|
126 | 126 | $query .= ' ORDER BY registered '; |
127 | - } elseif ( $order_by == 'lastupdated' ) { |
|
127 | + } elseif ($order_by == 'lastupdated') { |
|
128 | 128 | $query .= ' ORDER BY last_updated '; |
129 | - } elseif ( $order_by == 'blogname' ) { |
|
130 | - if ( is_subdomain_install() ) { |
|
129 | + } elseif ($order_by == 'blogname') { |
|
130 | + if (is_subdomain_install()) { |
|
131 | 131 | $query .= ' ORDER BY domain '; |
132 | 132 | } else { |
133 | 133 | $query .= ' ORDER BY path '; |
134 | 134 | } |
135 | - } elseif ( $order_by == 'blog_id' ) { |
|
135 | + } elseif ($order_by == 'blog_id') { |
|
136 | 136 | $query .= ' ORDER BY blog_id '; |
137 | 137 | } else { |
138 | 138 | $order_by = null; |
139 | 139 | } |
140 | 140 | |
141 | - if ( isset( $order_by ) ) { |
|
142 | - $order = ( isset( $_REQUEST['order'] ) && 'DESC' == strtoupper( $_REQUEST['order'] ) ) ? "DESC" : "ASC"; |
|
141 | + if (isset($order_by)) { |
|
142 | + $order = (isset($_REQUEST['order']) && 'DESC' == strtoupper($_REQUEST['order'])) ? "DESC" : "ASC"; |
|
143 | 143 | $query .= $order; |
144 | 144 | } |
145 | 145 | |
146 | 146 | // Don't do an unbounded count on large networks |
147 | - if ( ! wp_is_large_network() ) |
|
148 | - $total = $wpdb->get_var( str_replace( 'SELECT *', 'SELECT COUNT( blog_id )', $query ) ); |
|
147 | + if ( ! wp_is_large_network()) |
|
148 | + $total = $wpdb->get_var(str_replace('SELECT *', 'SELECT COUNT( blog_id )', $query)); |
|
149 | 149 | |
150 | - $query .= " LIMIT " . intval( ( $pagenum - 1 ) * $per_page ) . ", " . intval( $per_page ); |
|
151 | - $this->items = $wpdb->get_results( $query, ARRAY_A ); |
|
150 | + $query .= " LIMIT ".intval(($pagenum - 1) * $per_page).", ".intval($per_page); |
|
151 | + $this->items = $wpdb->get_results($query, ARRAY_A); |
|
152 | 152 | |
153 | - if ( wp_is_large_network() ) |
|
153 | + if (wp_is_large_network()) |
|
154 | 154 | $total = count($this->items); |
155 | 155 | |
156 | - $this->set_pagination_args( array( |
|
156 | + $this->set_pagination_args(array( |
|
157 | 157 | 'total_items' => $total, |
158 | 158 | 'per_page' => $per_page, |
159 | - ) ); |
|
159 | + )); |
|
160 | 160 | } |
161 | 161 | |
162 | 162 | /** |
163 | 163 | * @access public |
164 | 164 | */ |
165 | 165 | public function no_items() { |
166 | - _e( 'No sites found.' ); |
|
166 | + _e('No sites found.'); |
|
167 | 167 | } |
168 | 168 | |
169 | 169 | /** |
@@ -172,10 +172,10 @@ discard block |
||
172 | 172 | */ |
173 | 173 | protected function get_bulk_actions() { |
174 | 174 | $actions = array(); |
175 | - if ( current_user_can( 'delete_sites' ) ) |
|
176 | - $actions['delete'] = __( 'Delete' ); |
|
177 | - $actions['spam'] = _x( 'Mark as Spam', 'site' ); |
|
178 | - $actions['notspam'] = _x( 'Not Spam', 'site' ); |
|
175 | + if (current_user_can('delete_sites')) |
|
176 | + $actions['delete'] = __('Delete'); |
|
177 | + $actions['spam'] = _x('Mark as Spam', 'site'); |
|
178 | + $actions['notspam'] = _x('Not Spam', 'site'); |
|
179 | 179 | |
180 | 180 | return $actions; |
181 | 181 | } |
@@ -185,13 +185,13 @@ discard block |
||
185 | 185 | * |
186 | 186 | * @param string $which |
187 | 187 | */ |
188 | - protected function pagination( $which ) { |
|
188 | + protected function pagination($which) { |
|
189 | 189 | global $mode; |
190 | 190 | |
191 | - parent::pagination( $which ); |
|
191 | + parent::pagination($which); |
|
192 | 192 | |
193 | - if ( 'top' == $which ) |
|
194 | - $this->view_switcher( $mode ); |
|
193 | + if ('top' == $which) |
|
194 | + $this->view_switcher($mode); |
|
195 | 195 | } |
196 | 196 | |
197 | 197 | /** |
@@ -200,14 +200,14 @@ discard block |
||
200 | 200 | public function get_columns() { |
201 | 201 | $sites_columns = array( |
202 | 202 | 'cb' => '<input type="checkbox" />', |
203 | - 'blogname' => __( 'URL' ), |
|
204 | - 'lastupdated' => __( 'Last Updated' ), |
|
205 | - 'registered' => _x( 'Registered', 'site' ), |
|
206 | - 'users' => __( 'Users' ), |
|
203 | + 'blogname' => __('URL'), |
|
204 | + 'lastupdated' => __('Last Updated'), |
|
205 | + 'registered' => _x('Registered', 'site'), |
|
206 | + 'users' => __('Users'), |
|
207 | 207 | ); |
208 | 208 | |
209 | - if ( has_filter( 'wpmublogsaction' ) ) { |
|
210 | - $sites_columns['plugins'] = __( 'Actions' ); |
|
209 | + if (has_filter('wpmublogsaction')) { |
|
210 | + $sites_columns['plugins'] = __('Actions'); |
|
211 | 211 | } |
212 | 212 | |
213 | 213 | /** |
@@ -218,7 +218,7 @@ discard block |
||
218 | 218 | * @param array $sites_columns An array of displayed site columns. Default 'cb', |
219 | 219 | * 'blogname', 'lastupdated', 'registered', 'users'. |
220 | 220 | */ |
221 | - return apply_filters( 'wpmu_blogs_columns', $sites_columns ); |
|
221 | + return apply_filters('wpmu_blogs_columns', $sites_columns); |
|
222 | 222 | } |
223 | 223 | |
224 | 224 | /** |
@@ -240,14 +240,14 @@ discard block |
||
240 | 240 | * |
241 | 241 | * @param array $blog Current site. |
242 | 242 | */ |
243 | - public function column_cb( $blog ) { |
|
244 | - if ( ! is_main_site( $blog['blog_id'] ) ) : |
|
245 | - $blogname = untrailingslashit( $blog['domain'] . $blog['path'] ); |
|
243 | + public function column_cb($blog) { |
|
244 | + if ( ! is_main_site($blog['blog_id'])) : |
|
245 | + $blogname = untrailingslashit($blog['domain'].$blog['path']); |
|
246 | 246 | ?> |
247 | 247 | <label class="screen-reader-text" for="blog_<?php echo $blog['blog_id']; ?>"><?php |
248 | - printf( __( 'Select %s' ), $blogname ); |
|
248 | + printf(__('Select %s'), $blogname); |
|
249 | 249 | ?></label> |
250 | - <input type="checkbox" id="blog_<?php echo $blog['blog_id'] ?>" name="allblogs[]" value="<?php echo esc_attr( $blog['blog_id'] ) ?>" /> |
|
250 | + <input type="checkbox" id="blog_<?php echo $blog['blog_id'] ?>" name="allblogs[]" value="<?php echo esc_attr($blog['blog_id']) ?>" /> |
|
251 | 251 | <?php endif; |
252 | 252 | } |
253 | 253 | |
@@ -261,37 +261,37 @@ discard block |
||
261 | 261 | * |
262 | 262 | * @param array $blog Current blog. |
263 | 263 | */ |
264 | - public function column_blogname( $blog ) { |
|
264 | + public function column_blogname($blog) { |
|
265 | 265 | global $mode; |
266 | 266 | |
267 | - $blogname = untrailingslashit( $blog['domain'] . $blog['path'] ); |
|
267 | + $blogname = untrailingslashit($blog['domain'].$blog['path']); |
|
268 | 268 | $blog_states = array(); |
269 | - reset( $this->status_list ); |
|
269 | + reset($this->status_list); |
|
270 | 270 | |
271 | - foreach ( $this->status_list as $status => $col ) { |
|
272 | - if ( $blog[ $status ] == 1 ) { |
|
271 | + foreach ($this->status_list as $status => $col) { |
|
272 | + if ($blog[$status] == 1) { |
|
273 | 273 | $blog_states[] = $col[1]; |
274 | 274 | } |
275 | 275 | } |
276 | 276 | $blog_state = ''; |
277 | - if ( ! empty( $blog_states ) ) { |
|
278 | - $state_count = count( $blog_states ); |
|
277 | + if ( ! empty($blog_states)) { |
|
278 | + $state_count = count($blog_states); |
|
279 | 279 | $i = 0; |
280 | 280 | $blog_state .= ' - '; |
281 | - foreach ( $blog_states as $state ) { |
|
281 | + foreach ($blog_states as $state) { |
|
282 | 282 | ++$i; |
283 | - $sep = ( $i == $state_count ) ? '' : ', '; |
|
283 | + $sep = ($i == $state_count) ? '' : ', '; |
|
284 | 284 | $blog_state .= "<span class='post-state'>$state$sep</span>"; |
285 | 285 | } |
286 | 286 | } |
287 | 287 | |
288 | 288 | ?> |
289 | - <a href="<?php echo esc_url( network_admin_url( 'site-info.php?id=' . $blog['blog_id'] ) ); ?>" class="edit"><?php echo $blogname . $blog_state; ?></a> |
|
289 | + <a href="<?php echo esc_url(network_admin_url('site-info.php?id='.$blog['blog_id'])); ?>" class="edit"><?php echo $blogname.$blog_state; ?></a> |
|
290 | 290 | <?php |
291 | - if ( 'list' !== $mode ) { |
|
292 | - switch_to_blog( $blog['blog_id'] ); |
|
291 | + if ('list' !== $mode) { |
|
292 | + switch_to_blog($blog['blog_id']); |
|
293 | 293 | /* translators: 1: site name, 2: site tagline. */ |
294 | - echo '<p>' . sprintf( __( '%1$s – <em>%2$s</em>' ), get_option( 'blogname' ), get_option( 'blogdescription ' ) ) . '</p>'; |
|
294 | + echo '<p>'.sprintf(__('%1$s – <em>%2$s</em>'), get_option('blogname'), get_option('blogdescription ')).'</p>'; |
|
295 | 295 | restore_current_blog(); |
296 | 296 | } |
297 | 297 | } |
@@ -304,16 +304,16 @@ discard block |
||
304 | 304 | * |
305 | 305 | * @param array $blog Current site. |
306 | 306 | */ |
307 | - public function column_lastupdated( $blog ) { |
|
307 | + public function column_lastupdated($blog) { |
|
308 | 308 | global $mode; |
309 | 309 | |
310 | - if ( 'list' == $mode ) { |
|
311 | - $date = __( 'Y/m/d' ); |
|
310 | + if ('list' == $mode) { |
|
311 | + $date = __('Y/m/d'); |
|
312 | 312 | } else { |
313 | - $date = __( 'Y/m/d g:i:s a' ); |
|
313 | + $date = __('Y/m/d g:i:s a'); |
|
314 | 314 | } |
315 | 315 | |
316 | - echo ( $blog['last_updated'] == '0000-00-00 00:00:00' ) ? __( 'Never' ) : mysql2date( $date, $blog['last_updated'] ); |
|
316 | + echo ($blog['last_updated'] == '0000-00-00 00:00:00') ? __('Never') : mysql2date($date, $blog['last_updated']); |
|
317 | 317 | } |
318 | 318 | |
319 | 319 | /** |
@@ -324,19 +324,19 @@ discard block |
||
324 | 324 | * |
325 | 325 | * @param array $blog Current site. |
326 | 326 | */ |
327 | - public function column_registered( $blog ) { |
|
327 | + public function column_registered($blog) { |
|
328 | 328 | global $mode; |
329 | 329 | |
330 | - if ( 'list' == $mode ) { |
|
331 | - $date = __( 'Y/m/d' ); |
|
330 | + if ('list' == $mode) { |
|
331 | + $date = __('Y/m/d'); |
|
332 | 332 | } else { |
333 | - $date = __( 'Y/m/d g:i:s a' ); |
|
333 | + $date = __('Y/m/d g:i:s a'); |
|
334 | 334 | } |
335 | 335 | |
336 | - if ( $blog['registered'] == '0000-00-00 00:00:00' ) { |
|
336 | + if ($blog['registered'] == '0000-00-00 00:00:00') { |
|
337 | 337 | echo '—'; |
338 | 338 | } else { |
339 | - echo mysql2date( $date, $blog['registered'] ); |
|
339 | + echo mysql2date($date, $blog['registered']); |
|
340 | 340 | } |
341 | 341 | } |
342 | 342 | |
@@ -348,19 +348,19 @@ discard block |
||
348 | 348 | * |
349 | 349 | * @param array $blog Current site. |
350 | 350 | */ |
351 | - public function column_users( $blog ) { |
|
352 | - $user_count = wp_cache_get( $blog['blog_id'] . '_user_count', 'blog-details' ); |
|
353 | - if ( ! $user_count ) { |
|
354 | - $blog_users = get_users( array( 'blog_id' => $blog['blog_id'], 'fields' => 'ID' ) ); |
|
355 | - $user_count = count( $blog_users ); |
|
356 | - unset( $blog_users ); |
|
357 | - wp_cache_set( $blog['blog_id'] . '_user_count', $user_count, 'blog-details', 12 * HOUR_IN_SECONDS ); |
|
351 | + public function column_users($blog) { |
|
352 | + $user_count = wp_cache_get($blog['blog_id'].'_user_count', 'blog-details'); |
|
353 | + if ( ! $user_count) { |
|
354 | + $blog_users = get_users(array('blog_id' => $blog['blog_id'], 'fields' => 'ID')); |
|
355 | + $user_count = count($blog_users); |
|
356 | + unset($blog_users); |
|
357 | + wp_cache_set($blog['blog_id'].'_user_count', $user_count, 'blog-details', 12 * HOUR_IN_SECONDS); |
|
358 | 358 | } |
359 | 359 | |
360 | 360 | printf( |
361 | 361 | '<a href="%s">%s</a>', |
362 | - esc_url( network_admin_url( 'site-users.php?id=' . $blog['blog_id'] ) ), |
|
363 | - number_format_i18n( $user_count ) |
|
362 | + esc_url(network_admin_url('site-users.php?id='.$blog['blog_id'])), |
|
363 | + number_format_i18n($user_count) |
|
364 | 364 | ); |
365 | 365 | } |
366 | 366 | |
@@ -372,8 +372,8 @@ discard block |
||
372 | 372 | * |
373 | 373 | * @param array $blog Current site. |
374 | 374 | */ |
375 | - public function column_plugins( $blog ) { |
|
376 | - if ( has_filter( 'wpmublogsaction' ) ) { |
|
375 | + public function column_plugins($blog) { |
|
376 | + if (has_filter('wpmublogsaction')) { |
|
377 | 377 | /** |
378 | 378 | * Fires inside the auxiliary 'Actions' column of the Sites list table. |
379 | 379 | * |
@@ -383,7 +383,7 @@ discard block |
||
383 | 383 | * |
384 | 384 | * @param int $blog_id The site ID. |
385 | 385 | */ |
386 | - do_action( 'wpmublogsaction', $blog['blog_id'] ); |
|
386 | + do_action('wpmublogsaction', $blog['blog_id']); |
|
387 | 387 | } |
388 | 388 | } |
389 | 389 | |
@@ -396,7 +396,7 @@ discard block |
||
396 | 396 | * @param array $blog Current site. |
397 | 397 | * @param string $column_name Current column name. |
398 | 398 | */ |
399 | - public function column_default( $blog, $column_name ) { |
|
399 | + public function column_default($blog, $column_name) { |
|
400 | 400 | /** |
401 | 401 | * Fires for each registered custom column in the Sites list table. |
402 | 402 | * |
@@ -405,7 +405,7 @@ discard block |
||
405 | 405 | * @param string $column_name The name of the column to display. |
406 | 406 | * @param int $blog_id The site ID. |
407 | 407 | */ |
408 | - do_action( 'manage_sites_custom_column', $column_name, $blog['blog_id'] ); |
|
408 | + do_action('manage_sites_custom_column', $column_name, $blog['blog_id']); |
|
409 | 409 | } |
410 | 410 | |
411 | 411 | /** |
@@ -413,19 +413,19 @@ discard block |
||
413 | 413 | * @global string $mode |
414 | 414 | */ |
415 | 415 | public function display_rows() { |
416 | - foreach ( $this->items as $blog ) { |
|
416 | + foreach ($this->items as $blog) { |
|
417 | 417 | $class = ''; |
418 | - reset( $this->status_list ); |
|
418 | + reset($this->status_list); |
|
419 | 419 | |
420 | - foreach ( $this->status_list as $status => $col ) { |
|
421 | - if ( $blog[ $status ] == 1 ) { |
|
420 | + foreach ($this->status_list as $status => $col) { |
|
421 | + if ($blog[$status] == 1) { |
|
422 | 422 | $class = " class='{$col[0]}'"; |
423 | 423 | } |
424 | 424 | } |
425 | 425 | |
426 | 426 | echo "<tr{$class}>"; |
427 | 427 | |
428 | - $this->single_row_columns( $blog ); |
|
428 | + $this->single_row_columns($blog); |
|
429 | 429 | |
430 | 430 | echo '</tr>'; |
431 | 431 | } |
@@ -454,12 +454,12 @@ discard block |
||
454 | 454 | * @param string $primary Primary column name. |
455 | 455 | * @return string Row actions output. |
456 | 456 | */ |
457 | - protected function handle_row_actions( $blog, $column_name, $primary ) { |
|
458 | - if ( $primary !== $column_name ) { |
|
457 | + protected function handle_row_actions($blog, $column_name, $primary) { |
|
458 | + if ($primary !== $column_name) { |
|
459 | 459 | return; |
460 | 460 | } |
461 | 461 | |
462 | - $blogname = untrailingslashit( $blog['domain'] . $blog['path'] ); |
|
462 | + $blogname = untrailingslashit($blog['domain'].$blog['path']); |
|
463 | 463 | |
464 | 464 | // Preordered. |
465 | 465 | $actions = array( |
@@ -471,33 +471,33 @@ discard block |
||
471 | 471 | 'visit' => '', |
472 | 472 | ); |
473 | 473 | |
474 | - $actions['edit'] = '<span class="edit"><a href="' . esc_url( network_admin_url( 'site-info.php?id=' . $blog['blog_id'] ) ) . '">' . __( 'Edit' ) . '</a></span>'; |
|
475 | - $actions['backend'] = "<span class='backend'><a href='" . esc_url( get_admin_url( $blog['blog_id'] ) ) . "' class='edit'>" . __( 'Dashboard' ) . '</a></span>'; |
|
476 | - if ( get_current_site()->blog_id != $blog['blog_id'] ) { |
|
477 | - if ( $blog['deleted'] == '1' ) { |
|
478 | - $actions['activate'] = '<span class="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></span>'; |
|
474 | + $actions['edit'] = '<span class="edit"><a href="'.esc_url(network_admin_url('site-info.php?id='.$blog['blog_id'])).'">'.__('Edit').'</a></span>'; |
|
475 | + $actions['backend'] = "<span class='backend'><a href='".esc_url(get_admin_url($blog['blog_id']))."' class='edit'>".__('Dashboard').'</a></span>'; |
|
476 | + if (get_current_site()->blog_id != $blog['blog_id']) { |
|
477 | + if ($blog['deleted'] == '1') { |
|
478 | + $actions['activate'] = '<span class="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></span>'; |
|
479 | 479 | } else { |
480 | - $actions['deactivate'] = '<span class="activate"><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></span>'; |
|
480 | + $actions['deactivate'] = '<span class="activate"><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></span>'; |
|
481 | 481 | } |
482 | 482 | |
483 | - if ( $blog['archived'] == '1' ) { |
|
484 | - $actions['unarchive'] = '<span class="archive"><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></span>'; |
|
483 | + if ($blog['archived'] == '1') { |
|
484 | + $actions['unarchive'] = '<span class="archive"><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></span>'; |
|
485 | 485 | } else { |
486 | - $actions['archive'] = '<span class="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></span>'; |
|
486 | + $actions['archive'] = '<span class="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></span>'; |
|
487 | 487 | } |
488 | 488 | |
489 | - if ( $blog['spam'] == '1' ) { |
|
490 | - $actions['unspam'] = '<span class="spam"><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></span>'; |
|
489 | + if ($blog['spam'] == '1') { |
|
490 | + $actions['unspam'] = '<span class="spam"><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></span>'; |
|
491 | 491 | } else { |
492 | - $actions['spam'] = '<span class="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></span>'; |
|
492 | + $actions['spam'] = '<span class="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></span>'; |
|
493 | 493 | } |
494 | 494 | |
495 | - if ( current_user_can( 'delete_site', $blog['blog_id'] ) ) { |
|
496 | - $actions['delete'] = '<span class="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></span>'; |
|
495 | + if (current_user_can('delete_site', $blog['blog_id'])) { |
|
496 | + $actions['delete'] = '<span class="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></span>'; |
|
497 | 497 | } |
498 | 498 | } |
499 | 499 | |
500 | - $actions['visit'] = "<span class='view'><a href='" . esc_url( get_home_url( $blog['blog_id'], '/' ) ) . "' rel='permalink'>" . __( 'Visit' ) . '</a></span>'; |
|
500 | + $actions['visit'] = "<span class='view'><a href='".esc_url(get_home_url($blog['blog_id'], '/'))."' rel='permalink'>".__('Visit').'</a></span>'; |
|
501 | 501 | |
502 | 502 | /** |
503 | 503 | * Filter the action links displayed for each site in the Sites list table. |
@@ -514,7 +514,7 @@ discard block |
||
514 | 514 | * @param string $blogname Site path, formatted depending on whether it is a sub-domain |
515 | 515 | * or subdirectory multisite install. |
516 | 516 | */ |
517 | - $actions = apply_filters( 'manage_sites_action_links', array_filter( $actions ), $blog['blog_id'], $blogname ); |
|
518 | - return $this->row_actions( $actions ); |
|
517 | + $actions = apply_filters('manage_sites_action_links', array_filter($actions), $blog['blog_id'], $blogname); |
|
518 | + return $this->row_actions($actions); |
|
519 | 519 | } |
520 | 520 | } |
@@ -79,10 +79,12 @@ discard block |
||
79 | 79 | * the latest blogs with no paging in order to avoid expensive count queries. |
80 | 80 | */ |
81 | 81 | if ( !$s && wp_is_large_network() ) { |
82 | - if ( !isset($_REQUEST['orderby']) ) |
|
83 | - $_GET['orderby'] = $_REQUEST['orderby'] = ''; |
|
84 | - if ( !isset($_REQUEST['order']) ) |
|
85 | - $_GET['order'] = $_REQUEST['order'] = 'DESC'; |
|
82 | + if ( !isset($_REQUEST['orderby']) ) { |
|
83 | + $_GET['orderby'] = $_REQUEST['orderby'] = ''; |
|
84 | + } |
|
85 | + if ( !isset($_REQUEST['order']) ) { |
|
86 | + $_GET['order'] = $_REQUEST['order'] = 'DESC'; |
|
87 | + } |
|
86 | 88 | } |
87 | 89 | |
88 | 90 | $query = "SELECT * FROM {$wpdb->blogs} WHERE site_id = '{$wpdb->siteid}' "; |
@@ -97,8 +99,9 @@ discard block |
||
97 | 99 | $sql = $wpdb->prepare( "SELECT blog_id FROM {$wpdb->registration_log} WHERE {$wpdb->registration_log}.IP LIKE %s", $wpdb->esc_like( $s ) . $wild ); |
98 | 100 | $reg_blog_ids = $wpdb->get_col( $sql ); |
99 | 101 | |
100 | - if ( !$reg_blog_ids ) |
|
101 | - $reg_blog_ids = array( 0 ); |
|
102 | + if ( !$reg_blog_ids ) { |
|
103 | + $reg_blog_ids = array( 0 ); |
|
104 | + } |
|
102 | 105 | |
103 | 106 | $query = "SELECT * |
104 | 107 | FROM {$wpdb->blogs} |
@@ -144,14 +147,16 @@ discard block |
||
144 | 147 | } |
145 | 148 | |
146 | 149 | // Don't do an unbounded count on large networks |
147 | - if ( ! wp_is_large_network() ) |
|
148 | - $total = $wpdb->get_var( str_replace( 'SELECT *', 'SELECT COUNT( blog_id )', $query ) ); |
|
150 | + if ( ! wp_is_large_network() ) { |
|
151 | + $total = $wpdb->get_var( str_replace( 'SELECT *', 'SELECT COUNT( blog_id )', $query ) ); |
|
152 | + } |
|
149 | 153 | |
150 | 154 | $query .= " LIMIT " . intval( ( $pagenum - 1 ) * $per_page ) . ", " . intval( $per_page ); |
151 | 155 | $this->items = $wpdb->get_results( $query, ARRAY_A ); |
152 | 156 | |
153 | - if ( wp_is_large_network() ) |
|
154 | - $total = count($this->items); |
|
157 | + if ( wp_is_large_network() ) { |
|
158 | + $total = count($this->items); |
|
159 | + } |
|
155 | 160 | |
156 | 161 | $this->set_pagination_args( array( |
157 | 162 | 'total_items' => $total, |
@@ -172,8 +177,9 @@ discard block |
||
172 | 177 | */ |
173 | 178 | protected function get_bulk_actions() { |
174 | 179 | $actions = array(); |
175 | - if ( current_user_can( 'delete_sites' ) ) |
|
176 | - $actions['delete'] = __( 'Delete' ); |
|
180 | + if ( current_user_can( 'delete_sites' ) ) { |
|
181 | + $actions['delete'] = __( 'Delete' ); |
|
182 | + } |
|
177 | 183 | $actions['spam'] = _x( 'Mark as Spam', 'site' ); |
178 | 184 | $actions['notspam'] = _x( 'Not Spam', 'site' ); |
179 | 185 | |
@@ -190,8 +196,9 @@ discard block |
||
190 | 196 | |
191 | 197 | parent::pagination( $which ); |
192 | 198 | |
193 | - if ( 'top' == $which ) |
|
194 | - $this->view_switcher( $mode ); |
|
199 | + if ( 'top' == $which ) { |
|
200 | + $this->view_switcher( $mode ); |
|
201 | + } |
|
195 | 202 | } |
196 | 203 | |
197 | 204 | /** |
@@ -1,10 +1,10 @@ |
||
1 | 1 | <?php |
2 | 2 | /** |
3 | - * WordPress Administration Screen API. |
|
4 | - * |
|
5 | - * @package WordPress |
|
6 | - * @subpackage Administration |
|
7 | - */ |
|
3 | + * WordPress Administration Screen API. |
|
4 | + * |
|
5 | + * @package WordPress |
|
6 | + * @subpackage Administration |
|
7 | + */ |
|
8 | 8 | |
9 | 9 | /** |
10 | 10 | * Get the column headers for a screen |
@@ -16,13 +16,13 @@ discard block |
||
16 | 16 | * @param string|WP_Screen $screen The screen you want the headers for |
17 | 17 | * @return array Containing the headers in the format id => UI String |
18 | 18 | */ |
19 | -function get_column_headers( $screen ) { |
|
20 | - if ( is_string( $screen ) ) |
|
21 | - $screen = convert_to_screen( $screen ); |
|
19 | +function get_column_headers($screen) { |
|
20 | + if (is_string($screen)) |
|
21 | + $screen = convert_to_screen($screen); |
|
22 | 22 | |
23 | 23 | static $column_headers = array(); |
24 | 24 | |
25 | - if ( ! isset( $column_headers[ $screen->id ] ) ) { |
|
25 | + if ( ! isset($column_headers[$screen->id])) { |
|
26 | 26 | |
27 | 27 | /** |
28 | 28 | * Filter the column headers for a list table on a specific screen. |
@@ -36,10 +36,10 @@ discard block |
||
36 | 36 | * |
37 | 37 | * @param array $columns An array of column headers. Default empty. |
38 | 38 | */ |
39 | - $column_headers[ $screen->id ] = apply_filters( "manage_{$screen->id}_columns", array() ); |
|
39 | + $column_headers[$screen->id] = apply_filters("manage_{$screen->id}_columns", array()); |
|
40 | 40 | } |
41 | 41 | |
42 | - return $column_headers[ $screen->id ]; |
|
42 | + return $column_headers[$screen->id]; |
|
43 | 43 | } |
44 | 44 | |
45 | 45 | /** |
@@ -50,11 +50,11 @@ discard block |
||
50 | 50 | * @param string|WP_Screen $screen The screen you want the hidden columns for |
51 | 51 | * @return array |
52 | 52 | */ |
53 | -function get_hidden_columns( $screen ) { |
|
54 | - if ( is_string( $screen ) ) |
|
55 | - $screen = convert_to_screen( $screen ); |
|
53 | +function get_hidden_columns($screen) { |
|
54 | + if (is_string($screen)) |
|
55 | + $screen = convert_to_screen($screen); |
|
56 | 56 | |
57 | - return (array) get_user_option( 'manage' . $screen->id . 'columnshidden' ); |
|
57 | + return (array) get_user_option('manage'.$screen->id.'columnshidden'); |
|
58 | 58 | } |
59 | 59 | |
60 | 60 | /** |
@@ -66,31 +66,31 @@ discard block |
||
66 | 66 | * |
67 | 67 | * @param WP_Screen $screen |
68 | 68 | */ |
69 | -function meta_box_prefs( $screen ) { |
|
69 | +function meta_box_prefs($screen) { |
|
70 | 70 | global $wp_meta_boxes; |
71 | 71 | |
72 | - if ( is_string( $screen ) ) |
|
73 | - $screen = convert_to_screen( $screen ); |
|
72 | + if (is_string($screen)) |
|
73 | + $screen = convert_to_screen($screen); |
|
74 | 74 | |
75 | - if ( empty($wp_meta_boxes[$screen->id]) ) |
|
75 | + if (empty($wp_meta_boxes[$screen->id])) |
|
76 | 76 | return; |
77 | 77 | |
78 | 78 | $hidden = get_hidden_meta_boxes($screen); |
79 | 79 | |
80 | - foreach ( array_keys( $wp_meta_boxes[ $screen->id ] ) as $context ) { |
|
81 | - foreach ( array( 'high', 'core', 'default', 'low' ) as $priority ) { |
|
82 | - if ( ! isset( $wp_meta_boxes[ $screen->id ][ $context ][ $priority ] ) ) { |
|
80 | + foreach (array_keys($wp_meta_boxes[$screen->id]) as $context) { |
|
81 | + foreach (array('high', 'core', 'default', 'low') as $priority) { |
|
82 | + if ( ! isset($wp_meta_boxes[$screen->id][$context][$priority])) { |
|
83 | 83 | continue; |
84 | 84 | } |
85 | - foreach ( $wp_meta_boxes[ $screen->id ][ $context ][ $priority ] as $box ) { |
|
86 | - if ( false == $box || ! $box['title'] ) |
|
85 | + foreach ($wp_meta_boxes[$screen->id][$context][$priority] as $box) { |
|
86 | + if (false == $box || ! $box['title']) |
|
87 | 87 | continue; |
88 | 88 | // Submit box cannot be hidden |
89 | - if ( 'submitdiv' == $box['id'] || 'linksubmitdiv' == $box['id'] ) |
|
89 | + if ('submitdiv' == $box['id'] || 'linksubmitdiv' == $box['id']) |
|
90 | 90 | continue; |
91 | 91 | $box_id = $box['id']; |
92 | - echo '<label for="' . $box_id . '-hide">'; |
|
93 | - echo '<input class="hide-postbox-tog" name="' . $box_id . '-hide" type="checkbox" id="' . $box_id . '-hide" value="' . $box_id . '"' . (! in_array($box_id, $hidden) ? ' checked="checked"' : '') . ' />'; |
|
92 | + echo '<label for="'.$box_id.'-hide">'; |
|
93 | + echo '<input class="hide-postbox-tog" name="'.$box_id.'-hide" type="checkbox" id="'.$box_id.'-hide" value="'.$box_id.'"'.( ! in_array($box_id, $hidden) ? ' checked="checked"' : '').' />'; |
|
94 | 94 | echo "{$box['title']}</label>\n"; |
95 | 95 | } |
96 | 96 | } |
@@ -105,22 +105,22 @@ discard block |
||
105 | 105 | * @param string|WP_Screen $screen Screen identifier |
106 | 106 | * @return array Hidden Meta Boxes |
107 | 107 | */ |
108 | -function get_hidden_meta_boxes( $screen ) { |
|
109 | - if ( is_string( $screen ) ) |
|
110 | - $screen = convert_to_screen( $screen ); |
|
108 | +function get_hidden_meta_boxes($screen) { |
|
109 | + if (is_string($screen)) |
|
110 | + $screen = convert_to_screen($screen); |
|
111 | 111 | |
112 | - $hidden = get_user_option( "metaboxhidden_{$screen->id}" ); |
|
112 | + $hidden = get_user_option("metaboxhidden_{$screen->id}"); |
|
113 | 113 | |
114 | - $use_defaults = ! is_array( $hidden ); |
|
114 | + $use_defaults = ! is_array($hidden); |
|
115 | 115 | |
116 | 116 | // Hide slug boxes by default |
117 | - if ( $use_defaults ) { |
|
117 | + if ($use_defaults) { |
|
118 | 118 | $hidden = array(); |
119 | - if ( 'post' == $screen->base ) { |
|
120 | - if ( 'post' == $screen->post_type || 'page' == $screen->post_type || 'attachment' == $screen->post_type ) |
|
119 | + if ('post' == $screen->base) { |
|
120 | + if ('post' == $screen->post_type || 'page' == $screen->post_type || 'attachment' == $screen->post_type) |
|
121 | 121 | $hidden = array('slugdiv', 'trackbacksdiv', 'postcustom', 'postexcerpt', 'commentstatusdiv', 'commentsdiv', 'authordiv', 'revisionsdiv'); |
122 | 122 | else |
123 | - $hidden = array( 'slugdiv' ); |
|
123 | + $hidden = array('slugdiv'); |
|
124 | 124 | } |
125 | 125 | |
126 | 126 | /** |
@@ -131,7 +131,7 @@ discard block |
||
131 | 131 | * @param array $hidden An array of meta boxes hidden by default. |
132 | 132 | * @param WP_Screen $screen WP_Screen object of the current screen. |
133 | 133 | */ |
134 | - $hidden = apply_filters( 'default_hidden_meta_boxes', $hidden, $screen ); |
|
134 | + $hidden = apply_filters('default_hidden_meta_boxes', $hidden, $screen); |
|
135 | 135 | } |
136 | 136 | |
137 | 137 | /** |
@@ -144,7 +144,7 @@ discard block |
||
144 | 144 | * @param bool $use_defaults Whether to show the default meta boxes. |
145 | 145 | * Default true. |
146 | 146 | */ |
147 | - return apply_filters( 'hidden_meta_boxes', $hidden, $screen, $use_defaults ); |
|
147 | + return apply_filters('hidden_meta_boxes', $hidden, $screen, $use_defaults); |
|
148 | 148 | } |
149 | 149 | |
150 | 150 | /** |
@@ -155,13 +155,13 @@ discard block |
||
155 | 155 | * @param string $option An option name. |
156 | 156 | * @param mixed $args Option-dependent arguments. |
157 | 157 | */ |
158 | -function add_screen_option( $option, $args = array() ) { |
|
158 | +function add_screen_option($option, $args = array()) { |
|
159 | 159 | $current_screen = get_current_screen(); |
160 | 160 | |
161 | - if ( ! $current_screen ) |
|
161 | + if ( ! $current_screen) |
|
162 | 162 | return; |
163 | 163 | |
164 | - $current_screen->add_option( $option, $args ); |
|
164 | + $current_screen->add_option($option, $args); |
|
165 | 165 | } |
166 | 166 | |
167 | 167 | /** |
@@ -176,7 +176,7 @@ discard block |
||
176 | 176 | function get_current_screen() { |
177 | 177 | global $current_screen; |
178 | 178 | |
179 | - if ( ! isset( $current_screen ) ) |
|
179 | + if ( ! isset($current_screen)) |
|
180 | 180 | return null; |
181 | 181 | |
182 | 182 | return $current_screen; |
@@ -190,8 +190,8 @@ discard block |
||
190 | 190 | * @param mixed $hook_name Optional. The hook name (also known as the hook suffix) used to determine the screen, |
191 | 191 | * or an existing screen object. |
192 | 192 | */ |
193 | -function set_current_screen( $hook_name = '' ) { |
|
194 | - WP_Screen::get( $hook_name )->set_current_screen(); |
|
193 | +function set_current_screen($hook_name = '') { |
|
194 | + WP_Screen::get($hook_name)->set_current_screen(); |
|
195 | 195 | } |
196 | 196 | |
197 | 197 | /** |
@@ -393,8 +393,8 @@ discard block |
||
393 | 393 | * Defaults to the current $hook_suffix global. |
394 | 394 | * @return WP_Screen Screen object. |
395 | 395 | */ |
396 | - public static function get( $hook_name = '' ) { |
|
397 | - if ( $hook_name instanceof WP_Screen ) { |
|
396 | + public static function get($hook_name = '') { |
|
397 | + if ($hook_name instanceof WP_Screen) { |
|
398 | 398 | return $hook_name; |
399 | 399 | } |
400 | 400 | |
@@ -402,144 +402,144 @@ discard block |
||
402 | 402 | $in_admin = false; |
403 | 403 | $action = ''; |
404 | 404 | |
405 | - if ( $hook_name ) |
|
405 | + if ($hook_name) |
|
406 | 406 | $id = $hook_name; |
407 | 407 | else |
408 | 408 | $id = $GLOBALS['hook_suffix']; |
409 | 409 | |
410 | 410 | // For those pesky meta boxes. |
411 | - if ( $hook_name && post_type_exists( $hook_name ) ) { |
|
411 | + if ($hook_name && post_type_exists($hook_name)) { |
|
412 | 412 | $post_type = $id; |
413 | 413 | $id = 'post'; // changes later. ends up being $base. |
414 | 414 | } else { |
415 | - if ( '.php' == substr( $id, -4 ) ) |
|
416 | - $id = substr( $id, 0, -4 ); |
|
415 | + if ('.php' == substr($id, -4)) |
|
416 | + $id = substr($id, 0, -4); |
|
417 | 417 | |
418 | - if ( 'post-new' == $id || 'link-add' == $id || 'media-new' == $id || 'user-new' == $id ) { |
|
419 | - $id = substr( $id, 0, -4 ); |
|
418 | + if ('post-new' == $id || 'link-add' == $id || 'media-new' == $id || 'user-new' == $id) { |
|
419 | + $id = substr($id, 0, -4); |
|
420 | 420 | $action = 'add'; |
421 | 421 | } |
422 | 422 | } |
423 | 423 | |
424 | - if ( ! $post_type && $hook_name ) { |
|
425 | - if ( '-network' == substr( $id, -8 ) ) { |
|
426 | - $id = substr( $id, 0, -8 ); |
|
424 | + if ( ! $post_type && $hook_name) { |
|
425 | + if ('-network' == substr($id, -8)) { |
|
426 | + $id = substr($id, 0, -8); |
|
427 | 427 | $in_admin = 'network'; |
428 | - } elseif ( '-user' == substr( $id, -5 ) ) { |
|
429 | - $id = substr( $id, 0, -5 ); |
|
428 | + } elseif ('-user' == substr($id, -5)) { |
|
429 | + $id = substr($id, 0, -5); |
|
430 | 430 | $in_admin = 'user'; |
431 | 431 | } |
432 | 432 | |
433 | - $id = sanitize_key( $id ); |
|
434 | - if ( 'edit-comments' != $id && 'edit-tags' != $id && 'edit-' == substr( $id, 0, 5 ) ) { |
|
435 | - $maybe = substr( $id, 5 ); |
|
436 | - if ( taxonomy_exists( $maybe ) ) { |
|
433 | + $id = sanitize_key($id); |
|
434 | + if ('edit-comments' != $id && 'edit-tags' != $id && 'edit-' == substr($id, 0, 5)) { |
|
435 | + $maybe = substr($id, 5); |
|
436 | + if (taxonomy_exists($maybe)) { |
|
437 | 437 | $id = 'edit-tags'; |
438 | 438 | $taxonomy = $maybe; |
439 | - } elseif ( post_type_exists( $maybe ) ) { |
|
439 | + } elseif (post_type_exists($maybe)) { |
|
440 | 440 | $id = 'edit'; |
441 | 441 | $post_type = $maybe; |
442 | 442 | } |
443 | 443 | } |
444 | 444 | |
445 | - if ( ! $in_admin ) |
|
445 | + if ( ! $in_admin) |
|
446 | 446 | $in_admin = 'site'; |
447 | 447 | } else { |
448 | - if ( defined( 'WP_NETWORK_ADMIN' ) && WP_NETWORK_ADMIN ) |
|
448 | + if (defined('WP_NETWORK_ADMIN') && WP_NETWORK_ADMIN) |
|
449 | 449 | $in_admin = 'network'; |
450 | - elseif ( defined( 'WP_USER_ADMIN' ) && WP_USER_ADMIN ) |
|
450 | + elseif (defined('WP_USER_ADMIN') && WP_USER_ADMIN) |
|
451 | 451 | $in_admin = 'user'; |
452 | 452 | else |
453 | 453 | $in_admin = 'site'; |
454 | 454 | } |
455 | 455 | |
456 | - if ( 'index' == $id ) |
|
456 | + if ('index' == $id) |
|
457 | 457 | $id = 'dashboard'; |
458 | - elseif ( 'front' == $id ) |
|
458 | + elseif ('front' == $id) |
|
459 | 459 | $in_admin = false; |
460 | 460 | |
461 | 461 | $base = $id; |
462 | 462 | |
463 | 463 | // If this is the current screen, see if we can be more accurate for post types and taxonomies. |
464 | - if ( ! $hook_name ) { |
|
465 | - if ( isset( $_REQUEST['post_type'] ) ) |
|
466 | - $post_type = post_type_exists( $_REQUEST['post_type'] ) ? $_REQUEST['post_type'] : false; |
|
467 | - if ( isset( $_REQUEST['taxonomy'] ) ) |
|
468 | - $taxonomy = taxonomy_exists( $_REQUEST['taxonomy'] ) ? $_REQUEST['taxonomy'] : false; |
|
464 | + if ( ! $hook_name) { |
|
465 | + if (isset($_REQUEST['post_type'])) |
|
466 | + $post_type = post_type_exists($_REQUEST['post_type']) ? $_REQUEST['post_type'] : false; |
|
467 | + if (isset($_REQUEST['taxonomy'])) |
|
468 | + $taxonomy = taxonomy_exists($_REQUEST['taxonomy']) ? $_REQUEST['taxonomy'] : false; |
|
469 | 469 | |
470 | - switch ( $base ) { |
|
470 | + switch ($base) { |
|
471 | 471 | case 'post' : |
472 | - if ( isset( $_GET['post'] ) ) |
|
472 | + if (isset($_GET['post'])) |
|
473 | 473 | $post_id = (int) $_GET['post']; |
474 | - elseif ( isset( $_POST['post_ID'] ) ) |
|
474 | + elseif (isset($_POST['post_ID'])) |
|
475 | 475 | $post_id = (int) $_POST['post_ID']; |
476 | 476 | else |
477 | 477 | $post_id = 0; |
478 | 478 | |
479 | - if ( $post_id ) { |
|
480 | - $post = get_post( $post_id ); |
|
481 | - if ( $post ) |
|
479 | + if ($post_id) { |
|
480 | + $post = get_post($post_id); |
|
481 | + if ($post) |
|
482 | 482 | $post_type = $post->post_type; |
483 | 483 | } |
484 | 484 | break; |
485 | 485 | case 'edit-tags' : |
486 | - if ( null === $post_type && is_object_in_taxonomy( 'post', $taxonomy ? $taxonomy : 'post_tag' ) ) |
|
486 | + if (null === $post_type && is_object_in_taxonomy('post', $taxonomy ? $taxonomy : 'post_tag')) |
|
487 | 487 | $post_type = 'post'; |
488 | 488 | break; |
489 | 489 | } |
490 | 490 | } |
491 | 491 | |
492 | - switch ( $base ) { |
|
492 | + switch ($base) { |
|
493 | 493 | case 'post' : |
494 | - if ( null === $post_type ) |
|
494 | + if (null === $post_type) |
|
495 | 495 | $post_type = 'post'; |
496 | 496 | $id = $post_type; |
497 | 497 | break; |
498 | 498 | case 'edit' : |
499 | - if ( null === $post_type ) |
|
499 | + if (null === $post_type) |
|
500 | 500 | $post_type = 'post'; |
501 | - $id .= '-' . $post_type; |
|
501 | + $id .= '-'.$post_type; |
|
502 | 502 | break; |
503 | 503 | case 'edit-tags' : |
504 | - if ( null === $taxonomy ) |
|
504 | + if (null === $taxonomy) |
|
505 | 505 | $taxonomy = 'post_tag'; |
506 | 506 | // The edit-tags ID does not contain the post type. Look for it in the request. |
507 | - if ( null === $post_type ) { |
|
507 | + if (null === $post_type) { |
|
508 | 508 | $post_type = 'post'; |
509 | - if ( isset( $_REQUEST['post_type'] ) && post_type_exists( $_REQUEST['post_type'] ) ) |
|
509 | + if (isset($_REQUEST['post_type']) && post_type_exists($_REQUEST['post_type'])) |
|
510 | 510 | $post_type = $_REQUEST['post_type']; |
511 | 511 | } |
512 | 512 | |
513 | - $id = 'edit-' . $taxonomy; |
|
513 | + $id = 'edit-'.$taxonomy; |
|
514 | 514 | break; |
515 | 515 | } |
516 | 516 | |
517 | - if ( 'network' == $in_admin ) { |
|
517 | + if ('network' == $in_admin) { |
|
518 | 518 | $id .= '-network'; |
519 | 519 | $base .= '-network'; |
520 | - } elseif ( 'user' == $in_admin ) { |
|
520 | + } elseif ('user' == $in_admin) { |
|
521 | 521 | $id .= '-user'; |
522 | 522 | $base .= '-user'; |
523 | 523 | } |
524 | 524 | |
525 | - if ( isset( self::$_registry[ $id ] ) ) { |
|
526 | - $screen = self::$_registry[ $id ]; |
|
527 | - if ( $screen === get_current_screen() ) |
|
525 | + if (isset(self::$_registry[$id])) { |
|
526 | + $screen = self::$_registry[$id]; |
|
527 | + if ($screen === get_current_screen()) |
|
528 | 528 | return $screen; |
529 | 529 | } else { |
530 | 530 | $screen = new WP_Screen(); |
531 | - $screen->id = $id; |
|
531 | + $screen->id = $id; |
|
532 | 532 | } |
533 | 533 | |
534 | 534 | $screen->base = $base; |
535 | 535 | $screen->action = $action; |
536 | 536 | $screen->post_type = (string) $post_type; |
537 | 537 | $screen->taxonomy = (string) $taxonomy; |
538 | - $screen->is_user = ( 'user' == $in_admin ); |
|
539 | - $screen->is_network = ( 'network' == $in_admin ); |
|
538 | + $screen->is_user = ('user' == $in_admin); |
|
539 | + $screen->is_network = ('network' == $in_admin); |
|
540 | 540 | $screen->in_admin = $in_admin; |
541 | 541 | |
542 | - self::$_registry[ $id ] = $screen; |
|
542 | + self::$_registry[$id] = $screen; |
|
543 | 543 | |
544 | 544 | return $screen; |
545 | 545 | } |
@@ -567,7 +567,7 @@ discard block |
||
567 | 567 | * |
568 | 568 | * @param WP_Screen $current_screen Current WP_Screen object. |
569 | 569 | */ |
570 | - do_action( 'current_screen', $current_screen ); |
|
570 | + do_action('current_screen', $current_screen); |
|
571 | 571 | } |
572 | 572 | |
573 | 573 | /** |
@@ -587,11 +587,11 @@ discard block |
||
587 | 587 | * If empty any of the three admins will result in true. |
588 | 588 | * @return bool True if the screen is in the indicated admin, false otherwise. |
589 | 589 | */ |
590 | - public function in_admin( $admin = null ) { |
|
591 | - if ( empty( $admin ) ) |
|
590 | + public function in_admin($admin = null) { |
|
591 | + if (empty($admin)) |
|
592 | 592 | return (bool) $this->in_admin; |
593 | 593 | |
594 | - return ( $admin == $this->in_admin ); |
|
594 | + return ($admin == $this->in_admin); |
|
595 | 595 | } |
596 | 596 | |
597 | 597 | /** |
@@ -606,8 +606,8 @@ discard block |
||
606 | 606 | * @param WP_Screen $screen A screen object. |
607 | 607 | * @param string $help Help text. |
608 | 608 | */ |
609 | - public static function add_old_compat_help( $screen, $help ) { |
|
610 | - self::$_old_compat_help[ $screen->id ] = $help; |
|
609 | + public static function add_old_compat_help($screen, $help) { |
|
610 | + self::$_old_compat_help[$screen->id] = $help; |
|
611 | 611 | } |
612 | 612 | |
613 | 613 | /** |
@@ -618,10 +618,10 @@ discard block |
||
618 | 618 | * |
619 | 619 | * @param string $parent_file The parent file of the screen. Typically the $parent_file global. |
620 | 620 | */ |
621 | - public function set_parentage( $parent_file ) { |
|
621 | + public function set_parentage($parent_file) { |
|
622 | 622 | $this->parent_file = $parent_file; |
623 | - list( $this->parent_base ) = explode( '?', $parent_file ); |
|
624 | - $this->parent_base = str_replace( '.php', '', $this->parent_base ); |
|
623 | + list($this->parent_base) = explode('?', $parent_file); |
|
624 | + $this->parent_base = str_replace('.php', '', $this->parent_base); |
|
625 | 625 | } |
626 | 626 | |
627 | 627 | /** |
@@ -633,8 +633,8 @@ discard block |
||
633 | 633 | * @param string $option Option ID |
634 | 634 | * @param mixed $args Option-dependent arguments. |
635 | 635 | */ |
636 | - public function add_option( $option, $args = array() ) { |
|
637 | - $this->_options[ $option ] = $args; |
|
636 | + public function add_option($option, $args = array()) { |
|
637 | + $this->_options[$option] = $args; |
|
638 | 638 | } |
639 | 639 | |
640 | 640 | /** |
@@ -644,8 +644,8 @@ discard block |
||
644 | 644 | * |
645 | 645 | * @param string $option Option ID. |
646 | 646 | */ |
647 | - public function remove_option( $option ) { |
|
648 | - unset( $this->_options[ $option ] ); |
|
647 | + public function remove_option($option) { |
|
648 | + unset($this->_options[$option]); |
|
649 | 649 | } |
650 | 650 | |
651 | 651 | /** |
@@ -678,15 +678,15 @@ discard block |
||
678 | 678 | * Default false. |
679 | 679 | * @return string The option value if set, null otherwise. |
680 | 680 | */ |
681 | - public function get_option( $option, $key = false ) { |
|
682 | - if ( ! isset( $this->_options[ $option ] ) ) |
|
681 | + public function get_option($option, $key = false) { |
|
682 | + if ( ! isset($this->_options[$option])) |
|
683 | 683 | return null; |
684 | - if ( $key ) { |
|
685 | - if ( isset( $this->_options[ $option ][ $key ] ) ) |
|
686 | - return $this->_options[ $option ][ $key ]; |
|
684 | + if ($key) { |
|
685 | + if (isset($this->_options[$option][$key])) |
|
686 | + return $this->_options[$option][$key]; |
|
687 | 687 | return null; |
688 | 688 | } |
689 | - return $this->_options[ $option ]; |
|
689 | + return $this->_options[$option]; |
|
690 | 690 | } |
691 | 691 | |
692 | 692 | /** |
@@ -708,10 +708,10 @@ discard block |
||
708 | 708 | * @param string $id Help Tab ID. |
709 | 709 | * @return array Help tab arguments. |
710 | 710 | */ |
711 | - public function get_help_tab( $id ) { |
|
712 | - if ( ! isset( $this->_help_tabs[ $id ] ) ) |
|
711 | + public function get_help_tab($id) { |
|
712 | + if ( ! isset($this->_help_tabs[$id])) |
|
713 | 713 | return null; |
714 | - return $this->_help_tabs[ $id ]; |
|
714 | + return $this->_help_tabs[$id]; |
|
715 | 715 | } |
716 | 716 | |
717 | 717 | /** |
@@ -727,23 +727,23 @@ discard block |
||
727 | 727 | * - callback - callback - A callback to generate the tab content. Optional. |
728 | 728 | * |
729 | 729 | */ |
730 | - public function add_help_tab( $args ) { |
|
730 | + public function add_help_tab($args) { |
|
731 | 731 | $defaults = array( |
732 | 732 | 'title' => false, |
733 | 733 | 'id' => false, |
734 | 734 | 'content' => '', |
735 | 735 | 'callback' => false, |
736 | 736 | ); |
737 | - $args = wp_parse_args( $args, $defaults ); |
|
737 | + $args = wp_parse_args($args, $defaults); |
|
738 | 738 | |
739 | - $args['id'] = sanitize_html_class( $args['id'] ); |
|
739 | + $args['id'] = sanitize_html_class($args['id']); |
|
740 | 740 | |
741 | 741 | // Ensure we have an ID and title. |
742 | - if ( ! $args['id'] || ! $args['title'] ) |
|
742 | + if ( ! $args['id'] || ! $args['title']) |
|
743 | 743 | return; |
744 | 744 | |
745 | 745 | // Allows for overriding an existing tab with that ID. |
746 | - $this->_help_tabs[ $args['id'] ] = $args; |
|
746 | + $this->_help_tabs[$args['id']] = $args; |
|
747 | 747 | } |
748 | 748 | |
749 | 749 | /** |
@@ -753,8 +753,8 @@ discard block |
||
753 | 753 | * |
754 | 754 | * @param string $id The help tab ID. |
755 | 755 | */ |
756 | - public function remove_help_tab( $id ) { |
|
757 | - unset( $this->_help_tabs[ $id ] ); |
|
756 | + public function remove_help_tab($id) { |
|
757 | + unset($this->_help_tabs[$id]); |
|
758 | 758 | } |
759 | 759 | |
760 | 760 | /** |
@@ -785,7 +785,7 @@ discard block |
||
785 | 785 | * |
786 | 786 | * @param string $content Sidebar content in plain text or HTML. |
787 | 787 | */ |
788 | - public function set_help_sidebar( $content ) { |
|
788 | + public function set_help_sidebar($content) { |
|
789 | 789 | $this->_help_sidebar = $content; |
790 | 790 | } |
791 | 791 | |
@@ -827,9 +827,9 @@ discard block |
||
827 | 827 | * @param array $old_compat_help Old contextual help. |
828 | 828 | * @param WP_Screen $this Current WP_Screen instance. |
829 | 829 | */ |
830 | - self::$_old_compat_help = apply_filters( 'contextual_help_list', self::$_old_compat_help, $this ); |
|
830 | + self::$_old_compat_help = apply_filters('contextual_help_list', self::$_old_compat_help, $this); |
|
831 | 831 | |
832 | - $old_help = isset( self::$_old_compat_help[ $this->id ] ) ? self::$_old_compat_help[ $this->id ] : ''; |
|
832 | + $old_help = isset(self::$_old_compat_help[$this->id]) ? self::$_old_compat_help[$this->id] : ''; |
|
833 | 833 | |
834 | 834 | /** |
835 | 835 | * Filter the legacy contextual help text. |
@@ -843,10 +843,10 @@ discard block |
||
843 | 843 | * @param WP_Screen $this Current WP_Screen instance. |
844 | 844 | * |
845 | 845 | */ |
846 | - $old_help = apply_filters( 'contextual_help', $old_help, $this->id, $this ); |
|
846 | + $old_help = apply_filters('contextual_help', $old_help, $this->id, $this); |
|
847 | 847 | |
848 | 848 | // Default help only if there is no old-style block of text and no new-style help tabs. |
849 | - if ( empty( $old_help ) && ! $this->get_help_tabs() ) { |
|
849 | + if (empty($old_help) && ! $this->get_help_tabs()) { |
|
850 | 850 | |
851 | 851 | /** |
852 | 852 | * Filter the default legacy contextual help text. |
@@ -857,44 +857,44 @@ discard block |
||
857 | 857 | * |
858 | 858 | * @param string $old_help_default Default contextual help text. |
859 | 859 | */ |
860 | - $default_help = apply_filters( 'default_contextual_help', '' ); |
|
861 | - if ( $default_help ) |
|
862 | - $old_help = '<p>' . $default_help . '</p>'; |
|
860 | + $default_help = apply_filters('default_contextual_help', ''); |
|
861 | + if ($default_help) |
|
862 | + $old_help = '<p>'.$default_help.'</p>'; |
|
863 | 863 | } |
864 | 864 | |
865 | - if ( $old_help ) { |
|
866 | - $this->add_help_tab( array( |
|
865 | + if ($old_help) { |
|
866 | + $this->add_help_tab(array( |
|
867 | 867 | 'id' => 'old-contextual-help', |
868 | 868 | 'title' => __('Overview'), |
869 | 869 | 'content' => $old_help, |
870 | - ) ); |
|
870 | + )); |
|
871 | 871 | } |
872 | 872 | |
873 | 873 | $help_sidebar = $this->get_help_sidebar(); |
874 | 874 | |
875 | 875 | $help_class = 'hidden'; |
876 | - if ( ! $help_sidebar ) |
|
876 | + if ( ! $help_sidebar) |
|
877 | 877 | $help_class .= ' no-sidebar'; |
878 | 878 | |
879 | 879 | // Time to render! |
880 | 880 | ?> |
881 | 881 | <div id="screen-meta" class="metabox-prefs"> |
882 | 882 | |
883 | - <div id="contextual-help-wrap" class="<?php echo esc_attr( $help_class ); ?>" tabindex="-1" aria-label="<?php esc_attr_e('Contextual Help Tab'); ?>"> |
|
883 | + <div id="contextual-help-wrap" class="<?php echo esc_attr($help_class); ?>" tabindex="-1" aria-label="<?php esc_attr_e('Contextual Help Tab'); ?>"> |
|
884 | 884 | <div id="contextual-help-back"></div> |
885 | 885 | <div id="contextual-help-columns"> |
886 | 886 | <div class="contextual-help-tabs"> |
887 | 887 | <ul> |
888 | 888 | <?php |
889 | 889 | $class = ' class="active"'; |
890 | - foreach ( $this->get_help_tabs() as $tab ) : |
|
890 | + foreach ($this->get_help_tabs() as $tab) : |
|
891 | 891 | $link_id = "tab-link-{$tab['id']}"; |
892 | 892 | $panel_id = "tab-panel-{$tab['id']}"; |
893 | 893 | ?> |
894 | 894 | |
895 | - <li id="<?php echo esc_attr( $link_id ); ?>"<?php echo $class; ?>> |
|
896 | - <a href="<?php echo esc_url( "#$panel_id" ); ?>" aria-controls="<?php echo esc_attr( $panel_id ); ?>"> |
|
897 | - <?php echo esc_html( $tab['title'] ); ?> |
|
895 | + <li id="<?php echo esc_attr($link_id); ?>"<?php echo $class; ?>> |
|
896 | + <a href="<?php echo esc_url("#$panel_id"); ?>" aria-controls="<?php echo esc_attr($panel_id); ?>"> |
|
897 | + <?php echo esc_html($tab['title']); ?> |
|
898 | 898 | </a> |
899 | 899 | </li> |
900 | 900 | <?php |
@@ -904,7 +904,7 @@ discard block |
||
904 | 904 | </ul> |
905 | 905 | </div> |
906 | 906 | |
907 | - <?php if ( $help_sidebar ) : ?> |
|
907 | + <?php if ($help_sidebar) : ?> |
|
908 | 908 | <div class="contextual-help-sidebar"> |
909 | 909 | <?php echo $help_sidebar; ?> |
910 | 910 | </div> |
@@ -913,18 +913,18 @@ discard block |
||
913 | 913 | <div class="contextual-help-tabs-wrap"> |
914 | 914 | <?php |
915 | 915 | $classes = 'help-tab-content active'; |
916 | - foreach ( $this->get_help_tabs() as $tab ): |
|
916 | + foreach ($this->get_help_tabs() as $tab): |
|
917 | 917 | $panel_id = "tab-panel-{$tab['id']}"; |
918 | 918 | ?> |
919 | 919 | |
920 | - <div id="<?php echo esc_attr( $panel_id ); ?>" class="<?php echo $classes; ?>"> |
|
920 | + <div id="<?php echo esc_attr($panel_id); ?>" class="<?php echo $classes; ?>"> |
|
921 | 921 | <?php |
922 | 922 | // Print tab content. |
923 | 923 | echo $tab['content']; |
924 | 924 | |
925 | 925 | // If it exists, fire tab callback. |
926 | - if ( ! empty( $tab['callback'] ) ) |
|
927 | - call_user_func_array( $tab['callback'], array( $this, $tab ) ); |
|
926 | + if ( ! empty($tab['callback'])) |
|
927 | + call_user_func_array($tab['callback'], array($this, $tab)); |
|
928 | 928 | ?> |
929 | 929 | </div> |
930 | 930 | <?php |
@@ -949,37 +949,37 @@ discard block |
||
949 | 949 | * @param string $screen_id Screen ID. |
950 | 950 | * @param WP_Screen $this Current WP_Screen instance. |
951 | 951 | */ |
952 | - $columns = apply_filters( 'screen_layout_columns', array(), $this->id, $this ); |
|
952 | + $columns = apply_filters('screen_layout_columns', array(), $this->id, $this); |
|
953 | 953 | |
954 | - if ( ! empty( $columns ) && isset( $columns[ $this->id ] ) ) |
|
955 | - $this->add_option( 'layout_columns', array('max' => $columns[ $this->id ] ) ); |
|
954 | + if ( ! empty($columns) && isset($columns[$this->id])) |
|
955 | + $this->add_option('layout_columns', array('max' => $columns[$this->id])); |
|
956 | 956 | |
957 | - if ( $this->get_option( 'layout_columns' ) ) { |
|
957 | + if ($this->get_option('layout_columns')) { |
|
958 | 958 | $this->columns = (int) get_user_option("screen_layout_$this->id"); |
959 | 959 | |
960 | - if ( ! $this->columns && $this->get_option( 'layout_columns', 'default' ) ) |
|
961 | - $this->columns = $this->get_option( 'layout_columns', 'default' ); |
|
960 | + if ( ! $this->columns && $this->get_option('layout_columns', 'default')) |
|
961 | + $this->columns = $this->get_option('layout_columns', 'default'); |
|
962 | 962 | } |
963 | - $GLOBALS[ 'screen_layout_columns' ] = $this->columns; // Set the global for back-compat. |
|
963 | + $GLOBALS['screen_layout_columns'] = $this->columns; // Set the global for back-compat. |
|
964 | 964 | |
965 | 965 | // Add screen options |
966 | - if ( $this->show_screen_options() ) |
|
966 | + if ($this->show_screen_options()) |
|
967 | 967 | $this->render_screen_options(); |
968 | 968 | ?> |
969 | 969 | </div> |
970 | 970 | <?php |
971 | - if ( ! $this->get_help_tabs() && ! $this->show_screen_options() ) |
|
971 | + if ( ! $this->get_help_tabs() && ! $this->show_screen_options()) |
|
972 | 972 | return; |
973 | 973 | ?> |
974 | 974 | <div id="screen-meta-links"> |
975 | - <?php if ( $this->get_help_tabs() ) : ?> |
|
975 | + <?php if ($this->get_help_tabs()) : ?> |
|
976 | 976 | <div id="contextual-help-link-wrap" class="hide-if-no-js screen-meta-toggle"> |
977 | - <button type="button" id="contextual-help-link" class="button show-settings" aria-controls="contextual-help-wrap" aria-expanded="false"><?php _e( 'Help' ); ?></button> |
|
977 | + <button type="button" id="contextual-help-link" class="button show-settings" aria-controls="contextual-help-wrap" aria-expanded="false"><?php _e('Help'); ?></button> |
|
978 | 978 | </div> |
979 | 979 | <?php endif; |
980 | - if ( $this->show_screen_options() ) : ?> |
|
980 | + if ($this->show_screen_options()) : ?> |
|
981 | 981 | <div id="screen-options-link-wrap" class="hide-if-no-js screen-meta-toggle"> |
982 | - <button type="button" id="show-settings-link" class="button show-settings" aria-controls="screen-options-wrap" aria-expanded="false"><?php _e( 'Screen Options' ); ?></button> |
|
982 | + <button type="button" id="show-settings-link" class="button show-settings" aria-controls="screen-options-wrap" aria-expanded="false"><?php _e('Screen Options'); ?></button> |
|
983 | 983 | </div> |
984 | 984 | <?php endif; ?> |
985 | 985 | </div> |
@@ -995,21 +995,21 @@ discard block |
||
995 | 995 | public function show_screen_options() { |
996 | 996 | global $wp_meta_boxes; |
997 | 997 | |
998 | - if ( is_bool( $this->_show_screen_options ) ) |
|
998 | + if (is_bool($this->_show_screen_options)) |
|
999 | 999 | return $this->_show_screen_options; |
1000 | 1000 | |
1001 | - $columns = get_column_headers( $this ); |
|
1001 | + $columns = get_column_headers($this); |
|
1002 | 1002 | |
1003 | - $show_screen = ! empty( $wp_meta_boxes[ $this->id ] ) || $columns || $this->get_option( 'per_page' ); |
|
1003 | + $show_screen = ! empty($wp_meta_boxes[$this->id]) || $columns || $this->get_option('per_page'); |
|
1004 | 1004 | |
1005 | - switch ( $this->base ) { |
|
1005 | + switch ($this->base) { |
|
1006 | 1006 | case 'widgets': |
1007 | - $this->_screen_settings = '<p><a id="access-on" href="widgets.php?widgets-access=on">' . __('Enable accessibility mode') . '</a><a id="access-off" href="widgets.php?widgets-access=off">' . __('Disable accessibility mode') . "</a></p>\n"; |
|
1007 | + $this->_screen_settings = '<p><a id="access-on" href="widgets.php?widgets-access=on">'.__('Enable accessibility mode').'</a><a id="access-off" href="widgets.php?widgets-access=off">'.__('Disable accessibility mode')."</a></p>\n"; |
|
1008 | 1008 | break; |
1009 | 1009 | case 'post' : |
1010 | 1010 | $expand = '<div class="editor-expand hidden"><label for="editor-expand-toggle">'; |
1011 | - $expand .= '<input type="checkbox" id="editor-expand-toggle"' . checked( get_user_setting( 'editor_expand', 'on' ), 'on', false ) . ' />'; |
|
1012 | - $expand .= __( 'Enable full-height editor and distraction-free functionality.' ) . '</label></div>'; |
|
1011 | + $expand .= '<input type="checkbox" id="editor-expand-toggle"'.checked(get_user_setting('editor_expand', 'on'), 'on', false).' />'; |
|
1012 | + $expand .= __('Enable full-height editor and distraction-free functionality.').'</label></div>'; |
|
1013 | 1013 | $this->_screen_settings = $expand; |
1014 | 1014 | break; |
1015 | 1015 | default: |
@@ -1028,9 +1028,9 @@ discard block |
||
1028 | 1028 | * @param string $screen_settings Screen settings. |
1029 | 1029 | * @param WP_Screen $this WP_Screen object. |
1030 | 1030 | */ |
1031 | - $this->_screen_settings = apply_filters( 'screen_settings', $this->_screen_settings, $this ); |
|
1031 | + $this->_screen_settings = apply_filters('screen_settings', $this->_screen_settings, $this); |
|
1032 | 1032 | |
1033 | - if ( $this->_screen_settings || $this->_options ) |
|
1033 | + if ($this->_screen_settings || $this->_options) |
|
1034 | 1034 | $show_screen = true; |
1035 | 1035 | |
1036 | 1036 | /** |
@@ -1042,7 +1042,7 @@ discard block |
||
1042 | 1042 | * Default true. |
1043 | 1043 | * @param WP_Screen $this Current WP_Screen instance. |
1044 | 1044 | */ |
1045 | - $this->_show_screen_options = apply_filters( 'screen_options_show_screen', $show_screen, $this ); |
|
1045 | + $this->_show_screen_options = apply_filters('screen_options_show_screen', $show_screen, $this); |
|
1046 | 1046 | return $this->_show_screen_options; |
1047 | 1047 | } |
1048 | 1048 | |
@@ -1056,59 +1056,59 @@ discard block |
||
1056 | 1056 | public function render_screen_options() { |
1057 | 1057 | global $wp_meta_boxes; |
1058 | 1058 | |
1059 | - $columns = get_column_headers( $this ); |
|
1060 | - $hidden = get_hidden_columns( $this ); |
|
1059 | + $columns = get_column_headers($this); |
|
1060 | + $hidden = get_hidden_columns($this); |
|
1061 | 1061 | |
1062 | 1062 | ?> |
1063 | 1063 | <div id="screen-options-wrap" class="hidden" tabindex="-1" aria-label="<?php esc_attr_e('Screen Options Tab'); ?>"> |
1064 | 1064 | <form id="adv-settings" method="post"> |
1065 | - <?php if ( isset( $wp_meta_boxes[ $this->id ] ) || $this->get_option( 'per_page' ) || ( $columns && empty( $columns['_title'] ) ) ) : ?> |
|
1066 | - <h5><?php _e( 'Show on screen' ); ?></h5> |
|
1065 | + <?php if (isset($wp_meta_boxes[$this->id]) || $this->get_option('per_page') || ($columns && empty($columns['_title']))) : ?> |
|
1066 | + <h5><?php _e('Show on screen'); ?></h5> |
|
1067 | 1067 | <?php |
1068 | 1068 | endif; |
1069 | 1069 | |
1070 | - if ( isset( $wp_meta_boxes[ $this->id ] ) ) : ?> |
|
1070 | + if (isset($wp_meta_boxes[$this->id])) : ?> |
|
1071 | 1071 | <div class="metabox-prefs"> |
1072 | 1072 | <?php |
1073 | - meta_box_prefs( $this ); |
|
1073 | + meta_box_prefs($this); |
|
1074 | 1074 | |
1075 | - if ( 'dashboard' === $this->id && has_action( 'welcome_panel' ) && current_user_can( 'edit_theme_options' ) ) { |
|
1076 | - if ( isset( $_GET['welcome'] ) ) { |
|
1077 | - $welcome_checked = empty( $_GET['welcome'] ) ? 0 : 1; |
|
1078 | - update_user_meta( get_current_user_id(), 'show_welcome_panel', $welcome_checked ); |
|
1075 | + if ('dashboard' === $this->id && has_action('welcome_panel') && current_user_can('edit_theme_options')) { |
|
1076 | + if (isset($_GET['welcome'])) { |
|
1077 | + $welcome_checked = empty($_GET['welcome']) ? 0 : 1; |
|
1078 | + update_user_meta(get_current_user_id(), 'show_welcome_panel', $welcome_checked); |
|
1079 | 1079 | } else { |
1080 | - $welcome_checked = get_user_meta( get_current_user_id(), 'show_welcome_panel', true ); |
|
1081 | - if ( 2 == $welcome_checked && wp_get_current_user()->user_email != get_option( 'admin_email' ) ) |
|
1080 | + $welcome_checked = get_user_meta(get_current_user_id(), 'show_welcome_panel', true); |
|
1081 | + if (2 == $welcome_checked && wp_get_current_user()->user_email != get_option('admin_email')) |
|
1082 | 1082 | $welcome_checked = false; |
1083 | 1083 | } |
1084 | 1084 | echo '<label for="wp_welcome_panel-hide">'; |
1085 | - echo '<input type="checkbox" id="wp_welcome_panel-hide"' . checked( (bool) $welcome_checked, true, false ) . ' />'; |
|
1086 | - echo _x( 'Welcome', 'Welcome panel' ) . "</label>\n"; |
|
1085 | + echo '<input type="checkbox" id="wp_welcome_panel-hide"'.checked((bool) $welcome_checked, true, false).' />'; |
|
1086 | + echo _x('Welcome', 'Welcome panel')."</label>\n"; |
|
1087 | 1087 | } |
1088 | 1088 | ?> |
1089 | 1089 | <br class="clear" /> |
1090 | 1090 | </div> |
1091 | 1091 | <?php endif; |
1092 | - if ( $columns ) : |
|
1093 | - if ( ! empty( $columns['_title'] ) ) : ?> |
|
1092 | + if ($columns) : |
|
1093 | + if ( ! empty($columns['_title'])) : ?> |
|
1094 | 1094 | <h5><?php echo $columns['_title']; ?></h5> |
1095 | 1095 | <?php endif; ?> |
1096 | 1096 | <div class="metabox-prefs"> |
1097 | 1097 | <?php |
1098 | 1098 | $special = array('_title', 'cb', 'comment', 'media', 'name', 'title', 'username', 'blogname'); |
1099 | 1099 | |
1100 | - foreach ( $columns as $column => $title ) { |
|
1100 | + foreach ($columns as $column => $title) { |
|
1101 | 1101 | // Can't hide these for they are special |
1102 | - if ( in_array( $column, $special ) ) |
|
1102 | + if (in_array($column, $special)) |
|
1103 | 1103 | continue; |
1104 | - if ( empty( $title ) ) |
|
1104 | + if (empty($title)) |
|
1105 | 1105 | continue; |
1106 | 1106 | |
1107 | - if ( 'comments' == $column ) |
|
1108 | - $title = __( 'Comments' ); |
|
1107 | + if ('comments' == $column) |
|
1108 | + $title = __('Comments'); |
|
1109 | 1109 | $id = "$column-hide"; |
1110 | - echo '<label for="' . $id . '">'; |
|
1111 | - echo '<input class="hide-column-tog" name="' . $id . '" type="checkbox" id="' . $id . '" value="' . $column . '"' . checked( !in_array($column, $hidden), true, false ) . ' />'; |
|
1110 | + echo '<label for="'.$id.'">'; |
|
1111 | + echo '<input class="hide-column-tog" name="'.$id.'" type="checkbox" id="'.$id.'" value="'.$column.'"'.checked( ! in_array($column, $hidden), true, false).' />'; |
|
1112 | 1112 | echo "$title</label>\n"; |
1113 | 1113 | } |
1114 | 1114 | ?> |
@@ -1121,7 +1121,7 @@ discard block |
||
1121 | 1121 | echo $this->_screen_settings; |
1122 | 1122 | |
1123 | 1123 | ?> |
1124 | - <div><?php wp_nonce_field( 'screen-options-nonce', 'screenoptionnonce', false ); ?></div> |
|
1124 | + <div><?php wp_nonce_field('screen-options-nonce', 'screenoptionnonce', false); ?></div> |
|
1125 | 1125 | </form> |
1126 | 1126 | </div> |
1127 | 1127 | <?php |
@@ -1133,22 +1133,22 @@ discard block |
||
1133 | 1133 | * @since 3.3.0 |
1134 | 1134 | */ |
1135 | 1135 | public function render_screen_layout() { |
1136 | - if ( ! $this->get_option('layout_columns') ) |
|
1136 | + if ( ! $this->get_option('layout_columns')) |
|
1137 | 1137 | return; |
1138 | 1138 | |
1139 | 1139 | $screen_layout_columns = $this->get_columns(); |
1140 | - $num = $this->get_option( 'layout_columns', 'max' ); |
|
1140 | + $num = $this->get_option('layout_columns', 'max'); |
|
1141 | 1141 | |
1142 | 1142 | ?> |
1143 | 1143 | <h5 class="screen-layout"><?php _e('Screen Layout'); ?></h5> |
1144 | 1144 | <div class='columns-prefs'><?php |
1145 | 1145 | _e('Number of Columns:'); |
1146 | - for ( $i = 1; $i <= $num; ++$i ): |
|
1146 | + for ($i = 1; $i <= $num; ++$i): |
|
1147 | 1147 | ?> |
1148 | 1148 | <label class="columns-prefs-<?php echo $i; ?>"> |
1149 | - <input type='radio' name='screen_columns' value='<?php echo esc_attr( $i ); ?>' |
|
1150 | - <?php checked( $screen_layout_columns, $i ); ?> /> |
|
1151 | - <?php echo esc_html( $i ); ?> |
|
1149 | + <input type='radio' name='screen_columns' value='<?php echo esc_attr($i); ?>' |
|
1150 | + <?php checked($screen_layout_columns, $i); ?> /> |
|
1151 | + <?php echo esc_html($i); ?> |
|
1152 | 1152 | </label> |
1153 | 1153 | <?php |
1154 | 1154 | endfor; ?> |
@@ -1162,58 +1162,58 @@ discard block |
||
1162 | 1162 | * @since 3.3.0 |
1163 | 1163 | */ |
1164 | 1164 | public function render_per_page_options() { |
1165 | - if ( null === $this->get_option( 'per_page' ) ) { |
|
1165 | + if (null === $this->get_option('per_page')) { |
|
1166 | 1166 | return; |
1167 | 1167 | } |
1168 | 1168 | |
1169 | - $per_page_label = $this->get_option( 'per_page', 'label' ); |
|
1170 | - if ( null === $per_page_label ) { |
|
1171 | - $per_page_label = __( 'Number of items per page:' ); |
|
1169 | + $per_page_label = $this->get_option('per_page', 'label'); |
|
1170 | + if (null === $per_page_label) { |
|
1171 | + $per_page_label = __('Number of items per page:'); |
|
1172 | 1172 | } |
1173 | 1173 | |
1174 | - $option = $this->get_option( 'per_page', 'option' ); |
|
1175 | - if ( ! $option ) { |
|
1176 | - $option = str_replace( '-', '_', "{$this->id}_per_page" ); |
|
1174 | + $option = $this->get_option('per_page', 'option'); |
|
1175 | + if ( ! $option) { |
|
1176 | + $option = str_replace('-', '_', "{$this->id}_per_page"); |
|
1177 | 1177 | } |
1178 | 1178 | |
1179 | - $per_page = (int) get_user_option( $option ); |
|
1180 | - if ( empty( $per_page ) || $per_page < 1 ) { |
|
1181 | - $per_page = $this->get_option( 'per_page', 'default' ); |
|
1182 | - if ( ! $per_page ) { |
|
1179 | + $per_page = (int) get_user_option($option); |
|
1180 | + if (empty($per_page) || $per_page < 1) { |
|
1181 | + $per_page = $this->get_option('per_page', 'default'); |
|
1182 | + if ( ! $per_page) { |
|
1183 | 1183 | $per_page = 20; |
1184 | 1184 | } |
1185 | 1185 | } |
1186 | 1186 | |
1187 | - if ( 'edit_comments_per_page' == $option ) { |
|
1188 | - $comment_status = isset( $_REQUEST['comment_status'] ) ? $_REQUEST['comment_status'] : 'all'; |
|
1187 | + if ('edit_comments_per_page' == $option) { |
|
1188 | + $comment_status = isset($_REQUEST['comment_status']) ? $_REQUEST['comment_status'] : 'all'; |
|
1189 | 1189 | |
1190 | 1190 | /** This filter is documented in wp-admin/includes/class-wp-comments-list-table.php */ |
1191 | - $per_page = apply_filters( 'comments_per_page', $per_page, $comment_status ); |
|
1192 | - } elseif ( 'categories_per_page' == $option ) { |
|
1191 | + $per_page = apply_filters('comments_per_page', $per_page, $comment_status); |
|
1192 | + } elseif ('categories_per_page' == $option) { |
|
1193 | 1193 | /** This filter is documented in wp-admin/includes/class-wp-terms-list-table.php */ |
1194 | - $per_page = apply_filters( 'edit_categories_per_page', $per_page ); |
|
1194 | + $per_page = apply_filters('edit_categories_per_page', $per_page); |
|
1195 | 1195 | } else { |
1196 | 1196 | /** This filter is documented in wp-admin/includes/class-wp-list-table.php */ |
1197 | - $per_page = apply_filters( $option, $per_page ); |
|
1197 | + $per_page = apply_filters($option, $per_page); |
|
1198 | 1198 | } |
1199 | 1199 | |
1200 | 1200 | // Back compat |
1201 | - if ( isset( $this->post_type ) ) { |
|
1201 | + if (isset($this->post_type)) { |
|
1202 | 1202 | /** This filter is documented in wp-admin/includes/class-wp-posts-list-table.php */ |
1203 | - $per_page = apply_filters( 'edit_posts_per_page', $per_page, $this->post_type ); |
|
1203 | + $per_page = apply_filters('edit_posts_per_page', $per_page, $this->post_type); |
|
1204 | 1204 | } |
1205 | 1205 | |
1206 | 1206 | ?> |
1207 | 1207 | <div class="screen-options"> |
1208 | - <?php if ( $per_page_label ) : ?> |
|
1209 | - <label for="<?php echo esc_attr( $option ); ?>"><?php echo $per_page_label; ?></label> |
|
1208 | + <?php if ($per_page_label) : ?> |
|
1209 | + <label for="<?php echo esc_attr($option); ?>"><?php echo $per_page_label; ?></label> |
|
1210 | 1210 | <input type="number" step="1" min="1" max="999" class="screen-per-page" name="wp_screen_options[value]" |
1211 | - id="<?php echo esc_attr( $option ); ?>" maxlength="3" |
|
1212 | - value="<?php echo esc_attr( $per_page ); ?>" /> |
|
1211 | + id="<?php echo esc_attr($option); ?>" maxlength="3" |
|
1212 | + value="<?php echo esc_attr($per_page); ?>" /> |
|
1213 | 1213 | <?php endif; |
1214 | 1214 | |
1215 | - echo get_submit_button( __( 'Apply' ), 'button', 'screen-options-apply', false ); ?> |
|
1216 | - <input type="hidden" name="wp_screen_options[option]" value="<?php echo esc_attr( $option ); ?>" /> |
|
1215 | + echo get_submit_button(__('Apply'), 'button', 'screen-options-apply', false); ?> |
|
1216 | + <input type="hidden" name="wp_screen_options[option]" value="<?php echo esc_attr($option); ?>" /> |
|
1217 | 1217 | </div> |
1218 | 1218 | <?php |
1219 | 1219 | } |
@@ -17,8 +17,9 @@ discard block |
||
17 | 17 | * @return array Containing the headers in the format id => UI String |
18 | 18 | */ |
19 | 19 | function get_column_headers( $screen ) { |
20 | - if ( is_string( $screen ) ) |
|
21 | - $screen = convert_to_screen( $screen ); |
|
20 | + if ( is_string( $screen ) ) { |
|
21 | + $screen = convert_to_screen( $screen ); |
|
22 | + } |
|
22 | 23 | |
23 | 24 | static $column_headers = array(); |
24 | 25 | |
@@ -51,8 +52,9 @@ discard block |
||
51 | 52 | * @return array |
52 | 53 | */ |
53 | 54 | function get_hidden_columns( $screen ) { |
54 | - if ( is_string( $screen ) ) |
|
55 | - $screen = convert_to_screen( $screen ); |
|
55 | + if ( is_string( $screen ) ) { |
|
56 | + $screen = convert_to_screen( $screen ); |
|
57 | + } |
|
56 | 58 | |
57 | 59 | return (array) get_user_option( 'manage' . $screen->id . 'columnshidden' ); |
58 | 60 | } |
@@ -69,11 +71,13 @@ discard block |
||
69 | 71 | function meta_box_prefs( $screen ) { |
70 | 72 | global $wp_meta_boxes; |
71 | 73 | |
72 | - if ( is_string( $screen ) ) |
|
73 | - $screen = convert_to_screen( $screen ); |
|
74 | + if ( is_string( $screen ) ) { |
|
75 | + $screen = convert_to_screen( $screen ); |
|
76 | + } |
|
74 | 77 | |
75 | - if ( empty($wp_meta_boxes[$screen->id]) ) |
|
76 | - return; |
|
78 | + if ( empty($wp_meta_boxes[$screen->id]) ) { |
|
79 | + return; |
|
80 | + } |
|
77 | 81 | |
78 | 82 | $hidden = get_hidden_meta_boxes($screen); |
79 | 83 | |
@@ -83,11 +87,13 @@ discard block |
||
83 | 87 | continue; |
84 | 88 | } |
85 | 89 | foreach ( $wp_meta_boxes[ $screen->id ][ $context ][ $priority ] as $box ) { |
86 | - if ( false == $box || ! $box['title'] ) |
|
87 | - continue; |
|
90 | + if ( false == $box || ! $box['title'] ) { |
|
91 | + continue; |
|
92 | + } |
|
88 | 93 | // Submit box cannot be hidden |
89 | - if ( 'submitdiv' == $box['id'] || 'linksubmitdiv' == $box['id'] ) |
|
90 | - continue; |
|
94 | + if ( 'submitdiv' == $box['id'] || 'linksubmitdiv' == $box['id'] ) { |
|
95 | + continue; |
|
96 | + } |
|
91 | 97 | $box_id = $box['id']; |
92 | 98 | echo '<label for="' . $box_id . '-hide">'; |
93 | 99 | echo '<input class="hide-postbox-tog" name="' . $box_id . '-hide" type="checkbox" id="' . $box_id . '-hide" value="' . $box_id . '"' . (! in_array($box_id, $hidden) ? ' checked="checked"' : '') . ' />'; |
@@ -106,8 +112,9 @@ discard block |
||
106 | 112 | * @return array Hidden Meta Boxes |
107 | 113 | */ |
108 | 114 | function get_hidden_meta_boxes( $screen ) { |
109 | - if ( is_string( $screen ) ) |
|
110 | - $screen = convert_to_screen( $screen ); |
|
115 | + if ( is_string( $screen ) ) { |
|
116 | + $screen = convert_to_screen( $screen ); |
|
117 | + } |
|
111 | 118 | |
112 | 119 | $hidden = get_user_option( "metaboxhidden_{$screen->id}" ); |
113 | 120 | |
@@ -117,10 +124,11 @@ discard block |
||
117 | 124 | if ( $use_defaults ) { |
118 | 125 | $hidden = array(); |
119 | 126 | if ( 'post' == $screen->base ) { |
120 | - if ( 'post' == $screen->post_type || 'page' == $screen->post_type || 'attachment' == $screen->post_type ) |
|
121 | - $hidden = array('slugdiv', 'trackbacksdiv', 'postcustom', 'postexcerpt', 'commentstatusdiv', 'commentsdiv', 'authordiv', 'revisionsdiv'); |
|
122 | - else |
|
123 | - $hidden = array( 'slugdiv' ); |
|
127 | + if ( 'post' == $screen->post_type || 'page' == $screen->post_type || 'attachment' == $screen->post_type ) { |
|
128 | + $hidden = array('slugdiv', 'trackbacksdiv', 'postcustom', 'postexcerpt', 'commentstatusdiv', 'commentsdiv', 'authordiv', 'revisionsdiv'); |
|
129 | + } else { |
|
130 | + $hidden = array( 'slugdiv' ); |
|
131 | + } |
|
124 | 132 | } |
125 | 133 | |
126 | 134 | /** |
@@ -158,8 +166,9 @@ discard block |
||
158 | 166 | function add_screen_option( $option, $args = array() ) { |
159 | 167 | $current_screen = get_current_screen(); |
160 | 168 | |
161 | - if ( ! $current_screen ) |
|
162 | - return; |
|
169 | + if ( ! $current_screen ) { |
|
170 | + return; |
|
171 | + } |
|
163 | 172 | |
164 | 173 | $current_screen->add_option( $option, $args ); |
165 | 174 | } |
@@ -176,8 +185,9 @@ discard block |
||
176 | 185 | function get_current_screen() { |
177 | 186 | global $current_screen; |
178 | 187 | |
179 | - if ( ! isset( $current_screen ) ) |
|
180 | - return null; |
|
188 | + if ( ! isset( $current_screen ) ) { |
|
189 | + return null; |
|
190 | + } |
|
181 | 191 | |
182 | 192 | return $current_screen; |
183 | 193 | } |
@@ -402,18 +412,20 @@ discard block |
||
402 | 412 | $in_admin = false; |
403 | 413 | $action = ''; |
404 | 414 | |
405 | - if ( $hook_name ) |
|
406 | - $id = $hook_name; |
|
407 | - else |
|
408 | - $id = $GLOBALS['hook_suffix']; |
|
415 | + if ( $hook_name ) { |
|
416 | + $id = $hook_name; |
|
417 | + } else { |
|
418 | + $id = $GLOBALS['hook_suffix']; |
|
419 | + } |
|
409 | 420 | |
410 | 421 | // For those pesky meta boxes. |
411 | 422 | if ( $hook_name && post_type_exists( $hook_name ) ) { |
412 | 423 | $post_type = $id; |
413 | 424 | $id = 'post'; // changes later. ends up being $base. |
414 | 425 | } else { |
415 | - if ( '.php' == substr( $id, -4 ) ) |
|
416 | - $id = substr( $id, 0, -4 ); |
|
426 | + if ( '.php' == substr( $id, -4 ) ) { |
|
427 | + $id = substr( $id, 0, -4 ); |
|
428 | + } |
|
417 | 429 | |
418 | 430 | if ( 'post-new' == $id || 'link-add' == $id || 'media-new' == $id || 'user-new' == $id ) { |
419 | 431 | $id = substr( $id, 0, -4 ); |
@@ -442,72 +454,84 @@ discard block |
||
442 | 454 | } |
443 | 455 | } |
444 | 456 | |
445 | - if ( ! $in_admin ) |
|
446 | - $in_admin = 'site'; |
|
457 | + if ( ! $in_admin ) { |
|
458 | + $in_admin = 'site'; |
|
459 | + } |
|
447 | 460 | } else { |
448 | - if ( defined( 'WP_NETWORK_ADMIN' ) && WP_NETWORK_ADMIN ) |
|
449 | - $in_admin = 'network'; |
|
450 | - elseif ( defined( 'WP_USER_ADMIN' ) && WP_USER_ADMIN ) |
|
451 | - $in_admin = 'user'; |
|
452 | - else |
|
453 | - $in_admin = 'site'; |
|
461 | + if ( defined( 'WP_NETWORK_ADMIN' ) && WP_NETWORK_ADMIN ) { |
|
462 | + $in_admin = 'network'; |
|
463 | + } elseif ( defined( 'WP_USER_ADMIN' ) && WP_USER_ADMIN ) { |
|
464 | + $in_admin = 'user'; |
|
465 | + } else { |
|
466 | + $in_admin = 'site'; |
|
467 | + } |
|
454 | 468 | } |
455 | 469 | |
456 | - if ( 'index' == $id ) |
|
457 | - $id = 'dashboard'; |
|
458 | - elseif ( 'front' == $id ) |
|
459 | - $in_admin = false; |
|
470 | + if ( 'index' == $id ) { |
|
471 | + $id = 'dashboard'; |
|
472 | + } elseif ( 'front' == $id ) { |
|
473 | + $in_admin = false; |
|
474 | + } |
|
460 | 475 | |
461 | 476 | $base = $id; |
462 | 477 | |
463 | 478 | // If this is the current screen, see if we can be more accurate for post types and taxonomies. |
464 | 479 | if ( ! $hook_name ) { |
465 | - if ( isset( $_REQUEST['post_type'] ) ) |
|
466 | - $post_type = post_type_exists( $_REQUEST['post_type'] ) ? $_REQUEST['post_type'] : false; |
|
467 | - if ( isset( $_REQUEST['taxonomy'] ) ) |
|
468 | - $taxonomy = taxonomy_exists( $_REQUEST['taxonomy'] ) ? $_REQUEST['taxonomy'] : false; |
|
480 | + if ( isset( $_REQUEST['post_type'] ) ) { |
|
481 | + $post_type = post_type_exists( $_REQUEST['post_type'] ) ? $_REQUEST['post_type'] : false; |
|
482 | + } |
|
483 | + if ( isset( $_REQUEST['taxonomy'] ) ) { |
|
484 | + $taxonomy = taxonomy_exists( $_REQUEST['taxonomy'] ) ? $_REQUEST['taxonomy'] : false; |
|
485 | + } |
|
469 | 486 | |
470 | 487 | switch ( $base ) { |
471 | 488 | case 'post' : |
472 | - if ( isset( $_GET['post'] ) ) |
|
473 | - $post_id = (int) $_GET['post']; |
|
474 | - elseif ( isset( $_POST['post_ID'] ) ) |
|
475 | - $post_id = (int) $_POST['post_ID']; |
|
476 | - else |
|
477 | - $post_id = 0; |
|
489 | + if ( isset( $_GET['post'] ) ) { |
|
490 | + $post_id = (int) $_GET['post']; |
|
491 | + } elseif ( isset( $_POST['post_ID'] ) ) { |
|
492 | + $post_id = (int) $_POST['post_ID']; |
|
493 | + } else { |
|
494 | + $post_id = 0; |
|
495 | + } |
|
478 | 496 | |
479 | 497 | if ( $post_id ) { |
480 | 498 | $post = get_post( $post_id ); |
481 | - if ( $post ) |
|
482 | - $post_type = $post->post_type; |
|
499 | + if ( $post ) { |
|
500 | + $post_type = $post->post_type; |
|
501 | + } |
|
483 | 502 | } |
484 | 503 | break; |
485 | 504 | case 'edit-tags' : |
486 | - if ( null === $post_type && is_object_in_taxonomy( 'post', $taxonomy ? $taxonomy : 'post_tag' ) ) |
|
487 | - $post_type = 'post'; |
|
505 | + if ( null === $post_type && is_object_in_taxonomy( 'post', $taxonomy ? $taxonomy : 'post_tag' ) ) { |
|
506 | + $post_type = 'post'; |
|
507 | + } |
|
488 | 508 | break; |
489 | 509 | } |
490 | 510 | } |
491 | 511 | |
492 | 512 | switch ( $base ) { |
493 | 513 | case 'post' : |
494 | - if ( null === $post_type ) |
|
495 | - $post_type = 'post'; |
|
514 | + if ( null === $post_type ) { |
|
515 | + $post_type = 'post'; |
|
516 | + } |
|
496 | 517 | $id = $post_type; |
497 | 518 | break; |
498 | 519 | case 'edit' : |
499 | - if ( null === $post_type ) |
|
500 | - $post_type = 'post'; |
|
520 | + if ( null === $post_type ) { |
|
521 | + $post_type = 'post'; |
|
522 | + } |
|
501 | 523 | $id .= '-' . $post_type; |
502 | 524 | break; |
503 | 525 | case 'edit-tags' : |
504 | - if ( null === $taxonomy ) |
|
505 | - $taxonomy = 'post_tag'; |
|
526 | + if ( null === $taxonomy ) { |
|
527 | + $taxonomy = 'post_tag'; |
|
528 | + } |
|
506 | 529 | // The edit-tags ID does not contain the post type. Look for it in the request. |
507 | 530 | if ( null === $post_type ) { |
508 | 531 | $post_type = 'post'; |
509 | - if ( isset( $_REQUEST['post_type'] ) && post_type_exists( $_REQUEST['post_type'] ) ) |
|
510 | - $post_type = $_REQUEST['post_type']; |
|
532 | + if ( isset( $_REQUEST['post_type'] ) && post_type_exists( $_REQUEST['post_type'] ) ) { |
|
533 | + $post_type = $_REQUEST['post_type']; |
|
534 | + } |
|
511 | 535 | } |
512 | 536 | |
513 | 537 | $id = 'edit-' . $taxonomy; |
@@ -524,8 +548,9 @@ discard block |
||
524 | 548 | |
525 | 549 | if ( isset( self::$_registry[ $id ] ) ) { |
526 | 550 | $screen = self::$_registry[ $id ]; |
527 | - if ( $screen === get_current_screen() ) |
|
528 | - return $screen; |
|
551 | + if ( $screen === get_current_screen() ) { |
|
552 | + return $screen; |
|
553 | + } |
|
529 | 554 | } else { |
530 | 555 | $screen = new WP_Screen(); |
531 | 556 | $screen->id = $id; |
@@ -588,8 +613,9 @@ discard block |
||
588 | 613 | * @return bool True if the screen is in the indicated admin, false otherwise. |
589 | 614 | */ |
590 | 615 | public function in_admin( $admin = null ) { |
591 | - if ( empty( $admin ) ) |
|
592 | - return (bool) $this->in_admin; |
|
616 | + if ( empty( $admin ) ) { |
|
617 | + return (bool) $this->in_admin; |
|
618 | + } |
|
593 | 619 | |
594 | 620 | return ( $admin == $this->in_admin ); |
595 | 621 | } |
@@ -679,11 +705,13 @@ discard block |
||
679 | 705 | * @return string The option value if set, null otherwise. |
680 | 706 | */ |
681 | 707 | public function get_option( $option, $key = false ) { |
682 | - if ( ! isset( $this->_options[ $option ] ) ) |
|
683 | - return null; |
|
708 | + if ( ! isset( $this->_options[ $option ] ) ) { |
|
709 | + return null; |
|
710 | + } |
|
684 | 711 | if ( $key ) { |
685 | - if ( isset( $this->_options[ $option ][ $key ] ) ) |
|
686 | - return $this->_options[ $option ][ $key ]; |
|
712 | + if ( isset( $this->_options[ $option ][ $key ] ) ) { |
|
713 | + return $this->_options[ $option ][ $key ]; |
|
714 | + } |
|
687 | 715 | return null; |
688 | 716 | } |
689 | 717 | return $this->_options[ $option ]; |
@@ -709,8 +737,9 @@ discard block |
||
709 | 737 | * @return array Help tab arguments. |
710 | 738 | */ |
711 | 739 | public function get_help_tab( $id ) { |
712 | - if ( ! isset( $this->_help_tabs[ $id ] ) ) |
|
713 | - return null; |
|
740 | + if ( ! isset( $this->_help_tabs[ $id ] ) ) { |
|
741 | + return null; |
|
742 | + } |
|
714 | 743 | return $this->_help_tabs[ $id ]; |
715 | 744 | } |
716 | 745 | |
@@ -739,8 +768,9 @@ discard block |
||
739 | 768 | $args['id'] = sanitize_html_class( $args['id'] ); |
740 | 769 | |
741 | 770 | // Ensure we have an ID and title. |
742 | - if ( ! $args['id'] || ! $args['title'] ) |
|
743 | - return; |
|
771 | + if ( ! $args['id'] || ! $args['title'] ) { |
|
772 | + return; |
|
773 | + } |
|
744 | 774 | |
745 | 775 | // Allows for overriding an existing tab with that ID. |
746 | 776 | $this->_help_tabs[ $args['id'] ] = $args; |
@@ -858,8 +888,9 @@ discard block |
||
858 | 888 | * @param string $old_help_default Default contextual help text. |
859 | 889 | */ |
860 | 890 | $default_help = apply_filters( 'default_contextual_help', '' ); |
861 | - if ( $default_help ) |
|
862 | - $old_help = '<p>' . $default_help . '</p>'; |
|
891 | + if ( $default_help ) { |
|
892 | + $old_help = '<p>' . $default_help . '</p>'; |
|
893 | + } |
|
863 | 894 | } |
864 | 895 | |
865 | 896 | if ( $old_help ) { |
@@ -873,8 +904,9 @@ discard block |
||
873 | 904 | $help_sidebar = $this->get_help_sidebar(); |
874 | 905 | |
875 | 906 | $help_class = 'hidden'; |
876 | - if ( ! $help_sidebar ) |
|
877 | - $help_class .= ' no-sidebar'; |
|
907 | + if ( ! $help_sidebar ) { |
|
908 | + $help_class .= ' no-sidebar'; |
|
909 | + } |
|
878 | 910 | |
879 | 911 | // Time to render! |
880 | 912 | ?> |
@@ -923,8 +955,9 @@ discard block |
||
923 | 955 | echo $tab['content']; |
924 | 956 | |
925 | 957 | // If it exists, fire tab callback. |
926 | - if ( ! empty( $tab['callback'] ) ) |
|
927 | - call_user_func_array( $tab['callback'], array( $this, $tab ) ); |
|
958 | + if ( ! empty( $tab['callback'] ) ) { |
|
959 | + call_user_func_array( $tab['callback'], array( $this, $tab ) ); |
|
960 | + } |
|
928 | 961 | ?> |
929 | 962 | </div> |
930 | 963 | <?php |
@@ -951,25 +984,29 @@ discard block |
||
951 | 984 | */ |
952 | 985 | $columns = apply_filters( 'screen_layout_columns', array(), $this->id, $this ); |
953 | 986 | |
954 | - if ( ! empty( $columns ) && isset( $columns[ $this->id ] ) ) |
|
955 | - $this->add_option( 'layout_columns', array('max' => $columns[ $this->id ] ) ); |
|
987 | + if ( ! empty( $columns ) && isset( $columns[ $this->id ] ) ) { |
|
988 | + $this->add_option( 'layout_columns', array('max' => $columns[ $this->id ] ) ); |
|
989 | + } |
|
956 | 990 | |
957 | 991 | if ( $this->get_option( 'layout_columns' ) ) { |
958 | 992 | $this->columns = (int) get_user_option("screen_layout_$this->id"); |
959 | 993 | |
960 | - if ( ! $this->columns && $this->get_option( 'layout_columns', 'default' ) ) |
|
961 | - $this->columns = $this->get_option( 'layout_columns', 'default' ); |
|
994 | + if ( ! $this->columns && $this->get_option( 'layout_columns', 'default' ) ) { |
|
995 | + $this->columns = $this->get_option( 'layout_columns', 'default' ); |
|
996 | + } |
|
962 | 997 | } |
963 | 998 | $GLOBALS[ 'screen_layout_columns' ] = $this->columns; // Set the global for back-compat. |
964 | 999 | |
965 | 1000 | // Add screen options |
966 | - if ( $this->show_screen_options() ) |
|
967 | - $this->render_screen_options(); |
|
1001 | + if ( $this->show_screen_options() ) { |
|
1002 | + $this->render_screen_options(); |
|
1003 | + } |
|
968 | 1004 | ?> |
969 | 1005 | </div> |
970 | 1006 | <?php |
971 | - if ( ! $this->get_help_tabs() && ! $this->show_screen_options() ) |
|
972 | - return; |
|
1007 | + if ( ! $this->get_help_tabs() && ! $this->show_screen_options() ) { |
|
1008 | + return; |
|
1009 | + } |
|
973 | 1010 | ?> |
974 | 1011 | <div id="screen-meta-links"> |
975 | 1012 | <?php if ( $this->get_help_tabs() ) : ?> |
@@ -995,8 +1032,9 @@ discard block |
||
995 | 1032 | public function show_screen_options() { |
996 | 1033 | global $wp_meta_boxes; |
997 | 1034 | |
998 | - if ( is_bool( $this->_show_screen_options ) ) |
|
999 | - return $this->_show_screen_options; |
|
1035 | + if ( is_bool( $this->_show_screen_options ) ) { |
|
1036 | + return $this->_show_screen_options; |
|
1037 | + } |
|
1000 | 1038 | |
1001 | 1039 | $columns = get_column_headers( $this ); |
1002 | 1040 | |
@@ -1030,8 +1068,9 @@ discard block |
||
1030 | 1068 | */ |
1031 | 1069 | $this->_screen_settings = apply_filters( 'screen_settings', $this->_screen_settings, $this ); |
1032 | 1070 | |
1033 | - if ( $this->_screen_settings || $this->_options ) |
|
1034 | - $show_screen = true; |
|
1071 | + if ( $this->_screen_settings || $this->_options ) { |
|
1072 | + $show_screen = true; |
|
1073 | + } |
|
1035 | 1074 | |
1036 | 1075 | /** |
1037 | 1076 | * Filter whether to show the Screen Options tab. |
@@ -1078,8 +1117,9 @@ discard block |
||
1078 | 1117 | update_user_meta( get_current_user_id(), 'show_welcome_panel', $welcome_checked ); |
1079 | 1118 | } else { |
1080 | 1119 | $welcome_checked = get_user_meta( get_current_user_id(), 'show_welcome_panel', true ); |
1081 | - if ( 2 == $welcome_checked && wp_get_current_user()->user_email != get_option( 'admin_email' ) ) |
|
1082 | - $welcome_checked = false; |
|
1120 | + if ( 2 == $welcome_checked && wp_get_current_user()->user_email != get_option( 'admin_email' ) ) { |
|
1121 | + $welcome_checked = false; |
|
1122 | + } |
|
1083 | 1123 | } |
1084 | 1124 | echo '<label for="wp_welcome_panel-hide">'; |
1085 | 1125 | echo '<input type="checkbox" id="wp_welcome_panel-hide"' . checked( (bool) $welcome_checked, true, false ) . ' />'; |
@@ -1099,13 +1139,16 @@ discard block |
||
1099 | 1139 | |
1100 | 1140 | foreach ( $columns as $column => $title ) { |
1101 | 1141 | // Can't hide these for they are special |
1102 | - if ( in_array( $column, $special ) ) |
|
1103 | - continue; |
|
1104 | - if ( empty( $title ) ) |
|
1105 | - continue; |
|
1142 | + if ( in_array( $column, $special ) ) { |
|
1143 | + continue; |
|
1144 | + } |
|
1145 | + if ( empty( $title ) ) { |
|
1146 | + continue; |
|
1147 | + } |
|
1106 | 1148 | |
1107 | - if ( 'comments' == $column ) |
|
1108 | - $title = __( 'Comments' ); |
|
1149 | + if ( 'comments' == $column ) { |
|
1150 | + $title = __( 'Comments' ); |
|
1151 | + } |
|
1109 | 1152 | $id = "$column-hide"; |
1110 | 1153 | echo '<label for="' . $id . '">'; |
1111 | 1154 | echo '<input class="hide-column-tog" name="' . $id . '" type="checkbox" id="' . $id . '" value="' . $column . '"' . checked( !in_array($column, $hidden), true, false ) . ' />'; |
@@ -1133,8 +1176,9 @@ discard block |
||
1133 | 1176 | * @since 3.3.0 |
1134 | 1177 | */ |
1135 | 1178 | public function render_screen_layout() { |
1136 | - if ( ! $this->get_option('layout_columns') ) |
|
1137 | - return; |
|
1179 | + if ( ! $this->get_option('layout_columns') ) { |
|
1180 | + return; |
|
1181 | + } |
|
1138 | 1182 | |
1139 | 1183 | $screen_layout_columns = $this->get_columns(); |
1140 | 1184 | $num = $this->get_option( 'layout_columns', 'max' ); |
@@ -1,10 +1,10 @@ |
||
1 | 1 | <?php |
2 | 2 | /** |
3 | - * WordPress Comment Administration API. |
|
4 | - * |
|
5 | - * @package WordPress |
|
6 | - * @subpackage Administration |
|
7 | - */ |
|
3 | + * WordPress Comment Administration API. |
|
4 | + * |
|
5 | + * @package WordPress |
|
6 | + * @subpackage Administration |
|
7 | + */ |
|
8 | 8 | |
9 | 9 | /** |
10 | 10 | * Determine if a comment exists based on author and date. |
@@ -20,11 +20,11 @@ discard block |
||
20 | 20 | function comment_exists($comment_author, $comment_date) { |
21 | 21 | global $wpdb; |
22 | 22 | |
23 | - return $wpdb->get_var( $wpdb->prepare("SELECT comment_post_ID FROM $wpdb->comments |
|
23 | + return $wpdb->get_var($wpdb->prepare("SELECT comment_post_ID FROM $wpdb->comments |
|
24 | 24 | WHERE comment_author = %s AND comment_date = %s", |
25 | - stripslashes( $comment_author ), |
|
26 | - stripslashes( $comment_date ) |
|
27 | - ) ); |
|
25 | + stripslashes($comment_author), |
|
26 | + stripslashes($comment_date) |
|
27 | + )); |
|
28 | 28 | } |
29 | 29 | |
30 | 30 | /** |
@@ -33,44 +33,44 @@ discard block |
||
33 | 33 | * @since 2.0.0 |
34 | 34 | */ |
35 | 35 | function edit_comment() { |
36 | - if ( ! current_user_can( 'edit_comment', (int) $_POST['comment_ID'] ) ) |
|
37 | - wp_die ( __( 'You are not allowed to edit comments on this post.' ) ); |
|
36 | + if ( ! current_user_can('edit_comment', (int) $_POST['comment_ID'])) |
|
37 | + wp_die(__('You are not allowed to edit comments on this post.')); |
|
38 | 38 | |
39 | - if ( isset( $_POST['newcomment_author'] ) ) |
|
39 | + if (isset($_POST['newcomment_author'])) |
|
40 | 40 | $_POST['comment_author'] = $_POST['newcomment_author']; |
41 | - if ( isset( $_POST['newcomment_author_email'] ) ) |
|
41 | + if (isset($_POST['newcomment_author_email'])) |
|
42 | 42 | $_POST['comment_author_email'] = $_POST['newcomment_author_email']; |
43 | - if ( isset( $_POST['newcomment_author_url'] ) ) |
|
43 | + if (isset($_POST['newcomment_author_url'])) |
|
44 | 44 | $_POST['comment_author_url'] = $_POST['newcomment_author_url']; |
45 | - if ( isset( $_POST['comment_status'] ) ) |
|
45 | + if (isset($_POST['comment_status'])) |
|
46 | 46 | $_POST['comment_approved'] = $_POST['comment_status']; |
47 | - if ( isset( $_POST['content'] ) ) |
|
47 | + if (isset($_POST['content'])) |
|
48 | 48 | $_POST['comment_content'] = $_POST['content']; |
49 | - if ( isset( $_POST['comment_ID'] ) ) |
|
49 | + if (isset($_POST['comment_ID'])) |
|
50 | 50 | $_POST['comment_ID'] = (int) $_POST['comment_ID']; |
51 | 51 | |
52 | - foreach ( array ('aa', 'mm', 'jj', 'hh', 'mn') as $timeunit ) { |
|
53 | - if ( !empty( $_POST['hidden_' . $timeunit] ) && $_POST['hidden_' . $timeunit] != $_POST[$timeunit] ) { |
|
52 | + foreach (array('aa', 'mm', 'jj', 'hh', 'mn') as $timeunit) { |
|
53 | + if ( ! empty($_POST['hidden_'.$timeunit]) && $_POST['hidden_'.$timeunit] != $_POST[$timeunit]) { |
|
54 | 54 | $_POST['edit_date'] = '1'; |
55 | 55 | break; |
56 | 56 | } |
57 | 57 | } |
58 | 58 | |
59 | - if ( !empty ( $_POST['edit_date'] ) ) { |
|
59 | + if ( ! empty ($_POST['edit_date'])) { |
|
60 | 60 | $aa = $_POST['aa']; |
61 | 61 | $mm = $_POST['mm']; |
62 | 62 | $jj = $_POST['jj']; |
63 | 63 | $hh = $_POST['hh']; |
64 | 64 | $mn = $_POST['mn']; |
65 | 65 | $ss = $_POST['ss']; |
66 | - $jj = ($jj > 31 ) ? 31 : $jj; |
|
67 | - $hh = ($hh > 23 ) ? $hh -24 : $hh; |
|
68 | - $mn = ($mn > 59 ) ? $mn -60 : $mn; |
|
69 | - $ss = ($ss > 59 ) ? $ss -60 : $ss; |
|
66 | + $jj = ($jj > 31) ? 31 : $jj; |
|
67 | + $hh = ($hh > 23) ? $hh - 24 : $hh; |
|
68 | + $mn = ($mn > 59) ? $mn - 60 : $mn; |
|
69 | + $ss = ($ss > 59) ? $ss - 60 : $ss; |
|
70 | 70 | $_POST['comment_date'] = "$aa-$mm-$jj $hh:$mn:$ss"; |
71 | 71 | } |
72 | 72 | |
73 | - wp_update_comment( $_POST ); |
|
73 | + wp_update_comment($_POST); |
|
74 | 74 | } |
75 | 75 | |
76 | 76 | /** |
@@ -81,14 +81,14 @@ discard block |
||
81 | 81 | * @param int $id ID of comment to retrieve. |
82 | 82 | * @return object|false Comment if found. False on failure. |
83 | 83 | */ |
84 | -function get_comment_to_edit( $id ) { |
|
85 | - if ( !$comment = get_comment($id) ) |
|
84 | +function get_comment_to_edit($id) { |
|
85 | + if ( ! $comment = get_comment($id)) |
|
86 | 86 | return false; |
87 | 87 | |
88 | 88 | $comment->comment_ID = (int) $comment->comment_ID; |
89 | 89 | $comment->comment_post_ID = (int) $comment->comment_post_ID; |
90 | 90 | |
91 | - $comment->comment_content = format_to_edit( $comment->comment_content ); |
|
91 | + $comment->comment_content = format_to_edit($comment->comment_content); |
|
92 | 92 | /** |
93 | 93 | * Filter the comment content before editing. |
94 | 94 | * |
@@ -96,11 +96,11 @@ discard block |
||
96 | 96 | * |
97 | 97 | * @param string $comment->comment_content Comment content. |
98 | 98 | */ |
99 | - $comment->comment_content = apply_filters( 'comment_edit_pre', $comment->comment_content ); |
|
99 | + $comment->comment_content = apply_filters('comment_edit_pre', $comment->comment_content); |
|
100 | 100 | |
101 | - $comment->comment_author = format_to_edit( $comment->comment_author ); |
|
102 | - $comment->comment_author_email = format_to_edit( $comment->comment_author_email ); |
|
103 | - $comment->comment_author_url = format_to_edit( $comment->comment_author_url ); |
|
101 | + $comment->comment_author = format_to_edit($comment->comment_author); |
|
102 | + $comment->comment_author_email = format_to_edit($comment->comment_author_email); |
|
103 | + $comment->comment_author_url = format_to_edit($comment->comment_author_url); |
|
104 | 104 | $comment->comment_author_url = esc_url($comment->comment_author_url); |
105 | 105 | |
106 | 106 | return $comment; |
@@ -116,23 +116,23 @@ discard block |
||
116 | 116 | * @param int|array $post_id Either a single Post ID or an array of Post IDs |
117 | 117 | * @return int|array Either a single Posts pending comments as an int or an array of ints keyed on the Post IDs |
118 | 118 | */ |
119 | -function get_pending_comments_num( $post_id ) { |
|
119 | +function get_pending_comments_num($post_id) { |
|
120 | 120 | global $wpdb; |
121 | 121 | |
122 | 122 | $single = false; |
123 | - if ( !is_array($post_id) ) { |
|
123 | + if ( ! is_array($post_id)) { |
|
124 | 124 | $post_id_array = (array) $post_id; |
125 | 125 | $single = true; |
126 | 126 | } else { |
127 | 127 | $post_id_array = $post_id; |
128 | 128 | } |
129 | 129 | $post_id_array = array_map('intval', $post_id_array); |
130 | - $post_id_in = "'" . implode("', '", $post_id_array) . "'"; |
|
130 | + $post_id_in = "'".implode("', '", $post_id_array)."'"; |
|
131 | 131 | |
132 | - $pending = $wpdb->get_results( "SELECT comment_post_ID, COUNT(comment_ID) as num_comments FROM $wpdb->comments WHERE comment_post_ID IN ( $post_id_in ) AND comment_approved = '0' GROUP BY comment_post_ID", ARRAY_A ); |
|
132 | + $pending = $wpdb->get_results("SELECT comment_post_ID, COUNT(comment_ID) as num_comments FROM $wpdb->comments WHERE comment_post_ID IN ( $post_id_in ) AND comment_approved = '0' GROUP BY comment_post_ID", ARRAY_A); |
|
133 | 133 | |
134 | - if ( $single ) { |
|
135 | - if ( empty($pending) ) |
|
134 | + if ($single) { |
|
135 | + if (empty($pending)) |
|
136 | 136 | return 0; |
137 | 137 | else |
138 | 138 | return absint($pending[0]['num_comments']); |
@@ -141,11 +141,11 @@ discard block |
||
141 | 141 | $pending_keyed = array(); |
142 | 142 | |
143 | 143 | // Default to zero pending for all posts in request |
144 | - foreach ( $post_id_array as $id ) |
|
144 | + foreach ($post_id_array as $id) |
|
145 | 145 | $pending_keyed[$id] = 0; |
146 | 146 | |
147 | - if ( !empty($pending) ) |
|
148 | - foreach ( $pending as $pend ) |
|
147 | + if ( ! empty($pending)) |
|
148 | + foreach ($pending as $pend) |
|
149 | 149 | $pending_keyed[$pend['comment_post_ID']] = absint($pend['num_comments']); |
150 | 150 | |
151 | 151 | return $pending_keyed; |
@@ -161,9 +161,9 @@ discard block |
||
161 | 161 | * @param string $name User name. |
162 | 162 | * @return string Avatar with Admin name. |
163 | 163 | */ |
164 | -function floated_admin_avatar( $name ) { |
|
164 | +function floated_admin_avatar($name) { |
|
165 | 165 | global $comment; |
166 | - $avatar = get_avatar( $comment, 32, 'mystery' ); |
|
166 | + $avatar = get_avatar($comment, 32, 'mystery'); |
|
167 | 167 | return "$avatar $name"; |
168 | 168 | } |
169 | 169 | |
@@ -171,6 +171,6 @@ discard block |
||
171 | 171 | * @since 2.7.0 |
172 | 172 | */ |
173 | 173 | function enqueue_comment_hotkeys_js() { |
174 | - if ( 'true' == get_user_option( 'comment_shortcuts' ) ) |
|
175 | - wp_enqueue_script( 'jquery-table-hotkeys' ); |
|
174 | + if ('true' == get_user_option('comment_shortcuts')) |
|
175 | + wp_enqueue_script('jquery-table-hotkeys'); |
|
176 | 176 | } |
@@ -33,21 +33,28 @@ discard block |
||
33 | 33 | * @since 2.0.0 |
34 | 34 | */ |
35 | 35 | function edit_comment() { |
36 | - if ( ! current_user_can( 'edit_comment', (int) $_POST['comment_ID'] ) ) |
|
37 | - wp_die ( __( 'You are not allowed to edit comments on this post.' ) ); |
|
38 | - |
|
39 | - if ( isset( $_POST['newcomment_author'] ) ) |
|
40 | - $_POST['comment_author'] = $_POST['newcomment_author']; |
|
41 | - if ( isset( $_POST['newcomment_author_email'] ) ) |
|
42 | - $_POST['comment_author_email'] = $_POST['newcomment_author_email']; |
|
43 | - if ( isset( $_POST['newcomment_author_url'] ) ) |
|
44 | - $_POST['comment_author_url'] = $_POST['newcomment_author_url']; |
|
45 | - if ( isset( $_POST['comment_status'] ) ) |
|
46 | - $_POST['comment_approved'] = $_POST['comment_status']; |
|
47 | - if ( isset( $_POST['content'] ) ) |
|
48 | - $_POST['comment_content'] = $_POST['content']; |
|
49 | - if ( isset( $_POST['comment_ID'] ) ) |
|
50 | - $_POST['comment_ID'] = (int) $_POST['comment_ID']; |
|
36 | + if ( ! current_user_can( 'edit_comment', (int) $_POST['comment_ID'] ) ) { |
|
37 | + wp_die ( __( 'You are not allowed to edit comments on this post.' ) ); |
|
38 | + } |
|
39 | + |
|
40 | + if ( isset( $_POST['newcomment_author'] ) ) { |
|
41 | + $_POST['comment_author'] = $_POST['newcomment_author']; |
|
42 | + } |
|
43 | + if ( isset( $_POST['newcomment_author_email'] ) ) { |
|
44 | + $_POST['comment_author_email'] = $_POST['newcomment_author_email']; |
|
45 | + } |
|
46 | + if ( isset( $_POST['newcomment_author_url'] ) ) { |
|
47 | + $_POST['comment_author_url'] = $_POST['newcomment_author_url']; |
|
48 | + } |
|
49 | + if ( isset( $_POST['comment_status'] ) ) { |
|
50 | + $_POST['comment_approved'] = $_POST['comment_status']; |
|
51 | + } |
|
52 | + if ( isset( $_POST['content'] ) ) { |
|
53 | + $_POST['comment_content'] = $_POST['content']; |
|
54 | + } |
|
55 | + if ( isset( $_POST['comment_ID'] ) ) { |
|
56 | + $_POST['comment_ID'] = (int) $_POST['comment_ID']; |
|
57 | + } |
|
51 | 58 | |
52 | 59 | foreach ( array ('aa', 'mm', 'jj', 'hh', 'mn') as $timeunit ) { |
53 | 60 | if ( !empty( $_POST['hidden_' . $timeunit] ) && $_POST['hidden_' . $timeunit] != $_POST[$timeunit] ) { |
@@ -82,8 +89,9 @@ discard block |
||
82 | 89 | * @return object|false Comment if found. False on failure. |
83 | 90 | */ |
84 | 91 | function get_comment_to_edit( $id ) { |
85 | - if ( !$comment = get_comment($id) ) |
|
86 | - return false; |
|
92 | + if ( !$comment = get_comment($id) ) { |
|
93 | + return false; |
|
94 | + } |
|
87 | 95 | |
88 | 96 | $comment->comment_ID = (int) $comment->comment_ID; |
89 | 97 | $comment->comment_post_ID = (int) $comment->comment_post_ID; |
@@ -132,21 +140,24 @@ discard block |
||
132 | 140 | $pending = $wpdb->get_results( "SELECT comment_post_ID, COUNT(comment_ID) as num_comments FROM $wpdb->comments WHERE comment_post_ID IN ( $post_id_in ) AND comment_approved = '0' GROUP BY comment_post_ID", ARRAY_A ); |
133 | 141 | |
134 | 142 | if ( $single ) { |
135 | - if ( empty($pending) ) |
|
136 | - return 0; |
|
137 | - else |
|
138 | - return absint($pending[0]['num_comments']); |
|
143 | + if ( empty($pending) ) { |
|
144 | + return 0; |
|
145 | + } else { |
|
146 | + return absint($pending[0]['num_comments']); |
|
147 | + } |
|
139 | 148 | } |
140 | 149 | |
141 | 150 | $pending_keyed = array(); |
142 | 151 | |
143 | 152 | // Default to zero pending for all posts in request |
144 | - foreach ( $post_id_array as $id ) |
|
145 | - $pending_keyed[$id] = 0; |
|
153 | + foreach ( $post_id_array as $id ) { |
|
154 | + $pending_keyed[$id] = 0; |
|
155 | + } |
|
146 | 156 | |
147 | - if ( !empty($pending) ) |
|
148 | - foreach ( $pending as $pend ) |
|
157 | + if ( !empty($pending) ) { |
|
158 | + foreach ( $pending as $pend ) |
|
149 | 159 | $pending_keyed[$pend['comment_post_ID']] = absint($pend['num_comments']); |
160 | + } |
|
150 | 161 | |
151 | 162 | return $pending_keyed; |
152 | 163 | } |
@@ -171,6 +182,7 @@ discard block |
||
171 | 182 | * @since 2.7.0 |
172 | 183 | */ |
173 | 184 | function enqueue_comment_hotkeys_js() { |
174 | - if ( 'true' == get_user_option( 'comment_shortcuts' ) ) |
|
175 | - wp_enqueue_script( 'jquery-table-hotkeys' ); |
|
176 | -} |
|
185 | + if ( 'true' == get_user_option( 'comment_shortcuts' ) ) { |
|
186 | + wp_enqueue_script( 'jquery-table-hotkeys' ); |
|
187 | + } |
|
188 | + } |