2014-04-09 23:22:44 +03:00
|
|
|
<?php
|
2014-04-26 01:58:07 +03:00
|
|
|
|
2014-04-09 23:22:44 +03:00
|
|
|
/**
|
2014-07-29 23:56:18 +03:00
|
|
|
* The core plugin file
|
2014-07-29 23:03:09 +03:00
|
|
|
*
|
2014-07-29 23:56:18 +03:00
|
|
|
* This is the core plugin file that is used to define internationalization,
|
|
|
|
* dashboard-specific hooks, and public-facing site hooks.
|
|
|
|
*
|
|
|
|
* Also maintains the unique identifier of this plugin as well as the current
|
|
|
|
* version of the plugin.
|
2014-07-29 23:03:09 +03:00
|
|
|
*
|
2014-07-29 23:56:18 +03:00
|
|
|
* @link http://example.com
|
2014-07-29 23:03:09 +03:00
|
|
|
* @since 1.0.0
|
2014-04-09 23:22:44 +03:00
|
|
|
*
|
2014-05-03 22:07:05 +03:00
|
|
|
* @package Plugin_Name
|
|
|
|
* @subpackage Plugin_Name/includes
|
2014-05-01 05:55:34 +03:00
|
|
|
*/
|
|
|
|
|
|
|
|
/**
|
2014-07-29 23:03:09 +03:00
|
|
|
* Short Description. (use period)
|
2014-04-26 01:58:07 +03:00
|
|
|
*
|
2014-07-29 23:03:09 +03:00
|
|
|
* Long Description.
|
2014-05-01 05:55:34 +03:00
|
|
|
*
|
2014-07-29 23:03:09 +03:00
|
|
|
* @since 1.0.0
|
2014-05-03 22:28:04 +03:00
|
|
|
* @package Plugin_Name
|
|
|
|
* @subpackage Plugin_Name/includes
|
|
|
|
* @author Your Name <email@example.com>
|
2014-04-09 23:22:44 +03:00
|
|
|
*/
|
|
|
|
class Plugin_Name {
|
|
|
|
|
2014-05-09 01:10:04 +03:00
|
|
|
/**
|
2014-07-29 23:56:18 +03:00
|
|
|
* The loader that's responsible for maintaining and registering all hooks that power
|
|
|
|
* the plugin.
|
2014-06-26 23:19:57 +03:00
|
|
|
*
|
|
|
|
* @since 1.0.0
|
2014-07-29 23:56:18 +03:00
|
|
|
* @access protected
|
|
|
|
* @var type Plugin_Name_Loader Maintains and registers all hooks for the plugin.
|
2014-05-09 01:10:04 +03:00
|
|
|
*/
|
2014-05-09 06:34:16 +03:00
|
|
|
protected $loader;
|
2014-05-09 01:10:04 +03:00
|
|
|
|
2014-05-09 06:34:16 +03:00
|
|
|
/**
|
2014-07-29 23:56:18 +03:00
|
|
|
* The unique identifier of this plugin.
|
2014-06-26 23:19:57 +03:00
|
|
|
*
|
|
|
|
* @since 1.0.0
|
2014-07-29 23:56:18 +03:00
|
|
|
* @access protected
|
|
|
|
* @var string $plugin_slug The slug used to uniquely identify this plugin.
|
2014-05-09 06:34:16 +03:00
|
|
|
*/
|
|
|
|
protected $plugin_slug;
|
2014-05-05 07:18:04 +03:00
|
|
|
|
2014-05-09 06:34:16 +03:00
|
|
|
/**
|
2014-07-29 23:56:18 +03:00
|
|
|
* The current version of the plugin.
|
2014-06-26 23:19:57 +03:00
|
|
|
*
|
|
|
|
* @since 1.0.0
|
2014-07-29 23:56:18 +03:00
|
|
|
* @access protected
|
|
|
|
* @var string $version The current version of the plugin.
|
2014-05-09 06:34:16 +03:00
|
|
|
*/
|
|
|
|
protected $version;
|
2014-05-05 07:18:04 +03:00
|
|
|
|
2014-05-09 06:34:16 +03:00
|
|
|
/**
|
2014-07-29 23:56:18 +03:00
|
|
|
* Define the core functionality of the plugin.
|
|
|
|
*
|
|
|
|
* Set the plugin slug and the plugin version that can be used throughout the plugin.
|
|
|
|
* Load the dependencies, define the locale, and set the hooks for the Dashboard and
|
|
|
|
* the public-facing side of the site.
|
2014-06-26 23:19:57 +03:00
|
|
|
*
|
|
|
|
* @since 1.0.0
|
2014-05-09 06:34:16 +03:00
|
|
|
*/
|
|
|
|
public function __construct() {
|
|
|
|
|
|
|
|
$this->plugin_slug = 'plugin-name-slug';
|
|
|
|
$this->version = '1.0.0';
|
|
|
|
|
|
|
|
$this->load_dependencies();
|
|
|
|
$this->set_locale();
|
|
|
|
$this->define_admin_hooks();
|
|
|
|
$this->define_public_hooks();
|
2014-05-05 07:18:04 +03:00
|
|
|
|
|
|
|
}
|
|
|
|
|
2014-05-09 06:34:16 +03:00
|
|
|
/**
|
2014-07-29 23:56:18 +03:00
|
|
|
* Load the required dependencies for this plugin.
|
|
|
|
*
|
|
|
|
* Include the following files that make up the plugin:
|
2014-06-26 23:19:57 +03:00
|
|
|
*
|
2014-07-29 23:56:18 +03:00
|
|
|
* - Plugin_Name_Loader. Orchestrates the hooks of the plugin.
|
|
|
|
* - Plugin_Name_i18n. Defines internationalization functionality.
|
|
|
|
* - Plugin_Name_Admin. Defines all hooks for the dashboard.
|
|
|
|
* - Plugin_Name_Public. 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.
|
2014-06-26 23:19:57 +03:00
|
|
|
*
|
|
|
|
* @since 1.0.0
|
2014-07-29 23:56:18 +03:00
|
|
|
* @access private
|
2014-05-09 06:34:16 +03:00
|
|
|
*/
|
|
|
|
private function load_dependencies() {
|
|
|
|
|
|
|
|
/**
|
|
|
|
* The class responsible for orchestrating the actions and filters of the
|
|
|
|
* core plugin.
|
|
|
|
*/
|
|
|
|
require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-plugin-name-loader.php';
|
|
|
|
|
|
|
|
/**
|
|
|
|
* The class responsible for defining internationalization functionality
|
|
|
|
* of the plugin.
|
|
|
|
*/
|
|
|
|
require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-plugin-name-i18n.php';
|
|
|
|
|
|
|
|
/**
|
|
|
|
* The class responsible for defining all actions that occur in the Dashboard.
|
|
|
|
*/
|
|
|
|
require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-plugin-name-admin.php';
|
|
|
|
|
|
|
|
/**
|
|
|
|
* The class responsible for defining all actions that occur in the public-facing
|
|
|
|
* side of the site.
|
|
|
|
*/
|
|
|
|
require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-plugin-name-public.php';
|
|
|
|
|
|
|
|
$this->loader = new Plugin_Name_Loader();
|
|
|
|
|
2014-05-05 07:18:04 +03:00
|
|
|
}
|
|
|
|
|
2014-05-09 06:34:16 +03:00
|
|
|
/**
|
2014-07-29 23:56:18 +03:00
|
|
|
* Define the locale for this plugin for internationalization.
|
2014-06-26 23:19:57 +03:00
|
|
|
*
|
2014-07-29 23:56:18 +03:00
|
|
|
* Uses the Plugin_Name_i18n class in order to set the domain and to register the hook
|
|
|
|
* with WordPress.
|
2014-06-26 23:19:57 +03:00
|
|
|
*
|
|
|
|
* @since 1.0.0
|
2014-07-29 23:56:18 +03:00
|
|
|
* @access private
|
2014-05-09 06:34:16 +03:00
|
|
|
*/
|
|
|
|
private function set_locale() {
|
|
|
|
|
|
|
|
$plugin_i18n = new Plugin_Name_i18n();
|
2014-07-29 23:03:09 +03:00
|
|
|
$plugin_i18n->set_domain( $this->get_plugin_slug() );
|
2014-07-29 23:56:18 +03:00
|
|
|
|
2014-05-09 06:34:16 +03:00
|
|
|
$this->loader->add_action( 'plugins_loaded', $plugin_i18n, 'load_plugin_textdomain' );
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2014-07-29 23:56:18 +03:00
|
|
|
* Register all of the hooks related to the dashboard functionality
|
|
|
|
* of the plugin.
|
2014-06-26 23:19:57 +03:00
|
|
|
*
|
|
|
|
* @since 1.0.0
|
2014-07-29 23:56:18 +03:00
|
|
|
* @access private
|
2014-05-09 06:34:16 +03:00
|
|
|
*/
|
|
|
|
private function define_admin_hooks() {
|
|
|
|
|
|
|
|
$plugin_admin = new Plugin_Name_Admin( $this->get_version() );
|
2014-07-29 23:56:18 +03:00
|
|
|
|
2014-05-09 06:34:16 +03:00
|
|
|
$this->loader->add_action( 'admin_enqueue_scripts', $plugin_admin, 'enqueue_styles' );
|
|
|
|
$this->loader->add_action( 'admin_enqueue_scripts', $plugin_admin, 'enqueue_scripts' );
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2014-07-29 23:56:18 +03:00
|
|
|
* Register all of the hooks related to the public-facing functionality
|
|
|
|
* of the plugin.
|
2014-06-26 23:19:57 +03:00
|
|
|
*
|
|
|
|
* @since 1.0.0
|
2014-07-29 23:56:18 +03:00
|
|
|
* @access private
|
2014-05-09 06:34:16 +03:00
|
|
|
*/
|
|
|
|
private function define_public_hooks() {
|
|
|
|
|
|
|
|
$plugin_public = new Plugin_Name_Public( $this->get_version() );
|
2014-07-29 23:56:18 +03:00
|
|
|
|
2014-05-09 06:34:16 +03:00
|
|
|
$this->loader->add_action( 'wp_enqueue_scripts', $plugin_public, 'enqueue_styles' );
|
|
|
|
$this->loader->add_action( 'wp_enqueue_scripts', $plugin_public, 'enqueue_scripts' );
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2014-07-29 23:56:18 +03:00
|
|
|
* Execute the loader to execute all of the hooks with WordPress.
|
2014-06-26 23:19:57 +03:00
|
|
|
*
|
|
|
|
* @since 1.0.0
|
2014-05-09 06:34:16 +03:00
|
|
|
*/
|
|
|
|
public function run() {
|
|
|
|
$this->loader->run();
|
2014-05-08 23:50:23 +03:00
|
|
|
}
|
|
|
|
|
2014-05-09 06:34:16 +03:00
|
|
|
/**
|
2014-07-29 23:56:18 +03:00
|
|
|
* The slug of the plugin used to uniquely identify it within the context of
|
|
|
|
* WordPress and to define internationalization functionality.
|
2014-06-26 23:19:57 +03:00
|
|
|
*
|
|
|
|
* @since 1.0.0
|
2014-07-29 23:56:18 +03:00
|
|
|
* @return string The slug of the plugin.
|
2014-05-09 06:34:16 +03:00
|
|
|
*/
|
2014-07-29 23:03:09 +03:00
|
|
|
public function get_plugin_slug() {
|
2014-05-09 01:10:04 +03:00
|
|
|
return $this->plugin_slug;
|
|
|
|
}
|
2014-05-01 05:55:34 +03:00
|
|
|
|
2014-05-09 06:34:16 +03:00
|
|
|
/**
|
2014-07-29 23:56:18 +03:00
|
|
|
* The reference to the class that orchestrates the hooks with the plugin.
|
2014-06-26 23:19:57 +03:00
|
|
|
*
|
|
|
|
* @since 1.0.0
|
2014-07-29 23:56:18 +03:00
|
|
|
* @return Plugin_Name_Loader Orchestrates the hooks of the plugin.
|
2014-05-09 06:34:16 +03:00
|
|
|
*/
|
|
|
|
public function get_loader() {
|
|
|
|
return $this->loader;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2014-07-29 23:56:18 +03:00
|
|
|
* Retrieve the version number of the plugin.
|
2014-06-26 23:19:57 +03:00
|
|
|
*
|
|
|
|
* @since 1.0.0
|
2014-07-29 23:56:18 +03:00
|
|
|
* @return string The version number of the plugin.
|
2014-05-09 06:34:16 +03:00
|
|
|
*/
|
|
|
|
public function get_version() {
|
|
|
|
return $this->version;
|
|
|
|
}
|
|
|
|
|
2014-04-26 01:39:31 +03:00
|
|
|
}
|