plugin development

wordpress plugin development


After a long time I got a requirement to wordpress plugin development, you all know one thing I usually work on codeigniter projects, I don’t have knowledge in wordpress plugin development, so I want to share my learning experience with you all.
Let’s start now, before going to develop plugin let’s check mandatory things to know about wordpress.

  • Knowledge on php technology
  • WordPress folder structure.
  • Adding plugins to Wp-content/plugins/your plugins
  • Adding themes to Wp-content/Themes/your themes
  • Installing the wordpress
  • Creating database and linking with your project by updating wp-config.php file in project root folder.
  • Creating admin panel and using admin panel functionality.

After learning above things you will get an idea about wordpress.
Now what we need to create to develop plugin?
Its simple just create a folder under wp-content/plugins/My_demo_plugin
Under this folder create a php file with plugin name as My_demo_plugin.php, we can create php file with different file name, to avoid duplicate names and functions, we use unique filenames and function names.
Now add below details to your plugin file My_demo_plugin.php

[sociallocker]

<?php

Plugin Name  : My Demo Plugin.
Plugin URL    : http://localhost/dev/mydemoplugin.
Description     : This is my first demo wordpress plugin.
Version           :  Plugin version V.0.11.
Author Name  : Joseph Reddy
Author URL    : https://www.eknowledgetree.com
License            : A Slug License name GPL2
?>

[/sociallocker]

Now save the file and open your project and login to your admin panel and check plugins tab in left sidebar, you will see your plugin My Demo Plugin there.

Now check the details you have provided to the plugin like Author, Description etc.Once done! Click on active link under plugin to activate your wordpress plugin.

Hurrah!! We created wordpress plugin, now it’s time to create functionality for our wordpress plugin
To write code functionality for our plugin we need to learn about wordpress hooks , there are two types of hooks let’s check what exactly they do in wordpress plugin.

  • Actions hook
  • Filters hook

Action hook:

Actions are hooks that the wordpress core launches at specific point at execution or when a specific event or action occurs.

      do_action(‘actionn name’)
          <?php add_action(‘my_demo_stuff’,’my_function_name’);?>

Filters hook:

filter are the hooks that wordpress launches to modify the database tables or sending the response to the browser screen.We can create our own filters by using add_filter() functions , but it should contain returning a string that can be filtered .

<?php

Function filter_mydemo($content)
{ 
$mydemo=array(‘joseph’,’reddy’,’male’);
$content=str_ireplace($mydemo,’{changed}’,$content);
Return $content;
}
 Add_filter(‘content’,’filter_mydemo’);
?>

We need more particle work to done, for this please check wordpress Hooks , you can get better understanding in this hooks topic.

Thanks for reading this article