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: main
Choose a base branch
from
Open

Conversation

kraftbj
Copy link
Contributor

@kraftbj kraftbj 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.

@sboisvert
Copy link

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

@kraftbj
Copy link
Contributor Author

kraftbj 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
Copy link
Contributor Author

kraftbj commented May 5, 2018

On deactivation, need to remove the msm_cron_update_sitemap cron event.

@kraftbj
Copy link
Contributor Author

kraftbj 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
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants