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.

Read Also:  AngularJS Search Auto Suggestion box with PHP MySQLi

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://www.pakainfo.com/
  Description: Pakainfo Main Plugin
  Author: Jaydeep Gondaliya
  Author URI: https://www.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
Read Also:  Laravel 5.8 - Get Last Inserted ID With Example

->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 :

Read Also:  Angular UI Grid Table Tutorial With Example

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.


Related FAQ

Here are some more FAQ related to this Article:

  1. Read Also:  JavaScript jQuery Tips and Tricks for Programmers
  2. Read Also:  How to Create a Wordpress Plugin in 10 Minutes Flat
  3. Read Also:  how to create plugin in wordpress with example
  4. Read Also:  PHP download file from url using curl example
  5. Read Also:  Learn Angular 5 from Scratch - angular 5 Tutorial
  6. Read Also:  $watch() Function using Angular Example
  7. Read Also:  Laravel GroupBy Error Solution 5.5 , 5.6, 5.7
  8. Read Also:  Simple Vue Router Example From Scratch
  9. Read Also:  how to create custom plugin in wordpress from scratch
  10. Read Also:  jQuery Disable onClick Event listeners
CLOSEX