Skip to content

Instantly share code, notes, and snippets.

@wvega
Created July 28, 2011 03:15
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save wvega/1110899 to your computer and use it in GitHub Desktop.
Save wvega/1110899 to your computer and use it in GitHub Desktop.
A WordPress plugin template
<?php
/*
Plugin Name:
Plugin URI: http://wvega.com
Description:
Version: 1.0
Author: Willington Vega
Author URI: http://wvega.com
License: GPLv2
*/
if (!function_exists('debug')) {
function debug($var = false, $showHtml = false, $showFrom = true) {
if ($showFrom) {
$calledFrom = debug_backtrace();
echo '<strong>';
echo substr(str_replace(ROOT, '', $calledFrom[0]['file']), 1);
echo '</strong>';
echo ' (line <strong>' . $calledFrom[0]['line'] . '</strong>)';
}
echo "\n<pre class=\"cake-debug\">\n";
$var = print_r($var, true);
if ($showHtml) {
$var = str_replace('<', '&lt;', str_replace('>', '&gt;', $var));
}
echo $var . "\n</pre>\n";
}
}
define('WPCE_DIR_NAME', str_replace(basename(__FILE__), '', plugin_basename(__FILE__)));
define('WPCE_URL', WP_PLUGIN_URL. '/' . WPCE_DIR_NAME);
define('WPCE_DIR', WP_PLUGIN_DIR. '/' . WPCE_DIR_NAME);
class Plugin {
public function activate() {}
}
$plugin = new Plugin();
register_activation_hook(__FILE__, array($plugin, 'activate'));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment