Viewing 14 replies - 1 through 14 (of 14 total)
  • Plugin Author Takayuki Miyoshi

    (@takayukister)

    What cache plugin do you use?

    Thread Starter kizora

    (@kizora)

    Hi

    I use the quickcache plugin.

    The SSL is enabled via Cloudflare, it is set to divert all http: requests to https:

    Cheers
    Chris

    Plugin Author Takayuki Miyoshi

    (@takayukister)

    The 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.php file.

    function my_wpcf7_ajax_loader( $url ) {
    	return str_replace( 'https://', '//', $url );
    }
    add_filter( 'wpcf7_ajax_loader', 'my_wpcf7_ajax_loader', 10, 1 );
    Thread Starter kizora

    (@kizora)

    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 https

    Hi Ov3rfly
    Thanks for the code – what does it do?

    Cheers
    Chris

    @kizora: The code fixes the “Mixed Content” problem for ajax-loader.gif

    Plugin Author Takayuki Miyoshi

    (@takayukister)

    Yes, I do have Cloudflare set to overwrite all link URLS with https.

    Does this cover <img src="..." /> URLs?

    Thread Starter kizora

    (@kizora)

    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 https://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( ‘https://&#8217;, ‘//’, $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
    Chris

    Thread Starter kizora

    (@kizora)

    Hi 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&#8221; );

    Cheers
    Chris

    @kizora: There is an extra } right after <?php which should not be there and probably causes the error.

    The filter replaces https:// with // which makes ajax-loader.gif url protocol-relative, similar to many other resources on your website (see html source at end of page).

    Thread Starter kizora

    (@kizora)

    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( ‘https://&#8217;, ‘//’, $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.php editing:

    function my_wpcf7_ajax_loader( $url ) {
    	return $url;
    }
    add_filter( 'wpcf7_ajax_loader', 'my_wpcf7_ajax_loader', 10, 1 );

    Another version which replaces http with https, in case the cloudflare can’t handle the escaped protocol-relative //

    function my_wpcf7_ajax_loader( $url ) {
    	return str_replace( 'https://', '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.

    Thread Starter kizora

    (@kizora)

    Excellent! thanks very much Ov3rfly. That code worked ??
    Cheers, Chris

    brucewilliam

    (@brucewilliam)

    @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( ‘https://files.cdn.spilcloud.com/df9aa4793b5/APB-30-11/index.html&#8217;, ‘myarcade_swfobject_content’, ‘807’, ‘633’, ‘9.0.0’, ”, [], {“wmode”:”direct”,”allowscriptaccess”:”always”,”swLiveConnect”:”true”,”quality”:”high”}, []);”

    my page is https://www.coolmathgamestop.com

Viewing 14 replies - 1 through 14 (of 14 total)
  • The topic ‘mixed content error using https:’ is closed to new replies.