Support » Plugin: WP BrowserUpdate » Customize the text directly from the plugin interface

  • Resolved typopositive

    (@typopositive)


    Hello,
    I would like to know if there is some way to customize the text in different languages straight through the plugin interface?
    I’ve read the documentation, but I’m not developer, so I don’t know how to integrate this part of script through my back-office:
    $buoop = {
    text_xx: “”
    // custom notification text for language “xx”
    // e.g. text_de for german and text_it for italian
    };
    Thanks!

Viewing 8 replies - 1 through 8 (of 8 total)
  • Plugin Author Marco Steinbrecher

    (@macsteini)

    I haven’t implemented this feature due to lack of use cases as of yet. Hence, you can’t use the above without coding knowledge.

    Thank you for the quick reply.
    I guess I will have to try anyway 🙂
    I imagine I should override this code in the functions.php of my child theme?
    Should I dequeue the script and enqueue my own?
    What is the best practice in this case?
    Thanks again!

    Plugin Author Marco Steinbrecher

    (@macsteini)

    Either way shouldn’t impact the performance too much. Try yourself and share your findings afterwards.

    @typopositive Until the dev add this feature, you can update the text with your custom text by dequeue the script and enqueue again in functions.php in child theme.

    ,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};

    See the example below.

    /**
     *
     * 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

    typopositive

    (@typopositive)

    @jimi007 Many thanks 🙂

    Hi – When we use the above code in the functions.php we have some strange coding appear at the bottom of the live site:

    array(8) { [0]=> string(1) “0” [1]=> string(5) “false” [2]=> string(4) “true” [3]=> string(6) “corner” [4]=> string(4) “true” [5]=> string(4) “true” [6]=> string(5) “false” [7]=> string(5) “false” }

    Are we doing something wrong/missing something?

    The plugin developer says it was something to do with the custom coding – “It seems you made manual changes to the plugin which causes this behaviour”.

    Thanks.

    @teamvolta Sorry I forget to 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');
    }
    • This reply was modified 1 month, 1 week ago by Jamil Ahmed.

    Hi Jamil,

    that has worked perfectly – thank you very much 🙂

Viewing 8 replies - 1 through 8 (of 8 total)
  • You must be logged in to reply to this topic.