Passed
Push — main ( 16d49b...d78e29 )
by TARIQ
111:03
created
brighty/wp-admin/includes/misc.php 1 patch
Indentation   +979 added lines, -979 removed lines patch added patch discarded remove patch
@@ -14,21 +14,21 @@  discard block
 block discarded – undo
14 14
  * @return bool Whether the server is running Apache with the mod_rewrite module loaded.
15 15
  */
16 16
 function got_mod_rewrite() {
17
-	$got_rewrite = apache_mod_loaded( 'mod_rewrite', true );
18
-
19
-	/**
20
-	 * Filters whether Apache and mod_rewrite are present.
21
-	 *
22
-	 * This filter was previously used to force URL rewriting for other servers,
23
-	 * like nginx. Use the {@see 'got_url_rewrite'} filter in got_url_rewrite() instead.
24
-	 *
25
-	 * @since 2.5.0
26
-	 *
27
-	 * @see got_url_rewrite()
28
-	 *
29
-	 * @param bool $got_rewrite Whether Apache and mod_rewrite are present.
30
-	 */
31
-	return apply_filters( 'got_rewrite', $got_rewrite );
17
+    $got_rewrite = apache_mod_loaded( 'mod_rewrite', true );
18
+
19
+    /**
20
+     * Filters whether Apache and mod_rewrite are present.
21
+     *
22
+     * This filter was previously used to force URL rewriting for other servers,
23
+     * like nginx. Use the {@see 'got_url_rewrite'} filter in got_url_rewrite() instead.
24
+     *
25
+     * @since 2.5.0
26
+     *
27
+     * @see got_url_rewrite()
28
+     *
29
+     * @param bool $got_rewrite Whether Apache and mod_rewrite are present.
30
+     */
31
+    return apply_filters( 'got_rewrite', $got_rewrite );
32 32
 }
33 33
 
34 34
 /**
@@ -43,16 +43,16 @@  discard block
 block discarded – undo
43 43
  * @return bool Whether the server supports URL rewriting.
44 44
  */
45 45
 function got_url_rewrite() {
46
-	$got_url_rewrite = ( got_mod_rewrite() || $GLOBALS['is_nginx'] || iis7_supports_permalinks() );
47
-
48
-	/**
49
-	 * Filters whether URL rewriting is available.
50
-	 *
51
-	 * @since 3.7.0
52
-	 *
53
-	 * @param bool $got_url_rewrite Whether URL rewriting is available.
54
-	 */
55
-	return apply_filters( 'got_url_rewrite', $got_url_rewrite );
46
+    $got_url_rewrite = ( got_mod_rewrite() || $GLOBALS['is_nginx'] || iis7_supports_permalinks() );
47
+
48
+    /**
49
+     * Filters whether URL rewriting is available.
50
+     *
51
+     * @since 3.7.0
52
+     *
53
+     * @param bool $got_url_rewrite Whether URL rewriting is available.
54
+     */
55
+    return apply_filters( 'got_url_rewrite', $got_url_rewrite );
56 56
 }
57 57
 
58 58
 /**
@@ -65,35 +65,35 @@  discard block
 block discarded – undo
65 65
  * @return string[] An array of strings from a file (.htaccess) from between BEGIN and END markers.
66 66
  */
67 67
 function extract_from_markers( $filename, $marker ) {
68
-	$result = array();
68
+    $result = array();
69 69
 
70
-	if ( ! file_exists( $filename ) ) {
71
-		return $result;
72
-	}
70
+    if ( ! file_exists( $filename ) ) {
71
+        return $result;
72
+    }
73 73
 
74
-	$markerdata = explode( "\n", implode( '', file( $filename ) ) );
74
+    $markerdata = explode( "\n", implode( '', file( $filename ) ) );
75 75
 
76
-	$state = false;
76
+    $state = false;
77 77
 
78
-	foreach ( $markerdata as $markerline ) {
79
-		if ( false !== strpos( $markerline, '# END ' . $marker ) ) {
80
-			$state = false;
81
-		}
78
+    foreach ( $markerdata as $markerline ) {
79
+        if ( false !== strpos( $markerline, '# END ' . $marker ) ) {
80
+            $state = false;
81
+        }
82 82
 
83
-		if ( $state ) {
84
-			if ( '#' === substr( $markerline, 0, 1 ) ) {
85
-				continue;
86
-			}
83
+        if ( $state ) {
84
+            if ( '#' === substr( $markerline, 0, 1 ) ) {
85
+                continue;
86
+            }
87 87
 
88
-			$result[] = $markerline;
89
-		}
88
+            $result[] = $markerline;
89
+        }
90 90
 
91
-		if ( false !== strpos( $markerline, '# BEGIN ' . $marker ) ) {
92
-			$state = true;
93
-		}
94
-	}
91
+        if ( false !== strpos( $markerline, '# BEGIN ' . $marker ) ) {
92
+            $state = true;
93
+        }
94
+    }
95 95
 
96
-	return $result;
96
+    return $result;
97 97
 }
98 98
 
99 99
 /**
@@ -111,139 +111,139 @@  discard block
 block discarded – undo
111 111
  * @return bool True on write success, false on failure.
112 112
  */
113 113
 function insert_with_markers( $filename, $marker, $insertion ) {
114
-	if ( ! file_exists( $filename ) ) {
115
-		if ( ! is_writable( dirname( $filename ) ) ) {
116
-			return false;
117
-		}
118
-
119
-		if ( ! touch( $filename ) ) {
120
-			return false;
121
-		}
122
-
123
-		// Make sure the file is created with a minimum set of permissions.
124
-		$perms = fileperms( $filename );
125
-
126
-		if ( $perms ) {
127
-			chmod( $filename, $perms | 0644 );
128
-		}
129
-	} elseif ( ! is_writable( $filename ) ) {
130
-		return false;
131
-	}
132
-
133
-	if ( ! is_array( $insertion ) ) {
134
-		$insertion = explode( "\n", $insertion );
135
-	}
136
-
137
-	$switched_locale = switch_to_locale( get_locale() );
138
-
139
-	$instructions = sprintf(
140
-		/* translators: 1: Marker. */
141
-		__(
142
-			'The directives (lines) between "BEGIN %1$s" and "END %1$s" are
114
+    if ( ! file_exists( $filename ) ) {
115
+        if ( ! is_writable( dirname( $filename ) ) ) {
116
+            return false;
117
+        }
118
+
119
+        if ( ! touch( $filename ) ) {
120
+            return false;
121
+        }
122
+
123
+        // Make sure the file is created with a minimum set of permissions.
124
+        $perms = fileperms( $filename );
125
+
126
+        if ( $perms ) {
127
+            chmod( $filename, $perms | 0644 );
128
+        }
129
+    } elseif ( ! is_writable( $filename ) ) {
130
+        return false;
131
+    }
132
+
133
+    if ( ! is_array( $insertion ) ) {
134
+        $insertion = explode( "\n", $insertion );
135
+    }
136
+
137
+    $switched_locale = switch_to_locale( get_locale() );
138
+
139
+    $instructions = sprintf(
140
+        /* translators: 1: Marker. */
141
+        __(
142
+            'The directives (lines) between "BEGIN %1$s" and "END %1$s" are
143 143
 dynamically generated, and should only be modified via WordPress filters.
144 144
 Any changes to the directives between these markers will be overwritten.'
145
-		),
146
-		$marker
147
-	);
148
-
149
-	$instructions = explode( "\n", $instructions );
150
-
151
-	foreach ( $instructions as $line => $text ) {
152
-		$instructions[ $line ] = '# ' . $text;
153
-	}
154
-
155
-	/**
156
-	 * Filters the inline instructions inserted before the dynamically generated content.
157
-	 *
158
-	 * @since 5.3.0
159
-	 *
160
-	 * @param string[] $instructions Array of lines with inline instructions.
161
-	 * @param string   $marker       The marker being inserted.
162
-	 */
163
-	$instructions = apply_filters( 'insert_with_markers_inline_instructions', $instructions, $marker );
164
-
165
-	if ( $switched_locale ) {
166
-		restore_previous_locale();
167
-	}
168
-
169
-	$insertion = array_merge( $instructions, $insertion );
170
-
171
-	$start_marker = "# BEGIN {$marker}";
172
-	$end_marker   = "# END {$marker}";
173
-
174
-	$fp = fopen( $filename, 'r+' );
175
-
176
-	if ( ! $fp ) {
177
-		return false;
178
-	}
179
-
180
-	// Attempt to get a lock. If the filesystem supports locking, this will block until the lock is acquired.
181
-	flock( $fp, LOCK_EX );
182
-
183
-	$lines = array();
184
-
185
-	while ( ! feof( $fp ) ) {
186
-		$lines[] = rtrim( fgets( $fp ), "\r\n" );
187
-	}
188
-
189
-	// Split out the existing file into the preceding lines, and those that appear after the marker.
190
-	$pre_lines        = array();
191
-	$post_lines       = array();
192
-	$existing_lines   = array();
193
-	$found_marker     = false;
194
-	$found_end_marker = false;
195
-
196
-	foreach ( $lines as $line ) {
197
-		if ( ! $found_marker && false !== strpos( $line, $start_marker ) ) {
198
-			$found_marker = true;
199
-			continue;
200
-		} elseif ( ! $found_end_marker && false !== strpos( $line, $end_marker ) ) {
201
-			$found_end_marker = true;
202
-			continue;
203
-		}
204
-
205
-		if ( ! $found_marker ) {
206
-			$pre_lines[] = $line;
207
-		} elseif ( $found_marker && $found_end_marker ) {
208
-			$post_lines[] = $line;
209
-		} else {
210
-			$existing_lines[] = $line;
211
-		}
212
-	}
213
-
214
-	// Check to see if there was a change.
215
-	if ( $existing_lines === $insertion ) {
216
-		flock( $fp, LOCK_UN );
217
-		fclose( $fp );
218
-
219
-		return true;
220
-	}
221
-
222
-	// Generate the new file data.
223
-	$new_file_data = implode(
224
-		"\n",
225
-		array_merge(
226
-			$pre_lines,
227
-			array( $start_marker ),
228
-			$insertion,
229
-			array( $end_marker ),
230
-			$post_lines
231
-		)
232
-	);
233
-
234
-	// Write to the start of the file, and truncate it to that length.
235
-	fseek( $fp, 0 );
236
-	$bytes = fwrite( $fp, $new_file_data );
237
-
238
-	if ( $bytes ) {
239
-		ftruncate( $fp, ftell( $fp ) );
240
-	}
241
-
242
-	fflush( $fp );
243
-	flock( $fp, LOCK_UN );
244
-	fclose( $fp );
245
-
246
-	return (bool) $bytes;
145
+        ),
146
+        $marker
147
+    );
148
+
149
+    $instructions = explode( "\n", $instructions );
150
+
151
+    foreach ( $instructions as $line => $text ) {
152
+        $instructions[ $line ] = '# ' . $text;
153
+    }
154
+
155
+    /**
156
+     * Filters the inline instructions inserted before the dynamically generated content.
157
+     *
158
+     * @since 5.3.0
159
+     *
160
+     * @param string[] $instructions Array of lines with inline instructions.
161
+     * @param string   $marker       The marker being inserted.
162
+     */
163
+    $instructions = apply_filters( 'insert_with_markers_inline_instructions', $instructions, $marker );
164
+
165
+    if ( $switched_locale ) {
166
+        restore_previous_locale();
167
+    }
168
+
169
+    $insertion = array_merge( $instructions, $insertion );
170
+
171
+    $start_marker = "# BEGIN {$marker}";
172
+    $end_marker   = "# END {$marker}";
173
+
174
+    $fp = fopen( $filename, 'r+' );
175
+
176
+    if ( ! $fp ) {
177
+        return false;
178
+    }
179
+
180
+    // Attempt to get a lock. If the filesystem supports locking, this will block until the lock is acquired.
181
+    flock( $fp, LOCK_EX );
182
+
183
+    $lines = array();
184
+
185
+    while ( ! feof( $fp ) ) {
186
+        $lines[] = rtrim( fgets( $fp ), "\r\n" );
187
+    }
188
+
189
+    // Split out the existing file into the preceding lines, and those that appear after the marker.
190
+    $pre_lines        = array();
191
+    $post_lines       = array();
192
+    $existing_lines   = array();
193
+    $found_marker     = false;
194
+    $found_end_marker = false;
195
+
196
+    foreach ( $lines as $line ) {
197
+        if ( ! $found_marker && false !== strpos( $line, $start_marker ) ) {
198
+            $found_marker = true;
199
+            continue;
200
+        } elseif ( ! $found_end_marker && false !== strpos( $line, $end_marker ) ) {
201
+            $found_end_marker = true;
202
+            continue;
203
+        }
204
+
205
+        if ( ! $found_marker ) {
206
+            $pre_lines[] = $line;
207
+        } elseif ( $found_marker && $found_end_marker ) {
208
+            $post_lines[] = $line;
209
+        } else {
210
+            $existing_lines[] = $line;
211
+        }
212
+    }
213
+
214
+    // Check to see if there was a change.
215
+    if ( $existing_lines === $insertion ) {
216
+        flock( $fp, LOCK_UN );
217
+        fclose( $fp );
218
+
219
+        return true;
220
+    }
221
+
222
+    // Generate the new file data.
223
+    $new_file_data = implode(
224
+        "\n",
225
+        array_merge(
226
+            $pre_lines,
227
+            array( $start_marker ),
228
+            $insertion,
229
+            array( $end_marker ),
230
+            $post_lines
231
+        )
232
+    );
233
+
234
+    // Write to the start of the file, and truncate it to that length.
235
+    fseek( $fp, 0 );
236
+    $bytes = fwrite( $fp, $new_file_data );
237
+
238
+    if ( $bytes ) {
239
+        ftruncate( $fp, ftell( $fp ) );
240
+    }
241
+
242
+    fflush( $fp );
243
+    flock( $fp, LOCK_UN );
244
+    fclose( $fp );
245
+
246
+    return (bool) $bytes;
247 247
 }
248 248
 
249 249
 /**
@@ -259,33 +259,33 @@  discard block
 block discarded – undo
259 259
  * @return bool|null True on write success, false on failure. Null in multisite.
260 260
  */
261 261
 function save_mod_rewrite_rules() {
262
-	global $wp_rewrite;
262
+    global $wp_rewrite;
263 263
 
264
-	if ( is_multisite() ) {
265
-		return;
266
-	}
264
+    if ( is_multisite() ) {
265
+        return;
266
+    }
267 267
 
268
-	// Ensure get_home_path() is declared.
269
-	require_once ABSPATH . 'wp-admin/includes/file.php';
268
+    // Ensure get_home_path() is declared.
269
+    require_once ABSPATH . 'wp-admin/includes/file.php';
270 270
 
271
-	$home_path     = get_home_path();
272
-	$htaccess_file = $home_path . '.htaccess';
271
+    $home_path     = get_home_path();
272
+    $htaccess_file = $home_path . '.htaccess';
273 273
 
274
-	/*
274
+    /*
275 275
 	 * If the file doesn't already exist check for write access to the directory
276 276
 	 * and whether we have some rules. Else check for write access to the file.
277 277
 	 */
278
-	if ( ! file_exists( $htaccess_file ) && is_writable( $home_path ) && $wp_rewrite->using_mod_rewrite_permalinks()
279
-		|| is_writable( $htaccess_file )
280
-	) {
281
-		if ( got_mod_rewrite() ) {
282
-			$rules = explode( "\n", $wp_rewrite->mod_rewrite_rules() );
278
+    if ( ! file_exists( $htaccess_file ) && is_writable( $home_path ) && $wp_rewrite->using_mod_rewrite_permalinks()
279
+        || is_writable( $htaccess_file )
280
+    ) {
281
+        if ( got_mod_rewrite() ) {
282
+            $rules = explode( "\n", $wp_rewrite->mod_rewrite_rules() );
283 283
 
284
-			return insert_with_markers( $htaccess_file, 'WordPress', $rules );
285
-		}
286
-	}
284
+            return insert_with_markers( $htaccess_file, 'WordPress', $rules );
285
+        }
286
+    }
287 287
 
288
-	return false;
288
+    return false;
289 289
 }
290 290
 
291 291
 /**
@@ -299,33 +299,33 @@  discard block
 block discarded – undo
299 299
  * @return bool|null True on write success, false on failure. Null in multisite.
300 300
  */
301 301
 function iis7_save_url_rewrite_rules() {
302
-	global $wp_rewrite;
302
+    global $wp_rewrite;
303 303
 
304
-	if ( is_multisite() ) {
305
-		return;
306
-	}
304
+    if ( is_multisite() ) {
305
+        return;
306
+    }
307 307
 
308
-	// Ensure get_home_path() is declared.
309
-	require_once ABSPATH . 'wp-admin/includes/file.php';
308
+    // Ensure get_home_path() is declared.
309
+    require_once ABSPATH . 'wp-admin/includes/file.php';
310 310
 
311
-	$home_path       = get_home_path();
312
-	$web_config_file = $home_path . 'web.config';
311
+    $home_path       = get_home_path();
312
+    $web_config_file = $home_path . 'web.config';
313 313
 
314
-	// Using win_is_writable() instead of is_writable() because of a bug in Windows PHP.
315
-	if ( iis7_supports_permalinks()
316
-		&& ( ! file_exists( $web_config_file ) && win_is_writable( $home_path ) && $wp_rewrite->using_mod_rewrite_permalinks()
317
-			|| win_is_writable( $web_config_file ) )
318
-	) {
319
-		$rule = $wp_rewrite->iis7_url_rewrite_rules( false );
314
+    // Using win_is_writable() instead of is_writable() because of a bug in Windows PHP.
315
+    if ( iis7_supports_permalinks()
316
+        && ( ! file_exists( $web_config_file ) && win_is_writable( $home_path ) && $wp_rewrite->using_mod_rewrite_permalinks()
317
+            || win_is_writable( $web_config_file ) )
318
+    ) {
319
+        $rule = $wp_rewrite->iis7_url_rewrite_rules( false );
320 320
 
321
-		if ( ! empty( $rule ) ) {
322
-			return iis7_add_rewrite_rule( $web_config_file, $rule );
323
-		} else {
324
-			return iis7_delete_rewrite_rule( $web_config_file );
325
-		}
326
-	}
321
+        if ( ! empty( $rule ) ) {
322
+            return iis7_add_rewrite_rule( $web_config_file, $rule );
323
+        } else {
324
+            return iis7_delete_rewrite_rule( $web_config_file );
325
+        }
326
+    }
327 327
 
328
-	return false;
328
+    return false;
329 329
 }
330 330
 
331 331
 /**
@@ -336,22 +336,22 @@  discard block
 block discarded – undo
336 336
  * @param string $file
337 337
  */
338 338
 function update_recently_edited( $file ) {
339
-	$oldfiles = (array) get_option( 'recently_edited' );
340
-
341
-	if ( $oldfiles ) {
342
-		$oldfiles   = array_reverse( $oldfiles );
343
-		$oldfiles[] = $file;
344
-		$oldfiles   = array_reverse( $oldfiles );
345
-		$oldfiles   = array_unique( $oldfiles );
346
-
347
-		if ( 5 < count( $oldfiles ) ) {
348
-			array_pop( $oldfiles );
349
-		}
350
-	} else {
351
-		$oldfiles[] = $file;
352
-	}
353
-
354
-	update_option( 'recently_edited', $oldfiles );
339
+    $oldfiles = (array) get_option( 'recently_edited' );
340
+
341
+    if ( $oldfiles ) {
342
+        $oldfiles   = array_reverse( $oldfiles );
343
+        $oldfiles[] = $file;
344
+        $oldfiles   = array_reverse( $oldfiles );
345
+        $oldfiles   = array_unique( $oldfiles );
346
+
347
+        if ( 5 < count( $oldfiles ) ) {
348
+            array_pop( $oldfiles );
349
+        }
350
+    } else {
351
+        $oldfiles[] = $file;
352
+    }
353
+
354
+    update_option( 'recently_edited', $oldfiles );
355 355
 }
356 356
 
357 357
 /**
@@ -364,20 +364,20 @@  discard block
 block discarded – undo
364 364
  * @return array Tree structure for listing theme files.
365 365
  */
366 366
 function wp_make_theme_file_tree( $allowed_files ) {
367
-	$tree_list = array();
367
+    $tree_list = array();
368 368
 
369
-	foreach ( $allowed_files as $file_name => $absolute_filename ) {
370
-		$list     = explode( '/', $file_name );
371
-		$last_dir = &$tree_list;
369
+    foreach ( $allowed_files as $file_name => $absolute_filename ) {
370
+        $list     = explode( '/', $file_name );
371
+        $last_dir = &$tree_list;
372 372
 
373
-		foreach ( $list as $dir ) {
374
-			$last_dir =& $last_dir[ $dir ];
375
-		}
373
+        foreach ( $list as $dir ) {
374
+            $last_dir =& $last_dir[ $dir ];
375
+        }
376 376
 
377
-		$last_dir = $file_name;
378
-	}
377
+        $last_dir = $file_name;
378
+    }
379 379
 
380
-	return $tree_list;
380
+    return $tree_list;
381 381
 }
382 382
 
383 383
 /**
@@ -396,20 +396,20 @@  discard block
 block discarded – undo
396 396
  * @param int          $index The aria-posinset for the current iteration.
397 397
  */
398 398
 function wp_print_theme_file_tree( $tree, $level = 2, $size = 1, $index = 1 ) {
399
-	global $relative_file, $stylesheet;
399
+    global $relative_file, $stylesheet;
400 400
 
401
-	if ( is_array( $tree ) ) {
402
-		$index = 0;
403
-		$size  = count( $tree );
401
+    if ( is_array( $tree ) ) {
402
+        $index = 0;
403
+        $size  = count( $tree );
404 404
 
405
-		foreach ( $tree as $label => $theme_file ) :
406
-			$index++;
405
+        foreach ( $tree as $label => $theme_file ) :
406
+            $index++;
407 407
 
408
-			if ( ! is_array( $theme_file ) ) {
409
-				wp_print_theme_file_tree( $theme_file, $level, $index, $size );
410
-				continue;
411
-			}
412
-			?>
408
+            if ( ! is_array( $theme_file ) ) {
409
+                wp_print_theme_file_tree( $theme_file, $level, $index, $size );
410
+                continue;
411
+            }
412
+            ?>
413 413
 			<li role="treeitem" aria-expanded="true" tabindex="-1"
414 414
 				aria-level="<?php echo esc_attr( $level ); ?>"
415 415
 				aria-setsize="<?php echo esc_attr( $size ); ?>"
@@ -418,17 +418,17 @@  discard block
 block discarded – undo
418 418
 				<ul role="group" class="tree-folder"><?php wp_print_theme_file_tree( $theme_file, $level + 1, $index, $size ); ?></ul>
419 419
 			</li>
420 420
 			<?php
421
-		endforeach;
422
-	} else {
423
-		$filename = $tree;
424
-		$url      = add_query_arg(
425
-			array(
426
-				'file'  => rawurlencode( $tree ),
427
-				'theme' => rawurlencode( $stylesheet ),
428
-			),
429
-			self_admin_url( 'theme-editor.php' )
430
-		);
431
-		?>
421
+        endforeach;
422
+    } else {
423
+        $filename = $tree;
424
+        $url      = add_query_arg(
425
+            array(
426
+                'file'  => rawurlencode( $tree ),
427
+                'theme' => rawurlencode( $stylesheet ),
428
+            ),
429
+            self_admin_url( 'theme-editor.php' )
430
+        );
431
+        ?>
432 432
 		<li role="none" class="<?php echo esc_attr( $relative_file === $filename ? 'current-file' : '' ); ?>">
433 433
 			<a role="treeitem" tabindex="<?php echo esc_attr( $relative_file === $filename ? '0' : '-1' ); ?>"
434 434
 				href="<?php echo esc_url( $url ); ?>"
@@ -436,22 +436,22 @@  discard block
 block discarded – undo
436 436
 				aria-setsize="<?php echo esc_attr( $size ); ?>"
437 437
 				aria-posinset="<?php echo esc_attr( $index ); ?>">
438 438
 				<?php
439
-				$file_description = esc_html( get_file_description( $filename ) );
440
-
441
-				if ( $file_description !== $filename && wp_basename( $filename ) !== $file_description ) {
442
-					$file_description .= '<br /><span class="nonessential">(' . esc_html( $filename ) . ')</span>';
443
-				}
444
-
445
-				if ( $relative_file === $filename ) {
446
-					echo '<span class="notice notice-info">' . $file_description . '</span>';
447
-				} else {
448
-					echo $file_description;
449
-				}
450
-				?>
439
+                $file_description = esc_html( get_file_description( $filename ) );
440
+
441
+                if ( $file_description !== $filename && wp_basename( $filename ) !== $file_description ) {
442
+                    $file_description .= '<br /><span class="nonessential">(' . esc_html( $filename ) . ')</span>';
443
+                }
444
+
445
+                if ( $relative_file === $filename ) {
446
+                    echo '<span class="notice notice-info">' . $file_description . '</span>';
447
+                } else {
448
+                    echo $file_description;
449
+                }
450
+                ?>
451 451
 			</a>
452 452
 		</li>
453 453
 		<?php
454
-	}
454
+    }
455 455
 }
456 456
 
457 457
 /**
@@ -464,20 +464,20 @@  discard block
 block discarded – undo
464 464
  * @return array Tree structure for listing plugin files.
465 465
  */
466 466
 function wp_make_plugin_file_tree( $plugin_editable_files ) {
467
-	$tree_list = array();
467
+    $tree_list = array();
468 468
 
469
-	foreach ( $plugin_editable_files as $plugin_file ) {
470
-		$list     = explode( '/', preg_replace( '#^.+?/#', '', $plugin_file ) );
471
-		$last_dir = &$tree_list;
469
+    foreach ( $plugin_editable_files as $plugin_file ) {
470
+        $list     = explode( '/', preg_replace( '#^.+?/#', '', $plugin_file ) );
471
+        $last_dir = &$tree_list;
472 472
 
473
-		foreach ( $list as $dir ) {
474
-			$last_dir =& $last_dir[ $dir ];
475
-		}
473
+        foreach ( $list as $dir ) {
474
+            $last_dir =& $last_dir[ $dir ];
475
+        }
476 476
 
477
-		$last_dir = $plugin_file;
478
-	}
477
+        $last_dir = $plugin_file;
478
+    }
479 479
 
480
-	return $tree_list;
480
+    return $tree_list;
481 481
 }
482 482
 
483 483
 /**
@@ -493,20 +493,20 @@  discard block
 block discarded – undo
493 493
  * @param int          $index The aria-posinset for the current iteration.
494 494
  */
495 495
 function wp_print_plugin_file_tree( $tree, $label = '', $level = 2, $size = 1, $index = 1 ) {
496
-	global $file, $plugin;
496
+    global $file, $plugin;
497 497
 
498
-	if ( is_array( $tree ) ) {
499
-		$index = 0;
500
-		$size  = count( $tree );
498
+    if ( is_array( $tree ) ) {
499
+        $index = 0;
500
+        $size  = count( $tree );
501 501
 
502
-		foreach ( $tree as $label => $plugin_file ) :
503
-			$index++;
502
+        foreach ( $tree as $label => $plugin_file ) :
503
+            $index++;
504 504
 
505
-			if ( ! is_array( $plugin_file ) ) {
506
-				wp_print_plugin_file_tree( $plugin_file, $label, $level, $index, $size );
507
-				continue;
508
-			}
509
-			?>
505
+            if ( ! is_array( $plugin_file ) ) {
506
+                wp_print_plugin_file_tree( $plugin_file, $label, $level, $index, $size );
507
+                continue;
508
+            }
509
+            ?>
510 510
 			<li role="treeitem" aria-expanded="true" tabindex="-1"
511 511
 				aria-level="<?php echo esc_attr( $level ); ?>"
512 512
 				aria-setsize="<?php echo esc_attr( $size ); ?>"
@@ -515,16 +515,16 @@  discard block
 block discarded – undo
515 515
 				<ul role="group" class="tree-folder"><?php wp_print_plugin_file_tree( $plugin_file, '', $level + 1, $index, $size ); ?></ul>
516 516
 			</li>
517 517
 			<?php
518
-		endforeach;
519
-	} else {
520
-		$url = add_query_arg(
521
-			array(
522
-				'file'   => rawurlencode( $tree ),
523
-				'plugin' => rawurlencode( $plugin ),
524
-			),
525
-			self_admin_url( 'plugin-editor.php' )
526
-		);
527
-		?>
518
+        endforeach;
519
+    } else {
520
+        $url = add_query_arg(
521
+            array(
522
+                'file'   => rawurlencode( $tree ),
523
+                'plugin' => rawurlencode( $plugin ),
524
+            ),
525
+            self_admin_url( 'plugin-editor.php' )
526
+        );
527
+        ?>
528 528
 		<li role="none" class="<?php echo esc_attr( $file === $tree ? 'current-file' : '' ); ?>">
529 529
 			<a role="treeitem" tabindex="<?php echo esc_attr( $file === $tree ? '0' : '-1' ); ?>"
530 530
 				href="<?php echo esc_url( $url ); ?>"
@@ -532,16 +532,16 @@  discard block
 block discarded – undo
532 532
 				aria-setsize="<?php echo esc_attr( $size ); ?>"
533 533
 				aria-posinset="<?php echo esc_attr( $index ); ?>">
534 534
 				<?php
535
-				if ( $file === $tree ) {
536
-					echo '<span class="notice notice-info">' . esc_html( $label ) . '</span>';
537
-				} else {
538
-					echo esc_html( $label );
539
-				}
540
-				?>
535
+                if ( $file === $tree ) {
536
+                    echo '<span class="notice notice-info">' . esc_html( $label ) . '</span>';
537
+                } else {
538
+                    echo esc_html( $label );
539
+                }
540
+                ?>
541 541
 			</a>
542 542
 		</li>
543 543
 		<?php
544
-	}
544
+    }
545 545
 }
546 546
 
547 547
 /**
@@ -553,15 +553,15 @@  discard block
 block discarded – undo
553 553
  * @param string $value
554 554
  */
555 555
 function update_home_siteurl( $old_value, $value ) {
556
-	if ( wp_installing() ) {
557
-		return;
558
-	}
559
-
560
-	if ( is_multisite() && ms_is_switched() ) {
561
-		delete_option( 'rewrite_rules' );
562
-	} else {
563
-		flush_rewrite_rules();
564
-	}
556
+    if ( wp_installing() ) {
557
+        return;
558
+    }
559
+
560
+    if ( is_multisite() && ms_is_switched() ) {
561
+        delete_option( 'rewrite_rules' );
562
+    } else {
563
+        flush_rewrite_rules();
564
+    }
565 565
 }
566 566
 
567 567
 
@@ -577,17 +577,17 @@  discard block
 block discarded – undo
577 577
  * @param array $vars An array of globals to reset.
578 578
  */
579 579
 function wp_reset_vars( $vars ) {
580
-	foreach ( $vars as $var ) {
581
-		if ( empty( $_POST[ $var ] ) ) {
582
-			if ( empty( $_GET[ $var ] ) ) {
583
-				$GLOBALS[ $var ] = '';
584
-			} else {
585
-				$GLOBALS[ $var ] = $_GET[ $var ];
586
-			}
587
-		} else {
588
-			$GLOBALS[ $var ] = $_POST[ $var ];
589
-		}
590
-	}
580
+    foreach ( $vars as $var ) {
581
+        if ( empty( $_POST[ $var ] ) ) {
582
+            if ( empty( $_GET[ $var ] ) ) {
583
+                $GLOBALS[ $var ] = '';
584
+            } else {
585
+                $GLOBALS[ $var ] = $_GET[ $var ];
586
+            }
587
+        } else {
588
+            $GLOBALS[ $var ] = $_POST[ $var ];
589
+        }
590
+    }
591 591
 }
592 592
 
593 593
 /**
@@ -598,17 +598,17 @@  discard block
 block discarded – undo
598 598
  * @param string|WP_Error $message
599 599
  */
600 600
 function show_message( $message ) {
601
-	if ( is_wp_error( $message ) ) {
602
-		if ( $message->get_error_data() && is_string( $message->get_error_data() ) ) {
603
-			$message = $message->get_error_message() . ': ' . $message->get_error_data();
604
-		} else {
605
-			$message = $message->get_error_message();
606
-		}
607
-	}
608
-
609
-	echo "<p>$message</p>\n";
610
-	wp_ob_end_flush_all();
611
-	flush();
601
+    if ( is_wp_error( $message ) ) {
602
+        if ( $message->get_error_data() && is_string( $message->get_error_data() ) ) {
603
+            $message = $message->get_error_message() . ': ' . $message->get_error_data();
604
+        } else {
605
+            $message = $message->get_error_message();
606
+        }
607
+    }
608
+
609
+    echo "<p>$message</p>\n";
610
+    wp_ob_end_flush_all();
611
+    flush();
612 612
 }
613 613
 
614 614
 /**
@@ -618,62 +618,62 @@  discard block
 block discarded – undo
618 618
  * @return array
619 619
  */
620 620
 function wp_doc_link_parse( $content ) {
621
-	if ( ! is_string( $content ) || empty( $content ) ) {
622
-		return array();
623
-	}
624
-
625
-	if ( ! function_exists( 'token_get_all' ) ) {
626
-		return array();
627
-	}
628
-
629
-	$tokens           = token_get_all( $content );
630
-	$count            = count( $tokens );
631
-	$functions        = array();
632
-	$ignore_functions = array();
633
-
634
-	for ( $t = 0; $t < $count - 2; $t++ ) {
635
-		if ( ! is_array( $tokens[ $t ] ) ) {
636
-			continue;
637
-		}
638
-
639
-		if ( T_STRING === $tokens[ $t ][0] && ( '(' === $tokens[ $t + 1 ] || '(' === $tokens[ $t + 2 ] ) ) {
640
-			// If it's a function or class defined locally, there's not going to be any docs available.
641
-			if ( ( isset( $tokens[ $t - 2 ][1] ) && in_array( $tokens[ $t - 2 ][1], array( 'function', 'class' ), true ) )
642
-				|| ( isset( $tokens[ $t - 2 ][0] ) && T_OBJECT_OPERATOR === $tokens[ $t - 1 ][0] )
643
-			) {
644
-				$ignore_functions[] = $tokens[ $t ][1];
645
-			}
646
-
647
-			// Add this to our stack of unique references.
648
-			$functions[] = $tokens[ $t ][1];
649
-		}
650
-	}
651
-
652
-	$functions = array_unique( $functions );
653
-	sort( $functions );
654
-
655
-	/**
656
-	 * Filters the list of functions and classes to be ignored from the documentation lookup.
657
-	 *
658
-	 * @since 2.8.0
659
-	 *
660
-	 * @param string[] $ignore_functions Array of names of functions and classes to be ignored.
661
-	 */
662
-	$ignore_functions = apply_filters( 'documentation_ignore_functions', $ignore_functions );
663
-
664
-	$ignore_functions = array_unique( $ignore_functions );
665
-
666
-	$out = array();
667
-
668
-	foreach ( $functions as $function ) {
669
-		if ( in_array( $function, $ignore_functions, true ) ) {
670
-			continue;
671
-		}
672
-
673
-		$out[] = $function;
674
-	}
675
-
676
-	return $out;
621
+    if ( ! is_string( $content ) || empty( $content ) ) {
622
+        return array();
623
+    }
624
+
625
+    if ( ! function_exists( 'token_get_all' ) ) {
626
+        return array();
627
+    }
628
+
629
+    $tokens           = token_get_all( $content );
630
+    $count            = count( $tokens );
631
+    $functions        = array();
632
+    $ignore_functions = array();
633
+
634
+    for ( $t = 0; $t < $count - 2; $t++ ) {
635
+        if ( ! is_array( $tokens[ $t ] ) ) {
636
+            continue;
637
+        }
638
+
639
+        if ( T_STRING === $tokens[ $t ][0] && ( '(' === $tokens[ $t + 1 ] || '(' === $tokens[ $t + 2 ] ) ) {
640
+            // If it's a function or class defined locally, there's not going to be any docs available.
641
+            if ( ( isset( $tokens[ $t - 2 ][1] ) && in_array( $tokens[ $t - 2 ][1], array( 'function', 'class' ), true ) )
642
+                || ( isset( $tokens[ $t - 2 ][0] ) && T_OBJECT_OPERATOR === $tokens[ $t - 1 ][0] )
643
+            ) {
644
+                $ignore_functions[] = $tokens[ $t ][1];
645
+            }
646
+
647
+            // Add this to our stack of unique references.
648
+            $functions[] = $tokens[ $t ][1];
649
+        }
650
+    }
651
+
652
+    $functions = array_unique( $functions );
653
+    sort( $functions );
654
+
655
+    /**
656
+     * Filters the list of functions and classes to be ignored from the documentation lookup.
657
+     *
658
+     * @since 2.8.0
659
+     *
660
+     * @param string[] $ignore_functions Array of names of functions and classes to be ignored.
661
+     */
662
+    $ignore_functions = apply_filters( 'documentation_ignore_functions', $ignore_functions );
663
+
664
+    $ignore_functions = array_unique( $ignore_functions );
665
+
666
+    $out = array();
667
+
668
+    foreach ( $functions as $function ) {
669
+        if ( in_array( $function, $ignore_functions, true ) ) {
670
+            continue;
671
+        }
672
+
673
+        $out[] = $function;
674
+    }
675
+
676
+    return $out;
677 677
 }
678 678
 
679 679
 /**
@@ -682,122 +682,122 @@  discard block
 block discarded – undo
682 682
  * @since 2.8.0
683 683
  */
684 684
 function set_screen_options() {
685
-	if ( ! isset( $_POST['wp_screen_options'] ) || ! is_array( $_POST['wp_screen_options'] ) ) {
686
-		return;
687
-	}
688
-
689
-	check_admin_referer( 'screen-options-nonce', 'screenoptionnonce' );
690
-
691
-	$user = wp_get_current_user();
692
-
693
-	if ( ! $user ) {
694
-		return;
695
-	}
696
-
697
-	$option = $_POST['wp_screen_options']['option'];
698
-	$value  = $_POST['wp_screen_options']['value'];
699
-
700
-	if ( sanitize_key( $option ) !== $option ) {
701
-		return;
702
-	}
703
-
704
-	$map_option = $option;
705
-	$type       = str_replace( 'edit_', '', $map_option );
706
-	$type       = str_replace( '_per_page', '', $type );
707
-
708
-	if ( in_array( $type, get_taxonomies(), true ) ) {
709
-		$map_option = 'edit_tags_per_page';
710
-	} elseif ( in_array( $type, get_post_types(), true ) ) {
711
-		$map_option = 'edit_per_page';
712
-	} else {
713
-		$option = str_replace( '-', '_', $option );
714
-	}
715
-
716
-	switch ( $map_option ) {
717
-		case 'edit_per_page':
718
-		case 'users_per_page':
719
-		case 'edit_comments_per_page':
720
-		case 'upload_per_page':
721
-		case 'edit_tags_per_page':
722
-		case 'plugins_per_page':
723
-		case 'export_personal_data_requests_per_page':
724
-		case 'remove_personal_data_requests_per_page':
725
-			// Network admin.
726
-		case 'sites_network_per_page':
727
-		case 'users_network_per_page':
728
-		case 'site_users_network_per_page':
729
-		case 'plugins_network_per_page':
730
-		case 'themes_network_per_page':
731
-		case 'site_themes_network_per_page':
732
-			$value = (int) $value;
733
-
734
-			if ( $value < 1 || $value > 999 ) {
735
-				return;
736
-			}
737
-
738
-			break;
739
-
740
-		default:
741
-			$screen_option = false;
742
-
743
-			if ( '_page' === substr( $option, -5 ) || 'layout_columns' === $option ) {
744
-				/**
745
-				 * Filters a screen option value before it is set.
746
-				 *
747
-				 * The filter can also be used to modify non-standard [items]_per_page
748
-				 * settings. See the parent function for a full list of standard options.
749
-				 *
750
-				 * Returning false from the filter will skip saving the current option.
751
-				 *
752
-				 * @since 2.8.0
753
-				 * @since 5.4.2 Only applied to options ending with '_page',
754
-				 *              or the 'layout_columns' option.
755
-				 *
756
-				 * @see set_screen_options()
757
-				 *
758
-				 * @param mixed  $screen_option The value to save instead of the option value.
759
-				 *                              Default false (to skip saving the current option).
760
-				 * @param string $option        The option name.
761
-				 * @param int    $value         The option value.
762
-				 */
763
-				$screen_option = apply_filters( 'set-screen-option', $screen_option, $option, $value ); // phpcs:ignore WordPress.NamingConventions.ValidHookName.UseUnderscores
764
-			}
765
-
766
-			/**
767
-			 * Filters a screen option value before it is set.
768
-			 *
769
-			 * The dynamic portion of the hook name, `$option`, refers to the option name.
770
-			 *
771
-			 * Returning false from the filter will skip saving the current option.
772
-			 *
773
-			 * @since 5.4.2
774
-			 *
775
-			 * @see set_screen_options()
776
-			 *
777
-			 * @param mixed   $screen_option The value to save instead of the option value.
778
-			 *                               Default false (to skip saving the current option).
779
-			 * @param string  $option        The option name.
780
-			 * @param int     $value         The option value.
781
-			 */
782
-			$value = apply_filters( "set_screen_option_{$option}", $screen_option, $option, $value );
783
-
784
-			if ( false === $value ) {
785
-				return;
786
-			}
787
-
788
-			break;
789
-	}
790
-
791
-	update_user_meta( $user->ID, $option, $value );
792
-
793
-	$url = remove_query_arg( array( 'pagenum', 'apage', 'paged' ), wp_get_referer() );
794
-
795
-	if ( isset( $_POST['mode'] ) ) {
796
-		$url = add_query_arg( array( 'mode' => $_POST['mode'] ), $url );
797
-	}
798
-
799
-	wp_safe_redirect( $url );
800
-	exit;
685
+    if ( ! isset( $_POST['wp_screen_options'] ) || ! is_array( $_POST['wp_screen_options'] ) ) {
686
+        return;
687
+    }
688
+
689
+    check_admin_referer( 'screen-options-nonce', 'screenoptionnonce' );
690
+
691
+    $user = wp_get_current_user();
692
+
693
+    if ( ! $user ) {
694
+        return;
695
+    }
696
+
697
+    $option = $_POST['wp_screen_options']['option'];
698
+    $value  = $_POST['wp_screen_options']['value'];
699
+
700
+    if ( sanitize_key( $option ) !== $option ) {
701
+        return;
702
+    }
703
+
704
+    $map_option = $option;
705
+    $type       = str_replace( 'edit_', '', $map_option );
706
+    $type       = str_replace( '_per_page', '', $type );
707
+
708
+    if ( in_array( $type, get_taxonomies(), true ) ) {
709
+        $map_option = 'edit_tags_per_page';
710
+    } elseif ( in_array( $type, get_post_types(), true ) ) {
711
+        $map_option = 'edit_per_page';
712
+    } else {
713
+        $option = str_replace( '-', '_', $option );
714
+    }
715
+
716
+    switch ( $map_option ) {
717
+        case 'edit_per_page':
718
+        case 'users_per_page':
719
+        case 'edit_comments_per_page':
720
+        case 'upload_per_page':
721
+        case 'edit_tags_per_page':
722
+        case 'plugins_per_page':
723
+        case 'export_personal_data_requests_per_page':
724
+        case 'remove_personal_data_requests_per_page':
725
+            // Network admin.
726
+        case 'sites_network_per_page':
727
+        case 'users_network_per_page':
728
+        case 'site_users_network_per_page':
729
+        case 'plugins_network_per_page':
730
+        case 'themes_network_per_page':
731
+        case 'site_themes_network_per_page':
732
+            $value = (int) $value;
733
+
734
+            if ( $value < 1 || $value > 999 ) {
735
+                return;
736
+            }
737
+
738
+            break;
739
+
740
+        default:
741
+            $screen_option = false;
742
+
743
+            if ( '_page' === substr( $option, -5 ) || 'layout_columns' === $option ) {
744
+                /**
745
+                 * Filters a screen option value before it is set.
746
+                 *
747
+                 * The filter can also be used to modify non-standard [items]_per_page
748
+                 * settings. See the parent function for a full list of standard options.
749
+                 *
750
+                 * Returning false from the filter will skip saving the current option.
751
+                 *
752
+                 * @since 2.8.0
753
+                 * @since 5.4.2 Only applied to options ending with '_page',
754
+                 *              or the 'layout_columns' option.
755
+                 *
756
+                 * @see set_screen_options()
757
+                 *
758
+                 * @param mixed  $screen_option The value to save instead of the option value.
759
+                 *                              Default false (to skip saving the current option).
760
+                 * @param string $option        The option name.
761
+                 * @param int    $value         The option value.
762
+                 */
763
+                $screen_option = apply_filters( 'set-screen-option', $screen_option, $option, $value ); // phpcs:ignore WordPress.NamingConventions.ValidHookName.UseUnderscores
764
+            }
765
+
766
+            /**
767
+             * Filters a screen option value before it is set.
768
+             *
769
+             * The dynamic portion of the hook name, `$option`, refers to the option name.
770
+             *
771
+             * Returning false from the filter will skip saving the current option.
772
+             *
773
+             * @since 5.4.2
774
+             *
775
+             * @see set_screen_options()
776
+             *
777
+             * @param mixed   $screen_option The value to save instead of the option value.
778
+             *                               Default false (to skip saving the current option).
779
+             * @param string  $option        The option name.
780
+             * @param int     $value         The option value.
781
+             */
782
+            $value = apply_filters( "set_screen_option_{$option}", $screen_option, $option, $value );
783
+
784
+            if ( false === $value ) {
785
+                return;
786
+            }
787
+
788
+            break;
789
+    }
790
+
791
+    update_user_meta( $user->ID, $option, $value );
792
+
793
+    $url = remove_query_arg( array( 'pagenum', 'apage', 'paged' ), wp_get_referer() );
794
+
795
+    if ( isset( $_POST['mode'] ) ) {
796
+        $url = add_query_arg( array( 'mode' => $_POST['mode'] ), $url );
797
+    }
798
+
799
+    wp_safe_redirect( $url );
800
+    exit;
801 801
 }
802 802
 
803 803
 /**
@@ -809,28 +809,28 @@  discard block
 block discarded – undo
809 809
  * @return bool
810 810
  */
811 811
 function iis7_rewrite_rule_exists( $filename ) {
812
-	if ( ! file_exists( $filename ) ) {
813
-		return false;
814
-	}
812
+    if ( ! file_exists( $filename ) ) {
813
+        return false;
814
+    }
815 815
 
816
-	if ( ! class_exists( 'DOMDocument', false ) ) {
817
-		return false;
818
-	}
816
+    if ( ! class_exists( 'DOMDocument', false ) ) {
817
+        return false;
818
+    }
819 819
 
820
-	$doc = new DOMDocument();
820
+    $doc = new DOMDocument();
821 821
 
822
-	if ( $doc->load( $filename ) === false ) {
823
-		return false;
824
-	}
822
+    if ( $doc->load( $filename ) === false ) {
823
+        return false;
824
+    }
825 825
 
826
-	$xpath = new DOMXPath( $doc );
827
-	$rules = $xpath->query( '/configuration/system.webServer/rewrite/rules/rule[starts-with(@name,\'wordpress\')] | /configuration/system.webServer/rewrite/rules/rule[starts-with(@name,\'WordPress\')]' );
826
+    $xpath = new DOMXPath( $doc );
827
+    $rules = $xpath->query( '/configuration/system.webServer/rewrite/rules/rule[starts-with(@name,\'wordpress\')] | /configuration/system.webServer/rewrite/rules/rule[starts-with(@name,\'WordPress\')]' );
828 828
 
829
-	if ( 0 === $rules->length ) {
830
-		return false;
831
-	}
829
+    if ( 0 === $rules->length ) {
830
+        return false;
831
+    }
832 832
 
833
-	return true;
833
+    return true;
834 834
 }
835 835
 
836 836
 /**
@@ -842,34 +842,34 @@  discard block
 block discarded – undo
842 842
  * @return bool
843 843
  */
844 844
 function iis7_delete_rewrite_rule( $filename ) {
845
-	// If configuration file does not exist then rules also do not exist, so there is nothing to delete.
846
-	if ( ! file_exists( $filename ) ) {
847
-		return true;
848
-	}
849
-
850
-	if ( ! class_exists( 'DOMDocument', false ) ) {
851
-		return false;
852
-	}
853
-
854
-	$doc                     = new DOMDocument();
855
-	$doc->preserveWhiteSpace = false;
856
-
857
-	if ( $doc->load( $filename ) === false ) {
858
-		return false;
859
-	}
860
-
861
-	$xpath = new DOMXPath( $doc );
862
-	$rules = $xpath->query( '/configuration/system.webServer/rewrite/rules/rule[starts-with(@name,\'wordpress\')] | /configuration/system.webServer/rewrite/rules/rule[starts-with(@name,\'WordPress\')]' );
863
-
864
-	if ( $rules->length > 0 ) {
865
-		$child  = $rules->item( 0 );
866
-		$parent = $child->parentNode;
867
-		$parent->removeChild( $child );
868
-		$doc->formatOutput = true;
869
-		saveDomDocument( $doc, $filename );
870
-	}
871
-
872
-	return true;
845
+    // If configuration file does not exist then rules also do not exist, so there is nothing to delete.
846
+    if ( ! file_exists( $filename ) ) {
847
+        return true;
848
+    }
849
+
850
+    if ( ! class_exists( 'DOMDocument', false ) ) {
851
+        return false;
852
+    }
853
+
854
+    $doc                     = new DOMDocument();
855
+    $doc->preserveWhiteSpace = false;
856
+
857
+    if ( $doc->load( $filename ) === false ) {
858
+        return false;
859
+    }
860
+
861
+    $xpath = new DOMXPath( $doc );
862
+    $rules = $xpath->query( '/configuration/system.webServer/rewrite/rules/rule[starts-with(@name,\'wordpress\')] | /configuration/system.webServer/rewrite/rules/rule[starts-with(@name,\'WordPress\')]' );
863
+
864
+    if ( $rules->length > 0 ) {
865
+        $child  = $rules->item( 0 );
866
+        $parent = $child->parentNode;
867
+        $parent->removeChild( $child );
868
+        $doc->formatOutput = true;
869
+        saveDomDocument( $doc, $filename );
870
+    }
871
+
872
+    return true;
873 873
 }
874 874
 
875 875
 /**
@@ -882,82 +882,82 @@  discard block
 block discarded – undo
882 882
  * @return bool
883 883
  */
884 884
 function iis7_add_rewrite_rule( $filename, $rewrite_rule ) {
885
-	if ( ! class_exists( 'DOMDocument', false ) ) {
886
-		return false;
887
-	}
888
-
889
-	// If configuration file does not exist then we create one.
890
-	if ( ! file_exists( $filename ) ) {
891
-		$fp = fopen( $filename, 'w' );
892
-		fwrite( $fp, '<configuration/>' );
893
-		fclose( $fp );
894
-	}
895
-
896
-	$doc                     = new DOMDocument();
897
-	$doc->preserveWhiteSpace = false;
898
-
899
-	if ( $doc->load( $filename ) === false ) {
900
-		return false;
901
-	}
902
-
903
-	$xpath = new DOMXPath( $doc );
904
-
905
-	// First check if the rule already exists as in that case there is no need to re-add it.
906
-	$wordpress_rules = $xpath->query( '/configuration/system.webServer/rewrite/rules/rule[starts-with(@name,\'wordpress\')] | /configuration/system.webServer/rewrite/rules/rule[starts-with(@name,\'WordPress\')]' );
907
-
908
-	if ( $wordpress_rules->length > 0 ) {
909
-		return true;
910
-	}
911
-
912
-	// Check the XPath to the rewrite rule and create XML nodes if they do not exist.
913
-	$xml_nodes = $xpath->query( '/configuration/system.webServer/rewrite/rules' );
914
-
915
-	if ( $xml_nodes->length > 0 ) {
916
-		$rules_node = $xml_nodes->item( 0 );
917
-	} else {
918
-		$rules_node = $doc->createElement( 'rules' );
919
-
920
-		$xml_nodes = $xpath->query( '/configuration/system.webServer/rewrite' );
921
-
922
-		if ( $xml_nodes->length > 0 ) {
923
-			$rewrite_node = $xml_nodes->item( 0 );
924
-			$rewrite_node->appendChild( $rules_node );
925
-		} else {
926
-			$rewrite_node = $doc->createElement( 'rewrite' );
927
-			$rewrite_node->appendChild( $rules_node );
928
-
929
-			$xml_nodes = $xpath->query( '/configuration/system.webServer' );
930
-
931
-			if ( $xml_nodes->length > 0 ) {
932
-				$system_web_server_node = $xml_nodes->item( 0 );
933
-				$system_web_server_node->appendChild( $rewrite_node );
934
-			} else {
935
-				$system_web_server_node = $doc->createElement( 'system.webServer' );
936
-				$system_web_server_node->appendChild( $rewrite_node );
937
-
938
-				$xml_nodes = $xpath->query( '/configuration' );
939
-
940
-				if ( $xml_nodes->length > 0 ) {
941
-					$config_node = $xml_nodes->item( 0 );
942
-					$config_node->appendChild( $system_web_server_node );
943
-				} else {
944
-					$config_node = $doc->createElement( 'configuration' );
945
-					$doc->appendChild( $config_node );
946
-					$config_node->appendChild( $system_web_server_node );
947
-				}
948
-			}
949
-		}
950
-	}
951
-
952
-	$rule_fragment = $doc->createDocumentFragment();
953
-	$rule_fragment->appendXML( $rewrite_rule );
954
-	$rules_node->appendChild( $rule_fragment );
955
-
956
-	$doc->encoding     = 'UTF-8';
957
-	$doc->formatOutput = true;
958
-	saveDomDocument( $doc, $filename );
959
-
960
-	return true;
885
+    if ( ! class_exists( 'DOMDocument', false ) ) {
886
+        return false;
887
+    }
888
+
889
+    // If configuration file does not exist then we create one.
890
+    if ( ! file_exists( $filename ) ) {
891
+        $fp = fopen( $filename, 'w' );
892
+        fwrite( $fp, '<configuration/>' );
893
+        fclose( $fp );
894
+    }
895
+
896
+    $doc                     = new DOMDocument();
897
+    $doc->preserveWhiteSpace = false;
898
+
899
+    if ( $doc->load( $filename ) === false ) {
900
+        return false;
901
+    }
902
+
903
+    $xpath = new DOMXPath( $doc );
904
+
905
+    // First check if the rule already exists as in that case there is no need to re-add it.
906
+    $wordpress_rules = $xpath->query( '/configuration/system.webServer/rewrite/rules/rule[starts-with(@name,\'wordpress\')] | /configuration/system.webServer/rewrite/rules/rule[starts-with(@name,\'WordPress\')]' );
907
+
908
+    if ( $wordpress_rules->length > 0 ) {
909
+        return true;
910
+    }
911
+
912
+    // Check the XPath to the rewrite rule and create XML nodes if they do not exist.
913
+    $xml_nodes = $xpath->query( '/configuration/system.webServer/rewrite/rules' );
914
+
915
+    if ( $xml_nodes->length > 0 ) {
916
+        $rules_node = $xml_nodes->item( 0 );
917
+    } else {
918
+        $rules_node = $doc->createElement( 'rules' );
919
+
920
+        $xml_nodes = $xpath->query( '/configuration/system.webServer/rewrite' );
921
+
922
+        if ( $xml_nodes->length > 0 ) {
923
+            $rewrite_node = $xml_nodes->item( 0 );
924
+            $rewrite_node->appendChild( $rules_node );
925
+        } else {
926
+            $rewrite_node = $doc->createElement( 'rewrite' );
927
+            $rewrite_node->appendChild( $rules_node );
928
+
929
+            $xml_nodes = $xpath->query( '/configuration/system.webServer' );
930
+
931
+            if ( $xml_nodes->length > 0 ) {
932
+                $system_web_server_node = $xml_nodes->item( 0 );
933
+                $system_web_server_node->appendChild( $rewrite_node );
934
+            } else {
935
+                $system_web_server_node = $doc->createElement( 'system.webServer' );
936
+                $system_web_server_node->appendChild( $rewrite_node );
937
+
938
+                $xml_nodes = $xpath->query( '/configuration' );
939
+
940
+                if ( $xml_nodes->length > 0 ) {
941
+                    $config_node = $xml_nodes->item( 0 );
942
+                    $config_node->appendChild( $system_web_server_node );
943
+                } else {
944
+                    $config_node = $doc->createElement( 'configuration' );
945
+                    $doc->appendChild( $config_node );
946
+                    $config_node->appendChild( $system_web_server_node );
947
+                }
948
+            }
949
+        }
950
+    }
951
+
952
+    $rule_fragment = $doc->createDocumentFragment();
953
+    $rule_fragment->appendXML( $rewrite_rule );
954
+    $rules_node->appendChild( $rule_fragment );
955
+
956
+    $doc->encoding     = 'UTF-8';
957
+    $doc->formatOutput = true;
958
+    saveDomDocument( $doc, $filename );
959
+
960
+    return true;
961 961
 }
962 962
 
963 963
 /**
@@ -969,12 +969,12 @@  discard block
 block discarded – undo
969 969
  * @param string      $filename
970 970
  */
971 971
 function saveDomDocument( $doc, $filename ) { // phpcs:ignore WordPress.NamingConventions.ValidFunctionName.FunctionNameInvalid
972
-	$config = $doc->saveXML();
973
-	$config = preg_replace( "/([^\r])\n/", "$1\r\n", $config );
972
+    $config = $doc->saveXML();
973
+    $config = preg_replace( "/([^\r])\n/", "$1\r\n", $config );
974 974
 
975
-	$fp = fopen( $filename, 'w' );
976
-	fwrite( $fp, $config );
977
-	fclose( $fp );
975
+    $fp = fopen( $filename, 'w' );
976
+    fwrite( $fp, $config );
977
+    fclose( $fp );
978 978
 }
979 979
 
980 980
 /**
@@ -987,37 +987,37 @@  discard block
 block discarded – undo
987 987
  * @param int $user_id User ID.
988 988
  */
989 989
 function admin_color_scheme_picker( $user_id ) {
990
-	global $_wp_admin_css_colors;
991
-
992
-	ksort( $_wp_admin_css_colors );
993
-
994
-	if ( isset( $_wp_admin_css_colors['fresh'] ) ) {
995
-		// Set Default ('fresh') and Light should go first.
996
-		$_wp_admin_css_colors = array_filter(
997
-			array_merge(
998
-				array(
999
-					'fresh'  => '',
1000
-					'light'  => '',
1001
-					'modern' => '',
1002
-				),
1003
-				$_wp_admin_css_colors
1004
-			)
1005
-		);
1006
-	}
1007
-
1008
-	$current_color = get_user_option( 'admin_color', $user_id );
1009
-
1010
-	if ( empty( $current_color ) || ! isset( $_wp_admin_css_colors[ $current_color ] ) ) {
1011
-		$current_color = 'fresh';
1012
-	}
1013
-	?>
990
+    global $_wp_admin_css_colors;
991
+
992
+    ksort( $_wp_admin_css_colors );
993
+
994
+    if ( isset( $_wp_admin_css_colors['fresh'] ) ) {
995
+        // Set Default ('fresh') and Light should go first.
996
+        $_wp_admin_css_colors = array_filter(
997
+            array_merge(
998
+                array(
999
+                    'fresh'  => '',
1000
+                    'light'  => '',
1001
+                    'modern' => '',
1002
+                ),
1003
+                $_wp_admin_css_colors
1004
+            )
1005
+        );
1006
+    }
1007
+
1008
+    $current_color = get_user_option( 'admin_color', $user_id );
1009
+
1010
+    if ( empty( $current_color ) || ! isset( $_wp_admin_css_colors[ $current_color ] ) ) {
1011
+        $current_color = 'fresh';
1012
+    }
1013
+    ?>
1014 1014
 	<fieldset id="color-picker" class="scheme-list">
1015 1015
 		<legend class="screen-reader-text"><span><?php _e( 'Admin Color Scheme' ); ?></span></legend>
1016 1016
 		<?php
1017
-		wp_nonce_field( 'save-color-scheme', 'color-nonce', false );
1018
-		foreach ( $_wp_admin_css_colors as $color => $color_info ) :
1017
+        wp_nonce_field( 'save-color-scheme', 'color-nonce', false );
1018
+        foreach ( $_wp_admin_css_colors as $color => $color_info ) :
1019 1019
 
1020
-			?>
1020
+            ?>
1021 1021
 			<div class="color-option <?php echo ( $color === $current_color ) ? 'selected' : ''; ?>">
1022 1022
 				<input name="admin_color" id="admin_color_<?php echo esc_attr( $color ); ?>" type="radio" value="<?php echo esc_attr( $color ); ?>" class="tog" <?php checked( $color, $current_color ); ?> />
1023 1023
 				<input type="hidden" class="css_url" value="<?php echo esc_url( $color_info->url ); ?>" />
@@ -1026,19 +1026,19 @@  discard block
 block discarded – undo
1026 1026
 				<table class="color-palette">
1027 1027
 					<tr>
1028 1028
 					<?php
1029
-					foreach ( $color_info->colors as $html_color ) {
1030
-						?>
1029
+                    foreach ( $color_info->colors as $html_color ) {
1030
+                        ?>
1031 1031
 						<td style="background-color: <?php echo esc_attr( $html_color ); ?>">&nbsp;</td>
1032 1032
 						<?php
1033
-					}
1034
-					?>
1033
+                    }
1034
+                    ?>
1035 1035
 					</tr>
1036 1036
 				</table>
1037 1037
 			</div>
1038 1038
 			<?php
1039 1039
 
1040
-		endforeach;
1041
-		?>
1040
+        endforeach;
1041
+        ?>
1042 1042
 	</fieldset>
1043 1043
 	<?php
1044 1044
 }
@@ -1048,29 +1048,29 @@  discard block
 block discarded – undo
1048 1048
  * @global array $_wp_admin_css_colors
1049 1049
  */
1050 1050
 function wp_color_scheme_settings() {
1051
-	global $_wp_admin_css_colors;
1052
-
1053
-	$color_scheme = get_user_option( 'admin_color' );
1054
-
1055
-	// It's possible to have a color scheme set that is no longer registered.
1056
-	if ( empty( $_wp_admin_css_colors[ $color_scheme ] ) ) {
1057
-		$color_scheme = 'fresh';
1058
-	}
1059
-
1060
-	if ( ! empty( $_wp_admin_css_colors[ $color_scheme ]->icon_colors ) ) {
1061
-		$icon_colors = $_wp_admin_css_colors[ $color_scheme ]->icon_colors;
1062
-	} elseif ( ! empty( $_wp_admin_css_colors['fresh']->icon_colors ) ) {
1063
-		$icon_colors = $_wp_admin_css_colors['fresh']->icon_colors;
1064
-	} else {
1065
-		// Fall back to the default set of icon colors if the default scheme is missing.
1066
-		$icon_colors = array(
1067
-			'base'    => '#a7aaad',
1068
-			'focus'   => '#72aee6',
1069
-			'current' => '#fff',
1070
-		);
1071
-	}
1072
-
1073
-	echo '<script type="text/javascript">var _wpColorScheme = ' . wp_json_encode( array( 'icons' => $icon_colors ) ) . ";</script>\n";
1051
+    global $_wp_admin_css_colors;
1052
+
1053
+    $color_scheme = get_user_option( 'admin_color' );
1054
+
1055
+    // It's possible to have a color scheme set that is no longer registered.
1056
+    if ( empty( $_wp_admin_css_colors[ $color_scheme ] ) ) {
1057
+        $color_scheme = 'fresh';
1058
+    }
1059
+
1060
+    if ( ! empty( $_wp_admin_css_colors[ $color_scheme ]->icon_colors ) ) {
1061
+        $icon_colors = $_wp_admin_css_colors[ $color_scheme ]->icon_colors;
1062
+    } elseif ( ! empty( $_wp_admin_css_colors['fresh']->icon_colors ) ) {
1063
+        $icon_colors = $_wp_admin_css_colors['fresh']->icon_colors;
1064
+    } else {
1065
+        // Fall back to the default set of icon colors if the default scheme is missing.
1066
+        $icon_colors = array(
1067
+            'base'    => '#a7aaad',
1068
+            'focus'   => '#72aee6',
1069
+            'current' => '#fff',
1070
+        );
1071
+    }
1072
+
1073
+    echo '<script type="text/javascript">var _wpColorScheme = ' . wp_json_encode( array( 'icons' => $icon_colors ) ) . ";</script>\n";
1074 1074
 }
1075 1075
 
1076 1076
 /**
@@ -1079,20 +1079,20 @@  discard block
 block discarded – undo
1079 1079
  * @since 5.5.0
1080 1080
  */
1081 1081
 function wp_admin_viewport_meta() {
1082
-	/**
1083
-	 * Filters the viewport meta in the admin.
1084
-	 *
1085
-	 * @since 5.5.0
1086
-	 *
1087
-	 * @param string $viewport_meta The viewport meta.
1088
-	 */
1089
-	$viewport_meta = apply_filters( 'admin_viewport_meta', 'width=device-width,initial-scale=1.0' );
1090
-
1091
-	if ( empty( $viewport_meta ) ) {
1092
-		return;
1093
-	}
1094
-
1095
-	echo '<meta name="viewport" content="' . esc_attr( $viewport_meta ) . '">';
1082
+    /**
1083
+     * Filters the viewport meta in the admin.
1084
+     *
1085
+     * @since 5.5.0
1086
+     *
1087
+     * @param string $viewport_meta The viewport meta.
1088
+     */
1089
+    $viewport_meta = apply_filters( 'admin_viewport_meta', 'width=device-width,initial-scale=1.0' );
1090
+
1091
+    if ( empty( $viewport_meta ) ) {
1092
+        return;
1093
+    }
1094
+
1095
+    echo '<meta name="viewport" content="' . esc_attr( $viewport_meta ) . '">';
1096 1096
 }
1097 1097
 
1098 1098
 /**
@@ -1106,7 +1106,7 @@  discard block
 block discarded – undo
1106 1106
  * @return string Filtered viewport meta.
1107 1107
  */
1108 1108
 function _customizer_mobile_viewport_meta( $viewport_meta ) {
1109
-	return trim( $viewport_meta, ',' ) . ',minimum-scale=0.5,maximum-scale=1.2';
1109
+    return trim( $viewport_meta, ',' ) . ',minimum-scale=0.5,maximum-scale=1.2';
1110 1110
 }
1111 1111
 
1112 1112
 /**
@@ -1120,44 +1120,44 @@  discard block
 block discarded – undo
1120 1120
  * @return array The Heartbeat response.
1121 1121
  */
1122 1122
 function wp_check_locked_posts( $response, $data, $screen_id ) {
1123
-	$checked = array();
1123
+    $checked = array();
1124 1124
 
1125
-	if ( array_key_exists( 'wp-check-locked-posts', $data ) && is_array( $data['wp-check-locked-posts'] ) ) {
1126
-		foreach ( $data['wp-check-locked-posts'] as $key ) {
1127
-			$post_id = absint( substr( $key, 5 ) );
1125
+    if ( array_key_exists( 'wp-check-locked-posts', $data ) && is_array( $data['wp-check-locked-posts'] ) ) {
1126
+        foreach ( $data['wp-check-locked-posts'] as $key ) {
1127
+            $post_id = absint( substr( $key, 5 ) );
1128 1128
 
1129
-			if ( ! $post_id ) {
1130
-				continue;
1131
-			}
1129
+            if ( ! $post_id ) {
1130
+                continue;
1131
+            }
1132 1132
 
1133
-			$user_id = wp_check_post_lock( $post_id );
1133
+            $user_id = wp_check_post_lock( $post_id );
1134 1134
 
1135
-			if ( $user_id ) {
1136
-				$user = get_userdata( $user_id );
1135
+            if ( $user_id ) {
1136
+                $user = get_userdata( $user_id );
1137 1137
 
1138
-				if ( $user && current_user_can( 'edit_post', $post_id ) ) {
1139
-					$send = array(
1140
-						'name' => $user->display_name,
1141
-						/* translators: %s: User's display name. */
1142
-						'text' => sprintf( __( '%s is currently editing' ), $user->display_name ),
1143
-					);
1138
+                if ( $user && current_user_can( 'edit_post', $post_id ) ) {
1139
+                    $send = array(
1140
+                        'name' => $user->display_name,
1141
+                        /* translators: %s: User's display name. */
1142
+                        'text' => sprintf( __( '%s is currently editing' ), $user->display_name ),
1143
+                    );
1144 1144
 
1145
-					if ( get_option( 'show_avatars' ) ) {
1146
-						$send['avatar_src']    = get_avatar_url( $user->ID, array( 'size' => 18 ) );
1147
-						$send['avatar_src_2x'] = get_avatar_url( $user->ID, array( 'size' => 36 ) );
1148
-					}
1145
+                    if ( get_option( 'show_avatars' ) ) {
1146
+                        $send['avatar_src']    = get_avatar_url( $user->ID, array( 'size' => 18 ) );
1147
+                        $send['avatar_src_2x'] = get_avatar_url( $user->ID, array( 'size' => 36 ) );
1148
+                    }
1149 1149
 
1150
-					$checked[ $key ] = $send;
1151
-				}
1152
-			}
1153
-		}
1154
-	}
1150
+                    $checked[ $key ] = $send;
1151
+                }
1152
+            }
1153
+        }
1154
+    }
1155 1155
 
1156
-	if ( ! empty( $checked ) ) {
1157
-		$response['wp-check-locked-posts'] = $checked;
1158
-	}
1156
+    if ( ! empty( $checked ) ) {
1157
+        $response['wp-check-locked-posts'] = $checked;
1158
+    }
1159 1159
 
1160
-	return $response;
1160
+    return $response;
1161 1161
 }
1162 1162
 
1163 1163
 /**
@@ -1171,48 +1171,48 @@  discard block
 block discarded – undo
1171 1171
  * @return array The Heartbeat response.
1172 1172
  */
1173 1173
 function wp_refresh_post_lock( $response, $data, $screen_id ) {
1174
-	if ( array_key_exists( 'wp-refresh-post-lock', $data ) ) {
1175
-		$received = $data['wp-refresh-post-lock'];
1176
-		$send     = array();
1174
+    if ( array_key_exists( 'wp-refresh-post-lock', $data ) ) {
1175
+        $received = $data['wp-refresh-post-lock'];
1176
+        $send     = array();
1177 1177
 
1178
-		$post_id = absint( $received['post_id'] );
1178
+        $post_id = absint( $received['post_id'] );
1179 1179
 
1180
-		if ( ! $post_id ) {
1181
-			return $response;
1182
-		}
1180
+        if ( ! $post_id ) {
1181
+            return $response;
1182
+        }
1183 1183
 
1184
-		if ( ! current_user_can( 'edit_post', $post_id ) ) {
1185
-			return $response;
1186
-		}
1184
+        if ( ! current_user_can( 'edit_post', $post_id ) ) {
1185
+            return $response;
1186
+        }
1187 1187
 
1188
-		$user_id = wp_check_post_lock( $post_id );
1189
-		$user    = get_userdata( $user_id );
1188
+        $user_id = wp_check_post_lock( $post_id );
1189
+        $user    = get_userdata( $user_id );
1190 1190
 
1191
-		if ( $user ) {
1192
-			$error = array(
1193
-				'name' => $user->display_name,
1194
-				/* translators: %s: User's display name. */
1195
-				'text' => sprintf( __( '%s has taken over and is currently editing.' ), $user->display_name ),
1196
-			);
1191
+        if ( $user ) {
1192
+            $error = array(
1193
+                'name' => $user->display_name,
1194
+                /* translators: %s: User's display name. */
1195
+                'text' => sprintf( __( '%s has taken over and is currently editing.' ), $user->display_name ),
1196
+            );
1197 1197
 
1198
-			if ( get_option( 'show_avatars' ) ) {
1199
-				$error['avatar_src']    = get_avatar_url( $user->ID, array( 'size' => 64 ) );
1200
-				$error['avatar_src_2x'] = get_avatar_url( $user->ID, array( 'size' => 128 ) );
1201
-			}
1198
+            if ( get_option( 'show_avatars' ) ) {
1199
+                $error['avatar_src']    = get_avatar_url( $user->ID, array( 'size' => 64 ) );
1200
+                $error['avatar_src_2x'] = get_avatar_url( $user->ID, array( 'size' => 128 ) );
1201
+            }
1202 1202
 
1203
-			$send['lock_error'] = $error;
1204
-		} else {
1205
-			$new_lock = wp_set_post_lock( $post_id );
1203
+            $send['lock_error'] = $error;
1204
+        } else {
1205
+            $new_lock = wp_set_post_lock( $post_id );
1206 1206
 
1207
-			if ( $new_lock ) {
1208
-				$send['new_lock'] = implode( ':', $new_lock );
1209
-			}
1210
-		}
1207
+            if ( $new_lock ) {
1208
+                $send['new_lock'] = implode( ':', $new_lock );
1209
+            }
1210
+        }
1211 1211
 
1212
-		$response['wp-refresh-post-lock'] = $send;
1213
-	}
1212
+        $response['wp-refresh-post-lock'] = $send;
1213
+    }
1214 1214
 
1215
-	return $response;
1215
+    return $response;
1216 1216
 }
1217 1217
 
1218 1218
 /**
@@ -1226,33 +1226,33 @@  discard block
 block discarded – undo
1226 1226
  * @return array The Heartbeat response.
1227 1227
  */
1228 1228
 function wp_refresh_post_nonces( $response, $data, $screen_id ) {
1229
-	if ( array_key_exists( 'wp-refresh-post-nonces', $data ) ) {
1230
-		$received = $data['wp-refresh-post-nonces'];
1229
+    if ( array_key_exists( 'wp-refresh-post-nonces', $data ) ) {
1230
+        $received = $data['wp-refresh-post-nonces'];
1231 1231
 
1232
-		$response['wp-refresh-post-nonces'] = array( 'check' => 1 );
1232
+        $response['wp-refresh-post-nonces'] = array( 'check' => 1 );
1233 1233
 
1234
-		$post_id = absint( $received['post_id'] );
1234
+        $post_id = absint( $received['post_id'] );
1235 1235
 
1236
-		if ( ! $post_id ) {
1237
-			return $response;
1238
-		}
1236
+        if ( ! $post_id ) {
1237
+            return $response;
1238
+        }
1239 1239
 
1240
-		if ( ! current_user_can( 'edit_post', $post_id ) ) {
1241
-			return $response;
1242
-		}
1240
+        if ( ! current_user_can( 'edit_post', $post_id ) ) {
1241
+            return $response;
1242
+        }
1243 1243
 
1244
-		$response['wp-refresh-post-nonces'] = array(
1245
-			'replace' => array(
1246
-				'getpermalinknonce'    => wp_create_nonce( 'getpermalink' ),
1247
-				'samplepermalinknonce' => wp_create_nonce( 'samplepermalink' ),
1248
-				'closedpostboxesnonce' => wp_create_nonce( 'closedpostboxes' ),
1249
-				'_ajax_linking_nonce'  => wp_create_nonce( 'internal-linking' ),
1250
-				'_wpnonce'             => wp_create_nonce( 'update-post_' . $post_id ),
1251
-			),
1252
-		);
1253
-	}
1254
-
1255
-	return $response;
1244
+        $response['wp-refresh-post-nonces'] = array(
1245
+            'replace' => array(
1246
+                'getpermalinknonce'    => wp_create_nonce( 'getpermalink' ),
1247
+                'samplepermalinknonce' => wp_create_nonce( 'samplepermalink' ),
1248
+                'closedpostboxesnonce' => wp_create_nonce( 'closedpostboxes' ),
1249
+                '_ajax_linking_nonce'  => wp_create_nonce( 'internal-linking' ),
1250
+                '_wpnonce'             => wp_create_nonce( 'update-post_' . $post_id ),
1251
+            ),
1252
+        );
1253
+    }
1254
+
1255
+    return $response;
1256 1256
 }
1257 1257
 
1258 1258
 /**
@@ -1264,13 +1264,13 @@  discard block
 block discarded – undo
1264 1264
  * @return array The Heartbeat response.
1265 1265
  */
1266 1266
 function wp_refresh_heartbeat_nonces( $response ) {
1267
-	// Refresh the Rest API nonce.
1268
-	$response['rest_nonce'] = wp_create_nonce( 'wp_rest' );
1267
+    // Refresh the Rest API nonce.
1268
+    $response['rest_nonce'] = wp_create_nonce( 'wp_rest' );
1269 1269
 
1270
-	// Refresh the Heartbeat nonce.
1271
-	$response['heartbeat_nonce'] = wp_create_nonce( 'heartbeat-nonce' );
1270
+    // Refresh the Heartbeat nonce.
1271
+    $response['heartbeat_nonce'] = wp_create_nonce( 'heartbeat-nonce' );
1272 1272
 
1273
-	return $response;
1273
+    return $response;
1274 1274
 }
1275 1275
 
1276 1276
 /**
@@ -1284,13 +1284,13 @@  discard block
 block discarded – undo
1284 1284
  * @return array Filtered Heartbeat settings.
1285 1285
  */
1286 1286
 function wp_heartbeat_set_suspension( $settings ) {
1287
-	global $pagenow;
1287
+    global $pagenow;
1288 1288
 
1289
-	if ( 'post.php' === $pagenow || 'post-new.php' === $pagenow ) {
1290
-		$settings['suspension'] = 'disable';
1291
-	}
1289
+    if ( 'post.php' === $pagenow || 'post-new.php' === $pagenow ) {
1290
+        $settings['suspension'] = 'disable';
1291
+    }
1292 1292
 
1293
-	return $settings;
1293
+    return $settings;
1294 1294
 }
1295 1295
 
1296 1296
 /**
@@ -1303,31 +1303,31 @@  discard block
 block discarded – undo
1303 1303
  * @return array The Heartbeat response.
1304 1304
  */
1305 1305
 function heartbeat_autosave( $response, $data ) {
1306
-	if ( ! empty( $data['wp_autosave'] ) ) {
1307
-		$saved = wp_autosave( $data['wp_autosave'] );
1308
-
1309
-		if ( is_wp_error( $saved ) ) {
1310
-			$response['wp_autosave'] = array(
1311
-				'success' => false,
1312
-				'message' => $saved->get_error_message(),
1313
-			);
1314
-		} elseif ( empty( $saved ) ) {
1315
-			$response['wp_autosave'] = array(
1316
-				'success' => false,
1317
-				'message' => __( 'Error while saving.' ),
1318
-			);
1319
-		} else {
1320
-			/* translators: Draft saved date format, see https://www.php.net/manual/datetime.format.php */
1321
-			$draft_saved_date_format = __( 'g:i:s a' );
1322
-			$response['wp_autosave'] = array(
1323
-				'success' => true,
1324
-				/* translators: %s: Date and time. */
1325
-				'message' => sprintf( __( 'Draft saved at %s.' ), date_i18n( $draft_saved_date_format ) ),
1326
-			);
1327
-		}
1328
-	}
1329
-
1330
-	return $response;
1306
+    if ( ! empty( $data['wp_autosave'] ) ) {
1307
+        $saved = wp_autosave( $data['wp_autosave'] );
1308
+
1309
+        if ( is_wp_error( $saved ) ) {
1310
+            $response['wp_autosave'] = array(
1311
+                'success' => false,
1312
+                'message' => $saved->get_error_message(),
1313
+            );
1314
+        } elseif ( empty( $saved ) ) {
1315
+            $response['wp_autosave'] = array(
1316
+                'success' => false,
1317
+                'message' => __( 'Error while saving.' ),
1318
+            );
1319
+        } else {
1320
+            /* translators: Draft saved date format, see https://www.php.net/manual/datetime.format.php */
1321
+            $draft_saved_date_format = __( 'g:i:s a' );
1322
+            $response['wp_autosave'] = array(
1323
+                'success' => true,
1324
+                /* translators: %s: Date and time. */
1325
+                'message' => sprintf( __( 'Draft saved at %s.' ), date_i18n( $draft_saved_date_format ) ),
1326
+            );
1327
+        }
1328
+    }
1329
+
1330
+    return $response;
1331 1331
 }
1332 1332
 
1333 1333
 /**
@@ -1339,16 +1339,16 @@  discard block
 block discarded – undo
1339 1339
  * @since 4.2.0
1340 1340
  */
1341 1341
 function wp_admin_canonical_url() {
1342
-	$removable_query_args = wp_removable_query_args();
1342
+    $removable_query_args = wp_removable_query_args();
1343 1343
 
1344
-	if ( empty( $removable_query_args ) ) {
1345
-		return;
1346
-	}
1344
+    if ( empty( $removable_query_args ) ) {
1345
+        return;
1346
+    }
1347 1347
 
1348
-	// Ensure we're using an absolute URL.
1349
-	$current_url  = set_url_scheme( 'http://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'] );
1350
-	$filtered_url = remove_query_arg( $removable_query_args, $current_url );
1351
-	?>
1348
+    // Ensure we're using an absolute URL.
1349
+    $current_url  = set_url_scheme( 'http://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'] );
1350
+    $filtered_url = remove_query_arg( $removable_query_args, $current_url );
1351
+    ?>
1352 1352
 	<link id="wp-admin-canonical" rel="canonical" href="<?php echo esc_url( $filtered_url ); ?>" />
1353 1353
 	<script>
1354 1354
 		if ( window.history.replaceState ) {
@@ -1364,21 +1364,21 @@  discard block
 block discarded – undo
1364 1364
  * @since 4.9.0
1365 1365
  */
1366 1366
 function wp_admin_headers() {
1367
-	$policy = 'strict-origin-when-cross-origin';
1368
-
1369
-	/**
1370
-	 * Filters the admin referrer policy header value.
1371
-	 *
1372
-	 * @since 4.9.0
1373
-	 * @since 4.9.5 The default value was changed to 'strict-origin-when-cross-origin'.
1374
-	 *
1375
-	 * @link https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Referrer-Policy
1376
-	 *
1377
-	 * @param string $policy The admin referrer policy header value. Default 'strict-origin-when-cross-origin'.
1378
-	 */
1379
-	$policy = apply_filters( 'admin_referrer_policy', $policy );
1380
-
1381
-	header( sprintf( 'Referrer-Policy: %s', $policy ) );
1367
+    $policy = 'strict-origin-when-cross-origin';
1368
+
1369
+    /**
1370
+     * Filters the admin referrer policy header value.
1371
+     *
1372
+     * @since 4.9.0
1373
+     * @since 4.9.5 The default value was changed to 'strict-origin-when-cross-origin'.
1374
+     *
1375
+     * @link https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Referrer-Policy
1376
+     *
1377
+     * @param string $policy The admin referrer policy header value. Default 'strict-origin-when-cross-origin'.
1378
+     */
1379
+    $policy = apply_filters( 'admin_referrer_policy', $policy );
1380
+
1381
+    header( sprintf( 'Referrer-Policy: %s', $policy ) );
1382 1382
 }
1383 1383
 
1384 1384
 /**
@@ -1390,7 +1390,7 @@  discard block
 block discarded – undo
1390 1390
  * @since 4.6.0
1391 1391
  */
1392 1392
 function wp_page_reload_on_back_button_js() {
1393
-	?>
1393
+    ?>
1394 1394
 	<script>
1395 1395
 		if ( typeof performance !== 'undefined' && performance.navigation && performance.navigation.type === 2 ) {
1396 1396
 			document.location.reload( true );
@@ -1411,22 +1411,22 @@  discard block
 block discarded – undo
1411 1411
  * @param string $value     The proposed new site admin email address.
1412 1412
  */
1413 1413
 function update_option_new_admin_email( $old_value, $value ) {
1414
-	if ( get_option( 'admin_email' ) === $value || ! is_email( $value ) ) {
1415
-		return;
1416
-	}
1414
+    if ( get_option( 'admin_email' ) === $value || ! is_email( $value ) ) {
1415
+        return;
1416
+    }
1417 1417
 
1418
-	$hash            = md5( $value . time() . wp_rand() );
1419
-	$new_admin_email = array(
1420
-		'hash'     => $hash,
1421
-		'newemail' => $value,
1422
-	);
1423
-	update_option( 'adminhash', $new_admin_email );
1418
+    $hash            = md5( $value . time() . wp_rand() );
1419
+    $new_admin_email = array(
1420
+        'hash'     => $hash,
1421
+        'newemail' => $value,
1422
+    );
1423
+    update_option( 'adminhash', $new_admin_email );
1424 1424
 
1425
-	$switched_locale = switch_to_locale( get_user_locale() );
1425
+    $switched_locale = switch_to_locale( get_user_locale() );
1426 1426
 
1427
-	/* translators: Do not translate USERNAME, ADMIN_URL, EMAIL, SITENAME, SITEURL: those are placeholders. */
1428
-	$email_text = __(
1429
-		'Howdy ###USERNAME###,
1427
+    /* translators: Do not translate USERNAME, ADMIN_URL, EMAIL, SITENAME, SITEURL: those are placeholders. */
1428
+    $email_text = __(
1429
+        'Howdy ###USERNAME###,
1430 1430
 
1431 1431
 Someone with administrator capabilities recently requested to have the
1432 1432
 administration email address changed on this site:
@@ -1443,57 +1443,57 @@  discard block
 block discarded – undo
1443 1443
 Regards,
1444 1444
 All at ###SITENAME###
1445 1445
 ###SITEURL###'
1446
-	);
1447
-
1448
-	/**
1449
-	 * Filters the text of the email sent when a change of site admin email address is attempted.
1450
-	 *
1451
-	 * The following strings have a special meaning and will get replaced dynamically:
1452
-	 * ###USERNAME###  The current user's username.
1453
-	 * ###ADMIN_URL### The link to click on to confirm the email change.
1454
-	 * ###EMAIL###     The proposed new site admin email address.
1455
-	 * ###SITENAME###  The name of the site.
1456
-	 * ###SITEURL###   The URL to the site.
1457
-	 *
1458
-	 * @since MU (3.0.0)
1459
-	 * @since 4.9.0 This filter is no longer Multisite specific.
1460
-	 *
1461
-	 * @param string $email_text      Text in the email.
1462
-	 * @param array  $new_admin_email {
1463
-	 *     Data relating to the new site admin email address.
1464
-	 *
1465
-	 *     @type string $hash     The secure hash used in the confirmation link URL.
1466
-	 *     @type string $newemail The proposed new site admin email address.
1467
-	 * }
1468
-	 */
1469
-	$content = apply_filters( 'new_admin_email_content', $email_text, $new_admin_email );
1470
-
1471
-	$current_user = wp_get_current_user();
1472
-	$content      = str_replace( '###USERNAME###', $current_user->user_login, $content );
1473
-	$content      = str_replace( '###ADMIN_URL###', esc_url( self_admin_url( 'options.php?adminhash=' . $hash ) ), $content );
1474
-	$content      = str_replace( '###EMAIL###', $value, $content );
1475
-	$content      = str_replace( '###SITENAME###', wp_specialchars_decode( get_option( 'blogname' ), ENT_QUOTES ), $content );
1476
-	$content      = str_replace( '###SITEURL###', home_url(), $content );
1477
-
1478
-	if ( '' !== get_option( 'blogname' ) ) {
1479
-		$site_title = wp_specialchars_decode( get_option( 'blogname' ), ENT_QUOTES );
1480
-	} else {
1481
-		$site_title = parse_url( home_url(), PHP_URL_HOST );
1482
-	}
1483
-
1484
-	wp_mail(
1485
-		$value,
1486
-		sprintf(
1487
-			/* translators: New admin email address notification email subject. %s: Site title. */
1488
-			__( '[%s] New Admin Email Address' ),
1489
-			$site_title
1490
-		),
1491
-		$content
1492
-	);
1493
-
1494
-	if ( $switched_locale ) {
1495
-		restore_previous_locale();
1496
-	}
1446
+    );
1447
+
1448
+    /**
1449
+     * Filters the text of the email sent when a change of site admin email address is attempted.
1450
+     *
1451
+     * The following strings have a special meaning and will get replaced dynamically:
1452
+     * ###USERNAME###  The current user's username.
1453
+     * ###ADMIN_URL### The link to click on to confirm the email change.
1454
+     * ###EMAIL###     The proposed new site admin email address.
1455
+     * ###SITENAME###  The name of the site.
1456
+     * ###SITEURL###   The URL to the site.
1457
+     *
1458
+     * @since MU (3.0.0)
1459
+     * @since 4.9.0 This filter is no longer Multisite specific.
1460
+     *
1461
+     * @param string $email_text      Text in the email.
1462
+     * @param array  $new_admin_email {
1463
+     *     Data relating to the new site admin email address.
1464
+     *
1465
+     *     @type string $hash     The secure hash used in the confirmation link URL.
1466
+     *     @type string $newemail The proposed new site admin email address.
1467
+     * }
1468
+     */
1469
+    $content = apply_filters( 'new_admin_email_content', $email_text, $new_admin_email );
1470
+
1471
+    $current_user = wp_get_current_user();
1472
+    $content      = str_replace( '###USERNAME###', $current_user->user_login, $content );
1473
+    $content      = str_replace( '###ADMIN_URL###', esc_url( self_admin_url( 'options.php?adminhash=' . $hash ) ), $content );
1474
+    $content      = str_replace( '###EMAIL###', $value, $content );
1475
+    $content      = str_replace( '###SITENAME###', wp_specialchars_decode( get_option( 'blogname' ), ENT_QUOTES ), $content );
1476
+    $content      = str_replace( '###SITEURL###', home_url(), $content );
1477
+
1478
+    if ( '' !== get_option( 'blogname' ) ) {
1479
+        $site_title = wp_specialchars_decode( get_option( 'blogname' ), ENT_QUOTES );
1480
+    } else {
1481
+        $site_title = parse_url( home_url(), PHP_URL_HOST );
1482
+    }
1483
+
1484
+    wp_mail(
1485
+        $value,
1486
+        sprintf(
1487
+            /* translators: New admin email address notification email subject. %s: Site title. */
1488
+            __( '[%s] New Admin Email Address' ),
1489
+            $site_title
1490
+        ),
1491
+        $content
1492
+    );
1493
+
1494
+    if ( $switched_locale ) {
1495
+        restore_previous_locale();
1496
+    }
1497 1497
 }
1498 1498
 
1499 1499
 /**
@@ -1508,12 +1508,12 @@  discard block
 block discarded – undo
1508 1508
  * @return string Page title.
1509 1509
  */
1510 1510
 function _wp_privacy_settings_filter_draft_page_titles( $title, $page ) {
1511
-	if ( 'draft' === $page->post_status && 'privacy' === get_current_screen()->id ) {
1512
-		/* translators: %s: Page title. */
1513
-		$title = sprintf( __( '%s (Draft)' ), $title );
1514
-	}
1511
+    if ( 'draft' === $page->post_status && 'privacy' === get_current_screen()->id ) {
1512
+        /* translators: %s: Page title. */
1513
+        $title = sprintf( __( '%s (Draft)' ), $title );
1514
+    }
1515 1515
 
1516
-	return $title;
1516
+    return $title;
1517 1517
 }
1518 1518
 
1519 1519
 /**
@@ -1525,58 +1525,58 @@  discard block
 block discarded – undo
1525 1525
  * @return array|false Array of PHP version data. False on failure.
1526 1526
  */
1527 1527
 function wp_check_php_version() {
1528
-	$version = phpversion();
1529
-	$key     = md5( $version );
1530
-
1531
-	$response = get_site_transient( 'php_check_' . $key );
1532
-
1533
-	if ( false === $response ) {
1534
-		$url = 'http://api.wordpress.org/core/serve-happy/1.0/';
1535
-
1536
-		if ( wp_http_supports( array( 'ssl' ) ) ) {
1537
-			$url = set_url_scheme( $url, 'https' );
1538
-		}
1539
-
1540
-		$url = add_query_arg( 'php_version', $version, $url );
1541
-
1542
-		$response = wp_remote_get( $url );
1543
-
1544
-		if ( is_wp_error( $response ) || 200 !== wp_remote_retrieve_response_code( $response ) ) {
1545
-			return false;
1546
-		}
1547
-
1548
-		/**
1549
-		 * Response should be an array with:
1550
-		 *  'recommended_version' - string - The PHP version recommended by WordPress.
1551
-		 *  'is_supported' - boolean - Whether the PHP version is actively supported.
1552
-		 *  'is_secure' - boolean - Whether the PHP version receives security updates.
1553
-		 *  'is_acceptable' - boolean - Whether the PHP version is still acceptable for WordPress.
1554
-		 */
1555
-		$response = json_decode( wp_remote_retrieve_body( $response ), true );
1556
-
1557
-		if ( ! is_array( $response ) ) {
1558
-			return false;
1559
-		}
1560
-
1561
-		set_site_transient( 'php_check_' . $key, $response, WEEK_IN_SECONDS );
1562
-	}
1563
-
1564
-	if ( isset( $response['is_acceptable'] ) && $response['is_acceptable'] ) {
1565
-		/**
1566
-		 * Filters whether the active PHP version is considered acceptable by WordPress.
1567
-		 *
1568
-		 * Returning false will trigger a PHP version warning to show up in the admin dashboard to administrators.
1569
-		 *
1570
-		 * This filter is only run if the wordpress.org Serve Happy API considers the PHP version acceptable, ensuring
1571
-		 * that this filter can only make this check stricter, but not loosen it.
1572
-		 *
1573
-		 * @since 5.1.1
1574
-		 *
1575
-		 * @param bool   $is_acceptable Whether the PHP version is considered acceptable. Default true.
1576
-		 * @param string $version       PHP version checked.
1577
-		 */
1578
-		$response['is_acceptable'] = (bool) apply_filters( 'wp_is_php_version_acceptable', true, $version );
1579
-	}
1580
-
1581
-	return $response;
1528
+    $version = phpversion();
1529
+    $key     = md5( $version );
1530
+
1531
+    $response = get_site_transient( 'php_check_' . $key );
1532
+
1533
+    if ( false === $response ) {
1534
+        $url = 'http://api.wordpress.org/core/serve-happy/1.0/';
1535
+
1536
+        if ( wp_http_supports( array( 'ssl' ) ) ) {
1537
+            $url = set_url_scheme( $url, 'https' );
1538
+        }
1539
+
1540
+        $url = add_query_arg( 'php_version', $version, $url );
1541
+
1542
+        $response = wp_remote_get( $url );
1543
+
1544
+        if ( is_wp_error( $response ) || 200 !== wp_remote_retrieve_response_code( $response ) ) {
1545
+            return false;
1546
+        }
1547
+
1548
+        /**
1549
+         * Response should be an array with:
1550
+         *  'recommended_version' - string - The PHP version recommended by WordPress.
1551
+         *  'is_supported' - boolean - Whether the PHP version is actively supported.
1552
+         *  'is_secure' - boolean - Whether the PHP version receives security updates.
1553
+         *  'is_acceptable' - boolean - Whether the PHP version is still acceptable for WordPress.
1554
+         */
1555
+        $response = json_decode( wp_remote_retrieve_body( $response ), true );
1556
+
1557
+        if ( ! is_array( $response ) ) {
1558
+            return false;
1559
+        }
1560
+
1561
+        set_site_transient( 'php_check_' . $key, $response, WEEK_IN_SECONDS );
1562
+    }
1563
+
1564
+    if ( isset( $response['is_acceptable'] ) && $response['is_acceptable'] ) {
1565
+        /**
1566
+         * Filters whether the active PHP version is considered acceptable by WordPress.
1567
+         *
1568
+         * Returning false will trigger a PHP version warning to show up in the admin dashboard to administrators.
1569
+         *
1570
+         * This filter is only run if the wordpress.org Serve Happy API considers the PHP version acceptable, ensuring
1571
+         * that this filter can only make this check stricter, but not loosen it.
1572
+         *
1573
+         * @since 5.1.1
1574
+         *
1575
+         * @param bool   $is_acceptable Whether the PHP version is considered acceptable. Default true.
1576
+         * @param string $version       PHP version checked.
1577
+         */
1578
+        $response['is_acceptable'] = (bool) apply_filters( 'wp_is_php_version_acceptable', true, $version );
1579
+    }
1580
+
1581
+    return $response;
1582 1582
 }
Please login to merge, or discard this patch.
brighty/wp-admin/includes/class-wp-ms-sites-list-table.php 1 patch
Indentation   +717 added lines, -717 removed lines patch added patch discarded remove patch
@@ -17,738 +17,738 @@
 block discarded – undo
17 17
  */
18 18
 class WP_MS_Sites_List_Table extends WP_List_Table {
19 19
 
20
-	/**
21
-	 * Site status list.
22
-	 *
23
-	 * @since 4.3.0
24
-	 * @var array
25
-	 */
26
-	public $status_list;
27
-
28
-	/**
29
-	 * Constructor.
30
-	 *
31
-	 * @since 3.1.0
32
-	 *
33
-	 * @see WP_List_Table::__construct() for more information on default arguments.
34
-	 *
35
-	 * @param array $args An associative array of arguments.
36
-	 */
37
-	public function __construct( $args = array() ) {
38
-		$this->status_list = array(
39
-			'archived' => array( 'site-archived', __( 'Archived' ) ),
40
-			'spam'     => array( 'site-spammed', _x( 'Spam', 'site' ) ),
41
-			'deleted'  => array( 'site-deleted', __( 'Deleted' ) ),
42
-			'mature'   => array( 'site-mature', __( 'Mature' ) ),
43
-		);
44
-
45
-		parent::__construct(
46
-			array(
47
-				'plural' => 'sites',
48
-				'screen' => isset( $args['screen'] ) ? $args['screen'] : null,
49
-			)
50
-		);
51
-	}
52
-
53
-	/**
54
-	 * @return bool
55
-	 */
56
-	public function ajax_user_can() {
57
-		return current_user_can( 'manage_sites' );
58
-	}
59
-
60
-	/**
61
-	 * Prepares the list of sites for display.
62
-	 *
63
-	 * @since 3.1.0
64
-	 *
65
-	 * @global string $mode List table view mode.
66
-	 * @global string $s
67
-	 * @global wpdb   $wpdb WordPress database abstraction object.
68
-	 */
69
-	public function prepare_items() {
70
-		global $mode, $s, $wpdb;
71
-
72
-		if ( ! empty( $_REQUEST['mode'] ) ) {
73
-			$mode = 'excerpt' === $_REQUEST['mode'] ? 'excerpt' : 'list';
74
-			set_user_setting( 'sites_list_mode', $mode );
75
-		} else {
76
-			$mode = get_user_setting( 'sites_list_mode', 'list' );
77
-		}
78
-
79
-		$per_page = $this->get_items_per_page( 'sites_network_per_page' );
80
-
81
-		$pagenum = $this->get_pagenum();
82
-
83
-		$s    = isset( $_REQUEST['s'] ) ? wp_unslash( trim( $_REQUEST['s'] ) ) : '';
84
-		$wild = '';
85
-		if ( false !== strpos( $s, '*' ) ) {
86
-			$wild = '*';
87
-			$s    = trim( $s, '*' );
88
-		}
89
-
90
-		/*
20
+    /**
21
+     * Site status list.
22
+     *
23
+     * @since 4.3.0
24
+     * @var array
25
+     */
26
+    public $status_list;
27
+
28
+    /**
29
+     * Constructor.
30
+     *
31
+     * @since 3.1.0
32
+     *
33
+     * @see WP_List_Table::__construct() for more information on default arguments.
34
+     *
35
+     * @param array $args An associative array of arguments.
36
+     */
37
+    public function __construct( $args = array() ) {
38
+        $this->status_list = array(
39
+            'archived' => array( 'site-archived', __( 'Archived' ) ),
40
+            'spam'     => array( 'site-spammed', _x( 'Spam', 'site' ) ),
41
+            'deleted'  => array( 'site-deleted', __( 'Deleted' ) ),
42
+            'mature'   => array( 'site-mature', __( 'Mature' ) ),
43
+        );
44
+
45
+        parent::__construct(
46
+            array(
47
+                'plural' => 'sites',
48
+                'screen' => isset( $args['screen'] ) ? $args['screen'] : null,
49
+            )
50
+        );
51
+    }
52
+
53
+    /**
54
+     * @return bool
55
+     */
56
+    public function ajax_user_can() {
57
+        return current_user_can( 'manage_sites' );
58
+    }
59
+
60
+    /**
61
+     * Prepares the list of sites for display.
62
+     *
63
+     * @since 3.1.0
64
+     *
65
+     * @global string $mode List table view mode.
66
+     * @global string $s
67
+     * @global wpdb   $wpdb WordPress database abstraction object.
68
+     */
69
+    public function prepare_items() {
70
+        global $mode, $s, $wpdb;
71
+
72
+        if ( ! empty( $_REQUEST['mode'] ) ) {
73
+            $mode = 'excerpt' === $_REQUEST['mode'] ? 'excerpt' : 'list';
74
+            set_user_setting( 'sites_list_mode', $mode );
75
+        } else {
76
+            $mode = get_user_setting( 'sites_list_mode', 'list' );
77
+        }
78
+
79
+        $per_page = $this->get_items_per_page( 'sites_network_per_page' );
80
+
81
+        $pagenum = $this->get_pagenum();
82
+
83
+        $s    = isset( $_REQUEST['s'] ) ? wp_unslash( trim( $_REQUEST['s'] ) ) : '';
84
+        $wild = '';
85
+        if ( false !== strpos( $s, '*' ) ) {
86
+            $wild = '*';
87
+            $s    = trim( $s, '*' );
88
+        }
89
+
90
+        /*
91 91
 		 * If the network is large and a search is not being performed, show only
92 92
 		 * the latest sites with no paging in order to avoid expensive count queries.
93 93
 		 */
94
-		if ( ! $s && wp_is_large_network() ) {
95
-			if ( ! isset( $_REQUEST['orderby'] ) ) {
96
-				$_GET['orderby']     = '';
97
-				$_REQUEST['orderby'] = '';
98
-			}
99
-			if ( ! isset( $_REQUEST['order'] ) ) {
100
-				$_GET['order']     = 'DESC';
101
-				$_REQUEST['order'] = 'DESC';
102
-			}
103
-		}
104
-
105
-		$args = array(
106
-			'number'     => (int) $per_page,
107
-			'offset'     => (int) ( ( $pagenum - 1 ) * $per_page ),
108
-			'network_id' => get_current_network_id(),
109
-		);
110
-
111
-		if ( empty( $s ) ) {
112
-			// Nothing to do.
113
-		} elseif ( preg_match( '/^[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}$/', $s ) ||
114
-					preg_match( '/^[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.?$/', $s ) ||
115
-					preg_match( '/^[0-9]{1,3}\.[0-9]{1,3}\.?$/', $s ) ||
116
-					preg_match( '/^[0-9]{1,3}\.$/', $s ) ) {
117
-			// IPv4 address.
118
-			$sql          = $wpdb->prepare( "SELECT blog_id FROM {$wpdb->registration_log} WHERE {$wpdb->registration_log}.IP LIKE %s", $wpdb->esc_like( $s ) . ( ! empty( $wild ) ? '%' : '' ) );
119
-			$reg_blog_ids = $wpdb->get_col( $sql );
120
-
121
-			if ( $reg_blog_ids ) {
122
-				$args['site__in'] = $reg_blog_ids;
123
-			}
124
-		} elseif ( is_numeric( $s ) && empty( $wild ) ) {
125
-			$args['ID'] = $s;
126
-		} else {
127
-			$args['search'] = $s;
128
-
129
-			if ( ! is_subdomain_install() ) {
130
-				$args['search_columns'] = array( 'path' );
131
-			}
132
-		}
133
-
134
-		$order_by = isset( $_REQUEST['orderby'] ) ? $_REQUEST['orderby'] : '';
135
-		if ( 'registered' === $order_by ) {
136
-			// 'registered' is a valid field name.
137
-		} elseif ( 'lastupdated' === $order_by ) {
138
-			$order_by = 'last_updated';
139
-		} elseif ( 'blogname' === $order_by ) {
140
-			if ( is_subdomain_install() ) {
141
-				$order_by = 'domain';
142
-			} else {
143
-				$order_by = 'path';
144
-			}
145
-		} elseif ( 'blog_id' === $order_by ) {
146
-			$order_by = 'id';
147
-		} elseif ( ! $order_by ) {
148
-			$order_by = false;
149
-		}
150
-
151
-		$args['orderby'] = $order_by;
152
-
153
-		if ( $order_by ) {
154
-			$args['order'] = ( isset( $_REQUEST['order'] ) && 'DESC' === strtoupper( $_REQUEST['order'] ) ) ? 'DESC' : 'ASC';
155
-		}
156
-
157
-		if ( wp_is_large_network() ) {
158
-			$args['no_found_rows'] = true;
159
-		} else {
160
-			$args['no_found_rows'] = false;
161
-		}
162
-
163
-		// Take into account the role the user has selected.
164
-		$status = isset( $_REQUEST['status'] ) ? wp_unslash( trim( $_REQUEST['status'] ) ) : '';
165
-		if ( in_array( $status, array( 'public', 'archived', 'mature', 'spam', 'deleted' ), true ) ) {
166
-			$args[ $status ] = 1;
167
-		}
168
-
169
-		/**
170
-		 * Filters the arguments for the site query in the sites list table.
171
-		 *
172
-		 * @since 4.6.0
173
-		 *
174
-		 * @param array $args An array of get_sites() arguments.
175
-		 */
176
-		$args = apply_filters( 'ms_sites_list_table_query_args', $args );
177
-
178
-		$_sites = get_sites( $args );
179
-		if ( is_array( $_sites ) ) {
180
-			update_site_cache( $_sites );
181
-
182
-			$this->items = array_slice( $_sites, 0, $per_page );
183
-		}
184
-
185
-		$total_sites = get_sites(
186
-			array_merge(
187
-				$args,
188
-				array(
189
-					'count'  => true,
190
-					'offset' => 0,
191
-					'number' => 0,
192
-				)
193
-			)
194
-		);
195
-
196
-		$this->set_pagination_args(
197
-			array(
198
-				'total_items' => $total_sites,
199
-				'per_page'    => $per_page,
200
-			)
201
-		);
202
-	}
203
-
204
-	/**
205
-	 */
206
-	public function no_items() {
207
-		_e( 'No sites found.' );
208
-	}
209
-
210
-	/**
211
-	 * Gets links to filter sites by status.
212
-	 *
213
-	 * @since 5.3.0
214
-	 *
215
-	 * @return array
216
-	 */
217
-	protected function get_views() {
218
-		$counts = wp_count_sites();
219
-
220
-		$statuses = array(
221
-			/* translators: %s: Number of sites. */
222
-			'all'      => _nx_noop(
223
-				'All <span class="count">(%s)</span>',
224
-				'All <span class="count">(%s)</span>',
225
-				'sites'
226
-			),
227
-
228
-			/* translators: %s: Number of sites. */
229
-			'public'   => _n_noop(
230
-				'Public <span class="count">(%s)</span>',
231
-				'Public <span class="count">(%s)</span>'
232
-			),
233
-
234
-			/* translators: %s: Number of sites. */
235
-			'archived' => _n_noop(
236
-				'Archived <span class="count">(%s)</span>',
237
-				'Archived <span class="count">(%s)</span>'
238
-			),
239
-
240
-			/* translators: %s: Number of sites. */
241
-			'mature'   => _n_noop(
242
-				'Mature <span class="count">(%s)</span>',
243
-				'Mature <span class="count">(%s)</span>'
244
-			),
245
-
246
-			/* translators: %s: Number of sites. */
247
-			'spam'     => _nx_noop(
248
-				'Spam <span class="count">(%s)</span>',
249
-				'Spam <span class="count">(%s)</span>',
250
-				'sites'
251
-			),
252
-
253
-			/* translators: %s: Number of sites. */
254
-			'deleted'  => _n_noop(
255
-				'Deleted <span class="count">(%s)</span>',
256
-				'Deleted <span class="count">(%s)</span>'
257
-			),
258
-		);
259
-
260
-		$view_links       = array();
261
-		$requested_status = isset( $_REQUEST['status'] ) ? wp_unslash( trim( $_REQUEST['status'] ) ) : '';
262
-		$url              = 'sites.php';
263
-
264
-		foreach ( $statuses as $status => $label_count ) {
265
-			$current_link_attributes = $requested_status === $status || ( '' === $requested_status && 'all' === $status )
266
-				? ' class="current" aria-current="page"'
267
-				: '';
268
-			if ( (int) $counts[ $status ] > 0 ) {
269
-				$label    = sprintf( translate_nooped_plural( $label_count, $counts[ $status ] ), number_format_i18n( $counts[ $status ] ) );
270
-				$full_url = 'all' === $status ? $url : add_query_arg( 'status', $status, $url );
271
-
272
-				$view_links[ $status ] = sprintf(
273
-					'<a href="%1$s"%2$s>%3$s</a>',
274
-					esc_url( $full_url ),
275
-					$current_link_attributes,
276
-					$label
277
-				);
278
-			}
279
-		}
280
-
281
-		return $view_links;
282
-	}
283
-
284
-	/**
285
-	 * @return array
286
-	 */
287
-	protected function get_bulk_actions() {
288
-		$actions = array();
289
-		if ( current_user_can( 'delete_sites' ) ) {
290
-			$actions['delete'] = __( 'Delete' );
291
-		}
292
-		$actions['spam']    = _x( 'Mark as spam', 'site' );
293
-		$actions['notspam'] = _x( 'Not spam', 'site' );
294
-
295
-		return $actions;
296
-	}
297
-
298
-	/**
299
-	 * @global string $mode List table view mode.
300
-	 *
301
-	 * @param string $which The location of the pagination nav markup: 'top' or 'bottom'.
302
-	 */
303
-	protected function pagination( $which ) {
304
-		global $mode;
305
-
306
-		parent::pagination( $which );
307
-
308
-		if ( 'top' === $which ) {
309
-			$this->view_switcher( $mode );
310
-		}
311
-	}
312
-
313
-	/**
314
-	 * Extra controls to be displayed between bulk actions and pagination.
315
-	 *
316
-	 * @since 5.3.0
317
-	 *
318
-	 * @param string $which The location of the extra table nav markup: 'top' or 'bottom'.
319
-	 */
320
-	protected function extra_tablenav( $which ) {
321
-		?>
94
+        if ( ! $s && wp_is_large_network() ) {
95
+            if ( ! isset( $_REQUEST['orderby'] ) ) {
96
+                $_GET['orderby']     = '';
97
+                $_REQUEST['orderby'] = '';
98
+            }
99
+            if ( ! isset( $_REQUEST['order'] ) ) {
100
+                $_GET['order']     = 'DESC';
101
+                $_REQUEST['order'] = 'DESC';
102
+            }
103
+        }
104
+
105
+        $args = array(
106
+            'number'     => (int) $per_page,
107
+            'offset'     => (int) ( ( $pagenum - 1 ) * $per_page ),
108
+            'network_id' => get_current_network_id(),
109
+        );
110
+
111
+        if ( empty( $s ) ) {
112
+            // Nothing to do.
113
+        } elseif ( preg_match( '/^[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}$/', $s ) ||
114
+                    preg_match( '/^[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.?$/', $s ) ||
115
+                    preg_match( '/^[0-9]{1,3}\.[0-9]{1,3}\.?$/', $s ) ||
116
+                    preg_match( '/^[0-9]{1,3}\.$/', $s ) ) {
117
+            // IPv4 address.
118
+            $sql          = $wpdb->prepare( "SELECT blog_id FROM {$wpdb->registration_log} WHERE {$wpdb->registration_log}.IP LIKE %s", $wpdb->esc_like( $s ) . ( ! empty( $wild ) ? '%' : '' ) );
119
+            $reg_blog_ids = $wpdb->get_col( $sql );
120
+
121
+            if ( $reg_blog_ids ) {
122
+                $args['site__in'] = $reg_blog_ids;
123
+            }
124
+        } elseif ( is_numeric( $s ) && empty( $wild ) ) {
125
+            $args['ID'] = $s;
126
+        } else {
127
+            $args['search'] = $s;
128
+
129
+            if ( ! is_subdomain_install() ) {
130
+                $args['search_columns'] = array( 'path' );
131
+            }
132
+        }
133
+
134
+        $order_by = isset( $_REQUEST['orderby'] ) ? $_REQUEST['orderby'] : '';
135
+        if ( 'registered' === $order_by ) {
136
+            // 'registered' is a valid field name.
137
+        } elseif ( 'lastupdated' === $order_by ) {
138
+            $order_by = 'last_updated';
139
+        } elseif ( 'blogname' === $order_by ) {
140
+            if ( is_subdomain_install() ) {
141
+                $order_by = 'domain';
142
+            } else {
143
+                $order_by = 'path';
144
+            }
145
+        } elseif ( 'blog_id' === $order_by ) {
146
+            $order_by = 'id';
147
+        } elseif ( ! $order_by ) {
148
+            $order_by = false;
149
+        }
150
+
151
+        $args['orderby'] = $order_by;
152
+
153
+        if ( $order_by ) {
154
+            $args['order'] = ( isset( $_REQUEST['order'] ) && 'DESC' === strtoupper( $_REQUEST['order'] ) ) ? 'DESC' : 'ASC';
155
+        }
156
+
157
+        if ( wp_is_large_network() ) {
158
+            $args['no_found_rows'] = true;
159
+        } else {
160
+            $args['no_found_rows'] = false;
161
+        }
162
+
163
+        // Take into account the role the user has selected.
164
+        $status = isset( $_REQUEST['status'] ) ? wp_unslash( trim( $_REQUEST['status'] ) ) : '';
165
+        if ( in_array( $status, array( 'public', 'archived', 'mature', 'spam', 'deleted' ), true ) ) {
166
+            $args[ $status ] = 1;
167
+        }
168
+
169
+        /**
170
+         * Filters the arguments for the site query in the sites list table.
171
+         *
172
+         * @since 4.6.0
173
+         *
174
+         * @param array $args An array of get_sites() arguments.
175
+         */
176
+        $args = apply_filters( 'ms_sites_list_table_query_args', $args );
177
+
178
+        $_sites = get_sites( $args );
179
+        if ( is_array( $_sites ) ) {
180
+            update_site_cache( $_sites );
181
+
182
+            $this->items = array_slice( $_sites, 0, $per_page );
183
+        }
184
+
185
+        $total_sites = get_sites(
186
+            array_merge(
187
+                $args,
188
+                array(
189
+                    'count'  => true,
190
+                    'offset' => 0,
191
+                    'number' => 0,
192
+                )
193
+            )
194
+        );
195
+
196
+        $this->set_pagination_args(
197
+            array(
198
+                'total_items' => $total_sites,
199
+                'per_page'    => $per_page,
200
+            )
201
+        );
202
+    }
203
+
204
+    /**
205
+     */
206
+    public function no_items() {
207
+        _e( 'No sites found.' );
208
+    }
209
+
210
+    /**
211
+     * Gets links to filter sites by status.
212
+     *
213
+     * @since 5.3.0
214
+     *
215
+     * @return array
216
+     */
217
+    protected function get_views() {
218
+        $counts = wp_count_sites();
219
+
220
+        $statuses = array(
221
+            /* translators: %s: Number of sites. */
222
+            'all'      => _nx_noop(
223
+                'All <span class="count">(%s)</span>',
224
+                'All <span class="count">(%s)</span>',
225
+                'sites'
226
+            ),
227
+
228
+            /* translators: %s: Number of sites. */
229
+            'public'   => _n_noop(
230
+                'Public <span class="count">(%s)</span>',
231
+                'Public <span class="count">(%s)</span>'
232
+            ),
233
+
234
+            /* translators: %s: Number of sites. */
235
+            'archived' => _n_noop(
236
+                'Archived <span class="count">(%s)</span>',
237
+                'Archived <span class="count">(%s)</span>'
238
+            ),
239
+
240
+            /* translators: %s: Number of sites. */
241
+            'mature'   => _n_noop(
242
+                'Mature <span class="count">(%s)</span>',
243
+                'Mature <span class="count">(%s)</span>'
244
+            ),
245
+
246
+            /* translators: %s: Number of sites. */
247
+            'spam'     => _nx_noop(
248
+                'Spam <span class="count">(%s)</span>',
249
+                'Spam <span class="count">(%s)</span>',
250
+                'sites'
251
+            ),
252
+
253
+            /* translators: %s: Number of sites. */
254
+            'deleted'  => _n_noop(
255
+                'Deleted <span class="count">(%s)</span>',
256
+                'Deleted <span class="count">(%s)</span>'
257
+            ),
258
+        );
259
+
260
+        $view_links       = array();
261
+        $requested_status = isset( $_REQUEST['status'] ) ? wp_unslash( trim( $_REQUEST['status'] ) ) : '';
262
+        $url              = 'sites.php';
263
+
264
+        foreach ( $statuses as $status => $label_count ) {
265
+            $current_link_attributes = $requested_status === $status || ( '' === $requested_status && 'all' === $status )
266
+                ? ' class="current" aria-current="page"'
267
+                : '';
268
+            if ( (int) $counts[ $status ] > 0 ) {
269
+                $label    = sprintf( translate_nooped_plural( $label_count, $counts[ $status ] ), number_format_i18n( $counts[ $status ] ) );
270
+                $full_url = 'all' === $status ? $url : add_query_arg( 'status', $status, $url );
271
+
272
+                $view_links[ $status ] = sprintf(
273
+                    '<a href="%1$s"%2$s>%3$s</a>',
274
+                    esc_url( $full_url ),
275
+                    $current_link_attributes,
276
+                    $label
277
+                );
278
+            }
279
+        }
280
+
281
+        return $view_links;
282
+    }
283
+
284
+    /**
285
+     * @return array
286
+     */
287
+    protected function get_bulk_actions() {
288
+        $actions = array();
289
+        if ( current_user_can( 'delete_sites' ) ) {
290
+            $actions['delete'] = __( 'Delete' );
291
+        }
292
+        $actions['spam']    = _x( 'Mark as spam', 'site' );
293
+        $actions['notspam'] = _x( 'Not spam', 'site' );
294
+
295
+        return $actions;
296
+    }
297
+
298
+    /**
299
+     * @global string $mode List table view mode.
300
+     *
301
+     * @param string $which The location of the pagination nav markup: 'top' or 'bottom'.
302
+     */
303
+    protected function pagination( $which ) {
304
+        global $mode;
305
+
306
+        parent::pagination( $which );
307
+
308
+        if ( 'top' === $which ) {
309
+            $this->view_switcher( $mode );
310
+        }
311
+    }
312
+
313
+    /**
314
+     * Extra controls to be displayed between bulk actions and pagination.
315
+     *
316
+     * @since 5.3.0
317
+     *
318
+     * @param string $which The location of the extra table nav markup: 'top' or 'bottom'.
319
+     */
320
+    protected function extra_tablenav( $which ) {
321
+        ?>
322 322
 		<div class="alignleft actions">
323 323
 		<?php
324
-		if ( 'top' === $which ) {
325
-			ob_start();
326
-
327
-			/**
328
-			 * Fires before the Filter button on the MS sites list table.
329
-			 *
330
-			 * @since 5.3.0
331
-			 *
332
-			 * @param string $which The location of the extra table nav markup: 'top' or 'bottom'.
333
-			 */
334
-			do_action( 'restrict_manage_sites', $which );
335
-
336
-			$output = ob_get_clean();
337
-
338
-			if ( ! empty( $output ) ) {
339
-				echo $output;
340
-				submit_button( __( 'Filter' ), '', 'filter_action', false, array( 'id' => 'site-query-submit' ) );
341
-			}
342
-		}
343
-		?>
324
+        if ( 'top' === $which ) {
325
+            ob_start();
326
+
327
+            /**
328
+             * Fires before the Filter button on the MS sites list table.
329
+             *
330
+             * @since 5.3.0
331
+             *
332
+             * @param string $which The location of the extra table nav markup: 'top' or 'bottom'.
333
+             */
334
+            do_action( 'restrict_manage_sites', $which );
335
+
336
+            $output = ob_get_clean();
337
+
338
+            if ( ! empty( $output ) ) {
339
+                echo $output;
340
+                submit_button( __( 'Filter' ), '', 'filter_action', false, array( 'id' => 'site-query-submit' ) );
341
+            }
342
+        }
343
+        ?>
344 344
 		</div>
345 345
 		<?php
346
-		/**
347
-		 * Fires immediately following the closing "actions" div in the tablenav for the
348
-		 * MS sites list table.
349
-		 *
350
-		 * @since 5.3.0
351
-		 *
352
-		 * @param string $which The location of the extra table nav markup: 'top' or 'bottom'.
353
-		 */
354
-		do_action( 'manage_sites_extra_tablenav', $which );
355
-	}
356
-
357
-	/**
358
-	 * @return array
359
-	 */
360
-	public function get_columns() {
361
-		$sites_columns = array(
362
-			'cb'          => '<input type="checkbox" />',
363
-			'blogname'    => __( 'URL' ),
364
-			'lastupdated' => __( 'Last Updated' ),
365
-			'registered'  => _x( 'Registered', 'site' ),
366
-			'users'       => __( 'Users' ),
367
-		);
368
-
369
-		if ( has_filter( 'wpmublogsaction' ) ) {
370
-			$sites_columns['plugins'] = __( 'Actions' );
371
-		}
372
-
373
-		/**
374
-		 * Filters the displayed site columns in Sites list table.
375
-		 *
376
-		 * @since MU (3.0.0)
377
-		 *
378
-		 * @param string[] $sites_columns An array of displayed site columns. Default 'cb',
379
-		 *                               'blogname', 'lastupdated', 'registered', 'users'.
380
-		 */
381
-		return apply_filters( 'wpmu_blogs_columns', $sites_columns );
382
-	}
383
-
384
-	/**
385
-	 * @return array
386
-	 */
387
-	protected function get_sortable_columns() {
388
-		return array(
389
-			'blogname'    => 'blogname',
390
-			'lastupdated' => 'lastupdated',
391
-			'registered'  => 'blog_id',
392
-		);
393
-	}
394
-
395
-	/**
396
-	 * Handles the checkbox column output.
397
-	 *
398
-	 * @since 4.3.0
399
-	 * @since 5.9.0 Renamed `$blog` to `$item` to match parent class for PHP 8 named parameter support.
400
-	 *
401
-	 * @param array $item Current site.
402
-	 */
403
-	public function column_cb( $item ) {
404
-		// Restores the more descriptive, specific name for use within this method.
405
-		$blog = $item;
406
-
407
-		if ( ! is_main_site( $blog['blog_id'] ) ) :
408
-			$blogname = untrailingslashit( $blog['domain'] . $blog['path'] );
409
-			?>
346
+        /**
347
+         * Fires immediately following the closing "actions" div in the tablenav for the
348
+         * MS sites list table.
349
+         *
350
+         * @since 5.3.0
351
+         *
352
+         * @param string $which The location of the extra table nav markup: 'top' or 'bottom'.
353
+         */
354
+        do_action( 'manage_sites_extra_tablenav', $which );
355
+    }
356
+
357
+    /**
358
+     * @return array
359
+     */
360
+    public function get_columns() {
361
+        $sites_columns = array(
362
+            'cb'          => '<input type="checkbox" />',
363
+            'blogname'    => __( 'URL' ),
364
+            'lastupdated' => __( 'Last Updated' ),
365
+            'registered'  => _x( 'Registered', 'site' ),
366
+            'users'       => __( 'Users' ),
367
+        );
368
+
369
+        if ( has_filter( 'wpmublogsaction' ) ) {
370
+            $sites_columns['plugins'] = __( 'Actions' );
371
+        }
372
+
373
+        /**
374
+         * Filters the displayed site columns in Sites list table.
375
+         *
376
+         * @since MU (3.0.0)
377
+         *
378
+         * @param string[] $sites_columns An array of displayed site columns. Default 'cb',
379
+         *                               'blogname', 'lastupdated', 'registered', 'users'.
380
+         */
381
+        return apply_filters( 'wpmu_blogs_columns', $sites_columns );
382
+    }
383
+
384
+    /**
385
+     * @return array
386
+     */
387
+    protected function get_sortable_columns() {
388
+        return array(
389
+            'blogname'    => 'blogname',
390
+            'lastupdated' => 'lastupdated',
391
+            'registered'  => 'blog_id',
392
+        );
393
+    }
394
+
395
+    /**
396
+     * Handles the checkbox column output.
397
+     *
398
+     * @since 4.3.0
399
+     * @since 5.9.0 Renamed `$blog` to `$item` to match parent class for PHP 8 named parameter support.
400
+     *
401
+     * @param array $item Current site.
402
+     */
403
+    public function column_cb( $item ) {
404
+        // Restores the more descriptive, specific name for use within this method.
405
+        $blog = $item;
406
+
407
+        if ( ! is_main_site( $blog['blog_id'] ) ) :
408
+            $blogname = untrailingslashit( $blog['domain'] . $blog['path'] );
409
+            ?>
410 410
 			<label class="screen-reader-text" for="blog_<?php echo $blog['blog_id']; ?>">
411 411
 				<?php
412
-				/* translators: %s: Site URL. */
413
-				printf( __( 'Select %s' ), $blogname );
414
-				?>
412
+                /* translators: %s: Site URL. */
413
+                printf( __( 'Select %s' ), $blogname );
414
+                ?>
415 415
 			</label>
416 416
 			<input type="checkbox" id="blog_<?php echo $blog['blog_id']; ?>" name="allblogs[]" value="<?php echo esc_attr( $blog['blog_id'] ); ?>" />
417 417
 			<?php
418
-		endif;
419
-	}
420
-
421
-	/**
422
-	 * Handles the ID column output.
423
-	 *
424
-	 * @since 4.4.0
425
-	 *
426
-	 * @param array $blog Current site.
427
-	 */
428
-	public function column_id( $blog ) {
429
-		echo $blog['blog_id'];
430
-	}
431
-
432
-	/**
433
-	 * Handles the site name column output.
434
-	 *
435
-	 * @since 4.3.0
436
-	 *
437
-	 * @global string $mode List table view mode.
438
-	 *
439
-	 * @param array $blog Current site.
440
-	 */
441
-	public function column_blogname( $blog ) {
442
-		global $mode;
443
-
444
-		$blogname = untrailingslashit( $blog['domain'] . $blog['path'] );
445
-
446
-		?>
418
+        endif;
419
+    }
420
+
421
+    /**
422
+     * Handles the ID column output.
423
+     *
424
+     * @since 4.4.0
425
+     *
426
+     * @param array $blog Current site.
427
+     */
428
+    public function column_id( $blog ) {
429
+        echo $blog['blog_id'];
430
+    }
431
+
432
+    /**
433
+     * Handles the site name column output.
434
+     *
435
+     * @since 4.3.0
436
+     *
437
+     * @global string $mode List table view mode.
438
+     *
439
+     * @param array $blog Current site.
440
+     */
441
+    public function column_blogname( $blog ) {
442
+        global $mode;
443
+
444
+        $blogname = untrailingslashit( $blog['domain'] . $blog['path'] );
445
+
446
+        ?>
447 447
 		<strong>
448 448
 			<a href="<?php echo esc_url( network_admin_url( 'site-info.php?id=' . $blog['blog_id'] ) ); ?>" class="edit"><?php echo $blogname; ?></a>
449 449
 			<?php $this->site_states( $blog ); ?>
450 450
 		</strong>
451 451
 		<?php
452
-		if ( 'list' !== $mode ) {
453
-			switch_to_blog( $blog['blog_id'] );
454
-			echo '<p>';
455
-			printf(
456
-				/* translators: 1: Site title, 2: Site tagline. */
457
-				__( '%1$s &#8211; %2$s' ),
458
-				get_option( 'blogname' ),
459
-				'<em>' . get_option( 'blogdescription' ) . '</em>'
460
-			);
461
-			echo '</p>';
462
-			restore_current_blog();
463
-		}
464
-	}
465
-
466
-	/**
467
-	 * Handles the lastupdated column output.
468
-	 *
469
-	 * @since 4.3.0
470
-	 *
471
-	 * @global string $mode List table view mode.
472
-	 *
473
-	 * @param array $blog Current site.
474
-	 */
475
-	public function column_lastupdated( $blog ) {
476
-		global $mode;
477
-
478
-		if ( 'list' === $mode ) {
479
-			$date = __( 'Y/m/d' );
480
-		} else {
481
-			$date = __( 'Y/m/d g:i:s a' );
482
-		}
483
-
484
-		echo ( '0000-00-00 00:00:00' === $blog['last_updated'] ) ? __( 'Never' ) : mysql2date( $date, $blog['last_updated'] );
485
-	}
486
-
487
-	/**
488
-	 * Handles the registered column output.
489
-	 *
490
-	 * @since 4.3.0
491
-	 *
492
-	 * @global string $mode List table view mode.
493
-	 *
494
-	 * @param array $blog Current site.
495
-	 */
496
-	public function column_registered( $blog ) {
497
-		global $mode;
498
-
499
-		if ( 'list' === $mode ) {
500
-			$date = __( 'Y/m/d' );
501
-		} else {
502
-			$date = __( 'Y/m/d g:i:s a' );
503
-		}
504
-
505
-		if ( '0000-00-00 00:00:00' === $blog['registered'] ) {
506
-			echo '&#x2014;';
507
-		} else {
508
-			echo mysql2date( $date, $blog['registered'] );
509
-		}
510
-	}
511
-
512
-	/**
513
-	 * Handles the users column output.
514
-	 *
515
-	 * @since 4.3.0
516
-	 *
517
-	 * @param array $blog Current site.
518
-	 */
519
-	public function column_users( $blog ) {
520
-		$user_count = wp_cache_get( $blog['blog_id'] . '_user_count', 'blog-details' );
521
-		if ( ! $user_count ) {
522
-			$blog_users = new WP_User_Query(
523
-				array(
524
-					'blog_id'     => $blog['blog_id'],
525
-					'fields'      => 'ID',
526
-					'number'      => 1,
527
-					'count_total' => true,
528
-				)
529
-			);
530
-			$user_count = $blog_users->get_total();
531
-			wp_cache_set( $blog['blog_id'] . '_user_count', $user_count, 'blog-details', 12 * HOUR_IN_SECONDS );
532
-		}
533
-
534
-		printf(
535
-			'<a href="%s">%s</a>',
536
-			esc_url( network_admin_url( 'site-users.php?id=' . $blog['blog_id'] ) ),
537
-			number_format_i18n( $user_count )
538
-		);
539
-	}
540
-
541
-	/**
542
-	 * Handles the plugins column output.
543
-	 *
544
-	 * @since 4.3.0
545
-	 *
546
-	 * @param array $blog Current site.
547
-	 */
548
-	public function column_plugins( $blog ) {
549
-		if ( has_filter( 'wpmublogsaction' ) ) {
550
-			/**
551
-			 * Fires inside the auxiliary 'Actions' column of the Sites list table.
552
-			 *
553
-			 * By default this column is hidden unless something is hooked to the action.
554
-			 *
555
-			 * @since MU (3.0.0)
556
-			 *
557
-			 * @param int $blog_id The site ID.
558
-			 */
559
-			do_action( 'wpmublogsaction', $blog['blog_id'] );
560
-		}
561
-	}
562
-
563
-	/**
564
-	 * Handles output for the default column.
565
-	 *
566
-	 * @since 4.3.0
567
-	 * @since 5.9.0 Renamed `$blog` to `$item` to match parent class for PHP 8 named parameter support.
568
-	 *
569
-	 * @param array  $item        Current site.
570
-	 * @param string $column_name Current column name.
571
-	 */
572
-	public function column_default( $item, $column_name ) {
573
-		/**
574
-		 * Fires for each registered custom column in the Sites list table.
575
-		 *
576
-		 * @since 3.1.0
577
-		 *
578
-		 * @param string $column_name The name of the column to display.
579
-		 * @param int    $blog_id     The site ID.
580
-		 */
581
-		do_action( 'manage_sites_custom_column', $column_name, $item['blog_id'] );
582
-	}
583
-
584
-	/**
585
-	 * @global string $mode List table view mode.
586
-	 */
587
-	public function display_rows() {
588
-		foreach ( $this->items as $blog ) {
589
-			$blog  = $blog->to_array();
590
-			$class = '';
591
-			reset( $this->status_list );
592
-
593
-			foreach ( $this->status_list as $status => $col ) {
594
-				if ( 1 == $blog[ $status ] ) {
595
-					$class = " class='{$col[0]}'";
596
-				}
597
-			}
598
-
599
-			echo "<tr{$class}>";
600
-
601
-			$this->single_row_columns( $blog );
602
-
603
-			echo '</tr>';
604
-		}
605
-	}
606
-
607
-	/**
608
-	 * Maybe output comma-separated site states.
609
-	 *
610
-	 * @since 5.3.0
611
-	 *
612
-	 * @param array $site
613
-	 */
614
-	protected function site_states( $site ) {
615
-		$site_states = array();
616
-
617
-		// $site is still an array, so get the object.
618
-		$_site = WP_Site::get_instance( $site['blog_id'] );
619
-
620
-		if ( is_main_site( $_site->id ) ) {
621
-			$site_states['main'] = __( 'Main' );
622
-		}
623
-
624
-		reset( $this->status_list );
625
-
626
-		$site_status = isset( $_REQUEST['status'] ) ? wp_unslash( trim( $_REQUEST['status'] ) ) : '';
627
-		foreach ( $this->status_list as $status => $col ) {
628
-			if ( ( 1 === (int) $_site->{$status} ) && ( $site_status !== $status ) ) {
629
-				$site_states[ $col[0] ] = $col[1];
630
-			}
631
-		}
632
-
633
-		/**
634
-		 * Filters the default site display states for items in the Sites list table.
635
-		 *
636
-		 * @since 5.3.0
637
-		 *
638
-		 * @param string[] $site_states An array of site states. Default 'Main',
639
-		 *                              'Archived', 'Mature', 'Spam', 'Deleted'.
640
-		 * @param WP_Site  $site        The current site object.
641
-		 */
642
-		$site_states = apply_filters( 'display_site_states', $site_states, $_site );
643
-
644
-		if ( ! empty( $site_states ) ) {
645
-			$state_count = count( $site_states );
646
-
647
-			$i = 0;
648
-
649
-			echo ' &mdash; ';
650
-
651
-			foreach ( $site_states as $state ) {
652
-				++$i;
653
-
654
-				$sep = ( $i < $state_count ) ? ', ' : '';
655
-
656
-				echo "<span class='post-state'>{$state}{$sep}</span>";
657
-			}
658
-		}
659
-	}
660
-
661
-	/**
662
-	 * Gets the name of the default primary column.
663
-	 *
664
-	 * @since 4.3.0
665
-	 *
666
-	 * @return string Name of the default primary column, in this case, 'blogname'.
667
-	 */
668
-	protected function get_default_primary_column_name() {
669
-		return 'blogname';
670
-	}
671
-
672
-	/**
673
-	 * Generates and displays row action links.
674
-	 *
675
-	 * @since 4.3.0
676
-	 * @since 5.9.0 Renamed `$blog` to `$item` to match parent class for PHP 8 named parameter support.
677
-	 *
678
-	 * @param array  $item        Site being acted upon.
679
-	 * @param string $column_name Current column name.
680
-	 * @param string $primary     Primary column name.
681
-	 * @return string Row actions output for sites in Multisite, or an empty string
682
-	 *                if the current column is not the primary column.
683
-	 */
684
-	protected function handle_row_actions( $item, $column_name, $primary ) {
685
-		if ( $primary !== $column_name ) {
686
-			return '';
687
-		}
688
-
689
-		// Restores the more descriptive, specific name for use within this method.
690
-		$blog     = $item;
691
-		$blogname = untrailingslashit( $blog['domain'] . $blog['path'] );
692
-
693
-		// Preordered.
694
-		$actions = array(
695
-			'edit'       => '',
696
-			'backend'    => '',
697
-			'activate'   => '',
698
-			'deactivate' => '',
699
-			'archive'    => '',
700
-			'unarchive'  => '',
701
-			'spam'       => '',
702
-			'unspam'     => '',
703
-			'delete'     => '',
704
-			'visit'      => '',
705
-		);
706
-
707
-		$actions['edit']    = '<a href="' . esc_url( network_admin_url( 'site-info.php?id=' . $blog['blog_id'] ) ) . '">' . __( 'Edit' ) . '</a>';
708
-		$actions['backend'] = "<a href='" . esc_url( get_admin_url( $blog['blog_id'] ) ) . "' class='edit'>" . __( 'Dashboard' ) . '</a>';
709
-		if ( get_network()->site_id != $blog['blog_id'] ) {
710
-			if ( '1' == $blog['deleted'] ) {
711
-				$actions['activate'] = '<a href="' . esc_url( wp_nonce_url( network_admin_url( 'sites.php?action=confirm&amp;action2=activateblog&amp;id=' . $blog['blog_id'] ), 'activateblog_' . $blog['blog_id'] ) ) . '">' . __( 'Activate' ) . '</a>';
712
-			} else {
713
-				$actions['deactivate'] = '<a href="' . esc_url( wp_nonce_url( network_admin_url( 'sites.php?action=confirm&amp;action2=deactivateblog&amp;id=' . $blog['blog_id'] ), 'deactivateblog_' . $blog['blog_id'] ) ) . '">' . __( 'Deactivate' ) . '</a>';
714
-			}
715
-
716
-			if ( '1' == $blog['archived'] ) {
717
-				$actions['unarchive'] = '<a href="' . esc_url( wp_nonce_url( network_admin_url( 'sites.php?action=confirm&amp;action2=unarchiveblog&amp;id=' . $blog['blog_id'] ), 'unarchiveblog_' . $blog['blog_id'] ) ) . '">' . __( 'Unarchive' ) . '</a>';
718
-			} else {
719
-				$actions['archive'] = '<a href="' . esc_url( wp_nonce_url( network_admin_url( 'sites.php?action=confirm&amp;action2=archiveblog&amp;id=' . $blog['blog_id'] ), 'archiveblog_' . $blog['blog_id'] ) ) . '">' . _x( 'Archive', 'verb; site' ) . '</a>';
720
-			}
721
-
722
-			if ( '1' == $blog['spam'] ) {
723
-				$actions['unspam'] = '<a href="' . esc_url( wp_nonce_url( network_admin_url( 'sites.php?action=confirm&amp;action2=unspamblog&amp;id=' . $blog['blog_id'] ), 'unspamblog_' . $blog['blog_id'] ) ) . '">' . _x( 'Not Spam', 'site' ) . '</a>';
724
-			} else {
725
-				$actions['spam'] = '<a href="' . esc_url( wp_nonce_url( network_admin_url( 'sites.php?action=confirm&amp;action2=spamblog&amp;id=' . $blog['blog_id'] ), 'spamblog_' . $blog['blog_id'] ) ) . '">' . _x( 'Spam', 'site' ) . '</a>';
726
-			}
727
-
728
-			if ( current_user_can( 'delete_site', $blog['blog_id'] ) ) {
729
-				$actions['delete'] = '<a href="' . esc_url( wp_nonce_url( network_admin_url( 'sites.php?action=confirm&amp;action2=deleteblog&amp;id=' . $blog['blog_id'] ), 'deleteblog_' . $blog['blog_id'] ) ) . '">' . __( 'Delete' ) . '</a>';
730
-			}
731
-		}
732
-
733
-		$actions['visit'] = "<a href='" . esc_url( get_home_url( $blog['blog_id'], '/' ) ) . "' rel='bookmark'>" . __( 'Visit' ) . '</a>';
734
-
735
-		/**
736
-		 * Filters the action links displayed for each site in the Sites list table.
737
-		 *
738
-		 * The 'Edit', 'Dashboard', 'Delete', and 'Visit' links are displayed by
739
-		 * default for each site. The site's status determines whether to show the
740
-		 * 'Activate' or 'Deactivate' link, 'Unarchive' or 'Archive' links, and
741
-		 * 'Not Spam' or 'Spam' link for each site.
742
-		 *
743
-		 * @since 3.1.0
744
-		 *
745
-		 * @param string[] $actions  An array of action links to be displayed.
746
-		 * @param int      $blog_id  The site ID.
747
-		 * @param string   $blogname Site path, formatted depending on whether it is a sub-domain
748
-		 *                           or subdirectory multisite installation.
749
-		 */
750
-		$actions = apply_filters( 'manage_sites_action_links', array_filter( $actions ), $blog['blog_id'], $blogname );
751
-
752
-		return $this->row_actions( $actions );
753
-	}
452
+        if ( 'list' !== $mode ) {
453
+            switch_to_blog( $blog['blog_id'] );
454
+            echo '<p>';
455
+            printf(
456
+                /* translators: 1: Site title, 2: Site tagline. */
457
+                __( '%1$s &#8211; %2$s' ),
458
+                get_option( 'blogname' ),
459
+                '<em>' . get_option( 'blogdescription' ) . '</em>'
460
+            );
461
+            echo '</p>';
462
+            restore_current_blog();
463
+        }
464
+    }
465
+
466
+    /**
467
+     * Handles the lastupdated column output.
468
+     *
469
+     * @since 4.3.0
470
+     *
471
+     * @global string $mode List table view mode.
472
+     *
473
+     * @param array $blog Current site.
474
+     */
475
+    public function column_lastupdated( $blog ) {
476
+        global $mode;
477
+
478
+        if ( 'list' === $mode ) {
479
+            $date = __( 'Y/m/d' );
480
+        } else {
481
+            $date = __( 'Y/m/d g:i:s a' );
482
+        }
483
+
484
+        echo ( '0000-00-00 00:00:00' === $blog['last_updated'] ) ? __( 'Never' ) : mysql2date( $date, $blog['last_updated'] );
485
+    }
486
+
487
+    /**
488
+     * Handles the registered column output.
489
+     *
490
+     * @since 4.3.0
491
+     *
492
+     * @global string $mode List table view mode.
493
+     *
494
+     * @param array $blog Current site.
495
+     */
496
+    public function column_registered( $blog ) {
497
+        global $mode;
498
+
499
+        if ( 'list' === $mode ) {
500
+            $date = __( 'Y/m/d' );
501
+        } else {
502
+            $date = __( 'Y/m/d g:i:s a' );
503
+        }
504
+
505
+        if ( '0000-00-00 00:00:00' === $blog['registered'] ) {
506
+            echo '&#x2014;';
507
+        } else {
508
+            echo mysql2date( $date, $blog['registered'] );
509
+        }
510
+    }
511
+
512
+    /**
513
+     * Handles the users column output.
514
+     *
515
+     * @since 4.3.0
516
+     *
517
+     * @param array $blog Current site.
518
+     */
519
+    public function column_users( $blog ) {
520
+        $user_count = wp_cache_get( $blog['blog_id'] . '_user_count', 'blog-details' );
521
+        if ( ! $user_count ) {
522
+            $blog_users = new WP_User_Query(
523
+                array(
524
+                    'blog_id'     => $blog['blog_id'],
525
+                    'fields'      => 'ID',
526
+                    'number'      => 1,
527
+                    'count_total' => true,
528
+                )
529
+            );
530
+            $user_count = $blog_users->get_total();
531
+            wp_cache_set( $blog['blog_id'] . '_user_count', $user_count, 'blog-details', 12 * HOUR_IN_SECONDS );
532
+        }
533
+
534
+        printf(
535
+            '<a href="%s">%s</a>',
536
+            esc_url( network_admin_url( 'site-users.php?id=' . $blog['blog_id'] ) ),
537
+            number_format_i18n( $user_count )
538
+        );
539
+    }
540
+
541
+    /**
542
+     * Handles the plugins column output.
543
+     *
544
+     * @since 4.3.0
545
+     *
546
+     * @param array $blog Current site.
547
+     */
548
+    public function column_plugins( $blog ) {
549
+        if ( has_filter( 'wpmublogsaction' ) ) {
550
+            /**
551
+             * Fires inside the auxiliary 'Actions' column of the Sites list table.
552
+             *
553
+             * By default this column is hidden unless something is hooked to the action.
554
+             *
555
+             * @since MU (3.0.0)
556
+             *
557
+             * @param int $blog_id The site ID.
558
+             */
559
+            do_action( 'wpmublogsaction', $blog['blog_id'] );
560
+        }
561
+    }
562
+
563
+    /**
564
+     * Handles output for the default column.
565
+     *
566
+     * @since 4.3.0
567
+     * @since 5.9.0 Renamed `$blog` to `$item` to match parent class for PHP 8 named parameter support.
568
+     *
569
+     * @param array  $item        Current site.
570
+     * @param string $column_name Current column name.
571
+     */
572
+    public function column_default( $item, $column_name ) {
573
+        /**
574
+         * Fires for each registered custom column in the Sites list table.
575
+         *
576
+         * @since 3.1.0
577
+         *
578
+         * @param string $column_name The name of the column to display.
579
+         * @param int    $blog_id     The site ID.
580
+         */
581
+        do_action( 'manage_sites_custom_column', $column_name, $item['blog_id'] );
582
+    }
583
+
584
+    /**
585
+     * @global string $mode List table view mode.
586
+     */
587
+    public function display_rows() {
588
+        foreach ( $this->items as $blog ) {
589
+            $blog  = $blog->to_array();
590
+            $class = '';
591
+            reset( $this->status_list );
592
+
593
+            foreach ( $this->status_list as $status => $col ) {
594
+                if ( 1 == $blog[ $status ] ) {
595
+                    $class = " class='{$col[0]}'";
596
+                }
597
+            }
598
+
599
+            echo "<tr{$class}>";
600
+
601
+            $this->single_row_columns( $blog );
602
+
603
+            echo '</tr>';
604
+        }
605
+    }
606
+
607
+    /**
608
+     * Maybe output comma-separated site states.
609
+     *
610
+     * @since 5.3.0
611
+     *
612
+     * @param array $site
613
+     */
614
+    protected function site_states( $site ) {
615
+        $site_states = array();
616
+
617
+        // $site is still an array, so get the object.
618
+        $_site = WP_Site::get_instance( $site['blog_id'] );
619
+
620
+        if ( is_main_site( $_site->id ) ) {
621
+            $site_states['main'] = __( 'Main' );
622
+        }
623
+
624
+        reset( $this->status_list );
625
+
626
+        $site_status = isset( $_REQUEST['status'] ) ? wp_unslash( trim( $_REQUEST['status'] ) ) : '';
627
+        foreach ( $this->status_list as $status => $col ) {
628
+            if ( ( 1 === (int) $_site->{$status} ) && ( $site_status !== $status ) ) {
629
+                $site_states[ $col[0] ] = $col[1];
630
+            }
631
+        }
632
+
633
+        /**
634
+         * Filters the default site display states for items in the Sites list table.
635
+         *
636
+         * @since 5.3.0
637
+         *
638
+         * @param string[] $site_states An array of site states. Default 'Main',
639
+         *                              'Archived', 'Mature', 'Spam', 'Deleted'.
640
+         * @param WP_Site  $site        The current site object.
641
+         */
642
+        $site_states = apply_filters( 'display_site_states', $site_states, $_site );
643
+
644
+        if ( ! empty( $site_states ) ) {
645
+            $state_count = count( $site_states );
646
+
647
+            $i = 0;
648
+
649
+            echo ' &mdash; ';
650
+
651
+            foreach ( $site_states as $state ) {
652
+                ++$i;
653
+
654
+                $sep = ( $i < $state_count ) ? ', ' : '';
655
+
656
+                echo "<span class='post-state'>{$state}{$sep}</span>";
657
+            }
658
+        }
659
+    }
660
+
661
+    /**
662
+     * Gets the name of the default primary column.
663
+     *
664
+     * @since 4.3.0
665
+     *
666
+     * @return string Name of the default primary column, in this case, 'blogname'.
667
+     */
668
+    protected function get_default_primary_column_name() {
669
+        return 'blogname';
670
+    }
671
+
672
+    /**
673
+     * Generates and displays row action links.
674
+     *
675
+     * @since 4.3.0
676
+     * @since 5.9.0 Renamed `$blog` to `$item` to match parent class for PHP 8 named parameter support.
677
+     *
678
+     * @param array  $item        Site being acted upon.
679
+     * @param string $column_name Current column name.
680
+     * @param string $primary     Primary column name.
681
+     * @return string Row actions output for sites in Multisite, or an empty string
682
+     *                if the current column is not the primary column.
683
+     */
684
+    protected function handle_row_actions( $item, $column_name, $primary ) {
685
+        if ( $primary !== $column_name ) {
686
+            return '';
687
+        }
688
+
689
+        // Restores the more descriptive, specific name for use within this method.
690
+        $blog     = $item;
691
+        $blogname = untrailingslashit( $blog['domain'] . $blog['path'] );
692
+
693
+        // Preordered.
694
+        $actions = array(
695
+            'edit'       => '',
696
+            'backend'    => '',
697
+            'activate'   => '',
698
+            'deactivate' => '',
699
+            'archive'    => '',
700
+            'unarchive'  => '',
701
+            'spam'       => '',
702
+            'unspam'     => '',
703
+            'delete'     => '',
704
+            'visit'      => '',
705
+        );
706
+
707
+        $actions['edit']    = '<a href="' . esc_url( network_admin_url( 'site-info.php?id=' . $blog['blog_id'] ) ) . '">' . __( 'Edit' ) . '</a>';
708
+        $actions['backend'] = "<a href='" . esc_url( get_admin_url( $blog['blog_id'] ) ) . "' class='edit'>" . __( 'Dashboard' ) . '</a>';
709
+        if ( get_network()->site_id != $blog['blog_id'] ) {
710
+            if ( '1' == $blog['deleted'] ) {
711
+                $actions['activate'] = '<a href="' . esc_url( wp_nonce_url( network_admin_url( 'sites.php?action=confirm&amp;action2=activateblog&amp;id=' . $blog['blog_id'] ), 'activateblog_' . $blog['blog_id'] ) ) . '">' . __( 'Activate' ) . '</a>';
712
+            } else {
713
+                $actions['deactivate'] = '<a href="' . esc_url( wp_nonce_url( network_admin_url( 'sites.php?action=confirm&amp;action2=deactivateblog&amp;id=' . $blog['blog_id'] ), 'deactivateblog_' . $blog['blog_id'] ) ) . '">' . __( 'Deactivate' ) . '</a>';
714
+            }
715
+
716
+            if ( '1' == $blog['archived'] ) {
717
+                $actions['unarchive'] = '<a href="' . esc_url( wp_nonce_url( network_admin_url( 'sites.php?action=confirm&amp;action2=unarchiveblog&amp;id=' . $blog['blog_id'] ), 'unarchiveblog_' . $blog['blog_id'] ) ) . '">' . __( 'Unarchive' ) . '</a>';
718
+            } else {
719
+                $actions['archive'] = '<a href="' . esc_url( wp_nonce_url( network_admin_url( 'sites.php?action=confirm&amp;action2=archiveblog&amp;id=' . $blog['blog_id'] ), 'archiveblog_' . $blog['blog_id'] ) ) . '">' . _x( 'Archive', 'verb; site' ) . '</a>';
720
+            }
721
+
722
+            if ( '1' == $blog['spam'] ) {
723
+                $actions['unspam'] = '<a href="' . esc_url( wp_nonce_url( network_admin_url( 'sites.php?action=confirm&amp;action2=unspamblog&amp;id=' . $blog['blog_id'] ), 'unspamblog_' . $blog['blog_id'] ) ) . '">' . _x( 'Not Spam', 'site' ) . '</a>';
724
+            } else {
725
+                $actions['spam'] = '<a href="' . esc_url( wp_nonce_url( network_admin_url( 'sites.php?action=confirm&amp;action2=spamblog&amp;id=' . $blog['blog_id'] ), 'spamblog_' . $blog['blog_id'] ) ) . '">' . _x( 'Spam', 'site' ) . '</a>';
726
+            }
727
+
728
+            if ( current_user_can( 'delete_site', $blog['blog_id'] ) ) {
729
+                $actions['delete'] = '<a href="' . esc_url( wp_nonce_url( network_admin_url( 'sites.php?action=confirm&amp;action2=deleteblog&amp;id=' . $blog['blog_id'] ), 'deleteblog_' . $blog['blog_id'] ) ) . '">' . __( 'Delete' ) . '</a>';
730
+            }
731
+        }
732
+
733
+        $actions['visit'] = "<a href='" . esc_url( get_home_url( $blog['blog_id'], '/' ) ) . "' rel='bookmark'>" . __( 'Visit' ) . '</a>';
734
+
735
+        /**
736
+         * Filters the action links displayed for each site in the Sites list table.
737
+         *
738
+         * The 'Edit', 'Dashboard', 'Delete', and 'Visit' links are displayed by
739
+         * default for each site. The site's status determines whether to show the
740
+         * 'Activate' or 'Deactivate' link, 'Unarchive' or 'Archive' links, and
741
+         * 'Not Spam' or 'Spam' link for each site.
742
+         *
743
+         * @since 3.1.0
744
+         *
745
+         * @param string[] $actions  An array of action links to be displayed.
746
+         * @param int      $blog_id  The site ID.
747
+         * @param string   $blogname Site path, formatted depending on whether it is a sub-domain
748
+         *                           or subdirectory multisite installation.
749
+         */
750
+        $actions = apply_filters( 'manage_sites_action_links', array_filter( $actions ), $blog['blog_id'], $blogname );
751
+
752
+        return $this->row_actions( $actions );
753
+    }
754 754
 }
Please login to merge, or discard this patch.
brighty/wp-admin/includes/deprecated.php 1 patch
Indentation   +628 added lines, -628 removed lines patch added patch discarded remove patch
@@ -18,9 +18,9 @@  discard block
 block discarded – undo
18 18
  * @see wp_editor()
19 19
  */
20 20
 function tinymce_include() {
21
-	_deprecated_function( __FUNCTION__, '2.1.0', 'wp_editor()' );
21
+    _deprecated_function( __FUNCTION__, '2.1.0', 'wp_editor()' );
22 22
 
23
-	wp_tiny_mce();
23
+    wp_tiny_mce();
24 24
 }
25 25
 
26 26
 /**
@@ -31,7 +31,7 @@  discard block
 block discarded – undo
31 31
  *
32 32
  */
33 33
 function documentation_link() {
34
-	_deprecated_function( __FUNCTION__, '2.5.0' );
34
+    _deprecated_function( __FUNCTION__, '2.5.0' );
35 35
 }
36 36
 
37 37
 /**
@@ -48,8 +48,8 @@  discard block
 block discarded – undo
48 48
  * @return array Shrunk dimensions (width, height).
49 49
  */
50 50
 function wp_shrink_dimensions( $width, $height, $wmax = 128, $hmax = 96 ) {
51
-	_deprecated_function( __FUNCTION__, '3.0.0', 'wp_constrain_dimensions()' );
52
-	return wp_constrain_dimensions( $width, $height, $wmax, $hmax );
51
+    _deprecated_function( __FUNCTION__, '3.0.0', 'wp_constrain_dimensions()' );
52
+    return wp_constrain_dimensions( $width, $height, $wmax, $hmax );
53 53
 }
54 54
 
55 55
 /**
@@ -64,8 +64,8 @@  discard block
 block discarded – undo
64 64
  * @return array Shrunk dimensions (width, height).
65 65
  */
66 66
 function get_udims( $width, $height ) {
67
-	_deprecated_function( __FUNCTION__, '3.5.0', 'wp_constrain_dimensions()' );
68
-	return wp_constrain_dimensions( $width, $height, 128, 96 );
67
+    _deprecated_function( __FUNCTION__, '3.5.0', 'wp_constrain_dimensions()' );
68
+    return wp_constrain_dimensions( $width, $height, 128, 96 );
69 69
 }
70 70
 
71 71
 /**
@@ -82,9 +82,9 @@  discard block
 block discarded – undo
82 82
  * @param array $popular_ids      Unused.
83 83
  */
84 84
 function dropdown_categories( $default_category = 0, $category_parent = 0, $popular_ids = array() ) {
85
-	_deprecated_function( __FUNCTION__, '2.6.0', 'wp_category_checklist()' );
86
-	global $post_ID;
87
-	wp_category_checklist( $post_ID );
85
+    _deprecated_function( __FUNCTION__, '2.6.0', 'wp_category_checklist()' );
86
+    global $post_ID;
87
+    wp_category_checklist( $post_ID );
88 88
 }
89 89
 
90 90
 /**
@@ -99,9 +99,9 @@  discard block
 block discarded – undo
99 99
  * @param int $default_link_category Unused.
100 100
  */
101 101
 function dropdown_link_categories( $default_link_category = 0 ) {
102
-	_deprecated_function( __FUNCTION__, '2.6.0', 'wp_link_category_checklist()' );
103
-	global $link_id;
104
-	wp_link_category_checklist( $link_id );
102
+    _deprecated_function( __FUNCTION__, '2.6.0', 'wp_link_category_checklist()' );
103
+    global $link_id;
104
+    wp_link_category_checklist( $link_id );
105 105
 }
106 106
 
107 107
 /**
@@ -115,9 +115,9 @@  discard block
 block discarded – undo
115 115
  * @return string Full filesystem path to edit.
116 116
  */
117 117
 function get_real_file_to_edit( $file ) {
118
-	_deprecated_function( __FUNCTION__, '2.9.0' );
118
+    _deprecated_function( __FUNCTION__, '2.9.0' );
119 119
 
120
-	return WP_CONTENT_DIR . $file;
120
+    return WP_CONTENT_DIR . $file;
121 121
 }
122 122
 
123 123
 /**
@@ -135,25 +135,25 @@  discard block
 block discarded – undo
135 135
  * @return void|false Void on success, false if no categories were found.
136 136
  */
137 137
 function wp_dropdown_cats( $current_cat = 0, $current_parent = 0, $category_parent = 0, $level = 0, $categories = 0 ) {
138
-	_deprecated_function( __FUNCTION__, '3.0.0', 'wp_dropdown_categories()' );
139
-	if (!$categories )
140
-		$categories = get_categories( array('hide_empty' => 0) );
141
-
142
-	if ( $categories ) {
143
-		foreach ( $categories as $category ) {
144
-			if ( $current_cat != $category->term_id && $category_parent == $category->parent) {
145
-				$pad = str_repeat( '&#8211; ', $level );
146
-				$category->name = esc_html( $category->name );
147
-				echo "\n\t<option value='$category->term_id'";
148
-				if ( $current_parent == $category->term_id )
149
-					echo " selected='selected'";
150
-				echo ">$pad$category->name</option>";
151
-				wp_dropdown_cats( $current_cat, $current_parent, $category->term_id, $level +1, $categories );
152
-			}
153
-		}
154
-	} else {
155
-		return false;
156
-	}
138
+    _deprecated_function( __FUNCTION__, '3.0.0', 'wp_dropdown_categories()' );
139
+    if (!$categories )
140
+        $categories = get_categories( array('hide_empty' => 0) );
141
+
142
+    if ( $categories ) {
143
+        foreach ( $categories as $category ) {
144
+            if ( $current_cat != $category->term_id && $category_parent == $category->parent) {
145
+                $pad = str_repeat( '&#8211; ', $level );
146
+                $category->name = esc_html( $category->name );
147
+                echo "\n\t<option value='$category->term_id'";
148
+                if ( $current_parent == $category->term_id )
149
+                    echo " selected='selected'";
150
+                echo ">$pad$category->name</option>";
151
+                wp_dropdown_cats( $current_cat, $current_parent, $category->term_id, $level +1, $categories );
152
+            }
153
+        }
154
+    } else {
155
+        return false;
156
+    }
157 157
 }
158 158
 
159 159
 /**
@@ -170,8 +170,8 @@  discard block
 block discarded – undo
170 170
  * @param callable $sanitize_callback Optional. A callback function that sanitizes the option's value.
171 171
  */
172 172
 function add_option_update_handler( $option_group, $option_name, $sanitize_callback = '' ) {
173
-	_deprecated_function( __FUNCTION__, '3.0.0', 'register_setting()' );
174
-	register_setting( $option_group, $option_name, $sanitize_callback );
173
+    _deprecated_function( __FUNCTION__, '3.0.0', 'register_setting()' );
174
+    register_setting( $option_group, $option_name, $sanitize_callback );
175 175
 }
176 176
 
177 177
 /**
@@ -186,8 +186,8 @@  discard block
 block discarded – undo
186 186
  * @param callable $sanitize_callback Optional. Deprecated.
187 187
  */
188 188
 function remove_option_update_handler( $option_group, $option_name, $sanitize_callback = '' ) {
189
-	_deprecated_function( __FUNCTION__, '3.0.0', 'unregister_setting()' );
190
-	unregister_setting( $option_group, $option_name, $sanitize_callback );
189
+    _deprecated_function( __FUNCTION__, '3.0.0', 'unregister_setting()' );
190
+    unregister_setting( $option_group, $option_name, $sanitize_callback );
191 191
 }
192 192
 
193 193
 /**
@@ -199,7 +199,7 @@  discard block
 block discarded – undo
199 199
  * @param string $filename
200 200
 **/
201 201
 function codepress_get_lang( $filename ) {
202
-	_deprecated_function( __FUNCTION__, '3.0.0' );
202
+    _deprecated_function( __FUNCTION__, '3.0.0' );
203 203
 }
204 204
 
205 205
 /**
@@ -209,7 +209,7 @@  discard block
 block discarded – undo
209 209
  * @deprecated 3.0.0
210 210
 **/
211 211
 function codepress_footer_js() {
212
-	_deprecated_function( __FUNCTION__, '3.0.0' );
212
+    _deprecated_function( __FUNCTION__, '3.0.0' );
213 213
 }
214 214
 
215 215
 /**
@@ -219,7 +219,7 @@  discard block
 block discarded – undo
219 219
  * @deprecated 3.0.0
220 220
 **/
221 221
 function use_codepress() {
222
-	_deprecated_function( __FUNCTION__, '3.0.0' );
222
+    _deprecated_function( __FUNCTION__, '3.0.0' );
223 223
 }
224 224
 
225 225
 /**
@@ -232,15 +232,15 @@  discard block
 block discarded – undo
232 232
  * @return array List of user IDs.
233 233
  */
234 234
 function get_author_user_ids() {
235
-	_deprecated_function( __FUNCTION__, '3.1.0', 'get_users()' );
235
+    _deprecated_function( __FUNCTION__, '3.1.0', 'get_users()' );
236 236
 
237
-	global $wpdb;
238
-	if ( !is_multisite() )
239
-		$level_key = $wpdb->get_blog_prefix() . 'user_level';
240
-	else
241
-		$level_key = $wpdb->get_blog_prefix() . 'capabilities'; // WPMU site admins don't have user_levels.
237
+    global $wpdb;
238
+    if ( !is_multisite() )
239
+        $level_key = $wpdb->get_blog_prefix() . 'user_level';
240
+    else
241
+        $level_key = $wpdb->get_blog_prefix() . 'capabilities'; // WPMU site admins don't have user_levels.
242 242
 
243
-	return $wpdb->get_col( $wpdb->prepare("SELECT user_id FROM $wpdb->usermeta WHERE meta_key = %s AND meta_value != '0'", $level_key) );
243
+    return $wpdb->get_col( $wpdb->prepare("SELECT user_id FROM $wpdb->usermeta WHERE meta_key = %s AND meta_value != '0'", $level_key) );
244 244
 }
245 245
 
246 246
 /**
@@ -254,20 +254,20 @@  discard block
 block discarded – undo
254 254
  * @return array|false List of editable authors. False if no editable users.
255 255
  */
256 256
 function get_editable_authors( $user_id ) {
257
-	_deprecated_function( __FUNCTION__, '3.1.0', 'get_users()' );
257
+    _deprecated_function( __FUNCTION__, '3.1.0', 'get_users()' );
258 258
 
259
-	global $wpdb;
259
+    global $wpdb;
260 260
 
261
-	$editable = get_editable_user_ids( $user_id );
261
+    $editable = get_editable_user_ids( $user_id );
262 262
 
263
-	if ( !$editable ) {
264
-		return false;
265
-	} else {
266
-		$editable = join(',', $editable);
267
-		$authors = $wpdb->get_results( "SELECT * FROM $wpdb->users WHERE ID IN ($editable) ORDER BY display_name" );
268
-	}
263
+    if ( !$editable ) {
264
+        return false;
265
+    } else {
266
+        $editable = join(',', $editable);
267
+        $authors = $wpdb->get_results( "SELECT * FROM $wpdb->users WHERE ID IN ($editable) ORDER BY display_name" );
268
+    }
269 269
 
270
-	return apply_filters('get_editable_authors', $authors);
270
+    return apply_filters('get_editable_authors', $authors);
271 271
 }
272 272
 
273 273
 /**
@@ -282,31 +282,31 @@  discard block
 block discarded – undo
282 282
  * @return array Array of editable user IDs, empty array otherwise.
283 283
  */
284 284
 function get_editable_user_ids( $user_id, $exclude_zeros = true, $post_type = 'post' ) {
285
-	_deprecated_function( __FUNCTION__, '3.1.0', 'get_users()' );
285
+    _deprecated_function( __FUNCTION__, '3.1.0', 'get_users()' );
286 286
 
287
-	global $wpdb;
287
+    global $wpdb;
288 288
 
289
-	if ( ! $user = get_userdata( $user_id ) )
290
-		return array();
291
-	$post_type_obj = get_post_type_object($post_type);
289
+    if ( ! $user = get_userdata( $user_id ) )
290
+        return array();
291
+    $post_type_obj = get_post_type_object($post_type);
292 292
 
293
-	if ( ! $user->has_cap($post_type_obj->cap->edit_others_posts) ) {
294
-		if ( $user->has_cap($post_type_obj->cap->edit_posts) || ! $exclude_zeros )
295
-			return array($user->ID);
296
-		else
297
-			return array();
298
-	}
293
+    if ( ! $user->has_cap($post_type_obj->cap->edit_others_posts) ) {
294
+        if ( $user->has_cap($post_type_obj->cap->edit_posts) || ! $exclude_zeros )
295
+            return array($user->ID);
296
+        else
297
+            return array();
298
+    }
299 299
 
300
-	if ( !is_multisite() )
301
-		$level_key = $wpdb->get_blog_prefix() . 'user_level';
302
-	else
303
-		$level_key = $wpdb->get_blog_prefix() . 'capabilities'; // WPMU site admins don't have user_levels.
300
+    if ( !is_multisite() )
301
+        $level_key = $wpdb->get_blog_prefix() . 'user_level';
302
+    else
303
+        $level_key = $wpdb->get_blog_prefix() . 'capabilities'; // WPMU site admins don't have user_levels.
304 304
 
305
-	$query = $wpdb->prepare("SELECT user_id FROM $wpdb->usermeta WHERE meta_key = %s", $level_key);
306
-	if ( $exclude_zeros )
307
-		$query .= " AND meta_value != '0'";
305
+    $query = $wpdb->prepare("SELECT user_id FROM $wpdb->usermeta WHERE meta_key = %s", $level_key);
306
+    if ( $exclude_zeros )
307
+        $query .= " AND meta_value != '0'";
308 308
 
309
-	return $wpdb->get_col( $query );
309
+    return $wpdb->get_col( $query );
310 310
 }
311 311
 
312 312
 /**
@@ -317,16 +317,16 @@  discard block
 block discarded – undo
317 317
  * @global wpdb $wpdb WordPress database abstraction object.
318 318
  */
319 319
 function get_nonauthor_user_ids() {
320
-	_deprecated_function( __FUNCTION__, '3.1.0', 'get_users()' );
320
+    _deprecated_function( __FUNCTION__, '3.1.0', 'get_users()' );
321 321
 
322
-	global $wpdb;
322
+    global $wpdb;
323 323
 
324
-	if ( !is_multisite() )
325
-		$level_key = $wpdb->get_blog_prefix() . 'user_level';
326
-	else
327
-		$level_key = $wpdb->get_blog_prefix() . 'capabilities'; // WPMU site admins don't have user_levels.
324
+    if ( !is_multisite() )
325
+        $level_key = $wpdb->get_blog_prefix() . 'user_level';
326
+    else
327
+        $level_key = $wpdb->get_blog_prefix() . 'capabilities'; // WPMU site admins don't have user_levels.
328 328
 
329
-	return $wpdb->get_col( $wpdb->prepare("SELECT user_id FROM $wpdb->usermeta WHERE meta_key = %s AND meta_value = '0'", $level_key) );
329
+    return $wpdb->get_col( $wpdb->prepare("SELECT user_id FROM $wpdb->usermeta WHERE meta_key = %s AND meta_value = '0'", $level_key) );
330 330
 }
331 331
 
332 332
 if ( ! class_exists( 'WP_User_Search', false ) ) :
@@ -338,337 +338,337 @@  discard block
 block discarded – undo
338 338
  */
339 339
 class WP_User_Search {
340 340
 
341
-	/**
342
-	 * {@internal Missing Description}}
343
-	 *
344
-	 * @since 2.1.0
345
-	 * @access private
346
-	 * @var mixed
347
-	 */
348
-	var $results;
349
-
350
-	/**
351
-	 * {@internal Missing Description}}
352
-	 *
353
-	 * @since 2.1.0
354
-	 * @access private
355
-	 * @var string
356
-	 */
357
-	var $search_term;
358
-
359
-	/**
360
-	 * Page number.
361
-	 *
362
-	 * @since 2.1.0
363
-	 * @access private
364
-	 * @var int
365
-	 */
366
-	var $page;
367
-
368
-	/**
369
-	 * Role name that users have.
370
-	 *
371
-	 * @since 2.5.0
372
-	 * @access private
373
-	 * @var string
374
-	 */
375
-	var $role;
376
-
377
-	/**
378
-	 * Raw page number.
379
-	 *
380
-	 * @since 2.1.0
381
-	 * @access private
382
-	 * @var int|bool
383
-	 */
384
-	var $raw_page;
385
-
386
-	/**
387
-	 * Amount of users to display per page.
388
-	 *
389
-	 * @since 2.1.0
390
-	 * @access public
391
-	 * @var int
392
-	 */
393
-	var $users_per_page = 50;
394
-
395
-	/**
396
-	 * {@internal Missing Description}}
397
-	 *
398
-	 * @since 2.1.0
399
-	 * @access private
400
-	 * @var int
401
-	 */
402
-	var $first_user;
403
-
404
-	/**
405
-	 * {@internal Missing Description}}
406
-	 *
407
-	 * @since 2.1.0
408
-	 * @access private
409
-	 * @var int
410
-	 */
411
-	var $last_user;
412
-
413
-	/**
414
-	 * {@internal Missing Description}}
415
-	 *
416
-	 * @since 2.1.0
417
-	 * @access private
418
-	 * @var string
419
-	 */
420
-	var $query_limit;
421
-
422
-	/**
423
-	 * {@internal Missing Description}}
424
-	 *
425
-	 * @since 3.0.0
426
-	 * @access private
427
-	 * @var string
428
-	 */
429
-	var $query_orderby;
430
-
431
-	/**
432
-	 * {@internal Missing Description}}
433
-	 *
434
-	 * @since 3.0.0
435
-	 * @access private
436
-	 * @var string
437
-	 */
438
-	var $query_from;
439
-
440
-	/**
441
-	 * {@internal Missing Description}}
442
-	 *
443
-	 * @since 3.0.0
444
-	 * @access private
445
-	 * @var string
446
-	 */
447
-	var $query_where;
448
-
449
-	/**
450
-	 * {@internal Missing Description}}
451
-	 *
452
-	 * @since 2.1.0
453
-	 * @access private
454
-	 * @var int
455
-	 */
456
-	var $total_users_for_query = 0;
457
-
458
-	/**
459
-	 * {@internal Missing Description}}
460
-	 *
461
-	 * @since 2.1.0
462
-	 * @access private
463
-	 * @var bool
464
-	 */
465
-	var $too_many_total_users = false;
466
-
467
-	/**
468
-	 * {@internal Missing Description}}
469
-	 *
470
-	 * @since 2.1.0
471
-	 * @access private
472
-	 * @var WP_Error
473
-	 */
474
-	var $search_errors;
475
-
476
-	/**
477
-	 * {@internal Missing Description}}
478
-	 *
479
-	 * @since 2.7.0
480
-	 * @access private
481
-	 * @var string
482
-	 */
483
-	var $paging_text;
484
-
485
-	/**
486
-	 * PHP5 Constructor - Sets up the object properties.
487
-	 *
488
-	 * @since 2.1.0
489
-	 *
490
-	 * @param string $search_term Search terms string.
491
-	 * @param int $page Optional. Page ID.
492
-	 * @param string $role Role name.
493
-	 * @return WP_User_Search
494
-	 */
495
-	function __construct( $search_term = '', $page = '', $role = '' ) {
496
-		_deprecated_function( __FUNCTION__, '3.1.0', 'WP_User_Query' );
497
-
498
-		$this->search_term = wp_unslash( $search_term );
499
-		$this->raw_page = ( '' == $page ) ? false : (int) $page;
500
-		$this->page = ( '' == $page ) ? 1 : (int) $page;
501
-		$this->role = $role;
502
-
503
-		$this->prepare_query();
504
-		$this->query();
505
-		$this->do_paging();
506
-	}
507
-
508
-	/**
509
-	 * PHP4 Constructor - Sets up the object properties.
510
-	 *
511
-	 * @since 2.1.0
512
-	 *
513
-	 * @param string $search_term Search terms string.
514
-	 * @param int $page Optional. Page ID.
515
-	 * @param string $role Role name.
516
-	 * @return WP_User_Search
517
-	 */
518
-	public function WP_User_Search( $search_term = '', $page = '', $role = '' ) {
519
-		self::__construct( $search_term, $page, $role );
520
-	}
521
-
522
-	/**
523
-	 * Prepares the user search query (legacy).
524
-	 *
525
-	 * @since 2.1.0
526
-	 * @access public
527
-	 */
528
-	public function prepare_query() {
529
-		global $wpdb;
530
-		$this->first_user = ($this->page - 1) * $this->users_per_page;
531
-
532
-		$this->query_limit = $wpdb->prepare(" LIMIT %d, %d", $this->first_user, $this->users_per_page);
533
-		$this->query_orderby = ' ORDER BY user_login';
534
-
535
-		$search_sql = '';
536
-		if ( $this->search_term ) {
537
-			$searches = array();
538
-			$search_sql = 'AND (';
539
-			foreach ( array('user_login', 'user_nicename', 'user_email', 'user_url', 'display_name') as $col )
540
-				$searches[] = $wpdb->prepare( $col . ' LIKE %s', '%' . like_escape($this->search_term) . '%' );
541
-			$search_sql .= implode(' OR ', $searches);
542
-			$search_sql .= ')';
543
-		}
544
-
545
-		$this->query_from = " FROM $wpdb->users";
546
-		$this->query_where = " WHERE 1=1 $search_sql";
547
-
548
-		if ( $this->role ) {
549
-			$this->query_from .= " INNER JOIN $wpdb->usermeta ON $wpdb->users.ID = $wpdb->usermeta.user_id";
550
-			$this->query_where .= $wpdb->prepare(" AND $wpdb->usermeta.meta_key = '{$wpdb->prefix}capabilities' AND $wpdb->usermeta.meta_value LIKE %s", '%' . $this->role . '%');
551
-		} elseif ( is_multisite() ) {
552
-			$level_key = $wpdb->prefix . 'capabilities'; // WPMU site admins don't have user_levels.
553
-			$this->query_from .= ", $wpdb->usermeta";
554
-			$this->query_where .= " AND $wpdb->users.ID = $wpdb->usermeta.user_id AND meta_key = '{$level_key}'";
555
-		}
556
-
557
-		do_action_ref_array( 'pre_user_search', array( &$this ) );
558
-	}
559
-
560
-	/**
561
-	 * Executes the user search query.
562
-	 *
563
-	 * @since 2.1.0
564
-	 * @access public
565
-	 */
566
-	public function query() {
567
-		global $wpdb;
568
-
569
-		$this->results = $wpdb->get_col("SELECT DISTINCT($wpdb->users.ID)" . $this->query_from . $this->query_where . $this->query_orderby . $this->query_limit);
570
-
571
-		if ( $this->results )
572
-			$this->total_users_for_query = $wpdb->get_var("SELECT COUNT(DISTINCT($wpdb->users.ID))" . $this->query_from . $this->query_where); // No limit.
573
-		else
574
-			$this->search_errors = new WP_Error('no_matching_users_found', __('No users found.'));
575
-	}
576
-
577
-	/**
578
-	 * Prepares variables for use in templates.
579
-	 *
580
-	 * @since 2.1.0
581
-	 * @access public
582
-	 */
583
-	function prepare_vars_for_template_usage() {}
584
-
585
-	/**
586
-	 * Handles paging for the user search query.
587
-	 *
588
-	 * @since 2.1.0
589
-	 * @access public
590
-	 */
591
-	public function do_paging() {
592
-		if ( $this->total_users_for_query > $this->users_per_page ) { // Have to page the results.
593
-			$args = array();
594
-			if ( ! empty($this->search_term) )
595
-				$args['usersearch'] = urlencode($this->search_term);
596
-			if ( ! empty($this->role) )
597
-				$args['role'] = urlencode($this->role);
598
-
599
-			$this->paging_text = paginate_links( array(
600
-				'total' => ceil($this->total_users_for_query / $this->users_per_page),
601
-				'current' => $this->page,
602
-				'base' => 'users.php?%_%',
603
-				'format' => 'userspage=%#%',
604
-				'add_args' => $args
605
-			) );
606
-			if ( $this->paging_text ) {
607
-				$this->paging_text = sprintf(
608
-					/* translators: 1: Starting number of users on the current page, 2: Ending number of users, 3: Total number of users. */
609
-					'<span class="displaying-num">' . __( 'Displaying %1$s&#8211;%2$s of %3$s' ) . '</span>%s',
610
-					number_format_i18n( ( $this->page - 1 ) * $this->users_per_page + 1 ),
611
-					number_format_i18n( min( $this->page * $this->users_per_page, $this->total_users_for_query ) ),
612
-					number_format_i18n( $this->total_users_for_query ),
613
-					$this->paging_text
614
-				);
615
-			}
616
-		}
617
-	}
618
-
619
-	/**
620
-	 * Retrieves the user search query results.
621
-	 *
622
-	 * @since 2.1.0
623
-	 * @access public
624
-	 *
625
-	 * @return array
626
-	 */
627
-	public function get_results() {
628
-		return (array) $this->results;
629
-	}
630
-
631
-	/**
632
-	 * Displaying paging text.
633
-	 *
634
-	 * @see do_paging() Builds paging text.
635
-	 *
636
-	 * @since 2.1.0
637
-	 * @access public
638
-	 */
639
-	function page_links() {
640
-		echo $this->paging_text;
641
-	}
642
-
643
-	/**
644
-	 * Whether paging is enabled.
645
-	 *
646
-	 * @see do_paging() Builds paging text.
647
-	 *
648
-	 * @since 2.1.0
649
-	 * @access public
650
-	 *
651
-	 * @return bool
652
-	 */
653
-	function results_are_paged() {
654
-		if ( $this->paging_text )
655
-			return true;
656
-		return false;
657
-	}
658
-
659
-	/**
660
-	 * Whether there are search terms.
661
-	 *
662
-	 * @since 2.1.0
663
-	 * @access public
664
-	 *
665
-	 * @return bool
666
-	 */
667
-	function is_search() {
668
-		if ( $this->search_term )
669
-			return true;
670
-		return false;
671
-	}
341
+    /**
342
+     * {@internal Missing Description}}
343
+     *
344
+     * @since 2.1.0
345
+     * @access private
346
+     * @var mixed
347
+     */
348
+    var $results;
349
+
350
+    /**
351
+     * {@internal Missing Description}}
352
+     *
353
+     * @since 2.1.0
354
+     * @access private
355
+     * @var string
356
+     */
357
+    var $search_term;
358
+
359
+    /**
360
+     * Page number.
361
+     *
362
+     * @since 2.1.0
363
+     * @access private
364
+     * @var int
365
+     */
366
+    var $page;
367
+
368
+    /**
369
+     * Role name that users have.
370
+     *
371
+     * @since 2.5.0
372
+     * @access private
373
+     * @var string
374
+     */
375
+    var $role;
376
+
377
+    /**
378
+     * Raw page number.
379
+     *
380
+     * @since 2.1.0
381
+     * @access private
382
+     * @var int|bool
383
+     */
384
+    var $raw_page;
385
+
386
+    /**
387
+     * Amount of users to display per page.
388
+     *
389
+     * @since 2.1.0
390
+     * @access public
391
+     * @var int
392
+     */
393
+    var $users_per_page = 50;
394
+
395
+    /**
396
+     * {@internal Missing Description}}
397
+     *
398
+     * @since 2.1.0
399
+     * @access private
400
+     * @var int
401
+     */
402
+    var $first_user;
403
+
404
+    /**
405
+     * {@internal Missing Description}}
406
+     *
407
+     * @since 2.1.0
408
+     * @access private
409
+     * @var int
410
+     */
411
+    var $last_user;
412
+
413
+    /**
414
+     * {@internal Missing Description}}
415
+     *
416
+     * @since 2.1.0
417
+     * @access private
418
+     * @var string
419
+     */
420
+    var $query_limit;
421
+
422
+    /**
423
+     * {@internal Missing Description}}
424
+     *
425
+     * @since 3.0.0
426
+     * @access private
427
+     * @var string
428
+     */
429
+    var $query_orderby;
430
+
431
+    /**
432
+     * {@internal Missing Description}}
433
+     *
434
+     * @since 3.0.0
435
+     * @access private
436
+     * @var string
437
+     */
438
+    var $query_from;
439
+
440
+    /**
441
+     * {@internal Missing Description}}
442
+     *
443
+     * @since 3.0.0
444
+     * @access private
445
+     * @var string
446
+     */
447
+    var $query_where;
448
+
449
+    /**
450
+     * {@internal Missing Description}}
451
+     *
452
+     * @since 2.1.0
453
+     * @access private
454
+     * @var int
455
+     */
456
+    var $total_users_for_query = 0;
457
+
458
+    /**
459
+     * {@internal Missing Description}}
460
+     *
461
+     * @since 2.1.0
462
+     * @access private
463
+     * @var bool
464
+     */
465
+    var $too_many_total_users = false;
466
+
467
+    /**
468
+     * {@internal Missing Description}}
469
+     *
470
+     * @since 2.1.0
471
+     * @access private
472
+     * @var WP_Error
473
+     */
474
+    var $search_errors;
475
+
476
+    /**
477
+     * {@internal Missing Description}}
478
+     *
479
+     * @since 2.7.0
480
+     * @access private
481
+     * @var string
482
+     */
483
+    var $paging_text;
484
+
485
+    /**
486
+     * PHP5 Constructor - Sets up the object properties.
487
+     *
488
+     * @since 2.1.0
489
+     *
490
+     * @param string $search_term Search terms string.
491
+     * @param int $page Optional. Page ID.
492
+     * @param string $role Role name.
493
+     * @return WP_User_Search
494
+     */
495
+    function __construct( $search_term = '', $page = '', $role = '' ) {
496
+        _deprecated_function( __FUNCTION__, '3.1.0', 'WP_User_Query' );
497
+
498
+        $this->search_term = wp_unslash( $search_term );
499
+        $this->raw_page = ( '' == $page ) ? false : (int) $page;
500
+        $this->page = ( '' == $page ) ? 1 : (int) $page;
501
+        $this->role = $role;
502
+
503
+        $this->prepare_query();
504
+        $this->query();
505
+        $this->do_paging();
506
+    }
507
+
508
+    /**
509
+     * PHP4 Constructor - Sets up the object properties.
510
+     *
511
+     * @since 2.1.0
512
+     *
513
+     * @param string $search_term Search terms string.
514
+     * @param int $page Optional. Page ID.
515
+     * @param string $role Role name.
516
+     * @return WP_User_Search
517
+     */
518
+    public function WP_User_Search( $search_term = '', $page = '', $role = '' ) {
519
+        self::__construct( $search_term, $page, $role );
520
+    }
521
+
522
+    /**
523
+     * Prepares the user search query (legacy).
524
+     *
525
+     * @since 2.1.0
526
+     * @access public
527
+     */
528
+    public function prepare_query() {
529
+        global $wpdb;
530
+        $this->first_user = ($this->page - 1) * $this->users_per_page;
531
+
532
+        $this->query_limit = $wpdb->prepare(" LIMIT %d, %d", $this->first_user, $this->users_per_page);
533
+        $this->query_orderby = ' ORDER BY user_login';
534
+
535
+        $search_sql = '';
536
+        if ( $this->search_term ) {
537
+            $searches = array();
538
+            $search_sql = 'AND (';
539
+            foreach ( array('user_login', 'user_nicename', 'user_email', 'user_url', 'display_name') as $col )
540
+                $searches[] = $wpdb->prepare( $col . ' LIKE %s', '%' . like_escape($this->search_term) . '%' );
541
+            $search_sql .= implode(' OR ', $searches);
542
+            $search_sql .= ')';
543
+        }
544
+
545
+        $this->query_from = " FROM $wpdb->users";
546
+        $this->query_where = " WHERE 1=1 $search_sql";
547
+
548
+        if ( $this->role ) {
549
+            $this->query_from .= " INNER JOIN $wpdb->usermeta ON $wpdb->users.ID = $wpdb->usermeta.user_id";
550
+            $this->query_where .= $wpdb->prepare(" AND $wpdb->usermeta.meta_key = '{$wpdb->prefix}capabilities' AND $wpdb->usermeta.meta_value LIKE %s", '%' . $this->role . '%');
551
+        } elseif ( is_multisite() ) {
552
+            $level_key = $wpdb->prefix . 'capabilities'; // WPMU site admins don't have user_levels.
553
+            $this->query_from .= ", $wpdb->usermeta";
554
+            $this->query_where .= " AND $wpdb->users.ID = $wpdb->usermeta.user_id AND meta_key = '{$level_key}'";
555
+        }
556
+
557
+        do_action_ref_array( 'pre_user_search', array( &$this ) );
558
+    }
559
+
560
+    /**
561
+     * Executes the user search query.
562
+     *
563
+     * @since 2.1.0
564
+     * @access public
565
+     */
566
+    public function query() {
567
+        global $wpdb;
568
+
569
+        $this->results = $wpdb->get_col("SELECT DISTINCT($wpdb->users.ID)" . $this->query_from . $this->query_where . $this->query_orderby . $this->query_limit);
570
+
571
+        if ( $this->results )
572
+            $this->total_users_for_query = $wpdb->get_var("SELECT COUNT(DISTINCT($wpdb->users.ID))" . $this->query_from . $this->query_where); // No limit.
573
+        else
574
+            $this->search_errors = new WP_Error('no_matching_users_found', __('No users found.'));
575
+    }
576
+
577
+    /**
578
+     * Prepares variables for use in templates.
579
+     *
580
+     * @since 2.1.0
581
+     * @access public
582
+     */
583
+    function prepare_vars_for_template_usage() {}
584
+
585
+    /**
586
+     * Handles paging for the user search query.
587
+     *
588
+     * @since 2.1.0
589
+     * @access public
590
+     */
591
+    public function do_paging() {
592
+        if ( $this->total_users_for_query > $this->users_per_page ) { // Have to page the results.
593
+            $args = array();
594
+            if ( ! empty($this->search_term) )
595
+                $args['usersearch'] = urlencode($this->search_term);
596
+            if ( ! empty($this->role) )
597
+                $args['role'] = urlencode($this->role);
598
+
599
+            $this->paging_text = paginate_links( array(
600
+                'total' => ceil($this->total_users_for_query / $this->users_per_page),
601
+                'current' => $this->page,
602
+                'base' => 'users.php?%_%',
603
+                'format' => 'userspage=%#%',
604
+                'add_args' => $args
605
+            ) );
606
+            if ( $this->paging_text ) {
607
+                $this->paging_text = sprintf(
608
+                    /* translators: 1: Starting number of users on the current page, 2: Ending number of users, 3: Total number of users. */
609
+                    '<span class="displaying-num">' . __( 'Displaying %1$s&#8211;%2$s of %3$s' ) . '</span>%s',
610
+                    number_format_i18n( ( $this->page - 1 ) * $this->users_per_page + 1 ),
611
+                    number_format_i18n( min( $this->page * $this->users_per_page, $this->total_users_for_query ) ),
612
+                    number_format_i18n( $this->total_users_for_query ),
613
+                    $this->paging_text
614
+                );
615
+            }
616
+        }
617
+    }
618
+
619
+    /**
620
+     * Retrieves the user search query results.
621
+     *
622
+     * @since 2.1.0
623
+     * @access public
624
+     *
625
+     * @return array
626
+     */
627
+    public function get_results() {
628
+        return (array) $this->results;
629
+    }
630
+
631
+    /**
632
+     * Displaying paging text.
633
+     *
634
+     * @see do_paging() Builds paging text.
635
+     *
636
+     * @since 2.1.0
637
+     * @access public
638
+     */
639
+    function page_links() {
640
+        echo $this->paging_text;
641
+    }
642
+
643
+    /**
644
+     * Whether paging is enabled.
645
+     *
646
+     * @see do_paging() Builds paging text.
647
+     *
648
+     * @since 2.1.0
649
+     * @access public
650
+     *
651
+     * @return bool
652
+     */
653
+    function results_are_paged() {
654
+        if ( $this->paging_text )
655
+            return true;
656
+        return false;
657
+    }
658
+
659
+    /**
660
+     * Whether there are search terms.
661
+     *
662
+     * @since 2.1.0
663
+     * @access public
664
+     *
665
+     * @return bool
666
+     */
667
+    function is_search() {
668
+        if ( $this->search_term )
669
+            return true;
670
+        return false;
671
+    }
672 672
 }
673 673
 endif;
674 674
 
@@ -687,27 +687,27 @@  discard block
 block discarded – undo
687 687
  * @return array List of posts from others.
688 688
  */
689 689
 function get_others_unpublished_posts( $user_id, $type = 'any' ) {
690
-	_deprecated_function( __FUNCTION__, '3.1.0' );
690
+    _deprecated_function( __FUNCTION__, '3.1.0' );
691 691
 
692
-	global $wpdb;
692
+    global $wpdb;
693 693
 
694
-	$editable = get_editable_user_ids( $user_id );
694
+    $editable = get_editable_user_ids( $user_id );
695 695
 
696
-	if ( in_array($type, array('draft', 'pending')) )
697
-		$type_sql = " post_status = '$type' ";
698
-	else
699
-		$type_sql = " ( post_status = 'draft' OR post_status = 'pending' ) ";
696
+    if ( in_array($type, array('draft', 'pending')) )
697
+        $type_sql = " post_status = '$type' ";
698
+    else
699
+        $type_sql = " ( post_status = 'draft' OR post_status = 'pending' ) ";
700 700
 
701
-	$dir = ( 'pending' == $type ) ? 'ASC' : 'DESC';
701
+    $dir = ( 'pending' == $type ) ? 'ASC' : 'DESC';
702 702
 
703
-	if ( !$editable ) {
704
-		$other_unpubs = '';
705
-	} else {
706
-		$editable = join(',', $editable);
707
-		$other_unpubs = $wpdb->get_results( $wpdb->prepare("SELECT ID, post_title, post_author FROM $wpdb->posts WHERE post_type = 'post' AND $type_sql AND post_author IN ($editable) AND post_author != %d ORDER BY post_modified $dir", $user_id) );
708
-	}
703
+    if ( !$editable ) {
704
+        $other_unpubs = '';
705
+    } else {
706
+        $editable = join(',', $editable);
707
+        $other_unpubs = $wpdb->get_results( $wpdb->prepare("SELECT ID, post_title, post_author FROM $wpdb->posts WHERE post_type = 'post' AND $type_sql AND post_author IN ($editable) AND post_author != %d ORDER BY post_modified $dir", $user_id) );
708
+    }
709 709
 
710
-	return apply_filters('get_others_drafts', $other_unpubs);
710
+    return apply_filters('get_others_drafts', $other_unpubs);
711 711
 }
712 712
 
713 713
 /**
@@ -720,9 +720,9 @@  discard block
 block discarded – undo
720 720
  * @return array List of drafts from other users.
721 721
  */
722 722
 function get_others_drafts($user_id) {
723
-	_deprecated_function( __FUNCTION__, '3.1.0' );
723
+    _deprecated_function( __FUNCTION__, '3.1.0' );
724 724
 
725
-	return get_others_unpublished_posts($user_id, 'draft');
725
+    return get_others_unpublished_posts($user_id, 'draft');
726 726
 }
727 727
 
728 728
 /**
@@ -735,9 +735,9 @@  discard block
 block discarded – undo
735 735
  * @return array List of posts with pending review post type from other users.
736 736
  */
737 737
 function get_others_pending($user_id) {
738
-	_deprecated_function( __FUNCTION__, '3.1.0' );
738
+    _deprecated_function( __FUNCTION__, '3.1.0' );
739 739
 
740
-	return get_others_unpublished_posts($user_id, 'pending');
740
+    return get_others_unpublished_posts($user_id, 'pending');
741 741
 }
742 742
 
743 743
 /**
@@ -748,8 +748,8 @@  discard block
 block discarded – undo
748 748
  * @see wp_dashboard_quick_press()
749 749
  */
750 750
 function wp_dashboard_quick_press_output() {
751
-	_deprecated_function( __FUNCTION__, '3.2.0', 'wp_dashboard_quick_press()' );
752
-	wp_dashboard_quick_press();
751
+    _deprecated_function( __FUNCTION__, '3.2.0', 'wp_dashboard_quick_press()' );
752
+    wp_dashboard_quick_press();
753 753
 }
754 754
 
755 755
 /**
@@ -760,23 +760,23 @@  discard block
 block discarded – undo
760 760
  * @see wp_editor()
761 761
  */
762 762
 function wp_tiny_mce( $teeny = false, $settings = false ) {
763
-	_deprecated_function( __FUNCTION__, '3.3.0', 'wp_editor()' );
763
+    _deprecated_function( __FUNCTION__, '3.3.0', 'wp_editor()' );
764 764
 
765
-	static $num = 1;
765
+    static $num = 1;
766 766
 
767
-	if ( ! class_exists( '_WP_Editors', false ) )
768
-		require_once ABSPATH . WPINC . '/class-wp-editor.php';
767
+    if ( ! class_exists( '_WP_Editors', false ) )
768
+        require_once ABSPATH . WPINC . '/class-wp-editor.php';
769 769
 
770
-	$editor_id = 'content' . $num++;
770
+    $editor_id = 'content' . $num++;
771 771
 
772
-	$set = array(
773
-		'teeny' => $teeny,
774
-		'tinymce' => $settings ? $settings : true,
775
-		'quicktags' => false
776
-	);
772
+    $set = array(
773
+        'teeny' => $teeny,
774
+        'tinymce' => $settings ? $settings : true,
775
+        'quicktags' => false
776
+    );
777 777
 
778
-	$set = _WP_Editors::parse_settings($editor_id, $set);
779
-	_WP_Editors::editor_settings($editor_id, $set);
778
+    $set = _WP_Editors::parse_settings($editor_id, $set);
779
+    _WP_Editors::editor_settings($editor_id, $set);
780 780
 }
781 781
 
782 782
 /**
@@ -786,7 +786,7 @@  discard block
 block discarded – undo
786 786
  * @see wp_editor()
787 787
  */
788 788
 function wp_preload_dialogs() {
789
-	_deprecated_function( __FUNCTION__, '3.3.0', 'wp_editor()' );
789
+    _deprecated_function( __FUNCTION__, '3.3.0', 'wp_editor()' );
790 790
 }
791 791
 
792 792
 /**
@@ -796,7 +796,7 @@  discard block
 block discarded – undo
796 796
  * @see wp_editor()
797 797
  */
798 798
 function wp_print_editor_js() {
799
-	_deprecated_function( __FUNCTION__, '3.3.0', 'wp_editor()' );
799
+    _deprecated_function( __FUNCTION__, '3.3.0', 'wp_editor()' );
800 800
 }
801 801
 
802 802
 /**
@@ -806,7 +806,7 @@  discard block
 block discarded – undo
806 806
  * @see wp_editor()
807 807
  */
808 808
 function wp_quicktags() {
809
-	_deprecated_function( __FUNCTION__, '3.3.0', 'wp_editor()' );
809
+    _deprecated_function( __FUNCTION__, '3.3.0', 'wp_editor()' );
810 810
 }
811 811
 
812 812
 /**
@@ -817,16 +817,16 @@  discard block
 block discarded – undo
817 817
  * @see WP_Screen::render_screen_layout()
818 818
  */
819 819
 function screen_layout( $screen ) {
820
-	_deprecated_function( __FUNCTION__, '3.3.0', '$current_screen->render_screen_layout()' );
820
+    _deprecated_function( __FUNCTION__, '3.3.0', '$current_screen->render_screen_layout()' );
821 821
 
822
-	$current_screen = get_current_screen();
822
+    $current_screen = get_current_screen();
823 823
 
824
-	if ( ! $current_screen )
825
-		return '';
824
+    if ( ! $current_screen )
825
+        return '';
826 826
 
827
-	ob_start();
828
-	$current_screen->render_screen_layout();
829
-	return ob_get_clean();
827
+    ob_start();
828
+    $current_screen->render_screen_layout();
829
+    return ob_get_clean();
830 830
 }
831 831
 
832 832
 /**
@@ -837,16 +837,16 @@  discard block
 block discarded – undo
837 837
  * @see WP_Screen::render_per_page_options()
838 838
  */
839 839
 function screen_options( $screen ) {
840
-	_deprecated_function( __FUNCTION__, '3.3.0', '$current_screen->render_per_page_options()' );
840
+    _deprecated_function( __FUNCTION__, '3.3.0', '$current_screen->render_per_page_options()' );
841 841
 
842
-	$current_screen = get_current_screen();
842
+    $current_screen = get_current_screen();
843 843
 
844
-	if ( ! $current_screen )
845
-		return '';
844
+    if ( ! $current_screen )
845
+        return '';
846 846
 
847
-	ob_start();
848
-	$current_screen->render_per_page_options();
849
-	return ob_get_clean();
847
+    ob_start();
848
+    $current_screen->render_per_page_options();
849
+    return ob_get_clean();
850 850
 }
851 851
 
852 852
 /**
@@ -857,8 +857,8 @@  discard block
 block discarded – undo
857 857
  * @see WP_Screen::render_screen_meta()
858 858
  */
859 859
 function screen_meta( $screen ) {
860
-	$current_screen = get_current_screen();
861
-	$current_screen->render_screen_meta();
860
+    $current_screen = get_current_screen();
861
+    $current_screen->render_screen_meta();
862 862
 }
863 863
 
864 864
 /**
@@ -869,7 +869,7 @@  discard block
 block discarded – undo
869 869
  * @see WP_Admin_Bar
870 870
  */
871 871
 function favorite_actions() {
872
-	_deprecated_function( __FUNCTION__, '3.2.0', 'WP_Admin_Bar' );
872
+    _deprecated_function( __FUNCTION__, '3.2.0', 'WP_Admin_Bar' );
873 873
 }
874 874
 
875 875
 /**
@@ -881,8 +881,8 @@  discard block
 block discarded – undo
881 881
  * @return null|string
882 882
  */
883 883
 function media_upload_image() {
884
-	_deprecated_function( __FUNCTION__, '3.3.0', 'wp_media_upload_handler()' );
885
-	return wp_media_upload_handler();
884
+    _deprecated_function( __FUNCTION__, '3.3.0', 'wp_media_upload_handler()' );
885
+    return wp_media_upload_handler();
886 886
 }
887 887
 
888 888
 /**
@@ -894,8 +894,8 @@  discard block
 block discarded – undo
894 894
  * @return null|string
895 895
  */
896 896
 function media_upload_audio() {
897
-	_deprecated_function( __FUNCTION__, '3.3.0', 'wp_media_upload_handler()' );
898
-	return wp_media_upload_handler();
897
+    _deprecated_function( __FUNCTION__, '3.3.0', 'wp_media_upload_handler()' );
898
+    return wp_media_upload_handler();
899 899
 }
900 900
 
901 901
 /**
@@ -907,8 +907,8 @@  discard block
 block discarded – undo
907 907
  * @return null|string
908 908
  */
909 909
 function media_upload_video() {
910
-	_deprecated_function( __FUNCTION__, '3.3.0', 'wp_media_upload_handler()' );
911
-	return wp_media_upload_handler();
910
+    _deprecated_function( __FUNCTION__, '3.3.0', 'wp_media_upload_handler()' );
911
+    return wp_media_upload_handler();
912 912
 }
913 913
 
914 914
 /**
@@ -920,8 +920,8 @@  discard block
 block discarded – undo
920 920
  * @return null|string
921 921
  */
922 922
 function media_upload_file() {
923
-	_deprecated_function( __FUNCTION__, '3.3.0', 'wp_media_upload_handler()' );
924
-	return wp_media_upload_handler();
923
+    _deprecated_function( __FUNCTION__, '3.3.0', 'wp_media_upload_handler()' );
924
+    return wp_media_upload_handler();
925 925
 }
926 926
 
927 927
 /**
@@ -933,8 +933,8 @@  discard block
 block discarded – undo
933 933
  * @return string
934 934
  */
935 935
 function type_url_form_image() {
936
-	_deprecated_function( __FUNCTION__, '3.3.0', "wp_media_insert_url_form('image')" );
937
-	return wp_media_insert_url_form( 'image' );
936
+    _deprecated_function( __FUNCTION__, '3.3.0', "wp_media_insert_url_form('image')" );
937
+    return wp_media_insert_url_form( 'image' );
938 938
 }
939 939
 
940 940
 /**
@@ -946,8 +946,8 @@  discard block
 block discarded – undo
946 946
  * @return string
947 947
  */
948 948
 function type_url_form_audio() {
949
-	_deprecated_function( __FUNCTION__, '3.3.0', "wp_media_insert_url_form('audio')" );
950
-	return wp_media_insert_url_form( 'audio' );
949
+    _deprecated_function( __FUNCTION__, '3.3.0', "wp_media_insert_url_form('audio')" );
950
+    return wp_media_insert_url_form( 'audio' );
951 951
 }
952 952
 
953 953
 /**
@@ -959,8 +959,8 @@  discard block
 block discarded – undo
959 959
  * @return string
960 960
  */
961 961
 function type_url_form_video() {
962
-	_deprecated_function( __FUNCTION__, '3.3.0', "wp_media_insert_url_form('video')" );
963
-	return wp_media_insert_url_form( 'video' );
962
+    _deprecated_function( __FUNCTION__, '3.3.0', "wp_media_insert_url_form('video')" );
963
+    return wp_media_insert_url_form( 'video' );
964 964
 }
965 965
 
966 966
 /**
@@ -972,8 +972,8 @@  discard block
 block discarded – undo
972 972
  * @return string
973 973
  */
974 974
 function type_url_form_file() {
975
-	_deprecated_function( __FUNCTION__, '3.3.0', "wp_media_insert_url_form('file')" );
976
-	return wp_media_insert_url_form( 'file' );
975
+    _deprecated_function( __FUNCTION__, '3.3.0', "wp_media_insert_url_form('file')" );
976
+    return wp_media_insert_url_form( 'file' );
977 977
 }
978 978
 
979 979
 /**
@@ -990,12 +990,12 @@  discard block
 block discarded – undo
990 990
  * @param string    $help   The content of an 'Overview' help tab.
991 991
  */
992 992
 function add_contextual_help( $screen, $help ) {
993
-	_deprecated_function( __FUNCTION__, '3.3.0', 'get_current_screen()->add_help_tab()' );
993
+    _deprecated_function( __FUNCTION__, '3.3.0', 'get_current_screen()->add_help_tab()' );
994 994
 
995
-	if ( is_string( $screen ) )
996
-		$screen = convert_to_screen( $screen );
995
+    if ( is_string( $screen ) )
996
+        $screen = convert_to_screen( $screen );
997 997
 
998
-	WP_Screen::add_old_compat_help( $screen, $help );
998
+    WP_Screen::add_old_compat_help( $screen, $help );
999 999
 }
1000 1000
 
1001 1001
 /**
@@ -1008,16 +1008,16 @@  discard block
 block discarded – undo
1008 1008
  * @return WP_Theme[] Array of WP_Theme objects keyed by their name.
1009 1009
  */
1010 1010
 function get_allowed_themes() {
1011
-	_deprecated_function( __FUNCTION__, '3.4.0', "wp_get_themes( array( 'allowed' => true ) )" );
1011
+    _deprecated_function( __FUNCTION__, '3.4.0', "wp_get_themes( array( 'allowed' => true ) )" );
1012 1012
 
1013
-	$themes = wp_get_themes( array( 'allowed' => true ) );
1013
+    $themes = wp_get_themes( array( 'allowed' => true ) );
1014 1014
 
1015
-	$wp_themes = array();
1016
-	foreach ( $themes as $theme ) {
1017
-		$wp_themes[ $theme->get('Name') ] = $theme;
1018
-	}
1015
+    $wp_themes = array();
1016
+    foreach ( $themes as $theme ) {
1017
+        $wp_themes[ $theme->get('Name') ] = $theme;
1018
+    }
1019 1019
 
1020
-	return $wp_themes;
1020
+    return $wp_themes;
1021 1021
 }
1022 1022
 
1023 1023
 /**
@@ -1030,19 +1030,19 @@  discard block
 block discarded – undo
1030 1030
  * @return array
1031 1031
  */
1032 1032
 function get_broken_themes() {
1033
-	_deprecated_function( __FUNCTION__, '3.4.0', "wp_get_themes( array( 'errors' => true )" );
1033
+    _deprecated_function( __FUNCTION__, '3.4.0', "wp_get_themes( array( 'errors' => true )" );
1034 1034
 
1035
-	$themes = wp_get_themes( array( 'errors' => true ) );
1036
-	$broken = array();
1037
-	foreach ( $themes as $theme ) {
1038
-		$name = $theme->get('Name');
1039
-		$broken[ $name ] = array(
1040
-			'Name' => $name,
1041
-			'Title' => $name,
1042
-			'Description' => $theme->errors()->get_error_message(),
1043
-		);
1044
-	}
1045
-	return $broken;
1035
+    $themes = wp_get_themes( array( 'errors' => true ) );
1036
+    $broken = array();
1037
+    foreach ( $themes as $theme ) {
1038
+        $name = $theme->get('Name');
1039
+        $broken[ $name ] = array(
1040
+            'Name' => $name,
1041
+            'Title' => $name,
1042
+            'Description' => $theme->errors()->get_error_message(),
1043
+        );
1044
+    }
1045
+    return $broken;
1046 1046
 }
1047 1047
 
1048 1048
 /**
@@ -1055,9 +1055,9 @@  discard block
 block discarded – undo
1055 1055
  * @return WP_Theme
1056 1056
  */
1057 1057
 function current_theme_info() {
1058
-	_deprecated_function( __FUNCTION__, '3.4.0', 'wp_get_theme()' );
1058
+    _deprecated_function( __FUNCTION__, '3.4.0', 'wp_get_theme()' );
1059 1059
 
1060
-	return wp_get_theme();
1060
+    return wp_get_theme();
1061 1061
 }
1062 1062
 
1063 1063
 /**
@@ -1068,7 +1068,7 @@  discard block
 block discarded – undo
1068 1068
  * @deprecated 3.5.0
1069 1069
  */
1070 1070
 function _insert_into_post_button( $type ) {
1071
-	_deprecated_function( __FUNCTION__, '3.5.0' );
1071
+    _deprecated_function( __FUNCTION__, '3.5.0' );
1072 1072
 }
1073 1073
 
1074 1074
 /**
@@ -1079,7 +1079,7 @@  discard block
 block discarded – undo
1079 1079
  * @deprecated 3.5.0
1080 1080
  */
1081 1081
 function _media_button($title, $icon, $type, $id) {
1082
-	_deprecated_function( __FUNCTION__, '3.5.0' );
1082
+    _deprecated_function( __FUNCTION__, '3.5.0' );
1083 1083
 }
1084 1084
 
1085 1085
 /**
@@ -1093,9 +1093,9 @@  discard block
 block discarded – undo
1093 1093
  * @return WP_Post
1094 1094
  */
1095 1095
 function get_post_to_edit( $id ) {
1096
-	_deprecated_function( __FUNCTION__, '3.5.0', 'get_post()' );
1096
+    _deprecated_function( __FUNCTION__, '3.5.0', 'get_post()' );
1097 1097
 
1098
-	return get_post( $id, OBJECT, 'edit' );
1098
+    return get_post( $id, OBJECT, 'edit' );
1099 1099
 }
1100 1100
 
1101 1101
 /**
@@ -1108,11 +1108,11 @@  discard block
 block discarded – undo
1108 1108
  * @return WP_Post Post object containing all the default post data as attributes
1109 1109
  */
1110 1110
 function get_default_page_to_edit() {
1111
-	_deprecated_function( __FUNCTION__, '3.5.0', "get_default_post_to_edit( 'page' )" );
1111
+    _deprecated_function( __FUNCTION__, '3.5.0', "get_default_post_to_edit( 'page' )" );
1112 1112
 
1113
-	$page = get_default_post_to_edit();
1114
-	$page->post_type = 'page';
1115
-	return $page;
1113
+    $page = get_default_post_to_edit();
1114
+    $page->post_type = 'page';
1115
+    return $page;
1116 1116
 }
1117 1117
 
1118 1118
 /**
@@ -1128,8 +1128,8 @@  discard block
 block discarded – undo
1128 1128
  * @return string Thumbnail path on success, Error string on failure.
1129 1129
  */
1130 1130
 function wp_create_thumbnail( $file, $max_side, $deprecated = '' ) {
1131
-	_deprecated_function( __FUNCTION__, '3.5.0', 'image_resize()' );
1132
-	return apply_filters( 'wp_create_thumbnail', image_resize( $file, $max_side, $max_side ) );
1131
+    _deprecated_function( __FUNCTION__, '3.5.0', 'image_resize()' );
1132
+    return apply_filters( 'wp_create_thumbnail', image_resize( $file, $max_side, $max_side ) );
1133 1133
 }
1134 1134
 
1135 1135
 /**
@@ -1141,7 +1141,7 @@  discard block
 block discarded – undo
1141 1141
  * @deprecated 3.6.0
1142 1142
  */
1143 1143
 function wp_nav_menu_locations_meta_box() {
1144
-	_deprecated_function( __FUNCTION__, '3.6.0' );
1144
+    _deprecated_function( __FUNCTION__, '3.6.0' );
1145 1145
 }
1146 1146
 
1147 1147
 /**
@@ -1155,14 +1155,14 @@  discard block
 block discarded – undo
1155 1155
  * @see Core_Upgrader
1156 1156
  */
1157 1157
 function wp_update_core($current, $feedback = '') {
1158
-	_deprecated_function( __FUNCTION__, '3.7.0', 'new Core_Upgrader();' );
1158
+    _deprecated_function( __FUNCTION__, '3.7.0', 'new Core_Upgrader();' );
1159 1159
 
1160
-	if ( !empty($feedback) )
1161
-		add_filter('update_feedback', $feedback);
1160
+    if ( !empty($feedback) )
1161
+        add_filter('update_feedback', $feedback);
1162 1162
 
1163
-	require ABSPATH . 'wp-admin/includes/class-wp-upgrader.php';
1164
-	$upgrader = new Core_Upgrader();
1165
-	return $upgrader->upgrade($current);
1163
+    require ABSPATH . 'wp-admin/includes/class-wp-upgrader.php';
1164
+    $upgrader = new Core_Upgrader();
1165
+    return $upgrader->upgrade($current);
1166 1166
 
1167 1167
 }
1168 1168
 
@@ -1178,14 +1178,14 @@  discard block
 block discarded – undo
1178 1178
  * @see Plugin_Upgrader
1179 1179
  */
1180 1180
 function wp_update_plugin($plugin, $feedback = '') {
1181
-	_deprecated_function( __FUNCTION__, '3.7.0', 'new Plugin_Upgrader();' );
1181
+    _deprecated_function( __FUNCTION__, '3.7.0', 'new Plugin_Upgrader();' );
1182 1182
 
1183
-	if ( !empty($feedback) )
1184
-		add_filter('update_feedback', $feedback);
1183
+    if ( !empty($feedback) )
1184
+        add_filter('update_feedback', $feedback);
1185 1185
 
1186
-	require ABSPATH . 'wp-admin/includes/class-wp-upgrader.php';
1187
-	$upgrader = new Plugin_Upgrader();
1188
-	return $upgrader->upgrade($plugin);
1186
+    require ABSPATH . 'wp-admin/includes/class-wp-upgrader.php';
1187
+    $upgrader = new Plugin_Upgrader();
1188
+    return $upgrader->upgrade($plugin);
1189 1189
 }
1190 1190
 
1191 1191
 /**
@@ -1200,14 +1200,14 @@  discard block
 block discarded – undo
1200 1200
  * @see Theme_Upgrader
1201 1201
  */
1202 1202
 function wp_update_theme($theme, $feedback = '') {
1203
-	_deprecated_function( __FUNCTION__, '3.7.0', 'new Theme_Upgrader();' );
1203
+    _deprecated_function( __FUNCTION__, '3.7.0', 'new Theme_Upgrader();' );
1204 1204
 
1205
-	if ( !empty($feedback) )
1206
-		add_filter('update_feedback', $feedback);
1205
+    if ( !empty($feedback) )
1206
+        add_filter('update_feedback', $feedback);
1207 1207
 
1208
-	require ABSPATH . 'wp-admin/includes/class-wp-upgrader.php';
1209
-	$upgrader = new Theme_Upgrader();
1210
-	return $upgrader->upgrade($theme);
1208
+    require ABSPATH . 'wp-admin/includes/class-wp-upgrader.php';
1209
+    $upgrader = new Theme_Upgrader();
1210
+    return $upgrader->upgrade($theme);
1211 1211
 }
1212 1212
 
1213 1213
 /**
@@ -1219,7 +1219,7 @@  discard block
 block discarded – undo
1219 1219
  * @param int|bool $id
1220 1220
  */
1221 1221
 function the_attachment_links( $id = false ) {
1222
-	_deprecated_function( __FUNCTION__, '3.7.0' );
1222
+    _deprecated_function( __FUNCTION__, '3.7.0' );
1223 1223
 }
1224 1224
 
1225 1225
 /**
@@ -1229,8 +1229,8 @@  discard block
 block discarded – undo
1229 1229
  * @deprecated 3.8.0
1230 1230
  */
1231 1231
 function screen_icon() {
1232
-	_deprecated_function( __FUNCTION__, '3.8.0' );
1233
-	echo get_screen_icon();
1232
+    _deprecated_function( __FUNCTION__, '3.8.0' );
1233
+    echo get_screen_icon();
1234 1234
 }
1235 1235
 
1236 1236
 /**
@@ -1242,8 +1242,8 @@  discard block
 block discarded – undo
1242 1242
  * @return string An HTML comment explaining that icons are no longer used.
1243 1243
  */
1244 1244
 function get_screen_icon() {
1245
-	_deprecated_function( __FUNCTION__, '3.8.0' );
1246
-	return '<!-- Screen icons are no longer used as of WordPress 3.8. -->';
1245
+    _deprecated_function( __FUNCTION__, '3.8.0' );
1246
+    return '<!-- Screen icons are no longer used as of WordPress 3.8. -->';
1247 1247
 }
1248 1248
 
1249 1249
 /**
@@ -1321,76 +1321,76 @@  discard block
 block discarded – undo
1321 1321
  * @param array  $args Array of arguments for this RSS feed.
1322 1322
  */
1323 1323
 function wp_dashboard_plugins_output( $rss, $args = array() ) {
1324
-	_deprecated_function( __FUNCTION__, '4.8.0' );
1324
+    _deprecated_function( __FUNCTION__, '4.8.0' );
1325 1325
 
1326
-	// Plugin feeds plus link to install them.
1327
-	$popular = fetch_feed( $args['url']['popular'] );
1326
+    // Plugin feeds plus link to install them.
1327
+    $popular = fetch_feed( $args['url']['popular'] );
1328 1328
 
1329
-	if ( false === $plugin_slugs = get_transient( 'plugin_slugs' ) ) {
1330
-		$plugin_slugs = array_keys( get_plugins() );
1331
-		set_transient( 'plugin_slugs', $plugin_slugs, DAY_IN_SECONDS );
1332
-	}
1329
+    if ( false === $plugin_slugs = get_transient( 'plugin_slugs' ) ) {
1330
+        $plugin_slugs = array_keys( get_plugins() );
1331
+        set_transient( 'plugin_slugs', $plugin_slugs, DAY_IN_SECONDS );
1332
+    }
1333 1333
 
1334
-	echo '<ul>';
1334
+    echo '<ul>';
1335 1335
 
1336
-	foreach ( array( $popular ) as $feed ) {
1337
-		if ( is_wp_error( $feed ) || ! $feed->get_item_quantity() )
1338
-			continue;
1336
+    foreach ( array( $popular ) as $feed ) {
1337
+        if ( is_wp_error( $feed ) || ! $feed->get_item_quantity() )
1338
+            continue;
1339 1339
 
1340
-		$items = $feed->get_items(0, 5);
1340
+        $items = $feed->get_items(0, 5);
1341 1341
 
1342
-		// Pick a random, non-installed plugin.
1343
-		while ( true ) {
1344
-			// Abort this foreach loop iteration if there's no plugins left of this type.
1345
-			if ( 0 === count($items) )
1346
-				continue 2;
1342
+        // Pick a random, non-installed plugin.
1343
+        while ( true ) {
1344
+            // Abort this foreach loop iteration if there's no plugins left of this type.
1345
+            if ( 0 === count($items) )
1346
+                continue 2;
1347 1347
 
1348
-			$item_key = array_rand($items);
1349
-			$item = $items[$item_key];
1348
+            $item_key = array_rand($items);
1349
+            $item = $items[$item_key];
1350 1350
 
1351
-			list($link, $frag) = explode( '#', $item->get_link() );
1351
+            list($link, $frag) = explode( '#', $item->get_link() );
1352 1352
 
1353
-			$link = esc_url($link);
1354
-			if ( preg_match( '|/([^/]+?)/?$|', $link, $matches ) )
1355
-				$slug = $matches[1];
1356
-			else {
1357
-				unset( $items[$item_key] );
1358
-				continue;
1359
-			}
1353
+            $link = esc_url($link);
1354
+            if ( preg_match( '|/([^/]+?)/?$|', $link, $matches ) )
1355
+                $slug = $matches[1];
1356
+            else {
1357
+                unset( $items[$item_key] );
1358
+                continue;
1359
+            }
1360 1360
 
1361
-			// Is this random plugin's slug already installed? If so, try again.
1362
-			reset( $plugin_slugs );
1363
-			foreach ( $plugin_slugs as $plugin_slug ) {
1364
-				if ( $slug == substr( $plugin_slug, 0, strlen( $slug ) ) ) {
1365
-					unset( $items[$item_key] );
1366
-					continue 2;
1367
-				}
1368
-			}
1361
+            // Is this random plugin's slug already installed? If so, try again.
1362
+            reset( $plugin_slugs );
1363
+            foreach ( $plugin_slugs as $plugin_slug ) {
1364
+                if ( $slug == substr( $plugin_slug, 0, strlen( $slug ) ) ) {
1365
+                    unset( $items[$item_key] );
1366
+                    continue 2;
1367
+                }
1368
+            }
1369 1369
 
1370
-			// If we get to this point, then the random plugin isn't installed and we can stop the while().
1371
-			break;
1372
-		}
1370
+            // If we get to this point, then the random plugin isn't installed and we can stop the while().
1371
+            break;
1372
+        }
1373 1373
 
1374
-		// Eliminate some common badly formed plugin descriptions.
1375
-		while ( ( null !== $item_key = array_rand($items) ) && false !== strpos( $items[$item_key]->get_description(), 'Plugin Name:' ) )
1376
-			unset($items[$item_key]);
1374
+        // Eliminate some common badly formed plugin descriptions.
1375
+        while ( ( null !== $item_key = array_rand($items) ) && false !== strpos( $items[$item_key]->get_description(), 'Plugin Name:' ) )
1376
+            unset($items[$item_key]);
1377 1377
 
1378
-		if ( !isset($items[$item_key]) )
1379
-			continue;
1378
+        if ( !isset($items[$item_key]) )
1379
+            continue;
1380 1380
 
1381
-		$raw_title = $item->get_title();
1381
+        $raw_title = $item->get_title();
1382 1382
 
1383
-		$ilink = wp_nonce_url('plugin-install.php?tab=plugin-information&plugin=' . $slug, 'install-plugin_' . $slug) . '&amp;TB_iframe=true&amp;width=600&amp;height=800';
1384
-		echo '<li class="dashboard-news-plugin"><span>' . __( 'Popular Plugin' ) . ':</span> ' . esc_html( $raw_title ) .
1385
-			'&nbsp;<a href="' . $ilink . '" class="thickbox open-plugin-details-modal" aria-label="' .
1386
-			/* translators: %s: Plugin name. */
1387
-			esc_attr( sprintf( _x( 'Install %s', 'plugin' ), $raw_title ) ) . '">(' . __( 'Install' ) . ')</a></li>';
1383
+        $ilink = wp_nonce_url('plugin-install.php?tab=plugin-information&plugin=' . $slug, 'install-plugin_' . $slug) . '&amp;TB_iframe=true&amp;width=600&amp;height=800';
1384
+        echo '<li class="dashboard-news-plugin"><span>' . __( 'Popular Plugin' ) . ':</span> ' . esc_html( $raw_title ) .
1385
+            '&nbsp;<a href="' . $ilink . '" class="thickbox open-plugin-details-modal" aria-label="' .
1386
+            /* translators: %s: Plugin name. */
1387
+            esc_attr( sprintf( _x( 'Install %s', 'plugin' ), $raw_title ) ) . '">(' . __( 'Install' ) . ')</a></li>';
1388 1388
 
1389
-		$feed->__destruct();
1390
-		unset( $feed );
1391
-	}
1389
+        $feed->__destruct();
1390
+        unset( $feed );
1391
+    }
1392 1392
 
1393
-	echo '</ul>';
1393
+    echo '</ul>';
1394 1394
 }
1395 1395
 
1396 1396
 /**
@@ -1404,7 +1404,7 @@  discard block
 block discarded – undo
1404 1404
  * @param int $new_ID
1405 1405
  */
1406 1406
 function _relocate_children( $old_ID, $new_ID ) {
1407
-	_deprecated_function( __FUNCTION__, '3.9.0' );
1407
+    _deprecated_function( __FUNCTION__, '3.9.0' );
1408 1408
 }
1409 1409
 
1410 1410
 /**
@@ -1431,13 +1431,13 @@  discard block
 block discarded – undo
1431 1431
  * @return string The resulting page's hook_suffix.
1432 1432
  */
1433 1433
 function add_object_page( $page_title, $menu_title, $capability, $menu_slug, $callback = '', $icon_url = '') {
1434
-	_deprecated_function( __FUNCTION__, '4.5.0', 'add_menu_page()' );
1434
+    _deprecated_function( __FUNCTION__, '4.5.0', 'add_menu_page()' );
1435 1435
 
1436
-	global $_wp_last_object_menu;
1436
+    global $_wp_last_object_menu;
1437 1437
 
1438
-	$_wp_last_object_menu++;
1438
+    $_wp_last_object_menu++;
1439 1439
 
1440
-	return add_menu_page($page_title, $menu_title, $capability, $menu_slug, $callback, $icon_url, $_wp_last_object_menu);
1440
+    return add_menu_page($page_title, $menu_title, $capability, $menu_slug, $callback, $icon_url, $_wp_last_object_menu);
1441 1441
 }
1442 1442
 
1443 1443
 /**
@@ -1464,13 +1464,13 @@  discard block
 block discarded – undo
1464 1464
  * @return string The resulting page's hook_suffix.
1465 1465
  */
1466 1466
 function add_utility_page( $page_title, $menu_title, $capability, $menu_slug, $callback = '', $icon_url = '') {
1467
-	_deprecated_function( __FUNCTION__, '4.5.0', 'add_menu_page()' );
1467
+    _deprecated_function( __FUNCTION__, '4.5.0', 'add_menu_page()' );
1468 1468
 
1469
-	global $_wp_last_utility_menu;
1469
+    global $_wp_last_utility_menu;
1470 1470
 
1471
-	$_wp_last_utility_menu++;
1471
+    $_wp_last_utility_menu++;
1472 1472
 
1473
-	return add_menu_page($page_title, $menu_title, $capability, $menu_slug, $callback, $icon_url, $_wp_last_utility_menu);
1473
+    return add_menu_page($page_title, $menu_title, $capability, $menu_slug, $callback, $icon_url, $_wp_last_utility_menu);
1474 1474
 }
1475 1475
 
1476 1476
 /**
@@ -1489,13 +1489,13 @@  discard block
 block discarded – undo
1489 1489
  * @global bool $is_chrome
1490 1490
  */
1491 1491
 function post_form_autocomplete_off() {
1492
-	global $is_safari, $is_chrome;
1492
+    global $is_safari, $is_chrome;
1493 1493
 
1494
-	_deprecated_function( __FUNCTION__, '4.6.0' );
1494
+    _deprecated_function( __FUNCTION__, '4.6.0' );
1495 1495
 
1496
-	if ( $is_safari || $is_chrome ) {
1497
-		echo ' autocomplete="off"';
1498
-	}
1496
+    if ( $is_safari || $is_chrome ) {
1497
+        echo ' autocomplete="off"';
1498
+    }
1499 1499
 }
1500 1500
 
1501 1501
 /**
@@ -1505,7 +1505,7 @@  discard block
 block discarded – undo
1505 1505
  * @deprecated 4.9.0
1506 1506
  */
1507 1507
 function options_permalink_add_js() {
1508
-	?>
1508
+    ?>
1509 1509
 	<script type="text/javascript">
1510 1510
 		jQuery( function() {
1511 1511
 			jQuery('.permalink-structure input:radio').change(function() {
@@ -1528,15 +1528,15 @@  discard block
 block discarded – undo
1528 1528
  * @deprecated 5.3.0
1529 1529
  */
1530 1530
 class WP_Privacy_Data_Export_Requests_Table extends WP_Privacy_Data_Export_Requests_List_Table {
1531
-	function __construct( $args ) {
1532
-		_deprecated_function( __CLASS__, '5.3.0', 'WP_Privacy_Data_Export_Requests_List_Table' );
1531
+    function __construct( $args ) {
1532
+        _deprecated_function( __CLASS__, '5.3.0', 'WP_Privacy_Data_Export_Requests_List_Table' );
1533 1533
 
1534
-		if ( ! isset( $args['screen'] ) || $args['screen'] === 'export_personal_data' ) {
1535
-			$args['screen'] = 'export-personal-data';
1536
-		}
1534
+        if ( ! isset( $args['screen'] ) || $args['screen'] === 'export_personal_data' ) {
1535
+            $args['screen'] = 'export-personal-data';
1536
+        }
1537 1537
 
1538
-		parent::__construct( $args );
1539
-	}
1538
+        parent::__construct( $args );
1539
+    }
1540 1540
 }
1541 1541
 
1542 1542
 /**
@@ -1546,15 +1546,15 @@  discard block
 block discarded – undo
1546 1546
  * @deprecated 5.3.0
1547 1547
  */
1548 1548
 class WP_Privacy_Data_Removal_Requests_Table extends WP_Privacy_Data_Removal_Requests_List_Table {
1549
-	function __construct( $args ) {
1550
-		_deprecated_function( __CLASS__, '5.3.0', 'WP_Privacy_Data_Removal_Requests_List_Table' );
1549
+    function __construct( $args ) {
1550
+        _deprecated_function( __CLASS__, '5.3.0', 'WP_Privacy_Data_Removal_Requests_List_Table' );
1551 1551
 
1552
-		if ( ! isset( $args['screen'] ) || $args['screen'] === 'remove_personal_data' ) {
1553
-			$args['screen'] = 'erase-personal-data';
1554
-		}
1552
+        if ( ! isset( $args['screen'] ) || $args['screen'] === 'remove_personal_data' ) {
1553
+            $args['screen'] = 'erase-personal-data';
1554
+        }
1555 1555
 
1556
-		parent::__construct( $args );
1557
-	}
1556
+        parent::__construct( $args );
1557
+    }
1558 1558
 }
1559 1559
 
1560 1560
 /**
@@ -1565,7 +1565,7 @@  discard block
 block discarded – undo
1565 1565
  * @deprecated 5.3.0
1566 1566
  */
1567 1567
 function _wp_privacy_requests_screen_options() {
1568
-	_deprecated_function( __FUNCTION__, '5.3.0' );
1568
+    _deprecated_function( __FUNCTION__, '5.3.0' );
1569 1569
 }
1570 1570
 
1571 1571
 /**
@@ -1580,7 +1580,7 @@  discard block
 block discarded – undo
1580 1580
  * @return array Attachment post object converted to an array.
1581 1581
  */
1582 1582
 function image_attachment_fields_to_save( $post, $attachment ) {
1583
-	_deprecated_function( __FUNCTION__, '6.0.0' );
1583
+    _deprecated_function( __FUNCTION__, '6.0.0' );
1584 1584
 
1585
-	return $post;
1585
+    return $post;
1586 1586
 }
Please login to merge, or discard this patch.
brighty/wp-admin/includes/update.php 1 patch
Indentation   +761 added lines, -761 removed lines patch added patch discarded remove patch
@@ -14,14 +14,14 @@  discard block
 block discarded – undo
14 14
  * @return object|array|false The response from the API on success, false on failure.
15 15
  */
16 16
 function get_preferred_from_update_core() {
17
-	$updates = get_core_updates();
18
-	if ( ! is_array( $updates ) ) {
19
-		return false;
20
-	}
21
-	if ( empty( $updates ) ) {
22
-		return (object) array( 'response' => 'latest' );
23
-	}
24
-	return $updates[0];
17
+    $updates = get_core_updates();
18
+    if ( ! is_array( $updates ) ) {
19
+        return false;
20
+    }
21
+    if ( empty( $updates ) ) {
22
+        return (object) array( 'response' => 'latest' );
23
+    }
24
+    return $updates[0];
25 25
 }
26 26
 
27 27
 /**
@@ -34,45 +34,45 @@  discard block
 block discarded – undo
34 34
  * @return array|false Array of the update objects on success, false on failure.
35 35
  */
36 36
 function get_core_updates( $options = array() ) {
37
-	$options   = array_merge(
38
-		array(
39
-			'available' => true,
40
-			'dismissed' => false,
41
-		),
42
-		$options
43
-	);
44
-	$dismissed = get_site_option( 'dismissed_update_core' );
45
-
46
-	if ( ! is_array( $dismissed ) ) {
47
-		$dismissed = array();
48
-	}
49
-
50
-	$from_api = get_site_transient( 'update_core' );
51
-
52
-	if ( ! isset( $from_api->updates ) || ! is_array( $from_api->updates ) ) {
53
-		return false;
54
-	}
55
-
56
-	$updates = $from_api->updates;
57
-	$result  = array();
58
-	foreach ( $updates as $update ) {
59
-		if ( 'autoupdate' === $update->response ) {
60
-			continue;
61
-		}
62
-
63
-		if ( array_key_exists( $update->current . '|' . $update->locale, $dismissed ) ) {
64
-			if ( $options['dismissed'] ) {
65
-				$update->dismissed = true;
66
-				$result[]          = $update;
67
-			}
68
-		} else {
69
-			if ( $options['available'] ) {
70
-				$update->dismissed = false;
71
-				$result[]          = $update;
72
-			}
73
-		}
74
-	}
75
-	return $result;
37
+    $options   = array_merge(
38
+        array(
39
+            'available' => true,
40
+            'dismissed' => false,
41
+        ),
42
+        $options
43
+    );
44
+    $dismissed = get_site_option( 'dismissed_update_core' );
45
+
46
+    if ( ! is_array( $dismissed ) ) {
47
+        $dismissed = array();
48
+    }
49
+
50
+    $from_api = get_site_transient( 'update_core' );
51
+
52
+    if ( ! isset( $from_api->updates ) || ! is_array( $from_api->updates ) ) {
53
+        return false;
54
+    }
55
+
56
+    $updates = $from_api->updates;
57
+    $result  = array();
58
+    foreach ( $updates as $update ) {
59
+        if ( 'autoupdate' === $update->response ) {
60
+            continue;
61
+        }
62
+
63
+        if ( array_key_exists( $update->current . '|' . $update->locale, $dismissed ) ) {
64
+            if ( $options['dismissed'] ) {
65
+                $update->dismissed = true;
66
+                $result[]          = $update;
67
+            }
68
+        } else {
69
+            if ( $options['available'] ) {
70
+                $update->dismissed = false;
71
+                $result[]          = $update;
72
+            }
73
+        }
74
+    }
75
+    return $result;
76 76
 }
77 77
 
78 78
 /**
@@ -85,29 +85,29 @@  discard block
 block discarded – undo
85 85
  * @return object|false The core update offering on success, false on failure.
86 86
  */
87 87
 function find_core_auto_update() {
88
-	$updates = get_site_transient( 'update_core' );
89
-	if ( ! $updates || empty( $updates->updates ) ) {
90
-		return false;
91
-	}
92
-
93
-	require_once ABSPATH . 'wp-admin/includes/class-wp-upgrader.php';
94
-
95
-	$auto_update = false;
96
-	$upgrader    = new WP_Automatic_Updater;
97
-	foreach ( $updates->updates as $update ) {
98
-		if ( 'autoupdate' !== $update->response ) {
99
-			continue;
100
-		}
101
-
102
-		if ( ! $upgrader->should_update( 'core', $update, ABSPATH ) ) {
103
-			continue;
104
-		}
105
-
106
-		if ( ! $auto_update || version_compare( $update->current, $auto_update->current, '>' ) ) {
107
-			$auto_update = $update;
108
-		}
109
-	}
110
-	return $auto_update;
88
+    $updates = get_site_transient( 'update_core' );
89
+    if ( ! $updates || empty( $updates->updates ) ) {
90
+        return false;
91
+    }
92
+
93
+    require_once ABSPATH . 'wp-admin/includes/class-wp-upgrader.php';
94
+
95
+    $auto_update = false;
96
+    $upgrader    = new WP_Automatic_Updater;
97
+    foreach ( $updates->updates as $update ) {
98
+        if ( 'autoupdate' !== $update->response ) {
99
+            continue;
100
+        }
101
+
102
+        if ( ! $upgrader->should_update( 'core', $update, ABSPATH ) ) {
103
+            continue;
104
+        }
105
+
106
+        if ( ! $auto_update || version_compare( $update->current, $auto_update->current, '>' ) ) {
107
+            $auto_update = $update;
108
+        }
109
+    }
110
+    return $auto_update;
111 111
 }
112 112
 
113 113
 /**
@@ -120,43 +120,43 @@  discard block
 block discarded – undo
120 120
  * @return array|false An array of checksums on success, false on failure.
121 121
  */
122 122
 function get_core_checksums( $version, $locale ) {
123
-	$http_url = 'http://api.wordpress.org/core/checksums/1.0/?' . http_build_query( compact( 'version', 'locale' ), '', '&' );
124
-	$url      = $http_url;
125
-
126
-	$ssl = wp_http_supports( array( 'ssl' ) );
127
-	if ( $ssl ) {
128
-		$url = set_url_scheme( $url, 'https' );
129
-	}
130
-
131
-	$options = array(
132
-		'timeout' => wp_doing_cron() ? 30 : 3,
133
-	);
134
-
135
-	$response = wp_remote_get( $url, $options );
136
-	if ( $ssl && is_wp_error( $response ) ) {
137
-		trigger_error(
138
-			sprintf(
139
-				/* translators: %s: Support forums URL. */
140
-				__( '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>.' ),
141
-				__( 'https://wordpress.org/support/forums/' )
142
-			) . ' ' . __( '(WordPress could not establish a secure connection to WordPress.org. Please contact your server administrator.)' ),
143
-			headers_sent() || WP_DEBUG ? E_USER_WARNING : E_USER_NOTICE
144
-		);
145
-		$response = wp_remote_get( $http_url, $options );
146
-	}
147
-
148
-	if ( is_wp_error( $response ) || 200 != wp_remote_retrieve_response_code( $response ) ) {
149
-		return false;
150
-	}
151
-
152
-	$body = trim( wp_remote_retrieve_body( $response ) );
153
-	$body = json_decode( $body, true );
154
-
155
-	if ( ! is_array( $body ) || ! isset( $body['checksums'] ) || ! is_array( $body['checksums'] ) ) {
156
-		return false;
157
-	}
158
-
159
-	return $body['checksums'];
123
+    $http_url = 'http://api.wordpress.org/core/checksums/1.0/?' . http_build_query( compact( 'version', 'locale' ), '', '&' );
124
+    $url      = $http_url;
125
+
126
+    $ssl = wp_http_supports( array( 'ssl' ) );
127
+    if ( $ssl ) {
128
+        $url = set_url_scheme( $url, 'https' );
129
+    }
130
+
131
+    $options = array(
132
+        'timeout' => wp_doing_cron() ? 30 : 3,
133
+    );
134
+
135
+    $response = wp_remote_get( $url, $options );
136
+    if ( $ssl && is_wp_error( $response ) ) {
137
+        trigger_error(
138
+            sprintf(
139
+                /* translators: %s: Support forums URL. */
140
+                __( '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>.' ),
141
+                __( 'https://wordpress.org/support/forums/' )
142
+            ) . ' ' . __( '(WordPress could not establish a secure connection to WordPress.org. Please contact your server administrator.)' ),
143
+            headers_sent() || WP_DEBUG ? E_USER_WARNING : E_USER_NOTICE
144
+        );
145
+        $response = wp_remote_get( $http_url, $options );
146
+    }
147
+
148
+    if ( is_wp_error( $response ) || 200 != wp_remote_retrieve_response_code( $response ) ) {
149
+        return false;
150
+    }
151
+
152
+    $body = trim( wp_remote_retrieve_body( $response ) );
153
+    $body = json_decode( $body, true );
154
+
155
+    if ( ! is_array( $body ) || ! isset( $body['checksums'] ) || ! is_array( $body['checksums'] ) ) {
156
+        return false;
157
+    }
158
+
159
+    return $body['checksums'];
160 160
 }
161 161
 
162 162
 /**
@@ -168,9 +168,9 @@  discard block
 block discarded – undo
168 168
  * @return bool
169 169
  */
170 170
 function dismiss_core_update( $update ) {
171
-	$dismissed = get_site_option( 'dismissed_update_core' );
172
-	$dismissed[ $update->current . '|' . $update->locale ] = true;
173
-	return update_site_option( 'dismissed_update_core', $dismissed );
171
+    $dismissed = get_site_option( 'dismissed_update_core' );
172
+    $dismissed[ $update->current . '|' . $update->locale ] = true;
173
+    return update_site_option( 'dismissed_update_core', $dismissed );
174 174
 }
175 175
 
176 176
 /**
@@ -183,15 +183,15 @@  discard block
 block discarded – undo
183 183
  * @return bool
184 184
  */
185 185
 function undismiss_core_update( $version, $locale ) {
186
-	$dismissed = get_site_option( 'dismissed_update_core' );
187
-	$key       = $version . '|' . $locale;
186
+    $dismissed = get_site_option( 'dismissed_update_core' );
187
+    $key       = $version . '|' . $locale;
188 188
 
189
-	if ( ! isset( $dismissed[ $key ] ) ) {
190
-		return false;
191
-	}
189
+    if ( ! isset( $dismissed[ $key ] ) ) {
190
+        return false;
191
+    }
192 192
 
193
-	unset( $dismissed[ $key ] );
194
-	return update_site_option( 'dismissed_update_core', $dismissed );
193
+    unset( $dismissed[ $key ] );
194
+    return update_site_option( 'dismissed_update_core', $dismissed );
195 195
 }
196 196
 
197 197
 /**
@@ -204,19 +204,19 @@  discard block
 block discarded – undo
204 204
  * @return object|false The core update offering on success, false on failure.
205 205
  */
206 206
 function find_core_update( $version, $locale ) {
207
-	$from_api = get_site_transient( 'update_core' );
208
-
209
-	if ( ! isset( $from_api->updates ) || ! is_array( $from_api->updates ) ) {
210
-		return false;
211
-	}
212
-
213
-	$updates = $from_api->updates;
214
-	foreach ( $updates as $update ) {
215
-		if ( $update->current == $version && $update->locale == $locale ) {
216
-			return $update;
217
-		}
218
-	}
219
-	return false;
207
+    $from_api = get_site_transient( 'update_core' );
208
+
209
+    if ( ! isset( $from_api->updates ) || ! is_array( $from_api->updates ) ) {
210
+        return false;
211
+    }
212
+
213
+    $updates = $from_api->updates;
214
+    foreach ( $updates as $update ) {
215
+        if ( $update->current == $version && $update->locale == $locale ) {
216
+            return $update;
217
+        }
218
+    }
219
+    return false;
220 220
 }
221 221
 
222 222
 /**
@@ -226,52 +226,52 @@  discard block
 block discarded – undo
226 226
  * @return string
227 227
  */
228 228
 function core_update_footer( $msg = '' ) {
229
-	if ( ! current_user_can( 'update_core' ) ) {
230
-		/* translators: %s: WordPress version. */
231
-		return sprintf( __( 'Version %s' ), get_bloginfo( 'version', 'display' ) );
232
-	}
233
-
234
-	$cur = get_preferred_from_update_core();
235
-	if ( ! is_object( $cur ) ) {
236
-		$cur = new stdClass;
237
-	}
238
-
239
-	if ( ! isset( $cur->current ) ) {
240
-		$cur->current = '';
241
-	}
242
-
243
-	if ( ! isset( $cur->response ) ) {
244
-		$cur->response = '';
245
-	}
246
-
247
-	// Include an unmodified $wp_version.
248
-	require ABSPATH . WPINC . '/version.php';
249
-
250
-	$is_development_version = preg_match( '/alpha|beta|RC/', $wp_version );
251
-
252
-	if ( $is_development_version ) {
253
-		return sprintf(
254
-			/* translators: 1: WordPress version number, 2: URL to WordPress Updates screen. */
255
-			__( 'You are using a development version (%1$s). Cool! Please <a href="%2$s">stay updated</a>.' ),
256
-			get_bloginfo( 'version', 'display' ),
257
-			network_admin_url( 'update-core.php' )
258
-		);
259
-	}
260
-
261
-	switch ( $cur->response ) {
262
-		case 'upgrade':
263
-			return sprintf(
264
-				'<strong><a href="%s">%s</a></strong>',
265
-				network_admin_url( 'update-core.php' ),
266
-				/* translators: %s: WordPress version. */
267
-				sprintf( __( 'Get Version %s' ), $cur->current )
268
-			);
269
-
270
-		case 'latest':
271
-		default:
272
-			/* translators: %s: WordPress version. */
273
-			return sprintf( __( 'Version %s' ), get_bloginfo( 'version', 'display' ) );
274
-	}
229
+    if ( ! current_user_can( 'update_core' ) ) {
230
+        /* translators: %s: WordPress version. */
231
+        return sprintf( __( 'Version %s' ), get_bloginfo( 'version', 'display' ) );
232
+    }
233
+
234
+    $cur = get_preferred_from_update_core();
235
+    if ( ! is_object( $cur ) ) {
236
+        $cur = new stdClass;
237
+    }
238
+
239
+    if ( ! isset( $cur->current ) ) {
240
+        $cur->current = '';
241
+    }
242
+
243
+    if ( ! isset( $cur->response ) ) {
244
+        $cur->response = '';
245
+    }
246
+
247
+    // Include an unmodified $wp_version.
248
+    require ABSPATH . WPINC . '/version.php';
249
+
250
+    $is_development_version = preg_match( '/alpha|beta|RC/', $wp_version );
251
+
252
+    if ( $is_development_version ) {
253
+        return sprintf(
254
+            /* translators: 1: WordPress version number, 2: URL to WordPress Updates screen. */
255
+            __( 'You are using a development version (%1$s). Cool! Please <a href="%2$s">stay updated</a>.' ),
256
+            get_bloginfo( 'version', 'display' ),
257
+            network_admin_url( 'update-core.php' )
258
+        );
259
+    }
260
+
261
+    switch ( $cur->response ) {
262
+        case 'upgrade':
263
+            return sprintf(
264
+                '<strong><a href="%s">%s</a></strong>',
265
+                network_admin_url( 'update-core.php' ),
266
+                /* translators: %s: WordPress version. */
267
+                sprintf( __( 'Get Version %s' ), $cur->current )
268
+            );
269
+
270
+        case 'latest':
271
+        default:
272
+            /* translators: %s: WordPress version. */
273
+            return sprintf( __( 'Version %s' ), get_bloginfo( 'version', 'display' ) );
274
+    }
275 275
 }
276 276
 
277 277
 /**
@@ -281,47 +281,47 @@  discard block
 block discarded – undo
281 281
  * @return void|false
282 282
  */
283 283
 function update_nag() {
284
-	global $pagenow;
285
-
286
-	if ( is_multisite() && ! current_user_can( 'update_core' ) ) {
287
-		return false;
288
-	}
289
-
290
-	if ( 'update-core.php' === $pagenow ) {
291
-		return;
292
-	}
293
-
294
-	$cur = get_preferred_from_update_core();
295
-
296
-	if ( ! isset( $cur->response ) || 'upgrade' !== $cur->response ) {
297
-		return false;
298
-	}
299
-
300
-	$version_url = sprintf(
301
-		/* translators: %s: WordPress version. */
302
-		esc_url( __( 'https://wordpress.org/support/wordpress-version/version-%s/' ) ),
303
-		sanitize_title( $cur->current )
304
-	);
305
-
306
-	if ( current_user_can( 'update_core' ) ) {
307
-		$msg = sprintf(
308
-			/* translators: 1: URL to WordPress release notes, 2: New WordPress version, 3: URL to network admin, 4: Accessibility text. */
309
-			__( '<a href="%1$s">WordPress %2$s</a> is available! <a href="%3$s" aria-label="%4$s">Please update now</a>.' ),
310
-			$version_url,
311
-			$cur->current,
312
-			network_admin_url( 'update-core.php' ),
313
-			esc_attr__( 'Please update WordPress now' )
314
-		);
315
-	} else {
316
-		$msg = sprintf(
317
-			/* translators: 1: URL to WordPress release notes, 2: New WordPress version. */
318
-			__( '<a href="%1$s">WordPress %2$s</a> is available! Please notify the site administrator.' ),
319
-			$version_url,
320
-			$cur->current
321
-		);
322
-	}
323
-
324
-	echo "<div class='update-nag notice notice-warning inline'>$msg</div>";
284
+    global $pagenow;
285
+
286
+    if ( is_multisite() && ! current_user_can( 'update_core' ) ) {
287
+        return false;
288
+    }
289
+
290
+    if ( 'update-core.php' === $pagenow ) {
291
+        return;
292
+    }
293
+
294
+    $cur = get_preferred_from_update_core();
295
+
296
+    if ( ! isset( $cur->response ) || 'upgrade' !== $cur->response ) {
297
+        return false;
298
+    }
299
+
300
+    $version_url = sprintf(
301
+        /* translators: %s: WordPress version. */
302
+        esc_url( __( 'https://wordpress.org/support/wordpress-version/version-%s/' ) ),
303
+        sanitize_title( $cur->current )
304
+    );
305
+
306
+    if ( current_user_can( 'update_core' ) ) {
307
+        $msg = sprintf(
308
+            /* translators: 1: URL to WordPress release notes, 2: New WordPress version, 3: URL to network admin, 4: Accessibility text. */
309
+            __( '<a href="%1$s">WordPress %2$s</a> is available! <a href="%3$s" aria-label="%4$s">Please update now</a>.' ),
310
+            $version_url,
311
+            $cur->current,
312
+            network_admin_url( 'update-core.php' ),
313
+            esc_attr__( 'Please update WordPress now' )
314
+        );
315
+    } else {
316
+        $msg = sprintf(
317
+            /* translators: 1: URL to WordPress release notes, 2: New WordPress version. */
318
+            __( '<a href="%1$s">WordPress %2$s</a> is available! Please notify the site administrator.' ),
319
+            $version_url,
320
+            $cur->current
321
+        );
322
+    }
323
+
324
+    echo "<div class='update-nag notice notice-warning inline'>$msg</div>";
325 325
 }
326 326
 
327 327
 /**
@@ -330,43 +330,43 @@  discard block
 block discarded – undo
330 330
  * @since 2.5.0
331 331
  */
332 332
 function update_right_now_message() {
333
-	$theme_name = wp_get_theme();
334
-	if ( current_user_can( 'switch_themes' ) ) {
335
-		$theme_name = sprintf( '<a href="themes.php">%1$s</a>', $theme_name );
336
-	}
337
-
338
-	$msg = '';
339
-
340
-	if ( current_user_can( 'update_core' ) ) {
341
-		$cur = get_preferred_from_update_core();
342
-
343
-		if ( isset( $cur->response ) && 'upgrade' === $cur->response ) {
344
-			$msg .= sprintf(
345
-				'<a href="%s" class="button" aria-describedby="wp-version">%s</a> ',
346
-				network_admin_url( 'update-core.php' ),
347
-				/* translators: %s: WordPress version number, or 'Latest' string. */
348
-				sprintf( __( 'Update to %s' ), $cur->current ? $cur->current : __( 'Latest' ) )
349
-			);
350
-		}
351
-	}
352
-
353
-	/* translators: 1: Version number, 2: Theme name. */
354
-	$content = __( 'WordPress %1$s running %2$s theme.' );
355
-
356
-	/**
357
-	 * Filters the text displayed in the 'At a Glance' dashboard widget.
358
-	 *
359
-	 * Prior to 3.8.0, the widget was named 'Right Now'.
360
-	 *
361
-	 * @since 4.4.0
362
-	 *
363
-	 * @param string $content Default text.
364
-	 */
365
-	$content = apply_filters( 'update_right_now_text', $content );
366
-
367
-	$msg .= sprintf( '<span id="wp-version">' . $content . '</span>', get_bloginfo( 'version', 'display' ), $theme_name );
368
-
369
-	echo "<p id='wp-version-message'>$msg</p>";
333
+    $theme_name = wp_get_theme();
334
+    if ( current_user_can( 'switch_themes' ) ) {
335
+        $theme_name = sprintf( '<a href="themes.php">%1$s</a>', $theme_name );
336
+    }
337
+
338
+    $msg = '';
339
+
340
+    if ( current_user_can( 'update_core' ) ) {
341
+        $cur = get_preferred_from_update_core();
342
+
343
+        if ( isset( $cur->response ) && 'upgrade' === $cur->response ) {
344
+            $msg .= sprintf(
345
+                '<a href="%s" class="button" aria-describedby="wp-version">%s</a> ',
346
+                network_admin_url( 'update-core.php' ),
347
+                /* translators: %s: WordPress version number, or 'Latest' string. */
348
+                sprintf( __( 'Update to %s' ), $cur->current ? $cur->current : __( 'Latest' ) )
349
+            );
350
+        }
351
+    }
352
+
353
+    /* translators: 1: Version number, 2: Theme name. */
354
+    $content = __( 'WordPress %1$s running %2$s theme.' );
355
+
356
+    /**
357
+     * Filters the text displayed in the 'At a Glance' dashboard widget.
358
+     *
359
+     * Prior to 3.8.0, the widget was named 'Right Now'.
360
+     *
361
+     * @since 4.4.0
362
+     *
363
+     * @param string $content Default text.
364
+     */
365
+    $content = apply_filters( 'update_right_now_text', $content );
366
+
367
+    $msg .= sprintf( '<span id="wp-version">' . $content . '</span>', get_bloginfo( 'version', 'display' ), $theme_name );
368
+
369
+    echo "<p id='wp-version-message'>$msg</p>";
370 370
 }
371 371
 
372 372
 /**
@@ -375,34 +375,34 @@  discard block
 block discarded – undo
375 375
  * @return array
376 376
  */
377 377
 function get_plugin_updates() {
378
-	$all_plugins     = get_plugins();
379
-	$upgrade_plugins = array();
380
-	$current         = get_site_transient( 'update_plugins' );
381
-	foreach ( (array) $all_plugins as $plugin_file => $plugin_data ) {
382
-		if ( isset( $current->response[ $plugin_file ] ) ) {
383
-			$upgrade_plugins[ $plugin_file ]         = (object) $plugin_data;
384
-			$upgrade_plugins[ $plugin_file ]->update = $current->response[ $plugin_file ];
385
-		}
386
-	}
387
-
388
-	return $upgrade_plugins;
378
+    $all_plugins     = get_plugins();
379
+    $upgrade_plugins = array();
380
+    $current         = get_site_transient( 'update_plugins' );
381
+    foreach ( (array) $all_plugins as $plugin_file => $plugin_data ) {
382
+        if ( isset( $current->response[ $plugin_file ] ) ) {
383
+            $upgrade_plugins[ $plugin_file ]         = (object) $plugin_data;
384
+            $upgrade_plugins[ $plugin_file ]->update = $current->response[ $plugin_file ];
385
+        }
386
+    }
387
+
388
+    return $upgrade_plugins;
389 389
 }
390 390
 
391 391
 /**
392 392
  * @since 2.9.0
393 393
  */
394 394
 function wp_plugin_update_rows() {
395
-	if ( ! current_user_can( 'update_plugins' ) ) {
396
-		return;
397
-	}
398
-
399
-	$plugins = get_site_transient( 'update_plugins' );
400
-	if ( isset( $plugins->response ) && is_array( $plugins->response ) ) {
401
-		$plugins = array_keys( $plugins->response );
402
-		foreach ( $plugins as $plugin_file ) {
403
-			add_action( "after_plugin_row_{$plugin_file}", 'wp_plugin_update_row', 10, 2 );
404
-		}
405
-	}
395
+    if ( ! current_user_can( 'update_plugins' ) ) {
396
+        return;
397
+    }
398
+
399
+    $plugins = get_site_transient( 'update_plugins' );
400
+    if ( isset( $plugins->response ) && is_array( $plugins->response ) ) {
401
+        $plugins = array_keys( $plugins->response );
402
+        foreach ( $plugins as $plugin_file ) {
403
+            add_action( "after_plugin_row_{$plugin_file}", 'wp_plugin_update_row', 10, 2 );
404
+        }
405
+    }
406 406
 }
407 407
 
408 408
 /**
@@ -415,173 +415,173 @@  discard block
 block discarded – undo
415 415
  * @return void|false
416 416
  */
417 417
 function wp_plugin_update_row( $file, $plugin_data ) {
418
-	$current = get_site_transient( 'update_plugins' );
419
-	if ( ! isset( $current->response[ $file ] ) ) {
420
-		return false;
421
-	}
422
-
423
-	$response = $current->response[ $file ];
424
-
425
-	$plugins_allowedtags = array(
426
-		'a'       => array(
427
-			'href'  => array(),
428
-			'title' => array(),
429
-		),
430
-		'abbr'    => array( 'title' => array() ),
431
-		'acronym' => array( 'title' => array() ),
432
-		'code'    => array(),
433
-		'em'      => array(),
434
-		'strong'  => array(),
435
-	);
436
-
437
-	$plugin_name = wp_kses( $plugin_data['Name'], $plugins_allowedtags );
438
-	$plugin_slug = isset( $response->slug ) ? $response->slug : $response->id;
439
-
440
-	if ( isset( $response->slug ) ) {
441
-		$details_url = self_admin_url( 'plugin-install.php?tab=plugin-information&plugin=' . $plugin_slug . '&section=changelog' );
442
-	} elseif ( isset( $response->url ) ) {
443
-		$details_url = $response->url;
444
-	} else {
445
-		$details_url = $plugin_data['PluginURI'];
446
-	}
447
-
448
-	$details_url = add_query_arg(
449
-		array(
450
-			'TB_iframe' => 'true',
451
-			'width'     => 600,
452
-			'height'    => 800,
453
-		),
454
-		$details_url
455
-	);
456
-
457
-	/** @var WP_Plugins_List_Table $wp_list_table */
458
-	$wp_list_table = _get_list_table(
459
-		'WP_Plugins_List_Table',
460
-		array(
461
-			'screen' => get_current_screen(),
462
-		)
463
-	);
464
-
465
-	if ( is_network_admin() || ! is_multisite() ) {
466
-		if ( is_network_admin() ) {
467
-			$active_class = is_plugin_active_for_network( $file ) ? ' active' : '';
468
-		} else {
469
-			$active_class = is_plugin_active( $file ) ? ' active' : '';
470
-		}
471
-
472
-		$requires_php   = isset( $response->requires_php ) ? $response->requires_php : null;
473
-		$compatible_php = is_php_version_compatible( $requires_php );
474
-		$notice_type    = $compatible_php ? 'notice-warning' : 'notice-error';
475
-
476
-		printf(
477
-			'<tr class="plugin-update-tr%s" id="%s" data-slug="%s" data-plugin="%s">' .
478
-			'<td colspan="%s" class="plugin-update colspanchange">' .
479
-			'<div class="update-message notice inline %s notice-alt"><p>',
480
-			$active_class,
481
-			esc_attr( $plugin_slug . '-update' ),
482
-			esc_attr( $plugin_slug ),
483
-			esc_attr( $file ),
484
-			esc_attr( $wp_list_table->get_column_count() ),
485
-			$notice_type
486
-		);
487
-
488
-		if ( ! current_user_can( 'update_plugins' ) ) {
489
-			printf(
490
-				/* translators: 1: Plugin name, 2: Details URL, 3: Additional link attributes, 4: Version number. */
491
-				__( 'There is a new version of %1$s available. <a href="%2$s" %3$s>View version %4$s details</a>.' ),
492
-				$plugin_name,
493
-				esc_url( $details_url ),
494
-				sprintf(
495
-					'class="thickbox open-plugin-details-modal" aria-label="%s"',
496
-					/* translators: 1: Plugin name, 2: Version number. */
497
-					esc_attr( sprintf( __( 'View %1$s version %2$s details' ), $plugin_name, $response->new_version ) )
498
-				),
499
-				esc_attr( $response->new_version )
500
-			);
501
-		} elseif ( empty( $response->package ) ) {
502
-			printf(
503
-				/* translators: 1: Plugin name, 2: Details URL, 3: Additional link attributes, 4: Version number. */
504
-				__( '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 plugin.</em>' ),
505
-				$plugin_name,
506
-				esc_url( $details_url ),
507
-				sprintf(
508
-					'class="thickbox open-plugin-details-modal" aria-label="%s"',
509
-					/* translators: 1: Plugin name, 2: Version number. */
510
-					esc_attr( sprintf( __( 'View %1$s version %2$s details' ), $plugin_name, $response->new_version ) )
511
-				),
512
-				esc_attr( $response->new_version )
513
-			);
514
-		} else {
515
-			if ( $compatible_php ) {
516
-				printf(
517
-					/* translators: 1: Plugin name, 2: Details URL, 3: Additional link attributes, 4: Version number, 5: Update URL, 6: Additional link attributes. */
518
-					__( '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>.' ),
519
-					$plugin_name,
520
-					esc_url( $details_url ),
521
-					sprintf(
522
-						'class="thickbox open-plugin-details-modal" aria-label="%s"',
523
-						/* translators: 1: Plugin name, 2: Version number. */
524
-						esc_attr( sprintf( __( 'View %1$s version %2$s details' ), $plugin_name, $response->new_version ) )
525
-					),
526
-					esc_attr( $response->new_version ),
527
-					wp_nonce_url( self_admin_url( 'update.php?action=upgrade-plugin&plugin=' ) . $file, 'upgrade-plugin_' . $file ),
528
-					sprintf(
529
-						'class="update-link" aria-label="%s"',
530
-						/* translators: %s: Plugin name. */
531
-						esc_attr( sprintf( _x( 'Update %s now', 'plugin' ), $plugin_name ) )
532
-					)
533
-				);
534
-			} else {
535
-				printf(
536
-					/* translators: 1: Plugin name, 2: Details URL, 3: Additional link attributes, 4: Version number 5: URL to Update PHP page. */
537
-					__( 'There is a new version of %1$s available, but it does not work with your version of PHP. <a href="%2$s" %3$s>View version %4$s details</a> or <a href="%5$s">learn more about updating PHP</a>.' ),
538
-					$plugin_name,
539
-					esc_url( $details_url ),
540
-					sprintf(
541
-						'class="thickbox open-plugin-details-modal" aria-label="%s"',
542
-						/* translators: 1: Plugin name, 2: Version number. */
543
-						esc_attr( sprintf( __( 'View %1$s version %2$s details' ), $plugin_name, $response->new_version ) )
544
-					),
545
-					esc_attr( $response->new_version ),
546
-					esc_url( wp_get_update_php_url() )
547
-				);
548
-				wp_update_php_annotation( '<br><em>', '</em>' );
549
-			}
550
-		}
551
-
552
-		/**
553
-		 * Fires at the end of the update message container in each
554
-		 * row of the plugins list table.
555
-		 *
556
-		 * The dynamic portion of the hook name, `$file`, refers to the path
557
-		 * of the plugin's primary file relative to the plugins directory.
558
-		 *
559
-		 * @since 2.8.0
560
-		 *
561
-		 * @param array  $plugin_data An array of plugin metadata. See get_plugin_data()
562
-		 *                            and the {@see 'plugin_row_meta'} filter for the list
563
-		 *                            of possible values.
564
-		 * @param object $response {
565
-		 *     An object of metadata about the available plugin update.
566
-		 *
567
-		 *     @type string   $id           Plugin ID, e.g. `w.org/plugins/[plugin-name]`.
568
-		 *     @type string   $slug         Plugin slug.
569
-		 *     @type string   $plugin       Plugin basename.
570
-		 *     @type string   $new_version  New plugin version.
571
-		 *     @type string   $url          Plugin URL.
572
-		 *     @type string   $package      Plugin update package URL.
573
-		 *     @type string[] $icons        An array of plugin icon URLs.
574
-		 *     @type string[] $banners      An array of plugin banner URLs.
575
-		 *     @type string[] $banners_rtl  An array of plugin RTL banner URLs.
576
-		 *     @type string   $requires     The version of WordPress which the plugin requires.
577
-		 *     @type string   $tested       The version of WordPress the plugin is tested against.
578
-		 *     @type string   $requires_php The version of PHP which the plugin requires.
579
-		 * }
580
-		 */
581
-		do_action( "in_plugin_update_message-{$file}", $plugin_data, $response ); // phpcs:ignore WordPress.NamingConventions.ValidHookName.UseUnderscores
582
-
583
-		echo '</p></div></td></tr>';
584
-	}
418
+    $current = get_site_transient( 'update_plugins' );
419
+    if ( ! isset( $current->response[ $file ] ) ) {
420
+        return false;
421
+    }
422
+
423
+    $response = $current->response[ $file ];
424
+
425
+    $plugins_allowedtags = array(
426
+        'a'       => array(
427
+            'href'  => array(),
428
+            'title' => array(),
429
+        ),
430
+        'abbr'    => array( 'title' => array() ),
431
+        'acronym' => array( 'title' => array() ),
432
+        'code'    => array(),
433
+        'em'      => array(),
434
+        'strong'  => array(),
435
+    );
436
+
437
+    $plugin_name = wp_kses( $plugin_data['Name'], $plugins_allowedtags );
438
+    $plugin_slug = isset( $response->slug ) ? $response->slug : $response->id;
439
+
440
+    if ( isset( $response->slug ) ) {
441
+        $details_url = self_admin_url( 'plugin-install.php?tab=plugin-information&plugin=' . $plugin_slug . '&section=changelog' );
442
+    } elseif ( isset( $response->url ) ) {
443
+        $details_url = $response->url;
444
+    } else {
445
+        $details_url = $plugin_data['PluginURI'];
446
+    }
447
+
448
+    $details_url = add_query_arg(
449
+        array(
450
+            'TB_iframe' => 'true',
451
+            'width'     => 600,
452
+            'height'    => 800,
453
+        ),
454
+        $details_url
455
+    );
456
+
457
+    /** @var WP_Plugins_List_Table $wp_list_table */
458
+    $wp_list_table = _get_list_table(
459
+        'WP_Plugins_List_Table',
460
+        array(
461
+            'screen' => get_current_screen(),
462
+        )
463
+    );
464
+
465
+    if ( is_network_admin() || ! is_multisite() ) {
466
+        if ( is_network_admin() ) {
467
+            $active_class = is_plugin_active_for_network( $file ) ? ' active' : '';
468
+        } else {
469
+            $active_class = is_plugin_active( $file ) ? ' active' : '';
470
+        }
471
+
472
+        $requires_php   = isset( $response->requires_php ) ? $response->requires_php : null;
473
+        $compatible_php = is_php_version_compatible( $requires_php );
474
+        $notice_type    = $compatible_php ? 'notice-warning' : 'notice-error';
475
+
476
+        printf(
477
+            '<tr class="plugin-update-tr%s" id="%s" data-slug="%s" data-plugin="%s">' .
478
+            '<td colspan="%s" class="plugin-update colspanchange">' .
479
+            '<div class="update-message notice inline %s notice-alt"><p>',
480
+            $active_class,
481
+            esc_attr( $plugin_slug . '-update' ),
482
+            esc_attr( $plugin_slug ),
483
+            esc_attr( $file ),
484
+            esc_attr( $wp_list_table->get_column_count() ),
485
+            $notice_type
486
+        );
487
+
488
+        if ( ! current_user_can( 'update_plugins' ) ) {
489
+            printf(
490
+                /* translators: 1: Plugin name, 2: Details URL, 3: Additional link attributes, 4: Version number. */
491
+                __( 'There is a new version of %1$s available. <a href="%2$s" %3$s>View version %4$s details</a>.' ),
492
+                $plugin_name,
493
+                esc_url( $details_url ),
494
+                sprintf(
495
+                    'class="thickbox open-plugin-details-modal" aria-label="%s"',
496
+                    /* translators: 1: Plugin name, 2: Version number. */
497
+                    esc_attr( sprintf( __( 'View %1$s version %2$s details' ), $plugin_name, $response->new_version ) )
498
+                ),
499
+                esc_attr( $response->new_version )
500
+            );
501
+        } elseif ( empty( $response->package ) ) {
502
+            printf(
503
+                /* translators: 1: Plugin name, 2: Details URL, 3: Additional link attributes, 4: Version number. */
504
+                __( '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 plugin.</em>' ),
505
+                $plugin_name,
506
+                esc_url( $details_url ),
507
+                sprintf(
508
+                    'class="thickbox open-plugin-details-modal" aria-label="%s"',
509
+                    /* translators: 1: Plugin name, 2: Version number. */
510
+                    esc_attr( sprintf( __( 'View %1$s version %2$s details' ), $plugin_name, $response->new_version ) )
511
+                ),
512
+                esc_attr( $response->new_version )
513
+            );
514
+        } else {
515
+            if ( $compatible_php ) {
516
+                printf(
517
+                    /* translators: 1: Plugin name, 2: Details URL, 3: Additional link attributes, 4: Version number, 5: Update URL, 6: Additional link attributes. */
518
+                    __( '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>.' ),
519
+                    $plugin_name,
520
+                    esc_url( $details_url ),
521
+                    sprintf(
522
+                        'class="thickbox open-plugin-details-modal" aria-label="%s"',
523
+                        /* translators: 1: Plugin name, 2: Version number. */
524
+                        esc_attr( sprintf( __( 'View %1$s version %2$s details' ), $plugin_name, $response->new_version ) )
525
+                    ),
526
+                    esc_attr( $response->new_version ),
527
+                    wp_nonce_url( self_admin_url( 'update.php?action=upgrade-plugin&plugin=' ) . $file, 'upgrade-plugin_' . $file ),
528
+                    sprintf(
529
+                        'class="update-link" aria-label="%s"',
530
+                        /* translators: %s: Plugin name. */
531
+                        esc_attr( sprintf( _x( 'Update %s now', 'plugin' ), $plugin_name ) )
532
+                    )
533
+                );
534
+            } else {
535
+                printf(
536
+                    /* translators: 1: Plugin name, 2: Details URL, 3: Additional link attributes, 4: Version number 5: URL to Update PHP page. */
537
+                    __( 'There is a new version of %1$s available, but it does not work with your version of PHP. <a href="%2$s" %3$s>View version %4$s details</a> or <a href="%5$s">learn more about updating PHP</a>.' ),
538
+                    $plugin_name,
539
+                    esc_url( $details_url ),
540
+                    sprintf(
541
+                        'class="thickbox open-plugin-details-modal" aria-label="%s"',
542
+                        /* translators: 1: Plugin name, 2: Version number. */
543
+                        esc_attr( sprintf( __( 'View %1$s version %2$s details' ), $plugin_name, $response->new_version ) )
544
+                    ),
545
+                    esc_attr( $response->new_version ),
546
+                    esc_url( wp_get_update_php_url() )
547
+                );
548
+                wp_update_php_annotation( '<br><em>', '</em>' );
549
+            }
550
+        }
551
+
552
+        /**
553
+         * Fires at the end of the update message container in each
554
+         * row of the plugins list table.
555
+         *
556
+         * The dynamic portion of the hook name, `$file`, refers to the path
557
+         * of the plugin's primary file relative to the plugins directory.
558
+         *
559
+         * @since 2.8.0
560
+         *
561
+         * @param array  $plugin_data An array of plugin metadata. See get_plugin_data()
562
+         *                            and the {@see 'plugin_row_meta'} filter for the list
563
+         *                            of possible values.
564
+         * @param object $response {
565
+         *     An object of metadata about the available plugin update.
566
+         *
567
+         *     @type string   $id           Plugin ID, e.g. `w.org/plugins/[plugin-name]`.
568
+         *     @type string   $slug         Plugin slug.
569
+         *     @type string   $plugin       Plugin basename.
570
+         *     @type string   $new_version  New plugin version.
571
+         *     @type string   $url          Plugin URL.
572
+         *     @type string   $package      Plugin update package URL.
573
+         *     @type string[] $icons        An array of plugin icon URLs.
574
+         *     @type string[] $banners      An array of plugin banner URLs.
575
+         *     @type string[] $banners_rtl  An array of plugin RTL banner URLs.
576
+         *     @type string   $requires     The version of WordPress which the plugin requires.
577
+         *     @type string   $tested       The version of WordPress the plugin is tested against.
578
+         *     @type string   $requires_php The version of PHP which the plugin requires.
579
+         * }
580
+         */
581
+        do_action( "in_plugin_update_message-{$file}", $plugin_data, $response ); // phpcs:ignore WordPress.NamingConventions.ValidHookName.UseUnderscores
582
+
583
+        echo '</p></div></td></tr>';
584
+    }
585 585
 }
586 586
 
587 587
 /**
@@ -590,37 +590,37 @@  discard block
 block discarded – undo
590 590
  * @return array
591 591
  */
592 592
 function get_theme_updates() {
593
-	$current = get_site_transient( 'update_themes' );
593
+    $current = get_site_transient( 'update_themes' );
594 594
 
595
-	if ( ! isset( $current->response ) ) {
596
-		return array();
597
-	}
595
+    if ( ! isset( $current->response ) ) {
596
+        return array();
597
+    }
598 598
 
599
-	$update_themes = array();
600
-	foreach ( $current->response as $stylesheet => $data ) {
601
-		$update_themes[ $stylesheet ]         = wp_get_theme( $stylesheet );
602
-		$update_themes[ $stylesheet ]->update = $data;
603
-	}
599
+    $update_themes = array();
600
+    foreach ( $current->response as $stylesheet => $data ) {
601
+        $update_themes[ $stylesheet ]         = wp_get_theme( $stylesheet );
602
+        $update_themes[ $stylesheet ]->update = $data;
603
+    }
604 604
 
605
-	return $update_themes;
605
+    return $update_themes;
606 606
 }
607 607
 
608 608
 /**
609 609
  * @since 3.1.0
610 610
  */
611 611
 function wp_theme_update_rows() {
612
-	if ( ! current_user_can( 'update_themes' ) ) {
613
-		return;
614
-	}
615
-
616
-	$themes = get_site_transient( 'update_themes' );
617
-	if ( isset( $themes->response ) && is_array( $themes->response ) ) {
618
-		$themes = array_keys( $themes->response );
619
-
620
-		foreach ( $themes as $theme ) {
621
-			add_action( "after_theme_row_{$theme}", 'wp_theme_update_row', 10, 2 );
622
-		}
623
-	}
612
+    if ( ! current_user_can( 'update_themes' ) ) {
613
+        return;
614
+    }
615
+
616
+    $themes = get_site_transient( 'update_themes' );
617
+    if ( isset( $themes->response ) && is_array( $themes->response ) ) {
618
+        $themes = array_keys( $themes->response );
619
+
620
+        foreach ( $themes as $theme ) {
621
+            add_action( "after_theme_row_{$theme}", 'wp_theme_update_row', 10, 2 );
622
+        }
623
+    }
624 624
 }
625 625
 
626 626
 /**
@@ -633,171 +633,171 @@  discard block
 block discarded – undo
633 633
  * @return void|false
634 634
  */
635 635
 function wp_theme_update_row( $theme_key, $theme ) {
636
-	$current = get_site_transient( 'update_themes' );
637
-
638
-	if ( ! isset( $current->response[ $theme_key ] ) ) {
639
-		return false;
640
-	}
641
-
642
-	$response = $current->response[ $theme_key ];
643
-
644
-	$details_url = add_query_arg(
645
-		array(
646
-			'TB_iframe' => 'true',
647
-			'width'     => 1024,
648
-			'height'    => 800,
649
-		),
650
-		$current->response[ $theme_key ]['url']
651
-	);
652
-
653
-	/** @var WP_MS_Themes_List_Table $wp_list_table */
654
-	$wp_list_table = _get_list_table( 'WP_MS_Themes_List_Table' );
655
-
656
-	$active = $theme->is_allowed( 'network' ) ? ' active' : '';
657
-
658
-	$requires_wp  = isset( $response['requires'] ) ? $response['requires'] : null;
659
-	$requires_php = isset( $response['requires_php'] ) ? $response['requires_php'] : null;
660
-
661
-	$compatible_wp  = is_wp_version_compatible( $requires_wp );
662
-	$compatible_php = is_php_version_compatible( $requires_php );
663
-
664
-	printf(
665
-		'<tr class="plugin-update-tr%s" id="%s" data-slug="%s">' .
666
-		'<td colspan="%s" class="plugin-update colspanchange">' .
667
-		'<div class="update-message notice inline notice-warning notice-alt"><p>',
668
-		$active,
669
-		esc_attr( $theme->get_stylesheet() . '-update' ),
670
-		esc_attr( $theme->get_stylesheet() ),
671
-		$wp_list_table->get_column_count()
672
-	);
673
-
674
-	if ( $compatible_wp && $compatible_php ) {
675
-		if ( ! current_user_can( 'update_themes' ) ) {
676
-			printf(
677
-				/* translators: 1: Theme name, 2: Details URL, 3: Additional link attributes, 4: Version number. */
678
-				__( 'There is a new version of %1$s available. <a href="%2$s" %3$s>View version %4$s details</a>.' ),
679
-				$theme['Name'],
680
-				esc_url( $details_url ),
681
-				sprintf(
682
-					'class="thickbox open-plugin-details-modal" aria-label="%s"',
683
-					/* translators: 1: Theme name, 2: Version number. */
684
-					esc_attr( sprintf( __( 'View %1$s version %2$s details' ), $theme['Name'], $response['new_version'] ) )
685
-				),
686
-				$response['new_version']
687
-			);
688
-		} elseif ( empty( $response['package'] ) ) {
689
-			printf(
690
-				/* translators: 1: Theme name, 2: Details URL, 3: Additional link attributes, 4: Version number. */
691
-				__( '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>' ),
692
-				$theme['Name'],
693
-				esc_url( $details_url ),
694
-				sprintf(
695
-					'class="thickbox open-plugin-details-modal" aria-label="%s"',
696
-					/* translators: 1: Theme name, 2: Version number. */
697
-					esc_attr( sprintf( __( 'View %1$s version %2$s details' ), $theme['Name'], $response['new_version'] ) )
698
-				),
699
-				$response['new_version']
700
-			);
701
-		} else {
702
-			printf(
703
-				/* translators: 1: Theme name, 2: Details URL, 3: Additional link attributes, 4: Version number, 5: Update URL, 6: Additional link attributes. */
704
-				__( '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>.' ),
705
-				$theme['Name'],
706
-				esc_url( $details_url ),
707
-				sprintf(
708
-					'class="thickbox open-plugin-details-modal" aria-label="%s"',
709
-					/* translators: 1: Theme name, 2: Version number. */
710
-					esc_attr( sprintf( __( 'View %1$s version %2$s details' ), $theme['Name'], $response['new_version'] ) )
711
-				),
712
-				$response['new_version'],
713
-				wp_nonce_url( self_admin_url( 'update.php?action=upgrade-theme&theme=' ) . $theme_key, 'upgrade-theme_' . $theme_key ),
714
-				sprintf(
715
-					'class="update-link" aria-label="%s"',
716
-					/* translators: %s: Theme name. */
717
-					esc_attr( sprintf( _x( 'Update %s now', 'theme' ), $theme['Name'] ) )
718
-				)
719
-			);
720
-		}
721
-	} else {
722
-		if ( ! $compatible_wp && ! $compatible_php ) {
723
-			printf(
724
-				/* translators: %s: Theme name. */
725
-				__( 'There is a new version of %s available, but it does not work with your versions of WordPress and PHP.' ),
726
-				$theme['Name']
727
-			);
728
-			if ( current_user_can( 'update_core' ) && current_user_can( 'update_php' ) ) {
729
-				printf(
730
-					/* translators: 1: URL to WordPress Updates screen, 2: URL to Update PHP page. */
731
-					' ' . __( '<a href="%1$s">Please update WordPress</a>, and then <a href="%2$s">learn more about updating PHP</a>.' ),
732
-					self_admin_url( 'update-core.php' ),
733
-					esc_url( wp_get_update_php_url() )
734
-				);
735
-				wp_update_php_annotation( '</p><p><em>', '</em>' );
736
-			} elseif ( current_user_can( 'update_core' ) ) {
737
-				printf(
738
-					/* translators: %s: URL to WordPress Updates screen. */
739
-					' ' . __( '<a href="%s">Please update WordPress</a>.' ),
740
-					self_admin_url( 'update-core.php' )
741
-				);
742
-			} elseif ( current_user_can( 'update_php' ) ) {
743
-				printf(
744
-					/* translators: %s: URL to Update PHP page. */
745
-					' ' . __( '<a href="%s">Learn more about updating PHP</a>.' ),
746
-					esc_url( wp_get_update_php_url() )
747
-				);
748
-				wp_update_php_annotation( '</p><p><em>', '</em>' );
749
-			}
750
-		} elseif ( ! $compatible_wp ) {
751
-			printf(
752
-				/* translators: %s: Theme name. */
753
-				__( 'There is a new version of %s available, but it does not work with your version of WordPress.' ),
754
-				$theme['Name']
755
-			);
756
-			if ( current_user_can( 'update_core' ) ) {
757
-				printf(
758
-					/* translators: %s: URL to WordPress Updates screen. */
759
-					' ' . __( '<a href="%s">Please update WordPress</a>.' ),
760
-					self_admin_url( 'update-core.php' )
761
-				);
762
-			}
763
-		} elseif ( ! $compatible_php ) {
764
-			printf(
765
-				/* translators: %s: Theme name. */
766
-				__( 'There is a new version of %s available, but it does not work with your version of PHP.' ),
767
-				$theme['Name']
768
-			);
769
-			if ( current_user_can( 'update_php' ) ) {
770
-				printf(
771
-					/* translators: %s: URL to Update PHP page. */
772
-					' ' . __( '<a href="%s">Learn more about updating PHP</a>.' ),
773
-					esc_url( wp_get_update_php_url() )
774
-				);
775
-				wp_update_php_annotation( '</p><p><em>', '</em>' );
776
-			}
777
-		}
778
-	}
779
-
780
-	/**
781
-	 * Fires at the end of the update message container in each
782
-	 * row of the themes list table.
783
-	 *
784
-	 * The dynamic portion of the hook name, `$theme_key`, refers to
785
-	 * the theme slug as found in the WordPress.org themes repository.
786
-	 *
787
-	 * @since 3.1.0
788
-	 *
789
-	 * @param WP_Theme $theme    The WP_Theme object.
790
-	 * @param array    $response {
791
-	 *     An array of metadata about the available theme update.
792
-	 *
793
-	 *     @type string $new_version New theme version.
794
-	 *     @type string $url         Theme URL.
795
-	 *     @type string $package     Theme update package URL.
796
-	 * }
797
-	 */
798
-	do_action( "in_theme_update_message-{$theme_key}", $theme, $response ); // phpcs:ignore WordPress.NamingConventions.ValidHookName.UseUnderscores
799
-
800
-	echo '</p></div></td></tr>';
636
+    $current = get_site_transient( 'update_themes' );
637
+
638
+    if ( ! isset( $current->response[ $theme_key ] ) ) {
639
+        return false;
640
+    }
641
+
642
+    $response = $current->response[ $theme_key ];
643
+
644
+    $details_url = add_query_arg(
645
+        array(
646
+            'TB_iframe' => 'true',
647
+            'width'     => 1024,
648
+            'height'    => 800,
649
+        ),
650
+        $current->response[ $theme_key ]['url']
651
+    );
652
+
653
+    /** @var WP_MS_Themes_List_Table $wp_list_table */
654
+    $wp_list_table = _get_list_table( 'WP_MS_Themes_List_Table' );
655
+
656
+    $active = $theme->is_allowed( 'network' ) ? ' active' : '';
657
+
658
+    $requires_wp  = isset( $response['requires'] ) ? $response['requires'] : null;
659
+    $requires_php = isset( $response['requires_php'] ) ? $response['requires_php'] : null;
660
+
661
+    $compatible_wp  = is_wp_version_compatible( $requires_wp );
662
+    $compatible_php = is_php_version_compatible( $requires_php );
663
+
664
+    printf(
665
+        '<tr class="plugin-update-tr%s" id="%s" data-slug="%s">' .
666
+        '<td colspan="%s" class="plugin-update colspanchange">' .
667
+        '<div class="update-message notice inline notice-warning notice-alt"><p>',
668
+        $active,
669
+        esc_attr( $theme->get_stylesheet() . '-update' ),
670
+        esc_attr( $theme->get_stylesheet() ),
671
+        $wp_list_table->get_column_count()
672
+    );
673
+
674
+    if ( $compatible_wp && $compatible_php ) {
675
+        if ( ! current_user_can( 'update_themes' ) ) {
676
+            printf(
677
+                /* translators: 1: Theme name, 2: Details URL, 3: Additional link attributes, 4: Version number. */
678
+                __( 'There is a new version of %1$s available. <a href="%2$s" %3$s>View version %4$s details</a>.' ),
679
+                $theme['Name'],
680
+                esc_url( $details_url ),
681
+                sprintf(
682
+                    'class="thickbox open-plugin-details-modal" aria-label="%s"',
683
+                    /* translators: 1: Theme name, 2: Version number. */
684
+                    esc_attr( sprintf( __( 'View %1$s version %2$s details' ), $theme['Name'], $response['new_version'] ) )
685
+                ),
686
+                $response['new_version']
687
+            );
688
+        } elseif ( empty( $response['package'] ) ) {
689
+            printf(
690
+                /* translators: 1: Theme name, 2: Details URL, 3: Additional link attributes, 4: Version number. */
691
+                __( '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>' ),
692
+                $theme['Name'],
693
+                esc_url( $details_url ),
694
+                sprintf(
695
+                    'class="thickbox open-plugin-details-modal" aria-label="%s"',
696
+                    /* translators: 1: Theme name, 2: Version number. */
697
+                    esc_attr( sprintf( __( 'View %1$s version %2$s details' ), $theme['Name'], $response['new_version'] ) )
698
+                ),
699
+                $response['new_version']
700
+            );
701
+        } else {
702
+            printf(
703
+                /* translators: 1: Theme name, 2: Details URL, 3: Additional link attributes, 4: Version number, 5: Update URL, 6: Additional link attributes. */
704
+                __( '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>.' ),
705
+                $theme['Name'],
706
+                esc_url( $details_url ),
707
+                sprintf(
708
+                    'class="thickbox open-plugin-details-modal" aria-label="%s"',
709
+                    /* translators: 1: Theme name, 2: Version number. */
710
+                    esc_attr( sprintf( __( 'View %1$s version %2$s details' ), $theme['Name'], $response['new_version'] ) )
711
+                ),
712
+                $response['new_version'],
713
+                wp_nonce_url( self_admin_url( 'update.php?action=upgrade-theme&theme=' ) . $theme_key, 'upgrade-theme_' . $theme_key ),
714
+                sprintf(
715
+                    'class="update-link" aria-label="%s"',
716
+                    /* translators: %s: Theme name. */
717
+                    esc_attr( sprintf( _x( 'Update %s now', 'theme' ), $theme['Name'] ) )
718
+                )
719
+            );
720
+        }
721
+    } else {
722
+        if ( ! $compatible_wp && ! $compatible_php ) {
723
+            printf(
724
+                /* translators: %s: Theme name. */
725
+                __( 'There is a new version of %s available, but it does not work with your versions of WordPress and PHP.' ),
726
+                $theme['Name']
727
+            );
728
+            if ( current_user_can( 'update_core' ) && current_user_can( 'update_php' ) ) {
729
+                printf(
730
+                    /* translators: 1: URL to WordPress Updates screen, 2: URL to Update PHP page. */
731
+                    ' ' . __( '<a href="%1$s">Please update WordPress</a>, and then <a href="%2$s">learn more about updating PHP</a>.' ),
732
+                    self_admin_url( 'update-core.php' ),
733
+                    esc_url( wp_get_update_php_url() )
734
+                );
735
+                wp_update_php_annotation( '</p><p><em>', '</em>' );
736
+            } elseif ( current_user_can( 'update_core' ) ) {
737
+                printf(
738
+                    /* translators: %s: URL to WordPress Updates screen. */
739
+                    ' ' . __( '<a href="%s">Please update WordPress</a>.' ),
740
+                    self_admin_url( 'update-core.php' )
741
+                );
742
+            } elseif ( current_user_can( 'update_php' ) ) {
743
+                printf(
744
+                    /* translators: %s: URL to Update PHP page. */
745
+                    ' ' . __( '<a href="%s">Learn more about updating PHP</a>.' ),
746
+                    esc_url( wp_get_update_php_url() )
747
+                );
748
+                wp_update_php_annotation( '</p><p><em>', '</em>' );
749
+            }
750
+        } elseif ( ! $compatible_wp ) {
751
+            printf(
752
+                /* translators: %s: Theme name. */
753
+                __( 'There is a new version of %s available, but it does not work with your version of WordPress.' ),
754
+                $theme['Name']
755
+            );
756
+            if ( current_user_can( 'update_core' ) ) {
757
+                printf(
758
+                    /* translators: %s: URL to WordPress Updates screen. */
759
+                    ' ' . __( '<a href="%s">Please update WordPress</a>.' ),
760
+                    self_admin_url( 'update-core.php' )
761
+                );
762
+            }
763
+        } elseif ( ! $compatible_php ) {
764
+            printf(
765
+                /* translators: %s: Theme name. */
766
+                __( 'There is a new version of %s available, but it does not work with your version of PHP.' ),
767
+                $theme['Name']
768
+            );
769
+            if ( current_user_can( 'update_php' ) ) {
770
+                printf(
771
+                    /* translators: %s: URL to Update PHP page. */
772
+                    ' ' . __( '<a href="%s">Learn more about updating PHP</a>.' ),
773
+                    esc_url( wp_get_update_php_url() )
774
+                );
775
+                wp_update_php_annotation( '</p><p><em>', '</em>' );
776
+            }
777
+        }
778
+    }
779
+
780
+    /**
781
+     * Fires at the end of the update message container in each
782
+     * row of the themes list table.
783
+     *
784
+     * The dynamic portion of the hook name, `$theme_key`, refers to
785
+     * the theme slug as found in the WordPress.org themes repository.
786
+     *
787
+     * @since 3.1.0
788
+     *
789
+     * @param WP_Theme $theme    The WP_Theme object.
790
+     * @param array    $response {
791
+     *     An array of metadata about the available theme update.
792
+     *
793
+     *     @type string $new_version New theme version.
794
+     *     @type string $url         Theme URL.
795
+     *     @type string $package     Theme update package URL.
796
+     * }
797
+     */
798
+    do_action( "in_theme_update_message-{$theme_key}", $theme, $response ); // phpcs:ignore WordPress.NamingConventions.ValidHookName.UseUnderscores
799
+
800
+    echo '</p></div></td></tr>';
801 801
 }
802 802
 
803 803
 /**
@@ -807,13 +807,13 @@  discard block
 block discarded – undo
807 807
  * @return void|false
808 808
  */
809 809
 function maintenance_nag() {
810
-	// Include an unmodified $wp_version.
811
-	require ABSPATH . WPINC . '/version.php';
812
-	global $upgrading;
813
-	$nag = isset( $upgrading );
814
-	if ( ! $nag ) {
815
-		$failed = get_site_option( 'auto_core_update_failed' );
816
-		/*
810
+    // Include an unmodified $wp_version.
811
+    require ABSPATH . WPINC . '/version.php';
812
+    global $upgrading;
813
+    $nag = isset( $upgrading );
814
+    if ( ! $nag ) {
815
+        $failed = get_site_option( 'auto_core_update_failed' );
816
+        /*
817 817
 		 * If an update failed critically, we may have copied over version.php but not other files.
818 818
 		 * In that case, if the installation claims we're running the version we attempted, nag.
819 819
 		 * This is serious enough to err on the side of nagging.
@@ -823,27 +823,27 @@  discard block
 block discarded – undo
823 823
 		 *
824 824
 		 * This flag is cleared whenever a successful update occurs using Core_Upgrader.
825 825
 		 */
826
-		$comparison = ! empty( $failed['critical'] ) ? '>=' : '>';
827
-		if ( isset( $failed['attempted'] ) && version_compare( $failed['attempted'], $wp_version, $comparison ) ) {
828
-			$nag = true;
829
-		}
830
-	}
831
-
832
-	if ( ! $nag ) {
833
-		return false;
834
-	}
835
-
836
-	if ( current_user_can( 'update_core' ) ) {
837
-		$msg = sprintf(
838
-			/* translators: %s: URL to WordPress Updates screen. */
839
-			__( 'An automated WordPress update has failed to complete - <a href="%s">please attempt the update again now</a>.' ),
840
-			'update-core.php'
841
-		);
842
-	} else {
843
-		$msg = __( 'An automated WordPress update has failed to complete! Please notify the site administrator.' );
844
-	}
845
-
846
-	echo "<div class='update-nag notice notice-warning inline'>$msg</div>";
826
+        $comparison = ! empty( $failed['critical'] ) ? '>=' : '>';
827
+        if ( isset( $failed['attempted'] ) && version_compare( $failed['attempted'], $wp_version, $comparison ) ) {
828
+            $nag = true;
829
+        }
830
+    }
831
+
832
+    if ( ! $nag ) {
833
+        return false;
834
+    }
835
+
836
+    if ( current_user_can( 'update_core' ) ) {
837
+        $msg = sprintf(
838
+            /* translators: %s: URL to WordPress Updates screen. */
839
+            __( 'An automated WordPress update has failed to complete - <a href="%s">please attempt the update again now</a>.' ),
840
+            'update-core.php'
841
+        );
842
+    } else {
843
+        $msg = __( 'An automated WordPress update has failed to complete! Please notify the site administrator.' );
844
+    }
845
+
846
+    echo "<div class='update-nag notice notice-warning inline'>$msg</div>";
847 847
 }
848 848
 
849 849
 /**
@@ -863,7 +863,7 @@  discard block
 block discarded – undo
863 863
  * @since 4.6.0
864 864
  */
865 865
 function wp_print_admin_notice_templates() {
866
-	?>
866
+    ?>
867 867
 	<script id="tmpl-wp-updates-admin-notice" type="text/html">
868 868
 		<div <# if ( data.id ) { #>id="{{ data.id }}"<# } #> class="notice {{ data.className }}"><p>{{{ data.message }}}</p></div>
869 869
 	</script>
@@ -874,26 +874,26 @@  discard block
 block discarded – undo
874 874
 					<# if ( 1 === data.successes ) { #>
875 875
 						<# if ( 'plugin' === data.type ) { #>
876 876
 							<?php
877
-							/* translators: %s: Number of plugins. */
878
-							printf( __( '%s plugin successfully updated.' ), '{{ data.successes }}' );
879
-							?>
877
+                            /* translators: %s: Number of plugins. */
878
+                            printf( __( '%s plugin successfully updated.' ), '{{ data.successes }}' );
879
+                            ?>
880 880
 						<# } else { #>
881 881
 							<?php
882
-							/* translators: %s: Number of themes. */
883
-							printf( __( '%s theme successfully updated.' ), '{{ data.successes }}' );
884
-							?>
882
+                            /* translators: %s: Number of themes. */
883
+                            printf( __( '%s theme successfully updated.' ), '{{ data.successes }}' );
884
+                            ?>
885 885
 						<# } #>
886 886
 					<# } else { #>
887 887
 						<# if ( 'plugin' === data.type ) { #>
888 888
 							<?php
889
-							/* translators: %s: Number of plugins. */
890
-							printf( __( '%s plugins successfully updated.' ), '{{ data.successes }}' );
891
-							?>
889
+                            /* translators: %s: Number of plugins. */
890
+                            printf( __( '%s plugins successfully updated.' ), '{{ data.successes }}' );
891
+                            ?>
892 892
 						<# } else { #>
893 893
 							<?php
894
-							/* translators: %s: Number of themes. */
895
-							printf( __( '%s themes successfully updated.' ), '{{ data.successes }}' );
896
-							?>
894
+                            /* translators: %s: Number of themes. */
895
+                            printf( __( '%s themes successfully updated.' ), '{{ data.successes }}' );
896
+                            ?>
897 897
 						<# } #>
898 898
 					<# } #>
899 899
 				<# } #>
@@ -901,14 +901,14 @@  discard block
 block discarded – undo
901 901
 					<button class="button-link bulk-action-errors-collapsed" aria-expanded="false">
902 902
 						<# if ( 1 === data.errors ) { #>
903 903
 							<?php
904
-							/* translators: %s: Number of failed updates. */
905
-							printf( __( '%s update failed.' ), '{{ data.errors }}' );
906
-							?>
904
+                            /* translators: %s: Number of failed updates. */
905
+                            printf( __( '%s update failed.' ), '{{ data.errors }}' );
906
+                            ?>
907 907
 						<# } else { #>
908 908
 							<?php
909
-							/* translators: %s: Number of failed updates. */
910
-							printf( __( '%s updates failed.' ), '{{ data.errors }}' );
911
-							?>
909
+                            /* translators: %s: Number of failed updates. */
910
+                            printf( __( '%s updates failed.' ), '{{ data.errors }}' );
911
+                            ?>
912 912
 						<# } #>
913 913
 						<span class="screen-reader-text"><?php _e( 'Show more details' ); ?></span>
914 914
 						<span class="toggle-indicator" aria-hidden="true"></span>
@@ -955,7 +955,7 @@  discard block
 block discarded – undo
955 955
  * @since 4.6.0
956 956
  */
957 957
 function wp_print_update_row_templates() {
958
-	?>
958
+    ?>
959 959
 	<script id="tmpl-item-update-row" type="text/template">
960 960
 		<tr class="plugin-update-tr update" id="{{ data.slug }}-update" data-slug="{{ data.slug }}" <# if ( data.plugin ) { #>data-plugin="{{ data.plugin }}"<# } #>>
961 961
 			<td colspan="{{ data.colspan }}" class="plugin-update colspanchange">
@@ -968,20 +968,20 @@  discard block
 block discarded – undo
968 968
 			<td colspan="{{ data.colspan }}" class="plugin-update colspanchange">
969 969
 				<# if ( data.plugin ) { #>
970 970
 					<?php
971
-					printf(
972
-						/* translators: %s: Plugin name. */
973
-						_x( '%s was successfully deleted.', 'plugin' ),
974
-						'<strong>{{{ data.name }}}</strong>'
975
-					);
976
-					?>
971
+                    printf(
972
+                        /* translators: %s: Plugin name. */
973
+                        _x( '%s was successfully deleted.', 'plugin' ),
974
+                        '<strong>{{{ data.name }}}</strong>'
975
+                    );
976
+                    ?>
977 977
 				<# } else { #>
978 978
 					<?php
979
-					printf(
980
-						/* translators: %s: Theme name. */
981
-						_x( '%s was successfully deleted.', 'theme' ),
982
-						'<strong>{{{ data.name }}}</strong>'
983
-					);
984
-					?>
979
+                    printf(
980
+                        /* translators: %s: Theme name. */
981
+                        _x( '%s was successfully deleted.', 'theme' ),
982
+                        '<strong>{{{ data.name }}}</strong>'
983
+                    );
984
+                    ?>
985 985
 				<# } #>
986 986
 			</td>
987 987
 		</tr>
@@ -995,24 +995,24 @@  discard block
 block discarded – undo
995 995
  * @since 5.2.0
996 996
  */
997 997
 function wp_recovery_mode_nag() {
998
-	if ( ! wp_is_recovery_mode() ) {
999
-		return;
1000
-	}
998
+    if ( ! wp_is_recovery_mode() ) {
999
+        return;
1000
+    }
1001 1001
 
1002
-	$url = wp_login_url();
1003
-	$url = add_query_arg( 'action', WP_Recovery_Mode::EXIT_ACTION, $url );
1004
-	$url = wp_nonce_url( $url, WP_Recovery_Mode::EXIT_ACTION );
1002
+    $url = wp_login_url();
1003
+    $url = add_query_arg( 'action', WP_Recovery_Mode::EXIT_ACTION, $url );
1004
+    $url = wp_nonce_url( $url, WP_Recovery_Mode::EXIT_ACTION );
1005 1005
 
1006
-	?>
1006
+    ?>
1007 1007
 	<div class="notice notice-info">
1008 1008
 		<p>
1009 1009
 			<?php
1010
-			printf(
1011
-				/* translators: %s: Recovery Mode exit link. */
1012
-				__( 'You are in recovery mode. This means there may be an error with a theme or plugin. To exit recovery mode, log out or use the Exit button. <a href="%s">Exit Recovery Mode</a>' ),
1013
-				esc_url( $url )
1014
-			);
1015
-			?>
1010
+            printf(
1011
+                /* translators: %s: Recovery Mode exit link. */
1012
+                __( 'You are in recovery mode. This means there may be an error with a theme or plugin. To exit recovery mode, log out or use the Exit button. <a href="%s">Exit Recovery Mode</a>' ),
1013
+                esc_url( $url )
1014
+            );
1015
+            ?>
1016 1016
 		</p>
1017 1017
 	</div>
1018 1018
 	<?php
@@ -1027,35 +1027,35 @@  discard block
 block discarded – undo
1027 1027
  * @return bool True if auto-updates are enabled for `$type`, false otherwise.
1028 1028
  */
1029 1029
 function wp_is_auto_update_enabled_for_type( $type ) {
1030
-	if ( ! class_exists( 'WP_Automatic_Updater' ) ) {
1031
-		require_once ABSPATH . 'wp-admin/includes/class-wp-automatic-updater.php';
1032
-	}
1033
-
1034
-	$updater = new WP_Automatic_Updater();
1035
-	$enabled = ! $updater->is_disabled();
1036
-
1037
-	switch ( $type ) {
1038
-		case 'plugin':
1039
-			/**
1040
-			 * Filters whether plugins auto-update is enabled.
1041
-			 *
1042
-			 * @since 5.5.0
1043
-			 *
1044
-			 * @param bool $enabled True if plugins auto-update is enabled, false otherwise.
1045
-			 */
1046
-			return apply_filters( 'plugins_auto_update_enabled', $enabled );
1047
-		case 'theme':
1048
-			/**
1049
-			 * Filters whether themes auto-update is enabled.
1050
-			 *
1051
-			 * @since 5.5.0
1052
-			 *
1053
-			 * @param bool $enabled True if themes auto-update is enabled, false otherwise.
1054
-			 */
1055
-			return apply_filters( 'themes_auto_update_enabled', $enabled );
1056
-	}
1057
-
1058
-	return false;
1030
+    if ( ! class_exists( 'WP_Automatic_Updater' ) ) {
1031
+        require_once ABSPATH . 'wp-admin/includes/class-wp-automatic-updater.php';
1032
+    }
1033
+
1034
+    $updater = new WP_Automatic_Updater();
1035
+    $enabled = ! $updater->is_disabled();
1036
+
1037
+    switch ( $type ) {
1038
+        case 'plugin':
1039
+            /**
1040
+             * Filters whether plugins auto-update is enabled.
1041
+             *
1042
+             * @since 5.5.0
1043
+             *
1044
+             * @param bool $enabled True if plugins auto-update is enabled, false otherwise.
1045
+             */
1046
+            return apply_filters( 'plugins_auto_update_enabled', $enabled );
1047
+        case 'theme':
1048
+            /**
1049
+             * Filters whether themes auto-update is enabled.
1050
+             *
1051
+             * @since 5.5.0
1052
+             *
1053
+             * @param bool $enabled True if themes auto-update is enabled, false otherwise.
1054
+             */
1055
+            return apply_filters( 'themes_auto_update_enabled', $enabled );
1056
+    }
1057
+
1058
+    return false;
1059 1059
 }
1060 1060
 
1061 1061
 /**
@@ -1070,8 +1070,8 @@  discard block
 block discarded – undo
1070 1070
  * @return bool True if auto-updates are forced for `$item`, false otherwise.
1071 1071
  */
1072 1072
 function wp_is_auto_update_forced_for_item( $type, $update, $item ) {
1073
-	/** This filter is documented in wp-admin/includes/class-wp-automatic-updater.php */
1074
-	return apply_filters( "auto_update_{$type}", $update, $item );
1073
+    /** This filter is documented in wp-admin/includes/class-wp-automatic-updater.php */
1074
+    return apply_filters( "auto_update_{$type}", $update, $item );
1075 1075
 }
1076 1076
 
1077 1077
 /**
@@ -1082,31 +1082,31 @@  discard block
 block discarded – undo
1082 1082
  * @return string The update message to be shown.
1083 1083
  */
1084 1084
 function wp_get_auto_update_message() {
1085
-	$next_update_time = wp_next_scheduled( 'wp_version_check' );
1086
-
1087
-	// Check if the event exists.
1088
-	if ( false === $next_update_time ) {
1089
-		$message = __( 'Automatic update not scheduled. There may be a problem with WP-Cron.' );
1090
-	} else {
1091
-		$time_to_next_update = human_time_diff( (int) $next_update_time );
1092
-
1093
-		// See if cron is overdue.
1094
-		$overdue = ( time() - $next_update_time ) > 0;
1095
-
1096
-		if ( $overdue ) {
1097
-			$message = sprintf(
1098
-				/* translators: %s: Duration that WP-Cron has been overdue. */
1099
-				__( 'Automatic update overdue by %s. There may be a problem with WP-Cron.' ),
1100
-				$time_to_next_update
1101
-			);
1102
-		} else {
1103
-			$message = sprintf(
1104
-				/* translators: %s: Time until the next update. */
1105
-				__( 'Automatic update scheduled in %s.' ),
1106
-				$time_to_next_update
1107
-			);
1108
-		}
1109
-	}
1110
-
1111
-	return $message;
1085
+    $next_update_time = wp_next_scheduled( 'wp_version_check' );
1086
+
1087
+    // Check if the event exists.
1088
+    if ( false === $next_update_time ) {
1089
+        $message = __( 'Automatic update not scheduled. There may be a problem with WP-Cron.' );
1090
+    } else {
1091
+        $time_to_next_update = human_time_diff( (int) $next_update_time );
1092
+
1093
+        // See if cron is overdue.
1094
+        $overdue = ( time() - $next_update_time ) > 0;
1095
+
1096
+        if ( $overdue ) {
1097
+            $message = sprintf(
1098
+                /* translators: %s: Duration that WP-Cron has been overdue. */
1099
+                __( 'Automatic update overdue by %s. There may be a problem with WP-Cron.' ),
1100
+                $time_to_next_update
1101
+            );
1102
+        } else {
1103
+            $message = sprintf(
1104
+                /* translators: %s: Time until the next update. */
1105
+                __( 'Automatic update scheduled in %s.' ),
1106
+                $time_to_next_update
1107
+            );
1108
+        }
1109
+    }
1110
+
1111
+    return $message;
1112 1112
 }
Please login to merge, or discard this patch.
brighty/wp-admin/includes/network.php 1 patch
Indentation   +392 added lines, -392 removed lines patch added patch discarded remove patch
@@ -17,13 +17,13 @@  discard block
 block discarded – undo
17 17
  * @return string|false Base domain if network exists, otherwise false.
18 18
  */
19 19
 function network_domain_check() {
20
-	global $wpdb;
20
+    global $wpdb;
21 21
 
22
-	$sql = $wpdb->prepare( 'SHOW TABLES LIKE %s', $wpdb->esc_like( $wpdb->site ) );
23
-	if ( $wpdb->get_var( $sql ) ) {
24
-		return $wpdb->get_var( "SELECT domain FROM $wpdb->site ORDER BY id ASC LIMIT 1" );
25
-	}
26
-	return false;
22
+    $sql = $wpdb->prepare( 'SHOW TABLES LIKE %s', $wpdb->esc_like( $wpdb->site ) );
23
+    if ( $wpdb->get_var( $sql ) ) {
24
+        return $wpdb->get_var( "SELECT domain FROM $wpdb->site ORDER BY id ASC LIMIT 1" );
25
+    }
26
+    return false;
27 27
 }
28 28
 
29 29
 /**
@@ -33,12 +33,12 @@  discard block
 block discarded – undo
33 33
  * @return bool Whether subdomain installation is allowed
34 34
  */
35 35
 function allow_subdomain_install() {
36
-	$domain = preg_replace( '|https?://([^/]+)|', '$1', get_option( 'home' ) );
37
-	if ( parse_url( get_option( 'home' ), PHP_URL_PATH ) || 'localhost' === $domain || preg_match( '|^[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+$|', $domain ) ) {
38
-		return false;
39
-	}
36
+    $domain = preg_replace( '|https?://([^/]+)|', '$1', get_option( 'home' ) );
37
+    if ( parse_url( get_option( 'home' ), PHP_URL_PATH ) || 'localhost' === $domain || preg_match( '|^[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+$|', $domain ) ) {
38
+        return false;
39
+    }
40 40
 
41
-	return true;
41
+    return true;
42 42
 }
43 43
 
44 44
 /**
@@ -51,30 +51,30 @@  discard block
 block discarded – undo
51 51
  * @return bool Whether subdirectory installation is allowed
52 52
  */
53 53
 function allow_subdirectory_install() {
54
-	global $wpdb;
55
-
56
-	/**
57
-	 * Filters whether to enable the subdirectory installation feature in Multisite.
58
-	 *
59
-	 * @since 3.0.0
60
-	 *
61
-	 * @param bool $allow Whether to enable the subdirectory installation feature in Multisite.
62
-	 *                    Default false.
63
-	 */
64
-	if ( apply_filters( 'allow_subdirectory_install', false ) ) {
65
-		return true;
66
-	}
67
-
68
-	if ( defined( 'ALLOW_SUBDIRECTORY_INSTALL' ) && ALLOW_SUBDIRECTORY_INSTALL ) {
69
-		return true;
70
-	}
71
-
72
-	$post = $wpdb->get_row( "SELECT ID FROM $wpdb->posts WHERE post_date < DATE_SUB(NOW(), INTERVAL 1 MONTH) AND post_status = 'publish'" );
73
-	if ( empty( $post ) ) {
74
-		return true;
75
-	}
76
-
77
-	return false;
54
+    global $wpdb;
55
+
56
+    /**
57
+     * Filters whether to enable the subdirectory installation feature in Multisite.
58
+     *
59
+     * @since 3.0.0
60
+     *
61
+     * @param bool $allow Whether to enable the subdirectory installation feature in Multisite.
62
+     *                    Default false.
63
+     */
64
+    if ( apply_filters( 'allow_subdirectory_install', false ) ) {
65
+        return true;
66
+    }
67
+
68
+    if ( defined( 'ALLOW_SUBDIRECTORY_INSTALL' ) && ALLOW_SUBDIRECTORY_INSTALL ) {
69
+        return true;
70
+    }
71
+
72
+    $post = $wpdb->get_row( "SELECT ID FROM $wpdb->posts WHERE post_date < DATE_SUB(NOW(), INTERVAL 1 MONTH) AND post_status = 'publish'" );
73
+    if ( empty( $post ) ) {
74
+        return true;
75
+    }
76
+
77
+    return false;
78 78
 }
79 79
 
80 80
 /**
@@ -84,16 +84,16 @@  discard block
 block discarded – undo
84 84
  * @return string Base domain.
85 85
  */
86 86
 function get_clean_basedomain() {
87
-	$existing_domain = network_domain_check();
88
-	if ( $existing_domain ) {
89
-		return $existing_domain;
90
-	}
91
-	$domain = preg_replace( '|https?://|', '', get_option( 'siteurl' ) );
92
-	$slash  = strpos( $domain, '/' );
93
-	if ( $slash ) {
94
-		$domain = substr( $domain, 0, $slash );
95
-	}
96
-	return $domain;
87
+    $existing_domain = network_domain_check();
88
+    if ( $existing_domain ) {
89
+        return $existing_domain;
90
+    }
91
+    $domain = preg_replace( '|https?://|', '', get_option( 'siteurl' ) );
92
+    $slash  = strpos( $domain, '/' );
93
+    if ( $slash ) {
94
+        $domain = substr( $domain, 0, $slash );
95
+    }
96
+    return $domain;
97 97
 }
98 98
 
99 99
 /**
@@ -110,120 +110,120 @@  discard block
 block discarded – undo
110 110
  * @param false|WP_Error $errors Optional. Error object. Default false.
111 111
  */
112 112
 function network_step1( $errors = false ) {
113
-	global $is_apache;
114
-
115
-	if ( defined( 'DO_NOT_UPGRADE_GLOBAL_TABLES' ) ) {
116
-		echo '<div class="error"><p><strong>' . __( 'Error:' ) . '</strong> ' . sprintf(
117
-			/* translators: %s: DO_NOT_UPGRADE_GLOBAL_TABLES */
118
-			__( 'The constant %s cannot be defined when creating a network.' ),
119
-			'<code>DO_NOT_UPGRADE_GLOBAL_TABLES</code>'
120
-		) . '</p></div>';
121
-		echo '</div>';
122
-		require_once ABSPATH . 'wp-admin/admin-footer.php';
123
-		die();
124
-	}
125
-
126
-	$active_plugins = get_option( 'active_plugins' );
127
-	if ( ! empty( $active_plugins ) ) {
128
-		echo '<div class="notice notice-warning"><p><strong>' . __( 'Warning:' ) . '</strong> ' . sprintf(
129
-			/* translators: %s: URL to Plugins screen. */
130
-			__( 'Please <a href="%s">deactivate your plugins</a> before enabling the Network feature.' ),
131
-			admin_url( 'plugins.php?plugin_status=active' )
132
-		) . '</p></div>';
133
-		echo '<p>' . __( 'Once the network is created, you may reactivate your plugins.' ) . '</p>';
134
-		echo '</div>';
135
-		require_once ABSPATH . 'wp-admin/admin-footer.php';
136
-		die();
137
-	}
138
-
139
-	$hostname  = get_clean_basedomain();
140
-	$has_ports = strstr( $hostname, ':' );
141
-	if ( ( false !== $has_ports && ! in_array( $has_ports, array( ':80', ':443' ), true ) ) ) {
142
-		echo '<div class="error"><p><strong>' . __( 'Error:' ) . '</strong> ' . __( 'You cannot install a network of sites with your server address.' ) . '</p></div>';
143
-		echo '<p>' . sprintf(
144
-			/* translators: %s: Port number. */
145
-			__( 'You cannot use port numbers such as %s.' ),
146
-			'<code>' . $has_ports . '</code>'
147
-		) . '</p>';
148
-		echo '<a href="' . esc_url( admin_url() ) . '">' . __( 'Go to Dashboard' ) . '</a>';
149
-		echo '</div>';
150
-		require_once ABSPATH . 'wp-admin/admin-footer.php';
151
-		die();
152
-	}
153
-
154
-	echo '<form method="post">';
155
-
156
-	wp_nonce_field( 'install-network-1' );
157
-
158
-	$error_codes = array();
159
-	if ( is_wp_error( $errors ) ) {
160
-		echo '<div class="error"><p><strong>' . __( 'Error: The network could not be created.' ) . '</strong></p>';
161
-		foreach ( $errors->get_error_messages() as $error ) {
162
-			echo "<p>$error</p>";
163
-		}
164
-		echo '</div>';
165
-		$error_codes = $errors->get_error_codes();
166
-	}
167
-
168
-	if ( ! empty( $_POST['sitename'] ) && ! in_array( 'empty_sitename', $error_codes, true ) ) {
169
-		$site_name = $_POST['sitename'];
170
-	} else {
171
-		/* translators: %s: Default network title. */
172
-		$site_name = sprintf( __( '%s Sites' ), get_option( 'blogname' ) );
173
-	}
174
-
175
-	if ( ! empty( $_POST['email'] ) && ! in_array( 'invalid_email', $error_codes, true ) ) {
176
-		$admin_email = $_POST['email'];
177
-	} else {
178
-		$admin_email = get_option( 'admin_email' );
179
-	}
180
-	?>
113
+    global $is_apache;
114
+
115
+    if ( defined( 'DO_NOT_UPGRADE_GLOBAL_TABLES' ) ) {
116
+        echo '<div class="error"><p><strong>' . __( 'Error:' ) . '</strong> ' . sprintf(
117
+            /* translators: %s: DO_NOT_UPGRADE_GLOBAL_TABLES */
118
+            __( 'The constant %s cannot be defined when creating a network.' ),
119
+            '<code>DO_NOT_UPGRADE_GLOBAL_TABLES</code>'
120
+        ) . '</p></div>';
121
+        echo '</div>';
122
+        require_once ABSPATH . 'wp-admin/admin-footer.php';
123
+        die();
124
+    }
125
+
126
+    $active_plugins = get_option( 'active_plugins' );
127
+    if ( ! empty( $active_plugins ) ) {
128
+        echo '<div class="notice notice-warning"><p><strong>' . __( 'Warning:' ) . '</strong> ' . sprintf(
129
+            /* translators: %s: URL to Plugins screen. */
130
+            __( 'Please <a href="%s">deactivate your plugins</a> before enabling the Network feature.' ),
131
+            admin_url( 'plugins.php?plugin_status=active' )
132
+        ) . '</p></div>';
133
+        echo '<p>' . __( 'Once the network is created, you may reactivate your plugins.' ) . '</p>';
134
+        echo '</div>';
135
+        require_once ABSPATH . 'wp-admin/admin-footer.php';
136
+        die();
137
+    }
138
+
139
+    $hostname  = get_clean_basedomain();
140
+    $has_ports = strstr( $hostname, ':' );
141
+    if ( ( false !== $has_ports && ! in_array( $has_ports, array( ':80', ':443' ), true ) ) ) {
142
+        echo '<div class="error"><p><strong>' . __( 'Error:' ) . '</strong> ' . __( 'You cannot install a network of sites with your server address.' ) . '</p></div>';
143
+        echo '<p>' . sprintf(
144
+            /* translators: %s: Port number. */
145
+            __( 'You cannot use port numbers such as %s.' ),
146
+            '<code>' . $has_ports . '</code>'
147
+        ) . '</p>';
148
+        echo '<a href="' . esc_url( admin_url() ) . '">' . __( 'Go to Dashboard' ) . '</a>';
149
+        echo '</div>';
150
+        require_once ABSPATH . 'wp-admin/admin-footer.php';
151
+        die();
152
+    }
153
+
154
+    echo '<form method="post">';
155
+
156
+    wp_nonce_field( 'install-network-1' );
157
+
158
+    $error_codes = array();
159
+    if ( is_wp_error( $errors ) ) {
160
+        echo '<div class="error"><p><strong>' . __( 'Error: The network could not be created.' ) . '</strong></p>';
161
+        foreach ( $errors->get_error_messages() as $error ) {
162
+            echo "<p>$error</p>";
163
+        }
164
+        echo '</div>';
165
+        $error_codes = $errors->get_error_codes();
166
+    }
167
+
168
+    if ( ! empty( $_POST['sitename'] ) && ! in_array( 'empty_sitename', $error_codes, true ) ) {
169
+        $site_name = $_POST['sitename'];
170
+    } else {
171
+        /* translators: %s: Default network title. */
172
+        $site_name = sprintf( __( '%s Sites' ), get_option( 'blogname' ) );
173
+    }
174
+
175
+    if ( ! empty( $_POST['email'] ) && ! in_array( 'invalid_email', $error_codes, true ) ) {
176
+        $admin_email = $_POST['email'];
177
+    } else {
178
+        $admin_email = get_option( 'admin_email' );
179
+    }
180
+    ?>
181 181
 	<p><?php _e( 'Welcome to the Network installation process!' ); ?></p>
182 182
 	<p><?php _e( 'Fill in the information below and you&#8217;ll be on your way to creating a network of WordPress sites. Configuration files will be created in the next step.' ); ?></p>
183 183
 	<?php
184 184
 
185
-	if ( isset( $_POST['subdomain_install'] ) ) {
186
-		$subdomain_install = (bool) $_POST['subdomain_install'];
187
-	} elseif ( apache_mod_loaded( 'mod_rewrite' ) ) { // Assume nothing.
188
-		$subdomain_install = true;
189
-	} elseif ( ! allow_subdirectory_install() ) {
190
-		$subdomain_install = true;
191
-	} else {
192
-		$subdomain_install = false;
193
-		$got_mod_rewrite   = got_mod_rewrite();
194
-		if ( $got_mod_rewrite ) { // Dangerous assumptions.
195
-			echo '<div class="updated inline"><p><strong>' . __( 'Note:' ) . '</strong> ';
196
-			printf(
197
-				/* translators: %s: mod_rewrite */
198
-				__( 'Please make sure the Apache %s module is installed as it will be used at the end of this installation.' ),
199
-				'<code>mod_rewrite</code>'
200
-			);
201
-			echo '</p>';
202
-		} elseif ( $is_apache ) {
203
-			echo '<div class="error inline"><p><strong>' . __( 'Warning:' ) . '</strong> ';
204
-			printf(
205
-				/* translators: %s: mod_rewrite */
206
-				__( 'It looks like the Apache %s module is not installed.' ),
207
-				'<code>mod_rewrite</code>'
208
-			);
209
-			echo '</p>';
210
-		}
211
-
212
-		if ( $got_mod_rewrite || $is_apache ) { // Protect against mod_rewrite mimicry (but ! Apache).
213
-			echo '<p>';
214
-			printf(
215
-				/* translators: 1: mod_rewrite, 2: mod_rewrite documentation URL, 3: Google search for mod_rewrite. */
216
-				__( 'If %1$s is disabled, ask your administrator to enable that module, or look at the <a href="%2$s">Apache documentation</a> or <a href="%3$s">elsewhere</a> for help setting it up.' ),
217
-				'<code>mod_rewrite</code>',
218
-				'https://httpd.apache.org/docs/mod/mod_rewrite.html',
219
-				'https://www.google.com/search?q=apache+mod_rewrite'
220
-			);
221
-			echo '</p></div>';
222
-		}
223
-	}
224
-
225
-	if ( allow_subdomain_install() && allow_subdirectory_install() ) :
226
-		?>
185
+    if ( isset( $_POST['subdomain_install'] ) ) {
186
+        $subdomain_install = (bool) $_POST['subdomain_install'];
187
+    } elseif ( apache_mod_loaded( 'mod_rewrite' ) ) { // Assume nothing.
188
+        $subdomain_install = true;
189
+    } elseif ( ! allow_subdirectory_install() ) {
190
+        $subdomain_install = true;
191
+    } else {
192
+        $subdomain_install = false;
193
+        $got_mod_rewrite   = got_mod_rewrite();
194
+        if ( $got_mod_rewrite ) { // Dangerous assumptions.
195
+            echo '<div class="updated inline"><p><strong>' . __( 'Note:' ) . '</strong> ';
196
+            printf(
197
+                /* translators: %s: mod_rewrite */
198
+                __( 'Please make sure the Apache %s module is installed as it will be used at the end of this installation.' ),
199
+                '<code>mod_rewrite</code>'
200
+            );
201
+            echo '</p>';
202
+        } elseif ( $is_apache ) {
203
+            echo '<div class="error inline"><p><strong>' . __( 'Warning:' ) . '</strong> ';
204
+            printf(
205
+                /* translators: %s: mod_rewrite */
206
+                __( 'It looks like the Apache %s module is not installed.' ),
207
+                '<code>mod_rewrite</code>'
208
+            );
209
+            echo '</p>';
210
+        }
211
+
212
+        if ( $got_mod_rewrite || $is_apache ) { // Protect against mod_rewrite mimicry (but ! Apache).
213
+            echo '<p>';
214
+            printf(
215
+                /* translators: 1: mod_rewrite, 2: mod_rewrite documentation URL, 3: Google search for mod_rewrite. */
216
+                __( 'If %1$s is disabled, ask your administrator to enable that module, or look at the <a href="%2$s">Apache documentation</a> or <a href="%3$s">elsewhere</a> for help setting it up.' ),
217
+                '<code>mod_rewrite</code>',
218
+                'https://httpd.apache.org/docs/mod/mod_rewrite.html',
219
+                'https://www.google.com/search?q=apache+mod_rewrite'
220
+            );
221
+            echo '</p></div>';
222
+        }
223
+    }
224
+
225
+    if ( allow_subdomain_install() && allow_subdirectory_install() ) :
226
+        ?>
227 227
 		<h3><?php esc_html_e( 'Addresses of Sites in your Network' ); ?></h3>
228 228
 		<p><?php _e( 'Please choose whether you would like sites in your WordPress network to use sub-domains or sub-directories.' ); ?>
229 229
 			<strong><?php _e( 'You cannot change this later.' ); ?></strong></p>
@@ -234,61 +234,61 @@  discard block
 block discarded – undo
234 234
 				<th><label><input type="radio" name="subdomain_install" value="1"<?php checked( $subdomain_install ); ?> /> <?php _e( 'Sub-domains' ); ?></label></th>
235 235
 				<td>
236 236
 				<?php
237
-				printf(
238
-					/* translators: 1: Host name. */
239
-					_x( 'like <code>site1.%1$s</code> and <code>site2.%1$s</code>', 'subdomain examples' ),
240
-					$hostname
241
-				);
242
-				?>
237
+                printf(
238
+                    /* translators: 1: Host name. */
239
+                    _x( 'like <code>site1.%1$s</code> and <code>site2.%1$s</code>', 'subdomain examples' ),
240
+                    $hostname
241
+                );
242
+                ?>
243 243
 				</td>
244 244
 			</tr>
245 245
 			<tr>
246 246
 				<th><label><input type="radio" name="subdomain_install" value="0"<?php checked( ! $subdomain_install ); ?> /> <?php _e( 'Sub-directories' ); ?></label></th>
247 247
 				<td>
248 248
 				<?php
249
-				printf(
250
-					/* translators: 1: Host name. */
251
-					_x( 'like <code>%1$s/site1</code> and <code>%1$s/site2</code>', 'subdirectory examples' ),
252
-					$hostname
253
-				);
254
-				?>
249
+                printf(
250
+                    /* translators: 1: Host name. */
251
+                    _x( 'like <code>%1$s/site1</code> and <code>%1$s/site2</code>', 'subdirectory examples' ),
252
+                    $hostname
253
+                );
254
+                ?>
255 255
 				</td>
256 256
 			</tr>
257 257
 		</table>
258 258
 
259 259
 		<?php
260
-	endif;
260
+    endif;
261 261
 
262
-	if ( WP_CONTENT_DIR !== ABSPATH . 'wp-content' && ( allow_subdirectory_install() || ! allow_subdomain_install() ) ) {
263
-		echo '<div class="error inline"><p><strong>' . __( 'Warning:' ) . '</strong> ' . __( 'Subdirectory networks may not be fully compatible with custom wp-content directories.' ) . '</p></div>';
264
-	}
262
+    if ( WP_CONTENT_DIR !== ABSPATH . 'wp-content' && ( allow_subdirectory_install() || ! allow_subdomain_install() ) ) {
263
+        echo '<div class="error inline"><p><strong>' . __( 'Warning:' ) . '</strong> ' . __( 'Subdirectory networks may not be fully compatible with custom wp-content directories.' ) . '</p></div>';
264
+    }
265 265
 
266
-	$is_www = ( 0 === strpos( $hostname, 'www.' ) );
267
-	if ( $is_www ) :
268
-		?>
266
+    $is_www = ( 0 === strpos( $hostname, 'www.' ) );
267
+    if ( $is_www ) :
268
+        ?>
269 269
 		<h3><?php esc_html_e( 'Server Address' ); ?></h3>
270 270
 		<p>
271 271
 		<?php
272
-		printf(
273
-			/* translators: 1: Site URL, 2: Host name, 3: www. */
274
-			__( 'You should consider changing your site domain to %1$s before enabling the network feature. It will still be possible to visit your site using the %3$s prefix with an address like %2$s but any links will not have the %3$s prefix.' ),
275
-			'<code>' . substr( $hostname, 4 ) . '</code>',
276
-			'<code>' . $hostname . '</code>',
277
-			'<code>www</code>'
278
-		);
279
-		?>
272
+        printf(
273
+            /* translators: 1: Site URL, 2: Host name, 3: www. */
274
+            __( 'You should consider changing your site domain to %1$s before enabling the network feature. It will still be possible to visit your site using the %3$s prefix with an address like %2$s but any links will not have the %3$s prefix.' ),
275
+            '<code>' . substr( $hostname, 4 ) . '</code>',
276
+            '<code>' . $hostname . '</code>',
277
+            '<code>www</code>'
278
+        );
279
+        ?>
280 280
 		</p>
281 281
 		<table class="form-table" role="presentation">
282 282
 			<tr>
283 283
 			<th scope='row'><?php esc_html_e( 'Server Address' ); ?></th>
284 284
 			<td>
285 285
 				<?php
286
-					printf(
287
-						/* translators: %s: Host name. */
288
-						__( 'The internet address of your network will be %s.' ),
289
-						'<code>' . $hostname . '</code>'
290
-					);
291
-				?>
286
+                    printf(
287
+                        /* translators: %s: Host name. */
288
+                        __( 'The internet address of your network will be %s.' ),
289
+                        '<code>' . $hostname . '</code>'
290
+                    );
291
+                ?>
292 292
 				</td>
293 293
 			</tr>
294 294
 		</table>
@@ -301,17 +301,17 @@  discard block
 block discarded – undo
301 301
 				<th scope="row"><?php esc_html_e( 'Sub-directory Installation' ); ?></th>
302 302
 				<td>
303 303
 				<?php
304
-					printf(
305
-						/* translators: 1: localhost, 2: localhost.localdomain */
306
-						__( 'Because you are using %1$s, the sites in your WordPress network must use sub-directories. Consider using %2$s if you wish to use sub-domains.' ),
307
-						'<code>localhost</code>',
308
-						'<code>localhost.localdomain</code>'
309
-					);
310
-					// Uh oh:
311
-				if ( ! allow_subdirectory_install() ) {
312
-					echo ' <strong>' . __( 'Warning:' ) . ' ' . __( 'The main site in a sub-directory installation will need to use a modified permalink structure, potentially breaking existing links.' ) . '</strong>';
313
-				}
314
-				?>
304
+                    printf(
305
+                        /* translators: 1: localhost, 2: localhost.localdomain */
306
+                        __( 'Because you are using %1$s, the sites in your WordPress network must use sub-directories. Consider using %2$s if you wish to use sub-domains.' ),
307
+                        '<code>localhost</code>',
308
+                        '<code>localhost.localdomain</code>'
309
+                    );
310
+                    // Uh oh:
311
+                if ( ! allow_subdirectory_install() ) {
312
+                    echo ' <strong>' . __( 'Warning:' ) . ' ' . __( 'The main site in a sub-directory installation will need to use a modified permalink structure, potentially breaking existing links.' ) . '</strong>';
313
+                }
314
+                ?>
315 315
 				</td>
316 316
 			</tr>
317 317
 		<?php elseif ( ! allow_subdomain_install() ) : ?>
@@ -319,12 +319,12 @@  discard block
 block discarded – undo
319 319
 				<th scope="row"><?php esc_html_e( 'Sub-directory Installation' ); ?></th>
320 320
 				<td>
321 321
 				<?php
322
-					_e( 'Because your installation is in a directory, the sites in your WordPress network must use sub-directories.' );
323
-					// Uh oh:
324
-				if ( ! allow_subdirectory_install() ) {
325
-					echo ' <strong>' . __( 'Warning:' ) . ' ' . __( 'The main site in a sub-directory installation will need to use a modified permalink structure, potentially breaking existing links.' ) . '</strong>';
326
-				}
327
-				?>
322
+                    _e( 'Because your installation is in a directory, the sites in your WordPress network must use sub-directories.' );
323
+                    // Uh oh:
324
+                if ( ! allow_subdirectory_install() ) {
325
+                    echo ' <strong>' . __( 'Warning:' ) . ' ' . __( 'The main site in a sub-directory installation will need to use a modified permalink structure, potentially breaking existing links.' ) . '</strong>';
326
+                }
327
+                ?>
328 328
 				</td>
329 329
 			</tr>
330 330
 		<?php elseif ( ! allow_subdirectory_install() ) : ?>
@@ -332,9 +332,9 @@  discard block
 block discarded – undo
332 332
 				<th scope="row"><?php esc_html_e( 'Sub-domain Installation' ); ?></th>
333 333
 				<td>
334 334
 				<?php
335
-				_e( 'Because your installation is not new, the sites in your WordPress network must use sub-domains.' );
336
-					echo ' <strong>' . __( 'The main site in a sub-directory installation will need to use a modified permalink structure, potentially breaking existing links.' ) . '</strong>';
337
-				?>
335
+                _e( 'Because your installation is not new, the sites in your WordPress network must use sub-domains.' );
336
+                    echo ' <strong>' . __( 'The main site in a sub-directory installation will need to use a modified permalink structure, potentially breaking existing links.' ) . '</strong>';
337
+                ?>
338 338
 				</td>
339 339
 			</tr>
340 340
 		<?php endif; ?>
@@ -343,12 +343,12 @@  discard block
 block discarded – undo
343 343
 				<th scope='row'><?php esc_html_e( 'Server Address' ); ?></th>
344 344
 				<td>
345 345
 					<?php
346
-					printf(
347
-						/* translators: %s: Host name. */
348
-						__( 'The internet address of your network will be %s.' ),
349
-						'<code>' . $hostname . '</code>'
350
-					);
351
-					?>
346
+                    printf(
347
+                        /* translators: %s: Host name. */
348
+                        __( 'The internet address of your network will be %s.' ),
349
+                        '<code>' . $hostname . '</code>'
350
+                    );
351
+                    ?>
352 352
 				</td>
353 353
 			</tr>
354 354
 		<?php endif; ?>
@@ -387,104 +387,104 @@  discard block
 block discarded – undo
387 387
  * @param false|WP_Error $errors Optional. Error object. Default false.
388 388
  */
389 389
 function network_step2( $errors = false ) {
390
-	global $wpdb, $is_nginx;
391
-
392
-	$hostname          = get_clean_basedomain();
393
-	$slashed_home      = trailingslashit( get_option( 'home' ) );
394
-	$base              = parse_url( $slashed_home, PHP_URL_PATH );
395
-	$document_root_fix = str_replace( '\\', '/', realpath( $_SERVER['DOCUMENT_ROOT'] ) );
396
-	$abspath_fix       = str_replace( '\\', '/', ABSPATH );
397
-	$home_path         = 0 === strpos( $abspath_fix, $document_root_fix ) ? $document_root_fix . $base : get_home_path();
398
-	$wp_siteurl_subdir = preg_replace( '#^' . preg_quote( $home_path, '#' ) . '#', '', $abspath_fix );
399
-	$rewrite_base      = ! empty( $wp_siteurl_subdir ) ? ltrim( trailingslashit( $wp_siteurl_subdir ), '/' ) : '';
400
-
401
-	$location_of_wp_config = $abspath_fix;
402
-	if ( ! file_exists( ABSPATH . 'wp-config.php' ) && file_exists( dirname( ABSPATH ) . '/wp-config.php' ) ) {
403
-		$location_of_wp_config = dirname( $abspath_fix );
404
-	}
405
-	$location_of_wp_config = trailingslashit( $location_of_wp_config );
406
-
407
-	// Wildcard DNS message.
408
-	if ( is_wp_error( $errors ) ) {
409
-		echo '<div class="error">' . $errors->get_error_message() . '</div>';
410
-	}
411
-
412
-	if ( $_POST ) {
413
-		if ( allow_subdomain_install() ) {
414
-			$subdomain_install = allow_subdirectory_install() ? ! empty( $_POST['subdomain_install'] ) : true;
415
-		} else {
416
-			$subdomain_install = false;
417
-		}
418
-	} else {
419
-		if ( is_multisite() ) {
420
-			$subdomain_install = is_subdomain_install();
421
-			?>
390
+    global $wpdb, $is_nginx;
391
+
392
+    $hostname          = get_clean_basedomain();
393
+    $slashed_home      = trailingslashit( get_option( 'home' ) );
394
+    $base              = parse_url( $slashed_home, PHP_URL_PATH );
395
+    $document_root_fix = str_replace( '\\', '/', realpath( $_SERVER['DOCUMENT_ROOT'] ) );
396
+    $abspath_fix       = str_replace( '\\', '/', ABSPATH );
397
+    $home_path         = 0 === strpos( $abspath_fix, $document_root_fix ) ? $document_root_fix . $base : get_home_path();
398
+    $wp_siteurl_subdir = preg_replace( '#^' . preg_quote( $home_path, '#' ) . '#', '', $abspath_fix );
399
+    $rewrite_base      = ! empty( $wp_siteurl_subdir ) ? ltrim( trailingslashit( $wp_siteurl_subdir ), '/' ) : '';
400
+
401
+    $location_of_wp_config = $abspath_fix;
402
+    if ( ! file_exists( ABSPATH . 'wp-config.php' ) && file_exists( dirname( ABSPATH ) . '/wp-config.php' ) ) {
403
+        $location_of_wp_config = dirname( $abspath_fix );
404
+    }
405
+    $location_of_wp_config = trailingslashit( $location_of_wp_config );
406
+
407
+    // Wildcard DNS message.
408
+    if ( is_wp_error( $errors ) ) {
409
+        echo '<div class="error">' . $errors->get_error_message() . '</div>';
410
+    }
411
+
412
+    if ( $_POST ) {
413
+        if ( allow_subdomain_install() ) {
414
+            $subdomain_install = allow_subdirectory_install() ? ! empty( $_POST['subdomain_install'] ) : true;
415
+        } else {
416
+            $subdomain_install = false;
417
+        }
418
+    } else {
419
+        if ( is_multisite() ) {
420
+            $subdomain_install = is_subdomain_install();
421
+            ?>
422 422
 	<p><?php _e( 'The original configuration steps are shown here for reference.' ); ?></p>
423 423
 			<?php
424
-		} else {
425
-			$subdomain_install = (bool) $wpdb->get_var( "SELECT meta_value FROM $wpdb->sitemeta WHERE site_id = 1 AND meta_key = 'subdomain_install'" );
426
-			?>
424
+        } else {
425
+            $subdomain_install = (bool) $wpdb->get_var( "SELECT meta_value FROM $wpdb->sitemeta WHERE site_id = 1 AND meta_key = 'subdomain_install'" );
426
+            ?>
427 427
 	<div class="error"><p><strong><?php _e( 'Warning:' ); ?></strong> <?php _e( 'An existing WordPress network was detected.' ); ?></p></div>
428 428
 	<p><?php _e( 'Please complete the configuration steps. To create a new network, you will need to empty or remove the network database tables.' ); ?></p>
429 429
 			<?php
430
-		}
431
-	}
430
+        }
431
+    }
432 432
 
433
-	$subdir_match          = $subdomain_install ? '' : '([_0-9a-zA-Z-]+/)?';
434
-	$subdir_replacement_01 = $subdomain_install ? '' : '$1';
435
-	$subdir_replacement_12 = $subdomain_install ? '$1' : '$2';
433
+    $subdir_match          = $subdomain_install ? '' : '([_0-9a-zA-Z-]+/)?';
434
+    $subdir_replacement_01 = $subdomain_install ? '' : '$1';
435
+    $subdir_replacement_12 = $subdomain_install ? '$1' : '$2';
436 436
 
437
-	if ( $_POST || ! is_multisite() ) {
438
-		?>
437
+    if ( $_POST || ! is_multisite() ) {
438
+        ?>
439 439
 		<h3><?php esc_html_e( 'Enabling the Network' ); ?></h3>
440 440
 		<p><?php _e( 'Complete the following steps to enable the features for creating a network of sites.' ); ?></p>
441 441
 		<div class="notice notice-warning inline"><p>
442 442
 		<?php
443
-		if ( file_exists( $home_path . '.htaccess' ) ) {
444
-			echo '<strong>' . __( 'Caution:' ) . '</strong> ';
445
-			printf(
446
-				/* translators: 1: wp-config.php, 2: .htaccess */
447
-				__( 'You should back up your existing %1$s and %2$s files.' ),
448
-				'<code>wp-config.php</code>',
449
-				'<code>.htaccess</code>'
450
-			);
451
-		} elseif ( file_exists( $home_path . 'web.config' ) ) {
452
-			echo '<strong>' . __( 'Caution:' ) . '</strong> ';
453
-			printf(
454
-				/* translators: 1: wp-config.php, 2: web.config */
455
-				__( 'You should back up your existing %1$s and %2$s files.' ),
456
-				'<code>wp-config.php</code>',
457
-				'<code>web.config</code>'
458
-			);
459
-		} else {
460
-			echo '<strong>' . __( 'Caution:' ) . '</strong> ';
461
-			printf(
462
-				/* translators: %s: wp-config.php */
463
-				__( 'You should back up your existing %s file.' ),
464
-				'<code>wp-config.php</code>'
465
-			);
466
-		}
467
-		?>
443
+        if ( file_exists( $home_path . '.htaccess' ) ) {
444
+            echo '<strong>' . __( 'Caution:' ) . '</strong> ';
445
+            printf(
446
+                /* translators: 1: wp-config.php, 2: .htaccess */
447
+                __( 'You should back up your existing %1$s and %2$s files.' ),
448
+                '<code>wp-config.php</code>',
449
+                '<code>.htaccess</code>'
450
+            );
451
+        } elseif ( file_exists( $home_path . 'web.config' ) ) {
452
+            echo '<strong>' . __( 'Caution:' ) . '</strong> ';
453
+            printf(
454
+                /* translators: 1: wp-config.php, 2: web.config */
455
+                __( 'You should back up your existing %1$s and %2$s files.' ),
456
+                '<code>wp-config.php</code>',
457
+                '<code>web.config</code>'
458
+            );
459
+        } else {
460
+            echo '<strong>' . __( 'Caution:' ) . '</strong> ';
461
+            printf(
462
+                /* translators: %s: wp-config.php */
463
+                __( 'You should back up your existing %s file.' ),
464
+                '<code>wp-config.php</code>'
465
+            );
466
+        }
467
+        ?>
468 468
 		</p></div>
469 469
 		<?php
470
-	}
471
-	?>
470
+    }
471
+    ?>
472 472
 	<ol>
473 473
 		<li><p>
474 474
 		<?php
475
-		printf(
476
-			/* translators: 1: wp-config.php, 2: Location of wp-config file, 3: Translated version of "That's all, stop editing! Happy publishing." */
477
-			__( 'Add the following to your %1$s file in %2$s <strong>above</strong> the line reading %3$s:' ),
478
-			'<code>wp-config.php</code>',
479
-			'<code>' . $location_of_wp_config . '</code>',
480
-			/*
475
+        printf(
476
+            /* translators: 1: wp-config.php, 2: Location of wp-config file, 3: Translated version of "That's all, stop editing! Happy publishing." */
477
+            __( 'Add the following to your %1$s file in %2$s <strong>above</strong> the line reading %3$s:' ),
478
+            '<code>wp-config.php</code>',
479
+            '<code>' . $location_of_wp_config . '</code>',
480
+            /*
481 481
 			 * translators: This string should only be translated if wp-config-sample.php is localized.
482 482
 			 * You can check the localized release package or
483 483
 			 * https://i18n.svn.wordpress.org/<locale code>/branches/<wp version>/dist/wp-config-sample.php
484 484
 			 */
485
-			'<code>/* ' . __( 'That&#8217;s all, stop editing! Happy publishing.' ) . ' */</code>'
486
-		);
487
-		?>
485
+            '<code>/* ' . __( 'That&#8217;s all, stop editing! Happy publishing.' ) . ' */</code>'
486
+        );
487
+        ?>
488 488
 		</p>
489 489
 		<textarea class="code" readonly="readonly" cols="100" rows="7">
490 490
 define( 'MULTISITE', true );
@@ -495,68 +495,68 @@  discard block
 block discarded – undo
495 495
 define( 'BLOG_ID_CURRENT_SITE', 1 );
496 496
 </textarea>
497 497
 		<?php
498
-		$keys_salts = array(
499
-			'AUTH_KEY'         => '',
500
-			'SECURE_AUTH_KEY'  => '',
501
-			'LOGGED_IN_KEY'    => '',
502
-			'NONCE_KEY'        => '',
503
-			'AUTH_SALT'        => '',
504
-			'SECURE_AUTH_SALT' => '',
505
-			'LOGGED_IN_SALT'   => '',
506
-			'NONCE_SALT'       => '',
507
-		);
508
-		foreach ( $keys_salts as $c => $v ) {
509
-			if ( defined( $c ) ) {
510
-				unset( $keys_salts[ $c ] );
511
-			}
512
-		}
513
-
514
-		if ( ! empty( $keys_salts ) ) {
515
-			$keys_salts_str = '';
516
-			$from_api       = wp_remote_get( 'https://api.wordpress.org/secret-key/1.1/salt/' );
517
-			if ( is_wp_error( $from_api ) ) {
518
-				foreach ( $keys_salts as $c => $v ) {
519
-					$keys_salts_str .= "\ndefine( '$c', '" . wp_generate_password( 64, true, true ) . "' );";
520
-				}
521
-			} else {
522
-				$from_api = explode( "\n", wp_remote_retrieve_body( $from_api ) );
523
-				foreach ( $keys_salts as $c => $v ) {
524
-					$keys_salts_str .= "\ndefine( '$c', '" . substr( array_shift( $from_api ), 28, 64 ) . "' );";
525
-				}
526
-			}
527
-			$num_keys_salts = count( $keys_salts );
528
-			?>
498
+        $keys_salts = array(
499
+            'AUTH_KEY'         => '',
500
+            'SECURE_AUTH_KEY'  => '',
501
+            'LOGGED_IN_KEY'    => '',
502
+            'NONCE_KEY'        => '',
503
+            'AUTH_SALT'        => '',
504
+            'SECURE_AUTH_SALT' => '',
505
+            'LOGGED_IN_SALT'   => '',
506
+            'NONCE_SALT'       => '',
507
+        );
508
+        foreach ( $keys_salts as $c => $v ) {
509
+            if ( defined( $c ) ) {
510
+                unset( $keys_salts[ $c ] );
511
+            }
512
+        }
513
+
514
+        if ( ! empty( $keys_salts ) ) {
515
+            $keys_salts_str = '';
516
+            $from_api       = wp_remote_get( 'https://api.wordpress.org/secret-key/1.1/salt/' );
517
+            if ( is_wp_error( $from_api ) ) {
518
+                foreach ( $keys_salts as $c => $v ) {
519
+                    $keys_salts_str .= "\ndefine( '$c', '" . wp_generate_password( 64, true, true ) . "' );";
520
+                }
521
+            } else {
522
+                $from_api = explode( "\n", wp_remote_retrieve_body( $from_api ) );
523
+                foreach ( $keys_salts as $c => $v ) {
524
+                    $keys_salts_str .= "\ndefine( '$c', '" . substr( array_shift( $from_api ), 28, 64 ) . "' );";
525
+                }
526
+            }
527
+            $num_keys_salts = count( $keys_salts );
528
+            ?>
529 529
 		<p>
530 530
 			<?php
531
-			if ( 1 === $num_keys_salts ) {
532
-				printf(
533
-					/* translators: %s: wp-config.php */
534
-					__( 'This unique authentication key is also missing from your %s file.' ),
535
-					'<code>wp-config.php</code>'
536
-				);
537
-			} else {
538
-				printf(
539
-					/* translators: %s: wp-config.php */
540
-					__( 'These unique authentication keys are also missing from your %s file.' ),
541
-					'<code>wp-config.php</code>'
542
-				);
543
-			}
544
-			?>
531
+            if ( 1 === $num_keys_salts ) {
532
+                printf(
533
+                    /* translators: %s: wp-config.php */
534
+                    __( 'This unique authentication key is also missing from your %s file.' ),
535
+                    '<code>wp-config.php</code>'
536
+                );
537
+            } else {
538
+                printf(
539
+                    /* translators: %s: wp-config.php */
540
+                    __( 'These unique authentication keys are also missing from your %s file.' ),
541
+                    '<code>wp-config.php</code>'
542
+                );
543
+            }
544
+            ?>
545 545
 			<?php _e( 'To make your installation more secure, you should also add:' ); ?>
546 546
 		</p>
547 547
 		<textarea class="code" readonly="readonly" cols="100" rows="<?php echo $num_keys_salts; ?>"><?php echo esc_textarea( $keys_salts_str ); ?></textarea>
548 548
 			<?php
549
-		}
550
-		?>
549
+        }
550
+        ?>
551 551
 		</li>
552 552
 	<?php
553
-	if ( iis7_supports_permalinks() ) :
554
-		// IIS doesn't support RewriteBase, all your RewriteBase are belong to us.
555
-		$iis_subdir_match       = ltrim( $base, '/' ) . $subdir_match;
556
-		$iis_rewrite_base       = ltrim( $base, '/' ) . $rewrite_base;
557
-		$iis_subdir_replacement = $subdomain_install ? '' : '{R:1}';
553
+    if ( iis7_supports_permalinks() ) :
554
+        // IIS doesn't support RewriteBase, all your RewriteBase are belong to us.
555
+        $iis_subdir_match       = ltrim( $base, '/' ) . $subdir_match;
556
+        $iis_rewrite_base       = ltrim( $base, '/' ) . $rewrite_base;
557
+        $iis_subdir_replacement = $subdomain_install ? '' : '{R:1}';
558 558
 
559
-		$web_config_file = '<?xml version="1.0" encoding="UTF-8"?>
559
+        $web_config_file = '<?xml version="1.0" encoding="UTF-8"?>
560 560
 <configuration>
561 561
     <system.webServer>
562 562
         <rewrite>
@@ -565,14 +565,14 @@  discard block
 block discarded – undo
565 565
                     <match url="^index\.php$" ignoreCase="false" />
566 566
                     <action type="None" />
567 567
                 </rule>';
568
-		if ( is_multisite() && get_site_option( 'ms_files_rewriting' ) ) {
569
-			$web_config_file .= '
568
+        if ( is_multisite() && get_site_option( 'ms_files_rewriting' ) ) {
569
+            $web_config_file .= '
570 570
                 <rule name="WordPress Rule for Files" stopProcessing="true">
571 571
                     <match url="^' . $iis_subdir_match . 'files/(.+)" ignoreCase="false" />
572 572
                     <action type="Rewrite" url="' . $iis_rewrite_base . WPINC . '/ms-files.php?file={R:1}" appendQueryString="false" />
573 573
                 </rule>';
574
-		}
575
-			$web_config_file .= '
574
+        }
575
+            $web_config_file .= '
576 576
                 <rule name="WordPress Rule 2" stopProcessing="true">
577 577
                     <match url="^' . $iis_subdir_match . 'wp-admin$" ignoreCase="false" />
578 578
                     <action type="Redirect" url="' . $iis_subdir_replacement . 'wp-admin/" redirectType="Permanent" />
@@ -603,42 +603,42 @@  discard block
 block discarded – undo
603 603
 </configuration>
604 604
 ';
605 605
 
606
-			echo '<li><p>';
607
-			printf(
608
-				/* translators: 1: File name (.htaccess or web.config), 2: File path. */
609
-				__( 'Add the following to your %1$s file in %2$s, <strong>replacing</strong> other WordPress rules:' ),
610
-				'<code>web.config</code>',
611
-				'<code>' . $home_path . '</code>'
612
-			);
613
-		echo '</p>';
614
-		if ( ! $subdomain_install && WP_CONTENT_DIR !== ABSPATH . 'wp-content' ) {
615
-			echo '<p><strong>' . __( 'Warning:' ) . ' ' . __( 'Subdirectory networks may not be fully compatible with custom wp-content directories.' ) . '</strong></p>';
616
-		}
617
-		?>
606
+            echo '<li><p>';
607
+            printf(
608
+                /* translators: 1: File name (.htaccess or web.config), 2: File path. */
609
+                __( 'Add the following to your %1$s file in %2$s, <strong>replacing</strong> other WordPress rules:' ),
610
+                '<code>web.config</code>',
611
+                '<code>' . $home_path . '</code>'
612
+            );
613
+        echo '</p>';
614
+        if ( ! $subdomain_install && WP_CONTENT_DIR !== ABSPATH . 'wp-content' ) {
615
+            echo '<p><strong>' . __( 'Warning:' ) . ' ' . __( 'Subdirectory networks may not be fully compatible with custom wp-content directories.' ) . '</strong></p>';
616
+        }
617
+        ?>
618 618
 		<textarea class="code" readonly="readonly" cols="100" rows="20"><?php echo esc_textarea( $web_config_file ); ?></textarea>
619 619
 		</li>
620 620
 	</ol>
621 621
 
622 622
 		<?php
623
-	elseif ( $is_nginx ) : // End iis7_supports_permalinks(). Link to Nginx documentation instead:
623
+    elseif ( $is_nginx ) : // End iis7_supports_permalinks(). Link to Nginx documentation instead:
624 624
 
625
-		echo '<li><p>';
626
-		printf(
627
-			/* translators: %s: Documentation URL. */
628
-			__( 'It seems your network is running with Nginx web server. <a href="%s">Learn more about further configuration</a>.' ),
629
-			__( 'https://wordpress.org/support/article/nginx/' )
630
-		);
631
-		echo '</p></li>';
625
+        echo '<li><p>';
626
+        printf(
627
+            /* translators: %s: Documentation URL. */
628
+            __( 'It seems your network is running with Nginx web server. <a href="%s">Learn more about further configuration</a>.' ),
629
+            __( 'https://wordpress.org/support/article/nginx/' )
630
+        );
631
+        echo '</p></li>';
632 632
 
633
-	else : // End $is_nginx. Construct an .htaccess file instead:
633
+    else : // End $is_nginx. Construct an .htaccess file instead:
634 634
 
635
-		$ms_files_rewriting = '';
636
-		if ( is_multisite() && get_site_option( 'ms_files_rewriting' ) ) {
637
-			$ms_files_rewriting  = "\n# uploaded files\nRewriteRule ^";
638
-			$ms_files_rewriting .= $subdir_match . "files/(.+) {$rewrite_base}" . WPINC . "/ms-files.php?file={$subdir_replacement_12} [L]" . "\n";
639
-		}
635
+        $ms_files_rewriting = '';
636
+        if ( is_multisite() && get_site_option( 'ms_files_rewriting' ) ) {
637
+            $ms_files_rewriting  = "\n# uploaded files\nRewriteRule ^";
638
+            $ms_files_rewriting .= $subdir_match . "files/(.+) {$rewrite_base}" . WPINC . "/ms-files.php?file={$subdir_replacement_12} [L]" . "\n";
639
+        }
640 640
 
641
-		$htaccess_file = <<<EOF
641
+        $htaccess_file = <<<EOF
642 642
 RewriteEngine On
643 643
 RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
644 644
 RewriteBase {$base}
@@ -656,28 +656,28 @@  discard block
 block discarded – undo
656 656
 
657 657
 EOF;
658 658
 
659
-		echo '<li><p>';
660
-		printf(
661
-			/* translators: 1: File name (.htaccess or web.config), 2: File path. */
662
-			__( 'Add the following to your %1$s file in %2$s, <strong>replacing</strong> other WordPress rules:' ),
663
-			'<code>.htaccess</code>',
664
-			'<code>' . $home_path . '</code>'
665
-		);
666
-		echo '</p>';
667
-		if ( ! $subdomain_install && WP_CONTENT_DIR !== ABSPATH . 'wp-content' ) {
668
-			echo '<p><strong>' . __( 'Warning:' ) . ' ' . __( 'Subdirectory networks may not be fully compatible with custom wp-content directories.' ) . '</strong></p>';
669
-		}
670
-		?>
659
+        echo '<li><p>';
660
+        printf(
661
+            /* translators: 1: File name (.htaccess or web.config), 2: File path. */
662
+            __( 'Add the following to your %1$s file in %2$s, <strong>replacing</strong> other WordPress rules:' ),
663
+            '<code>.htaccess</code>',
664
+            '<code>' . $home_path . '</code>'
665
+        );
666
+        echo '</p>';
667
+        if ( ! $subdomain_install && WP_CONTENT_DIR !== ABSPATH . 'wp-content' ) {
668
+            echo '<p><strong>' . __( 'Warning:' ) . ' ' . __( 'Subdirectory networks may not be fully compatible with custom wp-content directories.' ) . '</strong></p>';
669
+        }
670
+        ?>
671 671
 		<textarea class="code" readonly="readonly" cols="100" rows="<?php echo substr_count( $htaccess_file, "\n" ) + 1; ?>"><?php echo esc_textarea( $htaccess_file ); ?></textarea>
672 672
 		</li>
673 673
 	</ol>
674 674
 
675 675
 		<?php
676
-	endif; // End IIS/Nginx/Apache code branches.
676
+    endif; // End IIS/Nginx/Apache code branches.
677 677
 
678
-	if ( ! is_multisite() ) {
679
-		?>
678
+    if ( ! is_multisite() ) {
679
+        ?>
680 680
 		<p><?php _e( 'Once you complete these steps, your network is enabled and configured. You will have to log in again.' ); ?> <a href="<?php echo esc_url( wp_login_url() ); ?>"><?php _e( 'Log In' ); ?></a></p>
681 681
 		<?php
682
-	}
682
+    }
683 683
 }
Please login to merge, or discard this patch.
brighty/wp-admin/includes/class-wp-automatic-updater.php 1 patch
Indentation   +1425 added lines, -1425 removed lines patch added patch discarded remove patch
@@ -15,605 +15,605 @@  discard block
 block discarded – undo
15 15
  */
16 16
 class WP_Automatic_Updater {
17 17
 
18
-	/**
19
-	 * Tracks update results during processing.
20
-	 *
21
-	 * @var array
22
-	 */
23
-	protected $update_results = array();
24
-
25
-	/**
26
-	 * Determines whether the entire automatic updater is disabled.
27
-	 *
28
-	 * @since 3.7.0
29
-	 */
30
-	public function is_disabled() {
31
-		// Background updates are disabled if you don't want file changes.
32
-		if ( ! wp_is_file_mod_allowed( 'automatic_updater' ) ) {
33
-			return true;
34
-		}
35
-
36
-		if ( wp_installing() ) {
37
-			return true;
38
-		}
39
-
40
-		// More fine grained control can be done through the WP_AUTO_UPDATE_CORE constant and filters.
41
-		$disabled = defined( 'AUTOMATIC_UPDATER_DISABLED' ) && AUTOMATIC_UPDATER_DISABLED;
42
-
43
-		/**
44
-		 * Filters whether to entirely disable background updates.
45
-		 *
46
-		 * There are more fine-grained filters and controls for selective disabling.
47
-		 * This filter parallels the AUTOMATIC_UPDATER_DISABLED constant in name.
48
-		 *
49
-		 * This also disables update notification emails. That may change in the future.
50
-		 *
51
-		 * @since 3.7.0
52
-		 *
53
-		 * @param bool $disabled Whether the updater should be disabled.
54
-		 */
55
-		return apply_filters( 'automatic_updater_disabled', $disabled );
56
-	}
57
-
58
-	/**
59
-	 * Checks for version control checkouts.
60
-	 *
61
-	 * Checks for Subversion, Git, Mercurial, and Bazaar. It recursively looks up the
62
-	 * filesystem to the top of the drive, erring on the side of detecting a VCS
63
-	 * checkout somewhere.
64
-	 *
65
-	 * ABSPATH is always checked in addition to whatever `$context` is (which may be the
66
-	 * wp-content directory, for example). The underlying assumption is that if you are
67
-	 * using version control *anywhere*, then you should be making decisions for
68
-	 * how things get updated.
69
-	 *
70
-	 * @since 3.7.0
71
-	 *
72
-	 * @param string $context The filesystem path to check, in addition to ABSPATH.
73
-	 * @return bool True if a VCS checkout was discovered at `$context` or ABSPATH,
74
-	 *              or anywhere higher. False otherwise.
75
-	 */
76
-	public function is_vcs_checkout( $context ) {
77
-		$context_dirs = array( untrailingslashit( $context ) );
78
-		if ( ABSPATH !== $context ) {
79
-			$context_dirs[] = untrailingslashit( ABSPATH );
80
-		}
81
-
82
-		$vcs_dirs   = array( '.svn', '.git', '.hg', '.bzr' );
83
-		$check_dirs = array();
84
-
85
-		foreach ( $context_dirs as $context_dir ) {
86
-			// Walk up from $context_dir to the root.
87
-			do {
88
-				$check_dirs[] = $context_dir;
89
-
90
-				// Once we've hit '/' or 'C:\', we need to stop. dirname will keep returning the input here.
91
-				if ( dirname( $context_dir ) === $context_dir ) {
92
-					break;
93
-				}
94
-
95
-				// Continue one level at a time.
96
-			} while ( $context_dir = dirname( $context_dir ) );
97
-		}
98
-
99
-		$check_dirs = array_unique( $check_dirs );
100
-
101
-		// Search all directories we've found for evidence of version control.
102
-		foreach ( $vcs_dirs as $vcs_dir ) {
103
-			foreach ( $check_dirs as $check_dir ) {
104
-				$checkout = @is_dir( rtrim( $check_dir, '\\/' ) . "/$vcs_dir" );
105
-				if ( $checkout ) {
106
-					break 2;
107
-				}
108
-			}
109
-		}
110
-
111
-		/**
112
-		 * Filters whether the automatic updater should consider a filesystem
113
-		 * location to be potentially managed by a version control system.
114
-		 *
115
-		 * @since 3.7.0
116
-		 *
117
-		 * @param bool $checkout  Whether a VCS checkout was discovered at `$context`
118
-		 *                        or ABSPATH, or anywhere higher.
119
-		 * @param string $context The filesystem context (a path) against which
120
-		 *                        filesystem status should be checked.
121
-		 */
122
-		return apply_filters( 'automatic_updates_is_vcs_checkout', $checkout, $context );
123
-	}
124
-
125
-	/**
126
-	 * Tests to see if we can and should update a specific item.
127
-	 *
128
-	 * @since 3.7.0
129
-	 *
130
-	 * @global wpdb $wpdb WordPress database abstraction object.
131
-	 *
132
-	 * @param string $type    The type of update being checked: 'core', 'theme',
133
-	 *                        'plugin', 'translation'.
134
-	 * @param object $item    The update offer.
135
-	 * @param string $context The filesystem context (a path) against which filesystem
136
-	 *                        access and status should be checked.
137
-	 * @return bool True if the item should be updated, false otherwise.
138
-	 */
139
-	public function should_update( $type, $item, $context ) {
140
-		// Used to see if WP_Filesystem is set up to allow unattended updates.
141
-		$skin = new Automatic_Upgrader_Skin;
142
-
143
-		if ( $this->is_disabled() ) {
144
-			return false;
145
-		}
146
-
147
-		// Only relax the filesystem checks when the update doesn't include new files.
148
-		$allow_relaxed_file_ownership = false;
149
-		if ( 'core' === $type && isset( $item->new_files ) && ! $item->new_files ) {
150
-			$allow_relaxed_file_ownership = true;
151
-		}
152
-
153
-		// If we can't do an auto core update, we may still be able to email the user.
154
-		if ( ! $skin->request_filesystem_credentials( false, $context, $allow_relaxed_file_ownership )
155
-			|| $this->is_vcs_checkout( $context )
156
-		) {
157
-			if ( 'core' === $type ) {
158
-				$this->send_core_update_notification_email( $item );
159
-			}
160
-			return false;
161
-		}
162
-
163
-		// Next up, is this an item we can update?
164
-		if ( 'core' === $type ) {
165
-			$update = Core_Upgrader::should_update_to_version( $item->current );
166
-		} elseif ( 'plugin' === $type || 'theme' === $type ) {
167
-			$update = ! empty( $item->autoupdate );
168
-
169
-			if ( ! $update && wp_is_auto_update_enabled_for_type( $type ) ) {
170
-				// Check if the site admin has enabled auto-updates by default for the specific item.
171
-				$auto_updates = (array) get_site_option( "auto_update_{$type}s", array() );
172
-				$update       = in_array( $item->{$type}, $auto_updates, true );
173
-			}
174
-		} else {
175
-			$update = ! empty( $item->autoupdate );
176
-		}
177
-
178
-		// If the `disable_autoupdate` flag is set, override any user-choice, but allow filters.
179
-		if ( ! empty( $item->disable_autoupdate ) ) {
180
-			$update = $item->disable_autoupdate;
181
-		}
182
-
183
-		/**
184
-		 * Filters whether to automatically update core, a plugin, a theme, or a language.
185
-		 *
186
-		 * The dynamic portion of the hook name, `$type`, refers to the type of update
187
-		 * being checked.
188
-		 *
189
-		 * Possible hook names include:
190
-		 *
191
-		 *  - `auto_update_core`
192
-		 *  - `auto_update_plugin`
193
-		 *  - `auto_update_theme`
194
-		 *  - `auto_update_translation`
195
-		 *
196
-		 * Since WordPress 3.7, minor and development versions of core, and translations have
197
-		 * been auto-updated by default. New installs on WordPress 5.6 or higher will also
198
-		 * auto-update major versions by default. Starting in 5.6, older sites can opt-in to
199
-		 * major version auto-updates, and auto-updates for plugins and themes.
200
-		 *
201
-		 * See the {@see 'allow_dev_auto_core_updates'}, {@see 'allow_minor_auto_core_updates'},
202
-		 * and {@see 'allow_major_auto_core_updates'} filters for a more straightforward way to
203
-		 * adjust core updates.
204
-		 *
205
-		 * @since 3.7.0
206
-		 * @since 5.5.0 The `$update` parameter accepts the value of null.
207
-		 *
208
-		 * @param bool|null $update Whether to update. The value of null is internally used
209
-		 *                          to detect whether nothing has hooked into this filter.
210
-		 * @param object    $item   The update offer.
211
-		 */
212
-		$update = apply_filters( "auto_update_{$type}", $update, $item );
213
-
214
-		if ( ! $update ) {
215
-			if ( 'core' === $type ) {
216
-				$this->send_core_update_notification_email( $item );
217
-			}
218
-			return false;
219
-		}
220
-
221
-		// If it's a core update, are we actually compatible with its requirements?
222
-		if ( 'core' === $type ) {
223
-			global $wpdb;
224
-
225
-			$php_compat = version_compare( phpversion(), $item->php_version, '>=' );
226
-			if ( file_exists( WP_CONTENT_DIR . '/db.php' ) && empty( $wpdb->is_mysql ) ) {
227
-				$mysql_compat = true;
228
-			} else {
229
-				$mysql_compat = version_compare( $wpdb->db_version(), $item->mysql_version, '>=' );
230
-			}
231
-
232
-			if ( ! $php_compat || ! $mysql_compat ) {
233
-				return false;
234
-			}
235
-		}
236
-
237
-		// If updating a plugin or theme, ensure the minimum PHP version requirements are satisfied.
238
-		if ( in_array( $type, array( 'plugin', 'theme' ), true ) ) {
239
-			if ( ! empty( $item->requires_php ) && version_compare( phpversion(), $item->requires_php, '<' ) ) {
240
-				return false;
241
-			}
242
-		}
243
-
244
-		return true;
245
-	}
246
-
247
-	/**
248
-	 * Notifies an administrator of a core update.
249
-	 *
250
-	 * @since 3.7.0
251
-	 *
252
-	 * @param object $item The update offer.
253
-	 * @return bool True if the site administrator is notified of a core update,
254
-	 *              false otherwise.
255
-	 */
256
-	protected function send_core_update_notification_email( $item ) {
257
-		$notified = get_site_option( 'auto_core_update_notified' );
258
-
259
-		// Don't notify if we've already notified the same email address of the same version.
260
-		if ( $notified
261
-			&& get_site_option( 'admin_email' ) === $notified['email']
262
-			&& $notified['version'] === $item->current
263
-		) {
264
-			return false;
265
-		}
266
-
267
-		// See if we need to notify users of a core update.
268
-		$notify = ! empty( $item->notify_email );
269
-
270
-		/**
271
-		 * Filters whether to notify the site administrator of a new core update.
272
-		 *
273
-		 * By default, administrators are notified when the update offer received
274
-		 * from WordPress.org sets a particular flag. This allows some discretion
275
-		 * in if and when to notify.
276
-		 *
277
-		 * This filter is only evaluated once per release. If the same email address
278
-		 * was already notified of the same new version, WordPress won't repeatedly
279
-		 * email the administrator.
280
-		 *
281
-		 * This filter is also used on about.php to check if a plugin has disabled
282
-		 * these notifications.
283
-		 *
284
-		 * @since 3.7.0
285
-		 *
286
-		 * @param bool   $notify Whether the site administrator is notified.
287
-		 * @param object $item   The update offer.
288
-		 */
289
-		if ( ! apply_filters( 'send_core_update_notification_email', $notify, $item ) ) {
290
-			return false;
291
-		}
292
-
293
-		$this->send_email( 'manual', $item );
294
-		return true;
295
-	}
296
-
297
-	/**
298
-	 * Updates an item, if appropriate.
299
-	 *
300
-	 * @since 3.7.0
301
-	 *
302
-	 * @param string $type The type of update being checked: 'core', 'theme', 'plugin', 'translation'.
303
-	 * @param object $item The update offer.
304
-	 * @return null|WP_Error
305
-	 */
306
-	public function update( $type, $item ) {
307
-		$skin = new Automatic_Upgrader_Skin;
308
-
309
-		switch ( $type ) {
310
-			case 'core':
311
-				// The Core upgrader doesn't use the Upgrader's skin during the actual main part of the upgrade, instead, firing a filter.
312
-				add_filter( 'update_feedback', array( $skin, 'feedback' ) );
313
-				$upgrader = new Core_Upgrader( $skin );
314
-				$context  = ABSPATH;
315
-				break;
316
-			case 'plugin':
317
-				$upgrader = new Plugin_Upgrader( $skin );
318
-				$context  = WP_PLUGIN_DIR; // We don't support custom Plugin directories, or updates for WPMU_PLUGIN_DIR.
319
-				break;
320
-			case 'theme':
321
-				$upgrader = new Theme_Upgrader( $skin );
322
-				$context  = get_theme_root( $item->theme );
323
-				break;
324
-			case 'translation':
325
-				$upgrader = new Language_Pack_Upgrader( $skin );
326
-				$context  = WP_CONTENT_DIR; // WP_LANG_DIR;
327
-				break;
328
-		}
329
-
330
-		// Determine whether we can and should perform this update.
331
-		if ( ! $this->should_update( $type, $item, $context ) ) {
332
-			return false;
333
-		}
334
-
335
-		/**
336
-		 * Fires immediately prior to an auto-update.
337
-		 *
338
-		 * @since 4.4.0
339
-		 *
340
-		 * @param string $type    The type of update being checked: 'core', 'theme', 'plugin', or 'translation'.
341
-		 * @param object $item    The update offer.
342
-		 * @param string $context The filesystem context (a path) against which filesystem access and status
343
-		 *                        should be checked.
344
-		 */
345
-		do_action( 'pre_auto_update', $type, $item, $context );
346
-
347
-		$upgrader_item = $item;
348
-		switch ( $type ) {
349
-			case 'core':
350
-				/* translators: %s: WordPress version. */
351
-				$skin->feedback( __( 'Updating to WordPress %s' ), $item->version );
352
-				/* translators: %s: WordPress version. */
353
-				$item_name = sprintf( __( 'WordPress %s' ), $item->version );
354
-				break;
355
-			case 'theme':
356
-				$upgrader_item = $item->theme;
357
-				$theme         = wp_get_theme( $upgrader_item );
358
-				$item_name     = $theme->Get( 'Name' );
359
-				// Add the current version so that it can be reported in the notification email.
360
-				$item->current_version = $theme->get( 'Version' );
361
-				if ( empty( $item->current_version ) ) {
362
-					$item->current_version = false;
363
-				}
364
-				/* translators: %s: Theme name. */
365
-				$skin->feedback( __( 'Updating theme: %s' ), $item_name );
366
-				break;
367
-			case 'plugin':
368
-				$upgrader_item = $item->plugin;
369
-				$plugin_data   = get_plugin_data( $context . '/' . $upgrader_item );
370
-				$item_name     = $plugin_data['Name'];
371
-				// Add the current version so that it can be reported in the notification email.
372
-				$item->current_version = $plugin_data['Version'];
373
-				if ( empty( $item->current_version ) ) {
374
-					$item->current_version = false;
375
-				}
376
-				/* translators: %s: Plugin name. */
377
-				$skin->feedback( __( 'Updating plugin: %s' ), $item_name );
378
-				break;
379
-			case 'translation':
380
-				$language_item_name = $upgrader->get_name_for_update( $item );
381
-				/* translators: %s: Project name (plugin, theme, or WordPress). */
382
-				$item_name = sprintf( __( 'Translations for %s' ), $language_item_name );
383
-				/* translators: 1: Project name (plugin, theme, or WordPress), 2: Language. */
384
-				$skin->feedback( sprintf( __( 'Updating translations for %1$s (%2$s)&#8230;' ), $language_item_name, $item->language ) );
385
-				break;
386
-		}
387
-
388
-		$allow_relaxed_file_ownership = false;
389
-		if ( 'core' === $type && isset( $item->new_files ) && ! $item->new_files ) {
390
-			$allow_relaxed_file_ownership = true;
391
-		}
392
-
393
-		// Boom, this site's about to get a whole new splash of paint!
394
-		$upgrade_result = $upgrader->upgrade(
395
-			$upgrader_item,
396
-			array(
397
-				'clear_update_cache'           => false,
398
-				// Always use partial builds if possible for core updates.
399
-				'pre_check_md5'                => false,
400
-				// Only available for core updates.
401
-				'attempt_rollback'             => true,
402
-				// Allow relaxed file ownership in some scenarios.
403
-				'allow_relaxed_file_ownership' => $allow_relaxed_file_ownership,
404
-			)
405
-		);
406
-
407
-		// If the filesystem is unavailable, false is returned.
408
-		if ( false === $upgrade_result ) {
409
-			$upgrade_result = new WP_Error( 'fs_unavailable', __( 'Could not access filesystem.' ) );
410
-		}
411
-
412
-		if ( 'core' === $type ) {
413
-			if ( is_wp_error( $upgrade_result )
414
-				&& ( 'up_to_date' === $upgrade_result->get_error_code()
415
-					|| 'locked' === $upgrade_result->get_error_code() )
416
-			) {
417
-				// These aren't actual errors, treat it as a skipped-update instead
418
-				// to avoid triggering the post-core update failure routines.
419
-				return false;
420
-			}
421
-
422
-			// Core doesn't output this, so let's append it, so we don't get confused.
423
-			if ( is_wp_error( $upgrade_result ) ) {
424
-				$upgrade_result->add( 'installation_failed', __( 'Installation failed.' ) );
425
-				$skin->error( $upgrade_result );
426
-			} else {
427
-				$skin->feedback( __( 'WordPress updated successfully.' ) );
428
-			}
429
-		}
430
-
431
-		$this->update_results[ $type ][] = (object) array(
432
-			'item'     => $item,
433
-			'result'   => $upgrade_result,
434
-			'name'     => $item_name,
435
-			'messages' => $skin->get_upgrade_messages(),
436
-		);
437
-
438
-		return $upgrade_result;
439
-	}
440
-
441
-	/**
442
-	 * Kicks off the background update process, looping through all pending updates.
443
-	 *
444
-	 * @since 3.7.0
445
-	 */
446
-	public function run() {
447
-		if ( $this->is_disabled() ) {
448
-			return;
449
-		}
450
-
451
-		if ( ! is_main_network() || ! is_main_site() ) {
452
-			return;
453
-		}
454
-
455
-		if ( ! WP_Upgrader::create_lock( 'auto_updater' ) ) {
456
-			return;
457
-		}
458
-
459
-		// Don't automatically run these things, as we'll handle it ourselves.
460
-		remove_action( 'upgrader_process_complete', array( 'Language_Pack_Upgrader', 'async_upgrade' ), 20 );
461
-		remove_action( 'upgrader_process_complete', 'wp_version_check' );
462
-		remove_action( 'upgrader_process_complete', 'wp_update_plugins' );
463
-		remove_action( 'upgrader_process_complete', 'wp_update_themes' );
464
-
465
-		// Next, plugins.
466
-		wp_update_plugins(); // Check for plugin updates.
467
-		$plugin_updates = get_site_transient( 'update_plugins' );
468
-		if ( $plugin_updates && ! empty( $plugin_updates->response ) ) {
469
-			foreach ( $plugin_updates->response as $plugin ) {
470
-				$this->update( 'plugin', $plugin );
471
-			}
472
-			// Force refresh of plugin update information.
473
-			wp_clean_plugins_cache();
474
-		}
475
-
476
-		// Next, those themes we all love.
477
-		wp_update_themes();  // Check for theme updates.
478
-		$theme_updates = get_site_transient( 'update_themes' );
479
-		if ( $theme_updates && ! empty( $theme_updates->response ) ) {
480
-			foreach ( $theme_updates->response as $theme ) {
481
-				$this->update( 'theme', (object) $theme );
482
-			}
483
-			// Force refresh of theme update information.
484
-			wp_clean_themes_cache();
485
-		}
486
-
487
-		// Next, process any core update.
488
-		wp_version_check(); // Check for core updates.
489
-		$core_update = find_core_auto_update();
490
-
491
-		if ( $core_update ) {
492
-			$this->update( 'core', $core_update );
493
-		}
494
-
495
-		// Clean up, and check for any pending translations.
496
-		// (Core_Upgrader checks for core updates.)
497
-		$theme_stats = array();
498
-		if ( isset( $this->update_results['theme'] ) ) {
499
-			foreach ( $this->update_results['theme'] as $upgrade ) {
500
-				$theme_stats[ $upgrade->item->theme ] = ( true === $upgrade->result );
501
-			}
502
-		}
503
-		wp_update_themes( $theme_stats ); // Check for theme updates.
504
-
505
-		$plugin_stats = array();
506
-		if ( isset( $this->update_results['plugin'] ) ) {
507
-			foreach ( $this->update_results['plugin'] as $upgrade ) {
508
-				$plugin_stats[ $upgrade->item->plugin ] = ( true === $upgrade->result );
509
-			}
510
-		}
511
-		wp_update_plugins( $plugin_stats ); // Check for plugin updates.
512
-
513
-		// Finally, process any new translations.
514
-		$language_updates = wp_get_translation_updates();
515
-		if ( $language_updates ) {
516
-			foreach ( $language_updates as $update ) {
517
-				$this->update( 'translation', $update );
518
-			}
519
-
520
-			// Clear existing caches.
521
-			wp_clean_update_cache();
522
-
523
-			wp_version_check();  // Check for core updates.
524
-			wp_update_themes();  // Check for theme updates.
525
-			wp_update_plugins(); // Check for plugin updates.
526
-		}
527
-
528
-		// Send debugging email to admin for all development installations.
529
-		if ( ! empty( $this->update_results ) ) {
530
-			$development_version = false !== strpos( get_bloginfo( 'version' ), '-' );
531
-
532
-			/**
533
-			 * Filters whether to send a debugging email for each automatic background update.
534
-			 *
535
-			 * @since 3.7.0
536
-			 *
537
-			 * @param bool $development_version By default, emails are sent if the
538
-			 *                                  install is a development version.
539
-			 *                                  Return false to avoid the email.
540
-			 */
541
-			if ( apply_filters( 'automatic_updates_send_debug_email', $development_version ) ) {
542
-				$this->send_debug_email();
543
-			}
544
-
545
-			if ( ! empty( $this->update_results['core'] ) ) {
546
-				$this->after_core_update( $this->update_results['core'][0] );
547
-			} elseif ( ! empty( $this->update_results['plugin'] ) || ! empty( $this->update_results['theme'] ) ) {
548
-				$this->after_plugin_theme_update( $this->update_results );
549
-			}
550
-
551
-			/**
552
-			 * Fires after all automatic updates have run.
553
-			 *
554
-			 * @since 3.8.0
555
-			 *
556
-			 * @param array $update_results The results of all attempted updates.
557
-			 */
558
-			do_action( 'automatic_updates_complete', $this->update_results );
559
-		}
560
-
561
-		WP_Upgrader::release_lock( 'auto_updater' );
562
-	}
563
-
564
-	/**
565
-	 * If we tried to perform a core update, check if we should send an email,
566
-	 * and if we need to avoid processing future updates.
567
-	 *
568
-	 * @since 3.7.0
569
-	 *
570
-	 * @param object $update_result The result of the core update. Includes the update offer and result.
571
-	 */
572
-	protected function after_core_update( $update_result ) {
573
-		$wp_version = get_bloginfo( 'version' );
574
-
575
-		$core_update = $update_result->item;
576
-		$result      = $update_result->result;
577
-
578
-		if ( ! is_wp_error( $result ) ) {
579
-			$this->send_email( 'success', $core_update );
580
-			return;
581
-		}
582
-
583
-		$error_code = $result->get_error_code();
584
-
585
-		// Any of these WP_Error codes are critical failures, as in they occurred after we started to copy core files.
586
-		// We should not try to perform a background update again until there is a successful one-click update performed by the user.
587
-		$critical = false;
588
-		if ( 'disk_full' === $error_code || false !== strpos( $error_code, '__copy_dir' ) ) {
589
-			$critical = true;
590
-		} elseif ( 'rollback_was_required' === $error_code && is_wp_error( $result->get_error_data()->rollback ) ) {
591
-			// A rollback is only critical if it failed too.
592
-			$critical        = true;
593
-			$rollback_result = $result->get_error_data()->rollback;
594
-		} elseif ( false !== strpos( $error_code, 'do_rollback' ) ) {
595
-			$critical = true;
596
-		}
597
-
598
-		if ( $critical ) {
599
-			$critical_data = array(
600
-				'attempted'  => $core_update->current,
601
-				'current'    => $wp_version,
602
-				'error_code' => $error_code,
603
-				'error_data' => $result->get_error_data(),
604
-				'timestamp'  => time(),
605
-				'critical'   => true,
606
-			);
607
-			if ( isset( $rollback_result ) ) {
608
-				$critical_data['rollback_code'] = $rollback_result->get_error_code();
609
-				$critical_data['rollback_data'] = $rollback_result->get_error_data();
610
-			}
611
-			update_site_option( 'auto_core_update_failed', $critical_data );
612
-			$this->send_email( 'critical', $core_update, $result );
613
-			return;
614
-		}
615
-
616
-		/*
18
+    /**
19
+     * Tracks update results during processing.
20
+     *
21
+     * @var array
22
+     */
23
+    protected $update_results = array();
24
+
25
+    /**
26
+     * Determines whether the entire automatic updater is disabled.
27
+     *
28
+     * @since 3.7.0
29
+     */
30
+    public function is_disabled() {
31
+        // Background updates are disabled if you don't want file changes.
32
+        if ( ! wp_is_file_mod_allowed( 'automatic_updater' ) ) {
33
+            return true;
34
+        }
35
+
36
+        if ( wp_installing() ) {
37
+            return true;
38
+        }
39
+
40
+        // More fine grained control can be done through the WP_AUTO_UPDATE_CORE constant and filters.
41
+        $disabled = defined( 'AUTOMATIC_UPDATER_DISABLED' ) && AUTOMATIC_UPDATER_DISABLED;
42
+
43
+        /**
44
+         * Filters whether to entirely disable background updates.
45
+         *
46
+         * There are more fine-grained filters and controls for selective disabling.
47
+         * This filter parallels the AUTOMATIC_UPDATER_DISABLED constant in name.
48
+         *
49
+         * This also disables update notification emails. That may change in the future.
50
+         *
51
+         * @since 3.7.0
52
+         *
53
+         * @param bool $disabled Whether the updater should be disabled.
54
+         */
55
+        return apply_filters( 'automatic_updater_disabled', $disabled );
56
+    }
57
+
58
+    /**
59
+     * Checks for version control checkouts.
60
+     *
61
+     * Checks for Subversion, Git, Mercurial, and Bazaar. It recursively looks up the
62
+     * filesystem to the top of the drive, erring on the side of detecting a VCS
63
+     * checkout somewhere.
64
+     *
65
+     * ABSPATH is always checked in addition to whatever `$context` is (which may be the
66
+     * wp-content directory, for example). The underlying assumption is that if you are
67
+     * using version control *anywhere*, then you should be making decisions for
68
+     * how things get updated.
69
+     *
70
+     * @since 3.7.0
71
+     *
72
+     * @param string $context The filesystem path to check, in addition to ABSPATH.
73
+     * @return bool True if a VCS checkout was discovered at `$context` or ABSPATH,
74
+     *              or anywhere higher. False otherwise.
75
+     */
76
+    public function is_vcs_checkout( $context ) {
77
+        $context_dirs = array( untrailingslashit( $context ) );
78
+        if ( ABSPATH !== $context ) {
79
+            $context_dirs[] = untrailingslashit( ABSPATH );
80
+        }
81
+
82
+        $vcs_dirs   = array( '.svn', '.git', '.hg', '.bzr' );
83
+        $check_dirs = array();
84
+
85
+        foreach ( $context_dirs as $context_dir ) {
86
+            // Walk up from $context_dir to the root.
87
+            do {
88
+                $check_dirs[] = $context_dir;
89
+
90
+                // Once we've hit '/' or 'C:\', we need to stop. dirname will keep returning the input here.
91
+                if ( dirname( $context_dir ) === $context_dir ) {
92
+                    break;
93
+                }
94
+
95
+                // Continue one level at a time.
96
+            } while ( $context_dir = dirname( $context_dir ) );
97
+        }
98
+
99
+        $check_dirs = array_unique( $check_dirs );
100
+
101
+        // Search all directories we've found for evidence of version control.
102
+        foreach ( $vcs_dirs as $vcs_dir ) {
103
+            foreach ( $check_dirs as $check_dir ) {
104
+                $checkout = @is_dir( rtrim( $check_dir, '\\/' ) . "/$vcs_dir" );
105
+                if ( $checkout ) {
106
+                    break 2;
107
+                }
108
+            }
109
+        }
110
+
111
+        /**
112
+         * Filters whether the automatic updater should consider a filesystem
113
+         * location to be potentially managed by a version control system.
114
+         *
115
+         * @since 3.7.0
116
+         *
117
+         * @param bool $checkout  Whether a VCS checkout was discovered at `$context`
118
+         *                        or ABSPATH, or anywhere higher.
119
+         * @param string $context The filesystem context (a path) against which
120
+         *                        filesystem status should be checked.
121
+         */
122
+        return apply_filters( 'automatic_updates_is_vcs_checkout', $checkout, $context );
123
+    }
124
+
125
+    /**
126
+     * Tests to see if we can and should update a specific item.
127
+     *
128
+     * @since 3.7.0
129
+     *
130
+     * @global wpdb $wpdb WordPress database abstraction object.
131
+     *
132
+     * @param string $type    The type of update being checked: 'core', 'theme',
133
+     *                        'plugin', 'translation'.
134
+     * @param object $item    The update offer.
135
+     * @param string $context The filesystem context (a path) against which filesystem
136
+     *                        access and status should be checked.
137
+     * @return bool True if the item should be updated, false otherwise.
138
+     */
139
+    public function should_update( $type, $item, $context ) {
140
+        // Used to see if WP_Filesystem is set up to allow unattended updates.
141
+        $skin = new Automatic_Upgrader_Skin;
142
+
143
+        if ( $this->is_disabled() ) {
144
+            return false;
145
+        }
146
+
147
+        // Only relax the filesystem checks when the update doesn't include new files.
148
+        $allow_relaxed_file_ownership = false;
149
+        if ( 'core' === $type && isset( $item->new_files ) && ! $item->new_files ) {
150
+            $allow_relaxed_file_ownership = true;
151
+        }
152
+
153
+        // If we can't do an auto core update, we may still be able to email the user.
154
+        if ( ! $skin->request_filesystem_credentials( false, $context, $allow_relaxed_file_ownership )
155
+            || $this->is_vcs_checkout( $context )
156
+        ) {
157
+            if ( 'core' === $type ) {
158
+                $this->send_core_update_notification_email( $item );
159
+            }
160
+            return false;
161
+        }
162
+
163
+        // Next up, is this an item we can update?
164
+        if ( 'core' === $type ) {
165
+            $update = Core_Upgrader::should_update_to_version( $item->current );
166
+        } elseif ( 'plugin' === $type || 'theme' === $type ) {
167
+            $update = ! empty( $item->autoupdate );
168
+
169
+            if ( ! $update && wp_is_auto_update_enabled_for_type( $type ) ) {
170
+                // Check if the site admin has enabled auto-updates by default for the specific item.
171
+                $auto_updates = (array) get_site_option( "auto_update_{$type}s", array() );
172
+                $update       = in_array( $item->{$type}, $auto_updates, true );
173
+            }
174
+        } else {
175
+            $update = ! empty( $item->autoupdate );
176
+        }
177
+
178
+        // If the `disable_autoupdate` flag is set, override any user-choice, but allow filters.
179
+        if ( ! empty( $item->disable_autoupdate ) ) {
180
+            $update = $item->disable_autoupdate;
181
+        }
182
+
183
+        /**
184
+         * Filters whether to automatically update core, a plugin, a theme, or a language.
185
+         *
186
+         * The dynamic portion of the hook name, `$type`, refers to the type of update
187
+         * being checked.
188
+         *
189
+         * Possible hook names include:
190
+         *
191
+         *  - `auto_update_core`
192
+         *  - `auto_update_plugin`
193
+         *  - `auto_update_theme`
194
+         *  - `auto_update_translation`
195
+         *
196
+         * Since WordPress 3.7, minor and development versions of core, and translations have
197
+         * been auto-updated by default. New installs on WordPress 5.6 or higher will also
198
+         * auto-update major versions by default. Starting in 5.6, older sites can opt-in to
199
+         * major version auto-updates, and auto-updates for plugins and themes.
200
+         *
201
+         * See the {@see 'allow_dev_auto_core_updates'}, {@see 'allow_minor_auto_core_updates'},
202
+         * and {@see 'allow_major_auto_core_updates'} filters for a more straightforward way to
203
+         * adjust core updates.
204
+         *
205
+         * @since 3.7.0
206
+         * @since 5.5.0 The `$update` parameter accepts the value of null.
207
+         *
208
+         * @param bool|null $update Whether to update. The value of null is internally used
209
+         *                          to detect whether nothing has hooked into this filter.
210
+         * @param object    $item   The update offer.
211
+         */
212
+        $update = apply_filters( "auto_update_{$type}", $update, $item );
213
+
214
+        if ( ! $update ) {
215
+            if ( 'core' === $type ) {
216
+                $this->send_core_update_notification_email( $item );
217
+            }
218
+            return false;
219
+        }
220
+
221
+        // If it's a core update, are we actually compatible with its requirements?
222
+        if ( 'core' === $type ) {
223
+            global $wpdb;
224
+
225
+            $php_compat = version_compare( phpversion(), $item->php_version, '>=' );
226
+            if ( file_exists( WP_CONTENT_DIR . '/db.php' ) && empty( $wpdb->is_mysql ) ) {
227
+                $mysql_compat = true;
228
+            } else {
229
+                $mysql_compat = version_compare( $wpdb->db_version(), $item->mysql_version, '>=' );
230
+            }
231
+
232
+            if ( ! $php_compat || ! $mysql_compat ) {
233
+                return false;
234
+            }
235
+        }
236
+
237
+        // If updating a plugin or theme, ensure the minimum PHP version requirements are satisfied.
238
+        if ( in_array( $type, array( 'plugin', 'theme' ), true ) ) {
239
+            if ( ! empty( $item->requires_php ) && version_compare( phpversion(), $item->requires_php, '<' ) ) {
240
+                return false;
241
+            }
242
+        }
243
+
244
+        return true;
245
+    }
246
+
247
+    /**
248
+     * Notifies an administrator of a core update.
249
+     *
250
+     * @since 3.7.0
251
+     *
252
+     * @param object $item The update offer.
253
+     * @return bool True if the site administrator is notified of a core update,
254
+     *              false otherwise.
255
+     */
256
+    protected function send_core_update_notification_email( $item ) {
257
+        $notified = get_site_option( 'auto_core_update_notified' );
258
+
259
+        // Don't notify if we've already notified the same email address of the same version.
260
+        if ( $notified
261
+            && get_site_option( 'admin_email' ) === $notified['email']
262
+            && $notified['version'] === $item->current
263
+        ) {
264
+            return false;
265
+        }
266
+
267
+        // See if we need to notify users of a core update.
268
+        $notify = ! empty( $item->notify_email );
269
+
270
+        /**
271
+         * Filters whether to notify the site administrator of a new core update.
272
+         *
273
+         * By default, administrators are notified when the update offer received
274
+         * from WordPress.org sets a particular flag. This allows some discretion
275
+         * in if and when to notify.
276
+         *
277
+         * This filter is only evaluated once per release. If the same email address
278
+         * was already notified of the same new version, WordPress won't repeatedly
279
+         * email the administrator.
280
+         *
281
+         * This filter is also used on about.php to check if a plugin has disabled
282
+         * these notifications.
283
+         *
284
+         * @since 3.7.0
285
+         *
286
+         * @param bool   $notify Whether the site administrator is notified.
287
+         * @param object $item   The update offer.
288
+         */
289
+        if ( ! apply_filters( 'send_core_update_notification_email', $notify, $item ) ) {
290
+            return false;
291
+        }
292
+
293
+        $this->send_email( 'manual', $item );
294
+        return true;
295
+    }
296
+
297
+    /**
298
+     * Updates an item, if appropriate.
299
+     *
300
+     * @since 3.7.0
301
+     *
302
+     * @param string $type The type of update being checked: 'core', 'theme', 'plugin', 'translation'.
303
+     * @param object $item The update offer.
304
+     * @return null|WP_Error
305
+     */
306
+    public function update( $type, $item ) {
307
+        $skin = new Automatic_Upgrader_Skin;
308
+
309
+        switch ( $type ) {
310
+            case 'core':
311
+                // The Core upgrader doesn't use the Upgrader's skin during the actual main part of the upgrade, instead, firing a filter.
312
+                add_filter( 'update_feedback', array( $skin, 'feedback' ) );
313
+                $upgrader = new Core_Upgrader( $skin );
314
+                $context  = ABSPATH;
315
+                break;
316
+            case 'plugin':
317
+                $upgrader = new Plugin_Upgrader( $skin );
318
+                $context  = WP_PLUGIN_DIR; // We don't support custom Plugin directories, or updates for WPMU_PLUGIN_DIR.
319
+                break;
320
+            case 'theme':
321
+                $upgrader = new Theme_Upgrader( $skin );
322
+                $context  = get_theme_root( $item->theme );
323
+                break;
324
+            case 'translation':
325
+                $upgrader = new Language_Pack_Upgrader( $skin );
326
+                $context  = WP_CONTENT_DIR; // WP_LANG_DIR;
327
+                break;
328
+        }
329
+
330
+        // Determine whether we can and should perform this update.
331
+        if ( ! $this->should_update( $type, $item, $context ) ) {
332
+            return false;
333
+        }
334
+
335
+        /**
336
+         * Fires immediately prior to an auto-update.
337
+         *
338
+         * @since 4.4.0
339
+         *
340
+         * @param string $type    The type of update being checked: 'core', 'theme', 'plugin', or 'translation'.
341
+         * @param object $item    The update offer.
342
+         * @param string $context The filesystem context (a path) against which filesystem access and status
343
+         *                        should be checked.
344
+         */
345
+        do_action( 'pre_auto_update', $type, $item, $context );
346
+
347
+        $upgrader_item = $item;
348
+        switch ( $type ) {
349
+            case 'core':
350
+                /* translators: %s: WordPress version. */
351
+                $skin->feedback( __( 'Updating to WordPress %s' ), $item->version );
352
+                /* translators: %s: WordPress version. */
353
+                $item_name = sprintf( __( 'WordPress %s' ), $item->version );
354
+                break;
355
+            case 'theme':
356
+                $upgrader_item = $item->theme;
357
+                $theme         = wp_get_theme( $upgrader_item );
358
+                $item_name     = $theme->Get( 'Name' );
359
+                // Add the current version so that it can be reported in the notification email.
360
+                $item->current_version = $theme->get( 'Version' );
361
+                if ( empty( $item->current_version ) ) {
362
+                    $item->current_version = false;
363
+                }
364
+                /* translators: %s: Theme name. */
365
+                $skin->feedback( __( 'Updating theme: %s' ), $item_name );
366
+                break;
367
+            case 'plugin':
368
+                $upgrader_item = $item->plugin;
369
+                $plugin_data   = get_plugin_data( $context . '/' . $upgrader_item );
370
+                $item_name     = $plugin_data['Name'];
371
+                // Add the current version so that it can be reported in the notification email.
372
+                $item->current_version = $plugin_data['Version'];
373
+                if ( empty( $item->current_version ) ) {
374
+                    $item->current_version = false;
375
+                }
376
+                /* translators: %s: Plugin name. */
377
+                $skin->feedback( __( 'Updating plugin: %s' ), $item_name );
378
+                break;
379
+            case 'translation':
380
+                $language_item_name = $upgrader->get_name_for_update( $item );
381
+                /* translators: %s: Project name (plugin, theme, or WordPress). */
382
+                $item_name = sprintf( __( 'Translations for %s' ), $language_item_name );
383
+                /* translators: 1: Project name (plugin, theme, or WordPress), 2: Language. */
384
+                $skin->feedback( sprintf( __( 'Updating translations for %1$s (%2$s)&#8230;' ), $language_item_name, $item->language ) );
385
+                break;
386
+        }
387
+
388
+        $allow_relaxed_file_ownership = false;
389
+        if ( 'core' === $type && isset( $item->new_files ) && ! $item->new_files ) {
390
+            $allow_relaxed_file_ownership = true;
391
+        }
392
+
393
+        // Boom, this site's about to get a whole new splash of paint!
394
+        $upgrade_result = $upgrader->upgrade(
395
+            $upgrader_item,
396
+            array(
397
+                'clear_update_cache'           => false,
398
+                // Always use partial builds if possible for core updates.
399
+                'pre_check_md5'                => false,
400
+                // Only available for core updates.
401
+                'attempt_rollback'             => true,
402
+                // Allow relaxed file ownership in some scenarios.
403
+                'allow_relaxed_file_ownership' => $allow_relaxed_file_ownership,
404
+            )
405
+        );
406
+
407
+        // If the filesystem is unavailable, false is returned.
408
+        if ( false === $upgrade_result ) {
409
+            $upgrade_result = new WP_Error( 'fs_unavailable', __( 'Could not access filesystem.' ) );
410
+        }
411
+
412
+        if ( 'core' === $type ) {
413
+            if ( is_wp_error( $upgrade_result )
414
+                && ( 'up_to_date' === $upgrade_result->get_error_code()
415
+                    || 'locked' === $upgrade_result->get_error_code() )
416
+            ) {
417
+                // These aren't actual errors, treat it as a skipped-update instead
418
+                // to avoid triggering the post-core update failure routines.
419
+                return false;
420
+            }
421
+
422
+            // Core doesn't output this, so let's append it, so we don't get confused.
423
+            if ( is_wp_error( $upgrade_result ) ) {
424
+                $upgrade_result->add( 'installation_failed', __( 'Installation failed.' ) );
425
+                $skin->error( $upgrade_result );
426
+            } else {
427
+                $skin->feedback( __( 'WordPress updated successfully.' ) );
428
+            }
429
+        }
430
+
431
+        $this->update_results[ $type ][] = (object) array(
432
+            'item'     => $item,
433
+            'result'   => $upgrade_result,
434
+            'name'     => $item_name,
435
+            'messages' => $skin->get_upgrade_messages(),
436
+        );
437
+
438
+        return $upgrade_result;
439
+    }
440
+
441
+    /**
442
+     * Kicks off the background update process, looping through all pending updates.
443
+     *
444
+     * @since 3.7.0
445
+     */
446
+    public function run() {
447
+        if ( $this->is_disabled() ) {
448
+            return;
449
+        }
450
+
451
+        if ( ! is_main_network() || ! is_main_site() ) {
452
+            return;
453
+        }
454
+
455
+        if ( ! WP_Upgrader::create_lock( 'auto_updater' ) ) {
456
+            return;
457
+        }
458
+
459
+        // Don't automatically run these things, as we'll handle it ourselves.
460
+        remove_action( 'upgrader_process_complete', array( 'Language_Pack_Upgrader', 'async_upgrade' ), 20 );
461
+        remove_action( 'upgrader_process_complete', 'wp_version_check' );
462
+        remove_action( 'upgrader_process_complete', 'wp_update_plugins' );
463
+        remove_action( 'upgrader_process_complete', 'wp_update_themes' );
464
+
465
+        // Next, plugins.
466
+        wp_update_plugins(); // Check for plugin updates.
467
+        $plugin_updates = get_site_transient( 'update_plugins' );
468
+        if ( $plugin_updates && ! empty( $plugin_updates->response ) ) {
469
+            foreach ( $plugin_updates->response as $plugin ) {
470
+                $this->update( 'plugin', $plugin );
471
+            }
472
+            // Force refresh of plugin update information.
473
+            wp_clean_plugins_cache();
474
+        }
475
+
476
+        // Next, those themes we all love.
477
+        wp_update_themes();  // Check for theme updates.
478
+        $theme_updates = get_site_transient( 'update_themes' );
479
+        if ( $theme_updates && ! empty( $theme_updates->response ) ) {
480
+            foreach ( $theme_updates->response as $theme ) {
481
+                $this->update( 'theme', (object) $theme );
482
+            }
483
+            // Force refresh of theme update information.
484
+            wp_clean_themes_cache();
485
+        }
486
+
487
+        // Next, process any core update.
488
+        wp_version_check(); // Check for core updates.
489
+        $core_update = find_core_auto_update();
490
+
491
+        if ( $core_update ) {
492
+            $this->update( 'core', $core_update );
493
+        }
494
+
495
+        // Clean up, and check for any pending translations.
496
+        // (Core_Upgrader checks for core updates.)
497
+        $theme_stats = array();
498
+        if ( isset( $this->update_results['theme'] ) ) {
499
+            foreach ( $this->update_results['theme'] as $upgrade ) {
500
+                $theme_stats[ $upgrade->item->theme ] = ( true === $upgrade->result );
501
+            }
502
+        }
503
+        wp_update_themes( $theme_stats ); // Check for theme updates.
504
+
505
+        $plugin_stats = array();
506
+        if ( isset( $this->update_results['plugin'] ) ) {
507
+            foreach ( $this->update_results['plugin'] as $upgrade ) {
508
+                $plugin_stats[ $upgrade->item->plugin ] = ( true === $upgrade->result );
509
+            }
510
+        }
511
+        wp_update_plugins( $plugin_stats ); // Check for plugin updates.
512
+
513
+        // Finally, process any new translations.
514
+        $language_updates = wp_get_translation_updates();
515
+        if ( $language_updates ) {
516
+            foreach ( $language_updates as $update ) {
517
+                $this->update( 'translation', $update );
518
+            }
519
+
520
+            // Clear existing caches.
521
+            wp_clean_update_cache();
522
+
523
+            wp_version_check();  // Check for core updates.
524
+            wp_update_themes();  // Check for theme updates.
525
+            wp_update_plugins(); // Check for plugin updates.
526
+        }
527
+
528
+        // Send debugging email to admin for all development installations.
529
+        if ( ! empty( $this->update_results ) ) {
530
+            $development_version = false !== strpos( get_bloginfo( 'version' ), '-' );
531
+
532
+            /**
533
+             * Filters whether to send a debugging email for each automatic background update.
534
+             *
535
+             * @since 3.7.0
536
+             *
537
+             * @param bool $development_version By default, emails are sent if the
538
+             *                                  install is a development version.
539
+             *                                  Return false to avoid the email.
540
+             */
541
+            if ( apply_filters( 'automatic_updates_send_debug_email', $development_version ) ) {
542
+                $this->send_debug_email();
543
+            }
544
+
545
+            if ( ! empty( $this->update_results['core'] ) ) {
546
+                $this->after_core_update( $this->update_results['core'][0] );
547
+            } elseif ( ! empty( $this->update_results['plugin'] ) || ! empty( $this->update_results['theme'] ) ) {
548
+                $this->after_plugin_theme_update( $this->update_results );
549
+            }
550
+
551
+            /**
552
+             * Fires after all automatic updates have run.
553
+             *
554
+             * @since 3.8.0
555
+             *
556
+             * @param array $update_results The results of all attempted updates.
557
+             */
558
+            do_action( 'automatic_updates_complete', $this->update_results );
559
+        }
560
+
561
+        WP_Upgrader::release_lock( 'auto_updater' );
562
+    }
563
+
564
+    /**
565
+     * If we tried to perform a core update, check if we should send an email,
566
+     * and if we need to avoid processing future updates.
567
+     *
568
+     * @since 3.7.0
569
+     *
570
+     * @param object $update_result The result of the core update. Includes the update offer and result.
571
+     */
572
+    protected function after_core_update( $update_result ) {
573
+        $wp_version = get_bloginfo( 'version' );
574
+
575
+        $core_update = $update_result->item;
576
+        $result      = $update_result->result;
577
+
578
+        if ( ! is_wp_error( $result ) ) {
579
+            $this->send_email( 'success', $core_update );
580
+            return;
581
+        }
582
+
583
+        $error_code = $result->get_error_code();
584
+
585
+        // Any of these WP_Error codes are critical failures, as in they occurred after we started to copy core files.
586
+        // We should not try to perform a background update again until there is a successful one-click update performed by the user.
587
+        $critical = false;
588
+        if ( 'disk_full' === $error_code || false !== strpos( $error_code, '__copy_dir' ) ) {
589
+            $critical = true;
590
+        } elseif ( 'rollback_was_required' === $error_code && is_wp_error( $result->get_error_data()->rollback ) ) {
591
+            // A rollback is only critical if it failed too.
592
+            $critical        = true;
593
+            $rollback_result = $result->get_error_data()->rollback;
594
+        } elseif ( false !== strpos( $error_code, 'do_rollback' ) ) {
595
+            $critical = true;
596
+        }
597
+
598
+        if ( $critical ) {
599
+            $critical_data = array(
600
+                'attempted'  => $core_update->current,
601
+                'current'    => $wp_version,
602
+                'error_code' => $error_code,
603
+                'error_data' => $result->get_error_data(),
604
+                'timestamp'  => time(),
605
+                'critical'   => true,
606
+            );
607
+            if ( isset( $rollback_result ) ) {
608
+                $critical_data['rollback_code'] = $rollback_result->get_error_code();
609
+                $critical_data['rollback_data'] = $rollback_result->get_error_data();
610
+            }
611
+            update_site_option( 'auto_core_update_failed', $critical_data );
612
+            $this->send_email( 'critical', $core_update, $result );
613
+            return;
614
+        }
615
+
616
+        /*
617 617
 		 * Any other WP_Error code (like download_failed or files_not_writable) occurs before
618 618
 		 * we tried to copy over core files. Thus, the failures are early and graceful.
619 619
 		 *
@@ -624,745 +624,745 @@  discard block
 block discarded – undo
624 624
 		 * In fact, let's schedule a special update for an hour from now. (It's possible
625 625
 		 * the issue could actually be on WordPress.org's side.) If that one fails, then email.
626 626
 		 */
627
-		$send               = true;
628
-		$transient_failures = array( 'incompatible_archive', 'download_failed', 'insane_distro', 'locked' );
629
-		if ( in_array( $error_code, $transient_failures, true ) && ! get_site_option( 'auto_core_update_failed' ) ) {
630
-			wp_schedule_single_event( time() + HOUR_IN_SECONDS, 'wp_maybe_auto_update' );
631
-			$send = false;
632
-		}
633
-
634
-		$notified = get_site_option( 'auto_core_update_notified' );
635
-
636
-		// Don't notify if we've already notified the same email address of the same version of the same notification type.
637
-		if ( $notified
638
-			&& 'fail' === $notified['type']
639
-			&& get_site_option( 'admin_email' ) === $notified['email']
640
-			&& $notified['version'] === $core_update->current
641
-		) {
642
-			$send = false;
643
-		}
644
-
645
-		update_site_option(
646
-			'auto_core_update_failed',
647
-			array(
648
-				'attempted'  => $core_update->current,
649
-				'current'    => $wp_version,
650
-				'error_code' => $error_code,
651
-				'error_data' => $result->get_error_data(),
652
-				'timestamp'  => time(),
653
-				'retry'      => in_array( $error_code, $transient_failures, true ),
654
-			)
655
-		);
656
-
657
-		if ( $send ) {
658
-			$this->send_email( 'fail', $core_update, $result );
659
-		}
660
-	}
661
-
662
-	/**
663
-	 * Sends an email upon the completion or failure of a background core update.
664
-	 *
665
-	 * @since 3.7.0
666
-	 *
667
-	 * @param string $type        The type of email to send. Can be one of 'success', 'fail', 'manual', 'critical'.
668
-	 * @param object $core_update The update offer that was attempted.
669
-	 * @param mixed  $result      Optional. The result for the core update. Can be WP_Error.
670
-	 */
671
-	protected function send_email( $type, $core_update, $result = null ) {
672
-		update_site_option(
673
-			'auto_core_update_notified',
674
-			array(
675
-				'type'      => $type,
676
-				'email'     => get_site_option( 'admin_email' ),
677
-				'version'   => $core_update->current,
678
-				'timestamp' => time(),
679
-			)
680
-		);
681
-
682
-		$next_user_core_update = get_preferred_from_update_core();
683
-
684
-		// If the update transient is empty, use the update we just performed.
685
-		if ( ! $next_user_core_update ) {
686
-			$next_user_core_update = $core_update;
687
-		}
688
-
689
-		if ( 'upgrade' === $next_user_core_update->response
690
-			&& version_compare( $next_user_core_update->version, $core_update->version, '>' )
691
-		) {
692
-			$newer_version_available = true;
693
-		} else {
694
-			$newer_version_available = false;
695
-		}
696
-
697
-		/**
698
-		 * Filters whether to send an email following an automatic background core update.
699
-		 *
700
-		 * @since 3.7.0
701
-		 *
702
-		 * @param bool   $send        Whether to send the email. Default true.
703
-		 * @param string $type        The type of email to send. Can be one of
704
-		 *                            'success', 'fail', 'critical'.
705
-		 * @param object $core_update The update offer that was attempted.
706
-		 * @param mixed  $result      The result for the core update. Can be WP_Error.
707
-		 */
708
-		if ( 'manual' !== $type && ! apply_filters( 'auto_core_update_send_email', true, $type, $core_update, $result ) ) {
709
-			return;
710
-		}
711
-
712
-		switch ( $type ) {
713
-			case 'success': // We updated.
714
-				/* translators: Site updated notification email subject. 1: Site title, 2: WordPress version. */
715
-				$subject = __( '[%1$s] Your site has updated to WordPress %2$s' );
716
-				break;
717
-
718
-			case 'fail':   // We tried to update but couldn't.
719
-			case 'manual': // We can't update (and made no attempt).
720
-				/* translators: Update available notification email subject. 1: Site title, 2: WordPress version. */
721
-				$subject = __( '[%1$s] WordPress %2$s is available. Please update!' );
722
-				break;
723
-
724
-			case 'critical': // We tried to update, started to copy files, then things went wrong.
725
-				/* translators: Site down notification email subject. 1: Site title. */
726
-				$subject = __( '[%1$s] URGENT: Your site may be down due to a failed update' );
727
-				break;
728
-
729
-			default:
730
-				return;
731
-		}
732
-
733
-		// If the auto-update is not to the latest version, say that the current version of WP is available instead.
734
-		$version = 'success' === $type ? $core_update->current : $next_user_core_update->current;
735
-		$subject = sprintf( $subject, wp_specialchars_decode( get_option( 'blogname' ), ENT_QUOTES ), $version );
736
-
737
-		$body = '';
738
-
739
-		switch ( $type ) {
740
-			case 'success':
741
-				$body .= sprintf(
742
-					/* translators: 1: Home URL, 2: WordPress version. */
743
-					__( 'Howdy! Your site at %1$s has been updated automatically to WordPress %2$s.' ),
744
-					home_url(),
745
-					$core_update->current
746
-				);
747
-				$body .= "\n\n";
748
-				if ( ! $newer_version_available ) {
749
-					$body .= __( 'No further action is needed on your part.' ) . ' ';
750
-				}
751
-
752
-				// Can only reference the About screen if their update was successful.
753
-				list( $about_version ) = explode( '-', $core_update->current, 2 );
754
-				/* translators: %s: WordPress version. */
755
-				$body .= sprintf( __( 'For more on version %s, see the About WordPress screen:' ), $about_version );
756
-				$body .= "\n" . admin_url( 'about.php' );
757
-
758
-				if ( $newer_version_available ) {
759
-					/* translators: %s: WordPress latest version. */
760
-					$body .= "\n\n" . sprintf( __( 'WordPress %s is also now available.' ), $next_user_core_update->current ) . ' ';
761
-					$body .= __( 'Updating is easy and only takes a few moments:' );
762
-					$body .= "\n" . network_admin_url( 'update-core.php' );
763
-				}
764
-
765
-				break;
766
-
767
-			case 'fail':
768
-			case 'manual':
769
-				$body .= sprintf(
770
-					/* translators: 1: Home URL, 2: WordPress version. */
771
-					__( 'Please update your site at %1$s to WordPress %2$s.' ),
772
-					home_url(),
773
-					$next_user_core_update->current
774
-				);
775
-
776
-				$body .= "\n\n";
777
-
778
-				// Don't show this message if there is a newer version available.
779
-				// Potential for confusion, and also not useful for them to know at this point.
780
-				if ( 'fail' === $type && ! $newer_version_available ) {
781
-					$body .= __( 'An attempt was made, but your site could not be updated automatically.' ) . ' ';
782
-				}
783
-
784
-				$body .= __( 'Updating is easy and only takes a few moments:' );
785
-				$body .= "\n" . network_admin_url( 'update-core.php' );
786
-				break;
787
-
788
-			case 'critical':
789
-				if ( $newer_version_available ) {
790
-					$body .= sprintf(
791
-						/* translators: 1: Home URL, 2: WordPress version. */
792
-						__( 'Your site at %1$s experienced a critical failure while trying to update WordPress to version %2$s.' ),
793
-						home_url(),
794
-						$core_update->current
795
-					);
796
-				} else {
797
-					$body .= sprintf(
798
-						/* translators: 1: Home URL, 2: WordPress latest version. */
799
-						__( 'Your site at %1$s experienced a critical failure while trying to update to the latest version of WordPress, %2$s.' ),
800
-						home_url(),
801
-						$core_update->current
802
-					);
803
-				}
804
-
805
-				$body .= "\n\n" . __( "This means your site may be offline or broken. Don't panic; this can be fixed." );
806
-
807
-				$body .= "\n\n" . __( "Please check out your site now. It's possible that everything is working. If it says you need to update, you should do so:" );
808
-				$body .= "\n" . network_admin_url( 'update-core.php' );
809
-				break;
810
-		}
811
-
812
-		$critical_support = 'critical' === $type && ! empty( $core_update->support_email );
813
-		if ( $critical_support ) {
814
-			// Support offer if available.
815
-			$body .= "\n\n" . sprintf(
816
-				/* translators: %s: Support email address. */
817
-				__( 'The WordPress team is willing to help you. Forward this email to %s and the team will work with you to make sure your site is working.' ),
818
-				$core_update->support_email
819
-			);
820
-		} else {
821
-			// Add a note about the support forums.
822
-			$body .= "\n\n" . __( 'If you experience any issues or need support, the volunteers in the WordPress.org support forums may be able to help.' );
823
-			$body .= "\n" . __( 'https://wordpress.org/support/forums/' );
824
-		}
825
-
826
-		// Updates are important!
827
-		if ( 'success' !== $type || $newer_version_available ) {
828
-			$body .= "\n\n" . __( 'Keeping your site updated is important for security. It also makes the internet a safer place for you and your readers.' );
829
-		}
830
-
831
-		if ( $critical_support ) {
832
-			$body .= ' ' . __( "If you reach out to us, we'll also ensure you'll never have this problem again." );
833
-		}
834
-
835
-		// If things are successful and we're now on the latest, mention plugins and themes if any are out of date.
836
-		if ( 'success' === $type && ! $newer_version_available && ( get_plugin_updates() || get_theme_updates() ) ) {
837
-			$body .= "\n\n" . __( 'You also have some plugins or themes with updates available. Update them now:' );
838
-			$body .= "\n" . network_admin_url();
839
-		}
840
-
841
-		$body .= "\n\n" . __( 'The WordPress Team' ) . "\n";
842
-
843
-		if ( 'critical' === $type && is_wp_error( $result ) ) {
844
-			$body .= "\n***\n\n";
845
-			/* translators: %s: WordPress version. */
846
-			$body .= sprintf( __( 'Your site was running version %s.' ), get_bloginfo( 'version' ) );
847
-			$body .= ' ' . __( 'Some data that describes the error your site encountered has been put together.' );
848
-			$body .= ' ' . __( 'Your hosting company, support forum volunteers, or a friendly developer may be able to use this information to help you:' );
849
-
850
-			// If we had a rollback and we're still critical, then the rollback failed too.
851
-			// Loop through all errors (the main WP_Error, the update result, the rollback result) for code, data, etc.
852
-			if ( 'rollback_was_required' === $result->get_error_code() ) {
853
-				$errors = array( $result, $result->get_error_data()->update, $result->get_error_data()->rollback );
854
-			} else {
855
-				$errors = array( $result );
856
-			}
857
-
858
-			foreach ( $errors as $error ) {
859
-				if ( ! is_wp_error( $error ) ) {
860
-					continue;
861
-				}
862
-
863
-				$error_code = $error->get_error_code();
864
-				/* translators: %s: Error code. */
865
-				$body .= "\n\n" . sprintf( __( 'Error code: %s' ), $error_code );
866
-
867
-				if ( 'rollback_was_required' === $error_code ) {
868
-					continue;
869
-				}
870
-
871
-				if ( $error->get_error_message() ) {
872
-					$body .= "\n" . $error->get_error_message();
873
-				}
874
-
875
-				$error_data = $error->get_error_data();
876
-				if ( $error_data ) {
877
-					$body .= "\n" . implode( ', ', (array) $error_data );
878
-				}
879
-			}
880
-
881
-			$body .= "\n";
882
-		}
883
-
884
-		$to      = get_site_option( 'admin_email' );
885
-		$headers = '';
886
-
887
-		$email = compact( 'to', 'subject', 'body', 'headers' );
888
-
889
-		/**
890
-		 * Filters the email sent following an automatic background core update.
891
-		 *
892
-		 * @since 3.7.0
893
-		 *
894
-		 * @param array $email {
895
-		 *     Array of email arguments that will be passed to wp_mail().
896
-		 *
897
-		 *     @type string $to      The email recipient. An array of emails
898
-		 *                            can be returned, as handled by wp_mail().
899
-		 *     @type string $subject The email's subject.
900
-		 *     @type string $body    The email message body.
901
-		 *     @type string $headers Any email headers, defaults to no headers.
902
-		 * }
903
-		 * @param string $type        The type of email being sent. Can be one of
904
-		 *                            'success', 'fail', 'manual', 'critical'.
905
-		 * @param object $core_update The update offer that was attempted.
906
-		 * @param mixed  $result      The result for the core update. Can be WP_Error.
907
-		 */
908
-		$email = apply_filters( 'auto_core_update_email', $email, $type, $core_update, $result );
909
-
910
-		wp_mail( $email['to'], wp_specialchars_decode( $email['subject'] ), $email['body'], $email['headers'] );
911
-	}
912
-
913
-
914
-	/**
915
-	 * If we tried to perform plugin or theme updates, check if we should send an email.
916
-	 *
917
-	 * @since 5.5.0
918
-	 *
919
-	 * @param array $update_results The results of update tasks.
920
-	 */
921
-	protected function after_plugin_theme_update( $update_results ) {
922
-		$successful_updates = array();
923
-		$failed_updates     = array();
924
-
925
-		if ( ! empty( $update_results['plugin'] ) ) {
926
-			/**
927
-			 * Filters whether to send an email following an automatic background plugin update.
928
-			 *
929
-			 * @since 5.5.0
930
-			 * @since 5.5.1 Added the `$update_results` parameter.
931
-			 *
932
-			 * @param bool  $enabled        True if plugin update notifications are enabled, false otherwise.
933
-			 * @param array $update_results The results of plugins update tasks.
934
-			 */
935
-			$notifications_enabled = apply_filters( 'auto_plugin_update_send_email', true, $update_results['plugin'] );
936
-
937
-			if ( $notifications_enabled ) {
938
-				foreach ( $update_results['plugin'] as $update_result ) {
939
-					if ( true === $update_result->result ) {
940
-						$successful_updates['plugin'][] = $update_result;
941
-					} else {
942
-						$failed_updates['plugin'][] = $update_result;
943
-					}
944
-				}
945
-			}
946
-		}
947
-
948
-		if ( ! empty( $update_results['theme'] ) ) {
949
-			/**
950
-			 * Filters whether to send an email following an automatic background theme update.
951
-			 *
952
-			 * @since 5.5.0
953
-			 * @since 5.5.1 Added the `$update_results` parameter.
954
-			 *
955
-			 * @param bool  $enabled        True if theme update notifications are enabled, false otherwise.
956
-			 * @param array $update_results The results of theme update tasks.
957
-			 */
958
-			$notifications_enabled = apply_filters( 'auto_theme_update_send_email', true, $update_results['theme'] );
959
-
960
-			if ( $notifications_enabled ) {
961
-				foreach ( $update_results['theme'] as $update_result ) {
962
-					if ( true === $update_result->result ) {
963
-						$successful_updates['theme'][] = $update_result;
964
-					} else {
965
-						$failed_updates['theme'][] = $update_result;
966
-					}
967
-				}
968
-			}
969
-		}
970
-
971
-		if ( empty( $successful_updates ) && empty( $failed_updates ) ) {
972
-			return;
973
-		}
974
-
975
-		if ( empty( $failed_updates ) ) {
976
-			$this->send_plugin_theme_email( 'success', $successful_updates, $failed_updates );
977
-		} elseif ( empty( $successful_updates ) ) {
978
-			$this->send_plugin_theme_email( 'fail', $successful_updates, $failed_updates );
979
-		} else {
980
-			$this->send_plugin_theme_email( 'mixed', $successful_updates, $failed_updates );
981
-		}
982
-	}
983
-
984
-	/**
985
-	 * Sends an email upon the completion or failure of a plugin or theme background update.
986
-	 *
987
-	 * @since 5.5.0
988
-	 *
989
-	 * @param string $type               The type of email to send. Can be one of 'success', 'fail', 'mixed'.
990
-	 * @param array  $successful_updates A list of updates that succeeded.
991
-	 * @param array  $failed_updates     A list of updates that failed.
992
-	 */
993
-	protected function send_plugin_theme_email( $type, $successful_updates, $failed_updates ) {
994
-		// No updates were attempted.
995
-		if ( empty( $successful_updates ) && empty( $failed_updates ) ) {
996
-			return;
997
-		}
998
-
999
-		$unique_failures     = false;
1000
-		$past_failure_emails = get_option( 'auto_plugin_theme_update_emails', array() );
1001
-
1002
-		/*
627
+        $send               = true;
628
+        $transient_failures = array( 'incompatible_archive', 'download_failed', 'insane_distro', 'locked' );
629
+        if ( in_array( $error_code, $transient_failures, true ) && ! get_site_option( 'auto_core_update_failed' ) ) {
630
+            wp_schedule_single_event( time() + HOUR_IN_SECONDS, 'wp_maybe_auto_update' );
631
+            $send = false;
632
+        }
633
+
634
+        $notified = get_site_option( 'auto_core_update_notified' );
635
+
636
+        // Don't notify if we've already notified the same email address of the same version of the same notification type.
637
+        if ( $notified
638
+            && 'fail' === $notified['type']
639
+            && get_site_option( 'admin_email' ) === $notified['email']
640
+            && $notified['version'] === $core_update->current
641
+        ) {
642
+            $send = false;
643
+        }
644
+
645
+        update_site_option(
646
+            'auto_core_update_failed',
647
+            array(
648
+                'attempted'  => $core_update->current,
649
+                'current'    => $wp_version,
650
+                'error_code' => $error_code,
651
+                'error_data' => $result->get_error_data(),
652
+                'timestamp'  => time(),
653
+                'retry'      => in_array( $error_code, $transient_failures, true ),
654
+            )
655
+        );
656
+
657
+        if ( $send ) {
658
+            $this->send_email( 'fail', $core_update, $result );
659
+        }
660
+    }
661
+
662
+    /**
663
+     * Sends an email upon the completion or failure of a background core update.
664
+     *
665
+     * @since 3.7.0
666
+     *
667
+     * @param string $type        The type of email to send. Can be one of 'success', 'fail', 'manual', 'critical'.
668
+     * @param object $core_update The update offer that was attempted.
669
+     * @param mixed  $result      Optional. The result for the core update. Can be WP_Error.
670
+     */
671
+    protected function send_email( $type, $core_update, $result = null ) {
672
+        update_site_option(
673
+            'auto_core_update_notified',
674
+            array(
675
+                'type'      => $type,
676
+                'email'     => get_site_option( 'admin_email' ),
677
+                'version'   => $core_update->current,
678
+                'timestamp' => time(),
679
+            )
680
+        );
681
+
682
+        $next_user_core_update = get_preferred_from_update_core();
683
+
684
+        // If the update transient is empty, use the update we just performed.
685
+        if ( ! $next_user_core_update ) {
686
+            $next_user_core_update = $core_update;
687
+        }
688
+
689
+        if ( 'upgrade' === $next_user_core_update->response
690
+            && version_compare( $next_user_core_update->version, $core_update->version, '>' )
691
+        ) {
692
+            $newer_version_available = true;
693
+        } else {
694
+            $newer_version_available = false;
695
+        }
696
+
697
+        /**
698
+         * Filters whether to send an email following an automatic background core update.
699
+         *
700
+         * @since 3.7.0
701
+         *
702
+         * @param bool   $send        Whether to send the email. Default true.
703
+         * @param string $type        The type of email to send. Can be one of
704
+         *                            'success', 'fail', 'critical'.
705
+         * @param object $core_update The update offer that was attempted.
706
+         * @param mixed  $result      The result for the core update. Can be WP_Error.
707
+         */
708
+        if ( 'manual' !== $type && ! apply_filters( 'auto_core_update_send_email', true, $type, $core_update, $result ) ) {
709
+            return;
710
+        }
711
+
712
+        switch ( $type ) {
713
+            case 'success': // We updated.
714
+                /* translators: Site updated notification email subject. 1: Site title, 2: WordPress version. */
715
+                $subject = __( '[%1$s] Your site has updated to WordPress %2$s' );
716
+                break;
717
+
718
+            case 'fail':   // We tried to update but couldn't.
719
+            case 'manual': // We can't update (and made no attempt).
720
+                /* translators: Update available notification email subject. 1: Site title, 2: WordPress version. */
721
+                $subject = __( '[%1$s] WordPress %2$s is available. Please update!' );
722
+                break;
723
+
724
+            case 'critical': // We tried to update, started to copy files, then things went wrong.
725
+                /* translators: Site down notification email subject. 1: Site title. */
726
+                $subject = __( '[%1$s] URGENT: Your site may be down due to a failed update' );
727
+                break;
728
+
729
+            default:
730
+                return;
731
+        }
732
+
733
+        // If the auto-update is not to the latest version, say that the current version of WP is available instead.
734
+        $version = 'success' === $type ? $core_update->current : $next_user_core_update->current;
735
+        $subject = sprintf( $subject, wp_specialchars_decode( get_option( 'blogname' ), ENT_QUOTES ), $version );
736
+
737
+        $body = '';
738
+
739
+        switch ( $type ) {
740
+            case 'success':
741
+                $body .= sprintf(
742
+                    /* translators: 1: Home URL, 2: WordPress version. */
743
+                    __( 'Howdy! Your site at %1$s has been updated automatically to WordPress %2$s.' ),
744
+                    home_url(),
745
+                    $core_update->current
746
+                );
747
+                $body .= "\n\n";
748
+                if ( ! $newer_version_available ) {
749
+                    $body .= __( 'No further action is needed on your part.' ) . ' ';
750
+                }
751
+
752
+                // Can only reference the About screen if their update was successful.
753
+                list( $about_version ) = explode( '-', $core_update->current, 2 );
754
+                /* translators: %s: WordPress version. */
755
+                $body .= sprintf( __( 'For more on version %s, see the About WordPress screen:' ), $about_version );
756
+                $body .= "\n" . admin_url( 'about.php' );
757
+
758
+                if ( $newer_version_available ) {
759
+                    /* translators: %s: WordPress latest version. */
760
+                    $body .= "\n\n" . sprintf( __( 'WordPress %s is also now available.' ), $next_user_core_update->current ) . ' ';
761
+                    $body .= __( 'Updating is easy and only takes a few moments:' );
762
+                    $body .= "\n" . network_admin_url( 'update-core.php' );
763
+                }
764
+
765
+                break;
766
+
767
+            case 'fail':
768
+            case 'manual':
769
+                $body .= sprintf(
770
+                    /* translators: 1: Home URL, 2: WordPress version. */
771
+                    __( 'Please update your site at %1$s to WordPress %2$s.' ),
772
+                    home_url(),
773
+                    $next_user_core_update->current
774
+                );
775
+
776
+                $body .= "\n\n";
777
+
778
+                // Don't show this message if there is a newer version available.
779
+                // Potential for confusion, and also not useful for them to know at this point.
780
+                if ( 'fail' === $type && ! $newer_version_available ) {
781
+                    $body .= __( 'An attempt was made, but your site could not be updated automatically.' ) . ' ';
782
+                }
783
+
784
+                $body .= __( 'Updating is easy and only takes a few moments:' );
785
+                $body .= "\n" . network_admin_url( 'update-core.php' );
786
+                break;
787
+
788
+            case 'critical':
789
+                if ( $newer_version_available ) {
790
+                    $body .= sprintf(
791
+                        /* translators: 1: Home URL, 2: WordPress version. */
792
+                        __( 'Your site at %1$s experienced a critical failure while trying to update WordPress to version %2$s.' ),
793
+                        home_url(),
794
+                        $core_update->current
795
+                    );
796
+                } else {
797
+                    $body .= sprintf(
798
+                        /* translators: 1: Home URL, 2: WordPress latest version. */
799
+                        __( 'Your site at %1$s experienced a critical failure while trying to update to the latest version of WordPress, %2$s.' ),
800
+                        home_url(),
801
+                        $core_update->current
802
+                    );
803
+                }
804
+
805
+                $body .= "\n\n" . __( "This means your site may be offline or broken. Don't panic; this can be fixed." );
806
+
807
+                $body .= "\n\n" . __( "Please check out your site now. It's possible that everything is working. If it says you need to update, you should do so:" );
808
+                $body .= "\n" . network_admin_url( 'update-core.php' );
809
+                break;
810
+        }
811
+
812
+        $critical_support = 'critical' === $type && ! empty( $core_update->support_email );
813
+        if ( $critical_support ) {
814
+            // Support offer if available.
815
+            $body .= "\n\n" . sprintf(
816
+                /* translators: %s: Support email address. */
817
+                __( 'The WordPress team is willing to help you. Forward this email to %s and the team will work with you to make sure your site is working.' ),
818
+                $core_update->support_email
819
+            );
820
+        } else {
821
+            // Add a note about the support forums.
822
+            $body .= "\n\n" . __( 'If you experience any issues or need support, the volunteers in the WordPress.org support forums may be able to help.' );
823
+            $body .= "\n" . __( 'https://wordpress.org/support/forums/' );
824
+        }
825
+
826
+        // Updates are important!
827
+        if ( 'success' !== $type || $newer_version_available ) {
828
+            $body .= "\n\n" . __( 'Keeping your site updated is important for security. It also makes the internet a safer place for you and your readers.' );
829
+        }
830
+
831
+        if ( $critical_support ) {
832
+            $body .= ' ' . __( "If you reach out to us, we'll also ensure you'll never have this problem again." );
833
+        }
834
+
835
+        // If things are successful and we're now on the latest, mention plugins and themes if any are out of date.
836
+        if ( 'success' === $type && ! $newer_version_available && ( get_plugin_updates() || get_theme_updates() ) ) {
837
+            $body .= "\n\n" . __( 'You also have some plugins or themes with updates available. Update them now:' );
838
+            $body .= "\n" . network_admin_url();
839
+        }
840
+
841
+        $body .= "\n\n" . __( 'The WordPress Team' ) . "\n";
842
+
843
+        if ( 'critical' === $type && is_wp_error( $result ) ) {
844
+            $body .= "\n***\n\n";
845
+            /* translators: %s: WordPress version. */
846
+            $body .= sprintf( __( 'Your site was running version %s.' ), get_bloginfo( 'version' ) );
847
+            $body .= ' ' . __( 'Some data that describes the error your site encountered has been put together.' );
848
+            $body .= ' ' . __( 'Your hosting company, support forum volunteers, or a friendly developer may be able to use this information to help you:' );
849
+
850
+            // If we had a rollback and we're still critical, then the rollback failed too.
851
+            // Loop through all errors (the main WP_Error, the update result, the rollback result) for code, data, etc.
852
+            if ( 'rollback_was_required' === $result->get_error_code() ) {
853
+                $errors = array( $result, $result->get_error_data()->update, $result->get_error_data()->rollback );
854
+            } else {
855
+                $errors = array( $result );
856
+            }
857
+
858
+            foreach ( $errors as $error ) {
859
+                if ( ! is_wp_error( $error ) ) {
860
+                    continue;
861
+                }
862
+
863
+                $error_code = $error->get_error_code();
864
+                /* translators: %s: Error code. */
865
+                $body .= "\n\n" . sprintf( __( 'Error code: %s' ), $error_code );
866
+
867
+                if ( 'rollback_was_required' === $error_code ) {
868
+                    continue;
869
+                }
870
+
871
+                if ( $error->get_error_message() ) {
872
+                    $body .= "\n" . $error->get_error_message();
873
+                }
874
+
875
+                $error_data = $error->get_error_data();
876
+                if ( $error_data ) {
877
+                    $body .= "\n" . implode( ', ', (array) $error_data );
878
+                }
879
+            }
880
+
881
+            $body .= "\n";
882
+        }
883
+
884
+        $to      = get_site_option( 'admin_email' );
885
+        $headers = '';
886
+
887
+        $email = compact( 'to', 'subject', 'body', 'headers' );
888
+
889
+        /**
890
+         * Filters the email sent following an automatic background core update.
891
+         *
892
+         * @since 3.7.0
893
+         *
894
+         * @param array $email {
895
+         *     Array of email arguments that will be passed to wp_mail().
896
+         *
897
+         *     @type string $to      The email recipient. An array of emails
898
+         *                            can be returned, as handled by wp_mail().
899
+         *     @type string $subject The email's subject.
900
+         *     @type string $body    The email message body.
901
+         *     @type string $headers Any email headers, defaults to no headers.
902
+         * }
903
+         * @param string $type        The type of email being sent. Can be one of
904
+         *                            'success', 'fail', 'manual', 'critical'.
905
+         * @param object $core_update The update offer that was attempted.
906
+         * @param mixed  $result      The result for the core update. Can be WP_Error.
907
+         */
908
+        $email = apply_filters( 'auto_core_update_email', $email, $type, $core_update, $result );
909
+
910
+        wp_mail( $email['to'], wp_specialchars_decode( $email['subject'] ), $email['body'], $email['headers'] );
911
+    }
912
+
913
+
914
+    /**
915
+     * If we tried to perform plugin or theme updates, check if we should send an email.
916
+     *
917
+     * @since 5.5.0
918
+     *
919
+     * @param array $update_results The results of update tasks.
920
+     */
921
+    protected function after_plugin_theme_update( $update_results ) {
922
+        $successful_updates = array();
923
+        $failed_updates     = array();
924
+
925
+        if ( ! empty( $update_results['plugin'] ) ) {
926
+            /**
927
+             * Filters whether to send an email following an automatic background plugin update.
928
+             *
929
+             * @since 5.5.0
930
+             * @since 5.5.1 Added the `$update_results` parameter.
931
+             *
932
+             * @param bool  $enabled        True if plugin update notifications are enabled, false otherwise.
933
+             * @param array $update_results The results of plugins update tasks.
934
+             */
935
+            $notifications_enabled = apply_filters( 'auto_plugin_update_send_email', true, $update_results['plugin'] );
936
+
937
+            if ( $notifications_enabled ) {
938
+                foreach ( $update_results['plugin'] as $update_result ) {
939
+                    if ( true === $update_result->result ) {
940
+                        $successful_updates['plugin'][] = $update_result;
941
+                    } else {
942
+                        $failed_updates['plugin'][] = $update_result;
943
+                    }
944
+                }
945
+            }
946
+        }
947
+
948
+        if ( ! empty( $update_results['theme'] ) ) {
949
+            /**
950
+             * Filters whether to send an email following an automatic background theme update.
951
+             *
952
+             * @since 5.5.0
953
+             * @since 5.5.1 Added the `$update_results` parameter.
954
+             *
955
+             * @param bool  $enabled        True if theme update notifications are enabled, false otherwise.
956
+             * @param array $update_results The results of theme update tasks.
957
+             */
958
+            $notifications_enabled = apply_filters( 'auto_theme_update_send_email', true, $update_results['theme'] );
959
+
960
+            if ( $notifications_enabled ) {
961
+                foreach ( $update_results['theme'] as $update_result ) {
962
+                    if ( true === $update_result->result ) {
963
+                        $successful_updates['theme'][] = $update_result;
964
+                    } else {
965
+                        $failed_updates['theme'][] = $update_result;
966
+                    }
967
+                }
968
+            }
969
+        }
970
+
971
+        if ( empty( $successful_updates ) && empty( $failed_updates ) ) {
972
+            return;
973
+        }
974
+
975
+        if ( empty( $failed_updates ) ) {
976
+            $this->send_plugin_theme_email( 'success', $successful_updates, $failed_updates );
977
+        } elseif ( empty( $successful_updates ) ) {
978
+            $this->send_plugin_theme_email( 'fail', $successful_updates, $failed_updates );
979
+        } else {
980
+            $this->send_plugin_theme_email( 'mixed', $successful_updates, $failed_updates );
981
+        }
982
+    }
983
+
984
+    /**
985
+     * Sends an email upon the completion or failure of a plugin or theme background update.
986
+     *
987
+     * @since 5.5.0
988
+     *
989
+     * @param string $type               The type of email to send. Can be one of 'success', 'fail', 'mixed'.
990
+     * @param array  $successful_updates A list of updates that succeeded.
991
+     * @param array  $failed_updates     A list of updates that failed.
992
+     */
993
+    protected function send_plugin_theme_email( $type, $successful_updates, $failed_updates ) {
994
+        // No updates were attempted.
995
+        if ( empty( $successful_updates ) && empty( $failed_updates ) ) {
996
+            return;
997
+        }
998
+
999
+        $unique_failures     = false;
1000
+        $past_failure_emails = get_option( 'auto_plugin_theme_update_emails', array() );
1001
+
1002
+        /*
1003 1003
 		 * When only failures have occurred, an email should only be sent if there are unique failures.
1004 1004
 		 * A failure is considered unique if an email has not been sent for an update attempt failure
1005 1005
 		 * to a plugin or theme with the same new_version.
1006 1006
 		 */
1007
-		if ( 'fail' === $type ) {
1008
-			foreach ( $failed_updates as $update_type => $failures ) {
1009
-				foreach ( $failures as $failed_update ) {
1010
-					if ( ! isset( $past_failure_emails[ $failed_update->item->{$update_type} ] ) ) {
1011
-						$unique_failures = true;
1012
-						continue;
1013
-					}
1014
-
1015
-					// Check that the failure represents a new failure based on the new_version.
1016
-					if ( version_compare( $past_failure_emails[ $failed_update->item->{$update_type} ], $failed_update->item->new_version, '<' ) ) {
1017
-						$unique_failures = true;
1018
-					}
1019
-				}
1020
-			}
1021
-
1022
-			if ( ! $unique_failures ) {
1023
-				return;
1024
-			}
1025
-		}
1026
-
1027
-		$body               = array();
1028
-		$successful_plugins = ( ! empty( $successful_updates['plugin'] ) );
1029
-		$successful_themes  = ( ! empty( $successful_updates['theme'] ) );
1030
-		$failed_plugins     = ( ! empty( $failed_updates['plugin'] ) );
1031
-		$failed_themes      = ( ! empty( $failed_updates['theme'] ) );
1032
-
1033
-		switch ( $type ) {
1034
-			case 'success':
1035
-				if ( $successful_plugins && $successful_themes ) {
1036
-					/* translators: %s: Site title. */
1037
-					$subject = __( '[%s] Some plugins and themes have automatically updated' );
1038
-					$body[]  = sprintf(
1039
-						/* translators: %s: Home URL. */
1040
-						__( 'Howdy! Some plugins and themes have automatically updated to their latest versions on your site at %s. No further action is needed on your part.' ),
1041
-						home_url()
1042
-					);
1043
-				} elseif ( $successful_plugins ) {
1044
-					/* translators: %s: Site title. */
1045
-					$subject = __( '[%s] Some plugins were automatically updated' );
1046
-					$body[]  = sprintf(
1047
-						/* translators: %s: Home URL. */
1048
-						__( 'Howdy! Some plugins have automatically updated to their latest versions on your site at %s. No further action is needed on your part.' ),
1049
-						home_url()
1050
-					);
1051
-				} else {
1052
-					/* translators: %s: Site title. */
1053
-					$subject = __( '[%s] Some themes were automatically updated' );
1054
-					$body[]  = sprintf(
1055
-						/* translators: %s: Home URL. */
1056
-						__( 'Howdy! Some themes have automatically updated to their latest versions on your site at %s. No further action is needed on your part.' ),
1057
-						home_url()
1058
-					);
1059
-				}
1060
-
1061
-				break;
1062
-			case 'fail':
1063
-			case 'mixed':
1064
-				if ( $failed_plugins && $failed_themes ) {
1065
-					/* translators: %s: Site title. */
1066
-					$subject = __( '[%s] Some plugins and themes have failed to update' );
1067
-					$body[]  = sprintf(
1068
-						/* translators: %s: Home URL. */
1069
-						__( 'Howdy! Plugins and themes failed to update on your site at %s.' ),
1070
-						home_url()
1071
-					);
1072
-				} elseif ( $failed_plugins ) {
1073
-					/* translators: %s: Site title. */
1074
-					$subject = __( '[%s] Some plugins have failed to update' );
1075
-					$body[]  = sprintf(
1076
-						/* translators: %s: Home URL. */
1077
-						__( 'Howdy! Plugins failed to update on your site at %s.' ),
1078
-						home_url()
1079
-					);
1080
-				} else {
1081
-					/* translators: %s: Site title. */
1082
-					$subject = __( '[%s] Some themes have failed to update' );
1083
-					$body[]  = sprintf(
1084
-						/* translators: %s: Home URL. */
1085
-						__( 'Howdy! Themes failed to update on your site at %s.' ),
1086
-						home_url()
1087
-					);
1088
-				}
1089
-
1090
-				break;
1091
-		}
1092
-
1093
-		if ( in_array( $type, array( 'fail', 'mixed' ), true ) ) {
1094
-			$body[] = "\n";
1095
-			$body[] = __( 'Please check your site now. It’s possible that everything is working. If there are updates available, you should update.' );
1096
-			$body[] = "\n";
1097
-
1098
-			// List failed plugin updates.
1099
-			if ( ! empty( $failed_updates['plugin'] ) ) {
1100
-				$body[] = __( 'These plugins failed to update:' );
1101
-
1102
-				foreach ( $failed_updates['plugin'] as $item ) {
1103
-					if ( $item->item->current_version ) {
1104
-						$body[] = sprintf(
1105
-							/* translators: 1: Plugin name, 2: Current version number, 3: New version number. */
1106
-							__( '- %1$s (from version %2$s to %3$s)' ),
1107
-							$item->name,
1108
-							$item->item->current_version,
1109
-							$item->item->new_version
1110
-						);
1111
-					} else {
1112
-						$body[] = sprintf(
1113
-							/* translators: 1: Plugin name, 2: Version number. */
1114
-							__( '- %1$s version %2$s' ),
1115
-							$item->name,
1116
-							$item->item->new_version
1117
-						);
1118
-					}
1119
-
1120
-					$past_failure_emails[ $item->item->plugin ] = $item->item->new_version;
1121
-				}
1122
-
1123
-				$body[] = "\n";
1124
-			}
1125
-
1126
-			// List failed theme updates.
1127
-			if ( ! empty( $failed_updates['theme'] ) ) {
1128
-				$body[] = __( 'These themes failed to update:' );
1129
-
1130
-				foreach ( $failed_updates['theme'] as $item ) {
1131
-					if ( $item->item->current_version ) {
1132
-						$body[] = sprintf(
1133
-							/* translators: 1: Theme name, 2: Current version number, 3: New version number. */
1134
-							__( '- %1$s (from version %2$s to %3$s)' ),
1135
-							$item->name,
1136
-							$item->item->current_version,
1137
-							$item->item->new_version
1138
-						);
1139
-					} else {
1140
-						$body[] = sprintf(
1141
-							/* translators: 1: Theme name, 2: Version number. */
1142
-							__( '- %1$s version %2$s' ),
1143
-							$item->name,
1144
-							$item->item->new_version
1145
-						);
1146
-					}
1147
-
1148
-					$past_failure_emails[ $item->item->theme ] = $item->item->new_version;
1149
-				}
1150
-
1151
-				$body[] = "\n";
1152
-			}
1153
-		}
1154
-
1155
-		// List successful updates.
1156
-		if ( in_array( $type, array( 'success', 'mixed' ), true ) ) {
1157
-			$body[] = "\n";
1158
-
1159
-			// List successful plugin updates.
1160
-			if ( ! empty( $successful_updates['plugin'] ) ) {
1161
-				$body[] = __( 'These plugins are now up to date:' );
1162
-
1163
-				foreach ( $successful_updates['plugin'] as $item ) {
1164
-					if ( $item->item->current_version ) {
1165
-						$body[] = sprintf(
1166
-							/* translators: 1: Plugin name, 2: Current version number, 3: New version number. */
1167
-							__( '- %1$s (from version %2$s to %3$s)' ),
1168
-							$item->name,
1169
-							$item->item->current_version,
1170
-							$item->item->new_version
1171
-						);
1172
-					} else {
1173
-						$body[] = sprintf(
1174
-							/* translators: 1: Plugin name, 2: Version number. */
1175
-							__( '- %1$s version %2$s' ),
1176
-							$item->name,
1177
-							$item->item->new_version
1178
-						);
1179
-					}
1180
-
1181
-					unset( $past_failure_emails[ $item->item->plugin ] );
1182
-				}
1183
-
1184
-				$body[] = "\n";
1185
-			}
1186
-
1187
-			// List successful theme updates.
1188
-			if ( ! empty( $successful_updates['theme'] ) ) {
1189
-				$body[] = __( 'These themes are now up to date:' );
1190
-
1191
-				foreach ( $successful_updates['theme'] as $item ) {
1192
-					if ( $item->item->current_version ) {
1193
-						$body[] = sprintf(
1194
-							/* translators: 1: Theme name, 2: Current version number, 3: New version number. */
1195
-							__( '- %1$s (from version %2$s to %3$s)' ),
1196
-							$item->name,
1197
-							$item->item->current_version,
1198
-							$item->item->new_version
1199
-						);
1200
-					} else {
1201
-						$body[] = sprintf(
1202
-							/* translators: 1: Theme name, 2: Version number. */
1203
-							__( '- %1$s version %2$s' ),
1204
-							$item->name,
1205
-							$item->item->new_version
1206
-						);
1207
-					}
1208
-
1209
-					unset( $past_failure_emails[ $item->item->theme ] );
1210
-				}
1211
-
1212
-				$body[] = "\n";
1213
-			}
1214
-		}
1215
-
1216
-		if ( $failed_plugins ) {
1217
-			$body[] = sprintf(
1218
-				/* translators: %s: Plugins screen URL. */
1219
-				__( 'To manage plugins on your site, visit the Plugins page: %s' ),
1220
-				admin_url( 'plugins.php' )
1221
-			);
1222
-			$body[] = "\n";
1223
-		}
1224
-
1225
-		if ( $failed_themes ) {
1226
-			$body[] = sprintf(
1227
-				/* translators: %s: Themes screen URL. */
1228
-				__( 'To manage themes on your site, visit the Themes page: %s' ),
1229
-				admin_url( 'themes.php' )
1230
-			);
1231
-			$body[] = "\n";
1232
-		}
1233
-
1234
-		// Add a note about the support forums.
1235
-		$body[] = __( 'If you experience any issues or need support, the volunteers in the WordPress.org support forums may be able to help.' );
1236
-		$body[] = __( 'https://wordpress.org/support/forums/' );
1237
-		$body[] = "\n" . __( 'The WordPress Team' );
1238
-
1239
-		if ( '' !== get_option( 'blogname' ) ) {
1240
-			$site_title = wp_specialchars_decode( get_option( 'blogname' ), ENT_QUOTES );
1241
-		} else {
1242
-			$site_title = parse_url( home_url(), PHP_URL_HOST );
1243
-		}
1244
-
1245
-		$body    = implode( "\n", $body );
1246
-		$to      = get_site_option( 'admin_email' );
1247
-		$subject = sprintf( $subject, $site_title );
1248
-		$headers = '';
1249
-
1250
-		$email = compact( 'to', 'subject', 'body', 'headers' );
1251
-
1252
-		/**
1253
-		 * Filters the email sent following an automatic background update for plugins and themes.
1254
-		 *
1255
-		 * @since 5.5.0
1256
-		 *
1257
-		 * @param array  $email {
1258
-		 *     Array of email arguments that will be passed to wp_mail().
1259
-		 *
1260
-		 *     @type string $to      The email recipient. An array of emails
1261
-		 *                           can be returned, as handled by wp_mail().
1262
-		 *     @type string $subject The email's subject.
1263
-		 *     @type string $body    The email message body.
1264
-		 *     @type string $headers Any email headers, defaults to no headers.
1265
-		 * }
1266
-		 * @param string $type               The type of email being sent. Can be one of 'success', 'fail', 'mixed'.
1267
-		 * @param array  $successful_updates A list of updates that succeeded.
1268
-		 * @param array  $failed_updates     A list of updates that failed.
1269
-		 */
1270
-		$email = apply_filters( 'auto_plugin_theme_update_email', $email, $type, $successful_updates, $failed_updates );
1271
-
1272
-		$result = wp_mail( $email['to'], wp_specialchars_decode( $email['subject'] ), $email['body'], $email['headers'] );
1273
-
1274
-		if ( $result ) {
1275
-			update_option( 'auto_plugin_theme_update_emails', $past_failure_emails );
1276
-		}
1277
-	}
1278
-
1279
-	/**
1280
-	 * Prepares and sends an email of a full log of background update results, useful for debugging and geekery.
1281
-	 *
1282
-	 * @since 3.7.0
1283
-	 */
1284
-	protected function send_debug_email() {
1285
-		$update_count = 0;
1286
-		foreach ( $this->update_results as $type => $updates ) {
1287
-			$update_count += count( $updates );
1288
-		}
1289
-
1290
-		$body     = array();
1291
-		$failures = 0;
1292
-
1293
-		/* translators: %s: Network home URL. */
1294
-		$body[] = sprintf( __( 'WordPress site: %s' ), network_home_url( '/' ) );
1295
-
1296
-		// Core.
1297
-		if ( isset( $this->update_results['core'] ) ) {
1298
-			$result = $this->update_results['core'][0];
1299
-
1300
-			if ( $result->result && ! is_wp_error( $result->result ) ) {
1301
-				/* translators: %s: WordPress version. */
1302
-				$body[] = sprintf( __( 'SUCCESS: WordPress was successfully updated to %s' ), $result->name );
1303
-			} else {
1304
-				/* translators: %s: WordPress version. */
1305
-				$body[] = sprintf( __( 'FAILED: WordPress failed to update to %s' ), $result->name );
1306
-				$failures++;
1307
-			}
1308
-
1309
-			$body[] = '';
1310
-		}
1311
-
1312
-		// Plugins, Themes, Translations.
1313
-		foreach ( array( 'plugin', 'theme', 'translation' ) as $type ) {
1314
-			if ( ! isset( $this->update_results[ $type ] ) ) {
1315
-				continue;
1316
-			}
1317
-
1318
-			$success_items = wp_list_filter( $this->update_results[ $type ], array( 'result' => true ) );
1319
-
1320
-			if ( $success_items ) {
1321
-				$messages = array(
1322
-					'plugin'      => __( 'The following plugins were successfully updated:' ),
1323
-					'theme'       => __( 'The following themes were successfully updated:' ),
1324
-					'translation' => __( 'The following translations were successfully updated:' ),
1325
-				);
1326
-
1327
-				$body[] = $messages[ $type ];
1328
-				foreach ( wp_list_pluck( $success_items, 'name' ) as $name ) {
1329
-					/* translators: %s: Name of plugin / theme / translation. */
1330
-					$body[] = ' * ' . sprintf( __( 'SUCCESS: %s' ), $name );
1331
-				}
1332
-			}
1333
-
1334
-			if ( $success_items !== $this->update_results[ $type ] ) {
1335
-				// Failed updates.
1336
-				$messages = array(
1337
-					'plugin'      => __( 'The following plugins failed to update:' ),
1338
-					'theme'       => __( 'The following themes failed to update:' ),
1339
-					'translation' => __( 'The following translations failed to update:' ),
1340
-				);
1341
-
1342
-				$body[] = $messages[ $type ];
1343
-
1344
-				foreach ( $this->update_results[ $type ] as $item ) {
1345
-					if ( ! $item->result || is_wp_error( $item->result ) ) {
1346
-						/* translators: %s: Name of plugin / theme / translation. */
1347
-						$body[] = ' * ' . sprintf( __( 'FAILED: %s' ), $item->name );
1348
-						$failures++;
1349
-					}
1350
-				}
1351
-			}
1352
-
1353
-			$body[] = '';
1354
-		}
1355
-
1356
-		if ( '' !== get_bloginfo( 'name' ) ) {
1357
-			$site_title = wp_specialchars_decode( get_bloginfo( 'name' ), ENT_QUOTES );
1358
-		} else {
1359
-			$site_title = parse_url( home_url(), PHP_URL_HOST );
1360
-		}
1361
-
1362
-		if ( $failures ) {
1363
-			$body[] = trim(
1364
-				__(
1365
-					"BETA TESTING?
1007
+        if ( 'fail' === $type ) {
1008
+            foreach ( $failed_updates as $update_type => $failures ) {
1009
+                foreach ( $failures as $failed_update ) {
1010
+                    if ( ! isset( $past_failure_emails[ $failed_update->item->{$update_type} ] ) ) {
1011
+                        $unique_failures = true;
1012
+                        continue;
1013
+                    }
1014
+
1015
+                    // Check that the failure represents a new failure based on the new_version.
1016
+                    if ( version_compare( $past_failure_emails[ $failed_update->item->{$update_type} ], $failed_update->item->new_version, '<' ) ) {
1017
+                        $unique_failures = true;
1018
+                    }
1019
+                }
1020
+            }
1021
+
1022
+            if ( ! $unique_failures ) {
1023
+                return;
1024
+            }
1025
+        }
1026
+
1027
+        $body               = array();
1028
+        $successful_plugins = ( ! empty( $successful_updates['plugin'] ) );
1029
+        $successful_themes  = ( ! empty( $successful_updates['theme'] ) );
1030
+        $failed_plugins     = ( ! empty( $failed_updates['plugin'] ) );
1031
+        $failed_themes      = ( ! empty( $failed_updates['theme'] ) );
1032
+
1033
+        switch ( $type ) {
1034
+            case 'success':
1035
+                if ( $successful_plugins && $successful_themes ) {
1036
+                    /* translators: %s: Site title. */
1037
+                    $subject = __( '[%s] Some plugins and themes have automatically updated' );
1038
+                    $body[]  = sprintf(
1039
+                        /* translators: %s: Home URL. */
1040
+                        __( 'Howdy! Some plugins and themes have automatically updated to their latest versions on your site at %s. No further action is needed on your part.' ),
1041
+                        home_url()
1042
+                    );
1043
+                } elseif ( $successful_plugins ) {
1044
+                    /* translators: %s: Site title. */
1045
+                    $subject = __( '[%s] Some plugins were automatically updated' );
1046
+                    $body[]  = sprintf(
1047
+                        /* translators: %s: Home URL. */
1048
+                        __( 'Howdy! Some plugins have automatically updated to their latest versions on your site at %s. No further action is needed on your part.' ),
1049
+                        home_url()
1050
+                    );
1051
+                } else {
1052
+                    /* translators: %s: Site title. */
1053
+                    $subject = __( '[%s] Some themes were automatically updated' );
1054
+                    $body[]  = sprintf(
1055
+                        /* translators: %s: Home URL. */
1056
+                        __( 'Howdy! Some themes have automatically updated to their latest versions on your site at %s. No further action is needed on your part.' ),
1057
+                        home_url()
1058
+                    );
1059
+                }
1060
+
1061
+                break;
1062
+            case 'fail':
1063
+            case 'mixed':
1064
+                if ( $failed_plugins && $failed_themes ) {
1065
+                    /* translators: %s: Site title. */
1066
+                    $subject = __( '[%s] Some plugins and themes have failed to update' );
1067
+                    $body[]  = sprintf(
1068
+                        /* translators: %s: Home URL. */
1069
+                        __( 'Howdy! Plugins and themes failed to update on your site at %s.' ),
1070
+                        home_url()
1071
+                    );
1072
+                } elseif ( $failed_plugins ) {
1073
+                    /* translators: %s: Site title. */
1074
+                    $subject = __( '[%s] Some plugins have failed to update' );
1075
+                    $body[]  = sprintf(
1076
+                        /* translators: %s: Home URL. */
1077
+                        __( 'Howdy! Plugins failed to update on your site at %s.' ),
1078
+                        home_url()
1079
+                    );
1080
+                } else {
1081
+                    /* translators: %s: Site title. */
1082
+                    $subject = __( '[%s] Some themes have failed to update' );
1083
+                    $body[]  = sprintf(
1084
+                        /* translators: %s: Home URL. */
1085
+                        __( 'Howdy! Themes failed to update on your site at %s.' ),
1086
+                        home_url()
1087
+                    );
1088
+                }
1089
+
1090
+                break;
1091
+        }
1092
+
1093
+        if ( in_array( $type, array( 'fail', 'mixed' ), true ) ) {
1094
+            $body[] = "\n";
1095
+            $body[] = __( 'Please check your site now. It’s possible that everything is working. If there are updates available, you should update.' );
1096
+            $body[] = "\n";
1097
+
1098
+            // List failed plugin updates.
1099
+            if ( ! empty( $failed_updates['plugin'] ) ) {
1100
+                $body[] = __( 'These plugins failed to update:' );
1101
+
1102
+                foreach ( $failed_updates['plugin'] as $item ) {
1103
+                    if ( $item->item->current_version ) {
1104
+                        $body[] = sprintf(
1105
+                            /* translators: 1: Plugin name, 2: Current version number, 3: New version number. */
1106
+                            __( '- %1$s (from version %2$s to %3$s)' ),
1107
+                            $item->name,
1108
+                            $item->item->current_version,
1109
+                            $item->item->new_version
1110
+                        );
1111
+                    } else {
1112
+                        $body[] = sprintf(
1113
+                            /* translators: 1: Plugin name, 2: Version number. */
1114
+                            __( '- %1$s version %2$s' ),
1115
+                            $item->name,
1116
+                            $item->item->new_version
1117
+                        );
1118
+                    }
1119
+
1120
+                    $past_failure_emails[ $item->item->plugin ] = $item->item->new_version;
1121
+                }
1122
+
1123
+                $body[] = "\n";
1124
+            }
1125
+
1126
+            // List failed theme updates.
1127
+            if ( ! empty( $failed_updates['theme'] ) ) {
1128
+                $body[] = __( 'These themes failed to update:' );
1129
+
1130
+                foreach ( $failed_updates['theme'] as $item ) {
1131
+                    if ( $item->item->current_version ) {
1132
+                        $body[] = sprintf(
1133
+                            /* translators: 1: Theme name, 2: Current version number, 3: New version number. */
1134
+                            __( '- %1$s (from version %2$s to %3$s)' ),
1135
+                            $item->name,
1136
+                            $item->item->current_version,
1137
+                            $item->item->new_version
1138
+                        );
1139
+                    } else {
1140
+                        $body[] = sprintf(
1141
+                            /* translators: 1: Theme name, 2: Version number. */
1142
+                            __( '- %1$s version %2$s' ),
1143
+                            $item->name,
1144
+                            $item->item->new_version
1145
+                        );
1146
+                    }
1147
+
1148
+                    $past_failure_emails[ $item->item->theme ] = $item->item->new_version;
1149
+                }
1150
+
1151
+                $body[] = "\n";
1152
+            }
1153
+        }
1154
+
1155
+        // List successful updates.
1156
+        if ( in_array( $type, array( 'success', 'mixed' ), true ) ) {
1157
+            $body[] = "\n";
1158
+
1159
+            // List successful plugin updates.
1160
+            if ( ! empty( $successful_updates['plugin'] ) ) {
1161
+                $body[] = __( 'These plugins are now up to date:' );
1162
+
1163
+                foreach ( $successful_updates['plugin'] as $item ) {
1164
+                    if ( $item->item->current_version ) {
1165
+                        $body[] = sprintf(
1166
+                            /* translators: 1: Plugin name, 2: Current version number, 3: New version number. */
1167
+                            __( '- %1$s (from version %2$s to %3$s)' ),
1168
+                            $item->name,
1169
+                            $item->item->current_version,
1170
+                            $item->item->new_version
1171
+                        );
1172
+                    } else {
1173
+                        $body[] = sprintf(
1174
+                            /* translators: 1: Plugin name, 2: Version number. */
1175
+                            __( '- %1$s version %2$s' ),
1176
+                            $item->name,
1177
+                            $item->item->new_version
1178
+                        );
1179
+                    }
1180
+
1181
+                    unset( $past_failure_emails[ $item->item->plugin ] );
1182
+                }
1183
+
1184
+                $body[] = "\n";
1185
+            }
1186
+
1187
+            // List successful theme updates.
1188
+            if ( ! empty( $successful_updates['theme'] ) ) {
1189
+                $body[] = __( 'These themes are now up to date:' );
1190
+
1191
+                foreach ( $successful_updates['theme'] as $item ) {
1192
+                    if ( $item->item->current_version ) {
1193
+                        $body[] = sprintf(
1194
+                            /* translators: 1: Theme name, 2: Current version number, 3: New version number. */
1195
+                            __( '- %1$s (from version %2$s to %3$s)' ),
1196
+                            $item->name,
1197
+                            $item->item->current_version,
1198
+                            $item->item->new_version
1199
+                        );
1200
+                    } else {
1201
+                        $body[] = sprintf(
1202
+                            /* translators: 1: Theme name, 2: Version number. */
1203
+                            __( '- %1$s version %2$s' ),
1204
+                            $item->name,
1205
+                            $item->item->new_version
1206
+                        );
1207
+                    }
1208
+
1209
+                    unset( $past_failure_emails[ $item->item->theme ] );
1210
+                }
1211
+
1212
+                $body[] = "\n";
1213
+            }
1214
+        }
1215
+
1216
+        if ( $failed_plugins ) {
1217
+            $body[] = sprintf(
1218
+                /* translators: %s: Plugins screen URL. */
1219
+                __( 'To manage plugins on your site, visit the Plugins page: %s' ),
1220
+                admin_url( 'plugins.php' )
1221
+            );
1222
+            $body[] = "\n";
1223
+        }
1224
+
1225
+        if ( $failed_themes ) {
1226
+            $body[] = sprintf(
1227
+                /* translators: %s: Themes screen URL. */
1228
+                __( 'To manage themes on your site, visit the Themes page: %s' ),
1229
+                admin_url( 'themes.php' )
1230
+            );
1231
+            $body[] = "\n";
1232
+        }
1233
+
1234
+        // Add a note about the support forums.
1235
+        $body[] = __( 'If you experience any issues or need support, the volunteers in the WordPress.org support forums may be able to help.' );
1236
+        $body[] = __( 'https://wordpress.org/support/forums/' );
1237
+        $body[] = "\n" . __( 'The WordPress Team' );
1238
+
1239
+        if ( '' !== get_option( 'blogname' ) ) {
1240
+            $site_title = wp_specialchars_decode( get_option( 'blogname' ), ENT_QUOTES );
1241
+        } else {
1242
+            $site_title = parse_url( home_url(), PHP_URL_HOST );
1243
+        }
1244
+
1245
+        $body    = implode( "\n", $body );
1246
+        $to      = get_site_option( 'admin_email' );
1247
+        $subject = sprintf( $subject, $site_title );
1248
+        $headers = '';
1249
+
1250
+        $email = compact( 'to', 'subject', 'body', 'headers' );
1251
+
1252
+        /**
1253
+         * Filters the email sent following an automatic background update for plugins and themes.
1254
+         *
1255
+         * @since 5.5.0
1256
+         *
1257
+         * @param array  $email {
1258
+         *     Array of email arguments that will be passed to wp_mail().
1259
+         *
1260
+         *     @type string $to      The email recipient. An array of emails
1261
+         *                           can be returned, as handled by wp_mail().
1262
+         *     @type string $subject The email's subject.
1263
+         *     @type string $body    The email message body.
1264
+         *     @type string $headers Any email headers, defaults to no headers.
1265
+         * }
1266
+         * @param string $type               The type of email being sent. Can be one of 'success', 'fail', 'mixed'.
1267
+         * @param array  $successful_updates A list of updates that succeeded.
1268
+         * @param array  $failed_updates     A list of updates that failed.
1269
+         */
1270
+        $email = apply_filters( 'auto_plugin_theme_update_email', $email, $type, $successful_updates, $failed_updates );
1271
+
1272
+        $result = wp_mail( $email['to'], wp_specialchars_decode( $email['subject'] ), $email['body'], $email['headers'] );
1273
+
1274
+        if ( $result ) {
1275
+            update_option( 'auto_plugin_theme_update_emails', $past_failure_emails );
1276
+        }
1277
+    }
1278
+
1279
+    /**
1280
+     * Prepares and sends an email of a full log of background update results, useful for debugging and geekery.
1281
+     *
1282
+     * @since 3.7.0
1283
+     */
1284
+    protected function send_debug_email() {
1285
+        $update_count = 0;
1286
+        foreach ( $this->update_results as $type => $updates ) {
1287
+            $update_count += count( $updates );
1288
+        }
1289
+
1290
+        $body     = array();
1291
+        $failures = 0;
1292
+
1293
+        /* translators: %s: Network home URL. */
1294
+        $body[] = sprintf( __( 'WordPress site: %s' ), network_home_url( '/' ) );
1295
+
1296
+        // Core.
1297
+        if ( isset( $this->update_results['core'] ) ) {
1298
+            $result = $this->update_results['core'][0];
1299
+
1300
+            if ( $result->result && ! is_wp_error( $result->result ) ) {
1301
+                /* translators: %s: WordPress version. */
1302
+                $body[] = sprintf( __( 'SUCCESS: WordPress was successfully updated to %s' ), $result->name );
1303
+            } else {
1304
+                /* translators: %s: WordPress version. */
1305
+                $body[] = sprintf( __( 'FAILED: WordPress failed to update to %s' ), $result->name );
1306
+                $failures++;
1307
+            }
1308
+
1309
+            $body[] = '';
1310
+        }
1311
+
1312
+        // Plugins, Themes, Translations.
1313
+        foreach ( array( 'plugin', 'theme', 'translation' ) as $type ) {
1314
+            if ( ! isset( $this->update_results[ $type ] ) ) {
1315
+                continue;
1316
+            }
1317
+
1318
+            $success_items = wp_list_filter( $this->update_results[ $type ], array( 'result' => true ) );
1319
+
1320
+            if ( $success_items ) {
1321
+                $messages = array(
1322
+                    'plugin'      => __( 'The following plugins were successfully updated:' ),
1323
+                    'theme'       => __( 'The following themes were successfully updated:' ),
1324
+                    'translation' => __( 'The following translations were successfully updated:' ),
1325
+                );
1326
+
1327
+                $body[] = $messages[ $type ];
1328
+                foreach ( wp_list_pluck( $success_items, 'name' ) as $name ) {
1329
+                    /* translators: %s: Name of plugin / theme / translation. */
1330
+                    $body[] = ' * ' . sprintf( __( 'SUCCESS: %s' ), $name );
1331
+                }
1332
+            }
1333
+
1334
+            if ( $success_items !== $this->update_results[ $type ] ) {
1335
+                // Failed updates.
1336
+                $messages = array(
1337
+                    'plugin'      => __( 'The following plugins failed to update:' ),
1338
+                    'theme'       => __( 'The following themes failed to update:' ),
1339
+                    'translation' => __( 'The following translations failed to update:' ),
1340
+                );
1341
+
1342
+                $body[] = $messages[ $type ];
1343
+
1344
+                foreach ( $this->update_results[ $type ] as $item ) {
1345
+                    if ( ! $item->result || is_wp_error( $item->result ) ) {
1346
+                        /* translators: %s: Name of plugin / theme / translation. */
1347
+                        $body[] = ' * ' . sprintf( __( 'FAILED: %s' ), $item->name );
1348
+                        $failures++;
1349
+                    }
1350
+                }
1351
+            }
1352
+
1353
+            $body[] = '';
1354
+        }
1355
+
1356
+        if ( '' !== get_bloginfo( 'name' ) ) {
1357
+            $site_title = wp_specialchars_decode( get_bloginfo( 'name' ), ENT_QUOTES );
1358
+        } else {
1359
+            $site_title = parse_url( home_url(), PHP_URL_HOST );
1360
+        }
1361
+
1362
+        if ( $failures ) {
1363
+            $body[] = trim(
1364
+                __(
1365
+                    "BETA TESTING?
1366 1366
 =============
1367 1367
 
1368 1368
 This debugging email is sent when you are using a development version of WordPress.
@@ -1372,96 +1372,96 @@  discard block
 block discarded – undo
1372 1372
  * Or, if you're comfortable writing a bug report: https://core.trac.wordpress.org/
1373 1373
 
1374 1374
 Thanks! -- The WordPress Team"
1375
-				)
1376
-			);
1377
-			$body[] = '';
1378
-
1379
-			/* translators: Background update failed notification email subject. %s: Site title. */
1380
-			$subject = sprintf( __( '[%s] Background Update Failed' ), $site_title );
1381
-		} else {
1382
-			/* translators: Background update finished notification email subject. %s: Site title. */
1383
-			$subject = sprintf( __( '[%s] Background Update Finished' ), $site_title );
1384
-		}
1385
-
1386
-		$body[] = trim(
1387
-			__(
1388
-				'UPDATE LOG
1375
+                )
1376
+            );
1377
+            $body[] = '';
1378
+
1379
+            /* translators: Background update failed notification email subject. %s: Site title. */
1380
+            $subject = sprintf( __( '[%s] Background Update Failed' ), $site_title );
1381
+        } else {
1382
+            /* translators: Background update finished notification email subject. %s: Site title. */
1383
+            $subject = sprintf( __( '[%s] Background Update Finished' ), $site_title );
1384
+        }
1385
+
1386
+        $body[] = trim(
1387
+            __(
1388
+                'UPDATE LOG
1389 1389
 =========='
1390
-			)
1391
-		);
1392
-		$body[] = '';
1393
-
1394
-		foreach ( array( 'core', 'plugin', 'theme', 'translation' ) as $type ) {
1395
-			if ( ! isset( $this->update_results[ $type ] ) ) {
1396
-				continue;
1397
-			}
1398
-
1399
-			foreach ( $this->update_results[ $type ] as $update ) {
1400
-				$body[] = $update->name;
1401
-				$body[] = str_repeat( '-', strlen( $update->name ) );
1402
-
1403
-				foreach ( $update->messages as $message ) {
1404
-					$body[] = '  ' . html_entity_decode( str_replace( '&#8230;', '...', $message ) );
1405
-				}
1406
-
1407
-				if ( is_wp_error( $update->result ) ) {
1408
-					$results = array( 'update' => $update->result );
1409
-
1410
-					// If we rolled back, we want to know an error that occurred then too.
1411
-					if ( 'rollback_was_required' === $update->result->get_error_code() ) {
1412
-						$results = (array) $update->result->get_error_data();
1413
-					}
1414
-
1415
-					foreach ( $results as $result_type => $result ) {
1416
-						if ( ! is_wp_error( $result ) ) {
1417
-							continue;
1418
-						}
1419
-
1420
-						if ( 'rollback' === $result_type ) {
1421
-							/* translators: 1: Error code, 2: Error message. */
1422
-							$body[] = '  ' . sprintf( __( 'Rollback Error: [%1$s] %2$s' ), $result->get_error_code(), $result->get_error_message() );
1423
-						} else {
1424
-							/* translators: 1: Error code, 2: Error message. */
1425
-							$body[] = '  ' . sprintf( __( 'Error: [%1$s] %2$s' ), $result->get_error_code(), $result->get_error_message() );
1426
-						}
1427
-
1428
-						if ( $result->get_error_data() ) {
1429
-							$body[] = '         ' . implode( ', ', (array) $result->get_error_data() );
1430
-						}
1431
-					}
1432
-				}
1433
-
1434
-				$body[] = '';
1435
-			}
1436
-		}
1437
-
1438
-		$email = array(
1439
-			'to'      => get_site_option( 'admin_email' ),
1440
-			'subject' => $subject,
1441
-			'body'    => implode( "\n", $body ),
1442
-			'headers' => '',
1443
-		);
1444
-
1445
-		/**
1446
-		 * Filters the debug email that can be sent following an automatic
1447
-		 * background core update.
1448
-		 *
1449
-		 * @since 3.8.0
1450
-		 *
1451
-		 * @param array $email {
1452
-		 *     Array of email arguments that will be passed to wp_mail().
1453
-		 *
1454
-		 *     @type string $to      The email recipient. An array of emails
1455
-		 *                           can be returned, as handled by wp_mail().
1456
-		 *     @type string $subject Email subject.
1457
-		 *     @type string $body    Email message body.
1458
-		 *     @type string $headers Any email headers. Default empty.
1459
-		 * }
1460
-		 * @param int   $failures The number of failures encountered while upgrading.
1461
-		 * @param mixed $results  The results of all attempted updates.
1462
-		 */
1463
-		$email = apply_filters( 'automatic_updates_debug_email', $email, $failures, $this->update_results );
1464
-
1465
-		wp_mail( $email['to'], wp_specialchars_decode( $email['subject'] ), $email['body'], $email['headers'] );
1466
-	}
1390
+            )
1391
+        );
1392
+        $body[] = '';
1393
+
1394
+        foreach ( array( 'core', 'plugin', 'theme', 'translation' ) as $type ) {
1395
+            if ( ! isset( $this->update_results[ $type ] ) ) {
1396
+                continue;
1397
+            }
1398
+
1399
+            foreach ( $this->update_results[ $type ] as $update ) {
1400
+                $body[] = $update->name;
1401
+                $body[] = str_repeat( '-', strlen( $update->name ) );
1402
+
1403
+                foreach ( $update->messages as $message ) {
1404
+                    $body[] = '  ' . html_entity_decode( str_replace( '&#8230;', '...', $message ) );
1405
+                }
1406
+
1407
+                if ( is_wp_error( $update->result ) ) {
1408
+                    $results = array( 'update' => $update->result );
1409
+
1410
+                    // If we rolled back, we want to know an error that occurred then too.
1411
+                    if ( 'rollback_was_required' === $update->result->get_error_code() ) {
1412
+                        $results = (array) $update->result->get_error_data();
1413
+                    }
1414
+
1415
+                    foreach ( $results as $result_type => $result ) {
1416
+                        if ( ! is_wp_error( $result ) ) {
1417
+                            continue;
1418
+                        }
1419
+
1420
+                        if ( 'rollback' === $result_type ) {
1421
+                            /* translators: 1: Error code, 2: Error message. */
1422
+                            $body[] = '  ' . sprintf( __( 'Rollback Error: [%1$s] %2$s' ), $result->get_error_code(), $result->get_error_message() );
1423
+                        } else {
1424
+                            /* translators: 1: Error code, 2: Error message. */
1425
+                            $body[] = '  ' . sprintf( __( 'Error: [%1$s] %2$s' ), $result->get_error_code(), $result->get_error_message() );
1426
+                        }
1427
+
1428
+                        if ( $result->get_error_data() ) {
1429
+                            $body[] = '         ' . implode( ', ', (array) $result->get_error_data() );
1430
+                        }
1431
+                    }
1432
+                }
1433
+
1434
+                $body[] = '';
1435
+            }
1436
+        }
1437
+
1438
+        $email = array(
1439
+            'to'      => get_site_option( 'admin_email' ),
1440
+            'subject' => $subject,
1441
+            'body'    => implode( "\n", $body ),
1442
+            'headers' => '',
1443
+        );
1444
+
1445
+        /**
1446
+         * Filters the debug email that can be sent following an automatic
1447
+         * background core update.
1448
+         *
1449
+         * @since 3.8.0
1450
+         *
1451
+         * @param array $email {
1452
+         *     Array of email arguments that will be passed to wp_mail().
1453
+         *
1454
+         *     @type string $to      The email recipient. An array of emails
1455
+         *                           can be returned, as handled by wp_mail().
1456
+         *     @type string $subject Email subject.
1457
+         *     @type string $body    Email message body.
1458
+         *     @type string $headers Any email headers. Default empty.
1459
+         * }
1460
+         * @param int   $failures The number of failures encountered while upgrading.
1461
+         * @param mixed $results  The results of all attempted updates.
1462
+         */
1463
+        $email = apply_filters( 'automatic_updates_debug_email', $email, $failures, $this->update_results );
1464
+
1465
+        wp_mail( $email['to'], wp_specialchars_decode( $email['subject'] ), $email['body'], $email['headers'] );
1466
+    }
1467 1467
 }
Please login to merge, or discard this patch.
brighty/wp-admin/includes/menu.php 1 patch
Indentation   +245 added lines, -245 removed lines patch added patch discarded remove patch
@@ -8,66 +8,66 @@  discard block
 block discarded – undo
8 8
 
9 9
 if ( is_network_admin() ) {
10 10
 
11
-	/**
12
-	 * Fires before the administration menu loads in the Network Admin.
13
-	 *
14
-	 * The hook fires before menus and sub-menus are removed based on user privileges.
15
-	 *
16
-	 * @private
17
-	 * @since 3.1.0
18
-	 */
19
-	do_action( '_network_admin_menu' );
11
+    /**
12
+     * Fires before the administration menu loads in the Network Admin.
13
+     *
14
+     * The hook fires before menus and sub-menus are removed based on user privileges.
15
+     *
16
+     * @private
17
+     * @since 3.1.0
18
+     */
19
+    do_action( '_network_admin_menu' );
20 20
 } elseif ( is_user_admin() ) {
21 21
 
22
-	/**
23
-	 * Fires before the administration menu loads in the User Admin.
24
-	 *
25
-	 * The hook fires before menus and sub-menus are removed based on user privileges.
26
-	 *
27
-	 * @private
28
-	 * @since 3.1.0
29
-	 */
30
-	do_action( '_user_admin_menu' );
22
+    /**
23
+     * Fires before the administration menu loads in the User Admin.
24
+     *
25
+     * The hook fires before menus and sub-menus are removed based on user privileges.
26
+     *
27
+     * @private
28
+     * @since 3.1.0
29
+     */
30
+    do_action( '_user_admin_menu' );
31 31
 } else {
32 32
 
33
-	/**
34
-	 * Fires before the administration menu loads in the admin.
35
-	 *
36
-	 * The hook fires before menus and sub-menus are removed based on user privileges.
37
-	 *
38
-	 * @private
39
-	 * @since 2.2.0
40
-	 */
41
-	do_action( '_admin_menu' );
33
+    /**
34
+     * Fires before the administration menu loads in the admin.
35
+     *
36
+     * The hook fires before menus and sub-menus are removed based on user privileges.
37
+     *
38
+     * @private
39
+     * @since 2.2.0
40
+     */
41
+    do_action( '_admin_menu' );
42 42
 }
43 43
 
44 44
 // Create list of page plugin hook names.
45 45
 foreach ( $menu as $menu_page ) {
46
-	$pos = strpos( $menu_page[2], '?' );
47
-	if ( false !== $pos ) {
48
-		// Handle post_type=post|page|foo pages.
49
-		$hook_name = substr( $menu_page[2], 0, $pos );
50
-		$hook_args = substr( $menu_page[2], $pos + 1 );
51
-		wp_parse_str( $hook_args, $hook_args );
52
-		// Set the hook name to be the post type.
53
-		if ( isset( $hook_args['post_type'] ) ) {
54
-			$hook_name = $hook_args['post_type'];
55
-		} else {
56
-			$hook_name = basename( $hook_name, '.php' );
57
-		}
58
-		unset( $hook_args );
59
-	} else {
60
-		$hook_name = basename( $menu_page[2], '.php' );
61
-	}
62
-	$hook_name = sanitize_title( $hook_name );
63
-
64
-	if ( isset( $compat[ $hook_name ] ) ) {
65
-		$hook_name = $compat[ $hook_name ];
66
-	} elseif ( ! $hook_name ) {
67
-		continue;
68
-	}
69
-
70
-	$admin_page_hooks[ $menu_page[2] ] = $hook_name;
46
+    $pos = strpos( $menu_page[2], '?' );
47
+    if ( false !== $pos ) {
48
+        // Handle post_type=post|page|foo pages.
49
+        $hook_name = substr( $menu_page[2], 0, $pos );
50
+        $hook_args = substr( $menu_page[2], $pos + 1 );
51
+        wp_parse_str( $hook_args, $hook_args );
52
+        // Set the hook name to be the post type.
53
+        if ( isset( $hook_args['post_type'] ) ) {
54
+            $hook_name = $hook_args['post_type'];
55
+        } else {
56
+            $hook_name = basename( $hook_name, '.php' );
57
+        }
58
+        unset( $hook_args );
59
+    } else {
60
+        $hook_name = basename( $menu_page[2], '.php' );
61
+    }
62
+    $hook_name = sanitize_title( $hook_name );
63
+
64
+    if ( isset( $compat[ $hook_name ] ) ) {
65
+        $hook_name = $compat[ $hook_name ];
66
+    } elseif ( ! $hook_name ) {
67
+        continue;
68
+    }
69
+
70
+    $admin_page_hooks[ $menu_page[2] ] = $hook_name;
71 71
 }
72 72
 unset( $menu_page, $compat );
73 73
 
@@ -75,17 +75,17 @@  discard block
 block discarded – undo
75 75
 $_wp_menu_nopriv    = array();
76 76
 // Loop over submenus and remove pages for which the user does not have privs.
77 77
 foreach ( $submenu as $parent => $sub ) {
78
-	foreach ( $sub as $index => $data ) {
79
-		if ( ! current_user_can( $data[1] ) ) {
80
-			unset( $submenu[ $parent ][ $index ] );
81
-			$_wp_submenu_nopriv[ $parent ][ $data[2] ] = true;
82
-		}
83
-	}
84
-	unset( $index, $data );
85
-
86
-	if ( empty( $submenu[ $parent ] ) ) {
87
-		unset( $submenu[ $parent ] );
88
-	}
78
+    foreach ( $sub as $index => $data ) {
79
+        if ( ! current_user_can( $data[1] ) ) {
80
+            unset( $submenu[ $parent ][ $index ] );
81
+            $_wp_submenu_nopriv[ $parent ][ $data[2] ] = true;
82
+        }
83
+    }
84
+    unset( $index, $data );
85
+
86
+    if ( empty( $submenu[ $parent ] ) ) {
87
+        unset( $submenu[ $parent ] );
88
+    }
89 89
 }
90 90
 unset( $sub, $parent );
91 91
 
@@ -95,64 +95,64 @@  discard block
 block discarded – undo
95 95
  * will have the next submenu in line be assigned as the new menu parent.
96 96
  */
97 97
 foreach ( $menu as $id => $data ) {
98
-	if ( empty( $submenu[ $data[2] ] ) ) {
99
-		continue;
100
-	}
101
-	$subs       = $submenu[ $data[2] ];
102
-	$first_sub  = reset( $subs );
103
-	$old_parent = $data[2];
104
-	$new_parent = $first_sub[2];
105
-	/*
98
+    if ( empty( $submenu[ $data[2] ] ) ) {
99
+        continue;
100
+    }
101
+    $subs       = $submenu[ $data[2] ];
102
+    $first_sub  = reset( $subs );
103
+    $old_parent = $data[2];
104
+    $new_parent = $first_sub[2];
105
+    /*
106 106
 	 * If the first submenu is not the same as the assigned parent,
107 107
 	 * make the first submenu the new parent.
108 108
 	 */
109
-	if ( $new_parent != $old_parent ) {
110
-		$_wp_real_parent_file[ $old_parent ] = $new_parent;
111
-		$menu[ $id ][2]                      = $new_parent;
112
-
113
-		foreach ( $submenu[ $old_parent ] as $index => $data ) {
114
-			$submenu[ $new_parent ][ $index ] = $submenu[ $old_parent ][ $index ];
115
-			unset( $submenu[ $old_parent ][ $index ] );
116
-		}
117
-		unset( $submenu[ $old_parent ], $index );
118
-
119
-		if ( isset( $_wp_submenu_nopriv[ $old_parent ] ) ) {
120
-			$_wp_submenu_nopriv[ $new_parent ] = $_wp_submenu_nopriv[ $old_parent ];
121
-		}
122
-	}
109
+    if ( $new_parent != $old_parent ) {
110
+        $_wp_real_parent_file[ $old_parent ] = $new_parent;
111
+        $menu[ $id ][2]                      = $new_parent;
112
+
113
+        foreach ( $submenu[ $old_parent ] as $index => $data ) {
114
+            $submenu[ $new_parent ][ $index ] = $submenu[ $old_parent ][ $index ];
115
+            unset( $submenu[ $old_parent ][ $index ] );
116
+        }
117
+        unset( $submenu[ $old_parent ], $index );
118
+
119
+        if ( isset( $_wp_submenu_nopriv[ $old_parent ] ) ) {
120
+            $_wp_submenu_nopriv[ $new_parent ] = $_wp_submenu_nopriv[ $old_parent ];
121
+        }
122
+    }
123 123
 }
124 124
 unset( $id, $data, $subs, $first_sub, $old_parent, $new_parent );
125 125
 
126 126
 if ( is_network_admin() ) {
127 127
 
128
-	/**
129
-	 * Fires before the administration menu loads in the Network Admin.
130
-	 *
131
-	 * @since 3.1.0
132
-	 *
133
-	 * @param string $context Empty context.
134
-	 */
135
-	do_action( 'network_admin_menu', '' );
128
+    /**
129
+     * Fires before the administration menu loads in the Network Admin.
130
+     *
131
+     * @since 3.1.0
132
+     *
133
+     * @param string $context Empty context.
134
+     */
135
+    do_action( 'network_admin_menu', '' );
136 136
 } elseif ( is_user_admin() ) {
137 137
 
138
-	/**
139
-	 * Fires before the administration menu loads in the User Admin.
140
-	 *
141
-	 * @since 3.1.0
142
-	 *
143
-	 * @param string $context Empty context.
144
-	 */
145
-	do_action( 'user_admin_menu', '' );
138
+    /**
139
+     * Fires before the administration menu loads in the User Admin.
140
+     *
141
+     * @since 3.1.0
142
+     *
143
+     * @param string $context Empty context.
144
+     */
145
+    do_action( 'user_admin_menu', '' );
146 146
 } else {
147 147
 
148
-	/**
149
-	 * Fires before the administration menu loads in the admin.
150
-	 *
151
-	 * @since 1.5.0
152
-	 *
153
-	 * @param string $context Empty context.
154
-	 */
155
-	do_action( 'admin_menu', '' );
148
+    /**
149
+     * Fires before the administration menu loads in the admin.
150
+     *
151
+     * @since 1.5.0
152
+     *
153
+     * @param string $context Empty context.
154
+     */
155
+    do_action( 'admin_menu', '' );
156 156
 }
157 157
 
158 158
 /*
@@ -160,29 +160,29 @@  discard block
 block discarded – undo
160 160
  * that the user does not have. Run re-parent loop again.
161 161
  */
162 162
 foreach ( $menu as $id => $data ) {
163
-	if ( ! current_user_can( $data[1] ) ) {
164
-		$_wp_menu_nopriv[ $data[2] ] = true;
165
-	}
163
+    if ( ! current_user_can( $data[1] ) ) {
164
+        $_wp_menu_nopriv[ $data[2] ] = true;
165
+    }
166 166
 
167
-	/*
167
+    /*
168 168
 	 * If there is only one submenu and it is has same destination as the parent,
169 169
 	 * remove the submenu.
170 170
 	 */
171
-	if ( ! empty( $submenu[ $data[2] ] ) && 1 === count( $submenu[ $data[2] ] ) ) {
172
-		$subs      = $submenu[ $data[2] ];
173
-		$first_sub = reset( $subs );
174
-		if ( $data[2] == $first_sub[2] ) {
175
-			unset( $submenu[ $data[2] ] );
176
-		}
177
-	}
178
-
179
-	// If submenu is empty...
180
-	if ( empty( $submenu[ $data[2] ] ) ) {
181
-		// And user doesn't have privs, remove menu.
182
-		if ( isset( $_wp_menu_nopriv[ $data[2] ] ) ) {
183
-			unset( $menu[ $id ] );
184
-		}
185
-	}
171
+    if ( ! empty( $submenu[ $data[2] ] ) && 1 === count( $submenu[ $data[2] ] ) ) {
172
+        $subs      = $submenu[ $data[2] ];
173
+        $first_sub = reset( $subs );
174
+        if ( $data[2] == $first_sub[2] ) {
175
+            unset( $submenu[ $data[2] ] );
176
+        }
177
+    }
178
+
179
+    // If submenu is empty...
180
+    if ( empty( $submenu[ $data[2] ] ) ) {
181
+        // And user doesn't have privs, remove menu.
182
+        if ( isset( $_wp_menu_nopriv[ $data[2] ] ) ) {
183
+            unset( $menu[ $id ] );
184
+        }
185
+    }
186 186
 }
187 187
 unset( $id, $data, $subs, $first_sub );
188 188
 
@@ -196,11 +196,11 @@  discard block
 block discarded – undo
196 196
  * @return string The string with the CSS class added.
197 197
  */
198 198
 function add_cssclass( $class_to_add, $classes ) {
199
-	if ( empty( $classes ) ) {
200
-		return $class_to_add;
201
-	}
199
+    if ( empty( $classes ) ) {
200
+        return $class_to_add;
201
+    }
202 202
 
203
-	return $classes . ' ' . $class_to_add;
203
+    return $classes . ' ' . $class_to_add;
204 204
 }
205 205
 
206 206
 /**
@@ -214,49 +214,49 @@  discard block
 block discarded – undo
214 214
  * @return array The array of administration menu items with the CSS classes added.
215 215
  */
216 216
 function add_menu_classes( $menu ) {
217
-	$first_item  = false;
218
-	$last_order  = false;
219
-	$items_count = count( $menu );
220
-	$i           = 0;
221
-
222
-	foreach ( $menu as $order => $top ) {
223
-		$i++;
224
-
225
-		if ( 0 == $order ) { // Dashboard is always shown/single.
226
-			$menu[0][4] = add_cssclass( 'menu-top-first', $top[4] );
227
-			$last_order = 0;
228
-			continue;
229
-		}
230
-
231
-		if ( 0 === strpos( $top[2], 'separator' ) && false !== $last_order ) { // If separator.
232
-			$first_item             = true;
233
-			$classes                = $menu[ $last_order ][4];
234
-			$menu[ $last_order ][4] = add_cssclass( 'menu-top-last', $classes );
235
-			continue;
236
-		}
237
-
238
-		if ( $first_item ) {
239
-			$classes           = $menu[ $order ][4];
240
-			$menu[ $order ][4] = add_cssclass( 'menu-top-first', $classes );
241
-			$first_item        = false;
242
-		}
243
-
244
-		if ( $i == $items_count ) { // Last item.
245
-			$classes           = $menu[ $order ][4];
246
-			$menu[ $order ][4] = add_cssclass( 'menu-top-last', $classes );
247
-		}
248
-
249
-		$last_order = $order;
250
-	}
251
-
252
-	/**
253
-	 * Filters administration menu array with classes added for top-level items.
254
-	 *
255
-	 * @since 2.7.0
256
-	 *
257
-	 * @param array $menu Associative array of administration menu items.
258
-	 */
259
-	return apply_filters( 'add_menu_classes', $menu );
217
+    $first_item  = false;
218
+    $last_order  = false;
219
+    $items_count = count( $menu );
220
+    $i           = 0;
221
+
222
+    foreach ( $menu as $order => $top ) {
223
+        $i++;
224
+
225
+        if ( 0 == $order ) { // Dashboard is always shown/single.
226
+            $menu[0][4] = add_cssclass( 'menu-top-first', $top[4] );
227
+            $last_order = 0;
228
+            continue;
229
+        }
230
+
231
+        if ( 0 === strpos( $top[2], 'separator' ) && false !== $last_order ) { // If separator.
232
+            $first_item             = true;
233
+            $classes                = $menu[ $last_order ][4];
234
+            $menu[ $last_order ][4] = add_cssclass( 'menu-top-last', $classes );
235
+            continue;
236
+        }
237
+
238
+        if ( $first_item ) {
239
+            $classes           = $menu[ $order ][4];
240
+            $menu[ $order ][4] = add_cssclass( 'menu-top-first', $classes );
241
+            $first_item        = false;
242
+        }
243
+
244
+        if ( $i == $items_count ) { // Last item.
245
+            $classes           = $menu[ $order ][4];
246
+            $menu[ $order ][4] = add_cssclass( 'menu-top-last', $classes );
247
+        }
248
+
249
+        $last_order = $order;
250
+    }
251
+
252
+    /**
253
+     * Filters administration menu array with classes added for top-level items.
254
+     *
255
+     * @since 2.7.0
256
+     *
257
+     * @param array $menu Associative array of administration menu items.
258
+     */
259
+    return apply_filters( 'add_menu_classes', $menu );
260 260
 }
261 261
 
262 262
 uksort( $menu, 'strnatcasecmp' ); // Make it all pretty.
@@ -271,76 +271,76 @@  discard block
 block discarded – undo
271 271
  * @param bool $custom Whether custom ordering is enabled. Default false.
272 272
  */
273 273
 if ( apply_filters( 'custom_menu_order', false ) ) {
274
-	$menu_order = array();
275
-	foreach ( $menu as $menu_item ) {
276
-		$menu_order[] = $menu_item[2];
277
-	}
278
-	unset( $menu_item );
279
-	$default_menu_order = $menu_order;
280
-
281
-	/**
282
-	 * Filters the order of administration menu items.
283
-	 *
284
-	 * A truthy value must first be passed to the {@see 'custom_menu_order'} filter
285
-	 * for this filter to work. Use the following to enable custom menu ordering:
286
-	 *
287
-	 *     add_filter( 'custom_menu_order', '__return_true' );
288
-	 *
289
-	 * @since 2.8.0
290
-	 *
291
-	 * @param array $menu_order An ordered array of menu items.
292
-	 */
293
-	$menu_order         = apply_filters( 'menu_order', $menu_order );
294
-	$menu_order         = array_flip( $menu_order );
295
-	$default_menu_order = array_flip( $default_menu_order );
296
-
297
-	/**
298
-	 * @global array $menu_order
299
-	 * @global array $default_menu_order
300
-	 *
301
-	 * @param array $a
302
-	 * @param array $b
303
-	 * @return int
304
-	 */
305
-	function sort_menu( $a, $b ) {
306
-		global $menu_order, $default_menu_order;
307
-		$a = $a[2];
308
-		$b = $b[2];
309
-		if ( isset( $menu_order[ $a ] ) && ! isset( $menu_order[ $b ] ) ) {
310
-			return -1;
311
-		} elseif ( ! isset( $menu_order[ $a ] ) && isset( $menu_order[ $b ] ) ) {
312
-			return 1;
313
-		} elseif ( isset( $menu_order[ $a ] ) && isset( $menu_order[ $b ] ) ) {
314
-			if ( $menu_order[ $a ] == $menu_order[ $b ] ) {
315
-				return 0;
316
-			}
317
-			return ( $menu_order[ $a ] < $menu_order[ $b ] ) ? -1 : 1;
318
-		} else {
319
-			return ( $default_menu_order[ $a ] <= $default_menu_order[ $b ] ) ? -1 : 1;
320
-		}
321
-	}
322
-
323
-	usort( $menu, 'sort_menu' );
324
-	unset( $menu_order, $default_menu_order );
274
+    $menu_order = array();
275
+    foreach ( $menu as $menu_item ) {
276
+        $menu_order[] = $menu_item[2];
277
+    }
278
+    unset( $menu_item );
279
+    $default_menu_order = $menu_order;
280
+
281
+    /**
282
+     * Filters the order of administration menu items.
283
+     *
284
+     * A truthy value must first be passed to the {@see 'custom_menu_order'} filter
285
+     * for this filter to work. Use the following to enable custom menu ordering:
286
+     *
287
+     *     add_filter( 'custom_menu_order', '__return_true' );
288
+     *
289
+     * @since 2.8.0
290
+     *
291
+     * @param array $menu_order An ordered array of menu items.
292
+     */
293
+    $menu_order         = apply_filters( 'menu_order', $menu_order );
294
+    $menu_order         = array_flip( $menu_order );
295
+    $default_menu_order = array_flip( $default_menu_order );
296
+
297
+    /**
298
+     * @global array $menu_order
299
+     * @global array $default_menu_order
300
+     *
301
+     * @param array $a
302
+     * @param array $b
303
+     * @return int
304
+     */
305
+    function sort_menu( $a, $b ) {
306
+        global $menu_order, $default_menu_order;
307
+        $a = $a[2];
308
+        $b = $b[2];
309
+        if ( isset( $menu_order[ $a ] ) && ! isset( $menu_order[ $b ] ) ) {
310
+            return -1;
311
+        } elseif ( ! isset( $menu_order[ $a ] ) && isset( $menu_order[ $b ] ) ) {
312
+            return 1;
313
+        } elseif ( isset( $menu_order[ $a ] ) && isset( $menu_order[ $b ] ) ) {
314
+            if ( $menu_order[ $a ] == $menu_order[ $b ] ) {
315
+                return 0;
316
+            }
317
+            return ( $menu_order[ $a ] < $menu_order[ $b ] ) ? -1 : 1;
318
+        } else {
319
+            return ( $default_menu_order[ $a ] <= $default_menu_order[ $b ] ) ? -1 : 1;
320
+        }
321
+    }
322
+
323
+    usort( $menu, 'sort_menu' );
324
+    unset( $menu_order, $default_menu_order );
325 325
 }
326 326
 
327 327
 // Prevent adjacent separators.
328 328
 $prev_menu_was_separator = false;
329 329
 foreach ( $menu as $id => $data ) {
330
-	if ( false === stristr( $data[4], 'wp-menu-separator' ) ) {
330
+    if ( false === stristr( $data[4], 'wp-menu-separator' ) ) {
331 331
 
332
-		// This item is not a separator, so falsey the toggler and do nothing.
333
-		$prev_menu_was_separator = false;
334
-	} else {
332
+        // This item is not a separator, so falsey the toggler and do nothing.
333
+        $prev_menu_was_separator = false;
334
+    } else {
335 335
 
336
-		// The previous item was a separator, so unset this one.
337
-		if ( true === $prev_menu_was_separator ) {
338
-			unset( $menu[ $id ] );
339
-		}
336
+        // The previous item was a separator, so unset this one.
337
+        if ( true === $prev_menu_was_separator ) {
338
+            unset( $menu[ $id ] );
339
+        }
340 340
 
341
-		// This item is a separator, so truthy the toggler and move on.
342
-		$prev_menu_was_separator = true;
343
-	}
341
+        // This item is a separator, so truthy the toggler and move on.
342
+        $prev_menu_was_separator = true;
343
+    }
344 344
 }
345 345
 unset( $id, $data, $prev_menu_was_separator );
346 346
 
@@ -348,20 +348,20 @@  discard block
 block discarded – undo
348 348
 $last_menu_key = array_keys( $menu );
349 349
 $last_menu_key = array_pop( $last_menu_key );
350 350
 if ( ! empty( $menu ) && 'wp-menu-separator' === $menu[ $last_menu_key ][4] ) {
351
-	unset( $menu[ $last_menu_key ] );
351
+    unset( $menu[ $last_menu_key ] );
352 352
 }
353 353
 unset( $last_menu_key );
354 354
 
355 355
 if ( ! user_can_access_admin_page() ) {
356 356
 
357
-	/**
358
-	 * Fires when access to an admin page is denied.
359
-	 *
360
-	 * @since 2.5.0
361
-	 */
362
-	do_action( 'admin_page_access_denied' );
357
+    /**
358
+     * Fires when access to an admin page is denied.
359
+     *
360
+     * @since 2.5.0
361
+     */
362
+    do_action( 'admin_page_access_denied' );
363 363
 
364
-	wp_die( __( 'Sorry, you are not allowed to access this page.' ), 403 );
364
+    wp_die( __( 'Sorry, you are not allowed to access this page.' ), 403 );
365 365
 }
366 366
 
367 367
 $menu = add_menu_classes( $menu );
Please login to merge, or discard this patch.
brighty/wp-admin/includes/class-wp-filesystem-ftpsockets.php 1 patch
Indentation   +671 added lines, -671 removed lines patch added patch discarded remove patch
@@ -15,675 +15,675 @@
 block discarded – undo
15 15
  */
16 16
 class WP_Filesystem_ftpsockets extends WP_Filesystem_Base {
17 17
 
18
-	/**
19
-	 * @since 2.5.0
20
-	 * @var ftp
21
-	 */
22
-	public $ftp;
23
-
24
-	/**
25
-	 * Constructor.
26
-	 *
27
-	 * @since 2.5.0
28
-	 *
29
-	 * @param array $opt
30
-	 */
31
-	public function __construct( $opt = '' ) {
32
-		$this->method = 'ftpsockets';
33
-		$this->errors = new WP_Error();
34
-
35
-		// Check if possible to use ftp functions.
36
-		if ( ! include_once ABSPATH . 'wp-admin/includes/class-ftp.php' ) {
37
-			return;
38
-		}
39
-
40
-		$this->ftp = new ftp();
41
-
42
-		if ( empty( $opt['port'] ) ) {
43
-			$this->options['port'] = 21;
44
-		} else {
45
-			$this->options['port'] = (int) $opt['port'];
46
-		}
47
-
48
-		if ( empty( $opt['hostname'] ) ) {
49
-			$this->errors->add( 'empty_hostname', __( 'FTP hostname is required' ) );
50
-		} else {
51
-			$this->options['hostname'] = $opt['hostname'];
52
-		}
53
-
54
-		// Check if the options provided are OK.
55
-		if ( empty( $opt['username'] ) ) {
56
-			$this->errors->add( 'empty_username', __( 'FTP username is required' ) );
57
-		} else {
58
-			$this->options['username'] = $opt['username'];
59
-		}
60
-
61
-		if ( empty( $opt['password'] ) ) {
62
-			$this->errors->add( 'empty_password', __( 'FTP password is required' ) );
63
-		} else {
64
-			$this->options['password'] = $opt['password'];
65
-		}
66
-	}
67
-
68
-	/**
69
-	 * Connects filesystem.
70
-	 *
71
-	 * @since 2.5.0
72
-	 *
73
-	 * @return bool True on success, false on failure.
74
-	 */
75
-	public function connect() {
76
-		if ( ! $this->ftp ) {
77
-			return false;
78
-		}
79
-
80
-		$this->ftp->setTimeout( FS_CONNECT_TIMEOUT );
81
-
82
-		if ( ! $this->ftp->SetServer( $this->options['hostname'], $this->options['port'] ) ) {
83
-			$this->errors->add(
84
-				'connect',
85
-				sprintf(
86
-					/* translators: %s: hostname:port */
87
-					__( 'Failed to connect to FTP Server %s' ),
88
-					$this->options['hostname'] . ':' . $this->options['port']
89
-				)
90
-			);
91
-
92
-			return false;
93
-		}
94
-
95
-		if ( ! $this->ftp->connect() ) {
96
-			$this->errors->add(
97
-				'connect',
98
-				sprintf(
99
-					/* translators: %s: hostname:port */
100
-					__( 'Failed to connect to FTP Server %s' ),
101
-					$this->options['hostname'] . ':' . $this->options['port']
102
-				)
103
-			);
104
-
105
-			return false;
106
-		}
107
-
108
-		if ( ! $this->ftp->login( $this->options['username'], $this->options['password'] ) ) {
109
-			$this->errors->add(
110
-				'auth',
111
-				sprintf(
112
-					/* translators: %s: Username. */
113
-					__( 'Username/Password incorrect for %s' ),
114
-					$this->options['username']
115
-				)
116
-			);
117
-
118
-			return false;
119
-		}
120
-
121
-		$this->ftp->SetType( FTP_BINARY );
122
-		$this->ftp->Passive( true );
123
-		$this->ftp->setTimeout( FS_TIMEOUT );
124
-
125
-		return true;
126
-	}
127
-
128
-	/**
129
-	 * Reads entire file into a string.
130
-	 *
131
-	 * @since 2.5.0
132
-	 *
133
-	 * @param string $file Name of the file to read.
134
-	 * @return string|false Read data on success, false if no temporary file could be opened,
135
-	 *                      or if the file couldn't be retrieved.
136
-	 */
137
-	public function get_contents( $file ) {
138
-		if ( ! $this->exists( $file ) ) {
139
-			return false;
140
-		}
141
-
142
-		$tempfile   = wp_tempnam( $file );
143
-		$temphandle = fopen( $tempfile, 'w+' );
144
-
145
-		if ( ! $temphandle ) {
146
-			unlink( $tempfile );
147
-			return false;
148
-		}
149
-
150
-		mbstring_binary_safe_encoding();
151
-
152
-		if ( ! $this->ftp->fget( $temphandle, $file ) ) {
153
-			fclose( $temphandle );
154
-			unlink( $tempfile );
155
-
156
-			reset_mbstring_encoding();
157
-
158
-			return ''; // Blank document. File does exist, it's just blank.
159
-		}
160
-
161
-		reset_mbstring_encoding();
162
-
163
-		fseek( $temphandle, 0 ); // Skip back to the start of the file being written to.
164
-		$contents = '';
165
-
166
-		while ( ! feof( $temphandle ) ) {
167
-			$contents .= fread( $temphandle, 8 * KB_IN_BYTES );
168
-		}
169
-
170
-		fclose( $temphandle );
171
-		unlink( $tempfile );
172
-
173
-		return $contents;
174
-	}
175
-
176
-	/**
177
-	 * Reads entire file into an array.
178
-	 *
179
-	 * @since 2.5.0
180
-	 *
181
-	 * @param string $file Path to the file.
182
-	 * @return array|false File contents in an array on success, false on failure.
183
-	 */
184
-	public function get_contents_array( $file ) {
185
-		return explode( "\n", $this->get_contents( $file ) );
186
-	}
187
-
188
-	/**
189
-	 * Writes a string to a file.
190
-	 *
191
-	 * @since 2.5.0
192
-	 *
193
-	 * @param string    $file     Remote path to the file where to write the data.
194
-	 * @param string    $contents The data to write.
195
-	 * @param int|false $mode     Optional. The file permissions as octal number, usually 0644.
196
-	 *                            Default false.
197
-	 * @return bool True on success, false on failure.
198
-	 */
199
-	public function put_contents( $file, $contents, $mode = false ) {
200
-		$tempfile   = wp_tempnam( $file );
201
-		$temphandle = @fopen( $tempfile, 'w+' );
202
-
203
-		if ( ! $temphandle ) {
204
-			unlink( $tempfile );
205
-			return false;
206
-		}
207
-
208
-		// The FTP class uses string functions internally during file download/upload.
209
-		mbstring_binary_safe_encoding();
210
-
211
-		$bytes_written = fwrite( $temphandle, $contents );
212
-
213
-		if ( false === $bytes_written || strlen( $contents ) !== $bytes_written ) {
214
-			fclose( $temphandle );
215
-			unlink( $tempfile );
216
-
217
-			reset_mbstring_encoding();
218
-
219
-			return false;
220
-		}
221
-
222
-		fseek( $temphandle, 0 ); // Skip back to the start of the file being written to.
223
-
224
-		$ret = $this->ftp->fput( $file, $temphandle );
225
-
226
-		reset_mbstring_encoding();
227
-
228
-		fclose( $temphandle );
229
-		unlink( $tempfile );
230
-
231
-		$this->chmod( $file, $mode );
232
-
233
-		return $ret;
234
-	}
235
-
236
-	/**
237
-	 * Gets the current working directory.
238
-	 *
239
-	 * @since 2.5.0
240
-	 *
241
-	 * @return string|false The current working directory on success, false on failure.
242
-	 */
243
-	public function cwd() {
244
-		$cwd = $this->ftp->pwd();
245
-
246
-		if ( $cwd ) {
247
-			$cwd = trailingslashit( $cwd );
248
-		}
249
-
250
-		return $cwd;
251
-	}
252
-
253
-	/**
254
-	 * Changes current directory.
255
-	 *
256
-	 * @since 2.5.0
257
-	 *
258
-	 * @param string $dir The new current directory.
259
-	 * @return bool True on success, false on failure.
260
-	 */
261
-	public function chdir( $dir ) {
262
-		return $this->ftp->chdir( $dir );
263
-	}
264
-
265
-	/**
266
-	 * Changes filesystem permissions.
267
-	 *
268
-	 * @since 2.5.0
269
-	 *
270
-	 * @param string    $file      Path to the file.
271
-	 * @param int|false $mode      Optional. The permissions as octal number, usually 0644 for files,
272
-	 *                             0755 for directories. Default false.
273
-	 * @param bool      $recursive Optional. If set to true, changes file permissions recursively.
274
-	 *                             Default false.
275
-	 * @return bool True on success, false on failure.
276
-	 */
277
-	public function chmod( $file, $mode = false, $recursive = false ) {
278
-		if ( ! $mode ) {
279
-			if ( $this->is_file( $file ) ) {
280
-				$mode = FS_CHMOD_FILE;
281
-			} elseif ( $this->is_dir( $file ) ) {
282
-				$mode = FS_CHMOD_DIR;
283
-			} else {
284
-				return false;
285
-			}
286
-		}
287
-
288
-		// chmod any sub-objects if recursive.
289
-		if ( $recursive && $this->is_dir( $file ) ) {
290
-			$filelist = $this->dirlist( $file );
291
-
292
-			foreach ( (array) $filelist as $filename => $filemeta ) {
293
-				$this->chmod( $file . '/' . $filename, $mode, $recursive );
294
-			}
295
-		}
296
-
297
-		// chmod the file or directory.
298
-		return $this->ftp->chmod( $file, $mode );
299
-	}
300
-
301
-	/**
302
-	 * Gets the file owner.
303
-	 *
304
-	 * @since 2.5.0
305
-	 *
306
-	 * @param string $file Path to the file.
307
-	 * @return string|false Username of the owner on success, false on failure.
308
-	 */
309
-	public function owner( $file ) {
310
-		$dir = $this->dirlist( $file );
311
-
312
-		return $dir[ $file ]['owner'];
313
-	}
314
-
315
-	/**
316
-	 * Gets the permissions of the specified file or filepath in their octal format.
317
-	 *
318
-	 * @since 2.5.0
319
-	 *
320
-	 * @param string $file Path to the file.
321
-	 * @return string Mode of the file (the last 3 digits).
322
-	 */
323
-	public function getchmod( $file ) {
324
-		$dir = $this->dirlist( $file );
325
-
326
-		return $dir[ $file ]['permsn'];
327
-	}
328
-
329
-	/**
330
-	 * Gets the file's group.
331
-	 *
332
-	 * @since 2.5.0
333
-	 *
334
-	 * @param string $file Path to the file.
335
-	 * @return string|false The group on success, false on failure.
336
-	 */
337
-	public function group( $file ) {
338
-		$dir = $this->dirlist( $file );
339
-
340
-		return $dir[ $file ]['group'];
341
-	}
342
-
343
-	/**
344
-	 * Copies a file.
345
-	 *
346
-	 * @since 2.5.0
347
-	 *
348
-	 * @param string    $source      Path to the source file.
349
-	 * @param string    $destination Path to the destination file.
350
-	 * @param bool      $overwrite   Optional. Whether to overwrite the destination file if it exists.
351
-	 *                               Default false.
352
-	 * @param int|false $mode        Optional. The permissions as octal number, usually 0644 for files,
353
-	 *                               0755 for dirs. Default false.
354
-	 * @return bool True on success, false on failure.
355
-	 */
356
-	public function copy( $source, $destination, $overwrite = false, $mode = false ) {
357
-		if ( ! $overwrite && $this->exists( $destination ) ) {
358
-			return false;
359
-		}
360
-
361
-		$content = $this->get_contents( $source );
362
-
363
-		if ( false === $content ) {
364
-			return false;
365
-		}
366
-
367
-		return $this->put_contents( $destination, $content, $mode );
368
-	}
369
-
370
-	/**
371
-	 * Moves a file.
372
-	 *
373
-	 * @since 2.5.0
374
-	 *
375
-	 * @param string $source      Path to the source file.
376
-	 * @param string $destination Path to the destination file.
377
-	 * @param bool   $overwrite   Optional. Whether to overwrite the destination file if it exists.
378
-	 *                            Default false.
379
-	 * @return bool True on success, false on failure.
380
-	 */
381
-	public function move( $source, $destination, $overwrite = false ) {
382
-		return $this->ftp->rename( $source, $destination );
383
-	}
384
-
385
-	/**
386
-	 * Deletes a file or directory.
387
-	 *
388
-	 * @since 2.5.0
389
-	 *
390
-	 * @param string       $file      Path to the file or directory.
391
-	 * @param bool         $recursive Optional. If set to true, deletes files and folders recursively.
392
-	 *                                Default false.
393
-	 * @param string|false $type      Type of resource. 'f' for file, 'd' for directory.
394
-	 *                                Default false.
395
-	 * @return bool True on success, false on failure.
396
-	 */
397
-	public function delete( $file, $recursive = false, $type = false ) {
398
-		if ( empty( $file ) ) {
399
-			return false;
400
-		}
401
-
402
-		if ( 'f' === $type || $this->is_file( $file ) ) {
403
-			return $this->ftp->delete( $file );
404
-		}
405
-
406
-		if ( ! $recursive ) {
407
-			return $this->ftp->rmdir( $file );
408
-		}
409
-
410
-		return $this->ftp->mdel( $file );
411
-	}
412
-
413
-	/**
414
-	 * Checks if a file or directory exists.
415
-	 *
416
-	 * @since 2.5.0
417
-	 *
418
-	 * @param string $file Path to file or directory.
419
-	 * @return bool Whether $file exists or not.
420
-	 */
421
-	public function exists( $file ) {
422
-		$list = $this->ftp->nlist( $file );
423
-
424
-		if ( empty( $list ) && $this->is_dir( $file ) ) {
425
-			return true; // File is an empty directory.
426
-		}
427
-
428
-		return ! empty( $list ); // Empty list = no file, so invert.
429
-		// Return $this->ftp->is_exists($file); has issues with ABOR+426 responses on the ncFTPd server.
430
-	}
431
-
432
-	/**
433
-	 * Checks if resource is a file.
434
-	 *
435
-	 * @since 2.5.0
436
-	 *
437
-	 * @param string $file File path.
438
-	 * @return bool Whether $file is a file.
439
-	 */
440
-	public function is_file( $file ) {
441
-		if ( $this->is_dir( $file ) ) {
442
-			return false;
443
-		}
444
-
445
-		if ( $this->exists( $file ) ) {
446
-			return true;
447
-		}
448
-
449
-		return false;
450
-	}
451
-
452
-	/**
453
-	 * Checks if resource is a directory.
454
-	 *
455
-	 * @since 2.5.0
456
-	 *
457
-	 * @param string $path Directory path.
458
-	 * @return bool Whether $path is a directory.
459
-	 */
460
-	public function is_dir( $path ) {
461
-		$cwd = $this->cwd();
462
-
463
-		if ( $this->chdir( $path ) ) {
464
-			$this->chdir( $cwd );
465
-			return true;
466
-		}
467
-
468
-		return false;
469
-	}
470
-
471
-	/**
472
-	 * Checks if a file is readable.
473
-	 *
474
-	 * @since 2.5.0
475
-	 *
476
-	 * @param string $file Path to file.
477
-	 * @return bool Whether $file is readable.
478
-	 */
479
-	public function is_readable( $file ) {
480
-		return true;
481
-	}
482
-
483
-	/**
484
-	 * Checks if a file or directory is writable.
485
-	 *
486
-	 * @since 2.5.0
487
-	 *
488
-	 * @param string $file Path to file or directory.
489
-	 * @return bool Whether $file is writable.
490
-	 */
491
-	public function is_writable( $file ) {
492
-		return true;
493
-	}
494
-
495
-	/**
496
-	 * Gets the file's last access time.
497
-	 *
498
-	 * @since 2.5.0
499
-	 *
500
-	 * @param string $file Path to file.
501
-	 * @return int|false Unix timestamp representing last access time, false on failure.
502
-	 */
503
-	public function atime( $file ) {
504
-		return false;
505
-	}
506
-
507
-	/**
508
-	 * Gets the file modification time.
509
-	 *
510
-	 * @since 2.5.0
511
-	 *
512
-	 * @param string $file Path to file.
513
-	 * @return int|false Unix timestamp representing modification time, false on failure.
514
-	 */
515
-	public function mtime( $file ) {
516
-		return $this->ftp->mdtm( $file );
517
-	}
518
-
519
-	/**
520
-	 * Gets the file size (in bytes).
521
-	 *
522
-	 * @since 2.5.0
523
-	 *
524
-	 * @param string $file Path to file.
525
-	 * @return int|false Size of the file in bytes on success, false on failure.
526
-	 */
527
-	public function size( $file ) {
528
-		return $this->ftp->filesize( $file );
529
-	}
530
-
531
-	/**
532
-	 * Sets the access and modification times of a file.
533
-	 *
534
-	 * Note: If $file doesn't exist, it will be created.
535
-	 *
536
-	 * @since 2.5.0
537
-	 *
538
-	 * @param string $file  Path to file.
539
-	 * @param int    $time  Optional. Modified time to set for file.
540
-	 *                      Default 0.
541
-	 * @param int    $atime Optional. Access time to set for file.
542
-	 *                      Default 0.
543
-	 * @return bool True on success, false on failure.
544
-	 */
545
-	public function touch( $file, $time = 0, $atime = 0 ) {
546
-		return false;
547
-	}
548
-
549
-	/**
550
-	 * Creates a directory.
551
-	 *
552
-	 * @since 2.5.0
553
-	 *
554
-	 * @param string           $path  Path for new directory.
555
-	 * @param int|false        $chmod Optional. The permissions as octal number (or false to skip chmod).
556
-	 *                                Default false.
557
-	 * @param string|int|false $chown Optional. A user name or number (or false to skip chown).
558
-	 *                                Default false.
559
-	 * @param string|int|false $chgrp Optional. A group name or number (or false to skip chgrp).
560
-	 *                                Default false.
561
-	 * @return bool True on success, false on failure.
562
-	 */
563
-	public function mkdir( $path, $chmod = false, $chown = false, $chgrp = false ) {
564
-		$path = untrailingslashit( $path );
565
-
566
-		if ( empty( $path ) ) {
567
-			return false;
568
-		}
569
-
570
-		if ( ! $this->ftp->mkdir( $path ) ) {
571
-			return false;
572
-		}
573
-
574
-		if ( ! $chmod ) {
575
-			$chmod = FS_CHMOD_DIR;
576
-		}
577
-
578
-		$this->chmod( $path, $chmod );
579
-
580
-		return true;
581
-	}
582
-
583
-	/**
584
-	 * Deletes a directory.
585
-	 *
586
-	 * @since 2.5.0
587
-	 *
588
-	 * @param string $path      Path to directory.
589
-	 * @param bool   $recursive Optional. Whether to recursively remove files/directories.
590
-	 *                          Default false.
591
-	 * @return bool True on success, false on failure.
592
-	 */
593
-	public function rmdir( $path, $recursive = false ) {
594
-		return $this->delete( $path, $recursive );
595
-	}
596
-
597
-	/**
598
-	 * Gets details for files in a directory or a specific file.
599
-	 *
600
-	 * @since 2.5.0
601
-	 *
602
-	 * @param string $path           Path to directory or file.
603
-	 * @param bool   $include_hidden Optional. Whether to include details of hidden ("." prefixed) files.
604
-	 *                               Default true.
605
-	 * @param bool   $recursive      Optional. Whether to recursively include file details in nested directories.
606
-	 *                               Default false.
607
-	 * @return array|false {
608
-	 *     Array of files. False if unable to list directory contents.
609
-	 *
610
-	 *     @type string $name        Name of the file or directory.
611
-	 *     @type string $perms       *nix representation of permissions.
612
-	 *     @type string $permsn      Octal representation of permissions.
613
-	 *     @type string $owner       Owner name or ID.
614
-	 *     @type int    $size        Size of file in bytes.
615
-	 *     @type int    $lastmodunix Last modified unix timestamp.
616
-	 *     @type mixed  $lastmod     Last modified month (3 letter) and day (without leading 0).
617
-	 *     @type int    $time        Last modified time.
618
-	 *     @type string $type        Type of resource. 'f' for file, 'd' for directory.
619
-	 *     @type mixed  $files       If a directory and `$recursive` is true, contains another array of files.
620
-	 * }
621
-	 */
622
-	public function dirlist( $path = '.', $include_hidden = true, $recursive = false ) {
623
-		if ( $this->is_file( $path ) ) {
624
-			$limit_file = basename( $path );
625
-			$path       = dirname( $path ) . '/';
626
-		} else {
627
-			$limit_file = false;
628
-		}
629
-
630
-		mbstring_binary_safe_encoding();
631
-
632
-		$list = $this->ftp->dirlist( $path );
633
-
634
-		if ( empty( $list ) && ! $this->exists( $path ) ) {
635
-
636
-			reset_mbstring_encoding();
637
-
638
-			return false;
639
-		}
640
-
641
-		$ret = array();
642
-
643
-		foreach ( $list as $struc ) {
644
-
645
-			if ( '.' === $struc['name'] || '..' === $struc['name'] ) {
646
-				continue;
647
-			}
648
-
649
-			if ( ! $include_hidden && '.' === $struc['name'][0] ) {
650
-				continue;
651
-			}
652
-
653
-			if ( $limit_file && $struc['name'] !== $limit_file ) {
654
-				continue;
655
-			}
656
-
657
-			if ( 'd' === $struc['type'] ) {
658
-				if ( $recursive ) {
659
-					$struc['files'] = $this->dirlist( $path . '/' . $struc['name'], $include_hidden, $recursive );
660
-				} else {
661
-					$struc['files'] = array();
662
-				}
663
-			}
664
-
665
-			// Replace symlinks formatted as "source -> target" with just the source name.
666
-			if ( $struc['islink'] ) {
667
-				$struc['name'] = preg_replace( '/(\s*->\s*.*)$/', '', $struc['name'] );
668
-			}
669
-
670
-			// Add the octal representation of the file permissions.
671
-			$struc['permsn'] = $this->getnumchmodfromh( $struc['perms'] );
672
-
673
-			$ret[ $struc['name'] ] = $struc;
674
-		}
675
-
676
-		reset_mbstring_encoding();
677
-
678
-		return $ret;
679
-	}
680
-
681
-	/**
682
-	 * Destructor.
683
-	 *
684
-	 * @since 2.5.0
685
-	 */
686
-	public function __destruct() {
687
-		$this->ftp->quit();
688
-	}
18
+    /**
19
+     * @since 2.5.0
20
+     * @var ftp
21
+     */
22
+    public $ftp;
23
+
24
+    /**
25
+     * Constructor.
26
+     *
27
+     * @since 2.5.0
28
+     *
29
+     * @param array $opt
30
+     */
31
+    public function __construct( $opt = '' ) {
32
+        $this->method = 'ftpsockets';
33
+        $this->errors = new WP_Error();
34
+
35
+        // Check if possible to use ftp functions.
36
+        if ( ! include_once ABSPATH . 'wp-admin/includes/class-ftp.php' ) {
37
+            return;
38
+        }
39
+
40
+        $this->ftp = new ftp();
41
+
42
+        if ( empty( $opt['port'] ) ) {
43
+            $this->options['port'] = 21;
44
+        } else {
45
+            $this->options['port'] = (int) $opt['port'];
46
+        }
47
+
48
+        if ( empty( $opt['hostname'] ) ) {
49
+            $this->errors->add( 'empty_hostname', __( 'FTP hostname is required' ) );
50
+        } else {
51
+            $this->options['hostname'] = $opt['hostname'];
52
+        }
53
+
54
+        // Check if the options provided are OK.
55
+        if ( empty( $opt['username'] ) ) {
56
+            $this->errors->add( 'empty_username', __( 'FTP username is required' ) );
57
+        } else {
58
+            $this->options['username'] = $opt['username'];
59
+        }
60
+
61
+        if ( empty( $opt['password'] ) ) {
62
+            $this->errors->add( 'empty_password', __( 'FTP password is required' ) );
63
+        } else {
64
+            $this->options['password'] = $opt['password'];
65
+        }
66
+    }
67
+
68
+    /**
69
+     * Connects filesystem.
70
+     *
71
+     * @since 2.5.0
72
+     *
73
+     * @return bool True on success, false on failure.
74
+     */
75
+    public function connect() {
76
+        if ( ! $this->ftp ) {
77
+            return false;
78
+        }
79
+
80
+        $this->ftp->setTimeout( FS_CONNECT_TIMEOUT );
81
+
82
+        if ( ! $this->ftp->SetServer( $this->options['hostname'], $this->options['port'] ) ) {
83
+            $this->errors->add(
84
+                'connect',
85
+                sprintf(
86
+                    /* translators: %s: hostname:port */
87
+                    __( 'Failed to connect to FTP Server %s' ),
88
+                    $this->options['hostname'] . ':' . $this->options['port']
89
+                )
90
+            );
91
+
92
+            return false;
93
+        }
94
+
95
+        if ( ! $this->ftp->connect() ) {
96
+            $this->errors->add(
97
+                'connect',
98
+                sprintf(
99
+                    /* translators: %s: hostname:port */
100
+                    __( 'Failed to connect to FTP Server %s' ),
101
+                    $this->options['hostname'] . ':' . $this->options['port']
102
+                )
103
+            );
104
+
105
+            return false;
106
+        }
107
+
108
+        if ( ! $this->ftp->login( $this->options['username'], $this->options['password'] ) ) {
109
+            $this->errors->add(
110
+                'auth',
111
+                sprintf(
112
+                    /* translators: %s: Username. */
113
+                    __( 'Username/Password incorrect for %s' ),
114
+                    $this->options['username']
115
+                )
116
+            );
117
+
118
+            return false;
119
+        }
120
+
121
+        $this->ftp->SetType( FTP_BINARY );
122
+        $this->ftp->Passive( true );
123
+        $this->ftp->setTimeout( FS_TIMEOUT );
124
+
125
+        return true;
126
+    }
127
+
128
+    /**
129
+     * Reads entire file into a string.
130
+     *
131
+     * @since 2.5.0
132
+     *
133
+     * @param string $file Name of the file to read.
134
+     * @return string|false Read data on success, false if no temporary file could be opened,
135
+     *                      or if the file couldn't be retrieved.
136
+     */
137
+    public function get_contents( $file ) {
138
+        if ( ! $this->exists( $file ) ) {
139
+            return false;
140
+        }
141
+
142
+        $tempfile   = wp_tempnam( $file );
143
+        $temphandle = fopen( $tempfile, 'w+' );
144
+
145
+        if ( ! $temphandle ) {
146
+            unlink( $tempfile );
147
+            return false;
148
+        }
149
+
150
+        mbstring_binary_safe_encoding();
151
+
152
+        if ( ! $this->ftp->fget( $temphandle, $file ) ) {
153
+            fclose( $temphandle );
154
+            unlink( $tempfile );
155
+
156
+            reset_mbstring_encoding();
157
+
158
+            return ''; // Blank document. File does exist, it's just blank.
159
+        }
160
+
161
+        reset_mbstring_encoding();
162
+
163
+        fseek( $temphandle, 0 ); // Skip back to the start of the file being written to.
164
+        $contents = '';
165
+
166
+        while ( ! feof( $temphandle ) ) {
167
+            $contents .= fread( $temphandle, 8 * KB_IN_BYTES );
168
+        }
169
+
170
+        fclose( $temphandle );
171
+        unlink( $tempfile );
172
+
173
+        return $contents;
174
+    }
175
+
176
+    /**
177
+     * Reads entire file into an array.
178
+     *
179
+     * @since 2.5.0
180
+     *
181
+     * @param string $file Path to the file.
182
+     * @return array|false File contents in an array on success, false on failure.
183
+     */
184
+    public function get_contents_array( $file ) {
185
+        return explode( "\n", $this->get_contents( $file ) );
186
+    }
187
+
188
+    /**
189
+     * Writes a string to a file.
190
+     *
191
+     * @since 2.5.0
192
+     *
193
+     * @param string    $file     Remote path to the file where to write the data.
194
+     * @param string    $contents The data to write.
195
+     * @param int|false $mode     Optional. The file permissions as octal number, usually 0644.
196
+     *                            Default false.
197
+     * @return bool True on success, false on failure.
198
+     */
199
+    public function put_contents( $file, $contents, $mode = false ) {
200
+        $tempfile   = wp_tempnam( $file );
201
+        $temphandle = @fopen( $tempfile, 'w+' );
202
+
203
+        if ( ! $temphandle ) {
204
+            unlink( $tempfile );
205
+            return false;
206
+        }
207
+
208
+        // The FTP class uses string functions internally during file download/upload.
209
+        mbstring_binary_safe_encoding();
210
+
211
+        $bytes_written = fwrite( $temphandle, $contents );
212
+
213
+        if ( false === $bytes_written || strlen( $contents ) !== $bytes_written ) {
214
+            fclose( $temphandle );
215
+            unlink( $tempfile );
216
+
217
+            reset_mbstring_encoding();
218
+
219
+            return false;
220
+        }
221
+
222
+        fseek( $temphandle, 0 ); // Skip back to the start of the file being written to.
223
+
224
+        $ret = $this->ftp->fput( $file, $temphandle );
225
+
226
+        reset_mbstring_encoding();
227
+
228
+        fclose( $temphandle );
229
+        unlink( $tempfile );
230
+
231
+        $this->chmod( $file, $mode );
232
+
233
+        return $ret;
234
+    }
235
+
236
+    /**
237
+     * Gets the current working directory.
238
+     *
239
+     * @since 2.5.0
240
+     *
241
+     * @return string|false The current working directory on success, false on failure.
242
+     */
243
+    public function cwd() {
244
+        $cwd = $this->ftp->pwd();
245
+
246
+        if ( $cwd ) {
247
+            $cwd = trailingslashit( $cwd );
248
+        }
249
+
250
+        return $cwd;
251
+    }
252
+
253
+    /**
254
+     * Changes current directory.
255
+     *
256
+     * @since 2.5.0
257
+     *
258
+     * @param string $dir The new current directory.
259
+     * @return bool True on success, false on failure.
260
+     */
261
+    public function chdir( $dir ) {
262
+        return $this->ftp->chdir( $dir );
263
+    }
264
+
265
+    /**
266
+     * Changes filesystem permissions.
267
+     *
268
+     * @since 2.5.0
269
+     *
270
+     * @param string    $file      Path to the file.
271
+     * @param int|false $mode      Optional. The permissions as octal number, usually 0644 for files,
272
+     *                             0755 for directories. Default false.
273
+     * @param bool      $recursive Optional. If set to true, changes file permissions recursively.
274
+     *                             Default false.
275
+     * @return bool True on success, false on failure.
276
+     */
277
+    public function chmod( $file, $mode = false, $recursive = false ) {
278
+        if ( ! $mode ) {
279
+            if ( $this->is_file( $file ) ) {
280
+                $mode = FS_CHMOD_FILE;
281
+            } elseif ( $this->is_dir( $file ) ) {
282
+                $mode = FS_CHMOD_DIR;
283
+            } else {
284
+                return false;
285
+            }
286
+        }
287
+
288
+        // chmod any sub-objects if recursive.
289
+        if ( $recursive && $this->is_dir( $file ) ) {
290
+            $filelist = $this->dirlist( $file );
291
+
292
+            foreach ( (array) $filelist as $filename => $filemeta ) {
293
+                $this->chmod( $file . '/' . $filename, $mode, $recursive );
294
+            }
295
+        }
296
+
297
+        // chmod the file or directory.
298
+        return $this->ftp->chmod( $file, $mode );
299
+    }
300
+
301
+    /**
302
+     * Gets the file owner.
303
+     *
304
+     * @since 2.5.0
305
+     *
306
+     * @param string $file Path to the file.
307
+     * @return string|false Username of the owner on success, false on failure.
308
+     */
309
+    public function owner( $file ) {
310
+        $dir = $this->dirlist( $file );
311
+
312
+        return $dir[ $file ]['owner'];
313
+    }
314
+
315
+    /**
316
+     * Gets the permissions of the specified file or filepath in their octal format.
317
+     *
318
+     * @since 2.5.0
319
+     *
320
+     * @param string $file Path to the file.
321
+     * @return string Mode of the file (the last 3 digits).
322
+     */
323
+    public function getchmod( $file ) {
324
+        $dir = $this->dirlist( $file );
325
+
326
+        return $dir[ $file ]['permsn'];
327
+    }
328
+
329
+    /**
330
+     * Gets the file's group.
331
+     *
332
+     * @since 2.5.0
333
+     *
334
+     * @param string $file Path to the file.
335
+     * @return string|false The group on success, false on failure.
336
+     */
337
+    public function group( $file ) {
338
+        $dir = $this->dirlist( $file );
339
+
340
+        return $dir[ $file ]['group'];
341
+    }
342
+
343
+    /**
344
+     * Copies a file.
345
+     *
346
+     * @since 2.5.0
347
+     *
348
+     * @param string    $source      Path to the source file.
349
+     * @param string    $destination Path to the destination file.
350
+     * @param bool      $overwrite   Optional. Whether to overwrite the destination file if it exists.
351
+     *                               Default false.
352
+     * @param int|false $mode        Optional. The permissions as octal number, usually 0644 for files,
353
+     *                               0755 for dirs. Default false.
354
+     * @return bool True on success, false on failure.
355
+     */
356
+    public function copy( $source, $destination, $overwrite = false, $mode = false ) {
357
+        if ( ! $overwrite && $this->exists( $destination ) ) {
358
+            return false;
359
+        }
360
+
361
+        $content = $this->get_contents( $source );
362
+
363
+        if ( false === $content ) {
364
+            return false;
365
+        }
366
+
367
+        return $this->put_contents( $destination, $content, $mode );
368
+    }
369
+
370
+    /**
371
+     * Moves a file.
372
+     *
373
+     * @since 2.5.0
374
+     *
375
+     * @param string $source      Path to the source file.
376
+     * @param string $destination Path to the destination file.
377
+     * @param bool   $overwrite   Optional. Whether to overwrite the destination file if it exists.
378
+     *                            Default false.
379
+     * @return bool True on success, false on failure.
380
+     */
381
+    public function move( $source, $destination, $overwrite = false ) {
382
+        return $this->ftp->rename( $source, $destination );
383
+    }
384
+
385
+    /**
386
+     * Deletes a file or directory.
387
+     *
388
+     * @since 2.5.0
389
+     *
390
+     * @param string       $file      Path to the file or directory.
391
+     * @param bool         $recursive Optional. If set to true, deletes files and folders recursively.
392
+     *                                Default false.
393
+     * @param string|false $type      Type of resource. 'f' for file, 'd' for directory.
394
+     *                                Default false.
395
+     * @return bool True on success, false on failure.
396
+     */
397
+    public function delete( $file, $recursive = false, $type = false ) {
398
+        if ( empty( $file ) ) {
399
+            return false;
400
+        }
401
+
402
+        if ( 'f' === $type || $this->is_file( $file ) ) {
403
+            return $this->ftp->delete( $file );
404
+        }
405
+
406
+        if ( ! $recursive ) {
407
+            return $this->ftp->rmdir( $file );
408
+        }
409
+
410
+        return $this->ftp->mdel( $file );
411
+    }
412
+
413
+    /**
414
+     * Checks if a file or directory exists.
415
+     *
416
+     * @since 2.5.0
417
+     *
418
+     * @param string $file Path to file or directory.
419
+     * @return bool Whether $file exists or not.
420
+     */
421
+    public function exists( $file ) {
422
+        $list = $this->ftp->nlist( $file );
423
+
424
+        if ( empty( $list ) && $this->is_dir( $file ) ) {
425
+            return true; // File is an empty directory.
426
+        }
427
+
428
+        return ! empty( $list ); // Empty list = no file, so invert.
429
+        // Return $this->ftp->is_exists($file); has issues with ABOR+426 responses on the ncFTPd server.
430
+    }
431
+
432
+    /**
433
+     * Checks if resource is a file.
434
+     *
435
+     * @since 2.5.0
436
+     *
437
+     * @param string $file File path.
438
+     * @return bool Whether $file is a file.
439
+     */
440
+    public function is_file( $file ) {
441
+        if ( $this->is_dir( $file ) ) {
442
+            return false;
443
+        }
444
+
445
+        if ( $this->exists( $file ) ) {
446
+            return true;
447
+        }
448
+
449
+        return false;
450
+    }
451
+
452
+    /**
453
+     * Checks if resource is a directory.
454
+     *
455
+     * @since 2.5.0
456
+     *
457
+     * @param string $path Directory path.
458
+     * @return bool Whether $path is a directory.
459
+     */
460
+    public function is_dir( $path ) {
461
+        $cwd = $this->cwd();
462
+
463
+        if ( $this->chdir( $path ) ) {
464
+            $this->chdir( $cwd );
465
+            return true;
466
+        }
467
+
468
+        return false;
469
+    }
470
+
471
+    /**
472
+     * Checks if a file is readable.
473
+     *
474
+     * @since 2.5.0
475
+     *
476
+     * @param string $file Path to file.
477
+     * @return bool Whether $file is readable.
478
+     */
479
+    public function is_readable( $file ) {
480
+        return true;
481
+    }
482
+
483
+    /**
484
+     * Checks if a file or directory is writable.
485
+     *
486
+     * @since 2.5.0
487
+     *
488
+     * @param string $file Path to file or directory.
489
+     * @return bool Whether $file is writable.
490
+     */
491
+    public function is_writable( $file ) {
492
+        return true;
493
+    }
494
+
495
+    /**
496
+     * Gets the file's last access time.
497
+     *
498
+     * @since 2.5.0
499
+     *
500
+     * @param string $file Path to file.
501
+     * @return int|false Unix timestamp representing last access time, false on failure.
502
+     */
503
+    public function atime( $file ) {
504
+        return false;
505
+    }
506
+
507
+    /**
508
+     * Gets the file modification time.
509
+     *
510
+     * @since 2.5.0
511
+     *
512
+     * @param string $file Path to file.
513
+     * @return int|false Unix timestamp representing modification time, false on failure.
514
+     */
515
+    public function mtime( $file ) {
516
+        return $this->ftp->mdtm( $file );
517
+    }
518
+
519
+    /**
520
+     * Gets the file size (in bytes).
521
+     *
522
+     * @since 2.5.0
523
+     *
524
+     * @param string $file Path to file.
525
+     * @return int|false Size of the file in bytes on success, false on failure.
526
+     */
527
+    public function size( $file ) {
528
+        return $this->ftp->filesize( $file );
529
+    }
530
+
531
+    /**
532
+     * Sets the access and modification times of a file.
533
+     *
534
+     * Note: If $file doesn't exist, it will be created.
535
+     *
536
+     * @since 2.5.0
537
+     *
538
+     * @param string $file  Path to file.
539
+     * @param int    $time  Optional. Modified time to set for file.
540
+     *                      Default 0.
541
+     * @param int    $atime Optional. Access time to set for file.
542
+     *                      Default 0.
543
+     * @return bool True on success, false on failure.
544
+     */
545
+    public function touch( $file, $time = 0, $atime = 0 ) {
546
+        return false;
547
+    }
548
+
549
+    /**
550
+     * Creates a directory.
551
+     *
552
+     * @since 2.5.0
553
+     *
554
+     * @param string           $path  Path for new directory.
555
+     * @param int|false        $chmod Optional. The permissions as octal number (or false to skip chmod).
556
+     *                                Default false.
557
+     * @param string|int|false $chown Optional. A user name or number (or false to skip chown).
558
+     *                                Default false.
559
+     * @param string|int|false $chgrp Optional. A group name or number (or false to skip chgrp).
560
+     *                                Default false.
561
+     * @return bool True on success, false on failure.
562
+     */
563
+    public function mkdir( $path, $chmod = false, $chown = false, $chgrp = false ) {
564
+        $path = untrailingslashit( $path );
565
+
566
+        if ( empty( $path ) ) {
567
+            return false;
568
+        }
569
+
570
+        if ( ! $this->ftp->mkdir( $path ) ) {
571
+            return false;
572
+        }
573
+
574
+        if ( ! $chmod ) {
575
+            $chmod = FS_CHMOD_DIR;
576
+        }
577
+
578
+        $this->chmod( $path, $chmod );
579
+
580
+        return true;
581
+    }
582
+
583
+    /**
584
+     * Deletes a directory.
585
+     *
586
+     * @since 2.5.0
587
+     *
588
+     * @param string $path      Path to directory.
589
+     * @param bool   $recursive Optional. Whether to recursively remove files/directories.
590
+     *                          Default false.
591
+     * @return bool True on success, false on failure.
592
+     */
593
+    public function rmdir( $path, $recursive = false ) {
594
+        return $this->delete( $path, $recursive );
595
+    }
596
+
597
+    /**
598
+     * Gets details for files in a directory or a specific file.
599
+     *
600
+     * @since 2.5.0
601
+     *
602
+     * @param string $path           Path to directory or file.
603
+     * @param bool   $include_hidden Optional. Whether to include details of hidden ("." prefixed) files.
604
+     *                               Default true.
605
+     * @param bool   $recursive      Optional. Whether to recursively include file details in nested directories.
606
+     *                               Default false.
607
+     * @return array|false {
608
+     *     Array of files. False if unable to list directory contents.
609
+     *
610
+     *     @type string $name        Name of the file or directory.
611
+     *     @type string $perms       *nix representation of permissions.
612
+     *     @type string $permsn      Octal representation of permissions.
613
+     *     @type string $owner       Owner name or ID.
614
+     *     @type int    $size        Size of file in bytes.
615
+     *     @type int    $lastmodunix Last modified unix timestamp.
616
+     *     @type mixed  $lastmod     Last modified month (3 letter) and day (without leading 0).
617
+     *     @type int    $time        Last modified time.
618
+     *     @type string $type        Type of resource. 'f' for file, 'd' for directory.
619
+     *     @type mixed  $files       If a directory and `$recursive` is true, contains another array of files.
620
+     * }
621
+     */
622
+    public function dirlist( $path = '.', $include_hidden = true, $recursive = false ) {
623
+        if ( $this->is_file( $path ) ) {
624
+            $limit_file = basename( $path );
625
+            $path       = dirname( $path ) . '/';
626
+        } else {
627
+            $limit_file = false;
628
+        }
629
+
630
+        mbstring_binary_safe_encoding();
631
+
632
+        $list = $this->ftp->dirlist( $path );
633
+
634
+        if ( empty( $list ) && ! $this->exists( $path ) ) {
635
+
636
+            reset_mbstring_encoding();
637
+
638
+            return false;
639
+        }
640
+
641
+        $ret = array();
642
+
643
+        foreach ( $list as $struc ) {
644
+
645
+            if ( '.' === $struc['name'] || '..' === $struc['name'] ) {
646
+                continue;
647
+            }
648
+
649
+            if ( ! $include_hidden && '.' === $struc['name'][0] ) {
650
+                continue;
651
+            }
652
+
653
+            if ( $limit_file && $struc['name'] !== $limit_file ) {
654
+                continue;
655
+            }
656
+
657
+            if ( 'd' === $struc['type'] ) {
658
+                if ( $recursive ) {
659
+                    $struc['files'] = $this->dirlist( $path . '/' . $struc['name'], $include_hidden, $recursive );
660
+                } else {
661
+                    $struc['files'] = array();
662
+                }
663
+            }
664
+
665
+            // Replace symlinks formatted as "source -> target" with just the source name.
666
+            if ( $struc['islink'] ) {
667
+                $struc['name'] = preg_replace( '/(\s*->\s*.*)$/', '', $struc['name'] );
668
+            }
669
+
670
+            // Add the octal representation of the file permissions.
671
+            $struc['permsn'] = $this->getnumchmodfromh( $struc['perms'] );
672
+
673
+            $ret[ $struc['name'] ] = $struc;
674
+        }
675
+
676
+        reset_mbstring_encoding();
677
+
678
+        return $ret;
679
+    }
680
+
681
+    /**
682
+     * Destructor.
683
+     *
684
+     * @since 2.5.0
685
+     */
686
+    public function __destruct() {
687
+        $this->ftp->quit();
688
+    }
689 689
 }
Please login to merge, or discard this patch.
brighty/wp-admin/includes/class-wp-terms-list-table.php 1 patch
Indentation   +650 added lines, -650 removed lines patch added patch discarded remove patch
@@ -17,639 +17,639 @@  discard block
 block discarded – undo
17 17
  */
18 18
 class WP_Terms_List_Table extends WP_List_Table {
19 19
 
20
-	public $callback_args;
21
-
22
-	private $level;
23
-
24
-	/**
25
-	 * Constructor.
26
-	 *
27
-	 * @since 3.1.0
28
-	 *
29
-	 * @see WP_List_Table::__construct() for more information on default arguments.
30
-	 *
31
-	 * @global string $post_type
32
-	 * @global string $taxonomy
33
-	 * @global string $action
34
-	 * @global object $tax
35
-	 *
36
-	 * @param array $args An associative array of arguments.
37
-	 */
38
-	public function __construct( $args = array() ) {
39
-		global $post_type, $taxonomy, $action, $tax;
40
-
41
-		parent::__construct(
42
-			array(
43
-				'plural'   => 'tags',
44
-				'singular' => 'tag',
45
-				'screen'   => isset( $args['screen'] ) ? $args['screen'] : null,
46
-			)
47
-		);
48
-
49
-		$action    = $this->screen->action;
50
-		$post_type = $this->screen->post_type;
51
-		$taxonomy  = $this->screen->taxonomy;
52
-
53
-		if ( empty( $taxonomy ) ) {
54
-			$taxonomy = 'post_tag';
55
-		}
56
-
57
-		if ( ! taxonomy_exists( $taxonomy ) ) {
58
-			wp_die( __( 'Invalid taxonomy.' ) );
59
-		}
60
-
61
-		$tax = get_taxonomy( $taxonomy );
62
-
63
-		// @todo Still needed? Maybe just the show_ui part.
64
-		if ( empty( $post_type ) || ! in_array( $post_type, get_post_types( array( 'show_ui' => true ) ), true ) ) {
65
-			$post_type = 'post';
66
-		}
67
-
68
-	}
69
-
70
-	/**
71
-	 * @return bool
72
-	 */
73
-	public function ajax_user_can() {
74
-		return current_user_can( get_taxonomy( $this->screen->taxonomy )->cap->manage_terms );
75
-	}
76
-
77
-	/**
78
-	 */
79
-	public function prepare_items() {
80
-		$taxonomy = $this->screen->taxonomy;
81
-
82
-		$tags_per_page = $this->get_items_per_page( "edit_{$taxonomy}_per_page" );
83
-
84
-		if ( 'post_tag' === $taxonomy ) {
85
-			/**
86
-			 * Filters the number of terms displayed per page for the Tags list table.
87
-			 *
88
-			 * @since 2.8.0
89
-			 *
90
-			 * @param int $tags_per_page Number of tags to be displayed. Default 20.
91
-			 */
92
-			$tags_per_page = apply_filters( 'edit_tags_per_page', $tags_per_page );
93
-
94
-			/**
95
-			 * Filters the number of terms displayed per page for the Tags list table.
96
-			 *
97
-			 * @since 2.7.0
98
-			 * @deprecated 2.8.0 Use {@see 'edit_tags_per_page'} instead.
99
-			 *
100
-			 * @param int $tags_per_page Number of tags to be displayed. Default 20.
101
-			 */
102
-			$tags_per_page = apply_filters_deprecated( 'tagsperpage', array( $tags_per_page ), '2.8.0', 'edit_tags_per_page' );
103
-		} elseif ( 'category' === $taxonomy ) {
104
-			/**
105
-			 * Filters the number of terms displayed per page for the Categories list table.
106
-			 *
107
-			 * @since 2.8.0
108
-			 *
109
-			 * @param int $tags_per_page Number of categories to be displayed. Default 20.
110
-			 */
111
-			$tags_per_page = apply_filters( 'edit_categories_per_page', $tags_per_page );
112
-		}
113
-
114
-		$search = ! empty( $_REQUEST['s'] ) ? trim( wp_unslash( $_REQUEST['s'] ) ) : '';
115
-
116
-		$args = array(
117
-			'taxonomy'   => $taxonomy,
118
-			'search'     => $search,
119
-			'page'       => $this->get_pagenum(),
120
-			'number'     => $tags_per_page,
121
-			'hide_empty' => 0,
122
-		);
123
-
124
-		if ( ! empty( $_REQUEST['orderby'] ) ) {
125
-			$args['orderby'] = trim( wp_unslash( $_REQUEST['orderby'] ) );
126
-		}
127
-
128
-		if ( ! empty( $_REQUEST['order'] ) ) {
129
-			$args['order'] = trim( wp_unslash( $_REQUEST['order'] ) );
130
-		}
131
-
132
-		$args['offset'] = ( $args['page'] - 1 ) * $args['number'];
133
-
134
-		// Save the values because 'number' and 'offset' can be subsequently overridden.
135
-		$this->callback_args = $args;
136
-
137
-		if ( is_taxonomy_hierarchical( $taxonomy ) && ! isset( $args['orderby'] ) ) {
138
-			// We'll need the full set of terms then.
139
-			$args['number'] = 0;
140
-			$args['offset'] = $args['number'];
141
-		}
142
-
143
-		$this->items = get_terms( $args );
144
-
145
-		$this->set_pagination_args(
146
-			array(
147
-				'total_items' => wp_count_terms(
148
-					array(
149
-						'taxonomy' => $taxonomy,
150
-						'search'   => $search,
151
-					)
152
-				),
153
-				'per_page'    => $tags_per_page,
154
-			)
155
-		);
156
-	}
157
-
158
-	/**
159
-	 */
160
-	public function no_items() {
161
-		echo get_taxonomy( $this->screen->taxonomy )->labels->not_found;
162
-	}
163
-
164
-	/**
165
-	 * @return array
166
-	 */
167
-	protected function get_bulk_actions() {
168
-		$actions = array();
169
-
170
-		if ( current_user_can( get_taxonomy( $this->screen->taxonomy )->cap->delete_terms ) ) {
171
-			$actions['delete'] = __( 'Delete' );
172
-		}
173
-
174
-		return $actions;
175
-	}
176
-
177
-	/**
178
-	 * @return string
179
-	 */
180
-	public function current_action() {
181
-		if ( isset( $_REQUEST['action'] ) && isset( $_REQUEST['delete_tags'] ) && 'delete' === $_REQUEST['action'] ) {
182
-			return 'bulk-delete';
183
-		}
184
-
185
-		return parent::current_action();
186
-	}
187
-
188
-	/**
189
-	 * @return array
190
-	 */
191
-	public function get_columns() {
192
-		$columns = array(
193
-			'cb'          => '<input type="checkbox" />',
194
-			'name'        => _x( 'Name', 'term name' ),
195
-			'description' => __( 'Description' ),
196
-			'slug'        => __( 'Slug' ),
197
-		);
198
-
199
-		if ( 'link_category' === $this->screen->taxonomy ) {
200
-			$columns['links'] = __( 'Links' );
201
-		} else {
202
-			$columns['posts'] = _x( 'Count', 'Number/count of items' );
203
-		}
204
-
205
-		return $columns;
206
-	}
207
-
208
-	/**
209
-	 * @return array
210
-	 */
211
-	protected function get_sortable_columns() {
212
-		return array(
213
-			'name'        => 'name',
214
-			'description' => 'description',
215
-			'slug'        => 'slug',
216
-			'posts'       => 'count',
217
-			'links'       => 'count',
218
-		);
219
-	}
220
-
221
-	/**
222
-	 */
223
-	public function display_rows_or_placeholder() {
224
-		$taxonomy = $this->screen->taxonomy;
225
-
226
-		$number = $this->callback_args['number'];
227
-		$offset = $this->callback_args['offset'];
228
-
229
-		// Convert it to table rows.
230
-		$count = 0;
231
-
232
-		if ( empty( $this->items ) || ! is_array( $this->items ) ) {
233
-			echo '<tr class="no-items"><td class="colspanchange" colspan="' . $this->get_column_count() . '">';
234
-			$this->no_items();
235
-			echo '</td></tr>';
236
-			return;
237
-		}
238
-
239
-		if ( is_taxonomy_hierarchical( $taxonomy ) && ! isset( $this->callback_args['orderby'] ) ) {
240
-			if ( ! empty( $this->callback_args['search'] ) ) {// Ignore children on searches.
241
-				$children = array();
242
-			} else {
243
-				$children = _get_term_hierarchy( $taxonomy );
244
-			}
245
-
246
-			/*
20
+    public $callback_args;
21
+
22
+    private $level;
23
+
24
+    /**
25
+     * Constructor.
26
+     *
27
+     * @since 3.1.0
28
+     *
29
+     * @see WP_List_Table::__construct() for more information on default arguments.
30
+     *
31
+     * @global string $post_type
32
+     * @global string $taxonomy
33
+     * @global string $action
34
+     * @global object $tax
35
+     *
36
+     * @param array $args An associative array of arguments.
37
+     */
38
+    public function __construct( $args = array() ) {
39
+        global $post_type, $taxonomy, $action, $tax;
40
+
41
+        parent::__construct(
42
+            array(
43
+                'plural'   => 'tags',
44
+                'singular' => 'tag',
45
+                'screen'   => isset( $args['screen'] ) ? $args['screen'] : null,
46
+            )
47
+        );
48
+
49
+        $action    = $this->screen->action;
50
+        $post_type = $this->screen->post_type;
51
+        $taxonomy  = $this->screen->taxonomy;
52
+
53
+        if ( empty( $taxonomy ) ) {
54
+            $taxonomy = 'post_tag';
55
+        }
56
+
57
+        if ( ! taxonomy_exists( $taxonomy ) ) {
58
+            wp_die( __( 'Invalid taxonomy.' ) );
59
+        }
60
+
61
+        $tax = get_taxonomy( $taxonomy );
62
+
63
+        // @todo Still needed? Maybe just the show_ui part.
64
+        if ( empty( $post_type ) || ! in_array( $post_type, get_post_types( array( 'show_ui' => true ) ), true ) ) {
65
+            $post_type = 'post';
66
+        }
67
+
68
+    }
69
+
70
+    /**
71
+     * @return bool
72
+     */
73
+    public function ajax_user_can() {
74
+        return current_user_can( get_taxonomy( $this->screen->taxonomy )->cap->manage_terms );
75
+    }
76
+
77
+    /**
78
+     */
79
+    public function prepare_items() {
80
+        $taxonomy = $this->screen->taxonomy;
81
+
82
+        $tags_per_page = $this->get_items_per_page( "edit_{$taxonomy}_per_page" );
83
+
84
+        if ( 'post_tag' === $taxonomy ) {
85
+            /**
86
+             * Filters the number of terms displayed per page for the Tags list table.
87
+             *
88
+             * @since 2.8.0
89
+             *
90
+             * @param int $tags_per_page Number of tags to be displayed. Default 20.
91
+             */
92
+            $tags_per_page = apply_filters( 'edit_tags_per_page', $tags_per_page );
93
+
94
+            /**
95
+             * Filters the number of terms displayed per page for the Tags list table.
96
+             *
97
+             * @since 2.7.0
98
+             * @deprecated 2.8.0 Use {@see 'edit_tags_per_page'} instead.
99
+             *
100
+             * @param int $tags_per_page Number of tags to be displayed. Default 20.
101
+             */
102
+            $tags_per_page = apply_filters_deprecated( 'tagsperpage', array( $tags_per_page ), '2.8.0', 'edit_tags_per_page' );
103
+        } elseif ( 'category' === $taxonomy ) {
104
+            /**
105
+             * Filters the number of terms displayed per page for the Categories list table.
106
+             *
107
+             * @since 2.8.0
108
+             *
109
+             * @param int $tags_per_page Number of categories to be displayed. Default 20.
110
+             */
111
+            $tags_per_page = apply_filters( 'edit_categories_per_page', $tags_per_page );
112
+        }
113
+
114
+        $search = ! empty( $_REQUEST['s'] ) ? trim( wp_unslash( $_REQUEST['s'] ) ) : '';
115
+
116
+        $args = array(
117
+            'taxonomy'   => $taxonomy,
118
+            'search'     => $search,
119
+            'page'       => $this->get_pagenum(),
120
+            'number'     => $tags_per_page,
121
+            'hide_empty' => 0,
122
+        );
123
+
124
+        if ( ! empty( $_REQUEST['orderby'] ) ) {
125
+            $args['orderby'] = trim( wp_unslash( $_REQUEST['orderby'] ) );
126
+        }
127
+
128
+        if ( ! empty( $_REQUEST['order'] ) ) {
129
+            $args['order'] = trim( wp_unslash( $_REQUEST['order'] ) );
130
+        }
131
+
132
+        $args['offset'] = ( $args['page'] - 1 ) * $args['number'];
133
+
134
+        // Save the values because 'number' and 'offset' can be subsequently overridden.
135
+        $this->callback_args = $args;
136
+
137
+        if ( is_taxonomy_hierarchical( $taxonomy ) && ! isset( $args['orderby'] ) ) {
138
+            // We'll need the full set of terms then.
139
+            $args['number'] = 0;
140
+            $args['offset'] = $args['number'];
141
+        }
142
+
143
+        $this->items = get_terms( $args );
144
+
145
+        $this->set_pagination_args(
146
+            array(
147
+                'total_items' => wp_count_terms(
148
+                    array(
149
+                        'taxonomy' => $taxonomy,
150
+                        'search'   => $search,
151
+                    )
152
+                ),
153
+                'per_page'    => $tags_per_page,
154
+            )
155
+        );
156
+    }
157
+
158
+    /**
159
+     */
160
+    public function no_items() {
161
+        echo get_taxonomy( $this->screen->taxonomy )->labels->not_found;
162
+    }
163
+
164
+    /**
165
+     * @return array
166
+     */
167
+    protected function get_bulk_actions() {
168
+        $actions = array();
169
+
170
+        if ( current_user_can( get_taxonomy( $this->screen->taxonomy )->cap->delete_terms ) ) {
171
+            $actions['delete'] = __( 'Delete' );
172
+        }
173
+
174
+        return $actions;
175
+    }
176
+
177
+    /**
178
+     * @return string
179
+     */
180
+    public function current_action() {
181
+        if ( isset( $_REQUEST['action'] ) && isset( $_REQUEST['delete_tags'] ) && 'delete' === $_REQUEST['action'] ) {
182
+            return 'bulk-delete';
183
+        }
184
+
185
+        return parent::current_action();
186
+    }
187
+
188
+    /**
189
+     * @return array
190
+     */
191
+    public function get_columns() {
192
+        $columns = array(
193
+            'cb'          => '<input type="checkbox" />',
194
+            'name'        => _x( 'Name', 'term name' ),
195
+            'description' => __( 'Description' ),
196
+            'slug'        => __( 'Slug' ),
197
+        );
198
+
199
+        if ( 'link_category' === $this->screen->taxonomy ) {
200
+            $columns['links'] = __( 'Links' );
201
+        } else {
202
+            $columns['posts'] = _x( 'Count', 'Number/count of items' );
203
+        }
204
+
205
+        return $columns;
206
+    }
207
+
208
+    /**
209
+     * @return array
210
+     */
211
+    protected function get_sortable_columns() {
212
+        return array(
213
+            'name'        => 'name',
214
+            'description' => 'description',
215
+            'slug'        => 'slug',
216
+            'posts'       => 'count',
217
+            'links'       => 'count',
218
+        );
219
+    }
220
+
221
+    /**
222
+     */
223
+    public function display_rows_or_placeholder() {
224
+        $taxonomy = $this->screen->taxonomy;
225
+
226
+        $number = $this->callback_args['number'];
227
+        $offset = $this->callback_args['offset'];
228
+
229
+        // Convert it to table rows.
230
+        $count = 0;
231
+
232
+        if ( empty( $this->items ) || ! is_array( $this->items ) ) {
233
+            echo '<tr class="no-items"><td class="colspanchange" colspan="' . $this->get_column_count() . '">';
234
+            $this->no_items();
235
+            echo '</td></tr>';
236
+            return;
237
+        }
238
+
239
+        if ( is_taxonomy_hierarchical( $taxonomy ) && ! isset( $this->callback_args['orderby'] ) ) {
240
+            if ( ! empty( $this->callback_args['search'] ) ) {// Ignore children on searches.
241
+                $children = array();
242
+            } else {
243
+                $children = _get_term_hierarchy( $taxonomy );
244
+            }
245
+
246
+            /*
247 247
 			 * Some funky recursion to get the job done (paging & parents mainly) is contained within.
248 248
 			 * Skip it for non-hierarchical taxonomies for performance sake.
249 249
 			 */
250
-			$this->_rows( $taxonomy, $this->items, $children, $offset, $number, $count );
251
-		} else {
252
-			foreach ( $this->items as $term ) {
253
-				$this->single_row( $term );
254
-			}
255
-		}
256
-	}
257
-
258
-	/**
259
-	 * @param string $taxonomy
260
-	 * @param array  $terms
261
-	 * @param array  $children
262
-	 * @param int    $start
263
-	 * @param int    $per_page
264
-	 * @param int    $count
265
-	 * @param int    $parent_term
266
-	 * @param int    $level
267
-	 */
268
-	private function _rows( $taxonomy, $terms, &$children, $start, $per_page, &$count, $parent_term = 0, $level = 0 ) {
269
-
270
-		$end = $start + $per_page;
271
-
272
-		foreach ( $terms as $key => $term ) {
273
-
274
-			if ( $count >= $end ) {
275
-				break;
276
-			}
277
-
278
-			if ( $term->parent !== $parent_term && empty( $_REQUEST['s'] ) ) {
279
-				continue;
280
-			}
281
-
282
-			// If the page starts in a subtree, print the parents.
283
-			if ( $count === $start && $term->parent > 0 && empty( $_REQUEST['s'] ) ) {
284
-				$my_parents = array();
285
-				$parent_ids = array();
286
-				$p          = $term->parent;
287
-
288
-				while ( $p ) {
289
-					$my_parent    = get_term( $p, $taxonomy );
290
-					$my_parents[] = $my_parent;
291
-					$p            = $my_parent->parent;
292
-
293
-					if ( in_array( $p, $parent_ids, true ) ) { // Prevent parent loops.
294
-						break;
295
-					}
296
-
297
-					$parent_ids[] = $p;
298
-				}
299
-
300
-				unset( $parent_ids );
301
-
302
-				$num_parents = count( $my_parents );
303
-
304
-				while ( $my_parent = array_pop( $my_parents ) ) {
305
-					echo "\t";
306
-					$this->single_row( $my_parent, $level - $num_parents );
307
-					$num_parents--;
308
-				}
309
-			}
310
-
311
-			if ( $count >= $start ) {
312
-				echo "\t";
313
-				$this->single_row( $term, $level );
314
-			}
315
-
316
-			++$count;
317
-
318
-			unset( $terms[ $key ] );
319
-
320
-			if ( isset( $children[ $term->term_id ] ) && empty( $_REQUEST['s'] ) ) {
321
-				$this->_rows( $taxonomy, $terms, $children, $start, $per_page, $count, $term->term_id, $level + 1 );
322
-			}
323
-		}
324
-	}
325
-
326
-	/**
327
-	 * @global string $taxonomy
328
-	 * @param WP_Term $tag   Term object.
329
-	 * @param int     $level
330
-	 */
331
-	public function single_row( $tag, $level = 0 ) {
332
-		global $taxonomy;
333
-		$tag = sanitize_term( $tag, $taxonomy );
334
-
335
-		$this->level = $level;
336
-
337
-		if ( $tag->parent ) {
338
-			$count = count( get_ancestors( $tag->term_id, $taxonomy, 'taxonomy' ) );
339
-			$level = 'level-' . $count;
340
-		} else {
341
-			$level = 'level-0';
342
-		}
343
-
344
-		echo '<tr id="tag-' . $tag->term_id . '" class="' . $level . '">';
345
-		$this->single_row_columns( $tag );
346
-		echo '</tr>';
347
-	}
348
-
349
-	/**
350
-	 * @since 5.9.0 Renamed `$tag` to `$item` to match parent class for PHP 8 named parameter support.
351
-	 *
352
-	 * @param WP_Term $item Term object.
353
-	 * @return string
354
-	 */
355
-	public function column_cb( $item ) {
356
-		// Restores the more descriptive, specific name for use within this method.
357
-		$tag = $item;
358
-
359
-		if ( current_user_can( 'delete_term', $tag->term_id ) ) {
360
-			return sprintf(
361
-				'<label class="screen-reader-text" for="cb-select-%1$s">%2$s</label>' .
362
-				'<input type="checkbox" name="delete_tags[]" value="%1$s" id="cb-select-%1$s" />',
363
-				$tag->term_id,
364
-				/* translators: %s: Taxonomy term name. */
365
-				sprintf( __( 'Select %s' ), $tag->name )
366
-			);
367
-		}
368
-
369
-		return '&nbsp;';
370
-	}
371
-
372
-	/**
373
-	 * @param WP_Term $tag Term object.
374
-	 * @return string
375
-	 */
376
-	public function column_name( $tag ) {
377
-		$taxonomy = $this->screen->taxonomy;
378
-
379
-		$pad = str_repeat( '&#8212; ', max( 0, $this->level ) );
380
-
381
-		/**
382
-		 * Filters display of the term name in the terms list table.
383
-		 *
384
-		 * The default output may include padding due to the term's
385
-		 * current level in the term hierarchy.
386
-		 *
387
-		 * @since 2.5.0
388
-		 *
389
-		 * @see WP_Terms_List_Table::column_name()
390
-		 *
391
-		 * @param string $pad_tag_name The term name, padded if not top-level.
392
-		 * @param WP_Term $tag         Term object.
393
-		 */
394
-		$name = apply_filters( 'term_name', $pad . ' ' . $tag->name, $tag );
395
-
396
-		$qe_data = get_term( $tag->term_id, $taxonomy, OBJECT, 'edit' );
397
-
398
-		$uri = wp_doing_ajax() ? wp_get_referer() : $_SERVER['REQUEST_URI'];
399
-
400
-		$edit_link = get_edit_term_link( $tag, $taxonomy, $this->screen->post_type );
401
-
402
-		if ( $edit_link ) {
403
-			$edit_link = add_query_arg(
404
-				'wp_http_referer',
405
-				urlencode( wp_unslash( $uri ) ),
406
-				$edit_link
407
-			);
408
-			$name      = sprintf(
409
-				'<a class="row-title" href="%s" aria-label="%s">%s</a>',
410
-				esc_url( $edit_link ),
411
-				/* translators: %s: Taxonomy term name. */
412
-				esc_attr( sprintf( __( '&#8220;%s&#8221; (Edit)' ), $tag->name ) ),
413
-				$name
414
-			);
415
-		}
416
-
417
-		$out = sprintf(
418
-			'<strong>%s</strong><br />',
419
-			$name
420
-		);
421
-
422
-		$out .= '<div class="hidden" id="inline_' . $qe_data->term_id . '">';
423
-		$out .= '<div class="name">' . $qe_data->name . '</div>';
424
-
425
-		/** This filter is documented in wp-admin/edit-tag-form.php */
426
-		$out .= '<div class="slug">' . apply_filters( 'editable_slug', $qe_data->slug, $qe_data ) . '</div>';
427
-		$out .= '<div class="parent">' . $qe_data->parent . '</div></div>';
428
-
429
-		return $out;
430
-	}
431
-
432
-	/**
433
-	 * Gets the name of the default primary column.
434
-	 *
435
-	 * @since 4.3.0
436
-	 *
437
-	 * @return string Name of the default primary column, in this case, 'name'.
438
-	 */
439
-	protected function get_default_primary_column_name() {
440
-		return 'name';
441
-	}
442
-
443
-	/**
444
-	 * Generates and displays row action links.
445
-	 *
446
-	 * @since 4.3.0
447
-	 * @since 5.9.0 Renamed `$tag` to `$item` to match parent class for PHP 8 named parameter support.
448
-	 *
449
-	 * @param WP_Term $item        Tag being acted upon.
450
-	 * @param string  $column_name Current column name.
451
-	 * @param string  $primary     Primary column name.
452
-	 * @return string Row actions output for terms, or an empty string
453
-	 *                if the current column is not the primary column.
454
-	 */
455
-	protected function handle_row_actions( $item, $column_name, $primary ) {
456
-		if ( $primary !== $column_name ) {
457
-			return '';
458
-		}
459
-
460
-		// Restores the more descriptive, specific name for use within this method.
461
-		$tag      = $item;
462
-		$taxonomy = $this->screen->taxonomy;
463
-		$tax      = get_taxonomy( $taxonomy );
464
-		$uri      = wp_doing_ajax() ? wp_get_referer() : $_SERVER['REQUEST_URI'];
465
-
466
-		$edit_link = add_query_arg(
467
-			'wp_http_referer',
468
-			urlencode( wp_unslash( $uri ) ),
469
-			get_edit_term_link( $tag, $taxonomy, $this->screen->post_type )
470
-		);
471
-
472
-		$actions = array();
473
-
474
-		if ( current_user_can( 'edit_term', $tag->term_id ) ) {
475
-			$actions['edit'] = sprintf(
476
-				'<a href="%s" aria-label="%s">%s</a>',
477
-				esc_url( $edit_link ),
478
-				/* translators: %s: Taxonomy term name. */
479
-				esc_attr( sprintf( __( 'Edit &#8220;%s&#8221;' ), $tag->name ) ),
480
-				__( 'Edit' )
481
-			);
482
-			$actions['inline hide-if-no-js'] = sprintf(
483
-				'<button type="button" class="button-link editinline" aria-label="%s" aria-expanded="false">%s</button>',
484
-				/* translators: %s: Taxonomy term name. */
485
-				esc_attr( sprintf( __( 'Quick edit &#8220;%s&#8221; inline' ), $tag->name ) ),
486
-				__( 'Quick&nbsp;Edit' )
487
-			);
488
-		}
489
-
490
-		if ( current_user_can( 'delete_term', $tag->term_id ) ) {
491
-			$actions['delete'] = sprintf(
492
-				'<a href="%s" class="delete-tag aria-button-if-js" aria-label="%s">%s</a>',
493
-				wp_nonce_url( "edit-tags.php?action=delete&amp;taxonomy=$taxonomy&amp;tag_ID=$tag->term_id", 'delete-tag_' . $tag->term_id ),
494
-				/* translators: %s: Taxonomy term name. */
495
-				esc_attr( sprintf( __( 'Delete &#8220;%s&#8221;' ), $tag->name ) ),
496
-				__( 'Delete' )
497
-			);
498
-		}
499
-
500
-		if ( is_taxonomy_viewable( $tax ) ) {
501
-			$actions['view'] = sprintf(
502
-				'<a href="%s" aria-label="%s">%s</a>',
503
-				get_term_link( $tag ),
504
-				/* translators: %s: Taxonomy term name. */
505
-				esc_attr( sprintf( __( 'View &#8220;%s&#8221; archive' ), $tag->name ) ),
506
-				__( 'View' )
507
-			);
508
-		}
509
-
510
-		/**
511
-		 * Filters the action links displayed for each term in the Tags list table.
512
-		 *
513
-		 * @since 2.8.0
514
-		 * @since 3.0.0 Deprecated in favor of {@see '{$taxonomy}_row_actions'} filter.
515
-		 * @since 5.4.2 Restored (un-deprecated).
516
-		 *
517
-		 * @param string[] $actions An array of action links to be displayed. Default
518
-		 *                          'Edit', 'Quick Edit', 'Delete', and 'View'.
519
-		 * @param WP_Term  $tag     Term object.
520
-		 */
521
-		$actions = apply_filters( 'tag_row_actions', $actions, $tag );
522
-
523
-		/**
524
-		 * Filters the action links displayed for each term in the terms list table.
525
-		 *
526
-		 * The dynamic portion of the hook name, `$taxonomy`, refers to the taxonomy slug.
527
-		 *
528
-		 * Possible hook names include:
529
-		 *
530
-		 *  - `category_row_actions`
531
-		 *  - `post_tag_row_actions`
532
-		 *
533
-		 * @since 3.0.0
534
-		 *
535
-		 * @param string[] $actions An array of action links to be displayed. Default
536
-		 *                          'Edit', 'Quick Edit', 'Delete', and 'View'.
537
-		 * @param WP_Term  $tag     Term object.
538
-		 */
539
-		$actions = apply_filters( "{$taxonomy}_row_actions", $actions, $tag );
540
-
541
-		return $this->row_actions( $actions );
542
-	}
543
-
544
-	/**
545
-	 * @param WP_Term $tag Term object.
546
-	 * @return string
547
-	 */
548
-	public function column_description( $tag ) {
549
-		if ( $tag->description ) {
550
-			return $tag->description;
551
-		} else {
552
-			return '<span aria-hidden="true">&#8212;</span><span class="screen-reader-text">' . __( 'No description' ) . '</span>';
553
-		}
554
-	}
555
-
556
-	/**
557
-	 * @param WP_Term $tag Term object.
558
-	 * @return string
559
-	 */
560
-	public function column_slug( $tag ) {
561
-		/** This filter is documented in wp-admin/edit-tag-form.php */
562
-		return apply_filters( 'editable_slug', $tag->slug, $tag );
563
-	}
564
-
565
-	/**
566
-	 * @param WP_Term $tag Term object.
567
-	 * @return string
568
-	 */
569
-	public function column_posts( $tag ) {
570
-		$count = number_format_i18n( $tag->count );
571
-
572
-		$tax = get_taxonomy( $this->screen->taxonomy );
573
-
574
-		$ptype_object = get_post_type_object( $this->screen->post_type );
575
-		if ( ! $ptype_object->show_ui ) {
576
-			return $count;
577
-		}
578
-
579
-		if ( $tax->query_var ) {
580
-			$args = array( $tax->query_var => $tag->slug );
581
-		} else {
582
-			$args = array(
583
-				'taxonomy' => $tax->name,
584
-				'term'     => $tag->slug,
585
-			);
586
-		}
587
-
588
-		if ( 'post' !== $this->screen->post_type ) {
589
-			$args['post_type'] = $this->screen->post_type;
590
-		}
591
-
592
-		if ( 'attachment' === $this->screen->post_type ) {
593
-			return "<a href='" . esc_url( add_query_arg( $args, 'upload.php' ) ) . "'>$count</a>";
594
-		}
595
-
596
-		return "<a href='" . esc_url( add_query_arg( $args, 'edit.php' ) ) . "'>$count</a>";
597
-	}
598
-
599
-	/**
600
-	 * @param WP_Term $tag Term object.
601
-	 * @return string
602
-	 */
603
-	public function column_links( $tag ) {
604
-		$count = number_format_i18n( $tag->count );
605
-
606
-		if ( $count ) {
607
-			$count = "<a href='link-manager.php?cat_id=$tag->term_id'>$count</a>";
608
-		}
609
-
610
-		return $count;
611
-	}
612
-
613
-	/**
614
-	 * @since 5.9.0 Renamed `$tag` to `$item` to match parent class for PHP 8 named parameter support.
615
-	 *
616
-	 * @param WP_Term $item        Term object.
617
-	 * @param string  $column_name Name of the column.
618
-	 * @return string
619
-	 */
620
-	public function column_default( $item, $column_name ) {
621
-		/**
622
-		 * Filters the displayed columns in the terms list table.
623
-		 *
624
-		 * The dynamic portion of the hook name, `$this->screen->taxonomy`,
625
-		 * refers to the slug of the current taxonomy.
626
-		 *
627
-		 * Possible hook names include:
628
-		 *
629
-		 *  - `manage_category_custom_column`
630
-		 *  - `manage_post_tag_custom_column`
631
-		 *
632
-		 * @since 2.8.0
633
-		 *
634
-		 * @param string $string      Custom column output. Default empty.
635
-		 * @param string $column_name Name of the column.
636
-		 * @param int    $term_id     Term ID.
637
-		 */
638
-		return apply_filters( "manage_{$this->screen->taxonomy}_custom_column", '', $column_name, $item->term_id );
639
-	}
640
-
641
-	/**
642
-	 * Outputs the hidden row displayed when inline editing
643
-	 *
644
-	 * @since 3.1.0
645
-	 */
646
-	public function inline_edit() {
647
-		$tax = get_taxonomy( $this->screen->taxonomy );
648
-
649
-		if ( ! current_user_can( $tax->cap->edit_terms ) ) {
650
-			return;
651
-		}
652
-		?>
250
+            $this->_rows( $taxonomy, $this->items, $children, $offset, $number, $count );
251
+        } else {
252
+            foreach ( $this->items as $term ) {
253
+                $this->single_row( $term );
254
+            }
255
+        }
256
+    }
257
+
258
+    /**
259
+     * @param string $taxonomy
260
+     * @param array  $terms
261
+     * @param array  $children
262
+     * @param int    $start
263
+     * @param int    $per_page
264
+     * @param int    $count
265
+     * @param int    $parent_term
266
+     * @param int    $level
267
+     */
268
+    private function _rows( $taxonomy, $terms, &$children, $start, $per_page, &$count, $parent_term = 0, $level = 0 ) {
269
+
270
+        $end = $start + $per_page;
271
+
272
+        foreach ( $terms as $key => $term ) {
273
+
274
+            if ( $count >= $end ) {
275
+                break;
276
+            }
277
+
278
+            if ( $term->parent !== $parent_term && empty( $_REQUEST['s'] ) ) {
279
+                continue;
280
+            }
281
+
282
+            // If the page starts in a subtree, print the parents.
283
+            if ( $count === $start && $term->parent > 0 && empty( $_REQUEST['s'] ) ) {
284
+                $my_parents = array();
285
+                $parent_ids = array();
286
+                $p          = $term->parent;
287
+
288
+                while ( $p ) {
289
+                    $my_parent    = get_term( $p, $taxonomy );
290
+                    $my_parents[] = $my_parent;
291
+                    $p            = $my_parent->parent;
292
+
293
+                    if ( in_array( $p, $parent_ids, true ) ) { // Prevent parent loops.
294
+                        break;
295
+                    }
296
+
297
+                    $parent_ids[] = $p;
298
+                }
299
+
300
+                unset( $parent_ids );
301
+
302
+                $num_parents = count( $my_parents );
303
+
304
+                while ( $my_parent = array_pop( $my_parents ) ) {
305
+                    echo "\t";
306
+                    $this->single_row( $my_parent, $level - $num_parents );
307
+                    $num_parents--;
308
+                }
309
+            }
310
+
311
+            if ( $count >= $start ) {
312
+                echo "\t";
313
+                $this->single_row( $term, $level );
314
+            }
315
+
316
+            ++$count;
317
+
318
+            unset( $terms[ $key ] );
319
+
320
+            if ( isset( $children[ $term->term_id ] ) && empty( $_REQUEST['s'] ) ) {
321
+                $this->_rows( $taxonomy, $terms, $children, $start, $per_page, $count, $term->term_id, $level + 1 );
322
+            }
323
+        }
324
+    }
325
+
326
+    /**
327
+     * @global string $taxonomy
328
+     * @param WP_Term $tag   Term object.
329
+     * @param int     $level
330
+     */
331
+    public function single_row( $tag, $level = 0 ) {
332
+        global $taxonomy;
333
+        $tag = sanitize_term( $tag, $taxonomy );
334
+
335
+        $this->level = $level;
336
+
337
+        if ( $tag->parent ) {
338
+            $count = count( get_ancestors( $tag->term_id, $taxonomy, 'taxonomy' ) );
339
+            $level = 'level-' . $count;
340
+        } else {
341
+            $level = 'level-0';
342
+        }
343
+
344
+        echo '<tr id="tag-' . $tag->term_id . '" class="' . $level . '">';
345
+        $this->single_row_columns( $tag );
346
+        echo '</tr>';
347
+    }
348
+
349
+    /**
350
+     * @since 5.9.0 Renamed `$tag` to `$item` to match parent class for PHP 8 named parameter support.
351
+     *
352
+     * @param WP_Term $item Term object.
353
+     * @return string
354
+     */
355
+    public function column_cb( $item ) {
356
+        // Restores the more descriptive, specific name for use within this method.
357
+        $tag = $item;
358
+
359
+        if ( current_user_can( 'delete_term', $tag->term_id ) ) {
360
+            return sprintf(
361
+                '<label class="screen-reader-text" for="cb-select-%1$s">%2$s</label>' .
362
+                '<input type="checkbox" name="delete_tags[]" value="%1$s" id="cb-select-%1$s" />',
363
+                $tag->term_id,
364
+                /* translators: %s: Taxonomy term name. */
365
+                sprintf( __( 'Select %s' ), $tag->name )
366
+            );
367
+        }
368
+
369
+        return '&nbsp;';
370
+    }
371
+
372
+    /**
373
+     * @param WP_Term $tag Term object.
374
+     * @return string
375
+     */
376
+    public function column_name( $tag ) {
377
+        $taxonomy = $this->screen->taxonomy;
378
+
379
+        $pad = str_repeat( '&#8212; ', max( 0, $this->level ) );
380
+
381
+        /**
382
+         * Filters display of the term name in the terms list table.
383
+         *
384
+         * The default output may include padding due to the term's
385
+         * current level in the term hierarchy.
386
+         *
387
+         * @since 2.5.0
388
+         *
389
+         * @see WP_Terms_List_Table::column_name()
390
+         *
391
+         * @param string $pad_tag_name The term name, padded if not top-level.
392
+         * @param WP_Term $tag         Term object.
393
+         */
394
+        $name = apply_filters( 'term_name', $pad . ' ' . $tag->name, $tag );
395
+
396
+        $qe_data = get_term( $tag->term_id, $taxonomy, OBJECT, 'edit' );
397
+
398
+        $uri = wp_doing_ajax() ? wp_get_referer() : $_SERVER['REQUEST_URI'];
399
+
400
+        $edit_link = get_edit_term_link( $tag, $taxonomy, $this->screen->post_type );
401
+
402
+        if ( $edit_link ) {
403
+            $edit_link = add_query_arg(
404
+                'wp_http_referer',
405
+                urlencode( wp_unslash( $uri ) ),
406
+                $edit_link
407
+            );
408
+            $name      = sprintf(
409
+                '<a class="row-title" href="%s" aria-label="%s">%s</a>',
410
+                esc_url( $edit_link ),
411
+                /* translators: %s: Taxonomy term name. */
412
+                esc_attr( sprintf( __( '&#8220;%s&#8221; (Edit)' ), $tag->name ) ),
413
+                $name
414
+            );
415
+        }
416
+
417
+        $out = sprintf(
418
+            '<strong>%s</strong><br />',
419
+            $name
420
+        );
421
+
422
+        $out .= '<div class="hidden" id="inline_' . $qe_data->term_id . '">';
423
+        $out .= '<div class="name">' . $qe_data->name . '</div>';
424
+
425
+        /** This filter is documented in wp-admin/edit-tag-form.php */
426
+        $out .= '<div class="slug">' . apply_filters( 'editable_slug', $qe_data->slug, $qe_data ) . '</div>';
427
+        $out .= '<div class="parent">' . $qe_data->parent . '</div></div>';
428
+
429
+        return $out;
430
+    }
431
+
432
+    /**
433
+     * Gets the name of the default primary column.
434
+     *
435
+     * @since 4.3.0
436
+     *
437
+     * @return string Name of the default primary column, in this case, 'name'.
438
+     */
439
+    protected function get_default_primary_column_name() {
440
+        return 'name';
441
+    }
442
+
443
+    /**
444
+     * Generates and displays row action links.
445
+     *
446
+     * @since 4.3.0
447
+     * @since 5.9.0 Renamed `$tag` to `$item` to match parent class for PHP 8 named parameter support.
448
+     *
449
+     * @param WP_Term $item        Tag being acted upon.
450
+     * @param string  $column_name Current column name.
451
+     * @param string  $primary     Primary column name.
452
+     * @return string Row actions output for terms, or an empty string
453
+     *                if the current column is not the primary column.
454
+     */
455
+    protected function handle_row_actions( $item, $column_name, $primary ) {
456
+        if ( $primary !== $column_name ) {
457
+            return '';
458
+        }
459
+
460
+        // Restores the more descriptive, specific name for use within this method.
461
+        $tag      = $item;
462
+        $taxonomy = $this->screen->taxonomy;
463
+        $tax      = get_taxonomy( $taxonomy );
464
+        $uri      = wp_doing_ajax() ? wp_get_referer() : $_SERVER['REQUEST_URI'];
465
+
466
+        $edit_link = add_query_arg(
467
+            'wp_http_referer',
468
+            urlencode( wp_unslash( $uri ) ),
469
+            get_edit_term_link( $tag, $taxonomy, $this->screen->post_type )
470
+        );
471
+
472
+        $actions = array();
473
+
474
+        if ( current_user_can( 'edit_term', $tag->term_id ) ) {
475
+            $actions['edit'] = sprintf(
476
+                '<a href="%s" aria-label="%s">%s</a>',
477
+                esc_url( $edit_link ),
478
+                /* translators: %s: Taxonomy term name. */
479
+                esc_attr( sprintf( __( 'Edit &#8220;%s&#8221;' ), $tag->name ) ),
480
+                __( 'Edit' )
481
+            );
482
+            $actions['inline hide-if-no-js'] = sprintf(
483
+                '<button type="button" class="button-link editinline" aria-label="%s" aria-expanded="false">%s</button>',
484
+                /* translators: %s: Taxonomy term name. */
485
+                esc_attr( sprintf( __( 'Quick edit &#8220;%s&#8221; inline' ), $tag->name ) ),
486
+                __( 'Quick&nbsp;Edit' )
487
+            );
488
+        }
489
+
490
+        if ( current_user_can( 'delete_term', $tag->term_id ) ) {
491
+            $actions['delete'] = sprintf(
492
+                '<a href="%s" class="delete-tag aria-button-if-js" aria-label="%s">%s</a>',
493
+                wp_nonce_url( "edit-tags.php?action=delete&amp;taxonomy=$taxonomy&amp;tag_ID=$tag->term_id", 'delete-tag_' . $tag->term_id ),
494
+                /* translators: %s: Taxonomy term name. */
495
+                esc_attr( sprintf( __( 'Delete &#8220;%s&#8221;' ), $tag->name ) ),
496
+                __( 'Delete' )
497
+            );
498
+        }
499
+
500
+        if ( is_taxonomy_viewable( $tax ) ) {
501
+            $actions['view'] = sprintf(
502
+                '<a href="%s" aria-label="%s">%s</a>',
503
+                get_term_link( $tag ),
504
+                /* translators: %s: Taxonomy term name. */
505
+                esc_attr( sprintf( __( 'View &#8220;%s&#8221; archive' ), $tag->name ) ),
506
+                __( 'View' )
507
+            );
508
+        }
509
+
510
+        /**
511
+         * Filters the action links displayed for each term in the Tags list table.
512
+         *
513
+         * @since 2.8.0
514
+         * @since 3.0.0 Deprecated in favor of {@see '{$taxonomy}_row_actions'} filter.
515
+         * @since 5.4.2 Restored (un-deprecated).
516
+         *
517
+         * @param string[] $actions An array of action links to be displayed. Default
518
+         *                          'Edit', 'Quick Edit', 'Delete', and 'View'.
519
+         * @param WP_Term  $tag     Term object.
520
+         */
521
+        $actions = apply_filters( 'tag_row_actions', $actions, $tag );
522
+
523
+        /**
524
+         * Filters the action links displayed for each term in the terms list table.
525
+         *
526
+         * The dynamic portion of the hook name, `$taxonomy`, refers to the taxonomy slug.
527
+         *
528
+         * Possible hook names include:
529
+         *
530
+         *  - `category_row_actions`
531
+         *  - `post_tag_row_actions`
532
+         *
533
+         * @since 3.0.0
534
+         *
535
+         * @param string[] $actions An array of action links to be displayed. Default
536
+         *                          'Edit', 'Quick Edit', 'Delete', and 'View'.
537
+         * @param WP_Term  $tag     Term object.
538
+         */
539
+        $actions = apply_filters( "{$taxonomy}_row_actions", $actions, $tag );
540
+
541
+        return $this->row_actions( $actions );
542
+    }
543
+
544
+    /**
545
+     * @param WP_Term $tag Term object.
546
+     * @return string
547
+     */
548
+    public function column_description( $tag ) {
549
+        if ( $tag->description ) {
550
+            return $tag->description;
551
+        } else {
552
+            return '<span aria-hidden="true">&#8212;</span><span class="screen-reader-text">' . __( 'No description' ) . '</span>';
553
+        }
554
+    }
555
+
556
+    /**
557
+     * @param WP_Term $tag Term object.
558
+     * @return string
559
+     */
560
+    public function column_slug( $tag ) {
561
+        /** This filter is documented in wp-admin/edit-tag-form.php */
562
+        return apply_filters( 'editable_slug', $tag->slug, $tag );
563
+    }
564
+
565
+    /**
566
+     * @param WP_Term $tag Term object.
567
+     * @return string
568
+     */
569
+    public function column_posts( $tag ) {
570
+        $count = number_format_i18n( $tag->count );
571
+
572
+        $tax = get_taxonomy( $this->screen->taxonomy );
573
+
574
+        $ptype_object = get_post_type_object( $this->screen->post_type );
575
+        if ( ! $ptype_object->show_ui ) {
576
+            return $count;
577
+        }
578
+
579
+        if ( $tax->query_var ) {
580
+            $args = array( $tax->query_var => $tag->slug );
581
+        } else {
582
+            $args = array(
583
+                'taxonomy' => $tax->name,
584
+                'term'     => $tag->slug,
585
+            );
586
+        }
587
+
588
+        if ( 'post' !== $this->screen->post_type ) {
589
+            $args['post_type'] = $this->screen->post_type;
590
+        }
591
+
592
+        if ( 'attachment' === $this->screen->post_type ) {
593
+            return "<a href='" . esc_url( add_query_arg( $args, 'upload.php' ) ) . "'>$count</a>";
594
+        }
595
+
596
+        return "<a href='" . esc_url( add_query_arg( $args, 'edit.php' ) ) . "'>$count</a>";
597
+    }
598
+
599
+    /**
600
+     * @param WP_Term $tag Term object.
601
+     * @return string
602
+     */
603
+    public function column_links( $tag ) {
604
+        $count = number_format_i18n( $tag->count );
605
+
606
+        if ( $count ) {
607
+            $count = "<a href='link-manager.php?cat_id=$tag->term_id'>$count</a>";
608
+        }
609
+
610
+        return $count;
611
+    }
612
+
613
+    /**
614
+     * @since 5.9.0 Renamed `$tag` to `$item` to match parent class for PHP 8 named parameter support.
615
+     *
616
+     * @param WP_Term $item        Term object.
617
+     * @param string  $column_name Name of the column.
618
+     * @return string
619
+     */
620
+    public function column_default( $item, $column_name ) {
621
+        /**
622
+         * Filters the displayed columns in the terms list table.
623
+         *
624
+         * The dynamic portion of the hook name, `$this->screen->taxonomy`,
625
+         * refers to the slug of the current taxonomy.
626
+         *
627
+         * Possible hook names include:
628
+         *
629
+         *  - `manage_category_custom_column`
630
+         *  - `manage_post_tag_custom_column`
631
+         *
632
+         * @since 2.8.0
633
+         *
634
+         * @param string $string      Custom column output. Default empty.
635
+         * @param string $column_name Name of the column.
636
+         * @param int    $term_id     Term ID.
637
+         */
638
+        return apply_filters( "manage_{$this->screen->taxonomy}_custom_column", '', $column_name, $item->term_id );
639
+    }
640
+
641
+    /**
642
+     * Outputs the hidden row displayed when inline editing
643
+     *
644
+     * @since 3.1.0
645
+     */
646
+    public function inline_edit() {
647
+        $tax = get_taxonomy( $this->screen->taxonomy );
648
+
649
+        if ( ! current_user_can( $tax->cap->edit_terms ) ) {
650
+            return;
651
+        }
652
+        ?>
653 653
 
654 654
 		<form method="get">
655 655
 		<table style="display: none"><tbody id="inlineedit">
@@ -676,25 +676,25 @@  discard block
 block discarded – undo
676 676
 			</fieldset>
677 677
 
678 678
 			<?php
679
-			$core_columns = array(
680
-				'cb'          => true,
681
-				'description' => true,
682
-				'name'        => true,
683
-				'slug'        => true,
684
-				'posts'       => true,
685
-			);
686
-
687
-			list( $columns ) = $this->get_column_info();
688
-
689
-			foreach ( $columns as $column_name => $column_display_name ) {
690
-				if ( isset( $core_columns[ $column_name ] ) ) {
691
-					continue;
692
-				}
693
-
694
-				/** This action is documented in wp-admin/includes/class-wp-posts-list-table.php */
695
-				do_action( 'quick_edit_custom_box', $column_name, 'edit-tags', $this->screen->taxonomy );
696
-			}
697
-			?>
679
+            $core_columns = array(
680
+                'cb'          => true,
681
+                'description' => true,
682
+                'name'        => true,
683
+                'slug'        => true,
684
+                'posts'       => true,
685
+            );
686
+
687
+            list( $columns ) = $this->get_column_info();
688
+
689
+            foreach ( $columns as $column_name => $column_display_name ) {
690
+                if ( isset( $core_columns[ $column_name ] ) ) {
691
+                    continue;
692
+                }
693
+
694
+                /** This action is documented in wp-admin/includes/class-wp-posts-list-table.php */
695
+                do_action( 'quick_edit_custom_box', $column_name, 'edit-tags', $this->screen->taxonomy );
696
+            }
697
+            ?>
698 698
 
699 699
 			<div class="inline-edit-save submit">
700 700
 				<button type="button" class="save button button-primary"><?php echo $tax->labels->update_item; ?></button>
@@ -716,5 +716,5 @@  discard block
 block discarded – undo
716 716
 		</tbody></table>
717 717
 		</form>
718 718
 		<?php
719
-	}
719
+    }
720 720
 }
Please login to merge, or discard this patch.