(Go: >> BACK << -|- >> HOME <<)

Skip to content

Details on configuration

Younes edited this page Oct 17, 2021 · 29 revisions

This is more detailed documentation on configuring the browser-update.org notification script in addition to the Customize and Test documentation page.

Configure browser versions to notify

By passing the object "required" you can specify the versions to notify: e.g.

$buoop = {
    required:{
        e:16,
        f:58,
        o:51,
        o_a:45,
        s:-1,
        c:"67.0.3396.12",
        y:18.1,
        v:"1.10",
        uc:11.5,
        samsung:7.0
    }
}

This means for example that Firefox ("f") 58 is required on the site and all versions before 58 (<58) will be notified.

Negative numbers specify how many versions behind the latest version are required.

E.g. s:-1 means Safari version 10.1 is needed if latest version ist 11.1

0 means the latest version is needed.

Browsers

Key Browser Note
e Edge Falls back to value specified in "i" when omitted
i Internet Explorer Falls back to value specified in "e" when omitted
c Chrome
f Firefox
o Opera
o_a Opera (Android)
s Safari
y Yandex Browser
v Vivaldi
uc UC Browser
ios iOS browser Falls back to "s" when omitted
samsung Samsung Internet (Android)

You can omit the configuration and it will fall back to a default.

Version history comparison uses "semantic version" comparison: e.g. "2.10">"2.1"

Use quotes around the version to clarify that 2.10 is not 2.1

You can also notify build versions: Be sure to use quotes in this case as it is no valid floating point number e.g c:"67.0.3396.12"

Notifying "insecure" browsers

The option insecure: true means that all browser that are severely insecure get notified. "Severely insecure" means that the browser has security issues that allow remote code execution and similar stuff, and that they are being actively exploited on the internet.

Currently these browsers are marked as insecure.

Notifying "unsupported" browsers

The option unsupported: true means that additionally to the browsers you set, also all browser versions that are not supplied with updates by the vendor any more get notified. Usually this is all but the latest version of the browser. Exceptions are Internet Explorer 11 and Firefox Long term support releases, which are still supported but are not the latest version.

Custom text

You can use a custom text message by specifying the parts of the message that get presented to users:

$buoop = {
    text: {
       'msg':'Your web browser ({brow_name}) is out of date.',
       'msgmore': 'Update your browser for more security, speed and the best experience on this site.', 
       'bupdate': 'Update browser', 
       'bignore': 'Ignore',
       'remind': 'You will be reminded in {days} days.',
       'bnever': 'Never show again'  
    }
}

Different messages depending on browser

If you want to have a message for a special browser use text_for_x where x is the id of the browser (see Browsers)

This will for example show a different message for Internet Explorer

$buoop = {
    text_for_i: {
       'msg':'Your browser ({brow_name}) is so damn old! Internet Explorer is not supported anymore.',
       'msgmore': 'Update your browser as soon as possible to use this site.'
    }
}

For wordpress beginners , you can translate text like this :

_you can update the text with your custom text by dequeue the script and enqueue : _

,text:"Mysite.com would like to remind you: Your browser {brow_name} is out of date. Please <a{up_but}>update for more security, comfort and the best experience on mysite.com",api:2019.08};

If you want to add the code manualy :


<script> 
var $buoop = {required:{e:0,f:0,o:0,s:0,c:0},insecure:true,unsupported:true,text:"Mysite.com would like to remind you: Your browser {brow_name} is out of date. Please <a{up_but}>update</a> for more security, comfort and the best experience on Mysite.com",api:2021.10 }; 
function $buo_f(){ 
 var e = document.createElement("script"); 
 e.src = "//browser-update.org/update.min.js"; 
 document.body.appendChild(e);
};
try {document.addEventListener("DOMContentLoaded", $buo_f,false)}
catch(e){window.attachEvent("onload", $buo_f)}
</script>

If you using a plugin try this code : :

/**
 *
 * WP Browser update plugin overide
 *
 */

if (  function_exists( 'wpbu' ) )  {

	function wpbu2() {
		$wpbu_vars = explode(' ', get_option('wp_browserupdate_browsers'));
		$wpbu_js = explode(' ', get_option('wp_browserupdate_js'));
		var_dump($wpbu_js);
		$browser = 'e:'.$wpbu_vars[0].',f:'.$wpbu_vars[1].',o:'.$wpbu_vars[2].',s:'.$wpbu_vars[3].(!isset($wpbu_vars[4])?'':',c:'.$wpbu_vars[4]);

		echo '<script type="text/javascript">
		var $buoop = {required:{'.$browser.'},test:'.(isset($wpbu_js[1]) ? $wpbu_js[1] : '').',newwindow:'.(isset($wpbu_js[2]) ? $wpbu_js[2] : '').',style:"'.(isset($wpbu_js[3]) ? $wpbu_js[3] : '').'",insecure:'.(isset($wpbu_js[4]) ? $wpbu_js[4] : '').',unsupported:'.(isset($wpbu_js[5]) ? $wpbu_js[5] : '').',mobile:'.(isset($wpbu_js[6]) ? $wpbu_js[6] : '').',shift_page_down:'.(isset($wpbu_js[7]) ? $wpbu_js[7] : '').',text:"Mysite.com would like to remind you: Your browser {brow_name} is out of date. Please <a{up_but}>update</a> for more security, comfort and the best experience on mysite.com",api:2019.08};

		function $buo_f(){
			var e = document.createElement("script");
			e.src = "//browser-update.org/update.min.js";
			document.body.appendChild(e);
		};
		try {document.addEventListener("DOMContentLoaded", $buo_f,false)}
		catch(e){window.attachEvent("onload", $buo_f)}
		</script>';
	}

	remove_action( 'wp_footer', 'wpbu' );
	add_action('wp_footer', 'wpbu2');
} 

Note: You need to update this code each time plugin updates this section of code


remove var_dump while I was testing the code. Just remove this line or comment out so it will not render anymore

Change this

var_dump($wpbu_js);

to

//var_dump($wpbu_js);

Corrected new code:

/**
 *
 * WP Browser update plugin overide
 *
 */

if (  function_exists( 'wpbu' ) )  {

	function wpbu2() {
		$wpbu_vars = explode(' ', get_option('wp_browserupdate_browsers'));
		$wpbu_js = explode(' ', get_option('wp_browserupdate_js'));
		$browser = 'e:'.$wpbu_vars[0].',f:'.$wpbu_vars[1].',o:'.$wpbu_vars[2].',s:'.$wpbu_vars[3].(!isset($wpbu_vars[4])?'':',c:'.$wpbu_vars[4]);

		echo '<script type="text/javascript">
		var $buoop = {required:{'.$browser.'},test:'.(isset($wpbu_js[1]) ? $wpbu_js[1] : '').',newwindow:'.(isset($wpbu_js[2]) ? $wpbu_js[2] : '').',style:"'.(isset($wpbu_js[3]) ? $wpbu_js[3] : '').'",insecure:'.(isset($wpbu_js[4]) ? $wpbu_js[4] : '').',unsupported:'.(isset($wpbu_js[5]) ? $wpbu_js[5] : '').',mobile:'.(isset($wpbu_js[6]) ? $wpbu_js[6] : '').',shift_page_down:'.(isset($wpbu_js[7]) ? $wpbu_js[7] : '').',text:"Mysite.com would like to remind you: Your browser {brow_name} is out of date. Please <a{up_but}>update</a> for more security, comfort and the best experience on mysite.com",api:2019.08};

		function $buo_f(){
			var e = document.createElement("script");
			e.src = "//browser-update.org/update.min.js";
			document.body.appendChild(e);
		};
		try {document.addEventListener("DOMContentLoaded", $buo_f,false)}
		catch(e){window.attachEvent("onload", $buo_f)}
		</script>';
	}

	remove_action( 'wp_footer', 'wpbu' );
	add_action('wp_footer', 'wpbu2');
}