Skip to content

Commit

Permalink
Merge pull request #1155 from angelleye/PFW-168
Browse files Browse the repository at this point in the history
Adjustments to "Require Secure Checkout" in latest versions of WooCom…
  • Loading branch information
Andrew Angell committed Jul 2, 2018
2 parents f2d40f6 + 3097def commit 0f71346
Show file tree
Hide file tree
Showing 8 changed files with 15 additions and 38 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,6 @@

class WC_Gateway_PayPal_Express_Function_AngellEYE {

public static function is_ssl_enable() {
try {
if (is_ssl() || get_option('woocommerce_force_ssl_checkout') == 'yes') {
return true;
} else {
return false;
}
} catch (Exception $ex) {

}
}

public function express_checkout_is_available() {
try {
$is_enable = $this->express_checkout_get_option('enabled');
Expand Down
4 changes: 2 additions & 2 deletions classes/wc-gateway-braintree-angelleye.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ class WC_Gateway_Braintree_AngellEYE extends WC_Payment_Gateway_CC {
function __construct() {
$this->id = 'braintree';
$this->icon = $this->get_option('card_icon', plugins_url('/assets/images/cards.png', plugin_basename(dirname(__FILE__))));
if (is_ssl() || get_option('woocommerce_force_ssl_checkout') == 'yes') {
if (is_ssl() || 'yes' === get_option( 'woocommerce_force_ssl_checkout' )) {
$this->icon = preg_replace("/^http:/i", "https:", $this->icon);
}
$this->icon = apply_filters('woocommerce_braintree_icon', $this->icon);
Expand Down Expand Up @@ -149,7 +149,7 @@ public function checks() {
if (version_compare(phpversion(), '5.2.1', '<')) {
echo '<div class="error"><p>' . sprintf(__('Braintree Error: Braintree requires PHP 5.2.1 and above. You are using version %s.', 'paypal-for-woocommerce'), phpversion()) . '</p></div>';
}
if ('no' == get_option('woocommerce_force_ssl_checkout') && !class_exists('WordPressHTTPS') && $this->enable_braintree_drop_in == false && $this->sandbox == false) {
if (!is_ssl() && $this->enable_braintree_drop_in == false && $this->sandbox == false) {
echo '<div class="error"><p>' . sprintf(__('Braintree is enabled, but the <a href="%s">force SSL option</a> is disabled; your checkout may not be secure! Please enable SSL and ensure your server has a valid SSL certificate - Braintree custome credit card UI will only work in sandbox mode.', 'paypal-for-woocommerce'), admin_url('admin.php?page=wc-settings&tab=checkout')) . '</p></div>';
}
$this->add_dependencies_admin_notices();
Expand Down
2 changes: 1 addition & 1 deletion classes/wc-gateway-paypal-advanced-angelleye.php
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ public function __construct() {
$this->is_encrypt = $this->get_option('is_encrypt', 'no');
$this->transtype = $this->get_option('transtype');
$this->mobilemode = $this->get_option('mobilemode', 'yes');
if ( is_ssl() || get_option( 'woocommerce_force_ssl_checkout' ) == 'yes' ) {
if ( is_ssl() || 'yes' === get_option( 'woocommerce_force_ssl_checkout' ) ) {
$this->icon = preg_replace("/^http:/i", "https:", $this->icon);
}
$this->icon = apply_filters('woocommerce_paypal_advanced_icon', $this->icon);
Expand Down
2 changes: 1 addition & 1 deletion classes/wc-gateway-paypal-credit-cards-rest-angelleye.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ function __construct() {
$this->init_form_fields();
$this->init_settings();
$this->icon = $this->get_option('card_icon', plugins_url('/assets/images/cards.png', plugin_basename(dirname(__FILE__))));
if (is_ssl()) {
if ( is_ssl() || 'yes' === get_option( 'woocommerce_force_ssl_checkout' ) ) {
$this->icon = preg_replace("/^http:/i", "https:", $this->icon);
}
$this->icon = apply_filters('woocommerce_paypal_credit_card_rest_icon', $this->icon);
Expand Down
10 changes: 5 additions & 5 deletions classes/wc-gateway-paypal-express-angelleye.php
Original file line number Diff line number Diff line change
Expand Up @@ -456,16 +456,16 @@ public function get_icon() {
if ($this->checkout_with_pp_button_type == 'customimage') {
$image_path = $this->pp_button_type_my_custom;
}
if ( is_ssl() || get_option( 'woocommerce_force_ssl_checkout' ) == 'yes' ) {
if ( is_ssl() || 'yes' === get_option( 'woocommerce_force_ssl_checkout' ) ) {
$image_path = str_replace( 'http:', 'https:', $image_path );
}
if ($this->paypal_account_optional == 'no' && $this->show_paypal_credit == 'yes' && $this->checkout_with_pp_button_type == 'paypalimage') {
$image_path = plugins_url('/assets/images/paypal.png', plugin_basename(dirname(__FILE__)));
if ( is_ssl() || get_option( 'woocommerce_force_ssl_checkout' ) == 'yes' ) {
if ( is_ssl() || 'yes' === get_option( 'woocommerce_force_ssl_checkout' ) ) {
$image_path = str_replace( 'http:', 'https:', $image_path );
}
$image_path_two = plugins_url('/assets/images/PP_credit_logo.png', plugin_basename(dirname(__FILE__)));
if ( is_ssl() || get_option( 'woocommerce_force_ssl_checkout' ) == 'yes' ) {
if ( is_ssl() || 'yes' === get_option( 'woocommerce_force_ssl_checkout' ) ) {
$image_path_two = str_replace( 'http:', 'https:', $image_path_two );
}
$icon = "<img src=\"$image_path\" alt='" . __('Pay with PayPal', 'paypal-for-woocommerce') . "'/>";
Expand All @@ -480,7 +480,7 @@ public function get_icon() {
public function init_form_fields() {
$rest_url = get_admin_url() . 'admin.php?page=wc-settings&tab=checkout&section=paypal_express&pms_reset=true';
$require_ssl = '';
if (!AngellEYE_Gateway_Paypal::is_ssl()) {
if ( is_ssl() || 'yes' === get_option( 'woocommerce_force_ssl_checkout' ) ) {
$require_ssl = __('This image requires an SSL host. Please upload your image to <a target="_blank" href="http://www.sslpic.com">www.sslpic.com</a> and enter the image URL here.', 'paypal-for-woocommerce');
}
$skip_final_review_option_not_allowed_guest_checkout = '';
Expand Down Expand Up @@ -1353,7 +1353,7 @@ public static function angelleye_get_paypalimage() {
$image_path = plugins_url('/assets/images/dynamic-image/' . AngellEYE_Utility::get_button_locale_code() . '.png', plugin_basename(dirname(__FILE__)));
} else {
$image_path = plugins_url('/assets/images/dynamic-image/' . AngellEYE_Utility::get_button_locale_code() . '.gif', plugin_basename(dirname(__FILE__)));
if ( is_ssl() || get_option( 'woocommerce_force_ssl_checkout' ) == 'yes' ) {
if ( is_ssl() || 'yes' === get_option( 'woocommerce_force_ssl_checkout' ) ) {
$image_path = preg_replace("/^http:/i", "https:", $image_path);
}
}
Expand Down
4 changes: 2 additions & 2 deletions classes/wc-gateway-paypal-pro-angelleye.php
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ function __construct() {

//fix ssl for image icon
$this->icon = $this->get_option('card_icon', plugins_url('/assets/images/cards.png', plugin_basename(dirname(__FILE__))));
if ( is_ssl() || get_option( 'woocommerce_force_ssl_checkout' ) == 'yes' ) {
if ( is_ssl() || 'yes' === get_option( 'woocommerce_force_ssl_checkout' ) ) {
$this->icon = preg_replace("/^http:/i", "https:", $this->icon);
}
$this->icon = apply_filters('woocommerce_paypal_pro_icon', $this->icon);
Expand Down Expand Up @@ -462,7 +462,7 @@ public function admin_options() {
*/
function is_available() {
if ($this->enabled == "yes") :
if ($this->testmode == false && get_option('woocommerce_force_ssl_checkout') == 'no' && !class_exists('WordPressHTTPS')) return false;
if ($this->testmode == false && !is_ssl()) return false;
// Currency check
if (!in_array(get_woocommerce_currency(), apply_filters('woocommerce_paypal_pro_supported_currencies', array('AUD', 'CAD', 'CZK', 'DKK', 'EUR', 'HUF', 'JPY', 'NOK', 'NZD', 'PLN', 'GBP', 'SGD', 'SEK', 'CHF', 'USD')))) return false;
// Required fields check
Expand Down
2 changes: 1 addition & 1 deletion classes/wc-gateway-paypal-pro-payflow-angelleye.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ function __construct() {

//fix ssl for image icon
$this->icon = $this->get_option('card_icon', plugins_url('/assets/images/payflow-cards.png', plugin_basename(dirname(__FILE__))));
if ( is_ssl() || get_option( 'woocommerce_force_ssl_checkout' ) == 'yes' ) {
if ( is_ssl() || 'yes' === get_option( 'woocommerce_force_ssl_checkout' ) ) {
$this->icon = preg_replace("/^http:/i", "https:", $this->icon);
}
$this->icon = apply_filters('woocommerce_paypal_pro_payflow_icon', $this->icon);
Expand Down
17 changes: 3 additions & 14 deletions paypal-for-woocommerce.php
Original file line number Diff line number Diff line change
Expand Up @@ -229,8 +229,8 @@ function admin_notices() {

if ((!empty($pp_pro['enabled']) && $pp_pro['enabled'] == 'yes') || ( !empty($pp_payflow['enabled']) && $pp_payflow['enabled']=='yes' )) {
// Show message if enabled and FORCE SSL is disabled and WordpressHTTPS plugin is not detected
if ( get_option('woocommerce_force_ssl_checkout')=='no' && ! class_exists( 'WordPressHTTPS' ) && !get_user_meta($user_id, 'ignore_pp_ssl') )
echo '<div class="error angelleye-notice" style="display:none;"><div class="angelleye-notice-logo"><span></span></div><div class="angelleye-notice-message">' . sprintf(__('WooCommerce PayPal Payments Pro requires that the %s option is enabled; your checkout may not be secure! Please enable SSL and ensure your server has a valid SSL certificate - PayPal Pro will only work in test mode.', 'paypal-for-woocommerce'), '<a href="'.admin_url('admin.php?page=wc-settings&tab=checkout#woocommerce_enable_guest_checkout').'">Force secure checkout</a>') . '</div><div class="angelleye-notice-cta"><button class="angelleye-notice-dismiss angelleye-dismiss-welcome" data-msg="ignore_pp_ssl">Dismiss</button></div></div>';
if ( !is_ssl() && !get_user_meta($user_id, 'ignore_pp_ssl') )
echo '<div class="error angelleye-notice" style="display:none;"><div class="angelleye-notice-logo"><span></span></div><div class="angelleye-notice-message">' . sprintf(__('WooCommerce PayPal Payments Pro requires that the %s option is enabled; your checkout may not be secure! Please enable SSL and ensure your server has a valid SSL certificate - PayPal Pro will only work in test mode.', 'paypal-for-woocommerce'), '<a href="'.admin_url('admin.php?page=wc-settings&tab=advanced#woocommerce_force_ssl_checkout').'">Force secure checkout</a>') . '</div><div class="angelleye-notice-cta"><button class="angelleye-notice-dismiss angelleye-dismiss-welcome" data-msg="ignore_pp_ssl">Dismiss</button></div></div>';
if (($pp_pro['testmode']=='yes' || $pp_payflow['testmode']=='yes' || $pp_settings['testmode']=='yes') && !get_user_meta($user_id, 'ignore_pp_sandbox')) {
$testmodes = array();
if ($pp_pro['enabled']=='yes' && $pp_pro['testmode']=='yes') $testmodes[] = 'PayPal Pro';
Expand Down Expand Up @@ -318,7 +318,7 @@ public function admin_scripts()
wp_register_script( 'angelleye_admin', plugins_url( '/assets/js/angelleye-admin.js' , __FILE__ ), array( 'jquery' ), VERSION_PFW);
$this->use_wp_locale_code = !empty($pp_settings['use_wp_locale_code']) ? $pp_settings['use_wp_locale_code'] : 'yes';
$translation_array = array(
'is_ssl' => AngellEYE_Gateway_Paypal::is_ssl()? "yes":"no",
'is_ssl' => is_ssl() ? "yes":"no",
'choose_image' => __('Choose Image', 'paypal-for-woocommerce'),
'shop_based_us' => (substr(get_option("woocommerce_default_country"), 0, 2) == 'US') ? "yes" : "no",
'payment_method' => $payment_method,
Expand Down Expand Up @@ -446,17 +446,6 @@ function donate_message() {
}
}

/**
* Check if site is SSL ready
*
*/
static public function is_ssl()
{
if (is_ssl() || get_option('woocommerce_force_ssl_checkout') == 'yes' || class_exists('WordPressHTTPS'))
return true;
return false;
}

public function angelleye_admin_menu_own(){
$this->plugin_screen_hook_suffix = add_submenu_page(
'options-general.php',
Expand Down

0 comments on commit 0f71346

Please sign in to comment.