Passed
Push — main ( 16d49b...d78e29 )
by TARIQ
111:03
created
brighty/wp-admin/includes/options.php 1 patch
Indentation   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -13,7 +13,7 @@  discard block
 block discarded – undo
13 13
  * @since 4.2.0
14 14
  */
15 15
 function options_discussion_add_js() {
16
-	?>
16
+    ?>
17 17
 	<script>
18 18
 	(function($){
19 19
 		var parent = $( '#show_avatars' ),
@@ -32,7 +32,7 @@  discard block
 block discarded – undo
32 32
  * @since 3.5.0
33 33
  */
34 34
 function options_general_add_js() {
35
-	?>
35
+    ?>
36 36
 <script type="text/javascript">
37 37
 	jQuery( function($) {
38 38
 		var $siteName = $( '#wp-admin-bar-site-name' ).children( 'a' ).first(),
@@ -107,7 +107,7 @@  discard block
 block discarded – undo
107 107
  * @since 3.5.0
108 108
  */
109 109
 function options_reading_add_js() {
110
-	?>
110
+    ?>
111 111
 <script type="text/javascript">
112 112
 	jQuery( function($) {
113 113
 		var section = $('#front-static-pages'),
@@ -129,6 +129,6 @@  discard block
 block discarded – undo
129 129
  * @since 3.5.0
130 130
  */
131 131
 function options_reading_blog_charset() {
132
-	echo '<input name="blog_charset" type="text" id="blog_charset" value="' . esc_attr( get_option( 'blog_charset' ) ) . '" class="regular-text" />';
133
-	echo '<p class="description">' . __( 'The <a href="https://wordpress.org/support/article/glossary/#character-set">character encoding</a> of your site (UTF-8 is recommended)' ) . '</p>';
132
+    echo '<input name="blog_charset" type="text" id="blog_charset" value="' . esc_attr( get_option( 'blog_charset' ) ) . '" class="regular-text" />';
133
+    echo '<p class="description">' . __( 'The <a href="https://wordpress.org/support/article/glossary/#character-set">character encoding</a> of your site (UTF-8 is recommended)' ) . '</p>';
134 134
 }
Please login to merge, or discard this patch.
brighty/wp-admin/includes/class-bulk-theme-upgrader-skin.php 1 patch
Indentation   +51 added lines, -51 removed lines patch added patch discarded remove patch
@@ -16,63 +16,63 @@
 block discarded – undo
16 16
  * @see Bulk_Upgrader_Skin
17 17
  */
18 18
 class Bulk_Theme_Upgrader_Skin extends Bulk_Upgrader_Skin {
19
-	public $theme_info = array(); // Theme_Upgrader::bulk_upgrade() will fill this in.
19
+    public $theme_info = array(); // Theme_Upgrader::bulk_upgrade() will fill this in.
20 20
 
21
-	public function add_strings() {
22
-		parent::add_strings();
23
-		/* translators: 1: Theme name, 2: Number of the theme, 3: Total number of themes being updated. */
24
-		$this->upgrader->strings['skin_before_update_header'] = __( 'Updating Theme %1$s (%2$d/%3$d)' );
25
-	}
21
+    public function add_strings() {
22
+        parent::add_strings();
23
+        /* translators: 1: Theme name, 2: Number of the theme, 3: Total number of themes being updated. */
24
+        $this->upgrader->strings['skin_before_update_header'] = __( 'Updating Theme %1$s (%2$d/%3$d)' );
25
+    }
26 26
 
27
-	/**
28
-	 * @param string $title
29
-	 */
30
-	public function before( $title = '' ) {
31
-		parent::before( $this->theme_info->display( 'Name' ) );
32
-	}
27
+    /**
28
+     * @param string $title
29
+     */
30
+    public function before( $title = '' ) {
31
+        parent::before( $this->theme_info->display( 'Name' ) );
32
+    }
33 33
 
34
-	/**
35
-	 * @param string $title
36
-	 */
37
-	public function after( $title = '' ) {
38
-		parent::after( $this->theme_info->display( 'Name' ) );
39
-		$this->decrement_update_count( 'theme' );
40
-	}
34
+    /**
35
+     * @param string $title
36
+     */
37
+    public function after( $title = '' ) {
38
+        parent::after( $this->theme_info->display( 'Name' ) );
39
+        $this->decrement_update_count( 'theme' );
40
+    }
41 41
 
42
-	/**
43
-	 */
44
-	public function bulk_footer() {
45
-		parent::bulk_footer();
42
+    /**
43
+     */
44
+    public function bulk_footer() {
45
+        parent::bulk_footer();
46 46
 
47
-		$update_actions = array(
48
-			'themes_page'  => sprintf(
49
-				'<a href="%s" target="_parent">%s</a>',
50
-				self_admin_url( 'themes.php' ),
51
-				__( 'Go to Themes page' )
52
-			),
53
-			'updates_page' => sprintf(
54
-				'<a href="%s" target="_parent">%s</a>',
55
-				self_admin_url( 'update-core.php' ),
56
-				__( 'Go to WordPress Updates page' )
57
-			),
58
-		);
47
+        $update_actions = array(
48
+            'themes_page'  => sprintf(
49
+                '<a href="%s" target="_parent">%s</a>',
50
+                self_admin_url( 'themes.php' ),
51
+                __( 'Go to Themes page' )
52
+            ),
53
+            'updates_page' => sprintf(
54
+                '<a href="%s" target="_parent">%s</a>',
55
+                self_admin_url( 'update-core.php' ),
56
+                __( 'Go to WordPress Updates page' )
57
+            ),
58
+        );
59 59
 
60
-		if ( ! current_user_can( 'switch_themes' ) && ! current_user_can( 'edit_theme_options' ) ) {
61
-			unset( $update_actions['themes_page'] );
62
-		}
60
+        if ( ! current_user_can( 'switch_themes' ) && ! current_user_can( 'edit_theme_options' ) ) {
61
+            unset( $update_actions['themes_page'] );
62
+        }
63 63
 
64
-		/**
65
-		 * Filters the list of action links available following bulk theme updates.
66
-		 *
67
-		 * @since 3.0.0
68
-		 *
69
-		 * @param string[] $update_actions Array of theme action links.
70
-		 * @param WP_Theme $theme_info     Theme object for the last-updated theme.
71
-		 */
72
-		$update_actions = apply_filters( 'update_bulk_theme_complete_actions', $update_actions, $this->theme_info );
64
+        /**
65
+         * Filters the list of action links available following bulk theme updates.
66
+         *
67
+         * @since 3.0.0
68
+         *
69
+         * @param string[] $update_actions Array of theme action links.
70
+         * @param WP_Theme $theme_info     Theme object for the last-updated theme.
71
+         */
72
+        $update_actions = apply_filters( 'update_bulk_theme_complete_actions', $update_actions, $this->theme_info );
73 73
 
74
-		if ( ! empty( $update_actions ) ) {
75
-			$this->feedback( implode( ' | ', (array) $update_actions ) );
76
-		}
77
-	}
74
+        if ( ! empty( $update_actions ) ) {
75
+            $this->feedback( implode( ' | ', (array) $update_actions ) );
76
+        }
77
+    }
78 78
 }
Please login to merge, or discard this patch.
brighty/wp-admin/includes/meta-boxes.php 1 patch
Indentation   +761 added lines, -761 removed lines patch added patch discarded remove patch
@@ -28,13 +28,13 @@  discard block
 block discarded – undo
28 28
  * }
29 29
  */
30 30
 function post_submit_meta_box( $post, $args = array() ) {
31
-	global $action;
31
+    global $action;
32 32
 
33
-	$post_id          = (int) $post->ID;
34
-	$post_type        = $post->post_type;
35
-	$post_type_object = get_post_type_object( $post_type );
36
-	$can_publish      = current_user_can( $post_type_object->cap->publish_posts );
37
-	?>
33
+    $post_id          = (int) $post->ID;
34
+    $post_type        = $post->post_type;
35
+    $post_type_object = get_post_type_object( $post_type );
36
+    $can_publish      = current_user_can( $post_type_object->cap->publish_posts );
37
+    ?>
38 38
 <div class="submitbox" id="submitpost">
39 39
 
40 40
 <div id="minor-publishing">
@@ -47,12 +47,12 @@  discard block
 block discarded – undo
47 47
 	<div id="minor-publishing-actions">
48 48
 		<div id="save-action">
49 49
 			<?php
50
-			if ( ! in_array( $post->post_status, array( 'publish', 'future', 'pending' ), true ) ) {
51
-				$private_style = '';
52
-				if ( 'private' === $post->post_status ) {
53
-					$private_style = 'style="display:none"';
54
-				}
55
-				?>
50
+            if ( ! in_array( $post->post_status, array( 'publish', 'future', 'pending' ), true ) ) {
51
+                $private_style = '';
52
+                if ( 'private' === $post->post_status ) {
53
+                    $private_style = 'style="display:none"';
54
+                }
55
+                ?>
56 56
 				<input <?php echo $private_style; ?> type="submit" name="save" id="save-post" value="<?php esc_attr_e( 'Save Draft' ); ?>" class="button" />
57 57
 				<span class="spinner"></span>
58 58
 			<?php } elseif ( 'pending' === $post->post_status && $can_publish ) { ?>
@@ -62,40 +62,40 @@  discard block
 block discarded – undo
62 62
 		</div>
63 63
 
64 64
 		<?php
65
-		if ( is_post_type_viewable( $post_type_object ) ) :
66
-			?>
65
+        if ( is_post_type_viewable( $post_type_object ) ) :
66
+            ?>
67 67
 			<div id="preview-action">
68 68
 				<?php
69
-				$preview_link = esc_url( get_preview_post_link( $post ) );
70
-				if ( 'publish' === $post->post_status ) {
71
-					$preview_button_text = __( 'Preview Changes' );
72
-				} else {
73
-					$preview_button_text = __( 'Preview' );
74
-				}
75
-
76
-				$preview_button = sprintf(
77
-					'%1$s<span class="screen-reader-text"> %2$s</span>',
78
-					$preview_button_text,
79
-					/* translators: Accessibility text. */
80
-					__( '(opens in a new tab)' )
81
-				);
82
-				?>
69
+                $preview_link = esc_url( get_preview_post_link( $post ) );
70
+                if ( 'publish' === $post->post_status ) {
71
+                    $preview_button_text = __( 'Preview Changes' );
72
+                } else {
73
+                    $preview_button_text = __( 'Preview' );
74
+                }
75
+
76
+                $preview_button = sprintf(
77
+                    '%1$s<span class="screen-reader-text"> %2$s</span>',
78
+                    $preview_button_text,
79
+                    /* translators: Accessibility text. */
80
+                    __( '(opens in a new tab)' )
81
+                );
82
+                ?>
83 83
 				<a class="preview button" href="<?php echo $preview_link; ?>" target="wp-preview-<?php echo $post_id; ?>" id="post-preview"><?php echo $preview_button; ?></a>
84 84
 				<input type="hidden" name="wp-preview" id="wp-preview" value="" />
85 85
 			</div>
86 86
 			<?php
87
-		endif;
88
-
89
-		/**
90
-		 * Fires after the Save Draft (or Save as Pending) and Preview (or Preview Changes) buttons
91
-		 * in the Publish meta box.
92
-		 *
93
-		 * @since 4.4.0
94
-		 *
95
-		 * @param WP_Post $post WP_Post object for the current post.
96
-		 */
97
-		do_action( 'post_submitbox_minor_actions', $post );
98
-		?>
87
+        endif;
88
+
89
+        /**
90
+         * Fires after the Save Draft (or Save as Pending) and Preview (or Preview Changes) buttons
91
+         * in the Publish meta box.
92
+         *
93
+         * @since 4.4.0
94
+         *
95
+         * @param WP_Post $post WP_Post object for the current post.
96
+         */
97
+        do_action( 'post_submitbox_minor_actions', $post );
98
+        ?>
99 99
 		<div class="clear"></div>
100 100
 	</div>
101 101
 
@@ -104,34 +104,34 @@  discard block
 block discarded – undo
104 104
 			<?php _e( 'Status:' ); ?>
105 105
 			<span id="post-status-display">
106 106
 				<?php
107
-				switch ( $post->post_status ) {
108
-					case 'private':
109
-						_e( 'Privately Published' );
110
-						break;
111
-					case 'publish':
112
-						_e( 'Published' );
113
-						break;
114
-					case 'future':
115
-						_e( 'Scheduled' );
116
-						break;
117
-					case 'pending':
118
-						_e( 'Pending Review' );
119
-						break;
120
-					case 'draft':
121
-					case 'auto-draft':
122
-						_e( 'Draft' );
123
-						break;
124
-				}
125
-				?>
107
+                switch ( $post->post_status ) {
108
+                    case 'private':
109
+                        _e( 'Privately Published' );
110
+                        break;
111
+                    case 'publish':
112
+                        _e( 'Published' );
113
+                        break;
114
+                    case 'future':
115
+                        _e( 'Scheduled' );
116
+                        break;
117
+                    case 'pending':
118
+                        _e( 'Pending Review' );
119
+                        break;
120
+                    case 'draft':
121
+                    case 'auto-draft':
122
+                        _e( 'Draft' );
123
+                        break;
124
+                }
125
+                ?>
126 126
 			</span>
127 127
 
128 128
 			<?php
129
-			if ( 'publish' === $post->post_status || 'private' === $post->post_status || $can_publish ) {
130
-				$private_style = '';
131
-				if ( 'private' === $post->post_status ) {
132
-					$private_style = 'style="display:none"';
133
-				}
134
-				?>
129
+            if ( 'publish' === $post->post_status || 'private' === $post->post_status || $can_publish ) {
130
+                $private_style = '';
131
+                if ( 'private' === $post->post_status ) {
132
+                    $private_style = 'style="display:none"';
133
+                }
134
+                ?>
135 135
 				<a href="#post_status" <?php echo $private_style; ?> class="edit-post-status hide-if-no-js" role="button"><span aria-hidden="true"><?php _e( 'Edit' ); ?></span> <span class="screen-reader-text"><?php _e( 'Edit status' ); ?></span></a>
136 136
 
137 137
 				<div id="post-status-select" class="hide-if-js">
@@ -156,31 +156,31 @@  discard block
 block discarded – undo
156 156
 					<a href="#post_status" class="cancel-post-status hide-if-no-js button-cancel"><?php _e( 'Cancel' ); ?></a>
157 157
 				</div>
158 158
 				<?php
159
-			}
160
-			?>
159
+            }
160
+            ?>
161 161
 		</div>
162 162
 
163 163
 		<div class="misc-pub-section misc-pub-visibility" id="visibility">
164 164
 			<?php _e( 'Visibility:' ); ?>
165 165
 			<span id="post-visibility-display">
166 166
 				<?php
167
-				if ( 'private' === $post->post_status ) {
168
-					$post->post_password = '';
169
-					$visibility          = 'private';
170
-					$visibility_trans    = __( 'Private' );
171
-				} elseif ( ! empty( $post->post_password ) ) {
172
-					$visibility       = 'password';
173
-					$visibility_trans = __( 'Password protected' );
174
-				} elseif ( 'post' === $post_type && is_sticky( $post_id ) ) {
175
-					$visibility       = 'public';
176
-					$visibility_trans = __( 'Public, Sticky' );
177
-				} else {
178
-					$visibility       = 'public';
179
-					$visibility_trans = __( 'Public' );
180
-				}
181
-
182
-				echo esc_html( $visibility_trans );
183
-				?>
167
+                if ( 'private' === $post->post_status ) {
168
+                    $post->post_password = '';
169
+                    $visibility          = 'private';
170
+                    $visibility_trans    = __( 'Private' );
171
+                } elseif ( ! empty( $post->post_password ) ) {
172
+                    $visibility       = 'password';
173
+                    $visibility_trans = __( 'Password protected' );
174
+                } elseif ( 'post' === $post_type && is_sticky( $post_id ) ) {
175
+                    $visibility       = 'public';
176
+                    $visibility_trans = __( 'Public, Sticky' );
177
+                } else {
178
+                    $visibility       = 'public';
179
+                    $visibility_trans = __( 'Public' );
180
+                }
181
+
182
+                echo esc_html( $visibility_trans );
183
+                ?>
184 184
 			</span>
185 185
 
186 186
 			<?php if ( $can_publish ) { ?>
@@ -213,57 +213,57 @@  discard block
 block discarded – undo
213 213
 		</div>
214 214
 
215 215
 		<?php
216
-		/* translators: Publish box date string. 1: Date, 2: Time. See https://www.php.net/manual/datetime.format.php */
217
-		$date_string = __( '%1$s at %2$s' );
218
-		/* translators: Publish box date format, see https://www.php.net/manual/datetime.format.php */
219
-		$date_format = _x( 'M j, Y', 'publish box date format' );
220
-		/* translators: Publish box time format, see https://www.php.net/manual/datetime.format.php */
221
-		$time_format = _x( 'H:i', 'publish box time format' );
222
-
223
-		if ( 0 !== $post_id ) {
224
-			if ( 'future' === $post->post_status ) { // Scheduled for publishing at a future date.
225
-				/* translators: Post date information. %s: Date on which the post is currently scheduled to be published. */
226
-				$stamp = __( 'Scheduled for: %s' );
227
-			} elseif ( 'publish' === $post->post_status || 'private' === $post->post_status ) { // Already published.
228
-				/* translators: Post date information. %s: Date on which the post was published. */
229
-				$stamp = __( 'Published on: %s' );
230
-			} elseif ( '0000-00-00 00:00:00' === $post->post_date_gmt ) { // Draft, 1 or more saves, no date specified.
231
-				$stamp = __( 'Publish <b>immediately</b>' );
232
-			} elseif ( time() < strtotime( $post->post_date_gmt . ' +0000' ) ) { // Draft, 1 or more saves, future date specified.
233
-				/* translators: Post date information. %s: Date on which the post is to be published. */
234
-				$stamp = __( 'Schedule for: %s' );
235
-			} else { // Draft, 1 or more saves, date specified.
236
-				/* translators: Post date information. %s: Date on which the post is to be published. */
237
-				$stamp = __( 'Publish on: %s' );
238
-			}
239
-			$date = sprintf(
240
-				$date_string,
241
-				date_i18n( $date_format, strtotime( $post->post_date ) ),
242
-				date_i18n( $time_format, strtotime( $post->post_date ) )
243
-			);
244
-		} else { // Draft (no saves, and thus no date specified).
245
-			$stamp = __( 'Publish <b>immediately</b>' );
246
-			$date  = sprintf(
247
-				$date_string,
248
-				date_i18n( $date_format, strtotime( current_time( 'mysql' ) ) ),
249
-				date_i18n( $time_format, strtotime( current_time( 'mysql' ) ) )
250
-			);
251
-		}
252
-
253
-		if ( ! empty( $args['args']['revisions_count'] ) ) :
254
-			?>
216
+        /* translators: Publish box date string. 1: Date, 2: Time. See https://www.php.net/manual/datetime.format.php */
217
+        $date_string = __( '%1$s at %2$s' );
218
+        /* translators: Publish box date format, see https://www.php.net/manual/datetime.format.php */
219
+        $date_format = _x( 'M j, Y', 'publish box date format' );
220
+        /* translators: Publish box time format, see https://www.php.net/manual/datetime.format.php */
221
+        $time_format = _x( 'H:i', 'publish box time format' );
222
+
223
+        if ( 0 !== $post_id ) {
224
+            if ( 'future' === $post->post_status ) { // Scheduled for publishing at a future date.
225
+                /* translators: Post date information. %s: Date on which the post is currently scheduled to be published. */
226
+                $stamp = __( 'Scheduled for: %s' );
227
+            } elseif ( 'publish' === $post->post_status || 'private' === $post->post_status ) { // Already published.
228
+                /* translators: Post date information. %s: Date on which the post was published. */
229
+                $stamp = __( 'Published on: %s' );
230
+            } elseif ( '0000-00-00 00:00:00' === $post->post_date_gmt ) { // Draft, 1 or more saves, no date specified.
231
+                $stamp = __( 'Publish <b>immediately</b>' );
232
+            } elseif ( time() < strtotime( $post->post_date_gmt . ' +0000' ) ) { // Draft, 1 or more saves, future date specified.
233
+                /* translators: Post date information. %s: Date on which the post is to be published. */
234
+                $stamp = __( 'Schedule for: %s' );
235
+            } else { // Draft, 1 or more saves, date specified.
236
+                /* translators: Post date information. %s: Date on which the post is to be published. */
237
+                $stamp = __( 'Publish on: %s' );
238
+            }
239
+            $date = sprintf(
240
+                $date_string,
241
+                date_i18n( $date_format, strtotime( $post->post_date ) ),
242
+                date_i18n( $time_format, strtotime( $post->post_date ) )
243
+            );
244
+        } else { // Draft (no saves, and thus no date specified).
245
+            $stamp = __( 'Publish <b>immediately</b>' );
246
+            $date  = sprintf(
247
+                $date_string,
248
+                date_i18n( $date_format, strtotime( current_time( 'mysql' ) ) ),
249
+                date_i18n( $time_format, strtotime( current_time( 'mysql' ) ) )
250
+            );
251
+        }
252
+
253
+        if ( ! empty( $args['args']['revisions_count'] ) ) :
254
+            ?>
255 255
 			<div class="misc-pub-section misc-pub-revisions">
256 256
 				<?php
257
-				/* translators: Post revisions heading. %s: The number of available revisions. */
258
-				printf( __( 'Revisions: %s' ), '<b>' . number_format_i18n( $args['args']['revisions_count'] ) . '</b>' );
259
-				?>
257
+                /* translators: Post revisions heading. %s: The number of available revisions. */
258
+                printf( __( 'Revisions: %s' ), '<b>' . number_format_i18n( $args['args']['revisions_count'] ) . '</b>' );
259
+                ?>
260 260
 				<a class="hide-if-no-js" href="<?php echo esc_url( get_edit_post_link( $args['args']['revision_id'] ) ); ?>"><span aria-hidden="true"><?php _ex( 'Browse', 'revisions' ); ?></span> <span class="screen-reader-text"><?php _e( 'Browse revisions' ); ?></span></a>
261 261
 			</div>
262 262
 			<?php
263
-		endif;
263
+        endif;
264 264
 
265
-		if ( $can_publish ) : // Contributors don't get to choose the date of publish.
266
-			?>
265
+        if ( $can_publish ) : // Contributors don't get to choose the date of publish.
266
+            ?>
267 267
 			<div class="misc-pub-section curtime misc-pub-curtime">
268 268
 				<span id="timestamp">
269 269
 					<?php printf( $stamp, '<b>' . $date . '</b>' ); ?>
@@ -278,101 +278,101 @@  discard block
 block discarded – undo
278 278
 				</fieldset>
279 279
 			</div>
280 280
 			<?php
281
-		endif;
281
+        endif;
282 282
 
283
-		if ( 'draft' === $post->post_status && get_post_meta( $post_id, '_customize_changeset_uuid', true ) ) :
284
-			?>
283
+        if ( 'draft' === $post->post_status && get_post_meta( $post_id, '_customize_changeset_uuid', true ) ) :
284
+            ?>
285 285
 			<div class="notice notice-info notice-alt inline">
286 286
 				<p>
287 287
 					<?php
288
-					printf(
289
-						/* translators: %s: URL to the Customizer. */
290
-						__( 'This draft comes from your <a href="%s">unpublished customization changes</a>. You can edit, but there is no need to publish now. It will be published automatically with those changes.' ),
291
-						esc_url(
292
-							add_query_arg(
293
-								'changeset_uuid',
294
-								rawurlencode( get_post_meta( $post_id, '_customize_changeset_uuid', true ) ),
295
-								admin_url( 'customize.php' )
296
-							)
297
-						)
298
-					);
299
-					?>
288
+                    printf(
289
+                        /* translators: %s: URL to the Customizer. */
290
+                        __( 'This draft comes from your <a href="%s">unpublished customization changes</a>. You can edit, but there is no need to publish now. It will be published automatically with those changes.' ),
291
+                        esc_url(
292
+                            add_query_arg(
293
+                                'changeset_uuid',
294
+                                rawurlencode( get_post_meta( $post_id, '_customize_changeset_uuid', true ) ),
295
+                                admin_url( 'customize.php' )
296
+                            )
297
+                        )
298
+                    );
299
+                    ?>
300 300
 				</p>
301 301
 			</div>
302 302
 			<?php
303
-		endif;
304
-
305
-		/**
306
-		 * Fires after the post time/date setting in the Publish meta box.
307
-		 *
308
-		 * @since 2.9.0
309
-		 * @since 4.4.0 Added the `$post` parameter.
310
-		 *
311
-		 * @param WP_Post $post WP_Post object for the current post.
312
-		 */
313
-		do_action( 'post_submitbox_misc_actions', $post );
314
-		?>
303
+        endif;
304
+
305
+        /**
306
+         * Fires after the post time/date setting in the Publish meta box.
307
+         *
308
+         * @since 2.9.0
309
+         * @since 4.4.0 Added the `$post` parameter.
310
+         *
311
+         * @param WP_Post $post WP_Post object for the current post.
312
+         */
313
+        do_action( 'post_submitbox_misc_actions', $post );
314
+        ?>
315 315
 	</div>
316 316
 	<div class="clear"></div>
317 317
 </div>
318 318
 
319 319
 <div id="major-publishing-actions">
320 320
 	<?php
321
-	/**
322
-	 * Fires at the beginning of the publishing actions section of the Publish meta box.
323
-	 *
324
-	 * @since 2.7.0
325
-	 * @since 4.9.0 Added the `$post` parameter.
326
-	 *
327
-	 * @param WP_Post|null $post WP_Post object for the current post on Edit Post screen,
328
-	 *                           null on Edit Link screen.
329
-	 */
330
-	do_action( 'post_submitbox_start', $post );
331
-	?>
321
+    /**
322
+     * Fires at the beginning of the publishing actions section of the Publish meta box.
323
+     *
324
+     * @since 2.7.0
325
+     * @since 4.9.0 Added the `$post` parameter.
326
+     *
327
+     * @param WP_Post|null $post WP_Post object for the current post on Edit Post screen,
328
+     *                           null on Edit Link screen.
329
+     */
330
+    do_action( 'post_submitbox_start', $post );
331
+    ?>
332 332
 	<div id="delete-action">
333 333
 		<?php
334
-		if ( current_user_can( 'delete_post', $post_id ) ) {
335
-			if ( ! EMPTY_TRASH_DAYS ) {
336
-				$delete_text = __( 'Delete permanently' );
337
-			} else {
338
-				$delete_text = __( 'Move to Trash' );
339
-			}
340
-			?>
334
+        if ( current_user_can( 'delete_post', $post_id ) ) {
335
+            if ( ! EMPTY_TRASH_DAYS ) {
336
+                $delete_text = __( 'Delete permanently' );
337
+            } else {
338
+                $delete_text = __( 'Move to Trash' );
339
+            }
340
+            ?>
341 341
 			<a class="submitdelete deletion" href="<?php echo get_delete_post_link( $post_id ); ?>"><?php echo $delete_text; ?></a>
342 342
 			<?php
343
-		}
344
-		?>
343
+        }
344
+        ?>
345 345
 	</div>
346 346
 
347 347
 	<div id="publishing-action">
348 348
 		<span class="spinner"></span>
349 349
 		<?php
350
-		if ( ! in_array( $post->post_status, array( 'publish', 'future', 'private' ), true ) || 0 === $post_id ) {
351
-			if ( $can_publish ) :
352
-				if ( ! empty( $post->post_date_gmt ) && time() < strtotime( $post->post_date_gmt . ' +0000' ) ) :
353
-					?>
350
+        if ( ! in_array( $post->post_status, array( 'publish', 'future', 'private' ), true ) || 0 === $post_id ) {
351
+            if ( $can_publish ) :
352
+                if ( ! empty( $post->post_date_gmt ) && time() < strtotime( $post->post_date_gmt . ' +0000' ) ) :
353
+                    ?>
354 354
 					<input name="original_publish" type="hidden" id="original_publish" value="<?php echo esc_attr_x( 'Schedule', 'post action/button label' ); ?>" />
355 355
 					<?php submit_button( _x( 'Schedule', 'post action/button label' ), 'primary large', 'publish', false ); ?>
356 356
 					<?php
357
-				else :
358
-					?>
357
+                else :
358
+                    ?>
359 359
 					<input name="original_publish" type="hidden" id="original_publish" value="<?php esc_attr_e( 'Publish' ); ?>" />
360 360
 					<?php submit_button( __( 'Publish' ), 'primary large', 'publish', false ); ?>
361 361
 					<?php
362
-				endif;
363
-			else :
364
-				?>
362
+                endif;
363
+            else :
364
+                ?>
365 365
 				<input name="original_publish" type="hidden" id="original_publish" value="<?php esc_attr_e( 'Submit for Review' ); ?>" />
366 366
 				<?php submit_button( __( 'Submit for Review' ), 'primary large', 'publish', false ); ?>
367 367
 				<?php
368
-			endif;
369
-		} else {
370
-			?>
368
+            endif;
369
+        } else {
370
+            ?>
371 371
 			<input name="original_publish" type="hidden" id="original_publish" value="<?php esc_attr_e( 'Update' ); ?>" />
372 372
 			<?php submit_button( __( 'Update' ), 'primary large', 'save', false, array( 'id' => 'publish' ) ); ?>
373 373
 			<?php
374
-		}
375
-		?>
374
+        }
375
+        ?>
376 376
 	</div>
377 377
 	<div class="clear"></div>
378 378
 </div>
@@ -389,7 +389,7 @@  discard block
 block discarded – undo
389 389
  * @param WP_Post $post Current post object.
390 390
  */
391 391
 function attachment_submit_meta_box( $post ) {
392
-	?>
392
+    ?>
393 393
 <div class="submitbox" id="submitpost">
394 394
 
395 395
 <div id="minor-publishing">
@@ -404,32 +404,32 @@  discard block
 block discarded – undo
404 404
 	<div class="misc-pub-section curtime misc-pub-curtime">
405 405
 		<span id="timestamp">
406 406
 			<?php
407
-			$uploaded_on = sprintf(
408
-				/* translators: Publish box date string. 1: Date, 2: Time. See https://www.php.net/manual/datetime.format.php */
409
-				__( '%1$s at %2$s' ),
410
-				/* translators: Publish box date format, see https://www.php.net/manual/datetime.format.php */
411
-				date_i18n( _x( 'M j, Y', 'publish box date format' ), strtotime( $post->post_date ) ),
412
-				/* translators: Publish box time format, see https://www.php.net/manual/datetime.format.php */
413
-				date_i18n( _x( 'H:i', 'publish box time format' ), strtotime( $post->post_date ) )
414
-			);
415
-			/* translators: Attachment information. %s: Date the attachment was uploaded. */
416
-			printf( __( 'Uploaded on: %s' ), '<b>' . $uploaded_on . '</b>' );
417
-			?>
407
+            $uploaded_on = sprintf(
408
+                /* translators: Publish box date string. 1: Date, 2: Time. See https://www.php.net/manual/datetime.format.php */
409
+                __( '%1$s at %2$s' ),
410
+                /* translators: Publish box date format, see https://www.php.net/manual/datetime.format.php */
411
+                date_i18n( _x( 'M j, Y', 'publish box date format' ), strtotime( $post->post_date ) ),
412
+                /* translators: Publish box time format, see https://www.php.net/manual/datetime.format.php */
413
+                date_i18n( _x( 'H:i', 'publish box time format' ), strtotime( $post->post_date ) )
414
+            );
415
+            /* translators: Attachment information. %s: Date the attachment was uploaded. */
416
+            printf( __( 'Uploaded on: %s' ), '<b>' . $uploaded_on . '</b>' );
417
+            ?>
418 418
 		</span>
419 419
 	</div><!-- .misc-pub-section -->
420 420
 
421 421
 	<?php
422
-	/**
423
-	 * Fires after the 'Uploaded on' section of the Save meta box
424
-	 * in the attachment editing screen.
425
-	 *
426
-	 * @since 3.5.0
427
-	 * @since 4.9.0 Added the `$post` parameter.
428
-	 *
429
-	 * @param WP_Post $post WP_Post object for the current attachment.
430
-	 */
431
-	do_action( 'attachment_submitbox_misc_actions', $post );
432
-	?>
422
+    /**
423
+     * Fires after the 'Uploaded on' section of the Save meta box
424
+     * in the attachment editing screen.
425
+     *
426
+     * @since 3.5.0
427
+     * @since 4.9.0 Added the `$post` parameter.
428
+     *
429
+     * @param WP_Post $post WP_Post object for the current attachment.
430
+     */
431
+    do_action( 'attachment_submitbox_misc_actions', $post );
432
+    ?>
433 433
 </div><!-- #misc-publishing-actions -->
434 434
 <div class="clear"></div>
435 435
 </div><!-- #minor-publishing -->
@@ -437,15 +437,15 @@  discard block
 block discarded – undo
437 437
 <div id="major-publishing-actions">
438 438
 	<div id="delete-action">
439 439
 	<?php
440
-	if ( current_user_can( 'delete_post', $post->ID ) ) {
441
-		if ( EMPTY_TRASH_DAYS && MEDIA_TRASH ) {
442
-			echo "<a class='submitdelete deletion' href='" . get_delete_post_link( $post->ID ) . "'>" . __( 'Move to Trash' ) . '</a>';
443
-		} else {
444
-			$delete_ays = ! MEDIA_TRASH ? " onclick='return showNotice.warn();'" : '';
445
-			echo "<a class='submitdelete deletion'$delete_ays href='" . get_delete_post_link( $post->ID, null, true ) . "'>" . __( 'Delete permanently' ) . '</a>';
446
-		}
447
-	}
448
-	?>
440
+    if ( current_user_can( 'delete_post', $post->ID ) ) {
441
+        if ( EMPTY_TRASH_DAYS && MEDIA_TRASH ) {
442
+            echo "<a class='submitdelete deletion' href='" . get_delete_post_link( $post->ID ) . "'>" . __( 'Move to Trash' ) . '</a>';
443
+        } else {
444
+            $delete_ays = ! MEDIA_TRASH ? " onclick='return showNotice.warn();'" : '';
445
+            echo "<a class='submitdelete deletion'$delete_ays href='" . get_delete_post_link( $post->ID, null, true ) . "'>" . __( 'Delete permanently' ) . '</a>';
446
+        }
447
+    }
448
+    ?>
449 449
 	</div>
450 450
 
451 451
 	<div id="publishing-action">
@@ -477,19 +477,19 @@  discard block
 block discarded – undo
477 477
  * }
478 478
  */
479 479
 function post_format_meta_box( $post, $box ) {
480
-	if ( current_theme_supports( 'post-formats' ) && post_type_supports( $post->post_type, 'post-formats' ) ) :
481
-		$post_formats = get_theme_support( 'post-formats' );
482
-
483
-		if ( is_array( $post_formats[0] ) ) :
484
-			$post_format = get_post_format( $post->ID );
485
-			if ( ! $post_format ) {
486
-				$post_format = '0';
487
-			}
488
-			// Add in the current one if it isn't there yet, in case the active theme doesn't support it.
489
-			if ( $post_format && ! in_array( $post_format, $post_formats[0], true ) ) {
490
-				$post_formats[0][] = $post_format;
491
-			}
492
-			?>
480
+    if ( current_theme_supports( 'post-formats' ) && post_type_supports( $post->post_type, 'post-formats' ) ) :
481
+        $post_formats = get_theme_support( 'post-formats' );
482
+
483
+        if ( is_array( $post_formats[0] ) ) :
484
+            $post_format = get_post_format( $post->ID );
485
+            if ( ! $post_format ) {
486
+                $post_format = '0';
487
+            }
488
+            // Add in the current one if it isn't there yet, in case the active theme doesn't support it.
489
+            if ( $post_format && ! in_array( $post_format, $post_formats[0], true ) ) {
490
+                $post_formats[0][] = $post_format;
491
+            }
492
+            ?>
493 493
 		<div id="post-formats-select">
494 494
 		<fieldset>
495 495
 			<legend class="screen-reader-text"><?php _e( 'Post Formats' ); ?></legend>
@@ -500,7 +500,7 @@  discard block
 block discarded – undo
500 500
 		</fieldset>
501 501
 	</div>
502 502
 			<?php
503
-	endif;
503
+    endif;
504 504
 endif;
505 505
 }
506 506
 
@@ -526,22 +526,22 @@  discard block
 block discarded – undo
526 526
  * }
527 527
  */
528 528
 function post_tags_meta_box( $post, $box ) {
529
-	$defaults = array( 'taxonomy' => 'post_tag' );
530
-	if ( ! isset( $box['args'] ) || ! is_array( $box['args'] ) ) {
531
-		$args = array();
532
-	} else {
533
-		$args = $box['args'];
534
-	}
535
-	$parsed_args           = wp_parse_args( $args, $defaults );
536
-	$tax_name              = esc_attr( $parsed_args['taxonomy'] );
537
-	$taxonomy              = get_taxonomy( $parsed_args['taxonomy'] );
538
-	$user_can_assign_terms = current_user_can( $taxonomy->cap->assign_terms );
539
-	$comma                 = _x( ',', 'tag delimiter' );
540
-	$terms_to_edit         = get_terms_to_edit( $post->ID, $tax_name );
541
-	if ( ! is_string( $terms_to_edit ) ) {
542
-		$terms_to_edit = '';
543
-	}
544
-	?>
529
+    $defaults = array( 'taxonomy' => 'post_tag' );
530
+    if ( ! isset( $box['args'] ) || ! is_array( $box['args'] ) ) {
531
+        $args = array();
532
+    } else {
533
+        $args = $box['args'];
534
+    }
535
+    $parsed_args           = wp_parse_args( $args, $defaults );
536
+    $tax_name              = esc_attr( $parsed_args['taxonomy'] );
537
+    $taxonomy              = get_taxonomy( $parsed_args['taxonomy'] );
538
+    $user_can_assign_terms = current_user_can( $taxonomy->cap->assign_terms );
539
+    $comma                 = _x( ',', 'tag delimiter' );
540
+    $terms_to_edit         = get_terms_to_edit( $post->ID, $tax_name );
541
+    if ( ! is_string( $terms_to_edit ) ) {
542
+        $terms_to_edit = '';
543
+    }
544
+    ?>
545 545
 <div class="tagsdiv" id="<?php echo $tax_name; ?>">
546 546
 	<div class="jaxtag">
547 547
 	<div class="nojs-tags hide-if-js">
@@ -589,16 +589,16 @@  discard block
 block discarded – undo
589 589
  * }
590 590
  */
591 591
 function post_categories_meta_box( $post, $box ) {
592
-	$defaults = array( 'taxonomy' => 'category' );
593
-	if ( ! isset( $box['args'] ) || ! is_array( $box['args'] ) ) {
594
-		$args = array();
595
-	} else {
596
-		$args = $box['args'];
597
-	}
598
-	$parsed_args = wp_parse_args( $args, $defaults );
599
-	$tax_name    = esc_attr( $parsed_args['taxonomy'] );
600
-	$taxonomy    = get_taxonomy( $parsed_args['taxonomy'] );
601
-	?>
592
+    $defaults = array( 'taxonomy' => 'category' );
593
+    if ( ! isset( $box['args'] ) || ! is_array( $box['args'] ) ) {
594
+        $args = array();
595
+    } else {
596
+        $args = $box['args'];
597
+    }
598
+    $parsed_args = wp_parse_args( $args, $defaults );
599
+    $tax_name    = esc_attr( $parsed_args['taxonomy'] );
600
+    $taxonomy    = get_taxonomy( $parsed_args['taxonomy'] );
601
+    ?>
602 602
 	<div id="taxonomy-<?php echo $tax_name; ?>" class="categorydiv">
603 603
 		<ul id="<?php echo $tax_name; ?>-tabs" class="category-tabs">
604 604
 			<li class="tabs"><a href="#<?php echo $tax_name; ?>-all"><?php echo $taxonomy->labels->all_items; ?></a></li>
@@ -613,29 +613,29 @@  discard block
 block discarded – undo
613 613
 
614 614
 		<div id="<?php echo $tax_name; ?>-all" class="tabs-panel">
615 615
 			<?php
616
-			$name = ( 'category' === $tax_name ) ? 'post_category' : 'tax_input[' . $tax_name . ']';
617
-			// Allows for an empty term set to be sent. 0 is an invalid term ID and will be ignored by empty() checks.
618
-			echo "<input type='hidden' name='{$name}[]' value='0' />";
619
-			?>
616
+            $name = ( 'category' === $tax_name ) ? 'post_category' : 'tax_input[' . $tax_name . ']';
617
+            // Allows for an empty term set to be sent. 0 is an invalid term ID and will be ignored by empty() checks.
618
+            echo "<input type='hidden' name='{$name}[]' value='0' />";
619
+            ?>
620 620
 			<ul id="<?php echo $tax_name; ?>checklist" data-wp-lists="list:<?php echo $tax_name; ?>" class="categorychecklist form-no-clear">
621 621
 				<?php
622
-				wp_terms_checklist(
623
-					$post->ID,
624
-					array(
625
-						'taxonomy'     => $tax_name,
626
-						'popular_cats' => $popular_ids,
627
-					)
628
-				);
629
-				?>
622
+                wp_terms_checklist(
623
+                    $post->ID,
624
+                    array(
625
+                        'taxonomy'     => $tax_name,
626
+                        'popular_cats' => $popular_ids,
627
+                    )
628
+                );
629
+                ?>
630 630
 			</ul>
631 631
 		</div>
632 632
 	<?php if ( current_user_can( $taxonomy->cap->edit_terms ) ) : ?>
633 633
 			<div id="<?php echo $tax_name; ?>-adder" class="wp-hidden-children">
634 634
 				<a id="<?php echo $tax_name; ?>-add-toggle" href="#<?php echo $tax_name; ?>-add" class="hide-if-no-js taxonomy-add-new">
635 635
 					<?php
636
-						/* translators: %s: Add New taxonomy label. */
637
-						printf( __( '+ %s' ), $taxonomy->labels->add_new_item );
638
-					?>
636
+                        /* translators: %s: Add New taxonomy label. */
637
+                        printf( __( '+ %s' ), $taxonomy->labels->add_new_item );
638
+                    ?>
639 639
 				</a>
640 640
 				<p id="<?php echo $tax_name; ?>-add" class="category-add wp-hidden-child">
641 641
 					<label class="screen-reader-text" for="new<?php echo $tax_name; ?>"><?php echo $taxonomy->labels->add_new_item; ?></label>
@@ -644,43 +644,43 @@  discard block
 block discarded – undo
644 644
 						<?php echo $taxonomy->labels->parent_item_colon; ?>
645 645
 					</label>
646 646
 					<?php
647
-					$parent_dropdown_args = array(
648
-						'taxonomy'         => $tax_name,
649
-						'hide_empty'       => 0,
650
-						'name'             => 'new' . $tax_name . '_parent',
651
-						'orderby'          => 'name',
652
-						'hierarchical'     => 1,
653
-						'show_option_none' => '&mdash; ' . $taxonomy->labels->parent_item . ' &mdash;',
654
-					);
655
-
656
-					/**
657
-					 * Filters the arguments for the taxonomy parent dropdown on the Post Edit page.
658
-					 *
659
-					 * @since 4.4.0
660
-					 *
661
-					 * @param array $parent_dropdown_args {
662
-					 *     Optional. Array of arguments to generate parent dropdown.
663
-					 *
664
-					 *     @type string   $taxonomy         Name of the taxonomy to retrieve.
665
-					 *     @type bool     $hide_if_empty    True to skip generating markup if no
666
-					 *                                      categories are found. Default 0.
667
-					 *     @type string   $name             Value for the 'name' attribute
668
-					 *                                      of the select element.
669
-					 *                                      Default "new{$tax_name}_parent".
670
-					 *     @type string   $orderby          Which column to use for ordering
671
-					 *                                      terms. Default 'name'.
672
-					 *     @type bool|int $hierarchical     Whether to traverse the taxonomy
673
-					 *                                      hierarchy. Default 1.
674
-					 *     @type string   $show_option_none Text to display for the "none" option.
675
-					 *                                      Default "&mdash; {$parent} &mdash;",
676
-					 *                                      where `$parent` is 'parent_item'
677
-					 *                                      taxonomy label.
678
-					 * }
679
-					 */
680
-					$parent_dropdown_args = apply_filters( 'post_edit_category_parent_dropdown_args', $parent_dropdown_args );
681
-
682
-					wp_dropdown_categories( $parent_dropdown_args );
683
-					?>
647
+                    $parent_dropdown_args = array(
648
+                        'taxonomy'         => $tax_name,
649
+                        'hide_empty'       => 0,
650
+                        'name'             => 'new' . $tax_name . '_parent',
651
+                        'orderby'          => 'name',
652
+                        'hierarchical'     => 1,
653
+                        'show_option_none' => '&mdash; ' . $taxonomy->labels->parent_item . ' &mdash;',
654
+                    );
655
+
656
+                    /**
657
+                     * Filters the arguments for the taxonomy parent dropdown on the Post Edit page.
658
+                     *
659
+                     * @since 4.4.0
660
+                     *
661
+                     * @param array $parent_dropdown_args {
662
+                     *     Optional. Array of arguments to generate parent dropdown.
663
+                     *
664
+                     *     @type string   $taxonomy         Name of the taxonomy to retrieve.
665
+                     *     @type bool     $hide_if_empty    True to skip generating markup if no
666
+                     *                                      categories are found. Default 0.
667
+                     *     @type string   $name             Value for the 'name' attribute
668
+                     *                                      of the select element.
669
+                     *                                      Default "new{$tax_name}_parent".
670
+                     *     @type string   $orderby          Which column to use for ordering
671
+                     *                                      terms. Default 'name'.
672
+                     *     @type bool|int $hierarchical     Whether to traverse the taxonomy
673
+                     *                                      hierarchy. Default 1.
674
+                     *     @type string   $show_option_none Text to display for the "none" option.
675
+                     *                                      Default "&mdash; {$parent} &mdash;",
676
+                     *                                      where `$parent` is 'parent_item'
677
+                     *                                      taxonomy label.
678
+                     * }
679
+                     */
680
+                    $parent_dropdown_args = apply_filters( 'post_edit_category_parent_dropdown_args', $parent_dropdown_args );
681
+
682
+                    wp_dropdown_categories( $parent_dropdown_args );
683
+                    ?>
684 684
 					<input type="button" id="<?php echo $tax_name; ?>-add-submit" data-wp-lists="add:<?php echo $tax_name; ?>checklist:<?php echo $tax_name; ?>-add" class="button category-add-submit" value="<?php echo esc_attr( $taxonomy->labels->add_new_item ); ?>" />
685 685
 					<?php wp_nonce_field( 'add-' . $tax_name, '_ajax_nonce-add-' . $tax_name, false ); ?>
686 686
 					<span id="<?php echo $tax_name; ?>-ajax-response"></span>
@@ -699,16 +699,16 @@  discard block
 block discarded – undo
699 699
  * @param WP_Post $post Current post object.
700 700
  */
701 701
 function post_excerpt_meta_box( $post ) {
702
-	?>
702
+    ?>
703 703
 <label class="screen-reader-text" for="excerpt"><?php _e( 'Excerpt' ); ?></label><textarea rows="1" cols="40" name="excerpt" id="excerpt"><?php echo $post->post_excerpt; // textarea_escaped ?></textarea>
704 704
 <p>
705 705
 	<?php
706
-	printf(
707
-		/* translators: %s: Documentation URL. */
708
-		__( 'Excerpts are optional hand-crafted summaries of your content that can be used in your theme. <a href="%s">Learn more about manual excerpts</a>.' ),
709
-		__( 'https://wordpress.org/support/article/excerpt/' )
710
-	);
711
-	?>
706
+    printf(
707
+        /* translators: %s: Documentation URL. */
708
+        __( 'Excerpts are optional hand-crafted summaries of your content that can be used in your theme. <a href="%s">Learn more about manual excerpts</a>.' ),
709
+        __( 'https://wordpress.org/support/article/excerpt/' )
710
+    );
711
+    ?>
712 712
 </p>
713 713
 	<?php
714 714
 }
@@ -721,19 +721,19 @@  discard block
 block discarded – undo
721 721
  * @param WP_Post $post Current post object.
722 722
  */
723 723
 function post_trackback_meta_box( $post ) {
724
-	$form_trackback = '<input type="text" name="trackback_url" id="trackback_url" class="code" value="' .
725
-		esc_attr( str_replace( "\n", ' ', $post->to_ping ) ) . '" aria-describedby="trackback-url-desc" />';
726
-
727
-	if ( '' !== $post->pinged ) {
728
-		$pings          = '<p>' . __( 'Already pinged:' ) . '</p><ul>';
729
-		$already_pinged = explode( "\n", trim( $post->pinged ) );
730
-		foreach ( $already_pinged as $pinged_url ) {
731
-			$pings .= "\n\t<li>" . esc_html( $pinged_url ) . '</li>';
732
-		}
733
-		$pings .= '</ul>';
734
-	}
735
-
736
-	?>
724
+    $form_trackback = '<input type="text" name="trackback_url" id="trackback_url" class="code" value="' .
725
+        esc_attr( str_replace( "\n", ' ', $post->to_ping ) ) . '" aria-describedby="trackback-url-desc" />';
726
+
727
+    if ( '' !== $post->pinged ) {
728
+        $pings          = '<p>' . __( 'Already pinged:' ) . '</p><ul>';
729
+        $already_pinged = explode( "\n", trim( $post->pinged ) );
730
+        foreach ( $already_pinged as $pinged_url ) {
731
+            $pings .= "\n\t<li>" . esc_html( $pinged_url ) . '</li>';
732
+        }
733
+        $pings .= '</ul>';
734
+    }
735
+
736
+    ?>
737 737
 <p>
738 738
 	<label for="trackback_url"><?php _e( 'Send trackbacks to:' ); ?></label>
739 739
 	<?php echo $form_trackback; ?>
@@ -741,17 +741,17 @@  discard block
 block discarded – undo
741 741
 <p id="trackback-url-desc" class="howto"><?php _e( 'Separate multiple URLs with spaces' ); ?></p>
742 742
 <p>
743 743
 	<?php
744
-	printf(
745
-		/* translators: %s: Documentation URL. */
746
-		__( 'Trackbacks are a way to notify legacy blog systems that you&#8217;ve linked to them. If you link other WordPress sites, they&#8217;ll be notified automatically using <a href="%s">pingbacks</a>, no other action necessary.' ),
747
-		__( 'https://wordpress.org/support/article/introduction-to-blogging/#comments' )
748
-	);
749
-	?>
744
+    printf(
745
+        /* translators: %s: Documentation URL. */
746
+        __( 'Trackbacks are a way to notify legacy blog systems that you&#8217;ve linked to them. If you link other WordPress sites, they&#8217;ll be notified automatically using <a href="%s">pingbacks</a>, no other action necessary.' ),
747
+        __( 'https://wordpress.org/support/article/introduction-to-blogging/#comments' )
748
+    );
749
+    ?>
750 750
 </p>
751 751
 	<?php
752
-	if ( ! empty( $pings ) ) {
753
-		echo $pings;
754
-	}
752
+    if ( ! empty( $pings ) ) {
753
+        echo $pings;
754
+    }
755 755
 }
756 756
 
757 757
 /**
@@ -762,28 +762,28 @@  discard block
 block discarded – undo
762 762
  * @param WP_Post $post Current post object.
763 763
  */
764 764
 function post_custom_meta_box( $post ) {
765
-	?>
765
+    ?>
766 766
 <div id="postcustomstuff">
767 767
 <div id="ajax-response"></div>
768 768
 	<?php
769
-	$metadata = has_meta( $post->ID );
770
-	foreach ( $metadata as $key => $value ) {
771
-		if ( is_protected_meta( $metadata[ $key ]['meta_key'], 'post' ) || ! current_user_can( 'edit_post_meta', $post->ID, $metadata[ $key ]['meta_key'] ) ) {
772
-			unset( $metadata[ $key ] );
773
-		}
774
-	}
775
-	list_meta( $metadata );
776
-	meta_form( $post );
777
-	?>
769
+    $metadata = has_meta( $post->ID );
770
+    foreach ( $metadata as $key => $value ) {
771
+        if ( is_protected_meta( $metadata[ $key ]['meta_key'], 'post' ) || ! current_user_can( 'edit_post_meta', $post->ID, $metadata[ $key ]['meta_key'] ) ) {
772
+            unset( $metadata[ $key ] );
773
+        }
774
+    }
775
+    list_meta( $metadata );
776
+    meta_form( $post );
777
+    ?>
778 778
 </div>
779 779
 <p>
780 780
 	<?php
781
-	printf(
782
-		/* translators: %s: Documentation URL. */
783
-		__( 'Custom fields can be used to add extra metadata to a post that you can <a href="%s">use in your theme</a>.' ),
784
-		__( 'https://wordpress.org/support/article/custom-fields/' )
785
-	);
786
-	?>
781
+    printf(
782
+        /* translators: %s: Documentation URL. */
783
+        __( 'Custom fields can be used to add extra metadata to a post that you can <a href="%s">use in your theme</a>.' ),
784
+        __( 'https://wordpress.org/support/article/custom-fields/' )
785
+    );
786
+    ?>
787 787
 </p>
788 788
 	<?php
789 789
 }
@@ -796,29 +796,29 @@  discard block
 block discarded – undo
796 796
  * @param WP_Post $post Current post object.
797 797
  */
798 798
 function post_comment_status_meta_box( $post ) {
799
-	?>
799
+    ?>
800 800
 <input name="advanced_view" type="hidden" value="1" />
801 801
 <p class="meta-options">
802 802
 	<label for="comment_status" class="selectit"><input name="comment_status" type="checkbox" id="comment_status" value="open" <?php checked( $post->comment_status, 'open' ); ?> /> <?php _e( 'Allow comments' ); ?></label><br />
803 803
 	<label for="ping_status" class="selectit"><input name="ping_status" type="checkbox" id="ping_status" value="open" <?php checked( $post->ping_status, 'open' ); ?> />
804 804
 		<?php
805
-		printf(
806
-			/* translators: %s: Documentation URL. */
807
-			__( 'Allow <a href="%s">trackbacks and pingbacks</a> on this page' ),
808
-			__( 'https://wordpress.org/support/article/introduction-to-blogging/#managing-comments' )
809
-		);
810
-		?>
805
+        printf(
806
+            /* translators: %s: Documentation URL. */
807
+            __( 'Allow <a href="%s">trackbacks and pingbacks</a> on this page' ),
808
+            __( 'https://wordpress.org/support/article/introduction-to-blogging/#managing-comments' )
809
+        );
810
+        ?>
811 811
 	</label>
812 812
 	<?php
813
-	/**
814
-	 * Fires at the end of the Discussion meta box on the post editing screen.
815
-	 *
816
-	 * @since 3.1.0
817
-	 *
818
-	 * @param WP_Post $post WP_Post object for the current post.
819
-	 */
820
-	do_action( 'post_comment_status_meta_box-options', $post ); // phpcs:ignore WordPress.NamingConventions.ValidHookName.UseUnderscores
821
-	?>
813
+    /**
814
+     * Fires at the end of the Discussion meta box on the post editing screen.
815
+     *
816
+     * @since 3.1.0
817
+     *
818
+     * @param WP_Post $post WP_Post object for the current post.
819
+     */
820
+    do_action( 'post_comment_status_meta_box-options', $post ); // phpcs:ignore WordPress.NamingConventions.ValidHookName.UseUnderscores
821
+    ?>
822 822
 </p>
823 823
 	<?php
824 824
 }
@@ -832,8 +832,8 @@  discard block
 block discarded – undo
832 832
  * @return array
833 833
  */
834 834
 function post_comment_meta_box_thead( $result ) {
835
-	unset( $result['cb'], $result['response'] );
836
-	return $result;
835
+    unset( $result['cb'], $result['response'] );
836
+    return $result;
837 837
 }
838 838
 
839 839
 /**
@@ -844,37 +844,37 @@  discard block
 block discarded – undo
844 844
  * @param WP_Post $post Current post object.
845 845
  */
846 846
 function post_comment_meta_box( $post ) {
847
-	wp_nonce_field( 'get-comments', 'add_comment_nonce', false );
848
-	?>
847
+    wp_nonce_field( 'get-comments', 'add_comment_nonce', false );
848
+    ?>
849 849
 	<p class="hide-if-no-js" id="add-new-comment"><button type="button" class="button" onclick="window.commentReply && commentReply.addcomment(<?php echo $post->ID; ?>);"><?php _e( 'Add Comment' ); ?></button></p>
850 850
 	<?php
851 851
 
852
-	$total         = get_comments(
853
-		array(
854
-			'post_id' => $post->ID,
855
-			'number'  => 1,
856
-			'count'   => true,
857
-		)
858
-	);
859
-	$wp_list_table = _get_list_table( 'WP_Post_Comments_List_Table' );
860
-	$wp_list_table->display( true );
861
-
862
-	if ( 1 > $total ) {
863
-		echo '<p id="no-comments">' . __( 'No comments yet.' ) . '</p>';
864
-	} else {
865
-		$hidden = get_hidden_meta_boxes( get_current_screen() );
866
-		if ( ! in_array( 'commentsdiv', $hidden, true ) ) {
867
-			?>
852
+    $total         = get_comments(
853
+        array(
854
+            'post_id' => $post->ID,
855
+            'number'  => 1,
856
+            'count'   => true,
857
+        )
858
+    );
859
+    $wp_list_table = _get_list_table( 'WP_Post_Comments_List_Table' );
860
+    $wp_list_table->display( true );
861
+
862
+    if ( 1 > $total ) {
863
+        echo '<p id="no-comments">' . __( 'No comments yet.' ) . '</p>';
864
+    } else {
865
+        $hidden = get_hidden_meta_boxes( get_current_screen() );
866
+        if ( ! in_array( 'commentsdiv', $hidden, true ) ) {
867
+            ?>
868 868
 			<script type="text/javascript">jQuery(function(){commentsBox.get(<?php echo $total; ?>, 10);});</script>
869 869
 			<?php
870
-		}
870
+        }
871 871
 
872
-		?>
872
+        ?>
873 873
 		<p class="hide-if-no-js" id="show-comments"><a href="#commentstatusdiv" onclick="commentsBox.load(<?php echo $total; ?>);return false;"><?php _e( 'Show comments' ); ?></a> <span class="spinner"></span></p>
874 874
 		<?php
875
-	}
875
+    }
876 876
 
877
-	wp_comment_trashnotice();
877
+    wp_comment_trashnotice();
878 878
 }
879 879
 
880 880
 /**
@@ -885,9 +885,9 @@  discard block
 block discarded – undo
885 885
  * @param WP_Post $post Current post object.
886 886
  */
887 887
 function post_slug_meta_box( $post ) {
888
-	/** This filter is documented in wp-admin/edit-tag-form.php */
889
-	$editable_slug = apply_filters( 'editable_slug', $post->post_name, $post );
890
-	?>
888
+    /** This filter is documented in wp-admin/edit-tag-form.php */
889
+    $editable_slug = apply_filters( 'editable_slug', $post->post_name, $post );
890
+    ?>
891 891
 <label class="screen-reader-text" for="post_name"><?php _e( 'Slug' ); ?></label><input name="post_name" type="text" size="13" id="post_name" value="<?php echo esc_attr( $editable_slug ); ?>" />
892 892
 	<?php
893 893
 }
@@ -902,21 +902,21 @@  discard block
 block discarded – undo
902 902
  * @param WP_Post $post Current post object.
903 903
  */
904 904
 function post_author_meta_box( $post ) {
905
-	global $user_ID;
905
+    global $user_ID;
906 906
 
907
-	$post_type_object = get_post_type_object( $post->post_type );
908
-	?>
907
+    $post_type_object = get_post_type_object( $post->post_type );
908
+    ?>
909 909
 <label class="screen-reader-text" for="post_author_override"><?php _e( 'Author' ); ?></label>
910 910
 	<?php
911
-	wp_dropdown_users(
912
-		array(
913
-			'capability'       => array( $post_type_object->cap->edit_posts ),
914
-			'name'             => 'post_author_override',
915
-			'selected'         => empty( $post->ID ) ? $user_ID : $post->post_author,
916
-			'include_selected' => true,
917
-			'show'             => 'display_name_with_login',
918
-		)
919
-	);
911
+    wp_dropdown_users(
912
+        array(
913
+            'capability'       => array( $post_type_object->cap->edit_posts ),
914
+            'name'             => 'post_author_override',
915
+            'selected'         => empty( $post->ID ) ? $user_ID : $post->post_author,
916
+            'include_selected' => true,
917
+            'show'             => 'display_name_with_login',
918
+        )
919
+    );
920 920
 }
921 921
 
922 922
 /**
@@ -927,7 +927,7 @@  discard block
 block discarded – undo
927 927
  * @param WP_Post $post Current post object.
928 928
  */
929 929
 function post_revisions_meta_box( $post ) {
930
-	wp_list_post_revisions( $post );
930
+    wp_list_post_revisions( $post );
931 931
 }
932 932
 
933 933
 //
@@ -942,67 +942,67 @@  discard block
 block discarded – undo
942 942
  * @param WP_Post $post Current post object.
943 943
  */
944 944
 function page_attributes_meta_box( $post ) {
945
-	if ( is_post_type_hierarchical( $post->post_type ) ) :
946
-		$dropdown_args = array(
947
-			'post_type'        => $post->post_type,
948
-			'exclude_tree'     => $post->ID,
949
-			'selected'         => $post->post_parent,
950
-			'name'             => 'parent_id',
951
-			'show_option_none' => __( '(no parent)' ),
952
-			'sort_column'      => 'menu_order, post_title',
953
-			'echo'             => 0,
954
-		);
955
-
956
-		/**
957
-		 * Filters the arguments used to generate a Pages drop-down element.
958
-		 *
959
-		 * @since 3.3.0
960
-		 *
961
-		 * @see wp_dropdown_pages()
962
-		 *
963
-		 * @param array   $dropdown_args Array of arguments used to generate the pages drop-down.
964
-		 * @param WP_Post $post          The current post.
965
-		 */
966
-		$dropdown_args = apply_filters( 'page_attributes_dropdown_pages_args', $dropdown_args, $post );
967
-		$pages         = wp_dropdown_pages( $dropdown_args );
968
-		if ( ! empty( $pages ) ) :
969
-			?>
945
+    if ( is_post_type_hierarchical( $post->post_type ) ) :
946
+        $dropdown_args = array(
947
+            'post_type'        => $post->post_type,
948
+            'exclude_tree'     => $post->ID,
949
+            'selected'         => $post->post_parent,
950
+            'name'             => 'parent_id',
951
+            'show_option_none' => __( '(no parent)' ),
952
+            'sort_column'      => 'menu_order, post_title',
953
+            'echo'             => 0,
954
+        );
955
+
956
+        /**
957
+         * Filters the arguments used to generate a Pages drop-down element.
958
+         *
959
+         * @since 3.3.0
960
+         *
961
+         * @see wp_dropdown_pages()
962
+         *
963
+         * @param array   $dropdown_args Array of arguments used to generate the pages drop-down.
964
+         * @param WP_Post $post          The current post.
965
+         */
966
+        $dropdown_args = apply_filters( 'page_attributes_dropdown_pages_args', $dropdown_args, $post );
967
+        $pages         = wp_dropdown_pages( $dropdown_args );
968
+        if ( ! empty( $pages ) ) :
969
+            ?>
970 970
 <p class="post-attributes-label-wrapper parent-id-label-wrapper"><label class="post-attributes-label" for="parent_id"><?php _e( 'Parent' ); ?></label></p>
971 971
 			<?php echo $pages; ?>
972 972
 			<?php
973
-		endif; // End empty pages check.
974
-	endif;  // End hierarchical check.
973
+        endif; // End empty pages check.
974
+    endif;  // End hierarchical check.
975 975
 
976
-	if ( count( get_page_templates( $post ) ) > 0 && get_option( 'page_for_posts' ) != $post->ID ) :
977
-		$template = ! empty( $post->page_template ) ? $post->page_template : false;
978
-		?>
976
+    if ( count( get_page_templates( $post ) ) > 0 && get_option( 'page_for_posts' ) != $post->ID ) :
977
+        $template = ! empty( $post->page_template ) ? $post->page_template : false;
978
+        ?>
979 979
 <p class="post-attributes-label-wrapper page-template-label-wrapper"><label class="post-attributes-label" for="page_template"><?php _e( 'Template' ); ?></label>
980 980
 		<?php
981
-		/**
982
-		 * Fires immediately after the label inside the 'Template' section
983
-		 * of the 'Page Attributes' meta box.
984
-		 *
985
-		 * @since 4.4.0
986
-		 *
987
-		 * @param string|false $template The template used for the current post.
988
-		 * @param WP_Post      $post     The current post.
989
-		 */
990
-		do_action( 'page_attributes_meta_box_template', $template, $post );
991
-		?>
981
+        /**
982
+         * Fires immediately after the label inside the 'Template' section
983
+         * of the 'Page Attributes' meta box.
984
+         *
985
+         * @since 4.4.0
986
+         *
987
+         * @param string|false $template The template used for the current post.
988
+         * @param WP_Post      $post     The current post.
989
+         */
990
+        do_action( 'page_attributes_meta_box_template', $template, $post );
991
+        ?>
992 992
 </p>
993 993
 <select name="page_template" id="page_template">
994 994
 		<?php
995
-		/**
996
-		 * Filters the title of the default page template displayed in the drop-down.
997
-		 *
998
-		 * @since 4.1.0
999
-		 *
1000
-		 * @param string $label   The display value for the default page template title.
1001
-		 * @param string $context Where the option label is displayed. Possible values
1002
-		 *                        include 'meta-box' or 'quick-edit'.
1003
-		 */
1004
-		$default_title = apply_filters( 'default_page_template_title', __( 'Default template' ), 'meta-box' );
1005
-		?>
995
+        /**
996
+         * Filters the title of the default page template displayed in the drop-down.
997
+         *
998
+         * @since 4.1.0
999
+         *
1000
+         * @param string $label   The display value for the default page template title.
1001
+         * @param string $context Where the option label is displayed. Possible values
1002
+         *                        include 'meta-box' or 'quick-edit'.
1003
+         */
1004
+        $default_title = apply_filters( 'default_page_template_title', __( 'Default template' ), 'meta-box' );
1005
+        ?>
1006 1006
 <option value="default"><?php echo esc_html( $default_title ); ?></option>
1007 1007
 		<?php page_template_dropdown( $template, $post->post_type ); ?>
1008 1008
 </select>
@@ -1011,20 +1011,20 @@  discard block
 block discarded – undo
1011 1011
 <p class="post-attributes-label-wrapper menu-order-label-wrapper"><label class="post-attributes-label" for="menu_order"><?php _e( 'Order' ); ?></label></p>
1012 1012
 <input name="menu_order" type="text" size="4" id="menu_order" value="<?php echo esc_attr( $post->menu_order ); ?>" />
1013 1013
 		<?php
1014
-		/**
1015
-		 * Fires before the help hint text in the 'Page Attributes' meta box.
1016
-		 *
1017
-		 * @since 4.9.0
1018
-		 *
1019
-		 * @param WP_Post $post The current post.
1020
-		 */
1021
-		do_action( 'page_attributes_misc_attributes', $post );
1022
-		?>
1014
+        /**
1015
+         * Fires before the help hint text in the 'Page Attributes' meta box.
1016
+         *
1017
+         * @since 4.9.0
1018
+         *
1019
+         * @param WP_Post $post The current post.
1020
+         */
1021
+        do_action( 'page_attributes_misc_attributes', $post );
1022
+        ?>
1023 1023
 		<?php if ( 'page' === $post->post_type && get_current_screen()->get_help_tabs() ) : ?>
1024 1024
 <p class="post-attributes-help-text"><?php _e( 'Need help? Use the Help tab above the screen title.' ); ?></p>
1025 1025
 			<?php
1026
-	endif;
1027
-	endif;
1026
+    endif;
1027
+    endif;
1028 1028
 }
1029 1029
 
1030 1030
 //
@@ -1039,7 +1039,7 @@  discard block
 block discarded – undo
1039 1039
  * @param object $link Current link object.
1040 1040
  */
1041 1041
 function link_submit_meta_box( $link ) {
1042
-	?>
1042
+    ?>
1043 1043
 <div class="submitbox" id="submitlink">
1044 1044
 
1045 1045
 <div id="minor-publishing">
@@ -1068,21 +1068,21 @@  discard block
 block discarded – undo
1068 1068
 
1069 1069
 <div id="major-publishing-actions">
1070 1070
 	<?php
1071
-	/** This action is documented in wp-admin/includes/meta-boxes.php */
1072
-	do_action( 'post_submitbox_start', null );
1073
-	?>
1071
+    /** This action is documented in wp-admin/includes/meta-boxes.php */
1072
+    do_action( 'post_submitbox_start', null );
1073
+    ?>
1074 1074
 <div id="delete-action">
1075 1075
 	<?php
1076
-	if ( ! empty( $_GET['action'] ) && 'edit' === $_GET['action'] && current_user_can( 'manage_links' ) ) {
1077
-		printf(
1078
-			'<a class="submitdelete deletion" href="%s" onclick="return confirm( \'%s\' );">%s</a>',
1079
-			wp_nonce_url( "link.php?action=delete&amp;link_id=$link->link_id", 'delete-bookmark_' . $link->link_id ),
1080
-			/* translators: %s: Link name. */
1081
-			esc_js( sprintf( __( "You are about to delete this link '%s'\n  'Cancel' to stop, 'OK' to delete." ), $link->link_name ) ),
1082
-			__( 'Delete' )
1083
-		);
1084
-	}
1085
-	?>
1076
+    if ( ! empty( $_GET['action'] ) && 'edit' === $_GET['action'] && current_user_can( 'manage_links' ) ) {
1077
+        printf(
1078
+            '<a class="submitdelete deletion" href="%s" onclick="return confirm( \'%s\' );">%s</a>',
1079
+            wp_nonce_url( "link.php?action=delete&amp;link_id=$link->link_id", 'delete-bookmark_' . $link->link_id ),
1080
+            /* translators: %s: Link name. */
1081
+            esc_js( sprintf( __( "You are about to delete this link '%s'\n  'Cancel' to stop, 'OK' to delete." ), $link->link_name ) ),
1082
+            __( 'Delete' )
1083
+        );
1084
+    }
1085
+    ?>
1086 1086
 </div>
1087 1087
 
1088 1088
 <div id="publishing-action">
@@ -1095,13 +1095,13 @@  discard block
 block discarded – undo
1095 1095
 <div class="clear"></div>
1096 1096
 </div>
1097 1097
 	<?php
1098
-	/**
1099
-	 * Fires at the end of the Publish box in the Link editing screen.
1100
-	 *
1101
-	 * @since 2.5.0
1102
-	 */
1103
-	do_action( 'submitlink_box' );
1104
-	?>
1098
+    /**
1099
+     * Fires at the end of the Publish box in the Link editing screen.
1100
+     *
1101
+     * @since 2.5.0
1102
+     */
1103
+    do_action( 'submitlink_box' );
1104
+    ?>
1105 1105
 <div class="clear"></div>
1106 1106
 </div>
1107 1107
 	<?php
@@ -1115,7 +1115,7 @@  discard block
 block discarded – undo
1115 1115
  * @param object $link Current link object.
1116 1116
  */
1117 1117
 function link_categories_meta_box( $link ) {
1118
-	?>
1118
+    ?>
1119 1119
 <div id="taxonomy-linkcategory" class="categorydiv">
1120 1120
 	<ul id="category-tabs" class="category-tabs">
1121 1121
 		<li class="tabs"><a href="#categories-all"><?php _e( 'All categories' ); ?></a></li>
@@ -1125,12 +1125,12 @@  discard block
 block discarded – undo
1125 1125
 	<div id="categories-all" class="tabs-panel">
1126 1126
 		<ul id="categorychecklist" data-wp-lists="list:category" class="categorychecklist form-no-clear">
1127 1127
 			<?php
1128
-			if ( isset( $link->link_id ) ) {
1129
-				wp_link_category_checklist( $link->link_id );
1130
-			} else {
1131
-				wp_link_category_checklist();
1132
-			}
1133
-			?>
1128
+            if ( isset( $link->link_id ) ) {
1129
+                wp_link_category_checklist( $link->link_id );
1130
+            } else {
1131
+                wp_link_category_checklist();
1132
+            }
1133
+            ?>
1134 1134
 		</ul>
1135 1135
 	</div>
1136 1136
 
@@ -1163,7 +1163,7 @@  discard block
 block discarded – undo
1163 1163
  */
1164 1164
 function link_target_meta_box( $link ) {
1165 1165
 
1166
-	?>
1166
+    ?>
1167 1167
 <fieldset><legend class="screen-reader-text"><span><?php _e( 'Target' ); ?></span></legend>
1168 1168
 <p><label for="link_target_blank" class="selectit">
1169 1169
 <input id="link_target_blank" type="radio" name="link_target" value="_blank" <?php echo ( isset( $link->link_target ) && ( '_blank' === $link->link_target ) ? 'checked="checked"' : '' ); ?> />
@@ -1195,47 +1195,47 @@  discard block
 block discarded – undo
1195 1195
  * @param mixed  $deprecated       Deprecated. Not used.
1196 1196
  */
1197 1197
 function xfn_check( $xfn_relationship, $xfn_value = '', $deprecated = '' ) {
1198
-	global $link;
1199
-
1200
-	if ( ! empty( $deprecated ) ) {
1201
-		_deprecated_argument( __FUNCTION__, '2.5.0' ); // Never implemented.
1202
-	}
1203
-
1204
-	$link_rel  = isset( $link->link_rel ) ? $link->link_rel : ''; // In PHP 5.3: $link_rel = $link->link_rel ?: '';
1205
-	$link_rels = preg_split( '/\s+/', $link_rel );
1206
-
1207
-	// Mark the specified value as checked if it matches the current link's relationship.
1208
-	if ( '' !== $xfn_value && in_array( $xfn_value, $link_rels, true ) ) {
1209
-		echo ' checked="checked"';
1210
-	}
1211
-
1212
-	if ( '' === $xfn_value ) {
1213
-		// Mark the 'none' value as checked if the current link does not match the specified relationship.
1214
-		if ( 'family' === $xfn_relationship
1215
-			&& ! array_intersect( $link_rels, array( 'child', 'parent', 'sibling', 'spouse', 'kin' ) )
1216
-		) {
1217
-			echo ' checked="checked"';
1218
-		}
1219
-
1220
-		if ( 'friendship' === $xfn_relationship
1221
-			&& ! array_intersect( $link_rels, array( 'friend', 'acquaintance', 'contact' ) )
1222
-		) {
1223
-			echo ' checked="checked"';
1224
-		}
1225
-
1226
-		if ( 'geographical' === $xfn_relationship
1227
-			&& ! array_intersect( $link_rels, array( 'co-resident', 'neighbor' ) )
1228
-		) {
1229
-			echo ' checked="checked"';
1230
-		}
1231
-
1232
-		// Mark the 'me' value as checked if it matches the current link's relationship.
1233
-		if ( 'identity' === $xfn_relationship
1234
-			&& in_array( 'me', $link_rels, true )
1235
-		) {
1236
-			echo ' checked="checked"';
1237
-		}
1238
-	}
1198
+    global $link;
1199
+
1200
+    if ( ! empty( $deprecated ) ) {
1201
+        _deprecated_argument( __FUNCTION__, '2.5.0' ); // Never implemented.
1202
+    }
1203
+
1204
+    $link_rel  = isset( $link->link_rel ) ? $link->link_rel : ''; // In PHP 5.3: $link_rel = $link->link_rel ?: '';
1205
+    $link_rels = preg_split( '/\s+/', $link_rel );
1206
+
1207
+    // Mark the specified value as checked if it matches the current link's relationship.
1208
+    if ( '' !== $xfn_value && in_array( $xfn_value, $link_rels, true ) ) {
1209
+        echo ' checked="checked"';
1210
+    }
1211
+
1212
+    if ( '' === $xfn_value ) {
1213
+        // Mark the 'none' value as checked if the current link does not match the specified relationship.
1214
+        if ( 'family' === $xfn_relationship
1215
+            && ! array_intersect( $link_rels, array( 'child', 'parent', 'sibling', 'spouse', 'kin' ) )
1216
+        ) {
1217
+            echo ' checked="checked"';
1218
+        }
1219
+
1220
+        if ( 'friendship' === $xfn_relationship
1221
+            && ! array_intersect( $link_rels, array( 'friend', 'acquaintance', 'contact' ) )
1222
+        ) {
1223
+            echo ' checked="checked"';
1224
+        }
1225
+
1226
+        if ( 'geographical' === $xfn_relationship
1227
+            && ! array_intersect( $link_rels, array( 'co-resident', 'neighbor' ) )
1228
+        ) {
1229
+            echo ' checked="checked"';
1230
+        }
1231
+
1232
+        // Mark the 'me' value as checked if it matches the current link's relationship.
1233
+        if ( 'identity' === $xfn_relationship
1234
+            && in_array( 'me', $link_rels, true )
1235
+        ) {
1236
+            echo ' checked="checked"';
1237
+        }
1238
+    }
1239 1239
 }
1240 1240
 
1241 1241
 /**
@@ -1246,7 +1246,7 @@  discard block
 block discarded – undo
1246 1246
  * @param object $link Current link object.
1247 1247
  */
1248 1248
 function link_xfn_meta_box( $link ) {
1249
-	?>
1249
+    ?>
1250 1250
 <table class="links-table">
1251 1251
 	<tr>
1252 1252
 		<th scope="row"><label for="link_rel"><?php /* translators: xfn: https://gmpg.org/xfn/ */ _e( 'rel:' ); ?></label></th>
@@ -1364,7 +1364,7 @@  discard block
 block discarded – undo
1364 1364
  * @param object $link Current link object.
1365 1365
  */
1366 1366
 function link_advanced_meta_box( $link ) {
1367
-	?>
1367
+    ?>
1368 1368
 <table class="links-table" cellpadding="0">
1369 1369
 	<tr>
1370 1370
 		<th scope="row"><label for="link_image"><?php _e( 'Image Address' ); ?></label></th>
@@ -1382,14 +1382,14 @@  discard block
 block discarded – undo
1382 1382
 		<th scope="row"><label for="link_rating"><?php _e( 'Rating' ); ?></label></th>
1383 1383
 		<td><select name="link_rating" id="link_rating" size="1">
1384 1384
 		<?php
1385
-		for ( $rating = 0; $rating <= 10; $rating++ ) {
1386
-			echo '<option value="' . $rating . '"';
1387
-			if ( isset( $link->link_rating ) && $link->link_rating == $rating ) {
1388
-				echo ' selected="selected"';
1389
-			}
1390
-			echo '>' . $rating . '</option>';
1391
-		}
1392
-		?>
1385
+        for ( $rating = 0; $rating <= 10; $rating++ ) {
1386
+            echo '<option value="' . $rating . '"';
1387
+            if ( isset( $link->link_rating ) && $link->link_rating == $rating ) {
1388
+                echo ' selected="selected"';
1389
+            }
1390
+            echo '>' . $rating . '</option>';
1391
+        }
1392
+        ?>
1393 1393
 		</select>&nbsp;<?php _e( '(Leave at 0 for no rating.)' ); ?>
1394 1394
 		</td>
1395 1395
 	</tr>
@@ -1405,8 +1405,8 @@  discard block
 block discarded – undo
1405 1405
  * @param WP_Post $post Current post object.
1406 1406
  */
1407 1407
 function post_thumbnail_meta_box( $post ) {
1408
-	$thumbnail_id = get_post_meta( $post->ID, '_thumbnail_id', true );
1409
-	echo _wp_post_thumbnail_html( $thumbnail_id, $post->ID );
1408
+    $thumbnail_id = get_post_meta( $post->ID, '_thumbnail_id', true );
1409
+    echo _wp_post_thumbnail_html( $thumbnail_id, $post->ID );
1410 1410
 }
1411 1411
 
1412 1412
 /**
@@ -1417,23 +1417,23 @@  discard block
 block discarded – undo
1417 1417
  * @param WP_Post $post Current post object.
1418 1418
  */
1419 1419
 function attachment_id3_data_meta_box( $post ) {
1420
-	$meta = array();
1421
-	if ( ! empty( $post->ID ) ) {
1422
-		$meta = wp_get_attachment_metadata( $post->ID );
1423
-	}
1424
-
1425
-	foreach ( wp_get_attachment_id3_keys( $post, 'edit' ) as $key => $label ) :
1426
-		$value = '';
1427
-		if ( ! empty( $meta[ $key ] ) ) {
1428
-			$value = $meta[ $key ];
1429
-		}
1430
-		?>
1420
+    $meta = array();
1421
+    if ( ! empty( $post->ID ) ) {
1422
+        $meta = wp_get_attachment_metadata( $post->ID );
1423
+    }
1424
+
1425
+    foreach ( wp_get_attachment_id3_keys( $post, 'edit' ) as $key => $label ) :
1426
+        $value = '';
1427
+        if ( ! empty( $meta[ $key ] ) ) {
1428
+            $value = $meta[ $key ];
1429
+        }
1430
+        ?>
1431 1431
 	<p>
1432 1432
 		<label for="title"><?php echo $label; ?></label><br />
1433 1433
 		<input type="text" name="id3_<?php echo esc_attr( $key ); ?>" id="id3_<?php echo esc_attr( $key ); ?>" class="large-text" value="<?php echo esc_attr( $value ); ?>" />
1434 1434
 	</p>
1435 1435
 		<?php
1436
-	endforeach;
1436
+    endforeach;
1437 1437
 }
1438 1438
 
1439 1439
 /**
@@ -1444,193 +1444,193 @@  discard block
 block discarded – undo
1444 1444
  * @param WP_Post $post The post object that these meta boxes are being generated for.
1445 1445
  */
1446 1446
 function register_and_do_post_meta_boxes( $post ) {
1447
-	$post_type        = $post->post_type;
1448
-	$post_type_object = get_post_type_object( $post_type );
1449
-
1450
-	$thumbnail_support = current_theme_supports( 'post-thumbnails', $post_type ) && post_type_supports( $post_type, 'thumbnail' );
1451
-	if ( ! $thumbnail_support && 'attachment' === $post_type && $post->post_mime_type ) {
1452
-		if ( wp_attachment_is( 'audio', $post ) ) {
1453
-			$thumbnail_support = post_type_supports( 'attachment:audio', 'thumbnail' ) || current_theme_supports( 'post-thumbnails', 'attachment:audio' );
1454
-		} elseif ( wp_attachment_is( 'video', $post ) ) {
1455
-			$thumbnail_support = post_type_supports( 'attachment:video', 'thumbnail' ) || current_theme_supports( 'post-thumbnails', 'attachment:video' );
1456
-		}
1457
-	}
1458
-
1459
-	$publish_callback_args = array( '__back_compat_meta_box' => true );
1460
-
1461
-	if ( post_type_supports( $post_type, 'revisions' ) && 'auto-draft' !== $post->post_status ) {
1462
-		$revisions = wp_get_post_revisions( $post->ID, array( 'fields' => 'ids' ) );
1463
-
1464
-		// We should aim to show the revisions meta box only when there are revisions.
1465
-		if ( count( $revisions ) > 1 ) {
1466
-			$publish_callback_args = array(
1467
-				'revisions_count'        => count( $revisions ),
1468
-				'revision_id'            => reset( $revisions ),
1469
-				'__back_compat_meta_box' => true,
1470
-			);
1471
-
1472
-			add_meta_box( 'revisionsdiv', __( 'Revisions' ), 'post_revisions_meta_box', null, 'normal', 'core', array( '__back_compat_meta_box' => true ) );
1473
-		}
1474
-	}
1475
-
1476
-	if ( 'attachment' === $post_type ) {
1477
-		wp_enqueue_script( 'image-edit' );
1478
-		wp_enqueue_style( 'imgareaselect' );
1479
-		add_meta_box( 'submitdiv', __( 'Save' ), 'attachment_submit_meta_box', null, 'side', 'core', array( '__back_compat_meta_box' => true ) );
1480
-		add_action( 'edit_form_after_title', 'edit_form_image_editor' );
1481
-
1482
-		if ( wp_attachment_is( 'audio', $post ) ) {
1483
-			add_meta_box( 'attachment-id3', __( 'Metadata' ), 'attachment_id3_data_meta_box', null, 'normal', 'core', array( '__back_compat_meta_box' => true ) );
1484
-		}
1485
-	} else {
1486
-		add_meta_box( 'submitdiv', __( 'Publish' ), 'post_submit_meta_box', null, 'side', 'core', $publish_callback_args );
1487
-	}
1488
-
1489
-	if ( current_theme_supports( 'post-formats' ) && post_type_supports( $post_type, 'post-formats' ) ) {
1490
-		add_meta_box( 'formatdiv', _x( 'Format', 'post format' ), 'post_format_meta_box', null, 'side', 'core', array( '__back_compat_meta_box' => true ) );
1491
-	}
1492
-
1493
-	// All taxonomies.
1494
-	foreach ( get_object_taxonomies( $post ) as $tax_name ) {
1495
-		$taxonomy = get_taxonomy( $tax_name );
1496
-		if ( ! $taxonomy->show_ui || false === $taxonomy->meta_box_cb ) {
1497
-			continue;
1498
-		}
1499
-
1500
-		$label = $taxonomy->labels->name;
1501
-
1502
-		if ( ! is_taxonomy_hierarchical( $tax_name ) ) {
1503
-			$tax_meta_box_id = 'tagsdiv-' . $tax_name;
1504
-		} else {
1505
-			$tax_meta_box_id = $tax_name . 'div';
1506
-		}
1507
-
1508
-		add_meta_box(
1509
-			$tax_meta_box_id,
1510
-			$label,
1511
-			$taxonomy->meta_box_cb,
1512
-			null,
1513
-			'side',
1514
-			'core',
1515
-			array(
1516
-				'taxonomy'               => $tax_name,
1517
-				'__back_compat_meta_box' => true,
1518
-			)
1519
-		);
1520
-	}
1521
-
1522
-	if ( post_type_supports( $post_type, 'page-attributes' ) || count( get_page_templates( $post ) ) > 0 ) {
1523
-		add_meta_box( 'pageparentdiv', $post_type_object->labels->attributes, 'page_attributes_meta_box', null, 'side', 'core', array( '__back_compat_meta_box' => true ) );
1524
-	}
1525
-
1526
-	if ( $thumbnail_support && current_user_can( 'upload_files' ) ) {
1527
-		add_meta_box( 'postimagediv', esc_html( $post_type_object->labels->featured_image ), 'post_thumbnail_meta_box', null, 'side', 'low', array( '__back_compat_meta_box' => true ) );
1528
-	}
1529
-
1530
-	if ( post_type_supports( $post_type, 'excerpt' ) ) {
1531
-		add_meta_box( 'postexcerpt', __( 'Excerpt' ), 'post_excerpt_meta_box', null, 'normal', 'core', array( '__back_compat_meta_box' => true ) );
1532
-	}
1533
-
1534
-	if ( post_type_supports( $post_type, 'trackbacks' ) ) {
1535
-		add_meta_box( 'trackbacksdiv', __( 'Send Trackbacks' ), 'post_trackback_meta_box', null, 'normal', 'core', array( '__back_compat_meta_box' => true ) );
1536
-	}
1537
-
1538
-	if ( post_type_supports( $post_type, 'custom-fields' ) ) {
1539
-		add_meta_box(
1540
-			'postcustom',
1541
-			__( 'Custom Fields' ),
1542
-			'post_custom_meta_box',
1543
-			null,
1544
-			'normal',
1545
-			'core',
1546
-			array(
1547
-				'__back_compat_meta_box'             => ! (bool) get_user_meta( get_current_user_id(), 'enable_custom_fields', true ),
1548
-				'__block_editor_compatible_meta_box' => true,
1549
-			)
1550
-		);
1551
-	}
1552
-
1553
-	/**
1554
-	 * Fires in the middle of built-in meta box registration.
1555
-	 *
1556
-	 * @since 2.1.0
1557
-	 * @deprecated 3.7.0 Use {@see 'add_meta_boxes'} instead.
1558
-	 *
1559
-	 * @param WP_Post $post Post object.
1560
-	 */
1561
-	do_action_deprecated( 'dbx_post_advanced', array( $post ), '3.7.0', 'add_meta_boxes' );
1562
-
1563
-	// Allow the Discussion meta box to show up if the post type supports comments,
1564
-	// or if comments or pings are open.
1565
-	if ( comments_open( $post ) || pings_open( $post ) || post_type_supports( $post_type, 'comments' ) ) {
1566
-		add_meta_box( 'commentstatusdiv', __( 'Discussion' ), 'post_comment_status_meta_box', null, 'normal', 'core', array( '__back_compat_meta_box' => true ) );
1567
-	}
1568
-
1569
-	$stati = get_post_stati( array( 'public' => true ) );
1570
-	if ( empty( $stati ) ) {
1571
-		$stati = array( 'publish' );
1572
-	}
1573
-	$stati[] = 'private';
1574
-
1575
-	if ( in_array( get_post_status( $post ), $stati, true ) ) {
1576
-		// If the post type support comments, or the post has comments,
1577
-		// allow the Comments meta box.
1578
-		if ( comments_open( $post ) || pings_open( $post ) || $post->comment_count > 0 || post_type_supports( $post_type, 'comments' ) ) {
1579
-			add_meta_box( 'commentsdiv', __( 'Comments' ), 'post_comment_meta_box', null, 'normal', 'core', array( '__back_compat_meta_box' => true ) );
1580
-		}
1581
-	}
1582
-
1583
-	if ( ! ( 'pending' === get_post_status( $post ) && ! current_user_can( $post_type_object->cap->publish_posts ) ) ) {
1584
-		add_meta_box( 'slugdiv', __( 'Slug' ), 'post_slug_meta_box', null, 'normal', 'core', array( '__back_compat_meta_box' => true ) );
1585
-	}
1586
-
1587
-	if ( post_type_supports( $post_type, 'author' ) && current_user_can( $post_type_object->cap->edit_others_posts ) ) {
1588
-		add_meta_box( 'authordiv', __( 'Author' ), 'post_author_meta_box', null, 'normal', 'core', array( '__back_compat_meta_box' => true ) );
1589
-	}
1590
-
1591
-	/**
1592
-	 * Fires after all built-in meta boxes have been added.
1593
-	 *
1594
-	 * @since 3.0.0
1595
-	 *
1596
-	 * @param string  $post_type Post type.
1597
-	 * @param WP_Post $post      Post object.
1598
-	 */
1599
-	do_action( 'add_meta_boxes', $post_type, $post );
1600
-
1601
-	/**
1602
-	 * Fires after all built-in meta boxes have been added, contextually for the given post type.
1603
-	 *
1604
-	 * The dynamic portion of the hook name, `$post_type`, refers to the post type of the post.
1605
-	 *
1606
-	 * Possible hook names include:
1607
-	 *
1608
-	 *  - `add_meta_boxes_post`
1609
-	 *  - `add_meta_boxes_page`
1610
-	 *  - `add_meta_boxes_attachment`
1611
-	 *
1612
-	 * @since 3.0.0
1613
-	 *
1614
-	 * @param WP_Post $post Post object.
1615
-	 */
1616
-	do_action( "add_meta_boxes_{$post_type}", $post );
1617
-
1618
-	/**
1619
-	 * Fires after meta boxes have been added.
1620
-	 *
1621
-	 * Fires once for each of the default meta box contexts: normal, advanced, and side.
1622
-	 *
1623
-	 * @since 3.0.0
1624
-	 *
1625
-	 * @param string                $post_type Post type of the post on Edit Post screen, 'link' on Edit Link screen,
1626
-	 *                                         'dashboard' on Dashboard screen.
1627
-	 * @param string                $context   Meta box context. Possible values include 'normal', 'advanced', 'side'.
1628
-	 * @param WP_Post|object|string $post      Post object on Edit Post screen, link object on Edit Link screen,
1629
-	 *                                         an empty string on Dashboard screen.
1630
-	 */
1631
-	do_action( 'do_meta_boxes', $post_type, 'normal', $post );
1632
-	/** This action is documented in wp-admin/includes/meta-boxes.php */
1633
-	do_action( 'do_meta_boxes', $post_type, 'advanced', $post );
1634
-	/** This action is documented in wp-admin/includes/meta-boxes.php */
1635
-	do_action( 'do_meta_boxes', $post_type, 'side', $post );
1447
+    $post_type        = $post->post_type;
1448
+    $post_type_object = get_post_type_object( $post_type );
1449
+
1450
+    $thumbnail_support = current_theme_supports( 'post-thumbnails', $post_type ) && post_type_supports( $post_type, 'thumbnail' );
1451
+    if ( ! $thumbnail_support && 'attachment' === $post_type && $post->post_mime_type ) {
1452
+        if ( wp_attachment_is( 'audio', $post ) ) {
1453
+            $thumbnail_support = post_type_supports( 'attachment:audio', 'thumbnail' ) || current_theme_supports( 'post-thumbnails', 'attachment:audio' );
1454
+        } elseif ( wp_attachment_is( 'video', $post ) ) {
1455
+            $thumbnail_support = post_type_supports( 'attachment:video', 'thumbnail' ) || current_theme_supports( 'post-thumbnails', 'attachment:video' );
1456
+        }
1457
+    }
1458
+
1459
+    $publish_callback_args = array( '__back_compat_meta_box' => true );
1460
+
1461
+    if ( post_type_supports( $post_type, 'revisions' ) && 'auto-draft' !== $post->post_status ) {
1462
+        $revisions = wp_get_post_revisions( $post->ID, array( 'fields' => 'ids' ) );
1463
+
1464
+        // We should aim to show the revisions meta box only when there are revisions.
1465
+        if ( count( $revisions ) > 1 ) {
1466
+            $publish_callback_args = array(
1467
+                'revisions_count'        => count( $revisions ),
1468
+                'revision_id'            => reset( $revisions ),
1469
+                '__back_compat_meta_box' => true,
1470
+            );
1471
+
1472
+            add_meta_box( 'revisionsdiv', __( 'Revisions' ), 'post_revisions_meta_box', null, 'normal', 'core', array( '__back_compat_meta_box' => true ) );
1473
+        }
1474
+    }
1475
+
1476
+    if ( 'attachment' === $post_type ) {
1477
+        wp_enqueue_script( 'image-edit' );
1478
+        wp_enqueue_style( 'imgareaselect' );
1479
+        add_meta_box( 'submitdiv', __( 'Save' ), 'attachment_submit_meta_box', null, 'side', 'core', array( '__back_compat_meta_box' => true ) );
1480
+        add_action( 'edit_form_after_title', 'edit_form_image_editor' );
1481
+
1482
+        if ( wp_attachment_is( 'audio', $post ) ) {
1483
+            add_meta_box( 'attachment-id3', __( 'Metadata' ), 'attachment_id3_data_meta_box', null, 'normal', 'core', array( '__back_compat_meta_box' => true ) );
1484
+        }
1485
+    } else {
1486
+        add_meta_box( 'submitdiv', __( 'Publish' ), 'post_submit_meta_box', null, 'side', 'core', $publish_callback_args );
1487
+    }
1488
+
1489
+    if ( current_theme_supports( 'post-formats' ) && post_type_supports( $post_type, 'post-formats' ) ) {
1490
+        add_meta_box( 'formatdiv', _x( 'Format', 'post format' ), 'post_format_meta_box', null, 'side', 'core', array( '__back_compat_meta_box' => true ) );
1491
+    }
1492
+
1493
+    // All taxonomies.
1494
+    foreach ( get_object_taxonomies( $post ) as $tax_name ) {
1495
+        $taxonomy = get_taxonomy( $tax_name );
1496
+        if ( ! $taxonomy->show_ui || false === $taxonomy->meta_box_cb ) {
1497
+            continue;
1498
+        }
1499
+
1500
+        $label = $taxonomy->labels->name;
1501
+
1502
+        if ( ! is_taxonomy_hierarchical( $tax_name ) ) {
1503
+            $tax_meta_box_id = 'tagsdiv-' . $tax_name;
1504
+        } else {
1505
+            $tax_meta_box_id = $tax_name . 'div';
1506
+        }
1507
+
1508
+        add_meta_box(
1509
+            $tax_meta_box_id,
1510
+            $label,
1511
+            $taxonomy->meta_box_cb,
1512
+            null,
1513
+            'side',
1514
+            'core',
1515
+            array(
1516
+                'taxonomy'               => $tax_name,
1517
+                '__back_compat_meta_box' => true,
1518
+            )
1519
+        );
1520
+    }
1521
+
1522
+    if ( post_type_supports( $post_type, 'page-attributes' ) || count( get_page_templates( $post ) ) > 0 ) {
1523
+        add_meta_box( 'pageparentdiv', $post_type_object->labels->attributes, 'page_attributes_meta_box', null, 'side', 'core', array( '__back_compat_meta_box' => true ) );
1524
+    }
1525
+
1526
+    if ( $thumbnail_support && current_user_can( 'upload_files' ) ) {
1527
+        add_meta_box( 'postimagediv', esc_html( $post_type_object->labels->featured_image ), 'post_thumbnail_meta_box', null, 'side', 'low', array( '__back_compat_meta_box' => true ) );
1528
+    }
1529
+
1530
+    if ( post_type_supports( $post_type, 'excerpt' ) ) {
1531
+        add_meta_box( 'postexcerpt', __( 'Excerpt' ), 'post_excerpt_meta_box', null, 'normal', 'core', array( '__back_compat_meta_box' => true ) );
1532
+    }
1533
+
1534
+    if ( post_type_supports( $post_type, 'trackbacks' ) ) {
1535
+        add_meta_box( 'trackbacksdiv', __( 'Send Trackbacks' ), 'post_trackback_meta_box', null, 'normal', 'core', array( '__back_compat_meta_box' => true ) );
1536
+    }
1537
+
1538
+    if ( post_type_supports( $post_type, 'custom-fields' ) ) {
1539
+        add_meta_box(
1540
+            'postcustom',
1541
+            __( 'Custom Fields' ),
1542
+            'post_custom_meta_box',
1543
+            null,
1544
+            'normal',
1545
+            'core',
1546
+            array(
1547
+                '__back_compat_meta_box'             => ! (bool) get_user_meta( get_current_user_id(), 'enable_custom_fields', true ),
1548
+                '__block_editor_compatible_meta_box' => true,
1549
+            )
1550
+        );
1551
+    }
1552
+
1553
+    /**
1554
+     * Fires in the middle of built-in meta box registration.
1555
+     *
1556
+     * @since 2.1.0
1557
+     * @deprecated 3.7.0 Use {@see 'add_meta_boxes'} instead.
1558
+     *
1559
+     * @param WP_Post $post Post object.
1560
+     */
1561
+    do_action_deprecated( 'dbx_post_advanced', array( $post ), '3.7.0', 'add_meta_boxes' );
1562
+
1563
+    // Allow the Discussion meta box to show up if the post type supports comments,
1564
+    // or if comments or pings are open.
1565
+    if ( comments_open( $post ) || pings_open( $post ) || post_type_supports( $post_type, 'comments' ) ) {
1566
+        add_meta_box( 'commentstatusdiv', __( 'Discussion' ), 'post_comment_status_meta_box', null, 'normal', 'core', array( '__back_compat_meta_box' => true ) );
1567
+    }
1568
+
1569
+    $stati = get_post_stati( array( 'public' => true ) );
1570
+    if ( empty( $stati ) ) {
1571
+        $stati = array( 'publish' );
1572
+    }
1573
+    $stati[] = 'private';
1574
+
1575
+    if ( in_array( get_post_status( $post ), $stati, true ) ) {
1576
+        // If the post type support comments, or the post has comments,
1577
+        // allow the Comments meta box.
1578
+        if ( comments_open( $post ) || pings_open( $post ) || $post->comment_count > 0 || post_type_supports( $post_type, 'comments' ) ) {
1579
+            add_meta_box( 'commentsdiv', __( 'Comments' ), 'post_comment_meta_box', null, 'normal', 'core', array( '__back_compat_meta_box' => true ) );
1580
+        }
1581
+    }
1582
+
1583
+    if ( ! ( 'pending' === get_post_status( $post ) && ! current_user_can( $post_type_object->cap->publish_posts ) ) ) {
1584
+        add_meta_box( 'slugdiv', __( 'Slug' ), 'post_slug_meta_box', null, 'normal', 'core', array( '__back_compat_meta_box' => true ) );
1585
+    }
1586
+
1587
+    if ( post_type_supports( $post_type, 'author' ) && current_user_can( $post_type_object->cap->edit_others_posts ) ) {
1588
+        add_meta_box( 'authordiv', __( 'Author' ), 'post_author_meta_box', null, 'normal', 'core', array( '__back_compat_meta_box' => true ) );
1589
+    }
1590
+
1591
+    /**
1592
+     * Fires after all built-in meta boxes have been added.
1593
+     *
1594
+     * @since 3.0.0
1595
+     *
1596
+     * @param string  $post_type Post type.
1597
+     * @param WP_Post $post      Post object.
1598
+     */
1599
+    do_action( 'add_meta_boxes', $post_type, $post );
1600
+
1601
+    /**
1602
+     * Fires after all built-in meta boxes have been added, contextually for the given post type.
1603
+     *
1604
+     * The dynamic portion of the hook name, `$post_type`, refers to the post type of the post.
1605
+     *
1606
+     * Possible hook names include:
1607
+     *
1608
+     *  - `add_meta_boxes_post`
1609
+     *  - `add_meta_boxes_page`
1610
+     *  - `add_meta_boxes_attachment`
1611
+     *
1612
+     * @since 3.0.0
1613
+     *
1614
+     * @param WP_Post $post Post object.
1615
+     */
1616
+    do_action( "add_meta_boxes_{$post_type}", $post );
1617
+
1618
+    /**
1619
+     * Fires after meta boxes have been added.
1620
+     *
1621
+     * Fires once for each of the default meta box contexts: normal, advanced, and side.
1622
+     *
1623
+     * @since 3.0.0
1624
+     *
1625
+     * @param string                $post_type Post type of the post on Edit Post screen, 'link' on Edit Link screen,
1626
+     *                                         'dashboard' on Dashboard screen.
1627
+     * @param string                $context   Meta box context. Possible values include 'normal', 'advanced', 'side'.
1628
+     * @param WP_Post|object|string $post      Post object on Edit Post screen, link object on Edit Link screen,
1629
+     *                                         an empty string on Dashboard screen.
1630
+     */
1631
+    do_action( 'do_meta_boxes', $post_type, 'normal', $post );
1632
+    /** This action is documented in wp-admin/includes/meta-boxes.php */
1633
+    do_action( 'do_meta_boxes', $post_type, 'advanced', $post );
1634
+    /** This action is documented in wp-admin/includes/meta-boxes.php */
1635
+    do_action( 'do_meta_boxes', $post_type, 'side', $post );
1636 1636
 }
Please login to merge, or discard this patch.
brighty/wp-admin/includes/bookmark.php 1 patch
Indentation   +232 added lines, -232 removed lines patch added patch discarded remove patch
@@ -14,7 +14,7 @@  discard block
 block discarded – undo
14 14
  * @return int|WP_Error Value 0 or WP_Error on failure. The link ID on success.
15 15
  */
16 16
 function add_link() {
17
-	return edit_link();
17
+    return edit_link();
18 18
 }
19 19
 
20 20
 /**
@@ -26,29 +26,29 @@  discard block
 block discarded – undo
26 26
  * @return int|WP_Error Value 0 or WP_Error on failure. The link ID on success.
27 27
  */
28 28
 function edit_link( $link_id = 0 ) {
29
-	if ( ! current_user_can( 'manage_links' ) ) {
30
-		wp_die(
31
-			'<h1>' . __( 'You need a higher level of permission.' ) . '</h1>' .
32
-			'<p>' . __( 'Sorry, you are not allowed to edit the links for this site.' ) . '</p>',
33
-			403
34
-		);
35
-	}
36
-
37
-	$_POST['link_url']   = esc_html( $_POST['link_url'] );
38
-	$_POST['link_url']   = esc_url( $_POST['link_url'] );
39
-	$_POST['link_name']  = esc_html( $_POST['link_name'] );
40
-	$_POST['link_image'] = esc_html( $_POST['link_image'] );
41
-	$_POST['link_rss']   = esc_url( $_POST['link_rss'] );
42
-	if ( ! isset( $_POST['link_visible'] ) || 'N' !== $_POST['link_visible'] ) {
43
-		$_POST['link_visible'] = 'Y';
44
-	}
45
-
46
-	if ( ! empty( $link_id ) ) {
47
-		$_POST['link_id'] = $link_id;
48
-		return wp_update_link( $_POST );
49
-	} else {
50
-		return wp_insert_link( $_POST );
51
-	}
29
+    if ( ! current_user_can( 'manage_links' ) ) {
30
+        wp_die(
31
+            '<h1>' . __( 'You need a higher level of permission.' ) . '</h1>' .
32
+            '<p>' . __( 'Sorry, you are not allowed to edit the links for this site.' ) . '</p>',
33
+            403
34
+        );
35
+    }
36
+
37
+    $_POST['link_url']   = esc_html( $_POST['link_url'] );
38
+    $_POST['link_url']   = esc_url( $_POST['link_url'] );
39
+    $_POST['link_name']  = esc_html( $_POST['link_name'] );
40
+    $_POST['link_image'] = esc_html( $_POST['link_image'] );
41
+    $_POST['link_rss']   = esc_url( $_POST['link_rss'] );
42
+    if ( ! isset( $_POST['link_visible'] ) || 'N' !== $_POST['link_visible'] ) {
43
+        $_POST['link_visible'] = 'Y';
44
+    }
45
+
46
+    if ( ! empty( $link_id ) ) {
47
+        $_POST['link_id'] = $link_id;
48
+        return wp_update_link( $_POST );
49
+    } else {
50
+        return wp_insert_link( $_POST );
51
+    }
52 52
 }
53 53
 
54 54
 /**
@@ -59,22 +59,22 @@  discard block
 block discarded – undo
59 59
  * @return stdClass Default link object.
60 60
  */
61 61
 function get_default_link_to_edit() {
62
-	$link = new stdClass;
63
-	if ( isset( $_GET['linkurl'] ) ) {
64
-		$link->link_url = esc_url( wp_unslash( $_GET['linkurl'] ) );
65
-	} else {
66
-		$link->link_url = '';
67
-	}
68
-
69
-	if ( isset( $_GET['name'] ) ) {
70
-		$link->link_name = esc_attr( wp_unslash( $_GET['name'] ) );
71
-	} else {
72
-		$link->link_name = '';
73
-	}
74
-
75
-	$link->link_visible = 'Y';
76
-
77
-	return $link;
62
+    $link = new stdClass;
63
+    if ( isset( $_GET['linkurl'] ) ) {
64
+        $link->link_url = esc_url( wp_unslash( $_GET['linkurl'] ) );
65
+    } else {
66
+        $link->link_url = '';
67
+    }
68
+
69
+    if ( isset( $_GET['name'] ) ) {
70
+        $link->link_name = esc_attr( wp_unslash( $_GET['name'] ) );
71
+    } else {
72
+        $link->link_name = '';
73
+    }
74
+
75
+    $link->link_visible = 'Y';
76
+
77
+    return $link;
78 78
 }
79 79
 
80 80
 /**
@@ -88,32 +88,32 @@  discard block
 block discarded – undo
88 88
  * @return true Always true.
89 89
  */
90 90
 function wp_delete_link( $link_id ) {
91
-	global $wpdb;
92
-	/**
93
-	 * Fires before a link is deleted.
94
-	 *
95
-	 * @since 2.0.0
96
-	 *
97
-	 * @param int $link_id ID of the link to delete.
98
-	 */
99
-	do_action( 'delete_link', $link_id );
100
-
101
-	wp_delete_object_term_relationships( $link_id, 'link_category' );
102
-
103
-	$wpdb->delete( $wpdb->links, array( 'link_id' => $link_id ) );
104
-
105
-	/**
106
-	 * Fires after a link has been deleted.
107
-	 *
108
-	 * @since 2.2.0
109
-	 *
110
-	 * @param int $link_id ID of the deleted link.
111
-	 */
112
-	do_action( 'deleted_link', $link_id );
113
-
114
-	clean_bookmark_cache( $link_id );
115
-
116
-	return true;
91
+    global $wpdb;
92
+    /**
93
+     * Fires before a link is deleted.
94
+     *
95
+     * @since 2.0.0
96
+     *
97
+     * @param int $link_id ID of the link to delete.
98
+     */
99
+    do_action( 'delete_link', $link_id );
100
+
101
+    wp_delete_object_term_relationships( $link_id, 'link_category' );
102
+
103
+    $wpdb->delete( $wpdb->links, array( 'link_id' => $link_id ) );
104
+
105
+    /**
106
+     * Fires after a link has been deleted.
107
+     *
108
+     * @since 2.2.0
109
+     *
110
+     * @param int $link_id ID of the deleted link.
111
+     */
112
+    do_action( 'deleted_link', $link_id );
113
+
114
+    clean_bookmark_cache( $link_id );
115
+
116
+    return true;
117 117
 }
118 118
 
119 119
 /**
@@ -125,8 +125,8 @@  discard block
 block discarded – undo
125 125
  * @return int[] The IDs of the requested link's categories.
126 126
  */
127 127
 function wp_get_link_cats( $link_id = 0 ) {
128
-	$cats = wp_get_object_terms( $link_id, 'link_category', array( 'fields' => 'ids' ) );
129
-	return array_unique( $cats );
128
+    $cats = wp_get_object_terms( $link_id, 'link_category', array( 'fields' => 'ids' ) );
129
+    return array_unique( $cats );
130 130
 }
131 131
 
132 132
 /**
@@ -138,7 +138,7 @@  discard block
 block discarded – undo
138 138
  * @return object Link object for editing.
139 139
  */
140 140
 function get_link_to_edit( $link ) {
141
-	return get_bookmark( $link, OBJECT, 'edit' );
141
+    return get_bookmark( $link, OBJECT, 'edit' );
142 142
 }
143 143
 
144 144
 /**
@@ -173,98 +173,98 @@  discard block
 block discarded – undo
173 173
  * @return int|WP_Error Value 0 or WP_Error on failure. The link ID on success.
174 174
  */
175 175
 function wp_insert_link( $linkdata, $wp_error = false ) {
176
-	global $wpdb;
177
-
178
-	$defaults = array(
179
-		'link_id'     => 0,
180
-		'link_name'   => '',
181
-		'link_url'    => '',
182
-		'link_rating' => 0,
183
-	);
184
-
185
-	$parsed_args = wp_parse_args( $linkdata, $defaults );
186
-	$parsed_args = wp_unslash( sanitize_bookmark( $parsed_args, 'db' ) );
187
-
188
-	$link_id   = $parsed_args['link_id'];
189
-	$link_name = $parsed_args['link_name'];
190
-	$link_url  = $parsed_args['link_url'];
191
-
192
-	$update = false;
193
-	if ( ! empty( $link_id ) ) {
194
-		$update = true;
195
-	}
196
-
197
-	if ( '' === trim( $link_name ) ) {
198
-		if ( '' !== trim( $link_url ) ) {
199
-			$link_name = $link_url;
200
-		} else {
201
-			return 0;
202
-		}
203
-	}
204
-
205
-	if ( '' === trim( $link_url ) ) {
206
-		return 0;
207
-	}
208
-
209
-	$link_rating      = ( ! empty( $parsed_args['link_rating'] ) ) ? $parsed_args['link_rating'] : 0;
210
-	$link_image       = ( ! empty( $parsed_args['link_image'] ) ) ? $parsed_args['link_image'] : '';
211
-	$link_target      = ( ! empty( $parsed_args['link_target'] ) ) ? $parsed_args['link_target'] : '';
212
-	$link_visible     = ( ! empty( $parsed_args['link_visible'] ) ) ? $parsed_args['link_visible'] : 'Y';
213
-	$link_owner       = ( ! empty( $parsed_args['link_owner'] ) ) ? $parsed_args['link_owner'] : get_current_user_id();
214
-	$link_notes       = ( ! empty( $parsed_args['link_notes'] ) ) ? $parsed_args['link_notes'] : '';
215
-	$link_description = ( ! empty( $parsed_args['link_description'] ) ) ? $parsed_args['link_description'] : '';
216
-	$link_rss         = ( ! empty( $parsed_args['link_rss'] ) ) ? $parsed_args['link_rss'] : '';
217
-	$link_rel         = ( ! empty( $parsed_args['link_rel'] ) ) ? $parsed_args['link_rel'] : '';
218
-	$link_category    = ( ! empty( $parsed_args['link_category'] ) ) ? $parsed_args['link_category'] : array();
219
-
220
-	// Make sure we set a valid category.
221
-	if ( ! is_array( $link_category ) || 0 === count( $link_category ) ) {
222
-		$link_category = array( get_option( 'default_link_category' ) );
223
-	}
224
-
225
-	if ( $update ) {
226
-		if ( false === $wpdb->update( $wpdb->links, compact( 'link_url', 'link_name', 'link_image', 'link_target', 'link_description', 'link_visible', 'link_owner', 'link_rating', 'link_rel', 'link_notes', 'link_rss' ), compact( 'link_id' ) ) ) {
227
-			if ( $wp_error ) {
228
-				return new WP_Error( 'db_update_error', __( 'Could not update link in the database.' ), $wpdb->last_error );
229
-			} else {
230
-				return 0;
231
-			}
232
-		}
233
-	} else {
234
-		if ( false === $wpdb->insert( $wpdb->links, compact( 'link_url', 'link_name', 'link_image', 'link_target', 'link_description', 'link_visible', 'link_owner', 'link_rating', 'link_rel', 'link_notes', 'link_rss' ) ) ) {
235
-			if ( $wp_error ) {
236
-				return new WP_Error( 'db_insert_error', __( 'Could not insert link into the database.' ), $wpdb->last_error );
237
-			} else {
238
-				return 0;
239
-			}
240
-		}
241
-		$link_id = (int) $wpdb->insert_id;
242
-	}
243
-
244
-	wp_set_link_cats( $link_id, $link_category );
245
-
246
-	if ( $update ) {
247
-		/**
248
-		 * Fires after a link was updated in the database.
249
-		 *
250
-		 * @since 2.0.0
251
-		 *
252
-		 * @param int $link_id ID of the link that was updated.
253
-		 */
254
-		do_action( 'edit_link', $link_id );
255
-	} else {
256
-		/**
257
-		 * Fires after a link was added to the database.
258
-		 *
259
-		 * @since 2.0.0
260
-		 *
261
-		 * @param int $link_id ID of the link that was added.
262
-		 */
263
-		do_action( 'add_link', $link_id );
264
-	}
265
-	clean_bookmark_cache( $link_id );
266
-
267
-	return $link_id;
176
+    global $wpdb;
177
+
178
+    $defaults = array(
179
+        'link_id'     => 0,
180
+        'link_name'   => '',
181
+        'link_url'    => '',
182
+        'link_rating' => 0,
183
+    );
184
+
185
+    $parsed_args = wp_parse_args( $linkdata, $defaults );
186
+    $parsed_args = wp_unslash( sanitize_bookmark( $parsed_args, 'db' ) );
187
+
188
+    $link_id   = $parsed_args['link_id'];
189
+    $link_name = $parsed_args['link_name'];
190
+    $link_url  = $parsed_args['link_url'];
191
+
192
+    $update = false;
193
+    if ( ! empty( $link_id ) ) {
194
+        $update = true;
195
+    }
196
+
197
+    if ( '' === trim( $link_name ) ) {
198
+        if ( '' !== trim( $link_url ) ) {
199
+            $link_name = $link_url;
200
+        } else {
201
+            return 0;
202
+        }
203
+    }
204
+
205
+    if ( '' === trim( $link_url ) ) {
206
+        return 0;
207
+    }
208
+
209
+    $link_rating      = ( ! empty( $parsed_args['link_rating'] ) ) ? $parsed_args['link_rating'] : 0;
210
+    $link_image       = ( ! empty( $parsed_args['link_image'] ) ) ? $parsed_args['link_image'] : '';
211
+    $link_target      = ( ! empty( $parsed_args['link_target'] ) ) ? $parsed_args['link_target'] : '';
212
+    $link_visible     = ( ! empty( $parsed_args['link_visible'] ) ) ? $parsed_args['link_visible'] : 'Y';
213
+    $link_owner       = ( ! empty( $parsed_args['link_owner'] ) ) ? $parsed_args['link_owner'] : get_current_user_id();
214
+    $link_notes       = ( ! empty( $parsed_args['link_notes'] ) ) ? $parsed_args['link_notes'] : '';
215
+    $link_description = ( ! empty( $parsed_args['link_description'] ) ) ? $parsed_args['link_description'] : '';
216
+    $link_rss         = ( ! empty( $parsed_args['link_rss'] ) ) ? $parsed_args['link_rss'] : '';
217
+    $link_rel         = ( ! empty( $parsed_args['link_rel'] ) ) ? $parsed_args['link_rel'] : '';
218
+    $link_category    = ( ! empty( $parsed_args['link_category'] ) ) ? $parsed_args['link_category'] : array();
219
+
220
+    // Make sure we set a valid category.
221
+    if ( ! is_array( $link_category ) || 0 === count( $link_category ) ) {
222
+        $link_category = array( get_option( 'default_link_category' ) );
223
+    }
224
+
225
+    if ( $update ) {
226
+        if ( false === $wpdb->update( $wpdb->links, compact( 'link_url', 'link_name', 'link_image', 'link_target', 'link_description', 'link_visible', 'link_owner', 'link_rating', 'link_rel', 'link_notes', 'link_rss' ), compact( 'link_id' ) ) ) {
227
+            if ( $wp_error ) {
228
+                return new WP_Error( 'db_update_error', __( 'Could not update link in the database.' ), $wpdb->last_error );
229
+            } else {
230
+                return 0;
231
+            }
232
+        }
233
+    } else {
234
+        if ( false === $wpdb->insert( $wpdb->links, compact( 'link_url', 'link_name', 'link_image', 'link_target', 'link_description', 'link_visible', 'link_owner', 'link_rating', 'link_rel', 'link_notes', 'link_rss' ) ) ) {
235
+            if ( $wp_error ) {
236
+                return new WP_Error( 'db_insert_error', __( 'Could not insert link into the database.' ), $wpdb->last_error );
237
+            } else {
238
+                return 0;
239
+            }
240
+        }
241
+        $link_id = (int) $wpdb->insert_id;
242
+    }
243
+
244
+    wp_set_link_cats( $link_id, $link_category );
245
+
246
+    if ( $update ) {
247
+        /**
248
+         * Fires after a link was updated in the database.
249
+         *
250
+         * @since 2.0.0
251
+         *
252
+         * @param int $link_id ID of the link that was updated.
253
+         */
254
+        do_action( 'edit_link', $link_id );
255
+    } else {
256
+        /**
257
+         * Fires after a link was added to the database.
258
+         *
259
+         * @since 2.0.0
260
+         *
261
+         * @param int $link_id ID of the link that was added.
262
+         */
263
+        do_action( 'add_link', $link_id );
264
+    }
265
+    clean_bookmark_cache( $link_id );
266
+
267
+    return $link_id;
268 268
 }
269 269
 
270 270
 /**
@@ -276,17 +276,17 @@  discard block
 block discarded – undo
276 276
  * @param int[] $link_categories Array of link category IDs to add the link to.
277 277
  */
278 278
 function wp_set_link_cats( $link_id = 0, $link_categories = array() ) {
279
-	// If $link_categories isn't already an array, make it one:
280
-	if ( ! is_array( $link_categories ) || 0 === count( $link_categories ) ) {
281
-		$link_categories = array( get_option( 'default_link_category' ) );
282
-	}
279
+    // If $link_categories isn't already an array, make it one:
280
+    if ( ! is_array( $link_categories ) || 0 === count( $link_categories ) ) {
281
+        $link_categories = array( get_option( 'default_link_category' ) );
282
+    }
283 283
 
284
-	$link_categories = array_map( 'intval', $link_categories );
285
-	$link_categories = array_unique( $link_categories );
284
+    $link_categories = array_map( 'intval', $link_categories );
285
+    $link_categories = array_unique( $link_categories );
286 286
 
287
-	wp_set_object_terms( $link_id, $link_categories, 'link_category' );
287
+    wp_set_object_terms( $link_id, $link_categories, 'link_category' );
288 288
 
289
-	clean_bookmark_cache( $link_id );
289
+    clean_bookmark_cache( $link_id );
290 290
 }
291 291
 
292 292
 /**
@@ -298,27 +298,27 @@  discard block
 block discarded – undo
298 298
  * @return int|WP_Error Value 0 or WP_Error on failure. The updated link ID on success.
299 299
  */
300 300
 function wp_update_link( $linkdata ) {
301
-	$link_id = (int) $linkdata['link_id'];
301
+    $link_id = (int) $linkdata['link_id'];
302 302
 
303
-	$link = get_bookmark( $link_id, ARRAY_A );
303
+    $link = get_bookmark( $link_id, ARRAY_A );
304 304
 
305
-	// Escape data pulled from DB.
306
-	$link = wp_slash( $link );
305
+    // Escape data pulled from DB.
306
+    $link = wp_slash( $link );
307 307
 
308
-	// Passed link category list overwrites existing category list if not empty.
309
-	if ( isset( $linkdata['link_category'] ) && is_array( $linkdata['link_category'] )
310
-		&& count( $linkdata['link_category'] ) > 0
311
-	) {
312
-		$link_cats = $linkdata['link_category'];
313
-	} else {
314
-		$link_cats = $link['link_category'];
315
-	}
308
+    // Passed link category list overwrites existing category list if not empty.
309
+    if ( isset( $linkdata['link_category'] ) && is_array( $linkdata['link_category'] )
310
+        && count( $linkdata['link_category'] ) > 0
311
+    ) {
312
+        $link_cats = $linkdata['link_category'];
313
+    } else {
314
+        $link_cats = $link['link_category'];
315
+    }
316 316
 
317
-	// Merge old and new fields with new fields overwriting old ones.
318
-	$linkdata                  = array_merge( $link, $linkdata );
319
-	$linkdata['link_category'] = $link_cats;
317
+    // Merge old and new fields with new fields overwriting old ones.
318
+    $linkdata                  = array_merge( $link, $linkdata );
319
+    $linkdata['link_category'] = $link_cats;
320 320
 
321
-	return wp_insert_link( $linkdata );
321
+    return wp_insert_link( $linkdata );
322 322
 }
323 323
 
324 324
 /**
@@ -330,51 +330,51 @@  discard block
 block discarded – undo
330 330
  * @global string $pagenow The filename of the current screen.
331 331
  */
332 332
 function wp_link_manager_disabled_message() {
333
-	global $pagenow;
334
-
335
-	if ( ! in_array( $pagenow, array( 'link-manager.php', 'link-add.php', 'link.php' ), true ) ) {
336
-		return;
337
-	}
338
-
339
-	add_filter( 'pre_option_link_manager_enabled', '__return_true', 100 );
340
-	$really_can_manage_links = current_user_can( 'manage_links' );
341
-	remove_filter( 'pre_option_link_manager_enabled', '__return_true', 100 );
342
-
343
-	if ( $really_can_manage_links ) {
344
-		$plugins = get_plugins();
345
-
346
-		if ( empty( $plugins['link-manager/link-manager.php'] ) ) {
347
-			if ( current_user_can( 'install_plugins' ) ) {
348
-				$install_url = wp_nonce_url(
349
-					self_admin_url( 'update.php?action=install-plugin&plugin=link-manager' ),
350
-					'install-plugin_link-manager'
351
-				);
352
-
353
-				wp_die(
354
-					sprintf(
355
-						/* translators: %s: A link to install the Link Manager plugin. */
356
-						__( 'If you are looking to use the link manager, please install the <a href="%s">Link Manager plugin</a>.' ),
357
-						esc_url( $install_url )
358
-					)
359
-				);
360
-			}
361
-		} elseif ( is_plugin_inactive( 'link-manager/link-manager.php' ) ) {
362
-			if ( current_user_can( 'activate_plugins' ) ) {
363
-				$activate_url = wp_nonce_url(
364
-					self_admin_url( 'plugins.php?action=activate&plugin=link-manager/link-manager.php' ),
365
-					'activate-plugin_link-manager/link-manager.php'
366
-				);
367
-
368
-				wp_die(
369
-					sprintf(
370
-						/* translators: %s: A link to activate the Link Manager plugin. */
371
-						__( 'Please activate the <a href="%s">Link Manager plugin</a> to use the link manager.' ),
372
-						esc_url( $activate_url )
373
-					)
374
-				);
375
-			}
376
-		}
377
-	}
378
-
379
-	wp_die( __( 'Sorry, you are not allowed to edit the links for this site.' ) );
333
+    global $pagenow;
334
+
335
+    if ( ! in_array( $pagenow, array( 'link-manager.php', 'link-add.php', 'link.php' ), true ) ) {
336
+        return;
337
+    }
338
+
339
+    add_filter( 'pre_option_link_manager_enabled', '__return_true', 100 );
340
+    $really_can_manage_links = current_user_can( 'manage_links' );
341
+    remove_filter( 'pre_option_link_manager_enabled', '__return_true', 100 );
342
+
343
+    if ( $really_can_manage_links ) {
344
+        $plugins = get_plugins();
345
+
346
+        if ( empty( $plugins['link-manager/link-manager.php'] ) ) {
347
+            if ( current_user_can( 'install_plugins' ) ) {
348
+                $install_url = wp_nonce_url(
349
+                    self_admin_url( 'update.php?action=install-plugin&plugin=link-manager' ),
350
+                    'install-plugin_link-manager'
351
+                );
352
+
353
+                wp_die(
354
+                    sprintf(
355
+                        /* translators: %s: A link to install the Link Manager plugin. */
356
+                        __( 'If you are looking to use the link manager, please install the <a href="%s">Link Manager plugin</a>.' ),
357
+                        esc_url( $install_url )
358
+                    )
359
+                );
360
+            }
361
+        } elseif ( is_plugin_inactive( 'link-manager/link-manager.php' ) ) {
362
+            if ( current_user_can( 'activate_plugins' ) ) {
363
+                $activate_url = wp_nonce_url(
364
+                    self_admin_url( 'plugins.php?action=activate&plugin=link-manager/link-manager.php' ),
365
+                    'activate-plugin_link-manager/link-manager.php'
366
+                );
367
+
368
+                wp_die(
369
+                    sprintf(
370
+                        /* translators: %s: A link to activate the Link Manager plugin. */
371
+                        __( 'Please activate the <a href="%s">Link Manager plugin</a> to use the link manager.' ),
372
+                        esc_url( $activate_url )
373
+                    )
374
+                );
375
+            }
376
+        }
377
+    }
378
+
379
+    wp_die( __( 'Sorry, you are not allowed to edit the links for this site.' ) );
380 380
 }
Please login to merge, or discard this patch.
brighty/wp-admin/includes/template.php 1 patch
Indentation   +1474 added lines, -1474 removed lines patch added patch discarded remove patch
@@ -38,17 +38,17 @@  discard block
 block discarded – undo
38 38
  *                                          the top of the list. Default true.
39 39
  */
40 40
 function wp_category_checklist( $post_id = 0, $descendants_and_self = 0, $selected_cats = false, $popular_cats = false, $walker = null, $checked_ontop = true ) {
41
-	wp_terms_checklist(
42
-		$post_id,
43
-		array(
44
-			'taxonomy'             => 'category',
45
-			'descendants_and_self' => $descendants_and_self,
46
-			'selected_cats'        => $selected_cats,
47
-			'popular_cats'         => $popular_cats,
48
-			'walker'               => $walker,
49
-			'checked_ontop'        => $checked_ontop,
50
-		)
51
-	);
41
+    wp_terms_checklist(
42
+        $post_id,
43
+        array(
44
+            'taxonomy'             => 'category',
45
+            'descendants_and_self' => $descendants_and_self,
46
+            'selected_cats'        => $selected_cats,
47
+            'popular_cats'         => $popular_cats,
48
+            'walker'               => $walker,
49
+            'checked_ontop'        => $checked_ontop,
50
+        )
51
+    );
52 52
 }
53 53
 
54 54
 /**
@@ -79,115 +79,115 @@  discard block
 block discarded – undo
79 79
  * @return string HTML list of input elements.
80 80
  */
81 81
 function wp_terms_checklist( $post_id = 0, $args = array() ) {
82
-	$defaults = array(
83
-		'descendants_and_self' => 0,
84
-		'selected_cats'        => false,
85
-		'popular_cats'         => false,
86
-		'walker'               => null,
87
-		'taxonomy'             => 'category',
88
-		'checked_ontop'        => true,
89
-		'echo'                 => true,
90
-	);
91
-
92
-	/**
93
-	 * Filters the taxonomy terms checklist arguments.
94
-	 *
95
-	 * @since 3.4.0
96
-	 *
97
-	 * @see wp_terms_checklist()
98
-	 *
99
-	 * @param array|string $args    An array or string of arguments.
100
-	 * @param int          $post_id The post ID.
101
-	 */
102
-	$params = apply_filters( 'wp_terms_checklist_args', $args, $post_id );
103
-
104
-	$parsed_args = wp_parse_args( $params, $defaults );
105
-
106
-	if ( empty( $parsed_args['walker'] ) || ! ( $parsed_args['walker'] instanceof Walker ) ) {
107
-		$walker = new Walker_Category_Checklist;
108
-	} else {
109
-		$walker = $parsed_args['walker'];
110
-	}
111
-
112
-	$taxonomy             = $parsed_args['taxonomy'];
113
-	$descendants_and_self = (int) $parsed_args['descendants_and_self'];
114
-
115
-	$args = array( 'taxonomy' => $taxonomy );
116
-
117
-	$tax              = get_taxonomy( $taxonomy );
118
-	$args['disabled'] = ! current_user_can( $tax->cap->assign_terms );
119
-
120
-	$args['list_only'] = ! empty( $parsed_args['list_only'] );
121
-
122
-	if ( is_array( $parsed_args['selected_cats'] ) ) {
123
-		$args['selected_cats'] = array_map( 'intval', $parsed_args['selected_cats'] );
124
-	} elseif ( $post_id ) {
125
-		$args['selected_cats'] = wp_get_object_terms( $post_id, $taxonomy, array_merge( $args, array( 'fields' => 'ids' ) ) );
126
-	} else {
127
-		$args['selected_cats'] = array();
128
-	}
129
-
130
-	if ( is_array( $parsed_args['popular_cats'] ) ) {
131
-		$args['popular_cats'] = array_map( 'intval', $parsed_args['popular_cats'] );
132
-	} else {
133
-		$args['popular_cats'] = get_terms(
134
-			array(
135
-				'taxonomy'     => $taxonomy,
136
-				'fields'       => 'ids',
137
-				'orderby'      => 'count',
138
-				'order'        => 'DESC',
139
-				'number'       => 10,
140
-				'hierarchical' => false,
141
-			)
142
-		);
143
-	}
144
-
145
-	if ( $descendants_and_self ) {
146
-		$categories = (array) get_terms(
147
-			array(
148
-				'taxonomy'     => $taxonomy,
149
-				'child_of'     => $descendants_and_self,
150
-				'hierarchical' => 0,
151
-				'hide_empty'   => 0,
152
-			)
153
-		);
154
-		$self       = get_term( $descendants_and_self, $taxonomy );
155
-		array_unshift( $categories, $self );
156
-	} else {
157
-		$categories = (array) get_terms(
158
-			array(
159
-				'taxonomy' => $taxonomy,
160
-				'get'      => 'all',
161
-			)
162
-		);
163
-	}
164
-
165
-	$output = '';
166
-
167
-	if ( $parsed_args['checked_ontop'] ) {
168
-		// Post-process $categories rather than adding an exclude to the get_terms() query
169
-		// to keep the query the same across all posts (for any query cache).
170
-		$checked_categories = array();
171
-		$keys               = array_keys( $categories );
172
-
173
-		foreach ( $keys as $k ) {
174
-			if ( in_array( $categories[ $k ]->term_id, $args['selected_cats'], true ) ) {
175
-				$checked_categories[] = $categories[ $k ];
176
-				unset( $categories[ $k ] );
177
-			}
178
-		}
179
-
180
-		// Put checked categories on top.
181
-		$output .= $walker->walk( $checked_categories, 0, $args );
182
-	}
183
-	// Then the rest of them.
184
-	$output .= $walker->walk( $categories, 0, $args );
185
-
186
-	if ( $parsed_args['echo'] ) {
187
-		echo $output;
188
-	}
189
-
190
-	return $output;
82
+    $defaults = array(
83
+        'descendants_and_self' => 0,
84
+        'selected_cats'        => false,
85
+        'popular_cats'         => false,
86
+        'walker'               => null,
87
+        'taxonomy'             => 'category',
88
+        'checked_ontop'        => true,
89
+        'echo'                 => true,
90
+    );
91
+
92
+    /**
93
+     * Filters the taxonomy terms checklist arguments.
94
+     *
95
+     * @since 3.4.0
96
+     *
97
+     * @see wp_terms_checklist()
98
+     *
99
+     * @param array|string $args    An array or string of arguments.
100
+     * @param int          $post_id The post ID.
101
+     */
102
+    $params = apply_filters( 'wp_terms_checklist_args', $args, $post_id );
103
+
104
+    $parsed_args = wp_parse_args( $params, $defaults );
105
+
106
+    if ( empty( $parsed_args['walker'] ) || ! ( $parsed_args['walker'] instanceof Walker ) ) {
107
+        $walker = new Walker_Category_Checklist;
108
+    } else {
109
+        $walker = $parsed_args['walker'];
110
+    }
111
+
112
+    $taxonomy             = $parsed_args['taxonomy'];
113
+    $descendants_and_self = (int) $parsed_args['descendants_and_self'];
114
+
115
+    $args = array( 'taxonomy' => $taxonomy );
116
+
117
+    $tax              = get_taxonomy( $taxonomy );
118
+    $args['disabled'] = ! current_user_can( $tax->cap->assign_terms );
119
+
120
+    $args['list_only'] = ! empty( $parsed_args['list_only'] );
121
+
122
+    if ( is_array( $parsed_args['selected_cats'] ) ) {
123
+        $args['selected_cats'] = array_map( 'intval', $parsed_args['selected_cats'] );
124
+    } elseif ( $post_id ) {
125
+        $args['selected_cats'] = wp_get_object_terms( $post_id, $taxonomy, array_merge( $args, array( 'fields' => 'ids' ) ) );
126
+    } else {
127
+        $args['selected_cats'] = array();
128
+    }
129
+
130
+    if ( is_array( $parsed_args['popular_cats'] ) ) {
131
+        $args['popular_cats'] = array_map( 'intval', $parsed_args['popular_cats'] );
132
+    } else {
133
+        $args['popular_cats'] = get_terms(
134
+            array(
135
+                'taxonomy'     => $taxonomy,
136
+                'fields'       => 'ids',
137
+                'orderby'      => 'count',
138
+                'order'        => 'DESC',
139
+                'number'       => 10,
140
+                'hierarchical' => false,
141
+            )
142
+        );
143
+    }
144
+
145
+    if ( $descendants_and_self ) {
146
+        $categories = (array) get_terms(
147
+            array(
148
+                'taxonomy'     => $taxonomy,
149
+                'child_of'     => $descendants_and_self,
150
+                'hierarchical' => 0,
151
+                'hide_empty'   => 0,
152
+            )
153
+        );
154
+        $self       = get_term( $descendants_and_self, $taxonomy );
155
+        array_unshift( $categories, $self );
156
+    } else {
157
+        $categories = (array) get_terms(
158
+            array(
159
+                'taxonomy' => $taxonomy,
160
+                'get'      => 'all',
161
+            )
162
+        );
163
+    }
164
+
165
+    $output = '';
166
+
167
+    if ( $parsed_args['checked_ontop'] ) {
168
+        // Post-process $categories rather than adding an exclude to the get_terms() query
169
+        // to keep the query the same across all posts (for any query cache).
170
+        $checked_categories = array();
171
+        $keys               = array_keys( $categories );
172
+
173
+        foreach ( $keys as $k ) {
174
+            if ( in_array( $categories[ $k ]->term_id, $args['selected_cats'], true ) ) {
175
+                $checked_categories[] = $categories[ $k ];
176
+                unset( $categories[ $k ] );
177
+            }
178
+        }
179
+
180
+        // Put checked categories on top.
181
+        $output .= $walker->walk( $checked_categories, 0, $args );
182
+    }
183
+    // Then the rest of them.
184
+    $output .= $walker->walk( $categories, 0, $args );
185
+
186
+    if ( $parsed_args['echo'] ) {
187
+        echo $output;
188
+    }
189
+
190
+    return $output;
191 191
 }
192 192
 
193 193
 /**
@@ -207,52 +207,52 @@  discard block
 block discarded – undo
207 207
  * @return int[] Array of popular term IDs.
208 208
  */
209 209
 function wp_popular_terms_checklist( $taxonomy, $default_term = 0, $number = 10, $display = true ) {
210
-	$post = get_post();
210
+    $post = get_post();
211 211
 
212
-	if ( $post && $post->ID ) {
213
-		$checked_terms = wp_get_object_terms( $post->ID, $taxonomy, array( 'fields' => 'ids' ) );
214
-	} else {
215
-		$checked_terms = array();
216
-	}
212
+    if ( $post && $post->ID ) {
213
+        $checked_terms = wp_get_object_terms( $post->ID, $taxonomy, array( 'fields' => 'ids' ) );
214
+    } else {
215
+        $checked_terms = array();
216
+    }
217 217
 
218
-	$terms = get_terms(
219
-		array(
220
-			'taxonomy'     => $taxonomy,
221
-			'orderby'      => 'count',
222
-			'order'        => 'DESC',
223
-			'number'       => $number,
224
-			'hierarchical' => false,
225
-		)
226
-	);
218
+    $terms = get_terms(
219
+        array(
220
+            'taxonomy'     => $taxonomy,
221
+            'orderby'      => 'count',
222
+            'order'        => 'DESC',
223
+            'number'       => $number,
224
+            'hierarchical' => false,
225
+        )
226
+    );
227 227
 
228
-	$tax = get_taxonomy( $taxonomy );
228
+    $tax = get_taxonomy( $taxonomy );
229 229
 
230
-	$popular_ids = array();
230
+    $popular_ids = array();
231 231
 
232
-	foreach ( (array) $terms as $term ) {
233
-		$popular_ids[] = $term->term_id;
232
+    foreach ( (array) $terms as $term ) {
233
+        $popular_ids[] = $term->term_id;
234 234
 
235
-		if ( ! $display ) { // Hack for Ajax use.
236
-			continue;
237
-		}
235
+        if ( ! $display ) { // Hack for Ajax use.
236
+            continue;
237
+        }
238 238
 
239
-		$id      = "popular-$taxonomy-$term->term_id";
240
-		$checked = in_array( $term->term_id, $checked_terms, true ) ? 'checked="checked"' : '';
241
-		?>
239
+        $id      = "popular-$taxonomy-$term->term_id";
240
+        $checked = in_array( $term->term_id, $checked_terms, true ) ? 'checked="checked"' : '';
241
+        ?>
242 242
 
243 243
 		<li id="<?php echo $id; ?>" class="popular-category">
244 244
 			<label class="selectit">
245 245
 				<input id="in-<?php echo $id; ?>" type="checkbox" <?php echo $checked; ?> value="<?php echo (int) $term->term_id; ?>" <?php disabled( ! current_user_can( $tax->cap->assign_terms ) ); ?> />
246 246
 				<?php
247
-				/** This filter is documented in wp-includes/category-template.php */
248
-				echo esc_html( apply_filters( 'the_category', $term->name, '', '' ) );
249
-				?>
247
+                /** This filter is documented in wp-includes/category-template.php */
248
+                echo esc_html( apply_filters( 'the_category', $term->name, '', '' ) );
249
+                ?>
250 250
 			</label>
251 251
 		</li>
252 252
 
253 253
 		<?php
254
-	}
255
-	return $popular_ids;
254
+    }
255
+    return $popular_ids;
256 256
 }
257 257
 
258 258
 /**
@@ -263,40 +263,40 @@  discard block
 block discarded – undo
263 263
  * @param int $link_id
264 264
  */
265 265
 function wp_link_category_checklist( $link_id = 0 ) {
266
-	$default = 1;
267
-
268
-	$checked_categories = array();
269
-
270
-	if ( $link_id ) {
271
-		$checked_categories = wp_get_link_cats( $link_id );
272
-		// No selected categories, strange.
273
-		if ( ! count( $checked_categories ) ) {
274
-			$checked_categories[] = $default;
275
-		}
276
-	} else {
277
-		$checked_categories[] = $default;
278
-	}
279
-
280
-	$categories = get_terms(
281
-		array(
282
-			'taxonomy'   => 'link_category',
283
-			'orderby'    => 'name',
284
-			'hide_empty' => 0,
285
-		)
286
-	);
287
-
288
-	if ( empty( $categories ) ) {
289
-		return;
290
-	}
291
-
292
-	foreach ( $categories as $category ) {
293
-		$cat_id = $category->term_id;
294
-
295
-		/** This filter is documented in wp-includes/category-template.php */
296
-		$name    = esc_html( apply_filters( 'the_category', $category->name, '', '' ) );
297
-		$checked = in_array( $cat_id, $checked_categories, true ) ? ' checked="checked"' : '';
298
-		echo '<li id="link-category-', $cat_id, '"><label for="in-link-category-', $cat_id, '" class="selectit"><input value="', $cat_id, '" type="checkbox" name="link_category[]" id="in-link-category-', $cat_id, '"', $checked, '/> ', $name, '</label></li>';
299
-	}
266
+    $default = 1;
267
+
268
+    $checked_categories = array();
269
+
270
+    if ( $link_id ) {
271
+        $checked_categories = wp_get_link_cats( $link_id );
272
+        // No selected categories, strange.
273
+        if ( ! count( $checked_categories ) ) {
274
+            $checked_categories[] = $default;
275
+        }
276
+    } else {
277
+        $checked_categories[] = $default;
278
+    }
279
+
280
+    $categories = get_terms(
281
+        array(
282
+            'taxonomy'   => 'link_category',
283
+            'orderby'    => 'name',
284
+            'hide_empty' => 0,
285
+        )
286
+    );
287
+
288
+    if ( empty( $categories ) ) {
289
+        return;
290
+    }
291
+
292
+    foreach ( $categories as $category ) {
293
+        $cat_id = $category->term_id;
294
+
295
+        /** This filter is documented in wp-includes/category-template.php */
296
+        $name    = esc_html( apply_filters( 'the_category', $category->name, '', '' ) );
297
+        $checked = in_array( $cat_id, $checked_categories, true ) ? ' checked="checked"' : '';
298
+        echo '<li id="link-category-', $cat_id, '"><label for="in-link-category-', $cat_id, '" class="selectit"><input value="', $cat_id, '" type="checkbox" name="link_category[]" id="in-link-category-', $cat_id, '"', $checked, '/> ', $name, '</label></li>';
299
+    }
300 300
 }
301 301
 
302 302
 /**
@@ -307,18 +307,18 @@  discard block
 block discarded – undo
307 307
  * @param WP_Post $post Post object.
308 308
  */
309 309
 function get_inline_data( $post ) {
310
-	$post_type_object = get_post_type_object( $post->post_type );
311
-	if ( ! current_user_can( 'edit_post', $post->ID ) ) {
312
-		return;
313
-	}
310
+    $post_type_object = get_post_type_object( $post->post_type );
311
+    if ( ! current_user_can( 'edit_post', $post->ID ) ) {
312
+        return;
313
+    }
314 314
 
315
-	$title = esc_textarea( trim( $post->post_title ) );
315
+    $title = esc_textarea( trim( $post->post_title ) );
316 316
 
317
-	echo '
317
+    echo '
318 318
 <div class="hidden" id="inline_' . $post->ID . '">
319 319
 	<div class="post_title">' . $title . '</div>' .
320
-	/** This filter is documented in wp-admin/edit-tag-form.php */
321
-	'<div class="post_name">' . apply_filters( 'editable_slug', $post->post_name, $post ) . '</div>
320
+    /** This filter is documented in wp-admin/edit-tag-form.php */
321
+    '<div class="post_name">' . apply_filters( 'editable_slug', $post->post_name, $post ) . '</div>
322 322
 	<div class="post_author">' . $post->post_author . '</div>
323 323
 	<div class="comment_status">' . esc_html( $post->comment_status ) . '</div>
324 324
 	<div class="ping_status">' . esc_html( $post->ping_status ) . '</div>
@@ -331,68 +331,68 @@  discard block
 block discarded – undo
331 331
 	<div class="ss">' . mysql2date( 's', $post->post_date, false ) . '</div>
332 332
 	<div class="post_password">' . esc_html( $post->post_password ) . '</div>';
333 333
 
334
-	if ( $post_type_object->hierarchical ) {
335
-		echo '<div class="post_parent">' . $post->post_parent . '</div>';
336
-	}
334
+    if ( $post_type_object->hierarchical ) {
335
+        echo '<div class="post_parent">' . $post->post_parent . '</div>';
336
+    }
337 337
 
338
-	echo '<div class="page_template">' . ( $post->page_template ? esc_html( $post->page_template ) : 'default' ) . '</div>';
338
+    echo '<div class="page_template">' . ( $post->page_template ? esc_html( $post->page_template ) : 'default' ) . '</div>';
339 339
 
340
-	if ( post_type_supports( $post->post_type, 'page-attributes' ) ) {
341
-		echo '<div class="menu_order">' . $post->menu_order . '</div>';
342
-	}
340
+    if ( post_type_supports( $post->post_type, 'page-attributes' ) ) {
341
+        echo '<div class="menu_order">' . $post->menu_order . '</div>';
342
+    }
343 343
 
344
-	$taxonomy_names = get_object_taxonomies( $post->post_type );
344
+    $taxonomy_names = get_object_taxonomies( $post->post_type );
345 345
 
346
-	foreach ( $taxonomy_names as $taxonomy_name ) {
347
-		$taxonomy = get_taxonomy( $taxonomy_name );
346
+    foreach ( $taxonomy_names as $taxonomy_name ) {
347
+        $taxonomy = get_taxonomy( $taxonomy_name );
348 348
 
349
-		if ( ! $taxonomy->show_in_quick_edit ) {
350
-			continue;
351
-		}
349
+        if ( ! $taxonomy->show_in_quick_edit ) {
350
+            continue;
351
+        }
352 352
 
353
-		if ( $taxonomy->hierarchical ) {
353
+        if ( $taxonomy->hierarchical ) {
354 354
 
355
-			$terms = get_object_term_cache( $post->ID, $taxonomy_name );
356
-			if ( false === $terms ) {
357
-				$terms = wp_get_object_terms( $post->ID, $taxonomy_name );
358
-				wp_cache_add( $post->ID, wp_list_pluck( $terms, 'term_id' ), $taxonomy_name . '_relationships' );
359
-			}
360
-			$term_ids = empty( $terms ) ? array() : wp_list_pluck( $terms, 'term_id' );
355
+            $terms = get_object_term_cache( $post->ID, $taxonomy_name );
356
+            if ( false === $terms ) {
357
+                $terms = wp_get_object_terms( $post->ID, $taxonomy_name );
358
+                wp_cache_add( $post->ID, wp_list_pluck( $terms, 'term_id' ), $taxonomy_name . '_relationships' );
359
+            }
360
+            $term_ids = empty( $terms ) ? array() : wp_list_pluck( $terms, 'term_id' );
361 361
 
362
-			echo '<div class="post_category" id="' . $taxonomy_name . '_' . $post->ID . '">' . implode( ',', $term_ids ) . '</div>';
362
+            echo '<div class="post_category" id="' . $taxonomy_name . '_' . $post->ID . '">' . implode( ',', $term_ids ) . '</div>';
363 363
 
364
-		} else {
364
+        } else {
365 365
 
366
-			$terms_to_edit = get_terms_to_edit( $post->ID, $taxonomy_name );
367
-			if ( ! is_string( $terms_to_edit ) ) {
368
-				$terms_to_edit = '';
369
-			}
366
+            $terms_to_edit = get_terms_to_edit( $post->ID, $taxonomy_name );
367
+            if ( ! is_string( $terms_to_edit ) ) {
368
+                $terms_to_edit = '';
369
+            }
370 370
 
371
-			echo '<div class="tags_input" id="' . $taxonomy_name . '_' . $post->ID . '">'
372
-				. esc_html( str_replace( ',', ', ', $terms_to_edit ) ) . '</div>';
371
+            echo '<div class="tags_input" id="' . $taxonomy_name . '_' . $post->ID . '">'
372
+                . esc_html( str_replace( ',', ', ', $terms_to_edit ) ) . '</div>';
373 373
 
374
-		}
375
-	}
376
-
377
-	if ( ! $post_type_object->hierarchical ) {
378
-		echo '<div class="sticky">' . ( is_sticky( $post->ID ) ? 'sticky' : '' ) . '</div>';
379
-	}
380
-
381
-	if ( post_type_supports( $post->post_type, 'post-formats' ) ) {
382
-		echo '<div class="post_format">' . esc_html( get_post_format( $post->ID ) ) . '</div>';
383
-	}
384
-
385
-	/**
386
-	 * Fires after outputting the fields for the inline editor for posts and pages.
387
-	 *
388
-	 * @since 4.9.8
389
-	 *
390
-	 * @param WP_Post      $post             The current post object.
391
-	 * @param WP_Post_Type $post_type_object The current post's post type object.
392
-	 */
393
-	do_action( 'add_inline_data', $post, $post_type_object );
374
+        }
375
+    }
394 376
 
395
-	echo '</div>';
377
+    if ( ! $post_type_object->hierarchical ) {
378
+        echo '<div class="sticky">' . ( is_sticky( $post->ID ) ? 'sticky' : '' ) . '</div>';
379
+    }
380
+
381
+    if ( post_type_supports( $post->post_type, 'post-formats' ) ) {
382
+        echo '<div class="post_format">' . esc_html( get_post_format( $post->ID ) ) . '</div>';
383
+    }
384
+
385
+    /**
386
+     * Fires after outputting the fields for the inline editor for posts and pages.
387
+     *
388
+     * @since 4.9.8
389
+     *
390
+     * @param WP_Post      $post             The current post object.
391
+     * @param WP_Post_Type $post_type_object The current post's post type object.
392
+     */
393
+    do_action( 'add_inline_data', $post, $post_type_object );
394
+
395
+    echo '</div>';
396 396
 }
397 397
 
398 398
 /**
@@ -408,46 +408,46 @@  discard block
 block discarded – undo
408 408
  * @param bool   $table_row
409 409
  */
410 410
 function wp_comment_reply( $position = 1, $checkbox = false, $mode = 'single', $table_row = true ) {
411
-	global $wp_list_table;
412
-	/**
413
-	 * Filters the in-line comment reply-to form output in the Comments
414
-	 * list table.
415
-	 *
416
-	 * Returning a non-empty value here will short-circuit display
417
-	 * of the in-line comment-reply form in the Comments list table,
418
-	 * echoing the returned value instead.
419
-	 *
420
-	 * @since 2.7.0
421
-	 *
422
-	 * @see wp_comment_reply()
423
-	 *
424
-	 * @param string $content The reply-to form content.
425
-	 * @param array  $args    An array of default args.
426
-	 */
427
-	$content = apply_filters(
428
-		'wp_comment_reply',
429
-		'',
430
-		array(
431
-			'position' => $position,
432
-			'checkbox' => $checkbox,
433
-			'mode'     => $mode,
434
-		)
435
-	);
436
-
437
-	if ( ! empty( $content ) ) {
438
-		echo $content;
439
-		return;
440
-	}
441
-
442
-	if ( ! $wp_list_table ) {
443
-		if ( 'single' === $mode ) {
444
-			$wp_list_table = _get_list_table( 'WP_Post_Comments_List_Table' );
445
-		} else {
446
-			$wp_list_table = _get_list_table( 'WP_Comments_List_Table' );
447
-		}
448
-	}
449
-
450
-	?>
411
+    global $wp_list_table;
412
+    /**
413
+     * Filters the in-line comment reply-to form output in the Comments
414
+     * list table.
415
+     *
416
+     * Returning a non-empty value here will short-circuit display
417
+     * of the in-line comment-reply form in the Comments list table,
418
+     * echoing the returned value instead.
419
+     *
420
+     * @since 2.7.0
421
+     *
422
+     * @see wp_comment_reply()
423
+     *
424
+     * @param string $content The reply-to form content.
425
+     * @param array  $args    An array of default args.
426
+     */
427
+    $content = apply_filters(
428
+        'wp_comment_reply',
429
+        '',
430
+        array(
431
+            'position' => $position,
432
+            'checkbox' => $checkbox,
433
+            'mode'     => $mode,
434
+        )
435
+    );
436
+
437
+    if ( ! empty( $content ) ) {
438
+        echo $content;
439
+        return;
440
+    }
441
+
442
+    if ( ! $wp_list_table ) {
443
+        if ( 'single' === $mode ) {
444
+            $wp_list_table = _get_list_table( 'WP_Post_Comments_List_Table' );
445
+        } else {
446
+            $wp_list_table = _get_list_table( 'WP_Comments_List_Table' );
447
+        }
448
+    }
449
+
450
+    ?>
451 451
 <form method="get">
452 452
 	<?php if ( $table_row ) : ?>
453 453
 <table style="display:none;"><tbody id="com-reply"><tr id="replyrow" class="inline-edit-row" style="display:none;"><td colspan="<?php echo $wp_list_table->get_column_count(); ?>" class="colspanchange">
@@ -464,17 +464,17 @@  discard block
 block discarded – undo
464 464
 	<div id="replycontainer">
465 465
 	<label for="replycontent" class="screen-reader-text"><?php _e( 'Comment' ); ?></label>
466 466
 	<?php
467
-	$quicktags_settings = array( 'buttons' => 'strong,em,link,block,del,ins,img,ul,ol,li,code,close' );
468
-	wp_editor(
469
-		'',
470
-		'replycontent',
471
-		array(
472
-			'media_buttons' => false,
473
-			'tinymce'       => false,
474
-			'quicktags'     => $quicktags_settings,
475
-		)
476
-	);
477
-	?>
467
+    $quicktags_settings = array( 'buttons' => 'strong,em,link,block,del,ins,img,ul,ol,li,code,close' );
468
+    wp_editor(
469
+        '',
470
+        'replycontent',
471
+        array(
472
+            'media_buttons' => false,
473
+            'tinymce'       => false,
474
+            'quicktags'     => $quicktags_settings,
475
+        )
476
+    );
477
+    ?>
478 478
 	</div>
479 479
 
480 480
 	<div id="edithead" style="display:none;">
@@ -517,11 +517,11 @@  discard block
 block discarded – undo
517 517
 	<input type="hidden" name="checkbox" id="checkbox" value="<?php echo $checkbox ? 1 : 0; ?>" />
518 518
 	<input type="hidden" name="mode" id="mode" value="<?php echo esc_attr( $mode ); ?>" />
519 519
 	<?php
520
-		wp_nonce_field( 'replyto-comment', '_ajax_nonce-replyto-comment', false );
521
-	if ( current_user_can( 'unfiltered_html' ) ) {
522
-		wp_nonce_field( 'unfiltered-html-comment', '_wp_unfiltered_html_comment', false );
523
-	}
524
-	?>
520
+        wp_nonce_field( 'replyto-comment', '_ajax_nonce-replyto-comment', false );
521
+    if ( current_user_can( 'unfiltered_html' ) ) {
522
+        wp_nonce_field( 'unfiltered-html-comment', '_wp_unfiltered_html_comment', false );
523
+    }
524
+    ?>
525 525
 	</fieldset>
526 526
 	<?php if ( $table_row ) : ?>
527 527
 </td></tr></tbody></table>
@@ -538,22 +538,22 @@  discard block
 block discarded – undo
538 538
  * @since 2.9.0
539 539
  */
540 540
 function wp_comment_trashnotice() {
541
-	?>
541
+    ?>
542 542
 <div class="hidden" id="trash-undo-holder">
543 543
 	<div class="trash-undo-inside">
544 544
 		<?php
545
-		/* translators: %s: Comment author, filled by Ajax. */
546
-		printf( __( 'Comment by %s moved to the Trash.' ), '<strong></strong>' );
547
-		?>
545
+        /* translators: %s: Comment author, filled by Ajax. */
546
+        printf( __( 'Comment by %s moved to the Trash.' ), '<strong></strong>' );
547
+        ?>
548 548
 		<span class="undo untrash"><a href="#"><?php _e( 'Undo' ); ?></a></span>
549 549
 	</div>
550 550
 </div>
551 551
 <div class="hidden" id="spam-undo-holder">
552 552
 	<div class="spam-undo-inside">
553 553
 		<?php
554
-		/* translators: %s: Comment author, filled by Ajax. */
555
-		printf( __( 'Comment by %s marked as spam.' ), '<strong></strong>' );
556
-		?>
554
+        /* translators: %s: Comment author, filled by Ajax. */
555
+        printf( __( 'Comment by %s marked as spam.' ), '<strong></strong>' );
556
+        ?>
557 557
 		<span class="undo unspam"><a href="#"><?php _e( 'Undo' ); ?></a></span>
558 558
 	</div>
559 559
 </div>
@@ -568,9 +568,9 @@  discard block
 block discarded – undo
568 568
  * @param array $meta
569 569
  */
570 570
 function list_meta( $meta ) {
571
-	// Exit if no meta.
572
-	if ( ! $meta ) {
573
-		echo '
571
+    // Exit if no meta.
572
+    if ( ! $meta ) {
573
+        echo '
574 574
 <table id="list-table" style="display: none;">
575 575
 	<thead>
576 576
 	<tr>
@@ -582,10 +582,10 @@  discard block
 block discarded – undo
582 582
 	<tr><td></td></tr>
583 583
 	</tbody>
584 584
 </table>'; // TBODY needed for list-manipulation JS.
585
-		return;
586
-	}
587
-	$count = 0;
588
-	?>
585
+        return;
586
+    }
587
+    $count = 0;
588
+    ?>
589 589
 <table id="list-table">
590 590
 	<thead>
591 591
 	<tr>
@@ -595,10 +595,10 @@  discard block
 block discarded – undo
595 595
 	</thead>
596 596
 	<tbody id='the-list' data-wp-lists='list:meta'>
597 597
 	<?php
598
-	foreach ( $meta as $entry ) {
599
-		echo _list_meta_row( $entry, $count );
600
-	}
601
-	?>
598
+    foreach ( $meta as $entry ) {
599
+        echo _list_meta_row( $entry, $count );
600
+    }
601
+    ?>
602 602
 	</tbody>
603 603
 </table>
604 604
 	<?php
@@ -614,49 +614,49 @@  discard block
 block discarded – undo
614 614
  * @return string
615 615
  */
616 616
 function _list_meta_row( $entry, &$count ) {
617
-	static $update_nonce = '';
618
-
619
-	if ( is_protected_meta( $entry['meta_key'], 'post' ) ) {
620
-		return '';
621
-	}
622
-
623
-	if ( ! $update_nonce ) {
624
-		$update_nonce = wp_create_nonce( 'add-meta' );
625
-	}
626
-
627
-	$r = '';
628
-	++ $count;
629
-
630
-	if ( is_serialized( $entry['meta_value'] ) ) {
631
-		if ( is_serialized_string( $entry['meta_value'] ) ) {
632
-			// This is a serialized string, so we should display it.
633
-			$entry['meta_value'] = maybe_unserialize( $entry['meta_value'] );
634
-		} else {
635
-			// This is a serialized array/object so we should NOT display it.
636
-			--$count;
637
-			return '';
638
-		}
639
-	}
640
-
641
-	$entry['meta_key']   = esc_attr( $entry['meta_key'] );
642
-	$entry['meta_value'] = esc_textarea( $entry['meta_value'] ); // Using a <textarea />.
643
-	$entry['meta_id']    = (int) $entry['meta_id'];
644
-
645
-	$delete_nonce = wp_create_nonce( 'delete-meta_' . $entry['meta_id'] );
646
-
647
-	$r .= "\n\t<tr id='meta-{$entry['meta_id']}'>";
648
-	$r .= "\n\t\t<td class='left'><label class='screen-reader-text' for='meta-{$entry['meta_id']}-key'>" . __( 'Key' ) . "</label><input name='meta[{$entry['meta_id']}][key]' id='meta-{$entry['meta_id']}-key' type='text' size='20' value='{$entry['meta_key']}' />";
649
-
650
-	$r .= "\n\t\t<div class='submit'>";
651
-	$r .= get_submit_button( __( 'Delete' ), 'deletemeta small', "deletemeta[{$entry['meta_id']}]", false, array( 'data-wp-lists' => "delete:the-list:meta-{$entry['meta_id']}::_ajax_nonce=$delete_nonce" ) );
652
-	$r .= "\n\t\t";
653
-	$r .= get_submit_button( __( 'Update' ), 'updatemeta small', "meta-{$entry['meta_id']}-submit", false, array( 'data-wp-lists' => "add:the-list:meta-{$entry['meta_id']}::_ajax_nonce-add-meta=$update_nonce" ) );
654
-	$r .= '</div>';
655
-	$r .= wp_nonce_field( 'change-meta', '_ajax_nonce', false, false );
656
-	$r .= '</td>';
657
-
658
-	$r .= "\n\t\t<td><label class='screen-reader-text' for='meta-{$entry['meta_id']}-value'>" . __( 'Value' ) . "</label><textarea name='meta[{$entry['meta_id']}][value]' id='meta-{$entry['meta_id']}-value' rows='2' cols='30'>{$entry['meta_value']}</textarea></td>\n\t</tr>";
659
-	return $r;
617
+    static $update_nonce = '';
618
+
619
+    if ( is_protected_meta( $entry['meta_key'], 'post' ) ) {
620
+        return '';
621
+    }
622
+
623
+    if ( ! $update_nonce ) {
624
+        $update_nonce = wp_create_nonce( 'add-meta' );
625
+    }
626
+
627
+    $r = '';
628
+    ++ $count;
629
+
630
+    if ( is_serialized( $entry['meta_value'] ) ) {
631
+        if ( is_serialized_string( $entry['meta_value'] ) ) {
632
+            // This is a serialized string, so we should display it.
633
+            $entry['meta_value'] = maybe_unserialize( $entry['meta_value'] );
634
+        } else {
635
+            // This is a serialized array/object so we should NOT display it.
636
+            --$count;
637
+            return '';
638
+        }
639
+    }
640
+
641
+    $entry['meta_key']   = esc_attr( $entry['meta_key'] );
642
+    $entry['meta_value'] = esc_textarea( $entry['meta_value'] ); // Using a <textarea />.
643
+    $entry['meta_id']    = (int) $entry['meta_id'];
644
+
645
+    $delete_nonce = wp_create_nonce( 'delete-meta_' . $entry['meta_id'] );
646
+
647
+    $r .= "\n\t<tr id='meta-{$entry['meta_id']}'>";
648
+    $r .= "\n\t\t<td class='left'><label class='screen-reader-text' for='meta-{$entry['meta_id']}-key'>" . __( 'Key' ) . "</label><input name='meta[{$entry['meta_id']}][key]' id='meta-{$entry['meta_id']}-key' type='text' size='20' value='{$entry['meta_key']}' />";
649
+
650
+    $r .= "\n\t\t<div class='submit'>";
651
+    $r .= get_submit_button( __( 'Delete' ), 'deletemeta small', "deletemeta[{$entry['meta_id']}]", false, array( 'data-wp-lists' => "delete:the-list:meta-{$entry['meta_id']}::_ajax_nonce=$delete_nonce" ) );
652
+    $r .= "\n\t\t";
653
+    $r .= get_submit_button( __( 'Update' ), 'updatemeta small', "meta-{$entry['meta_id']}-submit", false, array( 'data-wp-lists' => "add:the-list:meta-{$entry['meta_id']}::_ajax_nonce-add-meta=$update_nonce" ) );
654
+    $r .= '</div>';
655
+    $r .= wp_nonce_field( 'change-meta', '_ajax_nonce', false, false );
656
+    $r .= '</td>';
657
+
658
+    $r .= "\n\t\t<td><label class='screen-reader-text' for='meta-{$entry['meta_id']}-value'>" . __( 'Value' ) . "</label><textarea name='meta[{$entry['meta_id']}][value]' id='meta-{$entry['meta_id']}-value' rows='2' cols='30'>{$entry['meta_value']}</textarea></td>\n\t</tr>";
659
+    return $r;
660 660
 }
661 661
 
662 662
 /**
@@ -669,54 +669,54 @@  discard block
 block discarded – undo
669 669
  * @param WP_Post $post Optional. The post being edited.
670 670
  */
671 671
 function meta_form( $post = null ) {
672
-	global $wpdb;
673
-	$post = get_post( $post );
674
-
675
-	/**
676
-	 * Filters values for the meta key dropdown in the Custom Fields meta box.
677
-	 *
678
-	 * Returning a non-null value will effectively short-circuit and avoid a
679
-	 * potentially expensive query against postmeta.
680
-	 *
681
-	 * @since 4.4.0
682
-	 *
683
-	 * @param array|null $keys Pre-defined meta keys to be used in place of a postmeta query. Default null.
684
-	 * @param WP_Post    $post The current post object.
685
-	 */
686
-	$keys = apply_filters( 'postmeta_form_keys', null, $post );
687
-
688
-	if ( null === $keys ) {
689
-		/**
690
-		 * Filters the number of custom fields to retrieve for the drop-down
691
-		 * in the Custom Fields meta box.
692
-		 *
693
-		 * @since 2.1.0
694
-		 *
695
-		 * @param int $limit Number of custom fields to retrieve. Default 30.
696
-		 */
697
-		$limit = apply_filters( 'postmeta_form_limit', 30 );
698
-
699
-		$keys = $wpdb->get_col(
700
-			$wpdb->prepare(
701
-				"SELECT DISTINCT meta_key
672
+    global $wpdb;
673
+    $post = get_post( $post );
674
+
675
+    /**
676
+     * Filters values for the meta key dropdown in the Custom Fields meta box.
677
+     *
678
+     * Returning a non-null value will effectively short-circuit and avoid a
679
+     * potentially expensive query against postmeta.
680
+     *
681
+     * @since 4.4.0
682
+     *
683
+     * @param array|null $keys Pre-defined meta keys to be used in place of a postmeta query. Default null.
684
+     * @param WP_Post    $post The current post object.
685
+     */
686
+    $keys = apply_filters( 'postmeta_form_keys', null, $post );
687
+
688
+    if ( null === $keys ) {
689
+        /**
690
+         * Filters the number of custom fields to retrieve for the drop-down
691
+         * in the Custom Fields meta box.
692
+         *
693
+         * @since 2.1.0
694
+         *
695
+         * @param int $limit Number of custom fields to retrieve. Default 30.
696
+         */
697
+        $limit = apply_filters( 'postmeta_form_limit', 30 );
698
+
699
+        $keys = $wpdb->get_col(
700
+            $wpdb->prepare(
701
+                "SELECT DISTINCT meta_key
702 702
 				FROM $wpdb->postmeta
703 703
 				WHERE meta_key NOT BETWEEN '_' AND '_z'
704 704
 				HAVING meta_key NOT LIKE %s
705 705
 				ORDER BY meta_key
706 706
 				LIMIT %d",
707
-				$wpdb->esc_like( '_' ) . '%',
708
-				$limit
709
-			)
710
-		);
711
-	}
712
-
713
-	if ( $keys ) {
714
-		natcasesort( $keys );
715
-		$meta_key_input_id = 'metakeyselect';
716
-	} else {
717
-		$meta_key_input_id = 'metakeyinput';
718
-	}
719
-	?>
707
+                $wpdb->esc_like( '_' ) . '%',
708
+                $limit
709
+            )
710
+        );
711
+    }
712
+
713
+    if ( $keys ) {
714
+        natcasesort( $keys );
715
+        $meta_key_input_id = 'metakeyselect';
716
+    } else {
717
+        $meta_key_input_id = 'metakeyinput';
718
+    }
719
+    ?>
720 720
 <p><strong><?php _e( 'Add New Custom Field:' ); ?></strong></p>
721 721
 <table id="newmeta">
722 722
 <thead>
@@ -733,13 +733,13 @@  discard block
 block discarded – undo
733 733
 <select id="metakeyselect" name="metakeyselect">
734 734
 <option value="#NONE#"><?php _e( '&mdash; Select &mdash;' ); ?></option>
735 735
 		<?php
736
-		foreach ( $keys as $key ) {
737
-			if ( is_protected_meta( $key, 'post' ) || ! current_user_can( 'add_post_meta', $post->ID, $key ) ) {
738
-				continue;
739
-			}
740
-			echo "\n<option value='" . esc_attr( $key ) . "'>" . esc_html( $key ) . '</option>';
741
-		}
742
-		?>
736
+        foreach ( $keys as $key ) {
737
+            if ( is_protected_meta( $key, 'post' ) || ! current_user_can( 'add_post_meta', $post->ID, $key ) ) {
738
+                continue;
739
+            }
740
+            echo "\n<option value='" . esc_attr( $key ) . "'>" . esc_html( $key ) . '</option>';
741
+        }
742
+        ?>
743 743
 </select>
744 744
 <input class="hide-if-js" type="text" id="metakeyinput" name="metakeyinput" value="" />
745 745
 <a href="#postcustomstuff" class="hide-if-no-js" onclick="jQuery('#metakeyinput, #metakeyselect, #enternew, #cancelnew').toggle();return false;">
@@ -755,17 +755,17 @@  discard block
 block discarded – undo
755 755
 <tr><td colspan="2">
756 756
 <div class="submit">
757 757
 	<?php
758
-	submit_button(
759
-		__( 'Add Custom Field' ),
760
-		'',
761
-		'addmeta',
762
-		false,
763
-		array(
764
-			'id'            => 'newmeta-submit',
765
-			'data-wp-lists' => 'add:the-list:newmeta',
766
-		)
767
-	);
768
-	?>
758
+    submit_button(
759
+        __( 'Add Custom Field' ),
760
+        '',
761
+        'addmeta',
762
+        false,
763
+        array(
764
+            'id'            => 'newmeta-submit',
765
+            'data-wp-lists' => 'add:the-list:newmeta',
766
+        )
767
+    );
768
+    ?>
769 769
 </div>
770 770
 	<?php wp_nonce_field( 'add-meta', '_ajax_nonce-add-meta', false ); ?>
771 771
 </td></tr>
@@ -790,78 +790,78 @@  discard block
 block discarded – undo
790 790
  *                            Default 0|false.
791 791
  */
792 792
 function touch_time( $edit = 1, $for_post = 1, $tab_index = 0, $multi = 0 ) {
793
-	global $wp_locale;
794
-	$post = get_post();
795
-
796
-	if ( $for_post ) {
797
-		$edit = ! ( in_array( $post->post_status, array( 'draft', 'pending' ), true ) && ( ! $post->post_date_gmt || '0000-00-00 00:00:00' === $post->post_date_gmt ) );
798
-	}
799
-
800
-	$tab_index_attribute = '';
801
-	if ( (int) $tab_index > 0 ) {
802
-		$tab_index_attribute = " tabindex=\"$tab_index\"";
803
-	}
804
-
805
-	// @todo Remove this?
806
-	// echo '<label for="timestamp" style="display: block;"><input type="checkbox" class="checkbox" name="edit_date" value="1" id="timestamp"'.$tab_index_attribute.' /> '.__( 'Edit timestamp' ).'</label><br />';
807
-
808
-	$post_date = ( $for_post ) ? $post->post_date : get_comment()->comment_date;
809
-	$jj        = ( $edit ) ? mysql2date( 'd', $post_date, false ) : current_time( 'd' );
810
-	$mm        = ( $edit ) ? mysql2date( 'm', $post_date, false ) : current_time( 'm' );
811
-	$aa        = ( $edit ) ? mysql2date( 'Y', $post_date, false ) : current_time( 'Y' );
812
-	$hh        = ( $edit ) ? mysql2date( 'H', $post_date, false ) : current_time( 'H' );
813
-	$mn        = ( $edit ) ? mysql2date( 'i', $post_date, false ) : current_time( 'i' );
814
-	$ss        = ( $edit ) ? mysql2date( 's', $post_date, false ) : current_time( 's' );
815
-
816
-	$cur_jj = current_time( 'd' );
817
-	$cur_mm = current_time( 'm' );
818
-	$cur_aa = current_time( 'Y' );
819
-	$cur_hh = current_time( 'H' );
820
-	$cur_mn = current_time( 'i' );
821
-
822
-	$month = '<label><span class="screen-reader-text">' . __( 'Month' ) . '</span><select class="form-required" ' . ( $multi ? '' : 'id="mm" ' ) . 'name="mm"' . $tab_index_attribute . ">\n";
823
-	for ( $i = 1; $i < 13; $i = $i + 1 ) {
824
-		$monthnum  = zeroise( $i, 2 );
825
-		$monthtext = $wp_locale->get_month_abbrev( $wp_locale->get_month( $i ) );
826
-		$month    .= "\t\t\t" . '<option value="' . $monthnum . '" data-text="' . $monthtext . '" ' . selected( $monthnum, $mm, false ) . '>';
827
-		/* translators: 1: Month number (01, 02, etc.), 2: Month abbreviation. */
828
-		$month .= sprintf( __( '%1$s-%2$s' ), $monthnum, $monthtext ) . "</option>\n";
829
-	}
830
-	$month .= '</select></label>';
831
-
832
-	$day    = '<label><span class="screen-reader-text">' . __( 'Day' ) . '</span><input type="text" ' . ( $multi ? '' : 'id="jj" ' ) . 'name="jj" value="' . $jj . '" size="2" maxlength="2"' . $tab_index_attribute . ' autocomplete="off" class="form-required" /></label>';
833
-	$year   = '<label><span class="screen-reader-text">' . __( 'Year' ) . '</span><input type="text" ' . ( $multi ? '' : 'id="aa" ' ) . 'name="aa" value="' . $aa . '" size="4" maxlength="4"' . $tab_index_attribute . ' autocomplete="off" class="form-required" /></label>';
834
-	$hour   = '<label><span class="screen-reader-text">' . __( 'Hour' ) . '</span><input type="text" ' . ( $multi ? '' : 'id="hh" ' ) . 'name="hh" value="' . $hh . '" size="2" maxlength="2"' . $tab_index_attribute . ' autocomplete="off" class="form-required" /></label>';
835
-	$minute = '<label><span class="screen-reader-text">' . __( 'Minute' ) . '</span><input type="text" ' . ( $multi ? '' : 'id="mn" ' ) . 'name="mn" value="' . $mn . '" size="2" maxlength="2"' . $tab_index_attribute . ' autocomplete="off" class="form-required" /></label>';
836
-
837
-	echo '<div class="timestamp-wrap">';
838
-	/* translators: 1: Month, 2: Day, 3: Year, 4: Hour, 5: Minute. */
839
-	printf( __( '%1$s %2$s, %3$s at %4$s:%5$s' ), $month, $day, $year, $hour, $minute );
840
-
841
-	echo '</div><input type="hidden" id="ss" name="ss" value="' . $ss . '" />';
842
-
843
-	if ( $multi ) {
844
-		return;
845
-	}
846
-
847
-	echo "\n\n";
848
-
849
-	$map = array(
850
-		'mm' => array( $mm, $cur_mm ),
851
-		'jj' => array( $jj, $cur_jj ),
852
-		'aa' => array( $aa, $cur_aa ),
853
-		'hh' => array( $hh, $cur_hh ),
854
-		'mn' => array( $mn, $cur_mn ),
855
-	);
856
-
857
-	foreach ( $map as $timeunit => $value ) {
858
-		list( $unit, $curr ) = $value;
859
-
860
-		echo '<input type="hidden" id="hidden_' . $timeunit . '" name="hidden_' . $timeunit . '" value="' . $unit . '" />' . "\n";
861
-		$cur_timeunit = 'cur_' . $timeunit;
862
-		echo '<input type="hidden" id="' . $cur_timeunit . '" name="' . $cur_timeunit . '" value="' . $curr . '" />' . "\n";
863
-	}
864
-	?>
793
+    global $wp_locale;
794
+    $post = get_post();
795
+
796
+    if ( $for_post ) {
797
+        $edit = ! ( in_array( $post->post_status, array( 'draft', 'pending' ), true ) && ( ! $post->post_date_gmt || '0000-00-00 00:00:00' === $post->post_date_gmt ) );
798
+    }
799
+
800
+    $tab_index_attribute = '';
801
+    if ( (int) $tab_index > 0 ) {
802
+        $tab_index_attribute = " tabindex=\"$tab_index\"";
803
+    }
804
+
805
+    // @todo Remove this?
806
+    // echo '<label for="timestamp" style="display: block;"><input type="checkbox" class="checkbox" name="edit_date" value="1" id="timestamp"'.$tab_index_attribute.' /> '.__( 'Edit timestamp' ).'</label><br />';
807
+
808
+    $post_date = ( $for_post ) ? $post->post_date : get_comment()->comment_date;
809
+    $jj        = ( $edit ) ? mysql2date( 'd', $post_date, false ) : current_time( 'd' );
810
+    $mm        = ( $edit ) ? mysql2date( 'm', $post_date, false ) : current_time( 'm' );
811
+    $aa        = ( $edit ) ? mysql2date( 'Y', $post_date, false ) : current_time( 'Y' );
812
+    $hh        = ( $edit ) ? mysql2date( 'H', $post_date, false ) : current_time( 'H' );
813
+    $mn        = ( $edit ) ? mysql2date( 'i', $post_date, false ) : current_time( 'i' );
814
+    $ss        = ( $edit ) ? mysql2date( 's', $post_date, false ) : current_time( 's' );
815
+
816
+    $cur_jj = current_time( 'd' );
817
+    $cur_mm = current_time( 'm' );
818
+    $cur_aa = current_time( 'Y' );
819
+    $cur_hh = current_time( 'H' );
820
+    $cur_mn = current_time( 'i' );
821
+
822
+    $month = '<label><span class="screen-reader-text">' . __( 'Month' ) . '</span><select class="form-required" ' . ( $multi ? '' : 'id="mm" ' ) . 'name="mm"' . $tab_index_attribute . ">\n";
823
+    for ( $i = 1; $i < 13; $i = $i + 1 ) {
824
+        $monthnum  = zeroise( $i, 2 );
825
+        $monthtext = $wp_locale->get_month_abbrev( $wp_locale->get_month( $i ) );
826
+        $month    .= "\t\t\t" . '<option value="' . $monthnum . '" data-text="' . $monthtext . '" ' . selected( $monthnum, $mm, false ) . '>';
827
+        /* translators: 1: Month number (01, 02, etc.), 2: Month abbreviation. */
828
+        $month .= sprintf( __( '%1$s-%2$s' ), $monthnum, $monthtext ) . "</option>\n";
829
+    }
830
+    $month .= '</select></label>';
831
+
832
+    $day    = '<label><span class="screen-reader-text">' . __( 'Day' ) . '</span><input type="text" ' . ( $multi ? '' : 'id="jj" ' ) . 'name="jj" value="' . $jj . '" size="2" maxlength="2"' . $tab_index_attribute . ' autocomplete="off" class="form-required" /></label>';
833
+    $year   = '<label><span class="screen-reader-text">' . __( 'Year' ) . '</span><input type="text" ' . ( $multi ? '' : 'id="aa" ' ) . 'name="aa" value="' . $aa . '" size="4" maxlength="4"' . $tab_index_attribute . ' autocomplete="off" class="form-required" /></label>';
834
+    $hour   = '<label><span class="screen-reader-text">' . __( 'Hour' ) . '</span><input type="text" ' . ( $multi ? '' : 'id="hh" ' ) . 'name="hh" value="' . $hh . '" size="2" maxlength="2"' . $tab_index_attribute . ' autocomplete="off" class="form-required" /></label>';
835
+    $minute = '<label><span class="screen-reader-text">' . __( 'Minute' ) . '</span><input type="text" ' . ( $multi ? '' : 'id="mn" ' ) . 'name="mn" value="' . $mn . '" size="2" maxlength="2"' . $tab_index_attribute . ' autocomplete="off" class="form-required" /></label>';
836
+
837
+    echo '<div class="timestamp-wrap">';
838
+    /* translators: 1: Month, 2: Day, 3: Year, 4: Hour, 5: Minute. */
839
+    printf( __( '%1$s %2$s, %3$s at %4$s:%5$s' ), $month, $day, $year, $hour, $minute );
840
+
841
+    echo '</div><input type="hidden" id="ss" name="ss" value="' . $ss . '" />';
842
+
843
+    if ( $multi ) {
844
+        return;
845
+    }
846
+
847
+    echo "\n\n";
848
+
849
+    $map = array(
850
+        'mm' => array( $mm, $cur_mm ),
851
+        'jj' => array( $jj, $cur_jj ),
852
+        'aa' => array( $aa, $cur_aa ),
853
+        'hh' => array( $hh, $cur_hh ),
854
+        'mn' => array( $mn, $cur_mn ),
855
+    );
856
+
857
+    foreach ( $map as $timeunit => $value ) {
858
+        list( $unit, $curr ) = $value;
859
+
860
+        echo '<input type="hidden" id="hidden_' . $timeunit . '" name="hidden_' . $timeunit . '" value="' . $unit . '" />' . "\n";
861
+        $cur_timeunit = 'cur_' . $timeunit;
862
+        echo '<input type="hidden" id="' . $cur_timeunit . '" name="' . $cur_timeunit . '" value="' . $curr . '" />' . "\n";
863
+    }
864
+    ?>
865 865
 
866 866
 <p>
867 867
 <a href="#edit_timestamp" class="save-timestamp hide-if-no-js button"><?php _e( 'OK' ); ?></a>
@@ -880,14 +880,14 @@  discard block
 block discarded – undo
880 880
  * @param string $post_type        Optional. Post type to get templates for. Default 'post'.
881 881
  */
882 882
 function page_template_dropdown( $default_template = '', $post_type = 'page' ) {
883
-	$templates = get_page_templates( null, $post_type );
883
+    $templates = get_page_templates( null, $post_type );
884 884
 
885
-	ksort( $templates );
885
+    ksort( $templates );
886 886
 
887
-	foreach ( array_keys( $templates ) as $template ) {
888
-		$selected = selected( $default_template, $templates[ $template ], false );
889
-		echo "\n\t<option value='" . esc_attr( $templates[ $template ] ) . "' $selected>" . esc_html( $template ) . '</option>';
890
-	}
887
+    foreach ( array_keys( $templates ) as $template ) {
888
+        $selected = selected( $default_template, $templates[ $template ], false );
889
+        echo "\n\t<option value='" . esc_attr( $templates[ $template ] ) . "' $selected>" . esc_html( $template ) . '</option>';
890
+    }
891 891
 }
892 892
 
893 893
 /**
@@ -905,27 +905,27 @@  discard block
 block discarded – undo
905 905
  * @return void|false Void on success, false if the page has no children.
906 906
  */
907 907
 function parent_dropdown( $default_page = 0, $parent = 0, $level = 0, $post = null ) {
908
-	global $wpdb;
909
-
910
-	$post  = get_post( $post );
911
-	$items = $wpdb->get_results( $wpdb->prepare( "SELECT ID, post_parent, post_title FROM $wpdb->posts WHERE post_parent = %d AND post_type = 'page' ORDER BY menu_order", $parent ) );
912
-
913
-	if ( $items ) {
914
-		foreach ( $items as $item ) {
915
-			// A page cannot be its own parent.
916
-			if ( $post && $post->ID && (int) $item->ID === $post->ID ) {
917
-				continue;
918
-			}
919
-
920
-			$pad      = str_repeat( '&nbsp;', $level * 3 );
921
-			$selected = selected( $default_page, $item->ID, false );
922
-
923
-			echo "\n\t<option class='level-$level' value='$item->ID' $selected>$pad " . esc_html( $item->post_title ) . '</option>';
924
-			parent_dropdown( $default_page, $item->ID, $level + 1 );
925
-		}
926
-	} else {
927
-		return false;
928
-	}
908
+    global $wpdb;
909
+
910
+    $post  = get_post( $post );
911
+    $items = $wpdb->get_results( $wpdb->prepare( "SELECT ID, post_parent, post_title FROM $wpdb->posts WHERE post_parent = %d AND post_type = 'page' ORDER BY menu_order", $parent ) );
912
+
913
+    if ( $items ) {
914
+        foreach ( $items as $item ) {
915
+            // A page cannot be its own parent.
916
+            if ( $post && $post->ID && (int) $item->ID === $post->ID ) {
917
+                continue;
918
+            }
919
+
920
+            $pad      = str_repeat( '&nbsp;', $level * 3 );
921
+            $selected = selected( $default_page, $item->ID, false );
922
+
923
+            echo "\n\t<option class='level-$level' value='$item->ID' $selected>$pad " . esc_html( $item->post_title ) . '</option>';
924
+            parent_dropdown( $default_page, $item->ID, $level + 1 );
925
+        }
926
+    } else {
927
+        return false;
928
+    }
929 929
 }
930 930
 
931 931
 /**
@@ -936,21 +936,21 @@  discard block
 block discarded – undo
936 936
  * @param string $selected Slug for the role that should be already selected.
937 937
  */
938 938
 function wp_dropdown_roles( $selected = '' ) {
939
-	$r = '';
939
+    $r = '';
940 940
 
941
-	$editable_roles = array_reverse( get_editable_roles() );
941
+    $editable_roles = array_reverse( get_editable_roles() );
942 942
 
943
-	foreach ( $editable_roles as $role => $details ) {
944
-		$name = translate_user_role( $details['name'] );
945
-		// Preselect specified role.
946
-		if ( $selected === $role ) {
947
-			$r .= "\n\t<option selected='selected' value='" . esc_attr( $role ) . "'>$name</option>";
948
-		} else {
949
-			$r .= "\n\t<option value='" . esc_attr( $role ) . "'>$name</option>";
950
-		}
951
-	}
943
+    foreach ( $editable_roles as $role => $details ) {
944
+        $name = translate_user_role( $details['name'] );
945
+        // Preselect specified role.
946
+        if ( $selected === $role ) {
947
+            $r .= "\n\t<option selected='selected' value='" . esc_attr( $role ) . "'>$name</option>";
948
+        } else {
949
+            $r .= "\n\t<option value='" . esc_attr( $role ) . "'>$name</option>";
950
+        }
951
+    }
952 952
 
953
-	echo $r;
953
+    echo $r;
954 954
 }
955 955
 
956 956
 /**
@@ -962,35 +962,35 @@  discard block
 block discarded – undo
962 962
  */
963 963
 function wp_import_upload_form( $action ) {
964 964
 
965
-	/**
966
-	 * Filters the maximum allowed upload size for import files.
967
-	 *
968
-	 * @since 2.3.0
969
-	 *
970
-	 * @see wp_max_upload_size()
971
-	 *
972
-	 * @param int $max_upload_size Allowed upload size. Default 1 MB.
973
-	 */
974
-	$bytes      = apply_filters( 'import_upload_size_limit', wp_max_upload_size() );
975
-	$size       = size_format( $bytes );
976
-	$upload_dir = wp_upload_dir();
977
-	if ( ! empty( $upload_dir['error'] ) ) :
978
-		?>
965
+    /**
966
+     * Filters the maximum allowed upload size for import files.
967
+     *
968
+     * @since 2.3.0
969
+     *
970
+     * @see wp_max_upload_size()
971
+     *
972
+     * @param int $max_upload_size Allowed upload size. Default 1 MB.
973
+     */
974
+    $bytes      = apply_filters( 'import_upload_size_limit', wp_max_upload_size() );
975
+    $size       = size_format( $bytes );
976
+    $upload_dir = wp_upload_dir();
977
+    if ( ! empty( $upload_dir['error'] ) ) :
978
+        ?>
979 979
 		<div class="error"><p><?php _e( 'Before you can upload your import file, you will need to fix the following error:' ); ?></p>
980 980
 		<p><strong><?php echo $upload_dir['error']; ?></strong></p></div>
981 981
 		<?php
982
-	else :
983
-		?>
982
+    else :
983
+        ?>
984 984
 <form enctype="multipart/form-data" id="import-upload-form" method="post" class="wp-upload-form" action="<?php echo esc_url( wp_nonce_url( $action, 'import-upload' ) ); ?>">
985 985
 <p>
986 986
 		<?php
987
-		printf(
988
-			'<label for="upload">%s</label> (%s)',
989
-			__( 'Choose a file from your computer:' ),
990
-			/* translators: %s: Maximum allowed file size. */
991
-			sprintf( __( 'Maximum size: %s' ), $size )
992
-		);
993
-		?>
987
+        printf(
988
+            '<label for="upload">%s</label> (%s)',
989
+            __( 'Choose a file from your computer:' ),
990
+            /* translators: %s: Maximum allowed file size. */
991
+            sprintf( __( 'Maximum size: %s' ), $size )
992
+        );
993
+        ?>
994 994
 <input type="file" id="upload" name="import" size="25" />
995 995
 <input type="hidden" name="action" value="save" />
996 996
 <input type="hidden" name="max_file_size" value="<?php echo $bytes; ?>" />
@@ -998,7 +998,7 @@  discard block
 block discarded – undo
998 998
 		<?php submit_button( __( 'Upload file and import' ), 'primary' ); ?>
999 999
 </form>
1000 1000
 		<?php
1001
-	endif;
1001
+    endif;
1002 1002
 }
1003 1003
 
1004 1004
 /**
@@ -1033,94 +1033,94 @@  discard block
 block discarded – undo
1033 1033
  *                                              to your callback). Default null.
1034 1034
  */
1035 1035
 function add_meta_box( $id, $title, $callback, $screen = null, $context = 'advanced', $priority = 'default', $callback_args = null ) {
1036
-	global $wp_meta_boxes;
1037
-
1038
-	if ( empty( $screen ) ) {
1039
-		$screen = get_current_screen();
1040
-	} elseif ( is_string( $screen ) ) {
1041
-		$screen = convert_to_screen( $screen );
1042
-	} elseif ( is_array( $screen ) ) {
1043
-		foreach ( $screen as $single_screen ) {
1044
-			add_meta_box( $id, $title, $callback, $single_screen, $context, $priority, $callback_args );
1045
-		}
1046
-	}
1047
-
1048
-	if ( ! isset( $screen->id ) ) {
1049
-		return;
1050
-	}
1051
-
1052
-	$page = $screen->id;
1053
-
1054
-	if ( ! isset( $wp_meta_boxes ) ) {
1055
-		$wp_meta_boxes = array();
1056
-	}
1057
-	if ( ! isset( $wp_meta_boxes[ $page ] ) ) {
1058
-		$wp_meta_boxes[ $page ] = array();
1059
-	}
1060
-	if ( ! isset( $wp_meta_boxes[ $page ][ $context ] ) ) {
1061
-		$wp_meta_boxes[ $page ][ $context ] = array();
1062
-	}
1063
-
1064
-	foreach ( array_keys( $wp_meta_boxes[ $page ] ) as $a_context ) {
1065
-		foreach ( array( 'high', 'core', 'default', 'low' ) as $a_priority ) {
1066
-			if ( ! isset( $wp_meta_boxes[ $page ][ $a_context ][ $a_priority ][ $id ] ) ) {
1067
-				continue;
1068
-			}
1069
-
1070
-			// If a core box was previously removed, don't add.
1071
-			if ( ( 'core' === $priority || 'sorted' === $priority )
1072
-				&& false === $wp_meta_boxes[ $page ][ $a_context ][ $a_priority ][ $id ]
1073
-			) {
1074
-				return;
1075
-			}
1076
-
1077
-			// If a core box was previously added by a plugin, don't add.
1078
-			if ( 'core' === $priority ) {
1079
-				/*
1036
+    global $wp_meta_boxes;
1037
+
1038
+    if ( empty( $screen ) ) {
1039
+        $screen = get_current_screen();
1040
+    } elseif ( is_string( $screen ) ) {
1041
+        $screen = convert_to_screen( $screen );
1042
+    } elseif ( is_array( $screen ) ) {
1043
+        foreach ( $screen as $single_screen ) {
1044
+            add_meta_box( $id, $title, $callback, $single_screen, $context, $priority, $callback_args );
1045
+        }
1046
+    }
1047
+
1048
+    if ( ! isset( $screen->id ) ) {
1049
+        return;
1050
+    }
1051
+
1052
+    $page = $screen->id;
1053
+
1054
+    if ( ! isset( $wp_meta_boxes ) ) {
1055
+        $wp_meta_boxes = array();
1056
+    }
1057
+    if ( ! isset( $wp_meta_boxes[ $page ] ) ) {
1058
+        $wp_meta_boxes[ $page ] = array();
1059
+    }
1060
+    if ( ! isset( $wp_meta_boxes[ $page ][ $context ] ) ) {
1061
+        $wp_meta_boxes[ $page ][ $context ] = array();
1062
+    }
1063
+
1064
+    foreach ( array_keys( $wp_meta_boxes[ $page ] ) as $a_context ) {
1065
+        foreach ( array( 'high', 'core', 'default', 'low' ) as $a_priority ) {
1066
+            if ( ! isset( $wp_meta_boxes[ $page ][ $a_context ][ $a_priority ][ $id ] ) ) {
1067
+                continue;
1068
+            }
1069
+
1070
+            // If a core box was previously removed, don't add.
1071
+            if ( ( 'core' === $priority || 'sorted' === $priority )
1072
+                && false === $wp_meta_boxes[ $page ][ $a_context ][ $a_priority ][ $id ]
1073
+            ) {
1074
+                return;
1075
+            }
1076
+
1077
+            // If a core box was previously added by a plugin, don't add.
1078
+            if ( 'core' === $priority ) {
1079
+                /*
1080 1080
 				 * If the box was added with default priority, give it core priority
1081 1081
 				 * to maintain sort order.
1082 1082
 				 */
1083
-				if ( 'default' === $a_priority ) {
1084
-					$wp_meta_boxes[ $page ][ $a_context ]['core'][ $id ] = $wp_meta_boxes[ $page ][ $a_context ]['default'][ $id ];
1085
-					unset( $wp_meta_boxes[ $page ][ $a_context ]['default'][ $id ] );
1086
-				}
1087
-				return;
1088
-			}
1089
-
1090
-			// If no priority given and ID already present, use existing priority.
1091
-			if ( empty( $priority ) ) {
1092
-				$priority = $a_priority;
1093
-				/*
1083
+                if ( 'default' === $a_priority ) {
1084
+                    $wp_meta_boxes[ $page ][ $a_context ]['core'][ $id ] = $wp_meta_boxes[ $page ][ $a_context ]['default'][ $id ];
1085
+                    unset( $wp_meta_boxes[ $page ][ $a_context ]['default'][ $id ] );
1086
+                }
1087
+                return;
1088
+            }
1089
+
1090
+            // If no priority given and ID already present, use existing priority.
1091
+            if ( empty( $priority ) ) {
1092
+                $priority = $a_priority;
1093
+                /*
1094 1094
 				 * Else, if we're adding to the sorted priority, we don't know the title
1095 1095
 				 * or callback. Grab them from the previously added context/priority.
1096 1096
 				 */
1097
-			} elseif ( 'sorted' === $priority ) {
1098
-				$title         = $wp_meta_boxes[ $page ][ $a_context ][ $a_priority ][ $id ]['title'];
1099
-				$callback      = $wp_meta_boxes[ $page ][ $a_context ][ $a_priority ][ $id ]['callback'];
1100
-				$callback_args = $wp_meta_boxes[ $page ][ $a_context ][ $a_priority ][ $id ]['args'];
1101
-			}
1102
-
1103
-			// An ID can be in only one priority and one context.
1104
-			if ( $priority !== $a_priority || $context !== $a_context ) {
1105
-				unset( $wp_meta_boxes[ $page ][ $a_context ][ $a_priority ][ $id ] );
1106
-			}
1107
-		}
1108
-	}
1109
-
1110
-	if ( empty( $priority ) ) {
1111
-		$priority = 'low';
1112
-	}
1113
-
1114
-	if ( ! isset( $wp_meta_boxes[ $page ][ $context ][ $priority ] ) ) {
1115
-		$wp_meta_boxes[ $page ][ $context ][ $priority ] = array();
1116
-	}
1117
-
1118
-	$wp_meta_boxes[ $page ][ $context ][ $priority ][ $id ] = array(
1119
-		'id'       => $id,
1120
-		'title'    => $title,
1121
-		'callback' => $callback,
1122
-		'args'     => $callback_args,
1123
-	);
1097
+            } elseif ( 'sorted' === $priority ) {
1098
+                $title         = $wp_meta_boxes[ $page ][ $a_context ][ $a_priority ][ $id ]['title'];
1099
+                $callback      = $wp_meta_boxes[ $page ][ $a_context ][ $a_priority ][ $id ]['callback'];
1100
+                $callback_args = $wp_meta_boxes[ $page ][ $a_context ][ $a_priority ][ $id ]['args'];
1101
+            }
1102
+
1103
+            // An ID can be in only one priority and one context.
1104
+            if ( $priority !== $a_priority || $context !== $a_context ) {
1105
+                unset( $wp_meta_boxes[ $page ][ $a_context ][ $a_priority ][ $id ] );
1106
+            }
1107
+        }
1108
+    }
1109
+
1110
+    if ( empty( $priority ) ) {
1111
+        $priority = 'low';
1112
+    }
1113
+
1114
+    if ( ! isset( $wp_meta_boxes[ $page ][ $context ][ $priority ] ) ) {
1115
+        $wp_meta_boxes[ $page ][ $context ][ $priority ] = array();
1116
+    }
1117
+
1118
+    $wp_meta_boxes[ $page ][ $context ][ $priority ][ $id ] = array(
1119
+        'id'       => $id,
1120
+        'title'    => $title,
1121
+        'callback' => $callback,
1122
+        'args'     => $callback_args,
1123
+    );
1124 1124
 }
1125 1125
 
1126 1126
 
@@ -1141,54 +1141,54 @@  discard block
 block discarded – undo
1141 1141
  * }
1142 1142
  */
1143 1143
 function do_block_editor_incompatible_meta_box( $data_object, $box ) {
1144
-	$plugin  = _get_plugin_from_callback( $box['old_callback'] );
1145
-	$plugins = get_plugins();
1146
-	echo '<p>';
1147
-	if ( $plugin ) {
1148
-		/* translators: %s: The name of the plugin that generated this meta box. */
1149
-		printf( __( 'This meta box, from the %s plugin, is not compatible with the block editor.' ), "<strong>{$plugin['Name']}</strong>" );
1150
-	} else {
1151
-		_e( 'This meta box is not compatible with the block editor.' );
1152
-	}
1153
-	echo '</p>';
1154
-
1155
-	if ( empty( $plugins['classic-editor/classic-editor.php'] ) ) {
1156
-		if ( current_user_can( 'install_plugins' ) ) {
1157
-			$install_url = wp_nonce_url(
1158
-				self_admin_url( 'plugin-install.php?tab=favorites&user=wordpressdotorg&save=0' ),
1159
-				'save_wporg_username_' . get_current_user_id()
1160
-			);
1161
-
1162
-			echo '<p>';
1163
-			/* translators: %s: A link to install the Classic Editor plugin. */
1164
-			printf( __( 'Please install the <a href="%s">Classic Editor plugin</a> to use this meta box.' ), esc_url( $install_url ) );
1165
-			echo '</p>';
1166
-		}
1167
-	} elseif ( is_plugin_inactive( 'classic-editor/classic-editor.php' ) ) {
1168
-		if ( current_user_can( 'activate_plugins' ) ) {
1169
-			$activate_url = wp_nonce_url(
1170
-				self_admin_url( 'plugins.php?action=activate&plugin=classic-editor/classic-editor.php' ),
1171
-				'activate-plugin_classic-editor/classic-editor.php'
1172
-			);
1173
-
1174
-			echo '<p>';
1175
-			/* translators: %s: A link to activate the Classic Editor plugin. */
1176
-			printf( __( 'Please activate the <a href="%s">Classic Editor plugin</a> to use this meta box.' ), esc_url( $activate_url ) );
1177
-			echo '</p>';
1178
-		}
1179
-	} elseif ( $data_object instanceof WP_Post ) {
1180
-		$edit_url = add_query_arg(
1181
-			array(
1182
-				'classic-editor'         => '',
1183
-				'classic-editor__forget' => '',
1184
-			),
1185
-			get_edit_post_link( $data_object )
1186
-		);
1187
-		echo '<p>';
1188
-		/* translators: %s: A link to use the Classic Editor plugin. */
1189
-		printf( __( 'Please open the <a href="%s">classic editor</a> to use this meta box.' ), esc_url( $edit_url ) );
1190
-		echo '</p>';
1191
-	}
1144
+    $plugin  = _get_plugin_from_callback( $box['old_callback'] );
1145
+    $plugins = get_plugins();
1146
+    echo '<p>';
1147
+    if ( $plugin ) {
1148
+        /* translators: %s: The name of the plugin that generated this meta box. */
1149
+        printf( __( 'This meta box, from the %s plugin, is not compatible with the block editor.' ), "<strong>{$plugin['Name']}</strong>" );
1150
+    } else {
1151
+        _e( 'This meta box is not compatible with the block editor.' );
1152
+    }
1153
+    echo '</p>';
1154
+
1155
+    if ( empty( $plugins['classic-editor/classic-editor.php'] ) ) {
1156
+        if ( current_user_can( 'install_plugins' ) ) {
1157
+            $install_url = wp_nonce_url(
1158
+                self_admin_url( 'plugin-install.php?tab=favorites&user=wordpressdotorg&save=0' ),
1159
+                'save_wporg_username_' . get_current_user_id()
1160
+            );
1161
+
1162
+            echo '<p>';
1163
+            /* translators: %s: A link to install the Classic Editor plugin. */
1164
+            printf( __( 'Please install the <a href="%s">Classic Editor plugin</a> to use this meta box.' ), esc_url( $install_url ) );
1165
+            echo '</p>';
1166
+        }
1167
+    } elseif ( is_plugin_inactive( 'classic-editor/classic-editor.php' ) ) {
1168
+        if ( current_user_can( 'activate_plugins' ) ) {
1169
+            $activate_url = wp_nonce_url(
1170
+                self_admin_url( 'plugins.php?action=activate&plugin=classic-editor/classic-editor.php' ),
1171
+                'activate-plugin_classic-editor/classic-editor.php'
1172
+            );
1173
+
1174
+            echo '<p>';
1175
+            /* translators: %s: A link to activate the Classic Editor plugin. */
1176
+            printf( __( 'Please activate the <a href="%s">Classic Editor plugin</a> to use this meta box.' ), esc_url( $activate_url ) );
1177
+            echo '</p>';
1178
+        }
1179
+    } elseif ( $data_object instanceof WP_Post ) {
1180
+        $edit_url = add_query_arg(
1181
+            array(
1182
+                'classic-editor'         => '',
1183
+                'classic-editor__forget' => '',
1184
+            ),
1185
+            get_edit_post_link( $data_object )
1186
+        );
1187
+        echo '<p>';
1188
+        /* translators: %s: A link to use the Classic Editor plugin. */
1189
+        printf( __( 'Please open the <a href="%s">classic editor</a> to use this meta box.' ), esc_url( $edit_url ) );
1190
+        echo '</p>';
1191
+    }
1192 1192
 }
1193 1193
 
1194 1194
 /**
@@ -1202,41 +1202,41 @@  discard block
 block discarded – undo
1202 1202
  * @return array|null The plugin that the callback belongs to, or null if it doesn't belong to a plugin.
1203 1203
  */
1204 1204
 function _get_plugin_from_callback( $callback ) {
1205
-	try {
1206
-		if ( is_array( $callback ) ) {
1207
-			$reflection = new ReflectionMethod( $callback[0], $callback[1] );
1208
-		} elseif ( is_string( $callback ) && false !== strpos( $callback, '::' ) ) {
1209
-			$reflection = new ReflectionMethod( $callback );
1210
-		} else {
1211
-			$reflection = new ReflectionFunction( $callback );
1212
-		}
1213
-	} catch ( ReflectionException $exception ) {
1214
-		// We could not properly reflect on the callable, so we abort here.
1215
-		return null;
1216
-	}
1217
-
1218
-	// Don't show an error if it's an internal PHP function.
1219
-	if ( ! $reflection->isInternal() ) {
1220
-
1221
-		// Only show errors if the meta box was registered by a plugin.
1222
-		$filename   = wp_normalize_path( $reflection->getFileName() );
1223
-		$plugin_dir = wp_normalize_path( WP_PLUGIN_DIR );
1224
-
1225
-		if ( strpos( $filename, $plugin_dir ) === 0 ) {
1226
-			$filename = str_replace( $plugin_dir, '', $filename );
1227
-			$filename = preg_replace( '|^/([^/]*/).*$|', '\\1', $filename );
1228
-
1229
-			$plugins = get_plugins();
1230
-
1231
-			foreach ( $plugins as $name => $plugin ) {
1232
-				if ( strpos( $name, $filename ) === 0 ) {
1233
-					return $plugin;
1234
-				}
1235
-			}
1236
-		}
1237
-	}
1238
-
1239
-	return null;
1205
+    try {
1206
+        if ( is_array( $callback ) ) {
1207
+            $reflection = new ReflectionMethod( $callback[0], $callback[1] );
1208
+        } elseif ( is_string( $callback ) && false !== strpos( $callback, '::' ) ) {
1209
+            $reflection = new ReflectionMethod( $callback );
1210
+        } else {
1211
+            $reflection = new ReflectionFunction( $callback );
1212
+        }
1213
+    } catch ( ReflectionException $exception ) {
1214
+        // We could not properly reflect on the callable, so we abort here.
1215
+        return null;
1216
+    }
1217
+
1218
+    // Don't show an error if it's an internal PHP function.
1219
+    if ( ! $reflection->isInternal() ) {
1220
+
1221
+        // Only show errors if the meta box was registered by a plugin.
1222
+        $filename   = wp_normalize_path( $reflection->getFileName() );
1223
+        $plugin_dir = wp_normalize_path( WP_PLUGIN_DIR );
1224
+
1225
+        if ( strpos( $filename, $plugin_dir ) === 0 ) {
1226
+            $filename = str_replace( $plugin_dir, '', $filename );
1227
+            $filename = preg_replace( '|^/([^/]*/).*$|', '\\1', $filename );
1228
+
1229
+            $plugins = get_plugins();
1230
+
1231
+            foreach ( $plugins as $name => $plugin ) {
1232
+                if ( strpos( $name, $filename ) === 0 ) {
1233
+                    return $plugin;
1234
+                }
1235
+            }
1236
+        }
1237
+    }
1238
+
1239
+    return null;
1240 1240
 }
1241 1241
 
1242 1242
 /**
@@ -1257,158 +1257,158 @@  discard block
 block discarded – undo
1257 1257
  * @return int Number of meta_boxes.
1258 1258
  */
1259 1259
 function do_meta_boxes( $screen, $context, $data_object ) {
1260
-	global $wp_meta_boxes;
1261
-	static $already_sorted = false;
1262
-
1263
-	if ( empty( $screen ) ) {
1264
-		$screen = get_current_screen();
1265
-	} elseif ( is_string( $screen ) ) {
1266
-		$screen = convert_to_screen( $screen );
1267
-	}
1268
-
1269
-	$page = $screen->id;
1270
-
1271
-	$hidden = get_hidden_meta_boxes( $screen );
1272
-
1273
-	printf( '<div id="%s-sortables" class="meta-box-sortables">', esc_attr( $context ) );
1274
-
1275
-	// Grab the ones the user has manually sorted.
1276
-	// Pull them out of their previous context/priority and into the one the user chose.
1277
-	$sorted = get_user_option( "meta-box-order_$page" );
1278
-
1279
-	if ( ! $already_sorted && $sorted ) {
1280
-		foreach ( $sorted as $box_context => $ids ) {
1281
-			foreach ( explode( ',', $ids ) as $id ) {
1282
-				if ( $id && 'dashboard_browser_nag' !== $id ) {
1283
-					add_meta_box( $id, null, null, $screen, $box_context, 'sorted' );
1284
-				}
1285
-			}
1286
-		}
1287
-	}
1288
-
1289
-	$already_sorted = true;
1290
-
1291
-	$i = 0;
1292
-
1293
-	if ( isset( $wp_meta_boxes[ $page ][ $context ] ) ) {
1294
-		foreach ( array( 'high', 'sorted', 'core', 'default', 'low' ) as $priority ) {
1295
-			if ( isset( $wp_meta_boxes[ $page ][ $context ][ $priority ] ) ) {
1296
-				foreach ( (array) $wp_meta_boxes[ $page ][ $context ][ $priority ] as $box ) {
1297
-					if ( false === $box || ! $box['title'] ) {
1298
-						continue;
1299
-					}
1300
-
1301
-					$block_compatible = true;
1302
-					if ( is_array( $box['args'] ) ) {
1303
-						// If a meta box is just here for back compat, don't show it in the block editor.
1304
-						if ( $screen->is_block_editor() && isset( $box['args']['__back_compat_meta_box'] ) && $box['args']['__back_compat_meta_box'] ) {
1305
-							continue;
1306
-						}
1307
-
1308
-						if ( isset( $box['args']['__block_editor_compatible_meta_box'] ) ) {
1309
-							$block_compatible = (bool) $box['args']['__block_editor_compatible_meta_box'];
1310
-							unset( $box['args']['__block_editor_compatible_meta_box'] );
1311
-						}
1312
-
1313
-						// If the meta box is declared as incompatible with the block editor, override the callback function.
1314
-						if ( ! $block_compatible && $screen->is_block_editor() ) {
1315
-							$box['old_callback'] = $box['callback'];
1316
-							$box['callback']     = 'do_block_editor_incompatible_meta_box';
1317
-						}
1318
-
1319
-						if ( isset( $box['args']['__back_compat_meta_box'] ) ) {
1320
-							$block_compatible = $block_compatible || (bool) $box['args']['__back_compat_meta_box'];
1321
-							unset( $box['args']['__back_compat_meta_box'] );
1322
-						}
1323
-					}
1324
-
1325
-					$i++;
1326
-					// get_hidden_meta_boxes() doesn't apply in the block editor.
1327
-					$hidden_class = ( ! $screen->is_block_editor() && in_array( $box['id'], $hidden, true ) ) ? ' hide-if-js' : '';
1328
-					echo '<div id="' . $box['id'] . '" class="postbox ' . postbox_classes( $box['id'], $page ) . $hidden_class . '" ' . '>' . "\n";
1329
-
1330
-					echo '<div class="postbox-header">';
1331
-					echo '<h2 class="hndle">';
1332
-					if ( 'dashboard_php_nag' === $box['id'] ) {
1333
-						echo '<span aria-hidden="true" class="dashicons dashicons-warning"></span>';
1334
-						echo '<span class="screen-reader-text">' . __( 'Warning:' ) . ' </span>';
1335
-					}
1336
-					echo $box['title'];
1337
-					echo "</h2>\n";
1338
-
1339
-					if ( 'dashboard_browser_nag' !== $box['id'] ) {
1340
-						$widget_title = $box['title'];
1341
-
1342
-						if ( is_array( $box['args'] ) && isset( $box['args']['__widget_basename'] ) ) {
1343
-							$widget_title = $box['args']['__widget_basename'];
1344
-							// Do not pass this parameter to the user callback function.
1345
-							unset( $box['args']['__widget_basename'] );
1346
-						}
1347
-
1348
-						echo '<div class="handle-actions hide-if-no-js">';
1349
-
1350
-						echo '<button type="button" class="handle-order-higher" aria-disabled="false" aria-describedby="' . $box['id'] . '-handle-order-higher-description">';
1351
-						echo '<span class="screen-reader-text">' . __( 'Move up' ) . '</span>';
1352
-						echo '<span class="order-higher-indicator" aria-hidden="true"></span>';
1353
-						echo '</button>';
1354
-						echo '<span class="hidden" id="' . $box['id'] . '-handle-order-higher-description">' . sprintf(
1355
-							/* translators: %s: Meta box title. */
1356
-							__( 'Move %s box up' ),
1357
-							$widget_title
1358
-						) . '</span>';
1359
-
1360
-						echo '<button type="button" class="handle-order-lower" aria-disabled="false" aria-describedby="' . $box['id'] . '-handle-order-lower-description">';
1361
-						echo '<span class="screen-reader-text">' . __( 'Move down' ) . '</span>';
1362
-						echo '<span class="order-lower-indicator" aria-hidden="true"></span>';
1363
-						echo '</button>';
1364
-						echo '<span class="hidden" id="' . $box['id'] . '-handle-order-lower-description">' . sprintf(
1365
-							/* translators: %s: Meta box title. */
1366
-							__( 'Move %s box down' ),
1367
-							$widget_title
1368
-						) . '</span>';
1369
-
1370
-						echo '<button type="button" class="handlediv" aria-expanded="true">';
1371
-						echo '<span class="screen-reader-text">' . sprintf(
1372
-							/* translators: %s: Meta box title. */
1373
-							__( 'Toggle panel: %s' ),
1374
-							$widget_title
1375
-						) . '</span>';
1376
-						echo '<span class="toggle-indicator" aria-hidden="true"></span>';
1377
-						echo '</button>';
1378
-
1379
-						echo '</div>';
1380
-					}
1381
-					echo '</div>';
1382
-
1383
-					echo '<div class="inside">' . "\n";
1384
-
1385
-					if ( WP_DEBUG && ! $block_compatible && 'edit' === $screen->parent_base && ! $screen->is_block_editor() && ! isset( $_GET['meta-box-loader'] ) ) {
1386
-						$plugin = _get_plugin_from_callback( $box['callback'] );
1387
-						if ( $plugin ) {
1388
-							?>
1260
+    global $wp_meta_boxes;
1261
+    static $already_sorted = false;
1262
+
1263
+    if ( empty( $screen ) ) {
1264
+        $screen = get_current_screen();
1265
+    } elseif ( is_string( $screen ) ) {
1266
+        $screen = convert_to_screen( $screen );
1267
+    }
1268
+
1269
+    $page = $screen->id;
1270
+
1271
+    $hidden = get_hidden_meta_boxes( $screen );
1272
+
1273
+    printf( '<div id="%s-sortables" class="meta-box-sortables">', esc_attr( $context ) );
1274
+
1275
+    // Grab the ones the user has manually sorted.
1276
+    // Pull them out of their previous context/priority and into the one the user chose.
1277
+    $sorted = get_user_option( "meta-box-order_$page" );
1278
+
1279
+    if ( ! $already_sorted && $sorted ) {
1280
+        foreach ( $sorted as $box_context => $ids ) {
1281
+            foreach ( explode( ',', $ids ) as $id ) {
1282
+                if ( $id && 'dashboard_browser_nag' !== $id ) {
1283
+                    add_meta_box( $id, null, null, $screen, $box_context, 'sorted' );
1284
+                }
1285
+            }
1286
+        }
1287
+    }
1288
+
1289
+    $already_sorted = true;
1290
+
1291
+    $i = 0;
1292
+
1293
+    if ( isset( $wp_meta_boxes[ $page ][ $context ] ) ) {
1294
+        foreach ( array( 'high', 'sorted', 'core', 'default', 'low' ) as $priority ) {
1295
+            if ( isset( $wp_meta_boxes[ $page ][ $context ][ $priority ] ) ) {
1296
+                foreach ( (array) $wp_meta_boxes[ $page ][ $context ][ $priority ] as $box ) {
1297
+                    if ( false === $box || ! $box['title'] ) {
1298
+                        continue;
1299
+                    }
1300
+
1301
+                    $block_compatible = true;
1302
+                    if ( is_array( $box['args'] ) ) {
1303
+                        // If a meta box is just here for back compat, don't show it in the block editor.
1304
+                        if ( $screen->is_block_editor() && isset( $box['args']['__back_compat_meta_box'] ) && $box['args']['__back_compat_meta_box'] ) {
1305
+                            continue;
1306
+                        }
1307
+
1308
+                        if ( isset( $box['args']['__block_editor_compatible_meta_box'] ) ) {
1309
+                            $block_compatible = (bool) $box['args']['__block_editor_compatible_meta_box'];
1310
+                            unset( $box['args']['__block_editor_compatible_meta_box'] );
1311
+                        }
1312
+
1313
+                        // If the meta box is declared as incompatible with the block editor, override the callback function.
1314
+                        if ( ! $block_compatible && $screen->is_block_editor() ) {
1315
+                            $box['old_callback'] = $box['callback'];
1316
+                            $box['callback']     = 'do_block_editor_incompatible_meta_box';
1317
+                        }
1318
+
1319
+                        if ( isset( $box['args']['__back_compat_meta_box'] ) ) {
1320
+                            $block_compatible = $block_compatible || (bool) $box['args']['__back_compat_meta_box'];
1321
+                            unset( $box['args']['__back_compat_meta_box'] );
1322
+                        }
1323
+                    }
1324
+
1325
+                    $i++;
1326
+                    // get_hidden_meta_boxes() doesn't apply in the block editor.
1327
+                    $hidden_class = ( ! $screen->is_block_editor() && in_array( $box['id'], $hidden, true ) ) ? ' hide-if-js' : '';
1328
+                    echo '<div id="' . $box['id'] . '" class="postbox ' . postbox_classes( $box['id'], $page ) . $hidden_class . '" ' . '>' . "\n";
1329
+
1330
+                    echo '<div class="postbox-header">';
1331
+                    echo '<h2 class="hndle">';
1332
+                    if ( 'dashboard_php_nag' === $box['id'] ) {
1333
+                        echo '<span aria-hidden="true" class="dashicons dashicons-warning"></span>';
1334
+                        echo '<span class="screen-reader-text">' . __( 'Warning:' ) . ' </span>';
1335
+                    }
1336
+                    echo $box['title'];
1337
+                    echo "</h2>\n";
1338
+
1339
+                    if ( 'dashboard_browser_nag' !== $box['id'] ) {
1340
+                        $widget_title = $box['title'];
1341
+
1342
+                        if ( is_array( $box['args'] ) && isset( $box['args']['__widget_basename'] ) ) {
1343
+                            $widget_title = $box['args']['__widget_basename'];
1344
+                            // Do not pass this parameter to the user callback function.
1345
+                            unset( $box['args']['__widget_basename'] );
1346
+                        }
1347
+
1348
+                        echo '<div class="handle-actions hide-if-no-js">';
1349
+
1350
+                        echo '<button type="button" class="handle-order-higher" aria-disabled="false" aria-describedby="' . $box['id'] . '-handle-order-higher-description">';
1351
+                        echo '<span class="screen-reader-text">' . __( 'Move up' ) . '</span>';
1352
+                        echo '<span class="order-higher-indicator" aria-hidden="true"></span>';
1353
+                        echo '</button>';
1354
+                        echo '<span class="hidden" id="' . $box['id'] . '-handle-order-higher-description">' . sprintf(
1355
+                            /* translators: %s: Meta box title. */
1356
+                            __( 'Move %s box up' ),
1357
+                            $widget_title
1358
+                        ) . '</span>';
1359
+
1360
+                        echo '<button type="button" class="handle-order-lower" aria-disabled="false" aria-describedby="' . $box['id'] . '-handle-order-lower-description">';
1361
+                        echo '<span class="screen-reader-text">' . __( 'Move down' ) . '</span>';
1362
+                        echo '<span class="order-lower-indicator" aria-hidden="true"></span>';
1363
+                        echo '</button>';
1364
+                        echo '<span class="hidden" id="' . $box['id'] . '-handle-order-lower-description">' . sprintf(
1365
+                            /* translators: %s: Meta box title. */
1366
+                            __( 'Move %s box down' ),
1367
+                            $widget_title
1368
+                        ) . '</span>';
1369
+
1370
+                        echo '<button type="button" class="handlediv" aria-expanded="true">';
1371
+                        echo '<span class="screen-reader-text">' . sprintf(
1372
+                            /* translators: %s: Meta box title. */
1373
+                            __( 'Toggle panel: %s' ),
1374
+                            $widget_title
1375
+                        ) . '</span>';
1376
+                        echo '<span class="toggle-indicator" aria-hidden="true"></span>';
1377
+                        echo '</button>';
1378
+
1379
+                        echo '</div>';
1380
+                    }
1381
+                    echo '</div>';
1382
+
1383
+                    echo '<div class="inside">' . "\n";
1384
+
1385
+                    if ( WP_DEBUG && ! $block_compatible && 'edit' === $screen->parent_base && ! $screen->is_block_editor() && ! isset( $_GET['meta-box-loader'] ) ) {
1386
+                        $plugin = _get_plugin_from_callback( $box['callback'] );
1387
+                        if ( $plugin ) {
1388
+                            ?>
1389 1389
 							<div class="error inline">
1390 1390
 								<p>
1391 1391
 									<?php
1392
-										/* translators: %s: The name of the plugin that generated this meta box. */
1393
-										printf( __( 'This meta box, from the %s plugin, is not compatible with the block editor.' ), "<strong>{$plugin['Name']}</strong>" );
1394
-									?>
1392
+                                        /* translators: %s: The name of the plugin that generated this meta box. */
1393
+                                        printf( __( 'This meta box, from the %s plugin, is not compatible with the block editor.' ), "<strong>{$plugin['Name']}</strong>" );
1394
+                                    ?>
1395 1395
 								</p>
1396 1396
 							</div>
1397 1397
 							<?php
1398
-						}
1399
-					}
1398
+                        }
1399
+                    }
1400 1400
 
1401
-					call_user_func( $box['callback'], $data_object, $box );
1402
-					echo "</div>\n";
1403
-					echo "</div>\n";
1404
-				}
1405
-			}
1406
-		}
1407
-	}
1401
+                    call_user_func( $box['callback'], $data_object, $box );
1402
+                    echo "</div>\n";
1403
+                    echo "</div>\n";
1404
+                }
1405
+            }
1406
+        }
1407
+    }
1408 1408
 
1409
-	echo '</div>';
1409
+    echo '</div>';
1410 1410
 
1411
-	return $i;
1411
+    return $i;
1412 1412
 
1413 1413
 }
1414 1414
 
@@ -1431,37 +1431,37 @@  discard block
 block discarded – undo
1431 1431
  *                                        all use the 'side' context.
1432 1432
  */
1433 1433
 function remove_meta_box( $id, $screen, $context ) {
1434
-	global $wp_meta_boxes;
1435
-
1436
-	if ( empty( $screen ) ) {
1437
-		$screen = get_current_screen();
1438
-	} elseif ( is_string( $screen ) ) {
1439
-		$screen = convert_to_screen( $screen );
1440
-	} elseif ( is_array( $screen ) ) {
1441
-		foreach ( $screen as $single_screen ) {
1442
-			remove_meta_box( $id, $single_screen, $context );
1443
-		}
1444
-	}
1445
-
1446
-	if ( ! isset( $screen->id ) ) {
1447
-		return;
1448
-	}
1449
-
1450
-	$page = $screen->id;
1451
-
1452
-	if ( ! isset( $wp_meta_boxes ) ) {
1453
-		$wp_meta_boxes = array();
1454
-	}
1455
-	if ( ! isset( $wp_meta_boxes[ $page ] ) ) {
1456
-		$wp_meta_boxes[ $page ] = array();
1457
-	}
1458
-	if ( ! isset( $wp_meta_boxes[ $page ][ $context ] ) ) {
1459
-		$wp_meta_boxes[ $page ][ $context ] = array();
1460
-	}
1461
-
1462
-	foreach ( array( 'high', 'core', 'default', 'low' ) as $priority ) {
1463
-		$wp_meta_boxes[ $page ][ $context ][ $priority ][ $id ] = false;
1464
-	}
1434
+    global $wp_meta_boxes;
1435
+
1436
+    if ( empty( $screen ) ) {
1437
+        $screen = get_current_screen();
1438
+    } elseif ( is_string( $screen ) ) {
1439
+        $screen = convert_to_screen( $screen );
1440
+    } elseif ( is_array( $screen ) ) {
1441
+        foreach ( $screen as $single_screen ) {
1442
+            remove_meta_box( $id, $single_screen, $context );
1443
+        }
1444
+    }
1445
+
1446
+    if ( ! isset( $screen->id ) ) {
1447
+        return;
1448
+    }
1449
+
1450
+    $page = $screen->id;
1451
+
1452
+    if ( ! isset( $wp_meta_boxes ) ) {
1453
+        $wp_meta_boxes = array();
1454
+    }
1455
+    if ( ! isset( $wp_meta_boxes[ $page ] ) ) {
1456
+        $wp_meta_boxes[ $page ] = array();
1457
+    }
1458
+    if ( ! isset( $wp_meta_boxes[ $page ][ $context ] ) ) {
1459
+        $wp_meta_boxes[ $page ][ $context ] = array();
1460
+    }
1461
+
1462
+    foreach ( array( 'high', 'core', 'default', 'low' ) as $priority ) {
1463
+        $wp_meta_boxes[ $page ][ $context ][ $priority ][ $id ] = false;
1464
+    }
1465 1465
 }
1466 1466
 
1467 1467
 /**
@@ -1481,43 +1481,43 @@  discard block
 block discarded – undo
1481 1481
  * @return int Number of meta boxes as accordion sections.
1482 1482
  */
1483 1483
 function do_accordion_sections( $screen, $context, $data_object ) {
1484
-	global $wp_meta_boxes;
1484
+    global $wp_meta_boxes;
1485 1485
 
1486
-	wp_enqueue_script( 'accordion' );
1486
+    wp_enqueue_script( 'accordion' );
1487 1487
 
1488
-	if ( empty( $screen ) ) {
1489
-		$screen = get_current_screen();
1490
-	} elseif ( is_string( $screen ) ) {
1491
-		$screen = convert_to_screen( $screen );
1492
-	}
1488
+    if ( empty( $screen ) ) {
1489
+        $screen = get_current_screen();
1490
+    } elseif ( is_string( $screen ) ) {
1491
+        $screen = convert_to_screen( $screen );
1492
+    }
1493 1493
 
1494
-	$page = $screen->id;
1494
+    $page = $screen->id;
1495 1495
 
1496
-	$hidden = get_hidden_meta_boxes( $screen );
1497
-	?>
1496
+    $hidden = get_hidden_meta_boxes( $screen );
1497
+    ?>
1498 1498
 	<div id="side-sortables" class="accordion-container">
1499 1499
 		<ul class="outer-border">
1500 1500
 	<?php
1501
-	$i          = 0;
1502
-	$first_open = false;
1503
-
1504
-	if ( isset( $wp_meta_boxes[ $page ][ $context ] ) ) {
1505
-		foreach ( array( 'high', 'core', 'default', 'low' ) as $priority ) {
1506
-			if ( isset( $wp_meta_boxes[ $page ][ $context ][ $priority ] ) ) {
1507
-				foreach ( $wp_meta_boxes[ $page ][ $context ][ $priority ] as $box ) {
1508
-					if ( false === $box || ! $box['title'] ) {
1509
-						continue;
1510
-					}
1511
-
1512
-					$i++;
1513
-					$hidden_class = in_array( $box['id'], $hidden, true ) ? 'hide-if-js' : '';
1514
-
1515
-					$open_class = '';
1516
-					if ( ! $first_open && empty( $hidden_class ) ) {
1517
-						$first_open = true;
1518
-						$open_class = 'open';
1519
-					}
1520
-					?>
1501
+    $i          = 0;
1502
+    $first_open = false;
1503
+
1504
+    if ( isset( $wp_meta_boxes[ $page ][ $context ] ) ) {
1505
+        foreach ( array( 'high', 'core', 'default', 'low' ) as $priority ) {
1506
+            if ( isset( $wp_meta_boxes[ $page ][ $context ][ $priority ] ) ) {
1507
+                foreach ( $wp_meta_boxes[ $page ][ $context ][ $priority ] as $box ) {
1508
+                    if ( false === $box || ! $box['title'] ) {
1509
+                        continue;
1510
+                    }
1511
+
1512
+                    $i++;
1513
+                    $hidden_class = in_array( $box['id'], $hidden, true ) ? 'hide-if-js' : '';
1514
+
1515
+                    $open_class = '';
1516
+                    if ( ! $first_open && empty( $hidden_class ) ) {
1517
+                        $first_open = true;
1518
+                        $open_class = 'open';
1519
+                    }
1520
+                    ?>
1521 1521
 					<li class="control-section accordion-section <?php echo $hidden_class; ?> <?php echo $open_class; ?> <?php echo esc_attr( $box['id'] ); ?>" id="<?php echo esc_attr( $box['id'] ); ?>">
1522 1522
 						<h3 class="accordion-section-title hndle" tabindex="0">
1523 1523
 							<?php echo esc_html( $box['title'] ); ?>
@@ -1530,15 +1530,15 @@  discard block
 block discarded – undo
1530 1530
 						</div><!-- .accordion-section-content -->
1531 1531
 					</li><!-- .accordion-section -->
1532 1532
 					<?php
1533
-				}
1534
-			}
1535
-		}
1536
-	}
1537
-	?>
1533
+                }
1534
+            }
1535
+        }
1536
+    }
1537
+    ?>
1538 1538
 		</ul><!-- .outer-border -->
1539 1539
 	</div><!-- .accordion-container -->
1540 1540
 	<?php
1541
-	return $i;
1541
+    return $i;
1542 1542
 }
1543 1543
 
1544 1544
 /**
@@ -1564,39 +1564,39 @@  discard block
 block discarded – undo
1564 1564
  *                           add_options_page();
1565 1565
  */
1566 1566
 function add_settings_section( $id, $title, $callback, $page ) {
1567
-	global $wp_settings_sections;
1568
-
1569
-	if ( 'misc' === $page ) {
1570
-		_deprecated_argument(
1571
-			__FUNCTION__,
1572
-			'3.0.0',
1573
-			sprintf(
1574
-				/* translators: %s: misc */
1575
-				__( 'The "%s" options group has been removed. Use another settings group.' ),
1576
-				'misc'
1577
-			)
1578
-		);
1579
-		$page = 'general';
1580
-	}
1581
-
1582
-	if ( 'privacy' === $page ) {
1583
-		_deprecated_argument(
1584
-			__FUNCTION__,
1585
-			'3.5.0',
1586
-			sprintf(
1587
-				/* translators: %s: privacy */
1588
-				__( 'The "%s" options group has been removed. Use another settings group.' ),
1589
-				'privacy'
1590
-			)
1591
-		);
1592
-		$page = 'reading';
1593
-	}
1594
-
1595
-	$wp_settings_sections[ $page ][ $id ] = array(
1596
-		'id'       => $id,
1597
-		'title'    => $title,
1598
-		'callback' => $callback,
1599
-	);
1567
+    global $wp_settings_sections;
1568
+
1569
+    if ( 'misc' === $page ) {
1570
+        _deprecated_argument(
1571
+            __FUNCTION__,
1572
+            '3.0.0',
1573
+            sprintf(
1574
+                /* translators: %s: misc */
1575
+                __( 'The "%s" options group has been removed. Use another settings group.' ),
1576
+                'misc'
1577
+            )
1578
+        );
1579
+        $page = 'general';
1580
+    }
1581
+
1582
+    if ( 'privacy' === $page ) {
1583
+        _deprecated_argument(
1584
+            __FUNCTION__,
1585
+            '3.5.0',
1586
+            sprintf(
1587
+                /* translators: %s: privacy */
1588
+                __( 'The "%s" options group has been removed. Use another settings group.' ),
1589
+                'privacy'
1590
+            )
1591
+        );
1592
+        $page = 'reading';
1593
+    }
1594
+
1595
+    $wp_settings_sections[ $page ][ $id ] = array(
1596
+        'id'       => $id,
1597
+        'title'    => $title,
1598
+        'callback' => $callback,
1599
+    );
1600 1600
 }
1601 1601
 
1602 1602
 /**
@@ -1635,40 +1635,40 @@  discard block
 block discarded – undo
1635 1635
  * }
1636 1636
  */
1637 1637
 function add_settings_field( $id, $title, $callback, $page, $section = 'default', $args = array() ) {
1638
-	global $wp_settings_fields;
1639
-
1640
-	if ( 'misc' === $page ) {
1641
-		_deprecated_argument(
1642
-			__FUNCTION__,
1643
-			'3.0.0',
1644
-			sprintf(
1645
-				/* translators: %s: misc */
1646
-				__( 'The "%s" options group has been removed. Use another settings group.' ),
1647
-				'misc'
1648
-			)
1649
-		);
1650
-		$page = 'general';
1651
-	}
1652
-
1653
-	if ( 'privacy' === $page ) {
1654
-		_deprecated_argument(
1655
-			__FUNCTION__,
1656
-			'3.5.0',
1657
-			sprintf(
1658
-				/* translators: %s: privacy */
1659
-				__( 'The "%s" options group has been removed. Use another settings group.' ),
1660
-				'privacy'
1661
-			)
1662
-		);
1663
-		$page = 'reading';
1664
-	}
1665
-
1666
-	$wp_settings_fields[ $page ][ $section ][ $id ] = array(
1667
-		'id'       => $id,
1668
-		'title'    => $title,
1669
-		'callback' => $callback,
1670
-		'args'     => $args,
1671
-	);
1638
+    global $wp_settings_fields;
1639
+
1640
+    if ( 'misc' === $page ) {
1641
+        _deprecated_argument(
1642
+            __FUNCTION__,
1643
+            '3.0.0',
1644
+            sprintf(
1645
+                /* translators: %s: misc */
1646
+                __( 'The "%s" options group has been removed. Use another settings group.' ),
1647
+                'misc'
1648
+            )
1649
+        );
1650
+        $page = 'general';
1651
+    }
1652
+
1653
+    if ( 'privacy' === $page ) {
1654
+        _deprecated_argument(
1655
+            __FUNCTION__,
1656
+            '3.5.0',
1657
+            sprintf(
1658
+                /* translators: %s: privacy */
1659
+                __( 'The "%s" options group has been removed. Use another settings group.' ),
1660
+                'privacy'
1661
+            )
1662
+        );
1663
+        $page = 'reading';
1664
+    }
1665
+
1666
+    $wp_settings_fields[ $page ][ $section ][ $id ] = array(
1667
+        'id'       => $id,
1668
+        'title'    => $title,
1669
+        'callback' => $callback,
1670
+        'args'     => $args,
1671
+    );
1672 1672
 }
1673 1673
 
1674 1674
 /**
@@ -1685,28 +1685,28 @@  discard block
 block discarded – undo
1685 1685
  * @param string $page The slug name of the page whose settings sections you want to output.
1686 1686
  */
1687 1687
 function do_settings_sections( $page ) {
1688
-	global $wp_settings_sections, $wp_settings_fields;
1689
-
1690
-	if ( ! isset( $wp_settings_sections[ $page ] ) ) {
1691
-		return;
1692
-	}
1693
-
1694
-	foreach ( (array) $wp_settings_sections[ $page ] as $section ) {
1695
-		if ( $section['title'] ) {
1696
-			echo "<h2>{$section['title']}</h2>\n";
1697
-		}
1698
-
1699
-		if ( $section['callback'] ) {
1700
-			call_user_func( $section['callback'], $section );
1701
-		}
1702
-
1703
-		if ( ! isset( $wp_settings_fields ) || ! isset( $wp_settings_fields[ $page ] ) || ! isset( $wp_settings_fields[ $page ][ $section['id'] ] ) ) {
1704
-			continue;
1705
-		}
1706
-		echo '<table class="form-table" role="presentation">';
1707
-		do_settings_fields( $page, $section['id'] );
1708
-		echo '</table>';
1709
-	}
1688
+    global $wp_settings_sections, $wp_settings_fields;
1689
+
1690
+    if ( ! isset( $wp_settings_sections[ $page ] ) ) {
1691
+        return;
1692
+    }
1693
+
1694
+    foreach ( (array) $wp_settings_sections[ $page ] as $section ) {
1695
+        if ( $section['title'] ) {
1696
+            echo "<h2>{$section['title']}</h2>\n";
1697
+        }
1698
+
1699
+        if ( $section['callback'] ) {
1700
+            call_user_func( $section['callback'], $section );
1701
+        }
1702
+
1703
+        if ( ! isset( $wp_settings_fields ) || ! isset( $wp_settings_fields[ $page ] ) || ! isset( $wp_settings_fields[ $page ][ $section['id'] ] ) ) {
1704
+            continue;
1705
+        }
1706
+        echo '<table class="form-table" role="presentation">';
1707
+        do_settings_fields( $page, $section['id'] );
1708
+        echo '</table>';
1709
+    }
1710 1710
 }
1711 1711
 
1712 1712
 /**
@@ -1724,32 +1724,32 @@  discard block
 block discarded – undo
1724 1724
  * @param string $section Slug title of the settings section whose fields you want to show.
1725 1725
  */
1726 1726
 function do_settings_fields( $page, $section ) {
1727
-	global $wp_settings_fields;
1727
+    global $wp_settings_fields;
1728 1728
 
1729
-	if ( ! isset( $wp_settings_fields[ $page ][ $section ] ) ) {
1730
-		return;
1731
-	}
1729
+    if ( ! isset( $wp_settings_fields[ $page ][ $section ] ) ) {
1730
+        return;
1731
+    }
1732 1732
 
1733
-	foreach ( (array) $wp_settings_fields[ $page ][ $section ] as $field ) {
1734
-		$class = '';
1733
+    foreach ( (array) $wp_settings_fields[ $page ][ $section ] as $field ) {
1734
+        $class = '';
1735 1735
 
1736
-		if ( ! empty( $field['args']['class'] ) ) {
1737
-			$class = ' class="' . esc_attr( $field['args']['class'] ) . '"';
1738
-		}
1736
+        if ( ! empty( $field['args']['class'] ) ) {
1737
+            $class = ' class="' . esc_attr( $field['args']['class'] ) . '"';
1738
+        }
1739 1739
 
1740
-		echo "<tr{$class}>";
1740
+        echo "<tr{$class}>";
1741 1741
 
1742
-		if ( ! empty( $field['args']['label_for'] ) ) {
1743
-			echo '<th scope="row"><label for="' . esc_attr( $field['args']['label_for'] ) . '">' . $field['title'] . '</label></th>';
1744
-		} else {
1745
-			echo '<th scope="row">' . $field['title'] . '</th>';
1746
-		}
1742
+        if ( ! empty( $field['args']['label_for'] ) ) {
1743
+            echo '<th scope="row"><label for="' . esc_attr( $field['args']['label_for'] ) . '">' . $field['title'] . '</label></th>';
1744
+        } else {
1745
+            echo '<th scope="row">' . $field['title'] . '</th>';
1746
+        }
1747 1747
 
1748
-		echo '<td>';
1749
-		call_user_func( $field['callback'], $field['args'] );
1750
-		echo '</td>';
1751
-		echo '</tr>';
1752
-	}
1748
+        echo '<td>';
1749
+        call_user_func( $field['callback'], $field['args'] );
1750
+        echo '</td>';
1751
+        echo '</tr>';
1752
+    }
1753 1753
 }
1754 1754
 
1755 1755
 /**
@@ -1778,14 +1778,14 @@  discard block
 block discarded – undo
1778 1778
  *                        'success', 'warning', 'info'. Default 'error'.
1779 1779
  */
1780 1780
 function add_settings_error( $setting, $code, $message, $type = 'error' ) {
1781
-	global $wp_settings_errors;
1782
-
1783
-	$wp_settings_errors[] = array(
1784
-		'setting' => $setting,
1785
-		'code'    => $code,
1786
-		'message' => $message,
1787
-		'type'    => $type,
1788
-	);
1781
+    global $wp_settings_errors;
1782
+
1783
+    $wp_settings_errors[] = array(
1784
+        'setting' => $setting,
1785
+        'code'    => $code,
1786
+        'message' => $message,
1787
+        'type'    => $type,
1788
+    );
1789 1789
 }
1790 1790
 
1791 1791
 /**
@@ -1821,42 +1821,42 @@  discard block
 block discarded – undo
1821 1821
  * }
1822 1822
  */
1823 1823
 function get_settings_errors( $setting = '', $sanitize = false ) {
1824
-	global $wp_settings_errors;
1824
+    global $wp_settings_errors;
1825 1825
 
1826
-	/*
1826
+    /*
1827 1827
 	 * If $sanitize is true, manually re-run the sanitization for this option
1828 1828
 	 * This allows the $sanitize_callback from register_setting() to run, adding
1829 1829
 	 * any settings errors you want to show by default.
1830 1830
 	 */
1831
-	if ( $sanitize ) {
1832
-		sanitize_option( $setting, get_option( $setting ) );
1833
-	}
1834
-
1835
-	// If settings were passed back from options.php then use them.
1836
-	if ( isset( $_GET['settings-updated'] ) && $_GET['settings-updated'] && get_transient( 'settings_errors' ) ) {
1837
-		$wp_settings_errors = array_merge( (array) $wp_settings_errors, get_transient( 'settings_errors' ) );
1838
-		delete_transient( 'settings_errors' );
1839
-	}
1840
-
1841
-	// Check global in case errors have been added on this pageload.
1842
-	if ( empty( $wp_settings_errors ) ) {
1843
-		return array();
1844
-	}
1845
-
1846
-	// Filter the results to those of a specific setting if one was set.
1847
-	if ( $setting ) {
1848
-		$setting_errors = array();
1849
-
1850
-		foreach ( (array) $wp_settings_errors as $key => $details ) {
1851
-			if ( $setting === $details['setting'] ) {
1852
-				$setting_errors[] = $wp_settings_errors[ $key ];
1853
-			}
1854
-		}
1855
-
1856
-		return $setting_errors;
1857
-	}
1858
-
1859
-	return $wp_settings_errors;
1831
+    if ( $sanitize ) {
1832
+        sanitize_option( $setting, get_option( $setting ) );
1833
+    }
1834
+
1835
+    // If settings were passed back from options.php then use them.
1836
+    if ( isset( $_GET['settings-updated'] ) && $_GET['settings-updated'] && get_transient( 'settings_errors' ) ) {
1837
+        $wp_settings_errors = array_merge( (array) $wp_settings_errors, get_transient( 'settings_errors' ) );
1838
+        delete_transient( 'settings_errors' );
1839
+    }
1840
+
1841
+    // Check global in case errors have been added on this pageload.
1842
+    if ( empty( $wp_settings_errors ) ) {
1843
+        return array();
1844
+    }
1845
+
1846
+    // Filter the results to those of a specific setting if one was set.
1847
+    if ( $setting ) {
1848
+        $setting_errors = array();
1849
+
1850
+        foreach ( (array) $wp_settings_errors as $key => $details ) {
1851
+            if ( $setting === $details['setting'] ) {
1852
+                $setting_errors[] = $wp_settings_errors[ $key ];
1853
+            }
1854
+        }
1855
+
1856
+        return $setting_errors;
1857
+    }
1858
+
1859
+    return $wp_settings_errors;
1860 1860
 }
1861 1861
 
1862 1862
 /**
@@ -1890,42 +1890,42 @@  discard block
 block discarded – undo
1890 1890
  */
1891 1891
 function settings_errors( $setting = '', $sanitize = false, $hide_on_update = false ) {
1892 1892
 
1893
-	if ( $hide_on_update && ! empty( $_GET['settings-updated'] ) ) {
1894
-		return;
1895
-	}
1893
+    if ( $hide_on_update && ! empty( $_GET['settings-updated'] ) ) {
1894
+        return;
1895
+    }
1896 1896
 
1897
-	$settings_errors = get_settings_errors( $setting, $sanitize );
1897
+    $settings_errors = get_settings_errors( $setting, $sanitize );
1898 1898
 
1899
-	if ( empty( $settings_errors ) ) {
1900
-		return;
1901
-	}
1899
+    if ( empty( $settings_errors ) ) {
1900
+        return;
1901
+    }
1902 1902
 
1903
-	$output = '';
1903
+    $output = '';
1904 1904
 
1905
-	foreach ( $settings_errors as $key => $details ) {
1906
-		if ( 'updated' === $details['type'] ) {
1907
-			$details['type'] = 'success';
1908
-		}
1905
+    foreach ( $settings_errors as $key => $details ) {
1906
+        if ( 'updated' === $details['type'] ) {
1907
+            $details['type'] = 'success';
1908
+        }
1909 1909
 
1910
-		if ( in_array( $details['type'], array( 'error', 'success', 'warning', 'info' ), true ) ) {
1911
-			$details['type'] = 'notice-' . $details['type'];
1912
-		}
1910
+        if ( in_array( $details['type'], array( 'error', 'success', 'warning', 'info' ), true ) ) {
1911
+            $details['type'] = 'notice-' . $details['type'];
1912
+        }
1913
+
1914
+        $css_id    = sprintf(
1915
+            'setting-error-%s',
1916
+            esc_attr( $details['code'] )
1917
+        );
1918
+        $css_class = sprintf(
1919
+            'notice %s settings-error is-dismissible',
1920
+            esc_attr( $details['type'] )
1921
+        );
1922
+
1923
+        $output .= "<div id='$css_id' class='$css_class'> \n";
1924
+        $output .= "<p><strong>{$details['message']}</strong></p>";
1925
+        $output .= "</div> \n";
1926
+    }
1913 1927
 
1914
-		$css_id    = sprintf(
1915
-			'setting-error-%s',
1916
-			esc_attr( $details['code'] )
1917
-		);
1918
-		$css_class = sprintf(
1919
-			'notice %s settings-error is-dismissible',
1920
-			esc_attr( $details['type'] )
1921
-		);
1922
-
1923
-		$output .= "<div id='$css_id' class='$css_class'> \n";
1924
-		$output .= "<p><strong>{$details['message']}</strong></p>";
1925
-		$output .= "</div> \n";
1926
-	}
1927
-
1928
-	echo $output;
1928
+    echo $output;
1929 1929
 }
1930 1930
 
1931 1931
 /**
@@ -1936,7 +1936,7 @@  discard block
 block discarded – undo
1936 1936
  * @param string $found_action
1937 1937
  */
1938 1938
 function find_posts_div( $found_action = '' ) {
1939
-	?>
1939
+    ?>
1940 1940
 	<div id="find-posts" class="find-box" style="display: none;">
1941 1941
 		<div id="find-posts-head" class="find-box-head">
1942 1942
 			<?php _e( 'Attach to existing content' ); ?>
@@ -1973,10 +1973,10 @@  discard block
 block discarded – undo
1973 1973
  * @since 2.7.0
1974 1974
  */
1975 1975
 function the_post_password() {
1976
-	$post = get_post();
1977
-	if ( isset( $post->post_password ) ) {
1978
-		echo esc_attr( $post->post_password );
1979
-	}
1976
+    $post = get_post();
1977
+    if ( isset( $post->post_password ) ) {
1978
+        echo esc_attr( $post->post_password );
1979
+    }
1980 1980
 }
1981 1981
 
1982 1982
 /**
@@ -1991,11 +1991,11 @@  discard block
 block discarded – undo
1991 1991
  * @return string The post title if set.
1992 1992
  */
1993 1993
 function _draft_or_post_title( $post = 0 ) {
1994
-	$title = get_the_title( $post );
1995
-	if ( empty( $title ) ) {
1996
-		$title = __( '(no title)' );
1997
-	}
1998
-	return esc_html( $title );
1994
+    $title = get_the_title( $post );
1995
+    if ( empty( $title ) ) {
1996
+        $title = __( '(no title)' );
1997
+    }
1998
+    return esc_html( $title );
1999 1999
 }
2000 2000
 
2001 2001
 /**
@@ -2007,7 +2007,7 @@  discard block
 block discarded – undo
2007 2007
  * @since 2.7.0
2008 2008
  */
2009 2009
 function _admin_search_query() {
2010
-	echo isset( $_REQUEST['s'] ) ? esc_attr( wp_unslash( $_REQUEST['s'] ) ) : '';
2010
+    echo isset( $_REQUEST['s'] ) ? esc_attr( wp_unslash( $_REQUEST['s'] ) ) : '';
2011 2011
 }
2012 2012
 
2013 2013
 /**
@@ -2023,19 +2023,19 @@  discard block
 block discarded – undo
2023 2023
  * @param bool   $deprecated Not used.
2024 2024
  */
2025 2025
 function iframe_header( $title = '', $deprecated = false ) {
2026
-	show_admin_bar( false );
2027
-	global $hook_suffix, $admin_body_class, $wp_locale;
2028
-	$admin_body_class = preg_replace( '/[^a-z0-9_-]+/i', '-', $hook_suffix );
2026
+    show_admin_bar( false );
2027
+    global $hook_suffix, $admin_body_class, $wp_locale;
2028
+    $admin_body_class = preg_replace( '/[^a-z0-9_-]+/i', '-', $hook_suffix );
2029 2029
 
2030
-	$current_screen = get_current_screen();
2030
+    $current_screen = get_current_screen();
2031 2031
 
2032
-	header( 'Content-Type: ' . get_option( 'html_type' ) . '; charset=' . get_option( 'blog_charset' ) );
2033
-	_wp_admin_html_begin();
2034
-	?>
2032
+    header( 'Content-Type: ' . get_option( 'html_type' ) . '; charset=' . get_option( 'blog_charset' ) );
2033
+    _wp_admin_html_begin();
2034
+    ?>
2035 2035
 <title><?php bloginfo( 'name' ); ?> &rsaquo; <?php echo $title; ?> &#8212; <?php _e( 'WordPress' ); ?></title>
2036 2036
 	<?php
2037
-	wp_enqueue_style( 'colors' );
2038
-	?>
2037
+    wp_enqueue_style( 'colors' );
2038
+    ?>
2039 2039
 <script type="text/javascript">
2040 2040
 addLoadEvent = function(func){if(typeof jQuery!=='undefined')jQuery(function(){func();});else if(typeof wpOnload!=='function'){wpOnload=func;}else{var oldonload=wpOnload;wpOnload=function(){oldonload();func();}}};
2041 2041
 function tb_close(){var win=window.dialogArguments||opener||parent||top;win.tb_remove();}
@@ -2048,45 +2048,45 @@  discard block
 block discarded – undo
2048 2048
 	isRtl = <?php echo (int) is_rtl(); ?>;
2049 2049
 </script>
2050 2050
 	<?php
2051
-	/** This action is documented in wp-admin/admin-header.php */
2052
-	do_action( 'admin_enqueue_scripts', $hook_suffix );
2051
+    /** This action is documented in wp-admin/admin-header.php */
2052
+    do_action( 'admin_enqueue_scripts', $hook_suffix );
2053 2053
 
2054
-	/** This action is documented in wp-admin/admin-header.php */
2055
-	do_action( "admin_print_styles-{$hook_suffix}" );  // phpcs:ignore WordPress.NamingConventions.ValidHookName.UseUnderscores
2054
+    /** This action is documented in wp-admin/admin-header.php */
2055
+    do_action( "admin_print_styles-{$hook_suffix}" );  // phpcs:ignore WordPress.NamingConventions.ValidHookName.UseUnderscores
2056 2056
 
2057
-	/** This action is documented in wp-admin/admin-header.php */
2058
-	do_action( 'admin_print_styles' );
2057
+    /** This action is documented in wp-admin/admin-header.php */
2058
+    do_action( 'admin_print_styles' );
2059 2059
 
2060
-	/** This action is documented in wp-admin/admin-header.php */
2061
-	do_action( "admin_print_scripts-{$hook_suffix}" ); // phpcs:ignore WordPress.NamingConventions.ValidHookName.UseUnderscores
2060
+    /** This action is documented in wp-admin/admin-header.php */
2061
+    do_action( "admin_print_scripts-{$hook_suffix}" ); // phpcs:ignore WordPress.NamingConventions.ValidHookName.UseUnderscores
2062 2062
 
2063
-	/** This action is documented in wp-admin/admin-header.php */
2064
-	do_action( 'admin_print_scripts' );
2063
+    /** This action is documented in wp-admin/admin-header.php */
2064
+    do_action( 'admin_print_scripts' );
2065 2065
 
2066
-	/** This action is documented in wp-admin/admin-header.php */
2067
-	do_action( "admin_head-{$hook_suffix}" ); // phpcs:ignore WordPress.NamingConventions.ValidHookName.UseUnderscores
2066
+    /** This action is documented in wp-admin/admin-header.php */
2067
+    do_action( "admin_head-{$hook_suffix}" ); // phpcs:ignore WordPress.NamingConventions.ValidHookName.UseUnderscores
2068 2068
 
2069
-	/** This action is documented in wp-admin/admin-header.php */
2070
-	do_action( 'admin_head' );
2069
+    /** This action is documented in wp-admin/admin-header.php */
2070
+    do_action( 'admin_head' );
2071 2071
 
2072
-	$admin_body_class .= ' locale-' . sanitize_html_class( strtolower( str_replace( '_', '-', get_user_locale() ) ) );
2072
+    $admin_body_class .= ' locale-' . sanitize_html_class( strtolower( str_replace( '_', '-', get_user_locale() ) ) );
2073 2073
 
2074
-	if ( is_rtl() ) {
2075
-		$admin_body_class .= ' rtl';
2076
-	}
2074
+    if ( is_rtl() ) {
2075
+        $admin_body_class .= ' rtl';
2076
+    }
2077 2077
 
2078
-	?>
2078
+    ?>
2079 2079
 </head>
2080 2080
 	<?php
2081
-	/**
2082
-	 * @global string $body_id
2083
-	 */
2084
-	$admin_body_id = isset( $GLOBALS['body_id'] ) ? 'id="' . $GLOBALS['body_id'] . '" ' : '';
2085
-
2086
-	/** This filter is documented in wp-admin/admin-header.php */
2087
-	$admin_body_classes = apply_filters( 'admin_body_class', '' );
2088
-	$admin_body_classes = ltrim( $admin_body_classes . ' ' . $admin_body_class );
2089
-	?>
2081
+    /**
2082
+     * @global string $body_id
2083
+     */
2084
+    $admin_body_id = isset( $GLOBALS['body_id'] ) ? 'id="' . $GLOBALS['body_id'] . '" ' : '';
2085
+
2086
+    /** This filter is documented in wp-admin/admin-header.php */
2087
+    $admin_body_classes = apply_filters( 'admin_body_class', '' );
2088
+    $admin_body_classes = ltrim( $admin_body_classes . ' ' . $admin_body_class );
2089
+    ?>
2090 2090
 <body <?php echo $admin_body_id; ?>class="wp-admin wp-core-ui no-js iframe <?php echo $admin_body_classes; ?>">
2091 2091
 <script type="text/javascript">
2092 2092
 (function(){
@@ -2104,28 +2104,28 @@  discard block
 block discarded – undo
2104 2104
  * @since 2.7.0
2105 2105
  */
2106 2106
 function iframe_footer() {
2107
-	/*
2107
+    /*
2108 2108
 	 * We're going to hide any footer output on iFrame pages,
2109 2109
 	 * but run the hooks anyway since they output JavaScript
2110 2110
 	 * or other needed content.
2111 2111
 	 */
2112 2112
 
2113
-	/**
2114
-	 * @global string $hook_suffix
2115
-	 */
2116
-	global $hook_suffix;
2117
-	?>
2113
+    /**
2114
+     * @global string $hook_suffix
2115
+     */
2116
+    global $hook_suffix;
2117
+    ?>
2118 2118
 	<div class="hidden">
2119 2119
 	<?php
2120
-	/** This action is documented in wp-admin/admin-footer.php */
2121
-	do_action( 'admin_footer', $hook_suffix );
2120
+    /** This action is documented in wp-admin/admin-footer.php */
2121
+    do_action( 'admin_footer', $hook_suffix );
2122 2122
 
2123
-	/** This action is documented in wp-admin/admin-footer.php */
2124
-	do_action( "admin_print_footer_scripts-{$hook_suffix}" ); // phpcs:ignore WordPress.NamingConventions.ValidHookName.UseUnderscores
2123
+    /** This action is documented in wp-admin/admin-footer.php */
2124
+    do_action( "admin_print_footer_scripts-{$hook_suffix}" ); // phpcs:ignore WordPress.NamingConventions.ValidHookName.UseUnderscores
2125 2125
 
2126
-	/** This action is documented in wp-admin/admin-footer.php */
2127
-	do_action( 'admin_print_footer_scripts' );
2128
-	?>
2126
+    /** This action is documented in wp-admin/admin-footer.php */
2127
+    do_action( 'admin_print_footer_scripts' );
2128
+    ?>
2129 2129
 	</div>
2130 2130
 <script type="text/javascript">if(typeof wpOnload==='function')wpOnload();</script>
2131 2131
 </body>
@@ -2147,30 +2147,30 @@  discard block
 block discarded – undo
2147 2147
  * @return string Post states string.
2148 2148
  */
2149 2149
 function _post_states( $post, $display = true ) {
2150
-	$post_states        = get_post_states( $post );
2151
-	$post_states_string = '';
2150
+    $post_states        = get_post_states( $post );
2151
+    $post_states_string = '';
2152 2152
 
2153
-	if ( ! empty( $post_states ) ) {
2154
-		$state_count = count( $post_states );
2153
+    if ( ! empty( $post_states ) ) {
2154
+        $state_count = count( $post_states );
2155 2155
 
2156
-		$i = 0;
2156
+        $i = 0;
2157 2157
 
2158
-		$post_states_string .= ' &mdash; ';
2158
+        $post_states_string .= ' &mdash; ';
2159 2159
 
2160
-		foreach ( $post_states as $state ) {
2161
-			++$i;
2160
+        foreach ( $post_states as $state ) {
2161
+            ++$i;
2162 2162
 
2163
-			$sep = ( $i < $state_count ) ? ', ' : '';
2163
+            $sep = ( $i < $state_count ) ? ', ' : '';
2164 2164
 
2165
-			$post_states_string .= "<span class='post-state'>$state$sep</span>";
2166
-		}
2167
-	}
2165
+            $post_states_string .= "<span class='post-state'>$state$sep</span>";
2166
+        }
2167
+    }
2168 2168
 
2169
-	if ( $display ) {
2170
-		echo $post_states_string;
2171
-	}
2169
+    if ( $display ) {
2170
+        echo $post_states_string;
2171
+    }
2172 2172
 
2173
-	return $post_states_string;
2173
+    return $post_states_string;
2174 2174
 }
2175 2175
 
2176 2176
 /**
@@ -2182,71 +2182,71 @@  discard block
 block discarded – undo
2182 2182
  * @return string[] Array of post state labels keyed by their state.
2183 2183
  */
2184 2184
 function get_post_states( $post ) {
2185
-	$post_states = array();
2186
-
2187
-	if ( isset( $_REQUEST['post_status'] ) ) {
2188
-		$post_status = $_REQUEST['post_status'];
2189
-	} else {
2190
-		$post_status = '';
2191
-	}
2192
-
2193
-	if ( ! empty( $post->post_password ) ) {
2194
-		$post_states['protected'] = _x( 'Password protected', 'post status' );
2195
-	}
2196
-
2197
-	if ( 'private' === $post->post_status && 'private' !== $post_status ) {
2198
-		$post_states['private'] = _x( 'Private', 'post status' );
2199
-	}
2200
-
2201
-	if ( 'draft' === $post->post_status ) {
2202
-		if ( get_post_meta( $post->ID, '_customize_changeset_uuid', true ) ) {
2203
-			$post_states[] = __( 'Customization Draft' );
2204
-		} elseif ( 'draft' !== $post_status ) {
2205
-			$post_states['draft'] = _x( 'Draft', 'post status' );
2206
-		}
2207
-	} elseif ( 'trash' === $post->post_status && get_post_meta( $post->ID, '_customize_changeset_uuid', true ) ) {
2208
-		$post_states[] = _x( 'Customization Draft', 'post status' );
2209
-	}
2210
-
2211
-	if ( 'pending' === $post->post_status && 'pending' !== $post_status ) {
2212
-		$post_states['pending'] = _x( 'Pending', 'post status' );
2213
-	}
2214
-
2215
-	if ( is_sticky( $post->ID ) ) {
2216
-		$post_states['sticky'] = _x( 'Sticky', 'post status' );
2217
-	}
2218
-
2219
-	if ( 'future' === $post->post_status ) {
2220
-		$post_states['scheduled'] = _x( 'Scheduled', 'post status' );
2221
-	}
2222
-
2223
-	if ( 'page' === get_option( 'show_on_front' ) ) {
2224
-		if ( (int) get_option( 'page_on_front' ) === $post->ID ) {
2225
-			$post_states['page_on_front'] = _x( 'Front Page', 'page label' );
2226
-		}
2227
-
2228
-		if ( (int) get_option( 'page_for_posts' ) === $post->ID ) {
2229
-			$post_states['page_for_posts'] = _x( 'Posts Page', 'page label' );
2230
-		}
2231
-	}
2232
-
2233
-	if ( (int) get_option( 'wp_page_for_privacy_policy' ) === $post->ID ) {
2234
-		$post_states['page_for_privacy_policy'] = _x( 'Privacy Policy Page', 'page label' );
2235
-	}
2236
-
2237
-	/**
2238
-	 * Filters the default post display states used in the posts list table.
2239
-	 *
2240
-	 * @since 2.8.0
2241
-	 * @since 3.6.0 Added the `$post` parameter.
2242
-	 * @since 5.5.0 Also applied in the Customizer context. If any admin functions
2243
-	 *              are used within the filter, their existence should be checked
2244
-	 *              with `function_exists()` before being used.
2245
-	 *
2246
-	 * @param string[] $post_states An array of post display states.
2247
-	 * @param WP_Post  $post        The current post object.
2248
-	 */
2249
-	return apply_filters( 'display_post_states', $post_states, $post );
2185
+    $post_states = array();
2186
+
2187
+    if ( isset( $_REQUEST['post_status'] ) ) {
2188
+        $post_status = $_REQUEST['post_status'];
2189
+    } else {
2190
+        $post_status = '';
2191
+    }
2192
+
2193
+    if ( ! empty( $post->post_password ) ) {
2194
+        $post_states['protected'] = _x( 'Password protected', 'post status' );
2195
+    }
2196
+
2197
+    if ( 'private' === $post->post_status && 'private' !== $post_status ) {
2198
+        $post_states['private'] = _x( 'Private', 'post status' );
2199
+    }
2200
+
2201
+    if ( 'draft' === $post->post_status ) {
2202
+        if ( get_post_meta( $post->ID, '_customize_changeset_uuid', true ) ) {
2203
+            $post_states[] = __( 'Customization Draft' );
2204
+        } elseif ( 'draft' !== $post_status ) {
2205
+            $post_states['draft'] = _x( 'Draft', 'post status' );
2206
+        }
2207
+    } elseif ( 'trash' === $post->post_status && get_post_meta( $post->ID, '_customize_changeset_uuid', true ) ) {
2208
+        $post_states[] = _x( 'Customization Draft', 'post status' );
2209
+    }
2210
+
2211
+    if ( 'pending' === $post->post_status && 'pending' !== $post_status ) {
2212
+        $post_states['pending'] = _x( 'Pending', 'post status' );
2213
+    }
2214
+
2215
+    if ( is_sticky( $post->ID ) ) {
2216
+        $post_states['sticky'] = _x( 'Sticky', 'post status' );
2217
+    }
2218
+
2219
+    if ( 'future' === $post->post_status ) {
2220
+        $post_states['scheduled'] = _x( 'Scheduled', 'post status' );
2221
+    }
2222
+
2223
+    if ( 'page' === get_option( 'show_on_front' ) ) {
2224
+        if ( (int) get_option( 'page_on_front' ) === $post->ID ) {
2225
+            $post_states['page_on_front'] = _x( 'Front Page', 'page label' );
2226
+        }
2227
+
2228
+        if ( (int) get_option( 'page_for_posts' ) === $post->ID ) {
2229
+            $post_states['page_for_posts'] = _x( 'Posts Page', 'page label' );
2230
+        }
2231
+    }
2232
+
2233
+    if ( (int) get_option( 'wp_page_for_privacy_policy' ) === $post->ID ) {
2234
+        $post_states['page_for_privacy_policy'] = _x( 'Privacy Policy Page', 'page label' );
2235
+    }
2236
+
2237
+    /**
2238
+     * Filters the default post display states used in the posts list table.
2239
+     *
2240
+     * @since 2.8.0
2241
+     * @since 3.6.0 Added the `$post` parameter.
2242
+     * @since 5.5.0 Also applied in the Customizer context. If any admin functions
2243
+     *              are used within the filter, their existence should be checked
2244
+     *              with `function_exists()` before being used.
2245
+     *
2246
+     * @param string[] $post_states An array of post display states.
2247
+     * @param WP_Post  $post        The current post object.
2248
+     */
2249
+    return apply_filters( 'display_post_states', $post_states, $post );
2250 2250
 }
2251 2251
 
2252 2252
 /**
@@ -2261,30 +2261,30 @@  discard block
 block discarded – undo
2261 2261
  * @return string Media states string.
2262 2262
  */
2263 2263
 function _media_states( $post, $display = true ) {
2264
-	$media_states        = get_media_states( $post );
2265
-	$media_states_string = '';
2264
+    $media_states        = get_media_states( $post );
2265
+    $media_states_string = '';
2266 2266
 
2267
-	if ( ! empty( $media_states ) ) {
2268
-		$state_count = count( $media_states );
2267
+    if ( ! empty( $media_states ) ) {
2268
+        $state_count = count( $media_states );
2269 2269
 
2270
-		$i = 0;
2270
+        $i = 0;
2271 2271
 
2272
-		$media_states_string .= ' &mdash; ';
2272
+        $media_states_string .= ' &mdash; ';
2273 2273
 
2274
-		foreach ( $media_states as $state ) {
2275
-			++$i;
2274
+        foreach ( $media_states as $state ) {
2275
+            ++$i;
2276 2276
 
2277
-			$sep = ( $i < $state_count ) ? ', ' : '';
2277
+            $sep = ( $i < $state_count ) ? ', ' : '';
2278 2278
 
2279
-			$media_states_string .= "<span class='post-state'>$state$sep</span>";
2280
-		}
2281
-	}
2279
+            $media_states_string .= "<span class='post-state'>$state$sep</span>";
2280
+        }
2281
+    }
2282 2282
 
2283
-	if ( $display ) {
2284
-		echo $media_states_string;
2285
-	}
2283
+    if ( $display ) {
2284
+        echo $media_states_string;
2285
+    }
2286 2286
 
2287
-	return $media_states_string;
2287
+    return $media_states_string;
2288 2288
 }
2289 2289
 
2290 2290
 /**
@@ -2296,76 +2296,76 @@  discard block
 block discarded – undo
2296 2296
  * @return string[] Array of media state labels keyed by their state.
2297 2297
  */
2298 2298
 function get_media_states( $post ) {
2299
-	static $header_images;
2300
-
2301
-	$media_states = array();
2302
-	$stylesheet   = get_option( 'stylesheet' );
2303
-
2304
-	if ( current_theme_supports( 'custom-header' ) ) {
2305
-		$meta_header = get_post_meta( $post->ID, '_wp_attachment_is_custom_header', true );
2306
-
2307
-		if ( is_random_header_image() ) {
2308
-			if ( ! isset( $header_images ) ) {
2309
-				$header_images = wp_list_pluck( get_uploaded_header_images(), 'attachment_id' );
2310
-			}
2311
-
2312
-			if ( $meta_header === $stylesheet && in_array( $post->ID, $header_images, true ) ) {
2313
-				$media_states[] = __( 'Header Image' );
2314
-			}
2315
-		} else {
2316
-			$header_image = get_header_image();
2317
-
2318
-			// Display "Header Image" if the image was ever used as a header image.
2319
-			if ( ! empty( $meta_header ) && $meta_header === $stylesheet && wp_get_attachment_url( $post->ID ) !== $header_image ) {
2320
-				$media_states[] = __( 'Header Image' );
2321
-			}
2322
-
2323
-			// Display "Current Header Image" if the image is currently the header image.
2324
-			if ( $header_image && wp_get_attachment_url( $post->ID ) === $header_image ) {
2325
-				$media_states[] = __( 'Current Header Image' );
2326
-			}
2327
-		}
2328
-
2329
-		if ( get_theme_support( 'custom-header', 'video' ) && has_header_video() ) {
2330
-			$mods = get_theme_mods();
2331
-			if ( isset( $mods['header_video'] ) && $post->ID === $mods['header_video'] ) {
2332
-				$media_states[] = __( 'Current Header Video' );
2333
-			}
2334
-		}
2335
-	}
2336
-
2337
-	if ( current_theme_supports( 'custom-background' ) ) {
2338
-		$meta_background = get_post_meta( $post->ID, '_wp_attachment_is_custom_background', true );
2339
-
2340
-		if ( ! empty( $meta_background ) && $meta_background === $stylesheet ) {
2341
-			$media_states[] = __( 'Background Image' );
2342
-
2343
-			$background_image = get_background_image();
2344
-			if ( $background_image && wp_get_attachment_url( $post->ID ) === $background_image ) {
2345
-				$media_states[] = __( 'Current Background Image' );
2346
-			}
2347
-		}
2348
-	}
2349
-
2350
-	if ( (int) get_option( 'site_icon' ) === $post->ID ) {
2351
-		$media_states[] = __( 'Site Icon' );
2352
-	}
2353
-
2354
-	if ( (int) get_theme_mod( 'custom_logo' ) === $post->ID ) {
2355
-		$media_states[] = __( 'Logo' );
2356
-	}
2357
-
2358
-	/**
2359
-	 * Filters the default media display states for items in the Media list table.
2360
-	 *
2361
-	 * @since 3.2.0
2362
-	 * @since 4.8.0 Added the `$post` parameter.
2363
-	 *
2364
-	 * @param string[] $media_states An array of media states. Default 'Header Image',
2365
-	 *                               'Background Image', 'Site Icon', 'Logo'.
2366
-	 * @param WP_Post  $post         The current attachment object.
2367
-	 */
2368
-	return apply_filters( 'display_media_states', $media_states, $post );
2299
+    static $header_images;
2300
+
2301
+    $media_states = array();
2302
+    $stylesheet   = get_option( 'stylesheet' );
2303
+
2304
+    if ( current_theme_supports( 'custom-header' ) ) {
2305
+        $meta_header = get_post_meta( $post->ID, '_wp_attachment_is_custom_header', true );
2306
+
2307
+        if ( is_random_header_image() ) {
2308
+            if ( ! isset( $header_images ) ) {
2309
+                $header_images = wp_list_pluck( get_uploaded_header_images(), 'attachment_id' );
2310
+            }
2311
+
2312
+            if ( $meta_header === $stylesheet && in_array( $post->ID, $header_images, true ) ) {
2313
+                $media_states[] = __( 'Header Image' );
2314
+            }
2315
+        } else {
2316
+            $header_image = get_header_image();
2317
+
2318
+            // Display "Header Image" if the image was ever used as a header image.
2319
+            if ( ! empty( $meta_header ) && $meta_header === $stylesheet && wp_get_attachment_url( $post->ID ) !== $header_image ) {
2320
+                $media_states[] = __( 'Header Image' );
2321
+            }
2322
+
2323
+            // Display "Current Header Image" if the image is currently the header image.
2324
+            if ( $header_image && wp_get_attachment_url( $post->ID ) === $header_image ) {
2325
+                $media_states[] = __( 'Current Header Image' );
2326
+            }
2327
+        }
2328
+
2329
+        if ( get_theme_support( 'custom-header', 'video' ) && has_header_video() ) {
2330
+            $mods = get_theme_mods();
2331
+            if ( isset( $mods['header_video'] ) && $post->ID === $mods['header_video'] ) {
2332
+                $media_states[] = __( 'Current Header Video' );
2333
+            }
2334
+        }
2335
+    }
2336
+
2337
+    if ( current_theme_supports( 'custom-background' ) ) {
2338
+        $meta_background = get_post_meta( $post->ID, '_wp_attachment_is_custom_background', true );
2339
+
2340
+        if ( ! empty( $meta_background ) && $meta_background === $stylesheet ) {
2341
+            $media_states[] = __( 'Background Image' );
2342
+
2343
+            $background_image = get_background_image();
2344
+            if ( $background_image && wp_get_attachment_url( $post->ID ) === $background_image ) {
2345
+                $media_states[] = __( 'Current Background Image' );
2346
+            }
2347
+        }
2348
+    }
2349
+
2350
+    if ( (int) get_option( 'site_icon' ) === $post->ID ) {
2351
+        $media_states[] = __( 'Site Icon' );
2352
+    }
2353
+
2354
+    if ( (int) get_theme_mod( 'custom_logo' ) === $post->ID ) {
2355
+        $media_states[] = __( 'Logo' );
2356
+    }
2357
+
2358
+    /**
2359
+     * Filters the default media display states for items in the Media list table.
2360
+     *
2361
+     * @since 3.2.0
2362
+     * @since 4.8.0 Added the `$post` parameter.
2363
+     *
2364
+     * @param string[] $media_states An array of media states. Default 'Header Image',
2365
+     *                               'Background Image', 'Site Icon', 'Logo'.
2366
+     * @param WP_Post  $post         The current attachment object.
2367
+     */
2368
+    return apply_filters( 'display_media_states', $media_states, $post );
2369 2369
 }
2370 2370
 
2371 2371
 /**
@@ -2379,7 +2379,7 @@  discard block
 block discarded – undo
2379 2379
  * @since 2.8.0
2380 2380
  */
2381 2381
 function compression_test() {
2382
-	?>
2382
+    ?>
2383 2383
 	<script type="text/javascript">
2384 2384
 	var compressionNonce = <?php echo wp_json_encode( wp_create_nonce( 'update_can_compress_scripts' ) ); ?>;
2385 2385
 	var testCompression = {
@@ -2455,7 +2455,7 @@  discard block
 block discarded – undo
2455 2455
  *                                       preferred. Default null.
2456 2456
  */
2457 2457
 function submit_button( $text = null, $type = 'primary', $name = 'submit', $wrap = true, $other_attributes = null ) {
2458
-	echo get_submit_button( $text, $type, $name, $wrap, $other_attributes );
2458
+    echo get_submit_button( $text, $type, $name, $wrap, $other_attributes );
2459 2459
 }
2460 2460
 
2461 2461
 /**
@@ -2480,81 +2480,81 @@  discard block
 block discarded – undo
2480 2480
  * @return string Submit button HTML.
2481 2481
  */
2482 2482
 function get_submit_button( $text = '', $type = 'primary large', $name = 'submit', $wrap = true, $other_attributes = '' ) {
2483
-	if ( ! is_array( $type ) ) {
2484
-		$type = explode( ' ', $type );
2485
-	}
2486
-
2487
-	$button_shorthand = array( 'primary', 'small', 'large' );
2488
-	$classes          = array( 'button' );
2489
-
2490
-	foreach ( $type as $t ) {
2491
-		if ( 'secondary' === $t || 'button-secondary' === $t ) {
2492
-			continue;
2493
-		}
2494
-
2495
-		$classes[] = in_array( $t, $button_shorthand, true ) ? 'button-' . $t : $t;
2496
-	}
2497
-
2498
-	// Remove empty items, remove duplicate items, and finally build a string.
2499
-	$class = implode( ' ', array_unique( array_filter( $classes ) ) );
2500
-
2501
-	$text = $text ? $text : __( 'Save Changes' );
2502
-
2503
-	// Default the id attribute to $name unless an id was specifically provided in $other_attributes.
2504
-	$id = $name;
2505
-	if ( is_array( $other_attributes ) && isset( $other_attributes['id'] ) ) {
2506
-		$id = $other_attributes['id'];
2507
-		unset( $other_attributes['id'] );
2508
-	}
2509
-
2510
-	$attributes = '';
2511
-	if ( is_array( $other_attributes ) ) {
2512
-		foreach ( $other_attributes as $attribute => $value ) {
2513
-			$attributes .= $attribute . '="' . esc_attr( $value ) . '" '; // Trailing space is important.
2514
-		}
2515
-	} elseif ( ! empty( $other_attributes ) ) { // Attributes provided as a string.
2516
-		$attributes = $other_attributes;
2517
-	}
2518
-
2519
-	// Don't output empty name and id attributes.
2520
-	$name_attr = $name ? ' name="' . esc_attr( $name ) . '"' : '';
2521
-	$id_attr   = $id ? ' id="' . esc_attr( $id ) . '"' : '';
2522
-
2523
-	$button  = '<input type="submit"' . $name_attr . $id_attr . ' class="' . esc_attr( $class );
2524
-	$button .= '" value="' . esc_attr( $text ) . '" ' . $attributes . ' />';
2525
-
2526
-	if ( $wrap ) {
2527
-		$button = '<p class="submit">' . $button . '</p>';
2528
-	}
2529
-
2530
-	return $button;
2483
+    if ( ! is_array( $type ) ) {
2484
+        $type = explode( ' ', $type );
2485
+    }
2486
+
2487
+    $button_shorthand = array( 'primary', 'small', 'large' );
2488
+    $classes          = array( 'button' );
2489
+
2490
+    foreach ( $type as $t ) {
2491
+        if ( 'secondary' === $t || 'button-secondary' === $t ) {
2492
+            continue;
2493
+        }
2494
+
2495
+        $classes[] = in_array( $t, $button_shorthand, true ) ? 'button-' . $t : $t;
2496
+    }
2497
+
2498
+    // Remove empty items, remove duplicate items, and finally build a string.
2499
+    $class = implode( ' ', array_unique( array_filter( $classes ) ) );
2500
+
2501
+    $text = $text ? $text : __( 'Save Changes' );
2502
+
2503
+    // Default the id attribute to $name unless an id was specifically provided in $other_attributes.
2504
+    $id = $name;
2505
+    if ( is_array( $other_attributes ) && isset( $other_attributes['id'] ) ) {
2506
+        $id = $other_attributes['id'];
2507
+        unset( $other_attributes['id'] );
2508
+    }
2509
+
2510
+    $attributes = '';
2511
+    if ( is_array( $other_attributes ) ) {
2512
+        foreach ( $other_attributes as $attribute => $value ) {
2513
+            $attributes .= $attribute . '="' . esc_attr( $value ) . '" '; // Trailing space is important.
2514
+        }
2515
+    } elseif ( ! empty( $other_attributes ) ) { // Attributes provided as a string.
2516
+        $attributes = $other_attributes;
2517
+    }
2518
+
2519
+    // Don't output empty name and id attributes.
2520
+    $name_attr = $name ? ' name="' . esc_attr( $name ) . '"' : '';
2521
+    $id_attr   = $id ? ' id="' . esc_attr( $id ) . '"' : '';
2522
+
2523
+    $button  = '<input type="submit"' . $name_attr . $id_attr . ' class="' . esc_attr( $class );
2524
+    $button .= '" value="' . esc_attr( $text ) . '" ' . $attributes . ' />';
2525
+
2526
+    if ( $wrap ) {
2527
+        $button = '<p class="submit">' . $button . '</p>';
2528
+    }
2529
+
2530
+    return $button;
2531 2531
 }
2532 2532
 
2533 2533
 /**
2534 2534
  * @global bool $is_IE
2535 2535
  */
2536 2536
 function _wp_admin_html_begin() {
2537
-	global $is_IE;
2537
+    global $is_IE;
2538 2538
 
2539
-	$admin_html_class = ( is_admin_bar_showing() ) ? 'wp-toolbar' : '';
2539
+    $admin_html_class = ( is_admin_bar_showing() ) ? 'wp-toolbar' : '';
2540 2540
 
2541
-	if ( $is_IE ) {
2542
-		header( 'X-UA-Compatible: IE=edge' );
2543
-	}
2541
+    if ( $is_IE ) {
2542
+        header( 'X-UA-Compatible: IE=edge' );
2543
+    }
2544 2544
 
2545
-	?>
2545
+    ?>
2546 2546
 <!DOCTYPE html>
2547 2547
 <html class="<?php echo $admin_html_class; ?>"
2548 2548
 	<?php
2549
-	/**
2550
-	 * Fires inside the HTML tag in the admin header.
2551
-	 *
2552
-	 * @since 2.2.0
2553
-	 */
2554
-	do_action( 'admin_xml_ns' );
2555
-
2556
-	language_attributes();
2557
-	?>
2549
+    /**
2550
+     * Fires inside the HTML tag in the admin header.
2551
+     *
2552
+     * @since 2.2.0
2553
+     */
2554
+    do_action( 'admin_xml_ns' );
2555
+
2556
+    language_attributes();
2557
+    ?>
2558 2558
 >
2559 2559
 <head>
2560 2560
 <meta http-equiv="Content-Type" content="<?php bloginfo( 'html_type' ); ?>; charset=<?php echo get_option( 'blog_charset' ); ?>" />
@@ -2570,25 +2570,25 @@  discard block
 block discarded – undo
2570 2570
  * @return WP_Screen Screen object.
2571 2571
  */
2572 2572
 function convert_to_screen( $hook_name ) {
2573
-	if ( ! class_exists( 'WP_Screen' ) ) {
2574
-		_doing_it_wrong(
2575
-			'convert_to_screen(), add_meta_box()',
2576
-			sprintf(
2577
-				/* translators: 1: wp-admin/includes/template.php, 2: add_meta_box(), 3: add_meta_boxes */
2578
-				__( 'Likely direct inclusion of %1$s in order to use %2$s. This is very wrong. Hook the %2$s call into the %3$s action instead.' ),
2579
-				'<code>wp-admin/includes/template.php</code>',
2580
-				'<code>add_meta_box()</code>',
2581
-				'<code>add_meta_boxes</code>'
2582
-			),
2583
-			'3.3.0'
2584
-		);
2585
-		return (object) array(
2586
-			'id'   => '_invalid',
2587
-			'base' => '_are_belong_to_us',
2588
-		);
2589
-	}
2590
-
2591
-	return WP_Screen::get( $hook_name );
2573
+    if ( ! class_exists( 'WP_Screen' ) ) {
2574
+        _doing_it_wrong(
2575
+            'convert_to_screen(), add_meta_box()',
2576
+            sprintf(
2577
+                /* translators: 1: wp-admin/includes/template.php, 2: add_meta_box(), 3: add_meta_boxes */
2578
+                __( 'Likely direct inclusion of %1$s in order to use %2$s. This is very wrong. Hook the %2$s call into the %3$s action instead.' ),
2579
+                '<code>wp-admin/includes/template.php</code>',
2580
+                '<code>add_meta_box()</code>',
2581
+                '<code>add_meta_boxes</code>'
2582
+            ),
2583
+            '3.3.0'
2584
+        );
2585
+        return (object) array(
2586
+            'id'   => '_invalid',
2587
+            'base' => '_are_belong_to_us',
2588
+        );
2589
+    }
2590
+
2591
+    return WP_Screen::get( $hook_name );
2592 2592
 }
2593 2593
 
2594 2594
 /**
@@ -2598,7 +2598,7 @@  discard block
 block discarded – undo
2598 2598
  * @access private
2599 2599
  */
2600 2600
 function _local_storage_notice() {
2601
-	?>
2601
+    ?>
2602 2602
 	<div id="local-storage-notice" class="hidden notice is-dismissible">
2603 2603
 	<p class="local-restore">
2604 2604
 		<?php _e( 'The backup of this post in your browser is different from the version below.' ); ?>
@@ -2635,48 +2635,48 @@  discard block
 block discarded – undo
2635 2635
  * @return string Star rating HTML.
2636 2636
  */
2637 2637
 function wp_star_rating( $args = array() ) {
2638
-	$defaults    = array(
2639
-		'rating' => 0,
2640
-		'type'   => 'rating',
2641
-		'number' => 0,
2642
-		'echo'   => true,
2643
-	);
2644
-	$parsed_args = wp_parse_args( $args, $defaults );
2645
-
2646
-	// Non-English decimal places when the $rating is coming from a string.
2647
-	$rating = (float) str_replace( ',', '.', $parsed_args['rating'] );
2648
-
2649
-	// Convert percentage to star rating, 0..5 in .5 increments.
2650
-	if ( 'percent' === $parsed_args['type'] ) {
2651
-		$rating = round( $rating / 10, 0 ) / 2;
2652
-	}
2653
-
2654
-	// Calculate the number of each type of star needed.
2655
-	$full_stars  = floor( $rating );
2656
-	$half_stars  = ceil( $rating - $full_stars );
2657
-	$empty_stars = 5 - $full_stars - $half_stars;
2658
-
2659
-	if ( $parsed_args['number'] ) {
2660
-		/* translators: 1: The rating, 2: The number of ratings. */
2661
-		$format = _n( '%1$s rating based on %2$s rating', '%1$s rating based on %2$s ratings', $parsed_args['number'] );
2662
-		$title  = sprintf( $format, number_format_i18n( $rating, 1 ), number_format_i18n( $parsed_args['number'] ) );
2663
-	} else {
2664
-		/* translators: %s: The rating. */
2665
-		$title = sprintf( __( '%s rating' ), number_format_i18n( $rating, 1 ) );
2666
-	}
2667
-
2668
-	$output  = '<div class="star-rating">';
2669
-	$output .= '<span class="screen-reader-text">' . $title . '</span>';
2670
-	$output .= str_repeat( '<div class="star star-full" aria-hidden="true"></div>', $full_stars );
2671
-	$output .= str_repeat( '<div class="star star-half" aria-hidden="true"></div>', $half_stars );
2672
-	$output .= str_repeat( '<div class="star star-empty" aria-hidden="true"></div>', $empty_stars );
2673
-	$output .= '</div>';
2674
-
2675
-	if ( $parsed_args['echo'] ) {
2676
-		echo $output;
2677
-	}
2678
-
2679
-	return $output;
2638
+    $defaults    = array(
2639
+        'rating' => 0,
2640
+        'type'   => 'rating',
2641
+        'number' => 0,
2642
+        'echo'   => true,
2643
+    );
2644
+    $parsed_args = wp_parse_args( $args, $defaults );
2645
+
2646
+    // Non-English decimal places when the $rating is coming from a string.
2647
+    $rating = (float) str_replace( ',', '.', $parsed_args['rating'] );
2648
+
2649
+    // Convert percentage to star rating, 0..5 in .5 increments.
2650
+    if ( 'percent' === $parsed_args['type'] ) {
2651
+        $rating = round( $rating / 10, 0 ) / 2;
2652
+    }
2653
+
2654
+    // Calculate the number of each type of star needed.
2655
+    $full_stars  = floor( $rating );
2656
+    $half_stars  = ceil( $rating - $full_stars );
2657
+    $empty_stars = 5 - $full_stars - $half_stars;
2658
+
2659
+    if ( $parsed_args['number'] ) {
2660
+        /* translators: 1: The rating, 2: The number of ratings. */
2661
+        $format = _n( '%1$s rating based on %2$s rating', '%1$s rating based on %2$s ratings', $parsed_args['number'] );
2662
+        $title  = sprintf( $format, number_format_i18n( $rating, 1 ), number_format_i18n( $parsed_args['number'] ) );
2663
+    } else {
2664
+        /* translators: %s: The rating. */
2665
+        $title = sprintf( __( '%s rating' ), number_format_i18n( $rating, 1 ) );
2666
+    }
2667
+
2668
+    $output  = '<div class="star-rating">';
2669
+    $output .= '<span class="screen-reader-text">' . $title . '</span>';
2670
+    $output .= str_repeat( '<div class="star star-full" aria-hidden="true"></div>', $full_stars );
2671
+    $output .= str_repeat( '<div class="star star-half" aria-hidden="true"></div>', $half_stars );
2672
+    $output .= str_repeat( '<div class="star star-empty" aria-hidden="true"></div>', $empty_stars );
2673
+    $output .= '</div>';
2674
+
2675
+    if ( $parsed_args['echo'] ) {
2676
+        echo $output;
2677
+    }
2678
+
2679
+    return $output;
2680 2680
 }
2681 2681
 
2682 2682
 /**
@@ -2686,10 +2686,10 @@  discard block
 block discarded – undo
2686 2686
  * @since 4.2.0
2687 2687
  */
2688 2688
 function _wp_posts_page_notice() {
2689
-	printf(
2690
-		'<div class="notice notice-warning inline"><p>%s</p></div>',
2691
-		__( 'You are currently editing the page that shows your latest posts.' )
2692
-	);
2689
+    printf(
2690
+        '<div class="notice notice-warning inline"><p>%s</p></div>',
2691
+        __( 'You are currently editing the page that shows your latest posts.' )
2692
+    );
2693 2693
 }
2694 2694
 
2695 2695
 /**
@@ -2699,12 +2699,12 @@  discard block
 block discarded – undo
2699 2699
  * @since 5.8.0
2700 2700
  */
2701 2701
 function _wp_block_editor_posts_page_notice() {
2702
-	wp_add_inline_script(
2703
-		'wp-notices',
2704
-		sprintf(
2705
-			'wp.data.dispatch( "core/notices" ).createWarningNotice( "%s", { isDismissible: false } )',
2706
-			__( 'You are currently editing the page that shows your latest posts.' )
2707
-		),
2708
-		'after'
2709
-	);
2702
+    wp_add_inline_script(
2703
+        'wp-notices',
2704
+        sprintf(
2705
+            'wp.data.dispatch( "core/notices" ).createWarningNotice( "%s", { isDismissible: false } )',
2706
+            __( 'You are currently editing the page that shows your latest posts.' )
2707
+        ),
2708
+        'after'
2709
+    );
2710 2710
 }
Please login to merge, or discard this patch.
brighty/wp-admin/includes/plugin.php 1 patch
Indentation   +1466 added lines, -1466 removed lines patch added patch discarded remove patch
@@ -71,50 +71,50 @@  discard block
 block discarded – undo
71 71
  */
72 72
 function get_plugin_data( $plugin_file, $markup = true, $translate = true ) {
73 73
 
74
-	$default_headers = array(
75
-		'Name'        => 'Plugin Name',
76
-		'PluginURI'   => 'Plugin URI',
77
-		'Version'     => 'Version',
78
-		'Description' => 'Description',
79
-		'Author'      => 'Author',
80
-		'AuthorURI'   => 'Author URI',
81
-		'TextDomain'  => 'Text Domain',
82
-		'DomainPath'  => 'Domain Path',
83
-		'Network'     => 'Network',
84
-		'RequiresWP'  => 'Requires at least',
85
-		'RequiresPHP' => 'Requires PHP',
86
-		'UpdateURI'   => 'Update URI',
87
-		// Site Wide Only is deprecated in favor of Network.
88
-		'_sitewide'   => 'Site Wide Only',
89
-	);
90
-
91
-	$plugin_data = get_file_data( $plugin_file, $default_headers, 'plugin' );
92
-
93
-	// Site Wide Only is the old header for Network.
94
-	if ( ! $plugin_data['Network'] && $plugin_data['_sitewide'] ) {
95
-		/* translators: 1: Site Wide Only: true, 2: Network: true */
96
-		_deprecated_argument( __FUNCTION__, '3.0.0', sprintf( __( 'The %1$s plugin header is deprecated. Use %2$s instead.' ), '<code>Site Wide Only: true</code>', '<code>Network: true</code>' ) );
97
-		$plugin_data['Network'] = $plugin_data['_sitewide'];
98
-	}
99
-	$plugin_data['Network'] = ( 'true' === strtolower( $plugin_data['Network'] ) );
100
-	unset( $plugin_data['_sitewide'] );
101
-
102
-	// If no text domain is defined fall back to the plugin slug.
103
-	if ( ! $plugin_data['TextDomain'] ) {
104
-		$plugin_slug = dirname( plugin_basename( $plugin_file ) );
105
-		if ( '.' !== $plugin_slug && false === strpos( $plugin_slug, '/' ) ) {
106
-			$plugin_data['TextDomain'] = $plugin_slug;
107
-		}
108
-	}
109
-
110
-	if ( $markup || $translate ) {
111
-		$plugin_data = _get_plugin_data_markup_translate( $plugin_file, $plugin_data, $markup, $translate );
112
-	} else {
113
-		$plugin_data['Title']      = $plugin_data['Name'];
114
-		$plugin_data['AuthorName'] = $plugin_data['Author'];
115
-	}
116
-
117
-	return $plugin_data;
74
+    $default_headers = array(
75
+        'Name'        => 'Plugin Name',
76
+        'PluginURI'   => 'Plugin URI',
77
+        'Version'     => 'Version',
78
+        'Description' => 'Description',
79
+        'Author'      => 'Author',
80
+        'AuthorURI'   => 'Author URI',
81
+        'TextDomain'  => 'Text Domain',
82
+        'DomainPath'  => 'Domain Path',
83
+        'Network'     => 'Network',
84
+        'RequiresWP'  => 'Requires at least',
85
+        'RequiresPHP' => 'Requires PHP',
86
+        'UpdateURI'   => 'Update URI',
87
+        // Site Wide Only is deprecated in favor of Network.
88
+        '_sitewide'   => 'Site Wide Only',
89
+    );
90
+
91
+    $plugin_data = get_file_data( $plugin_file, $default_headers, 'plugin' );
92
+
93
+    // Site Wide Only is the old header for Network.
94
+    if ( ! $plugin_data['Network'] && $plugin_data['_sitewide'] ) {
95
+        /* translators: 1: Site Wide Only: true, 2: Network: true */
96
+        _deprecated_argument( __FUNCTION__, '3.0.0', sprintf( __( 'The %1$s plugin header is deprecated. Use %2$s instead.' ), '<code>Site Wide Only: true</code>', '<code>Network: true</code>' ) );
97
+        $plugin_data['Network'] = $plugin_data['_sitewide'];
98
+    }
99
+    $plugin_data['Network'] = ( 'true' === strtolower( $plugin_data['Network'] ) );
100
+    unset( $plugin_data['_sitewide'] );
101
+
102
+    // If no text domain is defined fall back to the plugin slug.
103
+    if ( ! $plugin_data['TextDomain'] ) {
104
+        $plugin_slug = dirname( plugin_basename( $plugin_file ) );
105
+        if ( '.' !== $plugin_slug && false === strpos( $plugin_slug, '/' ) ) {
106
+            $plugin_data['TextDomain'] = $plugin_slug;
107
+        }
108
+    }
109
+
110
+    if ( $markup || $translate ) {
111
+        $plugin_data = _get_plugin_data_markup_translate( $plugin_file, $plugin_data, $markup, $translate );
112
+    } else {
113
+        $plugin_data['Title']      = $plugin_data['Name'];
114
+        $plugin_data['AuthorName'] = $plugin_data['Author'];
115
+    }
116
+
117
+    return $plugin_data;
118 118
 }
119 119
 
120 120
 /**
@@ -136,84 +136,84 @@  discard block
 block discarded – undo
136 136
  */
137 137
 function _get_plugin_data_markup_translate( $plugin_file, $plugin_data, $markup = true, $translate = true ) {
138 138
 
139
-	// Sanitize the plugin filename to a WP_PLUGIN_DIR relative path.
140
-	$plugin_file = plugin_basename( $plugin_file );
141
-
142
-	// Translate fields.
143
-	if ( $translate ) {
144
-		$textdomain = $plugin_data['TextDomain'];
145
-		if ( $textdomain ) {
146
-			if ( ! is_textdomain_loaded( $textdomain ) ) {
147
-				if ( $plugin_data['DomainPath'] ) {
148
-					load_plugin_textdomain( $textdomain, false, dirname( $plugin_file ) . $plugin_data['DomainPath'] );
149
-				} else {
150
-					load_plugin_textdomain( $textdomain, false, dirname( $plugin_file ) );
151
-				}
152
-			}
153
-		} elseif ( 'hello.php' === basename( $plugin_file ) ) {
154
-			$textdomain = 'default';
155
-		}
156
-		if ( $textdomain ) {
157
-			foreach ( array( 'Name', 'PluginURI', 'Description', 'Author', 'AuthorURI', 'Version' ) as $field ) {
158
-				if ( ! empty( $plugin_data[ $field ] ) ) {
159
-					// phpcs:ignore WordPress.WP.I18n.LowLevelTranslationFunction,WordPress.WP.I18n.NonSingularStringLiteralText,WordPress.WP.I18n.NonSingularStringLiteralDomain
160
-					$plugin_data[ $field ] = translate( $plugin_data[ $field ], $textdomain );
161
-				}
162
-			}
163
-		}
164
-	}
165
-
166
-	// Sanitize fields.
167
-	$allowed_tags_in_links = array(
168
-		'abbr'    => array( 'title' => true ),
169
-		'acronym' => array( 'title' => true ),
170
-		'code'    => true,
171
-		'em'      => true,
172
-		'strong'  => true,
173
-	);
174
-
175
-	$allowed_tags      = $allowed_tags_in_links;
176
-	$allowed_tags['a'] = array(
177
-		'href'  => true,
178
-		'title' => true,
179
-	);
180
-
181
-	// Name is marked up inside <a> tags. Don't allow these.
182
-	// Author is too, but some plugins have used <a> here (omitting Author URI).
183
-	$plugin_data['Name']   = wp_kses( $plugin_data['Name'], $allowed_tags_in_links );
184
-	$plugin_data['Author'] = wp_kses( $plugin_data['Author'], $allowed_tags );
185
-
186
-	$plugin_data['Description'] = wp_kses( $plugin_data['Description'], $allowed_tags );
187
-	$plugin_data['Version']     = wp_kses( $plugin_data['Version'], $allowed_tags );
188
-
189
-	$plugin_data['PluginURI'] = esc_url( $plugin_data['PluginURI'] );
190
-	$plugin_data['AuthorURI'] = esc_url( $plugin_data['AuthorURI'] );
191
-
192
-	$plugin_data['Title']      = $plugin_data['Name'];
193
-	$plugin_data['AuthorName'] = $plugin_data['Author'];
194
-
195
-	// Apply markup.
196
-	if ( $markup ) {
197
-		if ( $plugin_data['PluginURI'] && $plugin_data['Name'] ) {
198
-			$plugin_data['Title'] = '<a href="' . $plugin_data['PluginURI'] . '">' . $plugin_data['Name'] . '</a>';
199
-		}
200
-
201
-		if ( $plugin_data['AuthorURI'] && $plugin_data['Author'] ) {
202
-			$plugin_data['Author'] = '<a href="' . $plugin_data['AuthorURI'] . '">' . $plugin_data['Author'] . '</a>';
203
-		}
204
-
205
-		$plugin_data['Description'] = wptexturize( $plugin_data['Description'] );
206
-
207
-		if ( $plugin_data['Author'] ) {
208
-			$plugin_data['Description'] .= sprintf(
209
-				/* translators: %s: Plugin author. */
210
-				' <cite>' . __( 'By %s.' ) . '</cite>',
211
-				$plugin_data['Author']
212
-			);
213
-		}
214
-	}
215
-
216
-	return $plugin_data;
139
+    // Sanitize the plugin filename to a WP_PLUGIN_DIR relative path.
140
+    $plugin_file = plugin_basename( $plugin_file );
141
+
142
+    // Translate fields.
143
+    if ( $translate ) {
144
+        $textdomain = $plugin_data['TextDomain'];
145
+        if ( $textdomain ) {
146
+            if ( ! is_textdomain_loaded( $textdomain ) ) {
147
+                if ( $plugin_data['DomainPath'] ) {
148
+                    load_plugin_textdomain( $textdomain, false, dirname( $plugin_file ) . $plugin_data['DomainPath'] );
149
+                } else {
150
+                    load_plugin_textdomain( $textdomain, false, dirname( $plugin_file ) );
151
+                }
152
+            }
153
+        } elseif ( 'hello.php' === basename( $plugin_file ) ) {
154
+            $textdomain = 'default';
155
+        }
156
+        if ( $textdomain ) {
157
+            foreach ( array( 'Name', 'PluginURI', 'Description', 'Author', 'AuthorURI', 'Version' ) as $field ) {
158
+                if ( ! empty( $plugin_data[ $field ] ) ) {
159
+                    // phpcs:ignore WordPress.WP.I18n.LowLevelTranslationFunction,WordPress.WP.I18n.NonSingularStringLiteralText,WordPress.WP.I18n.NonSingularStringLiteralDomain
160
+                    $plugin_data[ $field ] = translate( $plugin_data[ $field ], $textdomain );
161
+                }
162
+            }
163
+        }
164
+    }
165
+
166
+    // Sanitize fields.
167
+    $allowed_tags_in_links = array(
168
+        'abbr'    => array( 'title' => true ),
169
+        'acronym' => array( 'title' => true ),
170
+        'code'    => true,
171
+        'em'      => true,
172
+        'strong'  => true,
173
+    );
174
+
175
+    $allowed_tags      = $allowed_tags_in_links;
176
+    $allowed_tags['a'] = array(
177
+        'href'  => true,
178
+        'title' => true,
179
+    );
180
+
181
+    // Name is marked up inside <a> tags. Don't allow these.
182
+    // Author is too, but some plugins have used <a> here (omitting Author URI).
183
+    $plugin_data['Name']   = wp_kses( $plugin_data['Name'], $allowed_tags_in_links );
184
+    $plugin_data['Author'] = wp_kses( $plugin_data['Author'], $allowed_tags );
185
+
186
+    $plugin_data['Description'] = wp_kses( $plugin_data['Description'], $allowed_tags );
187
+    $plugin_data['Version']     = wp_kses( $plugin_data['Version'], $allowed_tags );
188
+
189
+    $plugin_data['PluginURI'] = esc_url( $plugin_data['PluginURI'] );
190
+    $plugin_data['AuthorURI'] = esc_url( $plugin_data['AuthorURI'] );
191
+
192
+    $plugin_data['Title']      = $plugin_data['Name'];
193
+    $plugin_data['AuthorName'] = $plugin_data['Author'];
194
+
195
+    // Apply markup.
196
+    if ( $markup ) {
197
+        if ( $plugin_data['PluginURI'] && $plugin_data['Name'] ) {
198
+            $plugin_data['Title'] = '<a href="' . $plugin_data['PluginURI'] . '">' . $plugin_data['Name'] . '</a>';
199
+        }
200
+
201
+        if ( $plugin_data['AuthorURI'] && $plugin_data['Author'] ) {
202
+            $plugin_data['Author'] = '<a href="' . $plugin_data['AuthorURI'] . '">' . $plugin_data['Author'] . '</a>';
203
+        }
204
+
205
+        $plugin_data['Description'] = wptexturize( $plugin_data['Description'] );
206
+
207
+        if ( $plugin_data['Author'] ) {
208
+            $plugin_data['Description'] .= sprintf(
209
+                /* translators: %s: Plugin author. */
210
+                ' <cite>' . __( 'By %s.' ) . '</cite>',
211
+                $plugin_data['Author']
212
+            );
213
+        }
214
+    }
215
+
216
+    return $plugin_data;
217 217
 }
218 218
 
219 219
 /**
@@ -225,30 +225,30 @@  discard block
 block discarded – undo
225 225
  * @return string[] Array of file names relative to the plugin root.
226 226
  */
227 227
 function get_plugin_files( $plugin ) {
228
-	$plugin_file = WP_PLUGIN_DIR . '/' . $plugin;
229
-	$dir         = dirname( $plugin_file );
228
+    $plugin_file = WP_PLUGIN_DIR . '/' . $plugin;
229
+    $dir         = dirname( $plugin_file );
230 230
 
231
-	$plugin_files = array( plugin_basename( $plugin_file ) );
231
+    $plugin_files = array( plugin_basename( $plugin_file ) );
232 232
 
233
-	if ( is_dir( $dir ) && WP_PLUGIN_DIR !== $dir ) {
233
+    if ( is_dir( $dir ) && WP_PLUGIN_DIR !== $dir ) {
234 234
 
235
-		/**
236
-		 * Filters the array of excluded directories and files while scanning the folder.
237
-		 *
238
-		 * @since 4.9.0
239
-		 *
240
-		 * @param string[] $exclusions Array of excluded directories and files.
241
-		 */
242
-		$exclusions = (array) apply_filters( 'plugin_files_exclusions', array( 'CVS', 'node_modules', 'vendor', 'bower_components' ) );
235
+        /**
236
+         * Filters the array of excluded directories and files while scanning the folder.
237
+         *
238
+         * @since 4.9.0
239
+         *
240
+         * @param string[] $exclusions Array of excluded directories and files.
241
+         */
242
+        $exclusions = (array) apply_filters( 'plugin_files_exclusions', array( 'CVS', 'node_modules', 'vendor', 'bower_components' ) );
243 243
 
244
-		$list_files = list_files( $dir, 100, $exclusions );
245
-		$list_files = array_map( 'plugin_basename', $list_files );
244
+        $list_files = list_files( $dir, 100, $exclusions );
245
+        $list_files = array_map( 'plugin_basename', $list_files );
246 246
 
247
-		$plugin_files = array_merge( $plugin_files, $list_files );
248
-		$plugin_files = array_values( array_unique( $plugin_files ) );
249
-	}
247
+        $plugin_files = array_merge( $plugin_files, $list_files );
248
+        $plugin_files = array_values( array_unique( $plugin_files ) );
249
+    }
250 250
 
251
-	return $plugin_files;
251
+    return $plugin_files;
252 252
 }
253 253
 
254 254
 /**
@@ -273,82 +273,82 @@  discard block
 block discarded – undo
273 273
  */
274 274
 function get_plugins( $plugin_folder = '' ) {
275 275
 
276
-	$cache_plugins = wp_cache_get( 'plugins', 'plugins' );
277
-	if ( ! $cache_plugins ) {
278
-		$cache_plugins = array();
279
-	}
280
-
281
-	if ( isset( $cache_plugins[ $plugin_folder ] ) ) {
282
-		return $cache_plugins[ $plugin_folder ];
283
-	}
284
-
285
-	$wp_plugins  = array();
286
-	$plugin_root = WP_PLUGIN_DIR;
287
-	if ( ! empty( $plugin_folder ) ) {
288
-		$plugin_root .= $plugin_folder;
289
-	}
290
-
291
-	// Files in wp-content/plugins directory.
292
-	$plugins_dir  = @opendir( $plugin_root );
293
-	$plugin_files = array();
294
-
295
-	if ( $plugins_dir ) {
296
-		while ( ( $file = readdir( $plugins_dir ) ) !== false ) {
297
-			if ( '.' === substr( $file, 0, 1 ) ) {
298
-				continue;
299
-			}
300
-
301
-			if ( is_dir( $plugin_root . '/' . $file ) ) {
302
-				$plugins_subdir = @opendir( $plugin_root . '/' . $file );
303
-
304
-				if ( $plugins_subdir ) {
305
-					while ( ( $subfile = readdir( $plugins_subdir ) ) !== false ) {
306
-						if ( '.' === substr( $subfile, 0, 1 ) ) {
307
-							continue;
308
-						}
309
-
310
-						if ( '.php' === substr( $subfile, -4 ) ) {
311
-							$plugin_files[] = "$file/$subfile";
312
-						}
313
-					}
314
-
315
-					closedir( $plugins_subdir );
316
-				}
317
-			} else {
318
-				if ( '.php' === substr( $file, -4 ) ) {
319
-					$plugin_files[] = $file;
320
-				}
321
-			}
322
-		}
323
-
324
-		closedir( $plugins_dir );
325
-	}
326
-
327
-	if ( empty( $plugin_files ) ) {
328
-		return $wp_plugins;
329
-	}
330
-
331
-	foreach ( $plugin_files as $plugin_file ) {
332
-		if ( ! is_readable( "$plugin_root/$plugin_file" ) ) {
333
-			continue;
334
-		}
335
-
336
-		// Do not apply markup/translate as it will be cached.
337
-		$plugin_data = get_plugin_data( "$plugin_root/$plugin_file", false, false );
338
-
339
-		if ( empty( $plugin_data['Name'] ) ) {
340
-			continue;
341
-		}
342
-
343
-		$wp_plugins[ plugin_basename( $plugin_file ) ] = $plugin_data;
344
-	}
345
-
346
-	uasort( $wp_plugins, '_sort_uname_callback' );
347
-
348
-	$cache_plugins[ $plugin_folder ] = $wp_plugins;
349
-	wp_cache_set( 'plugins', $cache_plugins, 'plugins' );
350
-
351
-	return $wp_plugins;
276
+    $cache_plugins = wp_cache_get( 'plugins', 'plugins' );
277
+    if ( ! $cache_plugins ) {
278
+        $cache_plugins = array();
279
+    }
280
+
281
+    if ( isset( $cache_plugins[ $plugin_folder ] ) ) {
282
+        return $cache_plugins[ $plugin_folder ];
283
+    }
284
+
285
+    $wp_plugins  = array();
286
+    $plugin_root = WP_PLUGIN_DIR;
287
+    if ( ! empty( $plugin_folder ) ) {
288
+        $plugin_root .= $plugin_folder;
289
+    }
290
+
291
+    // Files in wp-content/plugins directory.
292
+    $plugins_dir  = @opendir( $plugin_root );
293
+    $plugin_files = array();
294
+
295
+    if ( $plugins_dir ) {
296
+        while ( ( $file = readdir( $plugins_dir ) ) !== false ) {
297
+            if ( '.' === substr( $file, 0, 1 ) ) {
298
+                continue;
299
+            }
300
+
301
+            if ( is_dir( $plugin_root . '/' . $file ) ) {
302
+                $plugins_subdir = @opendir( $plugin_root . '/' . $file );
303
+
304
+                if ( $plugins_subdir ) {
305
+                    while ( ( $subfile = readdir( $plugins_subdir ) ) !== false ) {
306
+                        if ( '.' === substr( $subfile, 0, 1 ) ) {
307
+                            continue;
308
+                        }
309
+
310
+                        if ( '.php' === substr( $subfile, -4 ) ) {
311
+                            $plugin_files[] = "$file/$subfile";
312
+                        }
313
+                    }
314
+
315
+                    closedir( $plugins_subdir );
316
+                }
317
+            } else {
318
+                if ( '.php' === substr( $file, -4 ) ) {
319
+                    $plugin_files[] = $file;
320
+                }
321
+            }
322
+        }
323
+
324
+        closedir( $plugins_dir );
325
+    }
326
+
327
+    if ( empty( $plugin_files ) ) {
328
+        return $wp_plugins;
329
+    }
330
+
331
+    foreach ( $plugin_files as $plugin_file ) {
332
+        if ( ! is_readable( "$plugin_root/$plugin_file" ) ) {
333
+            continue;
334
+        }
335
+
336
+        // Do not apply markup/translate as it will be cached.
337
+        $plugin_data = get_plugin_data( "$plugin_root/$plugin_file", false, false );
338
+
339
+        if ( empty( $plugin_data['Name'] ) ) {
340
+            continue;
341
+        }
342
+
343
+        $wp_plugins[ plugin_basename( $plugin_file ) ] = $plugin_data;
344
+    }
345
+
346
+    uasort( $wp_plugins, '_sort_uname_callback' );
347
+
348
+    $cache_plugins[ $plugin_folder ] = $wp_plugins;
349
+    wp_cache_set( 'plugins', $cache_plugins, 'plugins' );
350
+
351
+    return $wp_plugins;
352 352
 }
353 353
 
354 354
 /**
@@ -360,54 +360,54 @@  discard block
 block discarded – undo
360 360
  * @return array[] Array of arrays of mu-plugin data, keyed by plugin file name. See `get_plugin_data()`.
361 361
  */
362 362
 function get_mu_plugins() {
363
-	$wp_plugins   = array();
364
-	$plugin_files = array();
365
-
366
-	if ( ! is_dir( WPMU_PLUGIN_DIR ) ) {
367
-		return $wp_plugins;
368
-	}
369
-
370
-	// Files in wp-content/mu-plugins directory.
371
-	$plugins_dir = @opendir( WPMU_PLUGIN_DIR );
372
-	if ( $plugins_dir ) {
373
-		while ( ( $file = readdir( $plugins_dir ) ) !== false ) {
374
-			if ( '.php' === substr( $file, -4 ) ) {
375
-				$plugin_files[] = $file;
376
-			}
377
-		}
378
-	} else {
379
-		return $wp_plugins;
380
-	}
381
-
382
-	closedir( $plugins_dir );
383
-
384
-	if ( empty( $plugin_files ) ) {
385
-		return $wp_plugins;
386
-	}
387
-
388
-	foreach ( $plugin_files as $plugin_file ) {
389
-		if ( ! is_readable( WPMU_PLUGIN_DIR . "/$plugin_file" ) ) {
390
-			continue;
391
-		}
392
-
393
-		// Do not apply markup/translate as it will be cached.
394
-		$plugin_data = get_plugin_data( WPMU_PLUGIN_DIR . "/$plugin_file", false, false );
395
-
396
-		if ( empty( $plugin_data['Name'] ) ) {
397
-			$plugin_data['Name'] = $plugin_file;
398
-		}
399
-
400
-		$wp_plugins[ $plugin_file ] = $plugin_data;
401
-	}
402
-
403
-	if ( isset( $wp_plugins['index.php'] ) && filesize( WPMU_PLUGIN_DIR . '/index.php' ) <= 30 ) {
404
-		// Silence is golden.
405
-		unset( $wp_plugins['index.php'] );
406
-	}
407
-
408
-	uasort( $wp_plugins, '_sort_uname_callback' );
409
-
410
-	return $wp_plugins;
363
+    $wp_plugins   = array();
364
+    $plugin_files = array();
365
+
366
+    if ( ! is_dir( WPMU_PLUGIN_DIR ) ) {
367
+        return $wp_plugins;
368
+    }
369
+
370
+    // Files in wp-content/mu-plugins directory.
371
+    $plugins_dir = @opendir( WPMU_PLUGIN_DIR );
372
+    if ( $plugins_dir ) {
373
+        while ( ( $file = readdir( $plugins_dir ) ) !== false ) {
374
+            if ( '.php' === substr( $file, -4 ) ) {
375
+                $plugin_files[] = $file;
376
+            }
377
+        }
378
+    } else {
379
+        return $wp_plugins;
380
+    }
381
+
382
+    closedir( $plugins_dir );
383
+
384
+    if ( empty( $plugin_files ) ) {
385
+        return $wp_plugins;
386
+    }
387
+
388
+    foreach ( $plugin_files as $plugin_file ) {
389
+        if ( ! is_readable( WPMU_PLUGIN_DIR . "/$plugin_file" ) ) {
390
+            continue;
391
+        }
392
+
393
+        // Do not apply markup/translate as it will be cached.
394
+        $plugin_data = get_plugin_data( WPMU_PLUGIN_DIR . "/$plugin_file", false, false );
395
+
396
+        if ( empty( $plugin_data['Name'] ) ) {
397
+            $plugin_data['Name'] = $plugin_file;
398
+        }
399
+
400
+        $wp_plugins[ $plugin_file ] = $plugin_data;
401
+    }
402
+
403
+    if ( isset( $wp_plugins['index.php'] ) && filesize( WPMU_PLUGIN_DIR . '/index.php' ) <= 30 ) {
404
+        // Silence is golden.
405
+        unset( $wp_plugins['index.php'] );
406
+    }
407
+
408
+    uasort( $wp_plugins, '_sort_uname_callback' );
409
+
410
+    return $wp_plugins;
411 411
 }
412 412
 
413 413
 /**
@@ -422,7 +422,7 @@  discard block
 block discarded – undo
422 422
  * @return int Return 0 or 1 based on two string comparison.
423 423
  */
424 424
 function _sort_uname_callback( $a, $b ) {
425
-	return strnatcasecmp( $a['Name'], $b['Name'] );
425
+    return strnatcasecmp( $a['Name'], $b['Name'] );
426 426
 }
427 427
 
428 428
 /**
@@ -432,47 +432,47 @@  discard block
 block discarded – undo
432 432
  * @return array[] Array of arrays of dropin plugin data, keyed by plugin file name. See `get_plugin_data()`.
433 433
  */
434 434
 function get_dropins() {
435
-	$dropins      = array();
436
-	$plugin_files = array();
435
+    $dropins      = array();
436
+    $plugin_files = array();
437 437
 
438
-	$_dropins = _get_dropins();
438
+    $_dropins = _get_dropins();
439 439
 
440
-	// Files in wp-content directory.
441
-	$plugins_dir = @opendir( WP_CONTENT_DIR );
442
-	if ( $plugins_dir ) {
443
-		while ( ( $file = readdir( $plugins_dir ) ) !== false ) {
444
-			if ( isset( $_dropins[ $file ] ) ) {
445
-				$plugin_files[] = $file;
446
-			}
447
-		}
448
-	} else {
449
-		return $dropins;
450
-	}
440
+    // Files in wp-content directory.
441
+    $plugins_dir = @opendir( WP_CONTENT_DIR );
442
+    if ( $plugins_dir ) {
443
+        while ( ( $file = readdir( $plugins_dir ) ) !== false ) {
444
+            if ( isset( $_dropins[ $file ] ) ) {
445
+                $plugin_files[] = $file;
446
+            }
447
+        }
448
+    } else {
449
+        return $dropins;
450
+    }
451 451
 
452
-	closedir( $plugins_dir );
452
+    closedir( $plugins_dir );
453 453
 
454
-	if ( empty( $plugin_files ) ) {
455
-		return $dropins;
456
-	}
454
+    if ( empty( $plugin_files ) ) {
455
+        return $dropins;
456
+    }
457 457
 
458
-	foreach ( $plugin_files as $plugin_file ) {
459
-		if ( ! is_readable( WP_CONTENT_DIR . "/$plugin_file" ) ) {
460
-			continue;
461
-		}
458
+    foreach ( $plugin_files as $plugin_file ) {
459
+        if ( ! is_readable( WP_CONTENT_DIR . "/$plugin_file" ) ) {
460
+            continue;
461
+        }
462 462
 
463
-		// Do not apply markup/translate as it will be cached.
464
-		$plugin_data = get_plugin_data( WP_CONTENT_DIR . "/$plugin_file", false, false );
463
+        // Do not apply markup/translate as it will be cached.
464
+        $plugin_data = get_plugin_data( WP_CONTENT_DIR . "/$plugin_file", false, false );
465 465
 
466
-		if ( empty( $plugin_data['Name'] ) ) {
467
-			$plugin_data['Name'] = $plugin_file;
468
-		}
466
+        if ( empty( $plugin_data['Name'] ) ) {
467
+            $plugin_data['Name'] = $plugin_file;
468
+        }
469 469
 
470
-		$dropins[ $plugin_file ] = $plugin_data;
471
-	}
470
+        $dropins[ $plugin_file ] = $plugin_data;
471
+    }
472 472
 
473
-	uksort( $dropins, 'strnatcasecmp' );
473
+    uksort( $dropins, 'strnatcasecmp' );
474 474
 
475
-	return $dropins;
475
+    return $dropins;
476 476
 }
477 477
 
478 478
 /**
@@ -486,25 +486,25 @@  discard block
 block discarded – undo
486 486
  *  true for the drop-in to be used, or true if no constant is required.
487 487
  */
488 488
 function _get_dropins() {
489
-	$dropins = array(
490
-		'advanced-cache.php'      => array( __( 'Advanced caching plugin.' ), 'WP_CACHE' ),  // WP_CACHE
491
-		'db.php'                  => array( __( 'Custom database class.' ), true ),          // Auto on load.
492
-		'db-error.php'            => array( __( 'Custom database error message.' ), true ),  // Auto on error.
493
-		'install.php'             => array( __( 'Custom installation script.' ), true ),     // Auto on installation.
494
-		'maintenance.php'         => array( __( 'Custom maintenance message.' ), true ),     // Auto on maintenance.
495
-		'object-cache.php'        => array( __( 'External object cache.' ), true ),          // Auto on load.
496
-		'php-error.php'           => array( __( 'Custom PHP error message.' ), true ),       // Auto on error.
497
-		'fatal-error-handler.php' => array( __( 'Custom PHP fatal error handler.' ), true ), // Auto on error.
498
-	);
499
-
500
-	if ( is_multisite() ) {
501
-		$dropins['sunrise.php']        = array( __( 'Executed before Multisite is loaded.' ), 'SUNRISE' ); // SUNRISE
502
-		$dropins['blog-deleted.php']   = array( __( 'Custom site deleted message.' ), true );   // Auto on deleted blog.
503
-		$dropins['blog-inactive.php']  = array( __( 'Custom site inactive message.' ), true );  // Auto on inactive blog.
504
-		$dropins['blog-suspended.php'] = array( __( 'Custom site suspended message.' ), true ); // Auto on archived or spammed blog.
505
-	}
506
-
507
-	return $dropins;
489
+    $dropins = array(
490
+        'advanced-cache.php'      => array( __( 'Advanced caching plugin.' ), 'WP_CACHE' ),  // WP_CACHE
491
+        'db.php'                  => array( __( 'Custom database class.' ), true ),          // Auto on load.
492
+        'db-error.php'            => array( __( 'Custom database error message.' ), true ),  // Auto on error.
493
+        'install.php'             => array( __( 'Custom installation script.' ), true ),     // Auto on installation.
494
+        'maintenance.php'         => array( __( 'Custom maintenance message.' ), true ),     // Auto on maintenance.
495
+        'object-cache.php'        => array( __( 'External object cache.' ), true ),          // Auto on load.
496
+        'php-error.php'           => array( __( 'Custom PHP error message.' ), true ),       // Auto on error.
497
+        'fatal-error-handler.php' => array( __( 'Custom PHP fatal error handler.' ), true ), // Auto on error.
498
+    );
499
+
500
+    if ( is_multisite() ) {
501
+        $dropins['sunrise.php']        = array( __( 'Executed before Multisite is loaded.' ), 'SUNRISE' ); // SUNRISE
502
+        $dropins['blog-deleted.php']   = array( __( 'Custom site deleted message.' ), true );   // Auto on deleted blog.
503
+        $dropins['blog-inactive.php']  = array( __( 'Custom site inactive message.' ), true );  // Auto on inactive blog.
504
+        $dropins['blog-suspended.php'] = array( __( 'Custom site suspended message.' ), true ); // Auto on archived or spammed blog.
505
+    }
506
+
507
+    return $dropins;
508 508
 }
509 509
 
510 510
 /**
@@ -525,7 +525,7 @@  discard block
 block discarded – undo
525 525
  * @return bool True, if in the active plugins list. False, not in the list.
526 526
  */
527 527
 function is_plugin_active( $plugin ) {
528
-	return in_array( $plugin, (array) get_option( 'active_plugins', array() ), true ) || is_plugin_active_for_network( $plugin );
528
+    return in_array( $plugin, (array) get_option( 'active_plugins', array() ), true ) || is_plugin_active_for_network( $plugin );
529 529
 }
530 530
 
531 531
 /**
@@ -545,7 +545,7 @@  discard block
 block discarded – undo
545 545
  * @return bool True if inactive. False if active.
546 546
  */
547 547
 function is_plugin_inactive( $plugin ) {
548
-	return ! is_plugin_active( $plugin );
548
+    return ! is_plugin_active( $plugin );
549 549
 }
550 550
 
551 551
 /**
@@ -566,16 +566,16 @@  discard block
 block discarded – undo
566 566
  * @return bool True if active for the network, otherwise false.
567 567
  */
568 568
 function is_plugin_active_for_network( $plugin ) {
569
-	if ( ! is_multisite() ) {
570
-		return false;
571
-	}
569
+    if ( ! is_multisite() ) {
570
+        return false;
571
+    }
572 572
 
573
-	$plugins = get_site_option( 'active_sitewide_plugins' );
574
-	if ( isset( $plugins[ $plugin ] ) ) {
575
-		return true;
576
-	}
573
+    $plugins = get_site_option( 'active_sitewide_plugins' );
574
+    if ( isset( $plugins[ $plugin ] ) ) {
575
+        return true;
576
+    }
577 577
 
578
-	return false;
578
+    return false;
579 579
 }
580 580
 
581 581
 /**
@@ -591,11 +591,11 @@  discard block
 block discarded – undo
591 591
  * @return bool True if plugin is network only, false otherwise.
592 592
  */
593 593
 function is_network_only_plugin( $plugin ) {
594
-	$plugin_data = get_plugin_data( WP_PLUGIN_DIR . '/' . $plugin );
595
-	if ( $plugin_data ) {
596
-		return $plugin_data['Network'];
597
-	}
598
-	return false;
594
+    $plugin_data = get_plugin_data( WP_PLUGIN_DIR . '/' . $plugin );
595
+    if ( $plugin_data ) {
596
+        return $plugin_data['Network'];
597
+    }
598
+    return false;
599 599
 }
600 600
 
601 601
 /**
@@ -627,106 +627,106 @@  discard block
 block discarded – undo
627 627
  * @return null|WP_Error Null on success, WP_Error on invalid file.
628 628
  */
629 629
 function activate_plugin( $plugin, $redirect = '', $network_wide = false, $silent = false ) {
630
-	$plugin = plugin_basename( trim( $plugin ) );
631
-
632
-	if ( is_multisite() && ( $network_wide || is_network_only_plugin( $plugin ) ) ) {
633
-		$network_wide        = true;
634
-		$current             = get_site_option( 'active_sitewide_plugins', array() );
635
-		$_GET['networkwide'] = 1; // Back compat for plugins looking for this value.
636
-	} else {
637
-		$current = get_option( 'active_plugins', array() );
638
-	}
639
-
640
-	$valid = validate_plugin( $plugin );
641
-	if ( is_wp_error( $valid ) ) {
642
-		return $valid;
643
-	}
644
-
645
-	$requirements = validate_plugin_requirements( $plugin );
646
-	if ( is_wp_error( $requirements ) ) {
647
-		return $requirements;
648
-	}
649
-
650
-	if ( $network_wide && ! isset( $current[ $plugin ] )
651
-		|| ! $network_wide && ! in_array( $plugin, $current, true )
652
-	) {
653
-		if ( ! empty( $redirect ) ) {
654
-			// We'll override this later if the plugin can be included without fatal error.
655
-			wp_redirect( add_query_arg( '_error_nonce', wp_create_nonce( 'plugin-activation-error_' . $plugin ), $redirect ) );
656
-		}
657
-
658
-		ob_start();
659
-
660
-		// Load the plugin to test whether it throws any errors.
661
-		plugin_sandbox_scrape( $plugin );
662
-
663
-		if ( ! $silent ) {
664
-			/**
665
-			 * Fires before a plugin is activated.
666
-			 *
667
-			 * If a plugin is silently activated (such as during an update),
668
-			 * this hook does not fire.
669
-			 *
670
-			 * @since 2.9.0
671
-			 *
672
-			 * @param string $plugin       Path to the plugin file relative to the plugins directory.
673
-			 * @param bool   $network_wide Whether to enable the plugin for all sites in the network
674
-			 *                             or just the current site. Multisite only. Default false.
675
-			 */
676
-			do_action( 'activate_plugin', $plugin, $network_wide );
677
-
678
-			/**
679
-			 * Fires as a specific plugin is being activated.
680
-			 *
681
-			 * This hook is the "activation" hook used internally by register_activation_hook().
682
-			 * The dynamic portion of the hook name, `$plugin`, refers to the plugin basename.
683
-			 *
684
-			 * If a plugin is silently activated (such as during an update), this hook does not fire.
685
-			 *
686
-			 * @since 2.0.0
687
-			 *
688
-			 * @param bool $network_wide Whether to enable the plugin for all sites in the network
689
-			 *                           or just the current site. Multisite only. Default false.
690
-			 */
691
-			do_action( "activate_{$plugin}", $network_wide );
692
-		}
693
-
694
-		if ( $network_wide ) {
695
-			$current            = get_site_option( 'active_sitewide_plugins', array() );
696
-			$current[ $plugin ] = time();
697
-			update_site_option( 'active_sitewide_plugins', $current );
698
-		} else {
699
-			$current   = get_option( 'active_plugins', array() );
700
-			$current[] = $plugin;
701
-			sort( $current );
702
-			update_option( 'active_plugins', $current );
703
-		}
704
-
705
-		if ( ! $silent ) {
706
-			/**
707
-			 * Fires after a plugin has been activated.
708
-			 *
709
-			 * If a plugin is silently activated (such as during an update),
710
-			 * this hook does not fire.
711
-			 *
712
-			 * @since 2.9.0
713
-			 *
714
-			 * @param string $plugin       Path to the plugin file relative to the plugins directory.
715
-			 * @param bool   $network_wide Whether to enable the plugin for all sites in the network
716
-			 *                             or just the current site. Multisite only. Default false.
717
-			 */
718
-			do_action( 'activated_plugin', $plugin, $network_wide );
719
-		}
720
-
721
-		if ( ob_get_length() > 0 ) {
722
-			$output = ob_get_clean();
723
-			return new WP_Error( 'unexpected_output', __( 'The plugin generated unexpected output.' ), $output );
724
-		}
725
-
726
-		ob_end_clean();
727
-	}
728
-
729
-	return null;
630
+    $plugin = plugin_basename( trim( $plugin ) );
631
+
632
+    if ( is_multisite() && ( $network_wide || is_network_only_plugin( $plugin ) ) ) {
633
+        $network_wide        = true;
634
+        $current             = get_site_option( 'active_sitewide_plugins', array() );
635
+        $_GET['networkwide'] = 1; // Back compat for plugins looking for this value.
636
+    } else {
637
+        $current = get_option( 'active_plugins', array() );
638
+    }
639
+
640
+    $valid = validate_plugin( $plugin );
641
+    if ( is_wp_error( $valid ) ) {
642
+        return $valid;
643
+    }
644
+
645
+    $requirements = validate_plugin_requirements( $plugin );
646
+    if ( is_wp_error( $requirements ) ) {
647
+        return $requirements;
648
+    }
649
+
650
+    if ( $network_wide && ! isset( $current[ $plugin ] )
651
+        || ! $network_wide && ! in_array( $plugin, $current, true )
652
+    ) {
653
+        if ( ! empty( $redirect ) ) {
654
+            // We'll override this later if the plugin can be included without fatal error.
655
+            wp_redirect( add_query_arg( '_error_nonce', wp_create_nonce( 'plugin-activation-error_' . $plugin ), $redirect ) );
656
+        }
657
+
658
+        ob_start();
659
+
660
+        // Load the plugin to test whether it throws any errors.
661
+        plugin_sandbox_scrape( $plugin );
662
+
663
+        if ( ! $silent ) {
664
+            /**
665
+             * Fires before a plugin is activated.
666
+             *
667
+             * If a plugin is silently activated (such as during an update),
668
+             * this hook does not fire.
669
+             *
670
+             * @since 2.9.0
671
+             *
672
+             * @param string $plugin       Path to the plugin file relative to the plugins directory.
673
+             * @param bool   $network_wide Whether to enable the plugin for all sites in the network
674
+             *                             or just the current site. Multisite only. Default false.
675
+             */
676
+            do_action( 'activate_plugin', $plugin, $network_wide );
677
+
678
+            /**
679
+             * Fires as a specific plugin is being activated.
680
+             *
681
+             * This hook is the "activation" hook used internally by register_activation_hook().
682
+             * The dynamic portion of the hook name, `$plugin`, refers to the plugin basename.
683
+             *
684
+             * If a plugin is silently activated (such as during an update), this hook does not fire.
685
+             *
686
+             * @since 2.0.0
687
+             *
688
+             * @param bool $network_wide Whether to enable the plugin for all sites in the network
689
+             *                           or just the current site. Multisite only. Default false.
690
+             */
691
+            do_action( "activate_{$plugin}", $network_wide );
692
+        }
693
+
694
+        if ( $network_wide ) {
695
+            $current            = get_site_option( 'active_sitewide_plugins', array() );
696
+            $current[ $plugin ] = time();
697
+            update_site_option( 'active_sitewide_plugins', $current );
698
+        } else {
699
+            $current   = get_option( 'active_plugins', array() );
700
+            $current[] = $plugin;
701
+            sort( $current );
702
+            update_option( 'active_plugins', $current );
703
+        }
704
+
705
+        if ( ! $silent ) {
706
+            /**
707
+             * Fires after a plugin has been activated.
708
+             *
709
+             * If a plugin is silently activated (such as during an update),
710
+             * this hook does not fire.
711
+             *
712
+             * @since 2.9.0
713
+             *
714
+             * @param string $plugin       Path to the plugin file relative to the plugins directory.
715
+             * @param bool   $network_wide Whether to enable the plugin for all sites in the network
716
+             *                             or just the current site. Multisite only. Default false.
717
+             */
718
+            do_action( 'activated_plugin', $plugin, $network_wide );
719
+        }
720
+
721
+        if ( ob_get_length() > 0 ) {
722
+            $output = ob_get_clean();
723
+            return new WP_Error( 'unexpected_output', __( 'The plugin generated unexpected output.' ), $output );
724
+        }
725
+
726
+        ob_end_clean();
727
+    }
728
+
729
+    return null;
730 730
 }
731 731
 
732 732
 /**
@@ -744,97 +744,97 @@  discard block
 block discarded – undo
744 744
  *                                      and the current site. Multisite only. Default null.
745 745
  */
746 746
 function deactivate_plugins( $plugins, $silent = false, $network_wide = null ) {
747
-	if ( is_multisite() ) {
748
-		$network_current = get_site_option( 'active_sitewide_plugins', array() );
749
-	}
750
-	$current    = get_option( 'active_plugins', array() );
751
-	$do_blog    = false;
752
-	$do_network = false;
753
-
754
-	foreach ( (array) $plugins as $plugin ) {
755
-		$plugin = plugin_basename( trim( $plugin ) );
756
-		if ( ! is_plugin_active( $plugin ) ) {
757
-			continue;
758
-		}
759
-
760
-		$network_deactivating = ( false !== $network_wide ) && is_plugin_active_for_network( $plugin );
761
-
762
-		if ( ! $silent ) {
763
-			/**
764
-			 * Fires before a plugin is deactivated.
765
-			 *
766
-			 * If a plugin is silently deactivated (such as during an update),
767
-			 * this hook does not fire.
768
-			 *
769
-			 * @since 2.9.0
770
-			 *
771
-			 * @param string $plugin               Path to the plugin file relative to the plugins directory.
772
-			 * @param bool   $network_deactivating Whether the plugin is deactivated for all sites in the network
773
-			 *                                     or just the current site. Multisite only. Default false.
774
-			 */
775
-			do_action( 'deactivate_plugin', $plugin, $network_deactivating );
776
-		}
777
-
778
-		if ( false !== $network_wide ) {
779
-			if ( is_plugin_active_for_network( $plugin ) ) {
780
-				$do_network = true;
781
-				unset( $network_current[ $plugin ] );
782
-			} elseif ( $network_wide ) {
783
-				continue;
784
-			}
785
-		}
786
-
787
-		if ( true !== $network_wide ) {
788
-			$key = array_search( $plugin, $current, true );
789
-			if ( false !== $key ) {
790
-				$do_blog = true;
791
-				unset( $current[ $key ] );
792
-			}
793
-		}
794
-
795
-		if ( $do_blog && wp_is_recovery_mode() ) {
796
-			list( $extension ) = explode( '/', $plugin );
797
-			wp_paused_plugins()->delete( $extension );
798
-		}
799
-
800
-		if ( ! $silent ) {
801
-			/**
802
-			 * Fires as a specific plugin is being deactivated.
803
-			 *
804
-			 * This hook is the "deactivation" hook used internally by register_deactivation_hook().
805
-			 * The dynamic portion of the hook name, `$plugin`, refers to the plugin basename.
806
-			 *
807
-			 * If a plugin is silently deactivated (such as during an update), this hook does not fire.
808
-			 *
809
-			 * @since 2.0.0
810
-			 *
811
-			 * @param bool $network_deactivating Whether the plugin is deactivated for all sites in the network
812
-			 *                                   or just the current site. Multisite only. Default false.
813
-			 */
814
-			do_action( "deactivate_{$plugin}", $network_deactivating );
815
-
816
-			/**
817
-			 * Fires after a plugin is deactivated.
818
-			 *
819
-			 * If a plugin is silently deactivated (such as during an update),
820
-			 * this hook does not fire.
821
-			 *
822
-			 * @since 2.9.0
823
-			 *
824
-			 * @param string $plugin               Path to the plugin file relative to the plugins directory.
825
-			 * @param bool   $network_deactivating Whether the plugin is deactivated for all sites in the network
826
-			 *                                     or just the current site. Multisite only. Default false.
827
-			 */
828
-			do_action( 'deactivated_plugin', $plugin, $network_deactivating );
829
-		}
830
-	}
831
-
832
-	if ( $do_blog ) {
833
-		update_option( 'active_plugins', $current );
834
-	}
835
-	if ( $do_network ) {
836
-		update_site_option( 'active_sitewide_plugins', $network_current );
837
-	}
747
+    if ( is_multisite() ) {
748
+        $network_current = get_site_option( 'active_sitewide_plugins', array() );
749
+    }
750
+    $current    = get_option( 'active_plugins', array() );
751
+    $do_blog    = false;
752
+    $do_network = false;
753
+
754
+    foreach ( (array) $plugins as $plugin ) {
755
+        $plugin = plugin_basename( trim( $plugin ) );
756
+        if ( ! is_plugin_active( $plugin ) ) {
757
+            continue;
758
+        }
759
+
760
+        $network_deactivating = ( false !== $network_wide ) && is_plugin_active_for_network( $plugin );
761
+
762
+        if ( ! $silent ) {
763
+            /**
764
+             * Fires before a plugin is deactivated.
765
+             *
766
+             * If a plugin is silently deactivated (such as during an update),
767
+             * this hook does not fire.
768
+             *
769
+             * @since 2.9.0
770
+             *
771
+             * @param string $plugin               Path to the plugin file relative to the plugins directory.
772
+             * @param bool   $network_deactivating Whether the plugin is deactivated for all sites in the network
773
+             *                                     or just the current site. Multisite only. Default false.
774
+             */
775
+            do_action( 'deactivate_plugin', $plugin, $network_deactivating );
776
+        }
777
+
778
+        if ( false !== $network_wide ) {
779
+            if ( is_plugin_active_for_network( $plugin ) ) {
780
+                $do_network = true;
781
+                unset( $network_current[ $plugin ] );
782
+            } elseif ( $network_wide ) {
783
+                continue;
784
+            }
785
+        }
786
+
787
+        if ( true !== $network_wide ) {
788
+            $key = array_search( $plugin, $current, true );
789
+            if ( false !== $key ) {
790
+                $do_blog = true;
791
+                unset( $current[ $key ] );
792
+            }
793
+        }
794
+
795
+        if ( $do_blog && wp_is_recovery_mode() ) {
796
+            list( $extension ) = explode( '/', $plugin );
797
+            wp_paused_plugins()->delete( $extension );
798
+        }
799
+
800
+        if ( ! $silent ) {
801
+            /**
802
+             * Fires as a specific plugin is being deactivated.
803
+             *
804
+             * This hook is the "deactivation" hook used internally by register_deactivation_hook().
805
+             * The dynamic portion of the hook name, `$plugin`, refers to the plugin basename.
806
+             *
807
+             * If a plugin is silently deactivated (such as during an update), this hook does not fire.
808
+             *
809
+             * @since 2.0.0
810
+             *
811
+             * @param bool $network_deactivating Whether the plugin is deactivated for all sites in the network
812
+             *                                   or just the current site. Multisite only. Default false.
813
+             */
814
+            do_action( "deactivate_{$plugin}", $network_deactivating );
815
+
816
+            /**
817
+             * Fires after a plugin is deactivated.
818
+             *
819
+             * If a plugin is silently deactivated (such as during an update),
820
+             * this hook does not fire.
821
+             *
822
+             * @since 2.9.0
823
+             *
824
+             * @param string $plugin               Path to the plugin file relative to the plugins directory.
825
+             * @param bool   $network_deactivating Whether the plugin is deactivated for all sites in the network
826
+             *                                     or just the current site. Multisite only. Default false.
827
+             */
828
+            do_action( 'deactivated_plugin', $plugin, $network_deactivating );
829
+        }
830
+    }
831
+
832
+    if ( $do_blog ) {
833
+        update_option( 'active_plugins', $current );
834
+    }
835
+    if ( $do_network ) {
836
+        update_site_option( 'active_sitewide_plugins', $network_current );
837
+    }
838 838
 }
839 839
 
840 840
 /**
@@ -855,26 +855,26 @@  discard block
 block discarded – undo
855 855
  * @return bool|WP_Error True when finished or WP_Error if there were errors during a plugin activation.
856 856
  */
857 857
 function activate_plugins( $plugins, $redirect = '', $network_wide = false, $silent = false ) {
858
-	if ( ! is_array( $plugins ) ) {
859
-		$plugins = array( $plugins );
860
-	}
861
-
862
-	$errors = array();
863
-	foreach ( $plugins as $plugin ) {
864
-		if ( ! empty( $redirect ) ) {
865
-			$redirect = add_query_arg( 'plugin', $plugin, $redirect );
866
-		}
867
-		$result = activate_plugin( $plugin, $redirect, $network_wide, $silent );
868
-		if ( is_wp_error( $result ) ) {
869
-			$errors[ $plugin ] = $result;
870
-		}
871
-	}
872
-
873
-	if ( ! empty( $errors ) ) {
874
-		return new WP_Error( 'plugins_invalid', __( 'One of the plugins is invalid.' ), $errors );
875
-	}
876
-
877
-	return true;
858
+    if ( ! is_array( $plugins ) ) {
859
+        $plugins = array( $plugins );
860
+    }
861
+
862
+    $errors = array();
863
+    foreach ( $plugins as $plugin ) {
864
+        if ( ! empty( $redirect ) ) {
865
+            $redirect = add_query_arg( 'plugin', $plugin, $redirect );
866
+        }
867
+        $result = activate_plugin( $plugin, $redirect, $network_wide, $silent );
868
+        if ( is_wp_error( $result ) ) {
869
+            $errors[ $plugin ] = $result;
870
+        }
871
+    }
872
+
873
+    if ( ! empty( $errors ) ) {
874
+        return new WP_Error( 'plugins_invalid', __( 'One of the plugins is invalid.' ), $errors );
875
+    }
876
+
877
+    return true;
878 878
 }
879 879
 
880 880
 /**
@@ -890,156 +890,156 @@  discard block
 block discarded – undo
890 890
  *                            `null` if filesystem credentials are required to proceed.
891 891
  */
892 892
 function delete_plugins( $plugins, $deprecated = '' ) {
893
-	global $wp_filesystem;
894
-
895
-	if ( empty( $plugins ) ) {
896
-		return false;
897
-	}
898
-
899
-	$checked = array();
900
-	foreach ( $plugins as $plugin ) {
901
-		$checked[] = 'checked[]=' . $plugin;
902
-	}
903
-
904
-	$url = wp_nonce_url( 'plugins.php?action=delete-selected&verify-delete=1&' . implode( '&', $checked ), 'bulk-plugins' );
905
-
906
-	ob_start();
907
-	$credentials = request_filesystem_credentials( $url );
908
-	$data        = ob_get_clean();
909
-
910
-	if ( false === $credentials ) {
911
-		if ( ! empty( $data ) ) {
912
-			require_once ABSPATH . 'wp-admin/admin-header.php';
913
-			echo $data;
914
-			require_once ABSPATH . 'wp-admin/admin-footer.php';
915
-			exit;
916
-		}
917
-		return;
918
-	}
919
-
920
-	if ( ! WP_Filesystem( $credentials ) ) {
921
-		ob_start();
922
-		// Failed to connect. Error and request again.
923
-		request_filesystem_credentials( $url, '', true );
924
-		$data = ob_get_clean();
925
-
926
-		if ( ! empty( $data ) ) {
927
-			require_once ABSPATH . 'wp-admin/admin-header.php';
928
-			echo $data;
929
-			require_once ABSPATH . 'wp-admin/admin-footer.php';
930
-			exit;
931
-		}
932
-		return;
933
-	}
934
-
935
-	if ( ! is_object( $wp_filesystem ) ) {
936
-		return new WP_Error( 'fs_unavailable', __( 'Could not access filesystem.' ) );
937
-	}
938
-
939
-	if ( is_wp_error( $wp_filesystem->errors ) && $wp_filesystem->errors->has_errors() ) {
940
-		return new WP_Error( 'fs_error', __( 'Filesystem error.' ), $wp_filesystem->errors );
941
-	}
942
-
943
-	// Get the base plugin folder.
944
-	$plugins_dir = $wp_filesystem->wp_plugins_dir();
945
-	if ( empty( $plugins_dir ) ) {
946
-		return new WP_Error( 'fs_no_plugins_dir', __( 'Unable to locate WordPress plugin directory.' ) );
947
-	}
948
-
949
-	$plugins_dir = trailingslashit( $plugins_dir );
950
-
951
-	$plugin_translations = wp_get_installed_translations( 'plugins' );
952
-
953
-	$errors = array();
954
-
955
-	foreach ( $plugins as $plugin_file ) {
956
-		// Run Uninstall hook.
957
-		if ( is_uninstallable_plugin( $plugin_file ) ) {
958
-			uninstall_plugin( $plugin_file );
959
-		}
960
-
961
-		/**
962
-		 * Fires immediately before a plugin deletion attempt.
963
-		 *
964
-		 * @since 4.4.0
965
-		 *
966
-		 * @param string $plugin_file Path to the plugin file relative to the plugins directory.
967
-		 */
968
-		do_action( 'delete_plugin', $plugin_file );
969
-
970
-		$this_plugin_dir = trailingslashit( dirname( $plugins_dir . $plugin_file ) );
971
-
972
-		// If plugin is in its own directory, recursively delete the directory.
973
-		// Base check on if plugin includes directory separator AND that it's not the root plugin folder.
974
-		if ( strpos( $plugin_file, '/' ) && $this_plugin_dir !== $plugins_dir ) {
975
-			$deleted = $wp_filesystem->delete( $this_plugin_dir, true );
976
-		} else {
977
-			$deleted = $wp_filesystem->delete( $plugins_dir . $plugin_file );
978
-		}
979
-
980
-		/**
981
-		 * Fires immediately after a plugin deletion attempt.
982
-		 *
983
-		 * @since 4.4.0
984
-		 *
985
-		 * @param string $plugin_file Path to the plugin file relative to the plugins directory.
986
-		 * @param bool   $deleted     Whether the plugin deletion was successful.
987
-		 */
988
-		do_action( 'deleted_plugin', $plugin_file, $deleted );
989
-
990
-		if ( ! $deleted ) {
991
-			$errors[] = $plugin_file;
992
-			continue;
993
-		}
994
-
995
-		$plugin_slug = dirname( $plugin_file );
996
-
997
-		if ( 'hello.php' === $plugin_file ) {
998
-			$plugin_slug = 'hello-dolly';
999
-		}
1000
-
1001
-		// Remove language files, silently.
1002
-		if ( '.' !== $plugin_slug && ! empty( $plugin_translations[ $plugin_slug ] ) ) {
1003
-			$translations = $plugin_translations[ $plugin_slug ];
1004
-
1005
-			foreach ( $translations as $translation => $data ) {
1006
-				$wp_filesystem->delete( WP_LANG_DIR . '/plugins/' . $plugin_slug . '-' . $translation . '.po' );
1007
-				$wp_filesystem->delete( WP_LANG_DIR . '/plugins/' . $plugin_slug . '-' . $translation . '.mo' );
1008
-
1009
-				$json_translation_files = glob( WP_LANG_DIR . '/plugins/' . $plugin_slug . '-' . $translation . '-*.json' );
1010
-				if ( $json_translation_files ) {
1011
-					array_map( array( $wp_filesystem, 'delete' ), $json_translation_files );
1012
-				}
1013
-			}
1014
-		}
1015
-	}
1016
-
1017
-	// Remove deleted plugins from the plugin updates list.
1018
-	$current = get_site_transient( 'update_plugins' );
1019
-	if ( $current ) {
1020
-		// Don't remove the plugins that weren't deleted.
1021
-		$deleted = array_diff( $plugins, $errors );
1022
-
1023
-		foreach ( $deleted as $plugin_file ) {
1024
-			unset( $current->response[ $plugin_file ] );
1025
-		}
1026
-
1027
-		set_site_transient( 'update_plugins', $current );
1028
-	}
1029
-
1030
-	if ( ! empty( $errors ) ) {
1031
-		if ( 1 === count( $errors ) ) {
1032
-			/* translators: %s: Plugin filename. */
1033
-			$message = __( 'Could not fully remove the plugin %s.' );
1034
-		} else {
1035
-			/* translators: %s: Comma-separated list of plugin filenames. */
1036
-			$message = __( 'Could not fully remove the plugins %s.' );
1037
-		}
1038
-
1039
-		return new WP_Error( 'could_not_remove_plugin', sprintf( $message, implode( ', ', $errors ) ) );
1040
-	}
1041
-
1042
-	return true;
893
+    global $wp_filesystem;
894
+
895
+    if ( empty( $plugins ) ) {
896
+        return false;
897
+    }
898
+
899
+    $checked = array();
900
+    foreach ( $plugins as $plugin ) {
901
+        $checked[] = 'checked[]=' . $plugin;
902
+    }
903
+
904
+    $url = wp_nonce_url( 'plugins.php?action=delete-selected&verify-delete=1&' . implode( '&', $checked ), 'bulk-plugins' );
905
+
906
+    ob_start();
907
+    $credentials = request_filesystem_credentials( $url );
908
+    $data        = ob_get_clean();
909
+
910
+    if ( false === $credentials ) {
911
+        if ( ! empty( $data ) ) {
912
+            require_once ABSPATH . 'wp-admin/admin-header.php';
913
+            echo $data;
914
+            require_once ABSPATH . 'wp-admin/admin-footer.php';
915
+            exit;
916
+        }
917
+        return;
918
+    }
919
+
920
+    if ( ! WP_Filesystem( $credentials ) ) {
921
+        ob_start();
922
+        // Failed to connect. Error and request again.
923
+        request_filesystem_credentials( $url, '', true );
924
+        $data = ob_get_clean();
925
+
926
+        if ( ! empty( $data ) ) {
927
+            require_once ABSPATH . 'wp-admin/admin-header.php';
928
+            echo $data;
929
+            require_once ABSPATH . 'wp-admin/admin-footer.php';
930
+            exit;
931
+        }
932
+        return;
933
+    }
934
+
935
+    if ( ! is_object( $wp_filesystem ) ) {
936
+        return new WP_Error( 'fs_unavailable', __( 'Could not access filesystem.' ) );
937
+    }
938
+
939
+    if ( is_wp_error( $wp_filesystem->errors ) && $wp_filesystem->errors->has_errors() ) {
940
+        return new WP_Error( 'fs_error', __( 'Filesystem error.' ), $wp_filesystem->errors );
941
+    }
942
+
943
+    // Get the base plugin folder.
944
+    $plugins_dir = $wp_filesystem->wp_plugins_dir();
945
+    if ( empty( $plugins_dir ) ) {
946
+        return new WP_Error( 'fs_no_plugins_dir', __( 'Unable to locate WordPress plugin directory.' ) );
947
+    }
948
+
949
+    $plugins_dir = trailingslashit( $plugins_dir );
950
+
951
+    $plugin_translations = wp_get_installed_translations( 'plugins' );
952
+
953
+    $errors = array();
954
+
955
+    foreach ( $plugins as $plugin_file ) {
956
+        // Run Uninstall hook.
957
+        if ( is_uninstallable_plugin( $plugin_file ) ) {
958
+            uninstall_plugin( $plugin_file );
959
+        }
960
+
961
+        /**
962
+         * Fires immediately before a plugin deletion attempt.
963
+         *
964
+         * @since 4.4.0
965
+         *
966
+         * @param string $plugin_file Path to the plugin file relative to the plugins directory.
967
+         */
968
+        do_action( 'delete_plugin', $plugin_file );
969
+
970
+        $this_plugin_dir = trailingslashit( dirname( $plugins_dir . $plugin_file ) );
971
+
972
+        // If plugin is in its own directory, recursively delete the directory.
973
+        // Base check on if plugin includes directory separator AND that it's not the root plugin folder.
974
+        if ( strpos( $plugin_file, '/' ) && $this_plugin_dir !== $plugins_dir ) {
975
+            $deleted = $wp_filesystem->delete( $this_plugin_dir, true );
976
+        } else {
977
+            $deleted = $wp_filesystem->delete( $plugins_dir . $plugin_file );
978
+        }
979
+
980
+        /**
981
+         * Fires immediately after a plugin deletion attempt.
982
+         *
983
+         * @since 4.4.0
984
+         *
985
+         * @param string $plugin_file Path to the plugin file relative to the plugins directory.
986
+         * @param bool   $deleted     Whether the plugin deletion was successful.
987
+         */
988
+        do_action( 'deleted_plugin', $plugin_file, $deleted );
989
+
990
+        if ( ! $deleted ) {
991
+            $errors[] = $plugin_file;
992
+            continue;
993
+        }
994
+
995
+        $plugin_slug = dirname( $plugin_file );
996
+
997
+        if ( 'hello.php' === $plugin_file ) {
998
+            $plugin_slug = 'hello-dolly';
999
+        }
1000
+
1001
+        // Remove language files, silently.
1002
+        if ( '.' !== $plugin_slug && ! empty( $plugin_translations[ $plugin_slug ] ) ) {
1003
+            $translations = $plugin_translations[ $plugin_slug ];
1004
+
1005
+            foreach ( $translations as $translation => $data ) {
1006
+                $wp_filesystem->delete( WP_LANG_DIR . '/plugins/' . $plugin_slug . '-' . $translation . '.po' );
1007
+                $wp_filesystem->delete( WP_LANG_DIR . '/plugins/' . $plugin_slug . '-' . $translation . '.mo' );
1008
+
1009
+                $json_translation_files = glob( WP_LANG_DIR . '/plugins/' . $plugin_slug . '-' . $translation . '-*.json' );
1010
+                if ( $json_translation_files ) {
1011
+                    array_map( array( $wp_filesystem, 'delete' ), $json_translation_files );
1012
+                }
1013
+            }
1014
+        }
1015
+    }
1016
+
1017
+    // Remove deleted plugins from the plugin updates list.
1018
+    $current = get_site_transient( 'update_plugins' );
1019
+    if ( $current ) {
1020
+        // Don't remove the plugins that weren't deleted.
1021
+        $deleted = array_diff( $plugins, $errors );
1022
+
1023
+        foreach ( $deleted as $plugin_file ) {
1024
+            unset( $current->response[ $plugin_file ] );
1025
+        }
1026
+
1027
+        set_site_transient( 'update_plugins', $current );
1028
+    }
1029
+
1030
+    if ( ! empty( $errors ) ) {
1031
+        if ( 1 === count( $errors ) ) {
1032
+            /* translators: %s: Plugin filename. */
1033
+            $message = __( 'Could not fully remove the plugin %s.' );
1034
+        } else {
1035
+            /* translators: %s: Comma-separated list of plugin filenames. */
1036
+            $message = __( 'Could not fully remove the plugins %s.' );
1037
+        }
1038
+
1039
+        return new WP_Error( 'could_not_remove_plugin', sprintf( $message, implode( ', ', $errors ) ) );
1040
+    }
1041
+
1042
+    return true;
1043 1043
 }
1044 1044
 
1045 1045
 /**
@@ -1052,33 +1052,33 @@  discard block
 block discarded – undo
1052 1052
  * @return WP_Error[] Array of plugin errors keyed by plugin file name.
1053 1053
  */
1054 1054
 function validate_active_plugins() {
1055
-	$plugins = get_option( 'active_plugins', array() );
1056
-	// Validate vartype: array.
1057
-	if ( ! is_array( $plugins ) ) {
1058
-		update_option( 'active_plugins', array() );
1059
-		$plugins = array();
1060
-	}
1061
-
1062
-	if ( is_multisite() && current_user_can( 'manage_network_plugins' ) ) {
1063
-		$network_plugins = (array) get_site_option( 'active_sitewide_plugins', array() );
1064
-		$plugins         = array_merge( $plugins, array_keys( $network_plugins ) );
1065
-	}
1066
-
1067
-	if ( empty( $plugins ) ) {
1068
-		return array();
1069
-	}
1070
-
1071
-	$invalid = array();
1072
-
1073
-	// Invalid plugins get deactivated.
1074
-	foreach ( $plugins as $plugin ) {
1075
-		$result = validate_plugin( $plugin );
1076
-		if ( is_wp_error( $result ) ) {
1077
-			$invalid[ $plugin ] = $result;
1078
-			deactivate_plugins( $plugin, true );
1079
-		}
1080
-	}
1081
-	return $invalid;
1055
+    $plugins = get_option( 'active_plugins', array() );
1056
+    // Validate vartype: array.
1057
+    if ( ! is_array( $plugins ) ) {
1058
+        update_option( 'active_plugins', array() );
1059
+        $plugins = array();
1060
+    }
1061
+
1062
+    if ( is_multisite() && current_user_can( 'manage_network_plugins' ) ) {
1063
+        $network_plugins = (array) get_site_option( 'active_sitewide_plugins', array() );
1064
+        $plugins         = array_merge( $plugins, array_keys( $network_plugins ) );
1065
+    }
1066
+
1067
+    if ( empty( $plugins ) ) {
1068
+        return array();
1069
+    }
1070
+
1071
+    $invalid = array();
1072
+
1073
+    // Invalid plugins get deactivated.
1074
+    foreach ( $plugins as $plugin ) {
1075
+        $result = validate_plugin( $plugin );
1076
+        if ( is_wp_error( $result ) ) {
1077
+            $invalid[ $plugin ] = $result;
1078
+            deactivate_plugins( $plugin, true );
1079
+        }
1080
+    }
1081
+    return $invalid;
1082 1082
 }
1083 1083
 
1084 1084
 /**
@@ -1092,18 +1092,18 @@  discard block
 block discarded – undo
1092 1092
  * @return int|WP_Error 0 on success, WP_Error on failure.
1093 1093
  */
1094 1094
 function validate_plugin( $plugin ) {
1095
-	if ( validate_file( $plugin ) ) {
1096
-		return new WP_Error( 'plugin_invalid', __( 'Invalid plugin path.' ) );
1097
-	}
1098
-	if ( ! file_exists( WP_PLUGIN_DIR . '/' . $plugin ) ) {
1099
-		return new WP_Error( 'plugin_not_found', __( 'Plugin file does not exist.' ) );
1100
-	}
1101
-
1102
-	$installed_plugins = get_plugins();
1103
-	if ( ! isset( $installed_plugins[ $plugin ] ) ) {
1104
-		return new WP_Error( 'no_plugin_header', __( 'The plugin does not have a valid header.' ) );
1105
-	}
1106
-	return 0;
1095
+    if ( validate_file( $plugin ) ) {
1096
+        return new WP_Error( 'plugin_invalid', __( 'Invalid plugin path.' ) );
1097
+    }
1098
+    if ( ! file_exists( WP_PLUGIN_DIR . '/' . $plugin ) ) {
1099
+        return new WP_Error( 'plugin_not_found', __( 'Plugin file does not exist.' ) );
1100
+    }
1101
+
1102
+    $installed_plugins = get_plugins();
1103
+    if ( ! isset( $installed_plugins[ $plugin ] ) ) {
1104
+        return new WP_Error( 'no_plugin_header', __( 'The plugin does not have a valid header.' ) );
1105
+    }
1106
+    return 0;
1107 1107
 }
1108 1108
 
1109 1109
 /**
@@ -1121,66 +1121,66 @@  discard block
 block discarded – undo
1121 1121
  * @return true|WP_Error True if requirements are met, WP_Error on failure.
1122 1122
  */
1123 1123
 function validate_plugin_requirements( $plugin ) {
1124
-	$plugin_headers = get_plugin_data( WP_PLUGIN_DIR . '/' . $plugin );
1125
-
1126
-	$requirements = array(
1127
-		'requires'     => ! empty( $plugin_headers['RequiresWP'] ) ? $plugin_headers['RequiresWP'] : '',
1128
-		'requires_php' => ! empty( $plugin_headers['RequiresPHP'] ) ? $plugin_headers['RequiresPHP'] : '',
1129
-	);
1130
-
1131
-	$compatible_wp  = is_wp_version_compatible( $requirements['requires'] );
1132
-	$compatible_php = is_php_version_compatible( $requirements['requires_php'] );
1133
-
1134
-	$php_update_message = '</p><p>' . sprintf(
1135
-		/* translators: %s: URL to Update PHP page. */
1136
-		__( '<a href="%s">Learn more about updating PHP</a>.' ),
1137
-		esc_url( wp_get_update_php_url() )
1138
-	);
1139
-
1140
-	$annotation = wp_get_update_php_annotation();
1141
-
1142
-	if ( $annotation ) {
1143
-		$php_update_message .= '</p><p><em>' . $annotation . '</em>';
1144
-	}
1145
-
1146
-	if ( ! $compatible_wp && ! $compatible_php ) {
1147
-		return new WP_Error(
1148
-			'plugin_wp_php_incompatible',
1149
-			'<p>' . sprintf(
1150
-				/* translators: 1: Current WordPress version, 2: Current PHP version, 3: Plugin name, 4: Required WordPress version, 5: Required PHP version. */
1151
-				_x( '<strong>Error:</strong> Current versions of WordPress (%1$s) and PHP (%2$s) do not meet minimum requirements for %3$s. The plugin requires WordPress %4$s and PHP %5$s.', 'plugin' ),
1152
-				get_bloginfo( 'version' ),
1153
-				phpversion(),
1154
-				$plugin_headers['Name'],
1155
-				$requirements['requires'],
1156
-				$requirements['requires_php']
1157
-			) . $php_update_message . '</p>'
1158
-		);
1159
-	} elseif ( ! $compatible_php ) {
1160
-		return new WP_Error(
1161
-			'plugin_php_incompatible',
1162
-			'<p>' . sprintf(
1163
-				/* translators: 1: Current PHP version, 2: Plugin name, 3: Required PHP version. */
1164
-				_x( '<strong>Error:</strong> Current PHP version (%1$s) does not meet minimum requirements for %2$s. The plugin requires PHP %3$s.', 'plugin' ),
1165
-				phpversion(),
1166
-				$plugin_headers['Name'],
1167
-				$requirements['requires_php']
1168
-			) . $php_update_message . '</p>'
1169
-		);
1170
-	} elseif ( ! $compatible_wp ) {
1171
-		return new WP_Error(
1172
-			'plugin_wp_incompatible',
1173
-			'<p>' . sprintf(
1174
-				/* translators: 1: Current WordPress version, 2: Plugin name, 3: Required WordPress version. */
1175
-				_x( '<strong>Error:</strong> Current WordPress version (%1$s) does not meet minimum requirements for %2$s. The plugin requires WordPress %3$s.', 'plugin' ),
1176
-				get_bloginfo( 'version' ),
1177
-				$plugin_headers['Name'],
1178
-				$requirements['requires']
1179
-			) . '</p>'
1180
-		);
1181
-	}
1182
-
1183
-	return true;
1124
+    $plugin_headers = get_plugin_data( WP_PLUGIN_DIR . '/' . $plugin );
1125
+
1126
+    $requirements = array(
1127
+        'requires'     => ! empty( $plugin_headers['RequiresWP'] ) ? $plugin_headers['RequiresWP'] : '',
1128
+        'requires_php' => ! empty( $plugin_headers['RequiresPHP'] ) ? $plugin_headers['RequiresPHP'] : '',
1129
+    );
1130
+
1131
+    $compatible_wp  = is_wp_version_compatible( $requirements['requires'] );
1132
+    $compatible_php = is_php_version_compatible( $requirements['requires_php'] );
1133
+
1134
+    $php_update_message = '</p><p>' . sprintf(
1135
+        /* translators: %s: URL to Update PHP page. */
1136
+        __( '<a href="%s">Learn more about updating PHP</a>.' ),
1137
+        esc_url( wp_get_update_php_url() )
1138
+    );
1139
+
1140
+    $annotation = wp_get_update_php_annotation();
1141
+
1142
+    if ( $annotation ) {
1143
+        $php_update_message .= '</p><p><em>' . $annotation . '</em>';
1144
+    }
1145
+
1146
+    if ( ! $compatible_wp && ! $compatible_php ) {
1147
+        return new WP_Error(
1148
+            'plugin_wp_php_incompatible',
1149
+            '<p>' . sprintf(
1150
+                /* translators: 1: Current WordPress version, 2: Current PHP version, 3: Plugin name, 4: Required WordPress version, 5: Required PHP version. */
1151
+                _x( '<strong>Error:</strong> Current versions of WordPress (%1$s) and PHP (%2$s) do not meet minimum requirements for %3$s. The plugin requires WordPress %4$s and PHP %5$s.', 'plugin' ),
1152
+                get_bloginfo( 'version' ),
1153
+                phpversion(),
1154
+                $plugin_headers['Name'],
1155
+                $requirements['requires'],
1156
+                $requirements['requires_php']
1157
+            ) . $php_update_message . '</p>'
1158
+        );
1159
+    } elseif ( ! $compatible_php ) {
1160
+        return new WP_Error(
1161
+            'plugin_php_incompatible',
1162
+            '<p>' . sprintf(
1163
+                /* translators: 1: Current PHP version, 2: Plugin name, 3: Required PHP version. */
1164
+                _x( '<strong>Error:</strong> Current PHP version (%1$s) does not meet minimum requirements for %2$s. The plugin requires PHP %3$s.', 'plugin' ),
1165
+                phpversion(),
1166
+                $plugin_headers['Name'],
1167
+                $requirements['requires_php']
1168
+            ) . $php_update_message . '</p>'
1169
+        );
1170
+    } elseif ( ! $compatible_wp ) {
1171
+        return new WP_Error(
1172
+            'plugin_wp_incompatible',
1173
+            '<p>' . sprintf(
1174
+                /* translators: 1: Current WordPress version, 2: Plugin name, 3: Required WordPress version. */
1175
+                _x( '<strong>Error:</strong> Current WordPress version (%1$s) does not meet minimum requirements for %2$s. The plugin requires WordPress %3$s.', 'plugin' ),
1176
+                get_bloginfo( 'version' ),
1177
+                $plugin_headers['Name'],
1178
+                $requirements['requires']
1179
+            ) . '</p>'
1180
+        );
1181
+    }
1182
+
1183
+    return true;
1184 1184
 }
1185 1185
 
1186 1186
 /**
@@ -1192,14 +1192,14 @@  discard block
 block discarded – undo
1192 1192
  * @return bool Whether plugin can be uninstalled.
1193 1193
  */
1194 1194
 function is_uninstallable_plugin( $plugin ) {
1195
-	$file = plugin_basename( $plugin );
1195
+    $file = plugin_basename( $plugin );
1196 1196
 
1197
-	$uninstallable_plugins = (array) get_option( 'uninstall_plugins' );
1198
-	if ( isset( $uninstallable_plugins[ $file ] ) || file_exists( WP_PLUGIN_DIR . '/' . dirname( $file ) . '/uninstall.php' ) ) {
1199
-		return true;
1200
-	}
1197
+    $uninstallable_plugins = (array) get_option( 'uninstall_plugins' );
1198
+    if ( isset( $uninstallable_plugins[ $file ] ) || file_exists( WP_PLUGIN_DIR . '/' . dirname( $file ) . '/uninstall.php' ) ) {
1199
+        return true;
1200
+    }
1201 1201
 
1202
-	return false;
1202
+    return false;
1203 1203
 }
1204 1204
 
1205 1205
 /**
@@ -1214,56 +1214,56 @@  discard block
 block discarded – undo
1214 1214
  *                   Void otherwise.
1215 1215
  */
1216 1216
 function uninstall_plugin( $plugin ) {
1217
-	$file = plugin_basename( $plugin );
1218
-
1219
-	$uninstallable_plugins = (array) get_option( 'uninstall_plugins' );
1220
-
1221
-	/**
1222
-	 * Fires in uninstall_plugin() immediately before the plugin is uninstalled.
1223
-	 *
1224
-	 * @since 4.5.0
1225
-	 *
1226
-	 * @param string $plugin                Path to the plugin file relative to the plugins directory.
1227
-	 * @param array  $uninstallable_plugins Uninstallable plugins.
1228
-	 */
1229
-	do_action( 'pre_uninstall_plugin', $plugin, $uninstallable_plugins );
1230
-
1231
-	if ( file_exists( WP_PLUGIN_DIR . '/' . dirname( $file ) . '/uninstall.php' ) ) {
1232
-		if ( isset( $uninstallable_plugins[ $file ] ) ) {
1233
-			unset( $uninstallable_plugins[ $file ] );
1234
-			update_option( 'uninstall_plugins', $uninstallable_plugins );
1235
-		}
1236
-		unset( $uninstallable_plugins );
1237
-
1238
-		define( 'WP_UNINSTALL_PLUGIN', $file );
1239
-
1240
-		wp_register_plugin_realpath( WP_PLUGIN_DIR . '/' . $file );
1241
-		include_once WP_PLUGIN_DIR . '/' . dirname( $file ) . '/uninstall.php';
1242
-
1243
-		return true;
1244
-	}
1245
-
1246
-	if ( isset( $uninstallable_plugins[ $file ] ) ) {
1247
-		$callable = $uninstallable_plugins[ $file ];
1248
-		unset( $uninstallable_plugins[ $file ] );
1249
-		update_option( 'uninstall_plugins', $uninstallable_plugins );
1250
-		unset( $uninstallable_plugins );
1251
-
1252
-		wp_register_plugin_realpath( WP_PLUGIN_DIR . '/' . $file );
1253
-		include_once WP_PLUGIN_DIR . '/' . $file;
1254
-
1255
-		add_action( "uninstall_{$file}", $callable );
1256
-
1257
-		/**
1258
-		 * Fires in uninstall_plugin() once the plugin has been uninstalled.
1259
-		 *
1260
-		 * The action concatenates the 'uninstall_' prefix with the basename of the
1261
-		 * plugin passed to uninstall_plugin() to create a dynamically-named action.
1262
-		 *
1263
-		 * @since 2.7.0
1264
-		 */
1265
-		do_action( "uninstall_{$file}" );
1266
-	}
1217
+    $file = plugin_basename( $plugin );
1218
+
1219
+    $uninstallable_plugins = (array) get_option( 'uninstall_plugins' );
1220
+
1221
+    /**
1222
+     * Fires in uninstall_plugin() immediately before the plugin is uninstalled.
1223
+     *
1224
+     * @since 4.5.0
1225
+     *
1226
+     * @param string $plugin                Path to the plugin file relative to the plugins directory.
1227
+     * @param array  $uninstallable_plugins Uninstallable plugins.
1228
+     */
1229
+    do_action( 'pre_uninstall_plugin', $plugin, $uninstallable_plugins );
1230
+
1231
+    if ( file_exists( WP_PLUGIN_DIR . '/' . dirname( $file ) . '/uninstall.php' ) ) {
1232
+        if ( isset( $uninstallable_plugins[ $file ] ) ) {
1233
+            unset( $uninstallable_plugins[ $file ] );
1234
+            update_option( 'uninstall_plugins', $uninstallable_plugins );
1235
+        }
1236
+        unset( $uninstallable_plugins );
1237
+
1238
+        define( 'WP_UNINSTALL_PLUGIN', $file );
1239
+
1240
+        wp_register_plugin_realpath( WP_PLUGIN_DIR . '/' . $file );
1241
+        include_once WP_PLUGIN_DIR . '/' . dirname( $file ) . '/uninstall.php';
1242
+
1243
+        return true;
1244
+    }
1245
+
1246
+    if ( isset( $uninstallable_plugins[ $file ] ) ) {
1247
+        $callable = $uninstallable_plugins[ $file ];
1248
+        unset( $uninstallable_plugins[ $file ] );
1249
+        update_option( 'uninstall_plugins', $uninstallable_plugins );
1250
+        unset( $uninstallable_plugins );
1251
+
1252
+        wp_register_plugin_realpath( WP_PLUGIN_DIR . '/' . $file );
1253
+        include_once WP_PLUGIN_DIR . '/' . $file;
1254
+
1255
+        add_action( "uninstall_{$file}", $callable );
1256
+
1257
+        /**
1258
+         * Fires in uninstall_plugin() once the plugin has been uninstalled.
1259
+         *
1260
+         * The action concatenates the 'uninstall_' prefix with the basename of the
1261
+         * plugin passed to uninstall_plugin() to create a dynamically-named action.
1262
+         *
1263
+         * @since 2.7.0
1264
+         */
1265
+        do_action( "uninstall_{$file}" );
1266
+    }
1267 1267
 }
1268 1268
 
1269 1269
 //
@@ -1303,49 +1303,49 @@  discard block
 block discarded – undo
1303 1303
  * @return string The resulting page's hook_suffix.
1304 1304
  */
1305 1305
 function add_menu_page( $page_title, $menu_title, $capability, $menu_slug, $callback = '', $icon_url = '', $position = null ) {
1306
-	global $menu, $admin_page_hooks, $_registered_pages, $_parent_pages;
1307
-
1308
-	$menu_slug = plugin_basename( $menu_slug );
1309
-
1310
-	$admin_page_hooks[ $menu_slug ] = sanitize_title( $menu_title );
1311
-
1312
-	$hookname = get_plugin_page_hookname( $menu_slug, '' );
1313
-
1314
-	if ( ! empty( $callback ) && ! empty( $hookname ) && current_user_can( $capability ) ) {
1315
-		add_action( $hookname, $callback );
1316
-	}
1317
-
1318
-	if ( empty( $icon_url ) ) {
1319
-		$icon_url   = 'dashicons-admin-generic';
1320
-		$icon_class = 'menu-icon-generic ';
1321
-	} else {
1322
-		$icon_url   = set_url_scheme( $icon_url );
1323
-		$icon_class = '';
1324
-	}
1325
-
1326
-	$new_menu = array( $menu_title, $capability, $menu_slug, $page_title, 'menu-top ' . $icon_class . $hookname, $hookname, $icon_url );
1327
-
1328
-	if ( null !== $position && ! is_numeric( $position ) ) {
1329
-		_doing_it_wrong(
1330
-			__FUNCTION__,
1331
-			sprintf(
1332
-				/* translators: %s: add_menu_page() */
1333
-				__( 'The seventh parameter passed to %s should be numeric representing menu position.' ),
1334
-				'<code>add_menu_page()</code>'
1335
-			),
1336
-			'6.0.0'
1337
-		);
1338
-		$position = null;
1339
-	}
1340
-
1341
-	if ( null === $position || ! is_numeric( $position ) ) {
1342
-		$menu[] = $new_menu;
1343
-	} elseif ( isset( $menu[ (string) $position ] ) ) {
1344
-		$collision_avoider = base_convert( substr( md5( $menu_slug . $menu_title ), -4 ), 16, 10 ) * 0.00001;
1345
-		$position          = (string) ( $position + $collision_avoider );
1346
-		$menu[ $position ] = $new_menu;
1347
-	} else {
1348
-		/*
1306
+    global $menu, $admin_page_hooks, $_registered_pages, $_parent_pages;
1307
+
1308
+    $menu_slug = plugin_basename( $menu_slug );
1309
+
1310
+    $admin_page_hooks[ $menu_slug ] = sanitize_title( $menu_title );
1311
+
1312
+    $hookname = get_plugin_page_hookname( $menu_slug, '' );
1313
+
1314
+    if ( ! empty( $callback ) && ! empty( $hookname ) && current_user_can( $capability ) ) {
1315
+        add_action( $hookname, $callback );
1316
+    }
1317
+
1318
+    if ( empty( $icon_url ) ) {
1319
+        $icon_url   = 'dashicons-admin-generic';
1320
+        $icon_class = 'menu-icon-generic ';
1321
+    } else {
1322
+        $icon_url   = set_url_scheme( $icon_url );
1323
+        $icon_class = '';
1324
+    }
1325
+
1326
+    $new_menu = array( $menu_title, $capability, $menu_slug, $page_title, 'menu-top ' . $icon_class . $hookname, $hookname, $icon_url );
1327
+
1328
+    if ( null !== $position && ! is_numeric( $position ) ) {
1329
+        _doing_it_wrong(
1330
+            __FUNCTION__,
1331
+            sprintf(
1332
+                /* translators: %s: add_menu_page() */
1333
+                __( 'The seventh parameter passed to %s should be numeric representing menu position.' ),
1334
+                '<code>add_menu_page()</code>'
1335
+            ),
1336
+            '6.0.0'
1337
+        );
1338
+        $position = null;
1339
+    }
1340
+
1341
+    if ( null === $position || ! is_numeric( $position ) ) {
1342
+        $menu[] = $new_menu;
1343
+    } elseif ( isset( $menu[ (string) $position ] ) ) {
1344
+        $collision_avoider = base_convert( substr( md5( $menu_slug . $menu_title ), -4 ), 16, 10 ) * 0.00001;
1345
+        $position          = (string) ( $position + $collision_avoider );
1346
+        $menu[ $position ] = $new_menu;
1347
+    } else {
1348
+        /*
1349 1349
 		 * Cast menu position to a string.
1350 1350
 		 *
1351 1351
 		 * This allows for floats to be passed as the position. PHP will normally cast a float to an
@@ -1353,16 +1353,16 @@  discard block
 block discarded – undo
1353 1353
 		 *
1354 1354
 		 * A string containing an integer value, eg "10", is treated as a numeric index.
1355 1355
 		 */
1356
-		$position          = (string) $position;
1357
-		$menu[ $position ] = $new_menu;
1358
-	}
1356
+        $position          = (string) $position;
1357
+        $menu[ $position ] = $new_menu;
1358
+    }
1359 1359
 
1360
-	$_registered_pages[ $hookname ] = true;
1360
+    $_registered_pages[ $hookname ] = true;
1361 1361
 
1362
-	// No parent as top level.
1363
-	$_parent_pages[ $menu_slug ] = false;
1362
+    // No parent as top level.
1363
+    $_parent_pages[ $menu_slug ] = false;
1364 1364
 
1365
-	return $hookname;
1365
+    return $hookname;
1366 1366
 }
1367 1367
 
1368 1368
 /**
@@ -1398,95 +1398,95 @@  discard block
 block discarded – undo
1398 1398
  * @return string|false The resulting page's hook_suffix, or false if the user does not have the capability required.
1399 1399
  */
1400 1400
 function add_submenu_page( $parent_slug, $page_title, $menu_title, $capability, $menu_slug, $callback = '', $position = null ) {
1401
-	global $submenu, $menu, $_wp_real_parent_file, $_wp_submenu_nopriv,
1402
-		$_registered_pages, $_parent_pages;
1401
+    global $submenu, $menu, $_wp_real_parent_file, $_wp_submenu_nopriv,
1402
+        $_registered_pages, $_parent_pages;
1403 1403
 
1404
-	$menu_slug   = plugin_basename( $menu_slug );
1405
-	$parent_slug = plugin_basename( $parent_slug );
1404
+    $menu_slug   = plugin_basename( $menu_slug );
1405
+    $parent_slug = plugin_basename( $parent_slug );
1406 1406
 
1407
-	if ( isset( $_wp_real_parent_file[ $parent_slug ] ) ) {
1408
-		$parent_slug = $_wp_real_parent_file[ $parent_slug ];
1409
-	}
1407
+    if ( isset( $_wp_real_parent_file[ $parent_slug ] ) ) {
1408
+        $parent_slug = $_wp_real_parent_file[ $parent_slug ];
1409
+    }
1410 1410
 
1411
-	if ( ! current_user_can( $capability ) ) {
1412
-		$_wp_submenu_nopriv[ $parent_slug ][ $menu_slug ] = true;
1413
-		return false;
1414
-	}
1411
+    if ( ! current_user_can( $capability ) ) {
1412
+        $_wp_submenu_nopriv[ $parent_slug ][ $menu_slug ] = true;
1413
+        return false;
1414
+    }
1415 1415
 
1416
-	/*
1416
+    /*
1417 1417
 	 * If the parent doesn't already have a submenu, add a link to the parent
1418 1418
 	 * as the first item in the submenu. If the submenu file is the same as the
1419 1419
 	 * parent file someone is trying to link back to the parent manually. In
1420 1420
 	 * this case, don't automatically add a link back to avoid duplication.
1421 1421
 	 */
1422
-	if ( ! isset( $submenu[ $parent_slug ] ) && $menu_slug !== $parent_slug ) {
1423
-		foreach ( (array) $menu as $parent_menu ) {
1424
-			if ( $parent_menu[2] === $parent_slug && current_user_can( $parent_menu[1] ) ) {
1425
-				$submenu[ $parent_slug ][] = array_slice( $parent_menu, 0, 4 );
1426
-			}
1427
-		}
1428
-	}
1429
-
1430
-	$new_sub_menu = array( $menu_title, $capability, $menu_slug, $page_title );
1431
-
1432
-	if ( null !== $position && ! is_numeric( $position ) ) {
1433
-		_doing_it_wrong(
1434
-			__FUNCTION__,
1435
-			sprintf(
1436
-				/* translators: %s: add_submenu_page() */
1437
-				__( 'The seventh parameter passed to %s should be numeric representing menu position.' ),
1438
-				'<code>add_submenu_page()</code>'
1439
-			),
1440
-			'5.3.0'
1441
-		);
1442
-		$position = null;
1443
-	}
1444
-
1445
-	if (
1446
-		null === $position ||
1447
-		( ! isset( $submenu[ $parent_slug ] ) || $position >= count( $submenu[ $parent_slug ] ) )
1448
-	) {
1449
-		$submenu[ $parent_slug ][] = $new_sub_menu;
1450
-	} else {
1451
-		// Test for a negative position.
1452
-		$position = max( $position, 0 );
1453
-		if ( 0 === $position ) {
1454
-			// For negative or `0` positions, prepend the submenu.
1455
-			array_unshift( $submenu[ $parent_slug ], $new_sub_menu );
1456
-		} else {
1457
-			// Grab all of the items before the insertion point.
1458
-			$before_items = array_slice( $submenu[ $parent_slug ], 0, $position, true );
1459
-			// Grab all of the items after the insertion point.
1460
-			$after_items = array_slice( $submenu[ $parent_slug ], $position, null, true );
1461
-			// Add the new item.
1462
-			$before_items[] = $new_sub_menu;
1463
-			// Merge the items.
1464
-			$submenu[ $parent_slug ] = array_merge( $before_items, $after_items );
1465
-		}
1466
-	}
1467
-
1468
-	// Sort the parent array.
1469
-	ksort( $submenu[ $parent_slug ] );
1470
-
1471
-	$hookname = get_plugin_page_hookname( $menu_slug, $parent_slug );
1472
-	if ( ! empty( $callback ) && ! empty( $hookname ) ) {
1473
-		add_action( $hookname, $callback );
1474
-	}
1475
-
1476
-	$_registered_pages[ $hookname ] = true;
1477
-
1478
-	/*
1422
+    if ( ! isset( $submenu[ $parent_slug ] ) && $menu_slug !== $parent_slug ) {
1423
+        foreach ( (array) $menu as $parent_menu ) {
1424
+            if ( $parent_menu[2] === $parent_slug && current_user_can( $parent_menu[1] ) ) {
1425
+                $submenu[ $parent_slug ][] = array_slice( $parent_menu, 0, 4 );
1426
+            }
1427
+        }
1428
+    }
1429
+
1430
+    $new_sub_menu = array( $menu_title, $capability, $menu_slug, $page_title );
1431
+
1432
+    if ( null !== $position && ! is_numeric( $position ) ) {
1433
+        _doing_it_wrong(
1434
+            __FUNCTION__,
1435
+            sprintf(
1436
+                /* translators: %s: add_submenu_page() */
1437
+                __( 'The seventh parameter passed to %s should be numeric representing menu position.' ),
1438
+                '<code>add_submenu_page()</code>'
1439
+            ),
1440
+            '5.3.0'
1441
+        );
1442
+        $position = null;
1443
+    }
1444
+
1445
+    if (
1446
+        null === $position ||
1447
+        ( ! isset( $submenu[ $parent_slug ] ) || $position >= count( $submenu[ $parent_slug ] ) )
1448
+    ) {
1449
+        $submenu[ $parent_slug ][] = $new_sub_menu;
1450
+    } else {
1451
+        // Test for a negative position.
1452
+        $position = max( $position, 0 );
1453
+        if ( 0 === $position ) {
1454
+            // For negative or `0` positions, prepend the submenu.
1455
+            array_unshift( $submenu[ $parent_slug ], $new_sub_menu );
1456
+        } else {
1457
+            // Grab all of the items before the insertion point.
1458
+            $before_items = array_slice( $submenu[ $parent_slug ], 0, $position, true );
1459
+            // Grab all of the items after the insertion point.
1460
+            $after_items = array_slice( $submenu[ $parent_slug ], $position, null, true );
1461
+            // Add the new item.
1462
+            $before_items[] = $new_sub_menu;
1463
+            // Merge the items.
1464
+            $submenu[ $parent_slug ] = array_merge( $before_items, $after_items );
1465
+        }
1466
+    }
1467
+
1468
+    // Sort the parent array.
1469
+    ksort( $submenu[ $parent_slug ] );
1470
+
1471
+    $hookname = get_plugin_page_hookname( $menu_slug, $parent_slug );
1472
+    if ( ! empty( $callback ) && ! empty( $hookname ) ) {
1473
+        add_action( $hookname, $callback );
1474
+    }
1475
+
1476
+    $_registered_pages[ $hookname ] = true;
1477
+
1478
+    /*
1479 1479
 	 * Backward-compatibility for plugins using add_management_page().
1480 1480
 	 * See wp-admin/admin.php for redirect from edit.php to tools.php.
1481 1481
 	 */
1482
-	if ( 'tools.php' === $parent_slug ) {
1483
-		$_registered_pages[ get_plugin_page_hookname( $menu_slug, 'edit.php' ) ] = true;
1484
-	}
1482
+    if ( 'tools.php' === $parent_slug ) {
1483
+        $_registered_pages[ get_plugin_page_hookname( $menu_slug, 'edit.php' ) ] = true;
1484
+    }
1485 1485
 
1486
-	// No parent as top level.
1487
-	$_parent_pages[ $menu_slug ] = $parent_slug;
1486
+    // No parent as top level.
1487
+    $_parent_pages[ $menu_slug ] = $parent_slug;
1488 1488
 
1489
-	return $hookname;
1489
+    return $hookname;
1490 1490
 }
1491 1491
 
1492 1492
 /**
@@ -1510,7 +1510,7 @@  discard block
 block discarded – undo
1510 1510
  * @return string|false The resulting page's hook_suffix, or false if the user does not have the capability required.
1511 1511
  */
1512 1512
 function add_management_page( $page_title, $menu_title, $capability, $menu_slug, $callback = '', $position = null ) {
1513
-	return add_submenu_page( 'tools.php', $page_title, $menu_title, $capability, $menu_slug, $callback, $position );
1513
+    return add_submenu_page( 'tools.php', $page_title, $menu_title, $capability, $menu_slug, $callback, $position );
1514 1514
 }
1515 1515
 
1516 1516
 /**
@@ -1534,7 +1534,7 @@  discard block
 block discarded – undo
1534 1534
  * @return string|false The resulting page's hook_suffix, or false if the user does not have the capability required.
1535 1535
  */
1536 1536
 function add_options_page( $page_title, $menu_title, $capability, $menu_slug, $callback = '', $position = null ) {
1537
-	return add_submenu_page( 'options-general.php', $page_title, $menu_title, $capability, $menu_slug, $callback, $position );
1537
+    return add_submenu_page( 'options-general.php', $page_title, $menu_title, $capability, $menu_slug, $callback, $position );
1538 1538
 }
1539 1539
 
1540 1540
 /**
@@ -1558,7 +1558,7 @@  discard block
 block discarded – undo
1558 1558
  * @return string|false The resulting page's hook_suffix, or false if the user does not have the capability required.
1559 1559
  */
1560 1560
 function add_theme_page( $page_title, $menu_title, $capability, $menu_slug, $callback = '', $position = null ) {
1561
-	return add_submenu_page( 'themes.php', $page_title, $menu_title, $capability, $menu_slug, $callback, $position );
1561
+    return add_submenu_page( 'themes.php', $page_title, $menu_title, $capability, $menu_slug, $callback, $position );
1562 1562
 }
1563 1563
 
1564 1564
 /**
@@ -1582,7 +1582,7 @@  discard block
 block discarded – undo
1582 1582
  * @return string|false The resulting page's hook_suffix, or false if the user does not have the capability required.
1583 1583
  */
1584 1584
 function add_plugins_page( $page_title, $menu_title, $capability, $menu_slug, $callback = '', $position = null ) {
1585
-	return add_submenu_page( 'plugins.php', $page_title, $menu_title, $capability, $menu_slug, $callback, $position );
1585
+    return add_submenu_page( 'plugins.php', $page_title, $menu_title, $capability, $menu_slug, $callback, $position );
1586 1586
 }
1587 1587
 
1588 1588
 /**
@@ -1606,12 +1606,12 @@  discard block
 block discarded – undo
1606 1606
  * @return string|false The resulting page's hook_suffix, or false if the user does not have the capability required.
1607 1607
  */
1608 1608
 function add_users_page( $page_title, $menu_title, $capability, $menu_slug, $callback = '', $position = null ) {
1609
-	if ( current_user_can( 'edit_users' ) ) {
1610
-		$parent = 'users.php';
1611
-	} else {
1612
-		$parent = 'profile.php';
1613
-	}
1614
-	return add_submenu_page( $parent, $page_title, $menu_title, $capability, $menu_slug, $callback, $position );
1609
+    if ( current_user_can( 'edit_users' ) ) {
1610
+        $parent = 'users.php';
1611
+    } else {
1612
+        $parent = 'profile.php';
1613
+    }
1614
+    return add_submenu_page( $parent, $page_title, $menu_title, $capability, $menu_slug, $callback, $position );
1615 1615
 }
1616 1616
 
1617 1617
 /**
@@ -1635,7 +1635,7 @@  discard block
 block discarded – undo
1635 1635
  * @return string|false The resulting page's hook_suffix, or false if the user does not have the capability required.
1636 1636
  */
1637 1637
 function add_dashboard_page( $page_title, $menu_title, $capability, $menu_slug, $callback = '', $position = null ) {
1638
-	return add_submenu_page( 'index.php', $page_title, $menu_title, $capability, $menu_slug, $callback, $position );
1638
+    return add_submenu_page( 'index.php', $page_title, $menu_title, $capability, $menu_slug, $callback, $position );
1639 1639
 }
1640 1640
 
1641 1641
 /**
@@ -1659,7 +1659,7 @@  discard block
 block discarded – undo
1659 1659
  * @return string|false The resulting page's hook_suffix, or false if the user does not have the capability required.
1660 1660
  */
1661 1661
 function add_posts_page( $page_title, $menu_title, $capability, $menu_slug, $callback = '', $position = null ) {
1662
-	return add_submenu_page( 'edit.php', $page_title, $menu_title, $capability, $menu_slug, $callback, $position );
1662
+    return add_submenu_page( 'edit.php', $page_title, $menu_title, $capability, $menu_slug, $callback, $position );
1663 1663
 }
1664 1664
 
1665 1665
 /**
@@ -1683,7 +1683,7 @@  discard block
 block discarded – undo
1683 1683
  * @return string|false The resulting page's hook_suffix, or false if the user does not have the capability required.
1684 1684
  */
1685 1685
 function add_media_page( $page_title, $menu_title, $capability, $menu_slug, $callback = '', $position = null ) {
1686
-	return add_submenu_page( 'upload.php', $page_title, $menu_title, $capability, $menu_slug, $callback, $position );
1686
+    return add_submenu_page( 'upload.php', $page_title, $menu_title, $capability, $menu_slug, $callback, $position );
1687 1687
 }
1688 1688
 
1689 1689
 /**
@@ -1707,7 +1707,7 @@  discard block
 block discarded – undo
1707 1707
  * @return string|false The resulting page's hook_suffix, or false if the user does not have the capability required.
1708 1708
  */
1709 1709
 function add_links_page( $page_title, $menu_title, $capability, $menu_slug, $callback = '', $position = null ) {
1710
-	return add_submenu_page( 'link-manager.php', $page_title, $menu_title, $capability, $menu_slug, $callback, $position );
1710
+    return add_submenu_page( 'link-manager.php', $page_title, $menu_title, $capability, $menu_slug, $callback, $position );
1711 1711
 }
1712 1712
 
1713 1713
 /**
@@ -1731,7 +1731,7 @@  discard block
 block discarded – undo
1731 1731
  * @return string|false The resulting page's hook_suffix, or false if the user does not have the capability required.
1732 1732
  */
1733 1733
 function add_pages_page( $page_title, $menu_title, $capability, $menu_slug, $callback = '', $position = null ) {
1734
-	return add_submenu_page( 'edit.php?post_type=page', $page_title, $menu_title, $capability, $menu_slug, $callback, $position );
1734
+    return add_submenu_page( 'edit.php?post_type=page', $page_title, $menu_title, $capability, $menu_slug, $callback, $position );
1735 1735
 }
1736 1736
 
1737 1737
 /**
@@ -1755,7 +1755,7 @@  discard block
 block discarded – undo
1755 1755
  * @return string|false The resulting page's hook_suffix, or false if the user does not have the capability required.
1756 1756
  */
1757 1757
 function add_comments_page( $page_title, $menu_title, $capability, $menu_slug, $callback = '', $position = null ) {
1758
-	return add_submenu_page( 'edit-comments.php', $page_title, $menu_title, $capability, $menu_slug, $callback, $position );
1758
+    return add_submenu_page( 'edit-comments.php', $page_title, $menu_title, $capability, $menu_slug, $callback, $position );
1759 1759
 }
1760 1760
 
1761 1761
 /**
@@ -1774,16 +1774,16 @@  discard block
 block discarded – undo
1774 1774
  * @return array|false The removed menu on success, false if not found.
1775 1775
  */
1776 1776
 function remove_menu_page( $menu_slug ) {
1777
-	global $menu;
1777
+    global $menu;
1778 1778
 
1779
-	foreach ( $menu as $i => $item ) {
1780
-		if ( $menu_slug === $item[2] ) {
1781
-			unset( $menu[ $i ] );
1782
-			return $item;
1783
-		}
1784
-	}
1779
+    foreach ( $menu as $i => $item ) {
1780
+        if ( $menu_slug === $item[2] ) {
1781
+            unset( $menu[ $i ] );
1782
+            return $item;
1783
+        }
1784
+    }
1785 1785
 
1786
-	return false;
1786
+    return false;
1787 1787
 }
1788 1788
 
1789 1789
 /**
@@ -1804,20 +1804,20 @@  discard block
 block discarded – undo
1804 1804
  * @return array|false The removed submenu on success, false if not found.
1805 1805
  */
1806 1806
 function remove_submenu_page( $menu_slug, $submenu_slug ) {
1807
-	global $submenu;
1807
+    global $submenu;
1808 1808
 
1809
-	if ( ! isset( $submenu[ $menu_slug ] ) ) {
1810
-		return false;
1811
-	}
1809
+    if ( ! isset( $submenu[ $menu_slug ] ) ) {
1810
+        return false;
1811
+    }
1812 1812
 
1813
-	foreach ( $submenu[ $menu_slug ] as $i => $item ) {
1814
-		if ( $submenu_slug === $item[2] ) {
1815
-			unset( $submenu[ $menu_slug ][ $i ] );
1816
-			return $item;
1817
-		}
1818
-	}
1813
+    foreach ( $submenu[ $menu_slug ] as $i => $item ) {
1814
+        if ( $submenu_slug === $item[2] ) {
1815
+            unset( $submenu[ $menu_slug ][ $i ] );
1816
+            return $item;
1817
+        }
1818
+    }
1819 1819
 
1820
-	return false;
1820
+    return false;
1821 1821
 }
1822 1822
 
1823 1823
 /**
@@ -1834,27 +1834,27 @@  discard block
 block discarded – undo
1834 1834
  * @return string The menu page URL.
1835 1835
  */
1836 1836
 function menu_page_url( $menu_slug, $display = true ) {
1837
-	global $_parent_pages;
1837
+    global $_parent_pages;
1838 1838
 
1839
-	if ( isset( $_parent_pages[ $menu_slug ] ) ) {
1840
-		$parent_slug = $_parent_pages[ $menu_slug ];
1839
+    if ( isset( $_parent_pages[ $menu_slug ] ) ) {
1840
+        $parent_slug = $_parent_pages[ $menu_slug ];
1841 1841
 
1842
-		if ( $parent_slug && ! isset( $_parent_pages[ $parent_slug ] ) ) {
1843
-			$url = admin_url( add_query_arg( 'page', $menu_slug, $parent_slug ) );
1844
-		} else {
1845
-			$url = admin_url( 'admin.php?page=' . $menu_slug );
1846
-		}
1847
-	} else {
1848
-		$url = '';
1849
-	}
1842
+        if ( $parent_slug && ! isset( $_parent_pages[ $parent_slug ] ) ) {
1843
+            $url = admin_url( add_query_arg( 'page', $menu_slug, $parent_slug ) );
1844
+        } else {
1845
+            $url = admin_url( 'admin.php?page=' . $menu_slug );
1846
+        }
1847
+    } else {
1848
+        $url = '';
1849
+    }
1850 1850
 
1851
-	$url = esc_url( $url );
1851
+    $url = esc_url( $url );
1852 1852
 
1853
-	if ( $display ) {
1854
-		echo $url;
1855
-	}
1853
+    if ( $display ) {
1854
+        echo $url;
1855
+    }
1856 1856
 
1857
-	return $url;
1857
+    return $url;
1858 1858
 }
1859 1859
 
1860 1860
 //
@@ -1880,75 +1880,75 @@  discard block
 block discarded – undo
1880 1880
  * @return string The parent file of the current admin page.
1881 1881
  */
1882 1882
 function get_admin_page_parent( $parent_page = '' ) {
1883
-	global $parent_file, $menu, $submenu, $pagenow, $typenow,
1884
-		$plugin_page, $_wp_real_parent_file, $_wp_menu_nopriv, $_wp_submenu_nopriv;
1885
-
1886
-	if ( ! empty( $parent_page ) && 'admin.php' !== $parent_page ) {
1887
-		if ( isset( $_wp_real_parent_file[ $parent_page ] ) ) {
1888
-			$parent_page = $_wp_real_parent_file[ $parent_page ];
1889
-		}
1890
-
1891
-		return $parent_page;
1892
-	}
1893
-
1894
-	if ( 'admin.php' === $pagenow && isset( $plugin_page ) ) {
1895
-		foreach ( (array) $menu as $parent_menu ) {
1896
-			if ( $parent_menu[2] === $plugin_page ) {
1897
-				$parent_file = $plugin_page;
1898
-
1899
-				if ( isset( $_wp_real_parent_file[ $parent_file ] ) ) {
1900
-					$parent_file = $_wp_real_parent_file[ $parent_file ];
1901
-				}
1902
-
1903
-				return $parent_file;
1904
-			}
1905
-		}
1906
-		if ( isset( $_wp_menu_nopriv[ $plugin_page ] ) ) {
1907
-			$parent_file = $plugin_page;
1908
-
1909
-			if ( isset( $_wp_real_parent_file[ $parent_file ] ) ) {
1910
-					$parent_file = $_wp_real_parent_file[ $parent_file ];
1911
-			}
1912
-
1913
-			return $parent_file;
1914
-		}
1915
-	}
1916
-
1917
-	if ( isset( $plugin_page ) && isset( $_wp_submenu_nopriv[ $pagenow ][ $plugin_page ] ) ) {
1918
-		$parent_file = $pagenow;
1919
-
1920
-		if ( isset( $_wp_real_parent_file[ $parent_file ] ) ) {
1921
-			$parent_file = $_wp_real_parent_file[ $parent_file ];
1922
-		}
1923
-
1924
-		return $parent_file;
1925
-	}
1926
-
1927
-	foreach ( array_keys( (array) $submenu ) as $parent_page ) {
1928
-		foreach ( $submenu[ $parent_page ] as $submenu_array ) {
1929
-			if ( isset( $_wp_real_parent_file[ $parent_page ] ) ) {
1930
-				$parent_page = $_wp_real_parent_file[ $parent_page ];
1931
-			}
1932
-
1933
-			if ( ! empty( $typenow ) && "$pagenow?post_type=$typenow" === $submenu_array[2] ) {
1934
-				$parent_file = $parent_page;
1935
-				return $parent_page;
1936
-			} elseif ( empty( $typenow ) && $pagenow === $submenu_array[2]
1937
-				&& ( empty( $parent_file ) || false === strpos( $parent_file, '?' ) )
1938
-			) {
1939
-				$parent_file = $parent_page;
1940
-				return $parent_page;
1941
-			} elseif ( isset( $plugin_page ) && $plugin_page === $submenu_array[2] ) {
1942
-				$parent_file = $parent_page;
1943
-				return $parent_page;
1944
-			}
1945
-		}
1946
-	}
1947
-
1948
-	if ( empty( $parent_file ) ) {
1949
-		$parent_file = '';
1950
-	}
1951
-	return '';
1883
+    global $parent_file, $menu, $submenu, $pagenow, $typenow,
1884
+        $plugin_page, $_wp_real_parent_file, $_wp_menu_nopriv, $_wp_submenu_nopriv;
1885
+
1886
+    if ( ! empty( $parent_page ) && 'admin.php' !== $parent_page ) {
1887
+        if ( isset( $_wp_real_parent_file[ $parent_page ] ) ) {
1888
+            $parent_page = $_wp_real_parent_file[ $parent_page ];
1889
+        }
1890
+
1891
+        return $parent_page;
1892
+    }
1893
+
1894
+    if ( 'admin.php' === $pagenow && isset( $plugin_page ) ) {
1895
+        foreach ( (array) $menu as $parent_menu ) {
1896
+            if ( $parent_menu[2] === $plugin_page ) {
1897
+                $parent_file = $plugin_page;
1898
+
1899
+                if ( isset( $_wp_real_parent_file[ $parent_file ] ) ) {
1900
+                    $parent_file = $_wp_real_parent_file[ $parent_file ];
1901
+                }
1902
+
1903
+                return $parent_file;
1904
+            }
1905
+        }
1906
+        if ( isset( $_wp_menu_nopriv[ $plugin_page ] ) ) {
1907
+            $parent_file = $plugin_page;
1908
+
1909
+            if ( isset( $_wp_real_parent_file[ $parent_file ] ) ) {
1910
+                    $parent_file = $_wp_real_parent_file[ $parent_file ];
1911
+            }
1912
+
1913
+            return $parent_file;
1914
+        }
1915
+    }
1916
+
1917
+    if ( isset( $plugin_page ) && isset( $_wp_submenu_nopriv[ $pagenow ][ $plugin_page ] ) ) {
1918
+        $parent_file = $pagenow;
1919
+
1920
+        if ( isset( $_wp_real_parent_file[ $parent_file ] ) ) {
1921
+            $parent_file = $_wp_real_parent_file[ $parent_file ];
1922
+        }
1923
+
1924
+        return $parent_file;
1925
+    }
1926
+
1927
+    foreach ( array_keys( (array) $submenu ) as $parent_page ) {
1928
+        foreach ( $submenu[ $parent_page ] as $submenu_array ) {
1929
+            if ( isset( $_wp_real_parent_file[ $parent_page ] ) ) {
1930
+                $parent_page = $_wp_real_parent_file[ $parent_page ];
1931
+            }
1932
+
1933
+            if ( ! empty( $typenow ) && "$pagenow?post_type=$typenow" === $submenu_array[2] ) {
1934
+                $parent_file = $parent_page;
1935
+                return $parent_page;
1936
+            } elseif ( empty( $typenow ) && $pagenow === $submenu_array[2]
1937
+                && ( empty( $parent_file ) || false === strpos( $parent_file, '?' ) )
1938
+            ) {
1939
+                $parent_file = $parent_page;
1940
+                return $parent_page;
1941
+            } elseif ( isset( $plugin_page ) && $plugin_page === $submenu_array[2] ) {
1942
+                $parent_file = $parent_page;
1943
+                return $parent_page;
1944
+            }
1945
+        }
1946
+    }
1947
+
1948
+    if ( empty( $parent_file ) ) {
1949
+        $parent_file = '';
1950
+    }
1951
+    return '';
1952 1952
 }
1953 1953
 
1954 1954
 /**
@@ -1966,75 +1966,75 @@  discard block
 block discarded – undo
1966 1966
  * @return string The title of the current admin page.
1967 1967
  */
1968 1968
 function get_admin_page_title() {
1969
-	global $title, $menu, $submenu, $pagenow, $typenow, $plugin_page;
1970
-
1971
-	if ( ! empty( $title ) ) {
1972
-		return $title;
1973
-	}
1974
-
1975
-	$hook = get_plugin_page_hook( $plugin_page, $pagenow );
1976
-
1977
-	$parent  = get_admin_page_parent();
1978
-	$parent1 = $parent;
1979
-
1980
-	if ( empty( $parent ) ) {
1981
-		foreach ( (array) $menu as $menu_array ) {
1982
-			if ( isset( $menu_array[3] ) ) {
1983
-				if ( $menu_array[2] === $pagenow ) {
1984
-					$title = $menu_array[3];
1985
-					return $menu_array[3];
1986
-				} elseif ( isset( $plugin_page ) && $plugin_page === $menu_array[2] && $hook === $menu_array[5] ) {
1987
-					$title = $menu_array[3];
1988
-					return $menu_array[3];
1989
-				}
1990
-			} else {
1991
-				$title = $menu_array[0];
1992
-				return $title;
1993
-			}
1994
-		}
1995
-	} else {
1996
-		foreach ( array_keys( $submenu ) as $parent ) {
1997
-			foreach ( $submenu[ $parent ] as $submenu_array ) {
1998
-				if ( isset( $plugin_page )
1999
-					&& $plugin_page === $submenu_array[2]
2000
-					&& ( $pagenow === $parent
2001
-						|| $plugin_page === $parent
2002
-						|| $plugin_page === $hook
2003
-						|| 'admin.php' === $pagenow && $parent1 !== $submenu_array[2]
2004
-						|| ! empty( $typenow ) && "$pagenow?post_type=$typenow" === $parent )
2005
-					) {
2006
-						$title = $submenu_array[3];
2007
-						return $submenu_array[3];
2008
-				}
2009
-
2010
-				if ( $submenu_array[2] !== $pagenow || isset( $_GET['page'] ) ) { // Not the current page.
2011
-					continue;
2012
-				}
2013
-
2014
-				if ( isset( $submenu_array[3] ) ) {
2015
-					$title = $submenu_array[3];
2016
-					return $submenu_array[3];
2017
-				} else {
2018
-					$title = $submenu_array[0];
2019
-					return $title;
2020
-				}
2021
-			}
2022
-		}
2023
-		if ( empty( $title ) ) {
2024
-			foreach ( $menu as $menu_array ) {
2025
-				if ( isset( $plugin_page )
2026
-					&& $plugin_page === $menu_array[2]
2027
-					&& 'admin.php' === $pagenow
2028
-					&& $parent1 === $menu_array[2]
2029
-				) {
2030
-						$title = $menu_array[3];
2031
-						return $menu_array[3];
2032
-				}
2033
-			}
2034
-		}
2035
-	}
2036
-
2037
-	return $title;
1969
+    global $title, $menu, $submenu, $pagenow, $typenow, $plugin_page;
1970
+
1971
+    if ( ! empty( $title ) ) {
1972
+        return $title;
1973
+    }
1974
+
1975
+    $hook = get_plugin_page_hook( $plugin_page, $pagenow );
1976
+
1977
+    $parent  = get_admin_page_parent();
1978
+    $parent1 = $parent;
1979
+
1980
+    if ( empty( $parent ) ) {
1981
+        foreach ( (array) $menu as $menu_array ) {
1982
+            if ( isset( $menu_array[3] ) ) {
1983
+                if ( $menu_array[2] === $pagenow ) {
1984
+                    $title = $menu_array[3];
1985
+                    return $menu_array[3];
1986
+                } elseif ( isset( $plugin_page ) && $plugin_page === $menu_array[2] && $hook === $menu_array[5] ) {
1987
+                    $title = $menu_array[3];
1988
+                    return $menu_array[3];
1989
+                }
1990
+            } else {
1991
+                $title = $menu_array[0];
1992
+                return $title;
1993
+            }
1994
+        }
1995
+    } else {
1996
+        foreach ( array_keys( $submenu ) as $parent ) {
1997
+            foreach ( $submenu[ $parent ] as $submenu_array ) {
1998
+                if ( isset( $plugin_page )
1999
+                    && $plugin_page === $submenu_array[2]
2000
+                    && ( $pagenow === $parent
2001
+                        || $plugin_page === $parent
2002
+                        || $plugin_page === $hook
2003
+                        || 'admin.php' === $pagenow && $parent1 !== $submenu_array[2]
2004
+                        || ! empty( $typenow ) && "$pagenow?post_type=$typenow" === $parent )
2005
+                    ) {
2006
+                        $title = $submenu_array[3];
2007
+                        return $submenu_array[3];
2008
+                }
2009
+
2010
+                if ( $submenu_array[2] !== $pagenow || isset( $_GET['page'] ) ) { // Not the current page.
2011
+                    continue;
2012
+                }
2013
+
2014
+                if ( isset( $submenu_array[3] ) ) {
2015
+                    $title = $submenu_array[3];
2016
+                    return $submenu_array[3];
2017
+                } else {
2018
+                    $title = $submenu_array[0];
2019
+                    return $title;
2020
+                }
2021
+            }
2022
+        }
2023
+        if ( empty( $title ) ) {
2024
+            foreach ( $menu as $menu_array ) {
2025
+                if ( isset( $plugin_page )
2026
+                    && $plugin_page === $menu_array[2]
2027
+                    && 'admin.php' === $pagenow
2028
+                    && $parent1 === $menu_array[2]
2029
+                ) {
2030
+                        $title = $menu_array[3];
2031
+                        return $menu_array[3];
2032
+                }
2033
+            }
2034
+        }
2035
+    }
2036
+
2037
+    return $title;
2038 2038
 }
2039 2039
 
2040 2040
 /**
@@ -2048,12 +2048,12 @@  discard block
 block discarded – undo
2048 2048
  * @return string|null Hook attached to the plugin page, null otherwise.
2049 2049
  */
2050 2050
 function get_plugin_page_hook( $plugin_page, $parent_page ) {
2051
-	$hook = get_plugin_page_hookname( $plugin_page, $parent_page );
2052
-	if ( has_action( $hook ) ) {
2053
-		return $hook;
2054
-	} else {
2055
-		return null;
2056
-	}
2051
+    $hook = get_plugin_page_hookname( $plugin_page, $parent_page );
2052
+    if ( has_action( $hook ) ) {
2053
+        return $hook;
2054
+    } else {
2055
+        return null;
2056
+    }
2057 2057
 }
2058 2058
 
2059 2059
 /**
@@ -2069,24 +2069,24 @@  discard block
 block discarded – undo
2069 2069
  * @return string Hook name for the plugin page.
2070 2070
  */
2071 2071
 function get_plugin_page_hookname( $plugin_page, $parent_page ) {
2072
-	global $admin_page_hooks;
2072
+    global $admin_page_hooks;
2073 2073
 
2074
-	$parent = get_admin_page_parent( $parent_page );
2074
+    $parent = get_admin_page_parent( $parent_page );
2075 2075
 
2076
-	$page_type = 'admin';
2077
-	if ( empty( $parent_page ) || 'admin.php' === $parent_page || isset( $admin_page_hooks[ $plugin_page ] ) ) {
2078
-		if ( isset( $admin_page_hooks[ $plugin_page ] ) ) {
2079
-			$page_type = 'toplevel';
2080
-		} elseif ( isset( $admin_page_hooks[ $parent ] ) ) {
2081
-			$page_type = $admin_page_hooks[ $parent ];
2082
-		}
2083
-	} elseif ( isset( $admin_page_hooks[ $parent ] ) ) {
2084
-		$page_type = $admin_page_hooks[ $parent ];
2085
-	}
2076
+    $page_type = 'admin';
2077
+    if ( empty( $parent_page ) || 'admin.php' === $parent_page || isset( $admin_page_hooks[ $plugin_page ] ) ) {
2078
+        if ( isset( $admin_page_hooks[ $plugin_page ] ) ) {
2079
+            $page_type = 'toplevel';
2080
+        } elseif ( isset( $admin_page_hooks[ $parent ] ) ) {
2081
+            $page_type = $admin_page_hooks[ $parent ];
2082
+        }
2083
+    } elseif ( isset( $admin_page_hooks[ $parent ] ) ) {
2084
+        $page_type = $admin_page_hooks[ $parent ];
2085
+    }
2086 2086
 
2087
-	$plugin_name = preg_replace( '!\.php!', '', $plugin_page );
2087
+    $plugin_name = preg_replace( '!\.php!', '', $plugin_page );
2088 2088
 
2089
-	return $page_type . '_page_' . $plugin_name;
2089
+    return $page_type . '_page_' . $plugin_name;
2090 2090
 }
2091 2091
 
2092 2092
 /**
@@ -2105,74 +2105,74 @@  discard block
 block discarded – undo
2105 2105
  * @return bool True if the current user can access the admin page, false otherwise.
2106 2106
  */
2107 2107
 function user_can_access_admin_page() {
2108
-	global $pagenow, $menu, $submenu, $_wp_menu_nopriv, $_wp_submenu_nopriv,
2109
-		$plugin_page, $_registered_pages;
2110
-
2111
-	$parent = get_admin_page_parent();
2112
-
2113
-	if ( ! isset( $plugin_page ) && isset( $_wp_submenu_nopriv[ $parent ][ $pagenow ] ) ) {
2114
-		return false;
2115
-	}
2116
-
2117
-	if ( isset( $plugin_page ) ) {
2118
-		if ( isset( $_wp_submenu_nopriv[ $parent ][ $plugin_page ] ) ) {
2119
-			return false;
2120
-		}
2121
-
2122
-		$hookname = get_plugin_page_hookname( $plugin_page, $parent );
2123
-
2124
-		if ( ! isset( $_registered_pages[ $hookname ] ) ) {
2125
-			return false;
2126
-		}
2127
-	}
2128
-
2129
-	if ( empty( $parent ) ) {
2130
-		if ( isset( $_wp_menu_nopriv[ $pagenow ] ) ) {
2131
-			return false;
2132
-		}
2133
-		if ( isset( $_wp_submenu_nopriv[ $pagenow ][ $pagenow ] ) ) {
2134
-			return false;
2135
-		}
2136
-		if ( isset( $plugin_page ) && isset( $_wp_submenu_nopriv[ $pagenow ][ $plugin_page ] ) ) {
2137
-			return false;
2138
-		}
2139
-		if ( isset( $plugin_page ) && isset( $_wp_menu_nopriv[ $plugin_page ] ) ) {
2140
-			return false;
2141
-		}
2142
-
2143
-		foreach ( array_keys( $_wp_submenu_nopriv ) as $key ) {
2144
-			if ( isset( $_wp_submenu_nopriv[ $key ][ $pagenow ] ) ) {
2145
-				return false;
2146
-			}
2147
-			if ( isset( $plugin_page ) && isset( $_wp_submenu_nopriv[ $key ][ $plugin_page ] ) ) {
2148
-				return false;
2149
-			}
2150
-		}
2151
-
2152
-		return true;
2153
-	}
2154
-
2155
-	if ( isset( $plugin_page ) && $plugin_page === $parent && isset( $_wp_menu_nopriv[ $plugin_page ] ) ) {
2156
-		return false;
2157
-	}
2158
-
2159
-	if ( isset( $submenu[ $parent ] ) ) {
2160
-		foreach ( $submenu[ $parent ] as $submenu_array ) {
2161
-			if ( isset( $plugin_page ) && $submenu_array[2] === $plugin_page ) {
2162
-				return current_user_can( $submenu_array[1] );
2163
-			} elseif ( $submenu_array[2] === $pagenow ) {
2164
-				return current_user_can( $submenu_array[1] );
2165
-			}
2166
-		}
2167
-	}
2168
-
2169
-	foreach ( $menu as $menu_array ) {
2170
-		if ( $menu_array[2] === $parent ) {
2171
-			return current_user_can( $menu_array[1] );
2172
-		}
2173
-	}
2174
-
2175
-	return true;
2108
+    global $pagenow, $menu, $submenu, $_wp_menu_nopriv, $_wp_submenu_nopriv,
2109
+        $plugin_page, $_registered_pages;
2110
+
2111
+    $parent = get_admin_page_parent();
2112
+
2113
+    if ( ! isset( $plugin_page ) && isset( $_wp_submenu_nopriv[ $parent ][ $pagenow ] ) ) {
2114
+        return false;
2115
+    }
2116
+
2117
+    if ( isset( $plugin_page ) ) {
2118
+        if ( isset( $_wp_submenu_nopriv[ $parent ][ $plugin_page ] ) ) {
2119
+            return false;
2120
+        }
2121
+
2122
+        $hookname = get_plugin_page_hookname( $plugin_page, $parent );
2123
+
2124
+        if ( ! isset( $_registered_pages[ $hookname ] ) ) {
2125
+            return false;
2126
+        }
2127
+    }
2128
+
2129
+    if ( empty( $parent ) ) {
2130
+        if ( isset( $_wp_menu_nopriv[ $pagenow ] ) ) {
2131
+            return false;
2132
+        }
2133
+        if ( isset( $_wp_submenu_nopriv[ $pagenow ][ $pagenow ] ) ) {
2134
+            return false;
2135
+        }
2136
+        if ( isset( $plugin_page ) && isset( $_wp_submenu_nopriv[ $pagenow ][ $plugin_page ] ) ) {
2137
+            return false;
2138
+        }
2139
+        if ( isset( $plugin_page ) && isset( $_wp_menu_nopriv[ $plugin_page ] ) ) {
2140
+            return false;
2141
+        }
2142
+
2143
+        foreach ( array_keys( $_wp_submenu_nopriv ) as $key ) {
2144
+            if ( isset( $_wp_submenu_nopriv[ $key ][ $pagenow ] ) ) {
2145
+                return false;
2146
+            }
2147
+            if ( isset( $plugin_page ) && isset( $_wp_submenu_nopriv[ $key ][ $plugin_page ] ) ) {
2148
+                return false;
2149
+            }
2150
+        }
2151
+
2152
+        return true;
2153
+    }
2154
+
2155
+    if ( isset( $plugin_page ) && $plugin_page === $parent && isset( $_wp_menu_nopriv[ $plugin_page ] ) ) {
2156
+        return false;
2157
+    }
2158
+
2159
+    if ( isset( $submenu[ $parent ] ) ) {
2160
+        foreach ( $submenu[ $parent ] as $submenu_array ) {
2161
+            if ( isset( $plugin_page ) && $submenu_array[2] === $plugin_page ) {
2162
+                return current_user_can( $submenu_array[1] );
2163
+            } elseif ( $submenu_array[2] === $pagenow ) {
2164
+                return current_user_can( $submenu_array[1] );
2165
+            }
2166
+        }
2167
+    }
2168
+
2169
+    foreach ( $menu as $menu_array ) {
2170
+        if ( $menu_array[2] === $parent ) {
2171
+            return current_user_can( $menu_array[1] );
2172
+        }
2173
+    }
2174
+
2175
+    return true;
2176 2176
 }
2177 2177
 
2178 2178
 /* Allowed list functions */
@@ -2192,13 +2192,13 @@  discard block
 block discarded – undo
2192 2192
  * @return array
2193 2193
  */
2194 2194
 function option_update_filter( $options ) {
2195
-	global $new_allowed_options;
2195
+    global $new_allowed_options;
2196 2196
 
2197
-	if ( is_array( $new_allowed_options ) ) {
2198
-		$options = add_allowed_options( $new_allowed_options, $options );
2199
-	}
2197
+    if ( is_array( $new_allowed_options ) ) {
2198
+        $options = add_allowed_options( $new_allowed_options, $options );
2199
+    }
2200 2200
 
2201
-	return $options;
2201
+    return $options;
2202 2202
 }
2203 2203
 
2204 2204
 /**
@@ -2213,27 +2213,27 @@  discard block
 block discarded – undo
2213 2213
  * @return array
2214 2214
  */
2215 2215
 function add_allowed_options( $new_options, $options = '' ) {
2216
-	if ( '' === $options ) {
2217
-		global $allowed_options;
2218
-	} else {
2219
-		$allowed_options = $options;
2220
-	}
2221
-
2222
-	foreach ( $new_options as $page => $keys ) {
2223
-		foreach ( $keys as $key ) {
2224
-			if ( ! isset( $allowed_options[ $page ] ) || ! is_array( $allowed_options[ $page ] ) ) {
2225
-				$allowed_options[ $page ]   = array();
2226
-				$allowed_options[ $page ][] = $key;
2227
-			} else {
2228
-				$pos = array_search( $key, $allowed_options[ $page ], true );
2229
-				if ( false === $pos ) {
2230
-					$allowed_options[ $page ][] = $key;
2231
-				}
2232
-			}
2233
-		}
2234
-	}
2235
-
2236
-	return $allowed_options;
2216
+    if ( '' === $options ) {
2217
+        global $allowed_options;
2218
+    } else {
2219
+        $allowed_options = $options;
2220
+    }
2221
+
2222
+    foreach ( $new_options as $page => $keys ) {
2223
+        foreach ( $keys as $key ) {
2224
+            if ( ! isset( $allowed_options[ $page ] ) || ! is_array( $allowed_options[ $page ] ) ) {
2225
+                $allowed_options[ $page ]   = array();
2226
+                $allowed_options[ $page ][] = $key;
2227
+            } else {
2228
+                $pos = array_search( $key, $allowed_options[ $page ], true );
2229
+                if ( false === $pos ) {
2230
+                    $allowed_options[ $page ][] = $key;
2231
+                }
2232
+            }
2233
+        }
2234
+    }
2235
+
2236
+    return $allowed_options;
2237 2237
 }
2238 2238
 
2239 2239
 /**
@@ -2248,24 +2248,24 @@  discard block
 block discarded – undo
2248 2248
  * @return array
2249 2249
  */
2250 2250
 function remove_allowed_options( $del_options, $options = '' ) {
2251
-	if ( '' === $options ) {
2252
-		global $allowed_options;
2253
-	} else {
2254
-		$allowed_options = $options;
2255
-	}
2256
-
2257
-	foreach ( $del_options as $page => $keys ) {
2258
-		foreach ( $keys as $key ) {
2259
-			if ( isset( $allowed_options[ $page ] ) && is_array( $allowed_options[ $page ] ) ) {
2260
-				$pos = array_search( $key, $allowed_options[ $page ], true );
2261
-				if ( false !== $pos ) {
2262
-					unset( $allowed_options[ $page ][ $pos ] );
2263
-				}
2264
-			}
2265
-		}
2266
-	}
2267
-
2268
-	return $allowed_options;
2251
+    if ( '' === $options ) {
2252
+        global $allowed_options;
2253
+    } else {
2254
+        $allowed_options = $options;
2255
+    }
2256
+
2257
+    foreach ( $del_options as $page => $keys ) {
2258
+        foreach ( $keys as $key ) {
2259
+            if ( isset( $allowed_options[ $page ] ) && is_array( $allowed_options[ $page ] ) ) {
2260
+                $pos = array_search( $key, $allowed_options[ $page ], true );
2261
+                if ( false !== $pos ) {
2262
+                    unset( $allowed_options[ $page ][ $pos ] );
2263
+                }
2264
+            }
2265
+        }
2266
+    }
2267
+
2268
+    return $allowed_options;
2269 2269
 }
2270 2270
 
2271 2271
 /**
@@ -2277,9 +2277,9 @@  discard block
 block discarded – undo
2277 2277
  *                             used in register_setting().
2278 2278
  */
2279 2279
 function settings_fields( $option_group ) {
2280
-	echo "<input type='hidden' name='option_page' value='" . esc_attr( $option_group ) . "' />";
2281
-	echo '<input type="hidden" name="action" value="update" />';
2282
-	wp_nonce_field( "$option_group-options" );
2280
+    echo "<input type='hidden' name='option_page' value='" . esc_attr( $option_group ) . "' />";
2281
+    echo '<input type="hidden" name="action" value="update" />';
2282
+    wp_nonce_field( "$option_group-options" );
2283 2283
 }
2284 2284
 
2285 2285
 /**
@@ -2290,10 +2290,10 @@  discard block
 block discarded – undo
2290 2290
  * @param bool $clear_update_cache Whether to clear the plugin updates cache. Default true.
2291 2291
  */
2292 2292
 function wp_clean_plugins_cache( $clear_update_cache = true ) {
2293
-	if ( $clear_update_cache ) {
2294
-		delete_site_transient( 'update_plugins' );
2295
-	}
2296
-	wp_cache_delete( 'plugins', 'plugins' );
2293
+    if ( $clear_update_cache ) {
2294
+        delete_site_transient( 'update_plugins' );
2295
+    }
2296
+    wp_cache_delete( 'plugins', 'plugins' );
2297 2297
 }
2298 2298
 
2299 2299
 /**
@@ -2305,12 +2305,12 @@  discard block
 block discarded – undo
2305 2305
  * @param string $plugin Path to the plugin file relative to the plugins directory.
2306 2306
  */
2307 2307
 function plugin_sandbox_scrape( $plugin ) {
2308
-	if ( ! defined( 'WP_SANDBOX_SCRAPING' ) ) {
2309
-		define( 'WP_SANDBOX_SCRAPING', true );
2310
-	}
2308
+    if ( ! defined( 'WP_SANDBOX_SCRAPING' ) ) {
2309
+        define( 'WP_SANDBOX_SCRAPING', true );
2310
+    }
2311 2311
 
2312
-	wp_register_plugin_realpath( WP_PLUGIN_DIR . '/' . $plugin );
2313
-	include_once WP_PLUGIN_DIR . '/' . $plugin;
2312
+    wp_register_plugin_realpath( WP_PLUGIN_DIR . '/' . $plugin );
2313
+    include_once WP_PLUGIN_DIR . '/' . $plugin;
2314 2314
 }
2315 2315
 
2316 2316
 /**
@@ -2340,35 +2340,35 @@  discard block
 block discarded – undo
2340 2340
  * @param string $policy_text The suggested content for inclusion in the policy.
2341 2341
  */
2342 2342
 function wp_add_privacy_policy_content( $plugin_name, $policy_text ) {
2343
-	if ( ! is_admin() ) {
2344
-		_doing_it_wrong(
2345
-			__FUNCTION__,
2346
-			sprintf(
2347
-				/* translators: %s: admin_init */
2348
-				__( 'The suggested privacy policy content should be added only in wp-admin by using the %s (or later) action.' ),
2349
-				'<code>admin_init</code>'
2350
-			),
2351
-			'4.9.7'
2352
-		);
2353
-		return;
2354
-	} elseif ( ! doing_action( 'admin_init' ) && ! did_action( 'admin_init' ) ) {
2355
-		_doing_it_wrong(
2356
-			__FUNCTION__,
2357
-			sprintf(
2358
-				/* translators: %s: admin_init */
2359
-				__( 'The suggested privacy policy content should be added by using the %s (or later) action. Please see the inline documentation.' ),
2360
-				'<code>admin_init</code>'
2361
-			),
2362
-			'4.9.7'
2363
-		);
2364
-		return;
2365
-	}
2366
-
2367
-	if ( ! class_exists( 'WP_Privacy_Policy_Content' ) ) {
2368
-		require_once ABSPATH . 'wp-admin/includes/class-wp-privacy-policy-content.php';
2369
-	}
2370
-
2371
-	WP_Privacy_Policy_Content::add( $plugin_name, $policy_text );
2343
+    if ( ! is_admin() ) {
2344
+        _doing_it_wrong(
2345
+            __FUNCTION__,
2346
+            sprintf(
2347
+                /* translators: %s: admin_init */
2348
+                __( 'The suggested privacy policy content should be added only in wp-admin by using the %s (or later) action.' ),
2349
+                '<code>admin_init</code>'
2350
+            ),
2351
+            '4.9.7'
2352
+        );
2353
+        return;
2354
+    } elseif ( ! doing_action( 'admin_init' ) && ! did_action( 'admin_init' ) ) {
2355
+        _doing_it_wrong(
2356
+            __FUNCTION__,
2357
+            sprintf(
2358
+                /* translators: %s: admin_init */
2359
+                __( 'The suggested privacy policy content should be added by using the %s (or later) action. Please see the inline documentation.' ),
2360
+                '<code>admin_init</code>'
2361
+            ),
2362
+            '4.9.7'
2363
+        );
2364
+        return;
2365
+    }
2366
+
2367
+    if ( ! class_exists( 'WP_Privacy_Policy_Content' ) ) {
2368
+        require_once ABSPATH . 'wp-admin/includes/class-wp-privacy-policy-content.php';
2369
+    }
2370
+
2371
+    WP_Privacy_Policy_Content::add( $plugin_name, $policy_text );
2372 2372
 }
2373 2373
 
2374 2374
 /**
@@ -2385,17 +2385,17 @@  discard block
 block discarded – undo
2385 2385
  * @return bool True, if in the list of paused plugins. False, if not in the list.
2386 2386
  */
2387 2387
 function is_plugin_paused( $plugin ) {
2388
-	if ( ! isset( $GLOBALS['_paused_plugins'] ) ) {
2389
-		return false;
2390
-	}
2388
+    if ( ! isset( $GLOBALS['_paused_plugins'] ) ) {
2389
+        return false;
2390
+    }
2391 2391
 
2392
-	if ( ! is_plugin_active( $plugin ) ) {
2393
-		return false;
2394
-	}
2392
+    if ( ! is_plugin_active( $plugin ) ) {
2393
+        return false;
2394
+    }
2395 2395
 
2396
-	list( $plugin ) = explode( '/', $plugin );
2396
+    list( $plugin ) = explode( '/', $plugin );
2397 2397
 
2398
-	return array_key_exists( $plugin, $GLOBALS['_paused_plugins'] );
2398
+    return array_key_exists( $plugin, $GLOBALS['_paused_plugins'] );
2399 2399
 }
2400 2400
 
2401 2401
 /**
@@ -2408,17 +2408,17 @@  discard block
 block discarded – undo
2408 2408
  *                     or false if none was recorded.
2409 2409
  */
2410 2410
 function wp_get_plugin_error( $plugin ) {
2411
-	if ( ! isset( $GLOBALS['_paused_plugins'] ) ) {
2412
-		return false;
2413
-	}
2411
+    if ( ! isset( $GLOBALS['_paused_plugins'] ) ) {
2412
+        return false;
2413
+    }
2414 2414
 
2415
-	list( $plugin ) = explode( '/', $plugin );
2415
+    list( $plugin ) = explode( '/', $plugin );
2416 2416
 
2417
-	if ( ! array_key_exists( $plugin, $GLOBALS['_paused_plugins'] ) ) {
2418
-		return false;
2419
-	}
2417
+    if ( ! array_key_exists( $plugin, $GLOBALS['_paused_plugins'] ) ) {
2418
+        return false;
2419
+    }
2420 2420
 
2421
-	return $GLOBALS['_paused_plugins'][ $plugin ];
2421
+    return $GLOBALS['_paused_plugins'][ $plugin ];
2422 2422
 }
2423 2423
 
2424 2424
 /**
@@ -2439,37 +2439,37 @@  discard block
 block discarded – undo
2439 2439
  *                       `WP_Error` on failure.
2440 2440
  */
2441 2441
 function resume_plugin( $plugin, $redirect = '' ) {
2442
-	/*
2442
+    /*
2443 2443
 	 * We'll override this later if the plugin could be resumed without
2444 2444
 	 * creating a fatal error.
2445 2445
 	 */
2446
-	if ( ! empty( $redirect ) ) {
2447
-		wp_redirect(
2448
-			add_query_arg(
2449
-				'_error_nonce',
2450
-				wp_create_nonce( 'plugin-resume-error_' . $plugin ),
2451
-				$redirect
2452
-			)
2453
-		);
2454
-
2455
-		// Load the plugin to test whether it throws a fatal error.
2456
-		ob_start();
2457
-		plugin_sandbox_scrape( $plugin );
2458
-		ob_clean();
2459
-	}
2460
-
2461
-	list( $extension ) = explode( '/', $plugin );
2462
-
2463
-	$result = wp_paused_plugins()->delete( $extension );
2464
-
2465
-	if ( ! $result ) {
2466
-		return new WP_Error(
2467
-			'could_not_resume_plugin',
2468
-			__( 'Could not resume the plugin.' )
2469
-		);
2470
-	}
2471
-
2472
-	return true;
2446
+    if ( ! empty( $redirect ) ) {
2447
+        wp_redirect(
2448
+            add_query_arg(
2449
+                '_error_nonce',
2450
+                wp_create_nonce( 'plugin-resume-error_' . $plugin ),
2451
+                $redirect
2452
+            )
2453
+        );
2454
+
2455
+        // Load the plugin to test whether it throws a fatal error.
2456
+        ob_start();
2457
+        plugin_sandbox_scrape( $plugin );
2458
+        ob_clean();
2459
+    }
2460
+
2461
+    list( $extension ) = explode( '/', $plugin );
2462
+
2463
+    $result = wp_paused_plugins()->delete( $extension );
2464
+
2465
+    if ( ! $result ) {
2466
+        return new WP_Error(
2467
+            'could_not_resume_plugin',
2468
+            __( 'Could not resume the plugin.' )
2469
+        );
2470
+    }
2471
+
2472
+    return true;
2473 2473
 }
2474 2474
 
2475 2475
 /**
@@ -2480,25 +2480,25 @@  discard block
 block discarded – undo
2480 2480
  * @global string $pagenow The filename of the current screen.
2481 2481
  */
2482 2482
 function paused_plugins_notice() {
2483
-	if ( 'plugins.php' === $GLOBALS['pagenow'] ) {
2484
-		return;
2485
-	}
2486
-
2487
-	if ( ! current_user_can( 'resume_plugins' ) ) {
2488
-		return;
2489
-	}
2490
-
2491
-	if ( ! isset( $GLOBALS['_paused_plugins'] ) || empty( $GLOBALS['_paused_plugins'] ) ) {
2492
-		return;
2493
-	}
2494
-
2495
-	printf(
2496
-		'<div class="notice notice-error"><p><strong>%s</strong><br>%s</p><p><a href="%s">%s</a></p></div>',
2497
-		__( 'One or more plugins failed to load properly.' ),
2498
-		__( 'You can find more details and make changes on the Plugins screen.' ),
2499
-		esc_url( admin_url( 'plugins.php?plugin_status=paused' ) ),
2500
-		__( 'Go to the Plugins screen' )
2501
-	);
2483
+    if ( 'plugins.php' === $GLOBALS['pagenow'] ) {
2484
+        return;
2485
+    }
2486
+
2487
+    if ( ! current_user_can( 'resume_plugins' ) ) {
2488
+        return;
2489
+    }
2490
+
2491
+    if ( ! isset( $GLOBALS['_paused_plugins'] ) || empty( $GLOBALS['_paused_plugins'] ) ) {
2492
+        return;
2493
+    }
2494
+
2495
+    printf(
2496
+        '<div class="notice notice-error"><p><strong>%s</strong><br>%s</p><p><a href="%s">%s</a></p></div>',
2497
+        __( 'One or more plugins failed to load properly.' ),
2498
+        __( 'You can find more details and make changes on the Plugins screen.' ),
2499
+        esc_url( admin_url( 'plugins.php?plugin_status=paused' ) ),
2500
+        __( 'Go to the Plugins screen' )
2501
+    );
2502 2502
 }
2503 2503
 
2504 2504
 /**
@@ -2514,74 +2514,74 @@  discard block
 block discarded – undo
2514 2514
  * @global string $wp_version The WordPress version string.
2515 2515
  */
2516 2516
 function deactivated_plugins_notice() {
2517
-	if ( 'plugins.php' === $GLOBALS['pagenow'] ) {
2518
-		return;
2519
-	}
2520
-
2521
-	if ( ! current_user_can( 'activate_plugins' ) ) {
2522
-		return;
2523
-	}
2524
-
2525
-	$blog_deactivated_plugins = get_option( 'wp_force_deactivated_plugins' );
2526
-	$site_deactivated_plugins = array();
2527
-
2528
-	if ( false === $blog_deactivated_plugins ) {
2529
-		// Option not in database, add an empty array to avoid extra DB queries on subsequent loads.
2530
-		update_option( 'wp_force_deactivated_plugins', array() );
2531
-	}
2532
-
2533
-	if ( is_multisite() ) {
2534
-		$site_deactivated_plugins = get_site_option( 'wp_force_deactivated_plugins' );
2535
-		if ( false === $site_deactivated_plugins ) {
2536
-			// Option not in database, add an empty array to avoid extra DB queries on subsequent loads.
2537
-			update_site_option( 'wp_force_deactivated_plugins', array() );
2538
-		}
2539
-	}
2540
-
2541
-	if ( empty( $blog_deactivated_plugins ) && empty( $site_deactivated_plugins ) ) {
2542
-		// No deactivated plugins.
2543
-		return;
2544
-	}
2545
-
2546
-	$deactivated_plugins = array_merge( $blog_deactivated_plugins, $site_deactivated_plugins );
2547
-
2548
-	foreach ( $deactivated_plugins as $plugin ) {
2549
-		if ( ! empty( $plugin['version_compatible'] ) && ! empty( $plugin['version_deactivated'] ) ) {
2550
-			$explanation = sprintf(
2551
-				/* translators: 1: Name of deactivated plugin, 2: Plugin version deactivated, 3: Current WP version, 4: Compatible plugin version. */
2552
-				__( '%1$s %2$s was deactivated due to incompatibility with WordPress %3$s, please upgrade to %1$s %4$s or later.' ),
2553
-				$plugin['plugin_name'],
2554
-				$plugin['version_deactivated'],
2555
-				$GLOBALS['wp_version'],
2556
-				$plugin['version_compatible']
2557
-			);
2558
-		} else {
2559
-			$explanation = sprintf(
2560
-				/* translators: 1: Name of deactivated plugin, 2: Plugin version deactivated, 3: Current WP version. */
2561
-				__( '%1$s %2$s was deactivated due to incompatibility with WordPress %3$s.' ),
2562
-				$plugin['plugin_name'],
2563
-				! empty( $plugin['version_deactivated'] ) ? $plugin['version_deactivated'] : '',
2564
-				$GLOBALS['wp_version'],
2565
-				$plugin['version_compatible']
2566
-			);
2567
-		}
2568
-
2569
-		printf(
2570
-			'<div class="notice notice-warning"><p><strong>%s</strong><br>%s</p><p><a href="%s">%s</a></p></div>',
2571
-			sprintf(
2572
-				/* translators: %s: Name of deactivated plugin. */
2573
-				__( '%s plugin deactivated during WordPress upgrade.' ),
2574
-				$plugin['plugin_name']
2575
-			),
2576
-			$explanation,
2577
-			esc_url( admin_url( 'plugins.php?plugin_status=inactive' ) ),
2578
-			__( 'Go to the Plugins screen' )
2579
-		);
2580
-	}
2581
-
2582
-	// Empty the options.
2583
-	update_option( 'wp_force_deactivated_plugins', array() );
2584
-	if ( is_multisite() ) {
2585
-		update_site_option( 'wp_force_deactivated_plugins', array() );
2586
-	}
2517
+    if ( 'plugins.php' === $GLOBALS['pagenow'] ) {
2518
+        return;
2519
+    }
2520
+
2521
+    if ( ! current_user_can( 'activate_plugins' ) ) {
2522
+        return;
2523
+    }
2524
+
2525
+    $blog_deactivated_plugins = get_option( 'wp_force_deactivated_plugins' );
2526
+    $site_deactivated_plugins = array();
2527
+
2528
+    if ( false === $blog_deactivated_plugins ) {
2529
+        // Option not in database, add an empty array to avoid extra DB queries on subsequent loads.
2530
+        update_option( 'wp_force_deactivated_plugins', array() );
2531
+    }
2532
+
2533
+    if ( is_multisite() ) {
2534
+        $site_deactivated_plugins = get_site_option( 'wp_force_deactivated_plugins' );
2535
+        if ( false === $site_deactivated_plugins ) {
2536
+            // Option not in database, add an empty array to avoid extra DB queries on subsequent loads.
2537
+            update_site_option( 'wp_force_deactivated_plugins', array() );
2538
+        }
2539
+    }
2540
+
2541
+    if ( empty( $blog_deactivated_plugins ) && empty( $site_deactivated_plugins ) ) {
2542
+        // No deactivated plugins.
2543
+        return;
2544
+    }
2545
+
2546
+    $deactivated_plugins = array_merge( $blog_deactivated_plugins, $site_deactivated_plugins );
2547
+
2548
+    foreach ( $deactivated_plugins as $plugin ) {
2549
+        if ( ! empty( $plugin['version_compatible'] ) && ! empty( $plugin['version_deactivated'] ) ) {
2550
+            $explanation = sprintf(
2551
+                /* translators: 1: Name of deactivated plugin, 2: Plugin version deactivated, 3: Current WP version, 4: Compatible plugin version. */
2552
+                __( '%1$s %2$s was deactivated due to incompatibility with WordPress %3$s, please upgrade to %1$s %4$s or later.' ),
2553
+                $plugin['plugin_name'],
2554
+                $plugin['version_deactivated'],
2555
+                $GLOBALS['wp_version'],
2556
+                $plugin['version_compatible']
2557
+            );
2558
+        } else {
2559
+            $explanation = sprintf(
2560
+                /* translators: 1: Name of deactivated plugin, 2: Plugin version deactivated, 3: Current WP version. */
2561
+                __( '%1$s %2$s was deactivated due to incompatibility with WordPress %3$s.' ),
2562
+                $plugin['plugin_name'],
2563
+                ! empty( $plugin['version_deactivated'] ) ? $plugin['version_deactivated'] : '',
2564
+                $GLOBALS['wp_version'],
2565
+                $plugin['version_compatible']
2566
+            );
2567
+        }
2568
+
2569
+        printf(
2570
+            '<div class="notice notice-warning"><p><strong>%s</strong><br>%s</p><p><a href="%s">%s</a></p></div>',
2571
+            sprintf(
2572
+                /* translators: %s: Name of deactivated plugin. */
2573
+                __( '%s plugin deactivated during WordPress upgrade.' ),
2574
+                $plugin['plugin_name']
2575
+            ),
2576
+            $explanation,
2577
+            esc_url( admin_url( 'plugins.php?plugin_status=inactive' ) ),
2578
+            __( 'Go to the Plugins screen' )
2579
+        );
2580
+    }
2581
+
2582
+    // Empty the options.
2583
+    update_option( 'wp_force_deactivated_plugins', array() );
2584
+    if ( is_multisite() ) {
2585
+        update_site_option( 'wp_force_deactivated_plugins', array() );
2586
+    }
2587 2587
 }
Please login to merge, or discard this patch.
brighty/wp-admin/includes/class-wp-screen.php 1 patch
Indentation   +1231 added lines, -1231 removed lines patch added patch discarded remove patch
@@ -13,859 +13,859 @@  discard block
 block discarded – undo
13 13
  * @since 3.3.0
14 14
  */
15 15
 final class WP_Screen {
16
-	/**
17
-	 * Any action associated with the screen.
18
-	 *
19
-	 * 'add' for *-add.php and *-new.php screens. Empty otherwise.
20
-	 *
21
-	 * @since 3.3.0
22
-	 * @var string
23
-	 */
24
-	public $action;
25
-
26
-	/**
27
-	 * The base type of the screen.
28
-	 *
29
-	 * This is typically the same as `$id` but with any post types and taxonomies stripped.
30
-	 * For example, for an `$id` of 'edit-post' the base is 'edit'.
31
-	 *
32
-	 * @since 3.3.0
33
-	 * @var string
34
-	 */
35
-	public $base;
36
-
37
-	/**
38
-	 * The number of columns to display. Access with get_columns().
39
-	 *
40
-	 * @since 3.4.0
41
-	 * @var int
42
-	 */
43
-	private $columns = 0;
44
-
45
-	/**
46
-	 * The unique ID of the screen.
47
-	 *
48
-	 * @since 3.3.0
49
-	 * @var string
50
-	 */
51
-	public $id;
52
-
53
-	/**
54
-	 * Which admin the screen is in. network | user | site | false
55
-	 *
56
-	 * @since 3.5.0
57
-	 * @var string
58
-	 */
59
-	protected $in_admin;
60
-
61
-	/**
62
-	 * Whether the screen is in the network admin.
63
-	 *
64
-	 * Deprecated. Use in_admin() instead.
65
-	 *
66
-	 * @since 3.3.0
67
-	 * @deprecated 3.5.0
68
-	 * @var bool
69
-	 */
70
-	public $is_network;
71
-
72
-	/**
73
-	 * Whether the screen is in the user admin.
74
-	 *
75
-	 * Deprecated. Use in_admin() instead.
76
-	 *
77
-	 * @since 3.3.0
78
-	 * @deprecated 3.5.0
79
-	 * @var bool
80
-	 */
81
-	public $is_user;
82
-
83
-	/**
84
-	 * The base menu parent.
85
-	 *
86
-	 * This is derived from `$parent_file` by removing the query string and any .php extension.
87
-	 * `$parent_file` values of 'edit.php?post_type=page' and 'edit.php?post_type=post'
88
-	 * have a `$parent_base` of 'edit'.
89
-	 *
90
-	 * @since 3.3.0
91
-	 * @var string
92
-	 */
93
-	public $parent_base;
94
-
95
-	/**
96
-	 * The parent_file for the screen per the admin menu system.
97
-	 *
98
-	 * Some `$parent_file` values are 'edit.php?post_type=page', 'edit.php', and 'options-general.php'.
99
-	 *
100
-	 * @since 3.3.0
101
-	 * @var string
102
-	 */
103
-	public $parent_file;
104
-
105
-	/**
106
-	 * The post type associated with the screen, if any.
107
-	 *
108
-	 * The 'edit.php?post_type=page' screen has a post type of 'page'.
109
-	 * The 'edit-tags.php?taxonomy=$taxonomy&post_type=page' screen has a post type of 'page'.
110
-	 *
111
-	 * @since 3.3.0
112
-	 * @var string
113
-	 */
114
-	public $post_type;
115
-
116
-	/**
117
-	 * The taxonomy associated with the screen, if any.
118
-	 *
119
-	 * The 'edit-tags.php?taxonomy=category' screen has a taxonomy of 'category'.
120
-	 *
121
-	 * @since 3.3.0
122
-	 * @var string
123
-	 */
124
-	public $taxonomy;
125
-
126
-	/**
127
-	 * The help tab data associated with the screen, if any.
128
-	 *
129
-	 * @since 3.3.0
130
-	 * @var array
131
-	 */
132
-	private $_help_tabs = array();
133
-
134
-	/**
135
-	 * The help sidebar data associated with screen, if any.
136
-	 *
137
-	 * @since 3.3.0
138
-	 * @var string
139
-	 */
140
-	private $_help_sidebar = '';
141
-
142
-	/**
143
-	 * The accessible hidden headings and text associated with the screen, if any.
144
-	 *
145
-	 * @since 4.4.0
146
-	 * @var array
147
-	 */
148
-	private $_screen_reader_content = array();
149
-
150
-	/**
151
-	 * Stores old string-based help.
152
-	 *
153
-	 * @var array
154
-	 */
155
-	private static $_old_compat_help = array();
156
-
157
-	/**
158
-	 * The screen options associated with screen, if any.
159
-	 *
160
-	 * @since 3.3.0
161
-	 * @var array
162
-	 */
163
-	private $_options = array();
164
-
165
-	/**
166
-	 * The screen object registry.
167
-	 *
168
-	 * @since 3.3.0
169
-	 *
170
-	 * @var array
171
-	 */
172
-	private static $_registry = array();
173
-
174
-	/**
175
-	 * Stores the result of the public show_screen_options function.
176
-	 *
177
-	 * @since 3.3.0
178
-	 * @var bool
179
-	 */
180
-	private $_show_screen_options;
181
-
182
-	/**
183
-	 * Stores the 'screen_settings' section of screen options.
184
-	 *
185
-	 * @since 3.3.0
186
-	 * @var string
187
-	 */
188
-	private $_screen_settings;
189
-
190
-	/**
191
-	 * Whether the screen is using the block editor.
192
-	 *
193
-	 * @since 5.0.0
194
-	 * @var bool
195
-	 */
196
-	public $is_block_editor = false;
197
-
198
-	/**
199
-	 * Fetches a screen object.
200
-	 *
201
-	 * @since 3.3.0
202
-	 *
203
-	 * @global string $hook_suffix
204
-	 *
205
-	 * @param string|WP_Screen $hook_name Optional. The hook name (also known as the hook suffix) used to determine the screen.
206
-	 *                                    Defaults to the current $hook_suffix global.
207
-	 * @return WP_Screen Screen object.
208
-	 */
209
-	public static function get( $hook_name = '' ) {
210
-		if ( $hook_name instanceof WP_Screen ) {
211
-			return $hook_name;
212
-		}
213
-
214
-		$post_type       = null;
215
-		$taxonomy        = null;
216
-		$in_admin        = false;
217
-		$action          = '';
218
-		$is_block_editor = false;
219
-
220
-		if ( $hook_name ) {
221
-			$id = $hook_name;
222
-		} else {
223
-			$id = $GLOBALS['hook_suffix'];
224
-		}
225
-
226
-		// For those pesky meta boxes.
227
-		if ( $hook_name && post_type_exists( $hook_name ) ) {
228
-			$post_type = $id;
229
-			$id        = 'post'; // Changes later. Ends up being $base.
230
-		} else {
231
-			if ( '.php' === substr( $id, -4 ) ) {
232
-				$id = substr( $id, 0, -4 );
233
-			}
234
-
235
-			if ( in_array( $id, array( 'post-new', 'link-add', 'media-new', 'user-new' ), true ) ) {
236
-				$id     = substr( $id, 0, -4 );
237
-				$action = 'add';
238
-			}
239
-		}
240
-
241
-		if ( ! $post_type && $hook_name ) {
242
-			if ( '-network' === substr( $id, -8 ) ) {
243
-				$id       = substr( $id, 0, -8 );
244
-				$in_admin = 'network';
245
-			} elseif ( '-user' === substr( $id, -5 ) ) {
246
-				$id       = substr( $id, 0, -5 );
247
-				$in_admin = 'user';
248
-			}
249
-
250
-			$id = sanitize_key( $id );
251
-			if ( 'edit-comments' !== $id && 'edit-tags' !== $id && 'edit-' === substr( $id, 0, 5 ) ) {
252
-				$maybe = substr( $id, 5 );
253
-				if ( taxonomy_exists( $maybe ) ) {
254
-					$id       = 'edit-tags';
255
-					$taxonomy = $maybe;
256
-				} elseif ( post_type_exists( $maybe ) ) {
257
-					$id        = 'edit';
258
-					$post_type = $maybe;
259
-				}
260
-			}
261
-
262
-			if ( ! $in_admin ) {
263
-				$in_admin = 'site';
264
-			}
265
-		} else {
266
-			if ( defined( 'WP_NETWORK_ADMIN' ) && WP_NETWORK_ADMIN ) {
267
-				$in_admin = 'network';
268
-			} elseif ( defined( 'WP_USER_ADMIN' ) && WP_USER_ADMIN ) {
269
-				$in_admin = 'user';
270
-			} else {
271
-				$in_admin = 'site';
272
-			}
273
-		}
274
-
275
-		if ( 'index' === $id ) {
276
-			$id = 'dashboard';
277
-		} elseif ( 'front' === $id ) {
278
-			$in_admin = false;
279
-		}
280
-
281
-		$base = $id;
282
-
283
-		// If this is the current screen, see if we can be more accurate for post types and taxonomies.
284
-		if ( ! $hook_name ) {
285
-			if ( isset( $_REQUEST['post_type'] ) ) {
286
-				$post_type = post_type_exists( $_REQUEST['post_type'] ) ? $_REQUEST['post_type'] : false;
287
-			}
288
-			if ( isset( $_REQUEST['taxonomy'] ) ) {
289
-				$taxonomy = taxonomy_exists( $_REQUEST['taxonomy'] ) ? $_REQUEST['taxonomy'] : false;
290
-			}
291
-
292
-			switch ( $base ) {
293
-				case 'post':
294
-					if ( isset( $_GET['post'] ) && isset( $_POST['post_ID'] ) && (int) $_GET['post'] !== (int) $_POST['post_ID'] ) {
295
-						wp_die( __( 'A post ID mismatch has been detected.' ), __( 'Sorry, you are not allowed to edit this item.' ), 400 );
296
-					} elseif ( isset( $_GET['post'] ) ) {
297
-						$post_id = (int) $_GET['post'];
298
-					} elseif ( isset( $_POST['post_ID'] ) ) {
299
-						$post_id = (int) $_POST['post_ID'];
300
-					} else {
301
-						$post_id = 0;
302
-					}
303
-
304
-					if ( $post_id ) {
305
-						$post = get_post( $post_id );
306
-						if ( $post ) {
307
-							$post_type = $post->post_type;
308
-
309
-							/** This filter is documented in wp-admin/post.php */
310
-							$replace_editor = apply_filters( 'replace_editor', false, $post );
311
-
312
-							if ( ! $replace_editor ) {
313
-								$is_block_editor = use_block_editor_for_post( $post );
314
-							}
315
-						}
316
-					}
317
-					break;
318
-				case 'edit-tags':
319
-				case 'term':
320
-					if ( null === $post_type && is_object_in_taxonomy( 'post', $taxonomy ? $taxonomy : 'post_tag' ) ) {
321
-						$post_type = 'post';
322
-					}
323
-					break;
324
-				case 'upload':
325
-					$post_type = 'attachment';
326
-					break;
327
-			}
328
-		}
329
-
330
-		switch ( $base ) {
331
-			case 'post':
332
-				if ( null === $post_type ) {
333
-					$post_type = 'post';
334
-				}
335
-
336
-				// When creating a new post, use the default block editor support value for the post type.
337
-				if ( empty( $post_id ) ) {
338
-					$is_block_editor = use_block_editor_for_post_type( $post_type );
339
-				}
340
-
341
-				$id = $post_type;
342
-				break;
343
-			case 'edit':
344
-				if ( null === $post_type ) {
345
-					$post_type = 'post';
346
-				}
347
-				$id .= '-' . $post_type;
348
-				break;
349
-			case 'edit-tags':
350
-			case 'term':
351
-				if ( null === $taxonomy ) {
352
-					$taxonomy = 'post_tag';
353
-				}
354
-				// The edit-tags ID does not contain the post type. Look for it in the request.
355
-				if ( null === $post_type ) {
356
-					$post_type = 'post';
357
-					if ( isset( $_REQUEST['post_type'] ) && post_type_exists( $_REQUEST['post_type'] ) ) {
358
-						$post_type = $_REQUEST['post_type'];
359
-					}
360
-				}
361
-
362
-				$id = 'edit-' . $taxonomy;
363
-				break;
364
-		}
365
-
366
-		if ( 'network' === $in_admin ) {
367
-			$id   .= '-network';
368
-			$base .= '-network';
369
-		} elseif ( 'user' === $in_admin ) {
370
-			$id   .= '-user';
371
-			$base .= '-user';
372
-		}
373
-
374
-		if ( isset( self::$_registry[ $id ] ) ) {
375
-			$screen = self::$_registry[ $id ];
376
-			if ( get_current_screen() === $screen ) {
377
-				return $screen;
378
-			}
379
-		} else {
380
-			$screen     = new self();
381
-			$screen->id = $id;
382
-		}
383
-
384
-		$screen->base            = $base;
385
-		$screen->action          = $action;
386
-		$screen->post_type       = (string) $post_type;
387
-		$screen->taxonomy        = (string) $taxonomy;
388
-		$screen->is_user         = ( 'user' === $in_admin );
389
-		$screen->is_network      = ( 'network' === $in_admin );
390
-		$screen->in_admin        = $in_admin;
391
-		$screen->is_block_editor = $is_block_editor;
392
-
393
-		self::$_registry[ $id ] = $screen;
394
-
395
-		return $screen;
396
-	}
397
-
398
-	/**
399
-	 * Makes the screen object the current screen.
400
-	 *
401
-	 * @see set_current_screen()
402
-	 * @since 3.3.0
403
-	 *
404
-	 * @global WP_Screen $current_screen WordPress current screen object.
405
-	 * @global string    $typenow        The post type of the current screen.
406
-	 * @global string    $taxnow         The taxonomy of the current screen.
407
-	 */
408
-	public function set_current_screen() {
409
-		global $current_screen, $taxnow, $typenow;
410
-
411
-		$current_screen = $this;
412
-		$typenow        = $this->post_type;
413
-		$taxnow         = $this->taxonomy;
414
-
415
-		/**
416
-		 * Fires after the current screen has been set.
417
-		 *
418
-		 * @since 3.0.0
419
-		 *
420
-		 * @param WP_Screen $current_screen Current WP_Screen object.
421
-		 */
422
-		do_action( 'current_screen', $current_screen );
423
-	}
424
-
425
-	/**
426
-	 * Constructor
427
-	 *
428
-	 * @since 3.3.0
429
-	 */
430
-	private function __construct() {}
431
-
432
-	/**
433
-	 * Indicates whether the screen is in a particular admin
434
-	 *
435
-	 * @since 3.5.0
436
-	 *
437
-	 * @param string $admin The admin to check against (network | user | site).
438
-	 *                      If empty any of the three admins will result in true.
439
-	 * @return bool True if the screen is in the indicated admin, false otherwise.
440
-	 */
441
-	public function in_admin( $admin = null ) {
442
-		if ( empty( $admin ) ) {
443
-			return (bool) $this->in_admin;
444
-		}
445
-
446
-		return ( $admin === $this->in_admin );
447
-	}
448
-
449
-	/**
450
-	 * Sets or returns whether the block editor is loading on the current screen.
451
-	 *
452
-	 * @since 5.0.0
453
-	 *
454
-	 * @param bool $set Optional. Sets whether the block editor is loading on the current screen or not.
455
-	 * @return bool True if the block editor is being loaded, false otherwise.
456
-	 */
457
-	public function is_block_editor( $set = null ) {
458
-		if ( null !== $set ) {
459
-			$this->is_block_editor = (bool) $set;
460
-		}
461
-
462
-		return $this->is_block_editor;
463
-	}
464
-
465
-	/**
466
-	 * Sets the old string-based contextual help for the screen for backward compatibility.
467
-	 *
468
-	 * @since 3.3.0
469
-	 *
470
-	 * @param WP_Screen $screen A screen object.
471
-	 * @param string    $help   Help text.
472
-	 */
473
-	public static function add_old_compat_help( $screen, $help ) {
474
-		self::$_old_compat_help[ $screen->id ] = $help;
475
-	}
476
-
477
-	/**
478
-	 * Set the parent information for the screen.
479
-	 *
480
-	 * This is called in admin-header.php after the menu parent for the screen has been determined.
481
-	 *
482
-	 * @since 3.3.0
483
-	 *
484
-	 * @param string $parent_file The parent file of the screen. Typically the $parent_file global.
485
-	 */
486
-	public function set_parentage( $parent_file ) {
487
-		$this->parent_file         = $parent_file;
488
-		list( $this->parent_base ) = explode( '?', $parent_file );
489
-		$this->parent_base         = str_replace( '.php', '', $this->parent_base );
490
-	}
491
-
492
-	/**
493
-	 * Adds an option for the screen.
494
-	 *
495
-	 * Call this in template files after admin.php is loaded and before admin-header.php is loaded
496
-	 * to add screen options.
497
-	 *
498
-	 * @since 3.3.0
499
-	 *
500
-	 * @param string $option Option ID.
501
-	 * @param mixed  $args   Option-dependent arguments.
502
-	 */
503
-	public function add_option( $option, $args = array() ) {
504
-		$this->_options[ $option ] = $args;
505
-	}
506
-
507
-	/**
508
-	 * Remove an option from the screen.
509
-	 *
510
-	 * @since 3.8.0
511
-	 *
512
-	 * @param string $option Option ID.
513
-	 */
514
-	public function remove_option( $option ) {
515
-		unset( $this->_options[ $option ] );
516
-	}
517
-
518
-	/**
519
-	 * Remove all options from the screen.
520
-	 *
521
-	 * @since 3.8.0
522
-	 */
523
-	public function remove_options() {
524
-		$this->_options = array();
525
-	}
526
-
527
-	/**
528
-	 * Get the options registered for the screen.
529
-	 *
530
-	 * @since 3.8.0
531
-	 *
532
-	 * @return array Options with arguments.
533
-	 */
534
-	public function get_options() {
535
-		return $this->_options;
536
-	}
537
-
538
-	/**
539
-	 * Gets the arguments for an option for the screen.
540
-	 *
541
-	 * @since 3.3.0
542
-	 *
543
-	 * @param string       $option Option name.
544
-	 * @param string|false $key    Optional. Specific array key for when the option is an array.
545
-	 *                             Default false.
546
-	 * @return string The option value if set, null otherwise.
547
-	 */
548
-	public function get_option( $option, $key = false ) {
549
-		if ( ! isset( $this->_options[ $option ] ) ) {
550
-			return null;
551
-		}
552
-		if ( $key ) {
553
-			if ( isset( $this->_options[ $option ][ $key ] ) ) {
554
-				return $this->_options[ $option ][ $key ];
555
-			}
556
-			return null;
557
-		}
558
-		return $this->_options[ $option ];
559
-	}
560
-
561
-	/**
562
-	 * Gets the help tabs registered for the screen.
563
-	 *
564
-	 * @since 3.4.0
565
-	 * @since 4.4.0 Help tabs are ordered by their priority.
566
-	 *
567
-	 * @return array Help tabs with arguments.
568
-	 */
569
-	public function get_help_tabs() {
570
-		$help_tabs = $this->_help_tabs;
571
-
572
-		$priorities = array();
573
-		foreach ( $help_tabs as $help_tab ) {
574
-			if ( isset( $priorities[ $help_tab['priority'] ] ) ) {
575
-				$priorities[ $help_tab['priority'] ][] = $help_tab;
576
-			} else {
577
-				$priorities[ $help_tab['priority'] ] = array( $help_tab );
578
-			}
579
-		}
580
-
581
-		ksort( $priorities );
582
-
583
-		$sorted = array();
584
-		foreach ( $priorities as $list ) {
585
-			foreach ( $list as $tab ) {
586
-				$sorted[ $tab['id'] ] = $tab;
587
-			}
588
-		}
589
-
590
-		return $sorted;
591
-	}
592
-
593
-	/**
594
-	 * Gets the arguments for a help tab.
595
-	 *
596
-	 * @since 3.4.0
597
-	 *
598
-	 * @param string $id Help Tab ID.
599
-	 * @return array Help tab arguments.
600
-	 */
601
-	public function get_help_tab( $id ) {
602
-		if ( ! isset( $this->_help_tabs[ $id ] ) ) {
603
-			return null;
604
-		}
605
-		return $this->_help_tabs[ $id ];
606
-	}
607
-
608
-	/**
609
-	 * Add a help tab to the contextual help for the screen.
610
-	 *
611
-	 * Call this on the `load-$pagenow` hook for the relevant screen,
612
-	 * or fetch the `$current_screen` object, or use get_current_screen()
613
-	 * and then call the method from the object.
614
-	 *
615
-	 * You may need to filter `$current_screen` using an if or switch statement
616
-	 * to prevent new help tabs from being added to ALL admin screens.
617
-	 *
618
-	 * @since 3.3.0
619
-	 * @since 4.4.0 The `$priority` argument was added.
620
-	 *
621
-	 * @param array $args {
622
-	 *     Array of arguments used to display the help tab.
623
-	 *
624
-	 *     @type string   $title    Title for the tab. Default false.
625
-	 *     @type string   $id       Tab ID. Must be HTML-safe and should be unique for this menu.
626
-	 *                              It is NOT allowed to contain any empty spaces. Default false.
627
-	 *     @type string   $content  Optional. Help tab content in plain text or HTML. Default empty string.
628
-	 *     @type callable $callback Optional. A callback to generate the tab content. Default false.
629
-	 *     @type int      $priority Optional. The priority of the tab, used for ordering. Default 10.
630
-	 * }
631
-	 */
632
-	public function add_help_tab( $args ) {
633
-		$defaults = array(
634
-			'title'    => false,
635
-			'id'       => false,
636
-			'content'  => '',
637
-			'callback' => false,
638
-			'priority' => 10,
639
-		);
640
-		$args     = wp_parse_args( $args, $defaults );
641
-
642
-		$args['id'] = sanitize_html_class( $args['id'] );
643
-
644
-		// Ensure we have an ID and title.
645
-		if ( ! $args['id'] || ! $args['title'] ) {
646
-			return;
647
-		}
648
-
649
-		// Allows for overriding an existing tab with that ID.
650
-		$this->_help_tabs[ $args['id'] ] = $args;
651
-	}
652
-
653
-	/**
654
-	 * Removes a help tab from the contextual help for the screen.
655
-	 *
656
-	 * @since 3.3.0
657
-	 *
658
-	 * @param string $id The help tab ID.
659
-	 */
660
-	public function remove_help_tab( $id ) {
661
-		unset( $this->_help_tabs[ $id ] );
662
-	}
663
-
664
-	/**
665
-	 * Removes all help tabs from the contextual help for the screen.
666
-	 *
667
-	 * @since 3.3.0
668
-	 */
669
-	public function remove_help_tabs() {
670
-		$this->_help_tabs = array();
671
-	}
672
-
673
-	/**
674
-	 * Gets the content from a contextual help sidebar.
675
-	 *
676
-	 * @since 3.4.0
677
-	 *
678
-	 * @return string Contents of the help sidebar.
679
-	 */
680
-	public function get_help_sidebar() {
681
-		return $this->_help_sidebar;
682
-	}
683
-
684
-	/**
685
-	 * Add a sidebar to the contextual help for the screen.
686
-	 *
687
-	 * Call this in template files after admin.php is loaded and before admin-header.php is loaded
688
-	 * to add a sidebar to the contextual help.
689
-	 *
690
-	 * @since 3.3.0
691
-	 *
692
-	 * @param string $content Sidebar content in plain text or HTML.
693
-	 */
694
-	public function set_help_sidebar( $content ) {
695
-		$this->_help_sidebar = $content;
696
-	}
697
-
698
-	/**
699
-	 * Gets the number of layout columns the user has selected.
700
-	 *
701
-	 * The layout_columns option controls the max number and default number of
702
-	 * columns. This method returns the number of columns within that range selected
703
-	 * by the user via Screen Options. If no selection has been made, the default
704
-	 * provisioned in layout_columns is returned. If the screen does not support
705
-	 * selecting the number of layout columns, 0 is returned.
706
-	 *
707
-	 * @since 3.4.0
708
-	 *
709
-	 * @return int Number of columns to display.
710
-	 */
711
-	public function get_columns() {
712
-		return $this->columns;
713
-	}
714
-
715
-	/**
716
-	 * Get the accessible hidden headings and text used in the screen.
717
-	 *
718
-	 * @since 4.4.0
719
-	 *
720
-	 * @see set_screen_reader_content() For more information on the array format.
721
-	 *
722
-	 * @return array An associative array of screen reader text strings.
723
-	 */
724
-	public function get_screen_reader_content() {
725
-		return $this->_screen_reader_content;
726
-	}
727
-
728
-	/**
729
-	 * Get a screen reader text string.
730
-	 *
731
-	 * @since 4.4.0
732
-	 *
733
-	 * @param string $key Screen reader text array named key.
734
-	 * @return string Screen reader text string.
735
-	 */
736
-	public function get_screen_reader_text( $key ) {
737
-		if ( ! isset( $this->_screen_reader_content[ $key ] ) ) {
738
-			return null;
739
-		}
740
-		return $this->_screen_reader_content[ $key ];
741
-	}
742
-
743
-	/**
744
-	 * Add accessible hidden headings and text for the screen.
745
-	 *
746
-	 * @since 4.4.0
747
-	 *
748
-	 * @param array $content {
749
-	 *     An associative array of screen reader text strings.
750
-	 *
751
-	 *     @type string $heading_views      Screen reader text for the filter links heading.
752
-	 *                                      Default 'Filter items list'.
753
-	 *     @type string $heading_pagination Screen reader text for the pagination heading.
754
-	 *                                      Default 'Items list navigation'.
755
-	 *     @type string $heading_list       Screen reader text for the items list heading.
756
-	 *                                      Default 'Items list'.
757
-	 * }
758
-	 */
759
-	public function set_screen_reader_content( $content = array() ) {
760
-		$defaults = array(
761
-			'heading_views'      => __( 'Filter items list' ),
762
-			'heading_pagination' => __( 'Items list navigation' ),
763
-			'heading_list'       => __( 'Items list' ),
764
-		);
765
-		$content  = wp_parse_args( $content, $defaults );
766
-
767
-		$this->_screen_reader_content = $content;
768
-	}
769
-
770
-	/**
771
-	 * Remove all the accessible hidden headings and text for the screen.
772
-	 *
773
-	 * @since 4.4.0
774
-	 */
775
-	public function remove_screen_reader_content() {
776
-		$this->_screen_reader_content = array();
777
-	}
778
-
779
-	/**
780
-	 * Render the screen's help section.
781
-	 *
782
-	 * This will trigger the deprecated filters for backward compatibility.
783
-	 *
784
-	 * @since 3.3.0
785
-	 *
786
-	 * @global string $screen_layout_columns
787
-	 */
788
-	public function render_screen_meta() {
789
-
790
-		/**
791
-		 * Filters the legacy contextual help list.
792
-		 *
793
-		 * @since 2.7.0
794
-		 * @deprecated 3.3.0 Use {@see get_current_screen()->add_help_tab()} or
795
-		 *                   {@see get_current_screen()->remove_help_tab()} instead.
796
-		 *
797
-		 * @param array     $old_compat_help Old contextual help.
798
-		 * @param WP_Screen $screen          Current WP_Screen instance.
799
-		 */
800
-		self::$_old_compat_help = apply_filters_deprecated(
801
-			'contextual_help_list',
802
-			array( self::$_old_compat_help, $this ),
803
-			'3.3.0',
804
-			'get_current_screen()->add_help_tab(), get_current_screen()->remove_help_tab()'
805
-		);
806
-
807
-		$old_help = isset( self::$_old_compat_help[ $this->id ] ) ? self::$_old_compat_help[ $this->id ] : '';
808
-
809
-		/**
810
-		 * Filters the legacy contextual help text.
811
-		 *
812
-		 * @since 2.7.0
813
-		 * @deprecated 3.3.0 Use {@see get_current_screen()->add_help_tab()} or
814
-		 *                   {@see get_current_screen()->remove_help_tab()} instead.
815
-		 *
816
-		 * @param string    $old_help  Help text that appears on the screen.
817
-		 * @param string    $screen_id Screen ID.
818
-		 * @param WP_Screen $screen    Current WP_Screen instance.
819
-		 */
820
-		$old_help = apply_filters_deprecated(
821
-			'contextual_help',
822
-			array( $old_help, $this->id, $this ),
823
-			'3.3.0',
824
-			'get_current_screen()->add_help_tab(), get_current_screen()->remove_help_tab()'
825
-		);
826
-
827
-		// Default help only if there is no old-style block of text and no new-style help tabs.
828
-		if ( empty( $old_help ) && ! $this->get_help_tabs() ) {
829
-
830
-			/**
831
-			 * Filters the default legacy contextual help text.
832
-			 *
833
-			 * @since 2.8.0
834
-			 * @deprecated 3.3.0 Use {@see get_current_screen()->add_help_tab()} or
835
-			 *                   {@see get_current_screen()->remove_help_tab()} instead.
836
-			 *
837
-			 * @param string $old_help_default Default contextual help text.
838
-			 */
839
-			$default_help = apply_filters_deprecated(
840
-				'default_contextual_help',
841
-				array( '' ),
842
-				'3.3.0',
843
-				'get_current_screen()->add_help_tab(), get_current_screen()->remove_help_tab()'
844
-			);
845
-			if ( $default_help ) {
846
-				$old_help = '<p>' . $default_help . '</p>';
847
-			}
848
-		}
849
-
850
-		if ( $old_help ) {
851
-			$this->add_help_tab(
852
-				array(
853
-					'id'      => 'old-contextual-help',
854
-					'title'   => __( 'Overview' ),
855
-					'content' => $old_help,
856
-				)
857
-			);
858
-		}
859
-
860
-		$help_sidebar = $this->get_help_sidebar();
861
-
862
-		$help_class = 'hidden';
863
-		if ( ! $help_sidebar ) {
864
-			$help_class .= ' no-sidebar';
865
-		}
866
-
867
-		// Time to render!
868
-		?>
16
+    /**
17
+     * Any action associated with the screen.
18
+     *
19
+     * 'add' for *-add.php and *-new.php screens. Empty otherwise.
20
+     *
21
+     * @since 3.3.0
22
+     * @var string
23
+     */
24
+    public $action;
25
+
26
+    /**
27
+     * The base type of the screen.
28
+     *
29
+     * This is typically the same as `$id` but with any post types and taxonomies stripped.
30
+     * For example, for an `$id` of 'edit-post' the base is 'edit'.
31
+     *
32
+     * @since 3.3.0
33
+     * @var string
34
+     */
35
+    public $base;
36
+
37
+    /**
38
+     * The number of columns to display. Access with get_columns().
39
+     *
40
+     * @since 3.4.0
41
+     * @var int
42
+     */
43
+    private $columns = 0;
44
+
45
+    /**
46
+     * The unique ID of the screen.
47
+     *
48
+     * @since 3.3.0
49
+     * @var string
50
+     */
51
+    public $id;
52
+
53
+    /**
54
+     * Which admin the screen is in. network | user | site | false
55
+     *
56
+     * @since 3.5.0
57
+     * @var string
58
+     */
59
+    protected $in_admin;
60
+
61
+    /**
62
+     * Whether the screen is in the network admin.
63
+     *
64
+     * Deprecated. Use in_admin() instead.
65
+     *
66
+     * @since 3.3.0
67
+     * @deprecated 3.5.0
68
+     * @var bool
69
+     */
70
+    public $is_network;
71
+
72
+    /**
73
+     * Whether the screen is in the user admin.
74
+     *
75
+     * Deprecated. Use in_admin() instead.
76
+     *
77
+     * @since 3.3.0
78
+     * @deprecated 3.5.0
79
+     * @var bool
80
+     */
81
+    public $is_user;
82
+
83
+    /**
84
+     * The base menu parent.
85
+     *
86
+     * This is derived from `$parent_file` by removing the query string and any .php extension.
87
+     * `$parent_file` values of 'edit.php?post_type=page' and 'edit.php?post_type=post'
88
+     * have a `$parent_base` of 'edit'.
89
+     *
90
+     * @since 3.3.0
91
+     * @var string
92
+     */
93
+    public $parent_base;
94
+
95
+    /**
96
+     * The parent_file for the screen per the admin menu system.
97
+     *
98
+     * Some `$parent_file` values are 'edit.php?post_type=page', 'edit.php', and 'options-general.php'.
99
+     *
100
+     * @since 3.3.0
101
+     * @var string
102
+     */
103
+    public $parent_file;
104
+
105
+    /**
106
+     * The post type associated with the screen, if any.
107
+     *
108
+     * The 'edit.php?post_type=page' screen has a post type of 'page'.
109
+     * The 'edit-tags.php?taxonomy=$taxonomy&post_type=page' screen has a post type of 'page'.
110
+     *
111
+     * @since 3.3.0
112
+     * @var string
113
+     */
114
+    public $post_type;
115
+
116
+    /**
117
+     * The taxonomy associated with the screen, if any.
118
+     *
119
+     * The 'edit-tags.php?taxonomy=category' screen has a taxonomy of 'category'.
120
+     *
121
+     * @since 3.3.0
122
+     * @var string
123
+     */
124
+    public $taxonomy;
125
+
126
+    /**
127
+     * The help tab data associated with the screen, if any.
128
+     *
129
+     * @since 3.3.0
130
+     * @var array
131
+     */
132
+    private $_help_tabs = array();
133
+
134
+    /**
135
+     * The help sidebar data associated with screen, if any.
136
+     *
137
+     * @since 3.3.0
138
+     * @var string
139
+     */
140
+    private $_help_sidebar = '';
141
+
142
+    /**
143
+     * The accessible hidden headings and text associated with the screen, if any.
144
+     *
145
+     * @since 4.4.0
146
+     * @var array
147
+     */
148
+    private $_screen_reader_content = array();
149
+
150
+    /**
151
+     * Stores old string-based help.
152
+     *
153
+     * @var array
154
+     */
155
+    private static $_old_compat_help = array();
156
+
157
+    /**
158
+     * The screen options associated with screen, if any.
159
+     *
160
+     * @since 3.3.0
161
+     * @var array
162
+     */
163
+    private $_options = array();
164
+
165
+    /**
166
+     * The screen object registry.
167
+     *
168
+     * @since 3.3.0
169
+     *
170
+     * @var array
171
+     */
172
+    private static $_registry = array();
173
+
174
+    /**
175
+     * Stores the result of the public show_screen_options function.
176
+     *
177
+     * @since 3.3.0
178
+     * @var bool
179
+     */
180
+    private $_show_screen_options;
181
+
182
+    /**
183
+     * Stores the 'screen_settings' section of screen options.
184
+     *
185
+     * @since 3.3.0
186
+     * @var string
187
+     */
188
+    private $_screen_settings;
189
+
190
+    /**
191
+     * Whether the screen is using the block editor.
192
+     *
193
+     * @since 5.0.0
194
+     * @var bool
195
+     */
196
+    public $is_block_editor = false;
197
+
198
+    /**
199
+     * Fetches a screen object.
200
+     *
201
+     * @since 3.3.0
202
+     *
203
+     * @global string $hook_suffix
204
+     *
205
+     * @param string|WP_Screen $hook_name Optional. The hook name (also known as the hook suffix) used to determine the screen.
206
+     *                                    Defaults to the current $hook_suffix global.
207
+     * @return WP_Screen Screen object.
208
+     */
209
+    public static function get( $hook_name = '' ) {
210
+        if ( $hook_name instanceof WP_Screen ) {
211
+            return $hook_name;
212
+        }
213
+
214
+        $post_type       = null;
215
+        $taxonomy        = null;
216
+        $in_admin        = false;
217
+        $action          = '';
218
+        $is_block_editor = false;
219
+
220
+        if ( $hook_name ) {
221
+            $id = $hook_name;
222
+        } else {
223
+            $id = $GLOBALS['hook_suffix'];
224
+        }
225
+
226
+        // For those pesky meta boxes.
227
+        if ( $hook_name && post_type_exists( $hook_name ) ) {
228
+            $post_type = $id;
229
+            $id        = 'post'; // Changes later. Ends up being $base.
230
+        } else {
231
+            if ( '.php' === substr( $id, -4 ) ) {
232
+                $id = substr( $id, 0, -4 );
233
+            }
234
+
235
+            if ( in_array( $id, array( 'post-new', 'link-add', 'media-new', 'user-new' ), true ) ) {
236
+                $id     = substr( $id, 0, -4 );
237
+                $action = 'add';
238
+            }
239
+        }
240
+
241
+        if ( ! $post_type && $hook_name ) {
242
+            if ( '-network' === substr( $id, -8 ) ) {
243
+                $id       = substr( $id, 0, -8 );
244
+                $in_admin = 'network';
245
+            } elseif ( '-user' === substr( $id, -5 ) ) {
246
+                $id       = substr( $id, 0, -5 );
247
+                $in_admin = 'user';
248
+            }
249
+
250
+            $id = sanitize_key( $id );
251
+            if ( 'edit-comments' !== $id && 'edit-tags' !== $id && 'edit-' === substr( $id, 0, 5 ) ) {
252
+                $maybe = substr( $id, 5 );
253
+                if ( taxonomy_exists( $maybe ) ) {
254
+                    $id       = 'edit-tags';
255
+                    $taxonomy = $maybe;
256
+                } elseif ( post_type_exists( $maybe ) ) {
257
+                    $id        = 'edit';
258
+                    $post_type = $maybe;
259
+                }
260
+            }
261
+
262
+            if ( ! $in_admin ) {
263
+                $in_admin = 'site';
264
+            }
265
+        } else {
266
+            if ( defined( 'WP_NETWORK_ADMIN' ) && WP_NETWORK_ADMIN ) {
267
+                $in_admin = 'network';
268
+            } elseif ( defined( 'WP_USER_ADMIN' ) && WP_USER_ADMIN ) {
269
+                $in_admin = 'user';
270
+            } else {
271
+                $in_admin = 'site';
272
+            }
273
+        }
274
+
275
+        if ( 'index' === $id ) {
276
+            $id = 'dashboard';
277
+        } elseif ( 'front' === $id ) {
278
+            $in_admin = false;
279
+        }
280
+
281
+        $base = $id;
282
+
283
+        // If this is the current screen, see if we can be more accurate for post types and taxonomies.
284
+        if ( ! $hook_name ) {
285
+            if ( isset( $_REQUEST['post_type'] ) ) {
286
+                $post_type = post_type_exists( $_REQUEST['post_type'] ) ? $_REQUEST['post_type'] : false;
287
+            }
288
+            if ( isset( $_REQUEST['taxonomy'] ) ) {
289
+                $taxonomy = taxonomy_exists( $_REQUEST['taxonomy'] ) ? $_REQUEST['taxonomy'] : false;
290
+            }
291
+
292
+            switch ( $base ) {
293
+                case 'post':
294
+                    if ( isset( $_GET['post'] ) && isset( $_POST['post_ID'] ) && (int) $_GET['post'] !== (int) $_POST['post_ID'] ) {
295
+                        wp_die( __( 'A post ID mismatch has been detected.' ), __( 'Sorry, you are not allowed to edit this item.' ), 400 );
296
+                    } elseif ( isset( $_GET['post'] ) ) {
297
+                        $post_id = (int) $_GET['post'];
298
+                    } elseif ( isset( $_POST['post_ID'] ) ) {
299
+                        $post_id = (int) $_POST['post_ID'];
300
+                    } else {
301
+                        $post_id = 0;
302
+                    }
303
+
304
+                    if ( $post_id ) {
305
+                        $post = get_post( $post_id );
306
+                        if ( $post ) {
307
+                            $post_type = $post->post_type;
308
+
309
+                            /** This filter is documented in wp-admin/post.php */
310
+                            $replace_editor = apply_filters( 'replace_editor', false, $post );
311
+
312
+                            if ( ! $replace_editor ) {
313
+                                $is_block_editor = use_block_editor_for_post( $post );
314
+                            }
315
+                        }
316
+                    }
317
+                    break;
318
+                case 'edit-tags':
319
+                case 'term':
320
+                    if ( null === $post_type && is_object_in_taxonomy( 'post', $taxonomy ? $taxonomy : 'post_tag' ) ) {
321
+                        $post_type = 'post';
322
+                    }
323
+                    break;
324
+                case 'upload':
325
+                    $post_type = 'attachment';
326
+                    break;
327
+            }
328
+        }
329
+
330
+        switch ( $base ) {
331
+            case 'post':
332
+                if ( null === $post_type ) {
333
+                    $post_type = 'post';
334
+                }
335
+
336
+                // When creating a new post, use the default block editor support value for the post type.
337
+                if ( empty( $post_id ) ) {
338
+                    $is_block_editor = use_block_editor_for_post_type( $post_type );
339
+                }
340
+
341
+                $id = $post_type;
342
+                break;
343
+            case 'edit':
344
+                if ( null === $post_type ) {
345
+                    $post_type = 'post';
346
+                }
347
+                $id .= '-' . $post_type;
348
+                break;
349
+            case 'edit-tags':
350
+            case 'term':
351
+                if ( null === $taxonomy ) {
352
+                    $taxonomy = 'post_tag';
353
+                }
354
+                // The edit-tags ID does not contain the post type. Look for it in the request.
355
+                if ( null === $post_type ) {
356
+                    $post_type = 'post';
357
+                    if ( isset( $_REQUEST['post_type'] ) && post_type_exists( $_REQUEST['post_type'] ) ) {
358
+                        $post_type = $_REQUEST['post_type'];
359
+                    }
360
+                }
361
+
362
+                $id = 'edit-' . $taxonomy;
363
+                break;
364
+        }
365
+
366
+        if ( 'network' === $in_admin ) {
367
+            $id   .= '-network';
368
+            $base .= '-network';
369
+        } elseif ( 'user' === $in_admin ) {
370
+            $id   .= '-user';
371
+            $base .= '-user';
372
+        }
373
+
374
+        if ( isset( self::$_registry[ $id ] ) ) {
375
+            $screen = self::$_registry[ $id ];
376
+            if ( get_current_screen() === $screen ) {
377
+                return $screen;
378
+            }
379
+        } else {
380
+            $screen     = new self();
381
+            $screen->id = $id;
382
+        }
383
+
384
+        $screen->base            = $base;
385
+        $screen->action          = $action;
386
+        $screen->post_type       = (string) $post_type;
387
+        $screen->taxonomy        = (string) $taxonomy;
388
+        $screen->is_user         = ( 'user' === $in_admin );
389
+        $screen->is_network      = ( 'network' === $in_admin );
390
+        $screen->in_admin        = $in_admin;
391
+        $screen->is_block_editor = $is_block_editor;
392
+
393
+        self::$_registry[ $id ] = $screen;
394
+
395
+        return $screen;
396
+    }
397
+
398
+    /**
399
+     * Makes the screen object the current screen.
400
+     *
401
+     * @see set_current_screen()
402
+     * @since 3.3.0
403
+     *
404
+     * @global WP_Screen $current_screen WordPress current screen object.
405
+     * @global string    $typenow        The post type of the current screen.
406
+     * @global string    $taxnow         The taxonomy of the current screen.
407
+     */
408
+    public function set_current_screen() {
409
+        global $current_screen, $taxnow, $typenow;
410
+
411
+        $current_screen = $this;
412
+        $typenow        = $this->post_type;
413
+        $taxnow         = $this->taxonomy;
414
+
415
+        /**
416
+         * Fires after the current screen has been set.
417
+         *
418
+         * @since 3.0.0
419
+         *
420
+         * @param WP_Screen $current_screen Current WP_Screen object.
421
+         */
422
+        do_action( 'current_screen', $current_screen );
423
+    }
424
+
425
+    /**
426
+     * Constructor
427
+     *
428
+     * @since 3.3.0
429
+     */
430
+    private function __construct() {}
431
+
432
+    /**
433
+     * Indicates whether the screen is in a particular admin
434
+     *
435
+     * @since 3.5.0
436
+     *
437
+     * @param string $admin The admin to check against (network | user | site).
438
+     *                      If empty any of the three admins will result in true.
439
+     * @return bool True if the screen is in the indicated admin, false otherwise.
440
+     */
441
+    public function in_admin( $admin = null ) {
442
+        if ( empty( $admin ) ) {
443
+            return (bool) $this->in_admin;
444
+        }
445
+
446
+        return ( $admin === $this->in_admin );
447
+    }
448
+
449
+    /**
450
+     * Sets or returns whether the block editor is loading on the current screen.
451
+     *
452
+     * @since 5.0.0
453
+     *
454
+     * @param bool $set Optional. Sets whether the block editor is loading on the current screen or not.
455
+     * @return bool True if the block editor is being loaded, false otherwise.
456
+     */
457
+    public function is_block_editor( $set = null ) {
458
+        if ( null !== $set ) {
459
+            $this->is_block_editor = (bool) $set;
460
+        }
461
+
462
+        return $this->is_block_editor;
463
+    }
464
+
465
+    /**
466
+     * Sets the old string-based contextual help for the screen for backward compatibility.
467
+     *
468
+     * @since 3.3.0
469
+     *
470
+     * @param WP_Screen $screen A screen object.
471
+     * @param string    $help   Help text.
472
+     */
473
+    public static function add_old_compat_help( $screen, $help ) {
474
+        self::$_old_compat_help[ $screen->id ] = $help;
475
+    }
476
+
477
+    /**
478
+     * Set the parent information for the screen.
479
+     *
480
+     * This is called in admin-header.php after the menu parent for the screen has been determined.
481
+     *
482
+     * @since 3.3.0
483
+     *
484
+     * @param string $parent_file The parent file of the screen. Typically the $parent_file global.
485
+     */
486
+    public function set_parentage( $parent_file ) {
487
+        $this->parent_file         = $parent_file;
488
+        list( $this->parent_base ) = explode( '?', $parent_file );
489
+        $this->parent_base         = str_replace( '.php', '', $this->parent_base );
490
+    }
491
+
492
+    /**
493
+     * Adds an option for the screen.
494
+     *
495
+     * Call this in template files after admin.php is loaded and before admin-header.php is loaded
496
+     * to add screen options.
497
+     *
498
+     * @since 3.3.0
499
+     *
500
+     * @param string $option Option ID.
501
+     * @param mixed  $args   Option-dependent arguments.
502
+     */
503
+    public function add_option( $option, $args = array() ) {
504
+        $this->_options[ $option ] = $args;
505
+    }
506
+
507
+    /**
508
+     * Remove an option from the screen.
509
+     *
510
+     * @since 3.8.0
511
+     *
512
+     * @param string $option Option ID.
513
+     */
514
+    public function remove_option( $option ) {
515
+        unset( $this->_options[ $option ] );
516
+    }
517
+
518
+    /**
519
+     * Remove all options from the screen.
520
+     *
521
+     * @since 3.8.0
522
+     */
523
+    public function remove_options() {
524
+        $this->_options = array();
525
+    }
526
+
527
+    /**
528
+     * Get the options registered for the screen.
529
+     *
530
+     * @since 3.8.0
531
+     *
532
+     * @return array Options with arguments.
533
+     */
534
+    public function get_options() {
535
+        return $this->_options;
536
+    }
537
+
538
+    /**
539
+     * Gets the arguments for an option for the screen.
540
+     *
541
+     * @since 3.3.0
542
+     *
543
+     * @param string       $option Option name.
544
+     * @param string|false $key    Optional. Specific array key for when the option is an array.
545
+     *                             Default false.
546
+     * @return string The option value if set, null otherwise.
547
+     */
548
+    public function get_option( $option, $key = false ) {
549
+        if ( ! isset( $this->_options[ $option ] ) ) {
550
+            return null;
551
+        }
552
+        if ( $key ) {
553
+            if ( isset( $this->_options[ $option ][ $key ] ) ) {
554
+                return $this->_options[ $option ][ $key ];
555
+            }
556
+            return null;
557
+        }
558
+        return $this->_options[ $option ];
559
+    }
560
+
561
+    /**
562
+     * Gets the help tabs registered for the screen.
563
+     *
564
+     * @since 3.4.0
565
+     * @since 4.4.0 Help tabs are ordered by their priority.
566
+     *
567
+     * @return array Help tabs with arguments.
568
+     */
569
+    public function get_help_tabs() {
570
+        $help_tabs = $this->_help_tabs;
571
+
572
+        $priorities = array();
573
+        foreach ( $help_tabs as $help_tab ) {
574
+            if ( isset( $priorities[ $help_tab['priority'] ] ) ) {
575
+                $priorities[ $help_tab['priority'] ][] = $help_tab;
576
+            } else {
577
+                $priorities[ $help_tab['priority'] ] = array( $help_tab );
578
+            }
579
+        }
580
+
581
+        ksort( $priorities );
582
+
583
+        $sorted = array();
584
+        foreach ( $priorities as $list ) {
585
+            foreach ( $list as $tab ) {
586
+                $sorted[ $tab['id'] ] = $tab;
587
+            }
588
+        }
589
+
590
+        return $sorted;
591
+    }
592
+
593
+    /**
594
+     * Gets the arguments for a help tab.
595
+     *
596
+     * @since 3.4.0
597
+     *
598
+     * @param string $id Help Tab ID.
599
+     * @return array Help tab arguments.
600
+     */
601
+    public function get_help_tab( $id ) {
602
+        if ( ! isset( $this->_help_tabs[ $id ] ) ) {
603
+            return null;
604
+        }
605
+        return $this->_help_tabs[ $id ];
606
+    }
607
+
608
+    /**
609
+     * Add a help tab to the contextual help for the screen.
610
+     *
611
+     * Call this on the `load-$pagenow` hook for the relevant screen,
612
+     * or fetch the `$current_screen` object, or use get_current_screen()
613
+     * and then call the method from the object.
614
+     *
615
+     * You may need to filter `$current_screen` using an if or switch statement
616
+     * to prevent new help tabs from being added to ALL admin screens.
617
+     *
618
+     * @since 3.3.0
619
+     * @since 4.4.0 The `$priority` argument was added.
620
+     *
621
+     * @param array $args {
622
+     *     Array of arguments used to display the help tab.
623
+     *
624
+     *     @type string   $title    Title for the tab. Default false.
625
+     *     @type string   $id       Tab ID. Must be HTML-safe and should be unique for this menu.
626
+     *                              It is NOT allowed to contain any empty spaces. Default false.
627
+     *     @type string   $content  Optional. Help tab content in plain text or HTML. Default empty string.
628
+     *     @type callable $callback Optional. A callback to generate the tab content. Default false.
629
+     *     @type int      $priority Optional. The priority of the tab, used for ordering. Default 10.
630
+     * }
631
+     */
632
+    public function add_help_tab( $args ) {
633
+        $defaults = array(
634
+            'title'    => false,
635
+            'id'       => false,
636
+            'content'  => '',
637
+            'callback' => false,
638
+            'priority' => 10,
639
+        );
640
+        $args     = wp_parse_args( $args, $defaults );
641
+
642
+        $args['id'] = sanitize_html_class( $args['id'] );
643
+
644
+        // Ensure we have an ID and title.
645
+        if ( ! $args['id'] || ! $args['title'] ) {
646
+            return;
647
+        }
648
+
649
+        // Allows for overriding an existing tab with that ID.
650
+        $this->_help_tabs[ $args['id'] ] = $args;
651
+    }
652
+
653
+    /**
654
+     * Removes a help tab from the contextual help for the screen.
655
+     *
656
+     * @since 3.3.0
657
+     *
658
+     * @param string $id The help tab ID.
659
+     */
660
+    public function remove_help_tab( $id ) {
661
+        unset( $this->_help_tabs[ $id ] );
662
+    }
663
+
664
+    /**
665
+     * Removes all help tabs from the contextual help for the screen.
666
+     *
667
+     * @since 3.3.0
668
+     */
669
+    public function remove_help_tabs() {
670
+        $this->_help_tabs = array();
671
+    }
672
+
673
+    /**
674
+     * Gets the content from a contextual help sidebar.
675
+     *
676
+     * @since 3.4.0
677
+     *
678
+     * @return string Contents of the help sidebar.
679
+     */
680
+    public function get_help_sidebar() {
681
+        return $this->_help_sidebar;
682
+    }
683
+
684
+    /**
685
+     * Add a sidebar to the contextual help for the screen.
686
+     *
687
+     * Call this in template files after admin.php is loaded and before admin-header.php is loaded
688
+     * to add a sidebar to the contextual help.
689
+     *
690
+     * @since 3.3.0
691
+     *
692
+     * @param string $content Sidebar content in plain text or HTML.
693
+     */
694
+    public function set_help_sidebar( $content ) {
695
+        $this->_help_sidebar = $content;
696
+    }
697
+
698
+    /**
699
+     * Gets the number of layout columns the user has selected.
700
+     *
701
+     * The layout_columns option controls the max number and default number of
702
+     * columns. This method returns the number of columns within that range selected
703
+     * by the user via Screen Options. If no selection has been made, the default
704
+     * provisioned in layout_columns is returned. If the screen does not support
705
+     * selecting the number of layout columns, 0 is returned.
706
+     *
707
+     * @since 3.4.0
708
+     *
709
+     * @return int Number of columns to display.
710
+     */
711
+    public function get_columns() {
712
+        return $this->columns;
713
+    }
714
+
715
+    /**
716
+     * Get the accessible hidden headings and text used in the screen.
717
+     *
718
+     * @since 4.4.0
719
+     *
720
+     * @see set_screen_reader_content() For more information on the array format.
721
+     *
722
+     * @return array An associative array of screen reader text strings.
723
+     */
724
+    public function get_screen_reader_content() {
725
+        return $this->_screen_reader_content;
726
+    }
727
+
728
+    /**
729
+     * Get a screen reader text string.
730
+     *
731
+     * @since 4.4.0
732
+     *
733
+     * @param string $key Screen reader text array named key.
734
+     * @return string Screen reader text string.
735
+     */
736
+    public function get_screen_reader_text( $key ) {
737
+        if ( ! isset( $this->_screen_reader_content[ $key ] ) ) {
738
+            return null;
739
+        }
740
+        return $this->_screen_reader_content[ $key ];
741
+    }
742
+
743
+    /**
744
+     * Add accessible hidden headings and text for the screen.
745
+     *
746
+     * @since 4.4.0
747
+     *
748
+     * @param array $content {
749
+     *     An associative array of screen reader text strings.
750
+     *
751
+     *     @type string $heading_views      Screen reader text for the filter links heading.
752
+     *                                      Default 'Filter items list'.
753
+     *     @type string $heading_pagination Screen reader text for the pagination heading.
754
+     *                                      Default 'Items list navigation'.
755
+     *     @type string $heading_list       Screen reader text for the items list heading.
756
+     *                                      Default 'Items list'.
757
+     * }
758
+     */
759
+    public function set_screen_reader_content( $content = array() ) {
760
+        $defaults = array(
761
+            'heading_views'      => __( 'Filter items list' ),
762
+            'heading_pagination' => __( 'Items list navigation' ),
763
+            'heading_list'       => __( 'Items list' ),
764
+        );
765
+        $content  = wp_parse_args( $content, $defaults );
766
+
767
+        $this->_screen_reader_content = $content;
768
+    }
769
+
770
+    /**
771
+     * Remove all the accessible hidden headings and text for the screen.
772
+     *
773
+     * @since 4.4.0
774
+     */
775
+    public function remove_screen_reader_content() {
776
+        $this->_screen_reader_content = array();
777
+    }
778
+
779
+    /**
780
+     * Render the screen's help section.
781
+     *
782
+     * This will trigger the deprecated filters for backward compatibility.
783
+     *
784
+     * @since 3.3.0
785
+     *
786
+     * @global string $screen_layout_columns
787
+     */
788
+    public function render_screen_meta() {
789
+
790
+        /**
791
+         * Filters the legacy contextual help list.
792
+         *
793
+         * @since 2.7.0
794
+         * @deprecated 3.3.0 Use {@see get_current_screen()->add_help_tab()} or
795
+         *                   {@see get_current_screen()->remove_help_tab()} instead.
796
+         *
797
+         * @param array     $old_compat_help Old contextual help.
798
+         * @param WP_Screen $screen          Current WP_Screen instance.
799
+         */
800
+        self::$_old_compat_help = apply_filters_deprecated(
801
+            'contextual_help_list',
802
+            array( self::$_old_compat_help, $this ),
803
+            '3.3.0',
804
+            'get_current_screen()->add_help_tab(), get_current_screen()->remove_help_tab()'
805
+        );
806
+
807
+        $old_help = isset( self::$_old_compat_help[ $this->id ] ) ? self::$_old_compat_help[ $this->id ] : '';
808
+
809
+        /**
810
+         * Filters the legacy contextual help text.
811
+         *
812
+         * @since 2.7.0
813
+         * @deprecated 3.3.0 Use {@see get_current_screen()->add_help_tab()} or
814
+         *                   {@see get_current_screen()->remove_help_tab()} instead.
815
+         *
816
+         * @param string    $old_help  Help text that appears on the screen.
817
+         * @param string    $screen_id Screen ID.
818
+         * @param WP_Screen $screen    Current WP_Screen instance.
819
+         */
820
+        $old_help = apply_filters_deprecated(
821
+            'contextual_help',
822
+            array( $old_help, $this->id, $this ),
823
+            '3.3.0',
824
+            'get_current_screen()->add_help_tab(), get_current_screen()->remove_help_tab()'
825
+        );
826
+
827
+        // Default help only if there is no old-style block of text and no new-style help tabs.
828
+        if ( empty( $old_help ) && ! $this->get_help_tabs() ) {
829
+
830
+            /**
831
+             * Filters the default legacy contextual help text.
832
+             *
833
+             * @since 2.8.0
834
+             * @deprecated 3.3.0 Use {@see get_current_screen()->add_help_tab()} or
835
+             *                   {@see get_current_screen()->remove_help_tab()} instead.
836
+             *
837
+             * @param string $old_help_default Default contextual help text.
838
+             */
839
+            $default_help = apply_filters_deprecated(
840
+                'default_contextual_help',
841
+                array( '' ),
842
+                '3.3.0',
843
+                'get_current_screen()->add_help_tab(), get_current_screen()->remove_help_tab()'
844
+            );
845
+            if ( $default_help ) {
846
+                $old_help = '<p>' . $default_help . '</p>';
847
+            }
848
+        }
849
+
850
+        if ( $old_help ) {
851
+            $this->add_help_tab(
852
+                array(
853
+                    'id'      => 'old-contextual-help',
854
+                    'title'   => __( 'Overview' ),
855
+                    'content' => $old_help,
856
+                )
857
+            );
858
+        }
859
+
860
+        $help_sidebar = $this->get_help_sidebar();
861
+
862
+        $help_class = 'hidden';
863
+        if ( ! $help_sidebar ) {
864
+            $help_class .= ' no-sidebar';
865
+        }
866
+
867
+        // Time to render!
868
+        ?>
869 869
 		<div id="screen-meta" class="metabox-prefs">
870 870
 
871 871
 			<div id="contextual-help-wrap" class="<?php echo esc_attr( $help_class ); ?>" tabindex="-1" aria-label="<?php esc_attr_e( 'Contextual Help Tab' ); ?>">
@@ -874,11 +874,11 @@  discard block
 block discarded – undo
874 874
 					<div class="contextual-help-tabs">
875 875
 						<ul>
876 876
 						<?php
877
-						$class = ' class="active"';
878
-						foreach ( $this->get_help_tabs() as $tab ) :
879
-							$link_id  = "tab-link-{$tab['id']}";
880
-							$panel_id = "tab-panel-{$tab['id']}";
881
-							?>
877
+                        $class = ' class="active"';
878
+                        foreach ( $this->get_help_tabs() as $tab ) :
879
+                            $link_id  = "tab-link-{$tab['id']}";
880
+                            $panel_id = "tab-panel-{$tab['id']}";
881
+                            ?>
882 882
 
883 883
 							<li id="<?php echo esc_attr( $link_id ); ?>"<?php echo $class; ?>>
884 884
 								<a href="<?php echo esc_url( "#$panel_id" ); ?>" aria-controls="<?php echo esc_attr( $panel_id ); ?>">
@@ -886,9 +886,9 @@  discard block
 block discarded – undo
886 886
 								</a>
887 887
 							</li>
888 888
 							<?php
889
-							$class = '';
890
-						endforeach;
891
-						?>
889
+                            $class = '';
890
+                        endforeach;
891
+                        ?>
892 892
 						</ul>
893 893
 					</div>
894 894
 
@@ -900,216 +900,216 @@  discard block
 block discarded – undo
900 900
 
901 901
 					<div class="contextual-help-tabs-wrap">
902 902
 						<?php
903
-						$classes = 'help-tab-content active';
904
-						foreach ( $this->get_help_tabs() as $tab ) :
905
-							$panel_id = "tab-panel-{$tab['id']}";
906
-							?>
903
+                        $classes = 'help-tab-content active';
904
+                        foreach ( $this->get_help_tabs() as $tab ) :
905
+                            $panel_id = "tab-panel-{$tab['id']}";
906
+                            ?>
907 907
 
908 908
 							<div id="<?php echo esc_attr( $panel_id ); ?>" class="<?php echo $classes; ?>">
909 909
 								<?php
910
-								// Print tab content.
911
-								echo $tab['content'];
912
-
913
-								// If it exists, fire tab callback.
914
-								if ( ! empty( $tab['callback'] ) ) {
915
-									call_user_func_array( $tab['callback'], array( $this, $tab ) );
916
-								}
917
-								?>
910
+                                // Print tab content.
911
+                                echo $tab['content'];
912
+
913
+                                // If it exists, fire tab callback.
914
+                                if ( ! empty( $tab['callback'] ) ) {
915
+                                    call_user_func_array( $tab['callback'], array( $this, $tab ) );
916
+                                }
917
+                                ?>
918 918
 							</div>
919 919
 							<?php
920
-							$classes = 'help-tab-content';
921
-						endforeach;
922
-						?>
920
+                            $classes = 'help-tab-content';
921
+                        endforeach;
922
+                        ?>
923 923
 					</div>
924 924
 				</div>
925 925
 			</div>
926 926
 		<?php
927
-		// Setup layout columns.
928
-
929
-		/**
930
-		 * Filters the array of screen layout columns.
931
-		 *
932
-		 * This hook provides back-compat for plugins using the back-compat
933
-		 * Filters instead of add_screen_option().
934
-		 *
935
-		 * @since 2.8.0
936
-		 *
937
-		 * @param array     $empty_columns Empty array.
938
-		 * @param string    $screen_id     Screen ID.
939
-		 * @param WP_Screen $screen        Current WP_Screen instance.
940
-		 */
941
-		$columns = apply_filters( 'screen_layout_columns', array(), $this->id, $this );
942
-
943
-		if ( ! empty( $columns ) && isset( $columns[ $this->id ] ) ) {
944
-			$this->add_option( 'layout_columns', array( 'max' => $columns[ $this->id ] ) );
945
-		}
946
-
947
-		if ( $this->get_option( 'layout_columns' ) ) {
948
-			$this->columns = (int) get_user_option( "screen_layout_$this->id" );
949
-
950
-			if ( ! $this->columns && $this->get_option( 'layout_columns', 'default' ) ) {
951
-				$this->columns = $this->get_option( 'layout_columns', 'default' );
952
-			}
953
-		}
954
-		$GLOBALS['screen_layout_columns'] = $this->columns; // Set the global for back-compat.
955
-
956
-		// Add screen options.
957
-		if ( $this->show_screen_options() ) {
958
-			$this->render_screen_options();
959
-		}
960
-		?>
927
+        // Setup layout columns.
928
+
929
+        /**
930
+         * Filters the array of screen layout columns.
931
+         *
932
+         * This hook provides back-compat for plugins using the back-compat
933
+         * Filters instead of add_screen_option().
934
+         *
935
+         * @since 2.8.0
936
+         *
937
+         * @param array     $empty_columns Empty array.
938
+         * @param string    $screen_id     Screen ID.
939
+         * @param WP_Screen $screen        Current WP_Screen instance.
940
+         */
941
+        $columns = apply_filters( 'screen_layout_columns', array(), $this->id, $this );
942
+
943
+        if ( ! empty( $columns ) && isset( $columns[ $this->id ] ) ) {
944
+            $this->add_option( 'layout_columns', array( 'max' => $columns[ $this->id ] ) );
945
+        }
946
+
947
+        if ( $this->get_option( 'layout_columns' ) ) {
948
+            $this->columns = (int) get_user_option( "screen_layout_$this->id" );
949
+
950
+            if ( ! $this->columns && $this->get_option( 'layout_columns', 'default' ) ) {
951
+                $this->columns = $this->get_option( 'layout_columns', 'default' );
952
+            }
953
+        }
954
+        $GLOBALS['screen_layout_columns'] = $this->columns; // Set the global for back-compat.
955
+
956
+        // Add screen options.
957
+        if ( $this->show_screen_options() ) {
958
+            $this->render_screen_options();
959
+        }
960
+        ?>
961 961
 		</div>
962 962
 		<?php
963
-		if ( ! $this->get_help_tabs() && ! $this->show_screen_options() ) {
964
-			return;
965
-		}
966
-		?>
963
+        if ( ! $this->get_help_tabs() && ! $this->show_screen_options() ) {
964
+            return;
965
+        }
966
+        ?>
967 967
 		<div id="screen-meta-links">
968 968
 		<?php if ( $this->show_screen_options() ) : ?>
969 969
 			<div id="screen-options-link-wrap" class="hide-if-no-js screen-meta-toggle">
970 970
 			<button type="button" id="show-settings-link" class="button show-settings" aria-controls="screen-options-wrap" aria-expanded="false"><?php _e( 'Screen Options' ); ?></button>
971 971
 			</div>
972 972
 			<?php
973
-		endif;
974
-		if ( $this->get_help_tabs() ) :
975
-			?>
973
+        endif;
974
+        if ( $this->get_help_tabs() ) :
975
+            ?>
976 976
 			<div id="contextual-help-link-wrap" class="hide-if-no-js screen-meta-toggle">
977 977
 			<button type="button" id="contextual-help-link" class="button show-settings" aria-controls="contextual-help-wrap" aria-expanded="false"><?php _e( 'Help' ); ?></button>
978 978
 			</div>
979 979
 		<?php endif; ?>
980 980
 		</div>
981 981
 		<?php
982
-	}
983
-
984
-	/**
985
-	 * @global array $wp_meta_boxes
986
-	 *
987
-	 * @return bool
988
-	 */
989
-	public function show_screen_options() {
990
-		global $wp_meta_boxes;
991
-
992
-		if ( is_bool( $this->_show_screen_options ) ) {
993
-			return $this->_show_screen_options;
994
-		}
995
-
996
-		$columns = get_column_headers( $this );
997
-
998
-		$show_screen = ! empty( $wp_meta_boxes[ $this->id ] ) || $columns || $this->get_option( 'per_page' );
999
-
1000
-		$this->_screen_settings = '';
1001
-
1002
-		if ( 'post' === $this->base ) {
1003
-			$expand                 = '<fieldset class="editor-expand hidden"><legend>' . __( 'Additional settings' ) . '</legend><label for="editor-expand-toggle">';
1004
-			$expand                .= '<input type="checkbox" id="editor-expand-toggle"' . checked( get_user_setting( 'editor_expand', 'on' ), 'on', false ) . ' />';
1005
-			$expand                .= __( 'Enable full-height editor and distraction-free functionality.' ) . '</label></fieldset>';
1006
-			$this->_screen_settings = $expand;
1007
-		}
1008
-
1009
-		/**
1010
-		 * Filters the screen settings text displayed in the Screen Options tab.
1011
-		 *
1012
-		 * @since 3.0.0
1013
-		 *
1014
-		 * @param string    $screen_settings Screen settings.
1015
-		 * @param WP_Screen $screen          WP_Screen object.
1016
-		 */
1017
-		$this->_screen_settings = apply_filters( 'screen_settings', $this->_screen_settings, $this );
1018
-
1019
-		if ( $this->_screen_settings || $this->_options ) {
1020
-			$show_screen = true;
1021
-		}
1022
-
1023
-		/**
1024
-		 * Filters whether to show the Screen Options tab.
1025
-		 *
1026
-		 * @since 3.2.0
1027
-		 *
1028
-		 * @param bool      $show_screen Whether to show Screen Options tab.
1029
-		 *                               Default true.
1030
-		 * @param WP_Screen $screen      Current WP_Screen instance.
1031
-		 */
1032
-		$this->_show_screen_options = apply_filters( 'screen_options_show_screen', $show_screen, $this );
1033
-		return $this->_show_screen_options;
1034
-	}
1035
-
1036
-	/**
1037
-	 * Render the screen options tab.
1038
-	 *
1039
-	 * @since 3.3.0
1040
-	 *
1041
-	 * @param array $options {
1042
-	 *     Options for the tab.
1043
-	 *
1044
-	 *     @type bool $wrap Whether the screen-options-wrap div will be included. Defaults to true.
1045
-	 * }
1046
-	 */
1047
-	public function render_screen_options( $options = array() ) {
1048
-		$options = wp_parse_args(
1049
-			$options,
1050
-			array(
1051
-				'wrap' => true,
1052
-			)
1053
-		);
1054
-
1055
-		$wrapper_start = '';
1056
-		$wrapper_end   = '';
1057
-		$form_start    = '';
1058
-		$form_end      = '';
1059
-
1060
-		// Output optional wrapper.
1061
-		if ( $options['wrap'] ) {
1062
-			$wrapper_start = '<div id="screen-options-wrap" class="hidden" tabindex="-1" aria-label="' . esc_attr__( 'Screen Options Tab' ) . '">';
1063
-			$wrapper_end   = '</div>';
1064
-		}
1065
-
1066
-		// Don't output the form and nonce for the widgets accessibility mode links.
1067
-		if ( 'widgets' !== $this->base ) {
1068
-			$form_start = "\n<form id='adv-settings' method='post'>\n";
1069
-			$form_end   = "\n" . wp_nonce_field( 'screen-options-nonce', 'screenoptionnonce', false, false ) . "\n</form>\n";
1070
-		}
1071
-
1072
-		echo $wrapper_start . $form_start;
1073
-
1074
-		$this->render_meta_boxes_preferences();
1075
-		$this->render_list_table_columns_preferences();
1076
-		$this->render_screen_layout();
1077
-		$this->render_per_page_options();
1078
-		$this->render_view_mode();
1079
-		echo $this->_screen_settings;
1080
-
1081
-		/**
1082
-		 * Filters whether to show the Screen Options submit button.
1083
-		 *
1084
-		 * @since 4.4.0
1085
-		 *
1086
-		 * @param bool      $show_button Whether to show Screen Options submit button.
1087
-		 *                               Default false.
1088
-		 * @param WP_Screen $screen      Current WP_Screen instance.
1089
-		 */
1090
-		$show_button = apply_filters( 'screen_options_show_submit', false, $this );
1091
-
1092
-		if ( $show_button ) {
1093
-			submit_button( __( 'Apply' ), 'primary', 'screen-options-apply', true );
1094
-		}
1095
-
1096
-		echo $form_end . $wrapper_end;
1097
-	}
1098
-
1099
-	/**
1100
-	 * Render the meta boxes preferences.
1101
-	 *
1102
-	 * @since 4.4.0
1103
-	 *
1104
-	 * @global array $wp_meta_boxes
1105
-	 */
1106
-	public function render_meta_boxes_preferences() {
1107
-		global $wp_meta_boxes;
1108
-
1109
-		if ( ! isset( $wp_meta_boxes[ $this->id ] ) ) {
1110
-			return;
1111
-		}
1112
-		?>
982
+    }
983
+
984
+    /**
985
+     * @global array $wp_meta_boxes
986
+     *
987
+     * @return bool
988
+     */
989
+    public function show_screen_options() {
990
+        global $wp_meta_boxes;
991
+
992
+        if ( is_bool( $this->_show_screen_options ) ) {
993
+            return $this->_show_screen_options;
994
+        }
995
+
996
+        $columns = get_column_headers( $this );
997
+
998
+        $show_screen = ! empty( $wp_meta_boxes[ $this->id ] ) || $columns || $this->get_option( 'per_page' );
999
+
1000
+        $this->_screen_settings = '';
1001
+
1002
+        if ( 'post' === $this->base ) {
1003
+            $expand                 = '<fieldset class="editor-expand hidden"><legend>' . __( 'Additional settings' ) . '</legend><label for="editor-expand-toggle">';
1004
+            $expand                .= '<input type="checkbox" id="editor-expand-toggle"' . checked( get_user_setting( 'editor_expand', 'on' ), 'on', false ) . ' />';
1005
+            $expand                .= __( 'Enable full-height editor and distraction-free functionality.' ) . '</label></fieldset>';
1006
+            $this->_screen_settings = $expand;
1007
+        }
1008
+
1009
+        /**
1010
+         * Filters the screen settings text displayed in the Screen Options tab.
1011
+         *
1012
+         * @since 3.0.0
1013
+         *
1014
+         * @param string    $screen_settings Screen settings.
1015
+         * @param WP_Screen $screen          WP_Screen object.
1016
+         */
1017
+        $this->_screen_settings = apply_filters( 'screen_settings', $this->_screen_settings, $this );
1018
+
1019
+        if ( $this->_screen_settings || $this->_options ) {
1020
+            $show_screen = true;
1021
+        }
1022
+
1023
+        /**
1024
+         * Filters whether to show the Screen Options tab.
1025
+         *
1026
+         * @since 3.2.0
1027
+         *
1028
+         * @param bool      $show_screen Whether to show Screen Options tab.
1029
+         *                               Default true.
1030
+         * @param WP_Screen $screen      Current WP_Screen instance.
1031
+         */
1032
+        $this->_show_screen_options = apply_filters( 'screen_options_show_screen', $show_screen, $this );
1033
+        return $this->_show_screen_options;
1034
+    }
1035
+
1036
+    /**
1037
+     * Render the screen options tab.
1038
+     *
1039
+     * @since 3.3.0
1040
+     *
1041
+     * @param array $options {
1042
+     *     Options for the tab.
1043
+     *
1044
+     *     @type bool $wrap Whether the screen-options-wrap div will be included. Defaults to true.
1045
+     * }
1046
+     */
1047
+    public function render_screen_options( $options = array() ) {
1048
+        $options = wp_parse_args(
1049
+            $options,
1050
+            array(
1051
+                'wrap' => true,
1052
+            )
1053
+        );
1054
+
1055
+        $wrapper_start = '';
1056
+        $wrapper_end   = '';
1057
+        $form_start    = '';
1058
+        $form_end      = '';
1059
+
1060
+        // Output optional wrapper.
1061
+        if ( $options['wrap'] ) {
1062
+            $wrapper_start = '<div id="screen-options-wrap" class="hidden" tabindex="-1" aria-label="' . esc_attr__( 'Screen Options Tab' ) . '">';
1063
+            $wrapper_end   = '</div>';
1064
+        }
1065
+
1066
+        // Don't output the form and nonce for the widgets accessibility mode links.
1067
+        if ( 'widgets' !== $this->base ) {
1068
+            $form_start = "\n<form id='adv-settings' method='post'>\n";
1069
+            $form_end   = "\n" . wp_nonce_field( 'screen-options-nonce', 'screenoptionnonce', false, false ) . "\n</form>\n";
1070
+        }
1071
+
1072
+        echo $wrapper_start . $form_start;
1073
+
1074
+        $this->render_meta_boxes_preferences();
1075
+        $this->render_list_table_columns_preferences();
1076
+        $this->render_screen_layout();
1077
+        $this->render_per_page_options();
1078
+        $this->render_view_mode();
1079
+        echo $this->_screen_settings;
1080
+
1081
+        /**
1082
+         * Filters whether to show the Screen Options submit button.
1083
+         *
1084
+         * @since 4.4.0
1085
+         *
1086
+         * @param bool      $show_button Whether to show Screen Options submit button.
1087
+         *                               Default false.
1088
+         * @param WP_Screen $screen      Current WP_Screen instance.
1089
+         */
1090
+        $show_button = apply_filters( 'screen_options_show_submit', false, $this );
1091
+
1092
+        if ( $show_button ) {
1093
+            submit_button( __( 'Apply' ), 'primary', 'screen-options-apply', true );
1094
+        }
1095
+
1096
+        echo $form_end . $wrapper_end;
1097
+    }
1098
+
1099
+    /**
1100
+     * Render the meta boxes preferences.
1101
+     *
1102
+     * @since 4.4.0
1103
+     *
1104
+     * @global array $wp_meta_boxes
1105
+     */
1106
+    public function render_meta_boxes_preferences() {
1107
+        global $wp_meta_boxes;
1108
+
1109
+        if ( ! isset( $wp_meta_boxes[ $this->id ] ) ) {
1110
+            return;
1111
+        }
1112
+        ?>
1113 1113
 		<fieldset class="metabox-prefs">
1114 1114
 		<legend><?php _e( 'Screen elements' ); ?></legend>
1115 1115
 		<p>
@@ -1118,158 +1118,158 @@  discard block
 block discarded – undo
1118 1118
 		</p>
1119 1119
 		<?php
1120 1120
 
1121
-		meta_box_prefs( $this );
1122
-
1123
-		if ( 'dashboard' === $this->id && has_action( 'welcome_panel' ) && current_user_can( 'edit_theme_options' ) ) {
1124
-			if ( isset( $_GET['welcome'] ) ) {
1125
-				$welcome_checked = empty( $_GET['welcome'] ) ? 0 : 1;
1126
-				update_user_meta( get_current_user_id(), 'show_welcome_panel', $welcome_checked );
1127
-			} else {
1128
-				$welcome_checked = (int) get_user_meta( get_current_user_id(), 'show_welcome_panel', true );
1129
-				if ( 2 === $welcome_checked && wp_get_current_user()->user_email !== get_option( 'admin_email' ) ) {
1130
-					$welcome_checked = false;
1131
-				}
1132
-			}
1133
-			echo '<label for="wp_welcome_panel-hide">';
1134
-			echo '<input type="checkbox" id="wp_welcome_panel-hide"' . checked( (bool) $welcome_checked, true, false ) . ' />';
1135
-			echo _x( 'Welcome', 'Welcome panel' ) . "</label>\n";
1136
-		}
1137
-		?>
1121
+        meta_box_prefs( $this );
1122
+
1123
+        if ( 'dashboard' === $this->id && has_action( 'welcome_panel' ) && current_user_can( 'edit_theme_options' ) ) {
1124
+            if ( isset( $_GET['welcome'] ) ) {
1125
+                $welcome_checked = empty( $_GET['welcome'] ) ? 0 : 1;
1126
+                update_user_meta( get_current_user_id(), 'show_welcome_panel', $welcome_checked );
1127
+            } else {
1128
+                $welcome_checked = (int) get_user_meta( get_current_user_id(), 'show_welcome_panel', true );
1129
+                if ( 2 === $welcome_checked && wp_get_current_user()->user_email !== get_option( 'admin_email' ) ) {
1130
+                    $welcome_checked = false;
1131
+                }
1132
+            }
1133
+            echo '<label for="wp_welcome_panel-hide">';
1134
+            echo '<input type="checkbox" id="wp_welcome_panel-hide"' . checked( (bool) $welcome_checked, true, false ) . ' />';
1135
+            echo _x( 'Welcome', 'Welcome panel' ) . "</label>\n";
1136
+        }
1137
+        ?>
1138 1138
 		</fieldset>
1139 1139
 		<?php
1140
-	}
1140
+    }
1141 1141
 
1142
-	/**
1143
-	 * Render the list table columns preferences.
1144
-	 *
1145
-	 * @since 4.4.0
1146
-	 */
1147
-	public function render_list_table_columns_preferences() {
1142
+    /**
1143
+     * Render the list table columns preferences.
1144
+     *
1145
+     * @since 4.4.0
1146
+     */
1147
+    public function render_list_table_columns_preferences() {
1148 1148
 
1149
-		$columns = get_column_headers( $this );
1150
-		$hidden  = get_hidden_columns( $this );
1149
+        $columns = get_column_headers( $this );
1150
+        $hidden  = get_hidden_columns( $this );
1151 1151
 
1152
-		if ( ! $columns ) {
1153
-			return;
1154
-		}
1152
+        if ( ! $columns ) {
1153
+            return;
1154
+        }
1155 1155
 
1156
-		$legend = ! empty( $columns['_title'] ) ? $columns['_title'] : __( 'Columns' );
1157
-		?>
1156
+        $legend = ! empty( $columns['_title'] ) ? $columns['_title'] : __( 'Columns' );
1157
+        ?>
1158 1158
 		<fieldset class="metabox-prefs">
1159 1159
 		<legend><?php echo $legend; ?></legend>
1160 1160
 		<?php
1161
-		$special = array( '_title', 'cb', 'comment', 'media', 'name', 'title', 'username', 'blogname' );
1161
+        $special = array( '_title', 'cb', 'comment', 'media', 'name', 'title', 'username', 'blogname' );
1162 1162
 
1163
-		foreach ( $columns as $column => $title ) {
1164
-			// Can't hide these for they are special.
1165
-			if ( in_array( $column, $special, true ) ) {
1166
-				continue;
1167
-			}
1163
+        foreach ( $columns as $column => $title ) {
1164
+            // Can't hide these for they are special.
1165
+            if ( in_array( $column, $special, true ) ) {
1166
+                continue;
1167
+            }
1168 1168
 
1169
-			if ( empty( $title ) ) {
1170
-				continue;
1171
-			}
1169
+            if ( empty( $title ) ) {
1170
+                continue;
1171
+            }
1172 1172
 
1173
-			/*
1173
+            /*
1174 1174
 			 * The Comments column uses HTML in the display name with some screen
1175 1175
 			 * reader text. Make sure to strip tags from the Comments column
1176 1176
 			 * title and any other custom column title plugins might add.
1177 1177
 			 */
1178
-			$title = wp_strip_all_tags( $title );
1179
-
1180
-			$id = "$column-hide";
1181
-			echo '<label>';
1182
-			echo '<input class="hide-column-tog" name="' . $id . '" type="checkbox" id="' . $id . '" value="' . $column . '"' . checked( ! in_array( $column, $hidden, true ), true, false ) . ' />';
1183
-			echo "$title</label>\n";
1184
-		}
1185
-		?>
1178
+            $title = wp_strip_all_tags( $title );
1179
+
1180
+            $id = "$column-hide";
1181
+            echo '<label>';
1182
+            echo '<input class="hide-column-tog" name="' . $id . '" type="checkbox" id="' . $id . '" value="' . $column . '"' . checked( ! in_array( $column, $hidden, true ), true, false ) . ' />';
1183
+            echo "$title</label>\n";
1184
+        }
1185
+        ?>
1186 1186
 		</fieldset>
1187 1187
 		<?php
1188
-	}
1189
-
1190
-	/**
1191
-	 * Render the option for number of columns on the page
1192
-	 *
1193
-	 * @since 3.3.0
1194
-	 */
1195
-	public function render_screen_layout() {
1196
-		if ( ! $this->get_option( 'layout_columns' ) ) {
1197
-			return;
1198
-		}
1199
-
1200
-		$screen_layout_columns = $this->get_columns();
1201
-		$num                   = $this->get_option( 'layout_columns', 'max' );
1202
-
1203
-		?>
1188
+    }
1189
+
1190
+    /**
1191
+     * Render the option for number of columns on the page
1192
+     *
1193
+     * @since 3.3.0
1194
+     */
1195
+    public function render_screen_layout() {
1196
+        if ( ! $this->get_option( 'layout_columns' ) ) {
1197
+            return;
1198
+        }
1199
+
1200
+        $screen_layout_columns = $this->get_columns();
1201
+        $num                   = $this->get_option( 'layout_columns', 'max' );
1202
+
1203
+        ?>
1204 1204
 		<fieldset class='columns-prefs'>
1205 1205
 		<legend class="screen-layout"><?php _e( 'Layout' ); ?></legend>
1206 1206
 		<?php for ( $i = 1; $i <= $num; ++$i ) : ?>
1207 1207
 			<label class="columns-prefs-<?php echo $i; ?>">
1208 1208
 			<input type='radio' name='screen_columns' value='<?php echo esc_attr( $i ); ?>' <?php checked( $screen_layout_columns, $i ); ?> />
1209 1209
 			<?php
1210
-				printf(
1211
-					/* translators: %s: Number of columns on the page. */
1212
-					_n( '%s column', '%s columns', $i ),
1213
-					number_format_i18n( $i )
1214
-				);
1215
-			?>
1210
+                printf(
1211
+                    /* translators: %s: Number of columns on the page. */
1212
+                    _n( '%s column', '%s columns', $i ),
1213
+                    number_format_i18n( $i )
1214
+                );
1215
+            ?>
1216 1216
 			</label>
1217 1217
 		<?php endfor; ?>
1218 1218
 		</fieldset>
1219 1219
 		<?php
1220
-	}
1221
-
1222
-	/**
1223
-	 * Render the items per page option
1224
-	 *
1225
-	 * @since 3.3.0
1226
-	 */
1227
-	public function render_per_page_options() {
1228
-		if ( null === $this->get_option( 'per_page' ) ) {
1229
-			return;
1230
-		}
1231
-
1232
-		$per_page_label = $this->get_option( 'per_page', 'label' );
1233
-		if ( null === $per_page_label ) {
1234
-			$per_page_label = __( 'Number of items per page:' );
1235
-		}
1236
-
1237
-		$option = $this->get_option( 'per_page', 'option' );
1238
-		if ( ! $option ) {
1239
-			$option = str_replace( '-', '_', "{$this->id}_per_page" );
1240
-		}
1241
-
1242
-		$per_page = (int) get_user_option( $option );
1243
-		if ( empty( $per_page ) || $per_page < 1 ) {
1244
-			$per_page = $this->get_option( 'per_page', 'default' );
1245
-			if ( ! $per_page ) {
1246
-				$per_page = 20;
1247
-			}
1248
-		}
1249
-
1250
-		if ( 'edit_comments_per_page' === $option ) {
1251
-			$comment_status = isset( $_REQUEST['comment_status'] ) ? $_REQUEST['comment_status'] : 'all';
1252
-
1253
-			/** This filter is documented in wp-admin/includes/class-wp-comments-list-table.php */
1254
-			$per_page = apply_filters( 'comments_per_page', $per_page, $comment_status );
1255
-		} elseif ( 'categories_per_page' === $option ) {
1256
-			/** This filter is documented in wp-admin/includes/class-wp-terms-list-table.php */
1257
-			$per_page = apply_filters( 'edit_categories_per_page', $per_page );
1258
-		} else {
1259
-			/** This filter is documented in wp-admin/includes/class-wp-list-table.php */
1260
-			$per_page = apply_filters( "{$option}", $per_page );
1261
-		}
1262
-
1263
-		// Back compat.
1264
-		if ( isset( $this->post_type ) ) {
1265
-			/** This filter is documented in wp-admin/includes/post.php */
1266
-			$per_page = apply_filters( 'edit_posts_per_page', $per_page, $this->post_type );
1267
-		}
1268
-
1269
-		// This needs a submit button.
1270
-		add_filter( 'screen_options_show_submit', '__return_true' );
1271
-
1272
-		?>
1220
+    }
1221
+
1222
+    /**
1223
+     * Render the items per page option
1224
+     *
1225
+     * @since 3.3.0
1226
+     */
1227
+    public function render_per_page_options() {
1228
+        if ( null === $this->get_option( 'per_page' ) ) {
1229
+            return;
1230
+        }
1231
+
1232
+        $per_page_label = $this->get_option( 'per_page', 'label' );
1233
+        if ( null === $per_page_label ) {
1234
+            $per_page_label = __( 'Number of items per page:' );
1235
+        }
1236
+
1237
+        $option = $this->get_option( 'per_page', 'option' );
1238
+        if ( ! $option ) {
1239
+            $option = str_replace( '-', '_', "{$this->id}_per_page" );
1240
+        }
1241
+
1242
+        $per_page = (int) get_user_option( $option );
1243
+        if ( empty( $per_page ) || $per_page < 1 ) {
1244
+            $per_page = $this->get_option( 'per_page', 'default' );
1245
+            if ( ! $per_page ) {
1246
+                $per_page = 20;
1247
+            }
1248
+        }
1249
+
1250
+        if ( 'edit_comments_per_page' === $option ) {
1251
+            $comment_status = isset( $_REQUEST['comment_status'] ) ? $_REQUEST['comment_status'] : 'all';
1252
+
1253
+            /** This filter is documented in wp-admin/includes/class-wp-comments-list-table.php */
1254
+            $per_page = apply_filters( 'comments_per_page', $per_page, $comment_status );
1255
+        } elseif ( 'categories_per_page' === $option ) {
1256
+            /** This filter is documented in wp-admin/includes/class-wp-terms-list-table.php */
1257
+            $per_page = apply_filters( 'edit_categories_per_page', $per_page );
1258
+        } else {
1259
+            /** This filter is documented in wp-admin/includes/class-wp-list-table.php */
1260
+            $per_page = apply_filters( "{$option}", $per_page );
1261
+        }
1262
+
1263
+        // Back compat.
1264
+        if ( isset( $this->post_type ) ) {
1265
+            /** This filter is documented in wp-admin/includes/post.php */
1266
+            $per_page = apply_filters( 'edit_posts_per_page', $per_page, $this->post_type );
1267
+        }
1268
+
1269
+        // This needs a submit button.
1270
+        add_filter( 'screen_options_show_submit', '__return_true' );
1271
+
1272
+        ?>
1273 1273
 		<fieldset class="screen-options">
1274 1274
 		<legend><?php _e( 'Pagination' ); ?></legend>
1275 1275
 			<?php if ( $per_page_label ) : ?>
@@ -1281,48 +1281,48 @@  discard block
 block discarded – undo
1281 1281
 				<input type="hidden" name="wp_screen_options[option]" value="<?php echo esc_attr( $option ); ?>" />
1282 1282
 		</fieldset>
1283 1283
 		<?php
1284
-	}
1285
-
1286
-	/**
1287
-	 * Render the list table view mode preferences.
1288
-	 *
1289
-	 * @since 4.4.0
1290
-	 *
1291
-	 * @global string $mode List table view mode.
1292
-	 */
1293
-	public function render_view_mode() {
1294
-		global $mode;
1295
-
1296
-		$screen = get_current_screen();
1297
-
1298
-		// Currently only enabled for posts and comments lists.
1299
-		if ( 'edit' !== $screen->base && 'edit-comments' !== $screen->base ) {
1300
-			return;
1301
-		}
1302
-
1303
-		$view_mode_post_types = get_post_types( array( 'show_ui' => true ) );
1304
-
1305
-		/**
1306
-		 * Filters the post types that have different view mode options.
1307
-		 *
1308
-		 * @since 4.4.0
1309
-		 *
1310
-		 * @param string[] $view_mode_post_types Array of post types that can change view modes.
1311
-		 *                                       Default post types with show_ui on.
1312
-		 */
1313
-		$view_mode_post_types = apply_filters( 'view_mode_post_types', $view_mode_post_types );
1314
-
1315
-		if ( 'edit' === $screen->base && ! in_array( $this->post_type, $view_mode_post_types, true ) ) {
1316
-			return;
1317
-		}
1318
-
1319
-		if ( ! isset( $mode ) ) {
1320
-			$mode = get_user_setting( 'posts_list_mode', 'list' );
1321
-		}
1322
-
1323
-		// This needs a submit button.
1324
-		add_filter( 'screen_options_show_submit', '__return_true' );
1325
-		?>
1284
+    }
1285
+
1286
+    /**
1287
+     * Render the list table view mode preferences.
1288
+     *
1289
+     * @since 4.4.0
1290
+     *
1291
+     * @global string $mode List table view mode.
1292
+     */
1293
+    public function render_view_mode() {
1294
+        global $mode;
1295
+
1296
+        $screen = get_current_screen();
1297
+
1298
+        // Currently only enabled for posts and comments lists.
1299
+        if ( 'edit' !== $screen->base && 'edit-comments' !== $screen->base ) {
1300
+            return;
1301
+        }
1302
+
1303
+        $view_mode_post_types = get_post_types( array( 'show_ui' => true ) );
1304
+
1305
+        /**
1306
+         * Filters the post types that have different view mode options.
1307
+         *
1308
+         * @since 4.4.0
1309
+         *
1310
+         * @param string[] $view_mode_post_types Array of post types that can change view modes.
1311
+         *                                       Default post types with show_ui on.
1312
+         */
1313
+        $view_mode_post_types = apply_filters( 'view_mode_post_types', $view_mode_post_types );
1314
+
1315
+        if ( 'edit' === $screen->base && ! in_array( $this->post_type, $view_mode_post_types, true ) ) {
1316
+            return;
1317
+        }
1318
+
1319
+        if ( ! isset( $mode ) ) {
1320
+            $mode = get_user_setting( 'posts_list_mode', 'list' );
1321
+        }
1322
+
1323
+        // This needs a submit button.
1324
+        add_filter( 'screen_options_show_submit', '__return_true' );
1325
+        ?>
1326 1326
 		<fieldset class="metabox-prefs view-mode">
1327 1327
 			<legend><?php _e( 'View mode' ); ?></legend>
1328 1328
 			<label for="list-view-mode">
@@ -1335,21 +1335,21 @@  discard block
 block discarded – undo
1335 1335
 			</label>
1336 1336
 		</fieldset>
1337 1337
 		<?php
1338
-	}
1339
-
1340
-	/**
1341
-	 * Render screen reader text.
1342
-	 *
1343
-	 * @since 4.4.0
1344
-	 *
1345
-	 * @param string $key The screen reader text array named key.
1346
-	 * @param string $tag Optional. The HTML tag to wrap the screen reader text. Default h2.
1347
-	 */
1348
-	public function render_screen_reader_content( $key = '', $tag = 'h2' ) {
1349
-
1350
-		if ( ! isset( $this->_screen_reader_content[ $key ] ) ) {
1351
-			return;
1352
-		}
1353
-		echo "<$tag class='screen-reader-text'>" . $this->_screen_reader_content[ $key ] . "</$tag>";
1354
-	}
1338
+    }
1339
+
1340
+    /**
1341
+     * Render screen reader text.
1342
+     *
1343
+     * @since 4.4.0
1344
+     *
1345
+     * @param string $key The screen reader text array named key.
1346
+     * @param string $tag Optional. The HTML tag to wrap the screen reader text. Default h2.
1347
+     */
1348
+    public function render_screen_reader_content( $key = '', $tag = 'h2' ) {
1349
+
1350
+        if ( ! isset( $this->_screen_reader_content[ $key ] ) ) {
1351
+            return;
1352
+        }
1353
+        echo "<$tag class='screen-reader-text'>" . $this->_screen_reader_content[ $key ] . "</$tag>";
1354
+    }
1355 1355
 }
Please login to merge, or discard this patch.
brighty/wp-admin/includes/edit-tag-messages.php 1 patch
Indentation   +27 added lines, -27 removed lines patch added patch discarded remove patch
@@ -10,33 +10,33 @@  discard block
 block discarded – undo
10 10
 $messages = array();
11 11
 // 0 = unused. Messages start at index 1.
12 12
 $messages['_item'] = array(
13
-	0 => '',
14
-	1 => __( 'Item added.' ),
15
-	2 => __( 'Item deleted.' ),
16
-	3 => __( 'Item updated.' ),
17
-	4 => __( 'Item not added.' ),
18
-	5 => __( 'Item not updated.' ),
19
-	6 => __( 'Items deleted.' ),
13
+    0 => '',
14
+    1 => __( 'Item added.' ),
15
+    2 => __( 'Item deleted.' ),
16
+    3 => __( 'Item updated.' ),
17
+    4 => __( 'Item not added.' ),
18
+    5 => __( 'Item not updated.' ),
19
+    6 => __( 'Items deleted.' ),
20 20
 );
21 21
 
22 22
 $messages['category'] = array(
23
-	0 => '',
24
-	1 => __( 'Category added.' ),
25
-	2 => __( 'Category deleted.' ),
26
-	3 => __( 'Category updated.' ),
27
-	4 => __( 'Category not added.' ),
28
-	5 => __( 'Category not updated.' ),
29
-	6 => __( 'Categories deleted.' ),
23
+    0 => '',
24
+    1 => __( 'Category added.' ),
25
+    2 => __( 'Category deleted.' ),
26
+    3 => __( 'Category updated.' ),
27
+    4 => __( 'Category not added.' ),
28
+    5 => __( 'Category not updated.' ),
29
+    6 => __( 'Categories deleted.' ),
30 30
 );
31 31
 
32 32
 $messages['post_tag'] = array(
33
-	0 => '',
34
-	1 => __( 'Tag added.' ),
35
-	2 => __( 'Tag deleted.' ),
36
-	3 => __( 'Tag updated.' ),
37
-	4 => __( 'Tag not added.' ),
38
-	5 => __( 'Tag not updated.' ),
39
-	6 => __( 'Tags deleted.' ),
33
+    0 => '',
34
+    1 => __( 'Tag added.' ),
35
+    2 => __( 'Tag deleted.' ),
36
+    3 => __( 'Tag updated.' ),
37
+    4 => __( 'Tag not added.' ),
38
+    5 => __( 'Tag not updated.' ),
39
+    6 => __( 'Tags deleted.' ),
40 40
 );
41 41
 
42 42
 /**
@@ -50,10 +50,10 @@  discard block
 block discarded – undo
50 50
 
51 51
 $message = false;
52 52
 if ( isset( $_REQUEST['message'] ) && (int) $_REQUEST['message'] ) {
53
-	$msg = (int) $_REQUEST['message'];
54
-	if ( isset( $messages[ $taxonomy ][ $msg ] ) ) {
55
-		$message = $messages[ $taxonomy ][ $msg ];
56
-	} elseif ( ! isset( $messages[ $taxonomy ] ) && isset( $messages['_item'][ $msg ] ) ) {
57
-		$message = $messages['_item'][ $msg ];
58
-	}
53
+    $msg = (int) $_REQUEST['message'];
54
+    if ( isset( $messages[ $taxonomy ][ $msg ] ) ) {
55
+        $message = $messages[ $taxonomy ][ $msg ];
56
+    } elseif ( ! isset( $messages[ $taxonomy ] ) && isset( $messages['_item'][ $msg ] ) ) {
57
+        $message = $messages['_item'][ $msg ];
58
+    }
59 59
 }
Please login to merge, or discard this patch.
brighty/wp-admin/includes/class-wp-upgrader.php 1 patch
Indentation   +888 added lines, -888 removed lines patch added patch discarded remove patch
@@ -50,903 +50,903 @@
 block discarded – undo
50 50
  */
51 51
 class WP_Upgrader {
52 52
 
53
-	/**
54
-	 * The error/notification strings used to update the user on the progress.
55
-	 *
56
-	 * @since 2.8.0
57
-	 * @var array $strings
58
-	 */
59
-	public $strings = array();
60
-
61
-	/**
62
-	 * The upgrader skin being used.
63
-	 *
64
-	 * @since 2.8.0
65
-	 * @var Automatic_Upgrader_Skin|WP_Upgrader_Skin $skin
66
-	 */
67
-	public $skin = null;
68
-
69
-	/**
70
-	 * The result of the installation.
71
-	 *
72
-	 * This is set by WP_Upgrader::install_package(), only when the package is installed
73
-	 * successfully. It will then be an array, unless a WP_Error is returned by the
74
-	 * {@see 'upgrader_post_install'} filter. In that case, the WP_Error will be assigned to
75
-	 * it.
76
-	 *
77
-	 * @since 2.8.0
78
-	 *
79
-	 * @var array|WP_Error $result {
80
-	 *     @type string $source             The full path to the source the files were installed from.
81
-	 *     @type string $source_files       List of all the files in the source directory.
82
-	 *     @type string $destination        The full path to the installation destination folder.
83
-	 *     @type string $destination_name   The name of the destination folder, or empty if `$destination`
84
-	 *                                      and `$local_destination` are the same.
85
-	 *     @type string $local_destination  The full local path to the destination folder. This is usually
86
-	 *                                      the same as `$destination`.
87
-	 *     @type string $remote_destination The full remote path to the destination folder
88
-	 *                                      (i.e., from `$wp_filesystem`).
89
-	 *     @type bool   $clear_destination  Whether the destination folder was cleared.
90
-	 * }
91
-	 */
92
-	public $result = array();
93
-
94
-	/**
95
-	 * The total number of updates being performed.
96
-	 *
97
-	 * Set by the bulk update methods.
98
-	 *
99
-	 * @since 3.0.0
100
-	 * @var int $update_count
101
-	 */
102
-	public $update_count = 0;
103
-
104
-	/**
105
-	 * The current update if multiple updates are being performed.
106
-	 *
107
-	 * Used by the bulk update methods, and incremented for each update.
108
-	 *
109
-	 * @since 3.0.0
110
-	 * @var int
111
-	 */
112
-	public $update_current = 0;
113
-
114
-	/**
115
-	 * Construct the upgrader with a skin.
116
-	 *
117
-	 * @since 2.8.0
118
-	 *
119
-	 * @param WP_Upgrader_Skin $skin The upgrader skin to use. Default is a WP_Upgrader_Skin
120
-	 *                               instance.
121
-	 */
122
-	public function __construct( $skin = null ) {
123
-		if ( null === $skin ) {
124
-			$this->skin = new WP_Upgrader_Skin();
125
-		} else {
126
-			$this->skin = $skin;
127
-		}
128
-	}
129
-
130
-	/**
131
-	 * Initialize the upgrader.
132
-	 *
133
-	 * This will set the relationship between the skin being used and this upgrader,
134
-	 * and also add the generic strings to `WP_Upgrader::$strings`.
135
-	 *
136
-	 * @since 2.8.0
137
-	 */
138
-	public function init() {
139
-		$this->skin->set_upgrader( $this );
140
-		$this->generic_strings();
141
-	}
142
-
143
-	/**
144
-	 * Add the generic strings to WP_Upgrader::$strings.
145
-	 *
146
-	 * @since 2.8.0
147
-	 */
148
-	public function generic_strings() {
149
-		$this->strings['bad_request']       = __( 'Invalid data provided.' );
150
-		$this->strings['fs_unavailable']    = __( 'Could not access filesystem.' );
151
-		$this->strings['fs_error']          = __( 'Filesystem error.' );
152
-		$this->strings['fs_no_root_dir']    = __( 'Unable to locate WordPress root directory.' );
153
-		$this->strings['fs_no_content_dir'] = __( 'Unable to locate WordPress content directory (wp-content).' );
154
-		$this->strings['fs_no_plugins_dir'] = __( 'Unable to locate WordPress plugin directory.' );
155
-		$this->strings['fs_no_themes_dir']  = __( 'Unable to locate WordPress theme directory.' );
156
-		/* translators: %s: Directory name. */
157
-		$this->strings['fs_no_folder'] = __( 'Unable to locate needed folder (%s).' );
158
-
159
-		$this->strings['download_failed']      = __( 'Download failed.' );
160
-		$this->strings['installing_package']   = __( 'Installing the latest version&#8230;' );
161
-		$this->strings['no_files']             = __( 'The package contains no files.' );
162
-		$this->strings['folder_exists']        = __( 'Destination folder already exists.' );
163
-		$this->strings['mkdir_failed']         = __( 'Could not create directory.' );
164
-		$this->strings['incompatible_archive'] = __( 'The package could not be installed.' );
165
-		$this->strings['files_not_writable']   = __( 'The update cannot be installed because some files could not be copied. This is usually due to inconsistent file permissions.' );
166
-
167
-		$this->strings['maintenance_start'] = __( 'Enabling Maintenance mode&#8230;' );
168
-		$this->strings['maintenance_end']   = __( 'Disabling Maintenance mode&#8230;' );
169
-	}
170
-
171
-	/**
172
-	 * Connect to the filesystem.
173
-	 *
174
-	 * @since 2.8.0
175
-	 *
176
-	 * @global WP_Filesystem_Base $wp_filesystem WordPress filesystem subclass.
177
-	 *
178
-	 * @param string[] $directories                  Optional. Array of directories. If any of these do
179
-	 *                                               not exist, a WP_Error object will be returned.
180
-	 *                                               Default empty array.
181
-	 * @param bool     $allow_relaxed_file_ownership Whether to allow relaxed file ownership.
182
-	 *                                               Default false.
183
-	 * @return bool|WP_Error True if able to connect, false or a WP_Error otherwise.
184
-	 */
185
-	public function fs_connect( $directories = array(), $allow_relaxed_file_ownership = false ) {
186
-		global $wp_filesystem;
187
-
188
-		$credentials = $this->skin->request_filesystem_credentials( false, $directories[0], $allow_relaxed_file_ownership );
189
-		if ( false === $credentials ) {
190
-			return false;
191
-		}
192
-
193
-		if ( ! WP_Filesystem( $credentials, $directories[0], $allow_relaxed_file_ownership ) ) {
194
-			$error = true;
195
-			if ( is_object( $wp_filesystem ) && $wp_filesystem->errors->has_errors() ) {
196
-				$error = $wp_filesystem->errors;
197
-			}
198
-			// Failed to connect. Error and request again.
199
-			$this->skin->request_filesystem_credentials( $error, $directories[0], $allow_relaxed_file_ownership );
200
-			return false;
201
-		}
202
-
203
-		if ( ! is_object( $wp_filesystem ) ) {
204
-			return new WP_Error( 'fs_unavailable', $this->strings['fs_unavailable'] );
205
-		}
206
-
207
-		if ( is_wp_error( $wp_filesystem->errors ) && $wp_filesystem->errors->has_errors() ) {
208
-			return new WP_Error( 'fs_error', $this->strings['fs_error'], $wp_filesystem->errors );
209
-		}
210
-
211
-		foreach ( (array) $directories as $dir ) {
212
-			switch ( $dir ) {
213
-				case ABSPATH:
214
-					if ( ! $wp_filesystem->abspath() ) {
215
-						return new WP_Error( 'fs_no_root_dir', $this->strings['fs_no_root_dir'] );
216
-					}
217
-					break;
218
-				case WP_CONTENT_DIR:
219
-					if ( ! $wp_filesystem->wp_content_dir() ) {
220
-						return new WP_Error( 'fs_no_content_dir', $this->strings['fs_no_content_dir'] );
221
-					}
222
-					break;
223
-				case WP_PLUGIN_DIR:
224
-					if ( ! $wp_filesystem->wp_plugins_dir() ) {
225
-						return new WP_Error( 'fs_no_plugins_dir', $this->strings['fs_no_plugins_dir'] );
226
-					}
227
-					break;
228
-				case get_theme_root():
229
-					if ( ! $wp_filesystem->wp_themes_dir() ) {
230
-						return new WP_Error( 'fs_no_themes_dir', $this->strings['fs_no_themes_dir'] );
231
-					}
232
-					break;
233
-				default:
234
-					if ( ! $wp_filesystem->find_folder( $dir ) ) {
235
-						return new WP_Error( 'fs_no_folder', sprintf( $this->strings['fs_no_folder'], esc_html( basename( $dir ) ) ) );
236
-					}
237
-					break;
238
-			}
239
-		}
240
-		return true;
241
-	}
242
-
243
-	/**
244
-	 * Download a package.
245
-	 *
246
-	 * @since 2.8.0
247
-	 * @since 5.2.0 Added the `$check_signatures` parameter.
248
-	 * @since 5.5.0 Added the `$hook_extra` parameter.
249
-	 *
250
-	 * @param string $package          The URI of the package. If this is the full path to an
251
-	 *                                 existing local file, it will be returned untouched.
252
-	 * @param bool   $check_signatures Whether to validate file signatures. Default false.
253
-	 * @param array  $hook_extra       Extra arguments to pass to the filter hooks. Default empty array.
254
-	 * @return string|WP_Error The full path to the downloaded package file, or a WP_Error object.
255
-	 */
256
-	public function download_package( $package, $check_signatures = false, $hook_extra = array() ) {
257
-		/**
258
-		 * Filters whether to return the package.
259
-		 *
260
-		 * @since 3.7.0
261
-		 * @since 5.5.0 Added the `$hook_extra` parameter.
262
-		 *
263
-		 * @param bool        $reply      Whether to bail without returning the package.
264
-		 *                                Default false.
265
-		 * @param string      $package    The package file name.
266
-		 * @param WP_Upgrader $upgrader   The WP_Upgrader instance.
267
-		 * @param array       $hook_extra Extra arguments passed to hooked filters.
268
-		 */
269
-		$reply = apply_filters( 'upgrader_pre_download', false, $package, $this, $hook_extra );
270
-		if ( false !== $reply ) {
271
-			return $reply;
272
-		}
273
-
274
-		if ( ! preg_match( '!^(http|https|ftp)://!i', $package ) && file_exists( $package ) ) { // Local file or remote?
275
-			return $package; // Must be a local file.
276
-		}
277
-
278
-		if ( empty( $package ) ) {
279
-			return new WP_Error( 'no_package', $this->strings['no_package'] );
280
-		}
281
-
282
-		$this->skin->feedback( 'downloading_package', $package );
283
-
284
-		$download_file = download_url( $package, 300, $check_signatures );
285
-
286
-		if ( is_wp_error( $download_file ) && ! $download_file->get_error_data( 'softfail-filename' ) ) {
287
-			return new WP_Error( 'download_failed', $this->strings['download_failed'], $download_file->get_error_message() );
288
-		}
289
-
290
-		return $download_file;
291
-	}
292
-
293
-	/**
294
-	 * Unpack a compressed package file.
295
-	 *
296
-	 * @since 2.8.0
297
-	 *
298
-	 * @global WP_Filesystem_Base $wp_filesystem WordPress filesystem subclass.
299
-	 *
300
-	 * @param string $package        Full path to the package file.
301
-	 * @param bool   $delete_package Optional. Whether to delete the package file after attempting
302
-	 *                               to unpack it. Default true.
303
-	 * @return string|WP_Error The path to the unpacked contents, or a WP_Error on failure.
304
-	 */
305
-	public function unpack_package( $package, $delete_package = true ) {
306
-		global $wp_filesystem;
307
-
308
-		$this->skin->feedback( 'unpack_package' );
309
-
310
-		$upgrade_folder = $wp_filesystem->wp_content_dir() . 'upgrade/';
311
-
312
-		// Clean up contents of upgrade directory beforehand.
313
-		$upgrade_files = $wp_filesystem->dirlist( $upgrade_folder );
314
-		if ( ! empty( $upgrade_files ) ) {
315
-			foreach ( $upgrade_files as $file ) {
316
-				$wp_filesystem->delete( $upgrade_folder . $file['name'], true );
317
-			}
318
-		}
319
-
320
-		// We need a working directory - strip off any .tmp or .zip suffixes.
321
-		$working_dir = $upgrade_folder . basename( basename( $package, '.tmp' ), '.zip' );
322
-
323
-		// Clean up working directory.
324
-		if ( $wp_filesystem->is_dir( $working_dir ) ) {
325
-			$wp_filesystem->delete( $working_dir, true );
326
-		}
327
-
328
-		// Unzip package to working directory.
329
-		$result = unzip_file( $package, $working_dir );
330
-
331
-		// Once extracted, delete the package if required.
332
-		if ( $delete_package ) {
333
-			unlink( $package );
334
-		}
335
-
336
-		if ( is_wp_error( $result ) ) {
337
-			$wp_filesystem->delete( $working_dir, true );
338
-			if ( 'incompatible_archive' === $result->get_error_code() ) {
339
-				return new WP_Error( 'incompatible_archive', $this->strings['incompatible_archive'], $result->get_error_data() );
340
-			}
341
-			return $result;
342
-		}
343
-
344
-		return $working_dir;
345
-	}
346
-
347
-	/**
348
-	 * Flatten the results of WP_Filesystem_Base::dirlist() for iterating over.
349
-	 *
350
-	 * @since 4.9.0
351
-	 * @access protected
352
-	 *
353
-	 * @param array  $nested_files Array of files as returned by WP_Filesystem_Base::dirlist().
354
-	 * @param string $path         Relative path to prepend to child nodes. Optional.
355
-	 * @return array A flattened array of the $nested_files specified.
356
-	 */
357
-	protected function flatten_dirlist( $nested_files, $path = '' ) {
358
-		$files = array();
359
-
360
-		foreach ( $nested_files as $name => $details ) {
361
-			$files[ $path . $name ] = $details;
362
-
363
-			// Append children recursively.
364
-			if ( ! empty( $details['files'] ) ) {
365
-				$children = $this->flatten_dirlist( $details['files'], $path . $name . '/' );
366
-
367
-				// Merge keeping possible numeric keys, which array_merge() will reindex from 0..n.
368
-				$files = $files + $children;
369
-			}
370
-		}
371
-
372
-		return $files;
373
-	}
374
-
375
-	/**
376
-	 * Clears the directory where this item is going to be installed into.
377
-	 *
378
-	 * @since 4.3.0
379
-	 *
380
-	 * @global WP_Filesystem_Base $wp_filesystem WordPress filesystem subclass.
381
-	 *
382
-	 * @param string $remote_destination The location on the remote filesystem to be cleared.
383
-	 * @return true|WP_Error True upon success, WP_Error on failure.
384
-	 */
385
-	public function clear_destination( $remote_destination ) {
386
-		global $wp_filesystem;
387
-
388
-		$files = $wp_filesystem->dirlist( $remote_destination, true, true );
389
-
390
-		// False indicates that the $remote_destination doesn't exist.
391
-		if ( false === $files ) {
392
-			return true;
393
-		}
394
-
395
-		// Flatten the file list to iterate over.
396
-		$files = $this->flatten_dirlist( $files );
397
-
398
-		// Check all files are writable before attempting to clear the destination.
399
-		$unwritable_files = array();
400
-
401
-		// Check writability.
402
-		foreach ( $files as $filename => $file_details ) {
403
-			if ( ! $wp_filesystem->is_writable( $remote_destination . $filename ) ) {
404
-				// Attempt to alter permissions to allow writes and try again.
405
-				$wp_filesystem->chmod( $remote_destination . $filename, ( 'd' === $file_details['type'] ? FS_CHMOD_DIR : FS_CHMOD_FILE ) );
406
-				if ( ! $wp_filesystem->is_writable( $remote_destination . $filename ) ) {
407
-					$unwritable_files[] = $filename;
408
-				}
409
-			}
410
-		}
411
-
412
-		if ( ! empty( $unwritable_files ) ) {
413
-			return new WP_Error( 'files_not_writable', $this->strings['files_not_writable'], implode( ', ', $unwritable_files ) );
414
-		}
415
-
416
-		if ( ! $wp_filesystem->delete( $remote_destination, true ) ) {
417
-			return new WP_Error( 'remove_old_failed', $this->strings['remove_old_failed'] );
418
-		}
419
-
420
-		return true;
421
-	}
422
-
423
-	/**
424
-	 * Install a package.
425
-	 *
426
-	 * Copies the contents of a package from a source directory, and installs them in
427
-	 * a destination directory. Optionally removes the source. It can also optionally
428
-	 * clear out the destination folder if it already exists.
429
-	 *
430
-	 * @since 2.8.0
431
-	 *
432
-	 * @global WP_Filesystem_Base $wp_filesystem        WordPress filesystem subclass.
433
-	 * @global array              $wp_theme_directories
434
-	 *
435
-	 * @param array|string $args {
436
-	 *     Optional. Array or string of arguments for installing a package. Default empty array.
437
-	 *
438
-	 *     @type string $source                      Required path to the package source. Default empty.
439
-	 *     @type string $destination                 Required path to a folder to install the package in.
440
-	 *                                               Default empty.
441
-	 *     @type bool   $clear_destination           Whether to delete any files already in the destination
442
-	 *                                               folder. Default false.
443
-	 *     @type bool   $clear_working               Whether to delete the files from the working directory
444
-	 *                                               after copying them to the destination. Default false.
445
-	 *     @type bool   $abort_if_destination_exists Whether to abort the installation if
446
-	 *                                               the destination folder already exists. Default true.
447
-	 *     @type array  $hook_extra                  Extra arguments to pass to the filter hooks called by
448
-	 *                                               WP_Upgrader::install_package(). Default empty array.
449
-	 * }
450
-	 *
451
-	 * @return array|WP_Error The result (also stored in `WP_Upgrader::$result`), or a WP_Error on failure.
452
-	 */
453
-	public function install_package( $args = array() ) {
454
-		global $wp_filesystem, $wp_theme_directories;
455
-
456
-		$defaults = array(
457
-			'source'                      => '', // Please always pass this.
458
-			'destination'                 => '', // ...and this.
459
-			'clear_destination'           => false,
460
-			'clear_working'               => false,
461
-			'abort_if_destination_exists' => true,
462
-			'hook_extra'                  => array(),
463
-		);
464
-
465
-		$args = wp_parse_args( $args, $defaults );
466
-
467
-		// These were previously extract()'d.
468
-		$source            = $args['source'];
469
-		$destination       = $args['destination'];
470
-		$clear_destination = $args['clear_destination'];
471
-
472
-		set_time_limit( 300 );
473
-
474
-		if ( empty( $source ) || empty( $destination ) ) {
475
-			return new WP_Error( 'bad_request', $this->strings['bad_request'] );
476
-		}
477
-		$this->skin->feedback( 'installing_package' );
478
-
479
-		/**
480
-		 * Filters the installation response before the installation has started.
481
-		 *
482
-		 * Returning a value that could be evaluated as a `WP_Error` will effectively
483
-		 * short-circuit the installation, returning that value instead.
484
-		 *
485
-		 * @since 2.8.0
486
-		 *
487
-		 * @param bool|WP_Error $response   Installation response.
488
-		 * @param array         $hook_extra Extra arguments passed to hooked filters.
489
-		 */
490
-		$res = apply_filters( 'upgrader_pre_install', true, $args['hook_extra'] );
491
-
492
-		if ( is_wp_error( $res ) ) {
493
-			return $res;
494
-		}
495
-
496
-		// Retain the original source and destinations.
497
-		$remote_source     = $args['source'];
498
-		$local_destination = $destination;
499
-
500
-		$source_files       = array_keys( $wp_filesystem->dirlist( $remote_source ) );
501
-		$remote_destination = $wp_filesystem->find_folder( $local_destination );
502
-
503
-		// Locate which directory to copy to the new folder. This is based on the actual folder holding the files.
504
-		if ( 1 === count( $source_files ) && $wp_filesystem->is_dir( trailingslashit( $args['source'] ) . $source_files[0] . '/' ) ) {
505
-			// Only one folder? Then we want its contents.
506
-			$source = trailingslashit( $args['source'] ) . trailingslashit( $source_files[0] );
507
-		} elseif ( 0 === count( $source_files ) ) {
508
-			// There are no files?
509
-			return new WP_Error( 'incompatible_archive_empty', $this->strings['incompatible_archive'], $this->strings['no_files'] );
510
-		} else {
511
-			// It's only a single file, the upgrader will use the folder name of this file as the destination folder.
512
-			// Folder name is based on zip filename.
513
-			$source = trailingslashit( $args['source'] );
514
-		}
515
-
516
-		/**
517
-		 * Filters the source file location for the upgrade package.
518
-		 *
519
-		 * @since 2.8.0
520
-		 * @since 4.4.0 The $hook_extra parameter became available.
521
-		 *
522
-		 * @param string      $source        File source location.
523
-		 * @param string      $remote_source Remote file source location.
524
-		 * @param WP_Upgrader $upgrader      WP_Upgrader instance.
525
-		 * @param array       $hook_extra    Extra arguments passed to hooked filters.
526
-		 */
527
-		$source = apply_filters( 'upgrader_source_selection', $source, $remote_source, $this, $args['hook_extra'] );
528
-
529
-		if ( is_wp_error( $source ) ) {
530
-			return $source;
531
-		}
532
-
533
-		// Has the source location changed? If so, we need a new source_files list.
534
-		if ( $source !== $remote_source ) {
535
-			$source_files = array_keys( $wp_filesystem->dirlist( $source ) );
536
-		}
537
-
538
-		/*
53
+    /**
54
+     * The error/notification strings used to update the user on the progress.
55
+     *
56
+     * @since 2.8.0
57
+     * @var array $strings
58
+     */
59
+    public $strings = array();
60
+
61
+    /**
62
+     * The upgrader skin being used.
63
+     *
64
+     * @since 2.8.0
65
+     * @var Automatic_Upgrader_Skin|WP_Upgrader_Skin $skin
66
+     */
67
+    public $skin = null;
68
+
69
+    /**
70
+     * The result of the installation.
71
+     *
72
+     * This is set by WP_Upgrader::install_package(), only when the package is installed
73
+     * successfully. It will then be an array, unless a WP_Error is returned by the
74
+     * {@see 'upgrader_post_install'} filter. In that case, the WP_Error will be assigned to
75
+     * it.
76
+     *
77
+     * @since 2.8.0
78
+     *
79
+     * @var array|WP_Error $result {
80
+     *     @type string $source             The full path to the source the files were installed from.
81
+     *     @type string $source_files       List of all the files in the source directory.
82
+     *     @type string $destination        The full path to the installation destination folder.
83
+     *     @type string $destination_name   The name of the destination folder, or empty if `$destination`
84
+     *                                      and `$local_destination` are the same.
85
+     *     @type string $local_destination  The full local path to the destination folder. This is usually
86
+     *                                      the same as `$destination`.
87
+     *     @type string $remote_destination The full remote path to the destination folder
88
+     *                                      (i.e., from `$wp_filesystem`).
89
+     *     @type bool   $clear_destination  Whether the destination folder was cleared.
90
+     * }
91
+     */
92
+    public $result = array();
93
+
94
+    /**
95
+     * The total number of updates being performed.
96
+     *
97
+     * Set by the bulk update methods.
98
+     *
99
+     * @since 3.0.0
100
+     * @var int $update_count
101
+     */
102
+    public $update_count = 0;
103
+
104
+    /**
105
+     * The current update if multiple updates are being performed.
106
+     *
107
+     * Used by the bulk update methods, and incremented for each update.
108
+     *
109
+     * @since 3.0.0
110
+     * @var int
111
+     */
112
+    public $update_current = 0;
113
+
114
+    /**
115
+     * Construct the upgrader with a skin.
116
+     *
117
+     * @since 2.8.0
118
+     *
119
+     * @param WP_Upgrader_Skin $skin The upgrader skin to use. Default is a WP_Upgrader_Skin
120
+     *                               instance.
121
+     */
122
+    public function __construct( $skin = null ) {
123
+        if ( null === $skin ) {
124
+            $this->skin = new WP_Upgrader_Skin();
125
+        } else {
126
+            $this->skin = $skin;
127
+        }
128
+    }
129
+
130
+    /**
131
+     * Initialize the upgrader.
132
+     *
133
+     * This will set the relationship between the skin being used and this upgrader,
134
+     * and also add the generic strings to `WP_Upgrader::$strings`.
135
+     *
136
+     * @since 2.8.0
137
+     */
138
+    public function init() {
139
+        $this->skin->set_upgrader( $this );
140
+        $this->generic_strings();
141
+    }
142
+
143
+    /**
144
+     * Add the generic strings to WP_Upgrader::$strings.
145
+     *
146
+     * @since 2.8.0
147
+     */
148
+    public function generic_strings() {
149
+        $this->strings['bad_request']       = __( 'Invalid data provided.' );
150
+        $this->strings['fs_unavailable']    = __( 'Could not access filesystem.' );
151
+        $this->strings['fs_error']          = __( 'Filesystem error.' );
152
+        $this->strings['fs_no_root_dir']    = __( 'Unable to locate WordPress root directory.' );
153
+        $this->strings['fs_no_content_dir'] = __( 'Unable to locate WordPress content directory (wp-content).' );
154
+        $this->strings['fs_no_plugins_dir'] = __( 'Unable to locate WordPress plugin directory.' );
155
+        $this->strings['fs_no_themes_dir']  = __( 'Unable to locate WordPress theme directory.' );
156
+        /* translators: %s: Directory name. */
157
+        $this->strings['fs_no_folder'] = __( 'Unable to locate needed folder (%s).' );
158
+
159
+        $this->strings['download_failed']      = __( 'Download failed.' );
160
+        $this->strings['installing_package']   = __( 'Installing the latest version&#8230;' );
161
+        $this->strings['no_files']             = __( 'The package contains no files.' );
162
+        $this->strings['folder_exists']        = __( 'Destination folder already exists.' );
163
+        $this->strings['mkdir_failed']         = __( 'Could not create directory.' );
164
+        $this->strings['incompatible_archive'] = __( 'The package could not be installed.' );
165
+        $this->strings['files_not_writable']   = __( 'The update cannot be installed because some files could not be copied. This is usually due to inconsistent file permissions.' );
166
+
167
+        $this->strings['maintenance_start'] = __( 'Enabling Maintenance mode&#8230;' );
168
+        $this->strings['maintenance_end']   = __( 'Disabling Maintenance mode&#8230;' );
169
+    }
170
+
171
+    /**
172
+     * Connect to the filesystem.
173
+     *
174
+     * @since 2.8.0
175
+     *
176
+     * @global WP_Filesystem_Base $wp_filesystem WordPress filesystem subclass.
177
+     *
178
+     * @param string[] $directories                  Optional. Array of directories. If any of these do
179
+     *                                               not exist, a WP_Error object will be returned.
180
+     *                                               Default empty array.
181
+     * @param bool     $allow_relaxed_file_ownership Whether to allow relaxed file ownership.
182
+     *                                               Default false.
183
+     * @return bool|WP_Error True if able to connect, false or a WP_Error otherwise.
184
+     */
185
+    public function fs_connect( $directories = array(), $allow_relaxed_file_ownership = false ) {
186
+        global $wp_filesystem;
187
+
188
+        $credentials = $this->skin->request_filesystem_credentials( false, $directories[0], $allow_relaxed_file_ownership );
189
+        if ( false === $credentials ) {
190
+            return false;
191
+        }
192
+
193
+        if ( ! WP_Filesystem( $credentials, $directories[0], $allow_relaxed_file_ownership ) ) {
194
+            $error = true;
195
+            if ( is_object( $wp_filesystem ) && $wp_filesystem->errors->has_errors() ) {
196
+                $error = $wp_filesystem->errors;
197
+            }
198
+            // Failed to connect. Error and request again.
199
+            $this->skin->request_filesystem_credentials( $error, $directories[0], $allow_relaxed_file_ownership );
200
+            return false;
201
+        }
202
+
203
+        if ( ! is_object( $wp_filesystem ) ) {
204
+            return new WP_Error( 'fs_unavailable', $this->strings['fs_unavailable'] );
205
+        }
206
+
207
+        if ( is_wp_error( $wp_filesystem->errors ) && $wp_filesystem->errors->has_errors() ) {
208
+            return new WP_Error( 'fs_error', $this->strings['fs_error'], $wp_filesystem->errors );
209
+        }
210
+
211
+        foreach ( (array) $directories as $dir ) {
212
+            switch ( $dir ) {
213
+                case ABSPATH:
214
+                    if ( ! $wp_filesystem->abspath() ) {
215
+                        return new WP_Error( 'fs_no_root_dir', $this->strings['fs_no_root_dir'] );
216
+                    }
217
+                    break;
218
+                case WP_CONTENT_DIR:
219
+                    if ( ! $wp_filesystem->wp_content_dir() ) {
220
+                        return new WP_Error( 'fs_no_content_dir', $this->strings['fs_no_content_dir'] );
221
+                    }
222
+                    break;
223
+                case WP_PLUGIN_DIR:
224
+                    if ( ! $wp_filesystem->wp_plugins_dir() ) {
225
+                        return new WP_Error( 'fs_no_plugins_dir', $this->strings['fs_no_plugins_dir'] );
226
+                    }
227
+                    break;
228
+                case get_theme_root():
229
+                    if ( ! $wp_filesystem->wp_themes_dir() ) {
230
+                        return new WP_Error( 'fs_no_themes_dir', $this->strings['fs_no_themes_dir'] );
231
+                    }
232
+                    break;
233
+                default:
234
+                    if ( ! $wp_filesystem->find_folder( $dir ) ) {
235
+                        return new WP_Error( 'fs_no_folder', sprintf( $this->strings['fs_no_folder'], esc_html( basename( $dir ) ) ) );
236
+                    }
237
+                    break;
238
+            }
239
+        }
240
+        return true;
241
+    }
242
+
243
+    /**
244
+     * Download a package.
245
+     *
246
+     * @since 2.8.0
247
+     * @since 5.2.0 Added the `$check_signatures` parameter.
248
+     * @since 5.5.0 Added the `$hook_extra` parameter.
249
+     *
250
+     * @param string $package          The URI of the package. If this is the full path to an
251
+     *                                 existing local file, it will be returned untouched.
252
+     * @param bool   $check_signatures Whether to validate file signatures. Default false.
253
+     * @param array  $hook_extra       Extra arguments to pass to the filter hooks. Default empty array.
254
+     * @return string|WP_Error The full path to the downloaded package file, or a WP_Error object.
255
+     */
256
+    public function download_package( $package, $check_signatures = false, $hook_extra = array() ) {
257
+        /**
258
+         * Filters whether to return the package.
259
+         *
260
+         * @since 3.7.0
261
+         * @since 5.5.0 Added the `$hook_extra` parameter.
262
+         *
263
+         * @param bool        $reply      Whether to bail without returning the package.
264
+         *                                Default false.
265
+         * @param string      $package    The package file name.
266
+         * @param WP_Upgrader $upgrader   The WP_Upgrader instance.
267
+         * @param array       $hook_extra Extra arguments passed to hooked filters.
268
+         */
269
+        $reply = apply_filters( 'upgrader_pre_download', false, $package, $this, $hook_extra );
270
+        if ( false !== $reply ) {
271
+            return $reply;
272
+        }
273
+
274
+        if ( ! preg_match( '!^(http|https|ftp)://!i', $package ) && file_exists( $package ) ) { // Local file or remote?
275
+            return $package; // Must be a local file.
276
+        }
277
+
278
+        if ( empty( $package ) ) {
279
+            return new WP_Error( 'no_package', $this->strings['no_package'] );
280
+        }
281
+
282
+        $this->skin->feedback( 'downloading_package', $package );
283
+
284
+        $download_file = download_url( $package, 300, $check_signatures );
285
+
286
+        if ( is_wp_error( $download_file ) && ! $download_file->get_error_data( 'softfail-filename' ) ) {
287
+            return new WP_Error( 'download_failed', $this->strings['download_failed'], $download_file->get_error_message() );
288
+        }
289
+
290
+        return $download_file;
291
+    }
292
+
293
+    /**
294
+     * Unpack a compressed package file.
295
+     *
296
+     * @since 2.8.0
297
+     *
298
+     * @global WP_Filesystem_Base $wp_filesystem WordPress filesystem subclass.
299
+     *
300
+     * @param string $package        Full path to the package file.
301
+     * @param bool   $delete_package Optional. Whether to delete the package file after attempting
302
+     *                               to unpack it. Default true.
303
+     * @return string|WP_Error The path to the unpacked contents, or a WP_Error on failure.
304
+     */
305
+    public function unpack_package( $package, $delete_package = true ) {
306
+        global $wp_filesystem;
307
+
308
+        $this->skin->feedback( 'unpack_package' );
309
+
310
+        $upgrade_folder = $wp_filesystem->wp_content_dir() . 'upgrade/';
311
+
312
+        // Clean up contents of upgrade directory beforehand.
313
+        $upgrade_files = $wp_filesystem->dirlist( $upgrade_folder );
314
+        if ( ! empty( $upgrade_files ) ) {
315
+            foreach ( $upgrade_files as $file ) {
316
+                $wp_filesystem->delete( $upgrade_folder . $file['name'], true );
317
+            }
318
+        }
319
+
320
+        // We need a working directory - strip off any .tmp or .zip suffixes.
321
+        $working_dir = $upgrade_folder . basename( basename( $package, '.tmp' ), '.zip' );
322
+
323
+        // Clean up working directory.
324
+        if ( $wp_filesystem->is_dir( $working_dir ) ) {
325
+            $wp_filesystem->delete( $working_dir, true );
326
+        }
327
+
328
+        // Unzip package to working directory.
329
+        $result = unzip_file( $package, $working_dir );
330
+
331
+        // Once extracted, delete the package if required.
332
+        if ( $delete_package ) {
333
+            unlink( $package );
334
+        }
335
+
336
+        if ( is_wp_error( $result ) ) {
337
+            $wp_filesystem->delete( $working_dir, true );
338
+            if ( 'incompatible_archive' === $result->get_error_code() ) {
339
+                return new WP_Error( 'incompatible_archive', $this->strings['incompatible_archive'], $result->get_error_data() );
340
+            }
341
+            return $result;
342
+        }
343
+
344
+        return $working_dir;
345
+    }
346
+
347
+    /**
348
+     * Flatten the results of WP_Filesystem_Base::dirlist() for iterating over.
349
+     *
350
+     * @since 4.9.0
351
+     * @access protected
352
+     *
353
+     * @param array  $nested_files Array of files as returned by WP_Filesystem_Base::dirlist().
354
+     * @param string $path         Relative path to prepend to child nodes. Optional.
355
+     * @return array A flattened array of the $nested_files specified.
356
+     */
357
+    protected function flatten_dirlist( $nested_files, $path = '' ) {
358
+        $files = array();
359
+
360
+        foreach ( $nested_files as $name => $details ) {
361
+            $files[ $path . $name ] = $details;
362
+
363
+            // Append children recursively.
364
+            if ( ! empty( $details['files'] ) ) {
365
+                $children = $this->flatten_dirlist( $details['files'], $path . $name . '/' );
366
+
367
+                // Merge keeping possible numeric keys, which array_merge() will reindex from 0..n.
368
+                $files = $files + $children;
369
+            }
370
+        }
371
+
372
+        return $files;
373
+    }
374
+
375
+    /**
376
+     * Clears the directory where this item is going to be installed into.
377
+     *
378
+     * @since 4.3.0
379
+     *
380
+     * @global WP_Filesystem_Base $wp_filesystem WordPress filesystem subclass.
381
+     *
382
+     * @param string $remote_destination The location on the remote filesystem to be cleared.
383
+     * @return true|WP_Error True upon success, WP_Error on failure.
384
+     */
385
+    public function clear_destination( $remote_destination ) {
386
+        global $wp_filesystem;
387
+
388
+        $files = $wp_filesystem->dirlist( $remote_destination, true, true );
389
+
390
+        // False indicates that the $remote_destination doesn't exist.
391
+        if ( false === $files ) {
392
+            return true;
393
+        }
394
+
395
+        // Flatten the file list to iterate over.
396
+        $files = $this->flatten_dirlist( $files );
397
+
398
+        // Check all files are writable before attempting to clear the destination.
399
+        $unwritable_files = array();
400
+
401
+        // Check writability.
402
+        foreach ( $files as $filename => $file_details ) {
403
+            if ( ! $wp_filesystem->is_writable( $remote_destination . $filename ) ) {
404
+                // Attempt to alter permissions to allow writes and try again.
405
+                $wp_filesystem->chmod( $remote_destination . $filename, ( 'd' === $file_details['type'] ? FS_CHMOD_DIR : FS_CHMOD_FILE ) );
406
+                if ( ! $wp_filesystem->is_writable( $remote_destination . $filename ) ) {
407
+                    $unwritable_files[] = $filename;
408
+                }
409
+            }
410
+        }
411
+
412
+        if ( ! empty( $unwritable_files ) ) {
413
+            return new WP_Error( 'files_not_writable', $this->strings['files_not_writable'], implode( ', ', $unwritable_files ) );
414
+        }
415
+
416
+        if ( ! $wp_filesystem->delete( $remote_destination, true ) ) {
417
+            return new WP_Error( 'remove_old_failed', $this->strings['remove_old_failed'] );
418
+        }
419
+
420
+        return true;
421
+    }
422
+
423
+    /**
424
+     * Install a package.
425
+     *
426
+     * Copies the contents of a package from a source directory, and installs them in
427
+     * a destination directory. Optionally removes the source. It can also optionally
428
+     * clear out the destination folder if it already exists.
429
+     *
430
+     * @since 2.8.0
431
+     *
432
+     * @global WP_Filesystem_Base $wp_filesystem        WordPress filesystem subclass.
433
+     * @global array              $wp_theme_directories
434
+     *
435
+     * @param array|string $args {
436
+     *     Optional. Array or string of arguments for installing a package. Default empty array.
437
+     *
438
+     *     @type string $source                      Required path to the package source. Default empty.
439
+     *     @type string $destination                 Required path to a folder to install the package in.
440
+     *                                               Default empty.
441
+     *     @type bool   $clear_destination           Whether to delete any files already in the destination
442
+     *                                               folder. Default false.
443
+     *     @type bool   $clear_working               Whether to delete the files from the working directory
444
+     *                                               after copying them to the destination. Default false.
445
+     *     @type bool   $abort_if_destination_exists Whether to abort the installation if
446
+     *                                               the destination folder already exists. Default true.
447
+     *     @type array  $hook_extra                  Extra arguments to pass to the filter hooks called by
448
+     *                                               WP_Upgrader::install_package(). Default empty array.
449
+     * }
450
+     *
451
+     * @return array|WP_Error The result (also stored in `WP_Upgrader::$result`), or a WP_Error on failure.
452
+     */
453
+    public function install_package( $args = array() ) {
454
+        global $wp_filesystem, $wp_theme_directories;
455
+
456
+        $defaults = array(
457
+            'source'                      => '', // Please always pass this.
458
+            'destination'                 => '', // ...and this.
459
+            'clear_destination'           => false,
460
+            'clear_working'               => false,
461
+            'abort_if_destination_exists' => true,
462
+            'hook_extra'                  => array(),
463
+        );
464
+
465
+        $args = wp_parse_args( $args, $defaults );
466
+
467
+        // These were previously extract()'d.
468
+        $source            = $args['source'];
469
+        $destination       = $args['destination'];
470
+        $clear_destination = $args['clear_destination'];
471
+
472
+        set_time_limit( 300 );
473
+
474
+        if ( empty( $source ) || empty( $destination ) ) {
475
+            return new WP_Error( 'bad_request', $this->strings['bad_request'] );
476
+        }
477
+        $this->skin->feedback( 'installing_package' );
478
+
479
+        /**
480
+         * Filters the installation response before the installation has started.
481
+         *
482
+         * Returning a value that could be evaluated as a `WP_Error` will effectively
483
+         * short-circuit the installation, returning that value instead.
484
+         *
485
+         * @since 2.8.0
486
+         *
487
+         * @param bool|WP_Error $response   Installation response.
488
+         * @param array         $hook_extra Extra arguments passed to hooked filters.
489
+         */
490
+        $res = apply_filters( 'upgrader_pre_install', true, $args['hook_extra'] );
491
+
492
+        if ( is_wp_error( $res ) ) {
493
+            return $res;
494
+        }
495
+
496
+        // Retain the original source and destinations.
497
+        $remote_source     = $args['source'];
498
+        $local_destination = $destination;
499
+
500
+        $source_files       = array_keys( $wp_filesystem->dirlist( $remote_source ) );
501
+        $remote_destination = $wp_filesystem->find_folder( $local_destination );
502
+
503
+        // Locate which directory to copy to the new folder. This is based on the actual folder holding the files.
504
+        if ( 1 === count( $source_files ) && $wp_filesystem->is_dir( trailingslashit( $args['source'] ) . $source_files[0] . '/' ) ) {
505
+            // Only one folder? Then we want its contents.
506
+            $source = trailingslashit( $args['source'] ) . trailingslashit( $source_files[0] );
507
+        } elseif ( 0 === count( $source_files ) ) {
508
+            // There are no files?
509
+            return new WP_Error( 'incompatible_archive_empty', $this->strings['incompatible_archive'], $this->strings['no_files'] );
510
+        } else {
511
+            // It's only a single file, the upgrader will use the folder name of this file as the destination folder.
512
+            // Folder name is based on zip filename.
513
+            $source = trailingslashit( $args['source'] );
514
+        }
515
+
516
+        /**
517
+         * Filters the source file location for the upgrade package.
518
+         *
519
+         * @since 2.8.0
520
+         * @since 4.4.0 The $hook_extra parameter became available.
521
+         *
522
+         * @param string      $source        File source location.
523
+         * @param string      $remote_source Remote file source location.
524
+         * @param WP_Upgrader $upgrader      WP_Upgrader instance.
525
+         * @param array       $hook_extra    Extra arguments passed to hooked filters.
526
+         */
527
+        $source = apply_filters( 'upgrader_source_selection', $source, $remote_source, $this, $args['hook_extra'] );
528
+
529
+        if ( is_wp_error( $source ) ) {
530
+            return $source;
531
+        }
532
+
533
+        // Has the source location changed? If so, we need a new source_files list.
534
+        if ( $source !== $remote_source ) {
535
+            $source_files = array_keys( $wp_filesystem->dirlist( $source ) );
536
+        }
537
+
538
+        /*
539 539
 		 * Protection against deleting files in any important base directories.
540 540
 		 * Theme_Upgrader & Plugin_Upgrader also trigger this, as they pass the
541 541
 		 * destination directory (WP_PLUGIN_DIR / wp-content/themes) intending
542 542
 		 * to copy the directory into the directory, whilst they pass the source
543 543
 		 * as the actual files to copy.
544 544
 		 */
545
-		$protected_directories = array( ABSPATH, WP_CONTENT_DIR, WP_PLUGIN_DIR, WP_CONTENT_DIR . '/themes' );
546
-
547
-		if ( is_array( $wp_theme_directories ) ) {
548
-			$protected_directories = array_merge( $protected_directories, $wp_theme_directories );
549
-		}
550
-
551
-		if ( in_array( $destination, $protected_directories, true ) ) {
552
-			$remote_destination = trailingslashit( $remote_destination ) . trailingslashit( basename( $source ) );
553
-			$destination        = trailingslashit( $destination ) . trailingslashit( basename( $source ) );
554
-		}
555
-
556
-		if ( $clear_destination ) {
557
-			// We're going to clear the destination if there's something there.
558
-			$this->skin->feedback( 'remove_old' );
559
-
560
-			$removed = $this->clear_destination( $remote_destination );
561
-
562
-			/**
563
-			 * Filters whether the upgrader cleared the destination.
564
-			 *
565
-			 * @since 2.8.0
566
-			 *
567
-			 * @param true|WP_Error $removed            Whether the destination was cleared.
568
-			 *                                          True upon success, WP_Error on failure.
569
-			 * @param string        $local_destination  The local package destination.
570
-			 * @param string        $remote_destination The remote package destination.
571
-			 * @param array         $hook_extra         Extra arguments passed to hooked filters.
572
-			 */
573
-			$removed = apply_filters( 'upgrader_clear_destination', $removed, $local_destination, $remote_destination, $args['hook_extra'] );
574
-
575
-			if ( is_wp_error( $removed ) ) {
576
-				return $removed;
577
-			}
578
-		} elseif ( $args['abort_if_destination_exists'] && $wp_filesystem->exists( $remote_destination ) ) {
579
-			// If we're not clearing the destination folder and something exists there already, bail.
580
-			// But first check to see if there are actually any files in the folder.
581
-			$_files = $wp_filesystem->dirlist( $remote_destination );
582
-			if ( ! empty( $_files ) ) {
583
-				$wp_filesystem->delete( $remote_source, true ); // Clear out the source files.
584
-				return new WP_Error( 'folder_exists', $this->strings['folder_exists'], $remote_destination );
585
-			}
586
-		}
587
-
588
-		// Create destination if needed.
589
-		if ( ! $wp_filesystem->exists( $remote_destination ) ) {
590
-			if ( ! $wp_filesystem->mkdir( $remote_destination, FS_CHMOD_DIR ) ) {
591
-				return new WP_Error( 'mkdir_failed_destination', $this->strings['mkdir_failed'], $remote_destination );
592
-			}
593
-		}
594
-
595
-		// Copy new version of item into place.
596
-		$result = copy_dir( $source, $remote_destination );
597
-		if ( is_wp_error( $result ) ) {
598
-			if ( $args['clear_working'] ) {
599
-				$wp_filesystem->delete( $remote_source, true );
600
-			}
601
-			return $result;
602
-		}
603
-
604
-		// Clear the working folder?
605
-		if ( $args['clear_working'] ) {
606
-			$wp_filesystem->delete( $remote_source, true );
607
-		}
608
-
609
-		$destination_name = basename( str_replace( $local_destination, '', $destination ) );
610
-		if ( '.' === $destination_name ) {
611
-			$destination_name = '';
612
-		}
613
-
614
-		$this->result = compact( 'source', 'source_files', 'destination', 'destination_name', 'local_destination', 'remote_destination', 'clear_destination' );
615
-
616
-		/**
617
-		 * Filters the installation response after the installation has finished.
618
-		 *
619
-		 * @since 2.8.0
620
-		 *
621
-		 * @param bool  $response   Installation response.
622
-		 * @param array $hook_extra Extra arguments passed to hooked filters.
623
-		 * @param array $result     Installation result data.
624
-		 */
625
-		$res = apply_filters( 'upgrader_post_install', true, $args['hook_extra'], $this->result );
626
-
627
-		if ( is_wp_error( $res ) ) {
628
-			$this->result = $res;
629
-			return $res;
630
-		}
631
-
632
-		// Bombard the calling function will all the info which we've just used.
633
-		return $this->result;
634
-	}
635
-
636
-	/**
637
-	 * Run an upgrade/installation.
638
-	 *
639
-	 * Attempts to download the package (if it is not a local file), unpack it, and
640
-	 * install it in the destination folder.
641
-	 *
642
-	 * @since 2.8.0
643
-	 *
644
-	 * @param array $options {
645
-	 *     Array or string of arguments for upgrading/installing a package.
646
-	 *
647
-	 *     @type string $package                     The full path or URI of the package to install.
648
-	 *                                               Default empty.
649
-	 *     @type string $destination                 The full path to the destination folder.
650
-	 *                                               Default empty.
651
-	 *     @type bool   $clear_destination           Whether to delete any files already in the
652
-	 *                                               destination folder. Default false.
653
-	 *     @type bool   $clear_working               Whether to delete the files from the working
654
-	 *                                               directory after copying them to the destination.
655
-	 *                                               Default true.
656
-	 *     @type bool   $abort_if_destination_exists Whether to abort the installation if the destination
657
-	 *                                               folder already exists. When true, `$clear_destination`
658
-	 *                                               should be false. Default true.
659
-	 *     @type bool   $is_multi                    Whether this run is one of multiple upgrade/installation
660
-	 *                                               actions being performed in bulk. When true, the skin
661
-	 *                                               WP_Upgrader::header() and WP_Upgrader::footer()
662
-	 *                                               aren't called. Default false.
663
-	 *     @type array  $hook_extra                  Extra arguments to pass to the filter hooks called by
664
-	 *                                               WP_Upgrader::run().
665
-	 * }
666
-	 * @return array|false|WP_Error The result from self::install_package() on success, otherwise a WP_Error,
667
-	 *                              or false if unable to connect to the filesystem.
668
-	 */
669
-	public function run( $options ) {
670
-
671
-		$defaults = array(
672
-			'package'                     => '', // Please always pass this.
673
-			'destination'                 => '', // ...and this.
674
-			'clear_destination'           => false,
675
-			'clear_working'               => true,
676
-			'abort_if_destination_exists' => true, // Abort if the destination directory exists. Pass clear_destination as false please.
677
-			'is_multi'                    => false,
678
-			'hook_extra'                  => array(), // Pass any extra $hook_extra args here, this will be passed to any hooked filters.
679
-		);
680
-
681
-		$options = wp_parse_args( $options, $defaults );
682
-
683
-		/**
684
-		 * Filters the package options before running an update.
685
-		 *
686
-		 * See also {@see 'upgrader_process_complete'}.
687
-		 *
688
-		 * @since 4.3.0
689
-		 *
690
-		 * @param array $options {
691
-		 *     Options used by the upgrader.
692
-		 *
693
-		 *     @type string $package                     Package for update.
694
-		 *     @type string $destination                 Update location.
695
-		 *     @type bool   $clear_destination           Clear the destination resource.
696
-		 *     @type bool   $clear_working               Clear the working resource.
697
-		 *     @type bool   $abort_if_destination_exists Abort if the Destination directory exists.
698
-		 *     @type bool   $is_multi                    Whether the upgrader is running multiple times.
699
-		 *     @type array  $hook_extra {
700
-		 *         Extra hook arguments.
701
-		 *
702
-		 *         @type string $action               Type of action. Default 'update'.
703
-		 *         @type string $type                 Type of update process. Accepts 'plugin', 'theme', or 'core'.
704
-		 *         @type bool   $bulk                 Whether the update process is a bulk update. Default true.
705
-		 *         @type string $plugin               Path to the plugin file relative to the plugins directory.
706
-		 *         @type string $theme                The stylesheet or template name of the theme.
707
-		 *         @type string $language_update_type The language pack update type. Accepts 'plugin', 'theme',
708
-		 *                                            or 'core'.
709
-		 *         @type object $language_update      The language pack update offer.
710
-		 *     }
711
-		 * }
712
-		 */
713
-		$options = apply_filters( 'upgrader_package_options', $options );
714
-
715
-		if ( ! $options['is_multi'] ) { // Call $this->header separately if running multiple times.
716
-			$this->skin->header();
717
-		}
718
-
719
-		// Connect to the filesystem first.
720
-		$res = $this->fs_connect( array( WP_CONTENT_DIR, $options['destination'] ) );
721
-		// Mainly for non-connected filesystem.
722
-		if ( ! $res ) {
723
-			if ( ! $options['is_multi'] ) {
724
-				$this->skin->footer();
725
-			}
726
-			return false;
727
-		}
728
-
729
-		$this->skin->before();
730
-
731
-		if ( is_wp_error( $res ) ) {
732
-			$this->skin->error( $res );
733
-			$this->skin->after();
734
-			if ( ! $options['is_multi'] ) {
735
-				$this->skin->footer();
736
-			}
737
-			return $res;
738
-		}
739
-
740
-		/*
545
+        $protected_directories = array( ABSPATH, WP_CONTENT_DIR, WP_PLUGIN_DIR, WP_CONTENT_DIR . '/themes' );
546
+
547
+        if ( is_array( $wp_theme_directories ) ) {
548
+            $protected_directories = array_merge( $protected_directories, $wp_theme_directories );
549
+        }
550
+
551
+        if ( in_array( $destination, $protected_directories, true ) ) {
552
+            $remote_destination = trailingslashit( $remote_destination ) . trailingslashit( basename( $source ) );
553
+            $destination        = trailingslashit( $destination ) . trailingslashit( basename( $source ) );
554
+        }
555
+
556
+        if ( $clear_destination ) {
557
+            // We're going to clear the destination if there's something there.
558
+            $this->skin->feedback( 'remove_old' );
559
+
560
+            $removed = $this->clear_destination( $remote_destination );
561
+
562
+            /**
563
+             * Filters whether the upgrader cleared the destination.
564
+             *
565
+             * @since 2.8.0
566
+             *
567
+             * @param true|WP_Error $removed            Whether the destination was cleared.
568
+             *                                          True upon success, WP_Error on failure.
569
+             * @param string        $local_destination  The local package destination.
570
+             * @param string        $remote_destination The remote package destination.
571
+             * @param array         $hook_extra         Extra arguments passed to hooked filters.
572
+             */
573
+            $removed = apply_filters( 'upgrader_clear_destination', $removed, $local_destination, $remote_destination, $args['hook_extra'] );
574
+
575
+            if ( is_wp_error( $removed ) ) {
576
+                return $removed;
577
+            }
578
+        } elseif ( $args['abort_if_destination_exists'] && $wp_filesystem->exists( $remote_destination ) ) {
579
+            // If we're not clearing the destination folder and something exists there already, bail.
580
+            // But first check to see if there are actually any files in the folder.
581
+            $_files = $wp_filesystem->dirlist( $remote_destination );
582
+            if ( ! empty( $_files ) ) {
583
+                $wp_filesystem->delete( $remote_source, true ); // Clear out the source files.
584
+                return new WP_Error( 'folder_exists', $this->strings['folder_exists'], $remote_destination );
585
+            }
586
+        }
587
+
588
+        // Create destination if needed.
589
+        if ( ! $wp_filesystem->exists( $remote_destination ) ) {
590
+            if ( ! $wp_filesystem->mkdir( $remote_destination, FS_CHMOD_DIR ) ) {
591
+                return new WP_Error( 'mkdir_failed_destination', $this->strings['mkdir_failed'], $remote_destination );
592
+            }
593
+        }
594
+
595
+        // Copy new version of item into place.
596
+        $result = copy_dir( $source, $remote_destination );
597
+        if ( is_wp_error( $result ) ) {
598
+            if ( $args['clear_working'] ) {
599
+                $wp_filesystem->delete( $remote_source, true );
600
+            }
601
+            return $result;
602
+        }
603
+
604
+        // Clear the working folder?
605
+        if ( $args['clear_working'] ) {
606
+            $wp_filesystem->delete( $remote_source, true );
607
+        }
608
+
609
+        $destination_name = basename( str_replace( $local_destination, '', $destination ) );
610
+        if ( '.' === $destination_name ) {
611
+            $destination_name = '';
612
+        }
613
+
614
+        $this->result = compact( 'source', 'source_files', 'destination', 'destination_name', 'local_destination', 'remote_destination', 'clear_destination' );
615
+
616
+        /**
617
+         * Filters the installation response after the installation has finished.
618
+         *
619
+         * @since 2.8.0
620
+         *
621
+         * @param bool  $response   Installation response.
622
+         * @param array $hook_extra Extra arguments passed to hooked filters.
623
+         * @param array $result     Installation result data.
624
+         */
625
+        $res = apply_filters( 'upgrader_post_install', true, $args['hook_extra'], $this->result );
626
+
627
+        if ( is_wp_error( $res ) ) {
628
+            $this->result = $res;
629
+            return $res;
630
+        }
631
+
632
+        // Bombard the calling function will all the info which we've just used.
633
+        return $this->result;
634
+    }
635
+
636
+    /**
637
+     * Run an upgrade/installation.
638
+     *
639
+     * Attempts to download the package (if it is not a local file), unpack it, and
640
+     * install it in the destination folder.
641
+     *
642
+     * @since 2.8.0
643
+     *
644
+     * @param array $options {
645
+     *     Array or string of arguments for upgrading/installing a package.
646
+     *
647
+     *     @type string $package                     The full path or URI of the package to install.
648
+     *                                               Default empty.
649
+     *     @type string $destination                 The full path to the destination folder.
650
+     *                                               Default empty.
651
+     *     @type bool   $clear_destination           Whether to delete any files already in the
652
+     *                                               destination folder. Default false.
653
+     *     @type bool   $clear_working               Whether to delete the files from the working
654
+     *                                               directory after copying them to the destination.
655
+     *                                               Default true.
656
+     *     @type bool   $abort_if_destination_exists Whether to abort the installation if the destination
657
+     *                                               folder already exists. When true, `$clear_destination`
658
+     *                                               should be false. Default true.
659
+     *     @type bool   $is_multi                    Whether this run is one of multiple upgrade/installation
660
+     *                                               actions being performed in bulk. When true, the skin
661
+     *                                               WP_Upgrader::header() and WP_Upgrader::footer()
662
+     *                                               aren't called. Default false.
663
+     *     @type array  $hook_extra                  Extra arguments to pass to the filter hooks called by
664
+     *                                               WP_Upgrader::run().
665
+     * }
666
+     * @return array|false|WP_Error The result from self::install_package() on success, otherwise a WP_Error,
667
+     *                              or false if unable to connect to the filesystem.
668
+     */
669
+    public function run( $options ) {
670
+
671
+        $defaults = array(
672
+            'package'                     => '', // Please always pass this.
673
+            'destination'                 => '', // ...and this.
674
+            'clear_destination'           => false,
675
+            'clear_working'               => true,
676
+            'abort_if_destination_exists' => true, // Abort if the destination directory exists. Pass clear_destination as false please.
677
+            'is_multi'                    => false,
678
+            'hook_extra'                  => array(), // Pass any extra $hook_extra args here, this will be passed to any hooked filters.
679
+        );
680
+
681
+        $options = wp_parse_args( $options, $defaults );
682
+
683
+        /**
684
+         * Filters the package options before running an update.
685
+         *
686
+         * See also {@see 'upgrader_process_complete'}.
687
+         *
688
+         * @since 4.3.0
689
+         *
690
+         * @param array $options {
691
+         *     Options used by the upgrader.
692
+         *
693
+         *     @type string $package                     Package for update.
694
+         *     @type string $destination                 Update location.
695
+         *     @type bool   $clear_destination           Clear the destination resource.
696
+         *     @type bool   $clear_working               Clear the working resource.
697
+         *     @type bool   $abort_if_destination_exists Abort if the Destination directory exists.
698
+         *     @type bool   $is_multi                    Whether the upgrader is running multiple times.
699
+         *     @type array  $hook_extra {
700
+         *         Extra hook arguments.
701
+         *
702
+         *         @type string $action               Type of action. Default 'update'.
703
+         *         @type string $type                 Type of update process. Accepts 'plugin', 'theme', or 'core'.
704
+         *         @type bool   $bulk                 Whether the update process is a bulk update. Default true.
705
+         *         @type string $plugin               Path to the plugin file relative to the plugins directory.
706
+         *         @type string $theme                The stylesheet or template name of the theme.
707
+         *         @type string $language_update_type The language pack update type. Accepts 'plugin', 'theme',
708
+         *                                            or 'core'.
709
+         *         @type object $language_update      The language pack update offer.
710
+         *     }
711
+         * }
712
+         */
713
+        $options = apply_filters( 'upgrader_package_options', $options );
714
+
715
+        if ( ! $options['is_multi'] ) { // Call $this->header separately if running multiple times.
716
+            $this->skin->header();
717
+        }
718
+
719
+        // Connect to the filesystem first.
720
+        $res = $this->fs_connect( array( WP_CONTENT_DIR, $options['destination'] ) );
721
+        // Mainly for non-connected filesystem.
722
+        if ( ! $res ) {
723
+            if ( ! $options['is_multi'] ) {
724
+                $this->skin->footer();
725
+            }
726
+            return false;
727
+        }
728
+
729
+        $this->skin->before();
730
+
731
+        if ( is_wp_error( $res ) ) {
732
+            $this->skin->error( $res );
733
+            $this->skin->after();
734
+            if ( ! $options['is_multi'] ) {
735
+                $this->skin->footer();
736
+            }
737
+            return $res;
738
+        }
739
+
740
+        /*
741 741
 		 * Download the package. Note: If the package is the full path
742 742
 		 * to an existing local file, it will be returned untouched.
743 743
 		 */
744
-		$download = $this->download_package( $options['package'], true, $options['hook_extra'] );
745
-
746
-		// Allow for signature soft-fail.
747
-		// WARNING: This may be removed in the future.
748
-		if ( is_wp_error( $download ) && $download->get_error_data( 'softfail-filename' ) ) {
749
-
750
-			// Don't output the 'no signature could be found' failure message for now.
751
-			if ( 'signature_verification_no_signature' !== $download->get_error_code() || WP_DEBUG ) {
752
-				// Output the failure error as a normal feedback, and not as an error.
753
-				$this->skin->feedback( $download->get_error_message() );
754
-
755
-				// Report this failure back to WordPress.org for debugging purposes.
756
-				wp_version_check(
757
-					array(
758
-						'signature_failure_code' => $download->get_error_code(),
759
-						'signature_failure_data' => $download->get_error_data(),
760
-					)
761
-				);
762
-			}
763
-
764
-			// Pretend this error didn't happen.
765
-			$download = $download->get_error_data( 'softfail-filename' );
766
-		}
767
-
768
-		if ( is_wp_error( $download ) ) {
769
-			$this->skin->error( $download );
770
-			$this->skin->after();
771
-			if ( ! $options['is_multi'] ) {
772
-				$this->skin->footer();
773
-			}
774
-			return $download;
775
-		}
776
-
777
-		$delete_package = ( $download !== $options['package'] ); // Do not delete a "local" file.
778
-
779
-		// Unzips the file into a temporary directory.
780
-		$working_dir = $this->unpack_package( $download, $delete_package );
781
-		if ( is_wp_error( $working_dir ) ) {
782
-			$this->skin->error( $working_dir );
783
-			$this->skin->after();
784
-			if ( ! $options['is_multi'] ) {
785
-				$this->skin->footer();
786
-			}
787
-			return $working_dir;
788
-		}
789
-
790
-		// With the given options, this installs it to the destination directory.
791
-		$result = $this->install_package(
792
-			array(
793
-				'source'                      => $working_dir,
794
-				'destination'                 => $options['destination'],
795
-				'clear_destination'           => $options['clear_destination'],
796
-				'abort_if_destination_exists' => $options['abort_if_destination_exists'],
797
-				'clear_working'               => $options['clear_working'],
798
-				'hook_extra'                  => $options['hook_extra'],
799
-			)
800
-		);
801
-
802
-		/**
803
-		 * Filters the result of WP_Upgrader::install_package().
804
-		 *
805
-		 * @since 5.7.0
806
-		 *
807
-		 * @param array|WP_Error $result     Result from WP_Upgrader::install_package().
808
-		 * @param array          $hook_extra Extra arguments passed to hooked filters.
809
-		 */
810
-		$result = apply_filters( 'upgrader_install_package_result', $result, $options['hook_extra'] );
811
-
812
-		$this->skin->set_result( $result );
813
-		if ( is_wp_error( $result ) ) {
814
-			$this->skin->error( $result );
815
-
816
-			if ( ! method_exists( $this->skin, 'hide_process_failed' ) || ! $this->skin->hide_process_failed( $result ) ) {
817
-				$this->skin->feedback( 'process_failed' );
818
-			}
819
-		} else {
820
-			// Installation succeeded.
821
-			$this->skin->feedback( 'process_success' );
822
-		}
823
-
824
-		$this->skin->after();
825
-
826
-		if ( ! $options['is_multi'] ) {
827
-
828
-			/**
829
-			 * Fires when the upgrader process is complete.
830
-			 *
831
-			 * See also {@see 'upgrader_package_options'}.
832
-			 *
833
-			 * @since 3.6.0
834
-			 * @since 3.7.0 Added to WP_Upgrader::run().
835
-			 * @since 4.6.0 `$translations` was added as a possible argument to `$hook_extra`.
836
-			 *
837
-			 * @param WP_Upgrader $upgrader   WP_Upgrader instance. In other contexts this might be a
838
-			 *                                Theme_Upgrader, Plugin_Upgrader, Core_Upgrade, or Language_Pack_Upgrader instance.
839
-			 * @param array       $hook_extra {
840
-			 *     Array of bulk item update data.
841
-			 *
842
-			 *     @type string $action       Type of action. Default 'update'.
843
-			 *     @type string $type         Type of update process. Accepts 'plugin', 'theme', 'translation', or 'core'.
844
-			 *     @type bool   $bulk         Whether the update process is a bulk update. Default true.
845
-			 *     @type array  $plugins      Array of the basename paths of the plugins' main files.
846
-			 *     @type array  $themes       The theme slugs.
847
-			 *     @type array  $translations {
848
-			 *         Array of translations update data.
849
-			 *
850
-			 *         @type string $language The locale the translation is for.
851
-			 *         @type string $type     Type of translation. Accepts 'plugin', 'theme', or 'core'.
852
-			 *         @type string $slug     Text domain the translation is for. The slug of a theme/plugin or
853
-			 *                                'default' for core translations.
854
-			 *         @type string $version  The version of a theme, plugin, or core.
855
-			 *     }
856
-			 * }
857
-			 */
858
-			do_action( 'upgrader_process_complete', $this, $options['hook_extra'] );
859
-
860
-			$this->skin->footer();
861
-		}
862
-
863
-		return $result;
864
-	}
865
-
866
-	/**
867
-	 * Toggle maintenance mode for the site.
868
-	 *
869
-	 * Creates/deletes the maintenance file to enable/disable maintenance mode.
870
-	 *
871
-	 * @since 2.8.0
872
-	 *
873
-	 * @global WP_Filesystem_Base $wp_filesystem WordPress filesystem subclass.
874
-	 *
875
-	 * @param bool $enable True to enable maintenance mode, false to disable.
876
-	 */
877
-	public function maintenance_mode( $enable = false ) {
878
-		global $wp_filesystem;
879
-		$file = $wp_filesystem->abspath() . '.maintenance';
880
-		if ( $enable ) {
881
-			$this->skin->feedback( 'maintenance_start' );
882
-			// Create maintenance file to signal that we are upgrading.
883
-			$maintenance_string = '<?php $upgrading = ' . time() . '; ?>';
884
-			$wp_filesystem->delete( $file );
885
-			$wp_filesystem->put_contents( $file, $maintenance_string, FS_CHMOD_FILE );
886
-		} elseif ( ! $enable && $wp_filesystem->exists( $file ) ) {
887
-			$this->skin->feedback( 'maintenance_end' );
888
-			$wp_filesystem->delete( $file );
889
-		}
890
-	}
891
-
892
-	/**
893
-	 * Creates a lock using WordPress options.
894
-	 *
895
-	 * @since 4.5.0
896
-	 *
897
-	 * @param string $lock_name       The name of this unique lock.
898
-	 * @param int    $release_timeout Optional. The duration in seconds to respect an existing lock.
899
-	 *                                Default: 1 hour.
900
-	 * @return bool False if a lock couldn't be created or if the lock is still valid. True otherwise.
901
-	 */
902
-	public static function create_lock( $lock_name, $release_timeout = null ) {
903
-		global $wpdb;
904
-		if ( ! $release_timeout ) {
905
-			$release_timeout = HOUR_IN_SECONDS;
906
-		}
907
-		$lock_option = $lock_name . '.lock';
908
-
909
-		// Try to lock.
910
-		$lock_result = $wpdb->query( $wpdb->prepare( "INSERT IGNORE INTO `$wpdb->options` ( `option_name`, `option_value`, `autoload` ) VALUES (%s, %s, 'no') /* LOCK */", $lock_option, time() ) );
911
-
912
-		if ( ! $lock_result ) {
913
-			$lock_result = get_option( $lock_option );
914
-
915
-			// If a lock couldn't be created, and there isn't a lock, bail.
916
-			if ( ! $lock_result ) {
917
-				return false;
918
-			}
919
-
920
-			// Check to see if the lock is still valid. If it is, bail.
921
-			if ( $lock_result > ( time() - $release_timeout ) ) {
922
-				return false;
923
-			}
924
-
925
-			// There must exist an expired lock, clear it and re-gain it.
926
-			WP_Upgrader::release_lock( $lock_name );
927
-
928
-			return WP_Upgrader::create_lock( $lock_name, $release_timeout );
929
-		}
930
-
931
-		// Update the lock, as by this point we've definitely got a lock, just need to fire the actions.
932
-		update_option( $lock_option, time() );
933
-
934
-		return true;
935
-	}
936
-
937
-	/**
938
-	 * Releases an upgrader lock.
939
-	 *
940
-	 * @since 4.5.0
941
-	 *
942
-	 * @see WP_Upgrader::create_lock()
943
-	 *
944
-	 * @param string $lock_name The name of this unique lock.
945
-	 * @return bool True if the lock was successfully released. False on failure.
946
-	 */
947
-	public static function release_lock( $lock_name ) {
948
-		return delete_option( $lock_name . '.lock' );
949
-	}
744
+        $download = $this->download_package( $options['package'], true, $options['hook_extra'] );
745
+
746
+        // Allow for signature soft-fail.
747
+        // WARNING: This may be removed in the future.
748
+        if ( is_wp_error( $download ) && $download->get_error_data( 'softfail-filename' ) ) {
749
+
750
+            // Don't output the 'no signature could be found' failure message for now.
751
+            if ( 'signature_verification_no_signature' !== $download->get_error_code() || WP_DEBUG ) {
752
+                // Output the failure error as a normal feedback, and not as an error.
753
+                $this->skin->feedback( $download->get_error_message() );
754
+
755
+                // Report this failure back to WordPress.org for debugging purposes.
756
+                wp_version_check(
757
+                    array(
758
+                        'signature_failure_code' => $download->get_error_code(),
759
+                        'signature_failure_data' => $download->get_error_data(),
760
+                    )
761
+                );
762
+            }
763
+
764
+            // Pretend this error didn't happen.
765
+            $download = $download->get_error_data( 'softfail-filename' );
766
+        }
767
+
768
+        if ( is_wp_error( $download ) ) {
769
+            $this->skin->error( $download );
770
+            $this->skin->after();
771
+            if ( ! $options['is_multi'] ) {
772
+                $this->skin->footer();
773
+            }
774
+            return $download;
775
+        }
776
+
777
+        $delete_package = ( $download !== $options['package'] ); // Do not delete a "local" file.
778
+
779
+        // Unzips the file into a temporary directory.
780
+        $working_dir = $this->unpack_package( $download, $delete_package );
781
+        if ( is_wp_error( $working_dir ) ) {
782
+            $this->skin->error( $working_dir );
783
+            $this->skin->after();
784
+            if ( ! $options['is_multi'] ) {
785
+                $this->skin->footer();
786
+            }
787
+            return $working_dir;
788
+        }
789
+
790
+        // With the given options, this installs it to the destination directory.
791
+        $result = $this->install_package(
792
+            array(
793
+                'source'                      => $working_dir,
794
+                'destination'                 => $options['destination'],
795
+                'clear_destination'           => $options['clear_destination'],
796
+                'abort_if_destination_exists' => $options['abort_if_destination_exists'],
797
+                'clear_working'               => $options['clear_working'],
798
+                'hook_extra'                  => $options['hook_extra'],
799
+            )
800
+        );
801
+
802
+        /**
803
+         * Filters the result of WP_Upgrader::install_package().
804
+         *
805
+         * @since 5.7.0
806
+         *
807
+         * @param array|WP_Error $result     Result from WP_Upgrader::install_package().
808
+         * @param array          $hook_extra Extra arguments passed to hooked filters.
809
+         */
810
+        $result = apply_filters( 'upgrader_install_package_result', $result, $options['hook_extra'] );
811
+
812
+        $this->skin->set_result( $result );
813
+        if ( is_wp_error( $result ) ) {
814
+            $this->skin->error( $result );
815
+
816
+            if ( ! method_exists( $this->skin, 'hide_process_failed' ) || ! $this->skin->hide_process_failed( $result ) ) {
817
+                $this->skin->feedback( 'process_failed' );
818
+            }
819
+        } else {
820
+            // Installation succeeded.
821
+            $this->skin->feedback( 'process_success' );
822
+        }
823
+
824
+        $this->skin->after();
825
+
826
+        if ( ! $options['is_multi'] ) {
827
+
828
+            /**
829
+             * Fires when the upgrader process is complete.
830
+             *
831
+             * See also {@see 'upgrader_package_options'}.
832
+             *
833
+             * @since 3.6.0
834
+             * @since 3.7.0 Added to WP_Upgrader::run().
835
+             * @since 4.6.0 `$translations` was added as a possible argument to `$hook_extra`.
836
+             *
837
+             * @param WP_Upgrader $upgrader   WP_Upgrader instance. In other contexts this might be a
838
+             *                                Theme_Upgrader, Plugin_Upgrader, Core_Upgrade, or Language_Pack_Upgrader instance.
839
+             * @param array       $hook_extra {
840
+             *     Array of bulk item update data.
841
+             *
842
+             *     @type string $action       Type of action. Default 'update'.
843
+             *     @type string $type         Type of update process. Accepts 'plugin', 'theme', 'translation', or 'core'.
844
+             *     @type bool   $bulk         Whether the update process is a bulk update. Default true.
845
+             *     @type array  $plugins      Array of the basename paths of the plugins' main files.
846
+             *     @type array  $themes       The theme slugs.
847
+             *     @type array  $translations {
848
+             *         Array of translations update data.
849
+             *
850
+             *         @type string $language The locale the translation is for.
851
+             *         @type string $type     Type of translation. Accepts 'plugin', 'theme', or 'core'.
852
+             *         @type string $slug     Text domain the translation is for. The slug of a theme/plugin or
853
+             *                                'default' for core translations.
854
+             *         @type string $version  The version of a theme, plugin, or core.
855
+             *     }
856
+             * }
857
+             */
858
+            do_action( 'upgrader_process_complete', $this, $options['hook_extra'] );
859
+
860
+            $this->skin->footer();
861
+        }
862
+
863
+        return $result;
864
+    }
865
+
866
+    /**
867
+     * Toggle maintenance mode for the site.
868
+     *
869
+     * Creates/deletes the maintenance file to enable/disable maintenance mode.
870
+     *
871
+     * @since 2.8.0
872
+     *
873
+     * @global WP_Filesystem_Base $wp_filesystem WordPress filesystem subclass.
874
+     *
875
+     * @param bool $enable True to enable maintenance mode, false to disable.
876
+     */
877
+    public function maintenance_mode( $enable = false ) {
878
+        global $wp_filesystem;
879
+        $file = $wp_filesystem->abspath() . '.maintenance';
880
+        if ( $enable ) {
881
+            $this->skin->feedback( 'maintenance_start' );
882
+            // Create maintenance file to signal that we are upgrading.
883
+            $maintenance_string = '<?php $upgrading = ' . time() . '; ?>';
884
+            $wp_filesystem->delete( $file );
885
+            $wp_filesystem->put_contents( $file, $maintenance_string, FS_CHMOD_FILE );
886
+        } elseif ( ! $enable && $wp_filesystem->exists( $file ) ) {
887
+            $this->skin->feedback( 'maintenance_end' );
888
+            $wp_filesystem->delete( $file );
889
+        }
890
+    }
891
+
892
+    /**
893
+     * Creates a lock using WordPress options.
894
+     *
895
+     * @since 4.5.0
896
+     *
897
+     * @param string $lock_name       The name of this unique lock.
898
+     * @param int    $release_timeout Optional. The duration in seconds to respect an existing lock.
899
+     *                                Default: 1 hour.
900
+     * @return bool False if a lock couldn't be created or if the lock is still valid. True otherwise.
901
+     */
902
+    public static function create_lock( $lock_name, $release_timeout = null ) {
903
+        global $wpdb;
904
+        if ( ! $release_timeout ) {
905
+            $release_timeout = HOUR_IN_SECONDS;
906
+        }
907
+        $lock_option = $lock_name . '.lock';
908
+
909
+        // Try to lock.
910
+        $lock_result = $wpdb->query( $wpdb->prepare( "INSERT IGNORE INTO `$wpdb->options` ( `option_name`, `option_value`, `autoload` ) VALUES (%s, %s, 'no') /* LOCK */", $lock_option, time() ) );
911
+
912
+        if ( ! $lock_result ) {
913
+            $lock_result = get_option( $lock_option );
914
+
915
+            // If a lock couldn't be created, and there isn't a lock, bail.
916
+            if ( ! $lock_result ) {
917
+                return false;
918
+            }
919
+
920
+            // Check to see if the lock is still valid. If it is, bail.
921
+            if ( $lock_result > ( time() - $release_timeout ) ) {
922
+                return false;
923
+            }
924
+
925
+            // There must exist an expired lock, clear it and re-gain it.
926
+            WP_Upgrader::release_lock( $lock_name );
927
+
928
+            return WP_Upgrader::create_lock( $lock_name, $release_timeout );
929
+        }
930
+
931
+        // Update the lock, as by this point we've definitely got a lock, just need to fire the actions.
932
+        update_option( $lock_option, time() );
933
+
934
+        return true;
935
+    }
936
+
937
+    /**
938
+     * Releases an upgrader lock.
939
+     *
940
+     * @since 4.5.0
941
+     *
942
+     * @see WP_Upgrader::create_lock()
943
+     *
944
+     * @param string $lock_name The name of this unique lock.
945
+     * @return bool True if the lock was successfully released. False on failure.
946
+     */
947
+    public static function release_lock( $lock_name ) {
948
+        return delete_option( $lock_name . '.lock' );
949
+    }
950 950
 }
951 951
 
952 952
 /** Plugin_Upgrader class */
Please login to merge, or discard this patch.