Skip to content

Instantly share code, notes, and snippets.

@navalon
Forked from srikat/genesis-boilerplate.php
Created October 29, 2016 01:04
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 navalon/7202755896780f9e3b8d8d0148788de0 to your computer and use it in GitHub Desktop.
Save navalon/7202755896780f9e3b8d8d0148788de0 to your computer and use it in GitHub Desktop.
Template for a Genesis specific plugin
<?php
/**
* Plugin Name: Genesis Boilerplate
* Plugin URI: http://example.com/
* Description: Write what the plugin does. Must be using the Genesis theme.
* Author: Your Name
* Author URI: http://example.com/
* Version: 1.0
* Text Domain: genesis-boilerplate
*
* Genesis Boilerplate is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 2 of the License, or
* any later version.
*
* Genesis Boilerplate is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Genesis Boilerplate. If not, see <http://www.gnu.org/licenses/>.
*
* @package PREFIX_Genesis_Boilerplate
* @author Your Name
* @since 1.0.0
* @license GPL-2.0+
*/
// Exit if accessed directly
if ( ! defined( 'ABSPATH' ) ) exit;
/**
* Main PREFIX_Genesis_Boilerplate class
*
* @since 1.0.0
* @package PREFIX_Genesis_Boilerplate
*/
class PREFIX_Genesis_Boilerplate {
/**
* Primary constructor.
*
* @since 1.0.0
*/
function __construct() {
// Run on plugin activation
register_activation_hook( __FILE__, array( $this, 'activation_hook' ) );
// Bootstrap and go
add_action( 'init', array( $this, 'init' ) );
}
/**
* Initialize the plugin.
*
* @since 1.0.0
*/
function init() {
// Fire action and filter hooks here
// add_action( 'genesis_after_header', 'prefix_function_name' );
}
/**
* Activation Hook - Confirm site is using Genesis
*
* @since 1.0.0
*/
function activation_hook() {
if ( 'genesis' != basename( TEMPLATEPATH ) ) {
deactivate_plugins( plugin_basename( __FILE__ ) );
wp_die( sprintf( __( 'Sorry, you can&rsquo;t activate unless you have installed <a href="%s">Genesis</a>', 'genesis-boilerplate' ), 'http://www.studiopress.com/features/' ) );
}
}
// Define your functions here
/**
* Description of the function
*
* @since
* @link http://example.com/
* @param
* @return
*/
function prefix_function_name() {
}
}
new PREFIX_Genesis_Boilerplate;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment