by Kaspars Dambis -- konstruktors.com / @konstruktors
We'll assume that your plugin is already hosted on the official WordPress plugin Subversion repository, and we'll use the Easy Digital Downloads plugin as an example.
<?php | |
class MyPlugin { | |
static function activation_hook() { | |
if ( ! version_compare( PHP_VERSION, '5.3.0', '>=' ) ) { | |
deactivate_plugins( __FILE__ ); | |
wp_die( wp_sprintf( '%1s: ' . __( 'Sorry, This plugin has taken a bold step in requiring PHP 5.3.0+. Your server is currently running PHP %2s, Please bug your host to upgrade to a recent version of PHP which is less bug-prone.', 'myplugin' ), __FILE__ , PHP_VERSION ) ); | |
} | |
} | |
} | |
register_activation_hook( __FILE__, array( 'MyPlugin', 'activation_hook' ) ); |
<?php | |
// initialize plugin | |
if ( function_exists( 'add_action' ) && function_exists( 'register_activation_hook' ) ) { | |
add_action( 'plugins_loaded', array( 'tabbed_plugin', 'get_object' ) ); | |
} | |
class tabbed_plugin | |
{ | |
// singleton class variable | |
static private $classobj = NULL; |
<?php | |
$wp_meta_boxes[ 'post' ][ 'normal' ][ 'core' ][ 'post excerpt' ][ 'title' ] = 'Abstract'; | |
$wp_meta_boxes[ 'post' ][ 'normal' ][ 'core' ][ 'post excerpt' ][ 'id' ] = 'postabstract'; |
<div class="wrap"> | |
<div id="icon-options-general" class="icon32"></div> | |
<h2>My Awesome Plugin</h2> | |
<div class="metabox-holder has-right-sidebar"> | |
<div class="inner-sidebar"> | |
<div class="postbox"> |
<?php | |
/* | |
Term Archive Pages: | |
- http://example.com/recipes/dinner/ | |
- http://example.com/recipes/breakfast,brunch/ | |
Single Recipe Pages: | |
- http://example.com/recipes/dinner/soup-title/ |
by Kaspars Dambis -- konstruktors.com / @konstruktors
We'll assume that your plugin is already hosted on the official WordPress plugin Subversion repository, and we'll use the Easy Digital Downloads plugin as an example.
<?php | |
/* | |
Plugin Name: WP Invite Codes | |
Plugin URI: http://pmg.co/ | |
Description: Makes wordpress an invite only community. | |
Version: n/a | |
Author: Christopher Davis | |
Author URI: http://pmg.co/people/chris | |
*/ |
<?php | |
date_default_timezone_set('America/Los_Angeles'); | |
class Deploy { | |
/** | |
* A callback function to call after the deploy has finished. | |
* | |
* @var callback |
<?php | |
// Add Theme and Plugin Editor to Admin Bar (to save time!) | |
function admin_bar_code_editor_option() { | |
global $wp_admin_bar; | |
if ( !is_super_admin() || !is_admin_bar_showing() ) | |
return; | |
$wp_admin_bar->add_menu( | |
array( | |
'id' => 'edit-code', | |
'title' => __('Code Editor'), |
<?php | |
/* | |
Plugin Name: Simple Post Views | |
Plugin URI: http://en.bainternet.info | |
Description: Simple And lightweight plugin to track post views. | |
Version: 0.2 | |
Author: Bainternet | |
Author URI: http://en.bainternet.info | |
*/ | |
if ( !class_exists('PostViews')){ |