-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
10 changed files
with
391 additions
and
103 deletions.
There are no files selected for viewing
10 changes: 0 additions & 10 deletions
10
lib/wordpress-phoenix/abstract-plugin-base/.circleci/codesniffer.ruleset.xml
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
47 changes: 47 additions & 0 deletions
47
lib/wordpress-phoenix/abstract-plugin-base/.circleci/phpcs.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
<?xml version="1.0"?> | ||
<ruleset name="wpphx"> | ||
<description>phpcs ruleset, based on WordPress Core and VIP standards.</description> | ||
|
||
<!-- Exclude specific Composer-related directories from linting. --> | ||
<exclude-pattern>*/vendor/*</exclude-pattern> | ||
<exclude-pattern>*/lib/index.php</exclude-pattern> | ||
<exclude-pattern>*/lib/autoload.php</exclude-pattern> | ||
<exclude-pattern>*/lib/bin/*</exclude-pattern> | ||
<exclude-pattern>*/lib/composer/*</exclude-pattern> | ||
|
||
<!-- Exclude static assets from linting. --> | ||
<exclude-pattern>*/assets/*</exclude-pattern> | ||
<exclude-pattern>*\.(css|js|xml)</exclude-pattern> | ||
<exclude-pattern>*/node_modules/*</exclude-pattern> | ||
|
||
<!-- Don't fail in CI if there are warnings. --> | ||
<config name="ignore_warnings_on_exit" value="1" /> | ||
|
||
<!-- Only worry about WordPress 5.0+. --> | ||
<config name="minimum_supported_wp_version" value="5.0" /> | ||
|
||
<rule ref="WordPress"> | ||
<exclude name="WordPress.WhiteSpace.PrecisionAlignment.Found" /> | ||
</rule> | ||
|
||
<rule ref="WordPress-Core"></rule> | ||
|
||
<rule ref="WordPress-VIP"> | ||
<exclude name="WordPress.VIP.SuperGlobalInputUsage" /> | ||
<exclude name="WordPress.VIP.RestrictedFunctions.switch_to_blog" /> | ||
<exclude name="WordPress.VIP.RestrictedFunctions.get_page_by_title" /> | ||
<exclude name="WordPress.VIP.RestrictedFunctions.get_page_by_title_get_page_by_title" /> | ||
</rule> | ||
|
||
<rule ref="WordPress.Files.FileName.InvalidClassFileName"> | ||
<exclude-pattern>/lib/*</exclude-pattern> | ||
<exclude-pattern>/src/*</exclude-pattern> | ||
</rule> | ||
|
||
<!-- Prevent empty lines at the start or end of control structures. --> | ||
<rule ref="WordPress.WhiteSpace.ControlStructureSpacing"> | ||
<properties> | ||
<property name="blank_line_check" value="true" /> | ||
</properties> | ||
</rule> | ||
</ruleset> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
root = true | ||
|
||
[*] | ||
indent_size = 4 | ||
indent_style = tab | ||
|
||
[*.{json,yml}] | ||
indent_size = 2 | ||
indent_style = space |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,2 @@ | ||
.idea/ | ||
vendor/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,109 +1,121 @@ | ||
# Abstract Plugin Base | ||
|
||
Used as a base class to help standardize the way we build WordPress plugins. | ||
|
||
CircleCI Build: [![CircleCI](https://circleci.com/gh/WordPress-Phoenix/abstract-plugin-base.svg?style=svg)](https://circleci.com/gh/WordPress-Phoenix/abstract-plugin-base) | ||
|
||
# WordPress Options Builder Class Library | ||
|
||
WordPress options builder class is a library that helps you setup theme or plugin options that store data in the database with just a line or two of code! | ||
## Table of Contents | ||
|
||
## Table of Contents: | ||
- [Installation](#installation) | ||
- [Usage](#usage) | ||
* [Installation](#installation) | ||
* [Usage](#usage) | ||
|
||
# Installation | ||
## Installation | ||
|
||
You can use this library to start a new plugin from scratch, or you can enhance your existing plugins with this library. Once you have read over the installation instructions it should make sense which direction to go. | ||
|
||
## Composer style (recommended) | ||
1. Confirm that composer is installed in your development environment using `which composer`. If CLI does not print any path, you need to install composer like `brew install composer`. | ||
2. Set CLI working directory to wp-content/plugins/{your-plugin-name} | ||
3. Install Abstract_Plugin class via composer command line like | ||
```bash | ||
composer require WordPress-Phoenix/abstract-plugin-base && composer install | ||
``` | ||
4. Look at sample code below to see how to include this library in your plugin. | ||
### Composer style (recommended) | ||
|
||
1. Confirm that composer is installed in your development environment using `which composer`. If CLI does not print any path, you need to [install Composer](https://getcomposer.org/download/). | ||
2. Set CLI working directory to wp-content/plugins/{your-plugin-name} | ||
3. Install Abstract_Plugin class via composer command line like | ||
```bash | ||
composer require wordpress-phoenix/abstract-plugin-base | ||
``` | ||
4. Look at sample code below to see how to include this library in your plugin. | ||
|
||
### Manual Installation | ||
|
||
1. Download the most updated copy of this repository from `https://api.github.com/repos/WordPress-Phoenix/abstract-plugin-base/zipball` | ||
2. Extract the zip file, and copy the PHP file into your plugin project. | ||
3. Include the file in your plugin. | ||
|
||
## Usage | ||
|
||
## Manual Installation | ||
1. Download the most updated copy of this repository from `https://api.github.com/repos/WordPress-Phoenix/abstract-plugin-base/zipball` | ||
2. Extract the zip file, and copy the PHP file into your plugin project. | ||
3. Use SSI (Server Side Includes) to include the file into your plugin. | ||
### Why should you use this library when building your plugin? | ||
By building your plugin using OOP principals, and extending this Plugin_Base class object, you will be able to quickly and efficiently build your plugin, allowing it to be simple to start, but giving it the ability to grow complex without changing its architecture. | ||
|
||
# Usage | ||
Immediate features include: | ||
|
||
## Why should you use this library when building your plugin? | ||
By building your plugin using OOP principals, and extending this Plugin_Base class object, you will be able to quickly and efficiently build | ||
your plugin, allowing it to be simple to start, but giving it the ability to grow complex without changing its architecture. Immediate | ||
features include: | ||
- Built in SPL Autoload for your includes folder, should you follow WordPress codex naming standards for class files. | ||
- Template class provides you all the best practices for standard plugin initialization | ||
- Minimizes code needed / maintenance of your main plugin file. | ||
- Assists developers new to WordPress plugin development in file / folder architecture. | ||
- By starting all your plugins with the same architecture, we create a standard that is better for the dev community. | ||
* Built in SPL Autoload for your includes folder, should you follow WordPress codex naming standards for class files. | ||
* Template class provides you all the best practices for standard plugin initialization | ||
* Minimizes code needed / maintenance of your main plugin file. | ||
* Assists developers new to WordPress plugin development in file / folder architecture. | ||
* By starting all your plugins with the same architecture, we create a standard that is better for the dev community. | ||
|
||
## Simplest example of the main plugin file, and required plugin class file | ||
### Simplest example of the main plugin file, and required plugin class file | ||
|
||
`custom-my-plugin.php`: | ||
|
||
custom-my-plugin.php | ||
```php | ||
<?php | ||
/** | ||
* Plugin Name: Custom My Plugin | ||
* Plugin URI: https://github.com/ | ||
*/ | ||
//avoid direct calls to this file, because now WP core and framework has been used | ||
// Avoid direct calls to this file, because now WP core and framework has been used | ||
if ( ! function_exists( 'add_filter' ) ) { | ||
header( 'Status: 403 Forbidden' ); | ||
header( 'HTTP/1.1 403 Forbidden' ); | ||
exit(); | ||
} | ||
// Create plugin instance on plugins_loaded action to maximize flexibility of wp hooks and filters system. | ||
include_once 'vendor/autoload.php'; | ||
include_once 'app/class-my-plugin.php'; | ||
Custom\My_Plugin\App::run( __FILE__ ); | ||
Custom\My_Plugin\App::run( __FILE__ ); | ||
``` | ||
app/class-app.php | ||
`app/class-app.php`: | ||
```php | ||
<?php | ||
namespace Custom\My_Plugin; | ||
use WPAZ_Plugin_Base\V_2_5\Abstract_Plugin; | ||
use WPAZ_Plugin_Base\V_2_6\Abstract_Plugin; | ||
/** | ||
* Class App | ||
*/ | ||
class App extends Abstract_Plugin { | ||
|
||
public static $autoload_class_prefix = __NAMESPACE__; | ||
protected static $current_file = __FILE__; | ||
public static $autoload_type = 'psr-4'; | ||
// Set to 2 when you use 2 namespaces in the main app file | ||
public static $autoload_ns_match_depth = 2; | ||
|
||
public function onload( $instance ) { | ||
// Nothing yet | ||
} // END public function __construct | ||
|
||
public function init() { | ||
do_action( get_called_class() . '_before_init' ); | ||
// Do plugin stuff usually looks something like | ||
// $subclass = new OptionalAppSubfolder/Custom_Class_Subclass(); | ||
// $subclass->custom_plugin_function(); | ||
do_action( get_called_class() . '_after_init' ); | ||
} | ||
|
||
public function authenticated_init() { | ||
if ( is_user_logged_in() ) { | ||
// Ready for wp-admin - but not required | ||
//$this->admin = new Admin/App( $this ); | ||
} | ||
} | ||
|
||
protected function defines_and_globals() { | ||
// None yet. | ||
} | ||
|
||
} // END class | ||
public static $autoload_class_prefix = __NAMESPACE__; | ||
protected static $current_file = __FILE__; | ||
public static $autoload_type = 'psr-4'; | ||
// Set to 2 when you use 2 namespaces in the main app file | ||
public static $autoload_ns_match_depth = 2; | ||
public function onload( $instance ) { | ||
// Nothing yet | ||
} | ||
public function init() { | ||
do_action( static::class . '_before_init' ); | ||
// Do plugin stuff usually looks something like | ||
// $subclass = new OptionalAppSubfolder\Custom_Class_Subclass(); | ||
// $subclass->custom_plugin_function(); | ||
do_action( static::class . '_after_init' ); | ||
} | ||
public function authenticated_init() { | ||
if ( ! is_user_logged_in() ) { | ||
return; | ||
} | ||
// Ready for wp-admin - but not required | ||
//$this->admin = new Admin\App( $this ); | ||
} | ||
protected function defines_and_globals() { | ||
// None yet. | ||
} | ||
} | ||
``` |
12 changes: 0 additions & 12 deletions
12
lib/wordpress-phoenix/abstract-plugin-base/composer-test.json
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.