Edit File by line
/home/zeestwma/richards.../wp-conte.../plugins/woocomme.../includes
File: class-wc-https.php
<?php
[0] Fix | Delete
[1] Fix | Delete
if ( ! defined( 'ABSPATH' ) ) {
[2] Fix | Delete
exit; // Exit if accessed directly
[3] Fix | Delete
}
[4] Fix | Delete
[5] Fix | Delete
/**
[6] Fix | Delete
* WC_HTTPS class.
[7] Fix | Delete
*
[8] Fix | Delete
* @class WC_HTTPS
[9] Fix | Delete
* @version 2.2.0
[10] Fix | Delete
* @package WooCommerce\Classes
[11] Fix | Delete
* @category Class
[12] Fix | Delete
* @author WooThemes
[13] Fix | Delete
*/
[14] Fix | Delete
class WC_HTTPS {
[15] Fix | Delete
[16] Fix | Delete
/**
[17] Fix | Delete
* Hook in our HTTPS functions if we're on the frontend. This will ensure any links output to a page (when viewing via HTTPS) are also served over HTTPS.
[18] Fix | Delete
*/
[19] Fix | Delete
public static function init() {
[20] Fix | Delete
if ( 'yes' === get_option( 'woocommerce_force_ssl_checkout' ) && ! is_admin() ) {
[21] Fix | Delete
// HTTPS urls with SSL on
[22] Fix | Delete
$filters = array(
[23] Fix | Delete
'post_thumbnail_html',
[24] Fix | Delete
'wp_get_attachment_image_attributes',
[25] Fix | Delete
'wp_get_attachment_url',
[26] Fix | Delete
'option_stylesheet_url',
[27] Fix | Delete
'option_template_url',
[28] Fix | Delete
'script_loader_src',
[29] Fix | Delete
'style_loader_src',
[30] Fix | Delete
'template_directory_uri',
[31] Fix | Delete
'stylesheet_directory_uri',
[32] Fix | Delete
'site_url',
[33] Fix | Delete
);
[34] Fix | Delete
[35] Fix | Delete
foreach ( $filters as $filter ) {
[36] Fix | Delete
add_filter( $filter, array( __CLASS__, 'force_https_url' ), 999 );
[37] Fix | Delete
}
[38] Fix | Delete
[39] Fix | Delete
add_filter( 'page_link', array( __CLASS__, 'force_https_page_link' ), 10, 2 );
[40] Fix | Delete
add_action( 'template_redirect', array( __CLASS__, 'force_https_template_redirect' ) );
[41] Fix | Delete
[42] Fix | Delete
if ( 'yes' == get_option( 'woocommerce_unforce_ssl_checkout' ) ) {
[43] Fix | Delete
add_action( 'template_redirect', array( __CLASS__, 'unforce_https_template_redirect' ) );
[44] Fix | Delete
}
[45] Fix | Delete
}
[46] Fix | Delete
add_action( 'http_api_curl', array( __CLASS__, 'http_api_curl' ), 10, 3 );
[47] Fix | Delete
}
[48] Fix | Delete
[49] Fix | Delete
/**
[50] Fix | Delete
* Force https for urls.
[51] Fix | Delete
*
[52] Fix | Delete
* @param mixed $content
[53] Fix | Delete
* @return string
[54] Fix | Delete
*/
[55] Fix | Delete
public static function force_https_url( $content ) {
[56] Fix | Delete
if ( is_ssl() ) {
[57] Fix | Delete
if ( is_array( $content ) ) {
[58] Fix | Delete
$content = array_map( 'WC_HTTPS::force_https_url', $content );
[59] Fix | Delete
} else {
[60] Fix | Delete
$content = str_replace( 'http:', 'https:', (string) $content );
[61] Fix | Delete
}
[62] Fix | Delete
}
[63] Fix | Delete
return $content;
[64] Fix | Delete
}
[65] Fix | Delete
[66] Fix | Delete
/**
[67] Fix | Delete
* Force a post link to be SSL if needed.
[68] Fix | Delete
*
[69] Fix | Delete
* @param string $link
[70] Fix | Delete
* @param int $page_id
[71] Fix | Delete
*
[72] Fix | Delete
* @return string
[73] Fix | Delete
*/
[74] Fix | Delete
public static function force_https_page_link( $link, $page_id ) {
[75] Fix | Delete
if ( in_array( $page_id, array( get_option( 'woocommerce_checkout_page_id' ), get_option( 'woocommerce_myaccount_page_id' ) ) ) ) {
[76] Fix | Delete
$link = str_replace( 'http:', 'https:', $link );
[77] Fix | Delete
} elseif ( 'yes' === get_option( 'woocommerce_unforce_ssl_checkout' ) && ! wc_site_is_https() ) {
[78] Fix | Delete
$link = str_replace( 'https:', 'http:', $link );
[79] Fix | Delete
}
[80] Fix | Delete
return $link;
[81] Fix | Delete
}
[82] Fix | Delete
[83] Fix | Delete
/**
[84] Fix | Delete
* Template redirect - if we end up on a page ensure it has the correct http/https url.
[85] Fix | Delete
*/
[86] Fix | Delete
public static function force_https_template_redirect() {
[87] Fix | Delete
if ( ! is_ssl() && ( is_checkout() || is_account_page() || apply_filters( 'woocommerce_force_ssl_checkout', false ) ) ) {
[88] Fix | Delete
[89] Fix | Delete
if ( 0 === strpos( $_SERVER['REQUEST_URI'], 'http' ) ) {
[90] Fix | Delete
wp_safe_redirect( preg_replace( '|^http://|', 'https://', $_SERVER['REQUEST_URI'] ) );
[91] Fix | Delete
exit;
[92] Fix | Delete
} else {
[93] Fix | Delete
wp_safe_redirect( 'https://' . ( ! empty( $_SERVER['HTTP_X_FORWARDED_HOST'] ) ? $_SERVER['HTTP_X_FORWARDED_HOST'] : $_SERVER['HTTP_HOST'] ) . $_SERVER['REQUEST_URI'] );
[94] Fix | Delete
exit;
[95] Fix | Delete
}
[96] Fix | Delete
}
[97] Fix | Delete
}
[98] Fix | Delete
[99] Fix | Delete
/**
[100] Fix | Delete
* Template redirect - if we end up on a page ensure it has the correct http/https url.
[101] Fix | Delete
*/
[102] Fix | Delete
public static function unforce_https_template_redirect() {
[103] Fix | Delete
if ( function_exists( 'is_customize_preview' ) && is_customize_preview() ) {
[104] Fix | Delete
return;
[105] Fix | Delete
}
[106] Fix | Delete
[107] Fix | Delete
if ( ! wc_site_is_https() && is_ssl() && $_SERVER['REQUEST_URI'] && ! is_checkout() && ! wp_doing_ajax() && ! is_account_page() && apply_filters( 'woocommerce_unforce_ssl_checkout', true ) ) {
[108] Fix | Delete
[109] Fix | Delete
if ( 0 === strpos( $_SERVER['REQUEST_URI'], 'http' ) ) {
[110] Fix | Delete
wp_safe_redirect( preg_replace( '|^https://|', 'http://', $_SERVER['REQUEST_URI'] ) );
[111] Fix | Delete
exit;
[112] Fix | Delete
} else {
[113] Fix | Delete
wp_safe_redirect( 'http://' . ( ! empty( $_SERVER['HTTP_X_FORWARDED_HOST'] ) ? $_SERVER['HTTP_X_FORWARDED_HOST'] : $_SERVER['HTTP_HOST'] ) . $_SERVER['REQUEST_URI'] );
[114] Fix | Delete
exit;
[115] Fix | Delete
}
[116] Fix | Delete
}
[117] Fix | Delete
}
[118] Fix | Delete
[119] Fix | Delete
/**
[120] Fix | Delete
* Force posts to PayPal to use TLS v1.2. See:
[121] Fix | Delete
* https://core.trac.wordpress.org/ticket/36320
[122] Fix | Delete
* https://core.trac.wordpress.org/ticket/34924#comment:13
[123] Fix | Delete
* https://www.paypal-knowledge.com/infocenter/index?page=content&widgetview=true&id=FAQ1914&viewlocale=en_US
[124] Fix | Delete
*
[125] Fix | Delete
* @param string $handle
[126] Fix | Delete
* @param mixed $r
[127] Fix | Delete
* @param string $url
[128] Fix | Delete
*/
[129] Fix | Delete
public static function http_api_curl( $handle, $r, $url ) {
[130] Fix | Delete
if ( strstr( $url, 'https://' ) && ( strstr( $url, '.paypal.com/nvp' ) || strstr( $url, '.paypal.com/cgi-bin/webscr' ) ) ) {
[131] Fix | Delete
curl_setopt( $handle, CURLOPT_SSLVERSION, 6 );
[132] Fix | Delete
}
[133] Fix | Delete
}
[134] Fix | Delete
}
[135] Fix | Delete
[136] Fix | Delete
WC_HTTPS::init();
[137] Fix | Delete
[138] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function