SlideShare a Scribd company logo
Best practices for
plugin development
Create a WordPress plugin from
scratch
Andrea Sciamanna
present
● Lead developer for WPML
● responsible and active
developer of the WPML
plugin and add-ons
past
● Web and desktop application
developer (mostly using .net
framework)
Agenda
● Quick introduction about:
a. code readability
b. documentation
c. patterns
● Some references
● Creating a WordPress plugin from scratch
● (time allowing) Introducing IDEs and OOP
Code readability
1. Use coding standards
a. Use WordPress PHP Coding Standards: http://goo.
gl/FTMm0a
b. Comment with PhpDOC: http://www.phpdoc.org
c. Don't repeat yourself (DRY): http://blog.codinghorror.
com/curlys-law-do-one-thing
d. Don’t go crazy trying to follow standards: just get used
to them.
References
● WordPress Codex: http://codex.wordpress.org
● Stack Overflow: http://stackoverflow.com
○ WordPress Development: http://wordpress.
stackexchange.com
● Google: seriously, do I need to tell you?
Create a WordPress
plugin from scratch
A “Fancy” plugin for your galleries
Integrate Fancybox in the standard WordPress
gallery.
Planned Functionalities
● Show images in a Fancybox/lightbox, rather
than opening them in a different page
● Do not interfere with the active theme
● Make it “SEO proof”
● Pseudo-Watermark images without modifying
them
● Allow some customization
Goals
● Learn how to:
○ enqueue scripts and styles
○ use actions and filters
○ use WordPress Settings API
● Learn best practices, of course!
● ...and the Fancybox plugin
Standard plugin structure
● Single file: unique file name (my-own-plugin.
php)
● Complex structure:
○ unique folder name (/wp-content/plugins/my-own-
plugin/)
○ bootstrap script: plugin.php or any name
● Main plugin file: Standard Plugin Information
● readme.txt file
Skeleton
Main plugin file
● Define useful constants, for later use:
○ Plugin version
○ Plugin path
○ Plugin folder
○ Plugin URL
● Include dependencies
○ Shared functions
○ Core class
○ Options class
➔ Remember to namespace
your functions, by either
using unique plugins, or
unique class names
➔ Do not use actual PHP
namespaces!
Hooks
● What are they?
○ Actions -> They do things
○ Filters -> They return something
● How they must be used?
○ “Hook” a filter, or action to a custom function
● When?
○ At the right time: it’s a bit tricky and needs practices,
some cheat sheet, or asking the community
Hook to some actions and filters
● The loader class: why?
○ Decoupling functionalities
○ Specialized classes
● Hook to actions:
○ ‘plugins_loaded’ -> the actual entry point (usually)
○ ‘wp_enqueue_scripts’ -> scripts and CSS goes here
● Hook to filters:
○ ‘wp_get_attachment_link’
Implement hooks
● Hook to actions
○ Add scripts and styles
■ Main script and styles
■ Fancybox, helpers and more
■ Pass data to scripts: wp_enqueue_script()
● Hook to filters
○ Tweak the gallery item link
Plugin options definitions and handling
● Implement plugin options
○ A new class => a new file
○ The options loader class
WP Settings API
● WP Settings API
○ register_setting()
○ add_settings_section()
○ add_settings_field()
○ callbacks
○ options_do_page
● Some thoughts about the APIs:
○ Counterintuitive
○ Old
Honestly, we ought to take the time to learn the Settings API however the steep the learning curve,
and start working with it. It is the definitive way to go about creating options pages, and it is the current
version of the API that we have available.
Tom McFarlin (http://tommcfarlin.com/wordpress-settings-api-wrapper)
Plugin options page
● Show the plugin options page
○ OTGS_Fancybox_Gallery_Options::get_setting static
method: why is static?
○ Add a menu item in “Settings” menu
○ Add some javascript and enqueue the script in the
back-end
Refine the main class
● Handle plugin options
● Take advantage of $wp_object_cache in
OTGS_Fancybox_Gallery::
get_attachment_link
The main gallery.js
● Do not use $ (in WordPress)!
● Implement jquery.fancybox()
● Cache jQuery elements
● Play with plugin options
Test it
Questions?

More Related Content

Viewers also liked

Best practices in WordPress Development
Best practices in WordPress DevelopmentBest practices in WordPress Development
Best practices in WordPress DevelopmentMindfire Solutions
 
Best Practices for WordPress in Enterprise
Best Practices for WordPress in EnterpriseBest Practices for WordPress in Enterprise
Best Practices for WordPress in EnterpriseTaylor Lovett
 
Best Practices for WordPress
Best Practices for WordPressBest Practices for WordPress
Best Practices for WordPressTaylor Lovett
 
Saving Time with WP-CLI
Saving Time with WP-CLISaving Time with WP-CLI
Saving Time with WP-CLITaylor Lovett
 
Sanitizing, Validating and Escaping in WordPress Themes and Plugins
Sanitizing, Validating and Escaping in WordPress Themes and PluginsSanitizing, Validating and Escaping in WordPress Themes and Plugins
Sanitizing, Validating and Escaping in WordPress Themes and PluginsMicah Wood
 
Installing WordPress on AWS
Installing WordPress on AWSInstalling WordPress on AWS
Installing WordPress on AWSManish Jain
 

Viewers also liked (6)

Best practices in WordPress Development
Best practices in WordPress DevelopmentBest practices in WordPress Development
Best practices in WordPress Development
 
Best Practices for WordPress in Enterprise
Best Practices for WordPress in EnterpriseBest Practices for WordPress in Enterprise
Best Practices for WordPress in Enterprise
 
Best Practices for WordPress
Best Practices for WordPressBest Practices for WordPress
Best Practices for WordPress
 
Saving Time with WP-CLI
Saving Time with WP-CLISaving Time with WP-CLI
Saving Time with WP-CLI
 
Sanitizing, Validating and Escaping in WordPress Themes and Plugins
Sanitizing, Validating and Escaping in WordPress Themes and PluginsSanitizing, Validating and Escaping in WordPress Themes and Plugins
Sanitizing, Validating and Escaping in WordPress Themes and Plugins
 
Installing WordPress on AWS
Installing WordPress on AWSInstalling WordPress on AWS
Installing WordPress on AWS
 

Similar to Saigon Wordpress Meetup - Best practices for plugin development - A WordPress plugin from scratch - Andrea

Developing word press professionally
Developing word press professionallyDeveloping word press professionally
Developing word press professionallyAustin Gil
 
GDI WordPress 2 January 2012
GDI WordPress 2 January 2012 GDI WordPress 2 January 2012
GDI WordPress 2 January 2012 pamselle
 
Pentester++
Pentester++Pentester++
Pentester++CTruncer
 
Plugin development demystified 2017
Plugin development demystified 2017Plugin development demystified 2017
Plugin development demystified 2017ylefebvre
 
WPSessions Composer for WordPress Plugin Development
WPSessions Composer for WordPress Plugin DevelopmentWPSessions Composer for WordPress Plugin Development
WPSessions Composer for WordPress Plugin DevelopmentCaldera Labs
 
Alice Phieu - WordPress For Beginners
Alice Phieu - WordPress For BeginnersAlice Phieu - WordPress For Beginners
Alice Phieu - WordPress For BeginnersAlice Phieu
 
Jbake workshop (Greach 2019)
Jbake workshop (Greach 2019)Jbake workshop (Greach 2019)
Jbake workshop (Greach 2019)Mario García
 
Contributing to Apache Airflow | Journey to becoming Airflow's leading contri...
Contributing to Apache Airflow | Journey to becoming Airflow's leading contri...Contributing to Apache Airflow | Journey to becoming Airflow's leading contri...
Contributing to Apache Airflow | Journey to becoming Airflow's leading contri...Kaxil Naik
 
Monster JavaScript Course - 50+ projects and applications
Monster JavaScript Course - 50+ projects and applicationsMonster JavaScript Course - 50+ projects and applications
Monster JavaScript Course - 50+ projects and applicationsLaurence Svekis ✔
 
WordPress: After The Install
WordPress: After The InstallWordPress: After The Install
WordPress: After The InstallWordPress NYC
 
A New CLI for Spring Developer Productivity
A New CLI for Spring Developer ProductivityA New CLI for Spring Developer Productivity
A New CLI for Spring Developer ProductivityVMware Tanzu
 
Gutenberg Extended
Gutenberg ExtendedGutenberg Extended
Gutenberg ExtendedSören Wrede
 
WordPress 101 Saturday Session
WordPress 101 Saturday SessionWordPress 101 Saturday Session
WordPress 101 Saturday Sessionpamselle
 
WordPress Theme Development: Part 2
WordPress Theme Development: Part 2WordPress Theme Development: Part 2
WordPress Theme Development: Part 2Josh Lee
 
Cypress report
Cypress reportCypress report
Cypress reportAdarsh
 
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
 
Django interview Questions| Edureka
Django interview  Questions| EdurekaDjango interview  Questions| Edureka
Django interview Questions| EdurekaEdureka!
 

Similar to Saigon Wordpress Meetup - Best practices for plugin development - A WordPress plugin from scratch - Andrea (20)

Developing word press professionally
Developing word press professionallyDeveloping word press professionally
Developing word press professionally
 
GDI WordPress 2 January 2012
GDI WordPress 2 January 2012 GDI WordPress 2 January 2012
GDI WordPress 2 January 2012
 
Pentester++
Pentester++Pentester++
Pentester++
 
It4k12 wordpress
It4k12 wordpressIt4k12 wordpress
It4k12 wordpress
 
Plugin development demystified 2017
Plugin development demystified 2017Plugin development demystified 2017
Plugin development demystified 2017
 
WPSessions Composer for WordPress Plugin Development
WPSessions Composer for WordPress Plugin DevelopmentWPSessions Composer for WordPress Plugin Development
WPSessions Composer for WordPress Plugin Development
 
Alice Phieu - WordPress For Beginners
Alice Phieu - WordPress For BeginnersAlice Phieu - WordPress For Beginners
Alice Phieu - WordPress For Beginners
 
Jbake workshop (Greach 2019)
Jbake workshop (Greach 2019)Jbake workshop (Greach 2019)
Jbake workshop (Greach 2019)
 
Contributing to Apache Airflow | Journey to becoming Airflow's leading contri...
Contributing to Apache Airflow | Journey to becoming Airflow's leading contri...Contributing to Apache Airflow | Journey to becoming Airflow's leading contri...
Contributing to Apache Airflow | Journey to becoming Airflow's leading contri...
 
Monster JavaScript Course - 50+ projects and applications
Monster JavaScript Course - 50+ projects and applicationsMonster JavaScript Course - 50+ projects and applications
Monster JavaScript Course - 50+ projects and applications
 
WordPress: After The Install
WordPress: After The InstallWordPress: After The Install
WordPress: After The Install
 
A New CLI for Spring Developer Productivity
A New CLI for Spring Developer ProductivityA New CLI for Spring Developer Productivity
A New CLI for Spring Developer Productivity
 
Code-Hub
Code-HubCode-Hub
Code-Hub
 
CollegeDiveIn presentation
CollegeDiveIn presentationCollegeDiveIn presentation
CollegeDiveIn presentation
 
Gutenberg Extended
Gutenberg ExtendedGutenberg Extended
Gutenberg Extended
 
WordPress 101 Saturday Session
WordPress 101 Saturday SessionWordPress 101 Saturday Session
WordPress 101 Saturday Session
 
WordPress Theme Development: Part 2
WordPress Theme Development: Part 2WordPress Theme Development: Part 2
WordPress Theme Development: Part 2
 
Cypress report
Cypress reportCypress report
Cypress report
 
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...
 
Django interview Questions| Edureka
Django interview  Questions| EdurekaDjango interview  Questions| Edureka
Django interview Questions| Edureka
 

More from Triết Sài Gòn

Hạnh Phúc Tùy Cách Nhìn
Hạnh Phúc Tùy Cách NhìnHạnh Phúc Tùy Cách Nhìn
Hạnh Phúc Tùy Cách NhìnTriết Sài Gòn
 
Saigon Wordpress Meetup - Themes Wordpress Meetup
Saigon Wordpress Meetup - Themes Wordpress MeetupSaigon Wordpress Meetup - Themes Wordpress Meetup
Saigon Wordpress Meetup - Themes Wordpress MeetupTriết Sài Gòn
 
Saigon Wordpress Meetup - How customers and developers understand each others...
Saigon Wordpress Meetup - How customers and developers understand each others...Saigon Wordpress Meetup - How customers and developers understand each others...
Saigon Wordpress Meetup - How customers and developers understand each others...Triết Sài Gòn
 
Saigon Wordpress Meetup - Building Sites With WordPress Opening Remarks - Dat...
Saigon Wordpress Meetup - Building Sites With WordPress Opening Remarks - Dat...Saigon Wordpress Meetup - Building Sites With WordPress Opening Remarks - Dat...
Saigon Wordpress Meetup - Building Sites With WordPress Opening Remarks - Dat...Triết Sài Gòn
 
Saigon Wordpress Meetup - Building a business around a WordPress plugin - Amir
Saigon Wordpress Meetup - Building a business around a WordPress plugin - AmirSaigon Wordpress Meetup - Building a business around a WordPress plugin - Amir
Saigon Wordpress Meetup - Building a business around a WordPress plugin - AmirTriết Sài Gòn
 
Saigon Wordpress Meetup - Wordpress HTML Text Widget - Thien Anh
Saigon Wordpress Meetup - Wordpress HTML Text Widget - Thien AnhSaigon Wordpress Meetup - Wordpress HTML Text Widget - Thien Anh
Saigon Wordpress Meetup - Wordpress HTML Text Widget - Thien AnhTriết Sài Gòn
 

More from Triết Sài Gòn (6)

Hạnh Phúc Tùy Cách Nhìn
Hạnh Phúc Tùy Cách NhìnHạnh Phúc Tùy Cách Nhìn
Hạnh Phúc Tùy Cách Nhìn
 
Saigon Wordpress Meetup - Themes Wordpress Meetup
Saigon Wordpress Meetup - Themes Wordpress MeetupSaigon Wordpress Meetup - Themes Wordpress Meetup
Saigon Wordpress Meetup - Themes Wordpress Meetup
 
Saigon Wordpress Meetup - How customers and developers understand each others...
Saigon Wordpress Meetup - How customers and developers understand each others...Saigon Wordpress Meetup - How customers and developers understand each others...
Saigon Wordpress Meetup - How customers and developers understand each others...
 
Saigon Wordpress Meetup - Building Sites With WordPress Opening Remarks - Dat...
Saigon Wordpress Meetup - Building Sites With WordPress Opening Remarks - Dat...Saigon Wordpress Meetup - Building Sites With WordPress Opening Remarks - Dat...
Saigon Wordpress Meetup - Building Sites With WordPress Opening Remarks - Dat...
 
Saigon Wordpress Meetup - Building a business around a WordPress plugin - Amir
Saigon Wordpress Meetup - Building a business around a WordPress plugin - AmirSaigon Wordpress Meetup - Building a business around a WordPress plugin - Amir
Saigon Wordpress Meetup - Building a business around a WordPress plugin - Amir
 
Saigon Wordpress Meetup - Wordpress HTML Text Widget - Thien Anh
Saigon Wordpress Meetup - Wordpress HTML Text Widget - Thien AnhSaigon Wordpress Meetup - Wordpress HTML Text Widget - Thien Anh
Saigon Wordpress Meetup - Wordpress HTML Text Widget - Thien Anh
 

Recently uploaded

How to Use Contact Form 7 Like a Pro.pptx
How to Use Contact Form 7 Like a Pro.pptxHow to Use Contact Form 7 Like a Pro.pptx
How to Use Contact Form 7 Like a Pro.pptxGal Baras
 
ER(Entity Relationship) Diagram for online shopping - TAE
ER(Entity Relationship) Diagram for online shopping - TAEER(Entity Relationship) Diagram for online shopping - TAE
ER(Entity Relationship) Diagram for online shopping - TAEHimani415946
 
The AI Powered Organization-Intro to AI-LAN.pdf
The AI Powered Organization-Intro to AI-LAN.pdfThe AI Powered Organization-Intro to AI-LAN.pdf
The AI Powered Organization-Intro to AI-LAN.pdfSiskaFitrianingrum
 
1.Wireless Communication System_Wireless communication is a broad term that i...
1.Wireless Communication System_Wireless communication is a broad term that i...1.Wireless Communication System_Wireless communication is a broad term that i...
1.Wireless Communication System_Wireless communication is a broad term that i...JeyaPerumal1
 
History+of+E-commerce+Development+in+China-www.cfye-commerce.shop
History+of+E-commerce+Development+in+China-www.cfye-commerce.shopHistory+of+E-commerce+Development+in+China-www.cfye-commerce.shop
History+of+E-commerce+Development+in+China-www.cfye-commerce.shoplaozhuseo02
 
Multi-cluster Kubernetes Networking- Patterns, Projects and Guidelines
Multi-cluster Kubernetes Networking- Patterns, Projects and GuidelinesMulti-cluster Kubernetes Networking- Patterns, Projects and Guidelines
Multi-cluster Kubernetes Networking- Patterns, Projects and GuidelinesSanjeev Rampal
 
The+Prospects+of+E-Commerce+in+China.pptx
The+Prospects+of+E-Commerce+in+China.pptxThe+Prospects+of+E-Commerce+in+China.pptx
The+Prospects+of+E-Commerce+in+China.pptxlaozhuseo02
 
一比一原版UTS毕业证悉尼科技大学毕业证成绩单如何办理
一比一原版UTS毕业证悉尼科技大学毕业证成绩单如何办理一比一原版UTS毕业证悉尼科技大学毕业证成绩单如何办理
一比一原版UTS毕业证悉尼科技大学毕业证成绩单如何办理aagad
 
The Use of AI in Indonesia Election 2024: A Case Study
The Use of AI in Indonesia Election 2024: A Case StudyThe Use of AI in Indonesia Election 2024: A Case Study
The Use of AI in Indonesia Election 2024: A Case StudyDamar Juniarto
 
Article writing on excessive use of internet.pptx
Article writing on excessive use of internet.pptxArticle writing on excessive use of internet.pptx
Article writing on excessive use of internet.pptxabhinandnam9997
 

Recently uploaded (12)

How to Use Contact Form 7 Like a Pro.pptx
How to Use Contact Form 7 Like a Pro.pptxHow to Use Contact Form 7 Like a Pro.pptx
How to Use Contact Form 7 Like a Pro.pptx
 
ER(Entity Relationship) Diagram for online shopping - TAE
ER(Entity Relationship) Diagram for online shopping - TAEER(Entity Relationship) Diagram for online shopping - TAE
ER(Entity Relationship) Diagram for online shopping - TAE
 
The AI Powered Organization-Intro to AI-LAN.pdf
The AI Powered Organization-Intro to AI-LAN.pdfThe AI Powered Organization-Intro to AI-LAN.pdf
The AI Powered Organization-Intro to AI-LAN.pdf
 
1.Wireless Communication System_Wireless communication is a broad term that i...
1.Wireless Communication System_Wireless communication is a broad term that i...1.Wireless Communication System_Wireless communication is a broad term that i...
1.Wireless Communication System_Wireless communication is a broad term that i...
 
Stay Ahead with 2024's Top Web Design Trends
Stay Ahead with 2024's Top Web Design TrendsStay Ahead with 2024's Top Web Design Trends
Stay Ahead with 2024's Top Web Design Trends
 
The Best AI Powered Software - Intellivid AI Studio
The Best AI Powered Software - Intellivid AI StudioThe Best AI Powered Software - Intellivid AI Studio
The Best AI Powered Software - Intellivid AI Studio
 
History+of+E-commerce+Development+in+China-www.cfye-commerce.shop
History+of+E-commerce+Development+in+China-www.cfye-commerce.shopHistory+of+E-commerce+Development+in+China-www.cfye-commerce.shop
History+of+E-commerce+Development+in+China-www.cfye-commerce.shop
 
Multi-cluster Kubernetes Networking- Patterns, Projects and Guidelines
Multi-cluster Kubernetes Networking- Patterns, Projects and GuidelinesMulti-cluster Kubernetes Networking- Patterns, Projects and Guidelines
Multi-cluster Kubernetes Networking- Patterns, Projects and Guidelines
 
The+Prospects+of+E-Commerce+in+China.pptx
The+Prospects+of+E-Commerce+in+China.pptxThe+Prospects+of+E-Commerce+in+China.pptx
The+Prospects+of+E-Commerce+in+China.pptx
 
一比一原版UTS毕业证悉尼科技大学毕业证成绩单如何办理
一比一原版UTS毕业证悉尼科技大学毕业证成绩单如何办理一比一原版UTS毕业证悉尼科技大学毕业证成绩单如何办理
一比一原版UTS毕业证悉尼科技大学毕业证成绩单如何办理
 
The Use of AI in Indonesia Election 2024: A Case Study
The Use of AI in Indonesia Election 2024: A Case StudyThe Use of AI in Indonesia Election 2024: A Case Study
The Use of AI in Indonesia Election 2024: A Case Study
 
Article writing on excessive use of internet.pptx
Article writing on excessive use of internet.pptxArticle writing on excessive use of internet.pptx
Article writing on excessive use of internet.pptx
 

Saigon Wordpress Meetup - Best practices for plugin development - A WordPress plugin from scratch - Andrea

  • 1. Best practices for plugin development Create a WordPress plugin from scratch
  • 2. Andrea Sciamanna present ● Lead developer for WPML ● responsible and active developer of the WPML plugin and add-ons past ● Web and desktop application developer (mostly using .net framework)
  • 3. Agenda ● Quick introduction about: a. code readability b. documentation c. patterns ● Some references ● Creating a WordPress plugin from scratch ● (time allowing) Introducing IDEs and OOP
  • 4. Code readability 1. Use coding standards a. Use WordPress PHP Coding Standards: http://goo. gl/FTMm0a b. Comment with PhpDOC: http://www.phpdoc.org c. Don't repeat yourself (DRY): http://blog.codinghorror. com/curlys-law-do-one-thing d. Don’t go crazy trying to follow standards: just get used to them.
  • 5. References ● WordPress Codex: http://codex.wordpress.org ● Stack Overflow: http://stackoverflow.com ○ WordPress Development: http://wordpress. stackexchange.com ● Google: seriously, do I need to tell you?
  • 7. A “Fancy” plugin for your galleries Integrate Fancybox in the standard WordPress gallery.
  • 8. Planned Functionalities ● Show images in a Fancybox/lightbox, rather than opening them in a different page ● Do not interfere with the active theme ● Make it “SEO proof” ● Pseudo-Watermark images without modifying them ● Allow some customization
  • 9. Goals ● Learn how to: ○ enqueue scripts and styles ○ use actions and filters ○ use WordPress Settings API ● Learn best practices, of course! ● ...and the Fancybox plugin
  • 10. Standard plugin structure ● Single file: unique file name (my-own-plugin. php) ● Complex structure: ○ unique folder name (/wp-content/plugins/my-own- plugin/) ○ bootstrap script: plugin.php or any name ● Main plugin file: Standard Plugin Information ● readme.txt file
  • 12. Main plugin file ● Define useful constants, for later use: ○ Plugin version ○ Plugin path ○ Plugin folder ○ Plugin URL ● Include dependencies ○ Shared functions ○ Core class ○ Options class ➔ Remember to namespace your functions, by either using unique plugins, or unique class names ➔ Do not use actual PHP namespaces!
  • 13. Hooks ● What are they? ○ Actions -> They do things ○ Filters -> They return something ● How they must be used? ○ “Hook” a filter, or action to a custom function ● When? ○ At the right time: it’s a bit tricky and needs practices, some cheat sheet, or asking the community
  • 14. Hook to some actions and filters ● The loader class: why? ○ Decoupling functionalities ○ Specialized classes ● Hook to actions: ○ ‘plugins_loaded’ -> the actual entry point (usually) ○ ‘wp_enqueue_scripts’ -> scripts and CSS goes here ● Hook to filters: ○ ‘wp_get_attachment_link’
  • 15. Implement hooks ● Hook to actions ○ Add scripts and styles ■ Main script and styles ■ Fancybox, helpers and more ■ Pass data to scripts: wp_enqueue_script() ● Hook to filters ○ Tweak the gallery item link
  • 16. Plugin options definitions and handling ● Implement plugin options ○ A new class => a new file ○ The options loader class
  • 17. WP Settings API ● WP Settings API ○ register_setting() ○ add_settings_section() ○ add_settings_field() ○ callbacks ○ options_do_page ● Some thoughts about the APIs: ○ Counterintuitive ○ Old Honestly, we ought to take the time to learn the Settings API however the steep the learning curve, and start working with it. It is the definitive way to go about creating options pages, and it is the current version of the API that we have available. Tom McFarlin (http://tommcfarlin.com/wordpress-settings-api-wrapper)
  • 18. Plugin options page ● Show the plugin options page ○ OTGS_Fancybox_Gallery_Options::get_setting static method: why is static? ○ Add a menu item in “Settings” menu ○ Add some javascript and enqueue the script in the back-end
  • 19. Refine the main class ● Handle plugin options ● Take advantage of $wp_object_cache in OTGS_Fancybox_Gallery:: get_attachment_link
  • 20. The main gallery.js ● Do not use $ (in WordPress)! ● Implement jquery.fancybox() ● Cache jQuery elements ● Play with plugin options