Nice procedure to create a wordpress widget plugin in step by step


You want to access in the wordpress core development. Really you are a greeks.

This nice procedure for you and it will amazed your structural plan and enthusiasm.

In the following article we will learn—>How to make a widget plugin?

–>How to show the effect  of widget in the content?

How to make a widget plugin?

Firstly–>We need to define the plugin and to upload it for sake of active it.

Definition of plugin is very nice and very easy.

<?php

/*
Plugin Name: how to create a widget
Plugin URI: https://webupdate24.com/
Description: Nice procedure of a widget
Author: Kafi
Version: 1
Author URI: https://webupdate24.com/
*/

Now i will describe  the aforementioned plugin information.

Plugin Name: how to create a widget
(This name will be the plugin name. we need to be careful
 about the name because the name should not create any conflict with other plugin name. 
So we need to make it unique name according to our requirements.)

Plugin URI: https://webupdate24.com/
(In here the address of the plugin availability will be mentioned. 
Its is important for use the plugin for other)

Description: Nice procedure of a widget
(Here the description of plugin i.e for which purpose it will be used should be 
mentioned here.
 Thats will be short description.)

Author: Kafi(In here name of the plugin developer will be exist.)

Version: 1(May be you will update the plugin for further requirements so version will change. 
In here version number will be shown)

Author URI: https://webupdate24.com/
(This will be plugin developer url address where the plugin user can sent any feedback to the developer.)

This is some sorts of information about plugin development. 
The following link will help you to know the  standard plugin information.
 http://codex.wordpress.org/Writing_a_Plugin

 

Code:
First step:
We need to trigger an action firstly. How to? Yes its very simple.
add_action('init','function_for_register_the_widget');

Second Step:
Now we should implement the function what we mentioned that it will be trigger when the plugin activated.
function

function_for_register_the_widget(){
register_sidebar_widget('our widget name', 'to_show_the_widget_output');

}

why we write the function? Yes it will be clear now. This will needed when we want to develop a widget .

This function takes two parameter one for the name of the widget and the second one for the output of the widget


step:3

now the high time to implement the desired output when the plugin will be dragged on widget panel.

Like that we want to echo the line  this plugin for beginners.

function to_show_the_widget_output()
{
  echo" this plugin for beginners";

}

OK now we already developed our plugin. So how to to you will see this? You will enjoy to do the next step.

Go to the admin panel. http://yourprojectname/wp-admin/

->click the Appearance and then the widget.

your widget will show that you develop it with the name

our widget name. Drag this widget to the place or sidebar where you want to show that. After setting the widget in your desired place you will show the line
 this plugin for beginners 

Full code is here:

 <?php
/*
Plugin Name: how to create a widget
Plugin URI: https://webupdate24.com/
Description: Nice procedure of a widget
Author: Kafi
Version: 1
Author URI: https://webupdate24.com/
*/

function_for_register_the_widget(){
register_sidebar_widget('our widget name', 'to_show_the_widget_output');

}

function to_show_the_widget_output()
{
  echo" this plugin for beginners";

}
 add_action('init','function_for_register_the_widget');

?>


Leave a Reply