PluginProbe ʕ •ᴥ•ʔ
Backup Migration / 1.3.6
Backup Migration v1.3.6
2.1.6 2.1.5.2 trunk 1.3.0 1.3.1 1.3.2 1.3.3 1.3.4 1.3.5 1.3.6 1.3.7 1.3.8 1.3.9 1.4.0 1.4.1 1.4.2 1.4.3 1.4.4 1.4.5 1.4.6 1.4.6.1 1.4.7 1.4.8 1.4.9 1.4.9.1 2.0.0 2.1.0 2.1.1 2.1.2 2.1.3 2.1.4 2.1.5 2.1.5.1
backup-backup / analyst / src / Mutator.php
backup-backup / analyst / src Last commit date
Account 2 years ago Cache 2 years ago Contracts 2 years ago Core 2 years ago Http 2 years ago Notices 2 years ago Analyst.php 2 years ago ApiRequestor.php 2 years ago ApiResponse.php 2 years ago Collector.php 2 years ago Mutator.php 2 years ago helpers.php 2 years ago
Mutator.php
104 lines
1 <?php
2
3 namespace Analyst;
4
5 use Analyst\Cache\DatabaseCache;
6 use Analyst\Contracts\CacheContract;
7 use Analyst\Notices\NoticeFactory;
8
9 /**
10 * Class Mutator mutates (modifies) UX with additional
11 * functional
12 */
13 class Mutator
14 {
15 protected $notices = [];
16
17 /**
18 * @var NoticeFactory
19 */
20 protected $factory;
21
22 /**
23 * @var CacheContract
24 */
25 protected $cache;
26
27 public function __construct()
28 {
29 $this->factory = NoticeFactory::instance();
30
31 $this->notices = $this->factory->getNotices();
32
33 $this->cache = DatabaseCache::getInstance();
34 }
35
36 /**
37 * Register filters all necessary stuff.
38 * Can be invoked only once.
39 *
40 * @return void
41 */
42 public function initialize()
43 {
44 $this->registerLinks();
45 $this->registerAssets();
46 $this->registerHooks();
47 }
48
49 /**
50 * Register all necessary filters and templates
51 *
52 * @return void
53 */
54 protected function registerLinks()
55 {
56 add_action('admin_footer', function () {
57 analyst_require_template('optout.php', [
58 'shieldImage' => analyst_assets_url('img/shield_question.png')
59 ]);
60
61 analyst_require_template('optin.php');
62
63 analyst_require_template('forms/deactivate.php', [
64 'pencilImage' => analyst_assets_url('img/pencil.png'),
65 'smileImage' => analyst_assets_url('img/smile.png'),
66 ]);
67
68 analyst_require_template('forms/install.php', [
69 'pluginToInstall' => $this->cache->get('plugin_to_install'),
70 'shieldImage' => analyst_assets_url('img/shield_success.png'),
71 ]);
72 });
73
74 add_action('admin_notices',function () {
75 foreach ($this->notices as $notice) {
76 analyst_require_template('notice.php', ['notice' => $notice]);
77 }
78 });
79 }
80
81 /**
82 * Register all assets
83 */
84 public function registerAssets()
85 {
86 add_action('admin_enqueue_scripts', function () {
87 wp_enqueue_style('analyst_custom', analyst_assets_url('/css/customize.css'));
88 wp_enqueue_script('analyst_custom', analyst_assets_url('/js/customize.js'));
89 });
90 }
91
92 /**
93 * Register action hooks
94 */
95 public function registerHooks()
96 {
97 add_action('wp_ajax_analyst_notification_dismiss', function () {
98 $this->factory->remove(sanitize_text_field($_POST['id']));
99
100 $this->factory->sync();
101 });
102 }
103 }
104