Skip to content

Instantly share code, notes, and snippets.

@Dankniel
Forked from wvega/wp-plugin-template.php
Created December 1, 2020 02:43
Show Gist options
  • Save Dankniel/b3d3cfaf952ab2fe436b1a99c6de2e44 to your computer and use it in GitHub Desktop.
Save Dankniel/b3d3cfaf952ab2fe436b1a99c6de2e44 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