PluginProbe
Tag Groups is the Advanced Way to Display Your Taxonomy Terms / trunk
Tag Groups is the Advanced Way to Display Your Taxonomy Terms vtrunk
2.2.2 2.2.1 2.2.0 trunk 1.40.0 1.40.2 1.41.0 1.42.1 1.43.0 1.43.1 1.43.10 1.43.10.1 1.43.2 1.43.3 1.43.4 1.43.5 1.43.6 1.43.7 1.43.9 1.44.0 1.44.1 1.44.3 1.44.3.1 2.0.0 2.0.1 All 36 releases
tag-groups / include / admin / class.update.php

class.update.php in Tag Groups is the Advanced Way to Display Your Taxonomy Terms trunk, at include/admin/class.update.php

147 lines 4.5 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 /**
4 * Tag Groups Pro
5 *
6 * @package Tag Groups Pro
7 * @author Christoph Amthor
8 * @copyright 2017 Christoph Amthor (@ Chatty Mango, chattymango.com)
9 * @license see official vendor website
10 *
11 *
12 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
13 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
14 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
15 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
16 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
17 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
18 * THE SOFTWARE.
19 *
20 */
21
22 // phpcs:disable PSR1.Classes.ClassDeclaration.MissingNamespace, Squiz.Classes.ValidClassName.NotCamelCaps, PSR1.Methods.CamelCapsMethodName.NotCamelCaps
23 if (! class_exists('TagGroups_Update')) {
24 class TagGroups_Update
25 {
26 private $old_version;
27 private $new_version;
28
29
30 /**
31 *
32 * @unittest
33 *
34 * @param string $old_version
35 * @param string $new_version
36 */
37 public function __construct($old_version, $new_version)
38 {
39
40 $this->old_version = $old_version;
41 $this->new_version = $new_version;
42 }
43
44
45 /**
46 * Run scripts for specific old or new versions
47 *
48 * @unittest
49 * @return void
50 */
51 public function run_specific_scripts()
52 {
53
54 if (empty($this->old_version) || empty($this->new_version)) {
55 return;
56 }
57
58 // phpcs:ignore Squiz.PHP.CommentedOutCode.Found
59 // if ( version_compare( $this->old_version, '1.18.0' , '<' ) ) {
60 // }
61 }
62
63
64 /**
65 * Run processes for all version number steps
66 *
67 * @param void
68 * @return void
69 */
70 public function run_general_scripts()
71 {
72
73 /*
74 * Taxonomy should not be empty
75 */
76 $tag_group_taxonomy = TagGroups_Options::get_option('tag_group_taxonomy', array());
77 if (empty($tag_group_taxonomy)) {
78 update_option('tag_group_taxonomy', array('post_tag'));
79 } elseif (! is_array($tag_group_taxonomy)) {
80 // Prevent some weird errors
81 TagGroups_Options::update_option('tag_group_taxonomy', array( $tag_group_taxonomy ));
82 }
83
84 /*
85 * Theme should not be empty
86 */
87 if ('' == TagGroups_Options::get_option('tag_group_theme', '')) {
88 TagGroups_Options::update_option('tag_group_theme', TAG_GROUPS_STANDARD_THEME);
89 }
90
91
92 /**
93 * Register time of first use
94 */
95 if (defined('TAG_GROUPS_PLUGIN_IS_FREE') && TAG_GROUPS_PLUGIN_IS_FREE) {
96 if (! TagGroups_Options::get_option('tag_group_base_first_activation_time', false)) {
97 update_option('tag_group_base_first_activation_time', time());
98 }
99 }
100
101
102 // If requested and new options exist, then remove old options.
103 if (
104 defined('TAG_GROUPS_REMOVE_OLD_OPTIONS')
105 && TAG_GROUPS_REMOVE_OLD_OPTIONS
106 && TagGroups_Options::get_option('term_groups', false)
107 && TagGroups_Options::get_option('term_group_positions', false)
108 && TagGroups_Options::get_option('term_group_labels', false)
109 ) {
110 delete_option('tag_group_labels');
111 delete_option('tag_group_ids');
112 delete_option('max_tag_group_id');
113 TagGroups_Error::log('[Tag Groups] Deleted deprecated options');
114 }
115
116
117 /**
118 * Start with some delay so that in the case of simultaneous activation the base plugin will be available
119 */
120 TagGroups_Cron::schedule_in_secs(2, 'tag_groups_check_tag_migration');
121 TagGroups_Cron::schedule_in_secs(500, 'tag_groups_check_if_migrations_done');
122 // long enough after premium tasks
123
124 /**
125 * Reset the group filter above the tags list
126 */
127 update_option('tag_group_tags_filter', array());
128 }
129
130
131 /**
132 * Update the database entry with the latest version
133 *
134 * @unittest
135 * @return void
136 */
137 public function update_version_number()
138 {
139
140 // save new version
141 TagGroups_Options::update_option('tag_group_base_version', $this->new_version);
142 }
143 }
144
145
146 }
147