changed WC_HTTPS::force_https_url filter priority
This commit is contained in:
parent
fe12b330c0
commit
9ce8250fcb
|
@ -1,5 +1,4 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
if ( ! defined( 'ABSPATH' ) ) {
|
if ( ! defined( 'ABSPATH' ) ) {
|
||||||
exit; // Exit if accessed directly
|
exit; // Exit if accessed directly
|
||||||
}
|
}
|
||||||
|
@ -7,11 +6,11 @@ if ( ! defined( 'ABSPATH' ) ) {
|
||||||
/**
|
/**
|
||||||
* WC_HTTPS class.
|
* WC_HTTPS class.
|
||||||
*
|
*
|
||||||
* @class WC_HTTPS
|
* @class WC_HTTPS
|
||||||
* @version 2.2.0
|
* @version 2.2.0
|
||||||
* @package WooCommerce/Classes
|
* @package WooCommerce/Classes
|
||||||
* @category Class
|
* @category Class
|
||||||
* @author WooThemes
|
* @author WooThemes
|
||||||
*/
|
*/
|
||||||
class WC_HTTPS {
|
class WC_HTTPS {
|
||||||
|
|
||||||
|
@ -21,17 +20,29 @@ class WC_HTTPS {
|
||||||
public static function init() {
|
public static function init() {
|
||||||
if ( 'yes' == get_option( 'woocommerce_force_ssl_checkout' ) ) {
|
if ( 'yes' == get_option( 'woocommerce_force_ssl_checkout' ) ) {
|
||||||
if ( ! is_admin() || ( defined( 'DOING_AJAX' ) && in_array( $_REQUEST['action'], array( 'woocommerce_get_refreshed_fragments', 'woocommerce_checkout', 'woocommerce_update_order_review', 'woocommerce_update_shipping_method', 'woocommerce_apply_coupon' ) ) ) ) {
|
if ( ! is_admin() || ( defined( 'DOING_AJAX' ) && in_array( $_REQUEST['action'], array( 'woocommerce_get_refreshed_fragments', 'woocommerce_checkout', 'woocommerce_update_order_review', 'woocommerce_update_shipping_method', 'woocommerce_apply_coupon' ) ) ) ) {
|
||||||
|
|
||||||
// HTTPS urls with SSL on
|
// HTTPS urls with SSL on
|
||||||
$filters = array( 'post_thumbnail_html', 'wp_get_attachment_url', 'wp_get_attachment_image_attributes', 'wp_get_attachment_url', 'option_stylesheet_url', 'option_template_url', 'script_loader_src', 'style_loader_src', 'template_directory_uri', 'stylesheet_directory_uri', 'site_url' );
|
$filters = array(
|
||||||
|
'post_thumbnail_html',
|
||||||
|
'wp_get_attachment_image_attributes',
|
||||||
|
'wp_get_attachment_url',
|
||||||
|
'option_stylesheet_url',
|
||||||
|
'option_template_url',
|
||||||
|
'script_loader_src',
|
||||||
|
'style_loader_src',
|
||||||
|
'template_directory_uri',
|
||||||
|
'stylesheet_directory_uri',
|
||||||
|
'site_url'
|
||||||
|
);
|
||||||
|
|
||||||
foreach ( $filters as $filter ) {
|
foreach ( $filters as $filter ) {
|
||||||
add_filter( $filter, array( __CLASS__, 'force_https_url' ) );
|
add_filter( $filter, array( __CLASS__, 'force_https_url' ), 999 );
|
||||||
}
|
}
|
||||||
|
|
||||||
add_filter( 'page_link', array( __CLASS__, 'force_https_page_link' ), 10, 2 );
|
add_filter( 'page_link', array( __CLASS__, 'force_https_page_link' ), 10, 2 );
|
||||||
add_action( 'template_redirect', array( __CLASS__, 'force_https_template_redirect' ) );
|
add_action( 'template_redirect', array( __CLASS__, 'force_https_template_redirect' ) );
|
||||||
|
|
||||||
if ( get_option('woocommerce_unforce_ssl_checkout') == 'yes' ) {
|
if ( 'yes' == get_option('woocommerce_unforce_ssl_checkout') ) {
|
||||||
add_action( 'template_redirect', array( __CLASS__, 'unforce_https_template_redirect' ) );
|
add_action( 'template_redirect', array( __CLASS__, 'unforce_https_template_redirect' ) );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -46,10 +57,11 @@ class WC_HTTPS {
|
||||||
*/
|
*/
|
||||||
public static function force_https_url( $content ) {
|
public static function force_https_url( $content ) {
|
||||||
if ( is_ssl() ) {
|
if ( is_ssl() ) {
|
||||||
if ( is_array( $content ) )
|
if ( is_array( $content ) ) {
|
||||||
$content = array_map( 'WC_HTTPS::force_https_url', $content );
|
$content = array_map( 'WC_HTTPS::force_https_url', $content );
|
||||||
else
|
} else {
|
||||||
$content = str_replace( 'http:', 'https:', $content );
|
$content = str_replace( 'http:', 'https:', $content );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return $content;
|
return $content;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue