SlideShare a Scribd company logo
1 of 10
Plugins: Debugging and Developing
Plugins are tools to extend the functionality of WordPress. Q: Has anyone here ever developed a WordPress plugin?
Are you wishing that WordPress had some new or modified feature? Always check the WordPress Plugin Repository first! No one wants to re-invent the wheel. Chances are that someone else has already created a plugin that would suite your needs.
Plugins live in /wp-content/plugins/ The plugin header lets WordPress know that this file is a plugin. <?php /* Plugin Name: Vox Importer Plugin URI: http://wordpress.org/extend/plugins/vox-importer/ Description: Import posts, comments, tags, and attachments from a Vox.com blog. Author: Automattic, Brian Colinger Author URI: http://automattic.com/ Version: 0.6 License: GPL v2 - http://www.gnu.org/licenses/old-licenses/gpl-2.0.html */ ?>
Potential Gotcha’s (How to break 10 million blogs with one line of code)
<?php function my_awesome_function() { $_POST = array_map( 'stripslashes', $_POST ); // ...Insert something into the database } my_awesome_function(); ?> What’s wrong with this code?
The proper way of doing this is to wrap this line with a conditional statement: 	$_POST = array_map( 'stripslashes_deep', $_POST ); stripslashes_deep() is a WordPress function that can properly handle multi-dimensional arrays.
/wp-admin/options-general.php?page=my-awesome-plugin
You could wrap the array_map code in a conditional check to make sure that you only run this code on this page. if ( 'my-awesome-plugin' == $_GET['page'] ) { $_POST = array_map( 'stripslashes_deep', $_POST ); }
Another way would be to create a nonce field in the submission form and check for it before processing the POST data. Add this to your form: <input name="update_settings" type="hidden" value="<?phpecho wp_create_nonce('update_settings'); ?>" /> In your plugin form handler function add this: if ( !wp_verify_nonce( $_POST['update_settings'], 'update_settings' ) ) return; Or you could check the referrer:check_admin_referer( $_GET['action'],'update_settings');

More Related Content

What's hot

Write microservice in golang
Write microservice in golangWrite microservice in golang
Write microservice in golangBo-Yi Wu
 
Creating a Smooth Development Workflow for High-Quality Modular Open-Source P...
Creating a Smooth Development Workflow for High-Quality Modular Open-Source P...Creating a Smooth Development Workflow for High-Quality Modular Open-Source P...
Creating a Smooth Development Workflow for High-Quality Modular Open-Source P...Pantheon
 
Introduction to Gitea with Drone
Introduction to Gitea with DroneIntroduction to Gitea with Drone
Introduction to Gitea with DroneBo-Yi Wu
 
Why Your Site is Slow: Performance Answers for Your Clients
Why Your Site is Slow: Performance Answers for Your ClientsWhy Your Site is Slow: Performance Answers for Your Clients
Why Your Site is Slow: Performance Answers for Your ClientsPantheon
 
GCE 上搭配 Cloud Storage 建置 Drone CI
 GCE 上搭配 Cloud Storage 建置 Drone CI GCE 上搭配 Cloud Storage 建置 Drone CI
GCE 上搭配 Cloud Storage 建置 Drone CIMING JUI Chen
 
A painless self-hosted Git service: Gitea
A painless self-hosted Git service: GiteaA painless self-hosted Git service: Gitea
A painless self-hosted Git service: GiteaBo-Yi Wu
 
Gorush: A push notification server written in Go
Gorush: A push notification server written in GoGorush: A push notification server written in Go
Gorush: A push notification server written in GoBo-Yi Wu
 
Developing Cross Platform Applications with Golang
Developing Cross Platform Applications with GolangDeveloping Cross Platform Applications with Golang
Developing Cross Platform Applications with GolangErhan Yakut
 

What's hot (13)

Write microservice in golang
Write microservice in golangWrite microservice in golang
Write microservice in golang
 
Creating a Smooth Development Workflow for High-Quality Modular Open-Source P...
Creating a Smooth Development Workflow for High-Quality Modular Open-Source P...Creating a Smooth Development Workflow for High-Quality Modular Open-Source P...
Creating a Smooth Development Workflow for High-Quality Modular Open-Source P...
 
LVPHP.org
LVPHP.orgLVPHP.org
LVPHP.org
 
ReactJS
ReactJSReactJS
ReactJS
 
Introduction to Gitea with Drone
Introduction to Gitea with DroneIntroduction to Gitea with Drone
Introduction to Gitea with Drone
 
composer_talk_20160209
composer_talk_20160209composer_talk_20160209
composer_talk_20160209
 
Why Your Site is Slow: Performance Answers for Your Clients
Why Your Site is Slow: Performance Answers for Your ClientsWhy Your Site is Slow: Performance Answers for Your Clients
Why Your Site is Slow: Performance Answers for Your Clients
 
GCE 上搭配 Cloud Storage 建置 Drone CI
 GCE 上搭配 Cloud Storage 建置 Drone CI GCE 上搭配 Cloud Storage 建置 Drone CI
GCE 上搭配 Cloud Storage 建置 Drone CI
 
A painless self-hosted Git service: Gitea
A painless self-hosted Git service: GiteaA painless self-hosted Git service: Gitea
A painless self-hosted Git service: Gitea
 
Gorush: A push notification server written in Go
Gorush: A push notification server written in GoGorush: A push notification server written in Go
Gorush: A push notification server written in Go
 
Developing Cross Platform Applications with Golang
Developing Cross Platform Applications with GolangDeveloping Cross Platform Applications with Golang
Developing Cross Platform Applications with Golang
 
Selenium using C# by Yogesh Kumar
Selenium using C# by  Yogesh KumarSelenium using C# by  Yogesh Kumar
Selenium using C# by Yogesh Kumar
 
Golang workshop
Golang workshopGolang workshop
Golang workshop
 

Viewers also liked

ARTS APS Action Research (INC)
ARTS APS Action Research (INC)ARTS APS Action Research (INC)
ARTS APS Action Research (INC)Reginald
 
Consumer protection Bulgaria
Consumer protection BulgariaConsumer protection Bulgaria
Consumer protection BulgariaJaromir Novak
 
McGladrey Guide to Accounting for Business Combinations - Second Edition
McGladrey Guide to Accounting for Business Combinations - Second EditionMcGladrey Guide to Accounting for Business Combinations - Second Edition
McGladrey Guide to Accounting for Business Combinations - Second EditionBrian Marshall
 
Ibm tivoli usage accounting manager v7.1 handbook sg247404
Ibm tivoli usage accounting manager v7.1 handbook sg247404Ibm tivoli usage accounting manager v7.1 handbook sg247404
Ibm tivoli usage accounting manager v7.1 handbook sg247404Banking at Ho Chi Minh city
 

Viewers also liked (8)

Ppt lesly
Ppt leslyPpt lesly
Ppt lesly
 
ARTS APS Action Research (INC)
ARTS APS Action Research (INC)ARTS APS Action Research (INC)
ARTS APS Action Research (INC)
 
Trayecto hologramatico 2
Trayecto hologramatico 2Trayecto hologramatico 2
Trayecto hologramatico 2
 
Consumer protection Bulgaria
Consumer protection BulgariaConsumer protection Bulgaria
Consumer protection Bulgaria
 
OECD_e-gov
OECD_e-govOECD_e-gov
OECD_e-gov
 
Mis handbook
Mis handbookMis handbook
Mis handbook
 
McGladrey Guide to Accounting for Business Combinations - Second Edition
McGladrey Guide to Accounting for Business Combinations - Second EditionMcGladrey Guide to Accounting for Business Combinations - Second Edition
McGladrey Guide to Accounting for Business Combinations - Second Edition
 
Ibm tivoli usage accounting manager v7.1 handbook sg247404
Ibm tivoli usage accounting manager v7.1 handbook sg247404Ibm tivoli usage accounting manager v7.1 handbook sg247404
Ibm tivoli usage accounting manager v7.1 handbook sg247404
 

Similar to Plugins debugging and developing

Write your first WordPress plugin
Write your first WordPress pluginWrite your first WordPress plugin
Write your first WordPress pluginAnthony Montalbano
 
WordPress Plugin Development For Beginners
WordPress Plugin Development For BeginnersWordPress Plugin Development For Beginners
WordPress Plugin Development For Beginnersjohnpbloch
 
Plugin development demystified 2017
Plugin development demystified 2017Plugin development demystified 2017
Plugin development demystified 2017ylefebvre
 
Making the Most of Plug-ins - WordCamp Toronto 2008
Making the Most of Plug-ins - WordCamp Toronto 2008Making the Most of Plug-ins - WordCamp Toronto 2008
Making the Most of Plug-ins - WordCamp Toronto 2008Brendan Sera-Shriar
 
WordPress Bootcamp Part 2 - Extending WordPress
WordPress Bootcamp Part 2 - Extending WordPressWordPress Bootcamp Part 2 - Extending WordPress
WordPress Bootcamp Part 2 - Extending WordPressMetronet
 
Beginning WordPress Plugin Development
Beginning WordPress Plugin DevelopmentBeginning WordPress Plugin Development
Beginning WordPress Plugin DevelopmentAizat Faiz
 
5 年後還是新手 - WordPress Plugin 開發大冒險 - GOTY
5 年後還是新手 - WordPress Plugin 開發大冒險 - GOTY5 年後還是新手 - WordPress Plugin 開發大冒險 - GOTY
5 年後還是新手 - WordPress Plugin 開發大冒險 - GOTYWilliam Chong
 
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- 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
 
Creating Your First WordPress Plugin
Creating Your First WordPress PluginCreating Your First WordPress Plugin
Creating Your First WordPress PluginBrad Williams
 
5 Steps to Develop a WordPress Plugin From Scratch.pdf
5 Steps to Develop a WordPress Plugin From Scratch.pdf5 Steps to Develop a WordPress Plugin From Scratch.pdf
5 Steps to Develop a WordPress Plugin From Scratch.pdfBeePlugin
 
Wordpress development: A Modern Approach
Wordpress development:  A Modern ApproachWordpress development:  A Modern Approach
Wordpress development: A Modern ApproachAlessandro Fiore
 
WordPress Plugin Development 201
WordPress Plugin Development 201WordPress Plugin Development 201
WordPress Plugin Development 201ylefebvre
 
Developing WordPress Plugins : For Begineers
Developing WordPress Plugins :  For BegineersDeveloping WordPress Plugins :  For Begineers
Developing WordPress Plugins : For BegineersM A Hossain Tonu
 
Wordpress #2 : customisation
Wordpress #2 : customisationWordpress #2 : customisation
Wordpress #2 : customisationJean Michel
 
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
 
Amazing WordPress & Productivity Tips
Amazing WordPress & Productivity TipsAmazing WordPress & Productivity Tips
Amazing WordPress & Productivity TipsTony Cecala, Ph.D.
 
Intro to WordPress Plugin Development
Intro to WordPress Plugin DevelopmentIntro to WordPress Plugin Development
Intro to WordPress Plugin DevelopmentBrad Williams
 
Extending WordPress - a guide to building your first plugin
Extending WordPress -  a guide to building your first pluginExtending WordPress -  a guide to building your first plugin
Extending WordPress - a guide to building your first pluginJonathan Bossenger
 

Similar to Plugins debugging and developing (20)

Write your first WordPress plugin
Write your first WordPress pluginWrite your first WordPress plugin
Write your first WordPress plugin
 
WordPress Plugin Development For Beginners
WordPress Plugin Development For BeginnersWordPress Plugin Development For Beginners
WordPress Plugin Development For Beginners
 
Plugin development demystified 2017
Plugin development demystified 2017Plugin development demystified 2017
Plugin development demystified 2017
 
Making the Most of Plug-ins - WordCamp Toronto 2008
Making the Most of Plug-ins - WordCamp Toronto 2008Making the Most of Plug-ins - WordCamp Toronto 2008
Making the Most of Plug-ins - WordCamp Toronto 2008
 
WordPress Bootcamp Part 2 - Extending WordPress
WordPress Bootcamp Part 2 - Extending WordPressWordPress Bootcamp Part 2 - Extending WordPress
WordPress Bootcamp Part 2 - Extending WordPress
 
Beginning WordPress Plugin Development
Beginning WordPress Plugin DevelopmentBeginning WordPress Plugin Development
Beginning WordPress Plugin Development
 
5 年後還是新手 - WordPress Plugin 開發大冒險 - GOTY
5 年後還是新手 - WordPress Plugin 開發大冒險 - GOTY5 年後還是新手 - WordPress Plugin 開發大冒險 - GOTY
5 年後還是新手 - WordPress Plugin 開發大冒險 - GOTY
 
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
 
Extending WordPress
Extending WordPressExtending WordPress
Extending WordPress
 
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
 
Creating Your First WordPress Plugin
Creating Your First WordPress PluginCreating Your First WordPress Plugin
Creating Your First WordPress Plugin
 
5 Steps to Develop a WordPress Plugin From Scratch.pdf
5 Steps to Develop a WordPress Plugin From Scratch.pdf5 Steps to Develop a WordPress Plugin From Scratch.pdf
5 Steps to Develop a WordPress Plugin From Scratch.pdf
 
Wordpress development: A Modern Approach
Wordpress development:  A Modern ApproachWordpress development:  A Modern Approach
Wordpress development: A Modern Approach
 
WordPress Plugin Development 201
WordPress Plugin Development 201WordPress Plugin Development 201
WordPress Plugin Development 201
 
Developing WordPress Plugins : For Begineers
Developing WordPress Plugins :  For BegineersDeveloping WordPress Plugins :  For Begineers
Developing WordPress Plugins : For Begineers
 
Wordpress #2 : customisation
Wordpress #2 : customisationWordpress #2 : customisation
Wordpress #2 : customisation
 
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
 
Amazing WordPress & Productivity Tips
Amazing WordPress & Productivity TipsAmazing WordPress & Productivity Tips
Amazing WordPress & Productivity Tips
 
Intro to WordPress Plugin Development
Intro to WordPress Plugin DevelopmentIntro to WordPress Plugin Development
Intro to WordPress Plugin Development
 
Extending WordPress - a guide to building your first plugin
Extending WordPress -  a guide to building your first pluginExtending WordPress -  a guide to building your first plugin
Extending WordPress - a guide to building your first plugin
 

Recently uploaded

Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slidevu2urc
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century educationjfdjdjcjdnsjd
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonetsnaman860154
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Miguel Araújo
 
Tech Trends Report 2024 Future Today Institute.pdf
Tech Trends Report 2024 Future Today Institute.pdfTech Trends Report 2024 Future Today Institute.pdf
Tech Trends Report 2024 Future Today Institute.pdfhans926745
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking MenDelhi Call girls
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Servicegiselly40
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking MenDelhi Call girls
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationMichael W. Hawkins
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationRadu Cotescu
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking MenDelhi Call girls
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUK Journal
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProduct Anonymous
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024The Digital Insurer
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Drew Madelung
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)Gabriella Davis
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityPrincipled Technologies
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreternaman860154
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘RTylerCroy
 

Recently uploaded (20)

Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonets
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
Tech Trends Report 2024 Future Today Institute.pdf
Tech Trends Report 2024 Future Today Institute.pdfTech Trends Report 2024 Future Today Institute.pdf
Tech Trends Report 2024 Future Today Institute.pdf
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreter
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 

Plugins debugging and developing

  • 2. Plugins are tools to extend the functionality of WordPress. Q: Has anyone here ever developed a WordPress plugin?
  • 3. Are you wishing that WordPress had some new or modified feature? Always check the WordPress Plugin Repository first! No one wants to re-invent the wheel. Chances are that someone else has already created a plugin that would suite your needs.
  • 4. Plugins live in /wp-content/plugins/ The plugin header lets WordPress know that this file is a plugin. <?php /* Plugin Name: Vox Importer Plugin URI: http://wordpress.org/extend/plugins/vox-importer/ Description: Import posts, comments, tags, and attachments from a Vox.com blog. Author: Automattic, Brian Colinger Author URI: http://automattic.com/ Version: 0.6 License: GPL v2 - http://www.gnu.org/licenses/old-licenses/gpl-2.0.html */ ?>
  • 5. Potential Gotcha’s (How to break 10 million blogs with one line of code)
  • 6. <?php function my_awesome_function() { $_POST = array_map( 'stripslashes', $_POST ); // ...Insert something into the database } my_awesome_function(); ?> What’s wrong with this code?
  • 7. The proper way of doing this is to wrap this line with a conditional statement: $_POST = array_map( 'stripslashes_deep', $_POST ); stripslashes_deep() is a WordPress function that can properly handle multi-dimensional arrays.
  • 9. You could wrap the array_map code in a conditional check to make sure that you only run this code on this page. if ( 'my-awesome-plugin' == $_GET['page'] ) { $_POST = array_map( 'stripslashes_deep', $_POST ); }
  • 10. Another way would be to create a nonce field in the submission form and check for it before processing the POST data. Add this to your form: <input name="update_settings" type="hidden" value="<?phpecho wp_create_nonce('update_settings'); ?>" /> In your plugin form handler function add this: if ( !wp_verify_nonce( $_POST['update_settings'], 'update_settings' ) ) return; Or you could check the referrer:check_admin_referer( $_GET['action'],'update_settings');

Editor's Notes

  1. With this header in place, your plugin will be listed on the Plugins admin screen.You will have to click the Activate link for the plugin to actually be enabled.
  2. If my_awesome_function() is part of a plugin, this function will be called on every page load.The bad part is the array_map of stripslashes on the $_POST array.This is what happens when I code without caffeine! Anytime the $_POST array is present, each element of that array will be stripped of slashes.Why is this bad? If the $_POST array contained a nested array, that array would be trashed and converted to a string == ‘Array’. Oopse...
  3. This only fixes part of the problem.Lets say that your plugin has an admin screen with a simple form. When the user clicks the submit button, you want to take that POST data and save it to the database. You need to make sure that your plugin’s form processor only executes when the $_POST array comes from it’s admin screen.
  4. There are a couple of ways to do this. Most admin screens will have a page slug associated with them. For example, if you have a settings screen for your plugin, the URL to it should be something like: