Passed
Push — main ( 16d49b...d78e29 )
by TARIQ
111:03
created
brighty/wp-admin/includes/class-wp-users-list-table.php 2 patches
Indentation   +642 added lines, -642 removed lines patch added patch discarded remove patch
@@ -17,292 +17,292 @@  discard block
 block discarded – undo
17 17
  */
18 18
 class WP_Users_List_Table extends WP_List_Table {
19 19
 
20
-	/**
21
-	 * Site ID to generate the Users list table for.
22
-	 *
23
-	 * @since 3.1.0
24
-	 * @var int
25
-	 */
26
-	public $site_id;
27
-
28
-	/**
29
-	 * Whether or not the current Users list table is for Multisite.
30
-	 *
31
-	 * @since 3.1.0
32
-	 * @var bool
33
-	 */
34
-	public $is_site_users;
35
-
36
-	/**
37
-	 * Constructor.
38
-	 *
39
-	 * @since 3.1.0
40
-	 *
41
-	 * @see WP_List_Table::__construct() for more information on default arguments.
42
-	 *
43
-	 * @param array $args An associative array of arguments.
44
-	 */
45
-	public function __construct( $args = array() ) {
46
-		parent::__construct(
47
-			array(
48
-				'singular' => 'user',
49
-				'plural'   => 'users',
50
-				'screen'   => isset( $args['screen'] ) ? $args['screen'] : null,
51
-			)
52
-		);
53
-
54
-		$this->is_site_users = 'site-users-network' === $this->screen->id;
55
-
56
-		if ( $this->is_site_users ) {
57
-			$this->site_id = isset( $_REQUEST['id'] ) ? (int) $_REQUEST['id'] : 0;
58
-		}
59
-	}
60
-
61
-	/**
62
-	 * Check the current user's permissions.
63
-	 *
64
-	 * @since 3.1.0
65
-	 *
66
-	 * @return bool
67
-	 */
68
-	public function ajax_user_can() {
69
-		if ( $this->is_site_users ) {
70
-			return current_user_can( 'manage_sites' );
71
-		} else {
72
-			return current_user_can( 'list_users' );
73
-		}
74
-	}
75
-
76
-	/**
77
-	 * Prepare the users list for display.
78
-	 *
79
-	 * @since 3.1.0
80
-	 *
81
-	 * @global string $role
82
-	 * @global string $usersearch
83
-	 */
84
-	public function prepare_items() {
85
-		global $role, $usersearch;
86
-
87
-		$usersearch = isset( $_REQUEST['s'] ) ? wp_unslash( trim( $_REQUEST['s'] ) ) : '';
88
-
89
-		$role = isset( $_REQUEST['role'] ) ? $_REQUEST['role'] : '';
90
-
91
-		$per_page       = ( $this->is_site_users ) ? 'site_users_network_per_page' : 'users_per_page';
92
-		$users_per_page = $this->get_items_per_page( $per_page );
93
-
94
-		$paged = $this->get_pagenum();
95
-
96
-		if ( 'none' === $role ) {
97
-			$args = array(
98
-				'number'  => $users_per_page,
99
-				'offset'  => ( $paged - 1 ) * $users_per_page,
100
-				'include' => wp_get_users_with_no_role( $this->site_id ),
101
-				'search'  => $usersearch,
102
-				'fields'  => 'all_with_meta',
103
-			);
104
-		} else {
105
-			$args = array(
106
-				'number' => $users_per_page,
107
-				'offset' => ( $paged - 1 ) * $users_per_page,
108
-				'role'   => $role,
109
-				'search' => $usersearch,
110
-				'fields' => 'all_with_meta',
111
-			);
112
-		}
113
-
114
-		if ( '' !== $args['search'] ) {
115
-			$args['search'] = '*' . $args['search'] . '*';
116
-		}
117
-
118
-		if ( $this->is_site_users ) {
119
-			$args['blog_id'] = $this->site_id;
120
-		}
121
-
122
-		if ( isset( $_REQUEST['orderby'] ) ) {
123
-			$args['orderby'] = $_REQUEST['orderby'];
124
-		}
125
-
126
-		if ( isset( $_REQUEST['order'] ) ) {
127
-			$args['order'] = $_REQUEST['order'];
128
-		}
129
-
130
-		/**
131
-		 * Filters the query arguments used to retrieve users for the current users list table.
132
-		 *
133
-		 * @since 4.4.0
134
-		 *
135
-		 * @param array $args Arguments passed to WP_User_Query to retrieve items for the current
136
-		 *                    users list table.
137
-		 */
138
-		$args = apply_filters( 'users_list_table_query_args', $args );
139
-
140
-		// Query the user IDs for this page.
141
-		$wp_user_search = new WP_User_Query( $args );
142
-
143
-		$this->items = $wp_user_search->get_results();
144
-
145
-		$this->set_pagination_args(
146
-			array(
147
-				'total_items' => $wp_user_search->get_total(),
148
-				'per_page'    => $users_per_page,
149
-			)
150
-		);
151
-	}
152
-
153
-	/**
154
-	 * Output 'no users' message.
155
-	 *
156
-	 * @since 3.1.0
157
-	 */
158
-	public function no_items() {
159
-		_e( 'No users found.' );
160
-	}
161
-
162
-	/**
163
-	 * Return an associative array listing all the views that can be used
164
-	 * with this table.
165
-	 *
166
-	 * Provides a list of roles and user count for that role for easy
167
-	 * Filtersing of the user table.
168
-	 *
169
-	 * @since 3.1.0
170
-	 *
171
-	 * @global string $role
172
-	 *
173
-	 * @return string[] An array of HTML links keyed by their view.
174
-	 */
175
-	protected function get_views() {
176
-		global $role;
177
-
178
-		$wp_roles = wp_roles();
179
-
180
-		$count_users = ! wp_is_large_user_count();
181
-
182
-		if ( $this->is_site_users ) {
183
-			$url = 'site-users.php?id=' . $this->site_id;
184
-		} else {
185
-			$url = 'users.php';
186
-		}
187
-
188
-		$role_links              = array();
189
-		$avail_roles             = array();
190
-		$all_text                = __( 'All' );
191
-		$current_link_attributes = empty( $role ) ? ' class="current" aria-current="page"' : '';
192
-
193
-		if ( $count_users ) {
194
-			if ( $this->is_site_users ) {
195
-				switch_to_blog( $this->site_id );
196
-				$users_of_blog = count_users( 'time', $this->site_id );
197
-				restore_current_blog();
198
-			} else {
199
-				$users_of_blog = count_users();
200
-			}
201
-
202
-			$total_users = $users_of_blog['total_users'];
203
-			$avail_roles =& $users_of_blog['avail_roles'];
204
-			unset( $users_of_blog );
205
-
206
-			$all_text = sprintf(
207
-				/* translators: %s: Number of users. */
208
-				_nx(
209
-					'All <span class="count">(%s)</span>',
210
-					'All <span class="count">(%s)</span>',
211
-					$total_users,
212
-					'users'
213
-				),
214
-				number_format_i18n( $total_users )
215
-			);
216
-		}
217
-
218
-		$role_links['all'] = sprintf( '<a href="%s"%s>%s</a>', $url, $current_link_attributes, $all_text );
219
-
220
-		foreach ( $wp_roles->get_names() as $this_role => $name ) {
221
-			if ( $count_users && ! isset( $avail_roles[ $this_role ] ) ) {
222
-				continue;
223
-			}
224
-
225
-			$current_link_attributes = '';
226
-
227
-			if ( $this_role === $role ) {
228
-				$current_link_attributes = ' class="current" aria-current="page"';
229
-			}
230
-
231
-			$name = translate_user_role( $name );
232
-			if ( $count_users ) {
233
-				$name = sprintf(
234
-					/* translators: 1: User role name, 2: Number of users. */
235
-					__( '%1$s <span class="count">(%2$s)</span>' ),
236
-					$name,
237
-					number_format_i18n( $avail_roles[ $this_role ] )
238
-				);
239
-			}
240
-
241
-			$role_links[ $this_role ] = "<a href='" . esc_url( add_query_arg( 'role', $this_role, $url ) ) . "'$current_link_attributes>$name</a>";
242
-		}
243
-
244
-		if ( ! empty( $avail_roles['none'] ) ) {
245
-
246
-			$current_link_attributes = '';
247
-
248
-			if ( 'none' === $role ) {
249
-				$current_link_attributes = ' class="current" aria-current="page"';
250
-			}
251
-
252
-			$name = __( 'No role' );
253
-			$name = sprintf(
254
-				/* translators: 1: User role name, 2: Number of users. */
255
-				__( '%1$s <span class="count">(%2$s)</span>' ),
256
-				$name,
257
-				number_format_i18n( $avail_roles['none'] )
258
-			);
259
-
260
-			$role_links['none'] = "<a href='" . esc_url( add_query_arg( 'role', 'none', $url ) ) . "'$current_link_attributes>$name</a>";
261
-		}
262
-
263
-		return $role_links;
264
-	}
265
-
266
-	/**
267
-	 * Retrieve an associative array of bulk actions available on this table.
268
-	 *
269
-	 * @since 3.1.0
270
-	 *
271
-	 * @return array Array of bulk action labels keyed by their action.
272
-	 */
273
-	protected function get_bulk_actions() {
274
-		$actions = array();
275
-
276
-		if ( is_multisite() ) {
277
-			if ( current_user_can( 'remove_users' ) ) {
278
-				$actions['remove'] = __( 'Remove' );
279
-			}
280
-		} else {
281
-			if ( current_user_can( 'delete_users' ) ) {
282
-				$actions['delete'] = __( 'Delete' );
283
-			}
284
-		}
285
-
286
-		// Add a password reset link to the bulk actions dropdown.
287
-		if ( current_user_can( 'edit_users' ) ) {
288
-			$actions['resetpassword'] = __( 'Send password reset' );
289
-		}
290
-
291
-		return $actions;
292
-	}
293
-
294
-	/**
295
-	 * Output the controls to allow user roles to be changed in bulk.
296
-	 *
297
-	 * @since 3.1.0
298
-	 *
299
-	 * @param string $which Whether this is being invoked above ("top")
300
-	 *                      or below the table ("bottom").
301
-	 */
302
-	protected function extra_tablenav( $which ) {
303
-		$id        = 'bottom' === $which ? 'new_role2' : 'new_role';
304
-		$button_id = 'bottom' === $which ? 'changeit2' : 'changeit';
305
-		?>
20
+    /**
21
+     * Site ID to generate the Users list table for.
22
+     *
23
+     * @since 3.1.0
24
+     * @var int
25
+     */
26
+    public $site_id;
27
+
28
+    /**
29
+     * Whether or not the current Users list table is for Multisite.
30
+     *
31
+     * @since 3.1.0
32
+     * @var bool
33
+     */
34
+    public $is_site_users;
35
+
36
+    /**
37
+     * Constructor.
38
+     *
39
+     * @since 3.1.0
40
+     *
41
+     * @see WP_List_Table::__construct() for more information on default arguments.
42
+     *
43
+     * @param array $args An associative array of arguments.
44
+     */
45
+    public function __construct( $args = array() ) {
46
+        parent::__construct(
47
+            array(
48
+                'singular' => 'user',
49
+                'plural'   => 'users',
50
+                'screen'   => isset( $args['screen'] ) ? $args['screen'] : null,
51
+            )
52
+        );
53
+
54
+        $this->is_site_users = 'site-users-network' === $this->screen->id;
55
+
56
+        if ( $this->is_site_users ) {
57
+            $this->site_id = isset( $_REQUEST['id'] ) ? (int) $_REQUEST['id'] : 0;
58
+        }
59
+    }
60
+
61
+    /**
62
+     * Check the current user's permissions.
63
+     *
64
+     * @since 3.1.0
65
+     *
66
+     * @return bool
67
+     */
68
+    public function ajax_user_can() {
69
+        if ( $this->is_site_users ) {
70
+            return current_user_can( 'manage_sites' );
71
+        } else {
72
+            return current_user_can( 'list_users' );
73
+        }
74
+    }
75
+
76
+    /**
77
+     * Prepare the users list for display.
78
+     *
79
+     * @since 3.1.0
80
+     *
81
+     * @global string $role
82
+     * @global string $usersearch
83
+     */
84
+    public function prepare_items() {
85
+        global $role, $usersearch;
86
+
87
+        $usersearch = isset( $_REQUEST['s'] ) ? wp_unslash( trim( $_REQUEST['s'] ) ) : '';
88
+
89
+        $role = isset( $_REQUEST['role'] ) ? $_REQUEST['role'] : '';
90
+
91
+        $per_page       = ( $this->is_site_users ) ? 'site_users_network_per_page' : 'users_per_page';
92
+        $users_per_page = $this->get_items_per_page( $per_page );
93
+
94
+        $paged = $this->get_pagenum();
95
+
96
+        if ( 'none' === $role ) {
97
+            $args = array(
98
+                'number'  => $users_per_page,
99
+                'offset'  => ( $paged - 1 ) * $users_per_page,
100
+                'include' => wp_get_users_with_no_role( $this->site_id ),
101
+                'search'  => $usersearch,
102
+                'fields'  => 'all_with_meta',
103
+            );
104
+        } else {
105
+            $args = array(
106
+                'number' => $users_per_page,
107
+                'offset' => ( $paged - 1 ) * $users_per_page,
108
+                'role'   => $role,
109
+                'search' => $usersearch,
110
+                'fields' => 'all_with_meta',
111
+            );
112
+        }
113
+
114
+        if ( '' !== $args['search'] ) {
115
+            $args['search'] = '*' . $args['search'] . '*';
116
+        }
117
+
118
+        if ( $this->is_site_users ) {
119
+            $args['blog_id'] = $this->site_id;
120
+        }
121
+
122
+        if ( isset( $_REQUEST['orderby'] ) ) {
123
+            $args['orderby'] = $_REQUEST['orderby'];
124
+        }
125
+
126
+        if ( isset( $_REQUEST['order'] ) ) {
127
+            $args['order'] = $_REQUEST['order'];
128
+        }
129
+
130
+        /**
131
+         * Filters the query arguments used to retrieve users for the current users list table.
132
+         *
133
+         * @since 4.4.0
134
+         *
135
+         * @param array $args Arguments passed to WP_User_Query to retrieve items for the current
136
+         *                    users list table.
137
+         */
138
+        $args = apply_filters( 'users_list_table_query_args', $args );
139
+
140
+        // Query the user IDs for this page.
141
+        $wp_user_search = new WP_User_Query( $args );
142
+
143
+        $this->items = $wp_user_search->get_results();
144
+
145
+        $this->set_pagination_args(
146
+            array(
147
+                'total_items' => $wp_user_search->get_total(),
148
+                'per_page'    => $users_per_page,
149
+            )
150
+        );
151
+    }
152
+
153
+    /**
154
+     * Output 'no users' message.
155
+     *
156
+     * @since 3.1.0
157
+     */
158
+    public function no_items() {
159
+        _e( 'No users found.' );
160
+    }
161
+
162
+    /**
163
+     * Return an associative array listing all the views that can be used
164
+     * with this table.
165
+     *
166
+     * Provides a list of roles and user count for that role for easy
167
+     * Filtersing of the user table.
168
+     *
169
+     * @since 3.1.0
170
+     *
171
+     * @global string $role
172
+     *
173
+     * @return string[] An array of HTML links keyed by their view.
174
+     */
175
+    protected function get_views() {
176
+        global $role;
177
+
178
+        $wp_roles = wp_roles();
179
+
180
+        $count_users = ! wp_is_large_user_count();
181
+
182
+        if ( $this->is_site_users ) {
183
+            $url = 'site-users.php?id=' . $this->site_id;
184
+        } else {
185
+            $url = 'users.php';
186
+        }
187
+
188
+        $role_links              = array();
189
+        $avail_roles             = array();
190
+        $all_text                = __( 'All' );
191
+        $current_link_attributes = empty( $role ) ? ' class="current" aria-current="page"' : '';
192
+
193
+        if ( $count_users ) {
194
+            if ( $this->is_site_users ) {
195
+                switch_to_blog( $this->site_id );
196
+                $users_of_blog = count_users( 'time', $this->site_id );
197
+                restore_current_blog();
198
+            } else {
199
+                $users_of_blog = count_users();
200
+            }
201
+
202
+            $total_users = $users_of_blog['total_users'];
203
+            $avail_roles =& $users_of_blog['avail_roles'];
204
+            unset( $users_of_blog );
205
+
206
+            $all_text = sprintf(
207
+                /* translators: %s: Number of users. */
208
+                _nx(
209
+                    'All <span class="count">(%s)</span>',
210
+                    'All <span class="count">(%s)</span>',
211
+                    $total_users,
212
+                    'users'
213
+                ),
214
+                number_format_i18n( $total_users )
215
+            );
216
+        }
217
+
218
+        $role_links['all'] = sprintf( '<a href="%s"%s>%s</a>', $url, $current_link_attributes, $all_text );
219
+
220
+        foreach ( $wp_roles->get_names() as $this_role => $name ) {
221
+            if ( $count_users && ! isset( $avail_roles[ $this_role ] ) ) {
222
+                continue;
223
+            }
224
+
225
+            $current_link_attributes = '';
226
+
227
+            if ( $this_role === $role ) {
228
+                $current_link_attributes = ' class="current" aria-current="page"';
229
+            }
230
+
231
+            $name = translate_user_role( $name );
232
+            if ( $count_users ) {
233
+                $name = sprintf(
234
+                    /* translators: 1: User role name, 2: Number of users. */
235
+                    __( '%1$s <span class="count">(%2$s)</span>' ),
236
+                    $name,
237
+                    number_format_i18n( $avail_roles[ $this_role ] )
238
+                );
239
+            }
240
+
241
+            $role_links[ $this_role ] = "<a href='" . esc_url( add_query_arg( 'role', $this_role, $url ) ) . "'$current_link_attributes>$name</a>";
242
+        }
243
+
244
+        if ( ! empty( $avail_roles['none'] ) ) {
245
+
246
+            $current_link_attributes = '';
247
+
248
+            if ( 'none' === $role ) {
249
+                $current_link_attributes = ' class="current" aria-current="page"';
250
+            }
251
+
252
+            $name = __( 'No role' );
253
+            $name = sprintf(
254
+                /* translators: 1: User role name, 2: Number of users. */
255
+                __( '%1$s <span class="count">(%2$s)</span>' ),
256
+                $name,
257
+                number_format_i18n( $avail_roles['none'] )
258
+            );
259
+
260
+            $role_links['none'] = "<a href='" . esc_url( add_query_arg( 'role', 'none', $url ) ) . "'$current_link_attributes>$name</a>";
261
+        }
262
+
263
+        return $role_links;
264
+    }
265
+
266
+    /**
267
+     * Retrieve an associative array of bulk actions available on this table.
268
+     *
269
+     * @since 3.1.0
270
+     *
271
+     * @return array Array of bulk action labels keyed by their action.
272
+     */
273
+    protected function get_bulk_actions() {
274
+        $actions = array();
275
+
276
+        if ( is_multisite() ) {
277
+            if ( current_user_can( 'remove_users' ) ) {
278
+                $actions['remove'] = __( 'Remove' );
279
+            }
280
+        } else {
281
+            if ( current_user_can( 'delete_users' ) ) {
282
+                $actions['delete'] = __( 'Delete' );
283
+            }
284
+        }
285
+
286
+        // Add a password reset link to the bulk actions dropdown.
287
+        if ( current_user_can( 'edit_users' ) ) {
288
+            $actions['resetpassword'] = __( 'Send password reset' );
289
+        }
290
+
291
+        return $actions;
292
+    }
293
+
294
+    /**
295
+     * Output the controls to allow user roles to be changed in bulk.
296
+     *
297
+     * @since 3.1.0
298
+     *
299
+     * @param string $which Whether this is being invoked above ("top")
300
+     *                      or below the table ("bottom").
301
+     */
302
+    protected function extra_tablenav( $which ) {
303
+        $id        = 'bottom' === $which ? 'new_role2' : 'new_role';
304
+        $button_id = 'bottom' === $which ? 'changeit2' : 'changeit';
305
+        ?>
306 306
 	<div class="alignleft actions">
307 307
 		<?php if ( current_user_can( 'promote_users' ) && $this->has_items() ) : ?>
308 308
 		<label class="screen-reader-text" for="<?php echo $id; ?>"><?php _e( 'Change role to&hellip;' ); ?></label>
@@ -312,363 +312,363 @@  discard block
 block discarded – undo
312 312
 			<option value="none"><?php _e( '&mdash; No role for this site &mdash;' ); ?></option>
313 313
 		</select>
314 314
 			<?php
315
-			submit_button( __( 'Change' ), '', $button_id, false );
316
-		endif;
317
-
318
-		/**
319
-		 * Fires just before the closing div containing the bulk role-change controls
320
-		 * in the Users list table.
321
-		 *
322
-		 * @since 3.5.0
323
-		 * @since 4.6.0 The `$which` parameter was added.
324
-		 *
325
-		 * @param string $which The location of the extra table nav markup: 'top' or 'bottom'.
326
-		 */
327
-		do_action( 'restrict_manage_users', $which );
328
-		?>
315
+            submit_button( __( 'Change' ), '', $button_id, false );
316
+        endif;
317
+
318
+        /**
319
+         * Fires just before the closing div containing the bulk role-change controls
320
+         * in the Users list table.
321
+         *
322
+         * @since 3.5.0
323
+         * @since 4.6.0 The `$which` parameter was added.
324
+         *
325
+         * @param string $which The location of the extra table nav markup: 'top' or 'bottom'.
326
+         */
327
+        do_action( 'restrict_manage_users', $which );
328
+        ?>
329 329
 		</div>
330 330
 		<?php
331
-		/**
332
-		 * Fires immediately following the closing "actions" div in the tablenav for the users
333
-		 * list table.
334
-		 *
335
-		 * @since 4.9.0
336
-		 *
337
-		 * @param string $which The location of the extra table nav markup: 'top' or 'bottom'.
338
-		 */
339
-		do_action( 'manage_users_extra_tablenav', $which );
340
-	}
341
-
342
-	/**
343
-	 * Capture the bulk action required, and return it.
344
-	 *
345
-	 * Overridden from the base class implementation to capture
346
-	 * the role change drop-down.
347
-	 *
348
-	 * @since 3.1.0
349
-	 *
350
-	 * @return string The bulk action required.
351
-	 */
352
-	public function current_action() {
353
-		if ( isset( $_REQUEST['changeit'] ) && ! empty( $_REQUEST['new_role'] ) ) {
354
-			return 'promote';
355
-		}
356
-
357
-		return parent::current_action();
358
-	}
359
-
360
-	/**
361
-	 * Get a list of columns for the list table.
362
-	 *
363
-	 * @since 3.1.0
364
-	 *
365
-	 * @return string[] Array of column titles keyed by their column name.
366
-	 */
367
-	public function get_columns() {
368
-		$c = array(
369
-			'cb'       => '<input type="checkbox" />',
370
-			'username' => __( 'Username' ),
371
-			'name'     => __( 'Name' ),
372
-			'email'    => __( 'Email' ),
373
-			'role'     => __( 'Role' ),
374
-			'posts'    => _x( 'Posts', 'post type general name' ),
375
-		);
376
-
377
-		if ( $this->is_site_users ) {
378
-			unset( $c['posts'] );
379
-		}
380
-
381
-		return $c;
382
-	}
383
-
384
-	/**
385
-	 * Get a list of sortable columns for the list table.
386
-	 *
387
-	 * @since 3.1.0
388
-	 *
389
-	 * @return array Array of sortable columns.
390
-	 */
391
-	protected function get_sortable_columns() {
392
-		$c = array(
393
-			'username' => 'login',
394
-			'email'    => 'email',
395
-		);
396
-
397
-		return $c;
398
-	}
399
-
400
-	/**
401
-	 * Generate the list table rows.
402
-	 *
403
-	 * @since 3.1.0
404
-	 */
405
-	public function display_rows() {
406
-		// Query the post counts for this page.
407
-		if ( ! $this->is_site_users ) {
408
-			$post_counts = count_many_users_posts( array_keys( $this->items ) );
409
-		}
410
-
411
-		foreach ( $this->items as $userid => $user_object ) {
412
-			echo "\n\t" . $this->single_row( $user_object, '', '', isset( $post_counts ) ? $post_counts[ $userid ] : 0 );
413
-		}
414
-	}
415
-
416
-	/**
417
-	 * Generate HTML for a single row on the users.php admin panel.
418
-	 *
419
-	 * @since 3.1.0
420
-	 * @since 4.2.0 The `$style` parameter was deprecated.
421
-	 * @since 4.4.0 The `$role` parameter was deprecated.
422
-	 *
423
-	 * @param WP_User $user_object The current user object.
424
-	 * @param string  $style       Deprecated. Not used.
425
-	 * @param string  $role        Deprecated. Not used.
426
-	 * @param int     $numposts    Optional. Post count to display for this user. Defaults
427
-	 *                             to zero, as in, a new user has made zero posts.
428
-	 * @return string Output for a single row.
429
-	 */
430
-	public function single_row( $user_object, $style = '', $role = '', $numposts = 0 ) {
431
-		if ( ! ( $user_object instanceof WP_User ) ) {
432
-			$user_object = get_userdata( (int) $user_object );
433
-		}
434
-		$user_object->filter = 'display';
435
-		$email               = $user_object->user_email;
436
-
437
-		if ( $this->is_site_users ) {
438
-			$url = "site-users.php?id={$this->site_id}&amp;";
439
-		} else {
440
-			$url = 'users.php?';
441
-		}
442
-
443
-		$user_roles = $this->get_role_list( $user_object );
444
-
445
-		// Set up the hover actions for this user.
446
-		$actions     = array();
447
-		$checkbox    = '';
448
-		$super_admin = '';
449
-
450
-		if ( is_multisite() && current_user_can( 'manage_network_users' ) ) {
451
-			if ( in_array( $user_object->user_login, get_super_admins(), true ) ) {
452
-				$super_admin = ' &mdash; ' . __( 'Super Admin' );
453
-			}
454
-		}
455
-
456
-		// Check if the user for this row is editable.
457
-		if ( current_user_can( 'list_users' ) ) {
458
-			// Set up the user editing link.
459
-			$edit_link = esc_url(
460
-				add_query_arg(
461
-					'wp_http_referer',
462
-					urlencode( wp_unslash( $_SERVER['REQUEST_URI'] ) ),
463
-					get_edit_user_link( $user_object->ID )
464
-				)
465
-			);
466
-
467
-			if ( current_user_can( 'edit_user', $user_object->ID ) ) {
468
-				$edit            = "<strong><a href=\"{$edit_link}\">{$user_object->user_login}</a>{$super_admin}</strong><br />";
469
-				$actions['edit'] = '<a href="' . $edit_link . '">' . __( 'Edit' ) . '</a>';
470
-			} else {
471
-				$edit = "<strong>{$user_object->user_login}{$super_admin}</strong><br />";
472
-			}
473
-
474
-			if ( ! is_multisite()
475
-				&& get_current_user_id() !== $user_object->ID
476
-				&& current_user_can( 'delete_user', $user_object->ID )
477
-			) {
478
-				$actions['delete'] = "<a class='submitdelete' href='" . wp_nonce_url( "users.php?action=delete&amp;user=$user_object->ID", 'bulk-users' ) . "'>" . __( 'Delete' ) . '</a>';
479
-			}
480
-
481
-			if ( is_multisite()
482
-				&& current_user_can( 'remove_user', $user_object->ID )
483
-			) {
484
-				$actions['remove'] = "<a class='submitdelete' href='" . wp_nonce_url( $url . "action=remove&amp;user=$user_object->ID", 'bulk-users' ) . "'>" . __( 'Remove' ) . '</a>';
485
-			}
486
-
487
-			// Add a link to the user's author archive, if not empty.
488
-			$author_posts_url = get_author_posts_url( $user_object->ID );
489
-			if ( $author_posts_url ) {
490
-				$actions['view'] = sprintf(
491
-					'<a href="%s" aria-label="%s">%s</a>',
492
-					esc_url( $author_posts_url ),
493
-					/* translators: %s: Author's display name. */
494
-					esc_attr( sprintf( __( 'View posts by %s' ), $user_object->display_name ) ),
495
-					__( 'View' )
496
-				);
497
-			}
498
-
499
-			// Add a link to send the user a reset password link by email.
500
-			if ( get_current_user_id() !== $user_object->ID
501
-				&& current_user_can( 'edit_user', $user_object->ID )
502
-			) {
503
-				$actions['resetpassword'] = "<a class='resetpassword' href='" . wp_nonce_url( "users.php?action=resetpassword&amp;users=$user_object->ID", 'bulk-users' ) . "'>" . __( 'Send password reset' ) . '</a>';
504
-			}
505
-
506
-			/**
507
-			 * Filters the action links displayed under each user in the Users list table.
508
-			 *
509
-			 * @since 2.8.0
510
-			 *
511
-			 * @param string[] $actions     An array of action links to be displayed.
512
-			 *                              Default 'Edit', 'Delete' for single site, and
513
-			 *                              'Edit', 'Remove' for Multisite.
514
-			 * @param WP_User  $user_object WP_User object for the currently listed user.
515
-			 */
516
-			$actions = apply_filters( 'user_row_actions', $actions, $user_object );
517
-
518
-			// Role classes.
519
-			$role_classes = esc_attr( implode( ' ', array_keys( $user_roles ) ) );
520
-
521
-			// Set up the checkbox (because the user is editable, otherwise it's empty).
522
-			$checkbox = sprintf(
523
-				'<label class="screen-reader-text" for="user_%1$s">%2$s</label>' .
524
-				'<input type="checkbox" name="users[]" id="user_%1$s" class="%3$s" value="%1$s" />',
525
-				$user_object->ID,
526
-				/* translators: %s: User login. */
527
-				sprintf( __( 'Select %s' ), $user_object->user_login ),
528
-				$role_classes
529
-			);
530
-
531
-		} else {
532
-			$edit = "<strong>{$user_object->user_login}{$super_admin}</strong>";
533
-		}
534
-
535
-		$avatar = get_avatar( $user_object->ID, 32 );
536
-
537
-		// Comma-separated list of user roles.
538
-		$roles_list = implode( ', ', $user_roles );
539
-
540
-		$r = "<tr id='user-$user_object->ID'>";
541
-
542
-		list( $columns, $hidden, $sortable, $primary ) = $this->get_column_info();
543
-
544
-		foreach ( $columns as $column_name => $column_display_name ) {
545
-			$classes = "$column_name column-$column_name";
546
-			if ( $primary === $column_name ) {
547
-				$classes .= ' has-row-actions column-primary';
548
-			}
549
-			if ( 'posts' === $column_name ) {
550
-				$classes .= ' num'; // Special case for that column.
551
-			}
552
-
553
-			if ( in_array( $column_name, $hidden, true ) ) {
554
-				$classes .= ' hidden';
555
-			}
556
-
557
-			$data = 'data-colname="' . esc_attr( wp_strip_all_tags( $column_display_name ) ) . '"';
558
-
559
-			$attributes = "class='$classes' $data";
560
-
561
-			if ( 'cb' === $column_name ) {
562
-				$r .= "<th scope='row' class='check-column'>$checkbox</th>";
563
-			} else {
564
-				$r .= "<td $attributes>";
565
-				switch ( $column_name ) {
566
-					case 'username':
567
-						$r .= "$avatar $edit";
568
-						break;
569
-					case 'name':
570
-						if ( $user_object->first_name && $user_object->last_name ) {
571
-							$r .= "$user_object->first_name $user_object->last_name";
572
-						} elseif ( $user_object->first_name ) {
573
-							$r .= $user_object->first_name;
574
-						} elseif ( $user_object->last_name ) {
575
-							$r .= $user_object->last_name;
576
-						} else {
577
-							$r .= sprintf(
578
-								'<span aria-hidden="true">&#8212;</span><span class="screen-reader-text">%s</span>',
579
-								_x( 'Unknown', 'name' )
580
-							);
581
-						}
582
-						break;
583
-					case 'email':
584
-						$r .= "<a href='" . esc_url( "mailto:$email" ) . "'>$email</a>";
585
-						break;
586
-					case 'role':
587
-						$r .= esc_html( $roles_list );
588
-						break;
589
-					case 'posts':
590
-						if ( $numposts > 0 ) {
591
-							$r .= sprintf(
592
-								'<a href="%s" class="edit"><span aria-hidden="true">%s</span><span class="screen-reader-text">%s</span></a>',
593
-								"edit.php?author={$user_object->ID}",
594
-								$numposts,
595
-								sprintf(
596
-									/* translators: %s: Number of posts. */
597
-									_n( '%s post by this author', '%s posts by this author', $numposts ),
598
-									number_format_i18n( $numposts )
599
-								)
600
-							);
601
-						} else {
602
-							$r .= 0;
603
-						}
604
-						break;
605
-					default:
606
-						/**
607
-						 * Filters the display output of custom columns in the Users list table.
608
-						 *
609
-						 * @since 2.8.0
610
-						 *
611
-						 * @param string $output      Custom column output. Default empty.
612
-						 * @param string $column_name Column name.
613
-						 * @param int    $user_id     ID of the currently-listed user.
614
-						 */
615
-						$r .= apply_filters( 'manage_users_custom_column', '', $column_name, $user_object->ID );
616
-				}
617
-
618
-				if ( $primary === $column_name ) {
619
-					$r .= $this->row_actions( $actions );
620
-				}
621
-				$r .= '</td>';
622
-			}
623
-		}
624
-		$r .= '</tr>';
625
-
626
-		return $r;
627
-	}
628
-
629
-	/**
630
-	 * Gets the name of the default primary column.
631
-	 *
632
-	 * @since 4.3.0
633
-	 *
634
-	 * @return string Name of the default primary column, in this case, 'username'.
635
-	 */
636
-	protected function get_default_primary_column_name() {
637
-		return 'username';
638
-	}
639
-
640
-	/**
641
-	 * Returns an array of translated user role names for a given user object.
642
-	 *
643
-	 * @since 4.4.0
644
-	 *
645
-	 * @param WP_User $user_object The WP_User object.
646
-	 * @return string[] An array of user role names keyed by role.
647
-	 */
648
-	protected function get_role_list( $user_object ) {
649
-		$wp_roles = wp_roles();
650
-
651
-		$role_list = array();
652
-
653
-		foreach ( $user_object->roles as $role ) {
654
-			if ( isset( $wp_roles->role_names[ $role ] ) ) {
655
-				$role_list[ $role ] = translate_user_role( $wp_roles->role_names[ $role ] );
656
-			}
657
-		}
658
-
659
-		if ( empty( $role_list ) ) {
660
-			$role_list['none'] = _x( 'None', 'no user roles' );
661
-		}
662
-
663
-		/**
664
-		 * Filters the returned array of translated role names for a user.
665
-		 *
666
-		 * @since 4.4.0
667
-		 *
668
-		 * @param string[] $role_list   An array of translated user role names keyed by role.
669
-		 * @param WP_User  $user_object A WP_User object.
670
-		 */
671
-		return apply_filters( 'get_role_list', $role_list, $user_object );
672
-	}
331
+        /**
332
+         * Fires immediately following the closing "actions" div in the tablenav for the users
333
+         * list table.
334
+         *
335
+         * @since 4.9.0
336
+         *
337
+         * @param string $which The location of the extra table nav markup: 'top' or 'bottom'.
338
+         */
339
+        do_action( 'manage_users_extra_tablenav', $which );
340
+    }
341
+
342
+    /**
343
+     * Capture the bulk action required, and return it.
344
+     *
345
+     * Overridden from the base class implementation to capture
346
+     * the role change drop-down.
347
+     *
348
+     * @since 3.1.0
349
+     *
350
+     * @return string The bulk action required.
351
+     */
352
+    public function current_action() {
353
+        if ( isset( $_REQUEST['changeit'] ) && ! empty( $_REQUEST['new_role'] ) ) {
354
+            return 'promote';
355
+        }
356
+
357
+        return parent::current_action();
358
+    }
359
+
360
+    /**
361
+     * Get a list of columns for the list table.
362
+     *
363
+     * @since 3.1.0
364
+     *
365
+     * @return string[] Array of column titles keyed by their column name.
366
+     */
367
+    public function get_columns() {
368
+        $c = array(
369
+            'cb'       => '<input type="checkbox" />',
370
+            'username' => __( 'Username' ),
371
+            'name'     => __( 'Name' ),
372
+            'email'    => __( 'Email' ),
373
+            'role'     => __( 'Role' ),
374
+            'posts'    => _x( 'Posts', 'post type general name' ),
375
+        );
376
+
377
+        if ( $this->is_site_users ) {
378
+            unset( $c['posts'] );
379
+        }
380
+
381
+        return $c;
382
+    }
383
+
384
+    /**
385
+     * Get a list of sortable columns for the list table.
386
+     *
387
+     * @since 3.1.0
388
+     *
389
+     * @return array Array of sortable columns.
390
+     */
391
+    protected function get_sortable_columns() {
392
+        $c = array(
393
+            'username' => 'login',
394
+            'email'    => 'email',
395
+        );
396
+
397
+        return $c;
398
+    }
399
+
400
+    /**
401
+     * Generate the list table rows.
402
+     *
403
+     * @since 3.1.0
404
+     */
405
+    public function display_rows() {
406
+        // Query the post counts for this page.
407
+        if ( ! $this->is_site_users ) {
408
+            $post_counts = count_many_users_posts( array_keys( $this->items ) );
409
+        }
410
+
411
+        foreach ( $this->items as $userid => $user_object ) {
412
+            echo "\n\t" . $this->single_row( $user_object, '', '', isset( $post_counts ) ? $post_counts[ $userid ] : 0 );
413
+        }
414
+    }
415
+
416
+    /**
417
+     * Generate HTML for a single row on the users.php admin panel.
418
+     *
419
+     * @since 3.1.0
420
+     * @since 4.2.0 The `$style` parameter was deprecated.
421
+     * @since 4.4.0 The `$role` parameter was deprecated.
422
+     *
423
+     * @param WP_User $user_object The current user object.
424
+     * @param string  $style       Deprecated. Not used.
425
+     * @param string  $role        Deprecated. Not used.
426
+     * @param int     $numposts    Optional. Post count to display for this user. Defaults
427
+     *                             to zero, as in, a new user has made zero posts.
428
+     * @return string Output for a single row.
429
+     */
430
+    public function single_row( $user_object, $style = '', $role = '', $numposts = 0 ) {
431
+        if ( ! ( $user_object instanceof WP_User ) ) {
432
+            $user_object = get_userdata( (int) $user_object );
433
+        }
434
+        $user_object->filter = 'display';
435
+        $email               = $user_object->user_email;
436
+
437
+        if ( $this->is_site_users ) {
438
+            $url = "site-users.php?id={$this->site_id}&amp;";
439
+        } else {
440
+            $url = 'users.php?';
441
+        }
442
+
443
+        $user_roles = $this->get_role_list( $user_object );
444
+
445
+        // Set up the hover actions for this user.
446
+        $actions     = array();
447
+        $checkbox    = '';
448
+        $super_admin = '';
449
+
450
+        if ( is_multisite() && current_user_can( 'manage_network_users' ) ) {
451
+            if ( in_array( $user_object->user_login, get_super_admins(), true ) ) {
452
+                $super_admin = ' &mdash; ' . __( 'Super Admin' );
453
+            }
454
+        }
455
+
456
+        // Check if the user for this row is editable.
457
+        if ( current_user_can( 'list_users' ) ) {
458
+            // Set up the user editing link.
459
+            $edit_link = esc_url(
460
+                add_query_arg(
461
+                    'wp_http_referer',
462
+                    urlencode( wp_unslash( $_SERVER['REQUEST_URI'] ) ),
463
+                    get_edit_user_link( $user_object->ID )
464
+                )
465
+            );
466
+
467
+            if ( current_user_can( 'edit_user', $user_object->ID ) ) {
468
+                $edit            = "<strong><a href=\"{$edit_link}\">{$user_object->user_login}</a>{$super_admin}</strong><br />";
469
+                $actions['edit'] = '<a href="' . $edit_link . '">' . __( 'Edit' ) . '</a>';
470
+            } else {
471
+                $edit = "<strong>{$user_object->user_login}{$super_admin}</strong><br />";
472
+            }
473
+
474
+            if ( ! is_multisite()
475
+                && get_current_user_id() !== $user_object->ID
476
+                && current_user_can( 'delete_user', $user_object->ID )
477
+            ) {
478
+                $actions['delete'] = "<a class='submitdelete' href='" . wp_nonce_url( "users.php?action=delete&amp;user=$user_object->ID", 'bulk-users' ) . "'>" . __( 'Delete' ) . '</a>';
479
+            }
480
+
481
+            if ( is_multisite()
482
+                && current_user_can( 'remove_user', $user_object->ID )
483
+            ) {
484
+                $actions['remove'] = "<a class='submitdelete' href='" . wp_nonce_url( $url . "action=remove&amp;user=$user_object->ID", 'bulk-users' ) . "'>" . __( 'Remove' ) . '</a>';
485
+            }
486
+
487
+            // Add a link to the user's author archive, if not empty.
488
+            $author_posts_url = get_author_posts_url( $user_object->ID );
489
+            if ( $author_posts_url ) {
490
+                $actions['view'] = sprintf(
491
+                    '<a href="%s" aria-label="%s">%s</a>',
492
+                    esc_url( $author_posts_url ),
493
+                    /* translators: %s: Author's display name. */
494
+                    esc_attr( sprintf( __( 'View posts by %s' ), $user_object->display_name ) ),
495
+                    __( 'View' )
496
+                );
497
+            }
498
+
499
+            // Add a link to send the user a reset password link by email.
500
+            if ( get_current_user_id() !== $user_object->ID
501
+                && current_user_can( 'edit_user', $user_object->ID )
502
+            ) {
503
+                $actions['resetpassword'] = "<a class='resetpassword' href='" . wp_nonce_url( "users.php?action=resetpassword&amp;users=$user_object->ID", 'bulk-users' ) . "'>" . __( 'Send password reset' ) . '</a>';
504
+            }
505
+
506
+            /**
507
+             * Filters the action links displayed under each user in the Users list table.
508
+             *
509
+             * @since 2.8.0
510
+             *
511
+             * @param string[] $actions     An array of action links to be displayed.
512
+             *                              Default 'Edit', 'Delete' for single site, and
513
+             *                              'Edit', 'Remove' for Multisite.
514
+             * @param WP_User  $user_object WP_User object for the currently listed user.
515
+             */
516
+            $actions = apply_filters( 'user_row_actions', $actions, $user_object );
517
+
518
+            // Role classes.
519
+            $role_classes = esc_attr( implode( ' ', array_keys( $user_roles ) ) );
520
+
521
+            // Set up the checkbox (because the user is editable, otherwise it's empty).
522
+            $checkbox = sprintf(
523
+                '<label class="screen-reader-text" for="user_%1$s">%2$s</label>' .
524
+                '<input type="checkbox" name="users[]" id="user_%1$s" class="%3$s" value="%1$s" />',
525
+                $user_object->ID,
526
+                /* translators: %s: User login. */
527
+                sprintf( __( 'Select %s' ), $user_object->user_login ),
528
+                $role_classes
529
+            );
530
+
531
+        } else {
532
+            $edit = "<strong>{$user_object->user_login}{$super_admin}</strong>";
533
+        }
534
+
535
+        $avatar = get_avatar( $user_object->ID, 32 );
536
+
537
+        // Comma-separated list of user roles.
538
+        $roles_list = implode( ', ', $user_roles );
539
+
540
+        $r = "<tr id='user-$user_object->ID'>";
541
+
542
+        list( $columns, $hidden, $sortable, $primary ) = $this->get_column_info();
543
+
544
+        foreach ( $columns as $column_name => $column_display_name ) {
545
+            $classes = "$column_name column-$column_name";
546
+            if ( $primary === $column_name ) {
547
+                $classes .= ' has-row-actions column-primary';
548
+            }
549
+            if ( 'posts' === $column_name ) {
550
+                $classes .= ' num'; // Special case for that column.
551
+            }
552
+
553
+            if ( in_array( $column_name, $hidden, true ) ) {
554
+                $classes .= ' hidden';
555
+            }
556
+
557
+            $data = 'data-colname="' . esc_attr( wp_strip_all_tags( $column_display_name ) ) . '"';
558
+
559
+            $attributes = "class='$classes' $data";
560
+
561
+            if ( 'cb' === $column_name ) {
562
+                $r .= "<th scope='row' class='check-column'>$checkbox</th>";
563
+            } else {
564
+                $r .= "<td $attributes>";
565
+                switch ( $column_name ) {
566
+                    case 'username':
567
+                        $r .= "$avatar $edit";
568
+                        break;
569
+                    case 'name':
570
+                        if ( $user_object->first_name && $user_object->last_name ) {
571
+                            $r .= "$user_object->first_name $user_object->last_name";
572
+                        } elseif ( $user_object->first_name ) {
573
+                            $r .= $user_object->first_name;
574
+                        } elseif ( $user_object->last_name ) {
575
+                            $r .= $user_object->last_name;
576
+                        } else {
577
+                            $r .= sprintf(
578
+                                '<span aria-hidden="true">&#8212;</span><span class="screen-reader-text">%s</span>',
579
+                                _x( 'Unknown', 'name' )
580
+                            );
581
+                        }
582
+                        break;
583
+                    case 'email':
584
+                        $r .= "<a href='" . esc_url( "mailto:$email" ) . "'>$email</a>";
585
+                        break;
586
+                    case 'role':
587
+                        $r .= esc_html( $roles_list );
588
+                        break;
589
+                    case 'posts':
590
+                        if ( $numposts > 0 ) {
591
+                            $r .= sprintf(
592
+                                '<a href="%s" class="edit"><span aria-hidden="true">%s</span><span class="screen-reader-text">%s</span></a>',
593
+                                "edit.php?author={$user_object->ID}",
594
+                                $numposts,
595
+                                sprintf(
596
+                                    /* translators: %s: Number of posts. */
597
+                                    _n( '%s post by this author', '%s posts by this author', $numposts ),
598
+                                    number_format_i18n( $numposts )
599
+                                )
600
+                            );
601
+                        } else {
602
+                            $r .= 0;
603
+                        }
604
+                        break;
605
+                    default:
606
+                        /**
607
+                         * Filters the display output of custom columns in the Users list table.
608
+                         *
609
+                         * @since 2.8.0
610
+                         *
611
+                         * @param string $output      Custom column output. Default empty.
612
+                         * @param string $column_name Column name.
613
+                         * @param int    $user_id     ID of the currently-listed user.
614
+                         */
615
+                        $r .= apply_filters( 'manage_users_custom_column', '', $column_name, $user_object->ID );
616
+                }
617
+
618
+                if ( $primary === $column_name ) {
619
+                    $r .= $this->row_actions( $actions );
620
+                }
621
+                $r .= '</td>';
622
+            }
623
+        }
624
+        $r .= '</tr>';
625
+
626
+        return $r;
627
+    }
628
+
629
+    /**
630
+     * Gets the name of the default primary column.
631
+     *
632
+     * @since 4.3.0
633
+     *
634
+     * @return string Name of the default primary column, in this case, 'username'.
635
+     */
636
+    protected function get_default_primary_column_name() {
637
+        return 'username';
638
+    }
639
+
640
+    /**
641
+     * Returns an array of translated user role names for a given user object.
642
+     *
643
+     * @since 4.4.0
644
+     *
645
+     * @param WP_User $user_object The WP_User object.
646
+     * @return string[] An array of user role names keyed by role.
647
+     */
648
+    protected function get_role_list( $user_object ) {
649
+        $wp_roles = wp_roles();
650
+
651
+        $role_list = array();
652
+
653
+        foreach ( $user_object->roles as $role ) {
654
+            if ( isset( $wp_roles->role_names[ $role ] ) ) {
655
+                $role_list[ $role ] = translate_user_role( $wp_roles->role_names[ $role ] );
656
+            }
657
+        }
658
+
659
+        if ( empty( $role_list ) ) {
660
+            $role_list['none'] = _x( 'None', 'no user roles' );
661
+        }
662
+
663
+        /**
664
+         * Filters the returned array of translated role names for a user.
665
+         *
666
+         * @since 4.4.0
667
+         *
668
+         * @param string[] $role_list   An array of translated user role names keyed by role.
669
+         * @param WP_User  $user_object A WP_User object.
670
+         */
671
+        return apply_filters( 'get_role_list', $role_list, $user_object );
672
+    }
673 673
 
674 674
 }
Please login to merge, or discard this patch.
Spacing   +134 added lines, -134 removed lines patch added patch discarded remove patch
@@ -42,19 +42,19 @@  discard block
 block discarded – undo
42 42
 	 *
43 43
 	 * @param array $args An associative array of arguments.
44 44
 	 */
45
-	public function __construct( $args = array() ) {
45
+	public function __construct($args = array()) {
46 46
 		parent::__construct(
47 47
 			array(
48 48
 				'singular' => 'user',
49 49
 				'plural'   => 'users',
50
-				'screen'   => isset( $args['screen'] ) ? $args['screen'] : null,
50
+				'screen'   => isset($args['screen']) ? $args['screen'] : null,
51 51
 			)
52 52
 		);
53 53
 
54 54
 		$this->is_site_users = 'site-users-network' === $this->screen->id;
55 55
 
56
-		if ( $this->is_site_users ) {
57
-			$this->site_id = isset( $_REQUEST['id'] ) ? (int) $_REQUEST['id'] : 0;
56
+		if ($this->is_site_users) {
57
+			$this->site_id = isset($_REQUEST['id']) ? (int) $_REQUEST['id'] : 0;
58 58
 		}
59 59
 	}
60 60
 
@@ -66,10 +66,10 @@  discard block
 block discarded – undo
66 66
 	 * @return bool
67 67
 	 */
68 68
 	public function ajax_user_can() {
69
-		if ( $this->is_site_users ) {
70
-			return current_user_can( 'manage_sites' );
69
+		if ($this->is_site_users) {
70
+			return current_user_can('manage_sites');
71 71
 		} else {
72
-			return current_user_can( 'list_users' );
72
+			return current_user_can('list_users');
73 73
 		}
74 74
 	}
75 75
 
@@ -84,46 +84,46 @@  discard block
 block discarded – undo
84 84
 	public function prepare_items() {
85 85
 		global $role, $usersearch;
86 86
 
87
-		$usersearch = isset( $_REQUEST['s'] ) ? wp_unslash( trim( $_REQUEST['s'] ) ) : '';
87
+		$usersearch = isset($_REQUEST['s']) ? wp_unslash(trim($_REQUEST['s'])) : '';
88 88
 
89
-		$role = isset( $_REQUEST['role'] ) ? $_REQUEST['role'] : '';
89
+		$role = isset($_REQUEST['role']) ? $_REQUEST['role'] : '';
90 90
 
91
-		$per_page       = ( $this->is_site_users ) ? 'site_users_network_per_page' : 'users_per_page';
92
-		$users_per_page = $this->get_items_per_page( $per_page );
91
+		$per_page       = ($this->is_site_users) ? 'site_users_network_per_page' : 'users_per_page';
92
+		$users_per_page = $this->get_items_per_page($per_page);
93 93
 
94 94
 		$paged = $this->get_pagenum();
95 95
 
96
-		if ( 'none' === $role ) {
96
+		if ('none' === $role) {
97 97
 			$args = array(
98 98
 				'number'  => $users_per_page,
99
-				'offset'  => ( $paged - 1 ) * $users_per_page,
100
-				'include' => wp_get_users_with_no_role( $this->site_id ),
99
+				'offset'  => ($paged - 1) * $users_per_page,
100
+				'include' => wp_get_users_with_no_role($this->site_id),
101 101
 				'search'  => $usersearch,
102 102
 				'fields'  => 'all_with_meta',
103 103
 			);
104 104
 		} else {
105 105
 			$args = array(
106 106
 				'number' => $users_per_page,
107
-				'offset' => ( $paged - 1 ) * $users_per_page,
107
+				'offset' => ($paged - 1) * $users_per_page,
108 108
 				'role'   => $role,
109 109
 				'search' => $usersearch,
110 110
 				'fields' => 'all_with_meta',
111 111
 			);
112 112
 		}
113 113
 
114
-		if ( '' !== $args['search'] ) {
114
+		if ('' !== $args['search']) {
115 115
 			$args['search'] = '*' . $args['search'] . '*';
116 116
 		}
117 117
 
118
-		if ( $this->is_site_users ) {
118
+		if ($this->is_site_users) {
119 119
 			$args['blog_id'] = $this->site_id;
120 120
 		}
121 121
 
122
-		if ( isset( $_REQUEST['orderby'] ) ) {
122
+		if (isset($_REQUEST['orderby'])) {
123 123
 			$args['orderby'] = $_REQUEST['orderby'];
124 124
 		}
125 125
 
126
-		if ( isset( $_REQUEST['order'] ) ) {
126
+		if (isset($_REQUEST['order'])) {
127 127
 			$args['order'] = $_REQUEST['order'];
128 128
 		}
129 129
 
@@ -135,10 +135,10 @@  discard block
 block discarded – undo
135 135
 		 * @param array $args Arguments passed to WP_User_Query to retrieve items for the current
136 136
 		 *                    users list table.
137 137
 		 */
138
-		$args = apply_filters( 'users_list_table_query_args', $args );
138
+		$args = apply_filters('users_list_table_query_args', $args);
139 139
 
140 140
 		// Query the user IDs for this page.
141
-		$wp_user_search = new WP_User_Query( $args );
141
+		$wp_user_search = new WP_User_Query($args);
142 142
 
143 143
 		$this->items = $wp_user_search->get_results();
144 144
 
@@ -156,7 +156,7 @@  discard block
 block discarded – undo
156 156
 	 * @since 3.1.0
157 157
 	 */
158 158
 	public function no_items() {
159
-		_e( 'No users found.' );
159
+		_e('No users found.');
160 160
 	}
161 161
 
162 162
 	/**
@@ -177,9 +177,9 @@  discard block
 block discarded – undo
177 177
 
178 178
 		$wp_roles = wp_roles();
179 179
 
180
-		$count_users = ! wp_is_large_user_count();
180
+		$count_users = !wp_is_large_user_count();
181 181
 
182
-		if ( $this->is_site_users ) {
182
+		if ($this->is_site_users) {
183 183
 			$url = 'site-users.php?id=' . $this->site_id;
184 184
 		} else {
185 185
 			$url = 'users.php';
@@ -187,21 +187,21 @@  discard block
 block discarded – undo
187 187
 
188 188
 		$role_links              = array();
189 189
 		$avail_roles             = array();
190
-		$all_text                = __( 'All' );
191
-		$current_link_attributes = empty( $role ) ? ' class="current" aria-current="page"' : '';
190
+		$all_text                = __('All');
191
+		$current_link_attributes = empty($role) ? ' class="current" aria-current="page"' : '';
192 192
 
193
-		if ( $count_users ) {
194
-			if ( $this->is_site_users ) {
195
-				switch_to_blog( $this->site_id );
196
-				$users_of_blog = count_users( 'time', $this->site_id );
193
+		if ($count_users) {
194
+			if ($this->is_site_users) {
195
+				switch_to_blog($this->site_id);
196
+				$users_of_blog = count_users('time', $this->site_id);
197 197
 				restore_current_blog();
198 198
 			} else {
199 199
 				$users_of_blog = count_users();
200 200
 			}
201 201
 
202 202
 			$total_users = $users_of_blog['total_users'];
203
-			$avail_roles =& $users_of_blog['avail_roles'];
204
-			unset( $users_of_blog );
203
+			$avail_roles = & $users_of_blog['avail_roles'];
204
+			unset($users_of_blog);
205 205
 
206 206
 			$all_text = sprintf(
207 207
 				/* translators: %s: Number of users. */
@@ -211,53 +211,53 @@  discard block
 block discarded – undo
211 211
 					$total_users,
212 212
 					'users'
213 213
 				),
214
-				number_format_i18n( $total_users )
214
+				number_format_i18n($total_users)
215 215
 			);
216 216
 		}
217 217
 
218
-		$role_links['all'] = sprintf( '<a href="%s"%s>%s</a>', $url, $current_link_attributes, $all_text );
218
+		$role_links['all'] = sprintf('<a href="%s"%s>%s</a>', $url, $current_link_attributes, $all_text);
219 219
 
220
-		foreach ( $wp_roles->get_names() as $this_role => $name ) {
221
-			if ( $count_users && ! isset( $avail_roles[ $this_role ] ) ) {
220
+		foreach ($wp_roles->get_names() as $this_role => $name) {
221
+			if ($count_users && !isset($avail_roles[$this_role])) {
222 222
 				continue;
223 223
 			}
224 224
 
225 225
 			$current_link_attributes = '';
226 226
 
227
-			if ( $this_role === $role ) {
227
+			if ($this_role === $role) {
228 228
 				$current_link_attributes = ' class="current" aria-current="page"';
229 229
 			}
230 230
 
231
-			$name = translate_user_role( $name );
232
-			if ( $count_users ) {
231
+			$name = translate_user_role($name);
232
+			if ($count_users) {
233 233
 				$name = sprintf(
234 234
 					/* translators: 1: User role name, 2: Number of users. */
235
-					__( '%1$s <span class="count">(%2$s)</span>' ),
235
+					__('%1$s <span class="count">(%2$s)</span>'),
236 236
 					$name,
237
-					number_format_i18n( $avail_roles[ $this_role ] )
237
+					number_format_i18n($avail_roles[$this_role])
238 238
 				);
239 239
 			}
240 240
 
241
-			$role_links[ $this_role ] = "<a href='" . esc_url( add_query_arg( 'role', $this_role, $url ) ) . "'$current_link_attributes>$name</a>";
241
+			$role_links[$this_role] = "<a href='" . esc_url(add_query_arg('role', $this_role, $url)) . "'$current_link_attributes>$name</a>";
242 242
 		}
243 243
 
244
-		if ( ! empty( $avail_roles['none'] ) ) {
244
+		if (!empty($avail_roles['none'])) {
245 245
 
246 246
 			$current_link_attributes = '';
247 247
 
248
-			if ( 'none' === $role ) {
248
+			if ('none' === $role) {
249 249
 				$current_link_attributes = ' class="current" aria-current="page"';
250 250
 			}
251 251
 
252
-			$name = __( 'No role' );
252
+			$name = __('No role');
253 253
 			$name = sprintf(
254 254
 				/* translators: 1: User role name, 2: Number of users. */
255
-				__( '%1$s <span class="count">(%2$s)</span>' ),
255
+				__('%1$s <span class="count">(%2$s)</span>'),
256 256
 				$name,
257
-				number_format_i18n( $avail_roles['none'] )
257
+				number_format_i18n($avail_roles['none'])
258 258
 			);
259 259
 
260
-			$role_links['none'] = "<a href='" . esc_url( add_query_arg( 'role', 'none', $url ) ) . "'$current_link_attributes>$name</a>";
260
+			$role_links['none'] = "<a href='" . esc_url(add_query_arg('role', 'none', $url)) . "'$current_link_attributes>$name</a>";
261 261
 		}
262 262
 
263 263
 		return $role_links;
@@ -273,19 +273,19 @@  discard block
 block discarded – undo
273 273
 	protected function get_bulk_actions() {
274 274
 		$actions = array();
275 275
 
276
-		if ( is_multisite() ) {
277
-			if ( current_user_can( 'remove_users' ) ) {
278
-				$actions['remove'] = __( 'Remove' );
276
+		if (is_multisite()) {
277
+			if (current_user_can('remove_users')) {
278
+				$actions['remove'] = __('Remove');
279 279
 			}
280 280
 		} else {
281
-			if ( current_user_can( 'delete_users' ) ) {
282
-				$actions['delete'] = __( 'Delete' );
281
+			if (current_user_can('delete_users')) {
282
+				$actions['delete'] = __('Delete');
283 283
 			}
284 284
 		}
285 285
 
286 286
 		// Add a password reset link to the bulk actions dropdown.
287
-		if ( current_user_can( 'edit_users' ) ) {
288
-			$actions['resetpassword'] = __( 'Send password reset' );
287
+		if (current_user_can('edit_users')) {
288
+			$actions['resetpassword'] = __('Send password reset');
289 289
 		}
290 290
 
291 291
 		return $actions;
@@ -299,20 +299,20 @@  discard block
 block discarded – undo
299 299
 	 * @param string $which Whether this is being invoked above ("top")
300 300
 	 *                      or below the table ("bottom").
301 301
 	 */
302
-	protected function extra_tablenav( $which ) {
302
+	protected function extra_tablenav($which) {
303 303
 		$id        = 'bottom' === $which ? 'new_role2' : 'new_role';
304 304
 		$button_id = 'bottom' === $which ? 'changeit2' : 'changeit';
305 305
 		?>
306 306
 	<div class="alignleft actions">
307
-		<?php if ( current_user_can( 'promote_users' ) && $this->has_items() ) : ?>
308
-		<label class="screen-reader-text" for="<?php echo $id; ?>"><?php _e( 'Change role to&hellip;' ); ?></label>
307
+		<?php if (current_user_can('promote_users') && $this->has_items()) : ?>
308
+		<label class="screen-reader-text" for="<?php echo $id; ?>"><?php _e('Change role to&hellip;'); ?></label>
309 309
 		<select name="<?php echo $id; ?>" id="<?php echo $id; ?>">
310
-			<option value=""><?php _e( 'Change role to&hellip;' ); ?></option>
310
+			<option value=""><?php _e('Change role to&hellip;'); ?></option>
311 311
 			<?php wp_dropdown_roles(); ?>
312
-			<option value="none"><?php _e( '&mdash; No role for this site &mdash;' ); ?></option>
312
+			<option value="none"><?php _e('&mdash; No role for this site &mdash;'); ?></option>
313 313
 		</select>
314 314
 			<?php
315
-			submit_button( __( 'Change' ), '', $button_id, false );
315
+			submit_button(__('Change'), '', $button_id, false);
316 316
 		endif;
317 317
 
318 318
 		/**
@@ -324,7 +324,7 @@  discard block
 block discarded – undo
324 324
 		 *
325 325
 		 * @param string $which The location of the extra table nav markup: 'top' or 'bottom'.
326 326
 		 */
327
-		do_action( 'restrict_manage_users', $which );
327
+		do_action('restrict_manage_users', $which);
328 328
 		?>
329 329
 		</div>
330 330
 		<?php
@@ -336,7 +336,7 @@  discard block
 block discarded – undo
336 336
 		 *
337 337
 		 * @param string $which The location of the extra table nav markup: 'top' or 'bottom'.
338 338
 		 */
339
-		do_action( 'manage_users_extra_tablenav', $which );
339
+		do_action('manage_users_extra_tablenav', $which);
340 340
 	}
341 341
 
342 342
 	/**
@@ -350,7 +350,7 @@  discard block
 block discarded – undo
350 350
 	 * @return string The bulk action required.
351 351
 	 */
352 352
 	public function current_action() {
353
-		if ( isset( $_REQUEST['changeit'] ) && ! empty( $_REQUEST['new_role'] ) ) {
353
+		if (isset($_REQUEST['changeit']) && !empty($_REQUEST['new_role'])) {
354 354
 			return 'promote';
355 355
 		}
356 356
 
@@ -367,15 +367,15 @@  discard block
 block discarded – undo
367 367
 	public function get_columns() {
368 368
 		$c = array(
369 369
 			'cb'       => '<input type="checkbox" />',
370
-			'username' => __( 'Username' ),
371
-			'name'     => __( 'Name' ),
372
-			'email'    => __( 'Email' ),
373
-			'role'     => __( 'Role' ),
374
-			'posts'    => _x( 'Posts', 'post type general name' ),
370
+			'username' => __('Username'),
371
+			'name'     => __('Name'),
372
+			'email'    => __('Email'),
373
+			'role'     => __('Role'),
374
+			'posts'    => _x('Posts', 'post type general name'),
375 375
 		);
376 376
 
377
-		if ( $this->is_site_users ) {
378
-			unset( $c['posts'] );
377
+		if ($this->is_site_users) {
378
+			unset($c['posts']);
379 379
 		}
380 380
 
381 381
 		return $c;
@@ -404,12 +404,12 @@  discard block
 block discarded – undo
404 404
 	 */
405 405
 	public function display_rows() {
406 406
 		// Query the post counts for this page.
407
-		if ( ! $this->is_site_users ) {
408
-			$post_counts = count_many_users_posts( array_keys( $this->items ) );
407
+		if (!$this->is_site_users) {
408
+			$post_counts = count_many_users_posts(array_keys($this->items));
409 409
 		}
410 410
 
411
-		foreach ( $this->items as $userid => $user_object ) {
412
-			echo "\n\t" . $this->single_row( $user_object, '', '', isset( $post_counts ) ? $post_counts[ $userid ] : 0 );
411
+		foreach ($this->items as $userid => $user_object) {
412
+			echo "\n\t" . $this->single_row($user_object, '', '', isset($post_counts) ? $post_counts[$userid] : 0);
413 413
 		}
414 414
 	}
415 415
 
@@ -427,80 +427,80 @@  discard block
 block discarded – undo
427 427
 	 *                             to zero, as in, a new user has made zero posts.
428 428
 	 * @return string Output for a single row.
429 429
 	 */
430
-	public function single_row( $user_object, $style = '', $role = '', $numposts = 0 ) {
431
-		if ( ! ( $user_object instanceof WP_User ) ) {
432
-			$user_object = get_userdata( (int) $user_object );
430
+	public function single_row($user_object, $style = '', $role = '', $numposts = 0) {
431
+		if (!($user_object instanceof WP_User)) {
432
+			$user_object = get_userdata((int) $user_object);
433 433
 		}
434 434
 		$user_object->filter = 'display';
435 435
 		$email               = $user_object->user_email;
436 436
 
437
-		if ( $this->is_site_users ) {
437
+		if ($this->is_site_users) {
438 438
 			$url = "site-users.php?id={$this->site_id}&amp;";
439 439
 		} else {
440 440
 			$url = 'users.php?';
441 441
 		}
442 442
 
443
-		$user_roles = $this->get_role_list( $user_object );
443
+		$user_roles = $this->get_role_list($user_object);
444 444
 
445 445
 		// Set up the hover actions for this user.
446 446
 		$actions     = array();
447 447
 		$checkbox    = '';
448 448
 		$super_admin = '';
449 449
 
450
-		if ( is_multisite() && current_user_can( 'manage_network_users' ) ) {
451
-			if ( in_array( $user_object->user_login, get_super_admins(), true ) ) {
452
-				$super_admin = ' &mdash; ' . __( 'Super Admin' );
450
+		if (is_multisite() && current_user_can('manage_network_users')) {
451
+			if (in_array($user_object->user_login, get_super_admins(), true)) {
452
+				$super_admin = ' &mdash; ' . __('Super Admin');
453 453
 			}
454 454
 		}
455 455
 
456 456
 		// Check if the user for this row is editable.
457
-		if ( current_user_can( 'list_users' ) ) {
457
+		if (current_user_can('list_users')) {
458 458
 			// Set up the user editing link.
459 459
 			$edit_link = esc_url(
460 460
 				add_query_arg(
461 461
 					'wp_http_referer',
462
-					urlencode( wp_unslash( $_SERVER['REQUEST_URI'] ) ),
463
-					get_edit_user_link( $user_object->ID )
462
+					urlencode(wp_unslash($_SERVER['REQUEST_URI'])),
463
+					get_edit_user_link($user_object->ID)
464 464
 				)
465 465
 			);
466 466
 
467
-			if ( current_user_can( 'edit_user', $user_object->ID ) ) {
467
+			if (current_user_can('edit_user', $user_object->ID)) {
468 468
 				$edit            = "<strong><a href=\"{$edit_link}\">{$user_object->user_login}</a>{$super_admin}</strong><br />";
469
-				$actions['edit'] = '<a href="' . $edit_link . '">' . __( 'Edit' ) . '</a>';
469
+				$actions['edit'] = '<a href="' . $edit_link . '">' . __('Edit') . '</a>';
470 470
 			} else {
471 471
 				$edit = "<strong>{$user_object->user_login}{$super_admin}</strong><br />";
472 472
 			}
473 473
 
474
-			if ( ! is_multisite()
474
+			if (!is_multisite()
475 475
 				&& get_current_user_id() !== $user_object->ID
476
-				&& current_user_can( 'delete_user', $user_object->ID )
476
+				&& current_user_can('delete_user', $user_object->ID)
477 477
 			) {
478
-				$actions['delete'] = "<a class='submitdelete' href='" . wp_nonce_url( "users.php?action=delete&amp;user=$user_object->ID", 'bulk-users' ) . "'>" . __( 'Delete' ) . '</a>';
478
+				$actions['delete'] = "<a class='submitdelete' href='" . wp_nonce_url("users.php?action=delete&amp;user=$user_object->ID", 'bulk-users') . "'>" . __('Delete') . '</a>';
479 479
 			}
480 480
 
481
-			if ( is_multisite()
482
-				&& current_user_can( 'remove_user', $user_object->ID )
481
+			if (is_multisite()
482
+				&& current_user_can('remove_user', $user_object->ID)
483 483
 			) {
484
-				$actions['remove'] = "<a class='submitdelete' href='" . wp_nonce_url( $url . "action=remove&amp;user=$user_object->ID", 'bulk-users' ) . "'>" . __( 'Remove' ) . '</a>';
484
+				$actions['remove'] = "<a class='submitdelete' href='" . wp_nonce_url($url . "action=remove&amp;user=$user_object->ID", 'bulk-users') . "'>" . __('Remove') . '</a>';
485 485
 			}
486 486
 
487 487
 			// Add a link to the user's author archive, if not empty.
488
-			$author_posts_url = get_author_posts_url( $user_object->ID );
489
-			if ( $author_posts_url ) {
488
+			$author_posts_url = get_author_posts_url($user_object->ID);
489
+			if ($author_posts_url) {
490 490
 				$actions['view'] = sprintf(
491 491
 					'<a href="%s" aria-label="%s">%s</a>',
492
-					esc_url( $author_posts_url ),
492
+					esc_url($author_posts_url),
493 493
 					/* translators: %s: Author's display name. */
494
-					esc_attr( sprintf( __( 'View posts by %s' ), $user_object->display_name ) ),
495
-					__( 'View' )
494
+					esc_attr(sprintf(__('View posts by %s'), $user_object->display_name)),
495
+					__('View')
496 496
 				);
497 497
 			}
498 498
 
499 499
 			// Add a link to send the user a reset password link by email.
500
-			if ( get_current_user_id() !== $user_object->ID
501
-				&& current_user_can( 'edit_user', $user_object->ID )
500
+			if (get_current_user_id() !== $user_object->ID
501
+				&& current_user_can('edit_user', $user_object->ID)
502 502
 			) {
503
-				$actions['resetpassword'] = "<a class='resetpassword' href='" . wp_nonce_url( "users.php?action=resetpassword&amp;users=$user_object->ID", 'bulk-users' ) . "'>" . __( 'Send password reset' ) . '</a>';
503
+				$actions['resetpassword'] = "<a class='resetpassword' href='" . wp_nonce_url("users.php?action=resetpassword&amp;users=$user_object->ID", 'bulk-users') . "'>" . __('Send password reset') . '</a>';
504 504
 			}
505 505
 
506 506
 			/**
@@ -513,10 +513,10 @@  discard block
 block discarded – undo
513 513
 			 *                              'Edit', 'Remove' for Multisite.
514 514
 			 * @param WP_User  $user_object WP_User object for the currently listed user.
515 515
 			 */
516
-			$actions = apply_filters( 'user_row_actions', $actions, $user_object );
516
+			$actions = apply_filters('user_row_actions', $actions, $user_object);
517 517
 
518 518
 			// Role classes.
519
-			$role_classes = esc_attr( implode( ' ', array_keys( $user_roles ) ) );
519
+			$role_classes = esc_attr(implode(' ', array_keys($user_roles)));
520 520
 
521 521
 			// Set up the checkbox (because the user is editable, otherwise it's empty).
522 522
 			$checkbox = sprintf(
@@ -524,7 +524,7 @@  discard block
 block discarded – undo
524 524
 				'<input type="checkbox" name="users[]" id="user_%1$s" class="%3$s" value="%1$s" />',
525 525
 				$user_object->ID,
526 526
 				/* translators: %s: User login. */
527
-				sprintf( __( 'Select %s' ), $user_object->user_login ),
527
+				sprintf(__('Select %s'), $user_object->user_login),
528 528
 				$role_classes
529 529
 			);
530 530
 
@@ -532,70 +532,70 @@  discard block
 block discarded – undo
532 532
 			$edit = "<strong>{$user_object->user_login}{$super_admin}</strong>";
533 533
 		}
534 534
 
535
-		$avatar = get_avatar( $user_object->ID, 32 );
535
+		$avatar = get_avatar($user_object->ID, 32);
536 536
 
537 537
 		// Comma-separated list of user roles.
538
-		$roles_list = implode( ', ', $user_roles );
538
+		$roles_list = implode(', ', $user_roles);
539 539
 
540 540
 		$r = "<tr id='user-$user_object->ID'>";
541 541
 
542
-		list( $columns, $hidden, $sortable, $primary ) = $this->get_column_info();
542
+		list($columns, $hidden, $sortable, $primary) = $this->get_column_info();
543 543
 
544
-		foreach ( $columns as $column_name => $column_display_name ) {
544
+		foreach ($columns as $column_name => $column_display_name) {
545 545
 			$classes = "$column_name column-$column_name";
546
-			if ( $primary === $column_name ) {
546
+			if ($primary === $column_name) {
547 547
 				$classes .= ' has-row-actions column-primary';
548 548
 			}
549
-			if ( 'posts' === $column_name ) {
549
+			if ('posts' === $column_name) {
550 550
 				$classes .= ' num'; // Special case for that column.
551 551
 			}
552 552
 
553
-			if ( in_array( $column_name, $hidden, true ) ) {
553
+			if (in_array($column_name, $hidden, true)) {
554 554
 				$classes .= ' hidden';
555 555
 			}
556 556
 
557
-			$data = 'data-colname="' . esc_attr( wp_strip_all_tags( $column_display_name ) ) . '"';
557
+			$data = 'data-colname="' . esc_attr(wp_strip_all_tags($column_display_name)) . '"';
558 558
 
559 559
 			$attributes = "class='$classes' $data";
560 560
 
561
-			if ( 'cb' === $column_name ) {
561
+			if ('cb' === $column_name) {
562 562
 				$r .= "<th scope='row' class='check-column'>$checkbox</th>";
563 563
 			} else {
564 564
 				$r .= "<td $attributes>";
565
-				switch ( $column_name ) {
565
+				switch ($column_name) {
566 566
 					case 'username':
567 567
 						$r .= "$avatar $edit";
568 568
 						break;
569 569
 					case 'name':
570
-						if ( $user_object->first_name && $user_object->last_name ) {
570
+						if ($user_object->first_name && $user_object->last_name) {
571 571
 							$r .= "$user_object->first_name $user_object->last_name";
572
-						} elseif ( $user_object->first_name ) {
572
+						} elseif ($user_object->first_name) {
573 573
 							$r .= $user_object->first_name;
574
-						} elseif ( $user_object->last_name ) {
574
+						} elseif ($user_object->last_name) {
575 575
 							$r .= $user_object->last_name;
576 576
 						} else {
577 577
 							$r .= sprintf(
578 578
 								'<span aria-hidden="true">&#8212;</span><span class="screen-reader-text">%s</span>',
579
-								_x( 'Unknown', 'name' )
579
+								_x('Unknown', 'name')
580 580
 							);
581 581
 						}
582 582
 						break;
583 583
 					case 'email':
584
-						$r .= "<a href='" . esc_url( "mailto:$email" ) . "'>$email</a>";
584
+						$r .= "<a href='" . esc_url("mailto:$email") . "'>$email</a>";
585 585
 						break;
586 586
 					case 'role':
587
-						$r .= esc_html( $roles_list );
587
+						$r .= esc_html($roles_list);
588 588
 						break;
589 589
 					case 'posts':
590
-						if ( $numposts > 0 ) {
590
+						if ($numposts > 0) {
591 591
 							$r .= sprintf(
592 592
 								'<a href="%s" class="edit"><span aria-hidden="true">%s</span><span class="screen-reader-text">%s</span></a>',
593 593
 								"edit.php?author={$user_object->ID}",
594 594
 								$numposts,
595 595
 								sprintf(
596 596
 									/* translators: %s: Number of posts. */
597
-									_n( '%s post by this author', '%s posts by this author', $numposts ),
598
-									number_format_i18n( $numposts )
597
+									_n('%s post by this author', '%s posts by this author', $numposts),
598
+									number_format_i18n($numposts)
599 599
 								)
600 600
 							);
601 601
 						} else {
@@ -612,11 +612,11 @@  discard block
 block discarded – undo
612 612
 						 * @param string $column_name Column name.
613 613
 						 * @param int    $user_id     ID of the currently-listed user.
614 614
 						 */
615
-						$r .= apply_filters( 'manage_users_custom_column', '', $column_name, $user_object->ID );
615
+						$r .= apply_filters('manage_users_custom_column', '', $column_name, $user_object->ID);
616 616
 				}
617 617
 
618
-				if ( $primary === $column_name ) {
619
-					$r .= $this->row_actions( $actions );
618
+				if ($primary === $column_name) {
619
+					$r .= $this->row_actions($actions);
620 620
 				}
621 621
 				$r .= '</td>';
622 622
 			}
@@ -645,19 +645,19 @@  discard block
 block discarded – undo
645 645
 	 * @param WP_User $user_object The WP_User object.
646 646
 	 * @return string[] An array of user role names keyed by role.
647 647
 	 */
648
-	protected function get_role_list( $user_object ) {
648
+	protected function get_role_list($user_object) {
649 649
 		$wp_roles = wp_roles();
650 650
 
651 651
 		$role_list = array();
652 652
 
653
-		foreach ( $user_object->roles as $role ) {
654
-			if ( isset( $wp_roles->role_names[ $role ] ) ) {
655
-				$role_list[ $role ] = translate_user_role( $wp_roles->role_names[ $role ] );
653
+		foreach ($user_object->roles as $role) {
654
+			if (isset($wp_roles->role_names[$role])) {
655
+				$role_list[$role] = translate_user_role($wp_roles->role_names[$role]);
656 656
 			}
657 657
 		}
658 658
 
659
-		if ( empty( $role_list ) ) {
660
-			$role_list['none'] = _x( 'None', 'no user roles' );
659
+		if (empty($role_list)) {
660
+			$role_list['none'] = _x('None', 'no user roles');
661 661
 		}
662 662
 
663 663
 		/**
@@ -668,7 +668,7 @@  discard block
 block discarded – undo
668 668
 		 * @param string[] $role_list   An array of translated user role names keyed by role.
669 669
 		 * @param WP_User  $user_object A WP_User object.
670 670
 		 */
671
-		return apply_filters( 'get_role_list', $role_list, $user_object );
671
+		return apply_filters('get_role_list', $role_list, $user_object);
672 672
 	}
673 673
 
674 674
 }
Please login to merge, or discard this patch.
brighty/wp-admin/includes/credits.php 2 patches
Indentation   +89 added lines, -89 removed lines patch added patch discarded remove patch
@@ -18,46 +18,46 @@  discard block
 block discarded – undo
18 18
  * @return array|false A list of all of the contributors, or false on error.
19 19
  */
20 20
 function wp_credits( $version = '', $locale = '' ) {
21
-	if ( ! $version ) {
22
-		// Include an unmodified $wp_version.
23
-		require ABSPATH . WPINC . '/version.php';
21
+    if ( ! $version ) {
22
+        // Include an unmodified $wp_version.
23
+        require ABSPATH . WPINC . '/version.php';
24 24
 
25
-		$version = $wp_version;
26
-	}
25
+        $version = $wp_version;
26
+    }
27 27
 
28
-	if ( ! $locale ) {
29
-		$locale = get_user_locale();
30
-	}
28
+    if ( ! $locale ) {
29
+        $locale = get_user_locale();
30
+    }
31 31
 
32
-	$results = get_site_transient( 'wordpress_credits_' . $locale );
32
+    $results = get_site_transient( 'wordpress_credits_' . $locale );
33 33
 
34
-	if ( ! is_array( $results )
35
-		|| false !== strpos( $version, '-' )
36
-		|| ( isset( $results['data']['version'] ) && strpos( $version, $results['data']['version'] ) !== 0 )
37
-	) {
38
-		$url     = "http://api.wordpress.org/core/credits/1.1/?version={$version}&locale={$locale}";
39
-		$options = array( 'user-agent' => 'WordPress/' . $version . '; ' . home_url( '/' ) );
34
+    if ( ! is_array( $results )
35
+        || false !== strpos( $version, '-' )
36
+        || ( isset( $results['data']['version'] ) && strpos( $version, $results['data']['version'] ) !== 0 )
37
+    ) {
38
+        $url     = "http://api.wordpress.org/core/credits/1.1/?version={$version}&locale={$locale}";
39
+        $options = array( 'user-agent' => 'WordPress/' . $version . '; ' . home_url( '/' ) );
40 40
 
41
-		if ( wp_http_supports( array( 'ssl' ) ) ) {
42
-			$url = set_url_scheme( $url, 'https' );
43
-		}
41
+        if ( wp_http_supports( array( 'ssl' ) ) ) {
42
+            $url = set_url_scheme( $url, 'https' );
43
+        }
44 44
 
45
-		$response = wp_remote_get( $url, $options );
45
+        $response = wp_remote_get( $url, $options );
46 46
 
47
-		if ( is_wp_error( $response ) || 200 !== wp_remote_retrieve_response_code( $response ) ) {
48
-			return false;
49
-		}
47
+        if ( is_wp_error( $response ) || 200 !== wp_remote_retrieve_response_code( $response ) ) {
48
+            return false;
49
+        }
50 50
 
51
-		$results = json_decode( wp_remote_retrieve_body( $response ), true );
51
+        $results = json_decode( wp_remote_retrieve_body( $response ), true );
52 52
 
53
-		if ( ! is_array( $results ) ) {
54
-			return false;
55
-		}
53
+        if ( ! is_array( $results ) ) {
54
+            return false;
55
+        }
56 56
 
57
-		set_site_transient( 'wordpress_credits_' . $locale, $results, DAY_IN_SECONDS );
58
-	}
57
+        set_site_transient( 'wordpress_credits_' . $locale, $results, DAY_IN_SECONDS );
58
+    }
59 59
 
60
-	return $results;
60
+    return $results;
61 61
 }
62 62
 
63 63
 /**
@@ -71,7 +71,7 @@  discard block
 block discarded – undo
71 71
  * @param string $profiles      URL to the contributor's WordPress.org profile page.
72 72
  */
73 73
 function _wp_credits_add_profile_link( &$display_name, $username, $profiles ) {
74
-	$display_name = '<a href="' . esc_url( sprintf( $profiles, $username ) ) . '">' . esc_html( $display_name ) . '</a>';
74
+    $display_name = '<a href="' . esc_url( sprintf( $profiles, $username ) ) . '">' . esc_html( $display_name ) . '</a>';
75 75
 }
76 76
 
77 77
 /**
@@ -83,7 +83,7 @@  discard block
 block discarded – undo
83 83
  * @param string $data External library data (passed by reference).
84 84
  */
85 85
 function _wp_credits_build_object_link( &$data ) {
86
-	$data = '<a href="' . esc_url( $data[1] ) . '">' . esc_html( $data[0] ) . '</a>';
86
+    $data = '<a href="' . esc_url( $data[1] ) . '">' . esc_html( $data[0] ) . '</a>';
87 87
 }
88 88
 
89 89
 /**
@@ -94,24 +94,24 @@  discard block
 block discarded – undo
94 94
  * @param array $group_data The current contributor group.
95 95
  */
96 96
 function wp_credits_section_title( $group_data = array() ) {
97
-	if ( ! count( $group_data ) ) {
98
-		return;
99
-	}
100
-
101
-	if ( $group_data['name'] ) {
102
-		if ( 'Translators' === $group_data['name'] ) {
103
-			// Considered a special slug in the API response. (Also, will never be returned for en_US.)
104
-			$title = _x( 'Translators', 'Translate this to be the equivalent of English Translators in your language for the credits page Translators section' );
105
-		} elseif ( isset( $group_data['placeholders'] ) ) {
106
-			// phpcs:ignore WordPress.WP.I18n.LowLevelTranslationFunction,WordPress.WP.I18n.NonSingularStringLiteralText
107
-			$title = vsprintf( translate( $group_data['name'] ), $group_data['placeholders'] );
108
-		} else {
109
-			// phpcs:ignore WordPress.WP.I18n.LowLevelTranslationFunction,WordPress.WP.I18n.NonSingularStringLiteralText
110
-			$title = translate( $group_data['name'] );
111
-		}
112
-
113
-		echo '<h2 class="wp-people-group-title">' . esc_html( $title ) . "</h2>\n";
114
-	}
97
+    if ( ! count( $group_data ) ) {
98
+        return;
99
+    }
100
+
101
+    if ( $group_data['name'] ) {
102
+        if ( 'Translators' === $group_data['name'] ) {
103
+            // Considered a special slug in the API response. (Also, will never be returned for en_US.)
104
+            $title = _x( 'Translators', 'Translate this to be the equivalent of English Translators in your language for the credits page Translators section' );
105
+        } elseif ( isset( $group_data['placeholders'] ) ) {
106
+            // phpcs:ignore WordPress.WP.I18n.LowLevelTranslationFunction,WordPress.WP.I18n.NonSingularStringLiteralText
107
+            $title = vsprintf( translate( $group_data['name'] ), $group_data['placeholders'] );
108
+        } else {
109
+            // phpcs:ignore WordPress.WP.I18n.LowLevelTranslationFunction,WordPress.WP.I18n.NonSingularStringLiteralText
110
+            $title = translate( $group_data['name'] );
111
+        }
112
+
113
+        echo '<h2 class="wp-people-group-title">' . esc_html( $title ) . "</h2>\n";
114
+    }
115 115
 }
116 116
 
117 117
 /**
@@ -123,44 +123,44 @@  discard block
 block discarded – undo
123 123
  * @param string $slug    The current group to display.
124 124
  */
125 125
 function wp_credits_section_list( $credits = array(), $slug = '' ) {
126
-	$group_data   = isset( $credits['groups'][ $slug ] ) ? $credits['groups'][ $slug ] : array();
127
-	$credits_data = $credits['data'];
128
-	if ( ! count( $group_data ) ) {
129
-		return;
130
-	}
131
-
132
-	if ( ! empty( $group_data['shuffle'] ) ) {
133
-		shuffle( $group_data['data'] ); // We were going to sort by ability to pronounce "hierarchical," but that wouldn't be fair to Matt.
134
-	}
135
-
136
-	switch ( $group_data['type'] ) {
137
-		case 'list':
138
-			array_walk( $group_data['data'], '_wp_credits_add_profile_link', $credits_data['profiles'] );
139
-			echo '<p class="wp-credits-list">' . wp_sprintf( '%l.', $group_data['data'] ) . "</p>\n\n";
140
-			break;
141
-		case 'libraries':
142
-			array_walk( $group_data['data'], '_wp_credits_build_object_link' );
143
-			echo '<p class="wp-credits-list">' . wp_sprintf( '%l.', $group_data['data'] ) . "</p>\n\n";
144
-			break;
145
-		default:
146
-			$compact = 'compact' === $group_data['type'];
147
-			$classes = 'wp-people-group ' . ( $compact ? 'compact' : '' );
148
-			echo '<ul class="' . $classes . '" id="wp-people-group-' . $slug . '">' . "\n";
149
-			foreach ( $group_data['data'] as $person_data ) {
150
-				echo '<li class="wp-person" id="wp-person-' . esc_attr( $person_data[2] ) . '">' . "\n\t";
151
-				echo '<a href="' . esc_url( sprintf( $credits_data['profiles'], $person_data[2] ) ) . '" class="web">';
152
-				$size   = $compact ? 80 : 160;
153
-				$data   = get_avatar_data( $person_data[1] . '@md5.gravatar.com', array( 'size' => $size ) );
154
-				$data2x = get_avatar_data( $person_data[1] . '@md5.gravatar.com', array( 'size' => $size * 2 ) );
155
-				echo '<span class="wp-person-avatar"><img src="' . esc_url( $data['url'] ) . '" srcset="' . esc_url( $data2x['url'] ) . ' 2x" class="gravatar" alt="" /></span>' . "\n";
156
-				echo esc_html( $person_data[0] ) . "</a>\n\t";
157
-				if ( ! $compact && ! empty( $person_data[3] ) ) {
158
-					// phpcs:ignore WordPress.WP.I18n.LowLevelTranslationFunction,WordPress.WP.I18n.NonSingularStringLiteralText
159
-					echo '<span class="title">' . translate( $person_data[3] ) . "</span>\n";
160
-				}
161
-				echo "</li>\n";
162
-			}
163
-			echo "</ul>\n";
164
-			break;
165
-	}
126
+    $group_data   = isset( $credits['groups'][ $slug ] ) ? $credits['groups'][ $slug ] : array();
127
+    $credits_data = $credits['data'];
128
+    if ( ! count( $group_data ) ) {
129
+        return;
130
+    }
131
+
132
+    if ( ! empty( $group_data['shuffle'] ) ) {
133
+        shuffle( $group_data['data'] ); // We were going to sort by ability to pronounce "hierarchical," but that wouldn't be fair to Matt.
134
+    }
135
+
136
+    switch ( $group_data['type'] ) {
137
+        case 'list':
138
+            array_walk( $group_data['data'], '_wp_credits_add_profile_link', $credits_data['profiles'] );
139
+            echo '<p class="wp-credits-list">' . wp_sprintf( '%l.', $group_data['data'] ) . "</p>\n\n";
140
+            break;
141
+        case 'libraries':
142
+            array_walk( $group_data['data'], '_wp_credits_build_object_link' );
143
+            echo '<p class="wp-credits-list">' . wp_sprintf( '%l.', $group_data['data'] ) . "</p>\n\n";
144
+            break;
145
+        default:
146
+            $compact = 'compact' === $group_data['type'];
147
+            $classes = 'wp-people-group ' . ( $compact ? 'compact' : '' );
148
+            echo '<ul class="' . $classes . '" id="wp-people-group-' . $slug . '">' . "\n";
149
+            foreach ( $group_data['data'] as $person_data ) {
150
+                echo '<li class="wp-person" id="wp-person-' . esc_attr( $person_data[2] ) . '">' . "\n\t";
151
+                echo '<a href="' . esc_url( sprintf( $credits_data['profiles'], $person_data[2] ) ) . '" class="web">';
152
+                $size   = $compact ? 80 : 160;
153
+                $data   = get_avatar_data( $person_data[1] . '@md5.gravatar.com', array( 'size' => $size ) );
154
+                $data2x = get_avatar_data( $person_data[1] . '@md5.gravatar.com', array( 'size' => $size * 2 ) );
155
+                echo '<span class="wp-person-avatar"><img src="' . esc_url( $data['url'] ) . '" srcset="' . esc_url( $data2x['url'] ) . ' 2x" class="gravatar" alt="" /></span>' . "\n";
156
+                echo esc_html( $person_data[0] ) . "</a>\n\t";
157
+                if ( ! $compact && ! empty( $person_data[3] ) ) {
158
+                    // phpcs:ignore WordPress.WP.I18n.LowLevelTranslationFunction,WordPress.WP.I18n.NonSingularStringLiteralText
159
+                    echo '<span class="title">' . translate( $person_data[3] ) . "</span>\n";
160
+                }
161
+                echo "</li>\n";
162
+            }
163
+            echo "</ul>\n";
164
+            break;
165
+    }
166 166
 }
Please login to merge, or discard this patch.
Spacing   +48 added lines, -48 removed lines patch added patch discarded remove patch
@@ -17,44 +17,44 @@  discard block
 block discarded – undo
17 17
  * @param string $locale  WordPress locale. Defaults to the current user's locale.
18 18
  * @return array|false A list of all of the contributors, or false on error.
19 19
  */
20
-function wp_credits( $version = '', $locale = '' ) {
21
-	if ( ! $version ) {
20
+function wp_credits($version = '', $locale = '') {
21
+	if (!$version) {
22 22
 		// Include an unmodified $wp_version.
23 23
 		require ABSPATH . WPINC . '/version.php';
24 24
 
25 25
 		$version = $wp_version;
26 26
 	}
27 27
 
28
-	if ( ! $locale ) {
28
+	if (!$locale) {
29 29
 		$locale = get_user_locale();
30 30
 	}
31 31
 
32
-	$results = get_site_transient( 'wordpress_credits_' . $locale );
32
+	$results = get_site_transient('wordpress_credits_' . $locale);
33 33
 
34
-	if ( ! is_array( $results )
35
-		|| false !== strpos( $version, '-' )
36
-		|| ( isset( $results['data']['version'] ) && strpos( $version, $results['data']['version'] ) !== 0 )
34
+	if (!is_array($results)
35
+		|| false !== strpos($version, '-')
36
+		|| (isset($results['data']['version']) && strpos($version, $results['data']['version']) !== 0)
37 37
 	) {
38 38
 		$url     = "http://api.wordpress.org/core/credits/1.1/?version={$version}&locale={$locale}";
39
-		$options = array( 'user-agent' => 'WordPress/' . $version . '; ' . home_url( '/' ) );
39
+		$options = array('user-agent' => 'WordPress/' . $version . '; ' . home_url('/'));
40 40
 
41
-		if ( wp_http_supports( array( 'ssl' ) ) ) {
42
-			$url = set_url_scheme( $url, 'https' );
41
+		if (wp_http_supports(array('ssl'))) {
42
+			$url = set_url_scheme($url, 'https');
43 43
 		}
44 44
 
45
-		$response = wp_remote_get( $url, $options );
45
+		$response = wp_remote_get($url, $options);
46 46
 
47
-		if ( is_wp_error( $response ) || 200 !== wp_remote_retrieve_response_code( $response ) ) {
47
+		if (is_wp_error($response) || 200 !== wp_remote_retrieve_response_code($response)) {
48 48
 			return false;
49 49
 		}
50 50
 
51
-		$results = json_decode( wp_remote_retrieve_body( $response ), true );
51
+		$results = json_decode(wp_remote_retrieve_body($response), true);
52 52
 
53
-		if ( ! is_array( $results ) ) {
53
+		if (!is_array($results)) {
54 54
 			return false;
55 55
 		}
56 56
 
57
-		set_site_transient( 'wordpress_credits_' . $locale, $results, DAY_IN_SECONDS );
57
+		set_site_transient('wordpress_credits_' . $locale, $results, DAY_IN_SECONDS);
58 58
 	}
59 59
 
60 60
 	return $results;
@@ -70,8 +70,8 @@  discard block
 block discarded – undo
70 70
  * @param string $username      The contributor's username.
71 71
  * @param string $profiles      URL to the contributor's WordPress.org profile page.
72 72
  */
73
-function _wp_credits_add_profile_link( &$display_name, $username, $profiles ) {
74
-	$display_name = '<a href="' . esc_url( sprintf( $profiles, $username ) ) . '">' . esc_html( $display_name ) . '</a>';
73
+function _wp_credits_add_profile_link(&$display_name, $username, $profiles) {
74
+	$display_name = '<a href="' . esc_url(sprintf($profiles, $username)) . '">' . esc_html($display_name) . '</a>';
75 75
 }
76 76
 
77 77
 /**
@@ -82,8 +82,8 @@  discard block
 block discarded – undo
82 82
  *
83 83
  * @param string $data External library data (passed by reference).
84 84
  */
85
-function _wp_credits_build_object_link( &$data ) {
86
-	$data = '<a href="' . esc_url( $data[1] ) . '">' . esc_html( $data[0] ) . '</a>';
85
+function _wp_credits_build_object_link(&$data) {
86
+	$data = '<a href="' . esc_url($data[1]) . '">' . esc_html($data[0]) . '</a>';
87 87
 }
88 88
 
89 89
 /**
@@ -93,24 +93,24 @@  discard block
 block discarded – undo
93 93
  *
94 94
  * @param array $group_data The current contributor group.
95 95
  */
96
-function wp_credits_section_title( $group_data = array() ) {
97
-	if ( ! count( $group_data ) ) {
96
+function wp_credits_section_title($group_data = array()) {
97
+	if (!count($group_data)) {
98 98
 		return;
99 99
 	}
100 100
 
101
-	if ( $group_data['name'] ) {
102
-		if ( 'Translators' === $group_data['name'] ) {
101
+	if ($group_data['name']) {
102
+		if ('Translators' === $group_data['name']) {
103 103
 			// Considered a special slug in the API response. (Also, will never be returned for en_US.)
104
-			$title = _x( 'Translators', 'Translate this to be the equivalent of English Translators in your language for the credits page Translators section' );
105
-		} elseif ( isset( $group_data['placeholders'] ) ) {
104
+			$title = _x('Translators', 'Translate this to be the equivalent of English Translators in your language for the credits page Translators section');
105
+		} elseif (isset($group_data['placeholders'])) {
106 106
 			// phpcs:ignore WordPress.WP.I18n.LowLevelTranslationFunction,WordPress.WP.I18n.NonSingularStringLiteralText
107
-			$title = vsprintf( translate( $group_data['name'] ), $group_data['placeholders'] );
107
+			$title = vsprintf(translate($group_data['name']), $group_data['placeholders']);
108 108
 		} else {
109 109
 			// phpcs:ignore WordPress.WP.I18n.LowLevelTranslationFunction,WordPress.WP.I18n.NonSingularStringLiteralText
110
-			$title = translate( $group_data['name'] );
110
+			$title = translate($group_data['name']);
111 111
 		}
112 112
 
113
-		echo '<h2 class="wp-people-group-title">' . esc_html( $title ) . "</h2>\n";
113
+		echo '<h2 class="wp-people-group-title">' . esc_html($title) . "</h2>\n";
114 114
 	}
115 115
 }
116 116
 
@@ -122,41 +122,41 @@  discard block
 block discarded – undo
122 122
  * @param array  $credits The credits groups returned from the API.
123 123
  * @param string $slug    The current group to display.
124 124
  */
125
-function wp_credits_section_list( $credits = array(), $slug = '' ) {
126
-	$group_data   = isset( $credits['groups'][ $slug ] ) ? $credits['groups'][ $slug ] : array();
125
+function wp_credits_section_list($credits = array(), $slug = '') {
126
+	$group_data   = isset($credits['groups'][$slug]) ? $credits['groups'][$slug] : array();
127 127
 	$credits_data = $credits['data'];
128
-	if ( ! count( $group_data ) ) {
128
+	if (!count($group_data)) {
129 129
 		return;
130 130
 	}
131 131
 
132
-	if ( ! empty( $group_data['shuffle'] ) ) {
133
-		shuffle( $group_data['data'] ); // We were going to sort by ability to pronounce "hierarchical," but that wouldn't be fair to Matt.
132
+	if (!empty($group_data['shuffle'])) {
133
+		shuffle($group_data['data']); // We were going to sort by ability to pronounce "hierarchical," but that wouldn't be fair to Matt.
134 134
 	}
135 135
 
136
-	switch ( $group_data['type'] ) {
136
+	switch ($group_data['type']) {
137 137
 		case 'list':
138
-			array_walk( $group_data['data'], '_wp_credits_add_profile_link', $credits_data['profiles'] );
139
-			echo '<p class="wp-credits-list">' . wp_sprintf( '%l.', $group_data['data'] ) . "</p>\n\n";
138
+			array_walk($group_data['data'], '_wp_credits_add_profile_link', $credits_data['profiles']);
139
+			echo '<p class="wp-credits-list">' . wp_sprintf('%l.', $group_data['data']) . "</p>\n\n";
140 140
 			break;
141 141
 		case 'libraries':
142
-			array_walk( $group_data['data'], '_wp_credits_build_object_link' );
143
-			echo '<p class="wp-credits-list">' . wp_sprintf( '%l.', $group_data['data'] ) . "</p>\n\n";
142
+			array_walk($group_data['data'], '_wp_credits_build_object_link');
143
+			echo '<p class="wp-credits-list">' . wp_sprintf('%l.', $group_data['data']) . "</p>\n\n";
144 144
 			break;
145 145
 		default:
146 146
 			$compact = 'compact' === $group_data['type'];
147
-			$classes = 'wp-people-group ' . ( $compact ? 'compact' : '' );
147
+			$classes = 'wp-people-group ' . ($compact ? 'compact' : '');
148 148
 			echo '<ul class="' . $classes . '" id="wp-people-group-' . $slug . '">' . "\n";
149
-			foreach ( $group_data['data'] as $person_data ) {
150
-				echo '<li class="wp-person" id="wp-person-' . esc_attr( $person_data[2] ) . '">' . "\n\t";
151
-				echo '<a href="' . esc_url( sprintf( $credits_data['profiles'], $person_data[2] ) ) . '" class="web">';
149
+			foreach ($group_data['data'] as $person_data) {
150
+				echo '<li class="wp-person" id="wp-person-' . esc_attr($person_data[2]) . '">' . "\n\t";
151
+				echo '<a href="' . esc_url(sprintf($credits_data['profiles'], $person_data[2])) . '" class="web">';
152 152
 				$size   = $compact ? 80 : 160;
153
-				$data   = get_avatar_data( $person_data[1] . '@md5.gravatar.com', array( 'size' => $size ) );
154
-				$data2x = get_avatar_data( $person_data[1] . '@md5.gravatar.com', array( 'size' => $size * 2 ) );
155
-				echo '<span class="wp-person-avatar"><img src="' . esc_url( $data['url'] ) . '" srcset="' . esc_url( $data2x['url'] ) . ' 2x" class="gravatar" alt="" /></span>' . "\n";
156
-				echo esc_html( $person_data[0] ) . "</a>\n\t";
157
-				if ( ! $compact && ! empty( $person_data[3] ) ) {
153
+				$data   = get_avatar_data($person_data[1] . '@md5.gravatar.com', array('size' => $size));
154
+				$data2x = get_avatar_data($person_data[1] . '@md5.gravatar.com', array('size' => $size * 2));
155
+				echo '<span class="wp-person-avatar"><img src="' . esc_url($data['url']) . '" srcset="' . esc_url($data2x['url']) . ' 2x" class="gravatar" alt="" /></span>' . "\n";
156
+				echo esc_html($person_data[0]) . "</a>\n\t";
157
+				if (!$compact && !empty($person_data[3])) {
158 158
 					// phpcs:ignore WordPress.WP.I18n.LowLevelTranslationFunction,WordPress.WP.I18n.NonSingularStringLiteralText
159
-					echo '<span class="title">' . translate( $person_data[3] ) . "</span>\n";
159
+					echo '<span class="title">' . translate($person_data[3]) . "</span>\n";
160 160
 				}
161 161
 				echo "</li>\n";
162 162
 			}
Please login to merge, or discard this patch.
brighty/wp-admin/includes/class-bulk-upgrader-skin.php 2 patches
Indentation   +162 added lines, -162 removed lines patch added patch discarded remove patch
@@ -16,166 +16,166 @@
 block discarded – undo
16 16
  * @see WP_Upgrader_Skin
17 17
  */
18 18
 class Bulk_Upgrader_Skin extends WP_Upgrader_Skin {
19
-	public $in_loop = false;
20
-	/**
21
-	 * @var string|false
22
-	 */
23
-	public $error = false;
24
-
25
-	/**
26
-	 * @param array $args
27
-	 */
28
-	public function __construct( $args = array() ) {
29
-		$defaults = array(
30
-			'url'   => '',
31
-			'nonce' => '',
32
-		);
33
-		$args     = wp_parse_args( $args, $defaults );
34
-
35
-		parent::__construct( $args );
36
-	}
37
-
38
-	/**
39
-	 */
40
-	public function add_strings() {
41
-		$this->upgrader->strings['skin_upgrade_start'] = __( 'The update process is starting. This process may take a while on some hosts, so please be patient.' );
42
-		/* translators: 1: Title of an update, 2: Error message. */
43
-		$this->upgrader->strings['skin_update_failed_error'] = __( 'An error occurred while updating %1$s: %2$s' );
44
-		/* translators: %s: Title of an update. */
45
-		$this->upgrader->strings['skin_update_failed'] = __( 'The update of %s failed.' );
46
-		/* translators: %s: Title of an update. */
47
-		$this->upgrader->strings['skin_update_successful'] = __( '%s updated successfully.' );
48
-		$this->upgrader->strings['skin_upgrade_end']       = __( 'All updates have been completed.' );
49
-	}
50
-
51
-	/**
52
-	 * @since 5.9.0 Renamed `$string` (a PHP reserved keyword) to `$feedback` for PHP 8 named parameter support.
53
-	 *
54
-	 * @param string $feedback Message data.
55
-	 * @param mixed  ...$args  Optional text replacements.
56
-	 */
57
-	public function feedback( $feedback, ...$args ) {
58
-		if ( isset( $this->upgrader->strings[ $feedback ] ) ) {
59
-			$feedback = $this->upgrader->strings[ $feedback ];
60
-		}
61
-
62
-		if ( strpos( $feedback, '%' ) !== false ) {
63
-			if ( $args ) {
64
-				$args     = array_map( 'strip_tags', $args );
65
-				$args     = array_map( 'esc_html', $args );
66
-				$feedback = vsprintf( $feedback, $args );
67
-			}
68
-		}
69
-		if ( empty( $feedback ) ) {
70
-			return;
71
-		}
72
-		if ( $this->in_loop ) {
73
-			echo "$feedback<br />\n";
74
-		} else {
75
-			echo "<p>$feedback</p>\n";
76
-		}
77
-	}
78
-
79
-	/**
80
-	 */
81
-	public function header() {
82
-		// Nothing, This will be displayed within a iframe.
83
-	}
84
-
85
-	/**
86
-	 */
87
-	public function footer() {
88
-		// Nothing, This will be displayed within a iframe.
89
-	}
90
-
91
-	/**
92
-	 * @since 5.9.0 Renamed `$error` to `$errors` for PHP 8 named parameter support.
93
-	 *
94
-	 * @param string|WP_Error $errors Errors.
95
-	 */
96
-	public function error( $errors ) {
97
-		if ( is_string( $errors ) && isset( $this->upgrader->strings[ $errors ] ) ) {
98
-			$this->error = $this->upgrader->strings[ $errors ];
99
-		}
100
-
101
-		if ( is_wp_error( $errors ) ) {
102
-			$messages = array();
103
-			foreach ( $errors->get_error_messages() as $emessage ) {
104
-				if ( $errors->get_error_data() && is_string( $errors->get_error_data() ) ) {
105
-					$messages[] = $emessage . ' ' . esc_html( strip_tags( $errors->get_error_data() ) );
106
-				} else {
107
-					$messages[] = $emessage;
108
-				}
109
-			}
110
-			$this->error = implode( ', ', $messages );
111
-		}
112
-		echo '<script type="text/javascript">jQuery(\'.waiting-' . esc_js( $this->upgrader->update_current ) . '\').hide();</script>';
113
-	}
114
-
115
-	/**
116
-	 */
117
-	public function bulk_header() {
118
-		$this->feedback( 'skin_upgrade_start' );
119
-	}
120
-
121
-	/**
122
-	 */
123
-	public function bulk_footer() {
124
-		$this->feedback( 'skin_upgrade_end' );
125
-	}
126
-
127
-	/**
128
-	 * @param string $title
129
-	 */
130
-	public function before( $title = '' ) {
131
-		$this->in_loop = true;
132
-		printf( '<h2>' . $this->upgrader->strings['skin_before_update_header'] . ' <span class="spinner waiting-' . $this->upgrader->update_current . '"></span></h2>', $title, $this->upgrader->update_current, $this->upgrader->update_count );
133
-		echo '<script type="text/javascript">jQuery(\'.waiting-' . esc_js( $this->upgrader->update_current ) . '\').css("display", "inline-block");</script>';
134
-		// This progress messages div gets moved via JavaScript when clicking on "Show details.".
135
-		echo '<div class="update-messages hide-if-js" id="progress-' . esc_attr( $this->upgrader->update_current ) . '"><p>';
136
-		$this->flush_output();
137
-	}
138
-
139
-	/**
140
-	 * @param string $title
141
-	 */
142
-	public function after( $title = '' ) {
143
-		echo '</p></div>';
144
-		if ( $this->error || ! $this->result ) {
145
-			if ( $this->error ) {
146
-				echo '<div class="error"><p>' . sprintf( $this->upgrader->strings['skin_update_failed_error'], $title, '<strong>' . $this->error . '</strong>' ) . '</p></div>';
147
-			} else {
148
-				echo '<div class="error"><p>' . sprintf( $this->upgrader->strings['skin_update_failed'], $title ) . '</p></div>';
149
-			}
150
-
151
-			echo '<script type="text/javascript">jQuery(\'#progress-' . esc_js( $this->upgrader->update_current ) . '\').show();</script>';
152
-		}
153
-		if ( $this->result && ! is_wp_error( $this->result ) ) {
154
-			if ( ! $this->error ) {
155
-				echo '<div class="updated js-update-details" data-update-details="progress-' . esc_attr( $this->upgrader->update_current ) . '">' .
156
-					'<p>' . sprintf( $this->upgrader->strings['skin_update_successful'], $title ) .
157
-					' <button type="button" class="hide-if-no-js button-link js-update-details-toggle" aria-expanded="false">' . __( 'Show details.' ) . '</button>' .
158
-					'</p></div>';
159
-			}
160
-
161
-			echo '<script type="text/javascript">jQuery(\'.waiting-' . esc_js( $this->upgrader->update_current ) . '\').hide();</script>';
162
-		}
163
-
164
-		$this->reset();
165
-		$this->flush_output();
166
-	}
167
-
168
-	/**
169
-	 */
170
-	public function reset() {
171
-		$this->in_loop = false;
172
-		$this->error   = false;
173
-	}
174
-
175
-	/**
176
-	 */
177
-	public function flush_output() {
178
-		wp_ob_end_flush_all();
179
-		flush();
180
-	}
19
+    public $in_loop = false;
20
+    /**
21
+     * @var string|false
22
+     */
23
+    public $error = false;
24
+
25
+    /**
26
+     * @param array $args
27
+     */
28
+    public function __construct( $args = array() ) {
29
+        $defaults = array(
30
+            'url'   => '',
31
+            'nonce' => '',
32
+        );
33
+        $args     = wp_parse_args( $args, $defaults );
34
+
35
+        parent::__construct( $args );
36
+    }
37
+
38
+    /**
39
+     */
40
+    public function add_strings() {
41
+        $this->upgrader->strings['skin_upgrade_start'] = __( 'The update process is starting. This process may take a while on some hosts, so please be patient.' );
42
+        /* translators: 1: Title of an update, 2: Error message. */
43
+        $this->upgrader->strings['skin_update_failed_error'] = __( 'An error occurred while updating %1$s: %2$s' );
44
+        /* translators: %s: Title of an update. */
45
+        $this->upgrader->strings['skin_update_failed'] = __( 'The update of %s failed.' );
46
+        /* translators: %s: Title of an update. */
47
+        $this->upgrader->strings['skin_update_successful'] = __( '%s updated successfully.' );
48
+        $this->upgrader->strings['skin_upgrade_end']       = __( 'All updates have been completed.' );
49
+    }
50
+
51
+    /**
52
+     * @since 5.9.0 Renamed `$string` (a PHP reserved keyword) to `$feedback` for PHP 8 named parameter support.
53
+     *
54
+     * @param string $feedback Message data.
55
+     * @param mixed  ...$args  Optional text replacements.
56
+     */
57
+    public function feedback( $feedback, ...$args ) {
58
+        if ( isset( $this->upgrader->strings[ $feedback ] ) ) {
59
+            $feedback = $this->upgrader->strings[ $feedback ];
60
+        }
61
+
62
+        if ( strpos( $feedback, '%' ) !== false ) {
63
+            if ( $args ) {
64
+                $args     = array_map( 'strip_tags', $args );
65
+                $args     = array_map( 'esc_html', $args );
66
+                $feedback = vsprintf( $feedback, $args );
67
+            }
68
+        }
69
+        if ( empty( $feedback ) ) {
70
+            return;
71
+        }
72
+        if ( $this->in_loop ) {
73
+            echo "$feedback<br />\n";
74
+        } else {
75
+            echo "<p>$feedback</p>\n";
76
+        }
77
+    }
78
+
79
+    /**
80
+     */
81
+    public function header() {
82
+        // Nothing, This will be displayed within a iframe.
83
+    }
84
+
85
+    /**
86
+     */
87
+    public function footer() {
88
+        // Nothing, This will be displayed within a iframe.
89
+    }
90
+
91
+    /**
92
+     * @since 5.9.0 Renamed `$error` to `$errors` for PHP 8 named parameter support.
93
+     *
94
+     * @param string|WP_Error $errors Errors.
95
+     */
96
+    public function error( $errors ) {
97
+        if ( is_string( $errors ) && isset( $this->upgrader->strings[ $errors ] ) ) {
98
+            $this->error = $this->upgrader->strings[ $errors ];
99
+        }
100
+
101
+        if ( is_wp_error( $errors ) ) {
102
+            $messages = array();
103
+            foreach ( $errors->get_error_messages() as $emessage ) {
104
+                if ( $errors->get_error_data() && is_string( $errors->get_error_data() ) ) {
105
+                    $messages[] = $emessage . ' ' . esc_html( strip_tags( $errors->get_error_data() ) );
106
+                } else {
107
+                    $messages[] = $emessage;
108
+                }
109
+            }
110
+            $this->error = implode( ', ', $messages );
111
+        }
112
+        echo '<script type="text/javascript">jQuery(\'.waiting-' . esc_js( $this->upgrader->update_current ) . '\').hide();</script>';
113
+    }
114
+
115
+    /**
116
+     */
117
+    public function bulk_header() {
118
+        $this->feedback( 'skin_upgrade_start' );
119
+    }
120
+
121
+    /**
122
+     */
123
+    public function bulk_footer() {
124
+        $this->feedback( 'skin_upgrade_end' );
125
+    }
126
+
127
+    /**
128
+     * @param string $title
129
+     */
130
+    public function before( $title = '' ) {
131
+        $this->in_loop = true;
132
+        printf( '<h2>' . $this->upgrader->strings['skin_before_update_header'] . ' <span class="spinner waiting-' . $this->upgrader->update_current . '"></span></h2>', $title, $this->upgrader->update_current, $this->upgrader->update_count );
133
+        echo '<script type="text/javascript">jQuery(\'.waiting-' . esc_js( $this->upgrader->update_current ) . '\').css("display", "inline-block");</script>';
134
+        // This progress messages div gets moved via JavaScript when clicking on "Show details.".
135
+        echo '<div class="update-messages hide-if-js" id="progress-' . esc_attr( $this->upgrader->update_current ) . '"><p>';
136
+        $this->flush_output();
137
+    }
138
+
139
+    /**
140
+     * @param string $title
141
+     */
142
+    public function after( $title = '' ) {
143
+        echo '</p></div>';
144
+        if ( $this->error || ! $this->result ) {
145
+            if ( $this->error ) {
146
+                echo '<div class="error"><p>' . sprintf( $this->upgrader->strings['skin_update_failed_error'], $title, '<strong>' . $this->error . '</strong>' ) . '</p></div>';
147
+            } else {
148
+                echo '<div class="error"><p>' . sprintf( $this->upgrader->strings['skin_update_failed'], $title ) . '</p></div>';
149
+            }
150
+
151
+            echo '<script type="text/javascript">jQuery(\'#progress-' . esc_js( $this->upgrader->update_current ) . '\').show();</script>';
152
+        }
153
+        if ( $this->result && ! is_wp_error( $this->result ) ) {
154
+            if ( ! $this->error ) {
155
+                echo '<div class="updated js-update-details" data-update-details="progress-' . esc_attr( $this->upgrader->update_current ) . '">' .
156
+                    '<p>' . sprintf( $this->upgrader->strings['skin_update_successful'], $title ) .
157
+                    ' <button type="button" class="hide-if-no-js button-link js-update-details-toggle" aria-expanded="false">' . __( 'Show details.' ) . '</button>' .
158
+                    '</p></div>';
159
+            }
160
+
161
+            echo '<script type="text/javascript">jQuery(\'.waiting-' . esc_js( $this->upgrader->update_current ) . '\').hide();</script>';
162
+        }
163
+
164
+        $this->reset();
165
+        $this->flush_output();
166
+    }
167
+
168
+    /**
169
+     */
170
+    public function reset() {
171
+        $this->in_loop = false;
172
+        $this->error   = false;
173
+    }
174
+
175
+    /**
176
+     */
177
+    public function flush_output() {
178
+        wp_ob_end_flush_all();
179
+        flush();
180
+    }
181 181
 }
Please login to merge, or discard this patch.
Spacing   +45 added lines, -45 removed lines patch added patch discarded remove patch
@@ -25,27 +25,27 @@  discard block
 block discarded – undo
25 25
 	/**
26 26
 	 * @param array $args
27 27
 	 */
28
-	public function __construct( $args = array() ) {
28
+	public function __construct($args = array()) {
29 29
 		$defaults = array(
30 30
 			'url'   => '',
31 31
 			'nonce' => '',
32 32
 		);
33
-		$args     = wp_parse_args( $args, $defaults );
33
+		$args = wp_parse_args($args, $defaults);
34 34
 
35
-		parent::__construct( $args );
35
+		parent::__construct($args);
36 36
 	}
37 37
 
38 38
 	/**
39 39
 	 */
40 40
 	public function add_strings() {
41
-		$this->upgrader->strings['skin_upgrade_start'] = __( 'The update process is starting. This process may take a while on some hosts, so please be patient.' );
41
+		$this->upgrader->strings['skin_upgrade_start'] = __('The update process is starting. This process may take a while on some hosts, so please be patient.');
42 42
 		/* translators: 1: Title of an update, 2: Error message. */
43
-		$this->upgrader->strings['skin_update_failed_error'] = __( 'An error occurred while updating %1$s: %2$s' );
43
+		$this->upgrader->strings['skin_update_failed_error'] = __('An error occurred while updating %1$s: %2$s');
44 44
 		/* translators: %s: Title of an update. */
45
-		$this->upgrader->strings['skin_update_failed'] = __( 'The update of %s failed.' );
45
+		$this->upgrader->strings['skin_update_failed'] = __('The update of %s failed.');
46 46
 		/* translators: %s: Title of an update. */
47
-		$this->upgrader->strings['skin_update_successful'] = __( '%s updated successfully.' );
48
-		$this->upgrader->strings['skin_upgrade_end']       = __( 'All updates have been completed.' );
47
+		$this->upgrader->strings['skin_update_successful'] = __('%s updated successfully.');
48
+		$this->upgrader->strings['skin_upgrade_end']       = __('All updates have been completed.');
49 49
 	}
50 50
 
51 51
 	/**
@@ -54,22 +54,22 @@  discard block
 block discarded – undo
54 54
 	 * @param string $feedback Message data.
55 55
 	 * @param mixed  ...$args  Optional text replacements.
56 56
 	 */
57
-	public function feedback( $feedback, ...$args ) {
58
-		if ( isset( $this->upgrader->strings[ $feedback ] ) ) {
59
-			$feedback = $this->upgrader->strings[ $feedback ];
57
+	public function feedback($feedback, ...$args) {
58
+		if (isset($this->upgrader->strings[$feedback])) {
59
+			$feedback = $this->upgrader->strings[$feedback];
60 60
 		}
61 61
 
62
-		if ( strpos( $feedback, '%' ) !== false ) {
63
-			if ( $args ) {
64
-				$args     = array_map( 'strip_tags', $args );
65
-				$args     = array_map( 'esc_html', $args );
66
-				$feedback = vsprintf( $feedback, $args );
62
+		if (strpos($feedback, '%') !== false) {
63
+			if ($args) {
64
+				$args     = array_map('strip_tags', $args);
65
+				$args     = array_map('esc_html', $args);
66
+				$feedback = vsprintf($feedback, $args);
67 67
 			}
68 68
 		}
69
-		if ( empty( $feedback ) ) {
69
+		if (empty($feedback)) {
70 70
 			return;
71 71
 		}
72
-		if ( $this->in_loop ) {
72
+		if ($this->in_loop) {
73 73
 			echo "$feedback<br />\n";
74 74
 		} else {
75 75
 			echo "<p>$feedback</p>\n";
@@ -93,72 +93,72 @@  discard block
 block discarded – undo
93 93
 	 *
94 94
 	 * @param string|WP_Error $errors Errors.
95 95
 	 */
96
-	public function error( $errors ) {
97
-		if ( is_string( $errors ) && isset( $this->upgrader->strings[ $errors ] ) ) {
98
-			$this->error = $this->upgrader->strings[ $errors ];
96
+	public function error($errors) {
97
+		if (is_string($errors) && isset($this->upgrader->strings[$errors])) {
98
+			$this->error = $this->upgrader->strings[$errors];
99 99
 		}
100 100
 
101
-		if ( is_wp_error( $errors ) ) {
101
+		if (is_wp_error($errors)) {
102 102
 			$messages = array();
103
-			foreach ( $errors->get_error_messages() as $emessage ) {
104
-				if ( $errors->get_error_data() && is_string( $errors->get_error_data() ) ) {
105
-					$messages[] = $emessage . ' ' . esc_html( strip_tags( $errors->get_error_data() ) );
103
+			foreach ($errors->get_error_messages() as $emessage) {
104
+				if ($errors->get_error_data() && is_string($errors->get_error_data())) {
105
+					$messages[] = $emessage . ' ' . esc_html(strip_tags($errors->get_error_data()));
106 106
 				} else {
107 107
 					$messages[] = $emessage;
108 108
 				}
109 109
 			}
110
-			$this->error = implode( ', ', $messages );
110
+			$this->error = implode(', ', $messages);
111 111
 		}
112
-		echo '<script type="text/javascript">jQuery(\'.waiting-' . esc_js( $this->upgrader->update_current ) . '\').hide();</script>';
112
+		echo '<script type="text/javascript">jQuery(\'.waiting-' . esc_js($this->upgrader->update_current) . '\').hide();</script>';
113 113
 	}
114 114
 
115 115
 	/**
116 116
 	 */
117 117
 	public function bulk_header() {
118
-		$this->feedback( 'skin_upgrade_start' );
118
+		$this->feedback('skin_upgrade_start');
119 119
 	}
120 120
 
121 121
 	/**
122 122
 	 */
123 123
 	public function bulk_footer() {
124
-		$this->feedback( 'skin_upgrade_end' );
124
+		$this->feedback('skin_upgrade_end');
125 125
 	}
126 126
 
127 127
 	/**
128 128
 	 * @param string $title
129 129
 	 */
130
-	public function before( $title = '' ) {
130
+	public function before($title = '') {
131 131
 		$this->in_loop = true;
132
-		printf( '<h2>' . $this->upgrader->strings['skin_before_update_header'] . ' <span class="spinner waiting-' . $this->upgrader->update_current . '"></span></h2>', $title, $this->upgrader->update_current, $this->upgrader->update_count );
133
-		echo '<script type="text/javascript">jQuery(\'.waiting-' . esc_js( $this->upgrader->update_current ) . '\').css("display", "inline-block");</script>';
132
+		printf('<h2>' . $this->upgrader->strings['skin_before_update_header'] . ' <span class="spinner waiting-' . $this->upgrader->update_current . '"></span></h2>', $title, $this->upgrader->update_current, $this->upgrader->update_count);
133
+		echo '<script type="text/javascript">jQuery(\'.waiting-' . esc_js($this->upgrader->update_current) . '\').css("display", "inline-block");</script>';
134 134
 		// This progress messages div gets moved via JavaScript when clicking on "Show details.".
135
-		echo '<div class="update-messages hide-if-js" id="progress-' . esc_attr( $this->upgrader->update_current ) . '"><p>';
135
+		echo '<div class="update-messages hide-if-js" id="progress-' . esc_attr($this->upgrader->update_current) . '"><p>';
136 136
 		$this->flush_output();
137 137
 	}
138 138
 
139 139
 	/**
140 140
 	 * @param string $title
141 141
 	 */
142
-	public function after( $title = '' ) {
142
+	public function after($title = '') {
143 143
 		echo '</p></div>';
144
-		if ( $this->error || ! $this->result ) {
145
-			if ( $this->error ) {
146
-				echo '<div class="error"><p>' . sprintf( $this->upgrader->strings['skin_update_failed_error'], $title, '<strong>' . $this->error . '</strong>' ) . '</p></div>';
144
+		if ($this->error || !$this->result) {
145
+			if ($this->error) {
146
+				echo '<div class="error"><p>' . sprintf($this->upgrader->strings['skin_update_failed_error'], $title, '<strong>' . $this->error . '</strong>') . '</p></div>';
147 147
 			} else {
148
-				echo '<div class="error"><p>' . sprintf( $this->upgrader->strings['skin_update_failed'], $title ) . '</p></div>';
148
+				echo '<div class="error"><p>' . sprintf($this->upgrader->strings['skin_update_failed'], $title) . '</p></div>';
149 149
 			}
150 150
 
151
-			echo '<script type="text/javascript">jQuery(\'#progress-' . esc_js( $this->upgrader->update_current ) . '\').show();</script>';
151
+			echo '<script type="text/javascript">jQuery(\'#progress-' . esc_js($this->upgrader->update_current) . '\').show();</script>';
152 152
 		}
153
-		if ( $this->result && ! is_wp_error( $this->result ) ) {
154
-			if ( ! $this->error ) {
155
-				echo '<div class="updated js-update-details" data-update-details="progress-' . esc_attr( $this->upgrader->update_current ) . '">' .
156
-					'<p>' . sprintf( $this->upgrader->strings['skin_update_successful'], $title ) .
157
-					' <button type="button" class="hide-if-no-js button-link js-update-details-toggle" aria-expanded="false">' . __( 'Show details.' ) . '</button>' .
153
+		if ($this->result && !is_wp_error($this->result)) {
154
+			if (!$this->error) {
155
+				echo '<div class="updated js-update-details" data-update-details="progress-' . esc_attr($this->upgrader->update_current) . '">' .
156
+					'<p>' . sprintf($this->upgrader->strings['skin_update_successful'], $title) .
157
+					' <button type="button" class="hide-if-no-js button-link js-update-details-toggle" aria-expanded="false">' . __('Show details.') . '</button>' .
158 158
 					'</p></div>';
159 159
 			}
160 160
 
161
-			echo '<script type="text/javascript">jQuery(\'.waiting-' . esc_js( $this->upgrader->update_current ) . '\').hide();</script>';
161
+			echo '<script type="text/javascript">jQuery(\'.waiting-' . esc_js($this->upgrader->update_current) . '\').hide();</script>';
162 162
 		}
163 163
 
164 164
 		$this->reset();
Please login to merge, or discard this patch.
brighty/wp-admin/includes/class-plugin-installer-skin.php 2 patches
Indentation   +330 added lines, -330 removed lines patch added patch discarded remove patch
@@ -16,334 +16,334 @@
 block discarded – undo
16 16
  * @see WP_Upgrader_Skin
17 17
  */
18 18
 class Plugin_Installer_Skin extends WP_Upgrader_Skin {
19
-	public $api;
20
-	public $type;
21
-	public $url;
22
-	public $overwrite;
23
-
24
-	private $is_downgrading = false;
25
-
26
-	/**
27
-	 * @param array $args
28
-	 */
29
-	public function __construct( $args = array() ) {
30
-		$defaults = array(
31
-			'type'      => 'web',
32
-			'url'       => '',
33
-			'plugin'    => '',
34
-			'nonce'     => '',
35
-			'title'     => '',
36
-			'overwrite' => '',
37
-		);
38
-		$args     = wp_parse_args( $args, $defaults );
39
-
40
-		$this->type      = $args['type'];
41
-		$this->url       = $args['url'];
42
-		$this->api       = isset( $args['api'] ) ? $args['api'] : array();
43
-		$this->overwrite = $args['overwrite'];
44
-
45
-		parent::__construct( $args );
46
-	}
47
-
48
-	/**
49
-	 * Action to perform before installing a plugin.
50
-	 *
51
-	 * @since 2.8.0
52
-	 */
53
-	public function before() {
54
-		if ( ! empty( $this->api ) ) {
55
-			$this->upgrader->strings['process_success'] = sprintf(
56
-				$this->upgrader->strings['process_success_specific'],
57
-				$this->api->name,
58
-				$this->api->version
59
-			);
60
-		}
61
-	}
62
-
63
-	/**
64
-	 * Hides the `process_failed` error when updating a plugin by uploading a zip file.
65
-	 *
66
-	 * @since 5.5.0
67
-	 *
68
-	 * @param WP_Error $wp_error WP_Error object.
69
-	 * @return bool
70
-	 */
71
-	public function hide_process_failed( $wp_error ) {
72
-		if (
73
-			'upload' === $this->type &&
74
-			'' === $this->overwrite &&
75
-			$wp_error->get_error_code() === 'folder_exists'
76
-		) {
77
-			return true;
78
-		}
79
-
80
-		return false;
81
-	}
82
-
83
-	/**
84
-	 * Action to perform following a plugin install.
85
-	 *
86
-	 * @since 2.8.0
87
-	 */
88
-	public function after() {
89
-		// Check if the plugin can be overwritten and output the HTML.
90
-		if ( $this->do_overwrite() ) {
91
-			return;
92
-		}
93
-
94
-		$plugin_file = $this->upgrader->plugin_info();
95
-
96
-		$install_actions = array();
97
-
98
-		$from = isset( $_GET['from'] ) ? wp_unslash( $_GET['from'] ) : 'plugins';
99
-
100
-		if ( 'import' === $from ) {
101
-			$install_actions['activate_plugin'] = sprintf(
102
-				'<a class="button button-primary" href="%s" target="_parent">%s</a>',
103
-				wp_nonce_url( 'plugins.php?action=activate&amp;from=import&amp;plugin=' . urlencode( $plugin_file ), 'activate-plugin_' . $plugin_file ),
104
-				__( 'Activate Plugin &amp; Run Importer' )
105
-			);
106
-		} elseif ( 'press-this' === $from ) {
107
-			$install_actions['activate_plugin'] = sprintf(
108
-				'<a class="button button-primary" href="%s" target="_parent">%s</a>',
109
-				wp_nonce_url( 'plugins.php?action=activate&amp;from=press-this&amp;plugin=' . urlencode( $plugin_file ), 'activate-plugin_' . $plugin_file ),
110
-				__( 'Activate Plugin &amp; Go to Press This' )
111
-			);
112
-		} else {
113
-			$install_actions['activate_plugin'] = sprintf(
114
-				'<a class="button button-primary" href="%s" target="_parent">%s</a>',
115
-				wp_nonce_url( 'plugins.php?action=activate&amp;plugin=' . urlencode( $plugin_file ), 'activate-plugin_' . $plugin_file ),
116
-				__( 'Activate Plugin' )
117
-			);
118
-		}
119
-
120
-		if ( is_multisite() && current_user_can( 'manage_network_plugins' ) ) {
121
-			$install_actions['network_activate'] = sprintf(
122
-				'<a class="button button-primary" href="%s" target="_parent">%s</a>',
123
-				wp_nonce_url( 'plugins.php?action=activate&amp;networkwide=1&amp;plugin=' . urlencode( $plugin_file ), 'activate-plugin_' . $plugin_file ),
124
-				__( 'Network Activate' )
125
-			);
126
-			unset( $install_actions['activate_plugin'] );
127
-		}
128
-
129
-		if ( 'import' === $from ) {
130
-			$install_actions['importers_page'] = sprintf(
131
-				'<a href="%s" target="_parent">%s</a>',
132
-				admin_url( 'import.php' ),
133
-				__( 'Go to Importers' )
134
-			);
135
-		} elseif ( 'web' === $this->type ) {
136
-			$install_actions['plugins_page'] = sprintf(
137
-				'<a href="%s" target="_parent">%s</a>',
138
-				self_admin_url( 'plugin-install.php' ),
139
-				__( 'Go to Plugin Installer' )
140
-			);
141
-		} elseif ( 'upload' === $this->type && 'plugins' === $from ) {
142
-			$install_actions['plugins_page'] = sprintf(
143
-				'<a href="%s">%s</a>',
144
-				self_admin_url( 'plugin-install.php' ),
145
-				__( 'Go to Plugin Installer' )
146
-			);
147
-		} else {
148
-			$install_actions['plugins_page'] = sprintf(
149
-				'<a href="%s" target="_parent">%s</a>',
150
-				self_admin_url( 'plugins.php' ),
151
-				__( 'Go to Plugins page' )
152
-			);
153
-		}
154
-
155
-		if ( ! $this->result || is_wp_error( $this->result ) ) {
156
-			unset( $install_actions['activate_plugin'], $install_actions['network_activate'] );
157
-		} elseif ( ! current_user_can( 'activate_plugin', $plugin_file ) || is_plugin_active( $plugin_file ) ) {
158
-			unset( $install_actions['activate_plugin'] );
159
-		}
160
-
161
-		/**
162
-		 * Filters the list of action links available following a single plugin installation.
163
-		 *
164
-		 * @since 2.7.0
165
-		 *
166
-		 * @param string[] $install_actions Array of plugin action links.
167
-		 * @param object   $api             Object containing WordPress.org API plugin data. Empty
168
-		 *                                  for non-API installs, such as when a plugin is installed
169
-		 *                                  via upload.
170
-		 * @param string   $plugin_file     Path to the plugin file relative to the plugins directory.
171
-		 */
172
-		$install_actions = apply_filters( 'install_plugin_complete_actions', $install_actions, $this->api, $plugin_file );
173
-
174
-		if ( ! empty( $install_actions ) ) {
175
-			$this->feedback( implode( ' ', (array) $install_actions ) );
176
-		}
177
-	}
178
-
179
-	/**
180
-	 * Check if the plugin can be overwritten and output the HTML for overwriting a plugin on upload.
181
-	 *
182
-	 * @since 5.5.0
183
-	 *
184
-	 * @return bool Whether the plugin can be overwritten and HTML was outputted.
185
-	 */
186
-	private function do_overwrite() {
187
-		if ( 'upload' !== $this->type || ! is_wp_error( $this->result ) || 'folder_exists' !== $this->result->get_error_code() ) {
188
-			return false;
189
-		}
190
-
191
-		$folder = $this->result->get_error_data( 'folder_exists' );
192
-		$folder = ltrim( substr( $folder, strlen( WP_PLUGIN_DIR ) ), '/' );
193
-
194
-		$current_plugin_data = false;
195
-		$all_plugins         = get_plugins();
196
-
197
-		foreach ( $all_plugins as $plugin => $plugin_data ) {
198
-			if ( strrpos( $plugin, $folder ) !== 0 ) {
199
-				continue;
200
-			}
201
-
202
-			$current_plugin_data = $plugin_data;
203
-		}
204
-
205
-		$new_plugin_data = $this->upgrader->new_plugin_data;
206
-
207
-		if ( ! $current_plugin_data || ! $new_plugin_data ) {
208
-			return false;
209
-		}
210
-
211
-		echo '<h2 class="update-from-upload-heading">' . esc_html__( 'This plugin is already installed.' ) . '</h2>';
212
-
213
-		$this->is_downgrading = version_compare( $current_plugin_data['Version'], $new_plugin_data['Version'], '>' );
214
-
215
-		$rows = array(
216
-			'Name'        => __( 'Plugin name' ),
217
-			'Version'     => __( 'Version' ),
218
-			'Author'      => __( 'Author' ),
219
-			'RequiresWP'  => __( 'Required WordPress version' ),
220
-			'RequiresPHP' => __( 'Required PHP version' ),
221
-		);
222
-
223
-		$table  = '<table class="update-from-upload-comparison"><tbody>';
224
-		$table .= '<tr><th></th><th>' . esc_html_x( 'Current', 'plugin' ) . '</th>';
225
-		$table .= '<th>' . esc_html_x( 'Uploaded', 'plugin' ) . '</th></tr>';
226
-
227
-		$is_same_plugin = true; // Let's consider only these rows.
228
-
229
-		foreach ( $rows as $field => $label ) {
230
-			$old_value = ! empty( $current_plugin_data[ $field ] ) ? (string) $current_plugin_data[ $field ] : '-';
231
-			$new_value = ! empty( $new_plugin_data[ $field ] ) ? (string) $new_plugin_data[ $field ] : '-';
232
-
233
-			$is_same_plugin = $is_same_plugin && ( $old_value === $new_value );
234
-
235
-			$diff_field   = ( 'Version' !== $field && $new_value !== $old_value );
236
-			$diff_version = ( 'Version' === $field && $this->is_downgrading );
237
-
238
-			$table .= '<tr><td class="name-label">' . $label . '</td><td>' . wp_strip_all_tags( $old_value ) . '</td>';
239
-			$table .= ( $diff_field || $diff_version ) ? '<td class="warning">' : '<td>';
240
-			$table .= wp_strip_all_tags( $new_value ) . '</td></tr>';
241
-		}
242
-
243
-		$table .= '</tbody></table>';
244
-
245
-		/**
246
-		 * Filters the compare table output for overwriting a plugin package on upload.
247
-		 *
248
-		 * @since 5.5.0
249
-		 *
250
-		 * @param string $table               The output table with Name, Version, Author, RequiresWP, and RequiresPHP info.
251
-		 * @param array  $current_plugin_data Array with current plugin data.
252
-		 * @param array  $new_plugin_data     Array with uploaded plugin data.
253
-		 */
254
-		echo apply_filters( 'install_plugin_overwrite_comparison', $table, $current_plugin_data, $new_plugin_data );
255
-
256
-		$install_actions = array();
257
-		$can_update      = true;
258
-
259
-		$blocked_message  = '<p>' . esc_html__( 'The plugin cannot be updated due to the following:' ) . '</p>';
260
-		$blocked_message .= '<ul class="ul-disc">';
261
-
262
-		$requires_php = isset( $new_plugin_data['RequiresPHP'] ) ? $new_plugin_data['RequiresPHP'] : null;
263
-		$requires_wp  = isset( $new_plugin_data['RequiresWP'] ) ? $new_plugin_data['RequiresWP'] : null;
264
-
265
-		if ( ! is_php_version_compatible( $requires_php ) ) {
266
-			$error = sprintf(
267
-				/* translators: 1: Current PHP version, 2: Version required by the uploaded plugin. */
268
-				__( 'The PHP version on your server is %1$s, however the uploaded plugin requires %2$s.' ),
269
-				phpversion(),
270
-				$requires_php
271
-			);
272
-
273
-			$blocked_message .= '<li>' . esc_html( $error ) . '</li>';
274
-			$can_update       = false;
275
-		}
276
-
277
-		if ( ! is_wp_version_compatible( $requires_wp ) ) {
278
-			$error = sprintf(
279
-				/* translators: 1: Current WordPress version, 2: Version required by the uploaded plugin. */
280
-				__( 'Your WordPress version is %1$s, however the uploaded plugin requires %2$s.' ),
281
-				get_bloginfo( 'version' ),
282
-				$requires_wp
283
-			);
284
-
285
-			$blocked_message .= '<li>' . esc_html( $error ) . '</li>';
286
-			$can_update       = false;
287
-		}
288
-
289
-		$blocked_message .= '</ul>';
290
-
291
-		if ( $can_update ) {
292
-			if ( $this->is_downgrading ) {
293
-				$warning = sprintf(
294
-					/* translators: %s: Documentation URL. */
295
-					__( 'You are uploading an older version of a current plugin. You can continue to install the older version, but be sure to <a href="%s">back up your database and files</a> first.' ),
296
-					__( 'https://wordpress.org/support/article/wordpress-backups/' )
297
-				);
298
-			} else {
299
-				$warning = sprintf(
300
-					/* translators: %s: Documentation URL. */
301
-					__( 'You are updating a plugin. Be sure to <a href="%s">back up your database and files</a> first.' ),
302
-					__( 'https://wordpress.org/support/article/wordpress-backups/' )
303
-				);
304
-			}
305
-
306
-			echo '<p class="update-from-upload-notice">' . $warning . '</p>';
307
-
308
-			$overwrite = $this->is_downgrading ? 'downgrade-plugin' : 'update-plugin';
309
-
310
-			$install_actions['overwrite_plugin'] = sprintf(
311
-				'<a class="button button-primary update-from-upload-overwrite" href="%s" target="_parent">%s</a>',
312
-				wp_nonce_url( add_query_arg( 'overwrite', $overwrite, $this->url ), 'plugin-upload' ),
313
-				_x( 'Replace current with uploaded', 'plugin' )
314
-			);
315
-		} else {
316
-			echo $blocked_message;
317
-		}
318
-
319
-		$cancel_url = add_query_arg( 'action', 'upload-plugin-cancel-overwrite', $this->url );
320
-
321
-		$install_actions['plugins_page'] = sprintf(
322
-			'<a class="button" href="%s">%s</a>',
323
-			wp_nonce_url( $cancel_url, 'plugin-upload-cancel-overwrite' ),
324
-			__( 'Cancel and go back' )
325
-		);
326
-
327
-		/**
328
-		 * Filters the list of action links available following a single plugin installation failure
329
-		 * when overwriting is allowed.
330
-		 *
331
-		 * @since 5.5.0
332
-		 *
333
-		 * @param string[] $install_actions Array of plugin action links.
334
-		 * @param object   $api             Object containing WordPress.org API plugin data.
335
-		 * @param array    $new_plugin_data Array with uploaded plugin data.
336
-		 */
337
-		$install_actions = apply_filters( 'install_plugin_overwrite_actions', $install_actions, $this->api, $new_plugin_data );
338
-
339
-		if ( ! empty( $install_actions ) ) {
340
-			printf(
341
-				'<p class="update-from-upload-expired hidden">%s</p>',
342
-				__( 'The uploaded file has expired. Please go back and upload it again.' )
343
-			);
344
-			echo '<p class="update-from-upload-actions">' . implode( ' ', (array) $install_actions ) . '</p>';
345
-		}
346
-
347
-		return true;
348
-	}
19
+    public $api;
20
+    public $type;
21
+    public $url;
22
+    public $overwrite;
23
+
24
+    private $is_downgrading = false;
25
+
26
+    /**
27
+     * @param array $args
28
+     */
29
+    public function __construct( $args = array() ) {
30
+        $defaults = array(
31
+            'type'      => 'web',
32
+            'url'       => '',
33
+            'plugin'    => '',
34
+            'nonce'     => '',
35
+            'title'     => '',
36
+            'overwrite' => '',
37
+        );
38
+        $args     = wp_parse_args( $args, $defaults );
39
+
40
+        $this->type      = $args['type'];
41
+        $this->url       = $args['url'];
42
+        $this->api       = isset( $args['api'] ) ? $args['api'] : array();
43
+        $this->overwrite = $args['overwrite'];
44
+
45
+        parent::__construct( $args );
46
+    }
47
+
48
+    /**
49
+     * Action to perform before installing a plugin.
50
+     *
51
+     * @since 2.8.0
52
+     */
53
+    public function before() {
54
+        if ( ! empty( $this->api ) ) {
55
+            $this->upgrader->strings['process_success'] = sprintf(
56
+                $this->upgrader->strings['process_success_specific'],
57
+                $this->api->name,
58
+                $this->api->version
59
+            );
60
+        }
61
+    }
62
+
63
+    /**
64
+     * Hides the `process_failed` error when updating a plugin by uploading a zip file.
65
+     *
66
+     * @since 5.5.0
67
+     *
68
+     * @param WP_Error $wp_error WP_Error object.
69
+     * @return bool
70
+     */
71
+    public function hide_process_failed( $wp_error ) {
72
+        if (
73
+            'upload' === $this->type &&
74
+            '' === $this->overwrite &&
75
+            $wp_error->get_error_code() === 'folder_exists'
76
+        ) {
77
+            return true;
78
+        }
79
+
80
+        return false;
81
+    }
82
+
83
+    /**
84
+     * Action to perform following a plugin install.
85
+     *
86
+     * @since 2.8.0
87
+     */
88
+    public function after() {
89
+        // Check if the plugin can be overwritten and output the HTML.
90
+        if ( $this->do_overwrite() ) {
91
+            return;
92
+        }
93
+
94
+        $plugin_file = $this->upgrader->plugin_info();
95
+
96
+        $install_actions = array();
97
+
98
+        $from = isset( $_GET['from'] ) ? wp_unslash( $_GET['from'] ) : 'plugins';
99
+
100
+        if ( 'import' === $from ) {
101
+            $install_actions['activate_plugin'] = sprintf(
102
+                '<a class="button button-primary" href="%s" target="_parent">%s</a>',
103
+                wp_nonce_url( 'plugins.php?action=activate&amp;from=import&amp;plugin=' . urlencode( $plugin_file ), 'activate-plugin_' . $plugin_file ),
104
+                __( 'Activate Plugin &amp; Run Importer' )
105
+            );
106
+        } elseif ( 'press-this' === $from ) {
107
+            $install_actions['activate_plugin'] = sprintf(
108
+                '<a class="button button-primary" href="%s" target="_parent">%s</a>',
109
+                wp_nonce_url( 'plugins.php?action=activate&amp;from=press-this&amp;plugin=' . urlencode( $plugin_file ), 'activate-plugin_' . $plugin_file ),
110
+                __( 'Activate Plugin &amp; Go to Press This' )
111
+            );
112
+        } else {
113
+            $install_actions['activate_plugin'] = sprintf(
114
+                '<a class="button button-primary" href="%s" target="_parent">%s</a>',
115
+                wp_nonce_url( 'plugins.php?action=activate&amp;plugin=' . urlencode( $plugin_file ), 'activate-plugin_' . $plugin_file ),
116
+                __( 'Activate Plugin' )
117
+            );
118
+        }
119
+
120
+        if ( is_multisite() && current_user_can( 'manage_network_plugins' ) ) {
121
+            $install_actions['network_activate'] = sprintf(
122
+                '<a class="button button-primary" href="%s" target="_parent">%s</a>',
123
+                wp_nonce_url( 'plugins.php?action=activate&amp;networkwide=1&amp;plugin=' . urlencode( $plugin_file ), 'activate-plugin_' . $plugin_file ),
124
+                __( 'Network Activate' )
125
+            );
126
+            unset( $install_actions['activate_plugin'] );
127
+        }
128
+
129
+        if ( 'import' === $from ) {
130
+            $install_actions['importers_page'] = sprintf(
131
+                '<a href="%s" target="_parent">%s</a>',
132
+                admin_url( 'import.php' ),
133
+                __( 'Go to Importers' )
134
+            );
135
+        } elseif ( 'web' === $this->type ) {
136
+            $install_actions['plugins_page'] = sprintf(
137
+                '<a href="%s" target="_parent">%s</a>',
138
+                self_admin_url( 'plugin-install.php' ),
139
+                __( 'Go to Plugin Installer' )
140
+            );
141
+        } elseif ( 'upload' === $this->type && 'plugins' === $from ) {
142
+            $install_actions['plugins_page'] = sprintf(
143
+                '<a href="%s">%s</a>',
144
+                self_admin_url( 'plugin-install.php' ),
145
+                __( 'Go to Plugin Installer' )
146
+            );
147
+        } else {
148
+            $install_actions['plugins_page'] = sprintf(
149
+                '<a href="%s" target="_parent">%s</a>',
150
+                self_admin_url( 'plugins.php' ),
151
+                __( 'Go to Plugins page' )
152
+            );
153
+        }
154
+
155
+        if ( ! $this->result || is_wp_error( $this->result ) ) {
156
+            unset( $install_actions['activate_plugin'], $install_actions['network_activate'] );
157
+        } elseif ( ! current_user_can( 'activate_plugin', $plugin_file ) || is_plugin_active( $plugin_file ) ) {
158
+            unset( $install_actions['activate_plugin'] );
159
+        }
160
+
161
+        /**
162
+         * Filters the list of action links available following a single plugin installation.
163
+         *
164
+         * @since 2.7.0
165
+         *
166
+         * @param string[] $install_actions Array of plugin action links.
167
+         * @param object   $api             Object containing WordPress.org API plugin data. Empty
168
+         *                                  for non-API installs, such as when a plugin is installed
169
+         *                                  via upload.
170
+         * @param string   $plugin_file     Path to the plugin file relative to the plugins directory.
171
+         */
172
+        $install_actions = apply_filters( 'install_plugin_complete_actions', $install_actions, $this->api, $plugin_file );
173
+
174
+        if ( ! empty( $install_actions ) ) {
175
+            $this->feedback( implode( ' ', (array) $install_actions ) );
176
+        }
177
+    }
178
+
179
+    /**
180
+     * Check if the plugin can be overwritten and output the HTML for overwriting a plugin on upload.
181
+     *
182
+     * @since 5.5.0
183
+     *
184
+     * @return bool Whether the plugin can be overwritten and HTML was outputted.
185
+     */
186
+    private function do_overwrite() {
187
+        if ( 'upload' !== $this->type || ! is_wp_error( $this->result ) || 'folder_exists' !== $this->result->get_error_code() ) {
188
+            return false;
189
+        }
190
+
191
+        $folder = $this->result->get_error_data( 'folder_exists' );
192
+        $folder = ltrim( substr( $folder, strlen( WP_PLUGIN_DIR ) ), '/' );
193
+
194
+        $current_plugin_data = false;
195
+        $all_plugins         = get_plugins();
196
+
197
+        foreach ( $all_plugins as $plugin => $plugin_data ) {
198
+            if ( strrpos( $plugin, $folder ) !== 0 ) {
199
+                continue;
200
+            }
201
+
202
+            $current_plugin_data = $plugin_data;
203
+        }
204
+
205
+        $new_plugin_data = $this->upgrader->new_plugin_data;
206
+
207
+        if ( ! $current_plugin_data || ! $new_plugin_data ) {
208
+            return false;
209
+        }
210
+
211
+        echo '<h2 class="update-from-upload-heading">' . esc_html__( 'This plugin is already installed.' ) . '</h2>';
212
+
213
+        $this->is_downgrading = version_compare( $current_plugin_data['Version'], $new_plugin_data['Version'], '>' );
214
+
215
+        $rows = array(
216
+            'Name'        => __( 'Plugin name' ),
217
+            'Version'     => __( 'Version' ),
218
+            'Author'      => __( 'Author' ),
219
+            'RequiresWP'  => __( 'Required WordPress version' ),
220
+            'RequiresPHP' => __( 'Required PHP version' ),
221
+        );
222
+
223
+        $table  = '<table class="update-from-upload-comparison"><tbody>';
224
+        $table .= '<tr><th></th><th>' . esc_html_x( 'Current', 'plugin' ) . '</th>';
225
+        $table .= '<th>' . esc_html_x( 'Uploaded', 'plugin' ) . '</th></tr>';
226
+
227
+        $is_same_plugin = true; // Let's consider only these rows.
228
+
229
+        foreach ( $rows as $field => $label ) {
230
+            $old_value = ! empty( $current_plugin_data[ $field ] ) ? (string) $current_plugin_data[ $field ] : '-';
231
+            $new_value = ! empty( $new_plugin_data[ $field ] ) ? (string) $new_plugin_data[ $field ] : '-';
232
+
233
+            $is_same_plugin = $is_same_plugin && ( $old_value === $new_value );
234
+
235
+            $diff_field   = ( 'Version' !== $field && $new_value !== $old_value );
236
+            $diff_version = ( 'Version' === $field && $this->is_downgrading );
237
+
238
+            $table .= '<tr><td class="name-label">' . $label . '</td><td>' . wp_strip_all_tags( $old_value ) . '</td>';
239
+            $table .= ( $diff_field || $diff_version ) ? '<td class="warning">' : '<td>';
240
+            $table .= wp_strip_all_tags( $new_value ) . '</td></tr>';
241
+        }
242
+
243
+        $table .= '</tbody></table>';
244
+
245
+        /**
246
+         * Filters the compare table output for overwriting a plugin package on upload.
247
+         *
248
+         * @since 5.5.0
249
+         *
250
+         * @param string $table               The output table with Name, Version, Author, RequiresWP, and RequiresPHP info.
251
+         * @param array  $current_plugin_data Array with current plugin data.
252
+         * @param array  $new_plugin_data     Array with uploaded plugin data.
253
+         */
254
+        echo apply_filters( 'install_plugin_overwrite_comparison', $table, $current_plugin_data, $new_plugin_data );
255
+
256
+        $install_actions = array();
257
+        $can_update      = true;
258
+
259
+        $blocked_message  = '<p>' . esc_html__( 'The plugin cannot be updated due to the following:' ) . '</p>';
260
+        $blocked_message .= '<ul class="ul-disc">';
261
+
262
+        $requires_php = isset( $new_plugin_data['RequiresPHP'] ) ? $new_plugin_data['RequiresPHP'] : null;
263
+        $requires_wp  = isset( $new_plugin_data['RequiresWP'] ) ? $new_plugin_data['RequiresWP'] : null;
264
+
265
+        if ( ! is_php_version_compatible( $requires_php ) ) {
266
+            $error = sprintf(
267
+                /* translators: 1: Current PHP version, 2: Version required by the uploaded plugin. */
268
+                __( 'The PHP version on your server is %1$s, however the uploaded plugin requires %2$s.' ),
269
+                phpversion(),
270
+                $requires_php
271
+            );
272
+
273
+            $blocked_message .= '<li>' . esc_html( $error ) . '</li>';
274
+            $can_update       = false;
275
+        }
276
+
277
+        if ( ! is_wp_version_compatible( $requires_wp ) ) {
278
+            $error = sprintf(
279
+                /* translators: 1: Current WordPress version, 2: Version required by the uploaded plugin. */
280
+                __( 'Your WordPress version is %1$s, however the uploaded plugin requires %2$s.' ),
281
+                get_bloginfo( 'version' ),
282
+                $requires_wp
283
+            );
284
+
285
+            $blocked_message .= '<li>' . esc_html( $error ) . '</li>';
286
+            $can_update       = false;
287
+        }
288
+
289
+        $blocked_message .= '</ul>';
290
+
291
+        if ( $can_update ) {
292
+            if ( $this->is_downgrading ) {
293
+                $warning = sprintf(
294
+                    /* translators: %s: Documentation URL. */
295
+                    __( 'You are uploading an older version of a current plugin. You can continue to install the older version, but be sure to <a href="%s">back up your database and files</a> first.' ),
296
+                    __( 'https://wordpress.org/support/article/wordpress-backups/' )
297
+                );
298
+            } else {
299
+                $warning = sprintf(
300
+                    /* translators: %s: Documentation URL. */
301
+                    __( 'You are updating a plugin. Be sure to <a href="%s">back up your database and files</a> first.' ),
302
+                    __( 'https://wordpress.org/support/article/wordpress-backups/' )
303
+                );
304
+            }
305
+
306
+            echo '<p class="update-from-upload-notice">' . $warning . '</p>';
307
+
308
+            $overwrite = $this->is_downgrading ? 'downgrade-plugin' : 'update-plugin';
309
+
310
+            $install_actions['overwrite_plugin'] = sprintf(
311
+                '<a class="button button-primary update-from-upload-overwrite" href="%s" target="_parent">%s</a>',
312
+                wp_nonce_url( add_query_arg( 'overwrite', $overwrite, $this->url ), 'plugin-upload' ),
313
+                _x( 'Replace current with uploaded', 'plugin' )
314
+            );
315
+        } else {
316
+            echo $blocked_message;
317
+        }
318
+
319
+        $cancel_url = add_query_arg( 'action', 'upload-plugin-cancel-overwrite', $this->url );
320
+
321
+        $install_actions['plugins_page'] = sprintf(
322
+            '<a class="button" href="%s">%s</a>',
323
+            wp_nonce_url( $cancel_url, 'plugin-upload-cancel-overwrite' ),
324
+            __( 'Cancel and go back' )
325
+        );
326
+
327
+        /**
328
+         * Filters the list of action links available following a single plugin installation failure
329
+         * when overwriting is allowed.
330
+         *
331
+         * @since 5.5.0
332
+         *
333
+         * @param string[] $install_actions Array of plugin action links.
334
+         * @param object   $api             Object containing WordPress.org API plugin data.
335
+         * @param array    $new_plugin_data Array with uploaded plugin data.
336
+         */
337
+        $install_actions = apply_filters( 'install_plugin_overwrite_actions', $install_actions, $this->api, $new_plugin_data );
338
+
339
+        if ( ! empty( $install_actions ) ) {
340
+            printf(
341
+                '<p class="update-from-upload-expired hidden">%s</p>',
342
+                __( 'The uploaded file has expired. Please go back and upload it again.' )
343
+            );
344
+            echo '<p class="update-from-upload-actions">' . implode( ' ', (array) $install_actions ) . '</p>';
345
+        }
346
+
347
+        return true;
348
+    }
349 349
 }
Please login to merge, or discard this patch.
Spacing   +88 added lines, -88 removed lines patch added patch discarded remove patch
@@ -26,7 +26,7 @@  discard block
 block discarded – undo
26 26
 	/**
27 27
 	 * @param array $args
28 28
 	 */
29
-	public function __construct( $args = array() ) {
29
+	public function __construct($args = array()) {
30 30
 		$defaults = array(
31 31
 			'type'      => 'web',
32 32
 			'url'       => '',
@@ -35,14 +35,14 @@  discard block
 block discarded – undo
35 35
 			'title'     => '',
36 36
 			'overwrite' => '',
37 37
 		);
38
-		$args     = wp_parse_args( $args, $defaults );
38
+		$args = wp_parse_args($args, $defaults);
39 39
 
40 40
 		$this->type      = $args['type'];
41 41
 		$this->url       = $args['url'];
42
-		$this->api       = isset( $args['api'] ) ? $args['api'] : array();
42
+		$this->api       = isset($args['api']) ? $args['api'] : array();
43 43
 		$this->overwrite = $args['overwrite'];
44 44
 
45
-		parent::__construct( $args );
45
+		parent::__construct($args);
46 46
 	}
47 47
 
48 48
 	/**
@@ -51,7 +51,7 @@  discard block
 block discarded – undo
51 51
 	 * @since 2.8.0
52 52
 	 */
53 53
 	public function before() {
54
-		if ( ! empty( $this->api ) ) {
54
+		if (!empty($this->api)) {
55 55
 			$this->upgrader->strings['process_success'] = sprintf(
56 56
 				$this->upgrader->strings['process_success_specific'],
57 57
 				$this->api->name,
@@ -68,7 +68,7 @@  discard block
 block discarded – undo
68 68
 	 * @param WP_Error $wp_error WP_Error object.
69 69
 	 * @return bool
70 70
 	 */
71
-	public function hide_process_failed( $wp_error ) {
71
+	public function hide_process_failed($wp_error) {
72 72
 		if (
73 73
 			'upload' === $this->type &&
74 74
 			'' === $this->overwrite &&
@@ -87,7 +87,7 @@  discard block
 block discarded – undo
87 87
 	 */
88 88
 	public function after() {
89 89
 		// Check if the plugin can be overwritten and output the HTML.
90
-		if ( $this->do_overwrite() ) {
90
+		if ($this->do_overwrite()) {
91 91
 			return;
92 92
 		}
93 93
 
@@ -95,67 +95,67 @@  discard block
 block discarded – undo
95 95
 
96 96
 		$install_actions = array();
97 97
 
98
-		$from = isset( $_GET['from'] ) ? wp_unslash( $_GET['from'] ) : 'plugins';
98
+		$from = isset($_GET['from']) ? wp_unslash($_GET['from']) : 'plugins';
99 99
 
100
-		if ( 'import' === $from ) {
100
+		if ('import' === $from) {
101 101
 			$install_actions['activate_plugin'] = sprintf(
102 102
 				'<a class="button button-primary" href="%s" target="_parent">%s</a>',
103
-				wp_nonce_url( 'plugins.php?action=activate&amp;from=import&amp;plugin=' . urlencode( $plugin_file ), 'activate-plugin_' . $plugin_file ),
104
-				__( 'Activate Plugin &amp; Run Importer' )
103
+				wp_nonce_url('plugins.php?action=activate&amp;from=import&amp;plugin=' . urlencode($plugin_file), 'activate-plugin_' . $plugin_file),
104
+				__('Activate Plugin &amp; Run Importer')
105 105
 			);
106
-		} elseif ( 'press-this' === $from ) {
106
+		} elseif ('press-this' === $from) {
107 107
 			$install_actions['activate_plugin'] = sprintf(
108 108
 				'<a class="button button-primary" href="%s" target="_parent">%s</a>',
109
-				wp_nonce_url( 'plugins.php?action=activate&amp;from=press-this&amp;plugin=' . urlencode( $plugin_file ), 'activate-plugin_' . $plugin_file ),
110
-				__( 'Activate Plugin &amp; Go to Press This' )
109
+				wp_nonce_url('plugins.php?action=activate&amp;from=press-this&amp;plugin=' . urlencode($plugin_file), 'activate-plugin_' . $plugin_file),
110
+				__('Activate Plugin &amp; Go to Press This')
111 111
 			);
112 112
 		} else {
113 113
 			$install_actions['activate_plugin'] = sprintf(
114 114
 				'<a class="button button-primary" href="%s" target="_parent">%s</a>',
115
-				wp_nonce_url( 'plugins.php?action=activate&amp;plugin=' . urlencode( $plugin_file ), 'activate-plugin_' . $plugin_file ),
116
-				__( 'Activate Plugin' )
115
+				wp_nonce_url('plugins.php?action=activate&amp;plugin=' . urlencode($plugin_file), 'activate-plugin_' . $plugin_file),
116
+				__('Activate Plugin')
117 117
 			);
118 118
 		}
119 119
 
120
-		if ( is_multisite() && current_user_can( 'manage_network_plugins' ) ) {
120
+		if (is_multisite() && current_user_can('manage_network_plugins')) {
121 121
 			$install_actions['network_activate'] = sprintf(
122 122
 				'<a class="button button-primary" href="%s" target="_parent">%s</a>',
123
-				wp_nonce_url( 'plugins.php?action=activate&amp;networkwide=1&amp;plugin=' . urlencode( $plugin_file ), 'activate-plugin_' . $plugin_file ),
124
-				__( 'Network Activate' )
123
+				wp_nonce_url('plugins.php?action=activate&amp;networkwide=1&amp;plugin=' . urlencode($plugin_file), 'activate-plugin_' . $plugin_file),
124
+				__('Network Activate')
125 125
 			);
126
-			unset( $install_actions['activate_plugin'] );
126
+			unset($install_actions['activate_plugin']);
127 127
 		}
128 128
 
129
-		if ( 'import' === $from ) {
129
+		if ('import' === $from) {
130 130
 			$install_actions['importers_page'] = sprintf(
131 131
 				'<a href="%s" target="_parent">%s</a>',
132
-				admin_url( 'import.php' ),
133
-				__( 'Go to Importers' )
132
+				admin_url('import.php'),
133
+				__('Go to Importers')
134 134
 			);
135
-		} elseif ( 'web' === $this->type ) {
135
+		} elseif ('web' === $this->type) {
136 136
 			$install_actions['plugins_page'] = sprintf(
137 137
 				'<a href="%s" target="_parent">%s</a>',
138
-				self_admin_url( 'plugin-install.php' ),
139
-				__( 'Go to Plugin Installer' )
138
+				self_admin_url('plugin-install.php'),
139
+				__('Go to Plugin Installer')
140 140
 			);
141
-		} elseif ( 'upload' === $this->type && 'plugins' === $from ) {
141
+		} elseif ('upload' === $this->type && 'plugins' === $from) {
142 142
 			$install_actions['plugins_page'] = sprintf(
143 143
 				'<a href="%s">%s</a>',
144
-				self_admin_url( 'plugin-install.php' ),
145
-				__( 'Go to Plugin Installer' )
144
+				self_admin_url('plugin-install.php'),
145
+				__('Go to Plugin Installer')
146 146
 			);
147 147
 		} else {
148 148
 			$install_actions['plugins_page'] = sprintf(
149 149
 				'<a href="%s" target="_parent">%s</a>',
150
-				self_admin_url( 'plugins.php' ),
151
-				__( 'Go to Plugins page' )
150
+				self_admin_url('plugins.php'),
151
+				__('Go to Plugins page')
152 152
 			);
153 153
 		}
154 154
 
155
-		if ( ! $this->result || is_wp_error( $this->result ) ) {
156
-			unset( $install_actions['activate_plugin'], $install_actions['network_activate'] );
157
-		} elseif ( ! current_user_can( 'activate_plugin', $plugin_file ) || is_plugin_active( $plugin_file ) ) {
158
-			unset( $install_actions['activate_plugin'] );
155
+		if (!$this->result || is_wp_error($this->result)) {
156
+			unset($install_actions['activate_plugin'], $install_actions['network_activate']);
157
+		} elseif (!current_user_can('activate_plugin', $plugin_file) || is_plugin_active($plugin_file)) {
158
+			unset($install_actions['activate_plugin']);
159 159
 		}
160 160
 
161 161
 		/**
@@ -169,10 +169,10 @@  discard block
 block discarded – undo
169 169
 		 *                                  via upload.
170 170
 		 * @param string   $plugin_file     Path to the plugin file relative to the plugins directory.
171 171
 		 */
172
-		$install_actions = apply_filters( 'install_plugin_complete_actions', $install_actions, $this->api, $plugin_file );
172
+		$install_actions = apply_filters('install_plugin_complete_actions', $install_actions, $this->api, $plugin_file);
173 173
 
174
-		if ( ! empty( $install_actions ) ) {
175
-			$this->feedback( implode( ' ', (array) $install_actions ) );
174
+		if (!empty($install_actions)) {
175
+			$this->feedback(implode(' ', (array) $install_actions));
176 176
 		}
177 177
 	}
178 178
 
@@ -184,18 +184,18 @@  discard block
 block discarded – undo
184 184
 	 * @return bool Whether the plugin can be overwritten and HTML was outputted.
185 185
 	 */
186 186
 	private function do_overwrite() {
187
-		if ( 'upload' !== $this->type || ! is_wp_error( $this->result ) || 'folder_exists' !== $this->result->get_error_code() ) {
187
+		if ('upload' !== $this->type || !is_wp_error($this->result) || 'folder_exists' !== $this->result->get_error_code()) {
188 188
 			return false;
189 189
 		}
190 190
 
191
-		$folder = $this->result->get_error_data( 'folder_exists' );
192
-		$folder = ltrim( substr( $folder, strlen( WP_PLUGIN_DIR ) ), '/' );
191
+		$folder = $this->result->get_error_data('folder_exists');
192
+		$folder = ltrim(substr($folder, strlen(WP_PLUGIN_DIR)), '/');
193 193
 
194 194
 		$current_plugin_data = false;
195 195
 		$all_plugins         = get_plugins();
196 196
 
197
-		foreach ( $all_plugins as $plugin => $plugin_data ) {
198
-			if ( strrpos( $plugin, $folder ) !== 0 ) {
197
+		foreach ($all_plugins as $plugin => $plugin_data) {
198
+			if (strrpos($plugin, $folder) !== 0) {
199 199
 				continue;
200 200
 			}
201 201
 
@@ -204,40 +204,40 @@  discard block
 block discarded – undo
204 204
 
205 205
 		$new_plugin_data = $this->upgrader->new_plugin_data;
206 206
 
207
-		if ( ! $current_plugin_data || ! $new_plugin_data ) {
207
+		if (!$current_plugin_data || !$new_plugin_data) {
208 208
 			return false;
209 209
 		}
210 210
 
211
-		echo '<h2 class="update-from-upload-heading">' . esc_html__( 'This plugin is already installed.' ) . '</h2>';
211
+		echo '<h2 class="update-from-upload-heading">' . esc_html__('This plugin is already installed.') . '</h2>';
212 212
 
213
-		$this->is_downgrading = version_compare( $current_plugin_data['Version'], $new_plugin_data['Version'], '>' );
213
+		$this->is_downgrading = version_compare($current_plugin_data['Version'], $new_plugin_data['Version'], '>');
214 214
 
215 215
 		$rows = array(
216
-			'Name'        => __( 'Plugin name' ),
217
-			'Version'     => __( 'Version' ),
218
-			'Author'      => __( 'Author' ),
219
-			'RequiresWP'  => __( 'Required WordPress version' ),
220
-			'RequiresPHP' => __( 'Required PHP version' ),
216
+			'Name'        => __('Plugin name'),
217
+			'Version'     => __('Version'),
218
+			'Author'      => __('Author'),
219
+			'RequiresWP'  => __('Required WordPress version'),
220
+			'RequiresPHP' => __('Required PHP version'),
221 221
 		);
222 222
 
223 223
 		$table  = '<table class="update-from-upload-comparison"><tbody>';
224
-		$table .= '<tr><th></th><th>' . esc_html_x( 'Current', 'plugin' ) . '</th>';
225
-		$table .= '<th>' . esc_html_x( 'Uploaded', 'plugin' ) . '</th></tr>';
224
+		$table .= '<tr><th></th><th>' . esc_html_x('Current', 'plugin') . '</th>';
225
+		$table .= '<th>' . esc_html_x('Uploaded', 'plugin') . '</th></tr>';
226 226
 
227 227
 		$is_same_plugin = true; // Let's consider only these rows.
228 228
 
229
-		foreach ( $rows as $field => $label ) {
230
-			$old_value = ! empty( $current_plugin_data[ $field ] ) ? (string) $current_plugin_data[ $field ] : '-';
231
-			$new_value = ! empty( $new_plugin_data[ $field ] ) ? (string) $new_plugin_data[ $field ] : '-';
229
+		foreach ($rows as $field => $label) {
230
+			$old_value = !empty($current_plugin_data[$field]) ? (string) $current_plugin_data[$field] : '-';
231
+			$new_value = !empty($new_plugin_data[$field]) ? (string) $new_plugin_data[$field] : '-';
232 232
 
233
-			$is_same_plugin = $is_same_plugin && ( $old_value === $new_value );
233
+			$is_same_plugin = $is_same_plugin && ($old_value === $new_value);
234 234
 
235
-			$diff_field   = ( 'Version' !== $field && $new_value !== $old_value );
236
-			$diff_version = ( 'Version' === $field && $this->is_downgrading );
235
+			$diff_field   = ('Version' !== $field && $new_value !== $old_value);
236
+			$diff_version = ('Version' === $field && $this->is_downgrading);
237 237
 
238
-			$table .= '<tr><td class="name-label">' . $label . '</td><td>' . wp_strip_all_tags( $old_value ) . '</td>';
239
-			$table .= ( $diff_field || $diff_version ) ? '<td class="warning">' : '<td>';
240
-			$table .= wp_strip_all_tags( $new_value ) . '</td></tr>';
238
+			$table .= '<tr><td class="name-label">' . $label . '</td><td>' . wp_strip_all_tags($old_value) . '</td>';
239
+			$table .= ($diff_field || $diff_version) ? '<td class="warning">' : '<td>';
240
+			$table .= wp_strip_all_tags($new_value) . '</td></tr>';
241 241
 		}
242 242
 
243 243
 		$table .= '</tbody></table>';
@@ -251,55 +251,55 @@  discard block
 block discarded – undo
251 251
 		 * @param array  $current_plugin_data Array with current plugin data.
252 252
 		 * @param array  $new_plugin_data     Array with uploaded plugin data.
253 253
 		 */
254
-		echo apply_filters( 'install_plugin_overwrite_comparison', $table, $current_plugin_data, $new_plugin_data );
254
+		echo apply_filters('install_plugin_overwrite_comparison', $table, $current_plugin_data, $new_plugin_data);
255 255
 
256 256
 		$install_actions = array();
257 257
 		$can_update      = true;
258 258
 
259
-		$blocked_message  = '<p>' . esc_html__( 'The plugin cannot be updated due to the following:' ) . '</p>';
259
+		$blocked_message  = '<p>' . esc_html__('The plugin cannot be updated due to the following:') . '</p>';
260 260
 		$blocked_message .= '<ul class="ul-disc">';
261 261
 
262
-		$requires_php = isset( $new_plugin_data['RequiresPHP'] ) ? $new_plugin_data['RequiresPHP'] : null;
263
-		$requires_wp  = isset( $new_plugin_data['RequiresWP'] ) ? $new_plugin_data['RequiresWP'] : null;
262
+		$requires_php = isset($new_plugin_data['RequiresPHP']) ? $new_plugin_data['RequiresPHP'] : null;
263
+		$requires_wp  = isset($new_plugin_data['RequiresWP']) ? $new_plugin_data['RequiresWP'] : null;
264 264
 
265
-		if ( ! is_php_version_compatible( $requires_php ) ) {
265
+		if (!is_php_version_compatible($requires_php)) {
266 266
 			$error = sprintf(
267 267
 				/* translators: 1: Current PHP version, 2: Version required by the uploaded plugin. */
268
-				__( 'The PHP version on your server is %1$s, however the uploaded plugin requires %2$s.' ),
268
+				__('The PHP version on your server is %1$s, however the uploaded plugin requires %2$s.'),
269 269
 				phpversion(),
270 270
 				$requires_php
271 271
 			);
272 272
 
273
-			$blocked_message .= '<li>' . esc_html( $error ) . '</li>';
273
+			$blocked_message .= '<li>' . esc_html($error) . '</li>';
274 274
 			$can_update       = false;
275 275
 		}
276 276
 
277
-		if ( ! is_wp_version_compatible( $requires_wp ) ) {
277
+		if (!is_wp_version_compatible($requires_wp)) {
278 278
 			$error = sprintf(
279 279
 				/* translators: 1: Current WordPress version, 2: Version required by the uploaded plugin. */
280
-				__( 'Your WordPress version is %1$s, however the uploaded plugin requires %2$s.' ),
281
-				get_bloginfo( 'version' ),
280
+				__('Your WordPress version is %1$s, however the uploaded plugin requires %2$s.'),
281
+				get_bloginfo('version'),
282 282
 				$requires_wp
283 283
 			);
284 284
 
285
-			$blocked_message .= '<li>' . esc_html( $error ) . '</li>';
285
+			$blocked_message .= '<li>' . esc_html($error) . '</li>';
286 286
 			$can_update       = false;
287 287
 		}
288 288
 
289 289
 		$blocked_message .= '</ul>';
290 290
 
291
-		if ( $can_update ) {
292
-			if ( $this->is_downgrading ) {
291
+		if ($can_update) {
292
+			if ($this->is_downgrading) {
293 293
 				$warning = sprintf(
294 294
 					/* translators: %s: Documentation URL. */
295
-					__( 'You are uploading an older version of a current plugin. You can continue to install the older version, but be sure to <a href="%s">back up your database and files</a> first.' ),
296
-					__( 'https://wordpress.org/support/article/wordpress-backups/' )
295
+					__('You are uploading an older version of a current plugin. You can continue to install the older version, but be sure to <a href="%s">back up your database and files</a> first.'),
296
+					__('https://wordpress.org/support/article/wordpress-backups/')
297 297
 				);
298 298
 			} else {
299 299
 				$warning = sprintf(
300 300
 					/* translators: %s: Documentation URL. */
301
-					__( 'You are updating a plugin. Be sure to <a href="%s">back up your database and files</a> first.' ),
302
-					__( 'https://wordpress.org/support/article/wordpress-backups/' )
301
+					__('You are updating a plugin. Be sure to <a href="%s">back up your database and files</a> first.'),
302
+					__('https://wordpress.org/support/article/wordpress-backups/')
303 303
 				);
304 304
 			}
305 305
 
@@ -309,19 +309,19 @@  discard block
 block discarded – undo
309 309
 
310 310
 			$install_actions['overwrite_plugin'] = sprintf(
311 311
 				'<a class="button button-primary update-from-upload-overwrite" href="%s" target="_parent">%s</a>',
312
-				wp_nonce_url( add_query_arg( 'overwrite', $overwrite, $this->url ), 'plugin-upload' ),
313
-				_x( 'Replace current with uploaded', 'plugin' )
312
+				wp_nonce_url(add_query_arg('overwrite', $overwrite, $this->url), 'plugin-upload'),
313
+				_x('Replace current with uploaded', 'plugin')
314 314
 			);
315 315
 		} else {
316 316
 			echo $blocked_message;
317 317
 		}
318 318
 
319
-		$cancel_url = add_query_arg( 'action', 'upload-plugin-cancel-overwrite', $this->url );
319
+		$cancel_url = add_query_arg('action', 'upload-plugin-cancel-overwrite', $this->url);
320 320
 
321 321
 		$install_actions['plugins_page'] = sprintf(
322 322
 			'<a class="button" href="%s">%s</a>',
323
-			wp_nonce_url( $cancel_url, 'plugin-upload-cancel-overwrite' ),
324
-			__( 'Cancel and go back' )
323
+			wp_nonce_url($cancel_url, 'plugin-upload-cancel-overwrite'),
324
+			__('Cancel and go back')
325 325
 		);
326 326
 
327 327
 		/**
@@ -334,14 +334,14 @@  discard block
 block discarded – undo
334 334
 		 * @param object   $api             Object containing WordPress.org API plugin data.
335 335
 		 * @param array    $new_plugin_data Array with uploaded plugin data.
336 336
 		 */
337
-		$install_actions = apply_filters( 'install_plugin_overwrite_actions', $install_actions, $this->api, $new_plugin_data );
337
+		$install_actions = apply_filters('install_plugin_overwrite_actions', $install_actions, $this->api, $new_plugin_data);
338 338
 
339
-		if ( ! empty( $install_actions ) ) {
339
+		if (!empty($install_actions)) {
340 340
 			printf(
341 341
 				'<p class="update-from-upload-expired hidden">%s</p>',
342
-				__( 'The uploaded file has expired. Please go back and upload it again.' )
342
+				__('The uploaded file has expired. Please go back and upload it again.')
343 343
 			);
344
-			echo '<p class="update-from-upload-actions">' . implode( ' ', (array) $install_actions ) . '</p>';
344
+			echo '<p class="update-from-upload-actions">' . implode(' ', (array) $install_actions) . '</p>';
345 345
 		}
346 346
 
347 347
 		return true;
Please login to merge, or discard this patch.
brighty/wp-admin/includes/translation-install.php 2 patches
Indentation   +197 added lines, -197 removed lines patch added patch discarded remove patch
@@ -17,96 +17,96 @@  discard block
 block discarded – undo
17 17
  * @return array|WP_Error On success an associative array of translations, WP_Error on failure.
18 18
  */
19 19
 function translations_api( $type, $args = null ) {
20
-	// Include an unmodified $wp_version.
21
-	require ABSPATH . WPINC . '/version.php';
22
-
23
-	if ( ! in_array( $type, array( 'plugins', 'themes', 'core' ), true ) ) {
24
-		return new WP_Error( 'invalid_type', __( 'Invalid translation type.' ) );
25
-	}
26
-
27
-	/**
28
-	 * Allows a plugin to override the WordPress.org Translation Installation API entirely.
29
-	 *
30
-	 * @since 4.0.0
31
-	 *
32
-	 * @param false|array $result The result array. Default false.
33
-	 * @param string      $type   The type of translations being requested.
34
-	 * @param object      $args   Translation API arguments.
35
-	 */
36
-	$res = apply_filters( 'translations_api', false, $type, $args );
37
-
38
-	if ( false === $res ) {
39
-		$url      = 'http://api.wordpress.org/translations/' . $type . '/1.0/';
40
-		$http_url = $url;
41
-		$ssl      = wp_http_supports( array( 'ssl' ) );
42
-		if ( $ssl ) {
43
-			$url = set_url_scheme( $url, 'https' );
44
-		}
45
-
46
-		$options = array(
47
-			'timeout' => 3,
48
-			'body'    => array(
49
-				'wp_version' => $wp_version,
50
-				'locale'     => get_locale(),
51
-				'version'    => $args['version'], // Version of plugin, theme or core.
52
-			),
53
-		);
54
-
55
-		if ( 'core' !== $type ) {
56
-			$options['body']['slug'] = $args['slug']; // Plugin or theme slug.
57
-		}
58
-
59
-		$request = wp_remote_post( $url, $options );
60
-
61
-		if ( $ssl && is_wp_error( $request ) ) {
62
-			trigger_error(
63
-				sprintf(
64
-					/* translators: %s: Support forums URL. */
65
-					__( 'An unexpected error occurred. Something may be wrong with WordPress.org or this server&#8217;s configuration. If you continue to have problems, please try the <a href="%s">support forums</a>.' ),
66
-					__( 'https://wordpress.org/support/forums/' )
67
-				) . ' ' . __( '(WordPress could not establish a secure connection to WordPress.org. Please contact your server administrator.)' ),
68
-				headers_sent() || WP_DEBUG ? E_USER_WARNING : E_USER_NOTICE
69
-			);
70
-
71
-			$request = wp_remote_post( $http_url, $options );
72
-		}
73
-
74
-		if ( is_wp_error( $request ) ) {
75
-			$res = new WP_Error(
76
-				'translations_api_failed',
77
-				sprintf(
78
-					/* translators: %s: Support forums URL. */
79
-					__( 'An unexpected error occurred. Something may be wrong with WordPress.org or this server&#8217;s configuration. If you continue to have problems, please try the <a href="%s">support forums</a>.' ),
80
-					__( 'https://wordpress.org/support/forums/' )
81
-				),
82
-				$request->get_error_message()
83
-			);
84
-		} else {
85
-			$res = json_decode( wp_remote_retrieve_body( $request ), true );
86
-			if ( ! is_object( $res ) && ! is_array( $res ) ) {
87
-				$res = new WP_Error(
88
-					'translations_api_failed',
89
-					sprintf(
90
-						/* translators: %s: Support forums URL. */
91
-						__( 'An unexpected error occurred. Something may be wrong with WordPress.org or this server&#8217;s configuration. If you continue to have problems, please try the <a href="%s">support forums</a>.' ),
92
-						__( 'https://wordpress.org/support/forums/' )
93
-					),
94
-					wp_remote_retrieve_body( $request )
95
-				);
96
-			}
97
-		}
98
-	}
99
-
100
-	/**
101
-	 * Filters the Translation Installation API response results.
102
-	 *
103
-	 * @since 4.0.0
104
-	 *
105
-	 * @param array|WP_Error $res  Response as an associative array or WP_Error.
106
-	 * @param string         $type The type of translations being requested.
107
-	 * @param object         $args Translation API arguments.
108
-	 */
109
-	return apply_filters( 'translations_api_result', $res, $type, $args );
20
+    // Include an unmodified $wp_version.
21
+    require ABSPATH . WPINC . '/version.php';
22
+
23
+    if ( ! in_array( $type, array( 'plugins', 'themes', 'core' ), true ) ) {
24
+        return new WP_Error( 'invalid_type', __( 'Invalid translation type.' ) );
25
+    }
26
+
27
+    /**
28
+     * Allows a plugin to override the WordPress.org Translation Installation API entirely.
29
+     *
30
+     * @since 4.0.0
31
+     *
32
+     * @param false|array $result The result array. Default false.
33
+     * @param string      $type   The type of translations being requested.
34
+     * @param object      $args   Translation API arguments.
35
+     */
36
+    $res = apply_filters( 'translations_api', false, $type, $args );
37
+
38
+    if ( false === $res ) {
39
+        $url      = 'http://api.wordpress.org/translations/' . $type . '/1.0/';
40
+        $http_url = $url;
41
+        $ssl      = wp_http_supports( array( 'ssl' ) );
42
+        if ( $ssl ) {
43
+            $url = set_url_scheme( $url, 'https' );
44
+        }
45
+
46
+        $options = array(
47
+            'timeout' => 3,
48
+            'body'    => array(
49
+                'wp_version' => $wp_version,
50
+                'locale'     => get_locale(),
51
+                'version'    => $args['version'], // Version of plugin, theme or core.
52
+            ),
53
+        );
54
+
55
+        if ( 'core' !== $type ) {
56
+            $options['body']['slug'] = $args['slug']; // Plugin or theme slug.
57
+        }
58
+
59
+        $request = wp_remote_post( $url, $options );
60
+
61
+        if ( $ssl && is_wp_error( $request ) ) {
62
+            trigger_error(
63
+                sprintf(
64
+                    /* translators: %s: Support forums URL. */
65
+                    __( 'An unexpected error occurred. Something may be wrong with WordPress.org or this server&#8217;s configuration. If you continue to have problems, please try the <a href="%s">support forums</a>.' ),
66
+                    __( 'https://wordpress.org/support/forums/' )
67
+                ) . ' ' . __( '(WordPress could not establish a secure connection to WordPress.org. Please contact your server administrator.)' ),
68
+                headers_sent() || WP_DEBUG ? E_USER_WARNING : E_USER_NOTICE
69
+            );
70
+
71
+            $request = wp_remote_post( $http_url, $options );
72
+        }
73
+
74
+        if ( is_wp_error( $request ) ) {
75
+            $res = new WP_Error(
76
+                'translations_api_failed',
77
+                sprintf(
78
+                    /* translators: %s: Support forums URL. */
79
+                    __( 'An unexpected error occurred. Something may be wrong with WordPress.org or this server&#8217;s configuration. If you continue to have problems, please try the <a href="%s">support forums</a>.' ),
80
+                    __( 'https://wordpress.org/support/forums/' )
81
+                ),
82
+                $request->get_error_message()
83
+            );
84
+        } else {
85
+            $res = json_decode( wp_remote_retrieve_body( $request ), true );
86
+            if ( ! is_object( $res ) && ! is_array( $res ) ) {
87
+                $res = new WP_Error(
88
+                    'translations_api_failed',
89
+                    sprintf(
90
+                        /* translators: %s: Support forums URL. */
91
+                        __( 'An unexpected error occurred. Something may be wrong with WordPress.org or this server&#8217;s configuration. If you continue to have problems, please try the <a href="%s">support forums</a>.' ),
92
+                        __( 'https://wordpress.org/support/forums/' )
93
+                    ),
94
+                    wp_remote_retrieve_body( $request )
95
+                );
96
+            }
97
+        }
98
+    }
99
+
100
+    /**
101
+     * Filters the Translation Installation API response results.
102
+     *
103
+     * @since 4.0.0
104
+     *
105
+     * @param array|WP_Error $res  Response as an associative array or WP_Error.
106
+     * @param string         $type The type of translations being requested.
107
+     * @param object         $args Translation API arguments.
108
+     */
109
+    return apply_filters( 'translations_api_result', $res, $type, $args );
110 110
 }
111 111
 
112 112
 /**
@@ -120,33 +120,33 @@  discard block
 block discarded – undo
120 120
  *                 in an error, an empty array will be returned.
121 121
  */
122 122
 function wp_get_available_translations() {
123
-	if ( ! wp_installing() ) {
124
-		$translations = get_site_transient( 'available_translations' );
125
-		if ( false !== $translations ) {
126
-			return $translations;
127
-		}
128
-	}
123
+    if ( ! wp_installing() ) {
124
+        $translations = get_site_transient( 'available_translations' );
125
+        if ( false !== $translations ) {
126
+            return $translations;
127
+        }
128
+    }
129 129
 
130
-	// Include an unmodified $wp_version.
131
-	require ABSPATH . WPINC . '/version.php';
130
+    // Include an unmodified $wp_version.
131
+    require ABSPATH . WPINC . '/version.php';
132 132
 
133
-	$api = translations_api( 'core', array( 'version' => $wp_version ) );
133
+    $api = translations_api( 'core', array( 'version' => $wp_version ) );
134 134
 
135
-	if ( is_wp_error( $api ) || empty( $api['translations'] ) ) {
136
-		return array();
137
-	}
135
+    if ( is_wp_error( $api ) || empty( $api['translations'] ) ) {
136
+        return array();
137
+    }
138 138
 
139
-	$translations = array();
140
-	// Key the array with the language code for now.
141
-	foreach ( $api['translations'] as $translation ) {
142
-		$translations[ $translation['language'] ] = $translation;
143
-	}
139
+    $translations = array();
140
+    // Key the array with the language code for now.
141
+    foreach ( $api['translations'] as $translation ) {
142
+        $translations[ $translation['language'] ] = $translation;
143
+    }
144 144
 
145
-	if ( ! defined( 'WP_INSTALLING' ) ) {
146
-		set_site_transient( 'available_translations', $translations, 3 * HOUR_IN_SECONDS );
147
-	}
145
+    if ( ! defined( 'WP_INSTALLING' ) ) {
146
+        set_site_transient( 'available_translations', $translations, 3 * HOUR_IN_SECONDS );
147
+    }
148 148
 
149
-	return $translations;
149
+    return $translations;
150 150
 }
151 151
 
152 152
 /**
@@ -159,43 +159,43 @@  discard block
 block discarded – undo
159 159
  * @param array[] $languages Array of available languages (populated via the Translation API).
160 160
  */
161 161
 function wp_install_language_form( $languages ) {
162
-	global $wp_local_package;
163
-
164
-	$installed_languages = get_available_languages();
165
-
166
-	echo "<label class='screen-reader-text' for='language'>Select a default language</label>\n";
167
-	echo "<select size='14' name='language' id='language'>\n";
168
-	echo '<option value="" lang="en" selected="selected" data-continue="Continue" data-installed="1">English (United States)</option>';
169
-	echo "\n";
170
-
171
-	if ( ! empty( $wp_local_package ) && isset( $languages[ $wp_local_package ] ) ) {
172
-		if ( isset( $languages[ $wp_local_package ] ) ) {
173
-			$language = $languages[ $wp_local_package ];
174
-			printf(
175
-				'<option value="%s" lang="%s" data-continue="%s"%s>%s</option>' . "\n",
176
-				esc_attr( $language['language'] ),
177
-				esc_attr( current( $language['iso'] ) ),
178
-				esc_attr( $language['strings']['continue'] ? $language['strings']['continue'] : 'Continue' ),
179
-				in_array( $language['language'], $installed_languages, true ) ? ' data-installed="1"' : '',
180
-				esc_html( $language['native_name'] )
181
-			);
182
-
183
-			unset( $languages[ $wp_local_package ] );
184
-		}
185
-	}
186
-
187
-	foreach ( $languages as $language ) {
188
-		printf(
189
-			'<option value="%s" lang="%s" data-continue="%s"%s>%s</option>' . "\n",
190
-			esc_attr( $language['language'] ),
191
-			esc_attr( current( $language['iso'] ) ),
192
-			esc_attr( $language['strings']['continue'] ? $language['strings']['continue'] : 'Continue' ),
193
-			in_array( $language['language'], $installed_languages, true ) ? ' data-installed="1"' : '',
194
-			esc_html( $language['native_name'] )
195
-		);
196
-	}
197
-	echo "</select>\n";
198
-	echo '<p class="step"><span class="spinner"></span><input id="language-continue" type="submit" class="button button-primary button-large" value="Continue" /></p>';
162
+    global $wp_local_package;
163
+
164
+    $installed_languages = get_available_languages();
165
+
166
+    echo "<label class='screen-reader-text' for='language'>Select a default language</label>\n";
167
+    echo "<select size='14' name='language' id='language'>\n";
168
+    echo '<option value="" lang="en" selected="selected" data-continue="Continue" data-installed="1">English (United States)</option>';
169
+    echo "\n";
170
+
171
+    if ( ! empty( $wp_local_package ) && isset( $languages[ $wp_local_package ] ) ) {
172
+        if ( isset( $languages[ $wp_local_package ] ) ) {
173
+            $language = $languages[ $wp_local_package ];
174
+            printf(
175
+                '<option value="%s" lang="%s" data-continue="%s"%s>%s</option>' . "\n",
176
+                esc_attr( $language['language'] ),
177
+                esc_attr( current( $language['iso'] ) ),
178
+                esc_attr( $language['strings']['continue'] ? $language['strings']['continue'] : 'Continue' ),
179
+                in_array( $language['language'], $installed_languages, true ) ? ' data-installed="1"' : '',
180
+                esc_html( $language['native_name'] )
181
+            );
182
+
183
+            unset( $languages[ $wp_local_package ] );
184
+        }
185
+    }
186
+
187
+    foreach ( $languages as $language ) {
188
+        printf(
189
+            '<option value="%s" lang="%s" data-continue="%s"%s>%s</option>' . "\n",
190
+            esc_attr( $language['language'] ),
191
+            esc_attr( current( $language['iso'] ) ),
192
+            esc_attr( $language['strings']['continue'] ? $language['strings']['continue'] : 'Continue' ),
193
+            in_array( $language['language'], $installed_languages, true ) ? ' data-installed="1"' : '',
194
+            esc_html( $language['native_name'] )
195
+        );
196
+    }
197
+    echo "</select>\n";
198
+    echo '<p class="step"><span class="spinner"></span><input id="language-continue" type="submit" class="button button-primary button-large" value="Continue" /></p>';
199 199
 }
200 200
 
201 201
 /**
@@ -210,43 +210,43 @@  discard block
 block discarded – undo
210 210
  *                      (or already installed), or false on failure.
211 211
  */
212 212
 function wp_download_language_pack( $download ) {
213
-	// Check if the translation is already installed.
214
-	if ( in_array( $download, get_available_languages(), true ) ) {
215
-		return $download;
216
-	}
217
-
218
-	if ( ! wp_is_file_mod_allowed( 'download_language_pack' ) ) {
219
-		return false;
220
-	}
221
-
222
-	// Confirm the translation is one we can download.
223
-	$translations = wp_get_available_translations();
224
-	if ( ! $translations ) {
225
-		return false;
226
-	}
227
-	foreach ( $translations as $translation ) {
228
-		if ( $translation['language'] === $download ) {
229
-			$translation_to_load = true;
230
-			break;
231
-		}
232
-	}
233
-
234
-	if ( empty( $translation_to_load ) ) {
235
-		return false;
236
-	}
237
-	$translation = (object) $translation;
238
-
239
-	require_once ABSPATH . 'wp-admin/includes/class-wp-upgrader.php';
240
-	$skin              = new Automatic_Upgrader_Skin;
241
-	$upgrader          = new Language_Pack_Upgrader( $skin );
242
-	$translation->type = 'core';
243
-	$result            = $upgrader->upgrade( $translation, array( 'clear_update_cache' => false ) );
244
-
245
-	if ( ! $result || is_wp_error( $result ) ) {
246
-		return false;
247
-	}
248
-
249
-	return $translation->language;
213
+    // Check if the translation is already installed.
214
+    if ( in_array( $download, get_available_languages(), true ) ) {
215
+        return $download;
216
+    }
217
+
218
+    if ( ! wp_is_file_mod_allowed( 'download_language_pack' ) ) {
219
+        return false;
220
+    }
221
+
222
+    // Confirm the translation is one we can download.
223
+    $translations = wp_get_available_translations();
224
+    if ( ! $translations ) {
225
+        return false;
226
+    }
227
+    foreach ( $translations as $translation ) {
228
+        if ( $translation['language'] === $download ) {
229
+            $translation_to_load = true;
230
+            break;
231
+        }
232
+    }
233
+
234
+    if ( empty( $translation_to_load ) ) {
235
+        return false;
236
+    }
237
+    $translation = (object) $translation;
238
+
239
+    require_once ABSPATH . 'wp-admin/includes/class-wp-upgrader.php';
240
+    $skin              = new Automatic_Upgrader_Skin;
241
+    $upgrader          = new Language_Pack_Upgrader( $skin );
242
+    $translation->type = 'core';
243
+    $result            = $upgrader->upgrade( $translation, array( 'clear_update_cache' => false ) );
244
+
245
+    if ( ! $result || is_wp_error( $result ) ) {
246
+        return false;
247
+    }
248
+
249
+    return $translation->language;
250 250
 }
251 251
 
252 252
 /**
@@ -258,20 +258,20 @@  discard block
 block discarded – undo
258 258
  * @return bool Returns true on success, false on failure.
259 259
  */
260 260
 function wp_can_install_language_pack() {
261
-	if ( ! wp_is_file_mod_allowed( 'can_install_language_pack' ) ) {
262
-		return false;
263
-	}
261
+    if ( ! wp_is_file_mod_allowed( 'can_install_language_pack' ) ) {
262
+        return false;
263
+    }
264 264
 
265
-	require_once ABSPATH . 'wp-admin/includes/class-wp-upgrader.php';
266
-	$skin     = new Automatic_Upgrader_Skin;
267
-	$upgrader = new Language_Pack_Upgrader( $skin );
268
-	$upgrader->init();
265
+    require_once ABSPATH . 'wp-admin/includes/class-wp-upgrader.php';
266
+    $skin     = new Automatic_Upgrader_Skin;
267
+    $upgrader = new Language_Pack_Upgrader( $skin );
268
+    $upgrader->init();
269 269
 
270
-	$check = $upgrader->fs_connect( array( WP_CONTENT_DIR, WP_LANG_DIR ) );
270
+    $check = $upgrader->fs_connect( array( WP_CONTENT_DIR, WP_LANG_DIR ) );
271 271
 
272
-	if ( ! $check || is_wp_error( $check ) ) {
273
-		return false;
274
-	}
272
+    if ( ! $check || is_wp_error( $check ) ) {
273
+        return false;
274
+    }
275 275
 
276
-	return true;
276
+    return true;
277 277
 }
Please login to merge, or discard this patch.
Spacing   +63 added lines, -63 removed lines patch added patch discarded remove patch
@@ -16,12 +16,12 @@  discard block
 block discarded – undo
16 16
  * @param array|object $args Translation API arguments. Optional.
17 17
  * @return array|WP_Error On success an associative array of translations, WP_Error on failure.
18 18
  */
19
-function translations_api( $type, $args = null ) {
19
+function translations_api($type, $args = null) {
20 20
 	// Include an unmodified $wp_version.
21 21
 	require ABSPATH . WPINC . '/version.php';
22 22
 
23
-	if ( ! in_array( $type, array( 'plugins', 'themes', 'core' ), true ) ) {
24
-		return new WP_Error( 'invalid_type', __( 'Invalid translation type.' ) );
23
+	if (!in_array($type, array('plugins', 'themes', 'core'), true)) {
24
+		return new WP_Error('invalid_type', __('Invalid translation type.'));
25 25
 	}
26 26
 
27 27
 	/**
@@ -33,14 +33,14 @@  discard block
 block discarded – undo
33 33
 	 * @param string      $type   The type of translations being requested.
34 34
 	 * @param object      $args   Translation API arguments.
35 35
 	 */
36
-	$res = apply_filters( 'translations_api', false, $type, $args );
36
+	$res = apply_filters('translations_api', false, $type, $args);
37 37
 
38
-	if ( false === $res ) {
38
+	if (false === $res) {
39 39
 		$url      = 'http://api.wordpress.org/translations/' . $type . '/1.0/';
40 40
 		$http_url = $url;
41
-		$ssl      = wp_http_supports( array( 'ssl' ) );
42
-		if ( $ssl ) {
43
-			$url = set_url_scheme( $url, 'https' );
41
+		$ssl      = wp_http_supports(array('ssl'));
42
+		if ($ssl) {
43
+			$url = set_url_scheme($url, 'https');
44 44
 		}
45 45
 
46 46
 		$options = array(
@@ -52,46 +52,46 @@  discard block
 block discarded – undo
52 52
 			),
53 53
 		);
54 54
 
55
-		if ( 'core' !== $type ) {
55
+		if ('core' !== $type) {
56 56
 			$options['body']['slug'] = $args['slug']; // Plugin or theme slug.
57 57
 		}
58 58
 
59
-		$request = wp_remote_post( $url, $options );
59
+		$request = wp_remote_post($url, $options);
60 60
 
61
-		if ( $ssl && is_wp_error( $request ) ) {
61
+		if ($ssl && is_wp_error($request)) {
62 62
 			trigger_error(
63 63
 				sprintf(
64 64
 					/* translators: %s: Support forums URL. */
65
-					__( 'An unexpected error occurred. Something may be wrong with WordPress.org or this server&#8217;s configuration. If you continue to have problems, please try the <a href="%s">support forums</a>.' ),
66
-					__( 'https://wordpress.org/support/forums/' )
67
-				) . ' ' . __( '(WordPress could not establish a secure connection to WordPress.org. Please contact your server administrator.)' ),
65
+					__('An unexpected error occurred. Something may be wrong with WordPress.org or this server&#8217;s configuration. If you continue to have problems, please try the <a href="%s">support forums</a>.'),
66
+					__('https://wordpress.org/support/forums/')
67
+				) . ' ' . __('(WordPress could not establish a secure connection to WordPress.org. Please contact your server administrator.)'),
68 68
 				headers_sent() || WP_DEBUG ? E_USER_WARNING : E_USER_NOTICE
69 69
 			);
70 70
 
71
-			$request = wp_remote_post( $http_url, $options );
71
+			$request = wp_remote_post($http_url, $options);
72 72
 		}
73 73
 
74
-		if ( is_wp_error( $request ) ) {
74
+		if (is_wp_error($request)) {
75 75
 			$res = new WP_Error(
76 76
 				'translations_api_failed',
77 77
 				sprintf(
78 78
 					/* translators: %s: Support forums URL. */
79
-					__( 'An unexpected error occurred. Something may be wrong with WordPress.org or this server&#8217;s configuration. If you continue to have problems, please try the <a href="%s">support forums</a>.' ),
80
-					__( 'https://wordpress.org/support/forums/' )
79
+					__('An unexpected error occurred. Something may be wrong with WordPress.org or this server&#8217;s configuration. If you continue to have problems, please try the <a href="%s">support forums</a>.'),
80
+					__('https://wordpress.org/support/forums/')
81 81
 				),
82 82
 				$request->get_error_message()
83 83
 			);
84 84
 		} else {
85
-			$res = json_decode( wp_remote_retrieve_body( $request ), true );
86
-			if ( ! is_object( $res ) && ! is_array( $res ) ) {
85
+			$res = json_decode(wp_remote_retrieve_body($request), true);
86
+			if (!is_object($res) && !is_array($res)) {
87 87
 				$res = new WP_Error(
88 88
 					'translations_api_failed',
89 89
 					sprintf(
90 90
 						/* translators: %s: Support forums URL. */
91
-						__( 'An unexpected error occurred. Something may be wrong with WordPress.org or this server&#8217;s configuration. If you continue to have problems, please try the <a href="%s">support forums</a>.' ),
92
-						__( 'https://wordpress.org/support/forums/' )
91
+						__('An unexpected error occurred. Something may be wrong with WordPress.org or this server&#8217;s configuration. If you continue to have problems, please try the <a href="%s">support forums</a>.'),
92
+						__('https://wordpress.org/support/forums/')
93 93
 					),
94
-					wp_remote_retrieve_body( $request )
94
+					wp_remote_retrieve_body($request)
95 95
 				);
96 96
 			}
97 97
 		}
@@ -106,7 +106,7 @@  discard block
 block discarded – undo
106 106
 	 * @param string         $type The type of translations being requested.
107 107
 	 * @param object         $args Translation API arguments.
108 108
 	 */
109
-	return apply_filters( 'translations_api_result', $res, $type, $args );
109
+	return apply_filters('translations_api_result', $res, $type, $args);
110 110
 }
111 111
 
112 112
 /**
@@ -120,9 +120,9 @@  discard block
 block discarded – undo
120 120
  *                 in an error, an empty array will be returned.
121 121
  */
122 122
 function wp_get_available_translations() {
123
-	if ( ! wp_installing() ) {
124
-		$translations = get_site_transient( 'available_translations' );
125
-		if ( false !== $translations ) {
123
+	if (!wp_installing()) {
124
+		$translations = get_site_transient('available_translations');
125
+		if (false !== $translations) {
126 126
 			return $translations;
127 127
 		}
128 128
 	}
@@ -130,20 +130,20 @@  discard block
 block discarded – undo
130 130
 	// Include an unmodified $wp_version.
131 131
 	require ABSPATH . WPINC . '/version.php';
132 132
 
133
-	$api = translations_api( 'core', array( 'version' => $wp_version ) );
133
+	$api = translations_api('core', array('version' => $wp_version));
134 134
 
135
-	if ( is_wp_error( $api ) || empty( $api['translations'] ) ) {
135
+	if (is_wp_error($api) || empty($api['translations'])) {
136 136
 		return array();
137 137
 	}
138 138
 
139 139
 	$translations = array();
140 140
 	// Key the array with the language code for now.
141
-	foreach ( $api['translations'] as $translation ) {
142
-		$translations[ $translation['language'] ] = $translation;
141
+	foreach ($api['translations'] as $translation) {
142
+		$translations[$translation['language']] = $translation;
143 143
 	}
144 144
 
145
-	if ( ! defined( 'WP_INSTALLING' ) ) {
146
-		set_site_transient( 'available_translations', $translations, 3 * HOUR_IN_SECONDS );
145
+	if (!defined('WP_INSTALLING')) {
146
+		set_site_transient('available_translations', $translations, 3 * HOUR_IN_SECONDS);
147 147
 	}
148 148
 
149 149
 	return $translations;
@@ -158,7 +158,7 @@  discard block
 block discarded – undo
158 158
  *
159 159
  * @param array[] $languages Array of available languages (populated via the Translation API).
160 160
  */
161
-function wp_install_language_form( $languages ) {
161
+function wp_install_language_form($languages) {
162 162
 	global $wp_local_package;
163 163
 
164 164
 	$installed_languages = get_available_languages();
@@ -168,30 +168,30 @@  discard block
 block discarded – undo
168 168
 	echo '<option value="" lang="en" selected="selected" data-continue="Continue" data-installed="1">English (United States)</option>';
169 169
 	echo "\n";
170 170
 
171
-	if ( ! empty( $wp_local_package ) && isset( $languages[ $wp_local_package ] ) ) {
172
-		if ( isset( $languages[ $wp_local_package ] ) ) {
173
-			$language = $languages[ $wp_local_package ];
171
+	if (!empty($wp_local_package) && isset($languages[$wp_local_package])) {
172
+		if (isset($languages[$wp_local_package])) {
173
+			$language = $languages[$wp_local_package];
174 174
 			printf(
175 175
 				'<option value="%s" lang="%s" data-continue="%s"%s>%s</option>' . "\n",
176
-				esc_attr( $language['language'] ),
177
-				esc_attr( current( $language['iso'] ) ),
178
-				esc_attr( $language['strings']['continue'] ? $language['strings']['continue'] : 'Continue' ),
179
-				in_array( $language['language'], $installed_languages, true ) ? ' data-installed="1"' : '',
180
-				esc_html( $language['native_name'] )
176
+				esc_attr($language['language']),
177
+				esc_attr(current($language['iso'])),
178
+				esc_attr($language['strings']['continue'] ? $language['strings']['continue'] : 'Continue'),
179
+				in_array($language['language'], $installed_languages, true) ? ' data-installed="1"' : '',
180
+				esc_html($language['native_name'])
181 181
 			);
182 182
 
183
-			unset( $languages[ $wp_local_package ] );
183
+			unset($languages[$wp_local_package]);
184 184
 		}
185 185
 	}
186 186
 
187
-	foreach ( $languages as $language ) {
187
+	foreach ($languages as $language) {
188 188
 		printf(
189 189
 			'<option value="%s" lang="%s" data-continue="%s"%s>%s</option>' . "\n",
190
-			esc_attr( $language['language'] ),
191
-			esc_attr( current( $language['iso'] ) ),
192
-			esc_attr( $language['strings']['continue'] ? $language['strings']['continue'] : 'Continue' ),
193
-			in_array( $language['language'], $installed_languages, true ) ? ' data-installed="1"' : '',
194
-			esc_html( $language['native_name'] )
190
+			esc_attr($language['language']),
191
+			esc_attr(current($language['iso'])),
192
+			esc_attr($language['strings']['continue'] ? $language['strings']['continue'] : 'Continue'),
193
+			in_array($language['language'], $installed_languages, true) ? ' data-installed="1"' : '',
194
+			esc_html($language['native_name'])
195 195
 		);
196 196
 	}
197 197
 	echo "</select>\n";
@@ -209,40 +209,40 @@  discard block
 block discarded – undo
209 209
  * @return string|false Returns the language code if successfully downloaded
210 210
  *                      (or already installed), or false on failure.
211 211
  */
212
-function wp_download_language_pack( $download ) {
212
+function wp_download_language_pack($download) {
213 213
 	// Check if the translation is already installed.
214
-	if ( in_array( $download, get_available_languages(), true ) ) {
214
+	if (in_array($download, get_available_languages(), true)) {
215 215
 		return $download;
216 216
 	}
217 217
 
218
-	if ( ! wp_is_file_mod_allowed( 'download_language_pack' ) ) {
218
+	if (!wp_is_file_mod_allowed('download_language_pack')) {
219 219
 		return false;
220 220
 	}
221 221
 
222 222
 	// Confirm the translation is one we can download.
223 223
 	$translations = wp_get_available_translations();
224
-	if ( ! $translations ) {
224
+	if (!$translations) {
225 225
 		return false;
226 226
 	}
227
-	foreach ( $translations as $translation ) {
228
-		if ( $translation['language'] === $download ) {
227
+	foreach ($translations as $translation) {
228
+		if ($translation['language'] === $download) {
229 229
 			$translation_to_load = true;
230 230
 			break;
231 231
 		}
232 232
 	}
233 233
 
234
-	if ( empty( $translation_to_load ) ) {
234
+	if (empty($translation_to_load)) {
235 235
 		return false;
236 236
 	}
237 237
 	$translation = (object) $translation;
238 238
 
239 239
 	require_once ABSPATH . 'wp-admin/includes/class-wp-upgrader.php';
240 240
 	$skin              = new Automatic_Upgrader_Skin;
241
-	$upgrader          = new Language_Pack_Upgrader( $skin );
241
+	$upgrader          = new Language_Pack_Upgrader($skin);
242 242
 	$translation->type = 'core';
243
-	$result            = $upgrader->upgrade( $translation, array( 'clear_update_cache' => false ) );
243
+	$result            = $upgrader->upgrade($translation, array('clear_update_cache' => false));
244 244
 
245
-	if ( ! $result || is_wp_error( $result ) ) {
245
+	if (!$result || is_wp_error($result)) {
246 246
 		return false;
247 247
 	}
248 248
 
@@ -258,18 +258,18 @@  discard block
 block discarded – undo
258 258
  * @return bool Returns true on success, false on failure.
259 259
  */
260 260
 function wp_can_install_language_pack() {
261
-	if ( ! wp_is_file_mod_allowed( 'can_install_language_pack' ) ) {
261
+	if (!wp_is_file_mod_allowed('can_install_language_pack')) {
262 262
 		return false;
263 263
 	}
264 264
 
265 265
 	require_once ABSPATH . 'wp-admin/includes/class-wp-upgrader.php';
266 266
 	$skin     = new Automatic_Upgrader_Skin;
267
-	$upgrader = new Language_Pack_Upgrader( $skin );
267
+	$upgrader = new Language_Pack_Upgrader($skin);
268 268
 	$upgrader->init();
269 269
 
270
-	$check = $upgrader->fs_connect( array( WP_CONTENT_DIR, WP_LANG_DIR ) );
270
+	$check = $upgrader->fs_connect(array(WP_CONTENT_DIR, WP_LANG_DIR));
271 271
 
272
-	if ( ! $check || is_wp_error( $check ) ) {
272
+	if (!$check || is_wp_error($check)) {
273 273
 		return false;
274 274
 	}
275 275
 
Please login to merge, or discard this patch.
brighty/wp-admin/includes/theme.php 2 patches
Indentation   +797 added lines, -797 removed lines patch added patch discarded remove patch
@@ -19,116 +19,116 @@  discard block
 block discarded – undo
19 19
  *                            Null if filesystem credentials are required to proceed.
20 20
  */
21 21
 function delete_theme( $stylesheet, $redirect = '' ) {
22
-	global $wp_filesystem;
23
-
24
-	if ( empty( $stylesheet ) ) {
25
-		return false;
26
-	}
27
-
28
-	if ( empty( $redirect ) ) {
29
-		$redirect = wp_nonce_url( 'themes.php?action=delete&stylesheet=' . urlencode( $stylesheet ), 'delete-theme_' . $stylesheet );
30
-	}
31
-
32
-	ob_start();
33
-	$credentials = request_filesystem_credentials( $redirect );
34
-	$data        = ob_get_clean();
35
-
36
-	if ( false === $credentials ) {
37
-		if ( ! empty( $data ) ) {
38
-			require_once ABSPATH . 'wp-admin/admin-header.php';
39
-			echo $data;
40
-			require_once ABSPATH . 'wp-admin/admin-footer.php';
41
-			exit;
42
-		}
43
-		return;
44
-	}
45
-
46
-	if ( ! WP_Filesystem( $credentials ) ) {
47
-		ob_start();
48
-		// Failed to connect. Error and request again.
49
-		request_filesystem_credentials( $redirect, '', true );
50
-		$data = ob_get_clean();
51
-
52
-		if ( ! empty( $data ) ) {
53
-			require_once ABSPATH . 'wp-admin/admin-header.php';
54
-			echo $data;
55
-			require_once ABSPATH . 'wp-admin/admin-footer.php';
56
-			exit;
57
-		}
58
-		return;
59
-	}
60
-
61
-	if ( ! is_object( $wp_filesystem ) ) {
62
-		return new WP_Error( 'fs_unavailable', __( 'Could not access filesystem.' ) );
63
-	}
64
-
65
-	if ( is_wp_error( $wp_filesystem->errors ) && $wp_filesystem->errors->has_errors() ) {
66
-		return new WP_Error( 'fs_error', __( 'Filesystem error.' ), $wp_filesystem->errors );
67
-	}
68
-
69
-	// Get the base plugin folder.
70
-	$themes_dir = $wp_filesystem->wp_themes_dir();
71
-	if ( empty( $themes_dir ) ) {
72
-		return new WP_Error( 'fs_no_themes_dir', __( 'Unable to locate WordPress theme directory.' ) );
73
-	}
74
-
75
-	/**
76
-	 * Fires immediately before a theme deletion attempt.
77
-	 *
78
-	 * @since 5.8.0
79
-	 *
80
-	 * @param string $stylesheet Stylesheet of the theme to delete.
81
-	 */
82
-	do_action( 'delete_theme', $stylesheet );
83
-
84
-	$themes_dir = trailingslashit( $themes_dir );
85
-	$theme_dir  = trailingslashit( $themes_dir . $stylesheet );
86
-	$deleted    = $wp_filesystem->delete( $theme_dir, true );
87
-
88
-	/**
89
-	 * Fires immediately after a theme deletion attempt.
90
-	 *
91
-	 * @since 5.8.0
92
-	 *
93
-	 * @param string $stylesheet Stylesheet of the theme to delete.
94
-	 * @param bool   $deleted    Whether the theme deletion was successful.
95
-	 */
96
-	do_action( 'deleted_theme', $stylesheet, $deleted );
97
-
98
-	if ( ! $deleted ) {
99
-		return new WP_Error(
100
-			'could_not_remove_theme',
101
-			/* translators: %s: Theme name. */
102
-			sprintf( __( 'Could not fully remove the theme %s.' ), $stylesheet )
103
-		);
104
-	}
105
-
106
-	$theme_translations = wp_get_installed_translations( 'themes' );
107
-
108
-	// Remove language files, silently.
109
-	if ( ! empty( $theme_translations[ $stylesheet ] ) ) {
110
-		$translations = $theme_translations[ $stylesheet ];
111
-
112
-		foreach ( $translations as $translation => $data ) {
113
-			$wp_filesystem->delete( WP_LANG_DIR . '/themes/' . $stylesheet . '-' . $translation . '.po' );
114
-			$wp_filesystem->delete( WP_LANG_DIR . '/themes/' . $stylesheet . '-' . $translation . '.mo' );
115
-
116
-			$json_translation_files = glob( WP_LANG_DIR . '/themes/' . $stylesheet . '-' . $translation . '-*.json' );
117
-			if ( $json_translation_files ) {
118
-				array_map( array( $wp_filesystem, 'delete' ), $json_translation_files );
119
-			}
120
-		}
121
-	}
122
-
123
-	// Remove the theme from allowed themes on the network.
124
-	if ( is_multisite() ) {
125
-		WP_Theme::network_disable_theme( $stylesheet );
126
-	}
127
-
128
-	// Force refresh of theme update information.
129
-	delete_site_transient( 'update_themes' );
130
-
131
-	return true;
22
+    global $wp_filesystem;
23
+
24
+    if ( empty( $stylesheet ) ) {
25
+        return false;
26
+    }
27
+
28
+    if ( empty( $redirect ) ) {
29
+        $redirect = wp_nonce_url( 'themes.php?action=delete&stylesheet=' . urlencode( $stylesheet ), 'delete-theme_' . $stylesheet );
30
+    }
31
+
32
+    ob_start();
33
+    $credentials = request_filesystem_credentials( $redirect );
34
+    $data        = ob_get_clean();
35
+
36
+    if ( false === $credentials ) {
37
+        if ( ! empty( $data ) ) {
38
+            require_once ABSPATH . 'wp-admin/admin-header.php';
39
+            echo $data;
40
+            require_once ABSPATH . 'wp-admin/admin-footer.php';
41
+            exit;
42
+        }
43
+        return;
44
+    }
45
+
46
+    if ( ! WP_Filesystem( $credentials ) ) {
47
+        ob_start();
48
+        // Failed to connect. Error and request again.
49
+        request_filesystem_credentials( $redirect, '', true );
50
+        $data = ob_get_clean();
51
+
52
+        if ( ! empty( $data ) ) {
53
+            require_once ABSPATH . 'wp-admin/admin-header.php';
54
+            echo $data;
55
+            require_once ABSPATH . 'wp-admin/admin-footer.php';
56
+            exit;
57
+        }
58
+        return;
59
+    }
60
+
61
+    if ( ! is_object( $wp_filesystem ) ) {
62
+        return new WP_Error( 'fs_unavailable', __( 'Could not access filesystem.' ) );
63
+    }
64
+
65
+    if ( is_wp_error( $wp_filesystem->errors ) && $wp_filesystem->errors->has_errors() ) {
66
+        return new WP_Error( 'fs_error', __( 'Filesystem error.' ), $wp_filesystem->errors );
67
+    }
68
+
69
+    // Get the base plugin folder.
70
+    $themes_dir = $wp_filesystem->wp_themes_dir();
71
+    if ( empty( $themes_dir ) ) {
72
+        return new WP_Error( 'fs_no_themes_dir', __( 'Unable to locate WordPress theme directory.' ) );
73
+    }
74
+
75
+    /**
76
+     * Fires immediately before a theme deletion attempt.
77
+     *
78
+     * @since 5.8.0
79
+     *
80
+     * @param string $stylesheet Stylesheet of the theme to delete.
81
+     */
82
+    do_action( 'delete_theme', $stylesheet );
83
+
84
+    $themes_dir = trailingslashit( $themes_dir );
85
+    $theme_dir  = trailingslashit( $themes_dir . $stylesheet );
86
+    $deleted    = $wp_filesystem->delete( $theme_dir, true );
87
+
88
+    /**
89
+     * Fires immediately after a theme deletion attempt.
90
+     *
91
+     * @since 5.8.0
92
+     *
93
+     * @param string $stylesheet Stylesheet of the theme to delete.
94
+     * @param bool   $deleted    Whether the theme deletion was successful.
95
+     */
96
+    do_action( 'deleted_theme', $stylesheet, $deleted );
97
+
98
+    if ( ! $deleted ) {
99
+        return new WP_Error(
100
+            'could_not_remove_theme',
101
+            /* translators: %s: Theme name. */
102
+            sprintf( __( 'Could not fully remove the theme %s.' ), $stylesheet )
103
+        );
104
+    }
105
+
106
+    $theme_translations = wp_get_installed_translations( 'themes' );
107
+
108
+    // Remove language files, silently.
109
+    if ( ! empty( $theme_translations[ $stylesheet ] ) ) {
110
+        $translations = $theme_translations[ $stylesheet ];
111
+
112
+        foreach ( $translations as $translation => $data ) {
113
+            $wp_filesystem->delete( WP_LANG_DIR . '/themes/' . $stylesheet . '-' . $translation . '.po' );
114
+            $wp_filesystem->delete( WP_LANG_DIR . '/themes/' . $stylesheet . '-' . $translation . '.mo' );
115
+
116
+            $json_translation_files = glob( WP_LANG_DIR . '/themes/' . $stylesheet . '-' . $translation . '-*.json' );
117
+            if ( $json_translation_files ) {
118
+                array_map( array( $wp_filesystem, 'delete' ), $json_translation_files );
119
+            }
120
+        }
121
+    }
122
+
123
+    // Remove the theme from allowed themes on the network.
124
+    if ( is_multisite() ) {
125
+        WP_Theme::network_disable_theme( $stylesheet );
126
+    }
127
+
128
+    // Force refresh of theme update information.
129
+    delete_site_transient( 'update_themes' );
130
+
131
+    return true;
132 132
 }
133 133
 
134 134
 /**
@@ -142,7 +142,7 @@  discard block
 block discarded – undo
142 142
  * @return string[] Array of template file names keyed by the template header name.
143 143
  */
144 144
 function get_page_templates( $post = null, $post_type = 'page' ) {
145
-	return array_flip( wp_get_theme()->get_page_templates( $post, $post_type ) );
145
+    return array_flip( wp_get_theme()->get_page_templates( $post, $post_type ) );
146 146
 }
147 147
 
148 148
 /**
@@ -156,7 +156,7 @@  discard block
 block discarded – undo
156 156
  * @return string
157 157
  */
158 158
 function _get_template_edit_filename( $fullpath, $containingfolder ) {
159
-	return str_replace( dirname( dirname( $containingfolder ) ), '', $fullpath );
159
+    return str_replace( dirname( dirname( $containingfolder ) ), '', $fullpath );
160 160
 }
161 161
 
162 162
 /**
@@ -171,7 +171,7 @@  discard block
 block discarded – undo
171 171
  * @param WP_Theme $theme Theme data object.
172 172
  */
173 173
 function theme_update_available( $theme ) {
174
-	echo get_theme_update_available( $theme );
174
+    echo get_theme_update_available( $theme );
175 175
 }
176 176
 
177 177
 /**
@@ -185,89 +185,89 @@  discard block
 block discarded – undo
185 185
  * @return string|false HTML for the update link, or false if invalid info was passed.
186 186
  */
187 187
 function get_theme_update_available( $theme ) {
188
-	static $themes_update = null;
189
-
190
-	if ( ! current_user_can( 'update_themes' ) ) {
191
-		return false;
192
-	}
193
-
194
-	if ( ! isset( $themes_update ) ) {
195
-		$themes_update = get_site_transient( 'update_themes' );
196
-	}
197
-
198
-	if ( ! ( $theme instanceof WP_Theme ) ) {
199
-		return false;
200
-	}
201
-
202
-	$stylesheet = $theme->get_stylesheet();
203
-
204
-	$html = '';
205
-
206
-	if ( isset( $themes_update->response[ $stylesheet ] ) ) {
207
-		$update      = $themes_update->response[ $stylesheet ];
208
-		$theme_name  = $theme->display( 'Name' );
209
-		$details_url = add_query_arg(
210
-			array(
211
-				'TB_iframe' => 'true',
212
-				'width'     => 1024,
213
-				'height'    => 800,
214
-			),
215
-			$update['url']
216
-		); // Theme browser inside WP? Replace this. Also, theme preview JS will override this on the available list.
217
-		$update_url  = wp_nonce_url( admin_url( 'update.php?action=upgrade-theme&amp;theme=' . urlencode( $stylesheet ) ), 'upgrade-theme_' . $stylesheet );
218
-
219
-		if ( ! is_multisite() ) {
220
-			if ( ! current_user_can( 'update_themes' ) ) {
221
-				$html = sprintf(
222
-					/* translators: 1: Theme name, 2: Theme details URL, 3: Additional link attributes, 4: Version number. */
223
-					'<p><strong>' . __( 'There is a new version of %1$s available. <a href="%2$s" %3$s>View version %4$s details</a>.' ) . '</strong></p>',
224
-					$theme_name,
225
-					esc_url( $details_url ),
226
-					sprintf(
227
-						'class="thickbox open-plugin-details-modal" aria-label="%s"',
228
-						/* translators: 1: Theme name, 2: Version number. */
229
-						esc_attr( sprintf( __( 'View %1$s version %2$s details' ), $theme_name, $update['new_version'] ) )
230
-					),
231
-					$update['new_version']
232
-				);
233
-			} elseif ( empty( $update['package'] ) ) {
234
-				$html = sprintf(
235
-					/* translators: 1: Theme name, 2: Theme details URL, 3: Additional link attributes, 4: Version number. */
236
-					'<p><strong>' . __( 'There is a new version of %1$s available. <a href="%2$s" %3$s>View version %4$s details</a>. <em>Automatic update is unavailable for this theme.</em>' ) . '</strong></p>',
237
-					$theme_name,
238
-					esc_url( $details_url ),
239
-					sprintf(
240
-						'class="thickbox open-plugin-details-modal" aria-label="%s"',
241
-						/* translators: 1: Theme name, 2: Version number. */
242
-						esc_attr( sprintf( __( 'View %1$s version %2$s details' ), $theme_name, $update['new_version'] ) )
243
-					),
244
-					$update['new_version']
245
-				);
246
-			} else {
247
-				$html = sprintf(
248
-					/* translators: 1: Theme name, 2: Theme details URL, 3: Additional link attributes, 4: Version number, 5: Update URL, 6: Additional link attributes. */
249
-					'<p><strong>' . __( 'There is a new version of %1$s available. <a href="%2$s" %3$s>View version %4$s details</a> or <a href="%5$s" %6$s>update now</a>.' ) . '</strong></p>',
250
-					$theme_name,
251
-					esc_url( $details_url ),
252
-					sprintf(
253
-						'class="thickbox open-plugin-details-modal" aria-label="%s"',
254
-						/* translators: 1: Theme name, 2: Version number. */
255
-						esc_attr( sprintf( __( 'View %1$s version %2$s details' ), $theme_name, $update['new_version'] ) )
256
-					),
257
-					$update['new_version'],
258
-					$update_url,
259
-					sprintf(
260
-						'aria-label="%s" id="update-theme" data-slug="%s"',
261
-						/* translators: %s: Theme name. */
262
-						esc_attr( sprintf( _x( 'Update %s now', 'theme' ), $theme_name ) ),
263
-						$stylesheet
264
-					)
265
-				);
266
-			}
267
-		}
268
-	}
269
-
270
-	return $html;
188
+    static $themes_update = null;
189
+
190
+    if ( ! current_user_can( 'update_themes' ) ) {
191
+        return false;
192
+    }
193
+
194
+    if ( ! isset( $themes_update ) ) {
195
+        $themes_update = get_site_transient( 'update_themes' );
196
+    }
197
+
198
+    if ( ! ( $theme instanceof WP_Theme ) ) {
199
+        return false;
200
+    }
201
+
202
+    $stylesheet = $theme->get_stylesheet();
203
+
204
+    $html = '';
205
+
206
+    if ( isset( $themes_update->response[ $stylesheet ] ) ) {
207
+        $update      = $themes_update->response[ $stylesheet ];
208
+        $theme_name  = $theme->display( 'Name' );
209
+        $details_url = add_query_arg(
210
+            array(
211
+                'TB_iframe' => 'true',
212
+                'width'     => 1024,
213
+                'height'    => 800,
214
+            ),
215
+            $update['url']
216
+        ); // Theme browser inside WP? Replace this. Also, theme preview JS will override this on the available list.
217
+        $update_url  = wp_nonce_url( admin_url( 'update.php?action=upgrade-theme&amp;theme=' . urlencode( $stylesheet ) ), 'upgrade-theme_' . $stylesheet );
218
+
219
+        if ( ! is_multisite() ) {
220
+            if ( ! current_user_can( 'update_themes' ) ) {
221
+                $html = sprintf(
222
+                    /* translators: 1: Theme name, 2: Theme details URL, 3: Additional link attributes, 4: Version number. */
223
+                    '<p><strong>' . __( 'There is a new version of %1$s available. <a href="%2$s" %3$s>View version %4$s details</a>.' ) . '</strong></p>',
224
+                    $theme_name,
225
+                    esc_url( $details_url ),
226
+                    sprintf(
227
+                        'class="thickbox open-plugin-details-modal" aria-label="%s"',
228
+                        /* translators: 1: Theme name, 2: Version number. */
229
+                        esc_attr( sprintf( __( 'View %1$s version %2$s details' ), $theme_name, $update['new_version'] ) )
230
+                    ),
231
+                    $update['new_version']
232
+                );
233
+            } elseif ( empty( $update['package'] ) ) {
234
+                $html = sprintf(
235
+                    /* translators: 1: Theme name, 2: Theme details URL, 3: Additional link attributes, 4: Version number. */
236
+                    '<p><strong>' . __( 'There is a new version of %1$s available. <a href="%2$s" %3$s>View version %4$s details</a>. <em>Automatic update is unavailable for this theme.</em>' ) . '</strong></p>',
237
+                    $theme_name,
238
+                    esc_url( $details_url ),
239
+                    sprintf(
240
+                        'class="thickbox open-plugin-details-modal" aria-label="%s"',
241
+                        /* translators: 1: Theme name, 2: Version number. */
242
+                        esc_attr( sprintf( __( 'View %1$s version %2$s details' ), $theme_name, $update['new_version'] ) )
243
+                    ),
244
+                    $update['new_version']
245
+                );
246
+            } else {
247
+                $html = sprintf(
248
+                    /* translators: 1: Theme name, 2: Theme details URL, 3: Additional link attributes, 4: Version number, 5: Update URL, 6: Additional link attributes. */
249
+                    '<p><strong>' . __( 'There is a new version of %1$s available. <a href="%2$s" %3$s>View version %4$s details</a> or <a href="%5$s" %6$s>update now</a>.' ) . '</strong></p>',
250
+                    $theme_name,
251
+                    esc_url( $details_url ),
252
+                    sprintf(
253
+                        'class="thickbox open-plugin-details-modal" aria-label="%s"',
254
+                        /* translators: 1: Theme name, 2: Version number. */
255
+                        esc_attr( sprintf( __( 'View %1$s version %2$s details' ), $theme_name, $update['new_version'] ) )
256
+                    ),
257
+                    $update['new_version'],
258
+                    $update_url,
259
+                    sprintf(
260
+                        'aria-label="%s" id="update-theme" data-slug="%s"',
261
+                        /* translators: %s: Theme name. */
262
+                        esc_attr( sprintf( _x( 'Update %s now', 'theme' ), $theme_name ) ),
263
+                        $stylesheet
264
+                    )
265
+                );
266
+            }
267
+        }
268
+    }
269
+
270
+    return $html;
271 271
 }
272 272
 
273 273
 /**
@@ -304,102 +304,102 @@  discard block
 block discarded – undo
304 304
  * @return array Array of features keyed by category with translations keyed by slug.
305 305
  */
306 306
 function get_theme_feature_list( $api = true ) {
307
-	// Hard-coded list is used if API is not accessible.
308
-	$features = array(
309
-
310
-		__( 'Subject' )  => array(
311
-			'blog'           => __( 'Blog' ),
312
-			'e-commerce'     => __( 'E-Commerce' ),
313
-			'education'      => __( 'Education' ),
314
-			'entertainment'  => __( 'Entertainment' ),
315
-			'food-and-drink' => __( 'Food & Drink' ),
316
-			'holiday'        => __( 'Holiday' ),
317
-			'news'           => __( 'News' ),
318
-			'photography'    => __( 'Photography' ),
319
-			'portfolio'      => __( 'Portfolio' ),
320
-		),
321
-
322
-		__( 'Features' ) => array(
323
-			'accessibility-ready'   => __( 'Accessibility Ready' ),
324
-			'block-patterns'        => __( 'Block Editor Patterns' ),
325
-			'block-styles'          => __( 'Block Editor Styles' ),
326
-			'custom-background'     => __( 'Custom Background' ),
327
-			'custom-colors'         => __( 'Custom Colors' ),
328
-			'custom-header'         => __( 'Custom Header' ),
329
-			'custom-logo'           => __( 'Custom Logo' ),
330
-			'editor-style'          => __( 'Editor Style' ),
331
-			'featured-image-header' => __( 'Featured Image Header' ),
332
-			'featured-images'       => __( 'Featured Images' ),
333
-			'footer-widgets'        => __( 'Footer Widgets' ),
334
-			'full-site-editing'     => __( 'Full Site Editing' ),
335
-			'full-width-template'   => __( 'Full Width Template' ),
336
-			'post-formats'          => __( 'Post Formats' ),
337
-			'sticky-post'           => __( 'Sticky Post' ),
338
-			'template-editing'      => __( 'Template Editing' ),
339
-			'theme-options'         => __( 'Theme Options' ),
340
-		),
341
-
342
-		__( 'Layout' )   => array(
343
-			'grid-layout'   => __( 'Grid Layout' ),
344
-			'one-column'    => __( 'One Column' ),
345
-			'two-columns'   => __( 'Two Columns' ),
346
-			'three-columns' => __( 'Three Columns' ),
347
-			'four-columns'  => __( 'Four Columns' ),
348
-			'left-sidebar'  => __( 'Left Sidebar' ),
349
-			'right-sidebar' => __( 'Right Sidebar' ),
350
-			'wide-blocks'   => __( 'Wide Blocks' ),
351
-		),
352
-
353
-	);
354
-
355
-	if ( ! $api || ! current_user_can( 'install_themes' ) ) {
356
-		return $features;
357
-	}
358
-
359
-	$feature_list = get_site_transient( 'wporg_theme_feature_list' );
360
-	if ( ! $feature_list ) {
361
-		set_site_transient( 'wporg_theme_feature_list', array(), 3 * HOUR_IN_SECONDS );
362
-	}
363
-
364
-	if ( ! $feature_list ) {
365
-		$feature_list = themes_api( 'feature_list', array() );
366
-		if ( is_wp_error( $feature_list ) ) {
367
-			return $features;
368
-		}
369
-	}
370
-
371
-	if ( ! $feature_list ) {
372
-		return $features;
373
-	}
374
-
375
-	set_site_transient( 'wporg_theme_feature_list', $feature_list, 3 * HOUR_IN_SECONDS );
376
-
377
-	$category_translations = array(
378
-		'Layout'   => __( 'Layout' ),
379
-		'Features' => __( 'Features' ),
380
-		'Subject'  => __( 'Subject' ),
381
-	);
382
-
383
-	$wporg_features = array();
384
-
385
-	// Loop over the wp.org canonical list and apply translations.
386
-	foreach ( (array) $feature_list as $feature_category => $feature_items ) {
387
-		if ( isset( $category_translations[ $feature_category ] ) ) {
388
-			$feature_category = $category_translations[ $feature_category ];
389
-		}
390
-
391
-		$wporg_features[ $feature_category ] = array();
392
-
393
-		foreach ( $feature_items as $feature ) {
394
-			if ( isset( $features[ $feature_category ][ $feature ] ) ) {
395
-				$wporg_features[ $feature_category ][ $feature ] = $features[ $feature_category ][ $feature ];
396
-			} else {
397
-				$wporg_features[ $feature_category ][ $feature ] = $feature;
398
-			}
399
-		}
400
-	}
401
-
402
-	return $wporg_features;
307
+    // Hard-coded list is used if API is not accessible.
308
+    $features = array(
309
+
310
+        __( 'Subject' )  => array(
311
+            'blog'           => __( 'Blog' ),
312
+            'e-commerce'     => __( 'E-Commerce' ),
313
+            'education'      => __( 'Education' ),
314
+            'entertainment'  => __( 'Entertainment' ),
315
+            'food-and-drink' => __( 'Food & Drink' ),
316
+            'holiday'        => __( 'Holiday' ),
317
+            'news'           => __( 'News' ),
318
+            'photography'    => __( 'Photography' ),
319
+            'portfolio'      => __( 'Portfolio' ),
320
+        ),
321
+
322
+        __( 'Features' ) => array(
323
+            'accessibility-ready'   => __( 'Accessibility Ready' ),
324
+            'block-patterns'        => __( 'Block Editor Patterns' ),
325
+            'block-styles'          => __( 'Block Editor Styles' ),
326
+            'custom-background'     => __( 'Custom Background' ),
327
+            'custom-colors'         => __( 'Custom Colors' ),
328
+            'custom-header'         => __( 'Custom Header' ),
329
+            'custom-logo'           => __( 'Custom Logo' ),
330
+            'editor-style'          => __( 'Editor Style' ),
331
+            'featured-image-header' => __( 'Featured Image Header' ),
332
+            'featured-images'       => __( 'Featured Images' ),
333
+            'footer-widgets'        => __( 'Footer Widgets' ),
334
+            'full-site-editing'     => __( 'Full Site Editing' ),
335
+            'full-width-template'   => __( 'Full Width Template' ),
336
+            'post-formats'          => __( 'Post Formats' ),
337
+            'sticky-post'           => __( 'Sticky Post' ),
338
+            'template-editing'      => __( 'Template Editing' ),
339
+            'theme-options'         => __( 'Theme Options' ),
340
+        ),
341
+
342
+        __( 'Layout' )   => array(
343
+            'grid-layout'   => __( 'Grid Layout' ),
344
+            'one-column'    => __( 'One Column' ),
345
+            'two-columns'   => __( 'Two Columns' ),
346
+            'three-columns' => __( 'Three Columns' ),
347
+            'four-columns'  => __( 'Four Columns' ),
348
+            'left-sidebar'  => __( 'Left Sidebar' ),
349
+            'right-sidebar' => __( 'Right Sidebar' ),
350
+            'wide-blocks'   => __( 'Wide Blocks' ),
351
+        ),
352
+
353
+    );
354
+
355
+    if ( ! $api || ! current_user_can( 'install_themes' ) ) {
356
+        return $features;
357
+    }
358
+
359
+    $feature_list = get_site_transient( 'wporg_theme_feature_list' );
360
+    if ( ! $feature_list ) {
361
+        set_site_transient( 'wporg_theme_feature_list', array(), 3 * HOUR_IN_SECONDS );
362
+    }
363
+
364
+    if ( ! $feature_list ) {
365
+        $feature_list = themes_api( 'feature_list', array() );
366
+        if ( is_wp_error( $feature_list ) ) {
367
+            return $features;
368
+        }
369
+    }
370
+
371
+    if ( ! $feature_list ) {
372
+        return $features;
373
+    }
374
+
375
+    set_site_transient( 'wporg_theme_feature_list', $feature_list, 3 * HOUR_IN_SECONDS );
376
+
377
+    $category_translations = array(
378
+        'Layout'   => __( 'Layout' ),
379
+        'Features' => __( 'Features' ),
380
+        'Subject'  => __( 'Subject' ),
381
+    );
382
+
383
+    $wporg_features = array();
384
+
385
+    // Loop over the wp.org canonical list and apply translations.
386
+    foreach ( (array) $feature_list as $feature_category => $feature_items ) {
387
+        if ( isset( $category_translations[ $feature_category ] ) ) {
388
+            $feature_category = $category_translations[ $feature_category ];
389
+        }
390
+
391
+        $wporg_features[ $feature_category ] = array();
392
+
393
+        foreach ( $feature_items as $feature ) {
394
+            if ( isset( $features[ $feature_category ][ $feature ] ) ) {
395
+                $wporg_features[ $feature_category ][ $feature ] = $features[ $feature_category ][ $feature ];
396
+            } else {
397
+                $wporg_features[ $feature_category ][ $feature ] = $feature;
398
+            }
399
+        }
400
+    }
401
+
402
+    return $wporg_features;
403 403
 }
404 404
 
405 405
 /**
@@ -484,150 +484,150 @@  discard block
 block discarded – undo
484 484
  *         for more information on the make-up of possible return objects depending on the value of `$action`.
485 485
  */
486 486
 function themes_api( $action, $args = array() ) {
487
-	// Include an unmodified $wp_version.
488
-	require ABSPATH . WPINC . '/version.php';
489
-
490
-	if ( is_array( $args ) ) {
491
-		$args = (object) $args;
492
-	}
493
-
494
-	if ( 'query_themes' === $action ) {
495
-		if ( ! isset( $args->per_page ) ) {
496
-			$args->per_page = 24;
497
-		}
498
-	}
499
-
500
-	if ( ! isset( $args->locale ) ) {
501
-		$args->locale = get_user_locale();
502
-	}
503
-
504
-	if ( ! isset( $args->wp_version ) ) {
505
-		$args->wp_version = substr( $wp_version, 0, 3 ); // x.y
506
-	}
507
-
508
-	/**
509
-	 * Filters arguments used to query for installer pages from the WordPress.org Themes API.
510
-	 *
511
-	 * Important: An object MUST be returned to this filter.
512
-	 *
513
-	 * @since 2.8.0
514
-	 *
515
-	 * @param object $args   Arguments used to query for installer pages from the WordPress.org Themes API.
516
-	 * @param string $action Requested action. Likely values are 'theme_information',
517
-	 *                       'feature_list', or 'query_themes'.
518
-	 */
519
-	$args = apply_filters( 'themes_api_args', $args, $action );
520
-
521
-	/**
522
-	 * Filters whether to override the WordPress.org Themes API.
523
-	 *
524
-	 * Returning a non-false value will effectively short-circuit the WordPress.org API request.
525
-	 *
526
-	 * If `$action` is 'query_themes', 'theme_information', or 'feature_list', an object MUST
527
-	 * be passed. If `$action` is 'hot_tags', an array should be passed.
528
-	 *
529
-	 * @since 2.8.0
530
-	 *
531
-	 * @param false|object|array $override Whether to override the WordPress.org Themes API. Default false.
532
-	 * @param string             $action   Requested action. Likely values are 'theme_information',
533
-	 *                                    'feature_list', or 'query_themes'.
534
-	 * @param object             $args     Arguments used to query for installer pages from the Themes API.
535
-	 */
536
-	$res = apply_filters( 'themes_api', false, $action, $args );
537
-
538
-	if ( ! $res ) {
539
-		$url = 'http://api.wordpress.org/themes/info/1.2/';
540
-		$url = add_query_arg(
541
-			array(
542
-				'action'  => $action,
543
-				'request' => $args,
544
-			),
545
-			$url
546
-		);
547
-
548
-		$http_url = $url;
549
-		$ssl      = wp_http_supports( array( 'ssl' ) );
550
-		if ( $ssl ) {
551
-			$url = set_url_scheme( $url, 'https' );
552
-		}
553
-
554
-		$http_args = array(
555
-			'user-agent' => 'WordPress/' . $wp_version . '; ' . home_url( '/' ),
556
-		);
557
-		$request   = wp_remote_get( $url, $http_args );
558
-
559
-		if ( $ssl && is_wp_error( $request ) ) {
560
-			if ( ! wp_doing_ajax() ) {
561
-				trigger_error(
562
-					sprintf(
563
-						/* translators: %s: Support forums URL. */
564
-						__( 'An unexpected error occurred. Something may be wrong with WordPress.org or this server&#8217;s configuration. If you continue to have problems, please try the <a href="%s">support forums</a>.' ),
565
-						__( 'https://wordpress.org/support/forums/' )
566
-					) . ' ' . __( '(WordPress could not establish a secure connection to WordPress.org. Please contact your server administrator.)' ),
567
-					headers_sent() || WP_DEBUG ? E_USER_WARNING : E_USER_NOTICE
568
-				);
569
-			}
570
-			$request = wp_remote_get( $http_url, $http_args );
571
-		}
572
-
573
-		if ( is_wp_error( $request ) ) {
574
-			$res = new WP_Error(
575
-				'themes_api_failed',
576
-				sprintf(
577
-					/* translators: %s: Support forums URL. */
578
-					__( 'An unexpected error occurred. Something may be wrong with WordPress.org or this server&#8217;s configuration. If you continue to have problems, please try the <a href="%s">support forums</a>.' ),
579
-					__( 'https://wordpress.org/support/forums/' )
580
-				),
581
-				$request->get_error_message()
582
-			);
583
-		} else {
584
-			$res = json_decode( wp_remote_retrieve_body( $request ), true );
585
-			if ( is_array( $res ) ) {
586
-				// Object casting is required in order to match the info/1.0 format.
587
-				$res = (object) $res;
588
-			} elseif ( null === $res ) {
589
-				$res = new WP_Error(
590
-					'themes_api_failed',
591
-					sprintf(
592
-						/* translators: %s: Support forums URL. */
593
-						__( 'An unexpected error occurred. Something may be wrong with WordPress.org or this server&#8217;s configuration. If you continue to have problems, please try the <a href="%s">support forums</a>.' ),
594
-						__( 'https://wordpress.org/support/forums/' )
595
-					),
596
-					wp_remote_retrieve_body( $request )
597
-				);
598
-			}
599
-
600
-			if ( isset( $res->error ) ) {
601
-				$res = new WP_Error( 'themes_api_failed', $res->error );
602
-			}
603
-		}
604
-
605
-		if ( ! is_wp_error( $res ) ) {
606
-			// Back-compat for info/1.2 API, upgrade the theme objects in query_themes to objects.
607
-			if ( 'query_themes' === $action ) {
608
-				foreach ( $res->themes as $i => $theme ) {
609
-					$res->themes[ $i ] = (object) $theme;
610
-				}
611
-			}
612
-
613
-			// Back-compat for info/1.2 API, downgrade the feature_list result back to an array.
614
-			if ( 'feature_list' === $action ) {
615
-				$res = (array) $res;
616
-			}
617
-		}
618
-	}
619
-
620
-	/**
621
-	 * Filters the returned WordPress.org Themes API response.
622
-	 *
623
-	 * @since 2.8.0
624
-	 *
625
-	 * @param array|stdClass|WP_Error $res    WordPress.org Themes API response.
626
-	 * @param string                  $action Requested action. Likely values are 'theme_information',
627
-	 *                                        'feature_list', or 'query_themes'.
628
-	 * @param stdClass                $args   Arguments used to query for installer pages from the WordPress.org Themes API.
629
-	 */
630
-	return apply_filters( 'themes_api_result', $res, $action, $args );
487
+    // Include an unmodified $wp_version.
488
+    require ABSPATH . WPINC . '/version.php';
489
+
490
+    if ( is_array( $args ) ) {
491
+        $args = (object) $args;
492
+    }
493
+
494
+    if ( 'query_themes' === $action ) {
495
+        if ( ! isset( $args->per_page ) ) {
496
+            $args->per_page = 24;
497
+        }
498
+    }
499
+
500
+    if ( ! isset( $args->locale ) ) {
501
+        $args->locale = get_user_locale();
502
+    }
503
+
504
+    if ( ! isset( $args->wp_version ) ) {
505
+        $args->wp_version = substr( $wp_version, 0, 3 ); // x.y
506
+    }
507
+
508
+    /**
509
+     * Filters arguments used to query for installer pages from the WordPress.org Themes API.
510
+     *
511
+     * Important: An object MUST be returned to this filter.
512
+     *
513
+     * @since 2.8.0
514
+     *
515
+     * @param object $args   Arguments used to query for installer pages from the WordPress.org Themes API.
516
+     * @param string $action Requested action. Likely values are 'theme_information',
517
+     *                       'feature_list', or 'query_themes'.
518
+     */
519
+    $args = apply_filters( 'themes_api_args', $args, $action );
520
+
521
+    /**
522
+     * Filters whether to override the WordPress.org Themes API.
523
+     *
524
+     * Returning a non-false value will effectively short-circuit the WordPress.org API request.
525
+     *
526
+     * If `$action` is 'query_themes', 'theme_information', or 'feature_list', an object MUST
527
+     * be passed. If `$action` is 'hot_tags', an array should be passed.
528
+     *
529
+     * @since 2.8.0
530
+     *
531
+     * @param false|object|array $override Whether to override the WordPress.org Themes API. Default false.
532
+     * @param string             $action   Requested action. Likely values are 'theme_information',
533
+     *                                    'feature_list', or 'query_themes'.
534
+     * @param object             $args     Arguments used to query for installer pages from the Themes API.
535
+     */
536
+    $res = apply_filters( 'themes_api', false, $action, $args );
537
+
538
+    if ( ! $res ) {
539
+        $url = 'http://api.wordpress.org/themes/info/1.2/';
540
+        $url = add_query_arg(
541
+            array(
542
+                'action'  => $action,
543
+                'request' => $args,
544
+            ),
545
+            $url
546
+        );
547
+
548
+        $http_url = $url;
549
+        $ssl      = wp_http_supports( array( 'ssl' ) );
550
+        if ( $ssl ) {
551
+            $url = set_url_scheme( $url, 'https' );
552
+        }
553
+
554
+        $http_args = array(
555
+            'user-agent' => 'WordPress/' . $wp_version . '; ' . home_url( '/' ),
556
+        );
557
+        $request   = wp_remote_get( $url, $http_args );
558
+
559
+        if ( $ssl && is_wp_error( $request ) ) {
560
+            if ( ! wp_doing_ajax() ) {
561
+                trigger_error(
562
+                    sprintf(
563
+                        /* translators: %s: Support forums URL. */
564
+                        __( 'An unexpected error occurred. Something may be wrong with WordPress.org or this server&#8217;s configuration. If you continue to have problems, please try the <a href="%s">support forums</a>.' ),
565
+                        __( 'https://wordpress.org/support/forums/' )
566
+                    ) . ' ' . __( '(WordPress could not establish a secure connection to WordPress.org. Please contact your server administrator.)' ),
567
+                    headers_sent() || WP_DEBUG ? E_USER_WARNING : E_USER_NOTICE
568
+                );
569
+            }
570
+            $request = wp_remote_get( $http_url, $http_args );
571
+        }
572
+
573
+        if ( is_wp_error( $request ) ) {
574
+            $res = new WP_Error(
575
+                'themes_api_failed',
576
+                sprintf(
577
+                    /* translators: %s: Support forums URL. */
578
+                    __( 'An unexpected error occurred. Something may be wrong with WordPress.org or this server&#8217;s configuration. If you continue to have problems, please try the <a href="%s">support forums</a>.' ),
579
+                    __( 'https://wordpress.org/support/forums/' )
580
+                ),
581
+                $request->get_error_message()
582
+            );
583
+        } else {
584
+            $res = json_decode( wp_remote_retrieve_body( $request ), true );
585
+            if ( is_array( $res ) ) {
586
+                // Object casting is required in order to match the info/1.0 format.
587
+                $res = (object) $res;
588
+            } elseif ( null === $res ) {
589
+                $res = new WP_Error(
590
+                    'themes_api_failed',
591
+                    sprintf(
592
+                        /* translators: %s: Support forums URL. */
593
+                        __( 'An unexpected error occurred. Something may be wrong with WordPress.org or this server&#8217;s configuration. If you continue to have problems, please try the <a href="%s">support forums</a>.' ),
594
+                        __( 'https://wordpress.org/support/forums/' )
595
+                    ),
596
+                    wp_remote_retrieve_body( $request )
597
+                );
598
+            }
599
+
600
+            if ( isset( $res->error ) ) {
601
+                $res = new WP_Error( 'themes_api_failed', $res->error );
602
+            }
603
+        }
604
+
605
+        if ( ! is_wp_error( $res ) ) {
606
+            // Back-compat for info/1.2 API, upgrade the theme objects in query_themes to objects.
607
+            if ( 'query_themes' === $action ) {
608
+                foreach ( $res->themes as $i => $theme ) {
609
+                    $res->themes[ $i ] = (object) $theme;
610
+                }
611
+            }
612
+
613
+            // Back-compat for info/1.2 API, downgrade the feature_list result back to an array.
614
+            if ( 'feature_list' === $action ) {
615
+                $res = (array) $res;
616
+            }
617
+        }
618
+    }
619
+
620
+    /**
621
+     * Filters the returned WordPress.org Themes API response.
622
+     *
623
+     * @since 2.8.0
624
+     *
625
+     * @param array|stdClass|WP_Error $res    WordPress.org Themes API response.
626
+     * @param string                  $action Requested action. Likely values are 'theme_information',
627
+     *                                        'feature_list', or 'query_themes'.
628
+     * @param stdClass                $args   Arguments used to query for installer pages from the WordPress.org Themes API.
629
+     */
630
+    return apply_filters( 'themes_api_result', $res, $action, $args );
631 631
 }
632 632
 
633 633
 /**
@@ -641,168 +641,168 @@  discard block
 block discarded – undo
641 641
  * @return array An associative array of theme data, sorted by name.
642 642
  */
643 643
 function wp_prepare_themes_for_js( $themes = null ) {
644
-	$current_theme = get_stylesheet();
645
-
646
-	/**
647
-	 * Filters theme data before it is prepared for JavaScript.
648
-	 *
649
-	 * Passing a non-empty array will result in wp_prepare_themes_for_js() returning
650
-	 * early with that value instead.
651
-	 *
652
-	 * @since 4.2.0
653
-	 *
654
-	 * @param array           $prepared_themes An associative array of theme data. Default empty array.
655
-	 * @param WP_Theme[]|null $themes          An array of theme objects to prepare, if any.
656
-	 * @param string          $current_theme   The active theme slug.
657
-	 */
658
-	$prepared_themes = (array) apply_filters( 'pre_prepare_themes_for_js', array(), $themes, $current_theme );
659
-
660
-	if ( ! empty( $prepared_themes ) ) {
661
-		return $prepared_themes;
662
-	}
663
-
664
-	// Make sure the active theme is listed first.
665
-	$prepared_themes[ $current_theme ] = array();
666
-
667
-	if ( null === $themes ) {
668
-		$themes = wp_get_themes( array( 'allowed' => true ) );
669
-		if ( ! isset( $themes[ $current_theme ] ) ) {
670
-			$themes[ $current_theme ] = wp_get_theme();
671
-		}
672
-	}
673
-
674
-	$updates    = array();
675
-	$no_updates = array();
676
-	if ( ! is_multisite() && current_user_can( 'update_themes' ) ) {
677
-		$updates_transient = get_site_transient( 'update_themes' );
678
-		if ( isset( $updates_transient->response ) ) {
679
-			$updates = $updates_transient->response;
680
-		}
681
-		if ( isset( $updates_transient->no_update ) ) {
682
-			$no_updates = $updates_transient->no_update;
683
-		}
684
-	}
685
-
686
-	WP_Theme::sort_by_name( $themes );
687
-
688
-	$parents = array();
689
-
690
-	$auto_updates = (array) get_site_option( 'auto_update_themes', array() );
691
-
692
-	foreach ( $themes as $theme ) {
693
-		$slug         = $theme->get_stylesheet();
694
-		$encoded_slug = urlencode( $slug );
695
-
696
-		$parent = false;
697
-		if ( $theme->parent() ) {
698
-			$parent           = $theme->parent();
699
-			$parents[ $slug ] = $parent->get_stylesheet();
700
-			$parent           = $parent->display( 'Name' );
701
-		}
702
-
703
-		$customize_action = null;
704
-
705
-		$can_edit_theme_options = current_user_can( 'edit_theme_options' );
706
-		$can_customize          = current_user_can( 'customize' );
707
-		$is_block_theme         = $theme->is_block_theme();
708
-
709
-		if ( $is_block_theme && $can_edit_theme_options ) {
710
-			$customize_action = esc_url( admin_url( 'site-editor.php' ) );
711
-		} elseif ( ! $is_block_theme && $can_customize && $can_edit_theme_options ) {
712
-			$customize_action = esc_url(
713
-				add_query_arg(
714
-					array(
715
-						'return' => urlencode( esc_url_raw( remove_query_arg( wp_removable_query_args(), wp_unslash( $_SERVER['REQUEST_URI'] ) ) ) ),
716
-					),
717
-					wp_customize_url( $slug )
718
-				)
719
-			);
720
-		}
721
-
722
-		$update_requires_wp  = isset( $updates[ $slug ]['requires'] ) ? $updates[ $slug ]['requires'] : null;
723
-		$update_requires_php = isset( $updates[ $slug ]['requires_php'] ) ? $updates[ $slug ]['requires_php'] : null;
724
-
725
-		$auto_update        = in_array( $slug, $auto_updates, true );
726
-		$auto_update_action = $auto_update ? 'disable-auto-update' : 'enable-auto-update';
727
-
728
-		if ( isset( $updates[ $slug ] ) ) {
729
-			$auto_update_supported      = true;
730
-			$auto_update_filter_payload = (object) $updates[ $slug ];
731
-		} elseif ( isset( $no_updates[ $slug ] ) ) {
732
-			$auto_update_supported      = true;
733
-			$auto_update_filter_payload = (object) $no_updates[ $slug ];
734
-		} else {
735
-			$auto_update_supported = false;
736
-			/*
644
+    $current_theme = get_stylesheet();
645
+
646
+    /**
647
+     * Filters theme data before it is prepared for JavaScript.
648
+     *
649
+     * Passing a non-empty array will result in wp_prepare_themes_for_js() returning
650
+     * early with that value instead.
651
+     *
652
+     * @since 4.2.0
653
+     *
654
+     * @param array           $prepared_themes An associative array of theme data. Default empty array.
655
+     * @param WP_Theme[]|null $themes          An array of theme objects to prepare, if any.
656
+     * @param string          $current_theme   The active theme slug.
657
+     */
658
+    $prepared_themes = (array) apply_filters( 'pre_prepare_themes_for_js', array(), $themes, $current_theme );
659
+
660
+    if ( ! empty( $prepared_themes ) ) {
661
+        return $prepared_themes;
662
+    }
663
+
664
+    // Make sure the active theme is listed first.
665
+    $prepared_themes[ $current_theme ] = array();
666
+
667
+    if ( null === $themes ) {
668
+        $themes = wp_get_themes( array( 'allowed' => true ) );
669
+        if ( ! isset( $themes[ $current_theme ] ) ) {
670
+            $themes[ $current_theme ] = wp_get_theme();
671
+        }
672
+    }
673
+
674
+    $updates    = array();
675
+    $no_updates = array();
676
+    if ( ! is_multisite() && current_user_can( 'update_themes' ) ) {
677
+        $updates_transient = get_site_transient( 'update_themes' );
678
+        if ( isset( $updates_transient->response ) ) {
679
+            $updates = $updates_transient->response;
680
+        }
681
+        if ( isset( $updates_transient->no_update ) ) {
682
+            $no_updates = $updates_transient->no_update;
683
+        }
684
+    }
685
+
686
+    WP_Theme::sort_by_name( $themes );
687
+
688
+    $parents = array();
689
+
690
+    $auto_updates = (array) get_site_option( 'auto_update_themes', array() );
691
+
692
+    foreach ( $themes as $theme ) {
693
+        $slug         = $theme->get_stylesheet();
694
+        $encoded_slug = urlencode( $slug );
695
+
696
+        $parent = false;
697
+        if ( $theme->parent() ) {
698
+            $parent           = $theme->parent();
699
+            $parents[ $slug ] = $parent->get_stylesheet();
700
+            $parent           = $parent->display( 'Name' );
701
+        }
702
+
703
+        $customize_action = null;
704
+
705
+        $can_edit_theme_options = current_user_can( 'edit_theme_options' );
706
+        $can_customize          = current_user_can( 'customize' );
707
+        $is_block_theme         = $theme->is_block_theme();
708
+
709
+        if ( $is_block_theme && $can_edit_theme_options ) {
710
+            $customize_action = esc_url( admin_url( 'site-editor.php' ) );
711
+        } elseif ( ! $is_block_theme && $can_customize && $can_edit_theme_options ) {
712
+            $customize_action = esc_url(
713
+                add_query_arg(
714
+                    array(
715
+                        'return' => urlencode( esc_url_raw( remove_query_arg( wp_removable_query_args(), wp_unslash( $_SERVER['REQUEST_URI'] ) ) ) ),
716
+                    ),
717
+                    wp_customize_url( $slug )
718
+                )
719
+            );
720
+        }
721
+
722
+        $update_requires_wp  = isset( $updates[ $slug ]['requires'] ) ? $updates[ $slug ]['requires'] : null;
723
+        $update_requires_php = isset( $updates[ $slug ]['requires_php'] ) ? $updates[ $slug ]['requires_php'] : null;
724
+
725
+        $auto_update        = in_array( $slug, $auto_updates, true );
726
+        $auto_update_action = $auto_update ? 'disable-auto-update' : 'enable-auto-update';
727
+
728
+        if ( isset( $updates[ $slug ] ) ) {
729
+            $auto_update_supported      = true;
730
+            $auto_update_filter_payload = (object) $updates[ $slug ];
731
+        } elseif ( isset( $no_updates[ $slug ] ) ) {
732
+            $auto_update_supported      = true;
733
+            $auto_update_filter_payload = (object) $no_updates[ $slug ];
734
+        } else {
735
+            $auto_update_supported = false;
736
+            /*
737 737
 			 * Create the expected payload for the auto_update_theme filter, this is the same data
738 738
 			 * as contained within $updates or $no_updates but used when the Theme is not known.
739 739
 			 */
740
-			$auto_update_filter_payload = (object) array(
741
-				'theme'        => $slug,
742
-				'new_version'  => $theme->get( 'Version' ),
743
-				'url'          => '',
744
-				'package'      => '',
745
-				'requires'     => $theme->get( 'RequiresWP' ),
746
-				'requires_php' => $theme->get( 'RequiresPHP' ),
747
-			);
748
-		}
749
-
750
-		$auto_update_forced = wp_is_auto_update_forced_for_item( 'theme', null, $auto_update_filter_payload );
751
-
752
-		$prepared_themes[ $slug ] = array(
753
-			'id'             => $slug,
754
-			'name'           => $theme->display( 'Name' ),
755
-			'screenshot'     => array( $theme->get_screenshot() ), // @todo Multiple screenshots.
756
-			'description'    => $theme->display( 'Description' ),
757
-			'author'         => $theme->display( 'Author', false, true ),
758
-			'authorAndUri'   => $theme->display( 'Author' ),
759
-			'tags'           => $theme->display( 'Tags' ),
760
-			'version'        => $theme->get( 'Version' ),
761
-			'compatibleWP'   => is_wp_version_compatible( $theme->get( 'RequiresWP' ) ),
762
-			'compatiblePHP'  => is_php_version_compatible( $theme->get( 'RequiresPHP' ) ),
763
-			'updateResponse' => array(
764
-				'compatibleWP'  => is_wp_version_compatible( $update_requires_wp ),
765
-				'compatiblePHP' => is_php_version_compatible( $update_requires_php ),
766
-			),
767
-			'parent'         => $parent,
768
-			'active'         => $slug === $current_theme,
769
-			'hasUpdate'      => isset( $updates[ $slug ] ),
770
-			'hasPackage'     => isset( $updates[ $slug ] ) && ! empty( $updates[ $slug ]['package'] ),
771
-			'update'         => get_theme_update_available( $theme ),
772
-			'autoupdate'     => array(
773
-				'enabled'   => $auto_update || $auto_update_forced,
774
-				'supported' => $auto_update_supported,
775
-				'forced'    => $auto_update_forced,
776
-			),
777
-			'actions'        => array(
778
-				'activate'   => current_user_can( 'switch_themes' ) ? wp_nonce_url( admin_url( 'themes.php?action=activate&amp;stylesheet=' . $encoded_slug ), 'switch-theme_' . $slug ) : null,
779
-				'customize'  => $customize_action,
780
-				'delete'     => ( ! is_multisite() && current_user_can( 'delete_themes' ) ) ? wp_nonce_url( admin_url( 'themes.php?action=delete&amp;stylesheet=' . $encoded_slug ), 'delete-theme_' . $slug ) : null,
781
-				'autoupdate' => wp_is_auto_update_enabled_for_type( 'theme' ) && ! is_multisite() && current_user_can( 'update_themes' )
782
-					? wp_nonce_url( admin_url( 'themes.php?action=' . $auto_update_action . '&amp;stylesheet=' . $encoded_slug ), 'updates' )
783
-					: null,
784
-			),
785
-			'blockTheme'     => $theme->is_block_theme(),
786
-		);
787
-	}
788
-
789
-	// Remove 'delete' action if theme has an active child.
790
-	if ( ! empty( $parents ) && array_key_exists( $current_theme, $parents ) ) {
791
-		unset( $prepared_themes[ $parents[ $current_theme ] ]['actions']['delete'] );
792
-	}
793
-
794
-	/**
795
-	 * Filters the themes prepared for JavaScript, for themes.php.
796
-	 *
797
-	 * Could be useful for changing the order, which is by name by default.
798
-	 *
799
-	 * @since 3.8.0
800
-	 *
801
-	 * @param array $prepared_themes Array of theme data.
802
-	 */
803
-	$prepared_themes = apply_filters( 'wp_prepare_themes_for_js', $prepared_themes );
804
-	$prepared_themes = array_values( $prepared_themes );
805
-	return array_filter( $prepared_themes );
740
+            $auto_update_filter_payload = (object) array(
741
+                'theme'        => $slug,
742
+                'new_version'  => $theme->get( 'Version' ),
743
+                'url'          => '',
744
+                'package'      => '',
745
+                'requires'     => $theme->get( 'RequiresWP' ),
746
+                'requires_php' => $theme->get( 'RequiresPHP' ),
747
+            );
748
+        }
749
+
750
+        $auto_update_forced = wp_is_auto_update_forced_for_item( 'theme', null, $auto_update_filter_payload );
751
+
752
+        $prepared_themes[ $slug ] = array(
753
+            'id'             => $slug,
754
+            'name'           => $theme->display( 'Name' ),
755
+            'screenshot'     => array( $theme->get_screenshot() ), // @todo Multiple screenshots.
756
+            'description'    => $theme->display( 'Description' ),
757
+            'author'         => $theme->display( 'Author', false, true ),
758
+            'authorAndUri'   => $theme->display( 'Author' ),
759
+            'tags'           => $theme->display( 'Tags' ),
760
+            'version'        => $theme->get( 'Version' ),
761
+            'compatibleWP'   => is_wp_version_compatible( $theme->get( 'RequiresWP' ) ),
762
+            'compatiblePHP'  => is_php_version_compatible( $theme->get( 'RequiresPHP' ) ),
763
+            'updateResponse' => array(
764
+                'compatibleWP'  => is_wp_version_compatible( $update_requires_wp ),
765
+                'compatiblePHP' => is_php_version_compatible( $update_requires_php ),
766
+            ),
767
+            'parent'         => $parent,
768
+            'active'         => $slug === $current_theme,
769
+            'hasUpdate'      => isset( $updates[ $slug ] ),
770
+            'hasPackage'     => isset( $updates[ $slug ] ) && ! empty( $updates[ $slug ]['package'] ),
771
+            'update'         => get_theme_update_available( $theme ),
772
+            'autoupdate'     => array(
773
+                'enabled'   => $auto_update || $auto_update_forced,
774
+                'supported' => $auto_update_supported,
775
+                'forced'    => $auto_update_forced,
776
+            ),
777
+            'actions'        => array(
778
+                'activate'   => current_user_can( 'switch_themes' ) ? wp_nonce_url( admin_url( 'themes.php?action=activate&amp;stylesheet=' . $encoded_slug ), 'switch-theme_' . $slug ) : null,
779
+                'customize'  => $customize_action,
780
+                'delete'     => ( ! is_multisite() && current_user_can( 'delete_themes' ) ) ? wp_nonce_url( admin_url( 'themes.php?action=delete&amp;stylesheet=' . $encoded_slug ), 'delete-theme_' . $slug ) : null,
781
+                'autoupdate' => wp_is_auto_update_enabled_for_type( 'theme' ) && ! is_multisite() && current_user_can( 'update_themes' )
782
+                    ? wp_nonce_url( admin_url( 'themes.php?action=' . $auto_update_action . '&amp;stylesheet=' . $encoded_slug ), 'updates' )
783
+                    : null,
784
+            ),
785
+            'blockTheme'     => $theme->is_block_theme(),
786
+        );
787
+    }
788
+
789
+    // Remove 'delete' action if theme has an active child.
790
+    if ( ! empty( $parents ) && array_key_exists( $current_theme, $parents ) ) {
791
+        unset( $prepared_themes[ $parents[ $current_theme ] ]['actions']['delete'] );
792
+    }
793
+
794
+    /**
795
+     * Filters the themes prepared for JavaScript, for themes.php.
796
+     *
797
+     * Could be useful for changing the order, which is by name by default.
798
+     *
799
+     * @since 3.8.0
800
+     *
801
+     * @param array $prepared_themes Array of theme data.
802
+     */
803
+    $prepared_themes = apply_filters( 'wp_prepare_themes_for_js', $prepared_themes );
804
+    $prepared_themes = array_values( $prepared_themes );
805
+    return array_filter( $prepared_themes );
806 806
 }
807 807
 
808 808
 /**
@@ -811,7 +811,7 @@  discard block
 block discarded – undo
811 811
  * @since 4.2.0
812 812
  */
813 813
 function customize_themes_print_templates() {
814
-	?>
814
+    ?>
815 815
 	<script type="text/html" id="tmpl-customize-themes-details-view">
816 816
 		<div class="theme-backdrop"></div>
817 817
 		<div class="theme-wrap wp-clearfix" role="document">
@@ -835,15 +835,15 @@  discard block
 block discarded – undo
835 835
 					<# } #>
836 836
 					<h2 class="theme-name">{{{ data.name }}}<span class="theme-version">
837 837
 						<?php
838
-						/* translators: %s: Theme version. */
839
-						printf( __( 'Version: %s' ), '{{ data.version }}' );
840
-						?>
838
+                        /* translators: %s: Theme version. */
839
+                        printf( __( 'Version: %s' ), '{{ data.version }}' );
840
+                        ?>
841 841
 					</span></h2>
842 842
 					<h3 class="theme-author">
843 843
 						<?php
844
-						/* translators: %s: Theme author link. */
845
-						printf( __( 'By %s' ), '{{{ data.authorAndUri }}}' );
846
-						?>
844
+                        /* translators: %s: Theme author link. */
845
+                        printf( __( 'By %s' ), '{{{ data.authorAndUri }}}' );
846
+                        ?>
847 847
 					</h3>
848 848
 
849 849
 					<# if ( data.stars && 0 != data.num_ratings ) { #>
@@ -851,14 +851,14 @@  discard block
 block discarded – undo
851 851
 							{{{ data.stars }}}
852 852
 							<a class="num-ratings" target="_blank" href="{{ data.reviews_url }}">
853 853
 								<?php
854
-								printf(
855
-									'%1$s <span class="screen-reader-text">%2$s</span>',
856
-									/* translators: %s: Number of ratings. */
857
-									sprintf( __( '(%s ratings)' ), '{{ data.num_ratings }}' ),
858
-									/* translators: Accessibility text. */
859
-									__( '(opens in a new tab)' )
860
-								);
861
-								?>
854
+                                printf(
855
+                                    '%1$s <span class="screen-reader-text">%2$s</span>',
856
+                                    /* translators: %s: Number of ratings. */
857
+                                    sprintf( __( '(%s ratings)' ), '{{ data.num_ratings }}' ),
858
+                                    /* translators: Accessibility text. */
859
+                                    __( '(opens in a new tab)' )
860
+                                );
861
+                                ?>
862 862
 							</a>
863 863
 						</div>
864 864
 					<# } #>
@@ -875,65 +875,65 @@  discard block
 block discarded – undo
875 875
 								<p>
876 876
 									<# if ( ! data.updateResponse.compatibleWP && ! data.updateResponse.compatiblePHP ) { #>
877 877
 										<?php
878
-										printf(
879
-											/* translators: %s: Theme name. */
880
-											__( 'There is a new version of %s available, but it does not work with your versions of WordPress and PHP.' ),
881
-											'{{{ data.name }}}'
882
-										);
883
-										if ( current_user_can( 'update_core' ) && current_user_can( 'update_php' ) ) {
884
-											printf(
885
-												/* translators: 1: URL to WordPress Updates screen, 2: URL to Update PHP page. */
886
-												' ' . __( '<a href="%1$s">Please update WordPress</a>, and then <a href="%2$s">learn more about updating PHP</a>.' ),
887
-												self_admin_url( 'update-core.php' ),
888
-												esc_url( wp_get_update_php_url() )
889
-											);
890
-											wp_update_php_annotation( '</p><p><em>', '</em>' );
891
-										} elseif ( current_user_can( 'update_core' ) ) {
892
-											printf(
893
-												/* translators: %s: URL to WordPress Updates screen. */
894
-												' ' . __( '<a href="%s">Please update WordPress</a>.' ),
895
-												self_admin_url( 'update-core.php' )
896
-											);
897
-										} elseif ( current_user_can( 'update_php' ) ) {
898
-											printf(
899
-												/* translators: %s: URL to Update PHP page. */
900
-												' ' . __( '<a href="%s">Learn more about updating PHP</a>.' ),
901
-												esc_url( wp_get_update_php_url() )
902
-											);
903
-											wp_update_php_annotation( '</p><p><em>', '</em>' );
904
-										}
905
-										?>
878
+                                        printf(
879
+                                            /* translators: %s: Theme name. */
880
+                                            __( 'There is a new version of %s available, but it does not work with your versions of WordPress and PHP.' ),
881
+                                            '{{{ data.name }}}'
882
+                                        );
883
+                                        if ( current_user_can( 'update_core' ) && current_user_can( 'update_php' ) ) {
884
+                                            printf(
885
+                                                /* translators: 1: URL to WordPress Updates screen, 2: URL to Update PHP page. */
886
+                                                ' ' . __( '<a href="%1$s">Please update WordPress</a>, and then <a href="%2$s">learn more about updating PHP</a>.' ),
887
+                                                self_admin_url( 'update-core.php' ),
888
+                                                esc_url( wp_get_update_php_url() )
889
+                                            );
890
+                                            wp_update_php_annotation( '</p><p><em>', '</em>' );
891
+                                        } elseif ( current_user_can( 'update_core' ) ) {
892
+                                            printf(
893
+                                                /* translators: %s: URL to WordPress Updates screen. */
894
+                                                ' ' . __( '<a href="%s">Please update WordPress</a>.' ),
895
+                                                self_admin_url( 'update-core.php' )
896
+                                            );
897
+                                        } elseif ( current_user_can( 'update_php' ) ) {
898
+                                            printf(
899
+                                                /* translators: %s: URL to Update PHP page. */
900
+                                                ' ' . __( '<a href="%s">Learn more about updating PHP</a>.' ),
901
+                                                esc_url( wp_get_update_php_url() )
902
+                                            );
903
+                                            wp_update_php_annotation( '</p><p><em>', '</em>' );
904
+                                        }
905
+                                        ?>
906 906
 									<# } else if ( ! data.updateResponse.compatibleWP ) { #>
907 907
 										<?php
908
-										printf(
909
-											/* translators: %s: Theme name. */
910
-											__( 'There is a new version of %s available, but it does not work with your version of WordPress.' ),
911
-											'{{{ data.name }}}'
912
-										);
913
-										if ( current_user_can( 'update_core' ) ) {
914
-											printf(
915
-												/* translators: %s: URL to WordPress Updates screen. */
916
-												' ' . __( '<a href="%s">Please update WordPress</a>.' ),
917
-												self_admin_url( 'update-core.php' )
918
-											);
919
-										}
920
-										?>
908
+                                        printf(
909
+                                            /* translators: %s: Theme name. */
910
+                                            __( 'There is a new version of %s available, but it does not work with your version of WordPress.' ),
911
+                                            '{{{ data.name }}}'
912
+                                        );
913
+                                        if ( current_user_can( 'update_core' ) ) {
914
+                                            printf(
915
+                                                /* translators: %s: URL to WordPress Updates screen. */
916
+                                                ' ' . __( '<a href="%s">Please update WordPress</a>.' ),
917
+                                                self_admin_url( 'update-core.php' )
918
+                                            );
919
+                                        }
920
+                                        ?>
921 921
 									<# } else if ( ! data.updateResponse.compatiblePHP ) { #>
922 922
 										<?php
923
-										printf(
924
-											/* translators: %s: Theme name. */
925
-											__( 'There is a new version of %s available, but it does not work with your version of PHP.' ),
926
-											'{{{ data.name }}}'
927
-										);
928
-										if ( current_user_can( 'update_php' ) ) {
929
-											printf(
930
-												/* translators: %s: URL to Update PHP page. */
931
-												' ' . __( '<a href="%s">Learn more about updating PHP</a>.' ),
932
-												esc_url( wp_get_update_php_url() )
933
-											);
934
-											wp_update_php_annotation( '</p><p><em>', '</em>' );
935
-										}
936
-										?>
923
+                                        printf(
924
+                                            /* translators: %s: Theme name. */
925
+                                            __( 'There is a new version of %s available, but it does not work with your version of PHP.' ),
926
+                                            '{{{ data.name }}}'
927
+                                        );
928
+                                        if ( current_user_can( 'update_php' ) ) {
929
+                                            printf(
930
+                                                /* translators: %s: URL to Update PHP page. */
931
+                                                ' ' . __( '<a href="%s">Learn more about updating PHP</a>.' ),
932
+                                                esc_url( wp_get_update_php_url() )
933
+                                            );
934
+                                            wp_update_php_annotation( '</p><p><em>', '</em>' );
935
+                                        }
936
+                                        ?>
937 937
 									<# } #>
938 938
 								</p>
939 939
 							</div>
@@ -943,12 +943,12 @@  discard block
 block discarded – undo
943 943
 					<# if ( data.parent ) { #>
944 944
 						<p class="parent-theme">
945 945
 							<?php
946
-							printf(
947
-								/* translators: %s: Theme name. */
948
-								__( 'This is a child theme of %s.' ),
949
-								'<strong>{{{ data.parent }}}</strong>'
950
-							);
951
-							?>
946
+                            printf(
947
+                                /* translators: %s: Theme name. */
948
+                                __( 'This is a child theme of %s.' ),
949
+                                '<strong>{{{ data.parent }}}</strong>'
950
+                            );
951
+                            ?>
952 952
 						</p>
953 953
 					<# } #>
954 954
 
@@ -956,68 +956,68 @@  discard block
 block discarded – undo
956 956
 						<div class="notice notice-error notice-alt notice-large"><p>
957 957
 							<# if ( ! data.compatibleWP && ! data.compatiblePHP ) { #>
958 958
 								<?php
959
-								_e( 'This theme does not work with your versions of WordPress and PHP.' );
960
-								if ( current_user_can( 'update_core' ) && current_user_can( 'update_php' ) ) {
961
-									printf(
962
-										/* translators: 1: URL to WordPress Updates screen, 2: URL to Update PHP page. */
963
-										' ' . __( '<a href="%1$s">Please update WordPress</a>, and then <a href="%2$s">learn more about updating PHP</a>.' ),
964
-										self_admin_url( 'update-core.php' ),
965
-										esc_url( wp_get_update_php_url() )
966
-									);
967
-									wp_update_php_annotation( '</p><p><em>', '</em>' );
968
-								} elseif ( current_user_can( 'update_core' ) ) {
969
-									printf(
970
-										/* translators: %s: URL to WordPress Updates screen. */
971
-										' ' . __( '<a href="%s">Please update WordPress</a>.' ),
972
-										self_admin_url( 'update-core.php' )
973
-									);
974
-								} elseif ( current_user_can( 'update_php' ) ) {
975
-									printf(
976
-										/* translators: %s: URL to Update PHP page. */
977
-										' ' . __( '<a href="%s">Learn more about updating PHP</a>.' ),
978
-										esc_url( wp_get_update_php_url() )
979
-									);
980
-									wp_update_php_annotation( '</p><p><em>', '</em>' );
981
-								}
982
-								?>
959
+                                _e( 'This theme does not work with your versions of WordPress and PHP.' );
960
+                                if ( current_user_can( 'update_core' ) && current_user_can( 'update_php' ) ) {
961
+                                    printf(
962
+                                        /* translators: 1: URL to WordPress Updates screen, 2: URL to Update PHP page. */
963
+                                        ' ' . __( '<a href="%1$s">Please update WordPress</a>, and then <a href="%2$s">learn more about updating PHP</a>.' ),
964
+                                        self_admin_url( 'update-core.php' ),
965
+                                        esc_url( wp_get_update_php_url() )
966
+                                    );
967
+                                    wp_update_php_annotation( '</p><p><em>', '</em>' );
968
+                                } elseif ( current_user_can( 'update_core' ) ) {
969
+                                    printf(
970
+                                        /* translators: %s: URL to WordPress Updates screen. */
971
+                                        ' ' . __( '<a href="%s">Please update WordPress</a>.' ),
972
+                                        self_admin_url( 'update-core.php' )
973
+                                    );
974
+                                } elseif ( current_user_can( 'update_php' ) ) {
975
+                                    printf(
976
+                                        /* translators: %s: URL to Update PHP page. */
977
+                                        ' ' . __( '<a href="%s">Learn more about updating PHP</a>.' ),
978
+                                        esc_url( wp_get_update_php_url() )
979
+                                    );
980
+                                    wp_update_php_annotation( '</p><p><em>', '</em>' );
981
+                                }
982
+                                ?>
983 983
 							<# } else if ( ! data.compatibleWP ) { #>
984 984
 								<?php
985
-								_e( 'This theme does not work with your version of WordPress.' );
986
-								if ( current_user_can( 'update_core' ) ) {
987
-									printf(
988
-										/* translators: %s: URL to WordPress Updates screen. */
989
-										' ' . __( '<a href="%s">Please update WordPress</a>.' ),
990
-										self_admin_url( 'update-core.php' )
991
-									);
992
-								}
993
-								?>
985
+                                _e( 'This theme does not work with your version of WordPress.' );
986
+                                if ( current_user_can( 'update_core' ) ) {
987
+                                    printf(
988
+                                        /* translators: %s: URL to WordPress Updates screen. */
989
+                                        ' ' . __( '<a href="%s">Please update WordPress</a>.' ),
990
+                                        self_admin_url( 'update-core.php' )
991
+                                    );
992
+                                }
993
+                                ?>
994 994
 							<# } else if ( ! data.compatiblePHP ) { #>
995 995
 								<?php
996
-								_e( 'This theme does not work with your version of PHP.' );
997
-								if ( current_user_can( 'update_php' ) ) {
998
-									printf(
999
-										/* translators: %s: URL to Update PHP page. */
1000
-										' ' . __( '<a href="%s">Learn more about updating PHP</a>.' ),
1001
-										esc_url( wp_get_update_php_url() )
1002
-									);
1003
-									wp_update_php_annotation( '</p><p><em>', '</em>' );
1004
-								}
1005
-								?>
996
+                                _e( 'This theme does not work with your version of PHP.' );
997
+                                if ( current_user_can( 'update_php' ) ) {
998
+                                    printf(
999
+                                        /* translators: %s: URL to Update PHP page. */
1000
+                                        ' ' . __( '<a href="%s">Learn more about updating PHP</a>.' ),
1001
+                                        esc_url( wp_get_update_php_url() )
1002
+                                    );
1003
+                                    wp_update_php_annotation( '</p><p><em>', '</em>' );
1004
+                                }
1005
+                                ?>
1006 1006
 							<# } #>
1007 1007
 						</p></div>
1008 1008
 					<# } else if ( ! data.active && data.blockTheme ) { #>
1009 1009
 						<div class="notice notice-error notice-alt notice-large"><p>
1010 1010
 						<?php
1011
-							_e( 'This theme doesn\'t support Customizer.' );
1012
-						?>
1011
+                            _e( 'This theme doesn\'t support Customizer.' );
1012
+                        ?>
1013 1013
 						<# if ( data.actions.activate ) { #>
1014 1014
 							<?php
1015
-							printf(
1016
-								/* translators: %s: URL to the themes page (also it activates the theme). */
1017
-								' ' . __( 'However, you can still <a href="%s">activate this theme</a>, and use the Site Editor to customize it.' ),
1018
-								'{{{ data.actions.activate }}}'
1019
-							);
1020
-							?>
1015
+                            printf(
1016
+                                /* translators: %s: URL to the themes page (also it activates the theme). */
1017
+                                ' ' . __( 'However, you can still <a href="%s">activate this theme</a>, and use the Site Editor to customize it.' ),
1018
+                                '{{{ data.actions.activate }}}'
1019
+                            );
1020
+                            ?>
1021 1021
 						<# } #>
1022 1022
 						</p></div>
1023 1023
 					<# } #>
@@ -1042,9 +1042,9 @@  discard block
 block discarded – undo
1042 1042
 
1043 1043
 					<# if ( data.blockTheme ) { #>
1044 1044
 						<?php
1045
-							/* translators: %s: Theme name. */
1046
-							$aria_label = sprintf( _x( 'Activate %s', 'theme' ), '{{ data.name }}' );
1047
-						?>
1045
+                            /* translators: %s: Theme name. */
1046
+                            $aria_label = sprintf( _x( 'Activate %s', 'theme' ), '{{ data.name }}' );
1047
+                        ?>
1048 1048
 						<# if ( data.compatibleWP && data.compatiblePHP && data.actions.activate ) { #>
1049 1049
 							<a href="{{{ data.actions.activate }}}" class="button button-primary activate" aria-label="<?php echo esc_attr( $aria_label ); ?>"><?php _e( 'Activate' ); ?></a>
1050 1050
 						<# } #>
@@ -1084,15 +1084,15 @@  discard block
 block discarded – undo
1084 1084
  * @return bool True, if in the list of paused themes. False, not in the list.
1085 1085
  */
1086 1086
 function is_theme_paused( $theme ) {
1087
-	if ( ! isset( $GLOBALS['_paused_themes'] ) ) {
1088
-		return false;
1089
-	}
1087
+    if ( ! isset( $GLOBALS['_paused_themes'] ) ) {
1088
+        return false;
1089
+    }
1090 1090
 
1091
-	if ( get_stylesheet() !== $theme && get_template() !== $theme ) {
1092
-		return false;
1093
-	}
1091
+    if ( get_stylesheet() !== $theme && get_template() !== $theme ) {
1092
+        return false;
1093
+    }
1094 1094
 
1095
-	return array_key_exists( $theme, $GLOBALS['_paused_themes'] );
1095
+    return array_key_exists( $theme, $GLOBALS['_paused_themes'] );
1096 1096
 }
1097 1097
 
1098 1098
 /**
@@ -1106,15 +1106,15 @@  discard block
 block discarded – undo
1106 1106
  *                     `error_get_last()`, or false if none was recorded.
1107 1107
  */
1108 1108
 function wp_get_theme_error( $theme ) {
1109
-	if ( ! isset( $GLOBALS['_paused_themes'] ) ) {
1110
-		return false;
1111
-	}
1109
+    if ( ! isset( $GLOBALS['_paused_themes'] ) ) {
1110
+        return false;
1111
+    }
1112 1112
 
1113
-	if ( ! array_key_exists( $theme, $GLOBALS['_paused_themes'] ) ) {
1114
-		return false;
1115
-	}
1113
+    if ( ! array_key_exists( $theme, $GLOBALS['_paused_themes'] ) ) {
1114
+        return false;
1115
+    }
1116 1116
 
1117
-	return $GLOBALS['_paused_themes'][ $theme ];
1117
+    return $GLOBALS['_paused_themes'][ $theme ];
1118 1118
 }
1119 1119
 
1120 1120
 /**
@@ -1135,49 +1135,49 @@  discard block
 block discarded – undo
1135 1135
  *                       `WP_Error` on failure.
1136 1136
  */
1137 1137
 function resume_theme( $theme, $redirect = '' ) {
1138
-	list( $extension ) = explode( '/', $theme );
1138
+    list( $extension ) = explode( '/', $theme );
1139 1139
 
1140
-	/*
1140
+    /*
1141 1141
 	 * We'll override this later if the theme could be resumed without
1142 1142
 	 * creating a fatal error.
1143 1143
 	 */
1144
-	if ( ! empty( $redirect ) ) {
1145
-		$functions_path = '';
1146
-		if ( strpos( STYLESHEETPATH, $extension ) ) {
1147
-			$functions_path = STYLESHEETPATH . '/functions.php';
1148
-		} elseif ( strpos( TEMPLATEPATH, $extension ) ) {
1149
-			$functions_path = TEMPLATEPATH . '/functions.php';
1150
-		}
1151
-
1152
-		if ( ! empty( $functions_path ) ) {
1153
-			wp_redirect(
1154
-				add_query_arg(
1155
-					'_error_nonce',
1156
-					wp_create_nonce( 'theme-resume-error_' . $theme ),
1157
-					$redirect
1158
-				)
1159
-			);
1160
-
1161
-			// Load the theme's functions.php to test whether it throws a fatal error.
1162
-			ob_start();
1163
-			if ( ! defined( 'WP_SANDBOX_SCRAPING' ) ) {
1164
-				define( 'WP_SANDBOX_SCRAPING', true );
1165
-			}
1166
-			include $functions_path;
1167
-			ob_clean();
1168
-		}
1169
-	}
1170
-
1171
-	$result = wp_paused_themes()->delete( $extension );
1172
-
1173
-	if ( ! $result ) {
1174
-		return new WP_Error(
1175
-			'could_not_resume_theme',
1176
-			__( 'Could not resume the theme.' )
1177
-		);
1178
-	}
1179
-
1180
-	return true;
1144
+    if ( ! empty( $redirect ) ) {
1145
+        $functions_path = '';
1146
+        if ( strpos( STYLESHEETPATH, $extension ) ) {
1147
+            $functions_path = STYLESHEETPATH . '/functions.php';
1148
+        } elseif ( strpos( TEMPLATEPATH, $extension ) ) {
1149
+            $functions_path = TEMPLATEPATH . '/functions.php';
1150
+        }
1151
+
1152
+        if ( ! empty( $functions_path ) ) {
1153
+            wp_redirect(
1154
+                add_query_arg(
1155
+                    '_error_nonce',
1156
+                    wp_create_nonce( 'theme-resume-error_' . $theme ),
1157
+                    $redirect
1158
+                )
1159
+            );
1160
+
1161
+            // Load the theme's functions.php to test whether it throws a fatal error.
1162
+            ob_start();
1163
+            if ( ! defined( 'WP_SANDBOX_SCRAPING' ) ) {
1164
+                define( 'WP_SANDBOX_SCRAPING', true );
1165
+            }
1166
+            include $functions_path;
1167
+            ob_clean();
1168
+        }
1169
+    }
1170
+
1171
+    $result = wp_paused_themes()->delete( $extension );
1172
+
1173
+    if ( ! $result ) {
1174
+        return new WP_Error(
1175
+            'could_not_resume_theme',
1176
+            __( 'Could not resume the theme.' )
1177
+        );
1178
+    }
1179
+
1180
+    return true;
1181 1181
 }
1182 1182
 
1183 1183
 /**
@@ -1188,23 +1188,23 @@  discard block
 block discarded – undo
1188 1188
  * @global string $pagenow The filename of the current screen.
1189 1189
  */
1190 1190
 function paused_themes_notice() {
1191
-	if ( 'themes.php' === $GLOBALS['pagenow'] ) {
1192
-		return;
1193
-	}
1194
-
1195
-	if ( ! current_user_can( 'resume_themes' ) ) {
1196
-		return;
1197
-	}
1198
-
1199
-	if ( ! isset( $GLOBALS['_paused_themes'] ) || empty( $GLOBALS['_paused_themes'] ) ) {
1200
-		return;
1201
-	}
1202
-
1203
-	printf(
1204
-		'<div class="notice notice-error"><p><strong>%s</strong><br>%s</p><p><a href="%s">%s</a></p></div>',
1205
-		__( 'One or more themes failed to load properly.' ),
1206
-		__( 'You can find more details and make changes on the Themes screen.' ),
1207
-		esc_url( admin_url( 'themes.php' ) ),
1208
-		__( 'Go to the Themes screen' )
1209
-	);
1191
+    if ( 'themes.php' === $GLOBALS['pagenow'] ) {
1192
+        return;
1193
+    }
1194
+
1195
+    if ( ! current_user_can( 'resume_themes' ) ) {
1196
+        return;
1197
+    }
1198
+
1199
+    if ( ! isset( $GLOBALS['_paused_themes'] ) || empty( $GLOBALS['_paused_themes'] ) ) {
1200
+        return;
1201
+    }
1202
+
1203
+    printf(
1204
+        '<div class="notice notice-error"><p><strong>%s</strong><br>%s</p><p><a href="%s">%s</a></p></div>',
1205
+        __( 'One or more themes failed to load properly.' ),
1206
+        __( 'You can find more details and make changes on the Themes screen.' ),
1207
+        esc_url( admin_url( 'themes.php' ) ),
1208
+        __( 'Go to the Themes screen' )
1209
+    );
1210 1210
 }
Please login to merge, or discard this patch.
Spacing   +316 added lines, -316 removed lines patch added patch discarded remove patch
@@ -18,23 +18,23 @@  discard block
 block discarded – undo
18 18
  * @return bool|null|WP_Error True on success, false if `$stylesheet` is empty, WP_Error on failure.
19 19
  *                            Null if filesystem credentials are required to proceed.
20 20
  */
21
-function delete_theme( $stylesheet, $redirect = '' ) {
21
+function delete_theme($stylesheet, $redirect = '') {
22 22
 	global $wp_filesystem;
23 23
 
24
-	if ( empty( $stylesheet ) ) {
24
+	if (empty($stylesheet)) {
25 25
 		return false;
26 26
 	}
27 27
 
28
-	if ( empty( $redirect ) ) {
29
-		$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 30
 	}
31 31
 
32 32
 	ob_start();
33
-	$credentials = request_filesystem_credentials( $redirect );
33
+	$credentials = request_filesystem_credentials($redirect);
34 34
 	$data        = ob_get_clean();
35 35
 
36
-	if ( false === $credentials ) {
37
-		if ( ! empty( $data ) ) {
36
+	if (false === $credentials) {
37
+		if (!empty($data)) {
38 38
 			require_once ABSPATH . 'wp-admin/admin-header.php';
39 39
 			echo $data;
40 40
 			require_once ABSPATH . 'wp-admin/admin-footer.php';
@@ -43,13 +43,13 @@  discard block
 block discarded – undo
43 43
 		return;
44 44
 	}
45 45
 
46
-	if ( ! WP_Filesystem( $credentials ) ) {
46
+	if (!WP_Filesystem($credentials)) {
47 47
 		ob_start();
48 48
 		// Failed to connect. Error and request again.
49
-		request_filesystem_credentials( $redirect, '', true );
49
+		request_filesystem_credentials($redirect, '', true);
50 50
 		$data = ob_get_clean();
51 51
 
52
-		if ( ! empty( $data ) ) {
52
+		if (!empty($data)) {
53 53
 			require_once ABSPATH . 'wp-admin/admin-header.php';
54 54
 			echo $data;
55 55
 			require_once ABSPATH . 'wp-admin/admin-footer.php';
@@ -58,18 +58,18 @@  discard block
 block discarded – undo
58 58
 		return;
59 59
 	}
60 60
 
61
-	if ( ! is_object( $wp_filesystem ) ) {
62
-		return new WP_Error( 'fs_unavailable', __( 'Could not access filesystem.' ) );
61
+	if (!is_object($wp_filesystem)) {
62
+		return new WP_Error('fs_unavailable', __('Could not access filesystem.'));
63 63
 	}
64 64
 
65
-	if ( is_wp_error( $wp_filesystem->errors ) && $wp_filesystem->errors->has_errors() ) {
66
-		return new WP_Error( 'fs_error', __( 'Filesystem error.' ), $wp_filesystem->errors );
65
+	if (is_wp_error($wp_filesystem->errors) && $wp_filesystem->errors->has_errors()) {
66
+		return new WP_Error('fs_error', __('Filesystem error.'), $wp_filesystem->errors);
67 67
 	}
68 68
 
69 69
 	// Get the base plugin folder.
70 70
 	$themes_dir = $wp_filesystem->wp_themes_dir();
71
-	if ( empty( $themes_dir ) ) {
72
-		return new WP_Error( 'fs_no_themes_dir', __( 'Unable to locate WordPress theme directory.' ) );
71
+	if (empty($themes_dir)) {
72
+		return new WP_Error('fs_no_themes_dir', __('Unable to locate WordPress theme directory.'));
73 73
 	}
74 74
 
75 75
 	/**
@@ -79,11 +79,11 @@  discard block
 block discarded – undo
79 79
 	 *
80 80
 	 * @param string $stylesheet Stylesheet of the theme to delete.
81 81
 	 */
82
-	do_action( 'delete_theme', $stylesheet );
82
+	do_action('delete_theme', $stylesheet);
83 83
 
84
-	$themes_dir = trailingslashit( $themes_dir );
85
-	$theme_dir  = trailingslashit( $themes_dir . $stylesheet );
86
-	$deleted    = $wp_filesystem->delete( $theme_dir, true );
84
+	$themes_dir = trailingslashit($themes_dir);
85
+	$theme_dir  = trailingslashit($themes_dir . $stylesheet);
86
+	$deleted    = $wp_filesystem->delete($theme_dir, true);
87 87
 
88 88
 	/**
89 89
 	 * Fires immediately after a theme deletion attempt.
@@ -93,40 +93,40 @@  discard block
 block discarded – undo
93 93
 	 * @param string $stylesheet Stylesheet of the theme to delete.
94 94
 	 * @param bool   $deleted    Whether the theme deletion was successful.
95 95
 	 */
96
-	do_action( 'deleted_theme', $stylesheet, $deleted );
96
+	do_action('deleted_theme', $stylesheet, $deleted);
97 97
 
98
-	if ( ! $deleted ) {
98
+	if (!$deleted) {
99 99
 		return new WP_Error(
100 100
 			'could_not_remove_theme',
101 101
 			/* translators: %s: Theme name. */
102
-			sprintf( __( 'Could not fully remove the theme %s.' ), $stylesheet )
102
+			sprintf(__('Could not fully remove the theme %s.'), $stylesheet)
103 103
 		);
104 104
 	}
105 105
 
106
-	$theme_translations = wp_get_installed_translations( 'themes' );
106
+	$theme_translations = wp_get_installed_translations('themes');
107 107
 
108 108
 	// Remove language files, silently.
109
-	if ( ! empty( $theme_translations[ $stylesheet ] ) ) {
110
-		$translations = $theme_translations[ $stylesheet ];
109
+	if (!empty($theme_translations[$stylesheet])) {
110
+		$translations = $theme_translations[$stylesheet];
111 111
 
112
-		foreach ( $translations as $translation => $data ) {
113
-			$wp_filesystem->delete( WP_LANG_DIR . '/themes/' . $stylesheet . '-' . $translation . '.po' );
114
-			$wp_filesystem->delete( WP_LANG_DIR . '/themes/' . $stylesheet . '-' . $translation . '.mo' );
112
+		foreach ($translations as $translation => $data) {
113
+			$wp_filesystem->delete(WP_LANG_DIR . '/themes/' . $stylesheet . '-' . $translation . '.po');
114
+			$wp_filesystem->delete(WP_LANG_DIR . '/themes/' . $stylesheet . '-' . $translation . '.mo');
115 115
 
116
-			$json_translation_files = glob( WP_LANG_DIR . '/themes/' . $stylesheet . '-' . $translation . '-*.json' );
117
-			if ( $json_translation_files ) {
118
-				array_map( array( $wp_filesystem, 'delete' ), $json_translation_files );
116
+			$json_translation_files = glob(WP_LANG_DIR . '/themes/' . $stylesheet . '-' . $translation . '-*.json');
117
+			if ($json_translation_files) {
118
+				array_map(array($wp_filesystem, 'delete'), $json_translation_files);
119 119
 			}
120 120
 		}
121 121
 	}
122 122
 
123 123
 	// Remove the theme from allowed themes on the network.
124
-	if ( is_multisite() ) {
125
-		WP_Theme::network_disable_theme( $stylesheet );
124
+	if (is_multisite()) {
125
+		WP_Theme::network_disable_theme($stylesheet);
126 126
 	}
127 127
 
128 128
 	// Force refresh of theme update information.
129
-	delete_site_transient( 'update_themes' );
129
+	delete_site_transient('update_themes');
130 130
 
131 131
 	return true;
132 132
 }
@@ -141,8 +141,8 @@  discard block
 block discarded – undo
141 141
  * @param string       $post_type Optional. Post type to get the templates for. Default 'page'.
142 142
  * @return string[] Array of template file names keyed by the template header name.
143 143
  */
144
-function get_page_templates( $post = null, $post_type = 'page' ) {
145
-	return array_flip( wp_get_theme()->get_page_templates( $post, $post_type ) );
144
+function get_page_templates($post = null, $post_type = 'page') {
145
+	return array_flip(wp_get_theme()->get_page_templates($post, $post_type));
146 146
 }
147 147
 
148 148
 /**
@@ -155,8 +155,8 @@  discard block
 block discarded – undo
155 155
  * @param string $containingfolder Path of the theme parent folder
156 156
  * @return string
157 157
  */
158
-function _get_template_edit_filename( $fullpath, $containingfolder ) {
159
-	return str_replace( dirname( dirname( $containingfolder ) ), '', $fullpath );
158
+function _get_template_edit_filename($fullpath, $containingfolder) {
159
+	return str_replace(dirname(dirname($containingfolder)), '', $fullpath);
160 160
 }
161 161
 
162 162
 /**
@@ -170,8 +170,8 @@  discard block
 block discarded – undo
170 170
  *
171 171
  * @param WP_Theme $theme Theme data object.
172 172
  */
173
-function theme_update_available( $theme ) {
174
-	echo get_theme_update_available( $theme );
173
+function theme_update_available($theme) {
174
+	echo get_theme_update_available($theme);
175 175
 }
176 176
 
177 177
 /**
@@ -184,18 +184,18 @@  discard block
 block discarded – undo
184 184
  * @param WP_Theme $theme WP_Theme object.
185 185
  * @return string|false HTML for the update link, or false if invalid info was passed.
186 186
  */
187
-function get_theme_update_available( $theme ) {
187
+function get_theme_update_available($theme) {
188 188
 	static $themes_update = null;
189 189
 
190
-	if ( ! current_user_can( 'update_themes' ) ) {
190
+	if (!current_user_can('update_themes')) {
191 191
 		return false;
192 192
 	}
193 193
 
194
-	if ( ! isset( $themes_update ) ) {
195
-		$themes_update = get_site_transient( 'update_themes' );
194
+	if (!isset($themes_update)) {
195
+		$themes_update = get_site_transient('update_themes');
196 196
 	}
197 197
 
198
-	if ( ! ( $theme instanceof WP_Theme ) ) {
198
+	if (!($theme instanceof WP_Theme)) {
199 199
 		return false;
200 200
 	}
201 201
 
@@ -203,9 +203,9 @@  discard block
 block discarded – undo
203 203
 
204 204
 	$html = '';
205 205
 
206
-	if ( isset( $themes_update->response[ $stylesheet ] ) ) {
207
-		$update      = $themes_update->response[ $stylesheet ];
208
-		$theme_name  = $theme->display( 'Name' );
206
+	if (isset($themes_update->response[$stylesheet])) {
207
+		$update      = $themes_update->response[$stylesheet];
208
+		$theme_name  = $theme->display('Name');
209 209
 		$details_url = add_query_arg(
210 210
 			array(
211 211
 				'TB_iframe' => 'true',
@@ -214,52 +214,52 @@  discard block
 block discarded – undo
214 214
 			),
215 215
 			$update['url']
216 216
 		); // Theme browser inside WP? Replace this. Also, theme preview JS will override this on the available list.
217
-		$update_url  = wp_nonce_url( admin_url( 'update.php?action=upgrade-theme&amp;theme=' . urlencode( $stylesheet ) ), 'upgrade-theme_' . $stylesheet );
217
+		$update_url = wp_nonce_url(admin_url('update.php?action=upgrade-theme&amp;theme=' . urlencode($stylesheet)), 'upgrade-theme_' . $stylesheet);
218 218
 
219
-		if ( ! is_multisite() ) {
220
-			if ( ! current_user_can( 'update_themes' ) ) {
219
+		if (!is_multisite()) {
220
+			if (!current_user_can('update_themes')) {
221 221
 				$html = sprintf(
222 222
 					/* translators: 1: Theme name, 2: Theme details URL, 3: Additional link attributes, 4: Version number. */
223
-					'<p><strong>' . __( 'There is a new version of %1$s available. <a href="%2$s" %3$s>View version %4$s details</a>.' ) . '</strong></p>',
223
+					'<p><strong>' . __('There is a new version of %1$s available. <a href="%2$s" %3$s>View version %4$s details</a>.') . '</strong></p>',
224 224
 					$theme_name,
225
-					esc_url( $details_url ),
225
+					esc_url($details_url),
226 226
 					sprintf(
227 227
 						'class="thickbox open-plugin-details-modal" aria-label="%s"',
228 228
 						/* translators: 1: Theme name, 2: Version number. */
229
-						esc_attr( sprintf( __( 'View %1$s version %2$s details' ), $theme_name, $update['new_version'] ) )
229
+						esc_attr(sprintf(__('View %1$s version %2$s details'), $theme_name, $update['new_version']))
230 230
 					),
231 231
 					$update['new_version']
232 232
 				);
233
-			} elseif ( empty( $update['package'] ) ) {
233
+			} elseif (empty($update['package'])) {
234 234
 				$html = sprintf(
235 235
 					/* translators: 1: Theme name, 2: Theme details URL, 3: Additional link attributes, 4: Version number. */
236
-					'<p><strong>' . __( 'There is a new version of %1$s available. <a href="%2$s" %3$s>View version %4$s details</a>. <em>Automatic update is unavailable for this theme.</em>' ) . '</strong></p>',
236
+					'<p><strong>' . __('There is a new version of %1$s available. <a href="%2$s" %3$s>View version %4$s details</a>. <em>Automatic update is unavailable for this theme.</em>') . '</strong></p>',
237 237
 					$theme_name,
238
-					esc_url( $details_url ),
238
+					esc_url($details_url),
239 239
 					sprintf(
240 240
 						'class="thickbox open-plugin-details-modal" aria-label="%s"',
241 241
 						/* translators: 1: Theme name, 2: Version number. */
242
-						esc_attr( sprintf( __( 'View %1$s version %2$s details' ), $theme_name, $update['new_version'] ) )
242
+						esc_attr(sprintf(__('View %1$s version %2$s details'), $theme_name, $update['new_version']))
243 243
 					),
244 244
 					$update['new_version']
245 245
 				);
246 246
 			} else {
247 247
 				$html = sprintf(
248 248
 					/* translators: 1: Theme name, 2: Theme details URL, 3: Additional link attributes, 4: Version number, 5: Update URL, 6: Additional link attributes. */
249
-					'<p><strong>' . __( 'There is a new version of %1$s available. <a href="%2$s" %3$s>View version %4$s details</a> or <a href="%5$s" %6$s>update now</a>.' ) . '</strong></p>',
249
+					'<p><strong>' . __('There is a new version of %1$s available. <a href="%2$s" %3$s>View version %4$s details</a> or <a href="%5$s" %6$s>update now</a>.') . '</strong></p>',
250 250
 					$theme_name,
251
-					esc_url( $details_url ),
251
+					esc_url($details_url),
252 252
 					sprintf(
253 253
 						'class="thickbox open-plugin-details-modal" aria-label="%s"',
254 254
 						/* translators: 1: Theme name, 2: Version number. */
255
-						esc_attr( sprintf( __( 'View %1$s version %2$s details' ), $theme_name, $update['new_version'] ) )
255
+						esc_attr(sprintf(__('View %1$s version %2$s details'), $theme_name, $update['new_version']))
256 256
 					),
257 257
 					$update['new_version'],
258 258
 					$update_url,
259 259
 					sprintf(
260 260
 						'aria-label="%s" id="update-theme" data-slug="%s"',
261 261
 						/* translators: %s: Theme name. */
262
-						esc_attr( sprintf( _x( 'Update %s now', 'theme' ), $theme_name ) ),
262
+						esc_attr(sprintf(_x('Update %s now', 'theme'), $theme_name)),
263 263
 						$stylesheet
264 264
 					)
265 265
 				);
@@ -303,98 +303,98 @@  discard block
 block discarded – undo
303 303
  * @param bool $api Optional. Whether try to fetch tags from the WordPress.org API. Defaults to true.
304 304
  * @return array Array of features keyed by category with translations keyed by slug.
305 305
  */
306
-function get_theme_feature_list( $api = true ) {
306
+function get_theme_feature_list($api = true) {
307 307
 	// Hard-coded list is used if API is not accessible.
308 308
 	$features = array(
309 309
 
310
-		__( 'Subject' )  => array(
311
-			'blog'           => __( 'Blog' ),
312
-			'e-commerce'     => __( 'E-Commerce' ),
313
-			'education'      => __( 'Education' ),
314
-			'entertainment'  => __( 'Entertainment' ),
315
-			'food-and-drink' => __( 'Food & Drink' ),
316
-			'holiday'        => __( 'Holiday' ),
317
-			'news'           => __( 'News' ),
318
-			'photography'    => __( 'Photography' ),
319
-			'portfolio'      => __( 'Portfolio' ),
310
+		__('Subject')  => array(
311
+			'blog'           => __('Blog'),
312
+			'e-commerce'     => __('E-Commerce'),
313
+			'education'      => __('Education'),
314
+			'entertainment'  => __('Entertainment'),
315
+			'food-and-drink' => __('Food & Drink'),
316
+			'holiday'        => __('Holiday'),
317
+			'news'           => __('News'),
318
+			'photography'    => __('Photography'),
319
+			'portfolio'      => __('Portfolio'),
320 320
 		),
321 321
 
322
-		__( 'Features' ) => array(
323
-			'accessibility-ready'   => __( 'Accessibility Ready' ),
324
-			'block-patterns'        => __( 'Block Editor Patterns' ),
325
-			'block-styles'          => __( 'Block Editor Styles' ),
326
-			'custom-background'     => __( 'Custom Background' ),
327
-			'custom-colors'         => __( 'Custom Colors' ),
328
-			'custom-header'         => __( 'Custom Header' ),
329
-			'custom-logo'           => __( 'Custom Logo' ),
330
-			'editor-style'          => __( 'Editor Style' ),
331
-			'featured-image-header' => __( 'Featured Image Header' ),
332
-			'featured-images'       => __( 'Featured Images' ),
333
-			'footer-widgets'        => __( 'Footer Widgets' ),
334
-			'full-site-editing'     => __( 'Full Site Editing' ),
335
-			'full-width-template'   => __( 'Full Width Template' ),
336
-			'post-formats'          => __( 'Post Formats' ),
337
-			'sticky-post'           => __( 'Sticky Post' ),
338
-			'template-editing'      => __( 'Template Editing' ),
339
-			'theme-options'         => __( 'Theme Options' ),
322
+		__('Features') => array(
323
+			'accessibility-ready'   => __('Accessibility Ready'),
324
+			'block-patterns'        => __('Block Editor Patterns'),
325
+			'block-styles'          => __('Block Editor Styles'),
326
+			'custom-background'     => __('Custom Background'),
327
+			'custom-colors'         => __('Custom Colors'),
328
+			'custom-header'         => __('Custom Header'),
329
+			'custom-logo'           => __('Custom Logo'),
330
+			'editor-style'          => __('Editor Style'),
331
+			'featured-image-header' => __('Featured Image Header'),
332
+			'featured-images'       => __('Featured Images'),
333
+			'footer-widgets'        => __('Footer Widgets'),
334
+			'full-site-editing'     => __('Full Site Editing'),
335
+			'full-width-template'   => __('Full Width Template'),
336
+			'post-formats'          => __('Post Formats'),
337
+			'sticky-post'           => __('Sticky Post'),
338
+			'template-editing'      => __('Template Editing'),
339
+			'theme-options'         => __('Theme Options'),
340 340
 		),
341 341
 
342
-		__( 'Layout' )   => array(
343
-			'grid-layout'   => __( 'Grid Layout' ),
344
-			'one-column'    => __( 'One Column' ),
345
-			'two-columns'   => __( 'Two Columns' ),
346
-			'three-columns' => __( 'Three Columns' ),
347
-			'four-columns'  => __( 'Four Columns' ),
348
-			'left-sidebar'  => __( 'Left Sidebar' ),
349
-			'right-sidebar' => __( 'Right Sidebar' ),
350
-			'wide-blocks'   => __( 'Wide Blocks' ),
342
+		__('Layout')   => array(
343
+			'grid-layout'   => __('Grid Layout'),
344
+			'one-column'    => __('One Column'),
345
+			'two-columns'   => __('Two Columns'),
346
+			'three-columns' => __('Three Columns'),
347
+			'four-columns'  => __('Four Columns'),
348
+			'left-sidebar'  => __('Left Sidebar'),
349
+			'right-sidebar' => __('Right Sidebar'),
350
+			'wide-blocks'   => __('Wide Blocks'),
351 351
 		),
352 352
 
353 353
 	);
354 354
 
355
-	if ( ! $api || ! current_user_can( 'install_themes' ) ) {
355
+	if (!$api || !current_user_can('install_themes')) {
356 356
 		return $features;
357 357
 	}
358 358
 
359
-	$feature_list = get_site_transient( 'wporg_theme_feature_list' );
360
-	if ( ! $feature_list ) {
361
-		set_site_transient( 'wporg_theme_feature_list', array(), 3 * HOUR_IN_SECONDS );
359
+	$feature_list = get_site_transient('wporg_theme_feature_list');
360
+	if (!$feature_list) {
361
+		set_site_transient('wporg_theme_feature_list', array(), 3 * HOUR_IN_SECONDS);
362 362
 	}
363 363
 
364
-	if ( ! $feature_list ) {
365
-		$feature_list = themes_api( 'feature_list', array() );
366
-		if ( is_wp_error( $feature_list ) ) {
364
+	if (!$feature_list) {
365
+		$feature_list = themes_api('feature_list', array());
366
+		if (is_wp_error($feature_list)) {
367 367
 			return $features;
368 368
 		}
369 369
 	}
370 370
 
371
-	if ( ! $feature_list ) {
371
+	if (!$feature_list) {
372 372
 		return $features;
373 373
 	}
374 374
 
375
-	set_site_transient( 'wporg_theme_feature_list', $feature_list, 3 * HOUR_IN_SECONDS );
375
+	set_site_transient('wporg_theme_feature_list', $feature_list, 3 * HOUR_IN_SECONDS);
376 376
 
377 377
 	$category_translations = array(
378
-		'Layout'   => __( 'Layout' ),
379
-		'Features' => __( 'Features' ),
380
-		'Subject'  => __( 'Subject' ),
378
+		'Layout'   => __('Layout'),
379
+		'Features' => __('Features'),
380
+		'Subject'  => __('Subject'),
381 381
 	);
382 382
 
383 383
 	$wporg_features = array();
384 384
 
385 385
 	// Loop over the wp.org canonical list and apply translations.
386
-	foreach ( (array) $feature_list as $feature_category => $feature_items ) {
387
-		if ( isset( $category_translations[ $feature_category ] ) ) {
388
-			$feature_category = $category_translations[ $feature_category ];
386
+	foreach ((array) $feature_list as $feature_category => $feature_items) {
387
+		if (isset($category_translations[$feature_category])) {
388
+			$feature_category = $category_translations[$feature_category];
389 389
 		}
390 390
 
391
-		$wporg_features[ $feature_category ] = array();
391
+		$wporg_features[$feature_category] = array();
392 392
 
393
-		foreach ( $feature_items as $feature ) {
394
-			if ( isset( $features[ $feature_category ][ $feature ] ) ) {
395
-				$wporg_features[ $feature_category ][ $feature ] = $features[ $feature_category ][ $feature ];
393
+		foreach ($feature_items as $feature) {
394
+			if (isset($features[$feature_category][$feature])) {
395
+				$wporg_features[$feature_category][$feature] = $features[$feature_category][$feature];
396 396
 			} else {
397
-				$wporg_features[ $feature_category ][ $feature ] = $feature;
397
+				$wporg_features[$feature_category][$feature] = $feature;
398 398
 			}
399 399
 		}
400 400
 	}
@@ -483,26 +483,26 @@  discard block
 block discarded – undo
483 483
  *         {@link https://developer.wordpress.org/reference/functions/themes_api/ function reference article}
484 484
  *         for more information on the make-up of possible return objects depending on the value of `$action`.
485 485
  */
486
-function themes_api( $action, $args = array() ) {
486
+function themes_api($action, $args = array()) {
487 487
 	// Include an unmodified $wp_version.
488 488
 	require ABSPATH . WPINC . '/version.php';
489 489
 
490
-	if ( is_array( $args ) ) {
490
+	if (is_array($args)) {
491 491
 		$args = (object) $args;
492 492
 	}
493 493
 
494
-	if ( 'query_themes' === $action ) {
495
-		if ( ! isset( $args->per_page ) ) {
494
+	if ('query_themes' === $action) {
495
+		if (!isset($args->per_page)) {
496 496
 			$args->per_page = 24;
497 497
 		}
498 498
 	}
499 499
 
500
-	if ( ! isset( $args->locale ) ) {
500
+	if (!isset($args->locale)) {
501 501
 		$args->locale = get_user_locale();
502 502
 	}
503 503
 
504
-	if ( ! isset( $args->wp_version ) ) {
505
-		$args->wp_version = substr( $wp_version, 0, 3 ); // x.y
504
+	if (!isset($args->wp_version)) {
505
+		$args->wp_version = substr($wp_version, 0, 3); // x.y
506 506
 	}
507 507
 
508 508
 	/**
@@ -516,7 +516,7 @@  discard block
 block discarded – undo
516 516
 	 * @param string $action Requested action. Likely values are 'theme_information',
517 517
 	 *                       'feature_list', or 'query_themes'.
518 518
 	 */
519
-	$args = apply_filters( 'themes_api_args', $args, $action );
519
+	$args = apply_filters('themes_api_args', $args, $action);
520 520
 
521 521
 	/**
522 522
 	 * Filters whether to override the WordPress.org Themes API.
@@ -533,9 +533,9 @@  discard block
 block discarded – undo
533 533
 	 *                                    'feature_list', or 'query_themes'.
534 534
 	 * @param object             $args     Arguments used to query for installer pages from the Themes API.
535 535
 	 */
536
-	$res = apply_filters( 'themes_api', false, $action, $args );
536
+	$res = apply_filters('themes_api', false, $action, $args);
537 537
 
538
-	if ( ! $res ) {
538
+	if (!$res) {
539 539
 		$url = 'http://api.wordpress.org/themes/info/1.2/';
540 540
 		$url = add_query_arg(
541 541
 			array(
@@ -546,72 +546,72 @@  discard block
 block discarded – undo
546 546
 		);
547 547
 
548 548
 		$http_url = $url;
549
-		$ssl      = wp_http_supports( array( 'ssl' ) );
550
-		if ( $ssl ) {
551
-			$url = set_url_scheme( $url, 'https' );
549
+		$ssl      = wp_http_supports(array('ssl'));
550
+		if ($ssl) {
551
+			$url = set_url_scheme($url, 'https');
552 552
 		}
553 553
 
554 554
 		$http_args = array(
555
-			'user-agent' => 'WordPress/' . $wp_version . '; ' . home_url( '/' ),
555
+			'user-agent' => 'WordPress/' . $wp_version . '; ' . home_url('/'),
556 556
 		);
557
-		$request   = wp_remote_get( $url, $http_args );
557
+		$request   = wp_remote_get($url, $http_args);
558 558
 
559
-		if ( $ssl && is_wp_error( $request ) ) {
560
-			if ( ! wp_doing_ajax() ) {
559
+		if ($ssl && is_wp_error($request)) {
560
+			if (!wp_doing_ajax()) {
561 561
 				trigger_error(
562 562
 					sprintf(
563 563
 						/* translators: %s: Support forums URL. */
564
-						__( 'An unexpected error occurred. Something may be wrong with WordPress.org or this server&#8217;s configuration. If you continue to have problems, please try the <a href="%s">support forums</a>.' ),
565
-						__( 'https://wordpress.org/support/forums/' )
566
-					) . ' ' . __( '(WordPress could not establish a secure connection to WordPress.org. Please contact your server administrator.)' ),
564
+						__('An unexpected error occurred. Something may be wrong with WordPress.org or this server&#8217;s configuration. If you continue to have problems, please try the <a href="%s">support forums</a>.'),
565
+						__('https://wordpress.org/support/forums/')
566
+					) . ' ' . __('(WordPress could not establish a secure connection to WordPress.org. Please contact your server administrator.)'),
567 567
 					headers_sent() || WP_DEBUG ? E_USER_WARNING : E_USER_NOTICE
568 568
 				);
569 569
 			}
570
-			$request = wp_remote_get( $http_url, $http_args );
570
+			$request = wp_remote_get($http_url, $http_args);
571 571
 		}
572 572
 
573
-		if ( is_wp_error( $request ) ) {
573
+		if (is_wp_error($request)) {
574 574
 			$res = new WP_Error(
575 575
 				'themes_api_failed',
576 576
 				sprintf(
577 577
 					/* translators: %s: Support forums URL. */
578
-					__( 'An unexpected error occurred. Something may be wrong with WordPress.org or this server&#8217;s configuration. If you continue to have problems, please try the <a href="%s">support forums</a>.' ),
579
-					__( 'https://wordpress.org/support/forums/' )
578
+					__('An unexpected error occurred. Something may be wrong with WordPress.org or this server&#8217;s configuration. If you continue to have problems, please try the <a href="%s">support forums</a>.'),
579
+					__('https://wordpress.org/support/forums/')
580 580
 				),
581 581
 				$request->get_error_message()
582 582
 			);
583 583
 		} else {
584
-			$res = json_decode( wp_remote_retrieve_body( $request ), true );
585
-			if ( is_array( $res ) ) {
584
+			$res = json_decode(wp_remote_retrieve_body($request), true);
585
+			if (is_array($res)) {
586 586
 				// Object casting is required in order to match the info/1.0 format.
587 587
 				$res = (object) $res;
588
-			} elseif ( null === $res ) {
588
+			} elseif (null === $res) {
589 589
 				$res = new WP_Error(
590 590
 					'themes_api_failed',
591 591
 					sprintf(
592 592
 						/* translators: %s: Support forums URL. */
593
-						__( 'An unexpected error occurred. Something may be wrong with WordPress.org or this server&#8217;s configuration. If you continue to have problems, please try the <a href="%s">support forums</a>.' ),
594
-						__( 'https://wordpress.org/support/forums/' )
593
+						__('An unexpected error occurred. Something may be wrong with WordPress.org or this server&#8217;s configuration. If you continue to have problems, please try the <a href="%s">support forums</a>.'),
594
+						__('https://wordpress.org/support/forums/')
595 595
 					),
596
-					wp_remote_retrieve_body( $request )
596
+					wp_remote_retrieve_body($request)
597 597
 				);
598 598
 			}
599 599
 
600
-			if ( isset( $res->error ) ) {
601
-				$res = new WP_Error( 'themes_api_failed', $res->error );
600
+			if (isset($res->error)) {
601
+				$res = new WP_Error('themes_api_failed', $res->error);
602 602
 			}
603 603
 		}
604 604
 
605
-		if ( ! is_wp_error( $res ) ) {
605
+		if (!is_wp_error($res)) {
606 606
 			// Back-compat for info/1.2 API, upgrade the theme objects in query_themes to objects.
607
-			if ( 'query_themes' === $action ) {
608
-				foreach ( $res->themes as $i => $theme ) {
609
-					$res->themes[ $i ] = (object) $theme;
607
+			if ('query_themes' === $action) {
608
+				foreach ($res->themes as $i => $theme) {
609
+					$res->themes[$i] = (object) $theme;
610 610
 				}
611 611
 			}
612 612
 
613 613
 			// Back-compat for info/1.2 API, downgrade the feature_list result back to an array.
614
-			if ( 'feature_list' === $action ) {
614
+			if ('feature_list' === $action) {
615 615
 				$res = (array) $res;
616 616
 			}
617 617
 		}
@@ -627,7 +627,7 @@  discard block
 block discarded – undo
627 627
 	 *                                        'feature_list', or 'query_themes'.
628 628
 	 * @param stdClass                $args   Arguments used to query for installer pages from the WordPress.org Themes API.
629 629
 	 */
630
-	return apply_filters( 'themes_api_result', $res, $action, $args );
630
+	return apply_filters('themes_api_result', $res, $action, $args);
631 631
 }
632 632
 
633 633
 /**
@@ -640,7 +640,7 @@  discard block
 block discarded – undo
640 640
  *
641 641
  * @return array An associative array of theme data, sorted by name.
642 642
  */
643
-function wp_prepare_themes_for_js( $themes = null ) {
643
+function wp_prepare_themes_for_js($themes = null) {
644 644
 	$current_theme = get_stylesheet();
645 645
 
646 646
 	/**
@@ -655,82 +655,82 @@  discard block
 block discarded – undo
655 655
 	 * @param WP_Theme[]|null $themes          An array of theme objects to prepare, if any.
656 656
 	 * @param string          $current_theme   The active theme slug.
657 657
 	 */
658
-	$prepared_themes = (array) apply_filters( 'pre_prepare_themes_for_js', array(), $themes, $current_theme );
658
+	$prepared_themes = (array) apply_filters('pre_prepare_themes_for_js', array(), $themes, $current_theme);
659 659
 
660
-	if ( ! empty( $prepared_themes ) ) {
660
+	if (!empty($prepared_themes)) {
661 661
 		return $prepared_themes;
662 662
 	}
663 663
 
664 664
 	// Make sure the active theme is listed first.
665
-	$prepared_themes[ $current_theme ] = array();
665
+	$prepared_themes[$current_theme] = array();
666 666
 
667
-	if ( null === $themes ) {
668
-		$themes = wp_get_themes( array( 'allowed' => true ) );
669
-		if ( ! isset( $themes[ $current_theme ] ) ) {
670
-			$themes[ $current_theme ] = wp_get_theme();
667
+	if (null === $themes) {
668
+		$themes = wp_get_themes(array('allowed' => true));
669
+		if (!isset($themes[$current_theme])) {
670
+			$themes[$current_theme] = wp_get_theme();
671 671
 		}
672 672
 	}
673 673
 
674 674
 	$updates    = array();
675 675
 	$no_updates = array();
676
-	if ( ! is_multisite() && current_user_can( 'update_themes' ) ) {
677
-		$updates_transient = get_site_transient( 'update_themes' );
678
-		if ( isset( $updates_transient->response ) ) {
676
+	if (!is_multisite() && current_user_can('update_themes')) {
677
+		$updates_transient = get_site_transient('update_themes');
678
+		if (isset($updates_transient->response)) {
679 679
 			$updates = $updates_transient->response;
680 680
 		}
681
-		if ( isset( $updates_transient->no_update ) ) {
681
+		if (isset($updates_transient->no_update)) {
682 682
 			$no_updates = $updates_transient->no_update;
683 683
 		}
684 684
 	}
685 685
 
686
-	WP_Theme::sort_by_name( $themes );
686
+	WP_Theme::sort_by_name($themes);
687 687
 
688 688
 	$parents = array();
689 689
 
690
-	$auto_updates = (array) get_site_option( 'auto_update_themes', array() );
690
+	$auto_updates = (array) get_site_option('auto_update_themes', array());
691 691
 
692
-	foreach ( $themes as $theme ) {
692
+	foreach ($themes as $theme) {
693 693
 		$slug         = $theme->get_stylesheet();
694
-		$encoded_slug = urlencode( $slug );
694
+		$encoded_slug = urlencode($slug);
695 695
 
696 696
 		$parent = false;
697
-		if ( $theme->parent() ) {
697
+		if ($theme->parent()) {
698 698
 			$parent           = $theme->parent();
699
-			$parents[ $slug ] = $parent->get_stylesheet();
700
-			$parent           = $parent->display( 'Name' );
699
+			$parents[$slug] = $parent->get_stylesheet();
700
+			$parent           = $parent->display('Name');
701 701
 		}
702 702
 
703 703
 		$customize_action = null;
704 704
 
705
-		$can_edit_theme_options = current_user_can( 'edit_theme_options' );
706
-		$can_customize          = current_user_can( 'customize' );
705
+		$can_edit_theme_options = current_user_can('edit_theme_options');
706
+		$can_customize          = current_user_can('customize');
707 707
 		$is_block_theme         = $theme->is_block_theme();
708 708
 
709
-		if ( $is_block_theme && $can_edit_theme_options ) {
710
-			$customize_action = esc_url( admin_url( 'site-editor.php' ) );
711
-		} elseif ( ! $is_block_theme && $can_customize && $can_edit_theme_options ) {
709
+		if ($is_block_theme && $can_edit_theme_options) {
710
+			$customize_action = esc_url(admin_url('site-editor.php'));
711
+		} elseif (!$is_block_theme && $can_customize && $can_edit_theme_options) {
712 712
 			$customize_action = esc_url(
713 713
 				add_query_arg(
714 714
 					array(
715
-						'return' => urlencode( esc_url_raw( remove_query_arg( wp_removable_query_args(), wp_unslash( $_SERVER['REQUEST_URI'] ) ) ) ),
715
+						'return' => urlencode(esc_url_raw(remove_query_arg(wp_removable_query_args(), wp_unslash($_SERVER['REQUEST_URI'])))),
716 716
 					),
717
-					wp_customize_url( $slug )
717
+					wp_customize_url($slug)
718 718
 				)
719 719
 			);
720 720
 		}
721 721
 
722
-		$update_requires_wp  = isset( $updates[ $slug ]['requires'] ) ? $updates[ $slug ]['requires'] : null;
723
-		$update_requires_php = isset( $updates[ $slug ]['requires_php'] ) ? $updates[ $slug ]['requires_php'] : null;
722
+		$update_requires_wp  = isset($updates[$slug]['requires']) ? $updates[$slug]['requires'] : null;
723
+		$update_requires_php = isset($updates[$slug]['requires_php']) ? $updates[$slug]['requires_php'] : null;
724 724
 
725
-		$auto_update        = in_array( $slug, $auto_updates, true );
725
+		$auto_update        = in_array($slug, $auto_updates, true);
726 726
 		$auto_update_action = $auto_update ? 'disable-auto-update' : 'enable-auto-update';
727 727
 
728
-		if ( isset( $updates[ $slug ] ) ) {
728
+		if (isset($updates[$slug])) {
729 729
 			$auto_update_supported      = true;
730
-			$auto_update_filter_payload = (object) $updates[ $slug ];
731
-		} elseif ( isset( $no_updates[ $slug ] ) ) {
730
+			$auto_update_filter_payload = (object) $updates[$slug];
731
+		} elseif (isset($no_updates[$slug])) {
732 732
 			$auto_update_supported      = true;
733
-			$auto_update_filter_payload = (object) $no_updates[ $slug ];
733
+			$auto_update_filter_payload = (object) $no_updates[$slug];
734 734
 		} else {
735 735
 			$auto_update_supported = false;
736 736
 			/*
@@ -739,47 +739,47 @@  discard block
 block discarded – undo
739 739
 			 */
740 740
 			$auto_update_filter_payload = (object) array(
741 741
 				'theme'        => $slug,
742
-				'new_version'  => $theme->get( 'Version' ),
742
+				'new_version'  => $theme->get('Version'),
743 743
 				'url'          => '',
744 744
 				'package'      => '',
745
-				'requires'     => $theme->get( 'RequiresWP' ),
746
-				'requires_php' => $theme->get( 'RequiresPHP' ),
745
+				'requires'     => $theme->get('RequiresWP'),
746
+				'requires_php' => $theme->get('RequiresPHP'),
747 747
 			);
748 748
 		}
749 749
 
750
-		$auto_update_forced = wp_is_auto_update_forced_for_item( 'theme', null, $auto_update_filter_payload );
750
+		$auto_update_forced = wp_is_auto_update_forced_for_item('theme', null, $auto_update_filter_payload);
751 751
 
752
-		$prepared_themes[ $slug ] = array(
752
+		$prepared_themes[$slug] = array(
753 753
 			'id'             => $slug,
754
-			'name'           => $theme->display( 'Name' ),
755
-			'screenshot'     => array( $theme->get_screenshot() ), // @todo Multiple screenshots.
756
-			'description'    => $theme->display( 'Description' ),
757
-			'author'         => $theme->display( 'Author', false, true ),
758
-			'authorAndUri'   => $theme->display( 'Author' ),
759
-			'tags'           => $theme->display( 'Tags' ),
760
-			'version'        => $theme->get( 'Version' ),
761
-			'compatibleWP'   => is_wp_version_compatible( $theme->get( 'RequiresWP' ) ),
762
-			'compatiblePHP'  => is_php_version_compatible( $theme->get( 'RequiresPHP' ) ),
754
+			'name'           => $theme->display('Name'),
755
+			'screenshot'     => array($theme->get_screenshot()), // @todo Multiple screenshots.
756
+			'description'    => $theme->display('Description'),
757
+			'author'         => $theme->display('Author', false, true),
758
+			'authorAndUri'   => $theme->display('Author'),
759
+			'tags'           => $theme->display('Tags'),
760
+			'version'        => $theme->get('Version'),
761
+			'compatibleWP'   => is_wp_version_compatible($theme->get('RequiresWP')),
762
+			'compatiblePHP'  => is_php_version_compatible($theme->get('RequiresPHP')),
763 763
 			'updateResponse' => array(
764
-				'compatibleWP'  => is_wp_version_compatible( $update_requires_wp ),
765
-				'compatiblePHP' => is_php_version_compatible( $update_requires_php ),
764
+				'compatibleWP'  => is_wp_version_compatible($update_requires_wp),
765
+				'compatiblePHP' => is_php_version_compatible($update_requires_php),
766 766
 			),
767 767
 			'parent'         => $parent,
768 768
 			'active'         => $slug === $current_theme,
769
-			'hasUpdate'      => isset( $updates[ $slug ] ),
770
-			'hasPackage'     => isset( $updates[ $slug ] ) && ! empty( $updates[ $slug ]['package'] ),
771
-			'update'         => get_theme_update_available( $theme ),
769
+			'hasUpdate'      => isset($updates[$slug]),
770
+			'hasPackage'     => isset($updates[$slug]) && !empty($updates[$slug]['package']),
771
+			'update'         => get_theme_update_available($theme),
772 772
 			'autoupdate'     => array(
773 773
 				'enabled'   => $auto_update || $auto_update_forced,
774 774
 				'supported' => $auto_update_supported,
775 775
 				'forced'    => $auto_update_forced,
776 776
 			),
777 777
 			'actions'        => array(
778
-				'activate'   => current_user_can( 'switch_themes' ) ? wp_nonce_url( admin_url( 'themes.php?action=activate&amp;stylesheet=' . $encoded_slug ), 'switch-theme_' . $slug ) : null,
778
+				'activate'   => current_user_can('switch_themes') ? wp_nonce_url(admin_url('themes.php?action=activate&amp;stylesheet=' . $encoded_slug), 'switch-theme_' . $slug) : null,
779 779
 				'customize'  => $customize_action,
780
-				'delete'     => ( ! is_multisite() && current_user_can( 'delete_themes' ) ) ? wp_nonce_url( admin_url( 'themes.php?action=delete&amp;stylesheet=' . $encoded_slug ), 'delete-theme_' . $slug ) : null,
781
-				'autoupdate' => wp_is_auto_update_enabled_for_type( 'theme' ) && ! is_multisite() && current_user_can( 'update_themes' )
782
-					? wp_nonce_url( admin_url( 'themes.php?action=' . $auto_update_action . '&amp;stylesheet=' . $encoded_slug ), 'updates' )
780
+				'delete'     => (!is_multisite() && current_user_can('delete_themes')) ? wp_nonce_url(admin_url('themes.php?action=delete&amp;stylesheet=' . $encoded_slug), 'delete-theme_' . $slug) : null,
781
+				'autoupdate' => wp_is_auto_update_enabled_for_type('theme') && !is_multisite() && current_user_can('update_themes')
782
+					? wp_nonce_url(admin_url('themes.php?action=' . $auto_update_action . '&amp;stylesheet=' . $encoded_slug), 'updates')
783 783
 					: null,
784 784
 			),
785 785
 			'blockTheme'     => $theme->is_block_theme(),
@@ -787,8 +787,8 @@  discard block
 block discarded – undo
787 787
 	}
788 788
 
789 789
 	// Remove 'delete' action if theme has an active child.
790
-	if ( ! empty( $parents ) && array_key_exists( $current_theme, $parents ) ) {
791
-		unset( $prepared_themes[ $parents[ $current_theme ] ]['actions']['delete'] );
790
+	if (!empty($parents) && array_key_exists($current_theme, $parents)) {
791
+		unset($prepared_themes[$parents[$current_theme]]['actions']['delete']);
792 792
 	}
793 793
 
794 794
 	/**
@@ -800,9 +800,9 @@  discard block
 block discarded – undo
800 800
 	 *
801 801
 	 * @param array $prepared_themes Array of theme data.
802 802
 	 */
803
-	$prepared_themes = apply_filters( 'wp_prepare_themes_for_js', $prepared_themes );
804
-	$prepared_themes = array_values( $prepared_themes );
805
-	return array_filter( $prepared_themes );
803
+	$prepared_themes = apply_filters('wp_prepare_themes_for_js', $prepared_themes);
804
+	$prepared_themes = array_values($prepared_themes);
805
+	return array_filter($prepared_themes);
806 806
 }
807 807
 
808 808
 /**
@@ -816,9 +816,9 @@  discard block
 block discarded – undo
816 816
 		<div class="theme-backdrop"></div>
817 817
 		<div class="theme-wrap wp-clearfix" role="document">
818 818
 			<div class="theme-header">
819
-				<button type="button" class="left dashicons dashicons-no"><span class="screen-reader-text"><?php _e( 'Show previous theme' ); ?></span></button>
820
-				<button type="button" class="right dashicons dashicons-no"><span class="screen-reader-text"><?php _e( 'Show next theme' ); ?></span></button>
821
-				<button type="button" class="close dashicons dashicons-no"><span class="screen-reader-text"><?php _e( 'Close details dialog' ); ?></span></button>
819
+				<button type="button" class="left dashicons dashicons-no"><span class="screen-reader-text"><?php _e('Show previous theme'); ?></span></button>
820
+				<button type="button" class="right dashicons dashicons-no"><span class="screen-reader-text"><?php _e('Show next theme'); ?></span></button>
821
+				<button type="button" class="close dashicons dashicons-no"><span class="screen-reader-text"><?php _e('Close details dialog'); ?></span></button>
822 822
 			</div>
823 823
 			<div class="theme-about wp-clearfix">
824 824
 				<div class="theme-screenshots">
@@ -831,18 +831,18 @@  discard block
 block discarded – undo
831 831
 
832 832
 				<div class="theme-info">
833 833
 					<# if ( data.active ) { #>
834
-						<span class="current-label"><?php _e( 'Active Theme' ); ?></span>
834
+						<span class="current-label"><?php _e('Active Theme'); ?></span>
835 835
 					<# } #>
836 836
 					<h2 class="theme-name">{{{ data.name }}}<span class="theme-version">
837 837
 						<?php
838 838
 						/* translators: %s: Theme version. */
839
-						printf( __( 'Version: %s' ), '{{ data.version }}' );
839
+						printf(__('Version: %s'), '{{ data.version }}');
840 840
 						?>
841 841
 					</span></h2>
842 842
 					<h3 class="theme-author">
843 843
 						<?php
844 844
 						/* translators: %s: Theme author link. */
845
-						printf( __( 'By %s' ), '{{{ data.authorAndUri }}}' );
845
+						printf(__('By %s'), '{{{ data.authorAndUri }}}');
846 846
 						?>
847 847
 					</h3>
848 848
 
@@ -854,9 +854,9 @@  discard block
 block discarded – undo
854 854
 								printf(
855 855
 									'%1$s <span class="screen-reader-text">%2$s</span>',
856 856
 									/* translators: %s: Number of ratings. */
857
-									sprintf( __( '(%s ratings)' ), '{{ data.num_ratings }}' ),
857
+									sprintf(__('(%s ratings)'), '{{ data.num_ratings }}'),
858 858
 									/* translators: Accessibility text. */
859
-									__( '(opens in a new tab)' )
859
+									__('(opens in a new tab)')
860 860
 								);
861 861
 								?>
862 862
 							</a>
@@ -866,55 +866,55 @@  discard block
 block discarded – undo
866 866
 					<# if ( data.hasUpdate ) { #>
867 867
 						<# if ( data.updateResponse.compatibleWP && data.updateResponse.compatiblePHP ) { #>
868 868
 							<div class="notice notice-warning notice-alt notice-large" data-slug="{{ data.id }}">
869
-								<h3 class="notice-title"><?php _e( 'Update Available' ); ?></h3>
869
+								<h3 class="notice-title"><?php _e('Update Available'); ?></h3>
870 870
 								{{{ data.update }}}
871 871
 							</div>
872 872
 						<# } else { #>
873 873
 							<div class="notice notice-error notice-alt notice-large" data-slug="{{ data.id }}">
874
-								<h3 class="notice-title"><?php _e( 'Update Incompatible' ); ?></h3>
874
+								<h3 class="notice-title"><?php _e('Update Incompatible'); ?></h3>
875 875
 								<p>
876 876
 									<# if ( ! data.updateResponse.compatibleWP && ! data.updateResponse.compatiblePHP ) { #>
877 877
 										<?php
878 878
 										printf(
879 879
 											/* translators: %s: Theme name. */
880
-											__( 'There is a new version of %s available, but it does not work with your versions of WordPress and PHP.' ),
880
+											__('There is a new version of %s available, but it does not work with your versions of WordPress and PHP.'),
881 881
 											'{{{ data.name }}}'
882 882
 										);
883
-										if ( current_user_can( 'update_core' ) && current_user_can( 'update_php' ) ) {
883
+										if (current_user_can('update_core') && current_user_can('update_php')) {
884 884
 											printf(
885 885
 												/* translators: 1: URL to WordPress Updates screen, 2: URL to Update PHP page. */
886
-												' ' . __( '<a href="%1$s">Please update WordPress</a>, and then <a href="%2$s">learn more about updating PHP</a>.' ),
887
-												self_admin_url( 'update-core.php' ),
888
-												esc_url( wp_get_update_php_url() )
886
+												' ' . __('<a href="%1$s">Please update WordPress</a>, and then <a href="%2$s">learn more about updating PHP</a>.'),
887
+												self_admin_url('update-core.php'),
888
+												esc_url(wp_get_update_php_url())
889 889
 											);
890
-											wp_update_php_annotation( '</p><p><em>', '</em>' );
891
-										} elseif ( current_user_can( 'update_core' ) ) {
890
+											wp_update_php_annotation('</p><p><em>', '</em>');
891
+										} elseif (current_user_can('update_core')) {
892 892
 											printf(
893 893
 												/* translators: %s: URL to WordPress Updates screen. */
894
-												' ' . __( '<a href="%s">Please update WordPress</a>.' ),
895
-												self_admin_url( 'update-core.php' )
894
+												' ' . __('<a href="%s">Please update WordPress</a>.'),
895
+												self_admin_url('update-core.php')
896 896
 											);
897
-										} elseif ( current_user_can( 'update_php' ) ) {
897
+										} elseif (current_user_can('update_php')) {
898 898
 											printf(
899 899
 												/* translators: %s: URL to Update PHP page. */
900
-												' ' . __( '<a href="%s">Learn more about updating PHP</a>.' ),
901
-												esc_url( wp_get_update_php_url() )
900
+												' ' . __('<a href="%s">Learn more about updating PHP</a>.'),
901
+												esc_url(wp_get_update_php_url())
902 902
 											);
903
-											wp_update_php_annotation( '</p><p><em>', '</em>' );
903
+											wp_update_php_annotation('</p><p><em>', '</em>');
904 904
 										}
905 905
 										?>
906 906
 									<# } else if ( ! data.updateResponse.compatibleWP ) { #>
907 907
 										<?php
908 908
 										printf(
909 909
 											/* translators: %s: Theme name. */
910
-											__( 'There is a new version of %s available, but it does not work with your version of WordPress.' ),
910
+											__('There is a new version of %s available, but it does not work with your version of WordPress.'),
911 911
 											'{{{ data.name }}}'
912 912
 										);
913
-										if ( current_user_can( 'update_core' ) ) {
913
+										if (current_user_can('update_core')) {
914 914
 											printf(
915 915
 												/* translators: %s: URL to WordPress Updates screen. */
916
-												' ' . __( '<a href="%s">Please update WordPress</a>.' ),
917
-												self_admin_url( 'update-core.php' )
916
+												' ' . __('<a href="%s">Please update WordPress</a>.'),
917
+												self_admin_url('update-core.php')
918 918
 											);
919 919
 										}
920 920
 										?>
@@ -922,16 +922,16 @@  discard block
 block discarded – undo
922 922
 										<?php
923 923
 										printf(
924 924
 											/* translators: %s: Theme name. */
925
-											__( 'There is a new version of %s available, but it does not work with your version of PHP.' ),
925
+											__('There is a new version of %s available, but it does not work with your version of PHP.'),
926 926
 											'{{{ data.name }}}'
927 927
 										);
928
-										if ( current_user_can( 'update_php' ) ) {
928
+										if (current_user_can('update_php')) {
929 929
 											printf(
930 930
 												/* translators: %s: URL to Update PHP page. */
931
-												' ' . __( '<a href="%s">Learn more about updating PHP</a>.' ),
932
-												esc_url( wp_get_update_php_url() )
931
+												' ' . __('<a href="%s">Learn more about updating PHP</a>.'),
932
+												esc_url(wp_get_update_php_url())
933 933
 											);
934
-											wp_update_php_annotation( '</p><p><em>', '</em>' );
934
+											wp_update_php_annotation('</p><p><em>', '</em>');
935 935
 										}
936 936
 										?>
937 937
 									<# } #>
@@ -945,7 +945,7 @@  discard block
 block discarded – undo
945 945
 							<?php
946 946
 							printf(
947 947
 								/* translators: %s: Theme name. */
948
-								__( 'This is a child theme of %s.' ),
948
+								__('This is a child theme of %s.'),
949 949
 								'<strong>{{{ data.parent }}}</strong>'
950 950
 							);
951 951
 							?>
@@ -956,51 +956,51 @@  discard block
 block discarded – undo
956 956
 						<div class="notice notice-error notice-alt notice-large"><p>
957 957
 							<# if ( ! data.compatibleWP && ! data.compatiblePHP ) { #>
958 958
 								<?php
959
-								_e( 'This theme does not work with your versions of WordPress and PHP.' );
960
-								if ( current_user_can( 'update_core' ) && current_user_can( 'update_php' ) ) {
959
+								_e('This theme does not work with your versions of WordPress and PHP.');
960
+								if (current_user_can('update_core') && current_user_can('update_php')) {
961 961
 									printf(
962 962
 										/* translators: 1: URL to WordPress Updates screen, 2: URL to Update PHP page. */
963
-										' ' . __( '<a href="%1$s">Please update WordPress</a>, and then <a href="%2$s">learn more about updating PHP</a>.' ),
964
-										self_admin_url( 'update-core.php' ),
965
-										esc_url( wp_get_update_php_url() )
963
+										' ' . __('<a href="%1$s">Please update WordPress</a>, and then <a href="%2$s">learn more about updating PHP</a>.'),
964
+										self_admin_url('update-core.php'),
965
+										esc_url(wp_get_update_php_url())
966 966
 									);
967
-									wp_update_php_annotation( '</p><p><em>', '</em>' );
968
-								} elseif ( current_user_can( 'update_core' ) ) {
967
+									wp_update_php_annotation('</p><p><em>', '</em>');
968
+								} elseif (current_user_can('update_core')) {
969 969
 									printf(
970 970
 										/* translators: %s: URL to WordPress Updates screen. */
971
-										' ' . __( '<a href="%s">Please update WordPress</a>.' ),
972
-										self_admin_url( 'update-core.php' )
971
+										' ' . __('<a href="%s">Please update WordPress</a>.'),
972
+										self_admin_url('update-core.php')
973 973
 									);
974
-								} elseif ( current_user_can( 'update_php' ) ) {
974
+								} elseif (current_user_can('update_php')) {
975 975
 									printf(
976 976
 										/* translators: %s: URL to Update PHP page. */
977
-										' ' . __( '<a href="%s">Learn more about updating PHP</a>.' ),
978
-										esc_url( wp_get_update_php_url() )
977
+										' ' . __('<a href="%s">Learn more about updating PHP</a>.'),
978
+										esc_url(wp_get_update_php_url())
979 979
 									);
980
-									wp_update_php_annotation( '</p><p><em>', '</em>' );
980
+									wp_update_php_annotation('</p><p><em>', '</em>');
981 981
 								}
982 982
 								?>
983 983
 							<# } else if ( ! data.compatibleWP ) { #>
984 984
 								<?php
985
-								_e( 'This theme does not work with your version of WordPress.' );
986
-								if ( current_user_can( 'update_core' ) ) {
985
+								_e('This theme does not work with your version of WordPress.');
986
+								if (current_user_can('update_core')) {
987 987
 									printf(
988 988
 										/* translators: %s: URL to WordPress Updates screen. */
989
-										' ' . __( '<a href="%s">Please update WordPress</a>.' ),
990
-										self_admin_url( 'update-core.php' )
989
+										' ' . __('<a href="%s">Please update WordPress</a>.'),
990
+										self_admin_url('update-core.php')
991 991
 									);
992 992
 								}
993 993
 								?>
994 994
 							<# } else if ( ! data.compatiblePHP ) { #>
995 995
 								<?php
996
-								_e( 'This theme does not work with your version of PHP.' );
997
-								if ( current_user_can( 'update_php' ) ) {
996
+								_e('This theme does not work with your version of PHP.');
997
+								if (current_user_can('update_php')) {
998 998
 									printf(
999 999
 										/* translators: %s: URL to Update PHP page. */
1000
-										' ' . __( '<a href="%s">Learn more about updating PHP</a>.' ),
1001
-										esc_url( wp_get_update_php_url() )
1000
+										' ' . __('<a href="%s">Learn more about updating PHP</a>.'),
1001
+										esc_url(wp_get_update_php_url())
1002 1002
 									);
1003
-									wp_update_php_annotation( '</p><p><em>', '</em>' );
1003
+									wp_update_php_annotation('</p><p><em>', '</em>');
1004 1004
 								}
1005 1005
 								?>
1006 1006
 							<# } #>
@@ -1008,13 +1008,13 @@  discard block
 block discarded – undo
1008 1008
 					<# } else if ( ! data.active && data.blockTheme ) { #>
1009 1009
 						<div class="notice notice-error notice-alt notice-large"><p>
1010 1010
 						<?php
1011
-							_e( 'This theme doesn\'t support Customizer.' );
1011
+							_e('This theme doesn\'t support Customizer.');
1012 1012
 						?>
1013 1013
 						<# if ( data.actions.activate ) { #>
1014 1014
 							<?php
1015 1015
 							printf(
1016 1016
 								/* translators: %s: URL to the themes page (also it activates the theme). */
1017
-								' ' . __( 'However, you can still <a href="%s">activate this theme</a>, and use the Site Editor to customize it.' ),
1017
+								' ' . __('However, you can still <a href="%s">activate this theme</a>, and use the Site Editor to customize it.'),
1018 1018
 								'{{{ data.actions.activate }}}'
1019 1019
 							);
1020 1020
 							?>
@@ -1025,43 +1025,43 @@  discard block
 block discarded – undo
1025 1025
 					<p class="theme-description">{{{ data.description }}}</p>
1026 1026
 
1027 1027
 					<# if ( data.tags ) { #>
1028
-						<p class="theme-tags"><span><?php _e( 'Tags:' ); ?></span> {{{ data.tags }}}</p>
1028
+						<p class="theme-tags"><span><?php _e('Tags:'); ?></span> {{{ data.tags }}}</p>
1029 1029
 					<# } #>
1030 1030
 				</div>
1031 1031
 			</div>
1032 1032
 
1033 1033
 			<div class="theme-actions">
1034 1034
 				<# if ( data.active ) { #>
1035
-					<button type="button" class="button button-primary customize-theme"><?php _e( 'Customize' ); ?></button>
1035
+					<button type="button" class="button button-primary customize-theme"><?php _e('Customize'); ?></button>
1036 1036
 				<# } else if ( 'installed' === data.type ) { #>
1037
-					<?php if ( current_user_can( 'delete_themes' ) ) { ?>
1037
+					<?php if (current_user_can('delete_themes')) { ?>
1038 1038
 						<# if ( data.actions && data.actions['delete'] ) { #>
1039
-							<a href="{{{ data.actions['delete'] }}}" data-slug="{{ data.id }}" class="button button-secondary delete-theme"><?php _e( 'Delete' ); ?></a>
1039
+							<a href="{{{ data.actions['delete'] }}}" data-slug="{{ data.id }}" class="button button-secondary delete-theme"><?php _e('Delete'); ?></a>
1040 1040
 						<# } #>
1041 1041
 					<?php } ?>
1042 1042
 
1043 1043
 					<# if ( data.blockTheme ) { #>
1044 1044
 						<?php
1045 1045
 							/* translators: %s: Theme name. */
1046
-							$aria_label = sprintf( _x( 'Activate %s', 'theme' ), '{{ data.name }}' );
1046
+							$aria_label = sprintf(_x('Activate %s', 'theme'), '{{ data.name }}');
1047 1047
 						?>
1048 1048
 						<# if ( data.compatibleWP && data.compatiblePHP && data.actions.activate ) { #>
1049
-							<a href="{{{ data.actions.activate }}}" class="button button-primary activate" aria-label="<?php echo esc_attr( $aria_label ); ?>"><?php _e( 'Activate' ); ?></a>
1049
+							<a href="{{{ data.actions.activate }}}" class="button button-primary activate" aria-label="<?php echo esc_attr($aria_label); ?>"><?php _e('Activate'); ?></a>
1050 1050
 						<# } #>
1051 1051
 					<# } else { #>
1052 1052
 						<# if ( data.compatibleWP && data.compatiblePHP ) { #>
1053
-							<button type="button" class="button button-primary preview-theme" data-slug="{{ data.id }}"><?php _e( 'Live Preview' ); ?></button>
1053
+							<button type="button" class="button button-primary preview-theme" data-slug="{{ data.id }}"><?php _e('Live Preview'); ?></button>
1054 1054
 						<# } else { #>
1055
-							<button class="button button-primary disabled"><?php _e( 'Live Preview' ); ?></button>
1055
+							<button class="button button-primary disabled"><?php _e('Live Preview'); ?></button>
1056 1056
 						<# } #>
1057 1057
 					<# } #>
1058 1058
 				<# } else { #>
1059 1059
 					<# if ( data.compatibleWP && data.compatiblePHP ) { #>
1060
-						<button type="button" class="button theme-install" data-slug="{{ data.id }}"><?php _e( 'Install' ); ?></button>
1061
-						<button type="button" class="button button-primary theme-install preview" data-slug="{{ data.id }}"><?php _e( 'Install &amp; Preview' ); ?></button>
1060
+						<button type="button" class="button theme-install" data-slug="{{ data.id }}"><?php _e('Install'); ?></button>
1061
+						<button type="button" class="button button-primary theme-install preview" data-slug="{{ data.id }}"><?php _e('Install &amp; Preview'); ?></button>
1062 1062
 					<# } else { #>
1063
-						<button type="button" class="button disabled"><?php _ex( 'Cannot Install', 'theme' ); ?></button>
1064
-						<button type="button" class="button button-primary disabled"><?php _e( 'Install &amp; Preview' ); ?></button>
1063
+						<button type="button" class="button disabled"><?php _ex('Cannot Install', 'theme'); ?></button>
1064
+						<button type="button" class="button button-primary disabled"><?php _e('Install &amp; Preview'); ?></button>
1065 1065
 					<# } #>
1066 1066
 				<# } #>
1067 1067
 			</div>
@@ -1083,16 +1083,16 @@  discard block
 block discarded – undo
1083 1083
  * @param string $theme Path to the theme directory relative to the themes directory.
1084 1084
  * @return bool True, if in the list of paused themes. False, not in the list.
1085 1085
  */
1086
-function is_theme_paused( $theme ) {
1087
-	if ( ! isset( $GLOBALS['_paused_themes'] ) ) {
1086
+function is_theme_paused($theme) {
1087
+	if (!isset($GLOBALS['_paused_themes'])) {
1088 1088
 		return false;
1089 1089
 	}
1090 1090
 
1091
-	if ( get_stylesheet() !== $theme && get_template() !== $theme ) {
1091
+	if (get_stylesheet() !== $theme && get_template() !== $theme) {
1092 1092
 		return false;
1093 1093
 	}
1094 1094
 
1095
-	return array_key_exists( $theme, $GLOBALS['_paused_themes'] );
1095
+	return array_key_exists($theme, $GLOBALS['_paused_themes']);
1096 1096
 }
1097 1097
 
1098 1098
 /**
@@ -1105,16 +1105,16 @@  discard block
 block discarded – undo
1105 1105
  * @return array|false Array of error information as it was returned by
1106 1106
  *                     `error_get_last()`, or false if none was recorded.
1107 1107
  */
1108
-function wp_get_theme_error( $theme ) {
1109
-	if ( ! isset( $GLOBALS['_paused_themes'] ) ) {
1108
+function wp_get_theme_error($theme) {
1109
+	if (!isset($GLOBALS['_paused_themes'])) {
1110 1110
 		return false;
1111 1111
 	}
1112 1112
 
1113
-	if ( ! array_key_exists( $theme, $GLOBALS['_paused_themes'] ) ) {
1113
+	if (!array_key_exists($theme, $GLOBALS['_paused_themes'])) {
1114 1114
 		return false;
1115 1115
 	}
1116 1116
 
1117
-	return $GLOBALS['_paused_themes'][ $theme ];
1117
+	return $GLOBALS['_paused_themes'][$theme];
1118 1118
 }
1119 1119
 
1120 1120
 /**
@@ -1134,46 +1134,46 @@  discard block
 block discarded – undo
1134 1134
  * @return bool|WP_Error True on success, false if `$theme` was not paused,
1135 1135
  *                       `WP_Error` on failure.
1136 1136
  */
1137
-function resume_theme( $theme, $redirect = '' ) {
1138
-	list( $extension ) = explode( '/', $theme );
1137
+function resume_theme($theme, $redirect = '') {
1138
+	list($extension) = explode('/', $theme);
1139 1139
 
1140 1140
 	/*
1141 1141
 	 * We'll override this later if the theme could be resumed without
1142 1142
 	 * creating a fatal error.
1143 1143
 	 */
1144
-	if ( ! empty( $redirect ) ) {
1144
+	if (!empty($redirect)) {
1145 1145
 		$functions_path = '';
1146
-		if ( strpos( STYLESHEETPATH, $extension ) ) {
1146
+		if (strpos(STYLESHEETPATH, $extension)) {
1147 1147
 			$functions_path = STYLESHEETPATH . '/functions.php';
1148
-		} elseif ( strpos( TEMPLATEPATH, $extension ) ) {
1148
+		} elseif (strpos(TEMPLATEPATH, $extension)) {
1149 1149
 			$functions_path = TEMPLATEPATH . '/functions.php';
1150 1150
 		}
1151 1151
 
1152
-		if ( ! empty( $functions_path ) ) {
1152
+		if (!empty($functions_path)) {
1153 1153
 			wp_redirect(
1154 1154
 				add_query_arg(
1155 1155
 					'_error_nonce',
1156
-					wp_create_nonce( 'theme-resume-error_' . $theme ),
1156
+					wp_create_nonce('theme-resume-error_' . $theme),
1157 1157
 					$redirect
1158 1158
 				)
1159 1159
 			);
1160 1160
 
1161 1161
 			// Load the theme's functions.php to test whether it throws a fatal error.
1162 1162
 			ob_start();
1163
-			if ( ! defined( 'WP_SANDBOX_SCRAPING' ) ) {
1164
-				define( 'WP_SANDBOX_SCRAPING', true );
1163
+			if (!defined('WP_SANDBOX_SCRAPING')) {
1164
+				define('WP_SANDBOX_SCRAPING', true);
1165 1165
 			}
1166 1166
 			include $functions_path;
1167 1167
 			ob_clean();
1168 1168
 		}
1169 1169
 	}
1170 1170
 
1171
-	$result = wp_paused_themes()->delete( $extension );
1171
+	$result = wp_paused_themes()->delete($extension);
1172 1172
 
1173
-	if ( ! $result ) {
1173
+	if (!$result) {
1174 1174
 		return new WP_Error(
1175 1175
 			'could_not_resume_theme',
1176
-			__( 'Could not resume the theme.' )
1176
+			__('Could not resume the theme.')
1177 1177
 		);
1178 1178
 	}
1179 1179
 
@@ -1188,23 +1188,23 @@  discard block
 block discarded – undo
1188 1188
  * @global string $pagenow The filename of the current screen.
1189 1189
  */
1190 1190
 function paused_themes_notice() {
1191
-	if ( 'themes.php' === $GLOBALS['pagenow'] ) {
1191
+	if ('themes.php' === $GLOBALS['pagenow']) {
1192 1192
 		return;
1193 1193
 	}
1194 1194
 
1195
-	if ( ! current_user_can( 'resume_themes' ) ) {
1195
+	if (!current_user_can('resume_themes')) {
1196 1196
 		return;
1197 1197
 	}
1198 1198
 
1199
-	if ( ! isset( $GLOBALS['_paused_themes'] ) || empty( $GLOBALS['_paused_themes'] ) ) {
1199
+	if (!isset($GLOBALS['_paused_themes']) || empty($GLOBALS['_paused_themes'])) {
1200 1200
 		return;
1201 1201
 	}
1202 1202
 
1203 1203
 	printf(
1204 1204
 		'<div class="notice notice-error"><p><strong>%s</strong><br>%s</p><p><a href="%s">%s</a></p></div>',
1205
-		__( 'One or more themes failed to load properly.' ),
1206
-		__( 'You can find more details and make changes on the Themes screen.' ),
1207
-		esc_url( admin_url( 'themes.php' ) ),
1208
-		__( 'Go to the Themes screen' )
1205
+		__('One or more themes failed to load properly.'),
1206
+		__('You can find more details and make changes on the Themes screen.'),
1207
+		esc_url(admin_url('themes.php')),
1208
+		__('Go to the Themes screen')
1209 1209
 	);
1210 1210
 }
Please login to merge, or discard this patch.
brighty/wp-admin/includes/class-file-upload-upgrader.php 2 patches
Indentation   +112 added lines, -112 removed lines patch added patch discarded remove patch
@@ -18,116 +18,116 @@
 block discarded – undo
18 18
  */
19 19
 class File_Upload_Upgrader {
20 20
 
21
-	/**
22
-	 * The full path to the file package.
23
-	 *
24
-	 * @since 2.8.0
25
-	 * @var string $package
26
-	 */
27
-	public $package;
28
-
29
-	/**
30
-	 * The name of the file.
31
-	 *
32
-	 * @since 2.8.0
33
-	 * @var string $filename
34
-	 */
35
-	public $filename;
36
-
37
-	/**
38
-	 * The ID of the attachment post for this file.
39
-	 *
40
-	 * @since 3.3.0
41
-	 * @var int $id
42
-	 */
43
-	public $id = 0;
44
-
45
-	/**
46
-	 * Construct the upgrader for a form.
47
-	 *
48
-	 * @since 2.8.0
49
-	 *
50
-	 * @param string $form      The name of the form the file was uploaded from.
51
-	 * @param string $urlholder The name of the `GET` parameter that holds the filename.
52
-	 */
53
-	public function __construct( $form, $urlholder ) {
54
-
55
-		if ( empty( $_FILES[ $form ]['name'] ) && empty( $_GET[ $urlholder ] ) ) {
56
-			wp_die( __( 'Please select a file' ) );
57
-		}
58
-
59
-		// Handle a newly uploaded file. Else, assume it's already been uploaded.
60
-		if ( ! empty( $_FILES ) ) {
61
-			$overrides = array(
62
-				'test_form' => false,
63
-				'test_type' => false,
64
-			);
65
-			$file      = wp_handle_upload( $_FILES[ $form ], $overrides );
66
-
67
-			if ( isset( $file['error'] ) ) {
68
-				wp_die( $file['error'] );
69
-			}
70
-
71
-			$this->filename = $_FILES[ $form ]['name'];
72
-			$this->package  = $file['file'];
73
-
74
-			// Construct the attachment array.
75
-			$attachment = array(
76
-				'post_title'     => $this->filename,
77
-				'post_content'   => $file['url'],
78
-				'post_mime_type' => $file['type'],
79
-				'guid'           => $file['url'],
80
-				'context'        => 'upgrader',
81
-				'post_status'    => 'private',
82
-			);
83
-
84
-			// Save the data.
85
-			$this->id = wp_insert_attachment( $attachment, $file['file'] );
86
-
87
-			// Schedule a cleanup for 2 hours from now in case of failed installation.
88
-			wp_schedule_single_event( time() + 2 * HOUR_IN_SECONDS, 'upgrader_scheduled_cleanup', array( $this->id ) );
89
-
90
-		} elseif ( is_numeric( $_GET[ $urlholder ] ) ) {
91
-			// Numeric Package = previously uploaded file, see above.
92
-			$this->id   = (int) $_GET[ $urlholder ];
93
-			$attachment = get_post( $this->id );
94
-			if ( empty( $attachment ) ) {
95
-				wp_die( __( 'Please select a file' ) );
96
-			}
97
-
98
-			$this->filename = $attachment->post_title;
99
-			$this->package  = get_attached_file( $attachment->ID );
100
-		} else {
101
-			// Else, It's set to something, Back compat for plugins using the old (pre-3.3) File_Uploader handler.
102
-			$uploads = wp_upload_dir();
103
-			if ( ! ( $uploads && false === $uploads['error'] ) ) {
104
-				wp_die( $uploads['error'] );
105
-			}
106
-
107
-			$this->filename = sanitize_file_name( $_GET[ $urlholder ] );
108
-			$this->package  = $uploads['basedir'] . '/' . $this->filename;
109
-
110
-			if ( 0 !== strpos( realpath( $this->package ), realpath( $uploads['basedir'] ) ) ) {
111
-				wp_die( __( 'Please select a file' ) );
112
-			}
113
-		}
114
-	}
115
-
116
-	/**
117
-	 * Delete the attachment/uploaded file.
118
-	 *
119
-	 * @since 3.2.2
120
-	 *
121
-	 * @return bool Whether the cleanup was successful.
122
-	 */
123
-	public function cleanup() {
124
-		if ( $this->id ) {
125
-			wp_delete_attachment( $this->id );
126
-
127
-		} elseif ( file_exists( $this->package ) ) {
128
-			return @unlink( $this->package );
129
-		}
130
-
131
-		return true;
132
-	}
21
+    /**
22
+     * The full path to the file package.
23
+     *
24
+     * @since 2.8.0
25
+     * @var string $package
26
+     */
27
+    public $package;
28
+
29
+    /**
30
+     * The name of the file.
31
+     *
32
+     * @since 2.8.0
33
+     * @var string $filename
34
+     */
35
+    public $filename;
36
+
37
+    /**
38
+     * The ID of the attachment post for this file.
39
+     *
40
+     * @since 3.3.0
41
+     * @var int $id
42
+     */
43
+    public $id = 0;
44
+
45
+    /**
46
+     * Construct the upgrader for a form.
47
+     *
48
+     * @since 2.8.0
49
+     *
50
+     * @param string $form      The name of the form the file was uploaded from.
51
+     * @param string $urlholder The name of the `GET` parameter that holds the filename.
52
+     */
53
+    public function __construct( $form, $urlholder ) {
54
+
55
+        if ( empty( $_FILES[ $form ]['name'] ) && empty( $_GET[ $urlholder ] ) ) {
56
+            wp_die( __( 'Please select a file' ) );
57
+        }
58
+
59
+        // Handle a newly uploaded file. Else, assume it's already been uploaded.
60
+        if ( ! empty( $_FILES ) ) {
61
+            $overrides = array(
62
+                'test_form' => false,
63
+                'test_type' => false,
64
+            );
65
+            $file      = wp_handle_upload( $_FILES[ $form ], $overrides );
66
+
67
+            if ( isset( $file['error'] ) ) {
68
+                wp_die( $file['error'] );
69
+            }
70
+
71
+            $this->filename = $_FILES[ $form ]['name'];
72
+            $this->package  = $file['file'];
73
+
74
+            // Construct the attachment array.
75
+            $attachment = array(
76
+                'post_title'     => $this->filename,
77
+                'post_content'   => $file['url'],
78
+                'post_mime_type' => $file['type'],
79
+                'guid'           => $file['url'],
80
+                'context'        => 'upgrader',
81
+                'post_status'    => 'private',
82
+            );
83
+
84
+            // Save the data.
85
+            $this->id = wp_insert_attachment( $attachment, $file['file'] );
86
+
87
+            // Schedule a cleanup for 2 hours from now in case of failed installation.
88
+            wp_schedule_single_event( time() + 2 * HOUR_IN_SECONDS, 'upgrader_scheduled_cleanup', array( $this->id ) );
89
+
90
+        } elseif ( is_numeric( $_GET[ $urlholder ] ) ) {
91
+            // Numeric Package = previously uploaded file, see above.
92
+            $this->id   = (int) $_GET[ $urlholder ];
93
+            $attachment = get_post( $this->id );
94
+            if ( empty( $attachment ) ) {
95
+                wp_die( __( 'Please select a file' ) );
96
+            }
97
+
98
+            $this->filename = $attachment->post_title;
99
+            $this->package  = get_attached_file( $attachment->ID );
100
+        } else {
101
+            // Else, It's set to something, Back compat for plugins using the old (pre-3.3) File_Uploader handler.
102
+            $uploads = wp_upload_dir();
103
+            if ( ! ( $uploads && false === $uploads['error'] ) ) {
104
+                wp_die( $uploads['error'] );
105
+            }
106
+
107
+            $this->filename = sanitize_file_name( $_GET[ $urlholder ] );
108
+            $this->package  = $uploads['basedir'] . '/' . $this->filename;
109
+
110
+            if ( 0 !== strpos( realpath( $this->package ), realpath( $uploads['basedir'] ) ) ) {
111
+                wp_die( __( 'Please select a file' ) );
112
+            }
113
+        }
114
+    }
115
+
116
+    /**
117
+     * Delete the attachment/uploaded file.
118
+     *
119
+     * @since 3.2.2
120
+     *
121
+     * @return bool Whether the cleanup was successful.
122
+     */
123
+    public function cleanup() {
124
+        if ( $this->id ) {
125
+            wp_delete_attachment( $this->id );
126
+
127
+        } elseif ( file_exists( $this->package ) ) {
128
+            return @unlink( $this->package );
129
+        }
130
+
131
+        return true;
132
+    }
133 133
 }
Please login to merge, or discard this patch.
Spacing   +25 added lines, -25 removed lines patch added patch discarded remove patch
@@ -50,25 +50,25 @@  discard block
 block discarded – undo
50 50
 	 * @param string $form      The name of the form the file was uploaded from.
51 51
 	 * @param string $urlholder The name of the `GET` parameter that holds the filename.
52 52
 	 */
53
-	public function __construct( $form, $urlholder ) {
53
+	public function __construct($form, $urlholder) {
54 54
 
55
-		if ( empty( $_FILES[ $form ]['name'] ) && empty( $_GET[ $urlholder ] ) ) {
56
-			wp_die( __( 'Please select a file' ) );
55
+		if (empty($_FILES[$form]['name']) && empty($_GET[$urlholder])) {
56
+			wp_die(__('Please select a file'));
57 57
 		}
58 58
 
59 59
 		// Handle a newly uploaded file. Else, assume it's already been uploaded.
60
-		if ( ! empty( $_FILES ) ) {
60
+		if (!empty($_FILES)) {
61 61
 			$overrides = array(
62 62
 				'test_form' => false,
63 63
 				'test_type' => false,
64 64
 			);
65
-			$file      = wp_handle_upload( $_FILES[ $form ], $overrides );
65
+			$file = wp_handle_upload($_FILES[$form], $overrides);
66 66
 
67
-			if ( isset( $file['error'] ) ) {
68
-				wp_die( $file['error'] );
67
+			if (isset($file['error'])) {
68
+				wp_die($file['error']);
69 69
 			}
70 70
 
71
-			$this->filename = $_FILES[ $form ]['name'];
71
+			$this->filename = $_FILES[$form]['name'];
72 72
 			$this->package  = $file['file'];
73 73
 
74 74
 			// Construct the attachment array.
@@ -82,33 +82,33 @@  discard block
 block discarded – undo
82 82
 			);
83 83
 
84 84
 			// Save the data.
85
-			$this->id = wp_insert_attachment( $attachment, $file['file'] );
85
+			$this->id = wp_insert_attachment($attachment, $file['file']);
86 86
 
87 87
 			// Schedule a cleanup for 2 hours from now in case of failed installation.
88
-			wp_schedule_single_event( time() + 2 * HOUR_IN_SECONDS, 'upgrader_scheduled_cleanup', array( $this->id ) );
88
+			wp_schedule_single_event(time() + 2 * HOUR_IN_SECONDS, 'upgrader_scheduled_cleanup', array($this->id));
89 89
 
90
-		} elseif ( is_numeric( $_GET[ $urlholder ] ) ) {
90
+		} elseif (is_numeric($_GET[$urlholder])) {
91 91
 			// Numeric Package = previously uploaded file, see above.
92
-			$this->id   = (int) $_GET[ $urlholder ];
93
-			$attachment = get_post( $this->id );
94
-			if ( empty( $attachment ) ) {
95
-				wp_die( __( 'Please select a file' ) );
92
+			$this->id   = (int) $_GET[$urlholder];
93
+			$attachment = get_post($this->id);
94
+			if (empty($attachment)) {
95
+				wp_die(__('Please select a file'));
96 96
 			}
97 97
 
98 98
 			$this->filename = $attachment->post_title;
99
-			$this->package  = get_attached_file( $attachment->ID );
99
+			$this->package  = get_attached_file($attachment->ID);
100 100
 		} else {
101 101
 			// Else, It's set to something, Back compat for plugins using the old (pre-3.3) File_Uploader handler.
102 102
 			$uploads = wp_upload_dir();
103
-			if ( ! ( $uploads && false === $uploads['error'] ) ) {
104
-				wp_die( $uploads['error'] );
103
+			if (!($uploads && false === $uploads['error'])) {
104
+				wp_die($uploads['error']);
105 105
 			}
106 106
 
107
-			$this->filename = sanitize_file_name( $_GET[ $urlholder ] );
107
+			$this->filename = sanitize_file_name($_GET[$urlholder]);
108 108
 			$this->package  = $uploads['basedir'] . '/' . $this->filename;
109 109
 
110
-			if ( 0 !== strpos( realpath( $this->package ), realpath( $uploads['basedir'] ) ) ) {
111
-				wp_die( __( 'Please select a file' ) );
110
+			if (0 !== strpos(realpath($this->package), realpath($uploads['basedir']))) {
111
+				wp_die(__('Please select a file'));
112 112
 			}
113 113
 		}
114 114
 	}
@@ -121,11 +121,11 @@  discard block
 block discarded – undo
121 121
 	 * @return bool Whether the cleanup was successful.
122 122
 	 */
123 123
 	public function cleanup() {
124
-		if ( $this->id ) {
125
-			wp_delete_attachment( $this->id );
124
+		if ($this->id) {
125
+			wp_delete_attachment($this->id);
126 126
 
127
-		} elseif ( file_exists( $this->package ) ) {
128
-			return @unlink( $this->package );
127
+		} elseif (file_exists($this->package)) {
128
+			return @unlink($this->package);
129 129
 		}
130 130
 
131 131
 		return true;
Please login to merge, or discard this patch.
brighty/wp-admin/includes/privacy-tools.php 2 patches
Indentation   +775 added lines, -775 removed lines patch added patch discarded remove patch
@@ -16,22 +16,22 @@  discard block
 block discarded – undo
16 16
  * @return true|WP_Error Returns true if sending the email was successful, or a WP_Error object.
17 17
  */
18 18
 function _wp_privacy_resend_request( $request_id ) {
19
-	$request_id = absint( $request_id );
20
-	$request    = get_post( $request_id );
19
+    $request_id = absint( $request_id );
20
+    $request    = get_post( $request_id );
21 21
 
22
-	if ( ! $request || 'user_request' !== $request->post_type ) {
23
-		return new WP_Error( 'privacy_request_error', __( 'Invalid personal data request.' ) );
24
-	}
22
+    if ( ! $request || 'user_request' !== $request->post_type ) {
23
+        return new WP_Error( 'privacy_request_error', __( 'Invalid personal data request.' ) );
24
+    }
25 25
 
26
-	$result = wp_send_user_request( $request_id );
26
+    $result = wp_send_user_request( $request_id );
27 27
 
28
-	if ( is_wp_error( $result ) ) {
29
-		return $result;
30
-	} elseif ( ! $result ) {
31
-		return new WP_Error( 'privacy_request_error', __( 'Unable to initiate confirmation for personal data request.' ) );
32
-	}
28
+    if ( is_wp_error( $result ) ) {
29
+        return $result;
30
+    } elseif ( ! $result ) {
31
+        return new WP_Error( 'privacy_request_error', __( 'Unable to initiate confirmation for personal data request.' ) );
32
+    }
33 33
 
34
-	return true;
34
+    return true;
35 35
 }
36 36
 
37 37
 /**
@@ -44,24 +44,24 @@  discard block
 block discarded – undo
44 44
  * @return int|WP_Error Request ID on success, or a WP_Error on failure.
45 45
  */
46 46
 function _wp_privacy_completed_request( $request_id ) {
47
-	// Get the request.
48
-	$request_id = absint( $request_id );
49
-	$request    = wp_get_user_request( $request_id );
47
+    // Get the request.
48
+    $request_id = absint( $request_id );
49
+    $request    = wp_get_user_request( $request_id );
50 50
 
51
-	if ( ! $request ) {
52
-		return new WP_Error( 'privacy_request_error', __( 'Invalid personal data request.' ) );
53
-	}
51
+    if ( ! $request ) {
52
+        return new WP_Error( 'privacy_request_error', __( 'Invalid personal data request.' ) );
53
+    }
54 54
 
55
-	update_post_meta( $request_id, '_wp_user_request_completed_timestamp', time() );
55
+    update_post_meta( $request_id, '_wp_user_request_completed_timestamp', time() );
56 56
 
57
-	$result = wp_update_post(
58
-		array(
59
-			'ID'          => $request_id,
60
-			'post_status' => 'request-completed',
61
-		)
62
-	);
57
+    $result = wp_update_post(
58
+        array(
59
+            'ID'          => $request_id,
60
+            'post_status' => 'request-completed',
61
+        )
62
+    );
63 63
 
64
-	return $result;
64
+    return $result;
65 65
 }
66 66
 
67 67
 /**
@@ -71,119 +71,119 @@  discard block
 block discarded – undo
71 71
  * @access private
72 72
  */
73 73
 function _wp_personal_data_handle_actions() {
74
-	if ( isset( $_POST['privacy_action_email_retry'] ) ) {
75
-		check_admin_referer( 'bulk-privacy_requests' );
76
-
77
-		$request_id = absint( current( array_keys( (array) wp_unslash( $_POST['privacy_action_email_retry'] ) ) ) );
78
-		$result     = _wp_privacy_resend_request( $request_id );
79
-
80
-		if ( is_wp_error( $result ) ) {
81
-			add_settings_error(
82
-				'privacy_action_email_retry',
83
-				'privacy_action_email_retry',
84
-				$result->get_error_message(),
85
-				'error'
86
-			);
87
-		} else {
88
-			add_settings_error(
89
-				'privacy_action_email_retry',
90
-				'privacy_action_email_retry',
91
-				__( 'Confirmation request sent again successfully.' ),
92
-				'success'
93
-			);
94
-		}
95
-	} elseif ( isset( $_POST['action'] ) ) {
96
-		$action = ! empty( $_POST['action'] ) ? sanitize_key( wp_unslash( $_POST['action'] ) ) : '';
97
-
98
-		switch ( $action ) {
99
-			case 'add_export_personal_data_request':
100
-			case 'add_remove_personal_data_request':
101
-				check_admin_referer( 'personal-data-request' );
102
-
103
-				if ( ! isset( $_POST['type_of_action'], $_POST['username_or_email_for_privacy_request'] ) ) {
104
-					add_settings_error(
105
-						'action_type',
106
-						'action_type',
107
-						__( 'Invalid personal data action.' ),
108
-						'error'
109
-					);
110
-				}
111
-				$action_type               = sanitize_text_field( wp_unslash( $_POST['type_of_action'] ) );
112
-				$username_or_email_address = sanitize_text_field( wp_unslash( $_POST['username_or_email_for_privacy_request'] ) );
113
-				$email_address             = '';
114
-				$status                    = 'pending';
115
-
116
-				if ( ! isset( $_POST['send_confirmation_email'] ) ) {
117
-					$status = 'confirmed';
118
-				}
119
-
120
-				if ( ! in_array( $action_type, _wp_privacy_action_request_types(), true ) ) {
121
-					add_settings_error(
122
-						'action_type',
123
-						'action_type',
124
-						__( 'Invalid personal data action.' ),
125
-						'error'
126
-					);
127
-				}
128
-
129
-				if ( ! is_email( $username_or_email_address ) ) {
130
-					$user = get_user_by( 'login', $username_or_email_address );
131
-					if ( ! $user instanceof WP_User ) {
132
-						add_settings_error(
133
-							'username_or_email_for_privacy_request',
134
-							'username_or_email_for_privacy_request',
135
-							__( 'Unable to add this request. A valid email address or username must be supplied.' ),
136
-							'error'
137
-						);
138
-					} else {
139
-						$email_address = $user->user_email;
140
-					}
141
-				} else {
142
-					$email_address = $username_or_email_address;
143
-				}
144
-
145
-				if ( empty( $email_address ) ) {
146
-					break;
147
-				}
148
-
149
-				$request_id = wp_create_user_request( $email_address, $action_type, array(), $status );
150
-				$message    = '';
151
-
152
-				if ( is_wp_error( $request_id ) ) {
153
-					$message = $request_id->get_error_message();
154
-				} elseif ( ! $request_id ) {
155
-					$message = __( 'Unable to initiate confirmation request.' );
156
-				}
157
-
158
-				if ( $message ) {
159
-					add_settings_error(
160
-						'username_or_email_for_privacy_request',
161
-						'username_or_email_for_privacy_request',
162
-						$message,
163
-						'error'
164
-					);
165
-					break;
166
-				}
167
-
168
-				if ( 'pending' === $status ) {
169
-					wp_send_user_request( $request_id );
170
-
171
-					$message = __( 'Confirmation request initiated successfully.' );
172
-				} elseif ( 'confirmed' === $status ) {
173
-					$message = __( 'Request added successfully.' );
174
-				}
175
-
176
-				if ( $message ) {
177
-					add_settings_error(
178
-						'username_or_email_for_privacy_request',
179
-						'username_or_email_for_privacy_request',
180
-						$message,
181
-						'success'
182
-					);
183
-					break;
184
-				}
185
-		}
186
-	}
74
+    if ( isset( $_POST['privacy_action_email_retry'] ) ) {
75
+        check_admin_referer( 'bulk-privacy_requests' );
76
+
77
+        $request_id = absint( current( array_keys( (array) wp_unslash( $_POST['privacy_action_email_retry'] ) ) ) );
78
+        $result     = _wp_privacy_resend_request( $request_id );
79
+
80
+        if ( is_wp_error( $result ) ) {
81
+            add_settings_error(
82
+                'privacy_action_email_retry',
83
+                'privacy_action_email_retry',
84
+                $result->get_error_message(),
85
+                'error'
86
+            );
87
+        } else {
88
+            add_settings_error(
89
+                'privacy_action_email_retry',
90
+                'privacy_action_email_retry',
91
+                __( 'Confirmation request sent again successfully.' ),
92
+                'success'
93
+            );
94
+        }
95
+    } elseif ( isset( $_POST['action'] ) ) {
96
+        $action = ! empty( $_POST['action'] ) ? sanitize_key( wp_unslash( $_POST['action'] ) ) : '';
97
+
98
+        switch ( $action ) {
99
+            case 'add_export_personal_data_request':
100
+            case 'add_remove_personal_data_request':
101
+                check_admin_referer( 'personal-data-request' );
102
+
103
+                if ( ! isset( $_POST['type_of_action'], $_POST['username_or_email_for_privacy_request'] ) ) {
104
+                    add_settings_error(
105
+                        'action_type',
106
+                        'action_type',
107
+                        __( 'Invalid personal data action.' ),
108
+                        'error'
109
+                    );
110
+                }
111
+                $action_type               = sanitize_text_field( wp_unslash( $_POST['type_of_action'] ) );
112
+                $username_or_email_address = sanitize_text_field( wp_unslash( $_POST['username_or_email_for_privacy_request'] ) );
113
+                $email_address             = '';
114
+                $status                    = 'pending';
115
+
116
+                if ( ! isset( $_POST['send_confirmation_email'] ) ) {
117
+                    $status = 'confirmed';
118
+                }
119
+
120
+                if ( ! in_array( $action_type, _wp_privacy_action_request_types(), true ) ) {
121
+                    add_settings_error(
122
+                        'action_type',
123
+                        'action_type',
124
+                        __( 'Invalid personal data action.' ),
125
+                        'error'
126
+                    );
127
+                }
128
+
129
+                if ( ! is_email( $username_or_email_address ) ) {
130
+                    $user = get_user_by( 'login', $username_or_email_address );
131
+                    if ( ! $user instanceof WP_User ) {
132
+                        add_settings_error(
133
+                            'username_or_email_for_privacy_request',
134
+                            'username_or_email_for_privacy_request',
135
+                            __( 'Unable to add this request. A valid email address or username must be supplied.' ),
136
+                            'error'
137
+                        );
138
+                    } else {
139
+                        $email_address = $user->user_email;
140
+                    }
141
+                } else {
142
+                    $email_address = $username_or_email_address;
143
+                }
144
+
145
+                if ( empty( $email_address ) ) {
146
+                    break;
147
+                }
148
+
149
+                $request_id = wp_create_user_request( $email_address, $action_type, array(), $status );
150
+                $message    = '';
151
+
152
+                if ( is_wp_error( $request_id ) ) {
153
+                    $message = $request_id->get_error_message();
154
+                } elseif ( ! $request_id ) {
155
+                    $message = __( 'Unable to initiate confirmation request.' );
156
+                }
157
+
158
+                if ( $message ) {
159
+                    add_settings_error(
160
+                        'username_or_email_for_privacy_request',
161
+                        'username_or_email_for_privacy_request',
162
+                        $message,
163
+                        'error'
164
+                    );
165
+                    break;
166
+                }
167
+
168
+                if ( 'pending' === $status ) {
169
+                    wp_send_user_request( $request_id );
170
+
171
+                    $message = __( 'Confirmation request initiated successfully.' );
172
+                } elseif ( 'confirmed' === $status ) {
173
+                    $message = __( 'Request added successfully.' );
174
+                }
175
+
176
+                if ( $message ) {
177
+                    add_settings_error(
178
+                        'username_or_email_for_privacy_request',
179
+                        'username_or_email_for_privacy_request',
180
+                        $message,
181
+                        'success'
182
+                    );
183
+                    break;
184
+                }
185
+        }
186
+    }
187 187
 }
188 188
 
189 189
 /**
@@ -193,35 +193,35 @@  discard block
 block discarded – undo
193 193
  * @access private
194 194
  */
195 195
 function _wp_personal_data_cleanup_requests() {
196
-	/** This filter is documented in wp-includes/user.php */
197
-	$expires = (int) apply_filters( 'user_request_key_expiration', DAY_IN_SECONDS );
198
-
199
-	$requests_query = new WP_Query(
200
-		array(
201
-			'post_type'      => 'user_request',
202
-			'posts_per_page' => -1,
203
-			'post_status'    => 'request-pending',
204
-			'fields'         => 'ids',
205
-			'date_query'     => array(
206
-				array(
207
-					'column' => 'post_modified_gmt',
208
-					'before' => $expires . ' seconds ago',
209
-				),
210
-			),
211
-		)
212
-	);
213
-
214
-	$request_ids = $requests_query->posts;
215
-
216
-	foreach ( $request_ids as $request_id ) {
217
-		wp_update_post(
218
-			array(
219
-				'ID'            => $request_id,
220
-				'post_status'   => 'request-failed',
221
-				'post_password' => '',
222
-			)
223
-		);
224
-	}
196
+    /** This filter is documented in wp-includes/user.php */
197
+    $expires = (int) apply_filters( 'user_request_key_expiration', DAY_IN_SECONDS );
198
+
199
+    $requests_query = new WP_Query(
200
+        array(
201
+            'post_type'      => 'user_request',
202
+            'posts_per_page' => -1,
203
+            'post_status'    => 'request-pending',
204
+            'fields'         => 'ids',
205
+            'date_query'     => array(
206
+                array(
207
+                    'column' => 'post_modified_gmt',
208
+                    'before' => $expires . ' seconds ago',
209
+                ),
210
+            ),
211
+        )
212
+    );
213
+
214
+    $request_ids = $requests_query->posts;
215
+
216
+    foreach ( $request_ids as $request_id ) {
217
+        wp_update_post(
218
+            array(
219
+                'ID'            => $request_id,
220
+                'post_status'   => 'request-failed',
221
+                'post_password' => '',
222
+            )
223
+        );
224
+    }
225 225
 }
226 226
 
227 227
 /**
@@ -250,54 +250,54 @@  discard block
 block discarded – undo
250 250
  * @return string The HTML for this group and its items.
251 251
  */
252 252
 function wp_privacy_generate_personal_data_export_group_html( $group_data, $group_id = '', $groups_count = 1 ) {
253
-	$group_id_attr = sanitize_title_with_dashes( $group_data['group_label'] . '-' . $group_id );
253
+    $group_id_attr = sanitize_title_with_dashes( $group_data['group_label'] . '-' . $group_id );
254 254
 
255
-	$group_html  = '<h2 id="' . esc_attr( $group_id_attr ) . '">';
256
-	$group_html .= esc_html( $group_data['group_label'] );
255
+    $group_html  = '<h2 id="' . esc_attr( $group_id_attr ) . '">';
256
+    $group_html .= esc_html( $group_data['group_label'] );
257 257
 
258
-	$items_count = count( (array) $group_data['items'] );
259
-	if ( $items_count > 1 ) {
260
-		$group_html .= sprintf( ' <span class="count">(%d)</span>', $items_count );
261
-	}
258
+    $items_count = count( (array) $group_data['items'] );
259
+    if ( $items_count > 1 ) {
260
+        $group_html .= sprintf( ' <span class="count">(%d)</span>', $items_count );
261
+    }
262 262
 
263
-	$group_html .= '</h2>';
263
+    $group_html .= '</h2>';
264 264
 
265
-	if ( ! empty( $group_data['group_description'] ) ) {
266
-		$group_html .= '<p>' . esc_html( $group_data['group_description'] ) . '</p>';
267
-	}
265
+    if ( ! empty( $group_data['group_description'] ) ) {
266
+        $group_html .= '<p>' . esc_html( $group_data['group_description'] ) . '</p>';
267
+    }
268 268
 
269
-	$group_html .= '<div>';
269
+    $group_html .= '<div>';
270 270
 
271
-	foreach ( (array) $group_data['items'] as $group_item_id => $group_item_data ) {
272
-		$group_html .= '<table>';
273
-		$group_html .= '<tbody>';
271
+    foreach ( (array) $group_data['items'] as $group_item_id => $group_item_data ) {
272
+        $group_html .= '<table>';
273
+        $group_html .= '<tbody>';
274 274
 
275
-		foreach ( (array) $group_item_data as $group_item_datum ) {
276
-			$value = $group_item_datum['value'];
277
-			// If it looks like a link, make it a link.
278
-			if ( false === strpos( $value, ' ' ) && ( 0 === strpos( $value, 'http://' ) || 0 === strpos( $value, 'https://' ) ) ) {
279
-				$value = '<a href="' . esc_url( $value ) . '">' . esc_html( $value ) . '</a>';
280
-			}
275
+        foreach ( (array) $group_item_data as $group_item_datum ) {
276
+            $value = $group_item_datum['value'];
277
+            // If it looks like a link, make it a link.
278
+            if ( false === strpos( $value, ' ' ) && ( 0 === strpos( $value, 'http://' ) || 0 === strpos( $value, 'https://' ) ) ) {
279
+                $value = '<a href="' . esc_url( $value ) . '">' . esc_html( $value ) . '</a>';
280
+            }
281 281
 
282
-			$group_html .= '<tr>';
283
-			$group_html .= '<th>' . esc_html( $group_item_datum['name'] ) . '</th>';
284
-			$group_html .= '<td>' . wp_kses( $value, 'personal_data_export' ) . '</td>';
285
-			$group_html .= '</tr>';
286
-		}
282
+            $group_html .= '<tr>';
283
+            $group_html .= '<th>' . esc_html( $group_item_datum['name'] ) . '</th>';
284
+            $group_html .= '<td>' . wp_kses( $value, 'personal_data_export' ) . '</td>';
285
+            $group_html .= '</tr>';
286
+        }
287 287
 
288
-		$group_html .= '</tbody>';
289
-		$group_html .= '</table>';
290
-	}
288
+        $group_html .= '</tbody>';
289
+        $group_html .= '</table>';
290
+    }
291 291
 
292
-	if ( $groups_count > 1 ) {
293
-		$group_html .= '<div class="return-to-top">';
294
-		$group_html .= '<a href="#top"><span aria-hidden="true">&uarr; </span> ' . esc_html__( 'Go to top' ) . '</a>';
295
-		$group_html .= '</div>';
296
-	}
292
+    if ( $groups_count > 1 ) {
293
+        $group_html .= '<div class="return-to-top">';
294
+        $group_html .= '<a href="#top"><span aria-hidden="true">&uarr; </span> ' . esc_html__( 'Go to top' ) . '</a>';
295
+        $group_html .= '</div>';
296
+    }
297 297
 
298
-	$group_html .= '</div>';
298
+    $group_html .= '</div>';
299 299
 
300
-	return $group_html;
300
+    return $group_html;
301 301
 }
302 302
 
303 303
 /**
@@ -308,273 +308,273 @@  discard block
 block discarded – undo
308 308
  * @param int $request_id The export request ID.
309 309
  */
310 310
 function wp_privacy_generate_personal_data_export_file( $request_id ) {
311
-	if ( ! class_exists( 'ZipArchive' ) ) {
312
-		wp_send_json_error( __( 'Unable to generate personal data export file. ZipArchive not available.' ) );
313
-	}
314
-
315
-	// Get the request.
316
-	$request = wp_get_user_request( $request_id );
317
-
318
-	if ( ! $request || 'export_personal_data' !== $request->action_name ) {
319
-		wp_send_json_error( __( 'Invalid request ID when generating personal data export file.' ) );
320
-	}
321
-
322
-	$email_address = $request->email;
323
-
324
-	if ( ! is_email( $email_address ) ) {
325
-		wp_send_json_error( __( 'Invalid email address when generating personal data export file.' ) );
326
-	}
327
-
328
-	// Create the exports folder if needed.
329
-	$exports_dir = wp_privacy_exports_dir();
330
-	$exports_url = wp_privacy_exports_url();
331
-
332
-	if ( ! wp_mkdir_p( $exports_dir ) ) {
333
-		wp_send_json_error( __( 'Unable to create personal data export folder.' ) );
334
-	}
335
-
336
-	// Protect export folder from browsing.
337
-	$index_pathname = $exports_dir . 'index.php';
338
-	if ( ! file_exists( $index_pathname ) ) {
339
-		$file = fopen( $index_pathname, 'w' );
340
-		if ( false === $file ) {
341
-			wp_send_json_error( __( 'Unable to protect personal data export folder from browsing.' ) );
342
-		}
343
-		fwrite( $file, "<?php\n// Silence is golden.\n" );
344
-		fclose( $file );
345
-	}
346
-
347
-	$obscura              = wp_generate_password( 32, false, false );
348
-	$file_basename        = 'wp-personal-data-file-' . $obscura;
349
-	$html_report_filename = wp_unique_filename( $exports_dir, $file_basename . '.html' );
350
-	$html_report_pathname = wp_normalize_path( $exports_dir . $html_report_filename );
351
-	$json_report_filename = $file_basename . '.json';
352
-	$json_report_pathname = wp_normalize_path( $exports_dir . $json_report_filename );
353
-
354
-	/*
311
+    if ( ! class_exists( 'ZipArchive' ) ) {
312
+        wp_send_json_error( __( 'Unable to generate personal data export file. ZipArchive not available.' ) );
313
+    }
314
+
315
+    // Get the request.
316
+    $request = wp_get_user_request( $request_id );
317
+
318
+    if ( ! $request || 'export_personal_data' !== $request->action_name ) {
319
+        wp_send_json_error( __( 'Invalid request ID when generating personal data export file.' ) );
320
+    }
321
+
322
+    $email_address = $request->email;
323
+
324
+    if ( ! is_email( $email_address ) ) {
325
+        wp_send_json_error( __( 'Invalid email address when generating personal data export file.' ) );
326
+    }
327
+
328
+    // Create the exports folder if needed.
329
+    $exports_dir = wp_privacy_exports_dir();
330
+    $exports_url = wp_privacy_exports_url();
331
+
332
+    if ( ! wp_mkdir_p( $exports_dir ) ) {
333
+        wp_send_json_error( __( 'Unable to create personal data export folder.' ) );
334
+    }
335
+
336
+    // Protect export folder from browsing.
337
+    $index_pathname = $exports_dir . 'index.php';
338
+    if ( ! file_exists( $index_pathname ) ) {
339
+        $file = fopen( $index_pathname, 'w' );
340
+        if ( false === $file ) {
341
+            wp_send_json_error( __( 'Unable to protect personal data export folder from browsing.' ) );
342
+        }
343
+        fwrite( $file, "<?php\n// Silence is golden.\n" );
344
+        fclose( $file );
345
+    }
346
+
347
+    $obscura              = wp_generate_password( 32, false, false );
348
+    $file_basename        = 'wp-personal-data-file-' . $obscura;
349
+    $html_report_filename = wp_unique_filename( $exports_dir, $file_basename . '.html' );
350
+    $html_report_pathname = wp_normalize_path( $exports_dir . $html_report_filename );
351
+    $json_report_filename = $file_basename . '.json';
352
+    $json_report_pathname = wp_normalize_path( $exports_dir . $json_report_filename );
353
+
354
+    /*
355 355
 	 * Gather general data needed.
356 356
 	 */
357 357
 
358
-	// Title.
359
-	$title = sprintf(
360
-		/* translators: %s: User's email address. */
361
-		__( 'Personal Data Export for %s' ),
362
-		$email_address
363
-	);
364
-
365
-	// First, build an "About" group on the fly for this report.
366
-	$about_group = array(
367
-		/* translators: Header for the About section in a personal data export. */
368
-		'group_label'       => _x( 'About', 'personal data group label' ),
369
-		/* translators: Description for the About section in a personal data export. */
370
-		'group_description' => _x( 'Overview of export report.', 'personal data group description' ),
371
-		'items'             => array(
372
-			'about-1' => array(
373
-				array(
374
-					'name'  => _x( 'Report generated for', 'email address' ),
375
-					'value' => $email_address,
376
-				),
377
-				array(
378
-					'name'  => _x( 'For site', 'website name' ),
379
-					'value' => get_bloginfo( 'name' ),
380
-				),
381
-				array(
382
-					'name'  => _x( 'At URL', 'website URL' ),
383
-					'value' => get_bloginfo( 'url' ),
384
-				),
385
-				array(
386
-					'name'  => _x( 'On', 'date/time' ),
387
-					'value' => current_time( 'mysql' ),
388
-				),
389
-			),
390
-		),
391
-	);
392
-
393
-	// And now, all the Groups.
394
-	$groups = get_post_meta( $request_id, '_export_data_grouped', true );
395
-	if ( is_array( $groups ) ) {
396
-		// Merge in the special "About" group.
397
-		$groups       = array_merge( array( 'about' => $about_group ), $groups );
398
-		$groups_count = count( $groups );
399
-	} else {
400
-		if ( false !== $groups ) {
401
-			_doing_it_wrong(
402
-				__FUNCTION__,
403
-				/* translators: %s: Post meta key. */
404
-				sprintf( __( 'The %s post meta must be an array.' ), '<code>_export_data_grouped</code>' ),
405
-				'5.8.0'
406
-			);
407
-		}
408
-
409
-		$groups       = null;
410
-		$groups_count = 0;
411
-	}
412
-
413
-	// Convert the groups to JSON format.
414
-	$groups_json = wp_json_encode( $groups );
415
-
416
-	if ( false === $groups_json ) {
417
-		$error_message = sprintf(
418
-			/* translators: %s: Error message. */
419
-			__( 'Unable to encode the personal data for export. Error: %s' ),
420
-			json_last_error_msg()
421
-		);
422
-
423
-		wp_send_json_error( $error_message );
424
-	}
425
-
426
-	/*
358
+    // Title.
359
+    $title = sprintf(
360
+        /* translators: %s: User's email address. */
361
+        __( 'Personal Data Export for %s' ),
362
+        $email_address
363
+    );
364
+
365
+    // First, build an "About" group on the fly for this report.
366
+    $about_group = array(
367
+        /* translators: Header for the About section in a personal data export. */
368
+        'group_label'       => _x( 'About', 'personal data group label' ),
369
+        /* translators: Description for the About section in a personal data export. */
370
+        'group_description' => _x( 'Overview of export report.', 'personal data group description' ),
371
+        'items'             => array(
372
+            'about-1' => array(
373
+                array(
374
+                    'name'  => _x( 'Report generated for', 'email address' ),
375
+                    'value' => $email_address,
376
+                ),
377
+                array(
378
+                    'name'  => _x( 'For site', 'website name' ),
379
+                    'value' => get_bloginfo( 'name' ),
380
+                ),
381
+                array(
382
+                    'name'  => _x( 'At URL', 'website URL' ),
383
+                    'value' => get_bloginfo( 'url' ),
384
+                ),
385
+                array(
386
+                    'name'  => _x( 'On', 'date/time' ),
387
+                    'value' => current_time( 'mysql' ),
388
+                ),
389
+            ),
390
+        ),
391
+    );
392
+
393
+    // And now, all the Groups.
394
+    $groups = get_post_meta( $request_id, '_export_data_grouped', true );
395
+    if ( is_array( $groups ) ) {
396
+        // Merge in the special "About" group.
397
+        $groups       = array_merge( array( 'about' => $about_group ), $groups );
398
+        $groups_count = count( $groups );
399
+    } else {
400
+        if ( false !== $groups ) {
401
+            _doing_it_wrong(
402
+                __FUNCTION__,
403
+                /* translators: %s: Post meta key. */
404
+                sprintf( __( 'The %s post meta must be an array.' ), '<code>_export_data_grouped</code>' ),
405
+                '5.8.0'
406
+            );
407
+        }
408
+
409
+        $groups       = null;
410
+        $groups_count = 0;
411
+    }
412
+
413
+    // Convert the groups to JSON format.
414
+    $groups_json = wp_json_encode( $groups );
415
+
416
+    if ( false === $groups_json ) {
417
+        $error_message = sprintf(
418
+            /* translators: %s: Error message. */
419
+            __( 'Unable to encode the personal data for export. Error: %s' ),
420
+            json_last_error_msg()
421
+        );
422
+
423
+        wp_send_json_error( $error_message );
424
+    }
425
+
426
+    /*
427 427
 	 * Handle the JSON export.
428 428
 	 */
429
-	$file = fopen( $json_report_pathname, 'w' );
429
+    $file = fopen( $json_report_pathname, 'w' );
430 430
 
431
-	if ( false === $file ) {
432
-		wp_send_json_error( __( 'Unable to open personal data export file (JSON report) for writing.' ) );
433
-	}
431
+    if ( false === $file ) {
432
+        wp_send_json_error( __( 'Unable to open personal data export file (JSON report) for writing.' ) );
433
+    }
434 434
 
435
-	fwrite( $file, '{' );
436
-	fwrite( $file, '"' . $title . '":' );
437
-	fwrite( $file, $groups_json );
438
-	fwrite( $file, '}' );
439
-	fclose( $file );
435
+    fwrite( $file, '{' );
436
+    fwrite( $file, '"' . $title . '":' );
437
+    fwrite( $file, $groups_json );
438
+    fwrite( $file, '}' );
439
+    fclose( $file );
440 440
 
441
-	/*
441
+    /*
442 442
 	 * Handle the HTML export.
443 443
 	 */
444
-	$file = fopen( $html_report_pathname, 'w' );
445
-
446
-	if ( false === $file ) {
447
-		wp_send_json_error( __( 'Unable to open personal data export (HTML report) for writing.' ) );
448
-	}
449
-
450
-	fwrite( $file, "<!DOCTYPE html>\n" );
451
-	fwrite( $file, "<html>\n" );
452
-	fwrite( $file, "<head>\n" );
453
-	fwrite( $file, "<meta http-equiv='Content-Type' content='text/html; charset=UTF-8' />\n" );
454
-	fwrite( $file, "<style type='text/css'>" );
455
-	fwrite( $file, 'body { color: black; font-family: Arial, sans-serif; font-size: 11pt; margin: 15px auto; width: 860px; }' );
456
-	fwrite( $file, 'table { background: #f0f0f0; border: 1px solid #ddd; margin-bottom: 20px; width: 100%; }' );
457
-	fwrite( $file, 'th { padding: 5px; text-align: left; width: 20%; }' );
458
-	fwrite( $file, 'td { padding: 5px; }' );
459
-	fwrite( $file, 'tr:nth-child(odd) { background-color: #fafafa; }' );
460
-	fwrite( $file, '.return-to-top { text-align: right; }' );
461
-	fwrite( $file, '</style>' );
462
-	fwrite( $file, '<title>' );
463
-	fwrite( $file, esc_html( $title ) );
464
-	fwrite( $file, '</title>' );
465
-	fwrite( $file, "</head>\n" );
466
-	fwrite( $file, "<body>\n" );
467
-	fwrite( $file, '<h1 id="top">' . esc_html__( 'Personal Data Export' ) . '</h1>' );
468
-
469
-	// Create TOC.
470
-	if ( $groups_count > 1 ) {
471
-		fwrite( $file, '<div id="table_of_contents">' );
472
-		fwrite( $file, '<h2>' . esc_html__( 'Table of Contents' ) . '</h2>' );
473
-		fwrite( $file, '<ul>' );
474
-		foreach ( (array) $groups as $group_id => $group_data ) {
475
-			$group_label       = esc_html( $group_data['group_label'] );
476
-			$group_id_attr     = sanitize_title_with_dashes( $group_data['group_label'] . '-' . $group_id );
477
-			$group_items_count = count( (array) $group_data['items'] );
478
-			if ( $group_items_count > 1 ) {
479
-				$group_label .= sprintf( ' <span class="count">(%d)</span>', $group_items_count );
480
-			}
481
-			fwrite( $file, '<li>' );
482
-			fwrite( $file, '<a href="#' . esc_attr( $group_id_attr ) . '">' . $group_label . '</a>' );
483
-			fwrite( $file, '</li>' );
484
-		}
485
-		fwrite( $file, '</ul>' );
486
-		fwrite( $file, '</div>' );
487
-	}
488
-
489
-	// Now, iterate over every group in $groups and have the formatter render it in HTML.
490
-	foreach ( (array) $groups as $group_id => $group_data ) {
491
-		fwrite( $file, wp_privacy_generate_personal_data_export_group_html( $group_data, $group_id, $groups_count ) );
492
-	}
493
-
494
-	fwrite( $file, "</body>\n" );
495
-	fwrite( $file, "</html>\n" );
496
-	fclose( $file );
497
-
498
-	/*
444
+    $file = fopen( $html_report_pathname, 'w' );
445
+
446
+    if ( false === $file ) {
447
+        wp_send_json_error( __( 'Unable to open personal data export (HTML report) for writing.' ) );
448
+    }
449
+
450
+    fwrite( $file, "<!DOCTYPE html>\n" );
451
+    fwrite( $file, "<html>\n" );
452
+    fwrite( $file, "<head>\n" );
453
+    fwrite( $file, "<meta http-equiv='Content-Type' content='text/html; charset=UTF-8' />\n" );
454
+    fwrite( $file, "<style type='text/css'>" );
455
+    fwrite( $file, 'body { color: black; font-family: Arial, sans-serif; font-size: 11pt; margin: 15px auto; width: 860px; }' );
456
+    fwrite( $file, 'table { background: #f0f0f0; border: 1px solid #ddd; margin-bottom: 20px; width: 100%; }' );
457
+    fwrite( $file, 'th { padding: 5px; text-align: left; width: 20%; }' );
458
+    fwrite( $file, 'td { padding: 5px; }' );
459
+    fwrite( $file, 'tr:nth-child(odd) { background-color: #fafafa; }' );
460
+    fwrite( $file, '.return-to-top { text-align: right; }' );
461
+    fwrite( $file, '</style>' );
462
+    fwrite( $file, '<title>' );
463
+    fwrite( $file, esc_html( $title ) );
464
+    fwrite( $file, '</title>' );
465
+    fwrite( $file, "</head>\n" );
466
+    fwrite( $file, "<body>\n" );
467
+    fwrite( $file, '<h1 id="top">' . esc_html__( 'Personal Data Export' ) . '</h1>' );
468
+
469
+    // Create TOC.
470
+    if ( $groups_count > 1 ) {
471
+        fwrite( $file, '<div id="table_of_contents">' );
472
+        fwrite( $file, '<h2>' . esc_html__( 'Table of Contents' ) . '</h2>' );
473
+        fwrite( $file, '<ul>' );
474
+        foreach ( (array) $groups as $group_id => $group_data ) {
475
+            $group_label       = esc_html( $group_data['group_label'] );
476
+            $group_id_attr     = sanitize_title_with_dashes( $group_data['group_label'] . '-' . $group_id );
477
+            $group_items_count = count( (array) $group_data['items'] );
478
+            if ( $group_items_count > 1 ) {
479
+                $group_label .= sprintf( ' <span class="count">(%d)</span>', $group_items_count );
480
+            }
481
+            fwrite( $file, '<li>' );
482
+            fwrite( $file, '<a href="#' . esc_attr( $group_id_attr ) . '">' . $group_label . '</a>' );
483
+            fwrite( $file, '</li>' );
484
+        }
485
+        fwrite( $file, '</ul>' );
486
+        fwrite( $file, '</div>' );
487
+    }
488
+
489
+    // Now, iterate over every group in $groups and have the formatter render it in HTML.
490
+    foreach ( (array) $groups as $group_id => $group_data ) {
491
+        fwrite( $file, wp_privacy_generate_personal_data_export_group_html( $group_data, $group_id, $groups_count ) );
492
+    }
493
+
494
+    fwrite( $file, "</body>\n" );
495
+    fwrite( $file, "</html>\n" );
496
+    fclose( $file );
497
+
498
+    /*
499 499
 	 * Now, generate the ZIP.
500 500
 	 *
501 501
 	 * If an archive has already been generated, then remove it and reuse the filename,
502 502
 	 * to avoid breaking any URLs that may have been previously sent via email.
503 503
 	 */
504
-	$error = false;
505
-
506
-	// This meta value is used from version 5.5.
507
-	$archive_filename = get_post_meta( $request_id, '_export_file_name', true );
508
-
509
-	// This one stored an absolute path and is used for backward compatibility.
510
-	$archive_pathname = get_post_meta( $request_id, '_export_file_path', true );
511
-
512
-	// If a filename meta exists, use it.
513
-	if ( ! empty( $archive_filename ) ) {
514
-		$archive_pathname = $exports_dir . $archive_filename;
515
-	} elseif ( ! empty( $archive_pathname ) ) {
516
-		// If a full path meta exists, use it and create the new meta value.
517
-		$archive_filename = basename( $archive_pathname );
518
-
519
-		update_post_meta( $request_id, '_export_file_name', $archive_filename );
520
-
521
-		// Remove the back-compat meta values.
522
-		delete_post_meta( $request_id, '_export_file_url' );
523
-		delete_post_meta( $request_id, '_export_file_path' );
524
-	} else {
525
-		// If there's no filename or full path stored, create a new file.
526
-		$archive_filename = $file_basename . '.zip';
527
-		$archive_pathname = $exports_dir . $archive_filename;
528
-
529
-		update_post_meta( $request_id, '_export_file_name', $archive_filename );
530
-	}
531
-
532
-	$archive_url = $exports_url . $archive_filename;
533
-
534
-	if ( ! empty( $archive_pathname ) && file_exists( $archive_pathname ) ) {
535
-		wp_delete_file( $archive_pathname );
536
-	}
537
-
538
-	$zip = new ZipArchive;
539
-	if ( true === $zip->open( $archive_pathname, ZipArchive::CREATE ) ) {
540
-		if ( ! $zip->addFile( $json_report_pathname, 'export.json' ) ) {
541
-			$error = __( 'Unable to archive the personal data export file (JSON format).' );
542
-		}
543
-
544
-		if ( ! $zip->addFile( $html_report_pathname, 'index.html' ) ) {
545
-			$error = __( 'Unable to archive the personal data export file (HTML format).' );
546
-		}
547
-
548
-		$zip->close();
549
-
550
-		if ( ! $error ) {
551
-			/**
552
-			 * Fires right after all personal data has been written to the export file.
553
-			 *
554
-			 * @since 4.9.6
555
-			 * @since 5.4.0 Added the `$json_report_pathname` parameter.
556
-			 *
557
-			 * @param string $archive_pathname     The full path to the export file on the filesystem.
558
-			 * @param string $archive_url          The URL of the archive file.
559
-			 * @param string $html_report_pathname The full path to the HTML personal data report on the filesystem.
560
-			 * @param int    $request_id           The export request ID.
561
-			 * @param string $json_report_pathname The full path to the JSON personal data report on the filesystem.
562
-			 */
563
-			do_action( 'wp_privacy_personal_data_export_file_created', $archive_pathname, $archive_url, $html_report_pathname, $request_id, $json_report_pathname );
564
-		}
565
-	} else {
566
-		$error = __( 'Unable to open personal data export file (archive) for writing.' );
567
-	}
568
-
569
-	// Remove the JSON file.
570
-	unlink( $json_report_pathname );
571
-
572
-	// Remove the HTML file.
573
-	unlink( $html_report_pathname );
574
-
575
-	if ( $error ) {
576
-		wp_send_json_error( $error );
577
-	}
504
+    $error = false;
505
+
506
+    // This meta value is used from version 5.5.
507
+    $archive_filename = get_post_meta( $request_id, '_export_file_name', true );
508
+
509
+    // This one stored an absolute path and is used for backward compatibility.
510
+    $archive_pathname = get_post_meta( $request_id, '_export_file_path', true );
511
+
512
+    // If a filename meta exists, use it.
513
+    if ( ! empty( $archive_filename ) ) {
514
+        $archive_pathname = $exports_dir . $archive_filename;
515
+    } elseif ( ! empty( $archive_pathname ) ) {
516
+        // If a full path meta exists, use it and create the new meta value.
517
+        $archive_filename = basename( $archive_pathname );
518
+
519
+        update_post_meta( $request_id, '_export_file_name', $archive_filename );
520
+
521
+        // Remove the back-compat meta values.
522
+        delete_post_meta( $request_id, '_export_file_url' );
523
+        delete_post_meta( $request_id, '_export_file_path' );
524
+    } else {
525
+        // If there's no filename or full path stored, create a new file.
526
+        $archive_filename = $file_basename . '.zip';
527
+        $archive_pathname = $exports_dir . $archive_filename;
528
+
529
+        update_post_meta( $request_id, '_export_file_name', $archive_filename );
530
+    }
531
+
532
+    $archive_url = $exports_url . $archive_filename;
533
+
534
+    if ( ! empty( $archive_pathname ) && file_exists( $archive_pathname ) ) {
535
+        wp_delete_file( $archive_pathname );
536
+    }
537
+
538
+    $zip = new ZipArchive;
539
+    if ( true === $zip->open( $archive_pathname, ZipArchive::CREATE ) ) {
540
+        if ( ! $zip->addFile( $json_report_pathname, 'export.json' ) ) {
541
+            $error = __( 'Unable to archive the personal data export file (JSON format).' );
542
+        }
543
+
544
+        if ( ! $zip->addFile( $html_report_pathname, 'index.html' ) ) {
545
+            $error = __( 'Unable to archive the personal data export file (HTML format).' );
546
+        }
547
+
548
+        $zip->close();
549
+
550
+        if ( ! $error ) {
551
+            /**
552
+             * Fires right after all personal data has been written to the export file.
553
+             *
554
+             * @since 4.9.6
555
+             * @since 5.4.0 Added the `$json_report_pathname` parameter.
556
+             *
557
+             * @param string $archive_pathname     The full path to the export file on the filesystem.
558
+             * @param string $archive_url          The URL of the archive file.
559
+             * @param string $html_report_pathname The full path to the HTML personal data report on the filesystem.
560
+             * @param int    $request_id           The export request ID.
561
+             * @param string $json_report_pathname The full path to the JSON personal data report on the filesystem.
562
+             */
563
+            do_action( 'wp_privacy_personal_data_export_file_created', $archive_pathname, $archive_url, $html_report_pathname, $request_id, $json_report_pathname );
564
+        }
565
+    } else {
566
+        $error = __( 'Unable to open personal data export file (archive) for writing.' );
567
+    }
568
+
569
+    // Remove the JSON file.
570
+    unlink( $json_report_pathname );
571
+
572
+    // Remove the HTML file.
573
+    unlink( $html_report_pathname );
574
+
575
+    if ( $error ) {
576
+        wp_send_json_error( $error );
577
+    }
578 578
 }
579 579
 
580 580
 /**
@@ -586,83 +586,83 @@  discard block
 block discarded – undo
586 586
  * @return true|WP_Error True on success or `WP_Error` on failure.
587 587
  */
588 588
 function wp_privacy_send_personal_data_export_email( $request_id ) {
589
-	// Get the request.
590
-	$request = wp_get_user_request( $request_id );
591
-
592
-	if ( ! $request || 'export_personal_data' !== $request->action_name ) {
593
-		return new WP_Error( 'invalid_request', __( 'Invalid request ID when sending personal data export email.' ) );
594
-	}
595
-
596
-	// Localize message content for user; fallback to site default for visitors.
597
-	if ( ! empty( $request->user_id ) ) {
598
-		$locale = get_user_locale( $request->user_id );
599
-	} else {
600
-		$locale = get_locale();
601
-	}
602
-
603
-	$switched_locale = switch_to_locale( $locale );
604
-
605
-	/** This filter is documented in wp-includes/functions.php */
606
-	$expiration      = apply_filters( 'wp_privacy_export_expiration', 3 * DAY_IN_SECONDS );
607
-	$expiration_date = date_i18n( get_option( 'date_format' ), time() + $expiration );
608
-
609
-	$exports_url      = wp_privacy_exports_url();
610
-	$export_file_name = get_post_meta( $request_id, '_export_file_name', true );
611
-	$export_file_url  = $exports_url . $export_file_name;
612
-
613
-	$site_name = wp_specialchars_decode( get_option( 'blogname' ), ENT_QUOTES );
614
-	$site_url  = home_url();
615
-
616
-	/**
617
-	 * Filters the recipient of the personal data export email notification.
618
-	 * Should be used with great caution to avoid sending the data export link to wrong emails.
619
-	 *
620
-	 * @since 5.3.0
621
-	 *
622
-	 * @param string          $request_email The email address of the notification recipient.
623
-	 * @param WP_User_Request $request       The request that is initiating the notification.
624
-	 */
625
-	$request_email = apply_filters( 'wp_privacy_personal_data_email_to', $request->email, $request );
626
-
627
-	$email_data = array(
628
-		'request'           => $request,
629
-		'expiration'        => $expiration,
630
-		'expiration_date'   => $expiration_date,
631
-		'message_recipient' => $request_email,
632
-		'export_file_url'   => $export_file_url,
633
-		'sitename'          => $site_name,
634
-		'siteurl'           => $site_url,
635
-	);
636
-
637
-	/* translators: Personal data export notification email subject. %s: Site title. */
638
-	$subject = sprintf( __( '[%s] Personal Data Export' ), $site_name );
639
-
640
-	/**
641
-	 * Filters the subject of the email sent when an export request is completed.
642
-	 *
643
-	 * @since 5.3.0
644
-	 *
645
-	 * @param string $subject    The email subject.
646
-	 * @param string $sitename   The name of the site.
647
-	 * @param array  $email_data {
648
-	 *     Data relating to the account action email.
649
-	 *
650
-	 *     @type WP_User_Request $request           User request object.
651
-	 *     @type int             $expiration        The time in seconds until the export file expires.
652
-	 *     @type string          $expiration_date   The localized date and time when the export file expires.
653
-	 *     @type string          $message_recipient The address that the email will be sent to. Defaults
654
-	 *                                              to the value of `$request->email`, but can be changed
655
-	 *                                              by the `wp_privacy_personal_data_email_to` filter.
656
-	 *     @type string          $export_file_url   The export file URL.
657
-	 *     @type string          $sitename          The site name sending the mail.
658
-	 *     @type string          $siteurl           The site URL sending the mail.
659
-	 * }
660
-	 */
661
-	$subject = apply_filters( 'wp_privacy_personal_data_email_subject', $subject, $site_name, $email_data );
662
-
663
-	/* translators: Do not translate EXPIRATION, LINK, SITENAME, SITEURL: those are placeholders. */
664
-	$email_text = __(
665
-		'Howdy,
589
+    // Get the request.
590
+    $request = wp_get_user_request( $request_id );
591
+
592
+    if ( ! $request || 'export_personal_data' !== $request->action_name ) {
593
+        return new WP_Error( 'invalid_request', __( 'Invalid request ID when sending personal data export email.' ) );
594
+    }
595
+
596
+    // Localize message content for user; fallback to site default for visitors.
597
+    if ( ! empty( $request->user_id ) ) {
598
+        $locale = get_user_locale( $request->user_id );
599
+    } else {
600
+        $locale = get_locale();
601
+    }
602
+
603
+    $switched_locale = switch_to_locale( $locale );
604
+
605
+    /** This filter is documented in wp-includes/functions.php */
606
+    $expiration      = apply_filters( 'wp_privacy_export_expiration', 3 * DAY_IN_SECONDS );
607
+    $expiration_date = date_i18n( get_option( 'date_format' ), time() + $expiration );
608
+
609
+    $exports_url      = wp_privacy_exports_url();
610
+    $export_file_name = get_post_meta( $request_id, '_export_file_name', true );
611
+    $export_file_url  = $exports_url . $export_file_name;
612
+
613
+    $site_name = wp_specialchars_decode( get_option( 'blogname' ), ENT_QUOTES );
614
+    $site_url  = home_url();
615
+
616
+    /**
617
+     * Filters the recipient of the personal data export email notification.
618
+     * Should be used with great caution to avoid sending the data export link to wrong emails.
619
+     *
620
+     * @since 5.3.0
621
+     *
622
+     * @param string          $request_email The email address of the notification recipient.
623
+     * @param WP_User_Request $request       The request that is initiating the notification.
624
+     */
625
+    $request_email = apply_filters( 'wp_privacy_personal_data_email_to', $request->email, $request );
626
+
627
+    $email_data = array(
628
+        'request'           => $request,
629
+        'expiration'        => $expiration,
630
+        'expiration_date'   => $expiration_date,
631
+        'message_recipient' => $request_email,
632
+        'export_file_url'   => $export_file_url,
633
+        'sitename'          => $site_name,
634
+        'siteurl'           => $site_url,
635
+    );
636
+
637
+    /* translators: Personal data export notification email subject. %s: Site title. */
638
+    $subject = sprintf( __( '[%s] Personal Data Export' ), $site_name );
639
+
640
+    /**
641
+     * Filters the subject of the email sent when an export request is completed.
642
+     *
643
+     * @since 5.3.0
644
+     *
645
+     * @param string $subject    The email subject.
646
+     * @param string $sitename   The name of the site.
647
+     * @param array  $email_data {
648
+     *     Data relating to the account action email.
649
+     *
650
+     *     @type WP_User_Request $request           User request object.
651
+     *     @type int             $expiration        The time in seconds until the export file expires.
652
+     *     @type string          $expiration_date   The localized date and time when the export file expires.
653
+     *     @type string          $message_recipient The address that the email will be sent to. Defaults
654
+     *                                              to the value of `$request->email`, but can be changed
655
+     *                                              by the `wp_privacy_personal_data_email_to` filter.
656
+     *     @type string          $export_file_url   The export file URL.
657
+     *     @type string          $sitename          The site name sending the mail.
658
+     *     @type string          $siteurl           The site URL sending the mail.
659
+     * }
660
+     */
661
+    $subject = apply_filters( 'wp_privacy_personal_data_email_subject', $subject, $site_name, $email_data );
662
+
663
+    /* translators: Do not translate EXPIRATION, LINK, SITENAME, SITEURL: those are placeholders. */
664
+    $email_text = __(
665
+        'Howdy,
666 666
 
667 667
 Your request for an export of personal data has been completed. You may
668 668
 download your personal data by clicking on the link below. For privacy
@@ -674,81 +674,81 @@  discard block
 block discarded – undo
674 674
 Regards,
675 675
 All at ###SITENAME###
676 676
 ###SITEURL###'
677
-	);
678
-
679
-	/**
680
-	 * Filters the text of the email sent with a personal data export file.
681
-	 *
682
-	 * The following strings have a special meaning and will get replaced dynamically:
683
-	 * ###EXPIRATION###         The date when the URL will be automatically deleted.
684
-	 * ###LINK###               URL of the personal data export file for the user.
685
-	 * ###SITENAME###           The name of the site.
686
-	 * ###SITEURL###            The URL to the site.
687
-	 *
688
-	 * @since 4.9.6
689
-	 * @since 5.3.0 Introduced the `$email_data` array.
690
-	 *
691
-	 * @param string $email_text Text in the email.
692
-	 * @param int    $request_id The request ID for this personal data export.
693
-	 * @param array  $email_data {
694
-	 *     Data relating to the account action email.
695
-	 *
696
-	 *     @type WP_User_Request $request           User request object.
697
-	 *     @type int             $expiration        The time in seconds until the export file expires.
698
-	 *     @type string          $expiration_date   The localized date and time when the export file expires.
699
-	 *     @type string          $message_recipient The address that the email will be sent to. Defaults
700
-	 *                                              to the value of `$request->email`, but can be changed
701
-	 *                                              by the `wp_privacy_personal_data_email_to` filter.
702
-	 *     @type string          $export_file_url   The export file URL.
703
-	 *     @type string          $sitename          The site name sending the mail.
704
-	 *     @type string          $siteurl           The site URL sending the mail.
705
-	 */
706
-	$content = apply_filters( 'wp_privacy_personal_data_email_content', $email_text, $request_id, $email_data );
707
-
708
-	$content = str_replace( '###EXPIRATION###', $expiration_date, $content );
709
-	$content = str_replace( '###LINK###', esc_url_raw( $export_file_url ), $content );
710
-	$content = str_replace( '###EMAIL###', $request_email, $content );
711
-	$content = str_replace( '###SITENAME###', $site_name, $content );
712
-	$content = str_replace( '###SITEURL###', esc_url_raw( $site_url ), $content );
713
-
714
-	$headers = '';
715
-
716
-	/**
717
-	 * Filters the headers of the email sent with a personal data export file.
718
-	 *
719
-	 * @since 5.4.0
720
-	 *
721
-	 * @param string|array $headers    The email headers.
722
-	 * @param string       $subject    The email subject.
723
-	 * @param string       $content    The email content.
724
-	 * @param int          $request_id The request ID.
725
-	 * @param array        $email_data {
726
-	 *     Data relating to the account action email.
727
-	 *
728
-	 *     @type WP_User_Request $request           User request object.
729
-	 *     @type int             $expiration        The time in seconds until the export file expires.
730
-	 *     @type string          $expiration_date   The localized date and time when the export file expires.
731
-	 *     @type string          $message_recipient The address that the email will be sent to. Defaults
732
-	 *                                              to the value of `$request->email`, but can be changed
733
-	 *                                              by the `wp_privacy_personal_data_email_to` filter.
734
-	 *     @type string          $export_file_url   The export file URL.
735
-	 *     @type string          $sitename          The site name sending the mail.
736
-	 *     @type string          $siteurl           The site URL sending the mail.
737
-	 * }
738
-	 */
739
-	$headers = apply_filters( 'wp_privacy_personal_data_email_headers', $headers, $subject, $content, $request_id, $email_data );
740
-
741
-	$mail_success = wp_mail( $request_email, $subject, $content, $headers );
742
-
743
-	if ( $switched_locale ) {
744
-		restore_previous_locale();
745
-	}
746
-
747
-	if ( ! $mail_success ) {
748
-		return new WP_Error( 'privacy_email_error', __( 'Unable to send personal data export email.' ) );
749
-	}
750
-
751
-	return true;
677
+    );
678
+
679
+    /**
680
+     * Filters the text of the email sent with a personal data export file.
681
+     *
682
+     * The following strings have a special meaning and will get replaced dynamically:
683
+     * ###EXPIRATION###         The date when the URL will be automatically deleted.
684
+     * ###LINK###               URL of the personal data export file for the user.
685
+     * ###SITENAME###           The name of the site.
686
+     * ###SITEURL###            The URL to the site.
687
+     *
688
+     * @since 4.9.6
689
+     * @since 5.3.0 Introduced the `$email_data` array.
690
+     *
691
+     * @param string $email_text Text in the email.
692
+     * @param int    $request_id The request ID for this personal data export.
693
+     * @param array  $email_data {
694
+     *     Data relating to the account action email.
695
+     *
696
+     *     @type WP_User_Request $request           User request object.
697
+     *     @type int             $expiration        The time in seconds until the export file expires.
698
+     *     @type string          $expiration_date   The localized date and time when the export file expires.
699
+     *     @type string          $message_recipient The address that the email will be sent to. Defaults
700
+     *                                              to the value of `$request->email`, but can be changed
701
+     *                                              by the `wp_privacy_personal_data_email_to` filter.
702
+     *     @type string          $export_file_url   The export file URL.
703
+     *     @type string          $sitename          The site name sending the mail.
704
+     *     @type string          $siteurl           The site URL sending the mail.
705
+     */
706
+    $content = apply_filters( 'wp_privacy_personal_data_email_content', $email_text, $request_id, $email_data );
707
+
708
+    $content = str_replace( '###EXPIRATION###', $expiration_date, $content );
709
+    $content = str_replace( '###LINK###', esc_url_raw( $export_file_url ), $content );
710
+    $content = str_replace( '###EMAIL###', $request_email, $content );
711
+    $content = str_replace( '###SITENAME###', $site_name, $content );
712
+    $content = str_replace( '###SITEURL###', esc_url_raw( $site_url ), $content );
713
+
714
+    $headers = '';
715
+
716
+    /**
717
+     * Filters the headers of the email sent with a personal data export file.
718
+     *
719
+     * @since 5.4.0
720
+     *
721
+     * @param string|array $headers    The email headers.
722
+     * @param string       $subject    The email subject.
723
+     * @param string       $content    The email content.
724
+     * @param int          $request_id The request ID.
725
+     * @param array        $email_data {
726
+     *     Data relating to the account action email.
727
+     *
728
+     *     @type WP_User_Request $request           User request object.
729
+     *     @type int             $expiration        The time in seconds until the export file expires.
730
+     *     @type string          $expiration_date   The localized date and time when the export file expires.
731
+     *     @type string          $message_recipient The address that the email will be sent to. Defaults
732
+     *                                              to the value of `$request->email`, but can be changed
733
+     *                                              by the `wp_privacy_personal_data_email_to` filter.
734
+     *     @type string          $export_file_url   The export file URL.
735
+     *     @type string          $sitename          The site name sending the mail.
736
+     *     @type string          $siteurl           The site URL sending the mail.
737
+     * }
738
+     */
739
+    $headers = apply_filters( 'wp_privacy_personal_data_email_headers', $headers, $subject, $content, $request_id, $email_data );
740
+
741
+    $mail_success = wp_mail( $request_email, $subject, $content, $headers );
742
+
743
+    if ( $switched_locale ) {
744
+        restore_previous_locale();
745
+    }
746
+
747
+    if ( ! $mail_success ) {
748
+        return new WP_Error( 'privacy_email_error', __( 'Unable to send personal data export email.' ) );
749
+    }
750
+
751
+    return true;
752 752
 }
753 753
 
754 754
 /**
@@ -768,127 +768,127 @@  discard block
 block discarded – undo
768 768
  * @return array The filtered response.
769 769
  */
770 770
 function wp_privacy_process_personal_data_export_page( $response, $exporter_index, $email_address, $page, $request_id, $send_as_email, $exporter_key ) {
771
-	/* Do some simple checks on the shape of the response from the exporter.
771
+    /* Do some simple checks on the shape of the response from the exporter.
772 772
 	 * If the exporter response is malformed, don't attempt to consume it - let it
773 773
 	 * pass through to generate a warning to the user by default Ajax processing.
774 774
 	 */
775
-	if ( ! is_array( $response ) ) {
776
-		return $response;
777
-	}
778
-
779
-	if ( ! array_key_exists( 'done', $response ) ) {
780
-		return $response;
781
-	}
782
-
783
-	if ( ! array_key_exists( 'data', $response ) ) {
784
-		return $response;
785
-	}
786
-
787
-	if ( ! is_array( $response['data'] ) ) {
788
-		return $response;
789
-	}
790
-
791
-	// Get the request.
792
-	$request = wp_get_user_request( $request_id );
793
-
794
-	if ( ! $request || 'export_personal_data' !== $request->action_name ) {
795
-		wp_send_json_error( __( 'Invalid request ID when merging personal data to export.' ) );
796
-	}
797
-
798
-	$export_data = array();
799
-
800
-	// First exporter, first page? Reset the report data accumulation array.
801
-	if ( 1 === $exporter_index && 1 === $page ) {
802
-		update_post_meta( $request_id, '_export_data_raw', $export_data );
803
-	} else {
804
-		$accumulated_data = get_post_meta( $request_id, '_export_data_raw', true );
805
-
806
-		if ( $accumulated_data ) {
807
-			$export_data = $accumulated_data;
808
-		}
809
-	}
810
-
811
-	// Now, merge the data from the exporter response into the data we have accumulated already.
812
-	$export_data = array_merge( $export_data, $response['data'] );
813
-	update_post_meta( $request_id, '_export_data_raw', $export_data );
814
-
815
-	// If we are not yet on the last page of the last exporter, return now.
816
-	/** This filter is documented in wp-admin/includes/ajax-actions.php */
817
-	$exporters        = apply_filters( 'wp_privacy_personal_data_exporters', array() );
818
-	$is_last_exporter = count( $exporters ) === $exporter_index;
819
-	$exporter_done    = $response['done'];
820
-	if ( ! $is_last_exporter || ! $exporter_done ) {
821
-		return $response;
822
-	}
823
-
824
-	// Last exporter, last page - let's prepare the export file.
825
-
826
-	// First we need to re-organize the raw data hierarchically in groups and items.
827
-	$groups = array();
828
-	foreach ( (array) $export_data as $export_datum ) {
829
-		$group_id    = $export_datum['group_id'];
830
-		$group_label = $export_datum['group_label'];
831
-
832
-		$group_description = '';
833
-		if ( ! empty( $export_datum['group_description'] ) ) {
834
-			$group_description = $export_datum['group_description'];
835
-		}
836
-
837
-		if ( ! array_key_exists( $group_id, $groups ) ) {
838
-			$groups[ $group_id ] = array(
839
-				'group_label'       => $group_label,
840
-				'group_description' => $group_description,
841
-				'items'             => array(),
842
-			);
843
-		}
844
-
845
-		$item_id = $export_datum['item_id'];
846
-		if ( ! array_key_exists( $item_id, $groups[ $group_id ]['items'] ) ) {
847
-			$groups[ $group_id ]['items'][ $item_id ] = array();
848
-		}
849
-
850
-		$old_item_data                            = $groups[ $group_id ]['items'][ $item_id ];
851
-		$merged_item_data                         = array_merge( $export_datum['data'], $old_item_data );
852
-		$groups[ $group_id ]['items'][ $item_id ] = $merged_item_data;
853
-	}
854
-
855
-	// Then save the grouped data into the request.
856
-	delete_post_meta( $request_id, '_export_data_raw' );
857
-	update_post_meta( $request_id, '_export_data_grouped', $groups );
858
-
859
-	/**
860
-	 * Generate the export file from the collected, grouped personal data.
861
-	 *
862
-	 * @since 4.9.6
863
-	 *
864
-	 * @param int $request_id The export request ID.
865
-	 */
866
-	do_action( 'wp_privacy_personal_data_export_file', $request_id );
867
-
868
-	// Clear the grouped data now that it is no longer needed.
869
-	delete_post_meta( $request_id, '_export_data_grouped' );
870
-
871
-	// If the destination is email, send it now.
872
-	if ( $send_as_email ) {
873
-		$mail_success = wp_privacy_send_personal_data_export_email( $request_id );
874
-		if ( is_wp_error( $mail_success ) ) {
875
-			wp_send_json_error( $mail_success->get_error_message() );
876
-		}
877
-
878
-		// Update the request to completed state when the export email is sent.
879
-		_wp_privacy_completed_request( $request_id );
880
-	} else {
881
-		// Modify the response to include the URL of the export file so the browser can fetch it.
882
-		$exports_url      = wp_privacy_exports_url();
883
-		$export_file_name = get_post_meta( $request_id, '_export_file_name', true );
884
-		$export_file_url  = $exports_url . $export_file_name;
885
-
886
-		if ( ! empty( $export_file_url ) ) {
887
-			$response['url'] = $export_file_url;
888
-		}
889
-	}
890
-
891
-	return $response;
775
+    if ( ! is_array( $response ) ) {
776
+        return $response;
777
+    }
778
+
779
+    if ( ! array_key_exists( 'done', $response ) ) {
780
+        return $response;
781
+    }
782
+
783
+    if ( ! array_key_exists( 'data', $response ) ) {
784
+        return $response;
785
+    }
786
+
787
+    if ( ! is_array( $response['data'] ) ) {
788
+        return $response;
789
+    }
790
+
791
+    // Get the request.
792
+    $request = wp_get_user_request( $request_id );
793
+
794
+    if ( ! $request || 'export_personal_data' !== $request->action_name ) {
795
+        wp_send_json_error( __( 'Invalid request ID when merging personal data to export.' ) );
796
+    }
797
+
798
+    $export_data = array();
799
+
800
+    // First exporter, first page? Reset the report data accumulation array.
801
+    if ( 1 === $exporter_index && 1 === $page ) {
802
+        update_post_meta( $request_id, '_export_data_raw', $export_data );
803
+    } else {
804
+        $accumulated_data = get_post_meta( $request_id, '_export_data_raw', true );
805
+
806
+        if ( $accumulated_data ) {
807
+            $export_data = $accumulated_data;
808
+        }
809
+    }
810
+
811
+    // Now, merge the data from the exporter response into the data we have accumulated already.
812
+    $export_data = array_merge( $export_data, $response['data'] );
813
+    update_post_meta( $request_id, '_export_data_raw', $export_data );
814
+
815
+    // If we are not yet on the last page of the last exporter, return now.
816
+    /** This filter is documented in wp-admin/includes/ajax-actions.php */
817
+    $exporters        = apply_filters( 'wp_privacy_personal_data_exporters', array() );
818
+    $is_last_exporter = count( $exporters ) === $exporter_index;
819
+    $exporter_done    = $response['done'];
820
+    if ( ! $is_last_exporter || ! $exporter_done ) {
821
+        return $response;
822
+    }
823
+
824
+    // Last exporter, last page - let's prepare the export file.
825
+
826
+    // First we need to re-organize the raw data hierarchically in groups and items.
827
+    $groups = array();
828
+    foreach ( (array) $export_data as $export_datum ) {
829
+        $group_id    = $export_datum['group_id'];
830
+        $group_label = $export_datum['group_label'];
831
+
832
+        $group_description = '';
833
+        if ( ! empty( $export_datum['group_description'] ) ) {
834
+            $group_description = $export_datum['group_description'];
835
+        }
836
+
837
+        if ( ! array_key_exists( $group_id, $groups ) ) {
838
+            $groups[ $group_id ] = array(
839
+                'group_label'       => $group_label,
840
+                'group_description' => $group_description,
841
+                'items'             => array(),
842
+            );
843
+        }
844
+
845
+        $item_id = $export_datum['item_id'];
846
+        if ( ! array_key_exists( $item_id, $groups[ $group_id ]['items'] ) ) {
847
+            $groups[ $group_id ]['items'][ $item_id ] = array();
848
+        }
849
+
850
+        $old_item_data                            = $groups[ $group_id ]['items'][ $item_id ];
851
+        $merged_item_data                         = array_merge( $export_datum['data'], $old_item_data );
852
+        $groups[ $group_id ]['items'][ $item_id ] = $merged_item_data;
853
+    }
854
+
855
+    // Then save the grouped data into the request.
856
+    delete_post_meta( $request_id, '_export_data_raw' );
857
+    update_post_meta( $request_id, '_export_data_grouped', $groups );
858
+
859
+    /**
860
+     * Generate the export file from the collected, grouped personal data.
861
+     *
862
+     * @since 4.9.6
863
+     *
864
+     * @param int $request_id The export request ID.
865
+     */
866
+    do_action( 'wp_privacy_personal_data_export_file', $request_id );
867
+
868
+    // Clear the grouped data now that it is no longer needed.
869
+    delete_post_meta( $request_id, '_export_data_grouped' );
870
+
871
+    // If the destination is email, send it now.
872
+    if ( $send_as_email ) {
873
+        $mail_success = wp_privacy_send_personal_data_export_email( $request_id );
874
+        if ( is_wp_error( $mail_success ) ) {
875
+            wp_send_json_error( $mail_success->get_error_message() );
876
+        }
877
+
878
+        // Update the request to completed state when the export email is sent.
879
+        _wp_privacy_completed_request( $request_id );
880
+    } else {
881
+        // Modify the response to include the URL of the export file so the browser can fetch it.
882
+        $exports_url      = wp_privacy_exports_url();
883
+        $export_file_name = get_post_meta( $request_id, '_export_file_name', true );
884
+        $export_file_url  = $exports_url . $export_file_name;
885
+
886
+        if ( ! empty( $export_file_url ) ) {
887
+            $response['url'] = $export_file_url;
888
+        }
889
+    }
890
+
891
+    return $response;
892 892
 }
893 893
 
894 894
 /**
@@ -914,57 +914,57 @@  discard block
 block discarded – undo
914 914
  * @return array The filtered response.
915 915
  */
916 916
 function wp_privacy_process_personal_data_erasure_page( $response, $eraser_index, $email_address, $page, $request_id ) {
917
-	/*
917
+    /*
918 918
 	 * If the eraser response is malformed, don't attempt to consume it; let it
919 919
 	 * pass through, so that the default Ajax processing will generate a warning
920 920
 	 * to the user.
921 921
 	 */
922
-	if ( ! is_array( $response ) ) {
923
-		return $response;
924
-	}
925
-
926
-	if ( ! array_key_exists( 'done', $response ) ) {
927
-		return $response;
928
-	}
929
-
930
-	if ( ! array_key_exists( 'items_removed', $response ) ) {
931
-		return $response;
932
-	}
933
-
934
-	if ( ! array_key_exists( 'items_retained', $response ) ) {
935
-		return $response;
936
-	}
937
-
938
-	if ( ! array_key_exists( 'messages', $response ) ) {
939
-		return $response;
940
-	}
941
-
942
-	// Get the request.
943
-	$request = wp_get_user_request( $request_id );
944
-
945
-	if ( ! $request || 'remove_personal_data' !== $request->action_name ) {
946
-		wp_send_json_error( __( 'Invalid request ID when processing personal data to erase.' ) );
947
-	}
948
-
949
-	/** This filter is documented in wp-admin/includes/ajax-actions.php */
950
-	$erasers        = apply_filters( 'wp_privacy_personal_data_erasers', array() );
951
-	$is_last_eraser = count( $erasers ) === $eraser_index;
952
-	$eraser_done    = $response['done'];
953
-
954
-	if ( ! $is_last_eraser || ! $eraser_done ) {
955
-		return $response;
956
-	}
957
-
958
-	_wp_privacy_completed_request( $request_id );
959
-
960
-	/**
961
-	 * Fires immediately after a personal data erasure request has been marked completed.
962
-	 *
963
-	 * @since 4.9.6
964
-	 *
965
-	 * @param int $request_id The privacy request post ID associated with this request.
966
-	 */
967
-	do_action( 'wp_privacy_personal_data_erased', $request_id );
968
-
969
-	return $response;
922
+    if ( ! is_array( $response ) ) {
923
+        return $response;
924
+    }
925
+
926
+    if ( ! array_key_exists( 'done', $response ) ) {
927
+        return $response;
928
+    }
929
+
930
+    if ( ! array_key_exists( 'items_removed', $response ) ) {
931
+        return $response;
932
+    }
933
+
934
+    if ( ! array_key_exists( 'items_retained', $response ) ) {
935
+        return $response;
936
+    }
937
+
938
+    if ( ! array_key_exists( 'messages', $response ) ) {
939
+        return $response;
940
+    }
941
+
942
+    // Get the request.
943
+    $request = wp_get_user_request( $request_id );
944
+
945
+    if ( ! $request || 'remove_personal_data' !== $request->action_name ) {
946
+        wp_send_json_error( __( 'Invalid request ID when processing personal data to erase.' ) );
947
+    }
948
+
949
+    /** This filter is documented in wp-admin/includes/ajax-actions.php */
950
+    $erasers        = apply_filters( 'wp_privacy_personal_data_erasers', array() );
951
+    $is_last_eraser = count( $erasers ) === $eraser_index;
952
+    $eraser_done    = $response['done'];
953
+
954
+    if ( ! $is_last_eraser || ! $eraser_done ) {
955
+        return $response;
956
+    }
957
+
958
+    _wp_privacy_completed_request( $request_id );
959
+
960
+    /**
961
+     * Fires immediately after a personal data erasure request has been marked completed.
962
+     *
963
+     * @since 4.9.6
964
+     *
965
+     * @param int $request_id The privacy request post ID associated with this request.
966
+     */
967
+    do_action( 'wp_privacy_personal_data_erased', $request_id );
968
+
969
+    return $response;
970 970
 }
Please login to merge, or discard this patch.
Spacing   +258 added lines, -258 removed lines patch added patch discarded remove patch
@@ -15,20 +15,20 @@  discard block
 block discarded – undo
15 15
  * @param int $request_id Request ID.
16 16
  * @return true|WP_Error Returns true if sending the email was successful, or a WP_Error object.
17 17
  */
18
-function _wp_privacy_resend_request( $request_id ) {
19
-	$request_id = absint( $request_id );
20
-	$request    = get_post( $request_id );
18
+function _wp_privacy_resend_request($request_id) {
19
+	$request_id = absint($request_id);
20
+	$request    = get_post($request_id);
21 21
 
22
-	if ( ! $request || 'user_request' !== $request->post_type ) {
23
-		return new WP_Error( 'privacy_request_error', __( 'Invalid personal data request.' ) );
22
+	if (!$request || 'user_request' !== $request->post_type) {
23
+		return new WP_Error('privacy_request_error', __('Invalid personal data request.'));
24 24
 	}
25 25
 
26
-	$result = wp_send_user_request( $request_id );
26
+	$result = wp_send_user_request($request_id);
27 27
 
28
-	if ( is_wp_error( $result ) ) {
28
+	if (is_wp_error($result)) {
29 29
 		return $result;
30
-	} elseif ( ! $result ) {
31
-		return new WP_Error( 'privacy_request_error', __( 'Unable to initiate confirmation for personal data request.' ) );
30
+	} elseif (!$result) {
31
+		return new WP_Error('privacy_request_error', __('Unable to initiate confirmation for personal data request.'));
32 32
 	}
33 33
 
34 34
 	return true;
@@ -43,16 +43,16 @@  discard block
 block discarded – undo
43 43
  * @param int $request_id Request ID.
44 44
  * @return int|WP_Error Request ID on success, or a WP_Error on failure.
45 45
  */
46
-function _wp_privacy_completed_request( $request_id ) {
46
+function _wp_privacy_completed_request($request_id) {
47 47
 	// Get the request.
48
-	$request_id = absint( $request_id );
49
-	$request    = wp_get_user_request( $request_id );
48
+	$request_id = absint($request_id);
49
+	$request    = wp_get_user_request($request_id);
50 50
 
51
-	if ( ! $request ) {
52
-		return new WP_Error( 'privacy_request_error', __( 'Invalid personal data request.' ) );
51
+	if (!$request) {
52
+		return new WP_Error('privacy_request_error', __('Invalid personal data request.'));
53 53
 	}
54 54
 
55
-	update_post_meta( $request_id, '_wp_user_request_completed_timestamp', time() );
55
+	update_post_meta($request_id, '_wp_user_request_completed_timestamp', time());
56 56
 
57 57
 	$result = wp_update_post(
58 58
 		array(
@@ -71,13 +71,13 @@  discard block
 block discarded – undo
71 71
  * @access private
72 72
  */
73 73
 function _wp_personal_data_handle_actions() {
74
-	if ( isset( $_POST['privacy_action_email_retry'] ) ) {
75
-		check_admin_referer( 'bulk-privacy_requests' );
74
+	if (isset($_POST['privacy_action_email_retry'])) {
75
+		check_admin_referer('bulk-privacy_requests');
76 76
 
77
-		$request_id = absint( current( array_keys( (array) wp_unslash( $_POST['privacy_action_email_retry'] ) ) ) );
78
-		$result     = _wp_privacy_resend_request( $request_id );
77
+		$request_id = absint(current(array_keys((array) wp_unslash($_POST['privacy_action_email_retry']))));
78
+		$result     = _wp_privacy_resend_request($request_id);
79 79
 
80
-		if ( is_wp_error( $result ) ) {
80
+		if (is_wp_error($result)) {
81 81
 			add_settings_error(
82 82
 				'privacy_action_email_retry',
83 83
 				'privacy_action_email_retry',
@@ -88,51 +88,51 @@  discard block
 block discarded – undo
88 88
 			add_settings_error(
89 89
 				'privacy_action_email_retry',
90 90
 				'privacy_action_email_retry',
91
-				__( 'Confirmation request sent again successfully.' ),
91
+				__('Confirmation request sent again successfully.'),
92 92
 				'success'
93 93
 			);
94 94
 		}
95
-	} elseif ( isset( $_POST['action'] ) ) {
96
-		$action = ! empty( $_POST['action'] ) ? sanitize_key( wp_unslash( $_POST['action'] ) ) : '';
95
+	} elseif (isset($_POST['action'])) {
96
+		$action = !empty($_POST['action']) ? sanitize_key(wp_unslash($_POST['action'])) : '';
97 97
 
98
-		switch ( $action ) {
98
+		switch ($action) {
99 99
 			case 'add_export_personal_data_request':
100 100
 			case 'add_remove_personal_data_request':
101
-				check_admin_referer( 'personal-data-request' );
101
+				check_admin_referer('personal-data-request');
102 102
 
103
-				if ( ! isset( $_POST['type_of_action'], $_POST['username_or_email_for_privacy_request'] ) ) {
103
+				if (!isset($_POST['type_of_action'], $_POST['username_or_email_for_privacy_request'])) {
104 104
 					add_settings_error(
105 105
 						'action_type',
106 106
 						'action_type',
107
-						__( 'Invalid personal data action.' ),
107
+						__('Invalid personal data action.'),
108 108
 						'error'
109 109
 					);
110 110
 				}
111
-				$action_type               = sanitize_text_field( wp_unslash( $_POST['type_of_action'] ) );
112
-				$username_or_email_address = sanitize_text_field( wp_unslash( $_POST['username_or_email_for_privacy_request'] ) );
111
+				$action_type               = sanitize_text_field(wp_unslash($_POST['type_of_action']));
112
+				$username_or_email_address = sanitize_text_field(wp_unslash($_POST['username_or_email_for_privacy_request']));
113 113
 				$email_address             = '';
114 114
 				$status                    = 'pending';
115 115
 
116
-				if ( ! isset( $_POST['send_confirmation_email'] ) ) {
116
+				if (!isset($_POST['send_confirmation_email'])) {
117 117
 					$status = 'confirmed';
118 118
 				}
119 119
 
120
-				if ( ! in_array( $action_type, _wp_privacy_action_request_types(), true ) ) {
120
+				if (!in_array($action_type, _wp_privacy_action_request_types(), true)) {
121 121
 					add_settings_error(
122 122
 						'action_type',
123 123
 						'action_type',
124
-						__( 'Invalid personal data action.' ),
124
+						__('Invalid personal data action.'),
125 125
 						'error'
126 126
 					);
127 127
 				}
128 128
 
129
-				if ( ! is_email( $username_or_email_address ) ) {
130
-					$user = get_user_by( 'login', $username_or_email_address );
131
-					if ( ! $user instanceof WP_User ) {
129
+				if (!is_email($username_or_email_address)) {
130
+					$user = get_user_by('login', $username_or_email_address);
131
+					if (!$user instanceof WP_User) {
132 132
 						add_settings_error(
133 133
 							'username_or_email_for_privacy_request',
134 134
 							'username_or_email_for_privacy_request',
135
-							__( 'Unable to add this request. A valid email address or username must be supplied.' ),
135
+							__('Unable to add this request. A valid email address or username must be supplied.'),
136 136
 							'error'
137 137
 						);
138 138
 					} else {
@@ -142,20 +142,20 @@  discard block
 block discarded – undo
142 142
 					$email_address = $username_or_email_address;
143 143
 				}
144 144
 
145
-				if ( empty( $email_address ) ) {
145
+				if (empty($email_address)) {
146 146
 					break;
147 147
 				}
148 148
 
149
-				$request_id = wp_create_user_request( $email_address, $action_type, array(), $status );
149
+				$request_id = wp_create_user_request($email_address, $action_type, array(), $status);
150 150
 				$message    = '';
151 151
 
152
-				if ( is_wp_error( $request_id ) ) {
152
+				if (is_wp_error($request_id)) {
153 153
 					$message = $request_id->get_error_message();
154
-				} elseif ( ! $request_id ) {
155
-					$message = __( 'Unable to initiate confirmation request.' );
154
+				} elseif (!$request_id) {
155
+					$message = __('Unable to initiate confirmation request.');
156 156
 				}
157 157
 
158
-				if ( $message ) {
158
+				if ($message) {
159 159
 					add_settings_error(
160 160
 						'username_or_email_for_privacy_request',
161 161
 						'username_or_email_for_privacy_request',
@@ -165,15 +165,15 @@  discard block
 block discarded – undo
165 165
 					break;
166 166
 				}
167 167
 
168
-				if ( 'pending' === $status ) {
169
-					wp_send_user_request( $request_id );
168
+				if ('pending' === $status) {
169
+					wp_send_user_request($request_id);
170 170
 
171
-					$message = __( 'Confirmation request initiated successfully.' );
172
-				} elseif ( 'confirmed' === $status ) {
173
-					$message = __( 'Request added successfully.' );
171
+					$message = __('Confirmation request initiated successfully.');
172
+				} elseif ('confirmed' === $status) {
173
+					$message = __('Request added successfully.');
174 174
 				}
175 175
 
176
-				if ( $message ) {
176
+				if ($message) {
177 177
 					add_settings_error(
178 178
 						'username_or_email_for_privacy_request',
179 179
 						'username_or_email_for_privacy_request',
@@ -194,7 +194,7 @@  discard block
 block discarded – undo
194 194
  */
195 195
 function _wp_personal_data_cleanup_requests() {
196 196
 	/** This filter is documented in wp-includes/user.php */
197
-	$expires = (int) apply_filters( 'user_request_key_expiration', DAY_IN_SECONDS );
197
+	$expires = (int) apply_filters('user_request_key_expiration', DAY_IN_SECONDS);
198 198
 
199 199
 	$requests_query = new WP_Query(
200 200
 		array(
@@ -213,7 +213,7 @@  discard block
 block discarded – undo
213 213
 
214 214
 	$request_ids = $requests_query->posts;
215 215
 
216
-	foreach ( $request_ids as $request_id ) {
216
+	foreach ($request_ids as $request_id) {
217 217
 		wp_update_post(
218 218
 			array(
219 219
 				'ID'            => $request_id,
@@ -249,39 +249,39 @@  discard block
 block discarded – undo
249 249
  * @param int    $groups_count The number of all groups
250 250
  * @return string The HTML for this group and its items.
251 251
  */
252
-function wp_privacy_generate_personal_data_export_group_html( $group_data, $group_id = '', $groups_count = 1 ) {
253
-	$group_id_attr = sanitize_title_with_dashes( $group_data['group_label'] . '-' . $group_id );
252
+function wp_privacy_generate_personal_data_export_group_html($group_data, $group_id = '', $groups_count = 1) {
253
+	$group_id_attr = sanitize_title_with_dashes($group_data['group_label'] . '-' . $group_id);
254 254
 
255
-	$group_html  = '<h2 id="' . esc_attr( $group_id_attr ) . '">';
256
-	$group_html .= esc_html( $group_data['group_label'] );
255
+	$group_html  = '<h2 id="' . esc_attr($group_id_attr) . '">';
256
+	$group_html .= esc_html($group_data['group_label']);
257 257
 
258
-	$items_count = count( (array) $group_data['items'] );
259
-	if ( $items_count > 1 ) {
260
-		$group_html .= sprintf( ' <span class="count">(%d)</span>', $items_count );
258
+	$items_count = count((array) $group_data['items']);
259
+	if ($items_count > 1) {
260
+		$group_html .= sprintf(' <span class="count">(%d)</span>', $items_count);
261 261
 	}
262 262
 
263 263
 	$group_html .= '</h2>';
264 264
 
265
-	if ( ! empty( $group_data['group_description'] ) ) {
266
-		$group_html .= '<p>' . esc_html( $group_data['group_description'] ) . '</p>';
265
+	if (!empty($group_data['group_description'])) {
266
+		$group_html .= '<p>' . esc_html($group_data['group_description']) . '</p>';
267 267
 	}
268 268
 
269 269
 	$group_html .= '<div>';
270 270
 
271
-	foreach ( (array) $group_data['items'] as $group_item_id => $group_item_data ) {
271
+	foreach ((array) $group_data['items'] as $group_item_id => $group_item_data) {
272 272
 		$group_html .= '<table>';
273 273
 		$group_html .= '<tbody>';
274 274
 
275
-		foreach ( (array) $group_item_data as $group_item_datum ) {
275
+		foreach ((array) $group_item_data as $group_item_datum) {
276 276
 			$value = $group_item_datum['value'];
277 277
 			// If it looks like a link, make it a link.
278
-			if ( false === strpos( $value, ' ' ) && ( 0 === strpos( $value, 'http://' ) || 0 === strpos( $value, 'https://' ) ) ) {
279
-				$value = '<a href="' . esc_url( $value ) . '">' . esc_html( $value ) . '</a>';
278
+			if (false === strpos($value, ' ') && (0 === strpos($value, 'http://') || 0 === strpos($value, 'https://'))) {
279
+				$value = '<a href="' . esc_url($value) . '">' . esc_html($value) . '</a>';
280 280
 			}
281 281
 
282 282
 			$group_html .= '<tr>';
283
-			$group_html .= '<th>' . esc_html( $group_item_datum['name'] ) . '</th>';
284
-			$group_html .= '<td>' . wp_kses( $value, 'personal_data_export' ) . '</td>';
283
+			$group_html .= '<th>' . esc_html($group_item_datum['name']) . '</th>';
284
+			$group_html .= '<td>' . wp_kses($value, 'personal_data_export') . '</td>';
285 285
 			$group_html .= '</tr>';
286 286
 		}
287 287
 
@@ -289,9 +289,9 @@  discard block
 block discarded – undo
289 289
 		$group_html .= '</table>';
290 290
 	}
291 291
 
292
-	if ( $groups_count > 1 ) {
292
+	if ($groups_count > 1) {
293 293
 		$group_html .= '<div class="return-to-top">';
294
-		$group_html .= '<a href="#top"><span aria-hidden="true">&uarr; </span> ' . esc_html__( 'Go to top' ) . '</a>';
294
+		$group_html .= '<a href="#top"><span aria-hidden="true">&uarr; </span> ' . esc_html__('Go to top') . '</a>';
295 295
 		$group_html .= '</div>';
296 296
 	}
297 297
 
@@ -307,49 +307,49 @@  discard block
 block discarded – undo
307 307
  *
308 308
  * @param int $request_id The export request ID.
309 309
  */
310
-function wp_privacy_generate_personal_data_export_file( $request_id ) {
311
-	if ( ! class_exists( 'ZipArchive' ) ) {
312
-		wp_send_json_error( __( 'Unable to generate personal data export file. ZipArchive not available.' ) );
310
+function wp_privacy_generate_personal_data_export_file($request_id) {
311
+	if (!class_exists('ZipArchive')) {
312
+		wp_send_json_error(__('Unable to generate personal data export file. ZipArchive not available.'));
313 313
 	}
314 314
 
315 315
 	// Get the request.
316
-	$request = wp_get_user_request( $request_id );
316
+	$request = wp_get_user_request($request_id);
317 317
 
318
-	if ( ! $request || 'export_personal_data' !== $request->action_name ) {
319
-		wp_send_json_error( __( 'Invalid request ID when generating personal data export file.' ) );
318
+	if (!$request || 'export_personal_data' !== $request->action_name) {
319
+		wp_send_json_error(__('Invalid request ID when generating personal data export file.'));
320 320
 	}
321 321
 
322 322
 	$email_address = $request->email;
323 323
 
324
-	if ( ! is_email( $email_address ) ) {
325
-		wp_send_json_error( __( 'Invalid email address when generating personal data export file.' ) );
324
+	if (!is_email($email_address)) {
325
+		wp_send_json_error(__('Invalid email address when generating personal data export file.'));
326 326
 	}
327 327
 
328 328
 	// Create the exports folder if needed.
329 329
 	$exports_dir = wp_privacy_exports_dir();
330 330
 	$exports_url = wp_privacy_exports_url();
331 331
 
332
-	if ( ! wp_mkdir_p( $exports_dir ) ) {
333
-		wp_send_json_error( __( 'Unable to create personal data export folder.' ) );
332
+	if (!wp_mkdir_p($exports_dir)) {
333
+		wp_send_json_error(__('Unable to create personal data export folder.'));
334 334
 	}
335 335
 
336 336
 	// Protect export folder from browsing.
337 337
 	$index_pathname = $exports_dir . 'index.php';
338
-	if ( ! file_exists( $index_pathname ) ) {
339
-		$file = fopen( $index_pathname, 'w' );
340
-		if ( false === $file ) {
341
-			wp_send_json_error( __( 'Unable to protect personal data export folder from browsing.' ) );
338
+	if (!file_exists($index_pathname)) {
339
+		$file = fopen($index_pathname, 'w');
340
+		if (false === $file) {
341
+			wp_send_json_error(__('Unable to protect personal data export folder from browsing.'));
342 342
 		}
343
-		fwrite( $file, "<?php\n// Silence is golden.\n" );
344
-		fclose( $file );
343
+		fwrite($file, "<?php\n// Silence is golden.\n");
344
+		fclose($file);
345 345
 	}
346 346
 
347
-	$obscura              = wp_generate_password( 32, false, false );
347
+	$obscura              = wp_generate_password(32, false, false);
348 348
 	$file_basename        = 'wp-personal-data-file-' . $obscura;
349
-	$html_report_filename = wp_unique_filename( $exports_dir, $file_basename . '.html' );
350
-	$html_report_pathname = wp_normalize_path( $exports_dir . $html_report_filename );
349
+	$html_report_filename = wp_unique_filename($exports_dir, $file_basename . '.html');
350
+	$html_report_pathname = wp_normalize_path($exports_dir . $html_report_filename);
351 351
 	$json_report_filename = $file_basename . '.json';
352
-	$json_report_pathname = wp_normalize_path( $exports_dir . $json_report_filename );
352
+	$json_report_pathname = wp_normalize_path($exports_dir . $json_report_filename);
353 353
 
354 354
 	/*
355 355
 	 * Gather general data needed.
@@ -358,50 +358,50 @@  discard block
 block discarded – undo
358 358
 	// Title.
359 359
 	$title = sprintf(
360 360
 		/* translators: %s: User's email address. */
361
-		__( 'Personal Data Export for %s' ),
361
+		__('Personal Data Export for %s'),
362 362
 		$email_address
363 363
 	);
364 364
 
365 365
 	// First, build an "About" group on the fly for this report.
366 366
 	$about_group = array(
367 367
 		/* translators: Header for the About section in a personal data export. */
368
-		'group_label'       => _x( 'About', 'personal data group label' ),
368
+		'group_label'       => _x('About', 'personal data group label'),
369 369
 		/* translators: Description for the About section in a personal data export. */
370
-		'group_description' => _x( 'Overview of export report.', 'personal data group description' ),
370
+		'group_description' => _x('Overview of export report.', 'personal data group description'),
371 371
 		'items'             => array(
372 372
 			'about-1' => array(
373 373
 				array(
374
-					'name'  => _x( 'Report generated for', 'email address' ),
374
+					'name'  => _x('Report generated for', 'email address'),
375 375
 					'value' => $email_address,
376 376
 				),
377 377
 				array(
378
-					'name'  => _x( 'For site', 'website name' ),
379
-					'value' => get_bloginfo( 'name' ),
378
+					'name'  => _x('For site', 'website name'),
379
+					'value' => get_bloginfo('name'),
380 380
 				),
381 381
 				array(
382
-					'name'  => _x( 'At URL', 'website URL' ),
383
-					'value' => get_bloginfo( 'url' ),
382
+					'name'  => _x('At URL', 'website URL'),
383
+					'value' => get_bloginfo('url'),
384 384
 				),
385 385
 				array(
386
-					'name'  => _x( 'On', 'date/time' ),
387
-					'value' => current_time( 'mysql' ),
386
+					'name'  => _x('On', 'date/time'),
387
+					'value' => current_time('mysql'),
388 388
 				),
389 389
 			),
390 390
 		),
391 391
 	);
392 392
 
393 393
 	// And now, all the Groups.
394
-	$groups = get_post_meta( $request_id, '_export_data_grouped', true );
395
-	if ( is_array( $groups ) ) {
394
+	$groups = get_post_meta($request_id, '_export_data_grouped', true);
395
+	if (is_array($groups)) {
396 396
 		// Merge in the special "About" group.
397
-		$groups       = array_merge( array( 'about' => $about_group ), $groups );
398
-		$groups_count = count( $groups );
397
+		$groups       = array_merge(array('about' => $about_group), $groups);
398
+		$groups_count = count($groups);
399 399
 	} else {
400
-		if ( false !== $groups ) {
400
+		if (false !== $groups) {
401 401
 			_doing_it_wrong(
402 402
 				__FUNCTION__,
403 403
 				/* translators: %s: Post meta key. */
404
-				sprintf( __( 'The %s post meta must be an array.' ), '<code>_export_data_grouped</code>' ),
404
+				sprintf(__('The %s post meta must be an array.'), '<code>_export_data_grouped</code>'),
405 405
 				'5.8.0'
406 406
 			);
407 407
 		}
@@ -411,89 +411,89 @@  discard block
 block discarded – undo
411 411
 	}
412 412
 
413 413
 	// Convert the groups to JSON format.
414
-	$groups_json = wp_json_encode( $groups );
414
+	$groups_json = wp_json_encode($groups);
415 415
 
416
-	if ( false === $groups_json ) {
416
+	if (false === $groups_json) {
417 417
 		$error_message = sprintf(
418 418
 			/* translators: %s: Error message. */
419
-			__( 'Unable to encode the personal data for export. Error: %s' ),
419
+			__('Unable to encode the personal data for export. Error: %s'),
420 420
 			json_last_error_msg()
421 421
 		);
422 422
 
423
-		wp_send_json_error( $error_message );
423
+		wp_send_json_error($error_message);
424 424
 	}
425 425
 
426 426
 	/*
427 427
 	 * Handle the JSON export.
428 428
 	 */
429
-	$file = fopen( $json_report_pathname, 'w' );
429
+	$file = fopen($json_report_pathname, 'w');
430 430
 
431
-	if ( false === $file ) {
432
-		wp_send_json_error( __( 'Unable to open personal data export file (JSON report) for writing.' ) );
431
+	if (false === $file) {
432
+		wp_send_json_error(__('Unable to open personal data export file (JSON report) for writing.'));
433 433
 	}
434 434
 
435
-	fwrite( $file, '{' );
436
-	fwrite( $file, '"' . $title . '":' );
437
-	fwrite( $file, $groups_json );
438
-	fwrite( $file, '}' );
439
-	fclose( $file );
435
+	fwrite($file, '{');
436
+	fwrite($file, '"' . $title . '":');
437
+	fwrite($file, $groups_json);
438
+	fwrite($file, '}');
439
+	fclose($file);
440 440
 
441 441
 	/*
442 442
 	 * Handle the HTML export.
443 443
 	 */
444
-	$file = fopen( $html_report_pathname, 'w' );
445
-
446
-	if ( false === $file ) {
447
-		wp_send_json_error( __( 'Unable to open personal data export (HTML report) for writing.' ) );
448
-	}
449
-
450
-	fwrite( $file, "<!DOCTYPE html>\n" );
451
-	fwrite( $file, "<html>\n" );
452
-	fwrite( $file, "<head>\n" );
453
-	fwrite( $file, "<meta http-equiv='Content-Type' content='text/html; charset=UTF-8' />\n" );
454
-	fwrite( $file, "<style type='text/css'>" );
455
-	fwrite( $file, 'body { color: black; font-family: Arial, sans-serif; font-size: 11pt; margin: 15px auto; width: 860px; }' );
456
-	fwrite( $file, 'table { background: #f0f0f0; border: 1px solid #ddd; margin-bottom: 20px; width: 100%; }' );
457
-	fwrite( $file, 'th { padding: 5px; text-align: left; width: 20%; }' );
458
-	fwrite( $file, 'td { padding: 5px; }' );
459
-	fwrite( $file, 'tr:nth-child(odd) { background-color: #fafafa; }' );
460
-	fwrite( $file, '.return-to-top { text-align: right; }' );
461
-	fwrite( $file, '</style>' );
462
-	fwrite( $file, '<title>' );
463
-	fwrite( $file, esc_html( $title ) );
464
-	fwrite( $file, '</title>' );
465
-	fwrite( $file, "</head>\n" );
466
-	fwrite( $file, "<body>\n" );
467
-	fwrite( $file, '<h1 id="top">' . esc_html__( 'Personal Data Export' ) . '</h1>' );
444
+	$file = fopen($html_report_pathname, 'w');
445
+
446
+	if (false === $file) {
447
+		wp_send_json_error(__('Unable to open personal data export (HTML report) for writing.'));
448
+	}
449
+
450
+	fwrite($file, "<!DOCTYPE html>\n");
451
+	fwrite($file, "<html>\n");
452
+	fwrite($file, "<head>\n");
453
+	fwrite($file, "<meta http-equiv='Content-Type' content='text/html; charset=UTF-8' />\n");
454
+	fwrite($file, "<style type='text/css'>");
455
+	fwrite($file, 'body { color: black; font-family: Arial, sans-serif; font-size: 11pt; margin: 15px auto; width: 860px; }');
456
+	fwrite($file, 'table { background: #f0f0f0; border: 1px solid #ddd; margin-bottom: 20px; width: 100%; }');
457
+	fwrite($file, 'th { padding: 5px; text-align: left; width: 20%; }');
458
+	fwrite($file, 'td { padding: 5px; }');
459
+	fwrite($file, 'tr:nth-child(odd) { background-color: #fafafa; }');
460
+	fwrite($file, '.return-to-top { text-align: right; }');
461
+	fwrite($file, '</style>');
462
+	fwrite($file, '<title>');
463
+	fwrite($file, esc_html($title));
464
+	fwrite($file, '</title>');
465
+	fwrite($file, "</head>\n");
466
+	fwrite($file, "<body>\n");
467
+	fwrite($file, '<h1 id="top">' . esc_html__('Personal Data Export') . '</h1>');
468 468
 
469 469
 	// Create TOC.
470
-	if ( $groups_count > 1 ) {
471
-		fwrite( $file, '<div id="table_of_contents">' );
472
-		fwrite( $file, '<h2>' . esc_html__( 'Table of Contents' ) . '</h2>' );
473
-		fwrite( $file, '<ul>' );
474
-		foreach ( (array) $groups as $group_id => $group_data ) {
475
-			$group_label       = esc_html( $group_data['group_label'] );
476
-			$group_id_attr     = sanitize_title_with_dashes( $group_data['group_label'] . '-' . $group_id );
477
-			$group_items_count = count( (array) $group_data['items'] );
478
-			if ( $group_items_count > 1 ) {
479
-				$group_label .= sprintf( ' <span class="count">(%d)</span>', $group_items_count );
470
+	if ($groups_count > 1) {
471
+		fwrite($file, '<div id="table_of_contents">');
472
+		fwrite($file, '<h2>' . esc_html__('Table of Contents') . '</h2>');
473
+		fwrite($file, '<ul>');
474
+		foreach ((array) $groups as $group_id => $group_data) {
475
+			$group_label       = esc_html($group_data['group_label']);
476
+			$group_id_attr     = sanitize_title_with_dashes($group_data['group_label'] . '-' . $group_id);
477
+			$group_items_count = count((array) $group_data['items']);
478
+			if ($group_items_count > 1) {
479
+				$group_label .= sprintf(' <span class="count">(%d)</span>', $group_items_count);
480 480
 			}
481
-			fwrite( $file, '<li>' );
482
-			fwrite( $file, '<a href="#' . esc_attr( $group_id_attr ) . '">' . $group_label . '</a>' );
483
-			fwrite( $file, '</li>' );
481
+			fwrite($file, '<li>');
482
+			fwrite($file, '<a href="#' . esc_attr($group_id_attr) . '">' . $group_label . '</a>');
483
+			fwrite($file, '</li>');
484 484
 		}
485
-		fwrite( $file, '</ul>' );
486
-		fwrite( $file, '</div>' );
485
+		fwrite($file, '</ul>');
486
+		fwrite($file, '</div>');
487 487
 	}
488 488
 
489 489
 	// Now, iterate over every group in $groups and have the formatter render it in HTML.
490
-	foreach ( (array) $groups as $group_id => $group_data ) {
491
-		fwrite( $file, wp_privacy_generate_personal_data_export_group_html( $group_data, $group_id, $groups_count ) );
490
+	foreach ((array) $groups as $group_id => $group_data) {
491
+		fwrite($file, wp_privacy_generate_personal_data_export_group_html($group_data, $group_id, $groups_count));
492 492
 	}
493 493
 
494
-	fwrite( $file, "</body>\n" );
495
-	fwrite( $file, "</html>\n" );
496
-	fclose( $file );
494
+	fwrite($file, "</body>\n");
495
+	fwrite($file, "</html>\n");
496
+	fclose($file);
497 497
 
498 498
 	/*
499 499
 	 * Now, generate the ZIP.
@@ -504,50 +504,50 @@  discard block
 block discarded – undo
504 504
 	$error = false;
505 505
 
506 506
 	// This meta value is used from version 5.5.
507
-	$archive_filename = get_post_meta( $request_id, '_export_file_name', true );
507
+	$archive_filename = get_post_meta($request_id, '_export_file_name', true);
508 508
 
509 509
 	// This one stored an absolute path and is used for backward compatibility.
510
-	$archive_pathname = get_post_meta( $request_id, '_export_file_path', true );
510
+	$archive_pathname = get_post_meta($request_id, '_export_file_path', true);
511 511
 
512 512
 	// If a filename meta exists, use it.
513
-	if ( ! empty( $archive_filename ) ) {
513
+	if (!empty($archive_filename)) {
514 514
 		$archive_pathname = $exports_dir . $archive_filename;
515
-	} elseif ( ! empty( $archive_pathname ) ) {
515
+	} elseif (!empty($archive_pathname)) {
516 516
 		// If a full path meta exists, use it and create the new meta value.
517
-		$archive_filename = basename( $archive_pathname );
517
+		$archive_filename = basename($archive_pathname);
518 518
 
519
-		update_post_meta( $request_id, '_export_file_name', $archive_filename );
519
+		update_post_meta($request_id, '_export_file_name', $archive_filename);
520 520
 
521 521
 		// Remove the back-compat meta values.
522
-		delete_post_meta( $request_id, '_export_file_url' );
523
-		delete_post_meta( $request_id, '_export_file_path' );
522
+		delete_post_meta($request_id, '_export_file_url');
523
+		delete_post_meta($request_id, '_export_file_path');
524 524
 	} else {
525 525
 		// If there's no filename or full path stored, create a new file.
526 526
 		$archive_filename = $file_basename . '.zip';
527 527
 		$archive_pathname = $exports_dir . $archive_filename;
528 528
 
529
-		update_post_meta( $request_id, '_export_file_name', $archive_filename );
529
+		update_post_meta($request_id, '_export_file_name', $archive_filename);
530 530
 	}
531 531
 
532 532
 	$archive_url = $exports_url . $archive_filename;
533 533
 
534
-	if ( ! empty( $archive_pathname ) && file_exists( $archive_pathname ) ) {
535
-		wp_delete_file( $archive_pathname );
534
+	if (!empty($archive_pathname) && file_exists($archive_pathname)) {
535
+		wp_delete_file($archive_pathname);
536 536
 	}
537 537
 
538 538
 	$zip = new ZipArchive;
539
-	if ( true === $zip->open( $archive_pathname, ZipArchive::CREATE ) ) {
540
-		if ( ! $zip->addFile( $json_report_pathname, 'export.json' ) ) {
541
-			$error = __( 'Unable to archive the personal data export file (JSON format).' );
539
+	if (true === $zip->open($archive_pathname, ZipArchive::CREATE)) {
540
+		if (!$zip->addFile($json_report_pathname, 'export.json')) {
541
+			$error = __('Unable to archive the personal data export file (JSON format).');
542 542
 		}
543 543
 
544
-		if ( ! $zip->addFile( $html_report_pathname, 'index.html' ) ) {
545
-			$error = __( 'Unable to archive the personal data export file (HTML format).' );
544
+		if (!$zip->addFile($html_report_pathname, 'index.html')) {
545
+			$error = __('Unable to archive the personal data export file (HTML format).');
546 546
 		}
547 547
 
548 548
 		$zip->close();
549 549
 
550
-		if ( ! $error ) {
550
+		if (!$error) {
551 551
 			/**
552 552
 			 * Fires right after all personal data has been written to the export file.
553 553
 			 *
@@ -560,20 +560,20 @@  discard block
 block discarded – undo
560 560
 			 * @param int    $request_id           The export request ID.
561 561
 			 * @param string $json_report_pathname The full path to the JSON personal data report on the filesystem.
562 562
 			 */
563
-			do_action( 'wp_privacy_personal_data_export_file_created', $archive_pathname, $archive_url, $html_report_pathname, $request_id, $json_report_pathname );
563
+			do_action('wp_privacy_personal_data_export_file_created', $archive_pathname, $archive_url, $html_report_pathname, $request_id, $json_report_pathname);
564 564
 		}
565 565
 	} else {
566
-		$error = __( 'Unable to open personal data export file (archive) for writing.' );
566
+		$error = __('Unable to open personal data export file (archive) for writing.');
567 567
 	}
568 568
 
569 569
 	// Remove the JSON file.
570
-	unlink( $json_report_pathname );
570
+	unlink($json_report_pathname);
571 571
 
572 572
 	// Remove the HTML file.
573
-	unlink( $html_report_pathname );
573
+	unlink($html_report_pathname);
574 574
 
575
-	if ( $error ) {
576
-		wp_send_json_error( $error );
575
+	if ($error) {
576
+		wp_send_json_error($error);
577 577
 	}
578 578
 }
579 579
 
@@ -585,32 +585,32 @@  discard block
 block discarded – undo
585 585
  * @param int $request_id The request ID for this personal data export.
586 586
  * @return true|WP_Error True on success or `WP_Error` on failure.
587 587
  */
588
-function wp_privacy_send_personal_data_export_email( $request_id ) {
588
+function wp_privacy_send_personal_data_export_email($request_id) {
589 589
 	// Get the request.
590
-	$request = wp_get_user_request( $request_id );
590
+	$request = wp_get_user_request($request_id);
591 591
 
592
-	if ( ! $request || 'export_personal_data' !== $request->action_name ) {
593
-		return new WP_Error( 'invalid_request', __( 'Invalid request ID when sending personal data export email.' ) );
592
+	if (!$request || 'export_personal_data' !== $request->action_name) {
593
+		return new WP_Error('invalid_request', __('Invalid request ID when sending personal data export email.'));
594 594
 	}
595 595
 
596 596
 	// Localize message content for user; fallback to site default for visitors.
597
-	if ( ! empty( $request->user_id ) ) {
598
-		$locale = get_user_locale( $request->user_id );
597
+	if (!empty($request->user_id)) {
598
+		$locale = get_user_locale($request->user_id);
599 599
 	} else {
600 600
 		$locale = get_locale();
601 601
 	}
602 602
 
603
-	$switched_locale = switch_to_locale( $locale );
603
+	$switched_locale = switch_to_locale($locale);
604 604
 
605 605
 	/** This filter is documented in wp-includes/functions.php */
606
-	$expiration      = apply_filters( 'wp_privacy_export_expiration', 3 * DAY_IN_SECONDS );
607
-	$expiration_date = date_i18n( get_option( 'date_format' ), time() + $expiration );
606
+	$expiration      = apply_filters('wp_privacy_export_expiration', 3 * DAY_IN_SECONDS);
607
+	$expiration_date = date_i18n(get_option('date_format'), time() + $expiration);
608 608
 
609 609
 	$exports_url      = wp_privacy_exports_url();
610
-	$export_file_name = get_post_meta( $request_id, '_export_file_name', true );
610
+	$export_file_name = get_post_meta($request_id, '_export_file_name', true);
611 611
 	$export_file_url  = $exports_url . $export_file_name;
612 612
 
613
-	$site_name = wp_specialchars_decode( get_option( 'blogname' ), ENT_QUOTES );
613
+	$site_name = wp_specialchars_decode(get_option('blogname'), ENT_QUOTES);
614 614
 	$site_url  = home_url();
615 615
 
616 616
 	/**
@@ -622,7 +622,7 @@  discard block
 block discarded – undo
622 622
 	 * @param string          $request_email The email address of the notification recipient.
623 623
 	 * @param WP_User_Request $request       The request that is initiating the notification.
624 624
 	 */
625
-	$request_email = apply_filters( 'wp_privacy_personal_data_email_to', $request->email, $request );
625
+	$request_email = apply_filters('wp_privacy_personal_data_email_to', $request->email, $request);
626 626
 
627 627
 	$email_data = array(
628 628
 		'request'           => $request,
@@ -635,7 +635,7 @@  discard block
 block discarded – undo
635 635
 	);
636 636
 
637 637
 	/* translators: Personal data export notification email subject. %s: Site title. */
638
-	$subject = sprintf( __( '[%s] Personal Data Export' ), $site_name );
638
+	$subject = sprintf(__('[%s] Personal Data Export'), $site_name);
639 639
 
640 640
 	/**
641 641
 	 * Filters the subject of the email sent when an export request is completed.
@@ -658,7 +658,7 @@  discard block
 block discarded – undo
658 658
 	 *     @type string          $siteurl           The site URL sending the mail.
659 659
 	 * }
660 660
 	 */
661
-	$subject = apply_filters( 'wp_privacy_personal_data_email_subject', $subject, $site_name, $email_data );
661
+	$subject = apply_filters('wp_privacy_personal_data_email_subject', $subject, $site_name, $email_data);
662 662
 
663 663
 	/* translators: Do not translate EXPIRATION, LINK, SITENAME, SITEURL: those are placeholders. */
664 664
 	$email_text = __(
@@ -703,13 +703,13 @@  discard block
 block discarded – undo
703 703
 	 *     @type string          $sitename          The site name sending the mail.
704 704
 	 *     @type string          $siteurl           The site URL sending the mail.
705 705
 	 */
706
-	$content = apply_filters( 'wp_privacy_personal_data_email_content', $email_text, $request_id, $email_data );
706
+	$content = apply_filters('wp_privacy_personal_data_email_content', $email_text, $request_id, $email_data);
707 707
 
708
-	$content = str_replace( '###EXPIRATION###', $expiration_date, $content );
709
-	$content = str_replace( '###LINK###', esc_url_raw( $export_file_url ), $content );
710
-	$content = str_replace( '###EMAIL###', $request_email, $content );
711
-	$content = str_replace( '###SITENAME###', $site_name, $content );
712
-	$content = str_replace( '###SITEURL###', esc_url_raw( $site_url ), $content );
708
+	$content = str_replace('###EXPIRATION###', $expiration_date, $content);
709
+	$content = str_replace('###LINK###', esc_url_raw($export_file_url), $content);
710
+	$content = str_replace('###EMAIL###', $request_email, $content);
711
+	$content = str_replace('###SITENAME###', $site_name, $content);
712
+	$content = str_replace('###SITEURL###', esc_url_raw($site_url), $content);
713 713
 
714 714
 	$headers = '';
715 715
 
@@ -736,16 +736,16 @@  discard block
 block discarded – undo
736 736
 	 *     @type string          $siteurl           The site URL sending the mail.
737 737
 	 * }
738 738
 	 */
739
-	$headers = apply_filters( 'wp_privacy_personal_data_email_headers', $headers, $subject, $content, $request_id, $email_data );
739
+	$headers = apply_filters('wp_privacy_personal_data_email_headers', $headers, $subject, $content, $request_id, $email_data);
740 740
 
741
-	$mail_success = wp_mail( $request_email, $subject, $content, $headers );
741
+	$mail_success = wp_mail($request_email, $subject, $content, $headers);
742 742
 
743
-	if ( $switched_locale ) {
743
+	if ($switched_locale) {
744 744
 		restore_previous_locale();
745 745
 	}
746 746
 
747
-	if ( ! $mail_success ) {
748
-		return new WP_Error( 'privacy_email_error', __( 'Unable to send personal data export email.' ) );
747
+	if (!$mail_success) {
748
+		return new WP_Error('privacy_email_error', __('Unable to send personal data export email.'));
749 749
 	}
750 750
 
751 751
 	return true;
@@ -767,57 +767,57 @@  discard block
 block discarded – undo
767 767
  * @param string $exporter_key    The slug (key) of the exporter.
768 768
  * @return array The filtered response.
769 769
  */
770
-function wp_privacy_process_personal_data_export_page( $response, $exporter_index, $email_address, $page, $request_id, $send_as_email, $exporter_key ) {
770
+function wp_privacy_process_personal_data_export_page($response, $exporter_index, $email_address, $page, $request_id, $send_as_email, $exporter_key) {
771 771
 	/* Do some simple checks on the shape of the response from the exporter.
772 772
 	 * If the exporter response is malformed, don't attempt to consume it - let it
773 773
 	 * pass through to generate a warning to the user by default Ajax processing.
774 774
 	 */
775
-	if ( ! is_array( $response ) ) {
775
+	if (!is_array($response)) {
776 776
 		return $response;
777 777
 	}
778 778
 
779
-	if ( ! array_key_exists( 'done', $response ) ) {
779
+	if (!array_key_exists('done', $response)) {
780 780
 		return $response;
781 781
 	}
782 782
 
783
-	if ( ! array_key_exists( 'data', $response ) ) {
783
+	if (!array_key_exists('data', $response)) {
784 784
 		return $response;
785 785
 	}
786 786
 
787
-	if ( ! is_array( $response['data'] ) ) {
787
+	if (!is_array($response['data'])) {
788 788
 		return $response;
789 789
 	}
790 790
 
791 791
 	// Get the request.
792
-	$request = wp_get_user_request( $request_id );
792
+	$request = wp_get_user_request($request_id);
793 793
 
794
-	if ( ! $request || 'export_personal_data' !== $request->action_name ) {
795
-		wp_send_json_error( __( 'Invalid request ID when merging personal data to export.' ) );
794
+	if (!$request || 'export_personal_data' !== $request->action_name) {
795
+		wp_send_json_error(__('Invalid request ID when merging personal data to export.'));
796 796
 	}
797 797
 
798 798
 	$export_data = array();
799 799
 
800 800
 	// First exporter, first page? Reset the report data accumulation array.
801
-	if ( 1 === $exporter_index && 1 === $page ) {
802
-		update_post_meta( $request_id, '_export_data_raw', $export_data );
801
+	if (1 === $exporter_index && 1 === $page) {
802
+		update_post_meta($request_id, '_export_data_raw', $export_data);
803 803
 	} else {
804
-		$accumulated_data = get_post_meta( $request_id, '_export_data_raw', true );
804
+		$accumulated_data = get_post_meta($request_id, '_export_data_raw', true);
805 805
 
806
-		if ( $accumulated_data ) {
806
+		if ($accumulated_data) {
807 807
 			$export_data = $accumulated_data;
808 808
 		}
809 809
 	}
810 810
 
811 811
 	// Now, merge the data from the exporter response into the data we have accumulated already.
812
-	$export_data = array_merge( $export_data, $response['data'] );
813
-	update_post_meta( $request_id, '_export_data_raw', $export_data );
812
+	$export_data = array_merge($export_data, $response['data']);
813
+	update_post_meta($request_id, '_export_data_raw', $export_data);
814 814
 
815 815
 	// If we are not yet on the last page of the last exporter, return now.
816 816
 	/** This filter is documented in wp-admin/includes/ajax-actions.php */
817
-	$exporters        = apply_filters( 'wp_privacy_personal_data_exporters', array() );
818
-	$is_last_exporter = count( $exporters ) === $exporter_index;
817
+	$exporters        = apply_filters('wp_privacy_personal_data_exporters', array());
818
+	$is_last_exporter = count($exporters) === $exporter_index;
819 819
 	$exporter_done    = $response['done'];
820
-	if ( ! $is_last_exporter || ! $exporter_done ) {
820
+	if (!$is_last_exporter || !$exporter_done) {
821 821
 		return $response;
822 822
 	}
823 823
 
@@ -825,17 +825,17 @@  discard block
 block discarded – undo
825 825
 
826 826
 	// First we need to re-organize the raw data hierarchically in groups and items.
827 827
 	$groups = array();
828
-	foreach ( (array) $export_data as $export_datum ) {
828
+	foreach ((array) $export_data as $export_datum) {
829 829
 		$group_id    = $export_datum['group_id'];
830 830
 		$group_label = $export_datum['group_label'];
831 831
 
832 832
 		$group_description = '';
833
-		if ( ! empty( $export_datum['group_description'] ) ) {
833
+		if (!empty($export_datum['group_description'])) {
834 834
 			$group_description = $export_datum['group_description'];
835 835
 		}
836 836
 
837
-		if ( ! array_key_exists( $group_id, $groups ) ) {
838
-			$groups[ $group_id ] = array(
837
+		if (!array_key_exists($group_id, $groups)) {
838
+			$groups[$group_id] = array(
839 839
 				'group_label'       => $group_label,
840 840
 				'group_description' => $group_description,
841 841
 				'items'             => array(),
@@ -843,18 +843,18 @@  discard block
 block discarded – undo
843 843
 		}
844 844
 
845 845
 		$item_id = $export_datum['item_id'];
846
-		if ( ! array_key_exists( $item_id, $groups[ $group_id ]['items'] ) ) {
847
-			$groups[ $group_id ]['items'][ $item_id ] = array();
846
+		if (!array_key_exists($item_id, $groups[$group_id]['items'])) {
847
+			$groups[$group_id]['items'][$item_id] = array();
848 848
 		}
849 849
 
850
-		$old_item_data                            = $groups[ $group_id ]['items'][ $item_id ];
851
-		$merged_item_data                         = array_merge( $export_datum['data'], $old_item_data );
852
-		$groups[ $group_id ]['items'][ $item_id ] = $merged_item_data;
850
+		$old_item_data                            = $groups[$group_id]['items'][$item_id];
851
+		$merged_item_data                         = array_merge($export_datum['data'], $old_item_data);
852
+		$groups[$group_id]['items'][$item_id] = $merged_item_data;
853 853
 	}
854 854
 
855 855
 	// Then save the grouped data into the request.
856
-	delete_post_meta( $request_id, '_export_data_raw' );
857
-	update_post_meta( $request_id, '_export_data_grouped', $groups );
856
+	delete_post_meta($request_id, '_export_data_raw');
857
+	update_post_meta($request_id, '_export_data_grouped', $groups);
858 858
 
859 859
 	/**
860 860
 	 * Generate the export file from the collected, grouped personal data.
@@ -863,27 +863,27 @@  discard block
 block discarded – undo
863 863
 	 *
864 864
 	 * @param int $request_id The export request ID.
865 865
 	 */
866
-	do_action( 'wp_privacy_personal_data_export_file', $request_id );
866
+	do_action('wp_privacy_personal_data_export_file', $request_id);
867 867
 
868 868
 	// Clear the grouped data now that it is no longer needed.
869
-	delete_post_meta( $request_id, '_export_data_grouped' );
869
+	delete_post_meta($request_id, '_export_data_grouped');
870 870
 
871 871
 	// If the destination is email, send it now.
872
-	if ( $send_as_email ) {
873
-		$mail_success = wp_privacy_send_personal_data_export_email( $request_id );
874
-		if ( is_wp_error( $mail_success ) ) {
875
-			wp_send_json_error( $mail_success->get_error_message() );
872
+	if ($send_as_email) {
873
+		$mail_success = wp_privacy_send_personal_data_export_email($request_id);
874
+		if (is_wp_error($mail_success)) {
875
+			wp_send_json_error($mail_success->get_error_message());
876 876
 		}
877 877
 
878 878
 		// Update the request to completed state when the export email is sent.
879
-		_wp_privacy_completed_request( $request_id );
879
+		_wp_privacy_completed_request($request_id);
880 880
 	} else {
881 881
 		// Modify the response to include the URL of the export file so the browser can fetch it.
882 882
 		$exports_url      = wp_privacy_exports_url();
883
-		$export_file_name = get_post_meta( $request_id, '_export_file_name', true );
883
+		$export_file_name = get_post_meta($request_id, '_export_file_name', true);
884 884
 		$export_file_url  = $exports_url . $export_file_name;
885 885
 
886
-		if ( ! empty( $export_file_url ) ) {
886
+		if (!empty($export_file_url)) {
887 887
 			$response['url'] = $export_file_url;
888 888
 		}
889 889
 	}
@@ -913,49 +913,49 @@  discard block
 block discarded – undo
913 913
  * @param int    $request_id    The request ID for this personal data erasure.
914 914
  * @return array The filtered response.
915 915
  */
916
-function wp_privacy_process_personal_data_erasure_page( $response, $eraser_index, $email_address, $page, $request_id ) {
916
+function wp_privacy_process_personal_data_erasure_page($response, $eraser_index, $email_address, $page, $request_id) {
917 917
 	/*
918 918
 	 * If the eraser response is malformed, don't attempt to consume it; let it
919 919
 	 * pass through, so that the default Ajax processing will generate a warning
920 920
 	 * to the user.
921 921
 	 */
922
-	if ( ! is_array( $response ) ) {
922
+	if (!is_array($response)) {
923 923
 		return $response;
924 924
 	}
925 925
 
926
-	if ( ! array_key_exists( 'done', $response ) ) {
926
+	if (!array_key_exists('done', $response)) {
927 927
 		return $response;
928 928
 	}
929 929
 
930
-	if ( ! array_key_exists( 'items_removed', $response ) ) {
930
+	if (!array_key_exists('items_removed', $response)) {
931 931
 		return $response;
932 932
 	}
933 933
 
934
-	if ( ! array_key_exists( 'items_retained', $response ) ) {
934
+	if (!array_key_exists('items_retained', $response)) {
935 935
 		return $response;
936 936
 	}
937 937
 
938
-	if ( ! array_key_exists( 'messages', $response ) ) {
938
+	if (!array_key_exists('messages', $response)) {
939 939
 		return $response;
940 940
 	}
941 941
 
942 942
 	// Get the request.
943
-	$request = wp_get_user_request( $request_id );
943
+	$request = wp_get_user_request($request_id);
944 944
 
945
-	if ( ! $request || 'remove_personal_data' !== $request->action_name ) {
946
-		wp_send_json_error( __( 'Invalid request ID when processing personal data to erase.' ) );
945
+	if (!$request || 'remove_personal_data' !== $request->action_name) {
946
+		wp_send_json_error(__('Invalid request ID when processing personal data to erase.'));
947 947
 	}
948 948
 
949 949
 	/** This filter is documented in wp-admin/includes/ajax-actions.php */
950
-	$erasers        = apply_filters( 'wp_privacy_personal_data_erasers', array() );
951
-	$is_last_eraser = count( $erasers ) === $eraser_index;
950
+	$erasers        = apply_filters('wp_privacy_personal_data_erasers', array());
951
+	$is_last_eraser = count($erasers) === $eraser_index;
952 952
 	$eraser_done    = $response['done'];
953 953
 
954
-	if ( ! $is_last_eraser || ! $eraser_done ) {
954
+	if (!$is_last_eraser || !$eraser_done) {
955 955
 		return $response;
956 956
 	}
957 957
 
958
-	_wp_privacy_completed_request( $request_id );
958
+	_wp_privacy_completed_request($request_id);
959 959
 
960 960
 	/**
961 961
 	 * Fires immediately after a personal data erasure request has been marked completed.
@@ -964,7 +964,7 @@  discard block
 block discarded – undo
964 964
 	 *
965 965
 	 * @param int $request_id The privacy request post ID associated with this request.
966 966
 	 */
967
-	do_action( 'wp_privacy_personal_data_erased', $request_id );
967
+	do_action('wp_privacy_personal_data_erased', $request_id);
968 968
 
969 969
 	return $response;
970 970
 }
Please login to merge, or discard this patch.
brighty/wp-admin/includes/user.php 2 patches
Indentation   +463 added lines, -463 removed lines patch added patch discarded remove patch
@@ -14,7 +14,7 @@  discard block
 block discarded – undo
14 14
  * @return int|WP_Error WP_Error or User ID.
15 15
  */
16 16
 function add_user() {
17
-	return edit_user();
17
+    return edit_user();
18 18
 }
19 19
 
20 20
 /**
@@ -28,219 +28,219 @@  discard block
 block discarded – undo
28 28
  * @return int|WP_Error User ID of the updated user or WP_Error on failure.
29 29
  */
30 30
 function edit_user( $user_id = 0 ) {
31
-	$wp_roles = wp_roles();
32
-	$user     = new stdClass;
33
-	$user_id  = (int) $user_id;
34
-	if ( $user_id ) {
35
-		$update           = true;
36
-		$user->ID         = $user_id;
37
-		$userdata         = get_userdata( $user_id );
38
-		$user->user_login = wp_slash( $userdata->user_login );
39
-	} else {
40
-		$update = false;
41
-	}
42
-
43
-	if ( ! $update && isset( $_POST['user_login'] ) ) {
44
-		$user->user_login = sanitize_user( wp_unslash( $_POST['user_login'] ), true );
45
-	}
46
-
47
-	$pass1 = '';
48
-	$pass2 = '';
49
-	if ( isset( $_POST['pass1'] ) ) {
50
-		$pass1 = trim( $_POST['pass1'] );
51
-	}
52
-	if ( isset( $_POST['pass2'] ) ) {
53
-		$pass2 = trim( $_POST['pass2'] );
54
-	}
55
-
56
-	if ( isset( $_POST['role'] ) && current_user_can( 'promote_users' ) && ( ! $user_id || current_user_can( 'promote_user', $user_id ) ) ) {
57
-		$new_role = sanitize_text_field( $_POST['role'] );
58
-
59
-		// If the new role isn't editable by the logged-in user die with error.
60
-		$editable_roles = get_editable_roles();
61
-		if ( ! empty( $new_role ) && empty( $editable_roles[ $new_role ] ) ) {
62
-			wp_die( __( 'Sorry, you are not allowed to give users that role.' ), 403 );
63
-		}
64
-
65
-		$potential_role = isset( $wp_roles->role_objects[ $new_role ] ) ? $wp_roles->role_objects[ $new_role ] : false;
66
-
67
-		/*
31
+    $wp_roles = wp_roles();
32
+    $user     = new stdClass;
33
+    $user_id  = (int) $user_id;
34
+    if ( $user_id ) {
35
+        $update           = true;
36
+        $user->ID         = $user_id;
37
+        $userdata         = get_userdata( $user_id );
38
+        $user->user_login = wp_slash( $userdata->user_login );
39
+    } else {
40
+        $update = false;
41
+    }
42
+
43
+    if ( ! $update && isset( $_POST['user_login'] ) ) {
44
+        $user->user_login = sanitize_user( wp_unslash( $_POST['user_login'] ), true );
45
+    }
46
+
47
+    $pass1 = '';
48
+    $pass2 = '';
49
+    if ( isset( $_POST['pass1'] ) ) {
50
+        $pass1 = trim( $_POST['pass1'] );
51
+    }
52
+    if ( isset( $_POST['pass2'] ) ) {
53
+        $pass2 = trim( $_POST['pass2'] );
54
+    }
55
+
56
+    if ( isset( $_POST['role'] ) && current_user_can( 'promote_users' ) && ( ! $user_id || current_user_can( 'promote_user', $user_id ) ) ) {
57
+        $new_role = sanitize_text_field( $_POST['role'] );
58
+
59
+        // If the new role isn't editable by the logged-in user die with error.
60
+        $editable_roles = get_editable_roles();
61
+        if ( ! empty( $new_role ) && empty( $editable_roles[ $new_role ] ) ) {
62
+            wp_die( __( 'Sorry, you are not allowed to give users that role.' ), 403 );
63
+        }
64
+
65
+        $potential_role = isset( $wp_roles->role_objects[ $new_role ] ) ? $wp_roles->role_objects[ $new_role ] : false;
66
+
67
+        /*
68 68
 		 * Don't let anyone with 'promote_users' edit their own role to something without it.
69 69
 		 * Multisite super admins can freely edit their roles, they possess all caps.
70 70
 		 */
71
-		if (
72
-			( is_multisite() && current_user_can( 'manage_network_users' ) ) ||
73
-			get_current_user_id() !== $user_id ||
74
-			( $potential_role && $potential_role->has_cap( 'promote_users' ) )
75
-		) {
76
-			$user->role = $new_role;
77
-		}
78
-	}
79
-
80
-	if ( isset( $_POST['email'] ) ) {
81
-		$user->user_email = sanitize_text_field( wp_unslash( $_POST['email'] ) );
82
-	}
83
-	if ( isset( $_POST['url'] ) ) {
84
-		if ( empty( $_POST['url'] ) || 'http://' === $_POST['url'] ) {
85
-			$user->user_url = '';
86
-		} else {
87
-			$user->user_url = esc_url_raw( $_POST['url'] );
88
-			$protocols      = implode( '|', array_map( 'preg_quote', wp_allowed_protocols() ) );
89
-			$user->user_url = preg_match( '/^(' . $protocols . '):/is', $user->user_url ) ? $user->user_url : 'http://' . $user->user_url;
90
-		}
91
-	}
92
-	if ( isset( $_POST['first_name'] ) ) {
93
-		$user->first_name = sanitize_text_field( $_POST['first_name'] );
94
-	}
95
-	if ( isset( $_POST['last_name'] ) ) {
96
-		$user->last_name = sanitize_text_field( $_POST['last_name'] );
97
-	}
98
-	if ( isset( $_POST['nickname'] ) ) {
99
-		$user->nickname = sanitize_text_field( $_POST['nickname'] );
100
-	}
101
-	if ( isset( $_POST['display_name'] ) ) {
102
-		$user->display_name = sanitize_text_field( $_POST['display_name'] );
103
-	}
104
-
105
-	if ( isset( $_POST['description'] ) ) {
106
-		$user->description = trim( $_POST['description'] );
107
-	}
108
-
109
-	foreach ( wp_get_user_contact_methods( $user ) as $method => $name ) {
110
-		if ( isset( $_POST[ $method ] ) ) {
111
-			$user->$method = sanitize_text_field( $_POST[ $method ] );
112
-		}
113
-	}
114
-
115
-	if ( isset( $_POST['locale'] ) ) {
116
-		$locale = sanitize_text_field( $_POST['locale'] );
117
-		if ( 'site-default' === $locale ) {
118
-			$locale = '';
119
-		} elseif ( '' === $locale ) {
120
-			$locale = 'en_US';
121
-		} elseif ( ! in_array( $locale, get_available_languages(), true ) ) {
122
-			$locale = '';
123
-		}
124
-
125
-		$user->locale = $locale;
126
-	}
127
-
128
-	if ( $update ) {
129
-		$user->rich_editing         = isset( $_POST['rich_editing'] ) && 'false' === $_POST['rich_editing'] ? 'false' : 'true';
130
-		$user->syntax_highlighting  = isset( $_POST['syntax_highlighting'] ) && 'false' === $_POST['syntax_highlighting'] ? 'false' : 'true';
131
-		$user->admin_color          = isset( $_POST['admin_color'] ) ? sanitize_text_field( $_POST['admin_color'] ) : 'fresh';
132
-		$user->show_admin_bar_front = isset( $_POST['admin_bar_front'] ) ? 'true' : 'false';
133
-	}
134
-
135
-	$user->comment_shortcuts = isset( $_POST['comment_shortcuts'] ) && 'true' === $_POST['comment_shortcuts'] ? 'true' : '';
136
-
137
-	$user->use_ssl = 0;
138
-	if ( ! empty( $_POST['use_ssl'] ) ) {
139
-		$user->use_ssl = 1;
140
-	}
141
-
142
-	$errors = new WP_Error();
143
-
144
-	/* checking that username has been typed */
145
-	if ( '' === $user->user_login ) {
146
-		$errors->add( 'user_login', __( '<strong>Error</strong>: Please enter a username.' ) );
147
-	}
148
-
149
-	/* checking that nickname has been typed */
150
-	if ( $update && empty( $user->nickname ) ) {
151
-		$errors->add( 'nickname', __( '<strong>Error</strong>: Please enter a nickname.' ) );
152
-	}
153
-
154
-	/**
155
-	 * Fires before the password and confirm password fields are checked for congruity.
156
-	 *
157
-	 * @since 1.5.1
158
-	 *
159
-	 * @param string $user_login The username.
160
-	 * @param string $pass1     The password (passed by reference).
161
-	 * @param string $pass2     The confirmed password (passed by reference).
162
-	 */
163
-	do_action_ref_array( 'check_passwords', array( $user->user_login, &$pass1, &$pass2 ) );
164
-
165
-	// Check for blank password when adding a user.
166
-	if ( ! $update && empty( $pass1 ) ) {
167
-		$errors->add( 'pass', __( '<strong>Error</strong>: Please enter a password.' ), array( 'form-field' => 'pass1' ) );
168
-	}
169
-
170
-	// Check for "\" in password.
171
-	if ( false !== strpos( wp_unslash( $pass1 ), '\\' ) ) {
172
-		$errors->add( 'pass', __( '<strong>Error</strong>: Passwords may not contain the character "\\".' ), array( 'form-field' => 'pass1' ) );
173
-	}
174
-
175
-	// Checking the password has been typed twice the same.
176
-	if ( ( $update || ! empty( $pass1 ) ) && $pass1 != $pass2 ) {
177
-		$errors->add( 'pass', __( '<strong>Error</strong>: Passwords do not match. Please enter the same password in both password fields.' ), array( 'form-field' => 'pass1' ) );
178
-	}
179
-
180
-	if ( ! empty( $pass1 ) ) {
181
-		$user->user_pass = $pass1;
182
-	}
183
-
184
-	if ( ! $update && isset( $_POST['user_login'] ) && ! validate_username( $_POST['user_login'] ) ) {
185
-		$errors->add( 'user_login', __( '<strong>Error</strong>: This username is invalid because it uses illegal characters. Please enter a valid username.' ) );
186
-	}
187
-
188
-	if ( ! $update && username_exists( $user->user_login ) ) {
189
-		$errors->add( 'user_login', __( '<strong>Error</strong>: This username is already registered. Please choose another one.' ) );
190
-	}
191
-
192
-	/** This filter is documented in wp-includes/user.php */
193
-	$illegal_logins = (array) apply_filters( 'illegal_user_logins', array() );
194
-
195
-	if ( in_array( strtolower( $user->user_login ), array_map( 'strtolower', $illegal_logins ), true ) ) {
196
-		$errors->add( 'invalid_username', __( '<strong>Error</strong>: Sorry, that username is not allowed.' ) );
197
-	}
198
-
199
-	/* checking email address */
200
-	if ( empty( $user->user_email ) ) {
201
-		$errors->add( 'empty_email', __( '<strong>Error</strong>: Please enter an email address.' ), array( 'form-field' => 'email' ) );
202
-	} elseif ( ! is_email( $user->user_email ) ) {
203
-		$errors->add( 'invalid_email', __( '<strong>Error</strong>: The email address is not correct.' ), array( 'form-field' => 'email' ) );
204
-	} else {
205
-		$owner_id = email_exists( $user->user_email );
206
-		if ( $owner_id && ( ! $update || ( $owner_id != $user->ID ) ) ) {
207
-			$errors->add( 'email_exists', __( '<strong>Error</strong>: This email is already registered. Please choose another one.' ), array( 'form-field' => 'email' ) );
208
-		}
209
-	}
210
-
211
-	/**
212
-	 * Fires before user profile update errors are returned.
213
-	 *
214
-	 * @since 2.8.0
215
-	 *
216
-	 * @param WP_Error $errors WP_Error object (passed by reference).
217
-	 * @param bool     $update Whether this is a user update.
218
-	 * @param stdClass $user   User object (passed by reference).
219
-	 */
220
-	do_action_ref_array( 'user_profile_update_errors', array( &$errors, $update, &$user ) );
221
-
222
-	if ( $errors->has_errors() ) {
223
-		return $errors;
224
-	}
225
-
226
-	if ( $update ) {
227
-		$user_id = wp_update_user( $user );
228
-	} else {
229
-		$user_id = wp_insert_user( $user );
230
-		$notify  = isset( $_POST['send_user_notification'] ) ? 'both' : 'admin';
231
-
232
-		/**
233
-		 * Fires after a new user has been created.
234
-		 *
235
-		 * @since 4.4.0
236
-		 *
237
-		 * @param int|WP_Error $user_id ID of the newly created user or WP_Error on failure.
238
-		 * @param string       $notify  Type of notification that should happen. See
239
-		 *                              wp_send_new_user_notifications() for more information.
240
-		 */
241
-		do_action( 'edit_user_created_user', $user_id, $notify );
242
-	}
243
-	return $user_id;
71
+        if (
72
+            ( is_multisite() && current_user_can( 'manage_network_users' ) ) ||
73
+            get_current_user_id() !== $user_id ||
74
+            ( $potential_role && $potential_role->has_cap( 'promote_users' ) )
75
+        ) {
76
+            $user->role = $new_role;
77
+        }
78
+    }
79
+
80
+    if ( isset( $_POST['email'] ) ) {
81
+        $user->user_email = sanitize_text_field( wp_unslash( $_POST['email'] ) );
82
+    }
83
+    if ( isset( $_POST['url'] ) ) {
84
+        if ( empty( $_POST['url'] ) || 'http://' === $_POST['url'] ) {
85
+            $user->user_url = '';
86
+        } else {
87
+            $user->user_url = esc_url_raw( $_POST['url'] );
88
+            $protocols      = implode( '|', array_map( 'preg_quote', wp_allowed_protocols() ) );
89
+            $user->user_url = preg_match( '/^(' . $protocols . '):/is', $user->user_url ) ? $user->user_url : 'http://' . $user->user_url;
90
+        }
91
+    }
92
+    if ( isset( $_POST['first_name'] ) ) {
93
+        $user->first_name = sanitize_text_field( $_POST['first_name'] );
94
+    }
95
+    if ( isset( $_POST['last_name'] ) ) {
96
+        $user->last_name = sanitize_text_field( $_POST['last_name'] );
97
+    }
98
+    if ( isset( $_POST['nickname'] ) ) {
99
+        $user->nickname = sanitize_text_field( $_POST['nickname'] );
100
+    }
101
+    if ( isset( $_POST['display_name'] ) ) {
102
+        $user->display_name = sanitize_text_field( $_POST['display_name'] );
103
+    }
104
+
105
+    if ( isset( $_POST['description'] ) ) {
106
+        $user->description = trim( $_POST['description'] );
107
+    }
108
+
109
+    foreach ( wp_get_user_contact_methods( $user ) as $method => $name ) {
110
+        if ( isset( $_POST[ $method ] ) ) {
111
+            $user->$method = sanitize_text_field( $_POST[ $method ] );
112
+        }
113
+    }
114
+
115
+    if ( isset( $_POST['locale'] ) ) {
116
+        $locale = sanitize_text_field( $_POST['locale'] );
117
+        if ( 'site-default' === $locale ) {
118
+            $locale = '';
119
+        } elseif ( '' === $locale ) {
120
+            $locale = 'en_US';
121
+        } elseif ( ! in_array( $locale, get_available_languages(), true ) ) {
122
+            $locale = '';
123
+        }
124
+
125
+        $user->locale = $locale;
126
+    }
127
+
128
+    if ( $update ) {
129
+        $user->rich_editing         = isset( $_POST['rich_editing'] ) && 'false' === $_POST['rich_editing'] ? 'false' : 'true';
130
+        $user->syntax_highlighting  = isset( $_POST['syntax_highlighting'] ) && 'false' === $_POST['syntax_highlighting'] ? 'false' : 'true';
131
+        $user->admin_color          = isset( $_POST['admin_color'] ) ? sanitize_text_field( $_POST['admin_color'] ) : 'fresh';
132
+        $user->show_admin_bar_front = isset( $_POST['admin_bar_front'] ) ? 'true' : 'false';
133
+    }
134
+
135
+    $user->comment_shortcuts = isset( $_POST['comment_shortcuts'] ) && 'true' === $_POST['comment_shortcuts'] ? 'true' : '';
136
+
137
+    $user->use_ssl = 0;
138
+    if ( ! empty( $_POST['use_ssl'] ) ) {
139
+        $user->use_ssl = 1;
140
+    }
141
+
142
+    $errors = new WP_Error();
143
+
144
+    /* checking that username has been typed */
145
+    if ( '' === $user->user_login ) {
146
+        $errors->add( 'user_login', __( '<strong>Error</strong>: Please enter a username.' ) );
147
+    }
148
+
149
+    /* checking that nickname has been typed */
150
+    if ( $update && empty( $user->nickname ) ) {
151
+        $errors->add( 'nickname', __( '<strong>Error</strong>: Please enter a nickname.' ) );
152
+    }
153
+
154
+    /**
155
+     * Fires before the password and confirm password fields are checked for congruity.
156
+     *
157
+     * @since 1.5.1
158
+     *
159
+     * @param string $user_login The username.
160
+     * @param string $pass1     The password (passed by reference).
161
+     * @param string $pass2     The confirmed password (passed by reference).
162
+     */
163
+    do_action_ref_array( 'check_passwords', array( $user->user_login, &$pass1, &$pass2 ) );
164
+
165
+    // Check for blank password when adding a user.
166
+    if ( ! $update && empty( $pass1 ) ) {
167
+        $errors->add( 'pass', __( '<strong>Error</strong>: Please enter a password.' ), array( 'form-field' => 'pass1' ) );
168
+    }
169
+
170
+    // Check for "\" in password.
171
+    if ( false !== strpos( wp_unslash( $pass1 ), '\\' ) ) {
172
+        $errors->add( 'pass', __( '<strong>Error</strong>: Passwords may not contain the character "\\".' ), array( 'form-field' => 'pass1' ) );
173
+    }
174
+
175
+    // Checking the password has been typed twice the same.
176
+    if ( ( $update || ! empty( $pass1 ) ) && $pass1 != $pass2 ) {
177
+        $errors->add( 'pass', __( '<strong>Error</strong>: Passwords do not match. Please enter the same password in both password fields.' ), array( 'form-field' => 'pass1' ) );
178
+    }
179
+
180
+    if ( ! empty( $pass1 ) ) {
181
+        $user->user_pass = $pass1;
182
+    }
183
+
184
+    if ( ! $update && isset( $_POST['user_login'] ) && ! validate_username( $_POST['user_login'] ) ) {
185
+        $errors->add( 'user_login', __( '<strong>Error</strong>: This username is invalid because it uses illegal characters. Please enter a valid username.' ) );
186
+    }
187
+
188
+    if ( ! $update && username_exists( $user->user_login ) ) {
189
+        $errors->add( 'user_login', __( '<strong>Error</strong>: This username is already registered. Please choose another one.' ) );
190
+    }
191
+
192
+    /** This filter is documented in wp-includes/user.php */
193
+    $illegal_logins = (array) apply_filters( 'illegal_user_logins', array() );
194
+
195
+    if ( in_array( strtolower( $user->user_login ), array_map( 'strtolower', $illegal_logins ), true ) ) {
196
+        $errors->add( 'invalid_username', __( '<strong>Error</strong>: Sorry, that username is not allowed.' ) );
197
+    }
198
+
199
+    /* checking email address */
200
+    if ( empty( $user->user_email ) ) {
201
+        $errors->add( 'empty_email', __( '<strong>Error</strong>: Please enter an email address.' ), array( 'form-field' => 'email' ) );
202
+    } elseif ( ! is_email( $user->user_email ) ) {
203
+        $errors->add( 'invalid_email', __( '<strong>Error</strong>: The email address is not correct.' ), array( 'form-field' => 'email' ) );
204
+    } else {
205
+        $owner_id = email_exists( $user->user_email );
206
+        if ( $owner_id && ( ! $update || ( $owner_id != $user->ID ) ) ) {
207
+            $errors->add( 'email_exists', __( '<strong>Error</strong>: This email is already registered. Please choose another one.' ), array( 'form-field' => 'email' ) );
208
+        }
209
+    }
210
+
211
+    /**
212
+     * Fires before user profile update errors are returned.
213
+     *
214
+     * @since 2.8.0
215
+     *
216
+     * @param WP_Error $errors WP_Error object (passed by reference).
217
+     * @param bool     $update Whether this is a user update.
218
+     * @param stdClass $user   User object (passed by reference).
219
+     */
220
+    do_action_ref_array( 'user_profile_update_errors', array( &$errors, $update, &$user ) );
221
+
222
+    if ( $errors->has_errors() ) {
223
+        return $errors;
224
+    }
225
+
226
+    if ( $update ) {
227
+        $user_id = wp_update_user( $user );
228
+    } else {
229
+        $user_id = wp_insert_user( $user );
230
+        $notify  = isset( $_POST['send_user_notification'] ) ? 'both' : 'admin';
231
+
232
+        /**
233
+         * Fires after a new user has been created.
234
+         *
235
+         * @since 4.4.0
236
+         *
237
+         * @param int|WP_Error $user_id ID of the newly created user or WP_Error on failure.
238
+         * @param string       $notify  Type of notification that should happen. See
239
+         *                              wp_send_new_user_notifications() for more information.
240
+         */
241
+        do_action( 'edit_user_created_user', $user_id, $notify );
242
+    }
243
+    return $user_id;
244 244
 }
245 245
 
246 246
 /**
@@ -260,18 +260,18 @@  discard block
 block discarded – undo
260 260
  * @return array[] Array of arrays containing role information.
261 261
  */
262 262
 function get_editable_roles() {
263
-	$all_roles = wp_roles()->roles;
264
-
265
-	/**
266
-	 * Filters the list of editable roles.
267
-	 *
268
-	 * @since 2.8.0
269
-	 *
270
-	 * @param array[] $all_roles Array of arrays containing role information.
271
-	 */
272
-	$editable_roles = apply_filters( 'editable_roles', $all_roles );
273
-
274
-	return $editable_roles;
263
+    $all_roles = wp_roles()->roles;
264
+
265
+    /**
266
+     * Filters the list of editable roles.
267
+     *
268
+     * @since 2.8.0
269
+     *
270
+     * @param array[] $all_roles Array of arrays containing role information.
271
+     */
272
+    $editable_roles = apply_filters( 'editable_roles', $all_roles );
273
+
274
+    return $editable_roles;
275 275
 }
276 276
 
277 277
 /**
@@ -283,13 +283,13 @@  discard block
 block discarded – undo
283 283
  * @return WP_User|false WP_User object on success, false on failure.
284 284
  */
285 285
 function get_user_to_edit( $user_id ) {
286
-	$user = get_userdata( $user_id );
286
+    $user = get_userdata( $user_id );
287 287
 
288
-	if ( $user ) {
289
-		$user->filter = 'edit';
290
-	}
288
+    if ( $user ) {
289
+        $user->filter = 'edit';
290
+    }
291 291
 
292
-	return $user;
292
+    return $user;
293 293
 }
294 294
 
295 295
 /**
@@ -303,18 +303,18 @@  discard block
 block discarded – undo
303 303
  * @return array
304 304
  */
305 305
 function get_users_drafts( $user_id ) {
306
-	global $wpdb;
307
-	$query = $wpdb->prepare( "SELECT ID, post_title FROM $wpdb->posts WHERE post_type = 'post' AND post_status = 'draft' AND post_author = %d ORDER BY post_modified DESC", $user_id );
308
-
309
-	/**
310
-	 * Filters the user's drafts query string.
311
-	 *
312
-	 * @since 2.0.0
313
-	 *
314
-	 * @param string $query The user's drafts query string.
315
-	 */
316
-	$query = apply_filters( 'get_users_drafts', $query );
317
-	return $wpdb->get_results( $query );
306
+    global $wpdb;
307
+    $query = $wpdb->prepare( "SELECT ID, post_title FROM $wpdb->posts WHERE post_type = 'post' AND post_status = 'draft' AND post_author = %d ORDER BY post_modified DESC", $user_id );
308
+
309
+    /**
310
+     * Filters the user's drafts query string.
311
+     *
312
+     * @since 2.0.0
313
+     *
314
+     * @param string $query The user's drafts query string.
315
+     */
316
+    $query = apply_filters( 'get_users_drafts', $query );
317
+    return $wpdb->get_results( $query );
318 318
 }
319 319
 
320 320
 /**
@@ -334,119 +334,119 @@  discard block
 block discarded – undo
334 334
  * @return bool True when finished.
335 335
  */
336 336
 function wp_delete_user( $id, $reassign = null ) {
337
-	global $wpdb;
338
-
339
-	if ( ! is_numeric( $id ) ) {
340
-		return false;
341
-	}
342
-
343
-	$id   = (int) $id;
344
-	$user = new WP_User( $id );
345
-
346
-	if ( ! $user->exists() ) {
347
-		return false;
348
-	}
349
-
350
-	// Normalize $reassign to null or a user ID. 'novalue' was an older default.
351
-	if ( 'novalue' === $reassign ) {
352
-		$reassign = null;
353
-	} elseif ( null !== $reassign ) {
354
-		$reassign = (int) $reassign;
355
-	}
356
-
357
-	/**
358
-	 * Fires immediately before a user is deleted from the database.
359
-	 *
360
-	 * @since 2.0.0
361
-	 * @since 5.5.0 Added the `$user` parameter.
362
-	 *
363
-	 * @param int      $id       ID of the user to delete.
364
-	 * @param int|null $reassign ID of the user to reassign posts and links to.
365
-	 *                           Default null, for no reassignment.
366
-	 * @param WP_User  $user     WP_User object of the user to delete.
367
-	 */
368
-	do_action( 'delete_user', $id, $reassign, $user );
369
-
370
-	if ( null === $reassign ) {
371
-		$post_types_to_delete = array();
372
-		foreach ( get_post_types( array(), 'objects' ) as $post_type ) {
373
-			if ( $post_type->delete_with_user ) {
374
-				$post_types_to_delete[] = $post_type->name;
375
-			} elseif ( null === $post_type->delete_with_user && post_type_supports( $post_type->name, 'author' ) ) {
376
-				$post_types_to_delete[] = $post_type->name;
377
-			}
378
-		}
379
-
380
-		/**
381
-		 * Filters the list of post types to delete with a user.
382
-		 *
383
-		 * @since 3.4.0
384
-		 *
385
-		 * @param string[] $post_types_to_delete Array of post types to delete.
386
-		 * @param int      $id                   User ID.
387
-		 */
388
-		$post_types_to_delete = apply_filters( 'post_types_to_delete_with_user', $post_types_to_delete, $id );
389
-		$post_types_to_delete = implode( "', '", $post_types_to_delete );
390
-		$post_ids             = $wpdb->get_col( $wpdb->prepare( "SELECT ID FROM $wpdb->posts WHERE post_author = %d AND post_type IN ('$post_types_to_delete')", $id ) );
391
-		if ( $post_ids ) {
392
-			foreach ( $post_ids as $post_id ) {
393
-				wp_delete_post( $post_id );
394
-			}
395
-		}
396
-
397
-		// Clean links.
398
-		$link_ids = $wpdb->get_col( $wpdb->prepare( "SELECT link_id FROM $wpdb->links WHERE link_owner = %d", $id ) );
399
-
400
-		if ( $link_ids ) {
401
-			foreach ( $link_ids as $link_id ) {
402
-				wp_delete_link( $link_id );
403
-			}
404
-		}
405
-	} else {
406
-		$post_ids = $wpdb->get_col( $wpdb->prepare( "SELECT ID FROM $wpdb->posts WHERE post_author = %d", $id ) );
407
-		$wpdb->update( $wpdb->posts, array( 'post_author' => $reassign ), array( 'post_author' => $id ) );
408
-		if ( ! empty( $post_ids ) ) {
409
-			foreach ( $post_ids as $post_id ) {
410
-				clean_post_cache( $post_id );
411
-			}
412
-		}
413
-		$link_ids = $wpdb->get_col( $wpdb->prepare( "SELECT link_id FROM $wpdb->links WHERE link_owner = %d", $id ) );
414
-		$wpdb->update( $wpdb->links, array( 'link_owner' => $reassign ), array( 'link_owner' => $id ) );
415
-		if ( ! empty( $link_ids ) ) {
416
-			foreach ( $link_ids as $link_id ) {
417
-				clean_bookmark_cache( $link_id );
418
-			}
419
-		}
420
-	}
421
-
422
-	// FINALLY, delete user.
423
-	if ( is_multisite() ) {
424
-		remove_user_from_blog( $id, get_current_blog_id() );
425
-	} else {
426
-		$meta = $wpdb->get_col( $wpdb->prepare( "SELECT umeta_id FROM $wpdb->usermeta WHERE user_id = %d", $id ) );
427
-		foreach ( $meta as $mid ) {
428
-			delete_metadata_by_mid( 'user', $mid );
429
-		}
430
-
431
-		$wpdb->delete( $wpdb->users, array( 'ID' => $id ) );
432
-	}
433
-
434
-	clean_user_cache( $user );
435
-
436
-	/**
437
-	 * Fires immediately after a user is deleted from the database.
438
-	 *
439
-	 * @since 2.9.0
440
-	 * @since 5.5.0 Added the `$user` parameter.
441
-	 *
442
-	 * @param int      $id       ID of the deleted user.
443
-	 * @param int|null $reassign ID of the user to reassign posts and links to.
444
-	 *                           Default null, for no reassignment.
445
-	 * @param WP_User  $user     WP_User object of the deleted user.
446
-	 */
447
-	do_action( 'deleted_user', $id, $reassign, $user );
448
-
449
-	return true;
337
+    global $wpdb;
338
+
339
+    if ( ! is_numeric( $id ) ) {
340
+        return false;
341
+    }
342
+
343
+    $id   = (int) $id;
344
+    $user = new WP_User( $id );
345
+
346
+    if ( ! $user->exists() ) {
347
+        return false;
348
+    }
349
+
350
+    // Normalize $reassign to null or a user ID. 'novalue' was an older default.
351
+    if ( 'novalue' === $reassign ) {
352
+        $reassign = null;
353
+    } elseif ( null !== $reassign ) {
354
+        $reassign = (int) $reassign;
355
+    }
356
+
357
+    /**
358
+     * Fires immediately before a user is deleted from the database.
359
+     *
360
+     * @since 2.0.0
361
+     * @since 5.5.0 Added the `$user` parameter.
362
+     *
363
+     * @param int      $id       ID of the user to delete.
364
+     * @param int|null $reassign ID of the user to reassign posts and links to.
365
+     *                           Default null, for no reassignment.
366
+     * @param WP_User  $user     WP_User object of the user to delete.
367
+     */
368
+    do_action( 'delete_user', $id, $reassign, $user );
369
+
370
+    if ( null === $reassign ) {
371
+        $post_types_to_delete = array();
372
+        foreach ( get_post_types( array(), 'objects' ) as $post_type ) {
373
+            if ( $post_type->delete_with_user ) {
374
+                $post_types_to_delete[] = $post_type->name;
375
+            } elseif ( null === $post_type->delete_with_user && post_type_supports( $post_type->name, 'author' ) ) {
376
+                $post_types_to_delete[] = $post_type->name;
377
+            }
378
+        }
379
+
380
+        /**
381
+         * Filters the list of post types to delete with a user.
382
+         *
383
+         * @since 3.4.0
384
+         *
385
+         * @param string[] $post_types_to_delete Array of post types to delete.
386
+         * @param int      $id                   User ID.
387
+         */
388
+        $post_types_to_delete = apply_filters( 'post_types_to_delete_with_user', $post_types_to_delete, $id );
389
+        $post_types_to_delete = implode( "', '", $post_types_to_delete );
390
+        $post_ids             = $wpdb->get_col( $wpdb->prepare( "SELECT ID FROM $wpdb->posts WHERE post_author = %d AND post_type IN ('$post_types_to_delete')", $id ) );
391
+        if ( $post_ids ) {
392
+            foreach ( $post_ids as $post_id ) {
393
+                wp_delete_post( $post_id );
394
+            }
395
+        }
396
+
397
+        // Clean links.
398
+        $link_ids = $wpdb->get_col( $wpdb->prepare( "SELECT link_id FROM $wpdb->links WHERE link_owner = %d", $id ) );
399
+
400
+        if ( $link_ids ) {
401
+            foreach ( $link_ids as $link_id ) {
402
+                wp_delete_link( $link_id );
403
+            }
404
+        }
405
+    } else {
406
+        $post_ids = $wpdb->get_col( $wpdb->prepare( "SELECT ID FROM $wpdb->posts WHERE post_author = %d", $id ) );
407
+        $wpdb->update( $wpdb->posts, array( 'post_author' => $reassign ), array( 'post_author' => $id ) );
408
+        if ( ! empty( $post_ids ) ) {
409
+            foreach ( $post_ids as $post_id ) {
410
+                clean_post_cache( $post_id );
411
+            }
412
+        }
413
+        $link_ids = $wpdb->get_col( $wpdb->prepare( "SELECT link_id FROM $wpdb->links WHERE link_owner = %d", $id ) );
414
+        $wpdb->update( $wpdb->links, array( 'link_owner' => $reassign ), array( 'link_owner' => $id ) );
415
+        if ( ! empty( $link_ids ) ) {
416
+            foreach ( $link_ids as $link_id ) {
417
+                clean_bookmark_cache( $link_id );
418
+            }
419
+        }
420
+    }
421
+
422
+    // FINALLY, delete user.
423
+    if ( is_multisite() ) {
424
+        remove_user_from_blog( $id, get_current_blog_id() );
425
+    } else {
426
+        $meta = $wpdb->get_col( $wpdb->prepare( "SELECT umeta_id FROM $wpdb->usermeta WHERE user_id = %d", $id ) );
427
+        foreach ( $meta as $mid ) {
428
+            delete_metadata_by_mid( 'user', $mid );
429
+        }
430
+
431
+        $wpdb->delete( $wpdb->users, array( 'ID' => $id ) );
432
+    }
433
+
434
+    clean_user_cache( $user );
435
+
436
+    /**
437
+     * Fires immediately after a user is deleted from the database.
438
+     *
439
+     * @since 2.9.0
440
+     * @since 5.5.0 Added the `$user` parameter.
441
+     *
442
+     * @param int      $id       ID of the deleted user.
443
+     * @param int|null $reassign ID of the user to reassign posts and links to.
444
+     *                           Default null, for no reassignment.
445
+     * @param WP_User  $user     WP_User object of the deleted user.
446
+     */
447
+    do_action( 'deleted_user', $id, $reassign, $user );
448
+
449
+    return true;
450 450
 }
451 451
 
452 452
 /**
@@ -457,10 +457,10 @@  discard block
 block discarded – undo
457 457
  * @param int $id User ID.
458 458
  */
459 459
 function wp_revoke_user( $id ) {
460
-	$id = (int) $id;
460
+    $id = (int) $id;
461 461
 
462
-	$user = new WP_User( $id );
463
-	$user->remove_all_caps();
462
+    $user = new WP_User( $id );
463
+    $user->remove_all_caps();
464 464
 }
465 465
 
466 466
 /**
@@ -471,19 +471,19 @@  discard block
 block discarded – undo
471 471
  * @param false $errors Deprecated.
472 472
  */
473 473
 function default_password_nag_handler( $errors = false ) {
474
-	global $user_ID;
475
-	// Short-circuit it.
476
-	if ( ! get_user_option( 'default_password_nag' ) ) {
477
-		return;
478
-	}
479
-
480
-	// get_user_setting() = JS-saved UI setting. Else no-js-fallback code.
481
-	if ( 'hide' === get_user_setting( 'default_password_nag' )
482
-		|| isset( $_GET['default_password_nag'] ) && '0' == $_GET['default_password_nag']
483
-	) {
484
-		delete_user_setting( 'default_password_nag' );
485
-		update_user_meta( $user_ID, 'default_password_nag', false );
486
-	}
474
+    global $user_ID;
475
+    // Short-circuit it.
476
+    if ( ! get_user_option( 'default_password_nag' ) ) {
477
+        return;
478
+    }
479
+
480
+    // get_user_setting() = JS-saved UI setting. Else no-js-fallback code.
481
+    if ( 'hide' === get_user_setting( 'default_password_nag' )
482
+        || isset( $_GET['default_password_nag'] ) && '0' == $_GET['default_password_nag']
483
+    ) {
484
+        delete_user_setting( 'default_password_nag' );
485
+        update_user_meta( $user_ID, 'default_password_nag', false );
486
+    }
487 487
 }
488 488
 
489 489
 /**
@@ -493,18 +493,18 @@  discard block
 block discarded – undo
493 493
  * @param WP_User $old_data
494 494
  */
495 495
 function default_password_nag_edit_user( $user_ID, $old_data ) {
496
-	// Short-circuit it.
497
-	if ( ! get_user_option( 'default_password_nag', $user_ID ) ) {
498
-		return;
499
-	}
500
-
501
-	$new_data = get_userdata( $user_ID );
502
-
503
-	// Remove the nag if the password has been changed.
504
-	if ( $new_data->user_pass != $old_data->user_pass ) {
505
-		delete_user_setting( 'default_password_nag' );
506
-		update_user_meta( $user_ID, 'default_password_nag', false );
507
-	}
496
+    // Short-circuit it.
497
+    if ( ! get_user_option( 'default_password_nag', $user_ID ) ) {
498
+        return;
499
+    }
500
+
501
+    $new_data = get_userdata( $user_ID );
502
+
503
+    // Remove the nag if the password has been changed.
504
+    if ( $new_data->user_pass != $old_data->user_pass ) {
505
+        delete_user_setting( 'default_password_nag' );
506
+        update_user_meta( $user_ID, 'default_password_nag', false );
507
+    }
508 508
 }
509 509
 
510 510
 /**
@@ -513,21 +513,21 @@  discard block
 block discarded – undo
513 513
  * @global string $pagenow The filename of the current screen.
514 514
  */
515 515
 function default_password_nag() {
516
-	global $pagenow;
517
-
518
-	// Short-circuit it.
519
-	if ( 'profile.php' === $pagenow || ! get_user_option( 'default_password_nag' ) ) {
520
-		return;
521
-	}
522
-
523
-	echo '<div class="error default-password-nag">';
524
-	echo '<p>';
525
-	echo '<strong>' . __( 'Notice:' ) . '</strong> ';
526
-	_e( 'You&rsquo;re using the auto-generated password for your account. Would you like to change it?' );
527
-	echo '</p><p>';
528
-	printf( '<a href="%s">' . __( 'Yes, take me to my profile page' ) . '</a> | ', get_edit_profile_url() . '#password' );
529
-	printf( '<a href="%s" id="default-password-nag-no">' . __( 'No thanks, do not remind me again' ) . '</a>', '?default_password_nag=0' );
530
-	echo '</p></div>';
516
+    global $pagenow;
517
+
518
+    // Short-circuit it.
519
+    if ( 'profile.php' === $pagenow || ! get_user_option( 'default_password_nag' ) ) {
520
+        return;
521
+    }
522
+
523
+    echo '<div class="error default-password-nag">';
524
+    echo '<p>';
525
+    echo '<strong>' . __( 'Notice:' ) . '</strong> ';
526
+    _e( 'You&rsquo;re using the auto-generated password for your account. Would you like to change it?' );
527
+    echo '</p><p>';
528
+    printf( '<a href="%s">' . __( 'Yes, take me to my profile page' ) . '</a> | ', get_edit_profile_url() . '#password' );
529
+    printf( '<a href="%s" id="default-password-nag-no">' . __( 'No thanks, do not remind me again' ) . '</a>', '?default_password_nag=0' );
530
+    echo '</p></div>';
531 531
 }
532 532
 
533 533
 /**
@@ -535,7 +535,7 @@  discard block
 block discarded – undo
535 535
  * @access private
536 536
  */
537 537
 function delete_users_add_js() {
538
-	?>
538
+    ?>
539 539
 <script>
540 540
 jQuery( function($) {
541 541
 	var submit = $('#submit').prop('disabled', true);
@@ -560,7 +560,7 @@  discard block
 block discarded – undo
560 560
  * @param WP_User $user User data object.
561 561
  */
562 562
 function use_ssl_preference( $user ) {
563
-	?>
563
+    ?>
564 564
 	<tr class="user-use-ssl-wrap">
565 565
 		<th scope="row"><?php _e( 'Use https' ); ?></th>
566 566
 		<td><label for="use_ssl"><input name="use_ssl" type="checkbox" id="use_ssl" value="1" <?php checked( '1', $user->use_ssl ); ?> /> <?php _e( 'Always use https when visiting the admin' ); ?></label></td>
@@ -575,19 +575,19 @@  discard block
 block discarded – undo
575 575
  * @return string
576 576
  */
577 577
 function admin_created_user_email( $text ) {
578
-	$roles = get_editable_roles();
579
-	$role  = $roles[ $_REQUEST['role'] ];
580
-
581
-	if ( '' !== get_bloginfo( 'name' ) ) {
582
-		$site_title = wp_specialchars_decode( get_bloginfo( 'name' ), ENT_QUOTES );
583
-	} else {
584
-		$site_title = parse_url( home_url(), PHP_URL_HOST );
585
-	}
586
-
587
-	return sprintf(
588
-		/* translators: 1: Site title, 2: Site URL, 3: User role. */
589
-		__(
590
-			'Hi,
578
+    $roles = get_editable_roles();
579
+    $role  = $roles[ $_REQUEST['role'] ];
580
+
581
+    if ( '' !== get_bloginfo( 'name' ) ) {
582
+        $site_title = wp_specialchars_decode( get_bloginfo( 'name' ), ENT_QUOTES );
583
+    } else {
584
+        $site_title = parse_url( home_url(), PHP_URL_HOST );
585
+    }
586
+
587
+    return sprintf(
588
+        /* translators: 1: Site title, 2: Site URL, 3: User role. */
589
+        __(
590
+            'Hi,
591 591
 You\'ve been invited to join \'%1$s\' at
592 592
 %2$s with the role of %3$s.
593 593
 If you do not want to join this site please ignore
@@ -595,11 +595,11 @@  discard block
 block discarded – undo
595 595
 
596 596
 Please click the following link to activate your user account:
597 597
 %%s'
598
-		),
599
-		$site_title,
600
-		home_url(),
601
-		wp_specialchars_decode( translate_user_role( $role['name'] ) )
602
-	);
598
+        ),
599
+        $site_title,
600
+        home_url(),
601
+        wp_specialchars_decode( translate_user_role( $role['name'] ) )
602
+    );
603 603
 }
604 604
 
605 605
 /**
@@ -619,51 +619,51 @@  discard block
 block discarded – undo
619 619
  * @return true|WP_Error True if the request is valid, a WP_Error object contains errors if not.
620 620
  */
621 621
 function wp_is_authorize_application_password_request_valid( $request, $user ) {
622
-	$error = new WP_Error();
623
-
624
-	if ( ! empty( $request['success_url'] ) ) {
625
-		$scheme = wp_parse_url( $request['success_url'], PHP_URL_SCHEME );
626
-
627
-		if ( 'http' === $scheme ) {
628
-			$error->add(
629
-				'invalid_redirect_scheme',
630
-				__( 'The success URL must be served over a secure connection.' )
631
-			);
632
-		}
633
-	}
634
-
635
-	if ( ! empty( $request['reject_url'] ) ) {
636
-		$scheme = wp_parse_url( $request['reject_url'], PHP_URL_SCHEME );
637
-
638
-		if ( 'http' === $scheme ) {
639
-			$error->add(
640
-				'invalid_redirect_scheme',
641
-				__( 'The rejection URL must be served over a secure connection.' )
642
-			);
643
-		}
644
-	}
645
-
646
-	if ( ! empty( $request['app_id'] ) && ! wp_is_uuid( $request['app_id'] ) ) {
647
-		$error->add(
648
-			'invalid_app_id',
649
-			__( 'The application ID must be a UUID.' )
650
-		);
651
-	}
652
-
653
-	/**
654
-	 * Fires before application password errors are returned.
655
-	 *
656
-	 * @since 5.6.0
657
-	 *
658
-	 * @param WP_Error $error   The error object.
659
-	 * @param array    $request The array of request data.
660
-	 * @param WP_User  $user    The user authorizing the application.
661
-	 */
662
-	do_action( 'wp_authorize_application_password_request_errors', $error, $request, $user );
663
-
664
-	if ( $error->has_errors() ) {
665
-		return $error;
666
-	}
667
-
668
-	return true;
622
+    $error = new WP_Error();
623
+
624
+    if ( ! empty( $request['success_url'] ) ) {
625
+        $scheme = wp_parse_url( $request['success_url'], PHP_URL_SCHEME );
626
+
627
+        if ( 'http' === $scheme ) {
628
+            $error->add(
629
+                'invalid_redirect_scheme',
630
+                __( 'The success URL must be served over a secure connection.' )
631
+            );
632
+        }
633
+    }
634
+
635
+    if ( ! empty( $request['reject_url'] ) ) {
636
+        $scheme = wp_parse_url( $request['reject_url'], PHP_URL_SCHEME );
637
+
638
+        if ( 'http' === $scheme ) {
639
+            $error->add(
640
+                'invalid_redirect_scheme',
641
+                __( 'The rejection URL must be served over a secure connection.' )
642
+            );
643
+        }
644
+    }
645
+
646
+    if ( ! empty( $request['app_id'] ) && ! wp_is_uuid( $request['app_id'] ) ) {
647
+        $error->add(
648
+            'invalid_app_id',
649
+            __( 'The application ID must be a UUID.' )
650
+        );
651
+    }
652
+
653
+    /**
654
+     * Fires before application password errors are returned.
655
+     *
656
+     * @since 5.6.0
657
+     *
658
+     * @param WP_Error $error   The error object.
659
+     * @param array    $request The array of request data.
660
+     * @param WP_User  $user    The user authorizing the application.
661
+     */
662
+    do_action( 'wp_authorize_application_password_request_errors', $error, $request, $user );
663
+
664
+    if ( $error->has_errors() ) {
665
+        return $error;
666
+    }
667
+
668
+    return true;
669 669
 }
Please login to merge, or discard this patch.
Spacing   +170 added lines, -170 removed lines patch added patch discarded remove patch
@@ -27,128 +27,128 @@  discard block
 block discarded – undo
27 27
  * @param int $user_id Optional. User ID.
28 28
  * @return int|WP_Error User ID of the updated user or WP_Error on failure.
29 29
  */
30
-function edit_user( $user_id = 0 ) {
30
+function edit_user($user_id = 0) {
31 31
 	$wp_roles = wp_roles();
32 32
 	$user     = new stdClass;
33 33
 	$user_id  = (int) $user_id;
34
-	if ( $user_id ) {
34
+	if ($user_id) {
35 35
 		$update           = true;
36 36
 		$user->ID         = $user_id;
37
-		$userdata         = get_userdata( $user_id );
38
-		$user->user_login = wp_slash( $userdata->user_login );
37
+		$userdata         = get_userdata($user_id);
38
+		$user->user_login = wp_slash($userdata->user_login);
39 39
 	} else {
40 40
 		$update = false;
41 41
 	}
42 42
 
43
-	if ( ! $update && isset( $_POST['user_login'] ) ) {
44
-		$user->user_login = sanitize_user( wp_unslash( $_POST['user_login'] ), true );
43
+	if (!$update && isset($_POST['user_login'])) {
44
+		$user->user_login = sanitize_user(wp_unslash($_POST['user_login']), true);
45 45
 	}
46 46
 
47 47
 	$pass1 = '';
48 48
 	$pass2 = '';
49
-	if ( isset( $_POST['pass1'] ) ) {
50
-		$pass1 = trim( $_POST['pass1'] );
49
+	if (isset($_POST['pass1'])) {
50
+		$pass1 = trim($_POST['pass1']);
51 51
 	}
52
-	if ( isset( $_POST['pass2'] ) ) {
53
-		$pass2 = trim( $_POST['pass2'] );
52
+	if (isset($_POST['pass2'])) {
53
+		$pass2 = trim($_POST['pass2']);
54 54
 	}
55 55
 
56
-	if ( isset( $_POST['role'] ) && current_user_can( 'promote_users' ) && ( ! $user_id || current_user_can( 'promote_user', $user_id ) ) ) {
57
-		$new_role = sanitize_text_field( $_POST['role'] );
56
+	if (isset($_POST['role']) && current_user_can('promote_users') && (!$user_id || current_user_can('promote_user', $user_id))) {
57
+		$new_role = sanitize_text_field($_POST['role']);
58 58
 
59 59
 		// If the new role isn't editable by the logged-in user die with error.
60 60
 		$editable_roles = get_editable_roles();
61
-		if ( ! empty( $new_role ) && empty( $editable_roles[ $new_role ] ) ) {
62
-			wp_die( __( 'Sorry, you are not allowed to give users that role.' ), 403 );
61
+		if (!empty($new_role) && empty($editable_roles[$new_role])) {
62
+			wp_die(__('Sorry, you are not allowed to give users that role.'), 403);
63 63
 		}
64 64
 
65
-		$potential_role = isset( $wp_roles->role_objects[ $new_role ] ) ? $wp_roles->role_objects[ $new_role ] : false;
65
+		$potential_role = isset($wp_roles->role_objects[$new_role]) ? $wp_roles->role_objects[$new_role] : false;
66 66
 
67 67
 		/*
68 68
 		 * Don't let anyone with 'promote_users' edit their own role to something without it.
69 69
 		 * Multisite super admins can freely edit their roles, they possess all caps.
70 70
 		 */
71 71
 		if (
72
-			( is_multisite() && current_user_can( 'manage_network_users' ) ) ||
72
+			(is_multisite() && current_user_can('manage_network_users')) ||
73 73
 			get_current_user_id() !== $user_id ||
74
-			( $potential_role && $potential_role->has_cap( 'promote_users' ) )
74
+			($potential_role && $potential_role->has_cap('promote_users'))
75 75
 		) {
76 76
 			$user->role = $new_role;
77 77
 		}
78 78
 	}
79 79
 
80
-	if ( isset( $_POST['email'] ) ) {
81
-		$user->user_email = sanitize_text_field( wp_unslash( $_POST['email'] ) );
80
+	if (isset($_POST['email'])) {
81
+		$user->user_email = sanitize_text_field(wp_unslash($_POST['email']));
82 82
 	}
83
-	if ( isset( $_POST['url'] ) ) {
84
-		if ( empty( $_POST['url'] ) || 'http://' === $_POST['url'] ) {
83
+	if (isset($_POST['url'])) {
84
+		if (empty($_POST['url']) || 'http://' === $_POST['url']) {
85 85
 			$user->user_url = '';
86 86
 		} else {
87
-			$user->user_url = esc_url_raw( $_POST['url'] );
88
-			$protocols      = implode( '|', array_map( 'preg_quote', wp_allowed_protocols() ) );
89
-			$user->user_url = preg_match( '/^(' . $protocols . '):/is', $user->user_url ) ? $user->user_url : 'http://' . $user->user_url;
87
+			$user->user_url = esc_url_raw($_POST['url']);
88
+			$protocols      = implode('|', array_map('preg_quote', wp_allowed_protocols()));
89
+			$user->user_url = preg_match('/^(' . $protocols . '):/is', $user->user_url) ? $user->user_url : 'http://' . $user->user_url;
90 90
 		}
91 91
 	}
92
-	if ( isset( $_POST['first_name'] ) ) {
93
-		$user->first_name = sanitize_text_field( $_POST['first_name'] );
92
+	if (isset($_POST['first_name'])) {
93
+		$user->first_name = sanitize_text_field($_POST['first_name']);
94 94
 	}
95
-	if ( isset( $_POST['last_name'] ) ) {
96
-		$user->last_name = sanitize_text_field( $_POST['last_name'] );
95
+	if (isset($_POST['last_name'])) {
96
+		$user->last_name = sanitize_text_field($_POST['last_name']);
97 97
 	}
98
-	if ( isset( $_POST['nickname'] ) ) {
99
-		$user->nickname = sanitize_text_field( $_POST['nickname'] );
98
+	if (isset($_POST['nickname'])) {
99
+		$user->nickname = sanitize_text_field($_POST['nickname']);
100 100
 	}
101
-	if ( isset( $_POST['display_name'] ) ) {
102
-		$user->display_name = sanitize_text_field( $_POST['display_name'] );
101
+	if (isset($_POST['display_name'])) {
102
+		$user->display_name = sanitize_text_field($_POST['display_name']);
103 103
 	}
104 104
 
105
-	if ( isset( $_POST['description'] ) ) {
106
-		$user->description = trim( $_POST['description'] );
105
+	if (isset($_POST['description'])) {
106
+		$user->description = trim($_POST['description']);
107 107
 	}
108 108
 
109
-	foreach ( wp_get_user_contact_methods( $user ) as $method => $name ) {
110
-		if ( isset( $_POST[ $method ] ) ) {
111
-			$user->$method = sanitize_text_field( $_POST[ $method ] );
109
+	foreach (wp_get_user_contact_methods($user) as $method => $name) {
110
+		if (isset($_POST[$method])) {
111
+			$user->$method = sanitize_text_field($_POST[$method]);
112 112
 		}
113 113
 	}
114 114
 
115
-	if ( isset( $_POST['locale'] ) ) {
116
-		$locale = sanitize_text_field( $_POST['locale'] );
117
-		if ( 'site-default' === $locale ) {
115
+	if (isset($_POST['locale'])) {
116
+		$locale = sanitize_text_field($_POST['locale']);
117
+		if ('site-default' === $locale) {
118 118
 			$locale = '';
119
-		} elseif ( '' === $locale ) {
119
+		} elseif ('' === $locale) {
120 120
 			$locale = 'en_US';
121
-		} elseif ( ! in_array( $locale, get_available_languages(), true ) ) {
121
+		} elseif (!in_array($locale, get_available_languages(), true)) {
122 122
 			$locale = '';
123 123
 		}
124 124
 
125 125
 		$user->locale = $locale;
126 126
 	}
127 127
 
128
-	if ( $update ) {
129
-		$user->rich_editing         = isset( $_POST['rich_editing'] ) && 'false' === $_POST['rich_editing'] ? 'false' : 'true';
130
-		$user->syntax_highlighting  = isset( $_POST['syntax_highlighting'] ) && 'false' === $_POST['syntax_highlighting'] ? 'false' : 'true';
131
-		$user->admin_color          = isset( $_POST['admin_color'] ) ? sanitize_text_field( $_POST['admin_color'] ) : 'fresh';
132
-		$user->show_admin_bar_front = isset( $_POST['admin_bar_front'] ) ? 'true' : 'false';
128
+	if ($update) {
129
+		$user->rich_editing         = isset($_POST['rich_editing']) && 'false' === $_POST['rich_editing'] ? 'false' : 'true';
130
+		$user->syntax_highlighting  = isset($_POST['syntax_highlighting']) && 'false' === $_POST['syntax_highlighting'] ? 'false' : 'true';
131
+		$user->admin_color          = isset($_POST['admin_color']) ? sanitize_text_field($_POST['admin_color']) : 'fresh';
132
+		$user->show_admin_bar_front = isset($_POST['admin_bar_front']) ? 'true' : 'false';
133 133
 	}
134 134
 
135
-	$user->comment_shortcuts = isset( $_POST['comment_shortcuts'] ) && 'true' === $_POST['comment_shortcuts'] ? 'true' : '';
135
+	$user->comment_shortcuts = isset($_POST['comment_shortcuts']) && 'true' === $_POST['comment_shortcuts'] ? 'true' : '';
136 136
 
137 137
 	$user->use_ssl = 0;
138
-	if ( ! empty( $_POST['use_ssl'] ) ) {
138
+	if (!empty($_POST['use_ssl'])) {
139 139
 		$user->use_ssl = 1;
140 140
 	}
141 141
 
142 142
 	$errors = new WP_Error();
143 143
 
144 144
 	/* checking that username has been typed */
145
-	if ( '' === $user->user_login ) {
146
-		$errors->add( 'user_login', __( '<strong>Error</strong>: Please enter a username.' ) );
145
+	if ('' === $user->user_login) {
146
+		$errors->add('user_login', __('<strong>Error</strong>: Please enter a username.'));
147 147
 	}
148 148
 
149 149
 	/* checking that nickname has been typed */
150
-	if ( $update && empty( $user->nickname ) ) {
151
-		$errors->add( 'nickname', __( '<strong>Error</strong>: Please enter a nickname.' ) );
150
+	if ($update && empty($user->nickname)) {
151
+		$errors->add('nickname', __('<strong>Error</strong>: Please enter a nickname.'));
152 152
 	}
153 153
 
154 154
 	/**
@@ -160,51 +160,51 @@  discard block
 block discarded – undo
160 160
 	 * @param string $pass1     The password (passed by reference).
161 161
 	 * @param string $pass2     The confirmed password (passed by reference).
162 162
 	 */
163
-	do_action_ref_array( 'check_passwords', array( $user->user_login, &$pass1, &$pass2 ) );
163
+	do_action_ref_array('check_passwords', array($user->user_login, &$pass1, &$pass2));
164 164
 
165 165
 	// Check for blank password when adding a user.
166
-	if ( ! $update && empty( $pass1 ) ) {
167
-		$errors->add( 'pass', __( '<strong>Error</strong>: Please enter a password.' ), array( 'form-field' => 'pass1' ) );
166
+	if (!$update && empty($pass1)) {
167
+		$errors->add('pass', __('<strong>Error</strong>: Please enter a password.'), array('form-field' => 'pass1'));
168 168
 	}
169 169
 
170 170
 	// Check for "\" in password.
171
-	if ( false !== strpos( wp_unslash( $pass1 ), '\\' ) ) {
172
-		$errors->add( 'pass', __( '<strong>Error</strong>: Passwords may not contain the character "\\".' ), array( 'form-field' => 'pass1' ) );
171
+	if (false !== strpos(wp_unslash($pass1), '\\')) {
172
+		$errors->add('pass', __('<strong>Error</strong>: Passwords may not contain the character "\\".'), array('form-field' => 'pass1'));
173 173
 	}
174 174
 
175 175
 	// Checking the password has been typed twice the same.
176
-	if ( ( $update || ! empty( $pass1 ) ) && $pass1 != $pass2 ) {
177
-		$errors->add( 'pass', __( '<strong>Error</strong>: Passwords do not match. Please enter the same password in both password fields.' ), array( 'form-field' => 'pass1' ) );
176
+	if (($update || !empty($pass1)) && $pass1 != $pass2) {
177
+		$errors->add('pass', __('<strong>Error</strong>: Passwords do not match. Please enter the same password in both password fields.'), array('form-field' => 'pass1'));
178 178
 	}
179 179
 
180
-	if ( ! empty( $pass1 ) ) {
180
+	if (!empty($pass1)) {
181 181
 		$user->user_pass = $pass1;
182 182
 	}
183 183
 
184
-	if ( ! $update && isset( $_POST['user_login'] ) && ! validate_username( $_POST['user_login'] ) ) {
185
-		$errors->add( 'user_login', __( '<strong>Error</strong>: This username is invalid because it uses illegal characters. Please enter a valid username.' ) );
184
+	if (!$update && isset($_POST['user_login']) && !validate_username($_POST['user_login'])) {
185
+		$errors->add('user_login', __('<strong>Error</strong>: This username is invalid because it uses illegal characters. Please enter a valid username.'));
186 186
 	}
187 187
 
188
-	if ( ! $update && username_exists( $user->user_login ) ) {
189
-		$errors->add( 'user_login', __( '<strong>Error</strong>: This username is already registered. Please choose another one.' ) );
188
+	if (!$update && username_exists($user->user_login)) {
189
+		$errors->add('user_login', __('<strong>Error</strong>: This username is already registered. Please choose another one.'));
190 190
 	}
191 191
 
192 192
 	/** This filter is documented in wp-includes/user.php */
193
-	$illegal_logins = (array) apply_filters( 'illegal_user_logins', array() );
193
+	$illegal_logins = (array) apply_filters('illegal_user_logins', array());
194 194
 
195
-	if ( in_array( strtolower( $user->user_login ), array_map( 'strtolower', $illegal_logins ), true ) ) {
196
-		$errors->add( 'invalid_username', __( '<strong>Error</strong>: Sorry, that username is not allowed.' ) );
195
+	if (in_array(strtolower($user->user_login), array_map('strtolower', $illegal_logins), true)) {
196
+		$errors->add('invalid_username', __('<strong>Error</strong>: Sorry, that username is not allowed.'));
197 197
 	}
198 198
 
199 199
 	/* checking email address */
200
-	if ( empty( $user->user_email ) ) {
201
-		$errors->add( 'empty_email', __( '<strong>Error</strong>: Please enter an email address.' ), array( 'form-field' => 'email' ) );
202
-	} elseif ( ! is_email( $user->user_email ) ) {
203
-		$errors->add( 'invalid_email', __( '<strong>Error</strong>: The email address is not correct.' ), array( 'form-field' => 'email' ) );
200
+	if (empty($user->user_email)) {
201
+		$errors->add('empty_email', __('<strong>Error</strong>: Please enter an email address.'), array('form-field' => 'email'));
202
+	} elseif (!is_email($user->user_email)) {
203
+		$errors->add('invalid_email', __('<strong>Error</strong>: The email address is not correct.'), array('form-field' => 'email'));
204 204
 	} else {
205
-		$owner_id = email_exists( $user->user_email );
206
-		if ( $owner_id && ( ! $update || ( $owner_id != $user->ID ) ) ) {
207
-			$errors->add( 'email_exists', __( '<strong>Error</strong>: This email is already registered. Please choose another one.' ), array( 'form-field' => 'email' ) );
205
+		$owner_id = email_exists($user->user_email);
206
+		if ($owner_id && (!$update || ($owner_id != $user->ID))) {
207
+			$errors->add('email_exists', __('<strong>Error</strong>: This email is already registered. Please choose another one.'), array('form-field' => 'email'));
208 208
 		}
209 209
 	}
210 210
 
@@ -217,17 +217,17 @@  discard block
 block discarded – undo
217 217
 	 * @param bool     $update Whether this is a user update.
218 218
 	 * @param stdClass $user   User object (passed by reference).
219 219
 	 */
220
-	do_action_ref_array( 'user_profile_update_errors', array( &$errors, $update, &$user ) );
220
+	do_action_ref_array('user_profile_update_errors', array(&$errors, $update, &$user));
221 221
 
222
-	if ( $errors->has_errors() ) {
222
+	if ($errors->has_errors()) {
223 223
 		return $errors;
224 224
 	}
225 225
 
226
-	if ( $update ) {
227
-		$user_id = wp_update_user( $user );
226
+	if ($update) {
227
+		$user_id = wp_update_user($user);
228 228
 	} else {
229
-		$user_id = wp_insert_user( $user );
230
-		$notify  = isset( $_POST['send_user_notification'] ) ? 'both' : 'admin';
229
+		$user_id = wp_insert_user($user);
230
+		$notify  = isset($_POST['send_user_notification']) ? 'both' : 'admin';
231 231
 
232 232
 		/**
233 233
 		 * Fires after a new user has been created.
@@ -238,7 +238,7 @@  discard block
 block discarded – undo
238 238
 		 * @param string       $notify  Type of notification that should happen. See
239 239
 		 *                              wp_send_new_user_notifications() for more information.
240 240
 		 */
241
-		do_action( 'edit_user_created_user', $user_id, $notify );
241
+		do_action('edit_user_created_user', $user_id, $notify);
242 242
 	}
243 243
 	return $user_id;
244 244
 }
@@ -269,7 +269,7 @@  discard block
 block discarded – undo
269 269
 	 *
270 270
 	 * @param array[] $all_roles Array of arrays containing role information.
271 271
 	 */
272
-	$editable_roles = apply_filters( 'editable_roles', $all_roles );
272
+	$editable_roles = apply_filters('editable_roles', $all_roles);
273 273
 
274 274
 	return $editable_roles;
275 275
 }
@@ -282,10 +282,10 @@  discard block
 block discarded – undo
282 282
  * @param int $user_id User ID.
283 283
  * @return WP_User|false WP_User object on success, false on failure.
284 284
  */
285
-function get_user_to_edit( $user_id ) {
286
-	$user = get_userdata( $user_id );
285
+function get_user_to_edit($user_id) {
286
+	$user = get_userdata($user_id);
287 287
 
288
-	if ( $user ) {
288
+	if ($user) {
289 289
 		$user->filter = 'edit';
290 290
 	}
291 291
 
@@ -302,9 +302,9 @@  discard block
 block discarded – undo
302 302
  * @param int $user_id User ID.
303 303
  * @return array
304 304
  */
305
-function get_users_drafts( $user_id ) {
305
+function get_users_drafts($user_id) {
306 306
 	global $wpdb;
307
-	$query = $wpdb->prepare( "SELECT ID, post_title FROM $wpdb->posts WHERE post_type = 'post' AND post_status = 'draft' AND post_author = %d ORDER BY post_modified DESC", $user_id );
307
+	$query = $wpdb->prepare("SELECT ID, post_title FROM $wpdb->posts WHERE post_type = 'post' AND post_status = 'draft' AND post_author = %d ORDER BY post_modified DESC", $user_id);
308 308
 
309 309
 	/**
310 310
 	 * Filters the user's drafts query string.
@@ -313,8 +313,8 @@  discard block
 block discarded – undo
313 313
 	 *
314 314
 	 * @param string $query The user's drafts query string.
315 315
 	 */
316
-	$query = apply_filters( 'get_users_drafts', $query );
317
-	return $wpdb->get_results( $query );
316
+	$query = apply_filters('get_users_drafts', $query);
317
+	return $wpdb->get_results($query);
318 318
 }
319 319
 
320 320
 /**
@@ -333,24 +333,24 @@  discard block
 block discarded – undo
333 333
  * @param int $reassign Optional. Reassign posts and links to new User ID.
334 334
  * @return bool True when finished.
335 335
  */
336
-function wp_delete_user( $id, $reassign = null ) {
336
+function wp_delete_user($id, $reassign = null) {
337 337
 	global $wpdb;
338 338
 
339
-	if ( ! is_numeric( $id ) ) {
339
+	if (!is_numeric($id)) {
340 340
 		return false;
341 341
 	}
342 342
 
343 343
 	$id   = (int) $id;
344
-	$user = new WP_User( $id );
344
+	$user = new WP_User($id);
345 345
 
346
-	if ( ! $user->exists() ) {
346
+	if (!$user->exists()) {
347 347
 		return false;
348 348
 	}
349 349
 
350 350
 	// Normalize $reassign to null or a user ID. 'novalue' was an older default.
351
-	if ( 'novalue' === $reassign ) {
351
+	if ('novalue' === $reassign) {
352 352
 		$reassign = null;
353
-	} elseif ( null !== $reassign ) {
353
+	} elseif (null !== $reassign) {
354 354
 		$reassign = (int) $reassign;
355 355
 	}
356 356
 
@@ -365,14 +365,14 @@  discard block
 block discarded – undo
365 365
 	 *                           Default null, for no reassignment.
366 366
 	 * @param WP_User  $user     WP_User object of the user to delete.
367 367
 	 */
368
-	do_action( 'delete_user', $id, $reassign, $user );
368
+	do_action('delete_user', $id, $reassign, $user);
369 369
 
370
-	if ( null === $reassign ) {
370
+	if (null === $reassign) {
371 371
 		$post_types_to_delete = array();
372
-		foreach ( get_post_types( array(), 'objects' ) as $post_type ) {
373
-			if ( $post_type->delete_with_user ) {
372
+		foreach (get_post_types(array(), 'objects') as $post_type) {
373
+			if ($post_type->delete_with_user) {
374 374
 				$post_types_to_delete[] = $post_type->name;
375
-			} elseif ( null === $post_type->delete_with_user && post_type_supports( $post_type->name, 'author' ) ) {
375
+			} elseif (null === $post_type->delete_with_user && post_type_supports($post_type->name, 'author')) {
376 376
 				$post_types_to_delete[] = $post_type->name;
377 377
 			}
378 378
 		}
@@ -385,53 +385,53 @@  discard block
 block discarded – undo
385 385
 		 * @param string[] $post_types_to_delete Array of post types to delete.
386 386
 		 * @param int      $id                   User ID.
387 387
 		 */
388
-		$post_types_to_delete = apply_filters( 'post_types_to_delete_with_user', $post_types_to_delete, $id );
389
-		$post_types_to_delete = implode( "', '", $post_types_to_delete );
390
-		$post_ids             = $wpdb->get_col( $wpdb->prepare( "SELECT ID FROM $wpdb->posts WHERE post_author = %d AND post_type IN ('$post_types_to_delete')", $id ) );
391
-		if ( $post_ids ) {
392
-			foreach ( $post_ids as $post_id ) {
393
-				wp_delete_post( $post_id );
388
+		$post_types_to_delete = apply_filters('post_types_to_delete_with_user', $post_types_to_delete, $id);
389
+		$post_types_to_delete = implode("', '", $post_types_to_delete);
390
+		$post_ids             = $wpdb->get_col($wpdb->prepare("SELECT ID FROM $wpdb->posts WHERE post_author = %d AND post_type IN ('$post_types_to_delete')", $id));
391
+		if ($post_ids) {
392
+			foreach ($post_ids as $post_id) {
393
+				wp_delete_post($post_id);
394 394
 			}
395 395
 		}
396 396
 
397 397
 		// Clean links.
398
-		$link_ids = $wpdb->get_col( $wpdb->prepare( "SELECT link_id FROM $wpdb->links WHERE link_owner = %d", $id ) );
398
+		$link_ids = $wpdb->get_col($wpdb->prepare("SELECT link_id FROM $wpdb->links WHERE link_owner = %d", $id));
399 399
 
400
-		if ( $link_ids ) {
401
-			foreach ( $link_ids as $link_id ) {
402
-				wp_delete_link( $link_id );
400
+		if ($link_ids) {
401
+			foreach ($link_ids as $link_id) {
402
+				wp_delete_link($link_id);
403 403
 			}
404 404
 		}
405 405
 	} else {
406
-		$post_ids = $wpdb->get_col( $wpdb->prepare( "SELECT ID FROM $wpdb->posts WHERE post_author = %d", $id ) );
407
-		$wpdb->update( $wpdb->posts, array( 'post_author' => $reassign ), array( 'post_author' => $id ) );
408
-		if ( ! empty( $post_ids ) ) {
409
-			foreach ( $post_ids as $post_id ) {
410
-				clean_post_cache( $post_id );
406
+		$post_ids = $wpdb->get_col($wpdb->prepare("SELECT ID FROM $wpdb->posts WHERE post_author = %d", $id));
407
+		$wpdb->update($wpdb->posts, array('post_author' => $reassign), array('post_author' => $id));
408
+		if (!empty($post_ids)) {
409
+			foreach ($post_ids as $post_id) {
410
+				clean_post_cache($post_id);
411 411
 			}
412 412
 		}
413
-		$link_ids = $wpdb->get_col( $wpdb->prepare( "SELECT link_id FROM $wpdb->links WHERE link_owner = %d", $id ) );
414
-		$wpdb->update( $wpdb->links, array( 'link_owner' => $reassign ), array( 'link_owner' => $id ) );
415
-		if ( ! empty( $link_ids ) ) {
416
-			foreach ( $link_ids as $link_id ) {
417
-				clean_bookmark_cache( $link_id );
413
+		$link_ids = $wpdb->get_col($wpdb->prepare("SELECT link_id FROM $wpdb->links WHERE link_owner = %d", $id));
414
+		$wpdb->update($wpdb->links, array('link_owner' => $reassign), array('link_owner' => $id));
415
+		if (!empty($link_ids)) {
416
+			foreach ($link_ids as $link_id) {
417
+				clean_bookmark_cache($link_id);
418 418
 			}
419 419
 		}
420 420
 	}
421 421
 
422 422
 	// FINALLY, delete user.
423
-	if ( is_multisite() ) {
424
-		remove_user_from_blog( $id, get_current_blog_id() );
423
+	if (is_multisite()) {
424
+		remove_user_from_blog($id, get_current_blog_id());
425 425
 	} else {
426
-		$meta = $wpdb->get_col( $wpdb->prepare( "SELECT umeta_id FROM $wpdb->usermeta WHERE user_id = %d", $id ) );
427
-		foreach ( $meta as $mid ) {
428
-			delete_metadata_by_mid( 'user', $mid );
426
+		$meta = $wpdb->get_col($wpdb->prepare("SELECT umeta_id FROM $wpdb->usermeta WHERE user_id = %d", $id));
427
+		foreach ($meta as $mid) {
428
+			delete_metadata_by_mid('user', $mid);
429 429
 		}
430 430
 
431
-		$wpdb->delete( $wpdb->users, array( 'ID' => $id ) );
431
+		$wpdb->delete($wpdb->users, array('ID' => $id));
432 432
 	}
433 433
 
434
-	clean_user_cache( $user );
434
+	clean_user_cache($user);
435 435
 
436 436
 	/**
437 437
 	 * Fires immediately after a user is deleted from the database.
@@ -444,7 +444,7 @@  discard block
 block discarded – undo
444 444
 	 *                           Default null, for no reassignment.
445 445
 	 * @param WP_User  $user     WP_User object of the deleted user.
446 446
 	 */
447
-	do_action( 'deleted_user', $id, $reassign, $user );
447
+	do_action('deleted_user', $id, $reassign, $user);
448 448
 
449 449
 	return true;
450 450
 }
@@ -456,10 +456,10 @@  discard block
 block discarded – undo
456 456
  *
457 457
  * @param int $id User ID.
458 458
  */
459
-function wp_revoke_user( $id ) {
459
+function wp_revoke_user($id) {
460 460
 	$id = (int) $id;
461 461
 
462
-	$user = new WP_User( $id );
462
+	$user = new WP_User($id);
463 463
 	$user->remove_all_caps();
464 464
 }
465 465
 
@@ -470,19 +470,19 @@  discard block
 block discarded – undo
470 470
  *
471 471
  * @param false $errors Deprecated.
472 472
  */
473
-function default_password_nag_handler( $errors = false ) {
473
+function default_password_nag_handler($errors = false) {
474 474
 	global $user_ID;
475 475
 	// Short-circuit it.
476
-	if ( ! get_user_option( 'default_password_nag' ) ) {
476
+	if (!get_user_option('default_password_nag')) {
477 477
 		return;
478 478
 	}
479 479
 
480 480
 	// get_user_setting() = JS-saved UI setting. Else no-js-fallback code.
481
-	if ( 'hide' === get_user_setting( 'default_password_nag' )
482
-		|| isset( $_GET['default_password_nag'] ) && '0' == $_GET['default_password_nag']
481
+	if ('hide' === get_user_setting('default_password_nag')
482
+		|| isset($_GET['default_password_nag']) && '0' == $_GET['default_password_nag']
483 483
 	) {
484
-		delete_user_setting( 'default_password_nag' );
485
-		update_user_meta( $user_ID, 'default_password_nag', false );
484
+		delete_user_setting('default_password_nag');
485
+		update_user_meta($user_ID, 'default_password_nag', false);
486 486
 	}
487 487
 }
488 488
 
@@ -492,18 +492,18 @@  discard block
 block discarded – undo
492 492
  * @param int     $user_ID
493 493
  * @param WP_User $old_data
494 494
  */
495
-function default_password_nag_edit_user( $user_ID, $old_data ) {
495
+function default_password_nag_edit_user($user_ID, $old_data) {
496 496
 	// Short-circuit it.
497
-	if ( ! get_user_option( 'default_password_nag', $user_ID ) ) {
497
+	if (!get_user_option('default_password_nag', $user_ID)) {
498 498
 		return;
499 499
 	}
500 500
 
501
-	$new_data = get_userdata( $user_ID );
501
+	$new_data = get_userdata($user_ID);
502 502
 
503 503
 	// Remove the nag if the password has been changed.
504
-	if ( $new_data->user_pass != $old_data->user_pass ) {
505
-		delete_user_setting( 'default_password_nag' );
506
-		update_user_meta( $user_ID, 'default_password_nag', false );
504
+	if ($new_data->user_pass != $old_data->user_pass) {
505
+		delete_user_setting('default_password_nag');
506
+		update_user_meta($user_ID, 'default_password_nag', false);
507 507
 	}
508 508
 }
509 509
 
@@ -516,17 +516,17 @@  discard block
 block discarded – undo
516 516
 	global $pagenow;
517 517
 
518 518
 	// Short-circuit it.
519
-	if ( 'profile.php' === $pagenow || ! get_user_option( 'default_password_nag' ) ) {
519
+	if ('profile.php' === $pagenow || !get_user_option('default_password_nag')) {
520 520
 		return;
521 521
 	}
522 522
 
523 523
 	echo '<div class="error default-password-nag">';
524 524
 	echo '<p>';
525
-	echo '<strong>' . __( 'Notice:' ) . '</strong> ';
526
-	_e( 'You&rsquo;re using the auto-generated password for your account. Would you like to change it?' );
525
+	echo '<strong>' . __('Notice:') . '</strong> ';
526
+	_e('You&rsquo;re using the auto-generated password for your account. Would you like to change it?');
527 527
 	echo '</p><p>';
528
-	printf( '<a href="%s">' . __( 'Yes, take me to my profile page' ) . '</a> | ', get_edit_profile_url() . '#password' );
529
-	printf( '<a href="%s" id="default-password-nag-no">' . __( 'No thanks, do not remind me again' ) . '</a>', '?default_password_nag=0' );
528
+	printf('<a href="%s">' . __('Yes, take me to my profile page') . '</a> | ', get_edit_profile_url() . '#password');
529
+	printf('<a href="%s" id="default-password-nag-no">' . __('No thanks, do not remind me again') . '</a>', '?default_password_nag=0');
530 530
 	echo '</p></div>';
531 531
 }
532 532
 
@@ -559,11 +559,11 @@  discard block
 block discarded – undo
559 559
  *
560 560
  * @param WP_User $user User data object.
561 561
  */
562
-function use_ssl_preference( $user ) {
562
+function use_ssl_preference($user) {
563 563
 	?>
564 564
 	<tr class="user-use-ssl-wrap">
565
-		<th scope="row"><?php _e( 'Use https' ); ?></th>
566
-		<td><label for="use_ssl"><input name="use_ssl" type="checkbox" id="use_ssl" value="1" <?php checked( '1', $user->use_ssl ); ?> /> <?php _e( 'Always use https when visiting the admin' ); ?></label></td>
565
+		<th scope="row"><?php _e('Use https'); ?></th>
566
+		<td><label for="use_ssl"><input name="use_ssl" type="checkbox" id="use_ssl" value="1" <?php checked('1', $user->use_ssl); ?> /> <?php _e('Always use https when visiting the admin'); ?></label></td>
567 567
 	</tr>
568 568
 	<?php
569 569
 }
@@ -574,14 +574,14 @@  discard block
 block discarded – undo
574 574
  * @param string $text
575 575
  * @return string
576 576
  */
577
-function admin_created_user_email( $text ) {
577
+function admin_created_user_email($text) {
578 578
 	$roles = get_editable_roles();
579
-	$role  = $roles[ $_REQUEST['role'] ];
579
+	$role  = $roles[$_REQUEST['role']];
580 580
 
581
-	if ( '' !== get_bloginfo( 'name' ) ) {
582
-		$site_title = wp_specialchars_decode( get_bloginfo( 'name' ), ENT_QUOTES );
581
+	if ('' !== get_bloginfo('name')) {
582
+		$site_title = wp_specialchars_decode(get_bloginfo('name'), ENT_QUOTES);
583 583
 	} else {
584
-		$site_title = parse_url( home_url(), PHP_URL_HOST );
584
+		$site_title = parse_url(home_url(), PHP_URL_HOST);
585 585
 	}
586 586
 
587 587
 	return sprintf(
@@ -598,7 +598,7 @@  discard block
 block discarded – undo
598 598
 		),
599 599
 		$site_title,
600 600
 		home_url(),
601
-		wp_specialchars_decode( translate_user_role( $role['name'] ) )
601
+		wp_specialchars_decode(translate_user_role($role['name']))
602 602
 	);
603 603
 }
604 604
 
@@ -618,35 +618,35 @@  discard block
 block discarded – undo
618 618
  * @param WP_User $user The user authorizing the application.
619 619
  * @return true|WP_Error True if the request is valid, a WP_Error object contains errors if not.
620 620
  */
621
-function wp_is_authorize_application_password_request_valid( $request, $user ) {
621
+function wp_is_authorize_application_password_request_valid($request, $user) {
622 622
 	$error = new WP_Error();
623 623
 
624
-	if ( ! empty( $request['success_url'] ) ) {
625
-		$scheme = wp_parse_url( $request['success_url'], PHP_URL_SCHEME );
624
+	if (!empty($request['success_url'])) {
625
+		$scheme = wp_parse_url($request['success_url'], PHP_URL_SCHEME);
626 626
 
627
-		if ( 'http' === $scheme ) {
627
+		if ('http' === $scheme) {
628 628
 			$error->add(
629 629
 				'invalid_redirect_scheme',
630
-				__( 'The success URL must be served over a secure connection.' )
630
+				__('The success URL must be served over a secure connection.')
631 631
 			);
632 632
 		}
633 633
 	}
634 634
 
635
-	if ( ! empty( $request['reject_url'] ) ) {
636
-		$scheme = wp_parse_url( $request['reject_url'], PHP_URL_SCHEME );
635
+	if (!empty($request['reject_url'])) {
636
+		$scheme = wp_parse_url($request['reject_url'], PHP_URL_SCHEME);
637 637
 
638
-		if ( 'http' === $scheme ) {
638
+		if ('http' === $scheme) {
639 639
 			$error->add(
640 640
 				'invalid_redirect_scheme',
641
-				__( 'The rejection URL must be served over a secure connection.' )
641
+				__('The rejection URL must be served over a secure connection.')
642 642
 			);
643 643
 		}
644 644
 	}
645 645
 
646
-	if ( ! empty( $request['app_id'] ) && ! wp_is_uuid( $request['app_id'] ) ) {
646
+	if (!empty($request['app_id']) && !wp_is_uuid($request['app_id'])) {
647 647
 		$error->add(
648 648
 			'invalid_app_id',
649
-			__( 'The application ID must be a UUID.' )
649
+			__('The application ID must be a UUID.')
650 650
 		);
651 651
 	}
652 652
 
@@ -659,9 +659,9 @@  discard block
 block discarded – undo
659 659
 	 * @param array    $request The array of request data.
660 660
 	 * @param WP_User  $user    The user authorizing the application.
661 661
 	 */
662
-	do_action( 'wp_authorize_application_password_request_errors', $error, $request, $user );
662
+	do_action('wp_authorize_application_password_request_errors', $error, $request, $user);
663 663
 
664
-	if ( $error->has_errors() ) {
664
+	if ($error->has_errors()) {
665 665
 		return $error;
666 666
 	}
667 667
 
Please login to merge, or discard this patch.