How to create a plugin in WordPress by code:-
The plugin is the special component that provides functionality in the WordPress application.
for example, if we want to create a feedback form then we can feedback plugin.
the plugin can be reused in another WordPress project. because the plugin is the independent plugin.
How we create a normal plugin:-
1) create file in wp-content/plugins folder
2) write meta tag
3) create the function and write functionality
4) call function under the action, hooks, and filter
action:- if we want to add any method under WordPress application then we can use action.
add_action('filter',methodname)
add_action('hooks',methodname)
hooks:- it is the event that will be called implicit for example if we want to call any functionality under page initialize.
add_action('init',method)
filter:- it is used to implement functionality under a particular part of the dashboard.
add_action('admin_head',methodname)
Simple Plugin Program Code:-
<?php
/*
plugin name:- scs-notice
description:- it is for scs events description
version: 1.0
Author: shiva
Author Uri: www.shivaconceptsotuion.com
*/
function displaynotice()
{
echo "<marquee><h1 style='color:red;'>TODAY is SIX Annversary of Shiva Concept Solution</h1></marquee>";
}
if(!is_admin())
add_action('init',displaynotice);
?>
Create Form Plugin:-
To create a form plugin same step should be followed.
we will use add_shortcode('shortcodename',functionname)
complete code for form plugin:-
<?php
/*
plugin name:- scs-addition
description:- it is for the addition of two number
version: 1.0
Author: shiva
Author Uri: www.shivaconceptsotuion.com
*/
function add()
{
?>
<form action="" method="post">
<input type="text" name="txtp" placeholder="Enter First Number" />
<br>
<br>
<input type="text" name="txtr" placeholder="Enter Second Number" />
<br>
<br>
<input type="submit" name="btnsubmit" value="ADD" />
</form>
<?php
if(isset($_REQUEST['btnsubmit']))
{
$a = $_REQUEST['txtp'];
$b = $_REQUEST['txtr'];
$c=$a+$b;
echo "Result is ".$c;
}
?>
<?php
}
add_shortcode('scsadd',add);
?>
for example, if we want to create a feedback form then we can feedback plugin.
the plugin can be reused in another WordPress project. because the plugin is the independent plugin.
How we create a normal plugin:-
1) create file in wp-content/plugins folder
2) write meta tag
3) create the function and write functionality
4) call function under the action, hooks, and filter
action:- if we want to add any method under WordPress application then we can use action.
add_action('filter',methodname)
add_action('hooks',methodname)
hooks:- it is the event that will be called implicit for example if we want to call any functionality under page initialize.
add_action('init',method)
filter:- it is used to implement functionality under a particular part of the dashboard.
add_action('admin_head',methodname)
Simple Plugin Program Code:-
<?php
/*
plugin name:- scs-notice
description:- it is for scs events description
version: 1.0
Author: shiva
Author Uri: www.shivaconceptsotuion.com
*/
function displaynotice()
{
echo "<marquee><h1 style='color:red;'>TODAY is SIX Annversary of Shiva Concept Solution</h1></marquee>";
}
if(!is_admin())
add_action('init',displaynotice);
?>
Create Form Plugin:-
To create a form plugin same step should be followed.
we will use add_shortcode('shortcodename',functionname)
complete code for form plugin:-
<?php
/*
plugin name:- scs-addition
description:- it is for the addition of two number
version: 1.0
Author: shiva
Author Uri: www.shivaconceptsotuion.com
*/
function add()
{
?>
<form action="" method="post">
<input type="text" name="txtp" placeholder="Enter First Number" />
<br>
<br>
<input type="text" name="txtr" placeholder="Enter Second Number" />
<br>
<br>
<input type="submit" name="btnsubmit" value="ADD" />
</form>
<?php
if(isset($_REQUEST['btnsubmit']))
{
$a = $_REQUEST['txtp'];
$b = $_REQUEST['txtr'];
$c=$a+$b;
echo "Result is ".$c;
}
?>
<?php
}
add_shortcode('scsadd',add);
?>
POST Answer of Questions and ASK to Doubt