how to create custom WordPress Plugin from scratch

Today, We want to share with you how to create custom WordPress Plugin from scratch.In this post we will show you how to create custom plugin in wordpress step by step, hear for how to create plugin in wordpress step by step with example we will give you demo and example for implement.In this post, we will learn about A Complete Guide of Creating WordPress Plugin from Scratch with an example.

how to create custom WordPress Plugin from scratch

There are the Following The simple About how to Simple custom WordPress Plugin from scratch Full Information With Example and source code.

Also Read :  jquery replace newline with br Example - Convert new lines to br - nl2br function

As I will cover this Post with live Working example to develop create wordpress plugin with database, so the wordpress plugin development course for this example is following below.

WordPress by adding the following to your wp-config.php file:

define('WP_DEBUG', true)

Step :1. Basic Structure:

It depends on the plugin. This is my basic structure for nearly every plugin:

my-plugin/
    inc/
    lib/
    admin/
    templates/
    css/
    js/
    images/
    lang/
    my-plugin.php
    readme.txt

Step :2. Plugin Header:

<?php
  /*
  Plugin name: Custom Plugin
  Plugin URI: https://pakainfo.com/
  Description: Pakainfo Main Plugin
  Author: Jaydeep Gondaliya
  Author URI: https://pakainfo.com
  Version: 2.5
  */
?>

Step :3. File Structure:(Folder Structure #)

/plugin-name
     plugin-name.php
     uninstall.php
     /languages
     /includes
     /admin
          /js
          /css
          /images
     /public
          /js
          /css
          /images

Step :4. Keep Plugin Clean:

  • register_activation_hook — it Runs when your wordpress plugin is activated
  • register_deactivation_hook — it Runs when your wordpress plugin is deactivated
  • register_uninstall_hook — it Runs when your wordpress plugin is uninstalled
Also Read :  Create First WordPress Plugin Step by Step for Beginners

->a) register_activation_hook:

<?php
  register_activation_hook( __FILE__, 'wp_plugin_name_plugin_activation' );
  function wp_plugin_name_plugin_activation() {
    //YOUR CODE 
  }
?>

->b) register_deactivation_hook:

<?php
  register_deactivation_hook( __FILE__, 'wp_plugin_name_plugin_deactivation' );
  function wp_plugin_name_plugin_deactivation() {
    //YOUR CODE
  }
?>

->c) register_uninstall_hook:

<?php
  register_uninstall_hook( __FILE__, 'wp_plugin_name_plugin_uninstall' );
  function wp_plugin_name_plugin_uninstall() {
    // Uninstallation stuff here
  }
?>

->d) creating uninstall.php file

<?php
if ( ! defined( 'WP_UNINSTALL_PLUGIN' ) ) {
    exit;
}
// Uninstallation actions here

Web Programming Tutorials Example with Demo

Read :

Summary

You can also read about AngularJS, ASP.NET, VueJs, PHP.

I hope you get an idea about how to Make custom WordPress Plugin from scratch.
I would like to have feedback on my infinityknow.com blog.
Your valuable feedback, question, or comments about this article are always welcome.
If you enjoyed and liked this post, don’t forget to share.

Leave a Reply

avatar
  Subscribe  
Notify of