diff --git a/.gitignore b/.gitignore index dfd6caa..6cf07ac 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,6 @@ /vendor -composer.lock \ No newline at end of file +/composer.lock +/*.sublime-project +/*.sublime-workspace +/.phpcs.xml +/phpcs.xml diff --git a/README.md b/README.md index f62b7f7..b6bb9d0 100644 --- a/README.md +++ b/README.md @@ -48,4 +48,4 @@ After cloning this repository, run `composer install` in the root directory of t ### From Packaged Releases on WordPress.org -Packaged releases on WordPress.org will automatically include the required autoloaders. \ No newline at end of file +Packaged releases on WordPress.org will automatically include the required autoloaders. diff --git a/bootstrap.php b/bootstrap.php new file mode 100644 index 0000000..9667196 --- /dev/null +++ b/bootstrap.php @@ -0,0 +1,19 @@ +init(); +} diff --git a/composer.json b/composer.json index c1de9de..7dd5f77 100644 --- a/composer.json +++ b/composer.json @@ -4,8 +4,6 @@ "type": "wordpress-plugin", "license": "GPL-2.0", "require": { - "composer/installers": "^1.4", - "xrstf/composer-php52": "^1.0", "gamajo/template-loader": "^1.3" }, "autoload": { @@ -13,15 +11,8 @@ "includes" ] }, - "scripts": { - "post-install-cmd": [ - "xrstf\\Composer52\\Generator::onPostInstallCmd" - ], - "post-update-cmd": [ - "xrstf\\Composer52\\Generator::onPostInstallCmd" - ], - "post-autoload-dump": [ - "xrstf\\Composer52\\Generator::onPostInstallCmd" - ] + "require-dev": { + "phpro/grumphp": "^0.14.1", + "squizlabs/php_codesniffer": "^3.3" } } diff --git a/grumphp.yml b/grumphp.yml new file mode 100644 index 0000000..e523a4c --- /dev/null +++ b/grumphp.yml @@ -0,0 +1,6 @@ +parameters: + hide_circumvention_tip: true + ignore_unstaged_changes: true + tasks: + phpcs: + standard: null diff --git a/includes/class-cli.php b/includes/CLI.php similarity index 80% rename from includes/class-cli.php rename to includes/CLI.php index b14c7d7..0fd7b34 100644 --- a/includes/class-cli.php +++ b/includes/CLI.php @@ -4,10 +4,6 @@ use WP_CLI_Command; use WP_CLI; -if ( ! class_exists( 'WP_CLI_Command' ) ) { - return; -} - /** * CLI access to the sample plugin. * @@ -25,10 +21,10 @@ * $ wp wp-plugin-base ping * pong */ -class CLI extends WP_CLI_Command { - - public function ping() { - WP_CLI::line( 'pong' ); - } - +class CLI extends WP_CLI_Command +{ + public function ping() + { + WP_CLI::line('pong'); + } } diff --git a/includes/Core.php b/includes/Core.php new file mode 100644 index 0000000..80d55fb --- /dev/null +++ b/includes/Core.php @@ -0,0 +1,43 @@ + + * @copyright Copyright (c) 2017 Mindsize + * @license http://www.gnu.org/licenses/gpl-2.0.html GNU General Public License v2.0 + */ +class Core +{ + + /** + * Container for template loader instance. + */ + protected $template_loader; + + /** + * Constructor. + */ + public function init() + { + if (defined('WP_CLI') && WP_CLI && class_exists('WP_CLI_Command')) { + WP_CLI::add_command(WP_PLUGIN_BASE_SLUG, __NAMESPACE__ . '\\CLI'); + } + + $this->template_loader = new TemplateLoader(); + } + + /** + * Template loader + */ + public function templateLoader() + { + return $this->template_loader; + } +} diff --git a/includes/class-wp-plugin-factory.php b/includes/PluginFactory.php similarity index 63% rename from includes/class-wp-plugin-factory.php rename to includes/PluginFactory.php index 4c85a76..c38cf5e 100644 --- a/includes/class-wp-plugin-factory.php +++ b/includes/PluginFactory.php @@ -9,14 +9,16 @@ * @copyright Copyright (c) 2017 Mindsize * @license http://www.gnu.org/licenses/gpl-2.0.html GNU General Public License v2.0 */ -class WP_Plugin_Factory { - public static function create() { - static $plugin = null; +class PluginFactory +{ + public static function create() + { + static $plugin = null; - if ( null === $plugin ) { - $plugin = new Core(); - } + if (null === $plugin) { + $plugin = new Core(); + } - return $plugin; - } + return $plugin; + } } diff --git a/includes/TemplateLoader.php b/includes/TemplateLoader.php new file mode 100644 index 0000000..054dbf5 --- /dev/null +++ b/includes/TemplateLoader.php @@ -0,0 +1,58 @@ + + * @copyright Copyright (c) 2017 Mindsize + * @license http://www.gnu.org/licenses/gpl-2.0.html GNU General Public License v2.0 + */ +class TemplateLoader extends Gamajo_Template_Loader +{ + + /** + * Prefix for filter names. + * + * @since 1.0.0 + * + * @var string + */ + protected $filter_prefix = WP_PLUGIN_BASE_SLUG; + + /** + * Directory name where custom templates for this plugin should be found in the theme. + * + * @since 1.0.0 + * + * @var string + */ + protected $theme_template_directory = WP_PLUGIN_BASE_SLUG; + + /** + * Reference to the root directory path of this plugin. + * + * Can either be a defined constant, or a relative reference from where the subclass lives. + * + * @since 1.0.0 + * + * @var string + */ + protected $plugin_directory = WP_PLUGIN_BASE_DIR; + + /** + * Directory name where templates are found in this plugin. + * + * Can either be a defined constant, or a relative reference from where the subclass lives. + * + * e.g. 'templates' or 'includes/templates', etc. + * + * @since 1.1.0 + * + * @var string + */ + protected $plugin_template_directory = 'templates'; +} diff --git a/includes/class-core.php b/includes/class-core.php deleted file mode 100644 index 60cede2..0000000 --- a/includes/class-core.php +++ /dev/null @@ -1,40 +0,0 @@ - - * @copyright Copyright (c) 2017 Mindsize - * @license http://www.gnu.org/licenses/gpl-2.0.html GNU General Public License v2.0 - */ -class Core { - - /** - * Container for template loader instance. - */ - protected $template_loader; - - /** - * Constructor. - */ - public function init() { - if ( defined( 'WP_CLI' ) && WP_CLI ) { - WP_CLI::add_command( WP_PLUGIN_BASE_SLUG, __NAMESPACE__ . '\\CLI' ); - } - - $this->template_loader = new Template_Loader(); - } - - /** - * Template loader - */ - public function template_loader() { - return $this->template_loader; - } -} diff --git a/includes/class-template-loader.php b/includes/class-template-loader.php deleted file mode 100644 index f34547c..0000000 --- a/includes/class-template-loader.php +++ /dev/null @@ -1,57 +0,0 @@ - - * @copyright Copyright (c) 2017 Mindsize - * @license http://www.gnu.org/licenses/gpl-2.0.html GNU General Public License v2.0 - */ -class Template_Loader extends Gamajo_Template_Loader { - - /** - * Prefix for filter names. - * - * @since 1.0.0 - * - * @var string - */ - protected $filter_prefix = WP_PLUGIN_BASE_SLUG; - - /** - * Directory name where custom templates for this plugin should be found in the theme. - * - * @since 1.0.0 - * - * @var string - */ - protected $theme_template_directory = WP_PLUGIN_BASE_SLUG; - - /** - * Reference to the root directory path of this plugin. - * - * Can either be a defined constant, or a relative reference from where the subclass lives. - * - * @since 1.0.0 - * - * @var string - */ - protected $plugin_directory = WP_PLUGIN_BASE_DIR; - - /** - * Directory name where templates are found in this plugin. - * - * Can either be a defined constant, or a relative reference from where the subclass lives. - * - * e.g. 'templates' or 'includes/templates', etc. - * - * @since 1.1.0 - * - * @var string - */ - protected $plugin_template_directory = 'templates'; -} diff --git a/phpcs.xml.dist b/phpcs.xml.dist new file mode 100644 index 0000000..fb4d273 --- /dev/null +++ b/phpcs.xml.dist @@ -0,0 +1,6 @@ + + + Override to always use PSR2 for this project. + + + diff --git a/wp-plugin-base.php b/wp-plugin-base.php index c77d5cb..70a45bc 100644 --- a/wp-plugin-base.php +++ b/wp-plugin-base.php @@ -1,9 +1,7 @@ init(); -} +require_once 'vendor/autoload.php'; +require_once 'bootstrap.php'; -add_action( 'plugins_loaded', __NAMESPACE__ . '\\load_plugin' ); +add_action('plugins_loaded', __NAMESPACE__ . '\\load_plugin');