must_escape = (array) apply_filters( 'tribe_help_must_escape_fields', $this->must_escape ); add_action( 'tribe_help_pre_get_sections', [ $this, 'append_system_info' ], 10 ); add_action( 'delete_option_rewrite_rules', [ $this, 'log_rewrite_rule_purge' ] ); add_action( 'rest_api_init', [ __CLASS__, 'create_sysinfo_endpoint' ] ); add_action( 'wp_ajax_tribe_toggle_sysinfo_optin', [ __CLASS__, 'ajax_sysinfo_optin' ] ); } /** * Display help tab info in events settings * * @param Tribe__Admin__Help_Page $help The Help Page Instance */ public function append_system_info( Tribe__Admin__Help_Page $help ) { $help->add_section_content( 'system-info', $this->formattedSupportStats(), 10 ); } /** * Collect system information for support * * @return array of system data for support */ public function getSupportStats() { global $wpdb; $user = wp_get_current_user(); $plugins = []; if ( function_exists( 'get_plugin_data' ) ) { $plugins_raw = wp_get_active_and_valid_plugins(); foreach ( $plugins_raw as $k => $v ) { $plugin_details = get_plugin_data( $v ); $plugin = $plugin_details['Name']; if ( ! empty( $plugin_details['Version'] ) ) { $plugin .= sprintf( ' version %s', $plugin_details['Version'] ); } if ( ! empty( $plugin_details['Author'] ) ) { $plugin .= sprintf( ' by %s', $plugin_details['Author'] ); } if ( ! empty( $plugin_details['AuthorURI'] ) ) { $plugin .= sprintf( ' (%s)', $plugin_details['AuthorURI'] ); } $plugins[] = $plugin; } } $network_plugins = []; if ( is_multisite() && function_exists( 'get_plugin_data' ) ) { $plugins_raw = wp_get_active_network_plugins(); foreach ( $plugins_raw as $k => $v ) { $plugin_details = get_plugin_data( $v ); $plugin = $plugin_details['Name']; if ( ! empty( $plugin_details['Version'] ) ) { $plugin .= sprintf( ' version %s', $plugin_details['Version'] ); } if ( ! empty( $plugin_details['Author'] ) ) { $plugin .= sprintf( ' by %s', $plugin_details['Author'] ); } if ( ! empty( $plugin_details['AuthorURI'] ) ) { $plugin .= sprintf( ' (%s)', $plugin_details['AuthorURI'] ); } $network_plugins[] = $plugin; } } $mu_plugins = []; if ( function_exists( 'get_mu_plugins' ) ) { $mu_plugins_raw = get_mu_plugins(); foreach ( $mu_plugins_raw as $k => $v ) { $plugin = $v['Name']; if ( ! empty( $v['Version'] ) ) { $plugin .= sprintf( ' version %s', $v['Version'] ); } if ( ! empty( $v['Author'] ) ) { $plugin .= sprintf( ' by %s', $v['Author'] ); } if ( ! empty( $v['AuthorURI'] ) ) { $plugin .= sprintf( ' (%s)', $v['AuthorURI'] ); } $mu_plugins[] = $plugin; } } $keys = apply_filters( 'tribe-pue-install-keys', [] ); //Obfuscate the License Keys for Security if ( is_array( $keys ) && ! empty( $keys ) ) { $secure_keys = []; foreach ( $keys as $plugin => $license ) { $secure_keys[ $plugin ] = preg_replace( '/^(.{4}).*(.{4})$/', '$1' . str_repeat( '#', 32 ) . '$2', $license ); } $keys = $secure_keys; } //Server $server = explode( ' ', $_SERVER['SERVER_SOFTWARE'] ); $server = explode( '/', reset( $server ) ); //PHP Information $php_info = []; $php_vars = [ 'max_execution_time', 'memory_limit', 'upload_max_filesize', 'post_max_size', 'display_errors', 'log_errors', ]; foreach ( $php_vars as $php_var ) { if ( isset( $wpdb->qm_php_vars ) && isset( $wpdb->qm_php_vars[ $php_var ] ) ) { $val = $wpdb->qm_php_vars[ $php_var ]; } else { $val = ini_get( $php_var ); } $php_info[ $php_var ] = $val; } $homepage = get_option( 'show_on_front' ); $homepage_page_id = get_option( 'page_on_front' ); if ( 'page' === $homepage ) { if ( -10 === (int) $homepage_page_id ) { $homepage_page_id .= ' (Main Events Page)'; } else { $homepage_page_id .= ' (' . esc_html( get_the_title( $homepage_page_id ) ) . ')'; } } $site_url = get_site_url(); $systeminfo = [ 'Home URL' => get_home_url(), 'Site URL' => $site_url, 'Site Language' => get_option( 'WPLANG' ) ? get_option( 'WPLANG' ) : esc_html__( 'English', 'tribe-common' ), 'Character Set' => get_option( 'blog_charset' ), 'Name' => $user->display_name, 'Email' => $user->user_email, 'Install keys' => $keys, 'WordPress version' => get_bloginfo( 'version' ), 'Permalink Structure' => $site_url . get_option( 'permalink_structure' ), 'Your homepage displays' => $homepage, 'Homepage page ID' => $homepage_page_id, 'PHP version' => phpversion(), 'PHP' => $php_info, 'Server' => $server[0], 'SAPI' => php_sapi_name(), 'Plugins' => $plugins, 'Network Plugins' => $network_plugins, 'MU Plugins' => $mu_plugins, 'Theme' => wp_get_theme()->get( 'Name' ), 'Multisite' => is_multisite(), 'Settings' => Tribe__Settings_Manager::get_options(), 'WP Timezone' => get_option( 'timezone_string' ) ? get_option( 'timezone_string' ) : esc_html__( 'Unknown or not set', 'tribe-common' ), 'WP GMT Offset' => get_option( 'gmt_offset' ) ? ' ' . get_option( 'gmt_offset' ) : esc_html__( 'Unknown or not set', 'tribe-common' ), 'Default PHP Timezone' => date_default_timezone_get(), 'WP Date Format' => get_option( 'date_format' ), 'WP Time Format' => get_option( 'time_format' ), 'Week Starts On' => get_option( 'start_of_week' ), 'Common Library Dir' => $GLOBALS['tribe-common-info']['dir'], 'Common Library Version' => $GLOBALS['tribe-common-info']['version'], ]; if ( $this->rewrite_rules_purged ) { $systeminfo['rewrite rules purged'] = esc_html__( 'Rewrite rules were purged on load of this help page. Chances are there is a rewrite rule flush occurring in a plugin or theme!', 'tribe-common' ); } /** * Allow for customization of the array of information that's turned into the "System Information" screen in the "Help" admin page. * * @param array $systeminfo The array of information turned into the "System Information" screen. */ $systeminfo = apply_filters( 'tribe-events-pro-support', $systeminfo ); return $systeminfo; } /** * Render system information into a pretty output * * @return string pretty HTML */ public function formattedSupportStats() { $systeminfo = $this->getSupportStats(); $output = ''; $output .= '
%s
' . esc_html__( 'Your system information will only be used by The Events Calendar\'s support team. All information is stored securely. We do not share this information with any third parties.', 'tribe-common' ) . '
'; $opt_in .= ''; return $opt_in; } /** * Method to send back sysinfo * * @param $query * * @return string|void * */ public static function sysinfo_query( $query ) { $optin_key = get_option( 'tribe_systeminfo_optin' ); if ( ! $optin_key ) { wp_send_json_error( __( 'Invalid Key', 'tribe-common' ) ); } $key = $query['key']; if ( $key != $optin_key ) { wp_send_json_error( __( 'Invalid Key', 'tribe-common' ) ); } $support = Tribe__Support::getInstance(); $systeminfo = $support->formattedSupportStats(); return $systeminfo; } /* * Create Unique Enpoint Per Site */ public static function create_sysinfo_endpoint() { $optin_key = get_option( 'tribe_systeminfo_optin' ); if ( $optin_key ) { register_rest_route( 'tribe_events/v2', '/(?P