1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104
<?php
include_once( 'class-ts-tracker.php' );
class TS_tracking {
public function __construct() {
add_action( 'admin_notices', array( &$this, 'orddd_track_usage_data' ) );
add_action( 'admin_footer', array( __CLASS__, 'orddd_admin_notices_scripts' ) );
add_action( 'wp_ajax_orddd_admin_notices', array( __CLASS__, 'orddd_admin_notices' ) );
}
public static function orddd_admin_notices_scripts() {
wp_enqueue_script(
'dismiss-notice.js',
plugins_url('/js/dismiss-notice.js', __FILE__),
'',
'',
false
);
}
public static function orddd_admin_notices() {
update_option( 'orddd_allow_tracking', 'dismissed' );
TS_Tracker::ts_send_tracking_data( false );
die();
}
private function ts_tracking_actions() {
if ( isset( $_GET[ 'orddd_tracker_optin' ] ) && isset( $_GET[ 'orddd_tracker_nonce' ] ) && wp_verify_nonce( $_GET[ 'orddd_tracker_nonce' ], 'orddd_tracker_optin' ) ) {
update_option( 'orddd_allow_tracking', 'yes' );
TS_Tracker::ts_send_tracking_data( true );
header( 'Location: ' . $_SERVER[ 'HTTP_REFERER' ] );
} elseif ( isset( $_GET[ 'orddd_tracker_optout' ] ) && isset( $_GET[ 'orddd_tracker_nonce' ] ) && wp_verify_nonce( $_GET[ 'orddd_tracker_nonce' ], 'orddd_tracker_optout' ) ) {
update_option( 'orddd_allow_tracking', 'no' );
TS_Tracker::ts_send_tracking_data( false );
header( 'Location: ' . $_SERVER[ 'HTTP_REFERER' ] );
}
}
function orddd_track_usage_data() {
$admin_url = get_admin_url();
echo '<input type="hidden" id="admin_url" value="' . $admin_url . '"/>';
$this->ts_tracking_actions();
if ( 'unknown' === get_option( 'orddd_allow_tracking', 'unknown' ) ) : ?>
<div class="orddd-message orddd-tracker notice notice-info is-dismissible" style="position: relative;">
<div style="position: absolute;"><img class="site-logo" src="<?php echo plugins_url(); ?>/order-delivery-date/images/site-logo-new.jpg"></div>
<p style="margin: 10px 0 10px 130px; font-size: medium;">
<?php print( __( 'Want to help make Order Delivery Date even more awesome? Allow Order Delivery Date to collect non-sensitive diagnostic data and usage information and get 20% off on your next purchase. <a href="https://www.tychesoftwares.com/order-delivery-date-usage-tracking/">Find out more</a>.', 'order-delivery-date' ) ); ?></p>
<p class="submit">
<a class="button-primary button button-large" href="<?php echo esc_url( wp_nonce_url( add_query_arg( 'orddd_tracker_optin', 'true' ), 'orddd_tracker_optin', 'orddd_tracker_nonce' ) ); ?>"><?php esc_html_e( 'Allow', 'order-delivery-date' ); ?></a>
<a class="button-secondary button button-large skip" href="<?php echo esc_url( wp_nonce_url( add_query_arg( 'orddd_tracker_optout', 'true' ), 'orddd_tracker_optout', 'orddd_tracker_nonce' ) ); ?>"><?php esc_html_e( 'No thanks', 'order-delivery-date' ); ?></a>
</p>
</div>
<?php endif;
}
}
$TS_tracking = new TS_tracking();