Skip to content

Commit d778a80

Browse files
authored
Merge pull request #219 from TycheSoftwares/branch-218
fix #218
2 parents 00f522a + c4d5878 commit d778a80

File tree

1 file changed

+14
-10
lines changed

1 file changed

+14
-10
lines changed

includes/component/tracking-data/ts-tracking.php

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -134,9 +134,10 @@ public static function ts_add_new_settings_field ( $ts_settings ) {
134134
/**
135135
* It will delete the tracking option from the database.
136136
*/
137-
public static function ts_reset_tracking_setting () {
137+
public static function ts_reset_tracking_setting() {
138+
139+
if ( isset( $_GET['ts_action'] ) && 'wcdn_reset_tracking' === $_GET['ts_action'] && isset( $_GET[ self::$plugin_prefix . '_tracker_reset_nonce' ] ) && wp_verify_nonce( sanitize_key( $_GET[ self::$plugin_prefix . '_tracker_reset_nonce' ] ), self::$plugin_prefix . '_tracker_reset' ) ) {
138140

139-
if ( isset ( $_GET [ 'ts_action' ] ) && 'wcdn_reset_tracking' == $_GET [ 'ts_action' ] ) {
140141
delete_option( self::$plugin_prefix . '_allow_tracking' );
141142
delete_option( 'wcdn_ts_tracker_last_send' );
142143
$ts_url = remove_query_arg( 'ts_action' );
@@ -154,7 +155,8 @@ public static function ts_add_reset_tracking_setting ( $value ) {
154155
if ( '' == self::$ts_add_setting_on_page && '' == self::$ts_add_setting_on_section && '' == self::$ts_register_setting ) {
155156
if ( $value['id'] == 'ts_reset_tracking' ) {
156157
$description = WC_Admin_Settings::get_field_description( $value );
157-
$ts_action = self::$ts_settings_page . "&ts_action=" . self::$plugin_prefix . "_reset_tracking";
158+
$nonce = wp_create_nonce( self::$plugin_prefix . '_tracker_reset' );
159+
$ts_action = add_query_arg( array( self::$plugin_prefix . '_tracker_reset_nonce' => $nonce, 'ts_action' => self::$plugin_prefix . '_reset_tracking' ), self::$ts_settings_page );
158160
?>
159161

160162
<tr valign="top">
@@ -197,17 +199,19 @@ public static function ts_reset_tracking_setting_section_callback ( ) {
197199

198200
/**
199201
* It will add the Reset button on the settings page.
200-
* @param array $args
202+
*
203+
* @param array $args Arguments.
201204
*/
202-
public static function ts_rereset_tracking_callback ( $args ) {
205+
public static function ts_rereset_tracking_callback( $args ) {
203206
$wcap_restrict_domain_address = get_option( 'wcap_restrict_domain_address' );
204207
$domain_value = isset( $wcap_restrict_domain_address ) ? esc_attr( $wcap_restrict_domain_address ) : '';
205-
// Next, we update the name attribute to access this element's ID in the context of the display options array
206-
// We also access the show_header element of the options collection in the call to the checked() helper function
207-
$ts_action = self::$ts_settings_page . "&amp;ts_action=" . self::$plugin_prefix . "_reset_tracking";
208+
// Next, we update the name attribute to access this element's ID in the context of the display options array.
209+
// We also access the show_header element of the options collection in the call to the checked() helper function.
210+
$nonce = wp_create_nonce( self::$plugin_prefix . '_tracker_reset' );
211+
$ts_action = add_query_arg( array( self::$plugin_prefix . '_tracker_reset_nonce' => $nonce, 'ts_action' => self::$plugin_prefix . '_reset_tracking' ), self::$ts_settings_page );
208212
printf( '<a href="'.$ts_action.'" class="button button-large reset_tracking">Reset</a>' );
209-
210-
// Here, we'll take the first argument of the array and add it to a label next to the checkbox
213+
214+
// Here, we'll take the first argument of the array and add it to a label next to the checkbox.
211215
$html = '<label for="wcap_restrict_domain_address_label"> ' . $args[0] . '</label>';
212216
echo $html;
213217
}

0 commit comments

Comments
 (0)