-1

OK I checked all other similar answers, but thanks to people that downvote for no reason there is no actual response.

I am using Wordpress and I have a Mixed Content with a website https://oujdaportail.net/

It is generating this error:

Mixed Content: The page at 'https://oujdaportail.net/' was loaded over HTTPS, but requested an insecure XMLHttpRequest endpoint 'http://oujdaportail.net/'. This request has been blocked; the content must be served over HTTPS.

Chrome debug console has been completely useless!! It detects the error at the first line of source code where there is nothing to look up.

I am not sure how I should resolve this... I need help to capture the source of this issue.

sideshowbarker
  • 81,827
  • 26
  • 193
  • 197
MrJack Mcfreder
  • 692
  • 1
  • 10
  • 21
  • If your questions are getting downvoted, then they do not meet the guidelines for the site. Please review the [help centre](https://stackoverflow.com/help/asking) It is Stack Overflow policy to downvote questions that don't meet the site guidelines. We cannot help if you do not give enough information - we are not mind readers! We don't know your code or what is causing your error. You need to debug the issue yourself - Chrome debug console is not the start and end for debugging. – FluffyKitten Sep 24 '17 at 02:41

1 Answers1

0

Finally! I would be someone's hero...

After hours of struggle, it turned out that wp_head and wp_footer where responsible for generating unknown HTTP requests. And to fix it all I had to do is create a custom wp_head and wp_footer function just like this:

/**
 * Wrapper for wp_head() which manages SSL
 *
 * @uses    wp_head()
 * @param   bool    $ssl
 * @return  void
 */
function custom_wp_head() {
  // Capture wp_head output with buffering
  ob_start();
  wp_head();
  $wp_head = ob_get_contents();
  ob_end_clean();

  // Replace plain protocols
  $wp_head = preg_replace( '/(["\'])http:\/\//', '\1https://', $wp_head );

  // Output
  echo $wp_head;
}

function custom_wp_footer() {
  // Capture wp_head output with buffering
  ob_start();
  wp_footer();
  $wp_footer = ob_get_contents();
  ob_end_clean();

  // Replace plain protocols
  $wp_footer = preg_replace( '/(["\'])http:\/\//', '\1https://', $wp_footer );

  // Output
  echo $wp_footer;
}
MrJack Mcfreder
  • 692
  • 1
  • 10
  • 21