| | 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 | 'Multisite' => ( is_multisite() ? 'Yes' : 'No' ), |
| | 28 | 'Language' => get_locale(), |
| | 29 | 'Home URL' => get_bloginfo( 'home' ), |
| | 30 | 'Site URL' => get_bloginfo( 'siteurl' ), |
| | 31 | 'HTTPS' => ( is_ssl() ? 'Enabled' : 'Disabled' ), |
| | 32 | 'Theme directory is writable' => ( wp_is_writable( TEMPLATEPATH . '/..' ) ? 'Yes' : 'No' ), |
| | 33 | 'Plugin directory is writable' => ( wp_is_writable( WP_PLUGIN_DIR ) ? 'Yes' : 'No' ), |
| | 34 | 'WordPress memory limit' => WP_MAX_MEMORY_LIMIT |
| | 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 | // Populate the server debug fields |
| | 51 | $info['Server']['fields']['PHP Version'] = phpversion(); |
| | 52 | $info['Server']['fields']['PHP SAPI'] = php_sapi_name(); |
| | 53 | $info['Server']['fields']['PHP post max size'] = ini_get( 'post_max_size' ); |
| | 54 | $info['Server']['fields']['PHP time limit'] = ini_get( 'max_execution_time' ); |
| | 55 | $info['Server']['fields']['PHP memory limit'] = ini_get( 'memory_limit' ); |
| | 56 | |
| | 57 | $cURL = curl_version(); |
| | 58 | $info['Server']['fields']['cURL Version'] = sprintf( '%s %s', $cURL['version'], $cURL['ssl_version'] ); |
| | 59 | |
| | 60 | $info['Server']['fields']['SUHOSIN installed'] = ( ( extension_loaded('suhosin') || ( defined( 'SUHOSIN_PATCH' ) && constant( 'SUHOSIN_PATCH' ) ) ) ? 'Yes' : 'No' ); |
| | 61 | |
| | 62 | |
| | 63 | // Populate the database debug fields. |
| | 64 | if ( is_resource( $wpdb->dbh ) ) { |
| | 65 | # Old mysql extension |
| | 66 | $extension = 'mysql'; |
| | 67 | } else if ( is_object( $wpdb->dbh ) ) { |
| | 68 | # mysqli or PDO |
| | 69 | $extension = get_class( $wpdb->dbh ); |
| | 70 | } else { |
| | 71 | # Who knows? |
| | 72 | $extension = null; |
| | 73 | } |
| | 74 | |
| | 75 | if ( method_exists( $wpdb, 'db_version' ) ) { |
| | 76 | $server = $wpdb->db_version(); |
| | 77 | } else { |
| | 78 | $server = null; |
| | 79 | } |
| | 80 | |
| | 81 | if ( isset( $wpdb->use_mysqli ) && $wpdb->use_mysqli ) { |
| | 82 | $client_version = mysqli_get_client_version(); |
| | 83 | } else { |
| | 84 | if ( preg_match( '|[0-9]{1,2}\.[0-9]{1,2}\.[0-9]{1,2}|', mysql_get_client_info(), $matches ) ) { |
| | 85 | $client_version = $matches[0]; |
| | 86 | } else { |
| | 87 | $client_version = null; |
| | 88 | } |
| | 89 | } |
| | 90 | |
| | 91 | $info['Database']['fields']['Extension'] = $extension; |
| | 92 | $info['Database']['fields']['Server version'] = $server; |
| | 93 | $info['Database']['fields']['Client version'] = $client_version; |
| | 94 | $info['Database']['fields']['Database user'] = $wpdb->dbuser; |
| | 95 | $info['Database']['fields']['Database host'] = $wpdb->dbhost; |
| | 96 | $info['Database']['fields']['Database table'] = $wpdb->dbname; |
| | 97 | $info['Database']['fields']['Database prefix'] = $wpdb->prefix; |
| | 98 | |
| | 99 | |
| | 100 | // List must use plugins if there are any |
| | 101 | $mu_plugins = get_mu_plugins(); |
| | 102 | |
| | 103 | foreach ( $mu_plugins AS $plugin_path => $plugin ) { |
| | 104 | $info['Must Use Plugins']['fields'][ $plugin['Name'] ] = sprintf( 'version %s by %s', $plugin['Version'], $plugin['Author'] ); |
| | 105 | } |
| | 106 | |
| | 107 | |
| | 108 | // List all available plugins |
| | 109 | $plugins = get_plugins(); |
| | 110 | |
| | 111 | foreach ( $plugins AS $plugin_path => $plugin ) { |
| | 112 | $info['Plugins']['fields'][ $plugin['Name'] ] = sprintf( '%s - version %s by %s', ( is_plugin_active( $plugin_path ) ? 'Enabled' : 'Disabled' ), $plugin['Version'], $plugin['Author'] ); |
| | 113 | } |
| | 114 | |
| | 115 | |
| | 116 | // Populate the section for the currently active theme |
| | 117 | $theme = wp_get_theme(); |
| | 118 | $info['Active theme']['fields'] = array( |
| | 119 | 'Name' => $theme->Name, |
| | 120 | 'Version' => $theme->Version, |
| | 121 | 'Author' => wp_kses( $theme->Author, array() ), |
| | 122 | 'Author URL' => $theme->AuthorURI, |
| | 123 | 'Parent theme' => ( $theme->parent_Theme ?: 'Not a child theme' ), |
| | 124 | ); |
| | 125 | |
| | 126 | |
| | 127 | // Populate a list of all themes available in the install |
| | 128 | $all_themes = wp_get_themes(); |
| | 129 | |
| | 130 | foreach ( $all_themes AS $theme_slug => $theme ) { |
| | 131 | $info['Other themes']['fields'][ sprintf( '%s (%s)', $theme->Name, $theme_slug ) ] = sprintf( 'version %s by %s', $theme->Version, wp_kses( $theme->Author, array() ) ); |
| | 132 | } |
| | 133 | |
| | 134 | |
| | 135 | |
| | 136 | /** |
| | 137 | * Add or modify new debug sections. |
| | 138 | * |
| | 139 | * Plugin or themes may wish to introduce their own debug information without creating additional admin pages for this |
| | 140 | * kind of information as it is rarely needed, they can then utilize this filter to introduce their own sections. |
| | 141 | * |
| | 142 | * This filter intentionally does not include the fields introduced by core as those should always be un-modified |
| | 143 | * and reliable for support related scenarios. |
| | 144 | * |
| | 145 | * @since 4.9.0 |
| | 146 | * |
| | 147 | * @param array $args { |
| | 148 | * The debug information to be added to the core information page. |
| | 149 | * |
| | 150 | * @type string $description Optional. A description for your information section which may contain basic HTML |
| | 151 | * markup: `em`, `strong` and `a` for linking to documentation or putting emphasis. |
| | 152 | * @type array $fields { |
| | 153 | * An associative array containing the data to be displayed, using a label as the key. |
| | 154 | * |
| | 155 | * @type string $information The details to be disclosed for this field. |
| | 156 | * } |
| | 157 | * } |
| | 158 | */ |
| | 159 | $external_info = apply_filters( 'debug_information', array() ); |
| | 160 | |
| | 161 | // Merge the core and external debug fields |
| | 162 | $info = array_merge( $info, $external_info ); |
| | 163 | ?> |
| | 164 | |
| | 165 | <div class="wrap"> |
| | 166 | <h1 class="wp-heading-inline"> |
| | 167 | <?php echo esc_html( $title ); ?> |
| | 168 | </h1> |
| | 169 | |
| | 170 | <?php |
| | 171 | foreach ( $info AS $section => $details ) { |
| | 172 | if ( ! isset( $details['fields'] ) || empty( $details['fields'] ) ) { |
| | 173 | continue; |
| | 174 | } |
| | 175 | |
| | 176 | printf( |
| | 177 | '<h2>%s</h2>', |
| | 178 | esc_html( $section ) |
| | 179 | ); |
| | 180 | |
| | 181 | if ( isset( $details['description'] ) && ! empty( $details['description'] ) ) { |
| | 182 | printf( |
| | 183 | '<p>%s</p>', |
| | 184 | wp_kses( $details['description'], array( |
| | 185 | 'a' => array( |
| | 186 | 'href' => true |
| | 187 | ), |
| | 188 | 'strong' => true, |
| | 189 | 'em' => true, |
| | 190 | ) ) |
| | 191 | ); |
| | 192 | } |
| | 193 | ?> |
| | 194 | <table class="widefat"> |
| | 195 | <tbody> |
| | 196 | <?php |
| | 197 | foreach ( $details['fields'] AS $field_name => $field_value ) { |
| | 198 | printf( |
| | 199 | '<tr><td>%s</td><td>%s</td></tr>', |
| | 200 | esc_html( $field_name ), |
| | 201 | esc_html( $field_value ) |
| | 202 | ); |
| | 203 | } |
| | 204 | ?> |
| | 205 | </tbody> |
| | 206 | </table> |
| | 207 | <?php |
| | 208 | } |
| | 209 | |
| | 210 | include( ABSPATH . 'wp-admin/admin-footer.php' ); |