JiveDig
5/9/2013 - 7:54 PM

Create new plugin in WordPress.

Create new plugin in WordPress.

<?php
/*
Plugin Name: CUSTOM - Website Title
Plugin URI: http://thestizmedia.com
Description: All custom funtionality for www.Website_Title_Here.com
Version: 1.0
Author: JiveDig
Author URI: http://thestizmedia.com
Copyright 2013 JiveDig (mike@thestizmedia.com)
*/

// Exit if accessed directly
if ( !defined( 'ABSPATH' ) ) exit;

// Plugin and class main setup
if ( ! class_exists( 'My_Plugin_Name' ) ) {

  class My_Plugin_Name {

  	public function __construct() {

			/** Define plugin directory constants */
			define( 'MY_PLUGIN_NAME_CORE_DIR', dirname( __FILE__ ) );
			define( 'MY_PLUGIN_NAME_INCLUDES_DIR', MY_PLUGIN_NAME_CORE_DIR . '/includes/' );
			define( 'MY_PLUGIN_NAME_PLUGIN_NAME', dirname( plugin_basename( __FILE__ ) ) );

		}

		/* Active and Deactivate the plugin */
		public static function activate() {
			// Do nothing on activation
		}

		public static function deactivate() {
			// Do nothing on deactivation
		}
	}
}

if ( class_exists('My_Plugin_Name' ) ) {
	// Installation and uninstallation hooks
	register_activation_hook( __FILE__, array( 'My_Plugin_Name', 'activate' ) );
	register_deactivation_hook( __FILE__, array( 'My_Plugin_Name', 'deactivate' ) );

	// instantiate the plugin class
	$My_Plugin_Name = new My_Plugin_Name();
}

/** Include core plugin files */
require_once( MY_PLUGIN_NAME_INCLUDES_DIR . 'post-types.php' );
/* require_once( MY_PLUGIN_NAME_INCLUDES_DIR . 'templates/some-file.php' ); */