| @@ -34,4 +34,30 @@ | ||
| 34 | 34 | $replace = array( '', '', '', '' ); |
| 35 | 35 | $result = str_replace( $search, $replace, $string ); |
| 36 | 36 | return $result; |
| 37 | 37 | } |
| 38 | + | |
| 39 | + | |
| 40 | +add_action( 'wp_ajax_wpdbbkp_email_unsubscribe', 'wpdbbkp_unsubcribe_email_notification' ); | |
| 41 | +add_action( 'wp_ajax_nopriv_wpdbbkp_email_unsubscribe', 'wpdbbkp_unsubcribe_email_notification' ); | |
| 42 | + | |
| 43 | +function wpdbbkp_unsubcribe_email_notification(){ | |
| 44 | + if(isset($_GET['unsubscribe_token'])){ // phpcs:ignore WordPress.Security.NonceVerification.Recommended -- unsubscribe_token is doing the job of nonce. | |
| 45 | + $saved_token=get_option('wpdbbkp_unsubscribe_token',false); | |
| 46 | + if($saved_token && $saved_token==$_GET['unsubscribe_token']){ // phpcs:ignore WordPress.Security.NonceVerification.Recommended -- unsubscribe_token is doing the job of nonce. | |
| 47 | + $current_status = get_option( 'wp_db_backup_destination_Email',false); | |
| 48 | + if($current_status == 1){ | |
| 49 | + update_option('wp_db_backup_destination_Email', 0 , false); | |
| 50 | + delete_option('wpdbbkp_unsubscribe_token'); | |
| 51 | + echo '<h3 align="center">'.esc_html__( 'You have successfully unsubscribed from recieveing backup notification on Email', 'wpdbbkp' ).'</h3>'; | |
| 52 | + }else if($current_status == 0){ | |
| 53 | + echo '<h3 align="center">'.esc_html__( 'You have already unsubscribed.', 'wpdbbkp' ).'</h3>'; | |
| 54 | + }else{ | |
| 55 | + echo '<h3 align="center">'.esc_html__( 'Invalid Request', 'wpdbbkp' ).'</h3>'; | |
| 56 | + } | |
| 57 | + } | |
| 58 | + else{ | |
| 59 | + echo '<h3 align="center">'.esc_html__( 'Unauthorised Access', 'wpdbbkp' ).'</h3>'; | |
| 60 | + } | |
| 61 | + } | |
| 62 | + wp_die(); | |
| 63 | +} | |