-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcinnamon-cache-plugin.php
More file actions
87 lines (73 loc) · 2.26 KB
/
cinnamon-cache-plugin.php
File metadata and controls
87 lines (73 loc) · 2.26 KB
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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
<?php
/**
* Cinnamon Cache Everything!
*
* @author Mohammad Keshavarz
* @link https://Mokech.ir
* @copyright Copyright © 2021 Mokech
*
* Plugin Name: Cinnamon Cache
* Plugin URI: https://mokech.ir/plugins/cinnamon-cache-plugin
* Description: Cinnamon Cache
* Version: 0.1.0
* Author: Mokech
* Author URI: https://mokech.ir
* Text Domain: cinnamon-cache
* License URI: LICENSE.txt
* Domain Path: /languages
* Tested up to: 5.9
*/
use Cinnamon\Handlers\CacheHandler;
use Cinnamon\Includes\CinnamonCachePluginEnum;
use Cinnamon\Panel\Management;
if (!defined('ABSPATH')) exit();
class CinnamonCachePlugin
{
public static function makeInstance()
{
$self = new self();
add_action('init', [$self, 'init']);
add_action('admin_bar_menu', [$self, 'cinnamonCacheToolbarItem'], 999);
add_action('admin_enqueue_scripts', [$self, 'enqueueAssets']);
}
public function defineConstants()
{
define('CI_CACHE', plugin_dir_path(__FILE__));
define('CI_CACHE_URI', plugin_dir_url(__FILE__));
}
public function init()
{
$this->defineConstants();
$this->loader();
$this->loadSettings();
$this->startCaching();
}
public function loadSettings()
{
new Management;
}
private function startCaching()
{
new CacheHandler;
}
public function cinnamonCacheToolbarItem($wpAdminBar)
{
$args = array(
'id' => 'ci_cache_item',
'title' => __('Flush All Cache', 'cinnamon-cache'),
'href' => wp_nonce_url(admin_url() . 'admin.php?page=' . CinnamonCachePluginEnum::PAGE_SLUG, -1, CinnamonCachePluginEnum::NONCE_NAME_PURGE),
);
$wpAdminBar->add_node($args);
}
public function enqueueAssets()
{
wp_enqueue_style('ci-cache-style', CI_CACHE_URI . 'assets/css/style.css', [], '1.0.0');
}
private function loader()
{
include_once CI_CACHE . 'includes/CinnamonCachePluginEnum.php';
include_once CI_CACHE . 'panel/Management.php';
include_once CI_CACHE . 'handlers/CacheHandler.php';
}
}
add_action('plugins_loaded', array('CinnamonCachePlugin', 'makeInstance'));