PluginProbe
Darkify – Dark Mode & Night Mode for Website & Admin (Dark Theme Included) / 1.0.1
Darkify – Dark Mode & Night Mode for Website & Admin (Dark Theme Included) v1.0.1
2.1.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 All 57 releases
darkify / includes / class-darkify.php

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

224 lines 5.7 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 plugin_dir_path(dirname(__FILE__)) . 'includes/class-darkify-loader.php';
109
110 /**
111 * The class responsible for defining internationalization functionality
112 * of the plugin.
113 */
114 require_once plugin_dir_path(dirname(__FILE__)) . 'includes/class-darkify-i18n.php';
115 require_once plugin_dir_path(dirname(__FILE__)) . 'includes/DarkifyUtils.php';
116 require_once plugin_dir_path(dirname(__FILE__)) . 'includes/DarkifyExternalSupport.php';
117
118 /**
119 * The class responsible for defining all actions that occur in the admin area.
120 */
121 require_once plugin_dir_path(dirname(__FILE__)) . 'admin/class-darkify-admin.php';
122 require_once plugin_dir_path(dirname(__FILE__)) . 'admin/ta-framework/classes/setup.class.php';
123 require_once plugin_dir_path(dirname(__FILE__)) . '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 plugin_dir_path(dirname(__FILE__)) . 'public/class-darkify-public.php';
130
131 $this->loader = new Darkify_Loader();
132 }
133
134 /**
135 * Define the locale for this plugin for internationalization.
136 *
137 * Uses the Darkify_i18n class in order to set the domain and to register the hook
138 * with WordPress.
139 *
140 * @since 1.0.0
141 * @access private
142 */
143 private function set_locale()
144 {
145
146 $plugin_i18n = new Darkify_i18n();
147
148 $this->loader->add_action('plugins_loaded', $plugin_i18n, 'load_plugin_textdomain');
149 }
150
151 /**
152 * Register all of the hooks related to the admin area functionality
153 * of the plugin.
154 *
155 * @since 1.0.0
156 * @access private
157 */
158 private function define_admin_hooks()
159 {
160
161 $plugin_admin = new Darkify_Admin($this->get_plugin_name(), $this->get_version());
162
163 $this->loader->add_action('admin_enqueue_scripts', $plugin_admin, 'enqueue_styles');
164 $this->loader->add_action('admin_enqueue_scripts', $plugin_admin, 'enqueue_scripts');
165 }
166
167 /**
168 * Register all of the hooks related to the public-facing functionality
169 * of the plugin.
170 *
171 * @since 1.0.0
172 * @access private
173 */
174 private function define_public_hooks()
175 {
176
177 $plugin_public = new Darkify_Public($this->get_plugin_name(), $this->get_version());
178 }
179
180 /**
181 * Run the loader to execute all of the hooks with WordPress.
182 *
183 * @since 1.0.0
184 */
185 public function run()
186 {
187 $this->loader->run();
188 }
189
190 /**
191 * The name of the plugin used to uniquely identify it within the context of
192 * WordPress and to define internationalization functionality.
193 *
194 * @since 1.0.0
195 * @return string The name of the plugin.
196 */
197 public function get_plugin_name()
198 {
199 return $this->plugin_name;
200 }
201
202 /**
203 * The reference to the class that orchestrates the hooks with the plugin.
204 *
205 * @since 1.0.0
206 * @return Darkify_Loader Orchestrates the hooks of the plugin.
207 */
208 public function get_loader()
209 {
210 return $this->loader;
211 }
212
213 /**
214 * Retrieve the version number of the plugin.
215 *
216 * @since 1.0.0
217 * @return string The version number of the plugin.
218 */
219 public function get_version()
220 {
221 return $this->version;
222 }
223 }
224