*/ class Frontend { /** * The ID of this plugin. * * @since 1.0.0 * @access private * @var string $plugin_name The ID of this plugin. */ private $plugin_name; /** * The version of this plugin. * * @since 1.0.0 * @access private * @var string $version The current version of this plugin. */ private $version; public $utils; public $settings; public $external_support; public $unique_id; /** * Initialize the class and set its properties. * * @since 1.0.0 * @param string $plugin_name The name of the plugin. * @param string $version The version of this plugin. */ public function __construct($plugin_name, $version) { $this->plugin_name = $plugin_name; $this->version = $version; $this->utils = new DarkifyUtils($this); $this->external_support = new DarkifyExternalSupport($this); new DarkifyShortcode($this); if (function_exists('wp_rand')) { $this->unique_id = wp_rand(); } $options = get_option('darkify'); $show_in_menu = isset($options['show_in_menu']) ? $options['show_in_menu'] : ""; $enable_switcher_in_menu = isset($show_in_menu["enable_switch_in_menu"]) ? $show_in_menu["enable_switch_in_menu"] : false; if ($enable_switcher_in_menu) { add_filter('wp_nav_menu_items', array($this, 'darkify_switch_in_menu'), 10, 2); } add_action('wp_enqueue_scripts', array($this, 'darkify_client_enqueue')); add_action('login_enqueue_scripts', array($this, 'darkify_client_enqueue')); add_action('register_enqueue_scripts', array($this, 'darkify_client_enqueue')); add_action('wp_head', array($this, 'darkify_client_header_script'), 1); add_action('login_head', array($this, 'darkify_client_header_script'), 1); add_action('register_head', array($this, 'darkify_client_header_script'), 1); add_action('wp_footer', array($this, 'darkify_client_footer_script')); add_action('login_footer', array($this, 'darkify_client_footer_script')); add_action('register_footer', array($this, 'darkify_client_footer_script')); } public function darkify_client_enqueue() { if ($this->darkify_is_dark_mode_allowed()) { $options = get_option('darkify'); $enable_dark_switcher = isset($options['enable_dark_switcher']) ? $options['enable_dark_switcher'] : 'classic'; $min = (apply_filters('darkify_dev_mode', false) || WP_DEBUG) ? '' : '.min'; wp_enqueue_style("theme-{$enable_dark_switcher}", DARKIFY_DIR_URL . 'src/assets/css/switcher/' . $enable_dark_switcher . $min . '.css', array(), DARKIFY_VERSION, 'all'); wp_register_style('theme-around', DARKIFY_DIR_URL . 'src/assets/css/switcher/around' . $min . '.css', array(), DARKIFY_VERSION, 'all'); wp_register_style('theme-classic', DARKIFY_DIR_URL . 'src/assets/css/switcher/classic' . $min . '.css', array(), DARKIFY_VERSION, 'all'); wp_register_style('theme-dark-inner', DARKIFY_DIR_URL . 'src/assets/css/switcher/dark-inner' . $min . '.css', array(), DARKIFY_VERSION, 'all'); wp_register_style('theme-dark-side', DARKIFY_DIR_URL . 'src/assets/css/switcher/dark-side' . $min . '.css', array(), DARKIFY_VERSION, 'all'); wp_register_style('theme-eclipse', DARKIFY_DIR_URL . 'src/assets/css/switcher/eclipse' . $min . '.css', array(), DARKIFY_VERSION, 'all'); wp_register_style('theme-expand', DARKIFY_DIR_URL . 'src/assets/css/switcher/expand' . $min . '.css', array(), DARKIFY_VERSION, 'all'); wp_register_style('theme-half-sun', DARKIFY_DIR_URL . 'src/assets/css/switcher/half-sun' . $min . '.css', array(), DARKIFY_VERSION, 'all'); wp_register_style('theme-horizon', DARKIFY_DIR_URL . 'src/assets/css/switcher/horizon' . $min . '.css', array(), DARKIFY_VERSION, 'all'); wp_register_style('theme-inner-moon', DARKIFY_DIR_URL . 'src/assets/css/switcher/inner-moon' . $min . '.css', array(), DARKIFY_VERSION, 'all'); wp_register_style('theme-lightbulb', DARKIFY_DIR_URL . 'src/assets/css/switcher/lightbulb' . $min . '.css', array(), DARKIFY_VERSION, 'all'); wp_register_style('theme-simple', DARKIFY_DIR_URL . 'src/assets/css/switcher/simple' . $min . '.css', array(), DARKIFY_VERSION, 'all'); wp_register_style('theme-within', DARKIFY_DIR_URL . 'src/assets/css/switcher/within' . $min . '.css', array(), DARKIFY_VERSION, 'all'); wp_enqueue_style('darkify-client-main', DARKIFY_DIR_URL . 'src/assets/css/client_main' . $min . '.css', array(), DARKIFY_VERSION); wp_enqueue_script('darkify-client-main', DARKIFY_DIR_URL . 'src/assets/js/client_main' . $min . '.js', array('jquery'), DARKIFY_VERSION); } } public function darkify_is_dark_mode_allowed() { $options = get_option('darkify'); /* Disable if Oxygen Builder is Opened */ if (isset($_GET['ct_builder'])) { if ($_GET['ct_builder'] == "true") { if (!isset($_GET['oxygen_iframe'])) { return False; } } } return True; } public function darkify_client_header_script() { if ($this->darkify_is_dark_mode_allowed()) { include_once DarkifyUtils::darkify_locate_template('header_script.php'); } } public function darkify_client_footer_script() { if ($this->darkify_is_dark_mode_allowed()) { include_once DarkifyUtils::darkify_locate_template('footer_script.php'); } } public function darkify_switch_in_menu($items, $args) { $options = get_option('darkify'); $show_in_menu = isset($options['show_in_menu']) ? $options['show_in_menu'] : ''; $switch_in_menu_location = isset($show_in_menu['switch_in_menu_location']) ? $show_in_menu['switch_in_menu_location'] : ''; $darkify_menu_shortcode_helper = $show_in_menu['darkify_menu_shortcode_helper']; if ($this->darkify_is_dark_mode_allowed()) { if (isset($args->menu->term_id)) { if ($args->menu->term_id == $switch_in_menu_location) { $items .= '