Plugin Directory

Changeset 2757214


Ignore:
Timestamp:
07/16/2022 01:49:20 AM (4 years ago)
Author:
wpcodelibrary
Message:

update code with phpcs

Location:
wpc-paypal-express-checkout
Files:
2 added
4 edited

Legend:

Unmodified
Added
Removed
  • wpc-paypal-express-checkout/tags/1.2.1/includes/class-wpc-paypal-express-checkout-gateway.php

    r2753956 r2757214  
    9797                    if (isset($this->response['TOKEN']) && !empty($this->response['TOKEN'])) {
    9898                        wp_redirect($this->wpc_ec_payurl($this->response['TOKEN']));
     99                        exit();
     100
    99101                    } else {
    100102                        if ($this->error_display_type == 'detailed') {
     
    105107                        $this->is_order_completed = false;
    106108                        wp_redirect($checkout_url);
     109                        exit();
     110
    107111                    }
    108112                } catch (Exception $e) {
    109113                    wc_add_notice(__('An error occurred, We were unable to process your order, please try again.', WPCPPEC_SLUG), 'error');
    110114                    wp_redirect($checkout_url);
     115                    exit();
     116
    111117                }
    112118                exit;
     
    116122                    return;
    117123                }
    118                 $token = esc_attr($_GET['token']);
     124                $token = sanitize_text_field($_GET['token']);
    119125                try {
    120126                    $this->response = $this->wpc_api()->wpc_ec_details($token);
     
    205211                    } else {
    206212                        wp_redirect(wc_get_checkout_url());
     213                        exit();
    207214                    }
    208215                } catch (Exception $e) {
    209216                    wc_add_notice(__('An error occurred, We were unable to process your order, please try again.', WPCPPEC_SLUG), 'error');
    210217                    wp_redirect($checkout_url);
     218                    exit();
     219
    211220                }
    212221                exit;
     
    256265                }
    257266                wp_redirect($checkout_url);
     267                exit();
     268
    258269            }
    259270            return;
     
    261272            wc_add_notice(__('An error occurred, We were unable to process your order, please try again.', WPCPPEC_SLUG), 'error');
    262273            wp_redirect($cancel_url);
     274            exit();
     275
    263276        }
    264277    }
     
    480493            } else {
    481494                wp_redirect($args['redirect']);
     495                exit();
     496
    482497            }
    483498            exit;
  • wpc-paypal-express-checkout/tags/1.2.1/public/class-wpc-paypal-express-checkout-public.php

    r2753956 r2757214  
    182182                $btn_html = '<div id="wpc_btn_product" style="' . $display_style . '">' . $btn_html . '</div>';
    183183            }
    184             echo $btn_html;
     184            echo wp_kses_post($btn_html);
    185185        }
    186186    }
     
    218218    public function wpc_redirect_after_addto_cart($url) {
    219219        if (isset($_POST['wpc_btn_product']) && !empty($_POST['wpc_btn_product'])) {
    220             return $_POST['wpc_btn_product'];
     220            return wp_kses_post($_POST['wpc_btn_product']);
    221221        } else {
    222222            return $url;
     
    284284
    285285    public function wc_ajax_update_shipping_costs() {
    286         if (!wp_verify_nonce($_POST['nonce'], '_wc_wpc_ec_update_shipping_costs_nonce')) {
    287             wp_die(__('Cheatin&#8217; huh?', WPCPPEC_SLUG));
     286        if (!wp_verify_nonce(sanitize_text_field($_POST['nonce']), '_wc_wpc_ec_update_shipping_costs_nonce')) {
     287            wp_die(esc_html('Cheatin&#8217; huh?'));
    288288        }
    289289        if (!defined('WOOCOMMERCE_CART')) {
     
    298298    public function wpc_ajax_generate_cart() {
    299299        global $post;
    300         if (!wp_verify_nonce($_POST['nonce'], '_wpc_generate_cart_nonce')) {
    301             wp_die(__('Cheatin&#8217; huh?', WPCPPEC_SLUG));
     300        if (!wp_verify_nonce(sanitize_text_field($_POST['nonce']), '_wpc_generate_cart_nonce')) {
     301            wp_die(esc_html('Cheatin&#8217; huh?'));
    302302        }
    303303        if (!defined('WOOCOMMERCE_CART')) {
     
    312312            $qty = !isset($_POST['qty']) ? 1 : absint($_POST['qty']);
    313313            if ($product->is_type('variable')) {
    314                 $attributes = array_map('wc_clean', $_POST['attributes']);
     314                $attributes = array_map('wc_clean', $_POST['attributes']); // phpcs:ignore
    315315                if (version_compare(WC_VERSION, '3.0', '<')) {
    316316                    $variation_id = $product->get_matching_variation($attributes);
  • wpc-paypal-express-checkout/trunk/includes/class-wpc-paypal-express-checkout-gateway.php

    r2080422 r2757214  
    9797                    if (isset($this->response['TOKEN']) && !empty($this->response['TOKEN'])) {
    9898                        wp_redirect($this->wpc_ec_payurl($this->response['TOKEN']));
     99                        exit();
     100
    99101                    } else {
    100102                        if ($this->error_display_type == 'detailed') {
     
    105107                        $this->is_order_completed = false;
    106108                        wp_redirect($checkout_url);
     109                        exit();
     110
    107111                    }
    108112                } catch (Exception $e) {
    109113                    wc_add_notice(__('An error occurred, We were unable to process your order, please try again.', WPCPPEC_SLUG), 'error');
    110114                    wp_redirect($checkout_url);
     115                    exit();
     116
    111117                }
    112118                exit;
     
    116122                    return;
    117123                }
    118                 $token = esc_attr($_GET['token']);
     124                $token = sanitize_text_field($_GET['token']);
    119125                try {
    120126                    $this->response = $this->wpc_api()->wpc_ec_details($token);
     
    205211                    } else {
    206212                        wp_redirect(wc_get_checkout_url());
     213                        exit();
    207214                    }
    208215                } catch (Exception $e) {
    209216                    wc_add_notice(__('An error occurred, We were unable to process your order, please try again.', WPCPPEC_SLUG), 'error');
    210217                    wp_redirect($checkout_url);
     218                    exit();
     219
    211220                }
    212221                exit;
     
    256265                }
    257266                wp_redirect($checkout_url);
     267                exit();
     268
    258269            }
    259270            return;
     
    261272            wc_add_notice(__('An error occurred, We were unable to process your order, please try again.', WPCPPEC_SLUG), 'error');
    262273            wp_redirect($cancel_url);
     274            exit();
     275
    263276        }
    264277    }
     
    480493            } else {
    481494                wp_redirect($args['redirect']);
     495                exit();
     496
    482497            }
    483498            exit;
  • wpc-paypal-express-checkout/trunk/public/class-wpc-paypal-express-checkout-public.php

    r2080422 r2757214  
    182182                $btn_html = '<div id="wpc_btn_product" style="' . $display_style . '">' . $btn_html . '</div>';
    183183            }
    184             echo $btn_html;
     184            echo wp_kses_post($btn_html);
    185185        }
    186186    }
     
    218218    public function wpc_redirect_after_addto_cart($url) {
    219219        if (isset($_POST['wpc_btn_product']) && !empty($_POST['wpc_btn_product'])) {
    220             return $_POST['wpc_btn_product'];
     220            return wp_kses_post($_POST['wpc_btn_product']);
    221221        } else {
    222222            return $url;
     
    284284
    285285    public function wc_ajax_update_shipping_costs() {
    286         if (!wp_verify_nonce($_POST['nonce'], '_wc_wpc_ec_update_shipping_costs_nonce')) {
    287             wp_die(__('Cheatin&#8217; huh?', WPCPPEC_SLUG));
     286        if (!wp_verify_nonce(sanitize_text_field($_POST['nonce']), '_wc_wpc_ec_update_shipping_costs_nonce')) {
     287            wp_die(esc_html('Cheatin&#8217; huh?'));
    288288        }
    289289        if (!defined('WOOCOMMERCE_CART')) {
     
    298298    public function wpc_ajax_generate_cart() {
    299299        global $post;
    300         if (!wp_verify_nonce($_POST['nonce'], '_wpc_generate_cart_nonce')) {
    301             wp_die(__('Cheatin&#8217; huh?', WPCPPEC_SLUG));
     300        if (!wp_verify_nonce(sanitize_text_field($_POST['nonce']), '_wpc_generate_cart_nonce')) {
     301            wp_die(esc_html('Cheatin&#8217; huh?'));
    302302        }
    303303        if (!defined('WOOCOMMERCE_CART')) {
     
    312312            $qty = !isset($_POST['qty']) ? 1 : absint($_POST['qty']);
    313313            if ($product->is_type('variable')) {
    314                 $attributes = array_map('wc_clean', $_POST['attributes']);
     314                $attributes = array_map('wc_clean', $_POST['attributes']); // phpcs:ignore
    315315                if (version_compare(WC_VERSION, '3.0', '<')) {
    316316                    $variation_id = $product->get_matching_variation($attributes);
Note: See TracChangeset for help on using the changeset viewer.