3

I'm going to develop a custom theme which will have a plugin included in it. Then, hide the UI from the site's admin.

I'm wondering what happens if the admin of the site having my theme activated on, decides to install and use the very same plugin separately? Everything will be ok? could that cause any conflict or problem?

  • 1
    why not to simply try? – Mark Kaplun Jun 8 '17 at 17:20
  • 1
    I've modified your question to make it more generic while hopefully keeping the same idea. This could be an issue with any plugin - not just ACF. Questions regarding 3rd party plugins ( such as ACF ) are considered to be off-topic and likely closed. – Howdy_McGee Jun 8 '17 at 17:23
  • I think this will be very plugin specific though – Andy Macaulay-Brook Jun 8 '17 at 17:24
5

I'm going to develop a custom theme which will have a plugin included in it.

Please, don't include a plugin in your theme.

Instead, I'd suggest using TGM Plugin Activation or some other mechanism to require or recommend plugins for your theme (TGM also works for plugins).

Separating your theme and any required or suggested plugins will allow everything to be updated independently, which is crucial for staying on top of security issues.

There was a huge security situation not too long ago caused (in part) by themes bundling a slider plugin which had a vulnerability. Even though the plugin's authors patched the vulnerability, the issue remained on many sites because the plugin was included in the theme and therefore was not updated. This creates a big headache for everybody -- plugin developers, end users, site visitors, and you (the theme developer).

Also, if you want to hide the UI for these plugins, I would suggest only doing so for non-administrator roles. This kind of stuff could be handled via your theme or via your own custom plugin.

-1

I've seen some themes take a "recommended plugin" approach, which is safer. Don't include the plugin in the theme. Instead, check for a function specific to the plugin that's required for some functionality - for example, if you're talking about ACF, you could use:

if(function_exists('have_rows')) {
    // Enable fancy theme feature
} else {
    // Tell site admin to install plugin if they want to enable fancy feature
}

This frees you in several ways:

  • You won't have to update your theme every time an update is available for the plugin.
  • You won't have issues with sites installing the plugin in addition to your theme.
  • If there are support issues with the plugin, you can easily direct them to the plugin authors. If the code is embedded in your theme, technically you should be supporting all features, which could quickly become overwhelming.
  • You won't run into copyright issues if the plugin isn't completely open source and free.

Especially if the plugin in question offers a premium paid version, you shouldn't bundle it directly into your theme.

Exception:

If you're trying to include a very small plugin, say 100 lines of code total, it's safe to include it in the theme. In order to prevent conflicts if the site installs the plugin too, prefix all of the functions so that you're not calling anything the same thing the plugin calls them. That way, both the plugin and the theme's functions will work.

  • downvoted, as all the disagreements are too long to specify in the comments but essentially in the general case, if the plugin do not do backward compatibility, the core assumption that you can use version N in a theme while a version N+1 is installed just have no merit. Think about themes that where built for WC 2.6, what happened when WC 3.0 came – Mark Kaplun Jun 8 '17 at 18:11
  • Yes, theme dependencies on plugins are inevitably going to run into problems. Stuffing a plugin into a theme isn't always a good answer (as in the OP's case of ACF) which is why I mentioned checking for a function's existence and adding extra features when the plugin is installed, versus depending 100% on the site using a particular plugin in order to use the theme. – WebElaine Jun 8 '17 at 19:58
  • 1
    the problem is that function existance is not enough. I ran into problem with using the select2 JS library in a theme because WC was using an outdated version. no way to test for that just by testing for the existance of the library, and worse it is impossible to run theme side by side. – Mark Kaplun Jun 9 '17 at 2:36

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.