mixed content error using https:
-
Hi
Installed plugin here – https://thebeautifulhousecompany.com/contact2/
In chrome debugger it shows a warning –
Mixed Content: The page at https://thebeautifulhousecompany.com/contact2/’ was loaded over HTTPS, but requested an insecure image ‘http://thebeautifulhousecompany.com/wp-content/plugins/contact-form-7/images/ajax-loader.gif’. This content should also be served over HTTPS.In IE11 debugger it shows 3 errors (the below error repeated) –
SEC7111: HTTPS security is compromised by http://thebeautifulhousecompany.com/wp-content/plugins/contact-form-7/images/ajax-loader.gif File: contact2which module loads ajax-loader.gif? I’m hoping I can edit it to point to https π
Also in IE11 the date picker doesn’t work, it does in chrome.
Cheers
Chris
-
What cache plugin do you use?
Hi
I use the quickcache plugin.
The SSL is enabled via Cloudflare, it is set to divert all http: requests to https:
Cheers
ChrisThe SSL is enabled via Cloudflare, it is set to divert all http: requests to https:
Maybe that is the problem. Your WordPress can’t recognize whether it is in HTTPS or HTTP when rendering a page.
Doesn’t Cloudflare have an option to overwrite all link URLs in a page with HTTPS versions?
@kizora: Try to add this to your theme
functions.phpfile.function my_wpcf7_ajax_loader( $url ) { return str_replace( 'http://', '//', $url ); } add_filter( 'wpcf7_ajax_loader', 'my_wpcf7_ajax_loader', 10, 1 );Hi Takayuki
Yes, I do have Cloudflare set to overwrite all link URLS with https. Everything else gets overwritten ok except for this plugin and an old cforms plugin where I had to hard code the httpsHi Ov3rfly
Thanks for the code – what does it do?Cheers
Chris@kizora: The code fixes the “Mixed Content” problem for
ajax-loader.gifYes, I do have Cloudflare set to overwrite all link URLS with https.
Does this cover
<img src="..." />URLs?Hi Ov3rfly
I added that code but got a server error 500 when I tried to update the contact page in wordpress admin –
“The website encountered an error while retrieving http://thebeautifulhousecompany/wp-admin/post.php. It may be down for maintenace or configured incorrectly”
It wasn’t down for maintenance.I added the code here
‘
<?php }function my_wpcf7_ajax_loader( $url ) {
return str_replace( ‘http://’, ‘//’, $url );
}
add_filter( ‘wpcf7_ajax_loader’, ‘my_wpcf7_ajax_loader’, 10, 1 );function register_main_menus() {
register_nav_menus(
array(
‘primary-menu’ => __( ‘Primary Menu’ ),
‘secondary-menu’ => __( ‘Secondary Menu’ )
)
);
};
‘
Cheers
ChrisHi Takayuki,
It is set to cover everything but I wonder whether it’s resolving the ajax-loader.gif url after cloudflare has converted http to https?In the plugins functions.php file there is this code:-
‘
function wpcf7_ajax_loader() {
$url = wpcf7_plugin_url( ‘images/ajax-loader.gif’ );return apply_filters( ‘wpcf7_ajax_loader’, $url );
}
‘Could I just hard code the https: ? by changing it to:
‘
$url = ( “https://thebeautifulhousecompany.com/wp-content/plugins/contact-form-7/images/ajax-loader.gif” );
‘
Cheers
Chris@kizora: There is an extra
}right after<?phpwhich should not be there and probably causes the error.The filter replaces
http://with//which makesajax-loader.gifurl protocol-relative, similar to many other resources on your website (see html source at end of page).Hi Ov3rfly
Sorry, should have copied the whole php file. That } is the end of the media queries bit. Here’s the whole function.php
‘
<?php
add_action( ‘after_setup_theme’, ‘et_setup_theme’ );
if ( ! function_exists( ‘et_setup_theme’ ) ){
function et_setup_theme(){
remove_action( ‘wp_head’, ‘feed_links’ );
remove_action( ‘wp_head’, ‘rsd_link’);
remove_action( ‘wp_head’, ‘wlwmanifest_link’);
remove_action( ‘wp_head’, ‘index_rel_link’);
remove_action( ‘wp_head’, ‘parent_post_rel_link’);
remove_action( ‘wp_head’, ‘start_post_rel_link’);
remove_action( ‘wp_head’, ‘adjacent_posts_rel_link’);
remove_action( ‘wp_head’, ‘wp_generator’);remove_action(‘wp_head’, ‘print_emoji_detection_script’, 7);
remove_action(‘wp_print_styles’, ‘print_emoji_styles’);
remove_action(‘admin_print_scripts’, ‘print_emoji_detection_script’ );
remove_action(‘admin_print_styles’, ‘print_emoji_styles’ );require_once(TEMPLATEPATH . ‘/epanel/custom_functions.php’);
require_once(TEMPLATEPATH . ‘/includes/functions/comments.php’);
require_once(TEMPLATEPATH . ‘/includes/functions/sidebars.php’);
load_theme_textdomain(‘ElegantEstate’,get_template_directory().’/lang’);
require_once(TEMPLATEPATH . ‘/epanel/options_elegantestate.php’);
require_once(TEMPLATEPATH . ‘/epanel/core_functions.php’);
require_once(TEMPLATEPATH . ‘/epanel/post_thumbnails_elegantestate.php’);
include(TEMPLATEPATH . ‘/includes/widgets.php’);
require_once(TEMPLATEPATH . ‘/includes/functions/additional_functions.php’);
}
}
// Add MEDIA QUERIES ………….
add_action(‘wp_head’,’et_portfoliopt_additional_styles’,100);
function et_portfoliopt_additional_styles(){ ?>
<style type=”text/css”>
#et_pt_portfolio_gallery { margin-left: -15px; }
.et_pt_portfolio_item { margin-left: 21px; }.et_portfolio_small { margin-left: -40px !important; }
.et_portfolio_small .et_pt_portfolio_item { margin-left: 38px !important; }@media only screen and (max-width:720px){
.et_portfolio_small { margin-left: 0px !important; }
.et_portfolio_small .et_pt_portfolio_item { margin-left: 5% !important; }
}@media only screen and (max-width:359px){
.et_portfolio_small { margin-left: -4px !important;}
.et_portfolio_small .et_pt_portfolio_item { margin-left: 2px !important; }
}.et_portfolio_large { margin-left: -8px !important; }
.et_portfolio_large .et_pt_portfolio_item { margin-left: 6px !important; }
</style>
<?php }function my_wpcf7_ajax_loader( $url ) {
return str_replace( ‘http://’, ‘//’, $url );
}
add_filter( ‘wpcf7_ajax_loader’, ‘my_wpcf7_ajax_loader’, 10, 1 );function register_main_menus() { register_nav_menus( array( ‘primary-menu’ => __( ‘Primary Menu’ ), ‘secondary-menu’ => __( ‘Secondary Menu’ ) ) );};
if (function_exists(‘register_nav_menus’)) add_action( ‘init’, ‘register_main_menus’ );if ( ! function_exists( ‘et_list_pings’ ) ){ function et_list_pings($comment, $args, $depth) { $GLOBALS[‘comment’] = $comment; ?> <li id=”comment-<?php comment_ID(); ?>”><?php comment_author_link(); ?> – <?php comment_excerpt(); ?> <?php }}
add_action(‘template_redirect’,’check_listing’);
function check_listing() {
if (isset($_REQUEST[“option-listing”])) {
$category_link = get_category_link( $_REQUEST[“option-listing”] );
wp_redirect($category_link);
}
}
function SearchFilter($query) {
if ($query->is_search) {
$query->set(‘post_type’, ‘post’);
}
return $query;
}if( !is_admin() ) add_filter(‘pre_get_posts’,’SearchFilter’);
add_filter(‘body_class’,’et_additional_body_class’);
function et_additional_body_class($classes) {
if ( !is_home()) $classes[] = ‘index’;return $classes;
} ?>
‘Looks good, not sure why you get an error.
To track down the problem, here a version of the filter which does nothing, it just returns the given url. If this version causes an error 500, something basic might be wrong with your
functions.phpediting:function my_wpcf7_ajax_loader( $url ) { return $url; } add_filter( 'wpcf7_ajax_loader', 'my_wpcf7_ajax_loader', 10, 1 );Another version which replaces
httpwithhttps, in case the cloudflare can’t handle the escaped protocol-relative//function my_wpcf7_ajax_loader( $url ) { return str_replace( 'http://', 'https://', $url ); } add_filter( 'wpcf7_ajax_loader', 'my_wpcf7_ajax_loader', 10, 1 );Only use one filter at a time and do not change anything else in settings etc.
PS. There is no need to re-save the form or page or similar. Just add the filter and reload the contact page in frontend.
Excellent! thanks very much Ov3rfly. That code worked π
Cheers, Chris@kizora : will this code work for me ? i am running gaming web page and flash games are creating mixed content problem for me. here is the error for reference
swfobject.embedSWF( ‘http://files.cdn.spilcloud.com/df9aa4793b5/APB-30-11/index.html’, ‘myarcade_swfobject_content’, ‘807’, ‘633’, ‘9.0.0’, ”, [], {“wmode”:”direct”,”allowscriptaccess”:”always”,”swLiveConnect”:”true”,”quality”:”high”}, []);”
my page is https://www.coolmathgamestop.com
The topic ‘mixed content error using https:’ is closed to new replies.