| | 1 | <?php |
| | 2 | /** |
| | 3 | * Get system status for debugging and support. |
| | 4 | * |
| | 5 | * @package WordPress |
| | 6 | * @subpackage Administration |
| | 7 | */ |
| | 8 | |
| | 9 | /** WordPress Administration Bootstrap */ |
| | 10 | require_once( dirname( __FILE__ ) . '/admin.php' ); |
| | 11 | |
| | 12 | if ( ! is_super_admin() ) { |
| | 13 | wp_die( __( 'Sorry, you do not have permission to access this page.' ) ); |
| | 14 | } |
| | 15 | |
| | 16 | global $wpdb; |
| | 17 | |
| | 18 | $title = __( 'System information' ); |
| | 19 | |
| | 20 | require_once( ABSPATH . 'wp-admin/admin-header.php' ); |
| | 21 | |
| | 22 | $info = array( |
| | 23 | 'WordPress' => array( |
| | 24 | 'fields' => array( |
| | 25 | 'Version' => get_bloginfo( 'version' ), |
| | 26 | 'Debug mode' => ( defined( 'WP_DEBUG' ) && WP_DEBUG ? __( 'Enabled' ) : __( 'Disabled' ) ), |
| | 27 | 'Language' => get_locale(), |
| | 28 | 'Home URL' => get_bloginfo( 'url' ), |
| | 29 | 'Site URL' => get_bloginfo( 'wpurl' ), |
| | 30 | 'HTTPS' => ( is_ssl() ? __( 'Enabled' ) : __( 'Disabled' ) ), |
| | 31 | 'Theme directory is writable' => ( wp_is_writable( TEMPLATEPATH . '/..' ) ? __( 'Yes' ) : __( 'No' ) ), |
| | 32 | 'Plugin directory is writable' => ( wp_is_writable( WP_PLUGIN_DIR ) ? __( 'Yes' ) : __( 'No' ) ), |
| | 33 | 'WordPress memory limit' => WP_MAX_MEMORY_LIMIT, |
| | 34 | 'Multisite' => ( is_multisite() ? __( 'Yes' ) : __( 'No' ) ), |
| | 35 | ), |
| | 36 | ), |
| | 37 | 'Active theme' => array(), |
| | 38 | 'Other themes' => array(), |
| | 39 | 'Must Use Plugins' => array(), |
| | 40 | 'Plugins' => array(), |
| | 41 | 'Server' => array( |
| | 42 | 'description' => __( 'The options shown below are relating to your server setup, and may require the help of your host if changes are required.' ), |
| | 43 | 'fields' => array() |
| | 44 | ), |
| | 45 | 'Database' => array( |
| | 46 | 'fields' => array() |
| | 47 | ) |
| | 48 | ); |
| | 49 | |
| | 50 | if ( is_multisite() ) { |
| | 51 | $network_query = new WP_Network_Query(); |
| | 52 | $network_ids = $network_query->query( array( |
| | 53 | 'fields' => 'ids', |
| | 54 | 'number' => 100, |
| | 55 | 'no_found_rows' => false, |
| | 56 | ) ); |
| | 57 | |
| | 58 | $site_count = 0; |
| | 59 | foreach ( $network_ids as $network_id ) { |
| | 60 | $site_count += get_blog_count( $network_id ); |
| | 61 | } |
| | 62 | |
| | 63 | $info['WordPress']['fields']['User Count'] = get_user_count(); |
| | 64 | $info['WordPress']['fields']['Site Count'] = $site_count; |
| | 65 | $info['WordPress']['fields']['Network Count'] = $network_query->found_networks; |
| | 66 | } else { |
| | 67 | $user_count = count_users(); |
| | 68 | |
| | 69 | $info['WordPress']['fields']['User Count'] = $user_count['total_users']; |
| | 70 | } |
| | 71 | |
| | 72 | // Populate the server debug fields |
| | 73 | $info['Server']['fields']['PHP Version'] = phpversion(); |
| | 74 | $info['Server']['fields']['PHP SAPI'] = php_sapi_name(); |
| | 75 | $info['Server']['fields']['PHP post max size'] = ini_get( 'post_max_size' ); |
| | 76 | $info['Server']['fields']['PHP time limit'] = ini_get( 'max_execution_time' ); |
| | 77 | $info['Server']['fields']['PHP memory limit'] = ini_get( 'memory_limit' ); |
| | 78 | |
| | 79 | $cURL = curl_version(); |
| | 80 | $info['Server']['fields']['cURL Version'] = sprintf( '%s %s', $cURL['version'], $cURL['ssl_version'] ); |
| | 81 | |
| | 82 | $info['Server']['fields']['SUHOSIN installed'] = ( ( extension_loaded('suhosin') || ( defined( 'SUHOSIN_PATCH' ) && constant( 'SUHOSIN_PATCH' ) ) ) ? __( 'Yes' ) : __( 'No' ) ); |
| | 83 | |
| | 84 | |
| | 85 | // Populate the database debug fields. |
| | 86 | if ( is_resource( $wpdb->dbh ) ) { |
| | 87 | # Old mysql extension |
| | 88 | $extension = 'mysql'; |
| | 89 | } else if ( is_object( $wpdb->dbh ) ) { |
| | 90 | # mysqli or PDO |
| | 91 | $extension = get_class( $wpdb->dbh ); |
| | 92 | } else { |
| | 93 | # Who knows? |
| | 94 | $extension = null; |
| | 95 | } |
| | 96 | |
| | 97 | if ( method_exists( $wpdb, 'db_version' ) ) { |
| | 98 | $server = $wpdb->db_version(); |
| | 99 | } else { |
| | 100 | $server = null; |
| | 101 | } |
| | 102 | |
| | 103 | if ( isset( $wpdb->use_mysqli ) && $wpdb->use_mysqli ) { |
| | 104 | $client_version = mysqli_get_client_version(); |
| | 105 | } else { |
| | 106 | if ( preg_match( '|[0-9]{1,2}\.[0-9]{1,2}\.[0-9]{1,2}|', mysql_get_client_info(), $matches ) ) { |
| | 107 | $client_version = $matches[0]; |
| | 108 | } else { |
| | 109 | $client_version = null; |
| | 110 | } |
| | 111 | } |
| | 112 | |
| | 113 | $info['Database']['fields']['Extension'] = $extension; |
| | 114 | $info['Database']['fields']['Server version'] = $server; |
| | 115 | $info['Database']['fields']['Client version'] = $client_version; |
| | 116 | $info['Database']['fields']['Database user'] = $wpdb->dbuser; |
| | 117 | $info['Database']['fields']['Database host'] = $wpdb->dbhost; |
| | 118 | $info['Database']['fields']['Database table'] = $wpdb->dbname; |
| | 119 | $info['Database']['fields']['Database prefix'] = $wpdb->prefix; |
| | 120 | |
| | 121 | |
| | 122 | // List must use plugins if there are any |
| | 123 | $mu_plugins = get_mu_plugins(); |
| | 124 | |
| | 125 | foreach ( $mu_plugins AS $plugin_path => $plugin ) { |
| | 126 | $info['Must Use Plugins']['fields'][ $plugin['Name'] ] = sprintf( 'version %s by %s', $plugin['Version'], $plugin['Author'] ); |
| | 127 | } |
| | 128 | |
| | 129 | |
| | 130 | // List all available plugins |
| | 131 | $plugins = get_plugins(); |
| | 132 | |
| | 133 | foreach ( $plugins AS $plugin_path => $plugin ) { |
| | 134 | $info['Plugins']['fields'][ $plugin['Name'] ] = sprintf( '%s - version %s by %s', ( is_plugin_active( $plugin_path ) ? __( 'Enabled' ) : __( 'Disabled' ) ), $plugin['Version'], $plugin['Author'] ); |
| | 135 | } |
| | 136 | |
| | 137 | |
| | 138 | // Populate the section for the currently active theme |
| | 139 | $theme = wp_get_theme(); |
| | 140 | $info['Active theme']['fields'] = array( |
| | 141 | 'Name' => $theme->Name, |
| | 142 | 'Version' => $theme->Version, |
| | 143 | 'Author' => wp_kses( $theme->Author, array() ), |
| | 144 | 'Author URL' => $theme->AuthorURI, |
| | 145 | 'Parent theme' => ( $theme->parent_Theme ?: 'Not a child theme' ), |
| | 146 | ); |
| | 147 | |
| | 148 | |
| | 149 | // Populate a list of all themes available in the install |
| | 150 | $all_themes = wp_get_themes(); |
| | 151 | |
| | 152 | foreach ( $all_themes AS $theme_slug => $theme ) { |
| | 153 | $info['Other themes']['fields'][ sprintf( '%s (%s)', $theme->Name, $theme_slug ) ] = sprintf( 'version %s by %s', $theme->Version, wp_kses( $theme->Author, array() ) ); |
| | 154 | } |
| | 155 | |
| | 156 | |
| | 157 | |
| | 158 | /** |
| | 159 | * Add or modify new debug sections. |
| | 160 | * |
| | 161 | * Plugin or themes may wish to introduce their own debug information without creating additional admin pages for this |
| | 162 | * kind of information as it is rarely needed, they can then utilize this filter to introduce their own sections. |
| | 163 | * |
| | 164 | * This filter intentionally does not include the fields introduced by core as those should always be un-modified |
| | 165 | * and reliable for support related scenarios. |
| | 166 | * |
| | 167 | * @since 4.9.0 |
| | 168 | * |
| | 169 | * @param array $args { |
| | 170 | * The debug information to be added to the core information page. |
| | 171 | * |
| | 172 | * @type string $description Optional. A description for your information section which may contain basic HTML |
| | 173 | * markup: `em`, `strong` and `a` for linking to documentation or putting emphasis. |
| | 174 | * @type array $fields { |
| | 175 | * An associative array containing the data to be displayed, using a label as the key. |
| | 176 | * |
| | 177 | * @type string $information The details to be disclosed for this field. |
| | 178 | * } |
| | 179 | * } |
| | 180 | */ |
| | 181 | $external_info = apply_filters( 'debug_information', array() ); |
| | 182 | |
| | 183 | // Merge the core and external debug fields |
| | 184 | $info = array_merge( $info, $external_info ); |
| | 185 | ?> |
| | 186 | |
| | 187 | <div class="wrap"> |
| | 188 | <h1 class="wp-heading-inline"> |
| | 189 | <?php echo esc_html( $title ); ?> |
| | 190 | </h1> |
| | 191 | |
| | 192 | <?php |
| | 193 | foreach ( $info AS $section => $details ) { |
| | 194 | if ( ! isset( $details['fields'] ) || empty( $details['fields'] ) ) { |
| | 195 | continue; |
| | 196 | } |
| | 197 | |
| | 198 | printf( |
| | 199 | '<h2>%s</h2>', |
| | 200 | esc_html( $section ) |
| | 201 | ); |
| | 202 | |
| | 203 | if ( isset( $details['description'] ) && ! empty( $details['description'] ) ) { |
| | 204 | printf( |
| | 205 | '<p>%s</p>', |
| | 206 | wp_kses( $details['description'], array( |
| | 207 | 'a' => array( |
| | 208 | 'href' => true |
| | 209 | ), |
| | 210 | 'strong' => true, |
| | 211 | 'em' => true, |
| | 212 | ) ) |
| | 213 | ); |
| | 214 | } |
| | 215 | ?> |
| | 216 | <table class="widefat"> |
| | 217 | <tbody> |
| | 218 | <?php |
| | 219 | foreach ( $details['fields'] AS $field_name => $field_value ) { |
| | 220 | printf( |
| | 221 | '<tr><td>%s</td><td>%s</td></tr>', |
| | 222 | esc_html( $field_name ), |
| | 223 | esc_html( $field_value ) |
| | 224 | ); |
| | 225 | } |
| | 226 | ?> |
| | 227 | </tbody> |
| | 228 | </table> |
| | 229 | <?php |
| | 230 | } |
| | 231 | |
| | 232 | include( ABSPATH . 'wp-admin/admin-footer.php' ); |