PluginProbe
MaxButtons – Create buttons / 6.28
MaxButtons – Create buttons v6.28
6.23 6.24 6.25 6.26 6.26.1 6.27 6.28 6.3 6.4 6.5 6.6 6.7 6.8 6.9 7.0 7.1 7.1.1 7.1.2 7.1.3 7.10 7.11 7.13 7.13.1 7.13.2 7.13.3 All 100 releases
← All changes | classes/installation.php +177 -273 7.136.28 View file →
@@ -1,11 +1,11 @@
1 -<?php
1 +<?php
2 2 namespace MaxButtons;
3 3 defined('ABSPATH') or die('No direct access permitted');
4 4
5 5 class maxInstall
6 6 {
7 - public static function activation_hook($network_wide) {
7 + static function activation_hook($network_wide) {
8 8 if ($network_wide) {
9 9 static::call_function_for_each_site( array('self','activate_plugin') );
10 10 }
11 11 else {
@@ -11,9 +11,9 @@
11 11 else {
12 12 static::activate_plugin();
13 13 }
14 14 }
15 - public static function deactivation_hook($network_wide) {
15 + static function deactivation_hook($network_wide) {
16 16
17 17 if ($network_wide) {
18 18 static::call_function_for_each_site( array('self','deactivate_plugin') );
19 19 }
@@ -19,37 +19,22 @@
19 19 }
20 20 else {
21 21 static::deactivate_plugin();
22 22 }
23 - }
23 + }
24 24
25 - public static function hasAddOn($addon)
26 - {
27 - switch($addon)
28 - {
29 - case 'socialshare':
30 - if (defined('MBSOCIAL_ROOT_FILE'))
31 - {
32 - return true;
33 - }
34 - break;
35 - }
36 -
37 - return false;
38 - }
39 -
40 25 // This should be done - once! Removed in time as well.
41 - public static function check_database()
26 + static function check_database()
42 27 {
43 - $checked = get_option("MB_DBASECHECK", true);
28 + $checked = get_option("MB_DBASECHECK", true);
44 29 if ($checked !== false) // removing this option.
45 - delete_option('MB_DBASECHECK');
46 -
30 + delete_option('MB_DBASECHECK');
31 +
47 32 $version = MAXBUTTONS_VERSION_NUM;
48 - $installed_version = MB()->get_installed_version();
33 + $installed_version = MB()->get_installed_version();
49 34 if ($version !== $installed_version)
50 35 {
51 - $table = maxUtils::get_table_name();
36 + $table = maxUtils::get_table_name();
52 37
53 38 self::activate_plugin(); // always run the DBdelta on version mismatch.
54 39 self::clear();
55 40 }
@@ -54,231 +39,149 @@
54 39 self::clear();
55 40 }
56 41 }
57 42
58 - public static function activate_plugin($gocreate = true)
43 + static function activate_plugin($gocreate = true)
59 44 {
45 + $button = new maxButton();
46 + $button->reset_cache(); //refresh cache
47 +
60 48 static::create_database_table();
61 - static::migrate();
49 + static::migrate();
62 50 static::upgradeUTF();
63 - static::updateFA();
64 -
65 - $button = MB()->getClass('button');
66 - $button->reset_cache(); //refresh cache
67 -
68 51 update_option(MAXBUTTONS_VERSION_KEY, MAXBUTTONS_VERSION_NUM);
69 - $created = get_option("MBFREE_CREATED");
70 - if ($created == '' && $gocreate)
71 - { update_option("MBFREE_CREATED", time());
72 - update_option("MBFREE_HOMEURL", home_url());
52 + $created = get_option("MBFREE_CREATED");
53 + if ($created == '' && $gocreate)
54 + { update_option("MBFREE_CREATED", time());
55 + update_option("MBFREE_HOMEURL", home_url());
73 56 }
74 57
75 58 }
76 -
59 +
77 60 /** Function to clear out obsolete and old options, items etc. */
78 - public static function clear()
61 + static function clear()
79 62 {
80 63 delete_option('MB_DBASECHECK');
81 64 }
82 -
83 - /** MOVE Button Database records from FA4 to FA5 */
84 - public static function updateFA()
85 - {
86 - global $wpdb;
87 -
88 - $table_name = maxUtils::get_table_name();
89 - $sql = ' SHOW COLUMNS FROM ' . $table_name . ' LIKE "icon"';
90 - $result = $wpdb->get_results($sql, ARRAY_A);
91 -
92 - // when the icon field does not exist. Otherwise this causes an activate notice.
93 - if (count($result) == 0)
94 - return;
95 -
96 -
97 - $conversion_path = MB()->get_plugin_path() . '/assets/libraries/font-awesome-5/shims.json';
98 - $conversion_array = json_decode(file_get_contents($conversion_path), ARRAY_A);
99 -
100 -
101 - $sql = 'select id, icon from ' . maxUtils::get_table_name();
102 - $result = $wpdb->get_results($sql, ARRAY_A);
103 - if (count($result) == 0)
104 - return;
105 -
106 - foreach($result as $item)
107 - {
108 - $button_id = $item['id'];
109 - if (! $button_id > 0)
110 - { continue; }
111 - // procedure from setupdata by button class
112 - $icondata = maybe_unserialize($item['icon']);
113 - if (! is_array($icondata) )
114 - {
115 - $icondata = json_decode($icondata, true);
116 - if (isset($icondata['fa_icon_value']) && strlen($icondata['fa_icon_value']) > 0)
117 - {
118 - $fa_icon = $icondata['fa_icon_value'];
119 - $fa_icon = str_replace('fa-', '', $fa_icon); // remove the prefix
120 -
121 - // don't convert converted icons.
122 - if (strpos($fa_icon, 'fas') === false && strpos($fa_icon, 'fab') === false && strpos($fa_icon,'far') === false)
123 - {
124 - $new_fa_icon = self::searchNewFA($fa_icon, $conversion_array);
125 - $icondata['fa_icon_value'] = $new_fa_icon;
126 - $wpdb->update(maxUtils::get_table_name(), array('icon' => json_encode($icondata)), array('id' => $button_id) );
127 -
128 - }
129 -
130 - }
131 - }
132 -
133 - }
134 -
135 - }
136 -
137 - /** Convert Font Awesome 4 to Font Awesome 5 via the conversion shims array
138 - * @param $old The old value, without the fa- prefix
139 - * @param $conversion_array The loaded FA5 shims library
65 +
66 + /** Move data from old version database to new version
67 +
68 + Check if new database table is empty ( aka new ) to prevent migrating the same data multiple times then copy all rows from old table to the new one.
140 69 */
141 - public static function searchNewFA($old, $conversion_array)
142 - {
143 - $new = false;
144 - foreach($conversion_array as $key => $items)
145 - {
146 - if ($items[0] == $old)
147 - {
148 - $new = (strlen($items[1]) > 0) ? $items[1] : 'fas'; // if not set, fas is the set
149 - $new .= ' fa-';
150 - $new .= (strlen($items[2]) > 0) ? $items[2] : $old ;
151 - }
152 -
153 - }
154 -
155 - if (! $new)
156 - {
157 - $new = 'fas fa-'. $old;
158 - }
159 -
160 - return $new;
161 - }
162 -
163 -
164 - /** Move data from old version database to new version
165 - *
166 - * Check if new database table is empty ( aka new ) to prevent migrating the same data multiple times then copy all rows from old table to the new one.
167 - */
168 70 static function migrate()
169 71 {
170 - global $wpdb;
171 -
172 - $old_table = maxUtils::get_table_name(true);
173 - $table = maxUtils::get_table_name();
174 -
72 + global $wpdb;
73 +
74 + $old_table = maxUtils::get_table_name(true);
75 + $table = maxUtils::get_table_name();
76 +
175 77 if (! self::maxbuttons_database_table_exists($old_table))
176 78 {
177 - return;
79 + return;
178 80 }
81 +
82 + $sql = "SELECT id from $table";
83 + $result = $wpdb->get_results($sql, ARRAY_A);
84 + if(count($result) > 0) return; // don't do this if table already has data.
179 85
180 - $sql = "SELECT id from $table";
181 - $result = $wpdb->get_results($sql, ARRAY_A);
182 - if(count($result) > 0) return; // don't do this if table already has data.
183 -
184 - $sql = "SELECT * FROM $old_table";
185 - $rows = $wpdb->get_results($sql, ARRAY_A);
186 -
187 - if (count($rows) == 0 ) // no button in all table; all is good.
188 - return true;
189 -
190 -
191 - foreach($rows as $row)
192 - {
86 + $sql = "SELECT * FROM $old_table";
87 + $rows = $wpdb->get_results($sql, ARRAY_A);
88 +
89 + if (count($rows) == 0 ) // no button in all table; all is good.
90 + return true;
91 +
92 +
93 + foreach($rows as $row)
94 + {
193 95 $data = static::convertOldFields($row);
194 - $id = $data["id"];
195 - global $wpdb;
196 - $wpdb->insert($table, array("id" => $id));
197 -
198 - //$data = apply_filters("mb-migration-data",$data, $row);
199 - $button = MB()->getClass('button');
96 + $id = $data["id"];
97 + global $wpdb;
98 + $wpdb->insert($table, array("id" => $id));
99 +
100 + //$data = apply_filters("mb-migration-data",$data, $row);
101 + $button = new maxButton();
200 102 $button->set($id);
201 103 $button->save($data);
202 104 }
203 105 }
204 -
106 +
205 107 /** Import fields from the old database format ( pre version 3.0 ) */
206 108 static function convertOldFields($row)
207 109 {
208 - $data = array();
110 + $data = array();
209 111
210 - $data["id"] = (isset($row["id"])) ? $row["id"] : -1;
112 +
113 + $data["id"] = (isset($row["id"])) ? $row["id"] : -1;
211 114 $data["name"] = $row["name"];
212 115 $data["status"] = isset($row["status"]) ? $row["status"] : 'publish'; // happens with downloadable packs.
213 - $data["description"] = $row["description"];
116 + $data["description"] = $row["description"];
214 117 $data["url"] = $row["url"];
215 118 $data["text"] = $row["text"];
216 119 $data["new_window"] = (isset($row["new_window"]) && $row["new_window"] != "") ? 1 : 0;
217 - $data["nofollow"] = (isset($row["nofollow"]) && $row["nofollow"] != "") ? 1 : 0;
218 -
219 - $data["font"] = $row["text_font_family"];
220 - $data["font_size"] = $row["text_font_size"];
221 - $data["font_style"] = $row["text_font_style"];
222 - $data["font_weight"] = $row["text_font_weight"];
223 - $data["text_shadow_offset_left"] = $row["text_shadow_offset_left"];
224 - $data["text_shadow_offset_top"] = $row["text_shadow_offset_top"];
225 - $data["text_shadow_width"] = $row["text_shadow_width"];
226 - $data["padding_top"] = $row["text_padding_top"];
227 - $data["padding_right"] = $row["text_padding_right"];
228 - $data["padding_bottom"] = $row["text_padding_bottom"];
120 + $data["nofollow"] = (isset($row["nofollow"]) && $row["nofollow"] != "") ? 1 : 0;
121 +
122 + $data["font"] = $row["text_font_family"];
123 + $data["font_size"] = $row["text_font_size"];
124 + $data["font_style"] = $row["text_font_style"];
125 + $data["font_weight"] = $row["text_font_weight"];
126 + $data["text_shadow_offset_left"] = $row["text_shadow_offset_left"];
127 + $data["text_shadow_offset_top"] = $row["text_shadow_offset_top"];
128 + $data["text_shadow_width"] = $row["text_shadow_width"];
129 + $data["padding_top"] = $row["text_padding_top"];
130 + $data["padding_right"] = $row["text_padding_right"];
131 + $data["padding_bottom"] = $row["text_padding_bottom"];
229 132 $data["padding_left"] = $row["text_padding_left"];
230 -
231 - $data["radius_top_left"] = $row["border_radius_top_left"];
232 - $data["radius_top_right"] = $row["border_radius_top_right"];
233 - $data["radius_bottom_left"] = $row["border_radius_bottom_left"];
234 - $data["radius_bottom_right"] = $row["border_radius_bottom_right"];
235 - $data["border_style"] = $row["border_style"];
236 - $data["border_width"] = $row["border_width"];
237 - $data["box_shadow_offset_left"] = $row["box_shadow_offset_left"];
238 - $data["box_shadow_offset_top"] = $row["box_shadow_offset_top"];
239 - $data["box_shadow_width"] = $row["box_shadow_width"];
240 -
241 - $data["text_color"] = $row["text_color"];
242 - $data["text_shadow_color"] = $row["text_shadow_color"];
243 - $data["gradient_start_color"] = $row["gradient_start_color"];
244 - $data["gradient_end_color"] = $row["gradient_end_color"];
245 - $data["border_color"] = $row["border_color"];
246 - $data["box_shadow_color"] = $row["box_shadow_color"];
247 -
248 - $data["text_color_hover"] = $row["text_color_hover"];
249 - $data["text_shadow_color_hover"] = $row["text_shadow_color_hover"];
250 - $data["gradient_start_color_hover"] = $row["gradient_start_color_hover"];
251 - $data["gradient_end_color_hover"] = $row["gradient_end_color_hover"];
252 - $data["border_color_hover"] = $row["border_color_hover"];
253 - $data["box_shadow_color_hover"] = $row["box_shadow_color_hover"];
254 -
255 - $data["gradient_stop"] = (isset($row["gradient_stop"])) ? $row["gradient_stop"] : 45;
133 +
134 + $data["radius_top_left"] = $row["border_radius_top_left"];
135 + $data["radius_top_right"] = $row["border_radius_top_right"];
136 + $data["radius_bottom_left"] = $row["border_radius_bottom_left"];
137 + $data["radius_bottom_right"] = $row["border_radius_bottom_right"];
138 + $data["border_style"] = $row["border_style"];
139 + $data["border_width"] = $row["border_width"];
140 + $data["box_shadow_offset_left"] = $row["box_shadow_offset_left"];
141 + $data["box_shadow_offset_top"] = $row["box_shadow_offset_top"];
142 + $data["box_shadow_width"] = $row["box_shadow_width"];
143 +
144 + $data["text_color"] = $row["text_color"];
145 + $data["text_shadow_color"] = $row["text_shadow_color"];
146 + $data["gradient_start_color"] = $row["gradient_start_color"];
147 + $data["gradient_end_color"] = $row["gradient_end_color"];
148 + $data["border_color"] = $row["border_color"];
149 + $data["box_shadow_color"] = $row["box_shadow_color"];
150 +
151 + $data["text_color_hover"] = $row["text_color_hover"];
152 + $data["text_shadow_color_hover"] = $row["text_shadow_color_hover"];
153 + $data["gradient_start_color_hover"] = $row["gradient_start_color_hover"];
154 + $data["gradient_end_color_hover"] = $row["gradient_end_color_hover"];
155 + $data["border_color_hover"] = $row["border_color_hover"];
156 + $data["box_shadow_color_hover"] = $row["box_shadow_color_hover"];
157 +
158 + $data["gradient_stop"] = (isset($row["gradient_stop"])) ? $row["gradient_stop"] : 45;
256 159 $data["gradient_start_opacity"] = (isset($row["gradient_start_opacity"])) ? $row["gradient_start_opacity"] : 100;
257 160 $data["gradient_end_opacity"] = (isset($row["gradient_end_opacity"])) ? $row["gradient_end_opacity"] : 100;
258 - $data["gradient_start_opacity_hover"] = (isset($row["gradient_start_opacity_hover"])) ? $row["gradient_start_opacity_hover"] : 100;
161 + $data["gradient_start_opacity_hover"] = (isset($row["gradient_start_opacity_hover"])) ? $row["gradient_start_opacity_hover"] : 100;
259 162 $data["gradient_end_opacity_hover"] = (isset($row["gradient_end_opacity_hover"])) ? $row["gradient_end_opacity_hover"] : 100;
260 -
261 - $data["container_enabled"] = (isset($row["container_enabled"]) && $row["container_enabled"] != "") ? 1 : 0;
262 - $data["container_center_div_wrap"] = (isset($row["container_center_div_wrap_enabled"]) && $row["container_center_div_wrap_enabled"] != "") ? 1 : 0;
263 - $data["container_width"] = isset($row["container_width"]) ? $row["container_width"] : '';
264 - $data["container_margin_top"] = isset($row["container_margin_top"]) ? $row["container_margin_top"] : '';
265 - $data["container_margin_right"] = isset($row["container_margin_right"]) ? $row["container_margin_right"] : '';
266 - $data["container_margin_bottom"] = isset($row["container_margin_bottom"]) ? $row["container_margin_right"] : '';
267 - $data["container_margin_left"] = isset($row["container_margin_left"]) ? $row["container_margin_left"] : '';
163 +
164 + $data["container_enabled"] = (isset($row["container_enabled"]) && $row["container_enabled"] != "") ? 1 : 0;
165 + $data["container_center_div_wrap"] = (isset($row["container_center_div_wrap_enabled"]) && $row["container_center_div_wrap_enabled"] != "") ? 1 : 0;
166 + $data["container_width"] = isset($row["container_width"]) ? $row["container_width"] : '';
167 + $data["container_margin_top"] = isset($row["container_margin_top"]) ? $row["container_margin_top"] : '';
168 + $data["container_margin_right"] = isset($row["container_margin_right"]) ? $row["container_margin_right"] : '';
169 + $data["container_margin_bottom"] = isset($row["container_margin_bottom"]) ? $row["container_margin_right"] : '';
170 + $data["container_margin_left"] = isset($row["container_margin_left"]) ? $row["container_margin_left"] : '';
268 171 $data["container_alignment"] = isset($row["container_alignment"]) ? $row["container_alignment"] : '';
269 -
270 - $data["status"] = (isset($row["status"])) ? $row["status"] : 'publish';
271 -
272 - $data["external_css"] = (isset($row["external_css"]) && $row["external_css"] != "") ? 1: 0;
172 +
173 + $data["status"] = (isset($row["status"])) ? $row["status"] : 'publish';
174 +
175 + $data["external_css"] = (isset($row["external_css"]) && $row["external_css"] != "") ? 1: 0;
273 176 $data["important_css"] = (isset($row["important_css"]) && $row["important_css"] != "") ? 1 : 0;
274 -
177 +
275 178 // icon
276 - $data["use_fa_icon"] = (isset($row["use_font_awesome_icon"]) && $row["use_font_awesome_icon"] != '') ? 1 : 0;
179 + $data["use_fa_icon"] = (isset($row["use_font_awesome_icon"]) && $row["use_font_awesome_icon"] != '') ? 1 : 0;
277 180 $data["fa_icon_value"] = (isset($row["font_awesome_icon"])) ? $row["font_awesome_icon"] : '';
278 - $data["fa_icon_size"] = (isset($row["font_awesome_icon_size"])) ? $row["font_awesome_icon_size"] : '';
181 + $data["fa_icon_size"] = (isset($row["font_awesome_icon_size"])) ? $row["font_awesome_icon_size"] : '';
279 182 $data["icon_url"] = (isset($row["icon_url"])) ? $row["icon_url"] : '';
280 - $data["icon_alt"] = (isset($row["icon_alt"])) ? $row["icon_alt"] : '';
183 + $data["icon_alt"] = (isset($row["icon_alt"])) ? $row["icon_alt"] : '';
281 184 $data["icon_position"] = (isset($row["icon_position"])) ? $row["icon_position"] : '';
282 185 $data["icon_padding_top"] = (isset($row["icon_padding_top"])) ? $row["icon_padding_top"] : '';
283 186 $data["icon_padding_bottom"] = (isset($row["icon_padding_bottom"])) ? $row["icon_padding_bottom"] : '';
284 187 $data["icon_padding_left"] = (isset($row["icon_padding_left"])) ? $row["icon_padding_left"] : '';
@@ -284,35 +187,35 @@
284 187 $data["icon_padding_left"] = (isset($row["icon_padding_left"])) ? $row["icon_padding_left"] : '';
285 188 $data["icon_padding_right"] = (isset($row["icon_padding_right"]))? $row["icon_padding_right"] : '';
286 189
287 190 // dimension
288 - $data["button_width"] = (isset($row["width"])) ? $row["width"] : '';
289 - $data["button_height"] = (isset($row["height"])) ? $row["height"] : '';
191 + $data["button_width"] = (isset($row["width"])) ? $row["width"] : '';
192 + $data["button_height"] = (isset($row["height"])) ? $row["height"] : '';
290 193
291 - // colorPro
292 - $data["icon_color"] = (isset($row["icon_color"])) ? $row["icon_color"] : '';
293 - $data["icon_color_hover"] = (isset($row["icon_color_hover"])) ? $row["icon_color_hover"] : '';
294 -
295 - // textPro
296 - $data["text2"] = $row["text2"];
297 - $data["font2"] = $row["text2_font_family"];
298 - $data["font_size2"] = $row["text2_font_size"];
299 - $data["font_style2"] = $row["text2_font_style"];
300 - $data["font_weight2"] = $row["text2_font_weight"];
301 - $data["padding_top2"] = $row["text2_padding_top"];
302 - $data["padding_right2"] = $row["text2_padding_right"];
303 - $data["padding_bottom2"] = $row["text2_padding_bottom"];
194 + // colorPro
195 + $data["icon_color"] = (isset($row["icon_color"])) ? $row["icon_color"] : '';
196 + $data["icon_color_hover"] = (isset($row["icon_color_hover"])) ? $row["icon_color_hover"] : '';
197 +
198 + // textPro
199 + $data["text2"] = $row["text2"];
200 + $data["font2"] = $row["text2_font_family"];
201 + $data["font_size2"] = $row["text2_font_size"];
202 + $data["font_style2"] = $row["text2_font_style"];
203 + $data["font_weight2"] = $row["text2_font_weight"];
204 + $data["padding_top2"] = $row["text2_padding_top"];
205 + $data["padding_right2"] = $row["text2_padding_right"];
206 + $data["padding_bottom2"] = $row["text2_padding_bottom"];
304 207 $data["padding_left2"] = $row["text2_padding_left"];
305 -
306 - $data["text_align"] = (isset($row["text_align"])) ? $row["text_align"] : '';
307 - $data["text_align2"] = (isset($row["text2_align"])) ? $row["text2_align"] : '';
308 - // here old / new Pro Database fields.
309 -
208 +
209 + $data["text_align"] = (isset($row["text_align"])) ? $row["text_align"] : '';
210 + $data["text_align2"] = (isset($row["text2_align"])) ? $row["text2_align"] : '';
211 + // here old / new Pro Database fields.
212 +
310 213 return $data;
311 214 }
312 -
215 +
313 216 static function deactivate_plugin()
314 - {
217 + {
315 218 delete_option(MAXBUTTONS_VERSION_KEY);
316 219 }
317 220
318 221
@@ -323,88 +226,88 @@
323 226
324 227
325 228 static function create_database_table() {
326 229 //global $maxbuttons_installed_version;
327 -
230 +
328 231 require_once(ABSPATH . 'wp-admin/includes/upgrade.php');
329 -
232 +
330 233 $table_name = maxUtils::get_table_name();
331 - $button = MB()->getClass('button');
234 + $button = new maxButton();
332 235 $blocks = $button->getBlocks();
333 -
236 +
334 237 // IMPORTANT: There MUST be two spaces between the PRIMARY KEY keywords
335 238 // and the column name, and the column name MUST be in parenthesis.
336 - $sql = "CREATE TABLE " . $table_name . " (
337 - id int NOT NULL AUTO_INCREMENT,
338 - name varchar(100) NULL,
339 - status varchar(10) default 'publish' NOT NULL,
340 - cache text,
239 + $sql = "CREATE TABLE " . $table_name . " (
240 + id int NOT NULL AUTO_INCREMENT,
241 + name varchar(100) NULL,
242 + status varchar(10) default 'publish' NOT NULL,
243 + cache text,
341 244 ";
245 +
342 246
343 -
344 247 foreach($blocks as $block)
345 248 {
346 - $block_name = $block->get_name();
347 -
348 - $sql .= "" . $block_name . " TEXT NULL, \n ";
249 + $block_name = $block->get_name();
250 +
251 + $sql .= "" . $block_name . " TEXT NULL, \n ";
349 252 }
350 -
253 +
351 254 $sql .= "updated TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
352 - created TIMESTAMP DEFAULT 0 NOT NULL,
353 - PRIMARY KEY (id) )";
255 + created TIMESTAMP DEFAULT 0 NOT NULL,
256 + PRIMARY KEY (id) )";
354 257
355 - $result = dbDelta($sql); // always dbdelta
258 + $result = dbDelta($sql); // always dbdelta
356 259
357 260 // Reset the cache if there were any left from before
358 - $button->reset_cache();
261 + $button->reset_cache();
359 262
360 263 // Collection table
361 264 $collection_table_name = maxUtils::get_collection_table_name();
362 -
363 - $sql = "CREATE TABLE " . $collection_table_name . " (
364 - meta_id int(11) NOT NULL AUTO_INCREMENT,
365 - collection_id int(11) NOT NULL,
366 - collection_key varchar(255),
367 - collection_value text,
368 - PRIMARY KEY (meta_id) )
369 -
265 +
266 + $sql = "CREATE TABLE " . $collection_table_name . " (
267 + meta_id int(11) NOT NULL AUTO_INCREMENT,
268 + collection_id int(11) NOT NULL,
269 + collection_key varchar(255),
270 + collection_value text,
271 + PRIMARY KEY (meta_id) )
272 +
370 273 ";
371 274
372 275 dbDelta($sql);
373 -
276 +
374 277 $collection_trans_table = maxUtils::get_coltrans_table_name();
375 - $sql = "CREATE TABLE $collection_trans_table (
376 - name varchar(1000),
278 + $sql = "CREATE TABLE $collection_trans_table (
279 + name varchar(1000),
377 280 value varchar(255),
378 281 expire int(11)
379 - );
380 - ";
381 - $res = dbDelta($sql);
282 + );
283 + ";
284 + $res = dbDelta($sql);
382 285 }
383 -
286 +
384 287 /** Attempt to upgrade UTF table to UTFmb4 - see this article https://make.wordpress.org/core/2015/04/02/the-utf8mb4-upgrade/
385 288 */
386 - public static function upgradeUTF()
289 + public static function upgradeUTF()
387 290 {
388 291 require_once(ABSPATH . 'wp-admin/includes/upgrade.php');
389 -
390 - if (! function_exists('maybe_convert_table_to_utf8mb4'))
391 - return; // Versions before 4.2.0
392 -
292 +
293 + if (! function_exists('maybe_convert_table_to_utf8mb4'))
294 + return; // Versions before 4.2.0
295 +
393 296 $table_name = maxUtils::get_table_name();
394 297 $collection_table_name = maxUtils::get_collection_table_name();
395 -
298 +
396 299 maybe_convert_table_to_utf8mb4($table_name);
397 - maybe_convert_table_to_utf8mb4($collection_table_name);
300 + maybe_convert_table_to_utf8mb4($collection_table_name);
398 301 }
399 -
302 +
400 303 /** Routine for activation for WPMU - All blogs */
401 304 public static function call_function_for_each_site($function) {
402 305 global $wpdb;
403 -
306 +
404 307 // Hold this so we can switch back to it
405 308 $root_blog = $wpdb->blogid;
406 -
309 +
407 310 // Get all the blogs/sites in the network and invoke the function for each one
408 311 $blog_ids = $wpdb->get_col("SELECT blog_id FROM $wpdb->blogs");
409 312 foreach ($blog_ids as $blog_id) {
410 313 switch_to_blog($blog_id);
@@ -409,9 +312,10 @@
409 312 foreach ($blog_ids as $blog_id) {
410 313 switch_to_blog($blog_id);
411 314 call_user_func($function);
412 315 }
413 -
316 +
414 317 // Now switch back to the root blog
415 318 switch_to_blog($root_blog);
416 319 }
417 320 } // class
321 +