Create a Simple WordPress Plugin from Scratch

In this blog we eill discuss how to create a simple wordpress plugin from scratch this is bery helpfull for Beginner’s to create wordpress plugin, so we will learn step by step process to create simple wordpress plugin

we eill create a simple folder with name worpress-test-plugin and inside the we eill create a PHP file with same name to achive the process of Simple WordPress Plugin Development Please follow the below steps:

Crerate a folder with name worpress-test-plugin as shown in screen below.

Create a PHP file inside it with same name as shown below

Now add the below comment information about you plugin in the above php file you have created

Now add function.php pathe in the same file, to write the plugin function

Before we begin writing the functions for the plugin, it is highly recommended to give all files, functions, and variables a unique prefix in their name to avoid any conflicts with other plugins. In our example, we’ll be using the prefix wtp, which is short for worpress-test-plugin

Create a new folder named Includes in the plugin’s main directory. We’ll use it to store supporting files used by the main file. In this folder, create a PHP file and name it wtp-functions.php. Give it the opening <?php tag on the first line.

This new file will contain all of your plugin’s functions.

We’ll have to include wtp-functions.php in the main plugin file to allow the other plugin files to use the functions it defines. Use require_once to ensure the plugin only works if the functions file is present.

Edit worpress-test-plugin.php as shown below. Then, save it and upload the file once again, overwriting the previous version when asked.

The WordPress function plugin_dir_path(FILE) allows you to include files from your plugin folder, providing the complete path to the directory that houses the new plugin.Now, navigate back to the mfp-functions.php file in the Includes directory. As our plugin will add a new top-level link to the navigation menu of the admin control panel, we’ll utilize a custom function named wtp_Add_My_Admin_Link(). Insert the code block below into the wtp-functions.php file.

Now compress the file and upload it as a plugin in you wordpres website

Further reading

  • React UseEffect | simplifyScript

    Understanding the useEffect hook in React

    In this article, we will learn about another React hook called useEffect(), through this article you will be able to understand what is react useEffect Hook and how to use useEffect() hook in react, this is most communally used hook after useState() hook, we mostly use this hook in every component on react now first […]
  • React useState function

    How to Use useState Hook in React Application

     In a React application, normal vanilla JavaScript may not work for some concepts. For example, if I want to toggle a class on a button click or add and remove classes, I might need to show a popup on the website. This can be easily achieved in vanilla JavaScript using the element.classList.toggle(“newClass”) method, allowing us to add […]
  • javascript DOm manipulation - simplifyscript

    What is DOM manipulation in javascript 

    In this article, we will explore JavaScript DOM manipulation, a key feature of JavaScript that allows developers to modify the Document Object Model (DOM) of a webpage. DOM manipulation enables you to dynamically alter the content and structure of HTML documents. To grasp this concept thoroughly, we’ll start by defining what the DOM is and […]