Plugin code
This commit is contained in:
parent
8819c70d0e
commit
2fde6edfdc
28 changed files with 6338 additions and 0 deletions
178
includes/class-cklph-wdl.php
Normal file
178
includes/class-cklph-wdl.php
Normal file
|
@ -0,0 +1,178 @@
|
|||
<?php
|
||||
/**
|
||||
* The core plugin class.
|
||||
*
|
||||
* This is used to define internationalization, admin-specific hooks, and
|
||||
* public-facing site hooks.
|
||||
*
|
||||
* @link https://chykalophia.com/woocommerce-direct-links
|
||||
* @since 0.1.0
|
||||
* @package Woocommerce_Direct_Links
|
||||
* @subpackage Woocommerce_Direct_Links/includes
|
||||
* @author Joel Sanguenza <joel@chykalophia.com>,
|
||||
* Lord Francis Navarro <francis@chykalophia.com>
|
||||
*/
|
||||
|
||||
// If this file is called directly, abort.
|
||||
if (!defined('ABSPATH')) {
|
||||
die;
|
||||
}
|
||||
|
||||
if (!class_exists('Cklph_Wdl')) {
|
||||
|
||||
/**
|
||||
* Loads the dependencies, internationalization, and the loader class.
|
||||
*/
|
||||
class Cklph_Wdl
|
||||
{
|
||||
|
||||
/**
|
||||
* The loader that's responsible for maintaining and registering all the hooks
|
||||
*
|
||||
* @since 0.1.0
|
||||
* @access protected
|
||||
* @var Wdl_Loader $wdl_loader Maintains and registers all hooks for wdl.
|
||||
*/
|
||||
protected $wdl_loader;
|
||||
|
||||
/**
|
||||
* The unique identifier of wdl.
|
||||
*
|
||||
* @since 0.1.0
|
||||
* @access protected
|
||||
* @var string $wdl_name The string used to uniquely identify wdl.
|
||||
*/
|
||||
protected $wdl_name;
|
||||
|
||||
/**
|
||||
* The current version
|
||||
*
|
||||
* @since 0.1.0
|
||||
* @access protected
|
||||
* @var string $wdl_version The current version of the wdl.
|
||||
*/
|
||||
protected $wdl_version;
|
||||
|
||||
/**
|
||||
* Define the core functionality of wdl.
|
||||
*
|
||||
* @since 0.1.0
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
if (defined('WDL_VERSION')) {
|
||||
$this->wdl_version = WDL_VERSION;
|
||||
} else {
|
||||
$this->wdl_version = '0.1.0';
|
||||
}
|
||||
$this->wdl_name = 'woocommerce-direct-links';
|
||||
|
||||
$this->load_dependencies();
|
||||
$this->set_locale();
|
||||
$this->define_admin_hooks();
|
||||
}
|
||||
|
||||
/**
|
||||
* Load the required dependencies for wdl
|
||||
* Also Creates an instance of the loader which will be used to register the hooks.
|
||||
*
|
||||
* @since 0.1.0
|
||||
* @access private
|
||||
*/
|
||||
private function load_dependencies()
|
||||
{
|
||||
|
||||
require_once CKLPH_WDL_PATH . 'admin/partials/list-tables/class-cklph-wdl-list-table.php';
|
||||
require_once CKLPH_WDL_PATH . 'admin/partials/class-cklph-wdl-wc-products.php';
|
||||
require_once CKLPH_WDL_PATH . 'admin/partials/class-cklph-wdl-shortlinks.php';
|
||||
require_once CKLPH_WDL_PATH . 'admin/partials/class-cklph-wdl-rest-api.php';
|
||||
require_once CKLPH_WDL_PATH . 'includes/class-cklph-wdl-loader.php';
|
||||
require_once CKLPH_WDL_PATH . 'includes/class-cklph-wdl-i18n.php';
|
||||
require_once CKLPH_WDL_PATH . 'admin/class-cklph-wdl-admin.php';
|
||||
|
||||
$this->wdl_loader = new Cklph_Wdl_Loader();
|
||||
}
|
||||
|
||||
/**
|
||||
* Define the locale for wdl for internationalization.
|
||||
*
|
||||
* @since 0.1.0
|
||||
* @access private
|
||||
*/
|
||||
private function set_locale()
|
||||
{
|
||||
|
||||
$wdl_i18n = new Cklph_Wdl_I18n();
|
||||
|
||||
$this->wdl_loader->add_action('plugins_loaded', $wdl_i18n, 'load_plugin_textdomain');
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Register all of the hooks related to the admin area functionality
|
||||
* of wdl.
|
||||
*
|
||||
* @since 0.1.0
|
||||
* @access private
|
||||
*/
|
||||
private function define_admin_hooks()
|
||||
{
|
||||
$wdl_admin = new Cklph_Wdl_Admin($this->get_plugin_name(), $this->get_version());
|
||||
|
||||
$this->wdl_loader->add_action('rest_api_init', $wdl_admin, 'cklph_wdl_rest_api');
|
||||
$this->wdl_loader->add_action('admin_init', $wdl_admin, 'cklph_wdl_has_woocommerce');
|
||||
$this->wdl_loader->add_action('admin_init', $wdl_admin, 'cklph_wdl_settings_init');
|
||||
$this->wdl_loader->add_action('admin_menu', $wdl_admin, 'cklph_wdl_add_admin_pages');
|
||||
$this->wdl_loader->add_action('admin_enqueue_scripts', $wdl_admin, 'cklph_wdl_enqueue_styles');
|
||||
$this->wdl_loader->add_action('admin_enqueue_scripts', $wdl_admin, 'cklph_wdl_enqueue_scripts');
|
||||
$this->wdl_loader->add_action('add_meta_boxes', $wdl_admin, 'cklph_wdl_add_meta_box');
|
||||
|
||||
$this->wdl_loader->add_filter('plugin_action_links_' . CKLPH_WDL_BASE, $wdl_admin, 'cklph_wdl_add_action_links');
|
||||
$this->wdl_loader->add_filter('set-screen-option', $wdl_admin, 'cklph_wdl_set_pagination_option', 10, 3);
|
||||
}
|
||||
|
||||
/**
|
||||
* Run the wdl loader to execute all of the hooks with WordPress.
|
||||
*
|
||||
* @since 0.1.0
|
||||
*/
|
||||
public function run()
|
||||
{
|
||||
$this->wdl_loader->run();
|
||||
}
|
||||
|
||||
/**
|
||||
* The name of the plugin used to uniquely identify it within the context of
|
||||
* WordPress and to define internationalization functionality.
|
||||
*
|
||||
* @since 0.1.0
|
||||
* @return string The name of the plugin.
|
||||
*/
|
||||
public function get_plugin_name()
|
||||
{
|
||||
return $this->wdl_name;
|
||||
}
|
||||
|
||||
/**
|
||||
* The reference to the class that orchestrates the hooks with wdl.
|
||||
*
|
||||
* @since 0.1.0
|
||||
* @return WDL_Loader Orchestrates the hooks wdl.
|
||||
*/
|
||||
public function get_loader()
|
||||
{
|
||||
return $this->wdl_loader;
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve the version number of wdl.
|
||||
*
|
||||
* @since 0.1.0
|
||||
* @return string The version number of wdl.
|
||||
*/
|
||||
public function get_version()
|
||||
{
|
||||
return $this->wdl_version;
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue