# darkify/1.3.2/src/Darkify.php

Darkify – Dark Mode &amp; Night Mode for Website &amp; Admin (Dark Theme Included), version 1.3.2. 213 lines.

- Page: https://pluginprobe.com/plugins/darkify/1.3.2/code/src/Darkify.php
- Raw: https://pluginprobe.com/plugins/darkify/1.3.2/raw/src/Darkify.php
- Modified: 2025-03-24T01:22:28+00:00

Line numbers below start at 1. Link to a line or a range by appending a fragment to the
page URL, for example `https://pluginprobe.com/plugins/darkify/1.3.2/code/src/Darkify.php#L10-L20`.

```php
<?php

/**
 * The file of the Darkify class.
 *
 * @link       https://themeatelier.net
 * @since      1.0.0
 *
 * @package Darkify
 */

namespace ThemeAtelier\Darkify;

use ThemeAtelier\Darkify\Admin\Admin;
use ThemeAtelier\Darkify\Frontend\Frontend;
use ThemeAtelier\Darkify\Helpers\ReviewNotice;

// don't call the file directly.
if (!defined('ABSPATH')) {
    exit;
}

/**
 * The main class of the plugin.
 *
 * Handle all the class and methods of the plugin.
 *
 * @author     ThemeAtelier <themeatelierbd@gmail.com>
 */
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'));
        add_action('activated_plugin', array($this, 'redirect_to'));
        $active_plugins = get_option('active_plugins');
        foreach ($active_plugins as $active_plugin) {
            $_temp = strpos($active_plugin, 'darkify.php');
            if (false != $_temp) {
                add_filter('plugin_action_links_' . $active_plugin, array($this, 'darkify_plugin_action_links'));
            }
        }
        new ReviewNotice();
    }

    /**
     * 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');
    }

    public function redirect_to($plugin)
    {
        if (DARKIFY_BASENAME === $plugin) {
            $redirect_url = esc_url(admin_url('admin.php?page=darkify'));
            exit(wp_kses_post(wp_safe_redirect($redirect_url)));
        }
    }

    /**
     * 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());
    }

    // Plugin settings in plugin list
    public function darkify_plugin_action_links(array $links)
    {
        $new_links = array(
            sprintf('<a href="' . esc_url(admin_url('admin.php?page=darkify#tab=general')) . '">' . esc_html__('Settings', 'darkify') . '</a>'),
            sprintf('<a target="_blank" href="https://themeatelier.net/contact">' . esc_html__('Support', 'darkify') . '</a>'),
            sprintf('<a style="font-weight: bold;color:#171717" target="_blank" href="https://themeatelier.net/downloads/darkify">' . esc_html__('Go Pro', 'darkify') . '</a>'),
        );
        return array_merge($new_links, $links);
    }
}

```
