*/
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('' . esc_html__('Settings', 'darkify') . ''),
sprintf('' . esc_html__('Support', 'darkify') . ''),
sprintf('' . esc_html__('Go Pro', 'darkify') . ''),
);
return array_merge($new_links, $links);
}
}