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

Using $plugin_name during activation #281

Open
EmilEriksen opened this issue Apr 5, 2015 · 6 comments
Open

Using $plugin_name during activation #281

EmilEriksen opened this issue Apr 5, 2015 · 6 comments

Comments

@EmilEriksen
Copy link

Every time I've made a plugin I've found myself needing the plugin name slug in the activator class (for instance to prefix options). Why is it that this is not made available in the activator (or deactivator) class?

@DevinVinson
Copy link
Owner

Good question that I don't have a good answer for unfortunately.

I've been looking at the activator and deactivator classes myself today and am going to go look through any discussions that have taken place about them.

If you have any thoughts, feel free to share.

@DevinVinson
Copy link
Owner

As quick follow up: #178

@EmilEriksen
Copy link
Author

Thanks for the reply Devin. Interesting. Since the (de)activation classes are static there's really no way of passing $plugin_name and $version to them unless of course these two variables are also made static, right? So one way could be including the main plugin class before the (de)activator classes in (de)activate_plugin_name() and making these variables static.

I've been looking at a bunch of plugins (WC, EDD, Ninja Forms, WP SEO etc.) and they all seem to be using constants. That could be another possibility.

@dimitrilongo
Copy link

@EmilEriksen also need some $plugin_name in the activator class, but can't because of non static. So i used constant, but don't like it. Did you find another solution ? Thanks

@pcfreak30
Copy link

I am turning the main class to a singleton for this.

@adamradocz
Copy link

I use Closure in my fork.

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

No branches or pull requests

5 participants