{"id":69231,"date":"2025-07-30T03:01:00","date_gmt":"2025-07-29T17:01:00","guid":{"rendered":"https:\/\/www.rjmprogramming.com.au\/ITblog\/?p=69231"},"modified":"2025-11-12T11:12:04","modified_gmt":"2025-11-12T01:12:04","slug":"wordpress-blog-html-iframe-mixed-content-issue-tutorial","status":"publish","type":"post","link":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wordpress-blog-html-iframe-mixed-content-issue-tutorial\/","title":{"rendered":"WordPress Blog HTML Iframe Mixed Content Issue Tutorial"},"content":{"rendered":"<div style=\"width: 230px\" class=\"wp-caption alignnone\"><a target=\"_blank\" href=\"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp_if_mc_issue.gif\" rel=\"noopener\"><img decoding=\"async\" style=\"border: 15px solid pink;\" alt=\"WordPress Blog HTML Iframe Mixed Content Issue Tutorial\" src=\"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp_if_mc_issue.gif\" title=\"WordPress Blog HTML Iframe Mixed Content Issue Tutorial\"  style=\"float:left;\"  \/><\/a><p class=\"wp-caption-text\">WordPress Blog HTML Iframe Mixed Content Issue Tutorial<\/p><\/div>\n<p>Our recent observation of &#8230;<\/p>\n<ul>\n<li>using this <a target=\"_blank\" title='WordPress.org ... your hosting' href='http:\/\/www.wordpress.org' rel=\"noopener\">WordPress<\/a>.org blog<\/li>\n<li>coming across some HTML iframe coded elements not showing<\/li>\n<li>always having <i>src<\/i> attributes starting with http: &#8230; which we wait for clientside means to fix for &#8230;<\/li>\n<li>mixed content errors that can occur<\/li>\n<\/ul>\n<p> &#8230; these HTML iframe element contents would often not show for the readers of the blog, and it is our theory that web browsers, within the last while, changed rules to the effect &#8220;one strike and you are out&#8221; and for us waiting for clientside means to change that &#8220;http:&#8221; to nothing (ie. get your protocol off the address bar protocol) was too late to help (avoid Mixed Content errors), and so we&#8217;re now fixing <a target=\"_blank\" title='Content Management System information from Wikipedia ... thanks' href='https:\/\/en.wikipedia.org\/wiki\/Content_management_system' rel=\"noopener\">CMS<\/a> WordPress blog content at the &#8220;server PHP side&#8221; in good ol&#8217; header.php to improve the situation here at this blog &#8230;<\/p>\n<p>&lt;?php<br \/>\n<code><br \/>\n  if (isset($post-&gt;post_content)) {  \/\/ iframe issue<br \/>\n    $ifrs=explode('&lt;\/' . 'ifr' . 'ame' . '&gt;', $post-&gt;post_content);<br \/>\n    $worryb=false;<br \/>\n    if (strpos($post-&gt;post_content, \"&lt;\/\" . \"ifr\" . \"ame&gt;\") !== false) { $worryb=true;  }<br \/>\n    for ($ichb=(-2 + sizeof($ifrs)); $ichb&gt;=0; $ichb--) {<br \/>\n      $worryb=false;<br \/>\n      if (strpos($ifrs[$ichb], '&lt;' . 'ifr' . 'ame' . ' ') !== false) {<br \/>\n        $bcontent=explode('&lt;' . 'ifr' . 'ame' . ' ', $ifrs[$ichb])[-1 + sizeof(explode('&lt;' . 'ifr' . 'ame' . ' ', $ifrs[$ichb]))];<br \/>\n        $crlflines=explode(\"src='http:\", $bcontent);<br \/>\n        if (sizeof($crlflines) &gt; 1) { $worryb=true; } else { $crlflines=explode('src=\"http:', $bcontent); if (sizeof($crlflines) &gt; 1) { $worryb=true; }  }<br \/>\n        if ($worryb && strpos($bcontent, 'http:\/\/localhost') === false) {<br \/>\n         $post-&gt;post_content=str_replace('&lt;' . 'ifr' . 'ame' . ' ' . $bcontent, '&lt;' . 'ifr' . 'ame' . ' ' . str_replace('http:','',$bcontent), $post-&gt;post_content);<br \/>\n         $ifrs=explode('&lt;\/' . 'ifr' . 'ame' . '&gt;', $post-&gt;post_content);<br \/>\n        }<br \/>\n      }<br \/>\n    }<br \/>\n  }<br \/>\n<\/code><br \/>\n?&gt;<\/p>\n<p> &#8230; to fix HTML iframe mixed content potential errors before they get presented and called, in any way, on a WordPress blog webpage.<\/p>\n<p><b><i>Stop Press<\/i><\/b><\/p>\n<p>Here we are at 12\/11\/2025 and realizing there is another PHP code change needed in header.php to fix this issue for more HTML iframe elements, <font color=blue>that being<\/font> &#8230;<\/p>\n<p>&lt;?php<br \/>\n<code><br \/>\n  <font color=blue>if (strpos((isset($post-&gt;post_content) ? $post-&gt;post_content : ''), '&lt;iframe src=\"http') !== false) {<br \/>\n    $post-&gt;post_content=str_replace('&lt;iframe src=\"http:\/\/www.rjmprogramming.com.au', '&lt;iframe src=\"\/\/www.rjmprogramming.com.au', str_replace('&lt;iframe src=\"https:\/\/www.rjmprogramming.com.au', '&lt;iframe src=\"\/\/www.rjmprogramming.com.au', $post-&gt;post_content));<br \/>\n  }<\/font><br \/>\n  <font color=olive>if (strpos((isset($post-&gt;post_content) ? $post-&gt;post_content : ''), \"&lt;hr\") !== false) {<br \/>\n    $xbitskw=explode(\"&gt;\", substr((isset($post-&gt;post_content) ? $post-&gt;post_content : ''),0,strpos((isset($post-&gt;post_content) ? $post-&gt;post_content : ''), \"&lt;hr\")));<br \/>\n  } else {<br \/>\n    $xbitskw=explode(\"&gt;\", (isset($post-&gt;post_content) ? $post-&gt;post_content : ''));<br \/>\n  }<\/font><br \/>\n\/\/ more of if follows<br \/>\n }<br \/>\n<\/code><br \/>\n?&gt;<\/p>\n<p> &#8230; <font color=olive>placed before<\/font> in the PHP.<\/p>\n<p>If this was interesting you may be interested in <a title='Click here to see topics in which you might be interested' href='#d69231' onclick='var dv=document.getElementById(\"d69231\"); dv.innerHTML = \"&lt;iframe width=670 height=600 src=\" + \"https:\/\/www.rjmprogramming.com.au\/ITblog\/tag\/mixed-content\" + \"&gt;&lt;\/iframe&gt;\"; dv.style.display = \"block\";'>this<\/a> too.<\/p>\n<div id='d69231' style='display: none; border-left: 2px solid green; border-top: 2px solid green;'><\/div>\n","protected":false},"excerpt":{"rendered":"<p>Our recent observation of &#8230; using this WordPress.org blog coming across some HTML iframe coded elements not showing always having src attributes starting with http: &#8230; which we wait for clientside means to fix for &#8230; mixed content errors that &hellip; <a href=\"https:\/\/www.rjmprogramming.com.au\/ITblog\/wordpress-blog-html-iframe-mixed-content-issue-tutorial\/\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[12,37],"tags":[151,216,2014,576,581,587,3226,932,997,1002,1200,1262,5245,1456],"class_list":["post-69231","post","type-post","status-publish","format-standard","hentry","category-elearning","category-tutorials","tag-blog","tag-cms","tag-content-management-system","tag-html","tag-http","tag-iframe","tag-mixed-content","tag-php","tag-programming","tag-protocol","tag-stop-press","tag-textarea","tag-tutorial-header-php","tag-wordpress"],"_links":{"self":[{"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/posts\/69231"}],"collection":[{"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/comments?post=69231"}],"version-history":[{"count":12,"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/posts\/69231\/revisions"}],"predecessor-version":[{"id":70569,"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/posts\/69231\/revisions\/70569"}],"wp:attachment":[{"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/media?parent=69231"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/categories?post=69231"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/tags?post=69231"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}