Last active
February 19, 2017 22:18
-
-
Save srikat/3bb946ec2ad52f9f4fa4 to your computer and use it in GitHub Desktop.
Template for a Genesis specific plugin
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
<?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’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