Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Local Environment: Auto-activate plugin or theme when running for the first time #238

Closed
danielbachhuber opened this issue May 3, 2023 · 8 comments · Fixed by #351
Closed
Assignees

Comments

@danielbachhuber
Copy link
Member

When running wp-now for the first time in a plugin or theme directory, it would be nice if the codebase was automatically activated.

However, we don't want to re-activate on server start if the user already deactivated the plugin or theme.

Done is:

  • Running wp-now for the first time auto-activates the plugin or theme.
@dmsnell
Copy link
Member

dmsnell commented May 3, 2023

In my fork I created an auto-mount of mu-plugins for this purpose
8c8e29f07

it's different than auto-activating a plugin, but I thought it was in a less surprising way that keeps control in the hands of the person using the tool - it's a behavior already there in WordPress and not a new surprise inside the Playground

@danielbachhuber
Copy link
Member Author

Makes sense. We automatically log the user in, though, so I think it's reasonable that auto-activating the plugin could be seen as a sensible default.

@dmsnell
Copy link
Member

dmsnell commented May 3, 2023

there's at least one difference to consider: auto-activating carries side-effects. the activation hook never runs for mu-plugins. in some cases it would be helpful to activate the plugin because of this; in other cases it could clobber something on the site.

it is pretty easy to run an activation hook manually via mu-plugins

just wanted to note this here as a possible good idea with unanticipated consequences.

@danielbachhuber
Copy link
Member Author

auto-activating carries side-effects. the activation hook never runs for mu-plugins. in some cases it would be helpful to activate the plugin because of this; in other cases it could clobber something on the site.

Ah, good point.

@danielbachhuber
Copy link
Member Author

I wonder if it would make sense to add WP-CLI support first (WordPress/playground-tools#25), and then handle theme auto-activation with WP-CLI...

@adamziel
Copy link
Collaborator

adamziel commented May 10, 2023

@danielbachhuber you can already auto-activate plugins using the activatePlugin function from the @wp-playground/blueprints package:

export interface ActivatePluginStep {
step: 'activatePlugin';
plugin: string;
}
/**
* Activates a WordPress plugin in the Playground.
*
* @param playground The playground client.
* @param plugin The plugin slug.
*/
export const activatePlugin: StepHandler<ActivatePluginStep> = async (
playground,
{ plugin },
progress
) => {

In general, I'd like to keep adding these utilities to Blueprints even if they overlap with what's already implemented wp-cli. This is because wp-cli is 5MB and I want to avoid loading it in most Playground installations on the web. cc @sejas

@sejas sejas self-assigned this May 10, 2023
@danielbachhuber
Copy link
Member Author

@adamziel Cool, works for me 👍

@sejas
Copy link
Collaborator

sejas commented May 16, 2023

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants