Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 0 additions & 12 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,23 +5,11 @@
"license": "GPL-2.0",
"require": {
"composer/installers": "^1.4",
"xrstf/composer-php52": "^1.0",
"gamajo/template-loader": "^1.3"
},
"autoload": {
"classmap": [
"includes"
]
},
"scripts": {
"post-install-cmd": [
"xrstf\\Composer52\\Generator::onPostInstallCmd"
],
"post-update-cmd": [
"xrstf\\Composer52\\Generator::onPostInstallCmd"
],
"post-autoload-dump": [
"xrstf\\Composer52\\Generator::onPostInstallCmd"
]
}
}
12 changes: 11 additions & 1 deletion includes/class-cli.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@
<?php
/**
* File that declares CLI access to the plugin.
*
* @package Mindsize\WP_Plugin_Base
*/

namespace Mindsize\WP_Plugin_Base;

use WP_CLI_Command;
Expand Down Expand Up @@ -26,7 +32,11 @@
* pong
*/
class CLI extends WP_CLI_Command {

/**
* Example WPCLI method that responds to a command.
*
* @return void
*/
public function ping() {
WP_CLI::line( 'pong' );
}
Expand Down
10 changes: 10 additions & 0 deletions includes/class-core.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@
<?php
/**
* Main plugin class file.
*
* @package Mindsize\WP_Plugin_Base
*/

namespace Mindsize\WP_Plugin_Base;

use WP_CLI;
Expand All @@ -17,6 +23,8 @@ class Core {

/**
* Container for template loader instance.
*
* @var $template_loader Will hold an instance of Template_Loader.
*/
protected $template_loader;

Expand All @@ -33,6 +41,8 @@ public function init() {

/**
* Template loader
*
* @return Template_Loader
*/
public function template_loader() {
return $this->template_loader;
Expand Down
6 changes: 6 additions & 0 deletions includes/class-template-loader.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@
<?php
/**
* File that holds the template loader class.
*
* @package Mindsize\WP_Plugin_Base
*/

namespace Mindsize\WP_Plugin_Base;

use Gamajo_Template_Loader;
Expand Down
14 changes: 14 additions & 0 deletions includes/class-wp-plugin-factory.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,12 @@
<?php
/**
* File that holds the WP Plugin Factory.
*
* It implements a shared instance. Functional access calls this
* which returns a stored instance of a plugin.
*
* @package Mindsize\WP_Plugin_Base
*/
namespace Mindsize\WP_Plugin_Base;

/**
Expand All @@ -10,6 +18,12 @@
* @license http://www.gnu.org/licenses/gpl-2.0.html GNU General Public License v2.0
*/
class WP_Plugin_Factory {
/**
* Method that either creates an instance of Core, or returns the
* previously created instance of Core.
*
* @return Core
*/
public static function create() {
static $plugin = null;

Expand Down
11 changes: 11 additions & 0 deletions phpcs.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<?xml version="1.0"?>
<ruleset name="Mindsize Ruleset">
<description>Apply WordPress Coding Standards to all plugin and theme files</description>

<rule ref="WordPress-Extra"/>
<rule ref="WordPress-Docs"/>
<exclude-pattern>/node_modules/*</exclude-pattern>
<exclude-pattern>/wp-content/vendor/*</exclude-pattern>
<exclude-pattern>/vendor/*</exclude-pattern>
<exclude-pattern>/cms/*</exclude-pattern>
</ruleset>
25 changes: 21 additions & 4 deletions wp-plugin-base.php
Original file line number Diff line number Diff line change
@@ -1,26 +1,38 @@
<?php
namespace Mindsize\WP_Plugin_Base;

/**
* Main entry point to the plugin.
*
* Plugin Name: WordPress Plugin Base
* Description: This is a sample plugin that was created with mindsize/wp-plugin-base
* Author: Mindsize
* Author URI: http://mindsize.me
* Version: 1.0.0
* Requires at least: 4.4
* Tested up to: 4.8
*
* @package Mindsize\WP_Plugin_Base
*/

namespace Mindsize\WP_Plugin_Base;

define( 'WP_PLUGIN_BASE_VERSION', '1.0.0' );
define( 'WP_PLUGIN_BASE_SLUG', 'wp-plugin-base' );
define( 'WP_PLUGIN_BASE_FILE', __FILE__ );
define( 'WP_PLUGIN_BASE_DIR', plugin_dir_path( WP_PLUGIN_BASE_FILE ) );
define( 'WP_PLUGIN_BASE_URL', plugin_dir_url( WP_PLUGIN_BASE_FILE ) );

if ( file_exists( WP_PLUGIN_BASE_DIR . 'vendor/autoload_52.php' ) ) {
require_once WP_PLUGIN_BASE_DIR . 'vendor/autoload_52.php';
if ( file_exists( WP_PLUGIN_BASE_DIR . 'vendor/autoload.php' ) ) {
require_once WP_PLUGIN_BASE_DIR . 'vendor/autoload.php';
}

/**
* Function access to the shared instance of the plugin.
*
* Used in lieu of a singleton.
*
* @throws \Exception In case the WP_Plugin_Factory class is not found.
* @return Core
*/
function wp_plugin_base() {
if ( ! class_exists( __NAMESPACE__ . '\\WP_Plugin_Factory' ) ) {
throw new \Exception( __NAMESPACE__ . '\\WP_Plugin_Factory class cannot be found.' );
Expand All @@ -29,6 +41,11 @@ function wp_plugin_base() {
return WP_Plugin_Factory::create();
}

/**
* Function that's hooked into plugins loaded.
*
* @return void
*/
function load_plugin() {
$instance = wp_plugin_base();
$instance->init();
Expand Down