__( 'Reset usage tracking', 'deposits-for-woocommerce'),
'type' => 'link',
'desc' => __( 'This will reset your usage tracking settings, causing it to show the opt-in banner again and not sending any data','ts-tracking'),
'button_text' => 'Reset',
'desc_tip' => true,
'class' => 'button-secondary reset_tracking',
'id' => 'ts_reset_tracking',
);
return $ts_settings;
}
/**
* It will delete the tracking option from the database.
*/
public static function ts_reset_tracking_setting () {
if ( isset ( $_GET [ 'ts_action' ] ) && 'wcdn_reset_tracking' == $_GET [ 'ts_action' ] ) {
delete_option( self::$plugin_prefix . '_allow_tracking' );
delete_option( 'wcdn_ts_tracker_last_send' );
$ts_url = remove_query_arg( 'ts_action' );
wp_safe_redirect( $ts_url );
}
}
/**
* It will add the settinig, which will allow store owner to reset the tracking data. Which will result into stop trakcing the data.
* @hook self::$plugin_prefix . '_add_new_settings'
*
*/
public static function ts_add_reset_tracking_setting ( $value ) {
if ( '' == self::$ts_add_setting_on_page && '' == self::$ts_add_setting_on_section && '' == self::$ts_register_setting ) {
if ( $value['id'] == 'ts_reset_tracking' ) {
$description = WC_Admin_Settings::get_field_description( $value );
$ts_action = self::$ts_settings_page . "&ts_action=" . self::$plugin_prefix . "_reset_tracking";
?>
|
|
Reset' );
// Here, we'll take the first argument of the array and add it to a label next to the checkbox
$html = '';
echo $html;
}
/**
* It will add a cron job for sending the tarcking data.
* By default it will set once in a week interval.
* @hook cron_schedules
* @param array $schedules
* @return array $schedules
*/
public static function ts_add_cron_schedule( $schedules ) {
$schedules[ 'once_in_week' ] = array(
'interval' => 604800, // one week in seconds
'display' => __( 'Once in a Week', self::$ts_plugin_locale )
);
return $schedules;
}
/**
* To capture the data from the client site.
*/
public static function ts_schedule_cron_job () {
if ( ! wp_next_scheduled( self::$plugin_prefix . '_ts_tracker_send_event' ) ) {
wp_schedule_event( time() + 604800, 'once_in_week', self::$plugin_prefix . '_ts_tracker_send_event' );
}
}
/**
* Load the js file in the admin
*
* @since 6.8
* @access public
*/
public static function ts_admin_notices_scripts() {
wp_enqueue_script(
self::$plugin_prefix . 'ts_dismiss_notice',
self::$ts_file_path . '/assets/js/dismiss-notice.js',
'',
'',
false
);
wp_localize_script( 'ts_dismiss_notice', 'ts_dismiss_notice', array (
'ts_prefix_of_plugin' => self::$plugin_prefix,
'ts_admin_url' => admin_url( 'admin-ajax.php' )
) );
}
/**
* Called when the dismiss icon is clicked on the notice.
*
* @since 6.8
* @access public
*/
public static function ts_admin_notices() {
update_option( self::$plugin_prefix . '_allow_tracking', 'dismissed' );
WCDN_TS_Tracker::ts_send_tracking_data( false );
die();
}
/**
* Send the data tracking data to the server.
*
* @access public
*
*/
private static function ts_tracking_actions() {
if ( isset( $_GET[ self::$plugin_prefix . '_tracker_optin' ] ) && isset( $_GET[ self::$plugin_prefix . '_tracker_nonce' ] ) && wp_verify_nonce( $_GET[ self::$plugin_prefix . '_tracker_nonce' ], self::$plugin_prefix . '_tracker_optin' ) ) {
update_option( self::$plugin_prefix . '_allow_tracking', 'yes' );
WCDN_TS_Tracker::ts_send_tracking_data( true );
header( 'Location: ' . $_SERVER[ 'HTTP_REFERER' ] );
} elseif ( isset( $_GET[ self::$plugin_prefix . '_tracker_optout' ] ) && isset( $_GET[ self::$plugin_prefix . '_tracker_nonce' ] ) && wp_verify_nonce( $_GET[ self::$plugin_prefix . '_tracker_nonce' ], self::$plugin_prefix . '_tracker_optout' ) ) {
update_option( self::$plugin_prefix . '_allow_tracking', 'no' );
WCDN_TS_Tracker::ts_send_tracking_data( false );
header( 'Location: ' . $_SERVER[ 'HTTP_REFERER' ] );
}
}
/**
* Adds a data usage tracking notice in the admin
*
* @access public
* @since 6.8
*/
public static function ts_track_usage_data() {
$admin_url = get_admin_url();
echo '';
self::ts_tracking_actions();
if ( 'unknown' === get_option( self::$plugin_prefix . '_allow_tracking', 'unknown' ) ) : ?>
Find out more.', self::$plugin_context ) ); ?>