*/ class Darkify { /** * Plugin version * * @since 1.0.0 * @access protected * @var string */ protected $version; /** * Plugin slug * * @since 1.0.0 * @access protected * @var string */ protected $plugin_slug; /** * Main Loader. * * The loader that's responsible for maintaining and registering all hooks that empowers * the plugin. * * @since 1.0.0 * @access protected * @var object */ protected $loader; /** * Constructor for the Darkify class. * * Sets up all the appropriate hooks and actions within the plugin. */ public function __construct() { $this->version = DARKIFY_VERSION; $this->plugin_slug = 'darkify'; $this->load_dependencies(); $this->define_constants(); $this->define_admin_hooks(); $this->define_public_hooks(); add_action('plugin_loaded', array($this, 'init_plugin')); } /** * Run the loader to execute all of the hooks with WordPress. * * @since 1.0.0 */ public function run() { $this->loader->run(); } /** * The slug of the plugin used to uniquely identify it within the context of * WordPress and to define internationalization functionality. * * @since 1.0.0 * @return string The name of the plugin. */ public function get_plugin_name() { return $this->plugin_slug; } /** * Retrieve the version number of the plugin. * * @since 1.0.0 * @return string The version number of the plugin. */ public function get_version() { return $this->version; } /** * Define the constants * * @return void */ public function define_constants() { define('DARKIFY_URL', plugins_url('', DARKIFY_FILE)); define('DARKIFY_ASSETS', DARKIFY_URL . '/src/assets/'); define('DARKIFY_ADMIN', DARKIFY_URL . '/src/Admin'); } /** * Load the plugin after all plugins are loaded. * * @return void */ public function init_plugin() { do_action('darkify_loaded'); load_plugin_textdomain('darkify', false, DARKIFY_DIR_NAME . "/languages"); } /** * Load the required dependencies for this plugin. * * Include the following files that make up the plugin: * * - Loader. Orchestrates the hooks of the plugin. * - Teamproi18n. Defines internationalization functionality. * - Admin. Defines all hooks for the admin area. * - Frontend. Defines all hooks for the public side of the site. * * Create an instance of the loader which will be used to register the hooks * with WordPress. * * @since 1.0.0 * @access private */ private function load_dependencies() { /** * The class responsible for orchestrating the actions and filters of the * core plugin. */ $this->loader = new Loader(); } /** * Register all of the hooks related to the admin dashboard functionality * of the plugin. * * @since 1.0.0 * @access private */ private function define_admin_hooks() { $plugin_admin = new Admin($this->get_plugin_name(), $this->get_version()); $this->loader->add_action('admin_enqueue_scripts', $plugin_admin, 'enqueue_styles'); $this->loader->add_action('admin_enqueue_scripts', $plugin_admin, 'enqueue_scripts'); } /** * Register all of the hooks related to the public-facing functionality * of the plugin. * * @since 1.0.0 * @access private */ private function define_public_hooks() { $plugin_public = new Frontend($this->get_plugin_name(), $this->get_version()); } }