Name . ' ' . $theme_data->Version; $checkout_page = edd_get_option( 'purchase_page', false ); $date = ( false !== $checkout_page ) ? get_post_field( 'post_date', $checkout_page ) : 'not set'; $server = isset( $_SERVER['SERVER_SOFTWARE'] ) ? $_SERVER['SERVER_SOFTWARE'] : ''; // Setup data. $data = array( 'php_version' => phpversion(), 'edd_version' => EDD_VERSION, 'wp_version' => get_bloginfo( 'version' ), 'server' => $server, 'install_date' => $date, 'multisite' => is_multisite(), 'url' => home_url(), 'theme' => $theme, 'email' => get_bloginfo( 'admin_email' ) ); // Retrieve current plugin information. if ( ! function_exists( 'get_plugins' ) ) { include ABSPATH . '/wp-admin/includes/plugin.php'; } // Get plugins $plugins = array_keys( get_plugins() ); $active_plugins = get_option( 'active_plugins', array() ); // Remove active plugins from list so we can show active and inactive separately. foreach ( $plugins as $key => $plugin ) { if ( in_array( $plugin, $active_plugins, true ) ) { unset( $plugins[ $key ] ); } } $data['active_plugins'] = $active_plugins; $data['inactive_plugins'] = $plugins; $data['active_gateways'] = array_keys( edd_get_enabled_payment_gateways() ); $data['products'] = wp_count_posts( 'download' )->publish; $data['download_label'] = edd_get_label_singular( true ); $data['locale'] = get_locale(); $this->data = $data; } /** * Send the data to the EDD server * * @access private * * @param bool $override If we should override the tracking setting. * @param bool $ignore_last_checkin If we should ignore when the last check in was. * * @return bool */ public function send_checkin( $override = false, $ignore_last_checkin = false ) { $home_url = trailingslashit( home_url() ); // Allows us to stop our own site from checking in, and a filter for our additional sites. if ( $home_url === 'https://easydigitaldownloads.com/' || apply_filters( 'edd_disable_tracking_checkin', false ) ) { return false; } if ( ! $this->tracking_allowed() && ! $override ) { return false; } // Send a maximum of once per week. $last_send = $this->get_last_send(); if ( is_numeric( $last_send ) && $last_send > strtotime( '-1 week' ) && ! $ignore_last_checkin ) { return false; } $this->setup_data(); wp_remote_post( 'https://easydigitaldownloads.com/?edd_action=checkin', array( 'method' => 'POST', 'timeout' => 8, 'redirection' => 5, 'httpversion' => '1.1', 'blocking' => false, 'body' => $this->data, 'user-agent' => 'EDD/' . EDD_VERSION . '; ' . get_bloginfo( 'url' ) ) ); update_option( 'edd_tracking_last_send', time() ); return true; } /** * Check for a new opt-in on settings save * * This runs during the sanitation of General settings, thus the return * * @return array */ public function check_for_settings_optin( $input ) { // Send an intial check in on settings save if ( isset( $input['allow_tracking'] ) && $input['allow_tracking'] == 1 ) { $this->send_checkin( true ); } return $input; } /** * Check for a new opt-in via the admin notice * * @return void */ public function check_for_optin() { if ( ! current_user_can( 'manage_options' ) ) { return; } edd_update_option( 'allow_tracking', 1 ); $this->send_checkin( true ); update_option( 'edd_tracking_notice', '1' ); } /** * Check for a new opt-in via the admin notice * * @return void */ public function check_for_optout() { if ( ! current_user_can( 'manage_options' ) ) { return; } edd_delete_option( 'allow_tracking' ); update_option( 'edd_tracking_notice', '1' ); edd_redirect( remove_query_arg( 'edd_action' ) ); } /** * Get the last time a checkin was sent * * @access private * @return false|string */ private function get_last_send() { return get_option( 'edd_tracking_last_send' ); } /** * Schedule a weekly checkin * * We send once a week (while tracking is allowed) to check in, which can be * used to determine active sites. * * @return void */ public function schedule_send() { if ( edd_doing_cron() ) { add_action( 'edd_weekly_scheduled_events', array( $this, 'send_checkin' ) ); } } /** * Display the admin notice to users that have not opted-in or out * * @return void */ public function admin_notice() { static $once = null; // Only 1 notice. if ( ! is_null( $once ) ) { return; } // Already ran once. $once = true; // Bail if already noticed. if ( get_option( 'edd_tracking_notice' ) ) { return; } // Bail if already allowed. if ( edd_get_option( 'allow_tracking', false ) ) { return; } // Bail if user cannot decide. if ( ! current_user_can( 'manage_options' ) ) { return; } // No notices for local installs. if ( edd_is_dev_environment() ) { update_option( 'edd_tracking_notice', '1' ); // Notify the user. } elseif ( edd_is_admin_page() && ! edd_is_admin_page( 'index.php' ) && ! edd_is_insertable_admin_page() ) { $optin_url = add_query_arg( 'edd_action', 'opt_into_tracking' ); $optout_url = add_query_arg( 'edd_action', 'opt_out_of_tracking' ); $base_url_slug = EDD\Admin\Pass_Manager::isPro() ? 'pricing' : 'lite-upgrade'; $pass_url = edd_link_helper( 'https://easydigitaldownloads.com/' . $base_url_slug, array( 'utm_medium' => 'telemetry', 'utm_content' => 'notice', ) ); // Add the notice. EDD()->notices->add_notice( array( 'id' => 'edd-allow-tracking', 'class' => 'updated', 'message' => array( '' . __( 'Help us improve Easy Digital Downloads!', 'easy-digital-downloads' ) . '', sprintf( __( 'Opt-in to sending the EDD team some information about your store, and immediately be emailed a discount, valid towards the purchase of a pass.', 'easy-digital-downloads' ), $pass_url ), __( 'No sensitive data is tracked.', 'easy-digital-downloads' ), '' . __( 'Allow', 'easy-digital-downloads' ) . ' ' . __( 'Do not allow', 'easy-digital-downloads' ) . '' ), 'is_dismissible' => false, ) ); } } }