Skip to content

Commit 8d9f7cf

Browse files
authored
Plugin structure (#25)
* Plugin structure * added unit tests to cover constructors
1 parent 0ae3eb5 commit 8d9f7cf

26 files changed

+470
-295
lines changed

includes/class-customfieldspermalink.php

Lines changed: 0 additions & 281 deletions
This file was deleted.

includes/class-plugin-updater.php

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
<?php
2+
/**
3+
* Class Updater
4+
*
5+
* @package WordPress_Custom_Fields_Permalink
6+
*/
7+
8+
namespace CustomFieldsPermalink;
9+
10+
/**
11+
* Class Plugin_Updater handles the upgrade process.
12+
*/
13+
class Plugin_Updater {
14+
15+
/**
16+
* This hook is called once any activated plugins have been loaded.
17+
*
18+
* @link https://codex.wordpress.org/Plugin_API/Action_Reference/plugins_loaded
19+
*/
20+
public function on_init_hook() {
21+
$version_option_name = '_wordpress_custom_fields_permalink_plugin_version';
22+
$version_from = get_option( $version_option_name, null );
23+
$version_to = WORDPRESS_CUSTOM_FIELDS_PERMALINK_PLUGIN_VERSION;
24+
if ( $version_from != $version_to ) {
25+
$this->update_plugin( $version_from, $version_to );
26+
update_option( $version_option_name, $version_to, true );
27+
}
28+
}
29+
30+
/**
31+
* Upgrades the plugin.
32+
*
33+
* @param string $version_from Currently running version.
34+
* @param string $version_to Version upgrade to.
35+
*/
36+
private function update_plugin( $version_from, $version_to ) {
37+
flush_rewrite_rules();
38+
}
39+
}

0 commit comments

Comments
 (0)