SlideShare a Scribd company logo
WordPress

Plugin Development
What is a Plugin?
Plugins are tools to extend the functionality of WordPress.
Plugins offer custom functions and features so that each user can tailor their site to
their specific needs.
WordPress is gaining more and more popularity each day, not just as a blogging
platform but also as a basic CMS, thus improving and extending its basic
functionality becoming a day-to-day necessity for a lot of developers. Fortunately,
the WordPress developers have foreseen these needs and added the possibility of
customizing the basic functionality by adding plugins. Basically, a WordPress
plugin is a (more or less) stand-alone piece of code that can be executed in different
sections and stages within a page or site
Steps to Create New PlugIn.

We will create a very simple plugin in this presentation. This
example will surely make u understand about the core concept of developing
plugins. Once you have idea of plugins, u can create more plugins by following the
same method and altering the code according to your need. Follow the step by step
procedure given below.
Plugins reside in WordpressWp-ContentPlugins

Step1. Create a Folder in Plugins directory and name it as Hello_World.
Step2. Create a php file with the same name in Hello_World folder.
i.e. Hello_World.php.
Step3. Add this code in the start of newly created file.
This code will let the wordpress understand that this is a plugin file. After Adding
this code You can check in DashboardPlugins, here u can see you plugin with all
the specification given in commented code.
<?php
/*
Plugin Name: Hello_World
Plugin URI: www.HellowWorld.com/
Description: A simple hello world wordpress plugin
Version: 1.0
Author: AliShah
Author URI: AliShah_120@yahoo.com
License: GPL
*/
?>
Activate Your Plugin.
Step4. Up till Now we have created a plugin, which has been activated
but it performs no functionality. This plugin should do something. So we place a
code which will print HelloWorld. For this purpose we will create a function which
will print hello world. And we will initiate this function with startup of wordpress
site . In this code a function will be used.
<?php
Add_action ('init','Hello_World');
function Hello_World()
{
Echo „ This Plugin is Working Fine‟;
}
?>
Add this code in Hello_World.php plugin file. Add_action is a function which
hooks a function with some action. In our example This calls Hello_World()
function when wordpress initializes.
Now you can see that „This Plugin is Working Fine‟ is written
somewhere on your website . If you can see this line. It means you are
doing good uptill now. Our Hello_World.php file has the following code
uptill now.
Our Hello World plugin is nearly done and with just few lines of code.
When our plugin is activated, add_action command calls our
hello_world() function when wordpress starts loading.
Why not, we build a plugin options page in admin area and provide a
backend for plugin users?
Right now, the plugin outputs hello world (its pretty much static) and if
somebody wants to output „„This Plugin is Working Fine‟ , they need to
open the php file and make changes everytime to print different text.
Asking the user to edit plugin files isnt a good idea! As a wordpress
plugin developer, it is you, who has to provide a good wordpress options
interface in the wp-admin area.
What should a Plugin do?
Here is what we do….
•When plugin gets activated, we create new database field `wp_hello_world_data`
using set_options() function.

•When plugin gets deactivated, we delete the database field `wp_hello_world_data`
•We create a options menu for Hello World in WordPress Admin > Settings.
•We save the user entered data in the wordpress database.
•We retrieve the data stored in wordpress database and output it using get_options()
function.
•Why we are creating database field? because the saved data must be saved
somewhere? ie. in wordpress database. This way the plugin outputs user entered
text, instead of the static “Hello World”.
Hooks
Hooks are provided by WordPress to allow your plugin to 'hook
into' the rest of WordPress; that is, to call functions in your plugin at specific times,
and thereby set your plugin in motion. There are two kinds of hooks:
Actions: Actions are the hooks that the WordPress core launches at specific points
during execution, or when specific events occur. Your plugin can specify that one
or more of its PHP functions are executed at these points, using the Action API.
Filters: Filters are the hooks that WordPress launches to modify text of various
types before adding it to the database or sending it to the browser screen. Your
plugin can specify that one or more of its PHP functions is executed to modify
specific types of text at these times, using the Filter API.
1.

Register_ Activation_Hook

Description
The register_activation_hook function registers a plugin function to be run when
the plugin is activated.
Syntax
<?php register_activation_hook( $file, $function ); ?>
Parameters...
$file: (string) (required) Path to the main plugin file inside the wp-content/plugins
directory. A full path will work. Default: None
$function:
The function to be run when the plugin is activated.
Example
register_activation_hook( __FILE__, „Hello_World_Install' );
2.

Register_ Deactivation _Hook

Description
The function register_deactivation_hook (introduced in WordPress 2.0) registers a
plugin function to be run when the plugin is deactivated.

Syntax
<?php register_deactivation_hook($file, $function); ?>
Parameters...
$file: (string) (required) Path to the main plugin file inside the wp-content/plugins
directory. A full path will work. Default: None
$function:
$function:
The function to be run when the plugin is activated.
Example
register_deactivation_hook( __FILE__, „Hello_World_Remove‟ );
Add Option Functions
Add _Option
This function will be used in Hello_World_Install(function). Add_Option is used to
set the user given value to plugin .

Syntax
<?php add_option( $option, $value, $deprecated, $autoload ); ?>
Parameters...
$option: Name of the option to be added. This is going to be placed into the database.
$value: Default value since we explicitly set it.
$deprecated: description. No need to give for versions after 2.0.
$autoload: should this option be automatically loaded when the page load . The value
may be Yes or No.
Example
<?php Add_option(„‟Hello_World_Data‟‟, „Default‟, „‟, „yes‟)
Delete Option Functions
Delete _Option
This function will be used in Hello_World_remove(function). A safe way of removing
a named option/value pair from the options database table.

Syntax
<?php delete_option( $option ); ?>
Parameters...
$option: Name of the option to be added. This is going to be deleted.
Example
<?php delete_option(„‟Hello_World_Data‟‟) ?>
In our example
Plugin Settings Page
This is our final step. All we need to create is plugin
settings page in the wordpress admin area. The settings page will update and
save the data to the database field `hello_world_data` which we created while
activating the plugin.
Here is a very important thing to remember:
The add_action for admin_menu should call a function
hello_world_admin_menu() containing add_options_page, which in turn
should call a function hello_world_html_code() containing html code.
Plugin Settings Page
So , first task is to add the Hello_World options in the
DashboardSettingsHello World .
For this purpose we will use the conditional tag for
confirmation of admin.
The tag is
If (is_admin() )
{
Run this code(here we will write the code for showing the
setting page for admin)
}
In this if condition an add_action () function is used which will call a
function „Hello_world_admin_menu().‟
Plugin Settings Page
<?php
if ( is_admin() )
{

/* Call the html code */
add_action ('admin_menu', 'hello_world_admin_menu');
function hello_world_admin_menu()
{
add_options_page('Hello World', 'Hello World', 'administrator',
'hello-world', 'hello_world_html_page');
}
}
?>
Plugin Settings Page
add_action ('admin_menu', 'hello_world_admin_menu');
Add_action is calling a function named 'hello_world_admin_menu„
in the body of this called function there is another function which is calling
for html page. This call is through an other function
„hello_world_html_page‟.
function hello_world_admin_menu()
{
add_options_page ('Hello World', 'Hello World', 'administrator',
'hello-world', 'hello_world_html_page');
}
}
?>
Add_Options_page

Function

Description
Add sub menu page to the Settings menu.
Syntax<?php
add_options_page ( $page_title, $menu_title, $capability, $menu_slug, $function);
?>
Parameters...
$page_title: this is the title of settings page.
$menu_Title: this is the title in dashboardsettings title
$capability: here we can give user who have permissions. i.e Admin
$menu-slug: brief info about menu.
$function: here the name of function. Which is to call.
Example
add_options_page('Hello World', 'Hello World Menu', 'administrator',
'hello-world', 'hello_world_html_page');
html Page
This is the last step. In previous slide , on add_options_page function we called a
function name „hello_world_html_page‟. Now we have to this function. We will
create a text filed and button, under the form object. User will write the desired
string and press the update button the value will be saved in data base.

More Related Content

What's hot

Understanding Technologies - Presentation for College Students
Understanding Technologies - Presentation for College StudentsUnderstanding Technologies - Presentation for College Students
Understanding Technologies - Presentation for College Students
Ketan Raval
 
Devise and Rails
Devise and RailsDevise and Rails
Devise and Rails
William Leeper
 
ADF 2.4.0 And Beyond
ADF 2.4.0 And BeyondADF 2.4.0 And Beyond
ADF 2.4.0 And Beyond
Eugenio Romano
 
How to build crud application using vue js, graphql, and hasura
How to build crud application using vue js, graphql, and hasuraHow to build crud application using vue js, graphql, and hasura
How to build crud application using vue js, graphql, and hasura
Katy Slemon
 
CodeIgniter PHP MVC Framework
CodeIgniter PHP MVC FrameworkCodeIgniter PHP MVC Framework
CodeIgniter PHP MVC Framework
Bo-Yi Wu
 
Rails 3: Dashing to the Finish
Rails 3: Dashing to the FinishRails 3: Dashing to the Finish
Rails 3: Dashing to the Finish
Yehuda Katz
 
Pundit
PunditPundit
Pundit
Bruce White
 
How to Webpack your Django!
How to Webpack your Django!How to Webpack your Django!
How to Webpack your Django!
David Gibbons
 
Symfony tips and tricks
Symfony tips and tricksSymfony tips and tricks
Symfony tips and tricks
Javier Eguiluz
 
Caldera Learn - LoopConf WP API + Angular FTW Workshop
Caldera Learn - LoopConf WP API + Angular FTW WorkshopCaldera Learn - LoopConf WP API + Angular FTW Workshop
Caldera Learn - LoopConf WP API + Angular FTW Workshop
CalderaLearn
 
Introduction to plugin development
Introduction to plugin developmentIntroduction to plugin development
Introduction to plugin development
Caldera Labs
 
Writing Pluggable Software
Writing Pluggable SoftwareWriting Pluggable Software
Writing Pluggable Software
Tatsuhiko Miyagawa
 
php-and-zend-framework-getting-started
php-and-zend-framework-getting-startedphp-and-zend-framework-getting-started
php-and-zend-framework-getting-started
tutorialsruby
 
Implementing Testing for Behavior-Driven Development Using Cucumber
Implementing Testing for Behavior-Driven Development Using CucumberImplementing Testing for Behavior-Driven Development Using Cucumber
Implementing Testing for Behavior-Driven Development Using Cucumber
TechWell
 
Top laravel packages to install handpicked list from expert
Top laravel packages to install handpicked list from expertTop laravel packages to install handpicked list from expert
Top laravel packages to install handpicked list from expert
Katy Slemon
 
Refactoring Large Web Applications with Backbone.js
Refactoring Large Web Applications with Backbone.jsRefactoring Large Web Applications with Backbone.js
Refactoring Large Web Applications with Backbone.js
Stacy London
 
In The Trenches With Tomster, Upgrading Ember.js & Ember Data
In The Trenches With Tomster, Upgrading Ember.js & Ember DataIn The Trenches With Tomster, Upgrading Ember.js & Ember Data
In The Trenches With Tomster, Upgrading Ember.js & Ember Data
Stacy London
 

What's hot (17)

Understanding Technologies - Presentation for College Students
Understanding Technologies - Presentation for College StudentsUnderstanding Technologies - Presentation for College Students
Understanding Technologies - Presentation for College Students
 
Devise and Rails
Devise and RailsDevise and Rails
Devise and Rails
 
ADF 2.4.0 And Beyond
ADF 2.4.0 And BeyondADF 2.4.0 And Beyond
ADF 2.4.0 And Beyond
 
How to build crud application using vue js, graphql, and hasura
How to build crud application using vue js, graphql, and hasuraHow to build crud application using vue js, graphql, and hasura
How to build crud application using vue js, graphql, and hasura
 
CodeIgniter PHP MVC Framework
CodeIgniter PHP MVC FrameworkCodeIgniter PHP MVC Framework
CodeIgniter PHP MVC Framework
 
Rails 3: Dashing to the Finish
Rails 3: Dashing to the FinishRails 3: Dashing to the Finish
Rails 3: Dashing to the Finish
 
Pundit
PunditPundit
Pundit
 
How to Webpack your Django!
How to Webpack your Django!How to Webpack your Django!
How to Webpack your Django!
 
Symfony tips and tricks
Symfony tips and tricksSymfony tips and tricks
Symfony tips and tricks
 
Caldera Learn - LoopConf WP API + Angular FTW Workshop
Caldera Learn - LoopConf WP API + Angular FTW WorkshopCaldera Learn - LoopConf WP API + Angular FTW Workshop
Caldera Learn - LoopConf WP API + Angular FTW Workshop
 
Introduction to plugin development
Introduction to plugin developmentIntroduction to plugin development
Introduction to plugin development
 
Writing Pluggable Software
Writing Pluggable SoftwareWriting Pluggable Software
Writing Pluggable Software
 
php-and-zend-framework-getting-started
php-and-zend-framework-getting-startedphp-and-zend-framework-getting-started
php-and-zend-framework-getting-started
 
Implementing Testing for Behavior-Driven Development Using Cucumber
Implementing Testing for Behavior-Driven Development Using CucumberImplementing Testing for Behavior-Driven Development Using Cucumber
Implementing Testing for Behavior-Driven Development Using Cucumber
 
Top laravel packages to install handpicked list from expert
Top laravel packages to install handpicked list from expertTop laravel packages to install handpicked list from expert
Top laravel packages to install handpicked list from expert
 
Refactoring Large Web Applications with Backbone.js
Refactoring Large Web Applications with Backbone.jsRefactoring Large Web Applications with Backbone.js
Refactoring Large Web Applications with Backbone.js
 
In The Trenches With Tomster, Upgrading Ember.js & Ember Data
In The Trenches With Tomster, Upgrading Ember.js & Ember DataIn The Trenches With Tomster, Upgrading Ember.js & Ember Data
In The Trenches With Tomster, Upgrading Ember.js & Ember Data
 

Viewers also liked

Tranzeo
TranzeoTranzeo
Tranzeo
Shahab Shahid
 
Ss Ton 2008 Final
Ss Ton 2008 FinalSs Ton 2008 Final
Ss Ton 2008 Final
Shahab Shahid
 
Suman Jlt
Suman JltSuman Jlt
Suman Jlt
Shahab Shahid
 
Woban Prototype Ieee Network
Woban Prototype Ieee NetworkWoban Prototype Ieee Network
Woban Prototype Ieee Network
Shahab Shahid
 
Wls2
Wls2Wls2
S06 S10 P05
S06 S10 P05S06 S10 P05
S06 S10 P05
Shahab Shahid
 
33
3333
Guidelines For Point To Point
Guidelines For Point To PointGuidelines For Point To Point
Guidelines For Point To Point
Shahab Shahid
 
Pid967241
Pid967241Pid967241
Pid967241
Shahab Shahid
 

Viewers also liked (9)

Tranzeo
TranzeoTranzeo
Tranzeo
 
Ss Ton 2008 Final
Ss Ton 2008 FinalSs Ton 2008 Final
Ss Ton 2008 Final
 
Suman Jlt
Suman JltSuman Jlt
Suman Jlt
 
Woban Prototype Ieee Network
Woban Prototype Ieee NetworkWoban Prototype Ieee Network
Woban Prototype Ieee Network
 
Wls2
Wls2Wls2
Wls2
 
S06 S10 P05
S06 S10 P05S06 S10 P05
S06 S10 P05
 
33
3333
33
 
Guidelines For Point To Point
Guidelines For Point To PointGuidelines For Point To Point
Guidelines For Point To Point
 
Pid967241
Pid967241Pid967241
Pid967241
 

Similar to Plug in development

WordPress basic fundamental of plugin development and creating shortcode
WordPress basic fundamental of plugin development and creating shortcodeWordPress basic fundamental of plugin development and creating shortcode
WordPress basic fundamental of plugin development and creating shortcode
Rakesh Kushwaha
 
Write your first WordPress plugin
Write your first WordPress pluginWrite your first WordPress plugin
Write your first WordPress plugin
Anthony Montalbano
 
How To Write a WordPress Plugin
How To Write a WordPress PluginHow To Write a WordPress Plugin
How To Write a WordPress Plugin
Andy Stratton
 
Getting started with WordPress development
Getting started with WordPress developmentGetting started with WordPress development
Getting started with WordPress development
Steve Mortiboy
 
Intro to WordPress Plugin Development
Intro to WordPress Plugin DevelopmentIntro to WordPress Plugin Development
Intro to WordPress Plugin Development
Brad Williams
 
Bending word press to your will
Bending word press to your willBending word press to your will
Bending word press to your will
Tom Jenkins
 
Wordpress as a framework
Wordpress as a frameworkWordpress as a framework
Wordpress as a framework
Aggelos Synadakis
 
Step by step guide for creating wordpress plugin
Step by step guide for creating wordpress pluginStep by step guide for creating wordpress plugin
Step by step guide for creating wordpress plugin
Mainak Goswami
 
Word press Plugins by WordPress Experts
Word press Plugins by WordPress ExpertsWord press Plugins by WordPress Experts
Word press Plugins by WordPress Experts
Yameen Khan
 
WordPress Plugins
WordPress PluginsWordPress Plugins
How to Create a Custom WordPress Plugin
How to Create a Custom WordPress PluginHow to Create a Custom WordPress Plugin
How to Create a Custom WordPress Plugin
Andolasoft Inc
 
WordPress Plugin development
WordPress Plugin developmentWordPress Plugin development
WordPress Plugin development
Mostafa Soufi
 
Demystifying Hooks, Actions & Filters - WordCamp Belfast 2018
Demystifying Hooks, Actions & Filters - WordCamp Belfast 2018Demystifying Hooks, Actions & Filters - WordCamp Belfast 2018
Demystifying Hooks, Actions & Filters - WordCamp Belfast 2018
Damien Carbery
 
How to create your own WordPress plugin
How to create your own WordPress pluginHow to create your own WordPress plugin
How to create your own WordPress plugin
John Tighe
 
Debugging - Figuring it out yourself (WordCamp Dublin 2019)
Debugging - Figuring it out yourself (WordCamp Dublin 2019)Debugging - Figuring it out yourself (WordCamp Dublin 2019)
Debugging - Figuring it out yourself (WordCamp Dublin 2019)
Damien Carbery
 
WordPress plugin #2
WordPress plugin #2WordPress plugin #2
WordPress plugin #2
giwoolee
 
Cakephp's Cache
Cakephp's CacheCakephp's Cache
Cakephp's Cache
vl
 
Magento++
Magento++Magento++
WordPress Structure and Best Practices
WordPress Structure and Best PracticesWordPress Structure and Best Practices
WordPress Structure and Best Practices
markparolisi
 
Jumping Into WordPress Plugin Programming
Jumping Into WordPress Plugin ProgrammingJumping Into WordPress Plugin Programming
Jumping Into WordPress Plugin Programming
Dougal Campbell
 

Similar to Plug in development (20)

WordPress basic fundamental of plugin development and creating shortcode
WordPress basic fundamental of plugin development and creating shortcodeWordPress basic fundamental of plugin development and creating shortcode
WordPress basic fundamental of plugin development and creating shortcode
 
Write your first WordPress plugin
Write your first WordPress pluginWrite your first WordPress plugin
Write your first WordPress plugin
 
How To Write a WordPress Plugin
How To Write a WordPress PluginHow To Write a WordPress Plugin
How To Write a WordPress Plugin
 
Getting started with WordPress development
Getting started with WordPress developmentGetting started with WordPress development
Getting started with WordPress development
 
Intro to WordPress Plugin Development
Intro to WordPress Plugin DevelopmentIntro to WordPress Plugin Development
Intro to WordPress Plugin Development
 
Bending word press to your will
Bending word press to your willBending word press to your will
Bending word press to your will
 
Wordpress as a framework
Wordpress as a frameworkWordpress as a framework
Wordpress as a framework
 
Step by step guide for creating wordpress plugin
Step by step guide for creating wordpress pluginStep by step guide for creating wordpress plugin
Step by step guide for creating wordpress plugin
 
Word press Plugins by WordPress Experts
Word press Plugins by WordPress ExpertsWord press Plugins by WordPress Experts
Word press Plugins by WordPress Experts
 
WordPress Plugins
WordPress PluginsWordPress Plugins
WordPress Plugins
 
How to Create a Custom WordPress Plugin
How to Create a Custom WordPress PluginHow to Create a Custom WordPress Plugin
How to Create a Custom WordPress Plugin
 
WordPress Plugin development
WordPress Plugin developmentWordPress Plugin development
WordPress Plugin development
 
Demystifying Hooks, Actions & Filters - WordCamp Belfast 2018
Demystifying Hooks, Actions & Filters - WordCamp Belfast 2018Demystifying Hooks, Actions & Filters - WordCamp Belfast 2018
Demystifying Hooks, Actions & Filters - WordCamp Belfast 2018
 
How to create your own WordPress plugin
How to create your own WordPress pluginHow to create your own WordPress plugin
How to create your own WordPress plugin
 
Debugging - Figuring it out yourself (WordCamp Dublin 2019)
Debugging - Figuring it out yourself (WordCamp Dublin 2019)Debugging - Figuring it out yourself (WordCamp Dublin 2019)
Debugging - Figuring it out yourself (WordCamp Dublin 2019)
 
WordPress plugin #2
WordPress plugin #2WordPress plugin #2
WordPress plugin #2
 
Cakephp's Cache
Cakephp's CacheCakephp's Cache
Cakephp's Cache
 
Magento++
Magento++Magento++
Magento++
 
WordPress Structure and Best Practices
WordPress Structure and Best PracticesWordPress Structure and Best Practices
WordPress Structure and Best Practices
 
Jumping Into WordPress Plugin Programming
Jumping Into WordPress Plugin ProgrammingJumping Into WordPress Plugin Programming
Jumping Into WordPress Plugin Programming
 

More from Lucky Ali

Sulphur crested coockatoo
Sulphur crested coockatooSulphur crested coockatoo
Sulphur crested coockatoo
Lucky Ali
 
Using resource materials
Using resource materialsUsing resource materials
Using resource materials
Lucky Ali
 
Health education
Health educationHealth education
Health education
Lucky Ali
 
Fat and ntfs
Fat and ntfsFat and ntfs
Fat and ntfs
Lucky Ali
 
Joomla 3-versions
Joomla 3-versionsJoomla 3-versions
Joomla 3-versions
Lucky Ali
 
Joomla 2-cms working
Joomla 2-cms workingJoomla 2-cms working
Joomla 2-cms workingLucky Ali
 
Joomla 1-introduction
Joomla 1-introductionJoomla 1-introduction
Joomla 1-introduction
Lucky Ali
 
Introduction to word press
Introduction to word pressIntroduction to word press
Introduction to word press
Lucky Ali
 
Custome page template
Custome page templateCustome page template
Custome page template
Lucky Ali
 
Post and page in word press
Post and page in word pressPost and page in word press
Post and page in word press
Lucky Ali
 

More from Lucky Ali (10)

Sulphur crested coockatoo
Sulphur crested coockatooSulphur crested coockatoo
Sulphur crested coockatoo
 
Using resource materials
Using resource materialsUsing resource materials
Using resource materials
 
Health education
Health educationHealth education
Health education
 
Fat and ntfs
Fat and ntfsFat and ntfs
Fat and ntfs
 
Joomla 3-versions
Joomla 3-versionsJoomla 3-versions
Joomla 3-versions
 
Joomla 2-cms working
Joomla 2-cms workingJoomla 2-cms working
Joomla 2-cms working
 
Joomla 1-introduction
Joomla 1-introductionJoomla 1-introduction
Joomla 1-introduction
 
Introduction to word press
Introduction to word pressIntroduction to word press
Introduction to word press
 
Custome page template
Custome page templateCustome page template
Custome page template
 
Post and page in word press
Post and page in word pressPost and page in word press
Post and page in word press
 

Recently uploaded

বাংলাদেশ অর্থনৈতিক সমীক্ষা (Economic Review) ২০২৪ UJS App.pdf
বাংলাদেশ অর্থনৈতিক সমীক্ষা (Economic Review) ২০২৪ UJS App.pdfবাংলাদেশ অর্থনৈতিক সমীক্ষা (Economic Review) ২০২৪ UJS App.pdf
বাংলাদেশ অর্থনৈতিক সমীক্ষা (Economic Review) ২০২৪ UJS App.pdf
eBook.com.bd (প্রয়োজনীয় বাংলা বই)
 
South African Journal of Science: Writing with integrity workshop (2024)
South African Journal of Science: Writing with integrity workshop (2024)South African Journal of Science: Writing with integrity workshop (2024)
South African Journal of Science: Writing with integrity workshop (2024)
Academy of Science of South Africa
 
Introduction to AI for Nonprofits with Tapp Network
Introduction to AI for Nonprofits with Tapp NetworkIntroduction to AI for Nonprofits with Tapp Network
Introduction to AI for Nonprofits with Tapp Network
TechSoup
 
DRUGS AND ITS classification slide share
DRUGS AND ITS classification slide shareDRUGS AND ITS classification slide share
DRUGS AND ITS classification slide share
taiba qazi
 
How to Fix the Import Error in the Odoo 17
How to Fix the Import Error in the Odoo 17How to Fix the Import Error in the Odoo 17
How to Fix the Import Error in the Odoo 17
Celine George
 
A Survey of Techniques for Maximizing LLM Performance.pptx
A Survey of Techniques for Maximizing LLM Performance.pptxA Survey of Techniques for Maximizing LLM Performance.pptx
A Survey of Techniques for Maximizing LLM Performance.pptx
thanhdowork
 
Hindi varnamala | hindi alphabet PPT.pdf
Hindi varnamala | hindi alphabet PPT.pdfHindi varnamala | hindi alphabet PPT.pdf
Hindi varnamala | hindi alphabet PPT.pdf
Dr. Mulla Adam Ali
 
C1 Rubenstein AP HuG xxxxxxxxxxxxxx.pptx
C1 Rubenstein AP HuG xxxxxxxxxxxxxx.pptxC1 Rubenstein AP HuG xxxxxxxxxxxxxx.pptx
C1 Rubenstein AP HuG xxxxxxxxxxxxxx.pptx
mulvey2
 
Chapter 4 - Islamic Financial Institutions in Malaysia.pptx
Chapter 4 - Islamic Financial Institutions in Malaysia.pptxChapter 4 - Islamic Financial Institutions in Malaysia.pptx
Chapter 4 - Islamic Financial Institutions in Malaysia.pptx
Mohd Adib Abd Muin, Senior Lecturer at Universiti Utara Malaysia
 
Executive Directors Chat Leveraging AI for Diversity, Equity, and Inclusion
Executive Directors Chat  Leveraging AI for Diversity, Equity, and InclusionExecutive Directors Chat  Leveraging AI for Diversity, Equity, and Inclusion
Executive Directors Chat Leveraging AI for Diversity, Equity, and Inclusion
TechSoup
 
Advanced Java[Extra Concepts, Not Difficult].docx
Advanced Java[Extra Concepts, Not Difficult].docxAdvanced Java[Extra Concepts, Not Difficult].docx
Advanced Java[Extra Concepts, Not Difficult].docx
adhitya5119
 
Liberal Approach to the Study of Indian Politics.pdf
Liberal Approach to the Study of Indian Politics.pdfLiberal Approach to the Study of Indian Politics.pdf
Liberal Approach to the Study of Indian Politics.pdf
WaniBasim
 
How to Build a Module in Odoo 17 Using the Scaffold Method
How to Build a Module in Odoo 17 Using the Scaffold MethodHow to Build a Module in Odoo 17 Using the Scaffold Method
How to Build a Module in Odoo 17 Using the Scaffold Method
Celine George
 
Azure Interview Questions and Answers PDF By ScholarHat
Azure Interview Questions and Answers PDF By ScholarHatAzure Interview Questions and Answers PDF By ScholarHat
Azure Interview Questions and Answers PDF By ScholarHat
Scholarhat
 
Digital Artifact 1 - 10VCD Environments Unit
Digital Artifact 1 - 10VCD Environments UnitDigital Artifact 1 - 10VCD Environments Unit
Digital Artifact 1 - 10VCD Environments Unit
chanes7
 
Exploiting Artificial Intelligence for Empowering Researchers and Faculty, In...
Exploiting Artificial Intelligence for Empowering Researchers and Faculty, In...Exploiting Artificial Intelligence for Empowering Researchers and Faculty, In...
Exploiting Artificial Intelligence for Empowering Researchers and Faculty, In...
Dr. Vinod Kumar Kanvaria
 
ANATOMY AND BIOMECHANICS OF HIP JOINT.pdf
ANATOMY AND BIOMECHANICS OF HIP JOINT.pdfANATOMY AND BIOMECHANICS OF HIP JOINT.pdf
ANATOMY AND BIOMECHANICS OF HIP JOINT.pdf
Priyankaranawat4
 
The basics of sentences session 5pptx.pptx
The basics of sentences session 5pptx.pptxThe basics of sentences session 5pptx.pptx
The basics of sentences session 5pptx.pptx
heathfieldcps1
 
How to Add Chatter in the odoo 17 ERP Module
How to Add Chatter in the odoo 17 ERP ModuleHow to Add Chatter in the odoo 17 ERP Module
How to Add Chatter in the odoo 17 ERP Module
Celine George
 
Life upper-Intermediate B2 Workbook for student
Life upper-Intermediate B2 Workbook for studentLife upper-Intermediate B2 Workbook for student
Life upper-Intermediate B2 Workbook for student
NgcHiNguyn25
 

Recently uploaded (20)

বাংলাদেশ অর্থনৈতিক সমীক্ষা (Economic Review) ২০২৪ UJS App.pdf
বাংলাদেশ অর্থনৈতিক সমীক্ষা (Economic Review) ২০২৪ UJS App.pdfবাংলাদেশ অর্থনৈতিক সমীক্ষা (Economic Review) ২০২৪ UJS App.pdf
বাংলাদেশ অর্থনৈতিক সমীক্ষা (Economic Review) ২০২৪ UJS App.pdf
 
South African Journal of Science: Writing with integrity workshop (2024)
South African Journal of Science: Writing with integrity workshop (2024)South African Journal of Science: Writing with integrity workshop (2024)
South African Journal of Science: Writing with integrity workshop (2024)
 
Introduction to AI for Nonprofits with Tapp Network
Introduction to AI for Nonprofits with Tapp NetworkIntroduction to AI for Nonprofits with Tapp Network
Introduction to AI for Nonprofits with Tapp Network
 
DRUGS AND ITS classification slide share
DRUGS AND ITS classification slide shareDRUGS AND ITS classification slide share
DRUGS AND ITS classification slide share
 
How to Fix the Import Error in the Odoo 17
How to Fix the Import Error in the Odoo 17How to Fix the Import Error in the Odoo 17
How to Fix the Import Error in the Odoo 17
 
A Survey of Techniques for Maximizing LLM Performance.pptx
A Survey of Techniques for Maximizing LLM Performance.pptxA Survey of Techniques for Maximizing LLM Performance.pptx
A Survey of Techniques for Maximizing LLM Performance.pptx
 
Hindi varnamala | hindi alphabet PPT.pdf
Hindi varnamala | hindi alphabet PPT.pdfHindi varnamala | hindi alphabet PPT.pdf
Hindi varnamala | hindi alphabet PPT.pdf
 
C1 Rubenstein AP HuG xxxxxxxxxxxxxx.pptx
C1 Rubenstein AP HuG xxxxxxxxxxxxxx.pptxC1 Rubenstein AP HuG xxxxxxxxxxxxxx.pptx
C1 Rubenstein AP HuG xxxxxxxxxxxxxx.pptx
 
Chapter 4 - Islamic Financial Institutions in Malaysia.pptx
Chapter 4 - Islamic Financial Institutions in Malaysia.pptxChapter 4 - Islamic Financial Institutions in Malaysia.pptx
Chapter 4 - Islamic Financial Institutions in Malaysia.pptx
 
Executive Directors Chat Leveraging AI for Diversity, Equity, and Inclusion
Executive Directors Chat  Leveraging AI for Diversity, Equity, and InclusionExecutive Directors Chat  Leveraging AI for Diversity, Equity, and Inclusion
Executive Directors Chat Leveraging AI for Diversity, Equity, and Inclusion
 
Advanced Java[Extra Concepts, Not Difficult].docx
Advanced Java[Extra Concepts, Not Difficult].docxAdvanced Java[Extra Concepts, Not Difficult].docx
Advanced Java[Extra Concepts, Not Difficult].docx
 
Liberal Approach to the Study of Indian Politics.pdf
Liberal Approach to the Study of Indian Politics.pdfLiberal Approach to the Study of Indian Politics.pdf
Liberal Approach to the Study of Indian Politics.pdf
 
How to Build a Module in Odoo 17 Using the Scaffold Method
How to Build a Module in Odoo 17 Using the Scaffold MethodHow to Build a Module in Odoo 17 Using the Scaffold Method
How to Build a Module in Odoo 17 Using the Scaffold Method
 
Azure Interview Questions and Answers PDF By ScholarHat
Azure Interview Questions and Answers PDF By ScholarHatAzure Interview Questions and Answers PDF By ScholarHat
Azure Interview Questions and Answers PDF By ScholarHat
 
Digital Artifact 1 - 10VCD Environments Unit
Digital Artifact 1 - 10VCD Environments UnitDigital Artifact 1 - 10VCD Environments Unit
Digital Artifact 1 - 10VCD Environments Unit
 
Exploiting Artificial Intelligence for Empowering Researchers and Faculty, In...
Exploiting Artificial Intelligence for Empowering Researchers and Faculty, In...Exploiting Artificial Intelligence for Empowering Researchers and Faculty, In...
Exploiting Artificial Intelligence for Empowering Researchers and Faculty, In...
 
ANATOMY AND BIOMECHANICS OF HIP JOINT.pdf
ANATOMY AND BIOMECHANICS OF HIP JOINT.pdfANATOMY AND BIOMECHANICS OF HIP JOINT.pdf
ANATOMY AND BIOMECHANICS OF HIP JOINT.pdf
 
The basics of sentences session 5pptx.pptx
The basics of sentences session 5pptx.pptxThe basics of sentences session 5pptx.pptx
The basics of sentences session 5pptx.pptx
 
How to Add Chatter in the odoo 17 ERP Module
How to Add Chatter in the odoo 17 ERP ModuleHow to Add Chatter in the odoo 17 ERP Module
How to Add Chatter in the odoo 17 ERP Module
 
Life upper-Intermediate B2 Workbook for student
Life upper-Intermediate B2 Workbook for studentLife upper-Intermediate B2 Workbook for student
Life upper-Intermediate B2 Workbook for student
 

Plug in development

  • 2. What is a Plugin? Plugins are tools to extend the functionality of WordPress. Plugins offer custom functions and features so that each user can tailor their site to their specific needs. WordPress is gaining more and more popularity each day, not just as a blogging platform but also as a basic CMS, thus improving and extending its basic functionality becoming a day-to-day necessity for a lot of developers. Fortunately, the WordPress developers have foreseen these needs and added the possibility of customizing the basic functionality by adding plugins. Basically, a WordPress plugin is a (more or less) stand-alone piece of code that can be executed in different sections and stages within a page or site
  • 3. Steps to Create New PlugIn. We will create a very simple plugin in this presentation. This example will surely make u understand about the core concept of developing plugins. Once you have idea of plugins, u can create more plugins by following the same method and altering the code according to your need. Follow the step by step procedure given below. Plugins reside in WordpressWp-ContentPlugins Step1. Create a Folder in Plugins directory and name it as Hello_World. Step2. Create a php file with the same name in Hello_World folder. i.e. Hello_World.php.
  • 4. Step3. Add this code in the start of newly created file. This code will let the wordpress understand that this is a plugin file. After Adding this code You can check in DashboardPlugins, here u can see you plugin with all the specification given in commented code. <?php /* Plugin Name: Hello_World Plugin URI: www.HellowWorld.com/ Description: A simple hello world wordpress plugin Version: 1.0 Author: AliShah Author URI: AliShah_120@yahoo.com License: GPL */ ?> Activate Your Plugin.
  • 5. Step4. Up till Now we have created a plugin, which has been activated but it performs no functionality. This plugin should do something. So we place a code which will print HelloWorld. For this purpose we will create a function which will print hello world. And we will initiate this function with startup of wordpress site . In this code a function will be used. <?php Add_action ('init','Hello_World'); function Hello_World() { Echo „ This Plugin is Working Fine‟; } ?> Add this code in Hello_World.php plugin file. Add_action is a function which hooks a function with some action. In our example This calls Hello_World() function when wordpress initializes.
  • 6. Now you can see that „This Plugin is Working Fine‟ is written somewhere on your website . If you can see this line. It means you are doing good uptill now. Our Hello_World.php file has the following code uptill now. Our Hello World plugin is nearly done and with just few lines of code. When our plugin is activated, add_action command calls our hello_world() function when wordpress starts loading. Why not, we build a plugin options page in admin area and provide a backend for plugin users? Right now, the plugin outputs hello world (its pretty much static) and if somebody wants to output „„This Plugin is Working Fine‟ , they need to open the php file and make changes everytime to print different text. Asking the user to edit plugin files isnt a good idea! As a wordpress plugin developer, it is you, who has to provide a good wordpress options interface in the wp-admin area.
  • 7. What should a Plugin do? Here is what we do…. •When plugin gets activated, we create new database field `wp_hello_world_data` using set_options() function. •When plugin gets deactivated, we delete the database field `wp_hello_world_data` •We create a options menu for Hello World in WordPress Admin > Settings. •We save the user entered data in the wordpress database. •We retrieve the data stored in wordpress database and output it using get_options() function. •Why we are creating database field? because the saved data must be saved somewhere? ie. in wordpress database. This way the plugin outputs user entered text, instead of the static “Hello World”.
  • 8. Hooks Hooks are provided by WordPress to allow your plugin to 'hook into' the rest of WordPress; that is, to call functions in your plugin at specific times, and thereby set your plugin in motion. There are two kinds of hooks: Actions: Actions are the hooks that the WordPress core launches at specific points during execution, or when specific events occur. Your plugin can specify that one or more of its PHP functions are executed at these points, using the Action API. Filters: Filters are the hooks that WordPress launches to modify text of various types before adding it to the database or sending it to the browser screen. Your plugin can specify that one or more of its PHP functions is executed to modify specific types of text at these times, using the Filter API.
  • 9. 1. Register_ Activation_Hook Description The register_activation_hook function registers a plugin function to be run when the plugin is activated. Syntax <?php register_activation_hook( $file, $function ); ?> Parameters... $file: (string) (required) Path to the main plugin file inside the wp-content/plugins directory. A full path will work. Default: None $function: The function to be run when the plugin is activated. Example register_activation_hook( __FILE__, „Hello_World_Install' );
  • 10. 2. Register_ Deactivation _Hook Description The function register_deactivation_hook (introduced in WordPress 2.0) registers a plugin function to be run when the plugin is deactivated. Syntax <?php register_deactivation_hook($file, $function); ?> Parameters... $file: (string) (required) Path to the main plugin file inside the wp-content/plugins directory. A full path will work. Default: None $function: $function: The function to be run when the plugin is activated. Example register_deactivation_hook( __FILE__, „Hello_World_Remove‟ );
  • 11. Add Option Functions Add _Option This function will be used in Hello_World_Install(function). Add_Option is used to set the user given value to plugin . Syntax <?php add_option( $option, $value, $deprecated, $autoload ); ?> Parameters... $option: Name of the option to be added. This is going to be placed into the database. $value: Default value since we explicitly set it. $deprecated: description. No need to give for versions after 2.0. $autoload: should this option be automatically loaded when the page load . The value may be Yes or No. Example <?php Add_option(„‟Hello_World_Data‟‟, „Default‟, „‟, „yes‟)
  • 12. Delete Option Functions Delete _Option This function will be used in Hello_World_remove(function). A safe way of removing a named option/value pair from the options database table. Syntax <?php delete_option( $option ); ?> Parameters... $option: Name of the option to be added. This is going to be deleted. Example <?php delete_option(„‟Hello_World_Data‟‟) ?>
  • 14. Plugin Settings Page This is our final step. All we need to create is plugin settings page in the wordpress admin area. The settings page will update and save the data to the database field `hello_world_data` which we created while activating the plugin. Here is a very important thing to remember: The add_action for admin_menu should call a function hello_world_admin_menu() containing add_options_page, which in turn should call a function hello_world_html_code() containing html code.
  • 15. Plugin Settings Page So , first task is to add the Hello_World options in the DashboardSettingsHello World . For this purpose we will use the conditional tag for confirmation of admin. The tag is If (is_admin() ) { Run this code(here we will write the code for showing the setting page for admin) } In this if condition an add_action () function is used which will call a function „Hello_world_admin_menu().‟
  • 16. Plugin Settings Page <?php if ( is_admin() ) { /* Call the html code */ add_action ('admin_menu', 'hello_world_admin_menu'); function hello_world_admin_menu() { add_options_page('Hello World', 'Hello World', 'administrator', 'hello-world', 'hello_world_html_page'); } } ?>
  • 17. Plugin Settings Page add_action ('admin_menu', 'hello_world_admin_menu'); Add_action is calling a function named 'hello_world_admin_menu„ in the body of this called function there is another function which is calling for html page. This call is through an other function „hello_world_html_page‟. function hello_world_admin_menu() { add_options_page ('Hello World', 'Hello World', 'administrator', 'hello-world', 'hello_world_html_page'); } } ?>
  • 18. Add_Options_page Function Description Add sub menu page to the Settings menu. Syntax<?php add_options_page ( $page_title, $menu_title, $capability, $menu_slug, $function); ?> Parameters... $page_title: this is the title of settings page. $menu_Title: this is the title in dashboardsettings title $capability: here we can give user who have permissions. i.e Admin $menu-slug: brief info about menu. $function: here the name of function. Which is to call. Example add_options_page('Hello World', 'Hello World Menu', 'administrator', 'hello-world', 'hello_world_html_page');
  • 19.
  • 20. html Page This is the last step. In previous slide , on add_options_page function we called a function name „hello_world_html_page‟. Now we have to this function. We will create a text filed and button, under the form object. User will write the desired string and press the update button the value will be saved in data base.