mirror of
https://github.com/inretio/WordPress-Plugin-Boilerplate
synced 2024-12-22 20:03:53 +02:00
removing extraneous whitespace, making sure comment lines don't exceed 80 characters, and providing updated comment blocks for functions, inline comments, and documentation for the new admin class
This commit is contained in:
parent
467d5e290f
commit
aa01ca281c
1 changed files with 43 additions and 19 deletions
|
@ -2,7 +2,7 @@
|
||||||
/**
|
/**
|
||||||
* Plugin Name.
|
* Plugin Name.
|
||||||
*
|
*
|
||||||
* @package Plugin_Name\Admin
|
* @package Plugin_Name_Admin
|
||||||
* @author Your Name <email@example.com>
|
* @author Your Name <email@example.com>
|
||||||
* @license GPL-2.0+
|
* @license GPL-2.0+
|
||||||
* @link http://example.com
|
* @link http://example.com
|
||||||
|
@ -10,7 +10,11 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Plugin Admin class.
|
* Plugin class. This class should ideally be used to work with the
|
||||||
|
* administrative side of the WordPress site.
|
||||||
|
*
|
||||||
|
* If you're interested in introducing public-facing
|
||||||
|
* functionality, then refer to `class-plugin-name-admin.php`
|
||||||
*
|
*
|
||||||
* TODO: Rename this class to a proper name for your plugin.
|
* TODO: Rename this class to a proper name for your plugin.
|
||||||
*
|
*
|
||||||
|
@ -38,13 +42,21 @@ class Plugin_Name_Admin {
|
||||||
protected $plugin_screen_hook_suffix = null;
|
protected $plugin_screen_hook_suffix = null;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Initialize the plugin by loading admin scripts & styles and adding a settings page and menu.
|
* Initialize the plugin by loading admin scripts & styles and adding a
|
||||||
|
* settings page and menu.
|
||||||
*
|
*
|
||||||
* @since 1.0.0
|
* @since 1.0.0
|
||||||
*/
|
*/
|
||||||
private function __construct() {
|
private function __construct() {
|
||||||
|
|
||||||
// Call $plugin_slug from initial plugin class. TODO: Rename "Plugin_Name" to the name of your initial plugin class
|
/*
|
||||||
|
* Call $plugin_slug from public plugin class.
|
||||||
|
*
|
||||||
|
* TODO:
|
||||||
|
*
|
||||||
|
* - Rename "Plugin_Name" to the name of your initial plugin class
|
||||||
|
*
|
||||||
|
*/
|
||||||
$plugin = Plugin_Name::get_instance();
|
$plugin = Plugin_Name::get_instance();
|
||||||
$this->plugin_slug = $plugin->get_plugin_slug();
|
$this->plugin_slug = $plugin->get_plugin_slug();
|
||||||
|
|
||||||
|
@ -55,11 +67,22 @@ class Plugin_Name_Admin {
|
||||||
// Add the options page and menu item.
|
// Add the options page and menu item.
|
||||||
add_action( 'admin_menu', array( $this, 'add_plugin_admin_menu' ) );
|
add_action( 'admin_menu', array( $this, 'add_plugin_admin_menu' ) );
|
||||||
|
|
||||||
// Add an action link pointing to the options page. TODO: Rename "plugin-name.php" to the name your plugin
|
/*
|
||||||
|
* Add an action link pointing to the options page.
|
||||||
|
*
|
||||||
|
* TODO:
|
||||||
|
*
|
||||||
|
* - Rename "plugin-name.php" to the name your plugin
|
||||||
|
*/
|
||||||
$plugin_basename = plugin_basename( plugin_dir_path( __FILE__ ) . 'plugin-name.php' );
|
$plugin_basename = plugin_basename( plugin_dir_path( __FILE__ ) . 'plugin-name.php' );
|
||||||
add_filter( 'plugin_action_links_' . $plugin_basename, array( $this, 'add_action_links' ) );
|
add_filter( 'plugin_action_links_' . $plugin_basename, array( $this, 'add_action_links' ) );
|
||||||
|
|
||||||
// Define custom functionality. Read more about actions and filters: http://codex.wordpress.org/Plugin_API#Hooks.2C_Actions_and_Filters
|
/*
|
||||||
|
* Define custom functionality.
|
||||||
|
*
|
||||||
|
* Read more about actions and filters:
|
||||||
|
* http://codex.wordpress.org/Plugin_API#Hooks.2C_Actions_and_Filters
|
||||||
|
*/
|
||||||
add_action( 'TODO', array( $this, 'action_method_name' ) );
|
add_action( 'TODO', array( $this, 'action_method_name' ) );
|
||||||
add_filter( 'TODO', array( $this, 'filter_method_name' ) );
|
add_filter( 'TODO', array( $this, 'filter_method_name' ) );
|
||||||
|
|
||||||
|
@ -96,7 +119,7 @@ class Plugin_Name_Admin {
|
||||||
}
|
}
|
||||||
|
|
||||||
$screen = get_current_screen();
|
$screen = get_current_screen();
|
||||||
if ( $screen->id == $this->plugin_screen_hook_suffix ) {
|
if ( $this->plugin_screen_hook_suffix == $screen->id ) {
|
||||||
wp_enqueue_style( $this->plugin_slug .'-admin-styles', plugins_url( 'css/admin.css', __FILE__ ), array(), Plugin_Name::VERSION );
|
wp_enqueue_style( $this->plugin_slug .'-admin-styles', plugins_url( 'css/admin.css', __FILE__ ), array(), Plugin_Name::VERSION );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -116,7 +139,7 @@ class Plugin_Name_Admin {
|
||||||
}
|
}
|
||||||
|
|
||||||
$screen = get_current_screen();
|
$screen = get_current_screen();
|
||||||
if ( $screen->id == $this->plugin_screen_hook_suffix ) {
|
if ( $this->plugin_screen_hook_suffix == $screen->id ) {
|
||||||
wp_enqueue_script( $this->plugin_slug . '-admin-script', plugins_url( 'js/admin.js', __FILE__ ), array( 'jquery' ), Plugin_Name::VERSION );
|
wp_enqueue_script( $this->plugin_slug . '-admin-script', plugins_url( 'js/admin.js', __FILE__ ), array( 'jquery' ), Plugin_Name::VERSION );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -138,9 +161,10 @@ class Plugin_Name_Admin {
|
||||||
*
|
*
|
||||||
* TODO:
|
* TODO:
|
||||||
*
|
*
|
||||||
* Change 'Page Title' to the title of your plugin admin page
|
* - Change 'Page Title' to the title of your plugin admin page
|
||||||
* Change 'Menu Text' to the text for menu item for the plugin settings page
|
* - Change 'Menu Text' to the text for menu item for the plugin settings page
|
||||||
* Change 'manage_options' to the capability you see fit (http://codex.wordpress.org/Roles_and_Capabilities)
|
* - Change 'manage_options' to the capability you see fit
|
||||||
|
* For reference: http://codex.wordpress.org/Roles_and_Capabilities
|
||||||
*/
|
*/
|
||||||
$this->plugin_screen_hook_suffix = add_options_page(
|
$this->plugin_screen_hook_suffix = add_options_page(
|
||||||
__( 'Page Title', $this->plugin_slug ),
|
__( 'Page Title', $this->plugin_slug ),
|
||||||
|
@ -181,8 +205,8 @@ class Plugin_Name_Admin {
|
||||||
* NOTE: Actions are points in the execution of a page or process
|
* NOTE: Actions are points in the execution of a page or process
|
||||||
* lifecycle that WordPress fires.
|
* lifecycle that WordPress fires.
|
||||||
*
|
*
|
||||||
* WordPress Actions: http://codex.wordpress.org/Plugin_API#Actions
|
* Actions: http://codex.wordpress.org/Plugin_API#Actions
|
||||||
* Action Reference: http://codex.wordpress.org/Plugin_API/Action_Reference
|
* Reference: http://codex.wordpress.org/Plugin_API/Action_Reference
|
||||||
*
|
*
|
||||||
* @since 1.0.0
|
* @since 1.0.0
|
||||||
*/
|
*/
|
||||||
|
@ -194,8 +218,8 @@ class Plugin_Name_Admin {
|
||||||
* NOTE: Filters are points of execution in which WordPress modifies data
|
* NOTE: Filters are points of execution in which WordPress modifies data
|
||||||
* before saving it or sending it to the browser.
|
* before saving it or sending it to the browser.
|
||||||
*
|
*
|
||||||
* WordPress Filters: http://codex.wordpress.org/Plugin_API#Filters
|
* Filters: http://codex.wordpress.org/Plugin_API#Filters
|
||||||
* Filter Reference: http://codex.wordpress.org/Plugin_API/Filter_Reference
|
* Reference: http://codex.wordpress.org/Plugin_API/Filter_Reference
|
||||||
*
|
*
|
||||||
* @since 1.0.0
|
* @since 1.0.0
|
||||||
*/
|
*/
|
||||||
|
|
Loading…
Reference in a new issue