SlideShare a Scribd company logo
Developing WordPress Plugins Markku Seguerra http://rebelpixel.com
What is a WordPress plugin? Little applications used to enhance functionality or add specific functions tailored to a site's specific needs.
Some plugins: - Akismet - WordPress Database Backup - WordPress.com Stats - wp-recent-links - Comment Hilite
What do you need to make a plugin? - a problem to solve - some PHP knowledge - some spare time - a test server with your test WordPress (XAMPP is good.)‏
Structure: Things to remember - A unique descriptive name - Naming: myplugin.php or /myplugin/ folder - Readme.txt format for wordpress.org/extend/plugins - Plugin home page - File headers (very important!)‏
Headers <?php /* Plugin Name:  Name Of The Plugin Plugin URI:  http://mypage.com/myplugin/ Description:  What does it do? Version:  1.0 Author:  Name Of The Plugin Author Author URI:  http://mypage.com/ */ ?>
Include your license details! The GPL (and compatible licenses) is commonly used for plugins.
Plugin Programming Before WP 1.2, customizations required altering the core files, causing conflicts among hacks (remember my-hacks.php?) and making upgrades very tedious. The solution?
Plugin API - Enabled &quot;hooks&quot; - Extend functionality without editing the core code - Two categories: Actions and Filters
Actions Specific points in the WordPress code that can be used to trigger plugin-specified events and functions. add_action( 'hook_name', 'your_function_name', [priority], [accepted_args] );
Sample action: “wp_login” function notify_on_login()‏ { // your code here // email to admin, etc... } add_action('wp_login', 'notify_on_login');
Filters Functions that modify text, lists and various types of information that are used and produced by WordPress. add_filter('hook_name', 'your_filter_function', [priority], [accepted_args]);
Sample filter: “the_content” function add_rss_invite()‏ { // output to screen the link to RSS feed // if 1st time visitor } add_filter('the_content', 'add_rss_invite');
Template Tags Plugins can also be used to generate special template tags that display custom content. - Recent comments - Top posts - Ad display
Storing Plugin Data - For large amount of data, create your own database table. - For fairly small and/or static data, use built-in WP &quot;Options&quot; capability. add_option($name, $value, $deprecated, $autoload); get_option($option); update_option($option_name, $newvalue);
Administration Menus & Pages - There are specific functions to add pages and menu items. add_menu_page(page_title, menu_title, access_level/capability, file, [function]); add_submenu_page();  add_options_page(); add_management_page(); add_theme_page();
Other things to consider - Internationalization - WordPress Coding Standards & inline documentation - Function prefixes to avoid name collision - When creating tables, use $wpdb->prefix - Minimize database writes. - Write secure code! (Use nonces, sanitize, etc.)‏ - Be aware of user roles and capabilities. - Stick to the WordPress API to avoid problems!
Sample plugin: Strip! <?php /* Plugin Name: Strip! Plugin URI: http://rebelpixel.com/ Description: Removes hyperlink tags from a given comment. Version: 0.1 Author: Markku Seguerra Author URI: http://rebelpixel.com/projects/strip/ */
/*  Copyright 2008  Markku Seguerra  (email : markku@gmail.com)‏ This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA */
add_filter('comment_text', 'strip_comments_add_admin'); function strip_comments_add_admin($text)‏ { // add the strip button to the comment } add_filter('comment_text', 'strip_comments_add'); add_filter('get_comment_author_link', 'strip_comments_add'); function strip_comments_add($text)‏ { // mark the comment as stripped and displays // it without links }
add_action('wp_ajax_strip', 'do_strip'); function do_strip()‏ { // function to mark comment as stripped // triggered via ajax } add_action('wp_ajax_unstrip', 'do_unstrip'); function do_unstrip()‏ { // function to mark comment as stripped } function strip_selected_tags($text, $tags = array())‏ { // our filter function that removes links }
add_action('admin_head', 'strip_comments_head'); function strip_comments_head()‏ { // show the necessary css and ajax // functions used in the admin interface }
<script type=&quot;text/javascript&quot;> //<![CDATA[ function strip_now(cid) { jQuery.post(&quot;<?php echo get_option('siteurl'); ?>/wp-admin/admin-ajax.php&quot;, {action:&quot;strip&quot;, &quot;c&quot;:cid, &quot;cookie&quot;: encodeURIComponent(document.cookie)}, function(str)  { pn = '#p-' + cid; jQuery(pn).html(str); }); } function unstrip_now(cid) { jQuery.post(&quot;<?php echo get_option('siteurl'); ?>/wp-admin/admin-ajax.php&quot;, {action:&quot;unstrip&quot;, &quot;c&quot;:cid, &quot;cookie&quot;: encodeURIComponent(document.cookie)}, function(str)  { pn = '#p-' + cid; jQuery(pn).html(str); }); } //]]> </script>
Thank you! Markku Seguerra http://rebelpixel.com

More Related Content

What's hot (20)

PPT
Week 7 introduction to theme development
henri_makembe
 
PDF
Creating Your First WordPress Plugin
Brad Williams
 
ODP
45 Minute Drupal Site
Angus Pratt
 
PPT
Week 12 - Search Engine Optimization
henri_makembe
 
KEY
CSI: WordPress -- Getting Into the Guts
Dougal Campbell
 
PPTX
Develop advance joomla! MVC Component for version 3
Gunjan Patel
 
PPTX
Introduction to WordPress Plugin Development, WordCamp North Canton, 2015
topher1kenobe
 
ODP
The Future Of WordPress Presentation
Dougal Campbell
 
PDF
WordCamp Finland 2015 - WordPress Security
Tiia Rantanen
 
PDF
Extending BuddyPress – WordCamp Milano 2011 [italian]
Francesco Laffi
 
PPTX
How to develope plugin in wordpress: 6 simple steps.
Jay Bharat
 
PPTX
WordPress Theme & Plugin i18n & L10n
codebangla
 
PPTX
Introduction to building joomla! components using FOF
Tim Plummer
 
PPTX
WordPress Theming
codebangla
 
PPTX
Hardening WordPress - SAScon Manchester 2013 (WordPress Security)
Bastian Grimm
 
PPTX
WordPress Theme Development
Bijay Oli
 
ODP
Developing new feature in Joomla - Joomladay UK 2016
Peter Martin
 
PDF
How to create a joomla component from scratch
Tim Plummer
 
PPT
Top 20 WordPress Plugins You've Never Heard Of
Brad Williams
 
PPT
Top 20 word press plugins you've never heard of
Toan Nguyen
 
Week 7 introduction to theme development
henri_makembe
 
Creating Your First WordPress Plugin
Brad Williams
 
45 Minute Drupal Site
Angus Pratt
 
Week 12 - Search Engine Optimization
henri_makembe
 
CSI: WordPress -- Getting Into the Guts
Dougal Campbell
 
Develop advance joomla! MVC Component for version 3
Gunjan Patel
 
Introduction to WordPress Plugin Development, WordCamp North Canton, 2015
topher1kenobe
 
The Future Of WordPress Presentation
Dougal Campbell
 
WordCamp Finland 2015 - WordPress Security
Tiia Rantanen
 
Extending BuddyPress – WordCamp Milano 2011 [italian]
Francesco Laffi
 
How to develope plugin in wordpress: 6 simple steps.
Jay Bharat
 
WordPress Theme & Plugin i18n & L10n
codebangla
 
Introduction to building joomla! components using FOF
Tim Plummer
 
WordPress Theming
codebangla
 
Hardening WordPress - SAScon Manchester 2013 (WordPress Security)
Bastian Grimm
 
WordPress Theme Development
Bijay Oli
 
Developing new feature in Joomla - Joomladay UK 2016
Peter Martin
 
How to create a joomla component from scratch
Tim Plummer
 
Top 20 WordPress Plugins You've Never Heard Of
Brad Williams
 
Top 20 word press plugins you've never heard of
Toan Nguyen
 

Viewers also liked (15)

PPTX
WordPress Plugins For Website Development
PixelCrayons
 
PDF
WordPress Plugins (WordCamp Utah)
alexkingorg
 
KEY
Intro to WordPress Plugins
zamoose
 
PDF
Intro to WordPress Plugins
Kristen Symonds
 
PPTX
Introduction To Simple WordPress Plugin Development
Bruce L Chamoff
 
PPTX
WordPress Plugins
randyhoyt
 
PPTX
WordPress Plugins and Security
Think Media Inc.
 
PPT
Developing Plugins For WordPress
Lester Chan
 
PDF
Intro to WordPress Plugin Development
Brad Williams
 
PDF
Wordpress Plugin Development Short Tutorial
Christos Zigkolis
 
PDF
Creating and Maintaining WordPress Plugins
Mark Jaquith
 
PPTX
Introduction To WordPress
Craig Bailey
 
PDF
Developing WordPress Plugins : For Begineers
M A Hossain Tonu
 
PDF
An easy guide to Plugin Development
Shinichi Nishikawa
 
PPTX
Favorite WordPress Plugins 2016
Laura Hartwig
 
WordPress Plugins For Website Development
PixelCrayons
 
WordPress Plugins (WordCamp Utah)
alexkingorg
 
Intro to WordPress Plugins
zamoose
 
Intro to WordPress Plugins
Kristen Symonds
 
Introduction To Simple WordPress Plugin Development
Bruce L Chamoff
 
WordPress Plugins
randyhoyt
 
WordPress Plugins and Security
Think Media Inc.
 
Developing Plugins For WordPress
Lester Chan
 
Intro to WordPress Plugin Development
Brad Williams
 
Wordpress Plugin Development Short Tutorial
Christos Zigkolis
 
Creating and Maintaining WordPress Plugins
Mark Jaquith
 
Introduction To WordPress
Craig Bailey
 
Developing WordPress Plugins : For Begineers
M A Hossain Tonu
 
An easy guide to Plugin Development
Shinichi Nishikawa
 
Favorite WordPress Plugins 2016
Laura Hartwig
 
Ad

Similar to Developing WordPress Plugins (20)

PPTX
10 Things Every Plugin Developer Should Know (WordCamp Atlanta 2013)
arcware
 
PDF
<Head> Presentation: Plugging Into Wordpress
Matt Harris
 
PDF
Write Your First WordPress Plugin
Ibrahim Abdel Fattah Mohamed
 
PPTX
Introduction to Plugin Programming, WordCamp Miami 2011
David Carr
 
PPT
WordPress Plugin Basics
Amanda Giles
 
PPT
WordPress Plugins: ur doin it wrong
Will Norris
 
PDF
WordPress plugin development
Luc De Brouwer
 
PPTX
From WordPress With Love
Up2 Technology
 
PDF
Write your first WordPress plugin
Anthony Montalbano
 
PPTX
PSD to WordPress
Nile Flores
 
PDF
Bending word press to your will
Tom Jenkins
 
PDF
Beyond the WordPress 5 minute Install
Steve Taylor
 
PDF
Stop Hacking WordPress, Start Working with it - Charly Leetham - WordCamp Syd...
WordCamp Sydney
 
PPT
Wordpress Optimization Settings
webhostingguy
 
PDF
Plugin Development @ WordCamp Norway 2014
Barry Kooij
 
PDF
Wordpress as a framework
Aggelos Synadakis
 
PDF
My first WordPress Plugin
Abbas Siddiqi
 
PPTX
Library 2.0 : Weblogs : Wordpress
Nurhazman Abdul Aziz
 
PDF
WordPress Beginners Workshop
The Toolbox, Inc.
 
PPTX
Let’s write a plugin
Brian Layman
 
10 Things Every Plugin Developer Should Know (WordCamp Atlanta 2013)
arcware
 
<Head> Presentation: Plugging Into Wordpress
Matt Harris
 
Write Your First WordPress Plugin
Ibrahim Abdel Fattah Mohamed
 
Introduction to Plugin Programming, WordCamp Miami 2011
David Carr
 
WordPress Plugin Basics
Amanda Giles
 
WordPress Plugins: ur doin it wrong
Will Norris
 
WordPress plugin development
Luc De Brouwer
 
From WordPress With Love
Up2 Technology
 
Write your first WordPress plugin
Anthony Montalbano
 
PSD to WordPress
Nile Flores
 
Bending word press to your will
Tom Jenkins
 
Beyond the WordPress 5 minute Install
Steve Taylor
 
Stop Hacking WordPress, Start Working with it - Charly Leetham - WordCamp Syd...
WordCamp Sydney
 
Wordpress Optimization Settings
webhostingguy
 
Plugin Development @ WordCamp Norway 2014
Barry Kooij
 
Wordpress as a framework
Aggelos Synadakis
 
My first WordPress Plugin
Abbas Siddiqi
 
Library 2.0 : Weblogs : Wordpress
Nurhazman Abdul Aziz
 
WordPress Beginners Workshop
The Toolbox, Inc.
 
Let’s write a plugin
Brian Layman
 
Ad

Recently uploaded (20)

PPTX
MSP360 Backup Scheduling and Retention Best Practices.pptx
MSP360
 
PDF
How Startups Are Growing Faster with App Developers in Australia.pdf
India App Developer
 
PDF
HCIP-Data Center Facility Deployment V2.0 Training Material (Without Remarks ...
mcastillo49
 
PDF
Human-centred design in online workplace learning and relationship to engagem...
Tracy Tang
 
PPT
Interview paper part 3, It is based on Interview Prep
SoumyadeepGhosh39
 
PDF
Fl Studio 24.2.2 Build 4597 Crack for Windows Free Download 2025
faizk77g
 
PDF
Rethinking Security Operations - SOC Evolution Journey.pdf
Haris Chughtai
 
PDF
Meetup Kickoff & Welcome - Rohit Yadav, CSIUG Chairman
ShapeBlue
 
PDF
Predicting the unpredictable: re-engineering recommendation algorithms for fr...
Speck&Tech
 
PPTX
UiPath Academic Alliance Educator Panels: Session 2 - Business Analyst Content
DianaGray10
 
PPTX
Darren Mills The Migration Modernization Balancing Act: Navigating Risks and...
AWS Chicago
 
PDF
Smart Air Quality Monitoring with Serrax AQM190 LITE
SERRAX TECHNOLOGIES LLP
 
PDF
Why Orbit Edge Tech is a Top Next JS Development Company in 2025
mahendraalaska08
 
PDF
SWEBOK Guide and Software Services Engineering Education
Hironori Washizaki
 
PDF
Empowering Cloud Providers with Apache CloudStack and Stackbill
ShapeBlue
 
PDF
The Builder’s Playbook - 2025 State of AI Report.pdf
jeroen339954
 
PDF
Wojciech Ciemski for Top Cyber News MAGAZINE. June 2025
Dr. Ludmila Morozova-Buss
 
PDF
SFWelly Summer 25 Release Highlights July 2025
Anna Loughnan Colquhoun
 
PPTX
Building and Operating a Private Cloud with CloudStack and LINBIT CloudStack ...
ShapeBlue
 
PDF
LLMs.txt: Easily Control How AI Crawls Your Site
Keploy
 
MSP360 Backup Scheduling and Retention Best Practices.pptx
MSP360
 
How Startups Are Growing Faster with App Developers in Australia.pdf
India App Developer
 
HCIP-Data Center Facility Deployment V2.0 Training Material (Without Remarks ...
mcastillo49
 
Human-centred design in online workplace learning and relationship to engagem...
Tracy Tang
 
Interview paper part 3, It is based on Interview Prep
SoumyadeepGhosh39
 
Fl Studio 24.2.2 Build 4597 Crack for Windows Free Download 2025
faizk77g
 
Rethinking Security Operations - SOC Evolution Journey.pdf
Haris Chughtai
 
Meetup Kickoff & Welcome - Rohit Yadav, CSIUG Chairman
ShapeBlue
 
Predicting the unpredictable: re-engineering recommendation algorithms for fr...
Speck&Tech
 
UiPath Academic Alliance Educator Panels: Session 2 - Business Analyst Content
DianaGray10
 
Darren Mills The Migration Modernization Balancing Act: Navigating Risks and...
AWS Chicago
 
Smart Air Quality Monitoring with Serrax AQM190 LITE
SERRAX TECHNOLOGIES LLP
 
Why Orbit Edge Tech is a Top Next JS Development Company in 2025
mahendraalaska08
 
SWEBOK Guide and Software Services Engineering Education
Hironori Washizaki
 
Empowering Cloud Providers with Apache CloudStack and Stackbill
ShapeBlue
 
The Builder’s Playbook - 2025 State of AI Report.pdf
jeroen339954
 
Wojciech Ciemski for Top Cyber News MAGAZINE. June 2025
Dr. Ludmila Morozova-Buss
 
SFWelly Summer 25 Release Highlights July 2025
Anna Loughnan Colquhoun
 
Building and Operating a Private Cloud with CloudStack and LINBIT CloudStack ...
ShapeBlue
 
LLMs.txt: Easily Control How AI Crawls Your Site
Keploy
 

Developing WordPress Plugins

  • 1. Developing WordPress Plugins Markku Seguerra http://rebelpixel.com
  • 2. What is a WordPress plugin? Little applications used to enhance functionality or add specific functions tailored to a site's specific needs.
  • 3. Some plugins: - Akismet - WordPress Database Backup - WordPress.com Stats - wp-recent-links - Comment Hilite
  • 4. What do you need to make a plugin? - a problem to solve - some PHP knowledge - some spare time - a test server with your test WordPress (XAMPP is good.)‏
  • 5. Structure: Things to remember - A unique descriptive name - Naming: myplugin.php or /myplugin/ folder - Readme.txt format for wordpress.org/extend/plugins - Plugin home page - File headers (very important!)‏
  • 6. Headers <?php /* Plugin Name: Name Of The Plugin Plugin URI: http://mypage.com/myplugin/ Description: What does it do? Version: 1.0 Author: Name Of The Plugin Author Author URI: http://mypage.com/ */ ?>
  • 7. Include your license details! The GPL (and compatible licenses) is commonly used for plugins.
  • 8. Plugin Programming Before WP 1.2, customizations required altering the core files, causing conflicts among hacks (remember my-hacks.php?) and making upgrades very tedious. The solution?
  • 9. Plugin API - Enabled &quot;hooks&quot; - Extend functionality without editing the core code - Two categories: Actions and Filters
  • 10. Actions Specific points in the WordPress code that can be used to trigger plugin-specified events and functions. add_action( 'hook_name', 'your_function_name', [priority], [accepted_args] );
  • 11. Sample action: “wp_login” function notify_on_login()‏ { // your code here // email to admin, etc... } add_action('wp_login', 'notify_on_login');
  • 12. Filters Functions that modify text, lists and various types of information that are used and produced by WordPress. add_filter('hook_name', 'your_filter_function', [priority], [accepted_args]);
  • 13. Sample filter: “the_content” function add_rss_invite()‏ { // output to screen the link to RSS feed // if 1st time visitor } add_filter('the_content', 'add_rss_invite');
  • 14. Template Tags Plugins can also be used to generate special template tags that display custom content. - Recent comments - Top posts - Ad display
  • 15. Storing Plugin Data - For large amount of data, create your own database table. - For fairly small and/or static data, use built-in WP &quot;Options&quot; capability. add_option($name, $value, $deprecated, $autoload); get_option($option); update_option($option_name, $newvalue);
  • 16. Administration Menus & Pages - There are specific functions to add pages and menu items. add_menu_page(page_title, menu_title, access_level/capability, file, [function]); add_submenu_page(); add_options_page(); add_management_page(); add_theme_page();
  • 17. Other things to consider - Internationalization - WordPress Coding Standards & inline documentation - Function prefixes to avoid name collision - When creating tables, use $wpdb->prefix - Minimize database writes. - Write secure code! (Use nonces, sanitize, etc.)‏ - Be aware of user roles and capabilities. - Stick to the WordPress API to avoid problems!
  • 18. Sample plugin: Strip! <?php /* Plugin Name: Strip! Plugin URI: http://rebelpixel.com/ Description: Removes hyperlink tags from a given comment. Version: 0.1 Author: Markku Seguerra Author URI: http://rebelpixel.com/projects/strip/ */
  • 19. /* Copyright 2008 Markku Seguerra (email : [email protected])‏ This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */
  • 20. add_filter('comment_text', 'strip_comments_add_admin'); function strip_comments_add_admin($text)‏ { // add the strip button to the comment } add_filter('comment_text', 'strip_comments_add'); add_filter('get_comment_author_link', 'strip_comments_add'); function strip_comments_add($text)‏ { // mark the comment as stripped and displays // it without links }
  • 21. add_action('wp_ajax_strip', 'do_strip'); function do_strip()‏ { // function to mark comment as stripped // triggered via ajax } add_action('wp_ajax_unstrip', 'do_unstrip'); function do_unstrip()‏ { // function to mark comment as stripped } function strip_selected_tags($text, $tags = array())‏ { // our filter function that removes links }
  • 22. add_action('admin_head', 'strip_comments_head'); function strip_comments_head()‏ { // show the necessary css and ajax // functions used in the admin interface }
  • 23. <script type=&quot;text/javascript&quot;> //<![CDATA[ function strip_now(cid) { jQuery.post(&quot;<?php echo get_option('siteurl'); ?>/wp-admin/admin-ajax.php&quot;, {action:&quot;strip&quot;, &quot;c&quot;:cid, &quot;cookie&quot;: encodeURIComponent(document.cookie)}, function(str) { pn = '#p-' + cid; jQuery(pn).html(str); }); } function unstrip_now(cid) { jQuery.post(&quot;<?php echo get_option('siteurl'); ?>/wp-admin/admin-ajax.php&quot;, {action:&quot;unstrip&quot;, &quot;c&quot;:cid, &quot;cookie&quot;: encodeURIComponent(document.cookie)}, function(str) { pn = '#p-' + cid; jQuery(pn).html(str); }); } //]]> </script>
  • 24. Thank you! Markku Seguerra http://rebelpixel.com