afragen / wp-dependency-installer

A lightweight class to add to WordPress plugins/themes to automatically install plugin dependencies.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

option to install/active during preview

JiveDig opened this issue · comments

This could certainly be a controversial request/option, but here's my scenario:

I have a Genesis child theme that actually has 99% of its code in a helper plugin that gets auto-installed/activated via wp-dependency-installer. It works great! This allows me to push "theme" updates via the plugin without overriding any customizations in the child theme. It's kind of a grandfather theme idea.

I have issues in scenarios where people want to preview the theme. The theme doesn't load correctly because all of the core functionality is in the plugin, which isn't loaded yet.

Therefore, I'm wondering if we can have an option to install/activate during preview too. My plugin already has code to deactivate itself if the theme isn't activated. The plugin should only work with my theme(s).

I’m not sure there’s a way to do this. Isn’t the preview shown before the theme has been activated? If so then the dependency installer framework isn’t active. I wonder if it’s possible to add some information to the preview stating that the theme’s companion plugin must be active for a preview.

Is there a hook that the theme runs during a preview?

The theme isn't activated, but the files must be loaded right? Honestly I don't really know anything about the preview stuff cause I never use it. I can do some digging, there's gotta be some load preview type hook I would think.

Currently the code works because it’s called when the theme is active. If there’s a hook that activates the plugin during a preview I would think that should also trigger the dependency installation too. I really have no idea how the Customizer preview works.

It might be simpler to add a notice somewhere in the README that the preview function will be incomplete and it would be best to simply install and activate the theme for a preview.