Skip to content

Instantly share code, notes, and snippets.

@rezzz-dev
Created August 10, 2016 16:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rezzz-dev/0c61f102697daa74c9eb925a478fe96f to your computer and use it in GitHub Desktop.
Save rezzz-dev/0c61f102697daa74c9eb925a478fe96f to your computer and use it in GitHub Desktop.
Plugin Extension Boilerplate
<?php
/**
* Plugin Name: Plugin Extension Boilerplate
* Plugin URI: https://rezzz.com/
* Description: Extend an existing plugin with more functionality (based: https://codeable.io/community/how-to-extend-a-wordpress-plugin-my-plugin-boilerplate/)
* Version: 1.0.0
* Author: Jason Resnick
* Author URI: https://rezzz.com/
* License: GNU General Public License v3.0
* License URI: http://www.gnu.org/licenses/gpl-3.0.html
*
* @package PEB
* @category Core
* @author rezzz
*/
class PEB {
private $textdomain = 'peb';
private $required_plugins = array();
function have_required_plugins() {
if ( empty( $this->required_plugins ) ) {
return true;
}
$active_plugins = (array) get_option( 'active_plugins', array() );
if ( is_multisite() ) {
$active_plugins = array_merge( $active_plugins, get_site_option( 'active_sitewide_plugins', array() ) );
}
foreach ( $this->required_plugins as $key => $required ) {
$required = ( ! is_numeric( $key ) ) ? "{$key}/{$required}.php" : "{$required}/{$required}.php";
if ( ! in_array( $required, $active_plugins ) && ! array_key_exists( $required, $active_plugins ) ) {
return false;
}
}
return true;
}
function __construct() {
if ( ! $this->have_required_plugins() ) {
return;
}
add_action( 'plugin_hook', array( $this, 'class_method' ) );
}
function class_method( $person ) {
}
}
global $PEB;
$PEB = new PEB();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment