Merge pull request #6008 from woothemes/fix-force-https
Changed WC_HTTPS::force_https_url filter priority
This commit is contained in:
commit
177d617b73
|
@ -1,5 +1,4 @@
|
|||
<?php
|
||||
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit; // Exit if accessed directly
|
||||
}
|
||||
|
@ -7,11 +6,11 @@ if ( ! defined( 'ABSPATH' ) ) {
|
|||
/**
|
||||
* WC_HTTPS class.
|
||||
*
|
||||
* @class WC_HTTPS
|
||||
* @version 2.2.0
|
||||
* @package WooCommerce/Classes
|
||||
* @category Class
|
||||
* @author WooThemes
|
||||
* @class WC_HTTPS
|
||||
* @version 2.2.0
|
||||
* @package WooCommerce/Classes
|
||||
* @category Class
|
||||
* @author WooThemes
|
||||
*/
|
||||
class WC_HTTPS {
|
||||
|
||||
|
@ -21,17 +20,29 @@ class WC_HTTPS {
|
|||
public static function init() {
|
||||
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' ) ) ) ) {
|
||||
|
||||
// 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 ) {
|
||||
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_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' ) );
|
||||
}
|
||||
}
|
||||
|
@ -46,10 +57,11 @@ class WC_HTTPS {
|
|||
*/
|
||||
public static function force_https_url( $content ) {
|
||||
if ( is_ssl() ) {
|
||||
if ( is_array( $content ) )
|
||||
if ( is_array( $content ) ) {
|
||||
$content = array_map( 'WC_HTTPS::force_https_url', $content );
|
||||
else
|
||||
} else {
|
||||
$content = str_replace( 'http:', 'https:', $content );
|
||||
}
|
||||
}
|
||||
return $content;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue