V5 version (for cool people)
FOR PLUGIN VERSION 2.7.4>
PAGE HELP – JS code – updated on 6 Dec 2023
(related addons/page-forum.php – updated on 30 Sep 2023)
wp-w3all-phpbb-integration/trunk/addons/page-forum.php
wp_w3all responsive iframe procedure
WordPress phpBB iframe template integration
UPDATE PROCEDURE: rebuild page-forum.php (or whatever named) via plugin admin, OR manually substitute it into your active WP template folder, with the new one that you find/copy into /wp-content/plugins/wp-w3all-phpbb-integration/addons. You’ll may also update the iframeResizer.contentWindow.min.js and iframeResizer.contentWindow.map files added into phpBB root, with news updated files you’ll find into /wp-content/plugins/wp-w3all-phpbb-integration/addons/resizer folder (this step is not always required, but only when iframe resizer library updates, which is notified on plugin changelog when plugin released). Done this, substitute the phpBB overall_header.html and overall_footer.html code (re-adding required values) with the new v5 code here below. Do not forget to rebuild phpBB template to make phpBB template modifications take effect, and may cleanup phpBB cache.
NOTE – relevant files: page-forum(or whatever you named it).php into your active WP template folder, while if using the awesome phpBB iframe shortcode the file is /wp-content/plugins/wp-w3all-phpbb-integration/views/wp_w3all_phpbb_iframe_short.php)
WP_w3all template integration steps
After you built/create the WP forum template page via option
WP_w3all phpBB embedded on WordPress Template
on WP_w3all admin config page, and the blank page on WordPress Admin -> Pages -> Add New, titled the same of created wp_w3all template page, so forum or board etc (then you’ll have into your active WordPress template folder a file named page-forum.php or page-board.php etc), to complete the procedure and get the responsive iframe height for the embedded/iframed phpBB into WordPress template page you need:
overall_footer.html code
Open with a text editor your phpBB template file overall_footer.html
and just before the closing </body> tag, add this code (do not select rows numbers on copied code):
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 |
<!-- IF not S_IS_BOT --> <script type="text/javascript"> // START MANDATORY CHANGES var w3allAllowDomain = 'https://w3host.com'; // MANDATORY! // Set/Change this value with your WordPress URL (example: https://axew3.com) var wordpress_url_page_forum = 'https://w3host.com/forum'; // MANDATORY! // (DO NOT ADD/INCLUDE final slash here) Url that point to your iframed wordpress forum page var w3all_custom_wp_w3fancyurl = 'w3'; // MANDATORY! If you changed the default w3 to have 'fancy URL' query string into the related WP plugin admin option, then change this value to match the same as it is the fancy URL setting // END MANDATORY CHANGES var pmn = "{PRIVATE_MESSAGE_COUNT}"; var w3all_phpbb_u_logged = "{S_USER_LOGGED_IN}"; var w3allappend = false; var boardU = "{BOARD_URL}"; // Lightbox scroll fix: // remove /* and */ to activate, also more below to complete ... /* $(".postimage").on("click", function(event) { var pos = event.pageY - 100; $(parent.window).scrollTop( 200 ); var el = document.getElementById("lightbox"); $("#lightboxOverlay").on("click", function() { $(parent.window).scrollTop( pos ); }); $(".lb-close").on("click", function() { $(parent.window).scrollTop( pos ); }); $(".lightbox").on("click", function() { $(parent.window).scrollTop( pos ); }); }); */ function w3allNormalize_phpBBUrl(href){ // try to 'normalize' passed relative links: needed all after last slash / // exception are kind of passed urls like: /phpbb323/app.php/help/faq // and if SEO mods that may assign some different kind of links values // by the way, SEO absolute urls http(s) should be (all?) already considered here ... var phpbbRUrl = href.split(/^.+?(\w+.+)$/); if( href.indexOf('app.php') > -1 ){ // since the previous not 'normalize' this type of passed value (and may miss something else) phpbburl = href.split(/^.+?(app\.php.+)$/); w3allappend = phpbburl[1]; } else if ( /^https?/ig.exec(href) !== null ){ // absolute http(s) passed: try to 'normalize' a possible seo mod phpbburl = href.split(boardU); w3allappend = phpbburl[1]; } else if ( phpbbRUrl[1] && phpbbRUrl[1].length > 1 ){ // 'normalize' any other w3allappend = phpbbRUrl[1]; } else if ( phpbbRUrl[0].length > 1 ){ w3allappend = phpbbRUrl[0]; } // ... if still not normalized if(/^\W/ig.exec(w3allappend) !== null){ w3allappend = w3allappend.split(/^.+?(\w+.+)$/); if(w3allappend[1]){ w3allappend = w3allappend[1]; } if ( w3allappend[1] && w3allappend[1].charAt(0) == '/' ){ w3allappend = w3allappend[1].substr(1); } } return w3allappend; } $(document).on("click", "a", function(e) { var href = $(this).attr("href"); var w3all_onview_attach = (href.indexOf('file.php') > -1); if( this.getAttribute('target') !== null ){ e.preventDefault(); window.open(href,'_blank'); return; } if ( href.charAt(0) == '#' || href.indexOf('\./download\/file\.php') > -1 ){ return; } // external link? if ((this.href.indexOf(boardU) > -1) != true){ if(/^(f|ht)tps?:\/\//i.test(href)) { e.preventDefault(); parent.location.replace(href); return; } } if ( /\/adm\//ig.exec(href) !== null ) { e.preventDefault(); parent.location.replace(href); return; } if ( href.indexOf('view=print') > -1 !== false ) { e.preventDefault(); window.open(href,'_blank'); return; } if ( href.indexOf('quickmod') > -1 ) { w3allNOappend = true; return; } if( /posting\.php\?mode=[reply|post|bump]/ig.exec(href) !== null || /mcp\.php\?/ig.exec(href) !== null ){ w3allNOappend = true; } // complete Lightbox correct attachment display // activate removing /* and */ // or used to open on new tab attachments /* if(w3all_onview_attach !== false){ e.preventDefault(); window.open(href,'_blank'); return; } */ w3allappend = w3allNormalize_phpBBUrl(href); if ('parentIFrame' in window){ if( typeof w3allNOappend == 'undefined' || w3allNOappend == false ){ window.parentIFrame.sendMessage(w3allappend); } } }); // w3all UPDATES for phpBB events if(window.self !== window.top){ $("#quickmod,.bookmark-link").on("click", function(event) { var pos = window.scrollY + document.querySelector('#quickmod').getBoundingClientRect().top; $(parent.window).scrollTop( 200 ); $("#darkenwrapper").on("click", function() { $(parent.window).scrollTop( pos ); }); $("#darken").on("click", function() { $(parent.window).scrollTop( pos ); }); }); if( window.location.hash.substr(1) == 'unread' ){ var postN = 1; $( "h3 > a" ).each(function (e) { ns = this.href.split('#p'); if( typeof ns != 'undefined' && /viewtopic.php\?p=/ig.exec(this.href) != null ){ if(ns[1] > postN){ w3lh = ns[1]; } } }) if( typeof w3lh != 'undefined' ){ w3lh = "p" + w3lh; } } if( typeof w3allNOappend == 'undefined' || w3allNOappend == false ) { $( window ).on( "load", function() { if(/#p/ig.exec(window.location.hash)){ let e = document.getElementById(window.location.hash.substr(1)).getBoundingClientRect(); let w3append = '#w3all_phpbbpmcount=' + pmn + '#w3all_phpbb_u_logged=' + w3all_phpbb_u_logged + '#w3all_lochash=' + parseInt(e.top); window.parent.postMessage({ 'message': w3append }, w3allAllowDomain); } else { let w3append = '#w3all_phpbbpmcount=' + pmn + '#w3all_phpbb_u_logged=' + w3all_phpbb_u_logged + '#w3all_lochash=0'; window.parent.postMessage({ 'message': w3append }, w3allAllowDomain); } // fix vertical iframe centered var w3iOS = !!navigator.platform && /iPad|iPhone|iPod/.test(navigator.platform); if(w3iOS == false) { var bd = document.getElementsByTagName("body"); var t = document.getElementById(bd[0].getAttribute("id")); if( typeof t != 'undefined' || t != false ) { t.setAttribute("style", "position:fixed;top:0%;left:0%;width:100%;margin:0px;"); } } }); } /*if (window.performance){ if( performance.getEntriesByType("navigation")[0].type == 'back_forward' ) { var w3E = performance.getEntriesByType("navigation"); var w3ER = w3allNormalize_phpBBUrl(w3E[0].name); parent.w3all_phpbb_pushUrlToParentOnBackForward(w3ER); } }*/ } // END if(window.self !== window.top){ </script> <script type="text/javascript" src="https://forum.w3host.com/iframeResizer.contentWindow.min.js" defer></script> <!-- ENDIF --> |
after you pasted this code into phpBB overall_footer.html
edit following lines:
1 2 3 4 5 |
// START MANDATORY CHANGES var w3allAllowDomain = 'https://w3host.com'; // MANDATORY! // Set/Change this value with your WordPress URL (example: https://axew3.com) var wordpress_url_page_forum = 'https://w3host.com/forum'; // MANDATORY! // (DO NOT ADD/INCLUDE final slash here) Url that point to your iframed wordpress forum page var w3all_custom_wp_w3fancyurl = 'w3'; // MANDATORY! If you changed the default w3 to have 'fancy URL' query string into the related WP plugin admin option, then change this value to match the same as it is the fancy URL setting // END MANDATORY CHANGES |
change the w3allAllowDomain var value to fit your WP URL.
Now check the other line to change:
1 |
var wordpress_url_page_forum = 'https://w3host.com/forum'; // MANDATORY! (DO NOT INCLUDE final slash here) Url that point to your wordpress forum page (without final slash) |
change value on this line that need to point to the URL of the WordPress created/named forum page (do not add final slash and change http or https as needed)
MANDATORY!
Change the w3 value of the line
1 |
var w3all_custom_wp_w3fancyurl = 'w3'; |
to fit the value that (if) you may changed it into the plugin admin, where option: Fancy URL query string for the WordPress page forum that embed phpBB
Finally, check this line
1 |
<script type="text/javascript" src="https://forum.w3host.com/iframeResizer.contentWindow.min.js" defer></script> |
in the code you added (last line): this should correctly point to the iframeResizer.contentWindow.min.js file that you’ll go to add into phpBB root folder (together with the file iframeResizer.contentWindow.map). You need to use the absolute URL (use http or https as needed, and adjust the url to fit your needs)
(MANDATORY!) or resizer won’t work
1 |
src="https://www.yoursite.com/your-phpbb-folder/iframeResizer.contentWindow.min.js" |
AFTER EDITED, save and load the modified overall_footer.html into your phpBB style folder, overwriting the default one, and so
load via ftp into the phpBB root folder (or copy/paste), both files
iframeResizer.contentWindow.min.js AND iframeResizer.contentWindow.map
that you find inside the folder
wp/wp-content/plugins/wp-w3all-phpbb-integration/addons/resizer
After this, phpBB require to recompile the template, or template files modifications do not affect. Open phpBB ACP, and so under:
Server Configuration -> Load settings -> Recompile stale style components set to YES and save. Load one time a phpBB full forum page. Leave as is at moment, especially if you follow adding also the code on overall_header.html (more below) to redirect any phpBB direct URL to the iframed phpBB into the WP page: then after tested that all work fine, return to ACP, and reset to NO and save. This step is needed to load/rebuild template modifications in phpBB if there are, but this option should be ever set to NO into an online/production site to save server resources. It is normally set to yes only for testing/devel purpose or to apply modifications on phpBB templates files.
overall_header.html code
If you want phpBB email notification links or any phpBB direct url to be redirected to the wp iframed forum page follow this step:
Open with a text editor your phpBB template file overall_header.html and immediately after the closing </title> tag add the following code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
<!-- IF not S_IS_BOT --><script> // START MANDATORY CHANGES var wordpress_url_page_f = 'https://subdomain.w3host.com/wordpress/forum'; // MANDATORY! // (DO NOT ADD/INCLUDE final slash here) Url that point to your iframed wordpress forum page var w3all_custom_wp_w3fancyurl = 'w3' // MANDATORY! If you changed w3 to have 'fancy URL' query string for the WP page forum, then change this value to match what your fancy URL setting is after you changed it on plugin admin page // END MANDATORY CHANGES function w3all0Normalize_phpBBUrl(u){ var bu = "{BOARD_URL}"; w3allappend = "{BOARD_URL}"; if ( /^https?/ig.exec(u) !== null ){ phpbburl = u.split(bu); w3allappend = phpbburl[1]; } if(/^\W/ig.exec(w3allappend) !== null){ w3allappend = w3allappend.split(/^.+?(\w+.+)$/); if(w3allappend[1]){ w3allappend = w3allappend[1]; } if ( w3allappend[1] && w3allappend[1].charAt(0) == '/' ){ w3allappend = w3allappend[1].substr(1); } } return w3allappend; } if ((window.self !== window.top) != true) { if(/adm\//ig.exec(window.location.href) === null){ // avoid x ACP var w3all_r = window.location.href.replace(/sid=.+/gi, ''); w3all_r = w3all0Normalize_phpBBUrl(w3all_r); if(/adm\/index\.php/ig.exec(w3all_r) == null){ hrefEnc = window.btoa(unescape(encodeURIComponent(w3all_r))); href0 = wordpress_url_page_f + '/?'+ w3all_custom_wp_w3fancyurl + '=' + hrefEnc; document.location.replace(href0); } }} // END force w3all to iframe redirect </script> <!-- ENDIF --> |
On added code, change URL on the line where:
1 |
var wordpress_url_page_f = 'https://subdomain.w3host.com/wordpress/forum'; |
to fit/point to the WordPress iframed forum page: DO NOT ADD final slash and setup as http or https as needed.
Change the default w3 value of the line:
1 |
var w3all_custom_wp_w3fancyurl = 'w3' |
to fit the value you may changed into the plugin admin, where there is the option: Fancy URL query string for the WordPress page forum that embed phpBB
Reset to No the Recompile phpBB template option after some test. So before to follow READ NEXT IMPORTANT NOTE
NOTE: if you need to disable/remove the overall_header.html javascript code, that do not allow (until javascript enabled on browser) to access front end real phpBB urls, forcing the redirect to the WP forum page, you can disable javascript on browser, if you do not want to remove/disable the added js snippet into the phpBB overall_header.html file. It is also !important to remember this if in trouble with login, and recompile Stale Template option in phpBB is set to Off at this time.
if the iframe do not display and you get mixed insecure content on console, you have to fix it doing this: open your WP header.php template file, and may just before others header meta tags add the follow:
<meta http-equiv="Content-Security-Policy" content="upgrade-insecure-requests">
For testing or for any other reason, you could also comment out the line where:
1 |
document.location.replace(href0); |
change into this:
1 |
//document.location.replace(href0); |
so phpBB direct URL’s will not be redirected to the WP page forum URL. But you can open the page-forum to see the iframed result in the while. Remember that to apply template modifications, phpBB require to recompile templates files.
NOTE: if the iframe still do not display correctly:
Iframe height do not resize to match my theme! (how to change heightCalculationMethod)
If using the Awesome iframe template integration via shortcode, relevant file to look into is:
/wp-content/plugins/wp-w3all-phpbb-integration/views/wp_w3all_phpbb_iframe_short.php
Check related shortcode page to know more about customization.
That’s all, enjoy your awesome template integration!
Appreciations: https://www.paypal.com/paypalme/alessionanni/
© 2023 axew3.com
Iframe resize library by: https://github.com/davidjbradshaw/iframe-resizer