WordPress Plugin functionality

class oPasswords {

//public or private $var main different is scope, when you have doubt take public
public $options;

//Wordpress calls init while initiation the plugin. So all your predefined are initialized
    public function __construct() {
        add_action('init', array($this, 'init'));
    }
// Initiate plugin, if you have things that you will initialize. Its not required

    public function init() {

    }

}

new oPasswords();

The plugin still do nothing, that we have to develop.
First we initiate some values we use.
We also can set a hook, a hook is a place where WordPress execute a given function.
In this case, when install do “paswords_install()”, when uninstall do “passwords_remove()”.
Most of the time is that used to set some values used by the plugin but saved by WordPress.
All other function calls will explained in order of importance.

    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();
    }

Main action done is pw_actions(), this was initiated in

public function init()

        //ADD function pw_actions() to admin menu
        add_action('admin_menu', array($this, 'pw_actions'));

This function makes the admin menu entries, and link them to sub menu items and other functions.

    public function pw_actions() {
        // Link in het admin menu
        if (is_admin()) {
            add_menu_page('CreatePasswords',        //page_title
                __('CreatePasswords', 'passwords'), //menu_title
                'administrator',                    //capability
                'passcreate',                       //menu_slug   IMPORTANT == parent_slug for others
                array($this, "load_passcreate"),    //function
                'dashicons-admin-network', 7);      //set icon
            add_submenu_page('passcreate',          //parent_slug IMPORTANT
                'Settings',                         //page_title
                'Initials',                         //menu_title
                'administrator',                    //capability
                'passinit',                         //menu_slug
                array($this, "load_passinit"));     //function
            add_submenu_page('passcreate', 
                'Settings', 
                'Documentation', 
                'administrator', 
                'passdoc', 
                array($this, "load_passdoc"));
            add_action('admin_menu', 'wp_passwords_actions');
        }
    }

There is a difference in menu_title, the firs one is __(‘CreatePasswords’, ‘passwords’) the second one is “Initials”, the difference is that the first one will translated to the local language the second one not. I will explaine later why and how.

previous

STILL IN PROGRESS

BATCHtools licentie 15 €
Programming pays my bills. Selling files yours? Come on, give me a fair share!
Koop nu een licentie en steun ons in de verdere ontwikkeling en onderhoud van BATCHTools
Hot Offers

Webshop.

Neem nu ook een webshop en vergroot uw verkoopmogelijkheden.


Vraag offerte aan.

Vraag vrijblijvend een offerte, laat u door onze adviseurs, adviseren en begeleiden.


Van start tot finish.

Van start tot finish begeleiden wij u bij het opzetten van uw webshop.

Online Facturatie