PluginProbe
Darkify – Dark Mode & Night Mode for Website & Admin (Dark Theme Included) / 1.2.3
Darkify – Dark Mode & Night Mode for Website & Admin (Dark Theme Included) v1.2.3
2.1.2 2.1.1 2.1.0 2.0.4 2.0.3 2.0.2 2.0.1 2.0.0 1.5.5 1.5.4 1.5.3 1.5.2 1.5.1 1.5.0 trunk 1.0.1 1.1.0 1.2.0 1.2.1 1.2.2 1.2.3 1.2.4 1.2.5 1.3.0 1.3.1 All 56 releases
darkify / includes / class-darkify.php

class-darkify.php in Darkify – Dark Mode & Night Mode for Website & Admin (Dark Theme Included) 1.2.3, at includes/class-darkify.php

228 lines 5.6 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 /**
4 * The file that defines the core plugin class
5 *
6 * A class definition that includes attributes and functions used across both the
7 * public-facing side of the site and the admin area.
8 *
9 * @link https://themeatelier.net/
10 * @since 1.0.0
11 *
12 * @package Darkify
13 * @subpackage Darkify/includes
14 */
15
16 /**
17 * The core plugin class.
18 *
19 * This is used to define internationalization, admin-specific hooks, and
20 * public-facing site hooks.
21 *
22 * Also maintains the unique identifier of this plugin as well as the current
23 * version of the plugin.
24 *
25 * @since 1.0.0
26 * @package Darkify
27 * @subpackage Darkify/includes
28 * @author ThemeAtelier <themeatelierbd@gmail.com>
29 */
30 class Darkify
31 {
32
33 /**
34 * The loader that's responsible for maintaining and registering all hooks that power
35 * the plugin.
36 *
37 * @since 1.0.0
38 * @access protected
39 * @var Darkify_Loader $loader Maintains and registers all hooks for the plugin.
40 */
41 protected $loader;
42
43 /**
44 * The unique identifier of this plugin.
45 *
46 * @since 1.0.0
47 * @access protected
48 * @var string $plugin_name The string used to uniquely identify this plugin.
49 */
50 protected $plugin_name;
51
52 /**
53 * The current version of the plugin.
54 *
55 * @since 1.0.0
56 * @access protected
57 * @var string $version The current version of the plugin.
58 */
59 protected $version;
60
61 /**
62 * Define the core functionality of the plugin.
63 *
64 * Set the plugin name and the plugin version that can be used throughout the plugin.
65 * Load the dependencies, define the locale, and set the hooks for the admin area and
66 * the public-facing side of the site.
67 *
68 * @since 1.0.0
69 */
70 public function __construct()
71 {
72 if (defined('DRK_LITE_VERSION')) {
73 $this->version = DRK_LITE_VERSION;
74 } else {
75 $this->version = '1.0.0';
76 }
77 $this->plugin_name = 'darkify';
78
79 $this->load_dependencies();
80 $this->set_locale();
81 $this->define_admin_hooks();
82 $this->define_public_hooks();
83 }
84
85 /**
86 * Load the required dependencies for this plugin.
87 *
88 * Include the following files that make up the plugin:
89 *
90 * - Darkify_Loader. Orchestrates the hooks of the plugin.
91 * - Darkify_i18n. Defines internationalization functionality.
92 * - Darkify_Admin. Defines all hooks for the admin area.
93 * - Darkify_Public. Defines all hooks for the public side of the site.
94 *
95 * Create an instance of the loader which will be used to register the hooks
96 * with WordPress.
97 *
98 * @since 1.0.0
99 * @access private
100 */
101 private function load_dependencies()
102 {
103
104 /**
105 * The class responsible for orchestrating the actions and filters of the
106 * core plugin.
107 */
108 require_once DRK_LITE_PATH . 'includes/class-darkify-loader.php';
109
110 /**
111 * The class responsible for defining internationalization functionality
112 * of the plugin.
113 */
114 require_once DRK_LITE_PATH . 'includes/class-darkify-i18n.php';
115 require_once DRK_LITE_PATH . 'includes/DarkifyUtils.php';
116 require_once DRK_LITE_PATH . 'includes/DarkifyExternalSupport.php';
117
118 /**
119 * The class responsible for defining all actions that occur in the admin area.
120 */
121 require_once DRK_LITE_PATH . 'admin/class-darkify-admin.php';
122 require_once DRK_LITE_PATH . 'admin/ta-framework/classes/setup.class.php';
123 require_once DRK_LITE_PATH . 'admin/ta-framework/config/admin-options.php';
124
125 /**
126 * The class responsible for defining all actions that occur in the public-facing
127 * side of the site.
128 */
129 require_once DRK_LITE_PATH . 'public/class-darkify-public.php';
130
131 $this->loader = new Darkify_Loader();
132
133 require_once DRK_LITE_PATH . 'admin/TADiscountPage/TADiscountPage.php';
134
135 new TADiscountPage;
136 }
137
138 /**
139 * Define the locale for this plugin for internationalization.
140 *
141 * Uses the Darkify_i18n class in order to set the domain and to register the hook
142 * with WordPress.
143 *
144 * @since 1.0.0
145 * @access private
146 */
147 private function set_locale()
148 {
149
150 $plugin_i18n = new Darkify_i18n();
151
152 $this->loader->add_action('plugins_loaded', $plugin_i18n, 'load_plugin_textdomain');
153 }
154
155 /**
156 * Register all of the hooks related to the admin area functionality
157 * of the plugin.
158 *
159 * @since 1.0.0
160 * @access private
161 */
162 private function define_admin_hooks()
163 {
164
165 $plugin_admin = new Darkify_Admin($this->get_plugin_name(), $this->get_version());
166
167 $this->loader->add_action('admin_enqueue_scripts', $plugin_admin, 'enqueue_styles');
168 $this->loader->add_action('admin_enqueue_scripts', $plugin_admin, 'enqueue_scripts');
169 }
170
171 /**
172 * Register all of the hooks related to the public-facing functionality
173 * of the plugin.
174 *
175 * @since 1.0.0
176 * @access private
177 */
178 private function define_public_hooks()
179 {
180
181 $plugin_public = new Darkify_Public($this->get_plugin_name(), $this->get_version());
182 }
183
184 /**
185 * Run the loader to execute all of the hooks with WordPress.
186 *
187 * @since 1.0.0
188 */
189 public function run()
190 {
191 $this->loader->run();
192 }
193
194 /**
195 * The name of the plugin used to uniquely identify it within the context of
196 * WordPress and to define internationalization functionality.
197 *
198 * @since 1.0.0
199 * @return string The name of the plugin.
200 */
201 public function get_plugin_name()
202 {
203 return $this->plugin_name;
204 }
205
206 /**
207 * The reference to the class that orchestrates the hooks with the plugin.
208 *
209 * @since 1.0.0
210 * @return Darkify_Loader Orchestrates the hooks of the plugin.
211 */
212 public function get_loader()
213 {
214 return $this->loader;
215 }
216
217 /**
218 * Retrieve the version number of the plugin.
219 *
220 * @since 1.0.0
221 * @return string The version number of the plugin.
222 */
223 public function get_version()
224 {
225 return $this->version;
226 }
227 }
228