plugin_slug = $plugin_slug; $this->config = wp_parse_args( $config, $this->get_default_config() ); } /** * Get Default configuration. * * @return array Default configuration. */ protected function get_default_config() { return array( 'show_post_types' => true, 'show_taxonomies' => true, 'show_users' => true, 'show_plugins' => true, 'show_network_plugins' => true, 'show_session_details' => false, ); } /** * Render system info. * * PHPCS is disabled for this function since alignment will mess up the system info output. * phpcs:disable */ public function render() { global $wpdb; ?> plugin_slug . '-system-info.txt'; } nocache_headers(); header( 'Content-type: text/plain' ); header( 'Content-Disposition: attachment; filename="' . $file_name . '"' ); echo wp_strip_all_tags( $_POST[ $this->plugin_slug . '-system-info'] ); die(); } /** * Get current theme name. * * @return string Current theme name. */ protected function get_current_theme_name() { if ( get_bloginfo( 'version' ) < '3.4' ) { $theme_data = get_theme_data( get_stylesheet_directory() . '/style.css' ); return $theme_data['Name'] . ' ' . $theme_data['Version']; } $theme_data = wp_get_theme(); return $theme_data->Name . ' ' . $theme_data->Version; } /** * Try to identity the hosting provider. * * @return string Web host name if identified, empty string otherwise. */ protected function print_web_host_details() { $host = ''; if ( defined( 'WPE_APIKEY' ) ) { $host = 'WP Engine'; } elseif ( defined( 'PAGELYBIN' ) ) { $host = 'Pagely'; } /** * Filter the identified webhost. * * @since 1.0.0 * * @param string $host Identified web host. * @param string $plugin_name Plugin slug. */ $host = apply_filters( 'system_info_host', $host, $this->plugin_slug ); if ( empty( $host ) ) { return; } echo '-- Hosting Provider --', "\n\n"; echo 'Host: ', $host, "\n"; echo "\n"; } /** * Print plugins that are currently active. */ protected function print_current_plugins() { if ( ! $this->config['show_plugins'] ) { return; } echo "\n"; echo '-- WordPress Active Plugins --', "\n\n"; $plugins = get_plugins(); $active_plugins = get_option( 'active_plugins', array() ); foreach ( $plugins as $plugin_path => $plugin ) { // If the plugin isn't active, don't show it. if ( ! in_array( $plugin_path, $active_plugins, true ) ) { continue; } echo $plugin['Name'] . ': ' . $plugin['Version'] . "\n"; } echo "\n"; } /** * Print network active plugins. */ protected function print_network_active_plugins() { if ( ! is_multisite() || ! $this->config['show_network_plugins'] ) { return; } echo "\n"; echo '-- Network Active Plugins --'; $plugins = wp_get_active_network_plugins(); $active_plugins = get_site_option( 'active_sitewide_plugins', array() ); foreach ( $plugins as $plugin_path ) { $plugin_base = plugin_basename( $plugin_path ); // If the plugin isn't active, don't show it. if ( ! array_key_exists( $plugin_base, $active_plugins ) ) { continue; } $plugin = get_plugin_data( $plugin_path ); echo $plugin['Name'] . ' :' . $plugin['Version'] . "\n"; } echo "\n"; } /** * Print the list of post types and the number of posts in them. * * @param int $spacing Spacing length. */ protected function print_post_types( $spacing = 26 ) { if ( ! $this->config['show_post_types'] ) { return; } $post_types = get_post_types(); echo 'Registered Post types: ', implode( ', ', $post_types ), "\n"; foreach ( $post_types as $post_type ) { echo $post_type; if ( strlen( $post_type ) < $spacing ) { echo str_repeat( ' ', $spacing - strlen( $post_type ) ); } $post_count = wp_count_posts( $post_type ); foreach ( $post_count as $key => $value ) { echo $key, '=', $value, ', '; } echo "\n"; } } /** * Print the list of taxonomies together with term count. */ protected function print_taxonomies() { if ( ! $this->config['show_taxonomies'] ) { return; } echo "\n"; echo 'Registered Taxonomies: '; $taxonomies = get_taxonomies(); foreach ( $taxonomies as $taxonomy ) { echo $taxonomy, ' (', wp_count_terms( $taxonomy, array( 'hide_empty' => false ) ), '), '; } echo "\n"; } /** * Print list of user roles and the number of users in each role. */ protected function print_user_roles() { global $wp_roles; if ( ! $this->config['show_users'] ) { return; } echo "\n"; echo 'Users: '; foreach ( $wp_roles->roles as $role => $role_details ) { echo $role_details['name'], ' (', absint( $this->get_user_count_by_role( $role ) ), '), '; } echo "\n"; } /** * Print session information. */ protected function print_session_information() { if ( ! $this->config['show_session_details'] ) { return; } ?> -- Session Configuration -- Session: Session Name: Cookie Path: Save Path: Use Cookies: Use Only Cookies: