public function process_renew_all()
 {
     if (empty($_POST['edd_renew_all'])) {
         return;
     }
     if (!is_user_logged_in()) {
         return;
     }
     if (!wp_verify_nonce($_POST['edd_sl_renew_all'], 'edd_sl_renew_all_nonce')) {
         wp_die(__('Error', 'edd-sl-renew-all'), __('Nonce verification failed', 'edd-sl-renew-all'), array('response' => 403));
     }
     $renew_type = edd_sanitize_text_field($_POST['edd_sl_renew_type']);
     $license_keys = edd_software_licensing()->get_license_keys_of_user(get_current_user_id());
     switch ($renew_type) {
         case 'expired':
             $stop_date = current_time('timestamp');
             break;
         case 'expiring_1_month':
             $stop_date = strtotime('+1 month', current_time('timestamp'));
             break;
         case 'all':
         default:
             $stop_date = false;
             break;
     }
     if ($license_keys) {
         foreach ($license_keys as $license) {
             if (!edd_software_licensing()->get_license_key($license->ID)) {
                 continue;
             }
             $expiration = edd_software_licensing()->get_license_expiration($license->ID);
             if ('lifetime' === $expiration) {
                 continue;
             }
             if ($stop_date && $expiration > $stop_date) {
                 continue;
             }
             edd_sl_add_renewal_to_cart($license->ID);
         }
         wp_redirect(edd_get_checkout_uri());
         exit;
     }
 }
Exemplo n.º 2
0
function edd_sl_apply_license_renewal($data)
{
    if (!edd_sl_renewals_allowed()) {
        return;
    }
    $license = !empty($data['edd_license_key']) ? sanitize_text_field($data['edd_license_key']) : false;
    $added = edd_sl_add_renewal_to_cart($license, true);
    if ($added && !is_wp_error($added)) {
        $redirect = edd_get_checkout_uri();
    } else {
        $code = $added->get_error_code();
        $message = $added->get_error_message();
        $redirect = add_query_arg(array('edd-sl-error' => $code, 'message' => $message), edd_get_checkout_uri());
    }
    wp_safe_redirect($redirect);
    exit;
}