[ALREADY AVAILABLE] Code snippet options: functions.php

The “add code snippet” extension is too limited. Most of my repeated code snippets need to be added to the functions.php file of the active theme. THAT would be a useful addition.

@nadworks This is exactly what the Code Snippet extension does. When you choose “Execute on Child Sites” it saves the code snippet within the Child Site’s DB and runs on every page load as if it was directly added to the functions.php file of your Child Theme.

MainWP Code Snippets Extension is a simple way to add code snippets to your child sites from one centralized location. No need to edit your theme’s functions.php file or wp-config anymore! - https://mainwp.com/extension/code-snippets/

I agree that adding snippets directly into functions.php would be very useful.

Out of curiosity, what sort of scripts do you “plug and play” like that on a regular basis?

@kwcjr is right. MainWP Code Snippets extension doesn’t need to insert code directly into the functions.php file. It simply saves to the database and executes so there is absolutely no need to insert it directly in the file.

This way is much easier for the extension to track where snippets are in use so it’s easy to remove when not needed.

1 Like

Since the current functionality of the extension provides the same as if code would be saved in the functions.php, we will have to reject this request.

1 Like

Understood.
Are there instructions about how to remove snippets again? Thanks.

Mainly custom shortcodes, Woocommerce hooks, minor customisations that don’t require yet another plugin, but can easily be done via the functions.php (i.e. customising the standard WP login page)

Here you can find the help tutorials for removing snippets:

And if the site is broken:

1 Like

Ah, so you’re just saving yourself a bit of time from not logging into the site to do it “manually”. I thought that maybe you added/removed snips more dynamically based on certain conditions, like running campaigns and such.

I’d do the same if I was a PHP wizz :slight_smile: