First of all we must have a idea what we want to develop, in this case:
- We want to develop a password generator.
- Generator must be useable in front and backend of the website.
- Shortcodes has to be for frontend available.
- User can choose which type of encryption he or she want to use.
- User can set how many repeats the plugin use.
- Documentation available in menu.
WordPress plugin Initialisation:
/* Plugin Name: opasswords Plugin URI : http://www.abs-hosting.nl/cms/new-password/ Description: Encrypted Passwords plugin. Author : CS ABS-Hosting.nl Author : CS : ABS-Hosting.nl / Walchum.net Version : 1.0 Author URI : http://www.abs-hosting.nl */
Thats all !,
if the above text is saved as passwords.php and installed as plugin it will do nothing only it will show your information. In WordPress it is a valid plugin and will apear in the plugin list.
- Pluginname is now called opasswords.
- Url to plugin form or download file.
- Short description
- Author
- Version is of your choice, 1, 0.1 etc.etc.
- Author Url, link to your own website
A litle strange is it that the file-name and class-name do not have to be the same!
The actual class :
class oPasswords { public $options; public function __construct() { add_action('init', array($this, 'init')); } /** * Initiate plugin */ public function init() { //set install hook, for adding of removing options register_activation_hook(__FILE__, array($this, 'passwords_install')); //* Runs on plugin deactivation*/ register_activation_hook(__FILE__, array($this, 'passwords_remove')); //register_deactivation_hook( __FILE__, $this->passwords_remove()); //get some CONSTANT values $this->defenitions(); $ok = load_plugin_textdomain('passwords', false, dirname(plugin_basename(__FILE__)) . '/languages'); add_action('admin_menu', array($this, 'pw_actions')); add_shortcode('passwords-new', array($this, 'wp_passwords_new')); add_shortcode('passwords-ex', array($this, 'wp_passwords_explain')); $this->wp_passwords_add_css_files(); //$this->wp_passwords_add_javascript_files(); $this->get_option(); } }
This class is center point of the plugin. All functions, who are called in this class, must be available and give correct responses otherwise the plugin will not be INSTALLED by WordPress.