@@ -39,27 +39,7 @@ public static function debug_data() {
3939
4040 // Save few function calls.
4141 $ upload_dir = wp_upload_dir ();
42- $ permalink_structure = get_option ( 'permalink_structure ' );
43- $ is_ssl = is_ssl ();
4442 $ is_multisite = is_multisite ();
45- $ users_can_register = get_option ( 'users_can_register ' );
46- $ blog_public = get_option ( 'blog_public ' );
47- $ default_comment_status = get_option ( 'default_comment_status ' );
48- $ environment_type = wp_get_environment_type ();
49- $ core_version = wp_get_wp_version ();
50- $ core_updates = get_core_updates ();
51- $ core_update_needed = '' ;
52-
53- if ( is_array ( $ core_updates ) ) {
54- foreach ( $ core_updates as $ core => $ update ) {
55- if ( 'upgrade ' === $ update ->response ) {
56- /* translators: %s: Latest WordPress version number. */
57- $ core_update_needed = ' ' . sprintf ( __ ( '(Latest version: %s) ' ), $ update ->version );
58- } else {
59- $ core_update_needed = '' ;
60- }
61- }
62- }
6343
6444 /*
6545 * Set up the array that holds all debug information.
@@ -75,7 +55,7 @@ public static function debug_data() {
7555 * @ticket 61648
7656 */
7757 $ info = array (
78- 'wp-core ' => array (),
58+ 'wp-core ' => self :: get_wp_core (),
7959 'wp-paths-sizes ' => array (),
8060 'wp-dropins ' => self ::get_wp_dropins (),
8161 'wp-active-theme ' => array (),
@@ -96,74 +76,6 @@ public static function debug_data() {
9676 unset( $ info ['wp-paths-sizes ' ] );
9777 }
9878
99- $ info ['wp-core ' ] = array (
100- 'label ' => __ ( 'WordPress ' ),
101- 'fields ' => array (
102- 'version ' => array (
103- 'label ' => __ ( 'Version ' ),
104- 'value ' => $ core_version . $ core_update_needed ,
105- 'debug ' => $ core_version ,
106- ),
107- 'site_language ' => array (
108- 'label ' => __ ( 'Site Language ' ),
109- 'value ' => get_locale (),
110- ),
111- 'user_language ' => array (
112- 'label ' => __ ( 'User Language ' ),
113- 'value ' => get_user_locale (),
114- ),
115- 'timezone ' => array (
116- 'label ' => __ ( 'Timezone ' ),
117- 'value ' => wp_timezone_string (),
118- ),
119- 'home_url ' => array (
120- 'label ' => __ ( 'Home URL ' ),
121- 'value ' => get_bloginfo ( 'url ' ),
122- 'private ' => true ,
123- ),
124- 'site_url ' => array (
125- 'label ' => __ ( 'Site URL ' ),
126- 'value ' => get_bloginfo ( 'wpurl ' ),
127- 'private ' => true ,
128- ),
129- 'permalink ' => array (
130- 'label ' => __ ( 'Permalink structure ' ),
131- 'value ' => $ permalink_structure ? $ permalink_structure : __ ( 'No permalink structure set ' ),
132- 'debug ' => $ permalink_structure ,
133- ),
134- 'https_status ' => array (
135- 'label ' => __ ( 'Is this site using HTTPS? ' ),
136- 'value ' => $ is_ssl ? __ ( 'Yes ' ) : __ ( 'No ' ),
137- 'debug ' => $ is_ssl ,
138- ),
139- 'multisite ' => array (
140- 'label ' => __ ( 'Is this a multisite? ' ),
141- 'value ' => $ is_multisite ? __ ( 'Yes ' ) : __ ( 'No ' ),
142- 'debug ' => $ is_multisite ,
143- ),
144- 'user_registration ' => array (
145- 'label ' => __ ( 'Can anyone register on this site? ' ),
146- 'value ' => $ users_can_register ? __ ( 'Yes ' ) : __ ( 'No ' ),
147- 'debug ' => $ users_can_register ,
148- ),
149- 'blog_public ' => array (
150- 'label ' => __ ( 'Is this site discouraging search engines? ' ),
151- 'value ' => $ blog_public ? __ ( 'No ' ) : __ ( 'Yes ' ),
152- 'debug ' => $ blog_public ,
153- ),
154- 'default_comment_status ' => array (
155- 'label ' => __ ( 'Default comment status ' ),
156- 'value ' => 'open ' === $ default_comment_status ? _x ( 'Open ' , 'comment status ' ) : _x ( 'Closed ' , 'comment status ' ),
157- 'debug ' => $ default_comment_status ,
158- ),
159- 'environment_type ' => array (
160- 'label ' => __ ( 'Environment type ' ),
161- 'value ' => $ environment_type ,
162- 'debug ' => $ environment_type ,
163- ),
164- ),
165- );
166-
16779 if ( ! $ is_multisite ) {
16880 $ info ['wp-paths-sizes ' ] = array (
16981 /* translators: Filesystem directory paths and storage sizes. */
@@ -188,68 +100,6 @@ public static function debug_data() {
188100 'fields ' => array (),
189101 );
190102
191- // Conditionally add debug information for multisite setups.
192- if ( is_multisite () ) {
193- $ site_id = get_current_blog_id ();
194-
195- $ info ['wp-core ' ]['fields ' ]['site_id ' ] = array (
196- 'label ' => __ ( 'Site ID ' ),
197- 'value ' => $ site_id ,
198- 'debug ' => $ site_id ,
199- );
200-
201- $ network_query = new WP_Network_Query ();
202- $ network_ids = $ network_query ->query (
203- array (
204- 'fields ' => 'ids ' ,
205- 'number ' => 100 ,
206- 'no_found_rows ' => false ,
207- )
208- );
209-
210- $ site_count = 0 ;
211- foreach ( $ network_ids as $ network_id ) {
212- $ site_count += get_blog_count ( $ network_id );
213- }
214-
215- $ info ['wp-core ' ]['fields ' ]['site_count ' ] = array (
216- 'label ' => __ ( 'Site count ' ),
217- 'value ' => $ site_count ,
218- );
219-
220- $ info ['wp-core ' ]['fields ' ]['network_count ' ] = array (
221- 'label ' => __ ( 'Network count ' ),
222- 'value ' => $ network_query ->found_networks ,
223- );
224- }
225-
226- $ info ['wp-core ' ]['fields ' ]['user_count ' ] = array (
227- 'label ' => __ ( 'User count ' ),
228- 'value ' => get_user_count (),
229- );
230-
231- // WordPress features requiring processing.
232- $ wp_dotorg = wp_remote_get ( 'https://wordpress.org ' , array ( 'timeout ' => 10 ) );
233-
234- if ( ! is_wp_error ( $ wp_dotorg ) ) {
235- $ info ['wp-core ' ]['fields ' ]['dotorg_communication ' ] = array (
236- 'label ' => __ ( 'Communication with WordPress.org ' ),
237- 'value ' => __ ( 'WordPress.org is reachable ' ),
238- 'debug ' => 'true ' ,
239- );
240- } else {
241- $ info ['wp-core ' ]['fields ' ]['dotorg_communication ' ] = array (
242- 'label ' => __ ( 'Communication with WordPress.org ' ),
243- 'value ' => sprintf (
244- /* translators: 1: The IP address WordPress.org resolves to. 2: The error returned by the lookup. */
245- __ ( 'Unable to reach WordPress.org at %1$s: %2$s ' ),
246- gethostbyname ( 'wordpress.org ' ),
247- $ wp_dotorg ->get_error_message ()
248- ),
249- 'debug ' => $ wp_dotorg ->get_error_message (),
250- );
251- }
252-
253103 // Remove accordion for Directories and Sizes if in Multisite.
254104 if ( ! $ is_multisite ) {
255105 $ loading = __ ( 'Loading… ' );
@@ -697,6 +547,169 @@ public static function debug_data() {
697547 return $ info ;
698548 }
699549
550+ /**
551+ * Gets the WordPress core section of the debug data.
552+ *
553+ * @since 6.7.0
554+ *
555+ * @return array
556+ */
557+ private static function get_wp_core (): array {
558+ // Save few function calls.
559+ $ permalink_structure = get_option ( 'permalink_structure ' );
560+ $ is_ssl = is_ssl ();
561+ $ users_can_register = get_option ( 'users_can_register ' );
562+ $ blog_public = get_option ( 'blog_public ' );
563+ $ default_comment_status = get_option ( 'default_comment_status ' );
564+ $ environment_type = wp_get_environment_type ();
565+ $ core_version = wp_get_wp_version ();
566+ $ core_updates = get_core_updates ();
567+ $ core_update_needed = '' ;
568+
569+ if ( is_array ( $ core_updates ) ) {
570+ foreach ( $ core_updates as $ core => $ update ) {
571+ if ( 'upgrade ' === $ update ->response ) {
572+ /* translators: %s: Latest WordPress version number. */
573+ $ core_update_needed = ' ' . sprintf ( __ ( '(Latest version: %s) ' ), $ update ->version );
574+ } else {
575+ $ core_update_needed = '' ;
576+ }
577+ }
578+ }
579+
580+ $ fields = array (
581+ 'version ' => array (
582+ 'label ' => __ ( 'Version ' ),
583+ 'value ' => $ core_version . $ core_update_needed ,
584+ 'debug ' => $ core_version ,
585+ ),
586+ 'site_language ' => array (
587+ 'label ' => __ ( 'Site Language ' ),
588+ 'value ' => get_locale (),
589+ ),
590+ 'user_language ' => array (
591+ 'label ' => __ ( 'User Language ' ),
592+ 'value ' => get_user_locale (),
593+ ),
594+ 'timezone ' => array (
595+ 'label ' => __ ( 'Timezone ' ),
596+ 'value ' => wp_timezone_string (),
597+ ),
598+ 'home_url ' => array (
599+ 'label ' => __ ( 'Home URL ' ),
600+ 'value ' => get_bloginfo ( 'url ' ),
601+ 'private ' => true ,
602+ ),
603+ 'site_url ' => array (
604+ 'label ' => __ ( 'Site URL ' ),
605+ 'value ' => get_bloginfo ( 'wpurl ' ),
606+ 'private ' => true ,
607+ ),
608+ 'permalink ' => array (
609+ 'label ' => __ ( 'Permalink structure ' ),
610+ 'value ' => $ permalink_structure ? $ permalink_structure : __ ( 'No permalink structure set ' ),
611+ 'debug ' => $ permalink_structure ,
612+ ),
613+ 'https_status ' => array (
614+ 'label ' => __ ( 'Is this site using HTTPS? ' ),
615+ 'value ' => $ is_ssl ? __ ( 'Yes ' ) : __ ( 'No ' ),
616+ 'debug ' => $ is_ssl ,
617+ ),
618+ 'multisite ' => array (
619+ 'label ' => __ ( 'Is this a multisite? ' ),
620+ 'value ' => is_multisite () ? __ ( 'Yes ' ) : __ ( 'No ' ),
621+ 'debug ' => is_multisite (),
622+ ),
623+ 'user_registration ' => array (
624+ 'label ' => __ ( 'Can anyone register on this site? ' ),
625+ 'value ' => $ users_can_register ? __ ( 'Yes ' ) : __ ( 'No ' ),
626+ 'debug ' => $ users_can_register ,
627+ ),
628+ 'blog_public ' => array (
629+ 'label ' => __ ( 'Is this site discouraging search engines? ' ),
630+ 'value ' => $ blog_public ? __ ( 'No ' ) : __ ( 'Yes ' ),
631+ 'debug ' => $ blog_public ,
632+ ),
633+ 'default_comment_status ' => array (
634+ 'label ' => __ ( 'Default comment status ' ),
635+ 'value ' => 'open ' === $ default_comment_status ? _x ( 'Open ' , 'comment status ' ) : _x ( 'Closed ' , 'comment status ' ),
636+ 'debug ' => $ default_comment_status ,
637+ ),
638+ 'environment_type ' => array (
639+ 'label ' => __ ( 'Environment type ' ),
640+ 'value ' => $ environment_type ,
641+ 'debug ' => $ environment_type ,
642+ ),
643+ );
644+
645+ // Conditionally add debug information for multisite setups.
646+ if ( is_multisite () ) {
647+ $ site_id = get_current_blog_id ();
648+
649+ $ fields ['site_id ' ] = array (
650+ 'label ' => __ ( 'Site ID ' ),
651+ 'value ' => $ site_id ,
652+ 'debug ' => $ site_id ,
653+ );
654+
655+ $ network_query = new WP_Network_Query ();
656+ $ network_ids = $ network_query ->query (
657+ array (
658+ 'fields ' => 'ids ' ,
659+ 'number ' => 100 ,
660+ 'no_found_rows ' => false ,
661+ )
662+ );
663+
664+ $ site_count = 0 ;
665+ foreach ( $ network_ids as $ network_id ) {
666+ $ site_count += get_blog_count ( $ network_id );
667+ }
668+
669+ $ fields ['site_count ' ] = array (
670+ 'label ' => __ ( 'Site count ' ),
671+ 'value ' => $ site_count ,
672+ );
673+
674+ $ fields ['network_count ' ] = array (
675+ 'label ' => __ ( 'Network count ' ),
676+ 'value ' => $ network_query ->found_networks ,
677+ );
678+ }
679+
680+ $ fields ['user_count ' ] = array (
681+ 'label ' => __ ( 'User count ' ),
682+ 'value ' => get_user_count (),
683+ );
684+
685+ // WordPress features requiring processing.
686+ $ wp_dotorg = wp_remote_get ( 'https://wordpress.org ' , array ( 'timeout ' => 10 ) );
687+
688+ if ( ! is_wp_error ( $ wp_dotorg ) ) {
689+ $ fields ['dotorg_communication ' ] = array (
690+ 'label ' => __ ( 'Communication with WordPress.org ' ),
691+ 'value ' => __ ( 'WordPress.org is reachable ' ),
692+ 'debug ' => 'true ' ,
693+ );
694+ } else {
695+ $ fields ['dotorg_communication ' ] = array (
696+ 'label ' => __ ( 'Communication with WordPress.org ' ),
697+ 'value ' => sprintf (
698+ /* translators: 1: The IP address WordPress.org resolves to. 2: The error returned by the lookup. */
699+ __ ( 'Unable to reach WordPress.org at %1$s: %2$s ' ),
700+ gethostbyname ( 'wordpress.org ' ),
701+ $ wp_dotorg ->get_error_message ()
702+ ),
703+ 'debug ' => $ wp_dotorg ->get_error_message (),
704+ );
705+ }
706+
707+ return array (
708+ 'label ' => __ ( 'WordPress ' ),
709+ 'fields ' => $ fields ,
710+ );
711+ }
712+
700713 /**
701714 * Gets the WordPress drop-in section of the debug data.
702715 *
0 commit comments