Forum Replies Created

Viewing 6 replies - 1 through 6 (of 6 total)
  • You can try this it will select all elements on the page:

    
    var activated = 0;
    document.getElementById("button").addEventListener('click', function () {
    	if (activated == 0) {
    		setStyle("background-color: white; color: black !important");
    		activated = 1;
    	} else {			
    		setStyle("background-color: black; color: white !important");
    		activated = 0;
    	}
    });
    
    function setStyle(myStyle) {
    	var elements = document.getElementsByTagName("*");
    	for(var i in elements) {
    		if(elements[i].setAttribute) {
    			elements[i].setAttribute("style", myStyle);
    		}
    	}
    }
    

    I would suggest looking at your page using a browser developer tool. If you press F12 in most browsers (I prefer Chrome) and the developer tools should pop up and will allow you to inspect the elements. Inspect the headlines and other elements that don’t have the colors you want and look at the styles and you should be able to see which style is overriding your colors. Then you can adjust your styles so they have priority. The !important helps deal with conflicts but it doesn’t always work. You will have to select the headlines specifically if they aren’t inheriting the colors from the body.

    I like to call the add_shortcode function in __construct function of the class.

    class PluginExample {
    	public function __construct() {		
    		add_shortcode('say-hello', array($this, 'hello'));
    	}
    	
    	public function hello() {		
    		echo '<h3>Hello World!</h3>';
    	}
    }
    
    $pluginExample = new PluginExample();

    You could try this:

    var activated = 0;
    document.getElementById("button").addEventListener('click', function () {
    	if (activated == 0) {			
    		document.body.setAttribute("style", "background-color: white; color: black !important");
    		activated = 1;
    	} else {			
    		document.body.setAttribute("style", "background-color: black; color: white !important");
    		activated = 0;
    	}
    });
    

    Adding the !important tag to your color attribute should override most of the color on the page, depending on how your theme’s style sheet is setup.

    • This reply was modified 6 years, 11 months ago by andy30z.
    Thread Starter andy30z

    (@andy30z)

    I have figured it out. It’s the sending of email that is slowing things down, probably due to the fact that I’m using shared hosting.

    Thread Starter andy30z

    (@andy30z)

    I do not have a cache plugin. So I’ve disabled all my plugins and it still takes 17 seconds. I’m not sure what could be causing this. Is this normal for WordPress? Could it be a server configuration issue?

Viewing 6 replies - 1 through 6 (of 6 total)