changed WC_HTTPS::force_https_url filter priority

This commit is contained in:
claudiosmweb 2014-08-11 10:03:27 -03:00
parent fe12b330c0
commit 9ce8250fcb
1 changed files with 24 additions and 12 deletions

View File

@ -1,5 +1,4 @@
<?php
if ( ! defined( 'ABSPATH' ) ) {
exit; // Exit if accessed directly
}
@ -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,11 +57,12 @@ 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;
}