WordPress.org

Forums

WP Code Prettify
[resolved] window.onload conflicts with other plugins (2 posts)

  1. the_champ
    Member
    Posted 11 months ago #

    Hi there,

    You have used following code in "wp-code-prettify.php" file

    window.onload = function(){prettyPrint();};

    which does not let run the window.onload function defined in other plugins/themes activated at websites. This, in turn, breaks the functionality of the website which uses your plugin.
    So, you must change that code to following:

    function soliOnLoad(func){
    			var boliqOldOnLoad = window.onload;
    			if (typeof window.onload != 'function') {
    				window.onload = func
    			} else {
    				window.onload = function () {
    					boliqOldOnLoad();
    					func()
    				}
    			}
    		}
    		soliOnLoad(function(){
    			window.onload = function(){prettyPrint();};
    		});

    Above will not cause conflict with window.onload function of any other plugin/theme.

    https://wordpress.org/plugins/wp-code-prettify/

  2. Soli
    Member
    Plugin Author

    Posted 11 months ago #

    Thank you very much, Champ.

    I have merged your code into the newest version v0.2.3. Please update.

Reply

You must log in to post.

About this Plugin

  • WP Code Prettify
  • Frequently Asked Questions
  • Support Threads
  • Reviews

About this Topic