PluginProbe
AcyMailing – An Ultimate Newsletter Plugin and Marketing Automation Solution for WordPress / 10.2.2
AcyMailing – An Ultimate Newsletter Plugin and Marketing Automation Solution for WordPress v10.2.2
11.1.1 11.1.0 11.0.5 11.0.4 11.0.3 11.0.2 11.0.1 11.0.0 10.11.1 10.11.0 10.10.2 10.10.1 10.10.0 10.9.1 trunk 10.0.0 10.0.1 10.1.0 10.1.1 10.1.2 10.1.3 10.1.4 10.2.0 10.2.1 10.2.2 All 62 releases
acymailing / WpInit / Activation.php

Activation.php in AcyMailing – An Ultimate Newsletter Plugin and Marketing Automation Solution for WordPress 10.2.2, at WpInit/Activation.php

108 lines 3.0 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace AcyMailing\WpInit;
4
5 use AcyMailing\Helpers\UpdateHelper;
6
7 class Activation
8 {
9 public function install()
10 {
11 $file_name = rtrim(dirname(__DIR__), DS).DS.'back'.DS.'tables.sql';
12 $handle = fopen($file_name, 'r');
13 $queries = fread($handle, filesize($file_name));
14 fclose($handle);
15
16 if (is_multisite() && is_network_admin()) {
17 $currentBlog = get_current_blog_id();
18 $sites = function_exists('get_sites') ? get_sites() : wp_get_sites();
19
20 foreach ($sites as $site) {
21 if (is_object($site)) {
22 $site = get_object_vars($site);
23 }
24 switch_to_blog($site['blog_id']);
25 $this->_sampledata($queries);
26 }
27
28 switch_to_blog($currentBlog);
29 } else {
30 $this->_sampledata($queries);
31 }
32
33 if (file_exists(ACYM_FOLDER.'update.php')) {
34 unlink(ACYM_FOLDER.'update.php');
35 }
36 }
37
38 private function _sampledata($queries)
39 {
40 global $wpdb;
41 $prefix = acym_getPrefix();
42
43 $acytables = str_replace('#__', $prefix, $queries);
44 $tables = explode('CREATE TABLE IF NOT EXISTS', $acytables);
45
46 foreach ($tables as $oneTable) {
47 $oneTable = trim($oneTable);
48 if (empty($oneTable)) {
49 continue;
50 }
51 $wpdb->query('CREATE TABLE IF NOT EXISTS'.$oneTable);
52 }
53
54 $this->updateAcym();
55 }
56
57 public function updateAcym()
58 {
59 if (!in_array(acym_getPrefix().'acym_configuration', acym_getTables())) {
60
61 return;
62 }
63
64 $config = acym_config();
65 if (!file_exists(ACYM_FOLDER.'update.php') && $config->get('installcomplete', 0) != 0) {
66 return;
67 }
68
69 acym_increasePerf();
70
71 $updateHelper = new UpdateHelper();
72 $updateHelper->addPref();
73 $updateHelper->updatePref();
74 $updateHelper->updateSQL();
75 $updateHelper->checkDB();
76
77 $config->save(['downloadurl' => '', 'lastupdatecheck' => '0']);
78
79 $languageFiles = acym_getFiles(ACYM_FOLDER.'language'.DS, '\.ini');
80 acym_createFolder(ACYM_LANGUAGE);
81 acym_createFolder(ACYM_UPLOAD_FOLDER_THUMBNAIL);
82 if (!empty($languageFiles)) {
83 foreach ($languageFiles as $oneFile) {
84 acym_copyFile(ACYM_FOLDER.'language'.DS.$oneFile, ACYM_LANGUAGE.$oneFile);
85 }
86 }
87
88 $updateHelper->installBounceRules();
89 $updateHelper->installList();
90 $updateHelper->installNotifications();
91
92 if ($updateHelper->firstInstallation) {
93 $updateHelper->installTemplates();
94 $updateHelper->installDefaultAutomations();
95 }
96
97 $updateHelper->deleteNewSplashScreenInstall();
98
99 $updateHelper->installFields();
100 $updateHelper->installAddons();
101 $updateHelper->installOverrideEmails();
102
103 $config->save(['installcomplete' => 1]);
104
105 acym_config(true);
106 }
107 }
108