-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathaucor-core.php
63 lines (53 loc) · 1.94 KB
/
aucor-core.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
<?php
/**
* Plugin Name: Aucor Core (Backwards Compatibility, Do Not Delete)
* Description: Auto-migrates old plugin naming to new – do not activate or delete
* Version: 1.1.4
* Author: Aucor Oy
* Author URI: https://www.aucor.fi
* Text Domain: aucor-core
*/
/**
* Main file used to be plugin.php but it was renamed
* to this file and that was a mistake as WP saves
* plugin file path to DB and causes errors on updating.
*
* To fix this mess, we'll need to keep this auto-migration
* for some sites that started using this plugin during the
* unlucky renaming phase to autofix it and remove it maybe
* for version 2.0.0.
*/
// include all plguin functionality
require_once 'plugin.php';
/**
* Auto-migrate active plugin data in DB to stop
* using "aucor-core.php" and prefer "plugin.php"
*/
function aucor_core_migrate_active_plugin($active_plugins) {
$active_plugins_changed = false;
if (is_array($active_plugins) && !empty($active_plugins)) {
foreach ($active_plugins as $i => $name) {
if ($name == 'aucor-core/aucor-core.php') {
$active_plugins[$i] = 'aucor-core/plugin.php';
$active_plugins_changed = true;
}
}
// remove duplicate plugin activations
if ($active_plugins_changed) {
$active_plugins = array_unique($active_plugins);
}
}
return $active_plugins;
}
$single_active_plugins = get_option('active_plugins');
$single_clean_active_plugins = aucor_core_migrate_active_plugin($single_active_plugins);
if ($single_active_plugins !== $single_clean_active_plugins) {
update_option('active_plugins', $single_clean_active_plugins);
}
if (is_multisite()) {
$network_active_plugins = get_site_option('active_plugins');
$network_clean_active_plugins = aucor_core_migrate_active_plugin($network_active_plugins);
if ($network_active_plugins !== $network_clean_active_plugins) {
update_site_option('active_plugins', $network_clean_active_plugins);
}
}