With Vantage Premium and a handful of siteorigin plugins, I am having trouble with the CSS from the theme customizer appearing AFTER the CSS from Appearance->Custom CSS.
This is a problem because the Theme customizer CSS will override any custom CSS (without an !important flag), which effectively ends the chain at the Theme’s built-css rather than my custom CSS
In my output pages’ source I see the following:
... <head> ... <style id='vantage-custom-css' class='siteorigin-custom-css' type='text/css'> .../*my css*/ </style> <style type="text/css" id="customizer-css"> .../*theme-built-css*/ </style> ...
Unfortunately the url I’m working is internal to our network, so I can’t include a link for sourcereference.
I have attempted some of my own troubleshooting and edits, but to no avail.
I have found a function called “css()” in the ‘vantagepremiumextrascustomizercustomizer.php’ file, which appears to control printing of the Theme-built customizer-css. If I comment this out, the style tag from the theme customizer (
<style id="customizer-css">...</style>) does not get written to the page.
It appears this method is called from a function in premium/inc/customizer.php, line 533-540:
function vantage_customizer_style() { ... echo $builder->css(); }
and again, I can comment this out and the theme-customizer-generated styles do not write to the page.
This function is registered with wp_head() using the following (line 542 of the same file):
add_action('wp_head', 'vantage_customizer_style', 20 /*20 represents the priority according to wordpress codex*/);
I found a function
function siteorigin_custom_css_display() { ... }in the vantagepremiumextrascsscss.php file, which also appears to write the custom css content with the following code:
echo "<style id='" . sanitize_html_class($theme) . "-custom-css' class='siteorigin-custom-css' type='text/css'>n"; echo siteorigin_custom_css_clean( $custom_css , '\') . "n"; echo "</style>n";
and registers it with
add_action('wp_head', 'siteorigin_custom_css_display', 15 /*15 represents the priority according to wordpress codex*/ );
Now, I’m not entirely familiar with the priorities, so first I tried changing the add_action line to change this function’s priority to 25 (meaning AFTER the $builder->css(); executes), but it does not change the order of elements on the pages.
Confused, I tried commenting out the ‘echo’ lines, but this did NOT appear to have any effect on rendered pages.
I’m still digging through the files, but haven’t found anything that seems to be related just yet.
Any help would be appreciated.
Thanks!
– Turk
EDIT:
So it appears that ‘siteorigin_custom_css_display()’ not the function used to print custom css to the rendered pages. Will need to keep looking.
SOLVED!
I found the function that renders the CSS to the page. It’s in \wp-content\plugins\so-css\so-css.php on line 70
If I comment this out, the custom CSS will not render to the pages.
This function appears to register with the following from line 31 of the same page:
so I edited this priority to read:
Resolved!
Hi Jonathan
Thanks for the update. Appreciate all the effort.
Just on a quick skim read of your work…this change isn’t update safe right? You’ve edited the plugin file directly?
I can’t seem to replicate the problem you’re getting. In local testing my Custom CSS comes before the Customizer CSS. I see they are both 20 but I’m not seeing the same order you are. Not quite sure why that is.
To make this edit update safe we could instead add the following in a child theme functions.php file:
Give a try if you’re keen.
Removing the Customizer styles at 20, adding them back at 30. Seems to work ok locally on my side.
Vanilla child theme if you need one:
https://siteorigin.com/wp-content/uploads/2015/03/vantage-child-starter.zip
Having just updated to Version: 2.4.4, I was excited to give this another try.
I updated my theme, and it again reordered the CSS so the customizer CSS comes after my custom CSS. Andrew, I tried adding the functions you mentioned in your first post, to the end of my Functions.php file, but it did not alter the order the CSS is printed to the page.
If I re-do my previously mentioned alterations, the order corrects itself. Ideas?
***** EDIT: If I re-do my previous alterations the order DOES NOT correct itself.
Hi Jonathan
Another direction to take might be to increase the specificity of each rule added to Appearance > Custom CSS. We wouldn’t mind assisting with that. If you post the contents of Custom CSS here or pastebin.com we could assist further.