* @return array A list of key-value pairs containing the analytics data. */ public static function all() { global $wp_version, $tinymce_version, $required_php_version, $required_mysql_version, $wpdb; // Retrieve objects needed to build the analytics array $theme = wp_get_theme(); $locale = explode( '_', get_locale() ); $rendering_modes = array( 'webcomponent' => __( 'Webcomponent', 'affilizz' ), 'hybrid' => __( 'Hybrid (server-side rendering + webcomponent)', 'affilizz' ), ); $current_rendering_mode = \Affilizz\Core::get_current_rendering_mode(); $current_rendering_mode = isset( $rendering_modes[ $current_rendering_mode ] ) ? $rendering_modes[ $current_rendering_mode ] : __( 'N/A', 'affilizz' ); $javascript_status = get_option( 'affilizz_disable_javascript', __( 'N/A', 'affilizz' ) ); $javascript_status = ( $javascript_status == 1 || $javascript_status == '1' ) ? __( 'Enabled', 'affilizz' ) : __( 'Disabled', 'affilizz' ); $selective_enqueing = get_option( 'affilizz_selective_enqueue', __( 'N/A', 'affilizz' ) ); $selective_enqueing = ( $selective_enqueing == 1 || $selective_enqueing == '1' ) ? __( 'Enabled', 'affilizz' ) : __( 'Disabled', 'affilizz' ); $javascript_debug_mode = get_option( 'affilizz_javascript_debug_mode', __( 'N/A', 'affilizz' ) ); $javascript_debug_mode = ( $javascript_debug_mode == 1 || $javascript_debug_mode == '1' ) ? __( 'Enabled', 'affilizz' ) : __( 'Disabled', 'affilizz' ); $plugin_data = array( 'RequiresPHP' => __( 'N/A', 'affilizz' ), 'RequiresWP' => __( 'N/A', 'affilizz' ), 'Version' => __( 'N/A', 'affilizz' ), ); if ( ! function_exists( 'get_plugin_data' ) ) { require_once ABSPATH . 'wp-admin/includes/plugin.php'; } if ( function_exists( 'get_plugin_data' ) ) { $plugin_data = get_plugin_data( trailingslashit( AFFILIZZ_DIRECTORY ) . 'init.php' ); $required_php_version = $plugin_data['RequiresPHP']; $required_wp_version = $plugin_data['RequiresWP']; } // Analytics data array building $data = array( 'operating_system' => array( 'key' => __( 'Operating system', 'affilizz' ), 'value' => explode( ' ', trim( php_uname() ) )[0], ), 'server_flavor' => array( 'key' => __( 'PHP web server', 'affilizz' ), 'value' => self::get_server_flavor(), ), 'php_version' => array( 'key' => __( 'PHP version', 'affilizz' ), 'value' => self::clean_version( phpversion() ), ), 'required_php_version' => array( 'key' => __( 'Required PHP version', 'affilizz' ), 'value' => self::clean_version( $required_php_version ), ), 'mysql_version' => array( 'key' => __( 'MySQL version', 'affilizz' ), 'value' => $wpdb->db_version(), ), 'required_mysql_version' => array( 'key' => __( 'Required MySQL version', 'affilizz' ), 'value' => self::clean_version( $required_mysql_version ), ), 'wordpress_version' => array( 'key' => __( 'WordPress version', 'affilizz' ), 'value' => self::clean_version( $wp_version ), ), 'required_wordpress_version' => array( 'key' => __( 'Required WordPress version', 'affilizz' ), 'value' => self::clean_version( $required_wp_version ), ), 'tinymce_version' => array( 'key' => __( 'TinyMCE version', 'affilizz' ), 'value' => self::clean_version( $tinymce_version ), ), 'theme_name' => array( 'key' => __( 'Theme name', 'affilizz' ), 'value' => $theme->get( 'Name' ), ), 'active_plugins' => array( 'key' => __( 'Active plugins', 'affilizz' ), 'value' => self::get_active_plugins_readable_list(), ), 'locale' => array( 'key' => __( 'Current locale', 'affilizz' ), 'value' => ( empty( $locale[0] ) ? __( 'Unknown locale', 'affilizz' ) : $locale[0] ), ), 'multisite' => array( 'key' => __( 'Multisite installation', 'affilizz' ), 'value' => is_multisite() ? __( 'Yes', 'affilizz' ) : __( 'No', 'affilizz' ), ), 'document_root' => array( 'key' => __( 'Document root', 'affilizz' ), 'value' => ( ! empty( $_SERVER['DOCUMENT_ROOT'] ) ? trailingslashit( sanitize_text_field( wp_unslash( $_SERVER['DOCUMENT_ROOT'] ) ) ) : __( 'N/A', 'affilizz' ) ), ), 'affilizz_version' => array( 'key' => __( 'Affilizz version', 'affilizz' ), 'value' => ( ! empty( AFFILIZZ_VERSION ) ? AFFILIZZ_VERSION : __( 'N/A', 'affilizz' ) ), ), 'affilizz_assets_build_version' => array( 'key' => __( 'Affilizz assets version', 'affilizz' ), 'value' => ( ! empty( AFFILIZZ_ASSETS_BUILD_VERSION ) ? AFFILIZZ_ASSETS_BUILD_VERSION : __( 'N/A', 'affilizz' ) ), ), 'affilizz_channel' => array( 'key' => __( 'Channel', 'affilizz' ), 'value' => get_option( 'affilizz_channel', __( 'N/A', 'affilizz' ) ), ), 'affilizz_channel_label' => array( 'key' => __( 'Channel label', 'affilizz' ), 'value' => get_option( 'affilizz_channel_label', __( 'N/A', 'affilizz' ) ), ), 'affilizz_organization' => array( 'key' => __( 'Organization', 'affilizz' ), 'value' => get_option( 'affilizz_organization', __( 'N/A', 'affilizz' ) ), ), 'affilizz_organization_label' => array( 'key' => __( 'Organization label', 'affilizz' ), 'value' => get_option( 'affilizz_organization_label', __( 'N/A', 'affilizz' ) ), ), 'affilizz_media' => array( 'key' => __( 'Media', 'affilizz' ), 'value' => get_option( 'affilizz_media', __( 'N/A', 'affilizz' ) ), ), 'affilizz_media_label' => array( 'key' => __( 'Media label', 'affilizz' ), 'value' => get_option( 'affilizz_media_label', __( 'N/A', 'affilizz' ) ), ), 'affilizz_api_key' => array( 'key' => __( 'API Key', 'affilizz' ), 'value' => get_option( 'affilizz_api_key', __( 'N/A', 'affilizz' ) ), ), 'affilizz_proxy_uuid' => array( 'key' => __( 'Current proxy UUID', 'affilizz' ), 'value' => get_option( 'affilizz_proxy_uuid', __( 'N/A', 'affilizz' ) ), ), 'affilizz_rendering_mode' => array( 'key' => __( 'Affilizz rendering mode', 'affilizz' ), 'value' => $current_rendering_mode, ), 'affilizz_disable_javascript' => array( 'key' => __( 'Affilizz javascript file injection', 'affilizz' ), 'value' => $javascript_status, ), 'affilizz_selective_enqueue' => array( 'key' => __( 'Selective assets load', 'affilizz' ), 'value' => $selective_enqueing, ), 'affilizz_javascript_debug_mode' => array( 'key' => __( 'JavaScript debug mode', 'affilizz' ), 'value' => $javascript_debug_mode, ), ); return $data; } private static function clean_version( $version_string = '0' ) { return preg_replace( '@^(\d\.\d+).*@', '\1', $version_string ); } private static function get_server_flavor() { global $is_nginx, $is_apache, $is_iis7, $is_IIS; if ( $is_nginx ) { return 'NGINX'; } if ( $is_apache ) { return 'Apache'; } if ( $is_iis7 ) { return 'IIS 7'; } if ( $is_IIS ) { return 'IIS'; } return __( 'Unknown server flavor', 'affilizz' ); } private static function get_active_plugins_readable_list() { // Get the plugin objects $return_array = array(); foreach ( get_plugins() as $plugin => $plugin_metadata ) { if ( ! is_plugin_active( $plugin ) ) { continue; } $return_array[ $plugin ] = trim( implode( ' ', array( $plugin_metadata['Name'], $plugin_metadata['Version'], /* translators: %s: whether the plugin is network activated. */ ( is_multisite() ? '(' . sprintf( __( 'Network : %s', 'affilizz' ), ( $plugin_metadata['Network'] ) ? __( 'Yes', 'affilizz' ) : __( 'No', 'affilizz' ) ) . ')' : '' ), ) ) ); } return implode( ', ', $return_array ); } }