mirror of
https://github.com/inretio/WordPress-Plugin-Boilerplate
synced 2025-04-19 05:35:36 +03:00
Documenting classes
Documenting classes that are core to each plugin, while also leaving other classes undocumented for an implementation-specific basis.
This commit is contained in:
parent
f09ca373d8
commit
560e5959a5
6 changed files with 137 additions and 135 deletions
|
@ -1,11 +1,15 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* Short Description (no period)
|
||||
* The core plugin file
|
||||
*
|
||||
* Long Description.
|
||||
* This is the core plugin file that is used to define internationalization,
|
||||
* dashboard-specific hooks, and public-facing site hooks.
|
||||
*
|
||||
* @link http://example.com/
|
||||
* Also maintains the unique identifier of this plugin as well as the current
|
||||
* version of the plugin.
|
||||
*
|
||||
* @link http://example.com
|
||||
* @since 1.0.0
|
||||
*
|
||||
* @package Plugin_Name
|
||||
|
@ -25,34 +29,39 @@
|
|||
class Plugin_Name {
|
||||
|
||||
/**
|
||||
* Short Description. (use period)
|
||||
* The loader that's responsible for maintaining and registering all hooks that power
|
||||
* the plugin.
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @access (private, protected, or public)
|
||||
* @var type $var Description.
|
||||
* @access protected
|
||||
* @var type Plugin_Name_Loader Maintains and registers all hooks for the plugin.
|
||||
*/
|
||||
protected $loader;
|
||||
|
||||
/**
|
||||
* Short Description. (use period)
|
||||
* The unique identifier of this plugin.
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @access (private, protected, or public)
|
||||
* @var type $var Description.
|
||||
* @access protected
|
||||
* @var string $plugin_slug The slug used to uniquely identify this plugin.
|
||||
*/
|
||||
protected $plugin_slug;
|
||||
|
||||
/**
|
||||
* Short Description. (use period)
|
||||
* The current version of the plugin.
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @access (private, protected, or public)
|
||||
* @var type $var Description.
|
||||
* @access protected
|
||||
* @var string $version The current version of the plugin.
|
||||
*/
|
||||
protected $version;
|
||||
|
||||
/**
|
||||
* Short Description. (use period)
|
||||
* 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.
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
|
@ -69,12 +78,20 @@ class Plugin_Name {
|
|||
}
|
||||
|
||||
/**
|
||||
* Short Description. (use period)
|
||||
* Load the required dependencies for this plugin.
|
||||
*
|
||||
* Long Description.
|
||||
* Include the following files that make up the plugin:
|
||||
*
|
||||
* - 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.
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @access (for functions: only use if private)
|
||||
* @access private
|
||||
*/
|
||||
private function load_dependencies() {
|
||||
|
||||
|
@ -106,57 +123,57 @@ class Plugin_Name {
|
|||
}
|
||||
|
||||
/**
|
||||
* Short Description. (use period)
|
||||
* Define the locale for this plugin for internationalization.
|
||||
*
|
||||
* Long Description.
|
||||
* Uses the Plugin_Name_i18n class in order to set the domain and to register the hook
|
||||
* with WordPress.
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @access (for functions: only use if private)
|
||||
* @access private
|
||||
*/
|
||||
private function set_locale() {
|
||||
|
||||
$plugin_i18n = new Plugin_Name_i18n();
|
||||
$plugin_i18n->set_domain( $this->get_plugin_slug() );
|
||||
|
||||
$this->loader->add_action( 'plugins_loaded', $plugin_i18n, 'load_plugin_textdomain' );
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Short Description. (use period)
|
||||
*
|
||||
* Long Description.
|
||||
* Register all of the hooks related to the dashboard functionality
|
||||
* of the plugin.
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @access (for functions: only use if private)
|
||||
* @access private
|
||||
*/
|
||||
private function define_admin_hooks() {
|
||||
|
||||
$plugin_admin = new Plugin_Name_Admin( $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' );
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Short Description. (use period)
|
||||
*
|
||||
* Long Description.
|
||||
* Register all of the hooks related to the public-facing functionality
|
||||
* of the plugin.
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @access (for functions: only use if private)
|
||||
* @access private
|
||||
*/
|
||||
private function define_public_hooks() {
|
||||
|
||||
$plugin_public = new Plugin_Name_Public( $this->get_version() );
|
||||
|
||||
$this->loader->add_action( 'wp_enqueue_scripts', $plugin_public, 'enqueue_styles' );
|
||||
$this->loader->add_action( 'wp_enqueue_scripts', $plugin_public, 'enqueue_scripts' );
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Short Description. (use period)
|
||||
*
|
||||
* Long Description.
|
||||
* Execute the loader to execute all of the hooks with WordPress.
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
|
@ -165,36 +182,31 @@ class Plugin_Name {
|
|||
}
|
||||
|
||||
/**
|
||||
* Short Description. (use period)
|
||||
*
|
||||
* Long Description.
|
||||
* 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 type Description
|
||||
* @return string The slug of the plugin.
|
||||
*/
|
||||
public function get_plugin_slug() {
|
||||
return $this->plugin_slug;
|
||||
}
|
||||
|
||||
/**
|
||||
* Short Description. (use period)
|
||||
*
|
||||
* Long Description.
|
||||
* The reference to the class that orchestrates the hooks with the plugin.
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @return type Description
|
||||
* @return Plugin_Name_Loader Orchestrates the hooks of the plugin.
|
||||
*/
|
||||
public function get_loader() {
|
||||
return $this->loader;
|
||||
}
|
||||
|
||||
/**
|
||||
* Short Description. (use period)
|
||||
*
|
||||
* Long Description.
|
||||
* Retrieve the version number of the plugin.
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @return type Description
|
||||
* @return string The version number of the plugin.
|
||||
*/
|
||||
public function get_version() {
|
||||
return $this->version;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue