From 051c68199d729e83f1fac566347328d67867fca4 Mon Sep 17 00:00:00 2001 From: Reza Latifi Date: Thu, 28 May 2020 00:38:19 +0430 Subject: [PATCH 1/3] Update README.md --- README.md | 60 +++++-------------------------------------------------- 1 file changed, 5 insertions(+), 55 deletions(-) diff --git a/README.md b/README.md index 715173755..78d4a0475 100644 --- a/README.md +++ b/README.md @@ -1,23 +1,15 @@ -# WordPress Plugin Boilerplate +# WordPress Micro Plugin Boilerplate -A standardized, organized, object-oriented foundation for building high-quality WordPress Plugins. +A standardized, organized, object-oriented, mimimal foundation for building high-quality Services or tiny WordPress plugins. ## Contents -The WordPress Plugin Boilerplate includes the following files: +The WordPress Micro Plugin Boilerplate includes the following files: * `.gitignore`. Used to exclude certain files from the repository. -* `CHANGELOG.md`. The list of changes to the core project. * `README.md`. The file that you’re currently reading. * A `plugin-name` directory that contains the source code - a fully executable WordPress plugin. -## Features - -* The Boilerplate is based on the [Plugin API](http://codex.wordpress.org/Plugin_API), [Coding Standards](http://codex.wordpress.org/WordPress_Coding_Standards), and [Documentation Standards](https://make.wordpress.org/core/handbook/best-practices/inline-documentation-standards/php/). -* All classes, functions, and variables are documented so that you know what you need to change. -* The Boilerplate uses a strict file organization scheme that corresponds both to the WordPress Plugin Repository structure, and that makes it easy to organize the files that compose the plugin. -* The project includes a `.pot` file as a starting point for internationalization. - ## Installation The Boilerplate can be installed directly into your plugins folder "as-is". You will want to rename it and the classes inside of it to fit your needs. For example, if your plugin is named 'example-me' then: @@ -30,22 +22,6 @@ The Boilerplate can be installed directly into your plugins folder "as-is". You It's safe to activate the plugin at this point. Because the Boilerplate has no real functionality there will be no menu items, meta boxes, or custom post types added until you write the code. -## WordPress.org Preparation - -The original launch of this version of the boilerplate included the folder structure needed for using your plugin on WordPress.org. That folder structure has been moved to its own repo here: https://github.com/DevinVinson/Plugin-Directory-Boilerplate - -## Recommended Tools - -### i18n Tools - -The WordPress Plugin Boilerplate uses a variable to store the text domain used when internationalizing strings throughout the Boilerplate. To take advantage of this method, there are tools that are recommended for providing correct, translatable files: - -* [Poedit](http://www.poedit.net/) -* [makepot](http://i18n.svn.wordpress.org/tools/trunk/) -* [i18n](https://github.com/grappler/i18n) - -Any of the above tools should provide you with the proper tooling to internationalize the plugin. - ## License The WordPress Plugin Boilerplate is licensed under the GPL v2 or later. @@ -68,32 +44,6 @@ For reference, [here's a discussion](http://make.wordpress.org/themes/2013/03/04 ### Includes -Note that if you include your own classes, or third-party libraries, there are three locations in which said files may go: - -* `plugin-name/includes` is where functionality shared between the admin area and the public-facing parts of the site reside -* `plugin-name/admin` is for all admin-specific functionality -* `plugin-name/public` is for all public-facing functionality - -Note that previous versions of the Boilerplate did not include `Plugin_Name_Loader` but this class is used to register all filters and actions with WordPress. - -The example code provided shows how to register your hooks with the Loader class. - -### What About Other Features? - -The previous version of the WordPress Plugin Boilerplate included support for a number of different projects such as the [GitHub Updater](https://github.com/afragen/github-updater). - -These tools are not part of the core of this Boilerplate, as I see them as being additions, forks, or other contributions to the Boilerplate. - -The same is true of using tools like Grunt, Composer, etc. These are all fantastic tools, but not everyone uses them. In order to keep the core Boilerplate as light as possible, these features have been removed and will be introduced in other editions, and will be listed and maintained on the project homepage. - -# Credits - -The WordPress Plugin Boilerplate was started in 2011 by [Tom McFarlin](http://twitter.com/tommcfarlin/) and has since included a number of great contributions. In March of 2015 the project was handed over by Tom to Devin Vinson. - -The current version of the Boilerplate was developed in conjunction with [Josh Eaton](https://twitter.com/jjeaton), [Ulrich Pogson](https://twitter.com/grapplerulrich), and [Brad Vincent](https://twitter.com/themergency). - -The homepage is based on a design as provided by [HTML5Up](http://html5up.net), the Boilerplate logo was designed by Rob McCaskill of [BungaWeb](http://bungaweb.com), and the site `favicon` was created by [Mickey Kay](https://twitter.com/McGuive7). - -## Documentation, FAQs, and More +Note that if you include your own classes, or third-party libraries, there is a location in which said files may go: -If you’re interested in writing any documentation or creating tutorials please [let me know](http://devinvinson.com/contact/) . +* `plugin-name/includes` From 8a215c27570b7568ffd61edce7944f89c9c2565a Mon Sep 17 00:00:00 2001 From: rezza007 Date: Thu, 28 May 2020 16:20:47 +0430 Subject: [PATCH 2/3] Minimized Plugin files --- plugin-name/admin/class-plugin-name-admin.php | 103 --------- plugin-name/admin/css/plugin-name-admin.css | 4 - plugin-name/admin/index.php | 1 - plugin-name/admin/js/plugin-name-admin.js | 32 --- .../partials/plugin-name-admin-display.php | 16 -- ...-name-public.php => class-plugin-name.php} | 24 +- plugin-name/css/plugin-name.css | 4 + .../includes/class-plugin-name-activator.php | 36 --- .../class-plugin-name-deactivator.php | 36 --- .../includes/class-plugin-name-loader.php | 129 ----------- plugin-name/includes/class-plugin-name.php | 218 ------------------ .../plugin-name.js} | 0 plugin-name/plugin-name.php | 185 ++++++++++++--- plugin-name/public/css/plugin-name-public.css | 4 - plugin-name/public/index.php | 1 - .../partials/plugin-name-public-display.php | 16 -- 16 files changed, 170 insertions(+), 639 deletions(-) delete mode 100644 plugin-name/admin/class-plugin-name-admin.php delete mode 100644 plugin-name/admin/css/plugin-name-admin.css delete mode 100644 plugin-name/admin/index.php delete mode 100644 plugin-name/admin/js/plugin-name-admin.js delete mode 100644 plugin-name/admin/partials/plugin-name-admin-display.php rename plugin-name/{public/class-plugin-name-public.php => class-plugin-name.php} (70%) create mode 100644 plugin-name/css/plugin-name.css delete mode 100644 plugin-name/includes/class-plugin-name-activator.php delete mode 100644 plugin-name/includes/class-plugin-name-deactivator.php delete mode 100644 plugin-name/includes/class-plugin-name-loader.php delete mode 100644 plugin-name/includes/class-plugin-name.php rename plugin-name/{public/js/plugin-name-public.js => js/plugin-name.js} (100%) delete mode 100644 plugin-name/public/css/plugin-name-public.css delete mode 100644 plugin-name/public/index.php delete mode 100644 plugin-name/public/partials/plugin-name-public-display.php diff --git a/plugin-name/admin/class-plugin-name-admin.php b/plugin-name/admin/class-plugin-name-admin.php deleted file mode 100644 index 3ef8d607a..000000000 --- a/plugin-name/admin/class-plugin-name-admin.php +++ /dev/null @@ -1,103 +0,0 @@ - - */ -class Plugin_Name_Admin { - - /** - * The ID of this plugin. - * - * @since 1.0.0 - * @access private - * @var string $plugin_name The ID of this plugin. - */ - private $plugin_name; - - /** - * The version of this plugin. - * - * @since 1.0.0 - * @access private - * @var string $version The current version of this plugin. - */ - private $version; - - /** - * Initialize the class and set its properties. - * - * @since 1.0.0 - * @param string $plugin_name The name of this plugin. - * @param string $version The version of this plugin. - */ - public function __construct( $plugin_name, $version ) { - - $this->plugin_name = $plugin_name; - $this->version = $version; - - } - - /** - * Register the stylesheets for the admin area. - * - * @since 1.0.0 - */ - public function enqueue_styles() { - - /** - * This function is provided for demonstration purposes only. - * - * An instance of this class should be passed to the run() function - * defined in Plugin_Name_Loader as all of the hooks are defined - * in that particular class. - * - * The Plugin_Name_Loader will then create the relationship - * between the defined hooks and the functions defined in this - * class. - */ - - wp_enqueue_style( $this->plugin_name, plugin_dir_url( __FILE__ ) . 'css/plugin-name-admin.css', array(), $this->version, 'all' ); - - } - - /** - * Register the JavaScript for the admin area. - * - * @since 1.0.0 - */ - public function enqueue_scripts() { - - /** - * This function is provided for demonstration purposes only. - * - * An instance of this class should be passed to the run() function - * defined in Plugin_Name_Loader as all of the hooks are defined - * in that particular class. - * - * The Plugin_Name_Loader will then create the relationship - * between the defined hooks and the functions defined in this - * class. - */ - - wp_enqueue_script( $this->plugin_name, plugin_dir_url( __FILE__ ) . 'js/plugin-name-admin.js', array( 'jquery' ), $this->version, false ); - - } - -} diff --git a/plugin-name/admin/css/plugin-name-admin.css b/plugin-name/admin/css/plugin-name-admin.css deleted file mode 100644 index 00c8c7f74..000000000 --- a/plugin-name/admin/css/plugin-name-admin.css +++ /dev/null @@ -1,4 +0,0 @@ -/** - * All of the CSS for your admin-specific functionality should be - * included in this file. - */ \ No newline at end of file diff --git a/plugin-name/admin/index.php b/plugin-name/admin/index.php deleted file mode 100644 index e71af0ef2..000000000 --- a/plugin-name/admin/index.php +++ /dev/null @@ -1 +0,0 @@ - - - diff --git a/plugin-name/public/class-plugin-name-public.php b/plugin-name/class-plugin-name.php similarity index 70% rename from plugin-name/public/class-plugin-name-public.php rename to plugin-name/class-plugin-name.php index 8336a3ad1..63bddd59b 100644 --- a/plugin-name/public/class-plugin-name-public.php +++ b/plugin-name/class-plugin-name.php @@ -1,26 +1,24 @@ */ -class Plugin_Name_Public { +class Plugin_Name { /** * The ID of this plugin. @@ -55,7 +53,7 @@ public function __construct( $plugin_name, $version ) { } /** - * Register the stylesheets for the public-facing side of the site. + * Register the stylesheets for the site. * * @since 1.0.0 */ @@ -64,16 +62,12 @@ public function enqueue_styles() { /** * This function is provided for demonstration purposes only. * - * An instance of this class should be passed to the run() function - * defined in Plugin_Name_Loader as all of the hooks are defined - * in that particular class. - * - * The Plugin_Name_Loader will then create the relationship + * The Plugin_Name_Init will then create the relationship * between the defined hooks and the functions defined in this * class. */ - wp_enqueue_style( $this->plugin_name, plugin_dir_url( __FILE__ ) . 'css/plugin-name-public.css', array(), $this->version, 'all' ); + wp_enqueue_style( $this->plugin_name, plugin_dir_url( __FILE__ ) . 'css/plugin-name.css', array(), $this->version, 'all' ); } @@ -88,7 +82,7 @@ public function enqueue_scripts() { * This function is provided for demonstration purposes only. * * An instance of this class should be passed to the run() function - * defined in Plugin_Name_Loader as all of the hooks are defined + * defined in Plugin_Name_Init as all of the hooks are defined * in that particular class. * * The Plugin_Name_Loader will then create the relationship @@ -96,7 +90,7 @@ public function enqueue_scripts() { * class. */ - wp_enqueue_script( $this->plugin_name, plugin_dir_url( __FILE__ ) . 'js/plugin-name-public.js', array( 'jquery' ), $this->version, false ); + wp_enqueue_script( $this->plugin_name, plugin_dir_url( __FILE__ ) . 'js/plugin-name.js', array( 'jquery' ), $this->version, false ); } diff --git a/plugin-name/css/plugin-name.css b/plugin-name/css/plugin-name.css new file mode 100644 index 000000000..5216ee129 --- /dev/null +++ b/plugin-name/css/plugin-name.css @@ -0,0 +1,4 @@ +/** + * All of the CSS for your facing functionality should be + * included in this file. + */ \ No newline at end of file diff --git a/plugin-name/includes/class-plugin-name-activator.php b/plugin-name/includes/class-plugin-name-activator.php deleted file mode 100644 index 475b78d01..000000000 --- a/plugin-name/includes/class-plugin-name-activator.php +++ /dev/null @@ -1,36 +0,0 @@ - - */ -class Plugin_Name_Activator { - - /** - * Short Description. (use period) - * - * Long Description. - * - * @since 1.0.0 - */ - public static function activate() { - - } - -} diff --git a/plugin-name/includes/class-plugin-name-deactivator.php b/plugin-name/includes/class-plugin-name-deactivator.php deleted file mode 100644 index 548795cff..000000000 --- a/plugin-name/includes/class-plugin-name-deactivator.php +++ /dev/null @@ -1,36 +0,0 @@ - - */ -class Plugin_Name_Deactivator { - - /** - * Short Description. (use period) - * - * Long Description. - * - * @since 1.0.0 - */ - public static function deactivate() { - - } - -} diff --git a/plugin-name/includes/class-plugin-name-loader.php b/plugin-name/includes/class-plugin-name-loader.php deleted file mode 100644 index 634ec4757..000000000 --- a/plugin-name/includes/class-plugin-name-loader.php +++ /dev/null @@ -1,129 +0,0 @@ - - */ -class Plugin_Name_Loader { - - /** - * The array of actions registered with WordPress. - * - * @since 1.0.0 - * @access protected - * @var array $actions The actions registered with WordPress to fire when the plugin loads. - */ - protected $actions; - - /** - * The array of filters registered with WordPress. - * - * @since 1.0.0 - * @access protected - * @var array $filters The filters registered with WordPress to fire when the plugin loads. - */ - protected $filters; - - /** - * Initialize the collections used to maintain the actions and filters. - * - * @since 1.0.0 - */ - public function __construct() { - - $this->actions = array(); - $this->filters = array(); - - } - - /** - * Add a new action to the collection to be registered with WordPress. - * - * @since 1.0.0 - * @param string $hook The name of the WordPress action that is being registered. - * @param object $component A reference to the instance of the object on which the action is defined. - * @param string $callback The name of the function definition on the $component. - * @param int $priority Optional. The priority at which the function should be fired. Default is 10. - * @param int $accepted_args Optional. The number of arguments that should be passed to the $callback. Default is 1. - */ - public function add_action( $hook, $component, $callback, $priority = 10, $accepted_args = 1 ) { - $this->actions = $this->add( $this->actions, $hook, $component, $callback, $priority, $accepted_args ); - } - - /** - * Add a new filter to the collection to be registered with WordPress. - * - * @since 1.0.0 - * @param string $hook The name of the WordPress filter that is being registered. - * @param object $component A reference to the instance of the object on which the filter is defined. - * @param string $callback The name of the function definition on the $component. - * @param int $priority Optional. The priority at which the function should be fired. Default is 10. - * @param int $accepted_args Optional. The number of arguments that should be passed to the $callback. Default is 1 - */ - public function add_filter( $hook, $component, $callback, $priority = 10, $accepted_args = 1 ) { - $this->filters = $this->add( $this->filters, $hook, $component, $callback, $priority, $accepted_args ); - } - - /** - * A utility function that is used to register the actions and hooks into a single - * collection. - * - * @since 1.0.0 - * @access private - * @param array $hooks The collection of hooks that is being registered (that is, actions or filters). - * @param string $hook The name of the WordPress filter that is being registered. - * @param object $component A reference to the instance of the object on which the filter is defined. - * @param string $callback The name of the function definition on the $component. - * @param int $priority The priority at which the function should be fired. - * @param int $accepted_args The number of arguments that should be passed to the $callback. - * @return array The collection of actions and filters registered with WordPress. - */ - private function add( $hooks, $hook, $component, $callback, $priority, $accepted_args ) { - - $hooks[] = array( - 'hook' => $hook, - 'component' => $component, - 'callback' => $callback, - 'priority' => $priority, - 'accepted_args' => $accepted_args - ); - - return $hooks; - - } - - /** - * Register the filters and actions with WordPress. - * - * @since 1.0.0 - */ - public function run() { - - foreach ( $this->filters as $hook ) { - add_filter( $hook['hook'], array( $hook['component'], $hook['callback'] ), $hook['priority'], $hook['accepted_args'] ); - } - - foreach ( $this->actions as $hook ) { - add_action( $hook['hook'], array( $hook['component'], $hook['callback'] ), $hook['priority'], $hook['accepted_args'] ); - } - - } - -} diff --git a/plugin-name/includes/class-plugin-name.php b/plugin-name/includes/class-plugin-name.php deleted file mode 100644 index 9906f3304..000000000 --- a/plugin-name/includes/class-plugin-name.php +++ /dev/null @@ -1,218 +0,0 @@ - - */ -class Plugin_Name { - - /** - * The loader that's responsible for maintaining and registering all hooks that power - * the plugin. - * - * @since 1.0.0 - * @access protected - * @var Plugin_Name_Loader $loader Maintains and registers all hooks for the plugin. - */ - protected $loader; - - /** - * The unique identifier of this plugin. - * - * @since 1.0.0 - * @access protected - * @var string $plugin_name The string used to uniquely identify this plugin. - */ - protected $plugin_name; - - /** - * The current version of the plugin. - * - * @since 1.0.0 - * @access protected - * @var string $version The current version of the plugin. - */ - protected $version; - - /** - * Define the core functionality of the plugin. - * - * Set the plugin name and the plugin version that can be used throughout the plugin. - * Load the dependencies, define the locale, and set the hooks for the admin area and - * the public-facing side of the site. - * - * @since 1.0.0 - */ - public function __construct() { - if ( defined( 'PLUGIN_NAME_VERSION' ) ) { - $this->version = PLUGIN_NAME_VERSION; - } else { - $this->version = '1.0.0'; - } - $this->plugin_name = 'plugin-name'; - - $this->load_dependencies(); - $this->set_locale(); - $this->define_admin_hooks(); - $this->define_public_hooks(); - - } - - /** - * Load the required dependencies for this plugin. - * - * 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 admin area. - * - 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 private - */ - 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 admin area. - */ - 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(); - - } - - /** - * Define the locale for this plugin for internationalization. - * - * Uses the Plugin_Name_i18n class in order to set the domain and to register the hook - * with WordPress. - * - * @since 1.0.0 - * @access private - */ - private function set_locale() { - - $plugin_i18n = new Plugin_Name_i18n(); - - $this->loader->add_action( 'plugins_loaded', $plugin_i18n, 'load_plugin_textdomain' ); - - } - - /** - * Register all of the hooks related to the admin area functionality - * of the plugin. - * - * @since 1.0.0 - * @access private - */ - private function define_admin_hooks() { - - $plugin_admin = new Plugin_Name_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 Plugin_Name_Public( $this->get_plugin_name(), $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' ); - - } - - /** - * Run the loader to execute all of the hooks with WordPress. - * - * @since 1.0.0 - */ - public function run() { - $this->loader->run(); - } - - /** - * The name 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_name; - } - - /** - * The reference to the class that orchestrates the hooks with the plugin. - * - * @since 1.0.0 - * @return Plugin_Name_Loader Orchestrates the hooks of the plugin. - */ - public function get_loader() { - return $this->loader; - } - - /** - * 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; - } - -} diff --git a/plugin-name/public/js/plugin-name-public.js b/plugin-name/js/plugin-name.js similarity index 100% rename from plugin-name/public/js/plugin-name-public.js rename to plugin-name/js/plugin-name.js diff --git a/plugin-name/plugin-name.php b/plugin-name/plugin-name.php index fbd8e6808..a24767053 100644 --- a/plugin-name/plugin-name.php +++ b/plugin-name/plugin-name.php @@ -38,31 +38,166 @@ define( 'PLUGIN_NAME_VERSION', '1.0.0' ); /** - * The code that runs during plugin activation. - * This action is documented in includes/class-plugin-name-activator.php + * The core plugin class that is used to define internationalization, + * admin-specific hooks, and public-facing site hooks. */ -function activate_plugin_name() { - require_once plugin_dir_path( __FILE__ ) . 'includes/class-plugin-name-activator.php'; - Plugin_Name_Activator::activate(); -} -/** - * The code that runs during plugin deactivation. - * This action is documented in includes/class-plugin-name-deactivator.php - */ -function deactivate_plugin_name() { - require_once plugin_dir_path( __FILE__ ) . 'includes/class-plugin-name-deactivator.php'; - Plugin_Name_Deactivator::deactivate(); -} +class Plugin_Name_Init { -register_activation_hook( __FILE__, 'activate_plugin_name' ); -register_deactivation_hook( __FILE__, 'deactivate_plugin_name' ); + /** + * The unique identifier of this plugin. + * + * @since 1.0.0 + * @access protected + * @var string $plugin_name The string used to uniquely identify this plugin. + */ + protected $plugin_name; -/** - * The core plugin class that is used to define internationalization, - * admin-specific hooks, and public-facing site hooks. - */ -require plugin_dir_path( __FILE__ ) . 'includes/class-plugin-name.php'; + /** + * The current version of the plugin. + * + * @since 1.0.0 + * @access protected + * @var string $version The current version of the plugin. + */ + protected $version; + + /** + * Define the core functionality of the plugin. + * + * Set the plugin name and the plugin version that can be used throughout the plugin. + * Load the dependencies, define the locale, and set the hooks for the admin area and + * the public-facing side of the site. + * + * @since 1.0.0 + */ + public function __construct() { + if ( defined( 'PLUGIN_NAME_VERSION' ) ) { + $version = PLUGIN_NAME_VERSION; + } else { + $version = '1.0.0'; + } + $plugin_name = 'plugin-name'; + + register_activation_hook( __FILE__, array($this, 'activate_plugin_name') ); + register_deactivation_hook( __FILE__, array($this, 'deactivate_plugin_name') ); + + $this->load_dependencies(); + $this->set_locale(); + $this->define_hooks(); + } + + /** + * Load the required dependencies for this plugin. + * + * Include the following files that make up the plugin: + * + * - Plugin_Name_i18n. Defines internationalization functionality. + * + * @since 1.0.0 + * @access private + */ + private function load_dependencies() { + + /** + * The class responsible for defining internationalization functionality + * of the plugin. + */ + require_once plugin_dir_path( __FILE__ ) . 'includes/class-plugin-name-i18n.php'; + + /** + * The class responsible for defining all actions that occur. + */ + require_once plugin_dir_path( __FILE__ ) . 'class-plugin-name.php'; + + } + + /** + * Define the locale for this plugin for internationalization. + * + * Uses the Plugin_Name_i18n class in order to set the domain and to register the hook + * with WordPress. + * + * @since 1.0.0 + * @access private + */ + private function set_locale() { + + $plugin_i18n = new Plugin_Name_i18n(); + + add_action( 'plugins_loaded', array($plugin_i18n, 'load_plugin_textdomain')); + + } + + /** + * Register the hooks of the plugin. + * + * @since 1.0.0 + * @access private + */ + private function define_hooks() { + + $plugin = new Plugin_Name( $this->get_plugin_name(), $this->get_version() ); + + add_action( 'admin_enqueue_scripts', array($plugin, 'enqueue_styles') ); + add_action( 'admin_enqueue_scripts', array($plugin, 'enqueue_scripts') ); + + /** + * The following lines will load public Front-end CSS/JS. + * In case of use, files should be created and methods should be implemented, + * Methods defined for 'admin_enqueue_scripts' hook could be used as templates. + */ + // add_action( 'wp_enqueue_scripts', array($plugin, 'enqueue_public_styles') ); + // add_action( 'wp_enqueue_scripts', array($plugin, 'enqueue_public_scripts') ); + + } + + /** + * The name 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_name; + } + + /** + * 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; + } + + /** + * The code that runs during plugin activation. + */ + function activate_plugin_name() { + /** + * Fired during plugin activation. + * + * This class defines all code necessary to run during the plugin's activation. + * + * + */ + } + + /** + * The code that runs during plugin deactivation. + */ + function deactivate_plugin_name() { + /** + * Fired during plugin deactivation. + * + * This class defines all code necessary to run during the plugin's deactivation. + */ + } + +} /** * Begins execution of the plugin. @@ -73,10 +208,4 @@ function deactivate_plugin_name() { * * @since 1.0.0 */ -function run_plugin_name() { - - $plugin = new Plugin_Name(); - $plugin->run(); - -} -run_plugin_name(); +$plugin = new Plugin_Name_Init(); diff --git a/plugin-name/public/css/plugin-name-public.css b/plugin-name/public/css/plugin-name-public.css deleted file mode 100644 index 65bbf9630..000000000 --- a/plugin-name/public/css/plugin-name-public.css +++ /dev/null @@ -1,4 +0,0 @@ -/** - * All of the CSS for your public-facing functionality should be - * included in this file. - */ \ No newline at end of file diff --git a/plugin-name/public/index.php b/plugin-name/public/index.php deleted file mode 100644 index e71af0ef2..000000000 --- a/plugin-name/public/index.php +++ /dev/null @@ -1 +0,0 @@ - - - From 251388345eba9d173903af8d1a6a8c4a9b4a354a Mon Sep 17 00:00:00 2001 From: Reza Latifi Date: Wed, 19 Aug 2020 01:58:40 +0430 Subject: [PATCH 3/3] Update plugin-name.php --- plugin-name/plugin-name.php | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/plugin-name/plugin-name.php b/plugin-name/plugin-name.php index a24767053..5ad68869a 100644 --- a/plugin-name/plugin-name.php +++ b/plugin-name/plugin-name.php @@ -138,17 +138,14 @@ private function set_locale() { private function define_hooks() { $plugin = new Plugin_Name( $this->get_plugin_name(), $this->get_version() ); - - add_action( 'admin_enqueue_scripts', array($plugin, 'enqueue_styles') ); - add_action( 'admin_enqueue_scripts', array($plugin, 'enqueue_scripts') ); /** * The following lines will load public Front-end CSS/JS. * In case of use, files should be created and methods should be implemented, * Methods defined for 'admin_enqueue_scripts' hook could be used as templates. */ - // add_action( 'wp_enqueue_scripts', array($plugin, 'enqueue_public_styles') ); - // add_action( 'wp_enqueue_scripts', array($plugin, 'enqueue_public_scripts') ); + add_action( 'admin_enqueue_scripts', array($plugin, 'enqueue_styles') ); + add_action( 'admin_enqueue_scripts', array($plugin, 'enqueue_scripts') ); }