path = dirname( __FILE__ ) . '/'; $this->validation = $this->validation_instance(); $this->collect_theme_info(); $this->wordpress_environment(); $this->collect_plugin_information(); $this->collect_php_info(); $this->collect_php_extensions(); $this->collect_server_environment(); } /** * Validation instance */ public function validation_instance() { return new CT_Config_Validation(); } /** * Output the result of the collection. */ public function output() { return $this->result; } /** * Collect PHP info */ protected function collect_php_info() { $version_validation = $this->validation->version( 'php-version', PHP_VERSION ); $post_max_size = $this->validation->compare( 'php-post-max-size', // @codingStandardsIgnoreLine ini_get( 'post_max_size' ) ); $max_execution_time = $this->validation->compare( 'php-max-execution-time', // @codingStandardsIgnoreLine ini_get( 'max_execution_time' ) ); $max_input_vars = $this->validation->compare( 'php-max-input-vars', // @codingStandardsIgnoreLine ini_get( 'max_input_vars' ) ); $safe_mode = $this->validation->is( 'php-safe-mode', // @codingStandardsIgnoreLine ini_get( 'safe_mode' ) ); $memory_limit = $this->validation->compare( 'php-memory-limit', ini_get( 'memory_limit' ) ); $upload_max_filesize = $this->validation->compare( 'php-upload-max-filesize', ini_get( 'upload_max_filesize' ) ); $allow_url_fopen = $this->validation->is( 'php-allow-url-fopen', ini_get( 'allow_url_fopen' ) ); $this->result['php'] = array( 'title' => __( 'PHP Configuration', 'ct' ), 'desc' => __( 'Information about PHP configuration.', 'ct' ), 'options' => array( 'version' => array( 'title' => __( 'PHP Version', 'ct' ), 'desc' => __( 'The current PHP version.', 'ct' ), 'value' => PHP_VERSION, 'success' => $version_validation['response'], 'message' => $version_validation['error'], 'doc' => 'http://php.net/', 'text' => 'Update', ), 'post_max_size' => array( 'title' => __( 'PHP Post Max Size', 'ct' ), 'desc' => __( 'The upload module limits the size of a single attachment to be less than either post_max_size, or upload_max_filesize, whichever is smaller.', 'ct' ), 'value' => ini_get( 'post_max_size' ), 'success' => $post_max_size['response'], 'message' => $post_max_size['error'], 'doc' => 'http://php.net/manual/en/ini.core.php', 'text' => __( 'Read More', 'ct' ), ), 'max_execution_time' => array( 'title' => __( 'PHP Time Limit', 'ct' ), 'desc' => __( 'This sets the maximum time in seconds a script is allowed to run before it is terminated by the parser. This helps prevent poorly written scripts from tying up the server.', 'ct' ), 'value' => ini_get( 'max_execution_time' ), 'success' => $max_execution_time['response'], 'message' => $max_execution_time['error'], 'doc' => 'http://php.net/manual/en/ini.core.php', 'text' => __( 'Read More', 'ct' ), ), 'max_input_vars' => array( 'title' => __( 'PHP Max Input Vars', 'ct' ), 'desc' => __( 'How many input variables may be accepted (limit is applied to $_GET, $_POST and $_COOKIE superglobal separately).', 'ct' ), // @codingStandardsIgnoreLine 'value' => ini_get( 'max_input_vars' ), 'success' => $max_input_vars['response'], 'message' => $max_input_vars['error'], 'doc' => 'http://php.net/manual/en/ini.core.php', 'text' => __( 'Read More', 'ct' ), ), 'safe_mode' => array( 'title' => __( 'PHP Safe Mode', 'ct' ), 'desc' => __( 'The PHP safe mode is an attempt to solve the shared-server security problem.', 'ct' ), // @codingStandardsIgnoreLine 'value' => ini_get( 'safe_mode' ) ? __( 'Yes', 'ct' ) : __( 'No', 'ct' ), 'success' => $safe_mode['response'], 'message' => $safe_mode['error'], 'doc' => 'https://www.godaddy.com/help/turning-off-php-safe-mode-on-your-plesk-server-119', 'text' => __( 'Read More', 'ct' ), ), 'memory_limit' => array( 'title' => __( 'PHP Memory Limit', 'ct' ), 'desc' => __( 'This sets the maximum amount of memory in bytes that a script is allowed to allocate.', 'ct' ), 'value' => ini_get( 'memory_limit' ), 'success' => $memory_limit['response'], 'message' => $memory_limit['error'], 'doc' => 'http://php.net/manual/en/ini.core.php', 'text' => __( 'Read More', 'ct' ), ), 'upload_max_filesize' => array( 'title' => __( 'PHP Upload Max Size', 'ct' ), 'desc' => __( 'The maximum size of an uploaded file.', 'ct' ), 'value' => ini_get( 'upload_max_filesize' ), 'success' => $upload_max_filesize['response'], 'message' => $upload_max_filesize['error'], 'doc' => 'http://php.net/manual/en/ini.core.php', 'text' => __( 'Read More', 'ct' ), ), 'allow_url_fopen' => array( 'title' => __( 'PHP Allow URL File Open', 'ct' ), 'desc' => __( 'This option enables the URL-aware fopen wrappers that enable accessing URL object like files.', 'ct' ), 'value' => ini_get( 'allow_url_fopen' ) ? __( 'Yes', 'ct' ) : __( 'No', 'ct' ), 'success' => $allow_url_fopen['response'], 'message' => $allow_url_fopen['error'], 'doc' => 'http://php.net/manual/en/ini.core.php', 'text' => __( 'Read More', 'ct' ), ), ), ); } /** * Collect info about WordPress environment */ protected function wordpress_environment() { global $wpdb; $wp_version = $this->validation->version( 'wp-version', get_bloginfo( 'version' ) ); $wp_debug = $this->validation->is( 'wp-debug', defined( 'WP_DEBUG' ) ? WP_DEBUG : null ); $wp_memory_limit = $this->validation->compare( 'wp-memory-limit', WP_MEMORY_LIMIT ); $wp_fs_method = $this->validation->is( 'wp-fs-method', defined( 'FS_METHOD' ) ? ( 'direct' === WP_DEBUG ) ? true : false : true ); $wp_is_plugins_writable = $this->validation->is( 'wp-is-plugins-writable', is_writable( WP_PLUGIN_DIR ) ); $this->result['wordpress_environment'] = array( 'title' => __( 'WordPress Environment', 'ct' ), 'desc' => __( 'Information about WordPress', 'ct' ), 'options' => array( 'home_url' => array( 'title' => __( 'Home URL', 'ct' ), 'desc' => __( 'Home URL link', 'ct' ), 'value' => home_url(), 'success' => true, ), 'site_url' => array( 'title' => __( 'Site URL', 'ct' ), 'desc' => __( 'Site URL link', 'ct' ), 'value' => site_url(), 'success' => true, ), 'wp_version' => array( 'title' => __( 'WP Version', 'ct' ), 'desc' => __( 'Compare the current WordPress version with required version.', 'ct' ), 'value' => get_bloginfo( 'version' ), 'success' => $wp_version['response'], 'message' => $wp_version['error'], 'doc' => admin_url( 'update-core.php' ), 'text' => 'update to ' . $this->validation->value( 'wp-version' ), ), 'wp_is_plugins_writable' => array( 'title' => __( 'Write Access to Plugins', 'ct' ), 'desc' => __( 'WordPress may need access to write to files in your plugins directory to enable certain functions.', 'ct' ), 'value' => is_writable( WP_PLUGIN_DIR ) ? __( 'Yes', 'ct' ) : __( 'No', 'ct' ), 'success' => $wp_is_plugins_writable['response'], 'message' => $wp_is_plugins_writable['error'], 'doc' => 'https://codex.wordpress.org/Changing_File_Permissions', 'text' => __( 'Read More', 'ct' ), ), 'wp_debug' => array( 'title' => __( 'WP_DEBUG', 'ct' ), 'desc' => __( 'WP_DEBUG is a PHP constant (a permanent global variable) that can be used to trigger the "debug" mode throughout WordPress. It is assumed to be false by default and is usually set to true in the wp-config.php file on development copies of WordPress.', 'ct' ), 'value' => defined( 'WP_DEBUG' ) ? WP_DEBUG ? __( 'Enabled', 'ct' ) : __( 'Disabled', 'ct' ) : __( 'Not set', 'ct' ), 'success' => $wp_debug['response'], 'message' => $wp_debug['error'], 'doc' => 'https://codex.wordpress.org/Debugging_in_WordPress', 'text' => __( 'Read More', 'ct' ), ), 'wp_fs_method' => array( 'title' => __( 'Filesystem Method', 'ct' ), 'desc' => __( 'FS_METHOD forces the filesystem method. It should only be "direct", "ssh2", "ftpext", or "ftpsockets".', 'ct' ), 'value' => defined( 'FS_METHOD' ) ? FS_METHOD : __( 'Not set', 'ct' ), 'success' => $wp_fs_method['response'], 'message' => $wp_fs_method['error'], 'doc' => 'https://codex.wordpress.org/Editing_wp-config.php#Override_of_default_file_permissions', 'text' => __( 'Read More', 'ct' ), ), 'wp_lang' => array( 'title' => __( 'WP Language', 'ct' ), 'desc' => __( 'Change the language in the admin settings screen. Settings > General > Site Language.', 'ct' ), 'value' => ( defined( 'WPLANG' ) && WPLANG ? WPLANG : 'en_US' ), 'success' => true, ), 'multisite' => array( 'title' => __( 'Multisite', 'ct' ), 'desc' => __( 'Multisite is a WordPress feature which allows users to create a network of sites on a single WordPress installation.', 'ct' ), 'value' => is_multisite() ? __( 'Yes', 'ct' ) : __( 'No', 'ct' ), 'success' => true, ), 'wp_memory_limit' => array( 'title' => __( 'WP Memory Limit', 'ct' ), 'desc' => __( 'Administration tasks require much memory than usual operation. When in the administration area, the memory can be increased or decreased from the WP_MEMORY_LIMIT', 'ct' ), 'value' => WP_MEMORY_LIMIT, 'success' => $wp_memory_limit['response'], 'message' => $wp_memory_limit['error'], 'doc' => 'https://codex.wordpress.org/Editing_wp-config.php#Increasing_memory_allocated_to_PHP', 'text' => __( 'Read More', 'ct' ), ), 'table_prefix' => array( 'title' => __( 'WP Table Prefix', 'ct' ), 'desc' => __( 'By default the WordPress database table prefix is wp_, you can change this prefix in the wp-config.php.', 'ct' ), 'value' => $wpdb->prefix, 'success' => true, ), 'wp_timezone' => array( 'title' => __( 'WP Timezone', 'ct' ), 'desc' => __( 'Time zones and time offsets. A time zone is a geographical region in which residents observe the same standard time.', 'ct' ), 'value' => get_option( 'timezone_string' ) . ', GMT: ' . get_option( 'gmt_offset' ), 'success' => true, ), 'permalink' => array( 'title' => __( 'Permalink Structure', 'ct' ), 'desc' => __( 'Permalinks are the permanent URLs to your individual weblog posts, as well as categories and other lists of weblog postings.', 'ct' ), 'value' => get_option( 'permalink_structure' ), 'success' => true, ), ), ); } /** * Collect info about theme */ protected function collect_theme_info() { $active_theme = wp_get_theme(); if ( is_child_theme() ) { $parent_theme = wp_get_theme( $active_theme->get( 'Template' ) ); } else { $parent_theme = $active_theme; } $options = array( 'theme_name' => array( 'title' => __( 'Theme Name', 'ct' ), 'desc' => __( 'The current theme name.', 'ct' ), 'value' => $active_theme->get( 'Name' ), 'success' => true, ), 'theme_version' => array( 'title' => __( 'Theme Version', 'ct' ), 'desc' => __( 'The current theme version.', 'ct' ), 'value' => $active_theme->get( 'Version' ), 'success' => true, ), 'theme_author' => array( 'title' => __( 'Theme Author', 'ct' ), 'desc' => __( 'The current theme author.', 'ct' ), 'value' => $active_theme->get( 'Author' ), 'success' => true, ), 'author_uri' => array( 'title' => __( 'Theme Author URI', 'ct' ), 'desc' => __( 'The current theme author website.', 'ct' ), 'value' => $active_theme->get( 'AuthorURI' ), 'success' => true, ), 'child_theme' => array( 'title' => __( 'Is Child Theme', 'ct' ), 'desc' => __( 'Whether a child theme is in use.', 'ct' ), 'value' => is_child_theme() ? __( 'Yes', 'ct' ) : __( 'No', 'ct' ), 'success' => true, ), ); if ( is_child_theme() ) { $options = array_merge( $options, array( 'parent_theme' => array( 'title' => __( 'Parent Theme', 'ct' ), 'desc' => __( 'Parent theme name.', 'ct' ), 'value' => $parent_theme->get( 'Name' ), 'success' => true, ), 'parent_theme_version' => array( 'title' => __( 'Parent Theme Version', 'ct' ), 'desc' => __( 'Current parent theme version.', 'ct' ), 'value' => $parent_theme->get( 'Version' ), 'success' => true, ), 'parent_theme_uri' => array( 'title' => __( 'Parent Theme URI', 'ct' ), 'desc' => __( 'Current parent theme website.', 'ct' ), 'value' => $parent_theme->get( 'ThemeURI' ), 'success' => true, ), ) ); } $this->result['theme_info'] = array( 'title' => __( 'Theme Information', 'ct' ), 'desc' => __( 'Information about your theme', 'ct' ), 'options' => $options, ); } /** * Collect information about plugin */ protected function collect_plugin_information() { $list_of_active_plugins = array(); $list_of_inactive_plugins = array(); if ( ! function_exists( 'get_plugins' ) ) { require_once ABSPATH . 'wp-admin/includes/plugin.php'; } $plugins = get_plugins(); $active_plugins = get_option( 'active_plugins', array() ); foreach ( $plugins as $plugin_path => $plugin ) { if ( in_array( $plugin_path, $active_plugins, true ) ) { $list_of_active_plugins[] = "{$plugin['Name']} (v{$plugin['Version']})"; } else { $list_of_inactive_plugins[] = "{$plugin['Name']} (v{$plugin['Version']})"; } } $this->result['plugin_info'] = array( 'title' => __( 'Plugins Information', 'ct' ), 'desc' => __( 'List of installed plugins', 'ct' ), 'options' => array( 'active_plugins' => array( 'title' => __( 'Active Plugins', 'ct' ), 'desc' => __( 'List of all active plugins.', 'ct' ), 'value' => implode( ', ', $list_of_active_plugins ), 'success' => true, ), 'inactive_plugins' => array( 'title' => __( 'Inactive Plugins', 'ct' ), 'desc' => __( 'List of all inactive plugins.', 'ct' ), 'value' => implode( ', ', $list_of_inactive_plugins ), 'success' => true, ), ), ); } /** * Collect info about PHP install */ protected function collect_php_extensions() { $php_display_errors = $this->validation->is( 'php-display-errors', ini_get( 'display_errors' ) ); $php_ziparchive = $this->validation->is( 'php-ziparchive', class_exists( 'ZipArchive' ) ); $this->result['php_extensions'] = array( 'title' => __( 'PHP Extensions', 'ct' ), 'desc' => __( 'List of PHP extensions', 'ct' ), 'options' => array( 'php_display_errors' => array( 'title' => __( 'Display Errors', 'ct' ), 'desc' => __( 'This determines whether errors should be printed to the screen as part of the output or if they should be hidden from the user.', 'ct' ), 'value' => ini_get( 'display_errors' ) ? __( 'Yes', 'ct' ) : __( 'No', 'ct' ), 'success' => $php_display_errors['response'], 'message' => $php_display_errors['error'], ), 'php_ziparchive' => array( 'title' => __( 'ZipArchive', 'ct' ), 'desc' => __( 'The ZipArchive extension allows you to read ZIP files.', 'ct' ), 'value' => class_exists( 'ZipArchive' ) ? __( 'Yes', 'ct' ) : __( 'No', 'ct' ), 'success' => $php_ziparchive['response'], 'message' => $php_ziparchive['error'], ), 'php_fsockopen' => array( 'title' => __( 'FSOCKOPEN', 'ct' ), 'desc' => __( 'Fsockopen lets you open an Internet or Unix domain socket connection for connecting to a resource via socket connection.', 'ct' ), 'value' => function_exists( 'fsockopen' ) ? __( 'Yes', 'ct' ) : __( 'No', 'ct' ), 'success' => true, ), 'php_curl' => array( 'title' => __( 'cURL', 'ct' ), 'desc' => __( 'CURL is an easy to use command line tool to send and receive files, and it supports almost all major protocols', 'ct' ), 'value' => function_exists( 'curl_init' ) ? __( 'Yes', 'ct' ) : __( 'No', 'ct' ), 'success' => true, ), 'php_soap' => array( 'title' => __( 'SOAP Client', 'ct' ), 'desc' => __( 'The SOAP extension can be used to write SOAP Servers and Clients.', 'ct' ), 'value' => class_exists( 'SoapClient' ) ? __( 'Yes', 'ct' ) : __( 'No', 'ct' ), 'success' => true, ), 'php_suhosin' => array( 'title' => __( 'SUHOSIN', 'ct' ), 'desc' => __( 'Suhosin is an advanced protection system for PHP installations.', 'ct' ), 'value' => extension_loaded( 'suhosin' ) ? __( 'Yes', 'ct' ) : __( 'No', 'ct' ), 'success' => true, ), ), ); } /** * Collect server environment info */ protected function collect_server_environment() { global $wpdb; if ( $wpdb->use_mysqli ) { // @codingStandardsIgnoreLine $mysql_ver = @mysqli_get_server_info( $wpdb->dbh ); } else { // @codingStandardsIgnoreLine $mysql_ver = @mysql_get_server_info(); } $mysql_version = $this->validation->version( 'mysql-version', $mysql_ver ); $this->result['server_environment'] = array( 'title' => __( 'Server Environment', 'ct' ), 'desc' => __( 'Information about server environment', 'ct' ), 'options' => array( 'server_info' => array( 'title' => __( 'Server Info', 'ct' ), 'desc' => __( 'Server Identification from header.', 'ct' ), // @codingStandardsIgnoreLine 'value' => $_SERVER['SERVER_SOFTWARE'], 'success' => true, ), 'default_timezone' => array( 'title' => __( 'Default Timezone', 'ct' ), 'desc' => __( 'default timezone used by all date/time functions in a script', 'ct' ), 'value' => date_default_timezone_get(), 'success' => true, ), 'mysql_version' => array( 'title' => __( 'MySQL Version', 'ct' ), 'desc' => __( 'Compare the current MySQL version with required version.', 'ct' ), 'value' => $mysql_ver, 'success' => $mysql_version['response'], 'message' => $mysql_version['error'], ), ), ); } }