Wordpress Tutorials
- Wordpress
- Directory and file structure.
- Wordpress configuration
- Htaccess Configuration
- WP-CONTENT user playground
- Increase file size loading in phpmyadmin on localhost.
- Fatal error: Allowed memory size of x bytes
- wordpress Dashboard
- How to set local host domain or Virtual host
- Header, index and footer page.
- How to create wordpress Themes
- Html to wordpress themes
- Child Themes
- Increase Upload Max Filesize
- wp_enqueue_style & script
- How to make plugin
- Create Plugin
- Insert data into table using plugin.
- Show data from database
- Hook & Filter
- Template Or Custom page template
- Custom Login template
- How to show post on diffrent page.
- Custom widgit
- How to use contact form 7 plugin.
- Wordpress Database
- How to use Duplicator plugin
- How to fix Fatal Error: Maximum Execution Time Exceeded in WordPress
- How to debuggin mode on in wordpress
- Auto update plugin and themes
- How to Transfer WordPress
- How to change a WordPress site URL
- Top 10 issues in wordpress
- wordpress website link
Wordpress setting
Wordpress Function
wordpress top 10 problems
Important Links
How to create a plugin ?
What is Plugin ?
A WordPress Plugin is a program, or a set of one or more functions, written in the PHP scripting language, that adds a specific set of features or services to the WordPress site, which can be seamlessly integrated with the site using access points and methods provided by the WordPress Plugin Application Program Interface (API).
Creating a Plugin
Names, Files, and Locations
The first thing you need to do is create a folder to store your plugin. Go to the wp-content/plugins/ directory in your WordPress installation and create a folder called myplugin. Keep in mind that whatever you name your plugin’s folder will be your plugin’s slug.
A plugin slug should be unique throughout the WordPress Plugin Repository if you want to upload it and make it publicly available.
Keep in mind that the plugin’s name is not necessarily the same as its slug. Take a look at the iThemes Security plugin. The last bit of the URL is the slug: better-wp-security.
Now that you have your myplugin folder, create a new file inside and name it my-login-plugin.php. This will be your main plugin file and its name should be the same as your plugin’s slug, with the PHP extension tacked on.
Example :
File name : my-login-plugin.php
<?php
/**
* Plugin Name: my-login-plugin
* Plugin URI: http://itechtuto.com
* Description: This plugin show login page details.
* Version: 1.0.0
* Author: Mahtab Habib
* Author URI: http://itechtuto.ocm
* License: GPL2
*/
function user_function()
{
$host = "localhost";
$username ="root";
$password = "";
$db_name = "web_demo";
$con = mysqli_connect($host,$username,$password)or die(mysqli_error());
mysqli_select_db($con,$db_name)or die(mysqli_error($con));
$user_name = $_GET['uname'];
$user_pass = $_GET['pass'];
$qry = "insert into user_table (name,password) values('$user_name','$user_pass')";
$result = mysqli_query($con, $qry);
?>
<form action="" method="get">
<label>Enter user name </label>
<input type="text" name="uname" />
<label>Enter user password </label>
<input type="password" name="pass" />
<input type="submit" name="submit" value="Submit"/>
</form>
<?php
}
function user_function1()
{
$host = "localhost";
$username ="root";
$password = "";
$db_name = "web_demo";
$con = mysqli_connect($host,$username,$password)or die(mysqli_error());
mysqli_select_db($con,$db_name)or die(mysqli_error($con));
$qry = "select * from user_table";
$result = mysqli_query($con, $qry);
while($row = mysqli_fetch_array($result))
{
$username = $row['name'];
$pass = $row['password'];
?>
<table>
<tr>
<td><?php echo $username;?></td>
<td><?php echo $pass;?></td>
</tr>
</table>
<?php
}
}
add_shortcode('button1', 'user_function1');
add_shortcode('button', 'user_function');
?>
This code is a PHP comment, which won’t be visible directly in the WordPress admin. WordPress does use the data within it to output the plugin’s name and some other data in the Plugins section of the backend.
Once you’ve saved this file, congratulation are in order because you’ve just created your first plugin! It does absolutely nothing, of course, but it should be available in the plugins section and you should be able to activate it
Output :-
suchas your page is contactus.php
button1
button
fetch data from table using plugin.
File name : getuser.php
<?php
/*
Plugin Name: myplugin_getuser
Description : my registration page details
Version : 1.0
Author : mahtab habib
*/
function user_function1()
{
include 'db.php';
$qry = "select * from user_table";
$result = mysqli_query($con, $qry);
while($row = mysqli_fetch_array($result))
{
$username = $row['name'];
$pass = $row['password'];
?>
<table>
<tr>
<td><?php echo $username;?></td>
<td><?php echo $pass;?></td>
</tr>
</table>
<?php
}
}
add_shortcode('button1', 'user_function1');
?>
Insert Data Using wordpress Plugin.
File name : insertuser.php
<?php
/*
Plugin Name: Mahtab
Plugin URI: http://sumit.com/
Description: use shortcode [sumit]
Version: 3.1.10
Author: Sumit Joshi
Author URI: http://xyz.com/
License: GPLv2 or later
Text Domain: sumit
*/
function des()
{
?>
<form id="contacts-form" method="post">
<fieldset>
<div class="field">
<label>Your Name:</label>
<input type="text" value="" name="n1"/>
</div>
<div class="field">
<label>Your E-mail:</label>
<input type="text" value="" name="e1"/>
</div>
<div class="field">
<label>Your Website:</label>
<input type="text" value="" name="w1"/>
</div>
<div class="field">
<label>Your Message:</label>
<textarea cols="1" rows="1" name="m1"></textarea>
</div>
<div class="wrapper"><input type="submit" name="sub" value="Submit"/></div>
</fieldset>
</form>
<?php
}
function cod()
{
global $wpdb;
extract($_POST);
//$table_name = $wpdb->prefix . "contact";
if(isset($sub))
{
if($wpdb->insert("wp_contact",array('name'=>$n1,'email'=>$e1,'website'=>$w1,'message'=>$m1)))
{
echo "Contact Send";
}
}
}
function man()
{
cod();
des();
}
add_shortcode("key-sumit","man");
?>
output:- Activate plugin
write shortcut on page
[key-submit]