SlideShare a Scribd company logo
1 of 20
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 StudentsKetan Raval
 
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 hasuraKaty Slemon
 
CodeIgniter PHP MVC Framework
CodeIgniter PHP MVC FrameworkCodeIgniter PHP MVC Framework
CodeIgniter PHP MVC FrameworkBo-Yi Wu
 
Rails 3: Dashing to the Finish
Rails 3: Dashing to the FinishRails 3: Dashing to the Finish
Rails 3: Dashing to the FinishYehuda Katz
 
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 tricksJavier 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 WorkshopCalderaLearn
 
Introduction to plugin development
Introduction to plugin developmentIntroduction to plugin development
Introduction to plugin developmentCaldera Labs
 
php-and-zend-framework-getting-started
php-and-zend-framework-getting-startedphp-and-zend-framework-getting-started
php-and-zend-framework-getting-startedtutorialsruby
 
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 CucumberTechWell
 
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 expertKaty 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.jsStacy 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 DataStacy 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 (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 shortcodeRakesh Kushwaha
 
Write your first WordPress plugin
Write your first WordPress pluginWrite your first WordPress plugin
Write your first WordPress pluginAnthony Montalbano
 
How To Write a WordPress Plugin
How To Write a WordPress PluginHow To Write a WordPress Plugin
How To Write a WordPress PluginAndy Stratton
 
Getting started with WordPress development
Getting started with WordPress developmentGetting started with WordPress development
Getting started with WordPress developmentSteve Mortiboy
 
Intro to WordPress Plugin Development
Intro to WordPress Plugin DevelopmentIntro to WordPress Plugin Development
Intro to WordPress Plugin DevelopmentBrad Williams
 
Bending word press to your will
Bending word press to your willBending word press to your will
Bending word press to your willTom Jenkins
 
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 pluginMainak Goswami
 
Word press Plugins by WordPress Experts
Word press Plugins by WordPress ExpertsWord press Plugins by WordPress Experts
Word press Plugins by WordPress ExpertsYameen Khan
 
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 PluginAndolasoft Inc
 
WordPress Plugin development
WordPress Plugin developmentWordPress Plugin development
WordPress Plugin developmentMostafa 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 2018Damien 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 pluginJohn 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 #2giwoolee
 
Cakephp's Cache
Cakephp's CacheCakephp's Cache
Cakephp's Cachevl
 
WordPress Structure and Best Practices
WordPress Structure and Best PracticesWordPress Structure and Best Practices
WordPress Structure and Best Practicesmarkparolisi
 
Jumping Into WordPress Plugin Programming
Jumping Into WordPress Plugin ProgrammingJumping Into WordPress Plugin Programming
Jumping Into WordPress Plugin ProgrammingDougal 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 coockatooLucky Ali
 
Using resource materials
Using resource materialsUsing resource materials
Using resource materialsLucky Ali
 
Health education
Health educationHealth education
Health educationLucky Ali
 
Fat and ntfs
Fat and ntfsFat and ntfs
Fat and ntfsLucky Ali
 
Joomla 3-versions
Joomla 3-versionsJoomla 3-versions
Joomla 3-versionsLucky 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-introductionLucky Ali
 
Introduction to word press
Introduction to word pressIntroduction to word press
Introduction to word pressLucky Ali
 
Custome page template
Custome page templateCustome page template
Custome page templateLucky Ali
 
Post and page in word press
Post and page in word pressPost and page in word press
Post and page in word pressLucky 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

Salient features of Environment protection Act 1986.pptx
Salient features of Environment protection Act 1986.pptxSalient features of Environment protection Act 1986.pptx
Salient features of Environment protection Act 1986.pptxakshayaramakrishnan21
 
How to Manage Notification Preferences in the Odoo 17
How to Manage Notification Preferences in the Odoo 17How to Manage Notification Preferences in the Odoo 17
How to Manage Notification Preferences in the Odoo 17Celine George
 
ppt your views.ppt your views of your college in your eyes
ppt your views.ppt your views of your college in your eyesppt your views.ppt your views of your college in your eyes
ppt your views.ppt your views of your college in your eyesashishpaul799
 
IATP How-to Foreign Travel May 2024.pdff
IATP How-to Foreign Travel May 2024.pdffIATP How-to Foreign Travel May 2024.pdff
IATP How-to Foreign Travel May 2024.pdff17thcssbs2
 
Mbaye_Astou.Education Civica_Human Rights.pptx
Mbaye_Astou.Education Civica_Human Rights.pptxMbaye_Astou.Education Civica_Human Rights.pptx
Mbaye_Astou.Education Civica_Human Rights.pptxnuriaiuzzolino1
 
Championnat de France de Tennis de table/
Championnat de France de Tennis de table/Championnat de France de Tennis de table/
Championnat de France de Tennis de table/siemaillard
 
The Benefits and Challenges of Open Educational Resources
The Benefits and Challenges of Open Educational ResourcesThe Benefits and Challenges of Open Educational Resources
The Benefits and Challenges of Open Educational Resourcesaileywriter
 
The basics of sentences session 4pptx.pptx
The basics of sentences session 4pptx.pptxThe basics of sentences session 4pptx.pptx
The basics of sentences session 4pptx.pptxheathfieldcps1
 
50 ĐỀ LUYỆN THI IOE LỚP 9 - NĂM HỌC 2022-2023 (CÓ LINK HÌNH, FILE AUDIO VÀ ĐÁ...
50 ĐỀ LUYỆN THI IOE LỚP 9 - NĂM HỌC 2022-2023 (CÓ LINK HÌNH, FILE AUDIO VÀ ĐÁ...50 ĐỀ LUYỆN THI IOE LỚP 9 - NĂM HỌC 2022-2023 (CÓ LINK HÌNH, FILE AUDIO VÀ ĐÁ...
50 ĐỀ LUYỆN THI IOE LỚP 9 - NĂM HỌC 2022-2023 (CÓ LINK HÌNH, FILE AUDIO VÀ ĐÁ...Nguyen Thanh Tu Collection
 
會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽
會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽
會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽中 央社
 
factors influencing drug absorption-final-2.pptx
factors influencing drug absorption-final-2.pptxfactors influencing drug absorption-final-2.pptx
factors influencing drug absorption-final-2.pptxSanjay Shekar
 
Matatag-Curriculum and the 21st Century Skills Presentation.pptx
Matatag-Curriculum and the 21st Century Skills Presentation.pptxMatatag-Curriculum and the 21st Century Skills Presentation.pptx
Matatag-Curriculum and the 21st Century Skills Presentation.pptxJenilouCasareno
 
size separation d pharm 1st year pharmaceutics
size separation d pharm 1st year pharmaceuticssize separation d pharm 1st year pharmaceutics
size separation d pharm 1st year pharmaceuticspragatimahajan3
 
Removal Strategy _ FEFO _ Working with Perishable Products in Odoo 17
Removal Strategy _ FEFO _ Working with Perishable Products in Odoo 17Removal Strategy _ FEFO _ Working with Perishable Products in Odoo 17
Removal Strategy _ FEFO _ Working with Perishable Products in Odoo 17Celine George
 
UNIT – IV_PCI Complaints: Complaints and evaluation of complaints, Handling o...
UNIT – IV_PCI Complaints: Complaints and evaluation of complaints, Handling o...UNIT – IV_PCI Complaints: Complaints and evaluation of complaints, Handling o...
UNIT – IV_PCI Complaints: Complaints and evaluation of complaints, Handling o...Sayali Powar
 
....................Muslim-Law notes.pdf
....................Muslim-Law notes.pdf....................Muslim-Law notes.pdf
....................Muslim-Law notes.pdfVikramadityaRaj
 
會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文
會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文
會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文中 央社
 
Keeping Your Information Safe with Centralized Security Services
Keeping Your Information Safe with Centralized Security ServicesKeeping Your Information Safe with Centralized Security Services
Keeping Your Information Safe with Centralized Security ServicesTechSoup
 

Recently uploaded (20)

Salient features of Environment protection Act 1986.pptx
Salient features of Environment protection Act 1986.pptxSalient features of Environment protection Act 1986.pptx
Salient features of Environment protection Act 1986.pptx
 
How to Manage Notification Preferences in the Odoo 17
How to Manage Notification Preferences in the Odoo 17How to Manage Notification Preferences in the Odoo 17
How to Manage Notification Preferences in the Odoo 17
 
ppt your views.ppt your views of your college in your eyes
ppt your views.ppt your views of your college in your eyesppt your views.ppt your views of your college in your eyes
ppt your views.ppt your views of your college in your eyes
 
IATP How-to Foreign Travel May 2024.pdff
IATP How-to Foreign Travel May 2024.pdffIATP How-to Foreign Travel May 2024.pdff
IATP How-to Foreign Travel May 2024.pdff
 
Operations Management - Book1.p - Dr. Abdulfatah A. Salem
Operations Management - Book1.p  - Dr. Abdulfatah A. SalemOperations Management - Book1.p  - Dr. Abdulfatah A. Salem
Operations Management - Book1.p - Dr. Abdulfatah A. Salem
 
Mbaye_Astou.Education Civica_Human Rights.pptx
Mbaye_Astou.Education Civica_Human Rights.pptxMbaye_Astou.Education Civica_Human Rights.pptx
Mbaye_Astou.Education Civica_Human Rights.pptx
 
Championnat de France de Tennis de table/
Championnat de France de Tennis de table/Championnat de France de Tennis de table/
Championnat de France de Tennis de table/
 
The Benefits and Challenges of Open Educational Resources
The Benefits and Challenges of Open Educational ResourcesThe Benefits and Challenges of Open Educational Resources
The Benefits and Challenges of Open Educational Resources
 
The basics of sentences session 4pptx.pptx
The basics of sentences session 4pptx.pptxThe basics of sentences session 4pptx.pptx
The basics of sentences session 4pptx.pptx
 
50 ĐỀ LUYỆN THI IOE LỚP 9 - NĂM HỌC 2022-2023 (CÓ LINK HÌNH, FILE AUDIO VÀ ĐÁ...
50 ĐỀ LUYỆN THI IOE LỚP 9 - NĂM HỌC 2022-2023 (CÓ LINK HÌNH, FILE AUDIO VÀ ĐÁ...50 ĐỀ LUYỆN THI IOE LỚP 9 - NĂM HỌC 2022-2023 (CÓ LINK HÌNH, FILE AUDIO VÀ ĐÁ...
50 ĐỀ LUYỆN THI IOE LỚP 9 - NĂM HỌC 2022-2023 (CÓ LINK HÌNH, FILE AUDIO VÀ ĐÁ...
 
會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽
會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽
會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽
 
factors influencing drug absorption-final-2.pptx
factors influencing drug absorption-final-2.pptxfactors influencing drug absorption-final-2.pptx
factors influencing drug absorption-final-2.pptx
 
Matatag-Curriculum and the 21st Century Skills Presentation.pptx
Matatag-Curriculum and the 21st Century Skills Presentation.pptxMatatag-Curriculum and the 21st Century Skills Presentation.pptx
Matatag-Curriculum and the 21st Century Skills Presentation.pptx
 
B.ed spl. HI pdusu exam paper-2023-24.pdf
B.ed spl. HI pdusu exam paper-2023-24.pdfB.ed spl. HI pdusu exam paper-2023-24.pdf
B.ed spl. HI pdusu exam paper-2023-24.pdf
 
size separation d pharm 1st year pharmaceutics
size separation d pharm 1st year pharmaceuticssize separation d pharm 1st year pharmaceutics
size separation d pharm 1st year pharmaceutics
 
Removal Strategy _ FEFO _ Working with Perishable Products in Odoo 17
Removal Strategy _ FEFO _ Working with Perishable Products in Odoo 17Removal Strategy _ FEFO _ Working with Perishable Products in Odoo 17
Removal Strategy _ FEFO _ Working with Perishable Products in Odoo 17
 
UNIT – IV_PCI Complaints: Complaints and evaluation of complaints, Handling o...
UNIT – IV_PCI Complaints: Complaints and evaluation of complaints, Handling o...UNIT – IV_PCI Complaints: Complaints and evaluation of complaints, Handling o...
UNIT – IV_PCI Complaints: Complaints and evaluation of complaints, Handling o...
 
....................Muslim-Law notes.pdf
....................Muslim-Law notes.pdf....................Muslim-Law notes.pdf
....................Muslim-Law notes.pdf
 
會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文
會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文
會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文
 
Keeping Your Information Safe with Centralized Security Services
Keeping Your Information Safe with Centralized Security ServicesKeeping Your Information Safe with Centralized Security Services
Keeping Your Information Safe with Centralized Security Services
 

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.