2017 © Pedro Peláez
 

library abstract-plugin-base

PHP class to extend when building a WordPress plugin allowing you to follow smart plugin setup standards.

image

wordpress-phoenix/abstract-plugin-base

PHP class to extend when building a WordPress plugin allowing you to follow smart plugin setup standards.

  • Friday, May 18, 2018
  • by sethcarstens
  • Repository
  • 6 Watchers
  • 8 Stars
  • 328 Installations
  • PHP
  • 1 Dependents
  • 0 Suggesters
  • 0 Forks
  • 2 Open issues
  • 28 Versions
  • 16 % Grown

The README.md

Abstract Plugin Base

Used as a base class to help standardize the way we build WordPress plugins., (*1)

CircleCI Build: CircleCI, (*2)

Table of Contents

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., (*3)

  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.
  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

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., (*4)

Immediate features include:, (*5)

  • 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

custom-my-plugin.php:, (*6)

<?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
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__ );

app/class-app.php:, (*7)

<?php

namespace Custom\My_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
    }

    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.
    }

}

The Versions

18/05 2018

dev-master

9999999-dev https://github.com/WordPress-Phoenix/abstract-plugin-base

PHP class to extend when building a WordPress plugin allowing you to follow smart plugin setup standards.

  Sources   Download

GPL-v3 GPL-3.0-or-later

plugin wordpress boilerplate abstract standardize

18/05 2018

dev-develop

dev-develop https://github.com/WordPress-Phoenix/abstract-plugin-base

PHP class to extend when building a WordPress plugin allowing you to follow smart plugin setup standards.

  Sources   Download

GPL-v3 GPL-3.0-or-later

plugin wordpress boilerplate abstract standardize

18/05 2018

dev-mlteal-update-readme

dev-mlteal-update-readme https://github.com/WordPress-Phoenix/abstract-plugin-base

PHP class to extend when building a WordPress plugin allowing you to follow smart plugin setup standards.

  Sources   Download

GPL-3.0-or-later

plugin wordpress boilerplate abstract standardize

22/03 2018

2.6.2

2.6.2.0 https://github.com/WordPress-Phoenix/abstract-plugin-base

PHP class to extend when building a WordPress plugin allowing you to follow smart plugin setup standards.

  Sources   Download

GPL-3.0-or-later

plugin wordpress boilerplate abstract standardize

06/03 2018

dev-dbr-propose-ajax-handling

dev-dbr-propose-ajax-handling https://github.com/WordPress-Phoenix/abstract-plugin-base

PHP class to extend when building a WordPress plugin allowing you to follow smart plugin setup standards.

  Sources   Download

GPL-3.0-or-later

plugin wordpress boilerplate abstract standardize

06/03 2018

2.6.1

2.6.1.0 https://github.com/WordPress-Phoenix/abstract-plugin-base

PHP class to extend when building a WordPress plugin allowing you to follow smart plugin setup standards.

  Sources   Download

GPL-3.0-or-later

plugin wordpress boilerplate abstract standardize

06/03 2018

dev-update-to-slugfix

dev-update-to-slugfix https://github.com/WordPress-Phoenix/abstract-plugin-base

PHP class to extend when building a WordPress plugin allowing you to follow smart plugin setup standards.

  Sources   Download

GPL-3.0-or-later

plugin wordpress boilerplate abstract standardize

06/03 2018

2.6.0

2.6.0.0 https://github.com/WordPress-Phoenix/abstract-plugin-base

PHP class to extend when building a WordPress plugin allowing you to follow smart plugin setup standards.

  Sources   Download

GPL-3.0-or-later

plugin wordpress boilerplate abstract standardize

01/02 2018

2.5.3.x-dev

2.5.3.9999999-dev https://github.com/WordPress-Phoenix/abstract-plugin-base

PHP class to extend when building a WordPress plugin allowing you to follow smart plugin setup standards.

  Sources   Download

GPL-3.0-or-later

plugin wordpress boilerplate abstract standardize

18/01 2018

2.5.3

2.5.3.0 https://github.com/WordPress-Phoenix/abstract-plugin-base

PHP class to extend when building a WordPress plugin allowing you to follow smart plugin setup standards.

  Sources   Download

GPL-v3

plugin wordpress boilerplate abstract standardize

01/09 2017

2.5.2

2.5.2.0 https://github.com/WordPress-Phoenix/abstract-plugin-base

PHP class to extend when building a WordPress plugin allowing you to follow smart plugin setup standards.

  Sources   Download

GPL-v3

plugin wordpress boilerplate abstract standardize

28/07 2017

2.5.1

2.5.1.0 https://github.com/WordPress-Phoenix/abstract-plugin-base

PHP class to extend when building a WordPress plugin allowing you to follow smart plugin setup standards.

  Sources   Download

GPL-v3

plugin wordpress boilerplate abstract standardize

27/07 2017

2.5.0

2.5.0.0 https://github.com/WordPress-Phoenix/abstract-plugin-base

PHP class to extend when building a WordPress plugin allowing you to follow smart plugin setup standards.

  Sources   Download

GPL-v3

plugin wordpress boilerplate abstract standardize

29/06 2017

2.4.0

2.4.0.0 https://github.com/WordPress-Phoenix/abstract-plugin-base

PHP class to extend when building a WordPress plugin allowing you to follow smart plugin setup standards.

  Sources   Download

GPL-v3

plugin wordpress boilerplate abstract standardize

28/06 2017

2.3.1

2.3.1.0 https://github.com/WordPress-Phoenix/abstract-plugin-base

PHP class to extend when building a WordPress plugin allowing you to follow smart plugin setup standards.

  Sources   Download

GPL-v3

plugin wordpress boilerplate abstract standardize

24/06 2017

2.3.0

2.3.0.0 https://github.com/WordPress-Phoenix/abstract-plugin-base

PHP class to extend when building a WordPress plugin allowing you to follow smart plugin setup standards.

  Sources   Download

GPL-v3

plugin wordpress boilerplate abstract standardize

01/03 2017

2.0.3

2.0.3.0 https://github.com/WordPress-Phoenix/abstract-plugin-base

PHP class to extend when building a WordPress plugin allowing you to follow smart plugin setup standards.

  Sources   Download

GPL-v3

plugin wordpress boilerplate abstract standardize

31/01 2017

2.0.2

2.0.2.0 https://github.com/WordPress-Phoenix/abstract-plugin-base

PHP class to extend when building a WordPress plugin allowing you to follow smart plugin setup standards.

  Sources   Download

GPL-v3

plugin wordpress boilerplate abstract standardize

31/01 2017

2.0.1

2.0.1.0 https://github.com/WordPress-Phoenix/abstract-plugin-base

PHP class to extend when building a WordPress plugin allowing you to follow smart plugin setup standards.

  Sources   Download

GPL-v3

plugin wordpress boilerplate abstract standardize

31/01 2017

2.0.0

2.0.0.0 https://github.com/WordPress-Phoenix/abstract-plugin-base

PHP class to extend when building a WordPress plugin allowing you to follow smart plugin setup standards.

  Sources   Download

GPL-v3

plugin wordpress boilerplate abstract standardize

21/01 2017

1.1.3

1.1.3.0 https://github.com/WordPress-Phoenix/abstract-plugin-base

PHP class to extend when building a WordPress plugin allowing you to follow smart plugin setup standards.

  Sources   Download

GPL-v3

plugin wordpress boilerplate abstract standardize

21/01 2017

1.1.2

1.1.2.0 https://github.com/WordPress-Phoenix/abstract-plugin-base

PHP class to extend when building a WordPress plugin allowing you to follow smart plugin setup standards.

  Sources   Download

GPL-v3

plugin wordpress boilerplate abstract standardize

20/01 2017

1.1.1

1.1.1.0 https://github.com/WordPress-Phoenix/abstract-plugin-base

PHP class to extend when building a WordPress plugin allowing you to follow smart plugin setup standards.

  Sources   Download

GPL-v3

plugin wordpress boilerplate abstract standardize

20/01 2017

1.1.0

1.1.0.0 https://github.com/WordPress-Phoenix/abstract-plugin-base

PHP class to extend when building a WordPress plugin allowing you to follow smart plugin setup standards.

  Sources   Download

GPL-v3

plugin wordpress boilerplate abstract standardize

15/12 2016

1.0.3

1.0.3.0 https://github.com/WordPress-Phoenix/abstract-plugin-base

PHP class to extend when building a WordPress plugin allowing you to follow smart plugin setup standards.

  Sources   Download

GPL-v3

plugin wordpress boilerplate abstract standardize

09/12 2016

1.0.2

1.0.2.0 https://github.com/WordPress-Phoenix/abstract-plugin-base

PHP class to extend when building a WordPress plugin allowing you to follow smart plugin setup standards.

  Sources   Download

GPL-v3

plugin wordpress boilerplate abstract standardize

17/11 2016

1.0.1

1.0.1.0 https://github.com/WordPress-Phoenix/abstract-plugin-base

PHP class to extend when building a WordPress plugin allowing you to follow smart plugin setup standards.

  Sources   Download

GPL-v3

plugin wordpress boilerplate abstract standardize

17/11 2016

1.0.0

1.0.0.0 https://github.com/WordPress-Phoenix/abstract-plugin-base

PHP class to extend when building a WordPress plugin allowing you to follow smart plugin setup standards.

  Sources   Download

GPL-v3

plugin wordpress boilerplate abstract standardize