| 1 |
<?php |
| 2 |
/** |
| 3 |
* Backup Filters |
| 4 |
* |
| 5 |
* @package wpdbbkp |
| 6 |
*/ |
| 7 |
|
| 8 |
add_filter( 'upgrader_pre_install', 'wp_db_backup_upgrader_pre_install', 10, 2 ); |
| 9 |
|
| 10 |
/** |
| 11 |
* Filter for upgrade theme or plugin. |
| 12 |
* |
| 13 |
* @param bool $response - Installation response. |
| 14 |
* @param array $hook_extra - Extra arguments passed to hooked filters. |
| 15 |
* @return bool |
| 16 |
*/ |
| 17 |
function wp_db_backup_upgrader_pre_install( $response, $hook_extra ) { |
| 18 |
$wp_db_backup_enable_auto_upgrade = get_option( 'wp_db_backup_enable_auto_upgrade' ); |
| 19 |
if ( 1 === $wp_db_backup_enable_auto_upgrade ) { |
| 20 |
$before_update_backup_obj = new wpdb_Admin(); |
| 21 |
$before_update_backup_obj->wp_db_backup_event_process(); |
| 22 |
} |
| 23 |
return $response; |
| 24 |
} |
| 25 |
|
| 26 |
/** |
| 27 |
* Validating input data for sequrity. |
| 28 |
* |
| 29 |
* @param string $string - Input data. |
| 30 |
* @return string |
| 31 |
*/ |
| 32 |
function wp_db_filter_data( $string ) { |
| 33 |
$search = array( 'animation-name', 'alert(', 'style=', 'onanimationstart' ); |
| 34 |
$replace = array( '', '', '', '' ); |
| 35 |
$result = str_replace( $search, $replace, $string ); |
| 36 |
return $result; |
| 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 |
} |
| 64 |
|