Troubleshooting_Diagnostics::get_diagnostics_data()
Summary
Sets a wp_send_json answer for the ajax call that holds information about the plugin and the hosting system
Source
File: src/BigCommerce/Settings/Sections/Troubleshooting_Diagnostics.php
'key' => 'multisite', 'value' => is_multisite() ? 'yes' : 'No', ], [ 'label' => __( 'Permalinks', 'bigcommerce' ), 'key' => 'permalinks', 'value' => get_option( 'permalink_structure' ), ], [ 'label' => __( 'Plugins Active', 'bigcommerce' ), 'key' => 'plugins', 'value' => $this->get_plugin_active_names(), ], [ 'label' => __( 'Network Plugins Active', 'bigcommerce' ), 'key' => 'networkplugins', 'value' => is_multisite() ? $this->get_plugin_network_active_names() : [], ], [ 'label' => __( 'Must Have Plugins', 'bigcommerce' ), 'key' => 'muplugins', 'value' => $this->get_mu_plugin_names(), ], ], ], [ 'label' => __( 'Server Environment', 'bigcommerce' ), 'key' => 'server', 'value' => [ [ 'label' => __( 'PHP Version', 'bigcommerce' ), 'key' => 'phpversion', 'value' => phpversion(), ], [ 'label' => __( 'Max Execution Time', 'bigcommerce' ), 'key' => 'max_execution_time', 'value' => ini_get( 'max_execution_time' ), ], [ 'label' => __( 'Memory Limit', 'bigcommerce' ), 'key' => 'memory_limit', 'value' => ini_get( 'memory_limit' ), ], [ 'label' => __( 'Upload Max Filesize', 'bigcommerce' ), 'key' => 'upload_max_filesize', 'value' => ini_get( 'upload_max_filesize' ), ], [ 'label' => __( 'Post Max Size', 'bigcommerce' ), 'key' => 'post_max_size', 'value' => ini_get( 'post_max_size' ), ], [ 'label' => __( 'WP debug', 'bigcommerce' ), 'key' => 'wp_debug', 'value' => ( defined( 'WP_DEBUG' ) && WP_DEBUG ) ? 'Yes' : 'No', ], [ 'label' => __( 'WP debug display', 'bigcommerce' ), 'key' => 'wp_debug_display', 'value' => ( defined( 'WP_DEBUG_DISPLAY' ) && WP_DEBUG_DISPLAY ) ? 'Yes' : 'No', ], [ 'label' => __( 'WP debug log', 'bigcommerce' ), 'key' => 'wp_debug_log', 'value' => ( defined( 'WP_DEBUG_LOG' ) && WP_DEBUG_LOG ) ? 'Yes' : 'No', ], [ 'label' => __( 'Mysql Version', 'bigcommerce' ), 'key' => 'mysqlversion', 'value' => $wpdb->db_version(), ], [ 'label' => __( 'Web Server', 'bigcommerce' ), 'key' => 'webserver', 'value' => $server_software, ], ], ], [ 'label' => __( 'BigCommerce Plugin', 'bigcommerce' ), 'key' => 'bigcommerce', 'value' => [ [ 'label' => __( 'Channel ID', 'bigcommerce' ), 'key' => 'channelid', 'value' => get_option( Channels::CHANNEL_ID ), ], [ 'label' => __( 'Store ID', 'bigcommerce' ), 'key' => 'storeid', 'value' => get_option( Onboarding_Api::STORE_ID, '' ), ], [ 'label' => __( 'Api URL', 'bigcommerce' ), 'key' => 'apiurl', 'value' => get_option( Api_Credentials::OPTION_STORE_URL ), ], [ 'label' => __( 'Import Frequency', 'bigcommerce' ), 'key' => 'importfrequency', 'value' => get_option( Import::OPTION_FREQUENCY ), ], [ 'label' => __( 'Import Status', 'bigcommerce' ), 'key' => 'importstatus', 'value' => $this->previous_status()[ 'status' ], ], [ 'label' => __( 'Last Import', 'bigcommerce' ), 'key' => 'lastimport', 'value' => $this->previous_status()[ 'time_date' ], ], [ 'label' => __( 'Next Import', 'bigcommerce' ), 'key' => 'nextimport', 'value' => $this->next_status()[ 'time_date' ], ], [ 'label' => __( 'Products Count', 'bigcommerce' ), 'key' => 'productcount', 'value' => $products_amount, ], [ 'label' => __( 'Cart Enabled', 'bigcommerce' ), 'key' => 'cartenabled', 'value' => get_option( Cart::OPTION_ENABLE_CART, true ) ? true : false, ], [ 'label' => __( 'Cart Page Slug', 'bigcommerce' ), 'key' => 'cartpage', 'value' => get_post_field( 'post_name', get_option( Cart_Page::NAME ) ), ], [ 'label' => __( 'Archive Slug', 'bigcommerce' ), 'key' => 'archiveslug', 'value' => get_option( Product_Archive::ARCHIVE_SLUG ), ], [ 'label' => __( 'Category Slug', 'bigcommerce' ), 'key' => 'categoryslug', 'value' => get_option( Product_Archive::CATEGORY_SLUG ), ], [ 'label' => __( 'Brand Slug', 'bigcommerce' ), 'key' => 'brandslug', 'value' => get_option( Product_Archive::BRAND_SLUG ), ], [ 'label' => __( 'Account Page Slug', 'bigcommerce' ), 'key' => 'accountslug', 'value' => get_post_field( 'post_name', get_option( Registration_Page::NAME ) ), ], [ 'label' => __( 'Gift Certificate Page Slug', 'bigcommerce' ), 'key' => 'giftcertificateslug', 'value' => get_post_field( 'post_name', get_option( Gift_Certificate_Page::NAME ) ), ], [ 'label' => __( 'Template Overrides', 'bigcommerce' ), 'key' => 'templateoverrides', 'value' => $this->get_template_overrides(), ], ], ], ]; /** * Filter the list of diagnostic data * * @param array $diagnostics */ $diagnostics = apply_filters( 'bigcommerce/diagnostics', $diagnostics ); // Send response wp_send_json( $diagnostics ); // Just in case wp_die( '', '', [ 'response' => null ] ); } /** * @return array List of active plugins */ private function get_plugin_network_active_names() { $active_plugins = (array) get_site_option( 'active_sitewide_plugins', [] ); if ( empty( $active_plugins ) ) { return []; } $plugins = get_plugins(); $plugin_names = []; $active_plugins = array_keys( $active_plugins ); sort( $active_plugins ); foreach ( $active_plugins as $plugin ) { if ( ! validate_file( $plugin ) // $plugin must validate as file && '.php' == substr( $plugin, - 4 ) // $plugin must end with '.php' && file_exists( WP_PLUGIN_DIR . '/' . $plugin ) // $plugin must exist ) { if ( isset( $plugins[ WP_PLUGIN_DIR . '/' . $plugin ] ) ) { $plugin_names[] = [ 'label' => $plugins[ $plugin ][ 'Name' ], 'value' => $plugins[ $plugin ][ 'Version' ], ];