Create New Item
×
Item Type
File
Folder
Item Name
×
Search file in folder and subfolders...
File Manager
/
wp-content
/
plugins
/
really-simple-ssl
Advanced Search
Upload
New Item
Settings
Back
Back Up
Advanced Editor
Save
<?php defined('ABSPATH') or die("you do not have access to this page!"); if (!class_exists('rsssl_admin_mixed_content_fixer')) { class rsssl_mixed_content_fixer { private static $_this; public $http_urls = array(); function __construct() { if (isset(self::$_this)) { wp_die(sprintf(__('%s is a singleton class and you cannot create a second instance.', 'really-simple-ssl'), get_class($this))); } self::$_this = $this; if (!is_admin() && is_ssl() && RSSSL()->rsssl_front_end->autoreplace_insecure_links) { $this->fix_mixed_content(); } } static function this() { return self::$_this; } public function fix_mixed_content() { if (defined('JSON_REQUEST') && JSON_REQUEST) { return; } if (defined('XMLRPC_REQUEST') && XMLRPC_REQUEST) { return; } $this->build_url_list(); if (is_admin()) { add_action("admin_init", array($this, "start_buffer"), 100); add_action("shutdown", array($this, "end_buffer"), 999); } else { if (RSSSL()->rsssl_front_end->switch_mixed_content_fixer_hook || defined('RSSSL_CONTENT_FIXER_ON_INIT') && RSSSL_CONTENT_FIXER_ON_INIT) { add_action("init", array($this, "start_buffer")); } else { add_action("template_redirect", array($this, "start_buffer")); } add_action("shutdown", array($this, "end_buffer"), 999); } } public function filter_buffer($buffer) { $buffer = $this->replace_insecure_links($buffer); return $buffer; } public function start_buffer() { ob_start(array($this, "filter_buffer")); } public function end_buffer() { if (ob_get_length()) { ob_end_flush(); } } public function build_url_list() { $home = str_replace("https://", "http://", get_option('home')); $home_no_www = str_replace("://www.", "://", $home); $home_yes_www = str_replace("://", "://www.", $home_no_www); $escaped_home = str_replace("/", "\\/", $home); $this->http_urls = array($home_yes_www, $home_no_www, $escaped_home, "src='http://", 'src="http://'); } public function replace_insecure_links($str) { if (substr($str, 0, 5) == "<?xml") { return $str; } $search_array = apply_filters('rlrsssl_replace_url_args', $this->http_urls); $ssl_array = str_replace(array("http://", "http:\\/\\/"), array("https://", "https:\\/\\/"), $search_array); $str = str_replace($search_array, $ssl_array, $str); $pattern = array('/url\\([\'"]?\\K(http:\\/\\/)(?=[^)]+)/i', '/<link [^>]*?href=[\'"]\\K(http:\\/\\/)(?=[^\'"]+)/i', '/<meta property="og:image" [^>]*?content=[\'"]\\K(http:\\/\\/)(?=[^\'"]+)/i', '/<form [^>]*?action=[\'"]\\K(http:\\/\\/)(?=[^\'"]+)/i'); $str = preg_replace($pattern, 'https://', $str); $str = preg_replace_callback('/<img[^\\>]*[^\\>\\S]+srcset=[\'"]\\K((?:[^"\'\\s,]+\\s*(?:\\s+\\d+[wx])(?:,\\s*)?)+)["\']/', array($this, 'replace_src_set'), $str); $str = str_replace("<body", '<body data-rsssl=1', $str); return apply_filters("rsssl_fixer_output", $str); } public function replace_src_set($matches) { return str_replace("http://", "https://", $matches[0]); } } }