Last active
December 10, 2015 16:38
-
-
Save keithics/4462455 to your computer and use it in GitHub Desktop.
Class Plugin for Wordpress
This file contains hidden or 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: Plugin for Wordpress | |
Plugin URI: | |
Description: A Sample Class Plugin for Wordpress | |
Version: 1.0 | |
Author: Webninja Mobile | |
Author URI: http://webninjamobile.com | |
*/ | |
// always have a prefix to make your plugin more 'plugin friendly' with others | |
define('PLUGURL',WP_PLUGIN_URL . '/prefix_plugin_name/'); // eg: wnm_survey (wnm = web ninja mobile) | |
define('PLUGPATH',WP_PLUGIN_DIR . '/prefix_plugin_name/'); | |
function call_PREFIXPluginName() // eg: class_WNMSurvey | |
{ | |
return new PREFIXPluginName(); | |
} | |
if ( is_admin() ) | |
add_action( 'load-post.php', 'call_PREFIXPluginName' ); | |
class PREFIXPluginName { | |
public function __construct() | |
{ | |
global $post; | |
add_action('admin_enqueue_scripts', array($this,'prefix_plugin_name_scripts')); // eg: wnm_survey_scripts | |
add_action( 'init', array(&$this,'prefix_plugin_name_init'),0); | |
add_action('admin_menu', array($this,'register_custom_menu_page')); | |
} | |
function wnm_init(){ | |
} | |
function prefix_plugin_name_scripts(){ | |
//wp_register_script('custom-js',WP_PLUGIN_URL.'prefix_plugin_name/js/custom.js'); | |
//wp_enqueue_script('custom-js'); | |
} | |
function register_custom_menu_page() { | |
add_menu_page('My Admin', 'My Admin', 'manage_options', 'my_plugin', array($this,'my_plugin_cb')); | |
} | |
function my_plugin_cb(){ | |
} | |
} | |
$PREFIXPluginName = new PREFIXPluginName(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment