SlideShare uma empresa Scribd logo
1 de 21
© Copyright 2010 Nibiru Solutions Private Limited 1
Presented by: Rakesh
2© Copyright 2010 Nibiru Solutions Private Limited 2
Agenda
Introduction
How to create wordpress plugin
How to create shortcode
How to create theme option
Quiz Questions
3© Copyright 2010 Nibiru Solutions Private Limited 3
Introduction
This session is very important and its very interesting.
In this session I cover some important worpress prebuild function
And there uses
Deep understanding of creating worpress plugin.
Creating wordpress shortcode and uses.
How to create theme options and uses
4© Copyright 2010 Nibiru Solutions Private Limited 4
How To Create Wordpress Plugin
WordPress is not just a blogging platform and it is such a
powerful CMS with unlimited capabilities, besides having
a huge user base.
Almost anything can be scripted with wordpress. You can
extend wordpress either by means of plugin or by a theme.
i will show you how to write a “Hello World” wordpress
plugin, which unlike many believe is surprisingly easy,
once you understand the very fundamentals.
5© Copyright 2010 Nibiru Solutions Private Limited 5
How To Create Wordpress Plugin -2
Plugin Files & Names
1. Always you chose a unique name to your plugin so that it doesnt
collide with names used in other plugins.
2. Assigning unique names, documenting and organizing the
plugin files is very important part of plugin creation.
3- place the plugin php file directly into the wp-
content/plugins folder
http://wordpress.org/plugins/about/readme.txt
6© Copyright 2010 Nibiru Solutions Private Limited 6
How To Create Wordpress Plugin -3
The Plugin Basics
The heart of a wordpress plugins is the below 2 functions
(commonly called `hooks`)
add_action ($tag, $func)
add_filter ($tag,$func)
add_action –> does an action at various points of wordpress
execution
add_filter –> does filtering the data (eg. escaping quotes before mysql
insert, or during output to browser.
7© Copyright 2010 Nibiru Solutions Private Limited 7
How To Create Wordpress Plugin -4
Plugin Information
Open your hello-world.php and in the first line, add this commented plugin
information to your file.
<?php
/*
Plugin Name: Hello-World Plugin
URI: http://yourdomain.com/
Description: A simple hello world wordpress plugin
Version: 1.0
Author: Your Name
Author URI: http://yourdomain.com
License: GPL
*/
?>
Save file.
8© Copyright 2010 Nibiru Solutions Private Limited 8
How To Create Wordpress Plugin -5
Go to your wordpress admin > plugins and you will see the new
plugin listed, waiting to get activated.
But this plugin had to do something right?
-> For that we write the code using add_action below the commented plugin
information in the hello-world.php
9© Copyright 2010 Nibiru Solutions Private Limited 9
How To Create Wordpress Plugin -6
<?php
/* This calls hello_world() function when wordpress initializes.*/
add_action('init','hello_world');
function hello_world() {
echo "Hello World";
}
?>
And Your Plugin done!
When our plugin is activated, add_action command calls our hello_world() function
when wordpress starts loading.
To test Open Any index.php , page.php or single.php And place the
following code.
<?php
if(function_exists('hello_world')) {
hello_world();
}
?>
10© Copyright 2010 Nibiru Solutions Private Limited 10
Build a plugin options page in admin area :
The plugin outputs hello world (its pretty much static).
So make this to dynamic we need to create a good admin interface.
Here is what we do….
We create a options menu for Hello World in WordPress Admin > Settings.
We save the user entered data in the wordpress database. Using set_options()
function.
We retrieve the data stored in wordpress database and output it using
get_options() function.
11© Copyright 2010 Nibiru Solutions Private Limited 11
Activating/Deactivating Plugin
It is very easy to write a function on what plugin does, when it gets
activated. WordPress offers 4 very important functions
register_activation_hook -> Runs on plugin activation
register_deactivation_hook -> Runs on plugin deactivation
add_option -> Creates new database field
get_option -> Retrieves the value in database field.
12© Copyright 2010 Nibiru Solutions Private Limited 12
Activating/Deactivating Plugin -2
Example : write fallowing code in hello-word.php
<?php
/* Runs when plugin is activated */
register_activation_hook(__FILE__,'hello_world_install');
/* Runs on plugin deactivation*/
register_deactivation_hook( __FILE__, 'hello_world_remove' );
function hello_world_install() {
/* Creates new database field */
add_option("hello_world_data", 'Default', '', 'yes');
}
function hello_world_remove() {
/* Deletes the database field */
delete_option('hello_world_data');
}
?>
13© Copyright 2010 Nibiru Solutions Private Limited 13
Plugin Settings Page
All we need to create is plugin settings page in the wordpress admin area.
<?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');
}
} ?>
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.
This is how the code should flow! Refer to wordpress administration menus
14© Copyright 2010 Nibiru Solutions Private Limited 14
Plugin Settings Page – Coding Part -1
The below function has the html code for the settings page,
containing the form
<?php
function hello_world_html_page() {
?>
<div>
<h2>Hello World Options</h2>
<form method="post" action="options.php">
<?php wp_nonce_field('update-options'); ?>
<table width="510">
<tr valign="top">
<th width="92" scope="row">Enter Text</th>
<td width="406">
15© Copyright 2010 Nibiru Solutions Private Limited 15
Plugin Settings Page – Coding Part -2
<input name="hello_world_data" type="text" id="hello_world_data"
value="<?php echo get_option('hello_world_data'); ?>" />
(ex. Hello World)</td>
</tr>
</table>
<input type="hidden" name="action" value="update" />
<input type="hidden" name="page_options" value="hello_world_data" />
<p>
<input type="submit" value="<?php _e('Save Changes') ?>" />
</p>
</form>
</div>
<?php } ?>
16© Copyright 2010 Nibiru Solutions Private Limited 16
Plugin Settings Page – Coding Part -3
And finally your plugin ready and looks like following.
You must remember 2 things in the above code.
1. Specify the database field we created before in the input text box as `hello_world_data`.
<input name="hello_world_data" type="text" id="hello_world_data“ value="<?php echo
get_option('hello_world_data'); ?>" />
2. If your form has number of fields (like textbox, selectbox etc), all those should be listed
in the value field of page_options, separated by commas. For more information, refer
to wordpress documentation
<input type="hidden" name="page_options" value="hello_world_data" />
17© Copyright 2010 Nibiru Solutions Private Limited 17
Wwordpres Shortcode
The Shortcode API
 Introduced in WordPress 2.5
 A simple set of functions for creating macro codes for use in post content.
 And a simple shortcode used like [shotcode].
Lets Create a shortcode of Hello Word plugin
<?php
function show_hello_text() {
return get_option('hello_world_data');
}
add_shortcode('showtext', 'show_hello_text');
?>
Use the shortcode [showtext] into page or post content to show your hello world text.
18© Copyright 2010 Nibiru Solutions Private Limited 18
How to create custom them option
If you create your own themes you will, sooner or later, want to allow
your theme users have some control over certain appearance and/or
functional elements of your theme.
19© Copyright 2010 Nibiru Solutions Private Limited 19
How to create custom them option -2
This commonly use following functions.
add_action( $tag, $function_to_add, $priority, $accepted_args );
register_setting( $option_group, $option_name, $sanitize_callback )
add_theme_page( $page_title, $menu_title, $capability, $menu_slug, $function );
settings_fields( $option_group )
## coding section
<? php
add_action( 'admin_init', 'theme_options_init' );
add_action( 'admin_menu', 'theme_options_add_page' );
function theme_options_init(){
register_setting( 'sample_options', 'sample_theme_options');
}
function theme_options_add_page() {
add_theme_page( __( 'Theme Options', 'sampletheme' ), __( 'Theme
Options', 'sampletheme' ), 'edit_theme_options', 'theme_options',
'theme_options_do_page' );
}
1- this used in setting_fields();
2- this function name and its used html
20© Copyright 2010 Nibiru Solutions Private Limited 20
How to create custom them option -3
function theme_options_do_page() {
global $select_options;
<form method="post" action="options.php">
<?php settings_fields( 'sample_options' ); ?>
<?php $options = get_option( 'sample_theme_options' ); ?>
<input id="sample_theme_options[showintro]" name="sample_theme_options[showintro]"
type="checkbox" value="1“ <?php checked( '1', $options['showintro'] ); ?> />
<input id="sample_theme_options[fburl]" type="text"
name="sample_theme_options[fburl]" value="<?php esc_attr_e( $options['fburl'] ); ?
>" />
<textarea id="sample_theme_options[introtext]"
class="large-text" cols="50" rows="10" name="sample_theme_options[introtext]"><?php
echo esc_textarea( $options['introtext'] ); ?></textarea>
<input type="submit" value="<?php _e( 'Save Options', 'customtheme' ); ?>" />
</form>
} ?>
1
2
21© Copyright 2010 Nibiru Solutions Private Limited 21
The End Of Then Session
Thank You !

Mais conteúdo relacionado

Mais procurados

Php login system with admin features evolt
Php login system with admin features   evoltPhp login system with admin features   evolt
Php login system with admin features evoltGIMT
 
Getting Into Drupal 8 Configuration
Getting Into Drupal 8 ConfigurationGetting Into Drupal 8 Configuration
Getting Into Drupal 8 ConfigurationPhilip Norton
 
20190118_NetadashiMeetup#8_React2019
20190118_NetadashiMeetup#8_React201920190118_NetadashiMeetup#8_React2019
20190118_NetadashiMeetup#8_React2019Makoto Mori
 
Your Business. Your Language. Your Code - dpc13
Your Business. Your Language. Your Code - dpc13Your Business. Your Language. Your Code - dpc13
Your Business. Your Language. Your Code - dpc13Stephan Hochdörfer
 
Login and Registration form using oop in php
Login and Registration form using oop in phpLogin and Registration form using oop in php
Login and Registration form using oop in phpherat university
 
Drupal 8 Services And Dependency Injection
Drupal 8 Services And Dependency InjectionDrupal 8 Services And Dependency Injection
Drupal 8 Services And Dependency InjectionPhilip Norton
 
WordPress Security - WordCamp Boston 2010
WordPress Security - WordCamp Boston 2010WordPress Security - WordCamp Boston 2010
WordPress Security - WordCamp Boston 2010Brad 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
 
Maven 3… so what?
Maven 3… so what?Maven 3… so what?
Maven 3… so what?Abel Muíño
 
How to configure PyCharm for Odoo development in Windows?
How to configure PyCharm for Odoo development in Windows?How to configure PyCharm for Odoo development in Windows?
How to configure PyCharm for Odoo development in Windows?Celine George
 
Firefox extension Development
Firefox extension DevelopmentFirefox extension Development
Firefox extension DevelopmentAbhinav Chittora
 
Gail villanueva add muscle to your wordpress site
Gail villanueva   add muscle to your wordpress siteGail villanueva   add muscle to your wordpress site
Gail villanueva add muscle to your wordpress sitereferences
 
Best practices in WordPress Development
Best practices in WordPress DevelopmentBest practices in WordPress Development
Best practices in WordPress DevelopmentMindfire Solutions
 
Django app deployment in Azure By Saurabh Agarwal
Django app deployment in Azure By Saurabh AgarwalDjango app deployment in Azure By Saurabh Agarwal
Django app deployment in Azure By Saurabh Agarwalratneshsinghparihar
 
Flutter movie apps tutor
Flutter movie apps tutorFlutter movie apps tutor
Flutter movie apps tutorHerry Prasetyo
 
Build website in_django
Build website in_django Build website in_django
Build website in_django swee meng ng
 

Mais procurados (20)

Php login system with admin features evolt
Php login system with admin features   evoltPhp login system with admin features   evolt
Php login system with admin features evolt
 
Getting Into Drupal 8 Configuration
Getting Into Drupal 8 ConfigurationGetting Into Drupal 8 Configuration
Getting Into Drupal 8 Configuration
 
20190118_NetadashiMeetup#8_React2019
20190118_NetadashiMeetup#8_React201920190118_NetadashiMeetup#8_React2019
20190118_NetadashiMeetup#8_React2019
 
Your Business. Your Language. Your Code - dpc13
Your Business. Your Language. Your Code - dpc13Your Business. Your Language. Your Code - dpc13
Your Business. Your Language. Your Code - dpc13
 
Login and Registration form using oop in php
Login and Registration form using oop in phpLogin and Registration form using oop in php
Login and Registration form using oop in php
 
HTML5와 모바일
HTML5와 모바일HTML5와 모바일
HTML5와 모바일
 
Drupal 8 Services And Dependency Injection
Drupal 8 Services And Dependency InjectionDrupal 8 Services And Dependency Injection
Drupal 8 Services And Dependency Injection
 
WordPress Security - WordCamp Boston 2010
WordPress Security - WordCamp Boston 2010WordPress Security - WordCamp Boston 2010
WordPress Security - WordCamp Boston 2010
 
Drupal 8 Services
Drupal 8 ServicesDrupal 8 Services
Drupal 8 Services
 
Bending word press to your will
Bending word press to your willBending word press to your will
Bending word press to your will
 
Maven 3… so what?
Maven 3… so what?Maven 3… so what?
Maven 3… so what?
 
WordPress and Ajax
WordPress and AjaxWordPress and Ajax
WordPress and Ajax
 
How to configure PyCharm for Odoo development in Windows?
How to configure PyCharm for Odoo development in Windows?How to configure PyCharm for Odoo development in Windows?
How to configure PyCharm for Odoo development in Windows?
 
Firefox extension Development
Firefox extension DevelopmentFirefox extension Development
Firefox extension Development
 
Gail villanueva add muscle to your wordpress site
Gail villanueva   add muscle to your wordpress siteGail villanueva   add muscle to your wordpress site
Gail villanueva add muscle to your wordpress site
 
Best practices in WordPress Development
Best practices in WordPress DevelopmentBest practices in WordPress Development
Best practices in WordPress Development
 
Creating a basic joomla
Creating a basic joomlaCreating a basic joomla
Creating a basic joomla
 
Django app deployment in Azure By Saurabh Agarwal
Django app deployment in Azure By Saurabh AgarwalDjango app deployment in Azure By Saurabh Agarwal
Django app deployment in Azure By Saurabh Agarwal
 
Flutter movie apps tutor
Flutter movie apps tutorFlutter movie apps tutor
Flutter movie apps tutor
 
Build website in_django
Build website in_django Build website in_django
Build website in_django
 

Semelhante a WordPress basic fundamental of plugin development and creating shortcode

Plug in development
Plug in developmentPlug in development
Plug in developmentLucky Ali
 
Write your first WordPress plugin
Write your first WordPress pluginWrite your first WordPress plugin
Write your first WordPress pluginAnthony Montalbano
 
Intro to WordPress Plugin Development
Intro to WordPress Plugin DevelopmentIntro to WordPress Plugin Development
Intro to WordPress Plugin DevelopmentBrad Williams
 
Getting started with WordPress development
Getting started with WordPress developmentGetting started with WordPress development
Getting started with WordPress developmentSteve Mortiboy
 
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
 
Creating Your First WordPress Plugin
Creating Your First WordPress PluginCreating Your First WordPress Plugin
Creating Your First WordPress PluginBrad Williams
 
Complete Wordpress Security By CHETAN SONI - Cyber Security Expert
Complete Wordpress Security By CHETAN SONI - Cyber Security ExpertComplete Wordpress Security By CHETAN SONI - Cyber Security Expert
Complete Wordpress Security By CHETAN SONI - Cyber Security ExpertChetan Soni
 
Introduction to Mangento
Introduction to Mangento Introduction to Mangento
Introduction to Mangento Ravi Mehrotra
 
Creating Openbravo Workspace Widgets
Creating Openbravo Workspace WidgetsCreating Openbravo Workspace Widgets
Creating Openbravo Workspace WidgetsRob Goris
 
Plugin development demystified 2017
Plugin development demystified 2017Plugin development demystified 2017
Plugin development demystified 2017ylefebvre
 
Simple module Development in Joomla! 2.5
Simple module Development in Joomla! 2.5Simple module Development in Joomla! 2.5
Simple module Development in Joomla! 2.5Vishwash Gaur
 
Working With The Symfony Admin Generator
Working With The Symfony Admin GeneratorWorking With The Symfony Admin Generator
Working With The Symfony Admin GeneratorJohn Cleveley
 
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
 
CodeIgniter PHP MVC Framework
CodeIgniter PHP MVC FrameworkCodeIgniter PHP MVC Framework
CodeIgniter PHP MVC FrameworkBo-Yi Wu
 
Behavior & Specification Driven Development in PHP - #OpenWest
Behavior & Specification Driven Development in PHP - #OpenWestBehavior & Specification Driven Development in PHP - #OpenWest
Behavior & Specification Driven Development in PHP - #OpenWestJoshua Warren
 
WordPress Developers Israel Meetup #1
WordPress Developers Israel Meetup #1WordPress Developers Israel Meetup #1
WordPress Developers Israel Meetup #1Yoav Farhi
 
WordPress Plugin Development- Rich Media Institute Workshop
WordPress Plugin Development- Rich Media Institute WorkshopWordPress Plugin Development- Rich Media Institute Workshop
WordPress Plugin Development- Rich Media Institute WorkshopBrendan Sera-Shriar
 
WordPress Plugins
WordPress PluginsWordPress Plugins
WordPress Pluginsrandyhoyt
 

Semelhante a WordPress basic fundamental of plugin development and creating shortcode (20)

Plug in development
Plug in developmentPlug in development
Plug in development
 
Write your first WordPress plugin
Write your first WordPress pluginWrite your first WordPress plugin
Write your first WordPress plugin
 
Wordpress as a framework
Wordpress as a frameworkWordpress as a framework
Wordpress as a framework
 
Intro to WordPress Plugin Development
Intro to WordPress Plugin DevelopmentIntro to WordPress Plugin Development
Intro to WordPress Plugin Development
 
Getting started with WordPress development
Getting started with WordPress developmentGetting started with WordPress development
Getting started with WordPress development
 
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)
 
Creating Your First WordPress Plugin
Creating Your First WordPress PluginCreating Your First WordPress Plugin
Creating Your First WordPress Plugin
 
Complete Wordpress Security By CHETAN SONI - Cyber Security Expert
Complete Wordpress Security By CHETAN SONI - Cyber Security ExpertComplete Wordpress Security By CHETAN SONI - Cyber Security Expert
Complete Wordpress Security By CHETAN SONI - Cyber Security Expert
 
Introduction to Mangento
Introduction to Mangento Introduction to Mangento
Introduction to Mangento
 
Mangento
MangentoMangento
Mangento
 
Creating Openbravo Workspace Widgets
Creating Openbravo Workspace WidgetsCreating Openbravo Workspace Widgets
Creating Openbravo Workspace Widgets
 
Plugin development demystified 2017
Plugin development demystified 2017Plugin development demystified 2017
Plugin development demystified 2017
 
Simple module Development in Joomla! 2.5
Simple module Development in Joomla! 2.5Simple module Development in Joomla! 2.5
Simple module Development in Joomla! 2.5
 
Working With The Symfony Admin Generator
Working With The Symfony Admin GeneratorWorking With The Symfony Admin Generator
Working With The Symfony Admin Generator
 
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
 
CodeIgniter PHP MVC Framework
CodeIgniter PHP MVC FrameworkCodeIgniter PHP MVC Framework
CodeIgniter PHP MVC Framework
 
Behavior & Specification Driven Development in PHP - #OpenWest
Behavior & Specification Driven Development in PHP - #OpenWestBehavior & Specification Driven Development in PHP - #OpenWest
Behavior & Specification Driven Development in PHP - #OpenWest
 
WordPress Developers Israel Meetup #1
WordPress Developers Israel Meetup #1WordPress Developers Israel Meetup #1
WordPress Developers Israel Meetup #1
 
WordPress Plugin Development- Rich Media Institute Workshop
WordPress Plugin Development- Rich Media Institute WorkshopWordPress Plugin Development- Rich Media Institute Workshop
WordPress Plugin Development- Rich Media Institute Workshop
 
WordPress Plugins
WordPress PluginsWordPress Plugins
WordPress Plugins
 

Último

SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxSOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxiammrhaywood
 
Sports & Fitness Value Added Course FY..
Sports & Fitness Value Added Course FY..Sports & Fitness Value Added Course FY..
Sports & Fitness Value Added Course FY..Disha Kariya
 
Measures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeMeasures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeThiyagu K
 
Class 11th Physics NEET formula sheet pdf
Class 11th Physics NEET formula sheet pdfClass 11th Physics NEET formula sheet pdf
Class 11th Physics NEET formula sheet pdfAyushMahapatra5
 
1029-Danh muc Sach Giao Khoa khoi 6.pdf
1029-Danh muc Sach Giao Khoa khoi  6.pdf1029-Danh muc Sach Giao Khoa khoi  6.pdf
1029-Danh muc Sach Giao Khoa khoi 6.pdfQucHHunhnh
 
Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104misteraugie
 
Making and Justifying Mathematical Decisions.pdf
Making and Justifying Mathematical Decisions.pdfMaking and Justifying Mathematical Decisions.pdf
Making and Justifying Mathematical Decisions.pdfChris Hunter
 
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...EduSkills OECD
 
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in DelhiRussian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhikauryashika82
 
The basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxThe basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxheathfieldcps1
 
Grant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingGrant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingTechSoup
 
1029 - Danh muc Sach Giao Khoa 10 . pdf
1029 -  Danh muc Sach Giao Khoa 10 . pdf1029 -  Danh muc Sach Giao Khoa 10 . pdf
1029 - Danh muc Sach Giao Khoa 10 . pdfQucHHunhnh
 
microwave assisted reaction. General introduction
microwave assisted reaction. General introductionmicrowave assisted reaction. General introduction
microwave assisted reaction. General introductionMaksud Ahmed
 
Z Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot GraphZ Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot GraphThiyagu K
 
Accessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactAccessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactdawncurless
 
Application orientated numerical on hev.ppt
Application orientated numerical on hev.pptApplication orientated numerical on hev.ppt
Application orientated numerical on hev.pptRamjanShidvankar
 
PROCESS RECORDING FORMAT.docx
PROCESS      RECORDING        FORMAT.docxPROCESS      RECORDING        FORMAT.docx
PROCESS RECORDING FORMAT.docxPoojaSen20
 
Unit-IV; Professional Sales Representative (PSR).pptx
Unit-IV; Professional Sales Representative (PSR).pptxUnit-IV; Professional Sales Representative (PSR).pptx
Unit-IV; Professional Sales Representative (PSR).pptxVishalSingh1417
 
fourth grading exam for kindergarten in writing
fourth grading exam for kindergarten in writingfourth grading exam for kindergarten in writing
fourth grading exam for kindergarten in writingTeacherCyreneCayanan
 

Último (20)

SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxSOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
 
Sports & Fitness Value Added Course FY..
Sports & Fitness Value Added Course FY..Sports & Fitness Value Added Course FY..
Sports & Fitness Value Added Course FY..
 
Measures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeMeasures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and Mode
 
Class 11th Physics NEET formula sheet pdf
Class 11th Physics NEET formula sheet pdfClass 11th Physics NEET formula sheet pdf
Class 11th Physics NEET formula sheet pdf
 
1029-Danh muc Sach Giao Khoa khoi 6.pdf
1029-Danh muc Sach Giao Khoa khoi  6.pdf1029-Danh muc Sach Giao Khoa khoi  6.pdf
1029-Danh muc Sach Giao Khoa khoi 6.pdf
 
Mattingly "AI & Prompt Design: The Basics of Prompt Design"
Mattingly "AI & Prompt Design: The Basics of Prompt Design"Mattingly "AI & Prompt Design: The Basics of Prompt Design"
Mattingly "AI & Prompt Design: The Basics of Prompt Design"
 
Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104
 
Making and Justifying Mathematical Decisions.pdf
Making and Justifying Mathematical Decisions.pdfMaking and Justifying Mathematical Decisions.pdf
Making and Justifying Mathematical Decisions.pdf
 
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
 
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in DelhiRussian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
 
The basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxThe basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptx
 
Grant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingGrant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy Consulting
 
1029 - Danh muc Sach Giao Khoa 10 . pdf
1029 -  Danh muc Sach Giao Khoa 10 . pdf1029 -  Danh muc Sach Giao Khoa 10 . pdf
1029 - Danh muc Sach Giao Khoa 10 . pdf
 
microwave assisted reaction. General introduction
microwave assisted reaction. General introductionmicrowave assisted reaction. General introduction
microwave assisted reaction. General introduction
 
Z Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot GraphZ Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot Graph
 
Accessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactAccessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impact
 
Application orientated numerical on hev.ppt
Application orientated numerical on hev.pptApplication orientated numerical on hev.ppt
Application orientated numerical on hev.ppt
 
PROCESS RECORDING FORMAT.docx
PROCESS      RECORDING        FORMAT.docxPROCESS      RECORDING        FORMAT.docx
PROCESS RECORDING FORMAT.docx
 
Unit-IV; Professional Sales Representative (PSR).pptx
Unit-IV; Professional Sales Representative (PSR).pptxUnit-IV; Professional Sales Representative (PSR).pptx
Unit-IV; Professional Sales Representative (PSR).pptx
 
fourth grading exam for kindergarten in writing
fourth grading exam for kindergarten in writingfourth grading exam for kindergarten in writing
fourth grading exam for kindergarten in writing
 

WordPress basic fundamental of plugin development and creating shortcode

  • 1. © Copyright 2010 Nibiru Solutions Private Limited 1 Presented by: Rakesh
  • 2. 2© Copyright 2010 Nibiru Solutions Private Limited 2 Agenda Introduction How to create wordpress plugin How to create shortcode How to create theme option Quiz Questions
  • 3. 3© Copyright 2010 Nibiru Solutions Private Limited 3 Introduction This session is very important and its very interesting. In this session I cover some important worpress prebuild function And there uses Deep understanding of creating worpress plugin. Creating wordpress shortcode and uses. How to create theme options and uses
  • 4. 4© Copyright 2010 Nibiru Solutions Private Limited 4 How To Create Wordpress Plugin WordPress is not just a blogging platform and it is such a powerful CMS with unlimited capabilities, besides having a huge user base. Almost anything can be scripted with wordpress. You can extend wordpress either by means of plugin or by a theme. i will show you how to write a “Hello World” wordpress plugin, which unlike many believe is surprisingly easy, once you understand the very fundamentals.
  • 5. 5© Copyright 2010 Nibiru Solutions Private Limited 5 How To Create Wordpress Plugin -2 Plugin Files & Names 1. Always you chose a unique name to your plugin so that it doesnt collide with names used in other plugins. 2. Assigning unique names, documenting and organizing the plugin files is very important part of plugin creation. 3- place the plugin php file directly into the wp- content/plugins folder http://wordpress.org/plugins/about/readme.txt
  • 6. 6© Copyright 2010 Nibiru Solutions Private Limited 6 How To Create Wordpress Plugin -3 The Plugin Basics The heart of a wordpress plugins is the below 2 functions (commonly called `hooks`) add_action ($tag, $func) add_filter ($tag,$func) add_action –> does an action at various points of wordpress execution add_filter –> does filtering the data (eg. escaping quotes before mysql insert, or during output to browser.
  • 7. 7© Copyright 2010 Nibiru Solutions Private Limited 7 How To Create Wordpress Plugin -4 Plugin Information Open your hello-world.php and in the first line, add this commented plugin information to your file. <?php /* Plugin Name: Hello-World Plugin URI: http://yourdomain.com/ Description: A simple hello world wordpress plugin Version: 1.0 Author: Your Name Author URI: http://yourdomain.com License: GPL */ ?> Save file.
  • 8. 8© Copyright 2010 Nibiru Solutions Private Limited 8 How To Create Wordpress Plugin -5 Go to your wordpress admin > plugins and you will see the new plugin listed, waiting to get activated. But this plugin had to do something right? -> For that we write the code using add_action below the commented plugin information in the hello-world.php
  • 9. 9© Copyright 2010 Nibiru Solutions Private Limited 9 How To Create Wordpress Plugin -6 <?php /* This calls hello_world() function when wordpress initializes.*/ add_action('init','hello_world'); function hello_world() { echo "Hello World"; } ?> And Your Plugin done! When our plugin is activated, add_action command calls our hello_world() function when wordpress starts loading. To test Open Any index.php , page.php or single.php And place the following code. <?php if(function_exists('hello_world')) { hello_world(); } ?>
  • 10. 10© Copyright 2010 Nibiru Solutions Private Limited 10 Build a plugin options page in admin area : The plugin outputs hello world (its pretty much static). So make this to dynamic we need to create a good admin interface. Here is what we do…. We create a options menu for Hello World in WordPress Admin > Settings. We save the user entered data in the wordpress database. Using set_options() function. We retrieve the data stored in wordpress database and output it using get_options() function.
  • 11. 11© Copyright 2010 Nibiru Solutions Private Limited 11 Activating/Deactivating Plugin It is very easy to write a function on what plugin does, when it gets activated. WordPress offers 4 very important functions register_activation_hook -> Runs on plugin activation register_deactivation_hook -> Runs on plugin deactivation add_option -> Creates new database field get_option -> Retrieves the value in database field.
  • 12. 12© Copyright 2010 Nibiru Solutions Private Limited 12 Activating/Deactivating Plugin -2 Example : write fallowing code in hello-word.php <?php /* Runs when plugin is activated */ register_activation_hook(__FILE__,'hello_world_install'); /* Runs on plugin deactivation*/ register_deactivation_hook( __FILE__, 'hello_world_remove' ); function hello_world_install() { /* Creates new database field */ add_option("hello_world_data", 'Default', '', 'yes'); } function hello_world_remove() { /* Deletes the database field */ delete_option('hello_world_data'); } ?>
  • 13. 13© Copyright 2010 Nibiru Solutions Private Limited 13 Plugin Settings Page All we need to create is plugin settings page in the wordpress admin area. <?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'); } } ?> 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. This is how the code should flow! Refer to wordpress administration menus
  • 14. 14© Copyright 2010 Nibiru Solutions Private Limited 14 Plugin Settings Page – Coding Part -1 The below function has the html code for the settings page, containing the form <?php function hello_world_html_page() { ?> <div> <h2>Hello World Options</h2> <form method="post" action="options.php"> <?php wp_nonce_field('update-options'); ?> <table width="510"> <tr valign="top"> <th width="92" scope="row">Enter Text</th> <td width="406">
  • 15. 15© Copyright 2010 Nibiru Solutions Private Limited 15 Plugin Settings Page – Coding Part -2 <input name="hello_world_data" type="text" id="hello_world_data" value="<?php echo get_option('hello_world_data'); ?>" /> (ex. Hello World)</td> </tr> </table> <input type="hidden" name="action" value="update" /> <input type="hidden" name="page_options" value="hello_world_data" /> <p> <input type="submit" value="<?php _e('Save Changes') ?>" /> </p> </form> </div> <?php } ?>
  • 16. 16© Copyright 2010 Nibiru Solutions Private Limited 16 Plugin Settings Page – Coding Part -3 And finally your plugin ready and looks like following. You must remember 2 things in the above code. 1. Specify the database field we created before in the input text box as `hello_world_data`. <input name="hello_world_data" type="text" id="hello_world_data“ value="<?php echo get_option('hello_world_data'); ?>" /> 2. If your form has number of fields (like textbox, selectbox etc), all those should be listed in the value field of page_options, separated by commas. For more information, refer to wordpress documentation <input type="hidden" name="page_options" value="hello_world_data" />
  • 17. 17© Copyright 2010 Nibiru Solutions Private Limited 17 Wwordpres Shortcode The Shortcode API  Introduced in WordPress 2.5  A simple set of functions for creating macro codes for use in post content.  And a simple shortcode used like [shotcode]. Lets Create a shortcode of Hello Word plugin <?php function show_hello_text() { return get_option('hello_world_data'); } add_shortcode('showtext', 'show_hello_text'); ?> Use the shortcode [showtext] into page or post content to show your hello world text.
  • 18. 18© Copyright 2010 Nibiru Solutions Private Limited 18 How to create custom them option If you create your own themes you will, sooner or later, want to allow your theme users have some control over certain appearance and/or functional elements of your theme.
  • 19. 19© Copyright 2010 Nibiru Solutions Private Limited 19 How to create custom them option -2 This commonly use following functions. add_action( $tag, $function_to_add, $priority, $accepted_args ); register_setting( $option_group, $option_name, $sanitize_callback ) add_theme_page( $page_title, $menu_title, $capability, $menu_slug, $function ); settings_fields( $option_group ) ## coding section <? php add_action( 'admin_init', 'theme_options_init' ); add_action( 'admin_menu', 'theme_options_add_page' ); function theme_options_init(){ register_setting( 'sample_options', 'sample_theme_options'); } function theme_options_add_page() { add_theme_page( __( 'Theme Options', 'sampletheme' ), __( 'Theme Options', 'sampletheme' ), 'edit_theme_options', 'theme_options', 'theme_options_do_page' ); } 1- this used in setting_fields(); 2- this function name and its used html
  • 20. 20© Copyright 2010 Nibiru Solutions Private Limited 20 How to create custom them option -3 function theme_options_do_page() { global $select_options; <form method="post" action="options.php"> <?php settings_fields( 'sample_options' ); ?> <?php $options = get_option( 'sample_theme_options' ); ?> <input id="sample_theme_options[showintro]" name="sample_theme_options[showintro]" type="checkbox" value="1“ <?php checked( '1', $options['showintro'] ); ?> /> <input id="sample_theme_options[fburl]" type="text" name="sample_theme_options[fburl]" value="<?php esc_attr_e( $options['fburl'] ); ? >" /> <textarea id="sample_theme_options[introtext]" class="large-text" cols="50" rows="10" name="sample_theme_options[introtext]"><?php echo esc_textarea( $options['introtext'] ); ?></textarea> <input type="submit" value="<?php _e( 'Save Options', 'customtheme' ); ?>" /> </form> } ?> 1 2
  • 21. 21© Copyright 2010 Nibiru Solutions Private Limited 21 The End Of Then Session Thank You !