| 1 |
<?php |
| 2 |
|
| 3 |
/** |
| 4 |
* The file of the Darkify class. |
| 5 |
* |
| 6 |
* @link https://themeatelier.net |
| 7 |
* @since 1.0.0 |
| 8 |
* |
| 9 |
* @package Darkify |
| 10 |
*/ |
| 11 |
|
| 12 |
namespace ThemeAtelier\Darkify; |
| 13 |
|
| 14 |
use ThemeAtelier\Darkify\Admin\Admin; |
| 15 |
use ThemeAtelier\Darkify\Frontend\Frontend; |
| 16 |
|
| 17 |
|
| 18 |
// don't call the file directly. |
| 19 |
if (!defined('ABSPATH')) { |
| 20 |
exit; |
| 21 |
} |
| 22 |
|
| 23 |
/** |
| 24 |
* The main class of the plugin. |
| 25 |
* |
| 26 |
* Handle all the class and methods of the plugin. |
| 27 |
* |
| 28 |
* @author ThemeAtelier <themeatelierbd@gmail.com> |
| 29 |
*/ |
| 30 |
class Darkify |
| 31 |
{ |
| 32 |
/** |
| 33 |
* Plugin version |
| 34 |
* |
| 35 |
* @since 1.0.0 |
| 36 |
* @access protected |
| 37 |
* @var string |
| 38 |
*/ |
| 39 |
protected $version; |
| 40 |
|
| 41 |
/** |
| 42 |
* Plugin slug |
| 43 |
* |
| 44 |
* @since 1.0.0 |
| 45 |
* @access protected |
| 46 |
* @var string |
| 47 |
*/ |
| 48 |
protected $plugin_slug; |
| 49 |
|
| 50 |
/** |
| 51 |
* Main Loader. |
| 52 |
* |
| 53 |
* The loader that's responsible for maintaining and registering all hooks that empowers |
| 54 |
* the plugin. |
| 55 |
* |
| 56 |
* @since 1.0.0 |
| 57 |
* @access protected |
| 58 |
* @var object |
| 59 |
*/ |
| 60 |
protected $loader; |
| 61 |
/** |
| 62 |
* Constructor for the Darkify class. |
| 63 |
* |
| 64 |
* Sets up all the appropriate hooks and actions within the plugin. |
| 65 |
*/ |
| 66 |
public function __construct() |
| 67 |
{ |
| 68 |
$this->version = DARKIFY_VERSION; |
| 69 |
$this->plugin_slug = 'darkify'; |
| 70 |
$this->load_dependencies(); |
| 71 |
$this->define_constants(); |
| 72 |
$this->define_admin_hooks(); |
| 73 |
$this->define_public_hooks(); |
| 74 |
add_action('plugin_loaded', array($this, 'init_plugin')); |
| 75 |
} |
| 76 |
|
| 77 |
/** |
| 78 |
* Run the loader to execute all of the hooks with WordPress. |
| 79 |
* |
| 80 |
* @since 1.0.0 |
| 81 |
*/ |
| 82 |
public function run() |
| 83 |
{ |
| 84 |
$this->loader->run(); |
| 85 |
} |
| 86 |
|
| 87 |
/** |
| 88 |
* The slug of the plugin used to uniquely identify it within the context of |
| 89 |
* WordPress and to define internationalization functionality. |
| 90 |
* |
| 91 |
* @since 1.0.0 |
| 92 |
* @return string The name of the plugin. |
| 93 |
*/ |
| 94 |
public function get_plugin_name() |
| 95 |
{ |
| 96 |
return $this->plugin_slug; |
| 97 |
} |
| 98 |
|
| 99 |
/** |
| 100 |
* Retrieve the version number of the plugin. |
| 101 |
* |
| 102 |
* @since 1.0.0 |
| 103 |
* @return string The version number of the plugin. |
| 104 |
*/ |
| 105 |
public function get_version() |
| 106 |
{ |
| 107 |
return $this->version; |
| 108 |
} |
| 109 |
|
| 110 |
/** |
| 111 |
* Define the constants |
| 112 |
* |
| 113 |
* @return void |
| 114 |
*/ |
| 115 |
public function define_constants() |
| 116 |
{ |
| 117 |
define('DARKIFY_URL', plugins_url('', DARKIFY_FILE)); |
| 118 |
define('DARKIFY_ASSETS', DARKIFY_URL . '/src/assets/'); |
| 119 |
define('DARKIFY_ADMIN', DARKIFY_URL . '/src/Admin'); |
| 120 |
} |
| 121 |
|
| 122 |
/** |
| 123 |
* Load the plugin after all plugins are loaded. |
| 124 |
* |
| 125 |
* @return void |
| 126 |
*/ |
| 127 |
public function init_plugin() |
| 128 |
{ |
| 129 |
do_action('darkify_loaded'); |
| 130 |
load_plugin_textdomain('darkify', false, DARKIFY_DIR_NAME . "/languages"); |
| 131 |
} |
| 132 |
|
| 133 |
/** |
| 134 |
* Load the required dependencies for this plugin. |
| 135 |
* |
| 136 |
* Include the following files that make up the plugin: |
| 137 |
* |
| 138 |
* - Loader. Orchestrates the hooks of the plugin. |
| 139 |
* - Teamproi18n. Defines internationalization functionality. |
| 140 |
* - Admin. Defines all hooks for the admin area. |
| 141 |
* - Frontend. Defines all hooks for the public side of the site. |
| 142 |
* |
| 143 |
* Create an instance of the loader which will be used to register the hooks |
| 144 |
* with WordPress. |
| 145 |
* |
| 146 |
* @since 1.0.0 |
| 147 |
* @access private |
| 148 |
*/ |
| 149 |
private function load_dependencies() |
| 150 |
{ |
| 151 |
/** |
| 152 |
* The class responsible for orchestrating the actions and filters of the |
| 153 |
* core plugin. |
| 154 |
*/ |
| 155 |
$this->loader = new Loader(); |
| 156 |
} |
| 157 |
|
| 158 |
/** |
| 159 |
* Register all of the hooks related to the admin dashboard functionality |
| 160 |
* of the plugin. |
| 161 |
* |
| 162 |
* @since 1.0.0 |
| 163 |
* @access private |
| 164 |
*/ |
| 165 |
private function define_admin_hooks() |
| 166 |
{ |
| 167 |
$plugin_admin = new Admin($this->get_plugin_name(), $this->get_version()); |
| 168 |
$this->loader->add_action('admin_enqueue_scripts', $plugin_admin, 'enqueue_styles'); |
| 169 |
$this->loader->add_action('admin_enqueue_scripts', $plugin_admin, 'enqueue_scripts'); |
| 170 |
} |
| 171 |
|
| 172 |
/** |
| 173 |
* Register all of the hooks related to the public-facing functionality |
| 174 |
* of the plugin. |
| 175 |
* |
| 176 |
* @since 1.0.0 |
| 177 |
* @access private |
| 178 |
*/ |
| 179 |
private function define_public_hooks() |
| 180 |
{ |
| 181 |
$plugin_public = new Frontend($this->get_plugin_name(), $this->get_version()); |
| 182 |
} |
| 183 |
} |
| 184 |
|