Is there a write up on using the Code Snippets extension to add a tracking code to a site that uses Oxygen Builder (and therefore does not process the themes header.php or footer.php were one would normally place the code)?
@qpgltdco MainWP Code Snippets Extension runs PHP methods within the functions.php file.
That’s unfortunate. Sites using the Oxygen Builder plugin do not process the functions.php file. I was hoping to avoid having to install the Insert Headers and Footers plugin that Oxygen suggests as a solution.
It’s actually unfortunate that the Oxegyn Builder has decided to desregard the file that every plugin and theme known to the WP community uses to make customizations.
I don’t know anything about Oxegen builder but that sounds like a locked in pain.
@qpgltdco Yeah this isn’t making sense - Oxegen Builder doesn’t have a functions.php file to edit but any base theme in WP does… They suggest using custom plugins instead of directly altering their functions.php file simply because if you alter those files without a Child Theme you risk loosing your code. - which suggests that the functions.php file is still utilized in some way.
Using the MainWP Code Snippets extension is basically as if you were to create your own plugin… You should try using it to see if it works…
When the Oxygen plugin is active the WordPress theme is disabled.
From their FAQ:
Will my theme work with Oxygen?
No. Oxygen completely disables the WordPress theme system. This means that while your theme won’t conflict with Oxygen, its styles and layout also won’t be applied to your site while Oxygen is active.
This is not correct, as you can read in the documentation:
This type of snippet will add the snippet on your child site, and it will be executed on-site load. This type of snippets will be saved in your child site database and executed each time your child site is loaded by the PHP command eval().
I think the usage of a Header/Footer plugin would be the most simple solution. These plugins are very light, so it shouldn’t hurt your performance.
@josklever It’s not wrong - technically. Yes, MainWP Code Snippets are in fact stored in the MainWP Child Plugin DB & run via eval() & ob_start() right before the MainWP Child Plugin functions.php is executed… My choice of verbiage here is to lessen confusion.
To map it out exactly how the Code Snippet extension functions:
- When Child Site loads all plugins installed are initiated.
- This fires of the MainWP Child Plugin file “mainwp-child.php”
- This file has an auto loader that includes all class files within /class one after another
- Then includes the MainWP Child Plugin function.php file.
Saved Code Snippets are fired off first thing right before the MainWP Child Plugin functions.php file is included.
Not to get off the main point in my response - adding code snippets to a Child Site that is utilizing Oxygen Builder should still function as intended even though it “disables” the default Theme rendering it’s functions.php file useless because It’s got nothing to do with the theme.
Oxygen recommends in their documentation to create Custom Plugins in order to extend functionality via code snippets. Within the link I posted above they reference this article: Why You Shouldn't Add Custom Code to functions.php – WPMU DEV
These plugins would all have a functions.php file associated with them just like the MainWP Child Plugin does. If that doesn’t work then the MainWP Child Plugin wouldn’t function at all either.
The code snippets used in my writeup would most likely be the same used in any plugin you would install via WP repository.
This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.