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

Add activation/deactivation functions #138

Open
wants to merge 2 commits into
base: master
from

Conversation

Projects
None yet
2 participants
@kraftbj
Copy link
Contributor

commented May 4, 2018

Fixes #137

This adds a simple call to the rewrite initiation function and flushes rewrites on plugin activation and a second function to run on deactivation.

On deactivation, there is no remove_rewrite_rule function, so we need to manually unset the rules. unset is safe enough that we can run it on all possible rules, not only the ones that were set in the beginning.

@kraftbj kraftbj added the enhancement label May 4, 2018

@kraftbj kraftbj requested review from sboisvert and mattoperry May 4, 2018

@sboisvert

This comment has been minimized.

Copy link

commented May 4, 2018

The functions look good, what benefit is there to them not being inside the class?

@kraftbj

This comment has been minimized.

Copy link
Contributor Author

commented May 4, 2018

Technically, it's all the same, but I see it as:

  1. Per coding standards, the class should be in a file by itself named as such.
  2. These functions are not plugin functionality per se, but meta work associated with the plugin.

It would set us up for splitting out the class to a separate file, while keeping these "meta" functions in the base plugin file. While we're aiming at PHP 5.5+ for best performance, we don't enforce that. Splitting out real functionality from the base plugin file would make it easier to use modern syntax without worrying about a hard fatal on upgrading sites that lack the proper PHP. We can use the activation function to check and not allow activation or only require_once the class file if meeting a PHP prereq.

tl;dr: It sets us up for less code churn in the future.

@kraftbj

This comment has been minimized.

Copy link
Contributor Author

commented May 5, 2018

On deactivation, need to remove the msm_cron_update_sitemap cron event.

@kraftbj

This comment has been minimized.

Copy link
Contributor Author

commented May 8, 2018

Cleaned out cron hooks and options in f92ebda. In both cases, we do not know how long it has been since the plugin was deactivated, so we should expect to need to start from scratch.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.