function hmbkp_remove_exclude_rule()
 {
     if (!isset($_POST['remove_rule']) || empty($_POST['remove_rule'])) {
         return array('error' => __("Error: Empty exclude directory path."));
     }
     $schedule_id = $this->check_schedule();
     $schedule = new HM\BackUpWordPress\Scheduled_Backup(sanitize_text_field($schedule_id));
     $excludes = $schedule->get_excludes();
     $schedule->set_excludes(array_diff($excludes, (array) stripslashes(sanitize_text_field($_POST['remove_rule']))));
     $schedule->save();
     $current_path = urldecode($_POST['browse_dir']);
     if (empty($current_path)) {
         $current_path = null;
     }
     $return = $this->get_excluded($current_path);
     $out['e'] = $return['e'];
     $out['current_browse_dir'] = $_POST['browse_dir'];
     return $out;
 }
Ejemplo n.º 2
0
/**
 * Delete an exclude rule
 *
 * @access public
 * @return void
 */
function hmbkp_remove_exclude_rule()
{
    check_admin_referer('hmbkp_remove_exclude_rule', 'hmbkp-remove_exclude_rule_nonce');
    if (!isset($_GET['hmbkp_remove_exclude'])) {
        die;
    }
    $schedule = new HM\BackUpWordPress\Scheduled_Backup(sanitize_text_field($_GET['hmbkp_schedule_id']));
    $excludes = $schedule->get_excludes();
    $schedule->set_excludes(array_diff($excludes, (array) stripslashes(sanitize_text_field($_GET['hmbkp_remove_exclude']))));
    $schedule->save();
    wp_safe_redirect(wp_get_referer(), '303');
    die;
}