​Application Development , Website Design Services in Toronto
  • Blog
  • About
  • Contact

Ten Things Every WordPress Plugin Developer Should Know

2/16/2016

0 Comments

 
Picture
WordPress Plugin Development
Plugin is considered as the powerful motivator for choosing the WordPress over other content management systems. Over time, it has picked a tons of features that makes it capable of powering millions of dynamic and robust websites around the world.

WordPress offers thousands of free and premium plugins that allow you to do anything whatever you need to develop a custom website for your business.It has ability to meet any need that you can think of. Now it is easy to write plugins with an API and the use of hooks.

In this article we will take insights of WordPress plugin development which every WordPress developer should know - 
​
1. Don’t Develop Without Debugging
The first thing is to enable debugging so that each time when you write a plugin code, WordPress raises warnings and error messages, but if you can’t see them then they might as well have not been raised at all.
It is important because it will notify you if you’re using any deprecated functions. Or else find its replacement and use that instead.

 2. Prefix Your Functions 
We have found that other plugin web developers sometimes use the same names for functions that I use. For example, function names like copy_file(), save_data(), and database_table_exists().
So each function must be uniquely named. The best way is to name all of your plugin functions with a prefix.
function myplugin_copy_file() {
}
function myplugin_save_data() {
}
function myplugin_database_table_exists() {
}

3. Global Paths Are Handy
If you want to make your plugin to look and feel good, you’ll need to add some images, CSS, and perhaps a little JavaScript as well. Now create your own global paths.
$image = MYPLUGIN_PLUGIN_URL . '/images/my-image.jpg';
$style = MYPLUGIN_PLUGIN_URL . '/css/my-style.css';
$script = MYPLUGIN_PLUGIN_URL . '/js/my-script.js';

4. Store the Plugin Version for Upgrades 
If your next version requires another table, you all need to create a couple more global variables and invoke the add_option()function:
if (!defined('MYPLUGIN_VERSION_KEY'))
    define('MYPLUGIN_VERSION_KEY', 'myplugin_version');

if (!defined('MYPLUGIN_VERSION_NUM'))
    define('MYPLUGIN_VERSION_NUM', '1.0.0');

add_option(MYPLUGIN_VERSION_KEY, MYPLUGIN_VERSION_NUM);

5. Use dbDelta() to Create/Update Database Tables
Use dbDelta() function to modify your own database tables in future versions of your plugin

6. Know the Difference Between include, include_once, require, and require_once 
include 'functions.php';
include_once 'functions.php';
require 'functions.php';
require_once 'functions.php';

7. Use bloginfo(‘wpurl’) Instead of bloginfo(‘url’)
Using bloginfo('wpurl') instead of bloginfo('url') is the safest way to go when building links 
// URL will be http://mydomain.com/wp-login.php
<a href="<?php bloginfo('url') ?>/wp-login.php">Login</a>

8. How and When to Use Actions and Filters
9. Add Your Own Settings Page or Admin Menu 
10. Provide a Shortcut to Your Settings Page with Plugin Action Links

We have covered a lot of useful stuff in this article. Hopefully it will help you to improve your WordPress plugin development from scratch. More details you can found on this - WordPress Codex





0 Comments



Leave a Reply.

    Author

    Robert Pitula is an experienced content writer at iMediadesigns, a Website Design Toronto agency and app development 
    ​company
    in Toronto.

    Archives

    January 2017
    December 2016
    November 2016
    October 2016
    September 2016
    July 2016
    June 2016
    May 2016
    April 2016
    March 2016
    February 2016
    January 2016

    RSS Feed

Powered by
  • Blog
  • About
  • Contact
✕