SlideShare a Scribd company logo
Playing Ball With
Plugins
Navigating and Extending Large Codebases:
A Field Guide
https://marcgratch.com | mgratch
WordCamp Boston 2017
Defining Your Problem
Make sure you’re solving a real problem
https://marcgratch.com | mgratch
WordCamp Boston 2017
Make sure you’re solving a real problem
• Is this behavior self-inflicted or inherent to the
plugin?
• Does this (will this) behavior bother the client? (Or is
it just me?)
• Will this impact launch?
• Can it be fixed with a bit of CSS?
https://marcgratch.com | mgratch
WordCamp Boston 2017
Be Aware: Dangerous Territory
Extending another plugin can get messy
https://marcgratch.com | mgratch
WordCamp Boston 2017
Some “dangers” of Extending/Integrating with
a 3rd Party Plugin
•Is the plugin regularly maintained?
•Are the plugin updates (typically) backwards
compatible?
•Did you ensure your code is maintainable?
https://marcgratch.com | mgratch
WordCamp Boston 2017
READ THE DOCS!
Seriously…
https://marcgratch.com | mgratch
WordCamp Boston 2017
Find a Good Place to Start:
Defining your Goal
• Making a Change on the Frontend:
• Determine what file manages where (or near) your final code will need to output (or
need to modify.)
• Look at the source code (in the browser)
• Find unique strings to search for. (HTML classes or IDs are usually a good place to
start.)
• Search the plugins code base for this unique string.
https://marcgratch.com | mgratch
WordCamp Boston 2017
Find a Good Place to Start:
Defining your Goal
• Making a Change on the Backend:
• READ THE DOCS
• Try to identify the function(s)handling the data you wish to change.
• Search All Files in the Plugin for `apply_filters` or `do_action`
• USE BREAK POINTS / XDEBUG / STEP THROUGH
https://marcgratch.com | mgratch
WordCamp Boston 2017
Hooks: They’re Magical
Nothing clever here… they really are.
https://marcgratch.com | mgratch
WordCamp Boston 2017
Hooks: They’re Magical
• Event Driven Programming
• Complex Changes Without Modifying Core Files
• Modify Data at the Source
• Upgrade Safely (typically)
• Backwards Compatible!!!! (typically)
https://marcgratch.com | mgratch
WordCamp Boston 2017
Pluggable Functions &
Overriding templates
The dangers within.
https://marcgratch.com | mgratch
WordCamp Boston 2017
Overriding Functions: Pluggable Functions
if ( ! function_exists( ‘some_function’ ) ) {
// do something different
}
• You can only do this once
• Only works as long as the pluggable function exists
https://marcgratch.com | mgratch
WordCamp Boston 2017
Pluggable “Template” Files
• When the original file is updated… yours will
remain. Old & Outdated.
• Multiple implementations are problematic.
• Only works as long as the original file exists/used
or no longer performs its intended function.
https://marcgratch.com | mgratch
WordCamp Boston 2017
Modifying Returned Content
• DO NOT MODIFY HTML WITH str_replace()
• Browsers are lenient – not all HTML is written the same.
• Modifying return HTML requires
DOMDocument Class
• Make sure the `class_exists(‘DOMDocument’)`
https://marcgratch.com | mgratch
WordCamp Boston 2017
If All Else Fails: Write a Patch
Then ask the plugin developers to implement it…
https://marcgratch.com | mgratch
WordCamp Boston 2017
Asking for a Change to the Core Plugin:
•Be Polite
•Identify if it’s an Edge Case
•Explain the Reason for your Patch
•Offer to fix another bug if you can…
https://marcgratch.com | mgratch
WordCamp Boston 2017
Asking for a Change to the Core Plugin:
…the other reason I was reaching out was in regards to submitting patches. I
realize it is likely an edge case, but I am hopeful that you might be willing to
consider implementing the attached patch. It simply adds the ability to add custom
fields (or content) to the bottom of the `getImageTab` output. I have tested it and
written further unit tests for it. The patch appears to work as expected.
Furthermore, I am familiar with your code base and I am happy to help with any
other bugs or roadmap features as I continue to work with your plugin…
https://marcgratch.com | mgratch
WordCamp Boston 2017
Asking for a Change to the Core Plugin:
First let me say I have been using your plugin since 2012 and I am always happy
to support good plugins and their authors.
I am hopeful you are willing to consider implementing the attached patch. It
allows form submission via AJAX. I am building a single page app and
honestly your plugin does everything I need except post back is killing the
experience. I have tested it on a vanilla WP install and it seems to be working.
If you run unit tests I am happy to write a few for this new functionality as
well…
https://marcgratch.com | mgratch
WordCamp Boston 2017
Great Resources
wptavern.com make.wordpress.org tommcfarlin.com
poststatus.com wordpress.tv pippinsplugins.com
joshpress.net wpchat.com carriedils.com
tuts+ wpbeginner.com carlalexander.ca
torquemag.io wpmayor.com yoast.com
wpshout.com helenhousandi.com gravitywiz.com
wplift.com chrislema.com webdevstudios.com
hookr.io
https://marcgratch.com | mgratch
WordCamp Boston 2017

More Related Content

Similar to playing ball with plugins WCBOS17.pptx

WordCamp Greenville 2018 - Beware the Dark Side, or an Intro to Development
WordCamp Greenville 2018 - Beware the Dark Side, or an Intro to DevelopmentWordCamp Greenville 2018 - Beware the Dark Side, or an Intro to Development
WordCamp Greenville 2018 - Beware the Dark Side, or an Intro to Development
Evan Mullins
 
Progressive Enhancement with JavaScript and Ajax
Progressive Enhancement with JavaScript and AjaxProgressive Enhancement with JavaScript and Ajax
Progressive Enhancement with JavaScript and Ajax
Christian Heilmann
 
How to build simple web apps to automate your SEO tasks - BrightonSEO Spring ...
How to build simple web apps to automate your SEO tasks - BrightonSEO Spring ...How to build simple web apps to automate your SEO tasks - BrightonSEO Spring ...
How to build simple web apps to automate your SEO tasks - BrightonSEO Spring ...
Charly Wargnier
 
Grails Worst Practices
Grails Worst PracticesGrails Worst Practices
Grails Worst Practices
Burt Beckwith
 
Introjs10.5.17SD
Introjs10.5.17SDIntrojs10.5.17SD
Introjs10.5.17SD
Thinkful
 
Tasting Your First Test Burger
Tasting Your First Test BurgerTasting Your First Test Burger
Tasting Your First Test Burger
Tautrimas Pajarskas
 
Teams, styles and scalable applications
Teams, styles and scalable applicationsTeams, styles and scalable applications
Teams, styles and scalable applications
Vittorio Vittori
 
Understanding progressive enhancement - yuiconf2010
Understanding progressive enhancement - yuiconf2010Understanding progressive enhancement - yuiconf2010
Understanding progressive enhancement - yuiconf2010Christian Heilmann
 
Midwest PHP 2017 DevOps For Small team
Midwest PHP 2017 DevOps For Small teamMidwest PHP 2017 DevOps For Small team
Midwest PHP 2017 DevOps For Small team
Joe Ferguson
 
Intro To Django
Intro To DjangoIntro To Django
Intro To Django
Udi Bauman
 
Shifting Gears
Shifting GearsShifting Gears
Shifting Gears
Christian Heilmann
 
Web Optimisation
Web OptimisationWeb Optimisation
Web Optimisation
Gregory Benner
 
OOScss Architecture For Rails Apps
OOScss Architecture For Rails AppsOOScss Architecture For Rails Apps
OOScss Architecture For Rails Apps
Netguru
 
Rapid Prototyping with Sass, Compass and Middleman by Bermon Painter
Rapid Prototyping with Sass, Compass and Middleman by Bermon PainterRapid Prototyping with Sass, Compass and Middleman by Bermon Painter
Rapid Prototyping with Sass, Compass and Middleman by Bermon Painter
Codemotion
 
DevSecCon Singapore 2018 - Remove developers’ shameful secrets or simply rem...
DevSecCon Singapore 2018 -  Remove developers’ shameful secrets or simply rem...DevSecCon Singapore 2018 -  Remove developers’ shameful secrets or simply rem...
DevSecCon Singapore 2018 - Remove developers’ shameful secrets or simply rem...
DevSecCon
 
Professional JavaScript: AntiPatterns
Professional JavaScript: AntiPatternsProfessional JavaScript: AntiPatterns
Professional JavaScript: AntiPatterns
Mike Wilcox
 
We continue checking Microsoft projects: analysis of PowerShell
We continue checking Microsoft projects: analysis of PowerShellWe continue checking Microsoft projects: analysis of PowerShell
We continue checking Microsoft projects: analysis of PowerShell
PVS-Studio
 
Xdebug for Beginners
Xdebug for BeginnersXdebug for Beginners
Xdebug for Beginners
Sean Prunka
 
Effizientere WordPress-Plugin-Entwicklung mit Softwaretests
Effizientere WordPress-Plugin-Entwicklung mit SoftwaretestsEffizientere WordPress-Plugin-Entwicklung mit Softwaretests
Effizientere WordPress-Plugin-Entwicklung mit Softwaretests
DECK36
 
Stapling and patching the web of now - ForwardJS3, San Francisco
Stapling and patching the web of now - ForwardJS3, San FranciscoStapling and patching the web of now - ForwardJS3, San Francisco
Stapling and patching the web of now - ForwardJS3, San Francisco
Christian Heilmann
 

Similar to playing ball with plugins WCBOS17.pptx (20)

WordCamp Greenville 2018 - Beware the Dark Side, or an Intro to Development
WordCamp Greenville 2018 - Beware the Dark Side, or an Intro to DevelopmentWordCamp Greenville 2018 - Beware the Dark Side, or an Intro to Development
WordCamp Greenville 2018 - Beware the Dark Side, or an Intro to Development
 
Progressive Enhancement with JavaScript and Ajax
Progressive Enhancement with JavaScript and AjaxProgressive Enhancement with JavaScript and Ajax
Progressive Enhancement with JavaScript and Ajax
 
How to build simple web apps to automate your SEO tasks - BrightonSEO Spring ...
How to build simple web apps to automate your SEO tasks - BrightonSEO Spring ...How to build simple web apps to automate your SEO tasks - BrightonSEO Spring ...
How to build simple web apps to automate your SEO tasks - BrightonSEO Spring ...
 
Grails Worst Practices
Grails Worst PracticesGrails Worst Practices
Grails Worst Practices
 
Introjs10.5.17SD
Introjs10.5.17SDIntrojs10.5.17SD
Introjs10.5.17SD
 
Tasting Your First Test Burger
Tasting Your First Test BurgerTasting Your First Test Burger
Tasting Your First Test Burger
 
Teams, styles and scalable applications
Teams, styles and scalable applicationsTeams, styles and scalable applications
Teams, styles and scalable applications
 
Understanding progressive enhancement - yuiconf2010
Understanding progressive enhancement - yuiconf2010Understanding progressive enhancement - yuiconf2010
Understanding progressive enhancement - yuiconf2010
 
Midwest PHP 2017 DevOps For Small team
Midwest PHP 2017 DevOps For Small teamMidwest PHP 2017 DevOps For Small team
Midwest PHP 2017 DevOps For Small team
 
Intro To Django
Intro To DjangoIntro To Django
Intro To Django
 
Shifting Gears
Shifting GearsShifting Gears
Shifting Gears
 
Web Optimisation
Web OptimisationWeb Optimisation
Web Optimisation
 
OOScss Architecture For Rails Apps
OOScss Architecture For Rails AppsOOScss Architecture For Rails Apps
OOScss Architecture For Rails Apps
 
Rapid Prototyping with Sass, Compass and Middleman by Bermon Painter
Rapid Prototyping with Sass, Compass and Middleman by Bermon PainterRapid Prototyping with Sass, Compass and Middleman by Bermon Painter
Rapid Prototyping with Sass, Compass and Middleman by Bermon Painter
 
DevSecCon Singapore 2018 - Remove developers’ shameful secrets or simply rem...
DevSecCon Singapore 2018 -  Remove developers’ shameful secrets or simply rem...DevSecCon Singapore 2018 -  Remove developers’ shameful secrets or simply rem...
DevSecCon Singapore 2018 - Remove developers’ shameful secrets or simply rem...
 
Professional JavaScript: AntiPatterns
Professional JavaScript: AntiPatternsProfessional JavaScript: AntiPatterns
Professional JavaScript: AntiPatterns
 
We continue checking Microsoft projects: analysis of PowerShell
We continue checking Microsoft projects: analysis of PowerShellWe continue checking Microsoft projects: analysis of PowerShell
We continue checking Microsoft projects: analysis of PowerShell
 
Xdebug for Beginners
Xdebug for BeginnersXdebug for Beginners
Xdebug for Beginners
 
Effizientere WordPress-Plugin-Entwicklung mit Softwaretests
Effizientere WordPress-Plugin-Entwicklung mit SoftwaretestsEffizientere WordPress-Plugin-Entwicklung mit Softwaretests
Effizientere WordPress-Plugin-Entwicklung mit Softwaretests
 
Stapling and patching the web of now - ForwardJS3, San Francisco
Stapling and patching the web of now - ForwardJS3, San FranciscoStapling and patching the web of now - ForwardJS3, San Francisco
Stapling and patching the web of now - ForwardJS3, San Francisco
 

Recently uploaded

Steel & Timber Design according to British Standard
Steel & Timber Design according to British StandardSteel & Timber Design according to British Standard
Steel & Timber Design according to British Standard
AkolbilaEmmanuel1
 
weather web application report.pdf
weather web application report.pdfweather web application report.pdf
weather web application report.pdf
Pratik Pawar
 
Technical Drawings introduction to drawing of prisms
Technical Drawings introduction to drawing of prismsTechnical Drawings introduction to drawing of prisms
Technical Drawings introduction to drawing of prisms
heavyhaig
 
一比一原版(SFU毕业证)西蒙菲莎大学毕业证成绩单如何办理
一比一原版(SFU毕业证)西蒙菲莎大学毕业证成绩单如何办理一比一原版(SFU毕业证)西蒙菲莎大学毕业证成绩单如何办理
一比一原版(SFU毕业证)西蒙菲莎大学毕业证成绩单如何办理
bakpo1
 
在线办理(ANU毕业证书)澳洲国立大学毕业证录取通知书一模一样
在线办理(ANU毕业证书)澳洲国立大学毕业证录取通知书一模一样在线办理(ANU毕业证书)澳洲国立大学毕业证录取通知书一模一样
在线办理(ANU毕业证书)澳洲国立大学毕业证录取通知书一模一样
obonagu
 
The Role of Electrical and Electronics Engineers in IOT Technology.pdf
The Role of Electrical and Electronics Engineers in IOT Technology.pdfThe Role of Electrical and Electronics Engineers in IOT Technology.pdf
The Role of Electrical and Electronics Engineers in IOT Technology.pdf
Nettur Technical Training Foundation
 
Pile Foundation by Venkatesh Taduvai (Sub Geotechnical Engineering II)-conver...
Pile Foundation by Venkatesh Taduvai (Sub Geotechnical Engineering II)-conver...Pile Foundation by Venkatesh Taduvai (Sub Geotechnical Engineering II)-conver...
Pile Foundation by Venkatesh Taduvai (Sub Geotechnical Engineering II)-conver...
AJAYKUMARPUND1
 
Hybrid optimization of pumped hydro system and solar- Engr. Abdul-Azeez.pdf
Hybrid optimization of pumped hydro system and solar- Engr. Abdul-Azeez.pdfHybrid optimization of pumped hydro system and solar- Engr. Abdul-Azeez.pdf
Hybrid optimization of pumped hydro system and solar- Engr. Abdul-Azeez.pdf
fxintegritypublishin
 
DfMAy 2024 - key insights and contributions
DfMAy 2024 - key insights and contributionsDfMAy 2024 - key insights and contributions
DfMAy 2024 - key insights and contributions
gestioneergodomus
 
14 Template Contractual Notice - EOT Application
14 Template Contractual Notice - EOT Application14 Template Contractual Notice - EOT Application
14 Template Contractual Notice - EOT Application
SyedAbiiAzazi1
 
Heap Sort (SS).ppt FOR ENGINEERING GRADUATES, BCA, MCA, MTECH, BSC STUDENTS
Heap Sort (SS).ppt FOR ENGINEERING GRADUATES, BCA, MCA, MTECH, BSC STUDENTSHeap Sort (SS).ppt FOR ENGINEERING GRADUATES, BCA, MCA, MTECH, BSC STUDENTS
Heap Sort (SS).ppt FOR ENGINEERING GRADUATES, BCA, MCA, MTECH, BSC STUDENTS
Soumen Santra
 
RAT: Retrieval Augmented Thoughts Elicit Context-Aware Reasoning in Long-Hori...
RAT: Retrieval Augmented Thoughts Elicit Context-Aware Reasoning in Long-Hori...RAT: Retrieval Augmented Thoughts Elicit Context-Aware Reasoning in Long-Hori...
RAT: Retrieval Augmented Thoughts Elicit Context-Aware Reasoning in Long-Hori...
thanhdowork
 
一比一原版(UofT毕业证)多伦多大学毕业证成绩单如何办理
一比一原版(UofT毕业证)多伦多大学毕业证成绩单如何办理一比一原版(UofT毕业证)多伦多大学毕业证成绩单如何办理
一比一原版(UofT毕业证)多伦多大学毕业证成绩单如何办理
ydteq
 
Hierarchical Digital Twin of a Naval Power System
Hierarchical Digital Twin of a Naval Power SystemHierarchical Digital Twin of a Naval Power System
Hierarchical Digital Twin of a Naval Power System
Kerry Sado
 
Sachpazis:Terzaghi Bearing Capacity Estimation in simple terms with Calculati...
Sachpazis:Terzaghi Bearing Capacity Estimation in simple terms with Calculati...Sachpazis:Terzaghi Bearing Capacity Estimation in simple terms with Calculati...
Sachpazis:Terzaghi Bearing Capacity Estimation in simple terms with Calculati...
Dr.Costas Sachpazis
 
DESIGN AND ANALYSIS OF A CAR SHOWROOM USING E TABS
DESIGN AND ANALYSIS OF A CAR SHOWROOM USING E TABSDESIGN AND ANALYSIS OF A CAR SHOWROOM USING E TABS
DESIGN AND ANALYSIS OF A CAR SHOWROOM USING E TABS
itech2017
 
Gen AI Study Jams _ For the GDSC Leads in India.pdf
Gen AI Study Jams _ For the GDSC Leads in India.pdfGen AI Study Jams _ For the GDSC Leads in India.pdf
Gen AI Study Jams _ For the GDSC Leads in India.pdf
gdsczhcet
 
Governing Equations for Fundamental Aerodynamics_Anderson2010.pdf
Governing Equations for Fundamental Aerodynamics_Anderson2010.pdfGoverning Equations for Fundamental Aerodynamics_Anderson2010.pdf
Governing Equations for Fundamental Aerodynamics_Anderson2010.pdf
WENKENLI1
 
Immunizing Image Classifiers Against Localized Adversary Attacks
Immunizing Image Classifiers Against Localized Adversary AttacksImmunizing Image Classifiers Against Localized Adversary Attacks
Immunizing Image Classifiers Against Localized Adversary Attacks
gerogepatton
 
一比一原版(IIT毕业证)伊利诺伊理工大学毕业证成绩单专业办理
一比一原版(IIT毕业证)伊利诺伊理工大学毕业证成绩单专业办理一比一原版(IIT毕业证)伊利诺伊理工大学毕业证成绩单专业办理
一比一原版(IIT毕业证)伊利诺伊理工大学毕业证成绩单专业办理
zwunae
 

Recently uploaded (20)

Steel & Timber Design according to British Standard
Steel & Timber Design according to British StandardSteel & Timber Design according to British Standard
Steel & Timber Design according to British Standard
 
weather web application report.pdf
weather web application report.pdfweather web application report.pdf
weather web application report.pdf
 
Technical Drawings introduction to drawing of prisms
Technical Drawings introduction to drawing of prismsTechnical Drawings introduction to drawing of prisms
Technical Drawings introduction to drawing of prisms
 
一比一原版(SFU毕业证)西蒙菲莎大学毕业证成绩单如何办理
一比一原版(SFU毕业证)西蒙菲莎大学毕业证成绩单如何办理一比一原版(SFU毕业证)西蒙菲莎大学毕业证成绩单如何办理
一比一原版(SFU毕业证)西蒙菲莎大学毕业证成绩单如何办理
 
在线办理(ANU毕业证书)澳洲国立大学毕业证录取通知书一模一样
在线办理(ANU毕业证书)澳洲国立大学毕业证录取通知书一模一样在线办理(ANU毕业证书)澳洲国立大学毕业证录取通知书一模一样
在线办理(ANU毕业证书)澳洲国立大学毕业证录取通知书一模一样
 
The Role of Electrical and Electronics Engineers in IOT Technology.pdf
The Role of Electrical and Electronics Engineers in IOT Technology.pdfThe Role of Electrical and Electronics Engineers in IOT Technology.pdf
The Role of Electrical and Electronics Engineers in IOT Technology.pdf
 
Pile Foundation by Venkatesh Taduvai (Sub Geotechnical Engineering II)-conver...
Pile Foundation by Venkatesh Taduvai (Sub Geotechnical Engineering II)-conver...Pile Foundation by Venkatesh Taduvai (Sub Geotechnical Engineering II)-conver...
Pile Foundation by Venkatesh Taduvai (Sub Geotechnical Engineering II)-conver...
 
Hybrid optimization of pumped hydro system and solar- Engr. Abdul-Azeez.pdf
Hybrid optimization of pumped hydro system and solar- Engr. Abdul-Azeez.pdfHybrid optimization of pumped hydro system and solar- Engr. Abdul-Azeez.pdf
Hybrid optimization of pumped hydro system and solar- Engr. Abdul-Azeez.pdf
 
DfMAy 2024 - key insights and contributions
DfMAy 2024 - key insights and contributionsDfMAy 2024 - key insights and contributions
DfMAy 2024 - key insights and contributions
 
14 Template Contractual Notice - EOT Application
14 Template Contractual Notice - EOT Application14 Template Contractual Notice - EOT Application
14 Template Contractual Notice - EOT Application
 
Heap Sort (SS).ppt FOR ENGINEERING GRADUATES, BCA, MCA, MTECH, BSC STUDENTS
Heap Sort (SS).ppt FOR ENGINEERING GRADUATES, BCA, MCA, MTECH, BSC STUDENTSHeap Sort (SS).ppt FOR ENGINEERING GRADUATES, BCA, MCA, MTECH, BSC STUDENTS
Heap Sort (SS).ppt FOR ENGINEERING GRADUATES, BCA, MCA, MTECH, BSC STUDENTS
 
RAT: Retrieval Augmented Thoughts Elicit Context-Aware Reasoning in Long-Hori...
RAT: Retrieval Augmented Thoughts Elicit Context-Aware Reasoning in Long-Hori...RAT: Retrieval Augmented Thoughts Elicit Context-Aware Reasoning in Long-Hori...
RAT: Retrieval Augmented Thoughts Elicit Context-Aware Reasoning in Long-Hori...
 
一比一原版(UofT毕业证)多伦多大学毕业证成绩单如何办理
一比一原版(UofT毕业证)多伦多大学毕业证成绩单如何办理一比一原版(UofT毕业证)多伦多大学毕业证成绩单如何办理
一比一原版(UofT毕业证)多伦多大学毕业证成绩单如何办理
 
Hierarchical Digital Twin of a Naval Power System
Hierarchical Digital Twin of a Naval Power SystemHierarchical Digital Twin of a Naval Power System
Hierarchical Digital Twin of a Naval Power System
 
Sachpazis:Terzaghi Bearing Capacity Estimation in simple terms with Calculati...
Sachpazis:Terzaghi Bearing Capacity Estimation in simple terms with Calculati...Sachpazis:Terzaghi Bearing Capacity Estimation in simple terms with Calculati...
Sachpazis:Terzaghi Bearing Capacity Estimation in simple terms with Calculati...
 
DESIGN AND ANALYSIS OF A CAR SHOWROOM USING E TABS
DESIGN AND ANALYSIS OF A CAR SHOWROOM USING E TABSDESIGN AND ANALYSIS OF A CAR SHOWROOM USING E TABS
DESIGN AND ANALYSIS OF A CAR SHOWROOM USING E TABS
 
Gen AI Study Jams _ For the GDSC Leads in India.pdf
Gen AI Study Jams _ For the GDSC Leads in India.pdfGen AI Study Jams _ For the GDSC Leads in India.pdf
Gen AI Study Jams _ For the GDSC Leads in India.pdf
 
Governing Equations for Fundamental Aerodynamics_Anderson2010.pdf
Governing Equations for Fundamental Aerodynamics_Anderson2010.pdfGoverning Equations for Fundamental Aerodynamics_Anderson2010.pdf
Governing Equations for Fundamental Aerodynamics_Anderson2010.pdf
 
Immunizing Image Classifiers Against Localized Adversary Attacks
Immunizing Image Classifiers Against Localized Adversary AttacksImmunizing Image Classifiers Against Localized Adversary Attacks
Immunizing Image Classifiers Against Localized Adversary Attacks
 
一比一原版(IIT毕业证)伊利诺伊理工大学毕业证成绩单专业办理
一比一原版(IIT毕业证)伊利诺伊理工大学毕业证成绩单专业办理一比一原版(IIT毕业证)伊利诺伊理工大学毕业证成绩单专业办理
一比一原版(IIT毕业证)伊利诺伊理工大学毕业证成绩单专业办理
 

playing ball with plugins WCBOS17.pptx

  • 1. Playing Ball With Plugins Navigating and Extending Large Codebases: A Field Guide https://marcgratch.com | mgratch WordCamp Boston 2017
  • 2. Defining Your Problem Make sure you’re solving a real problem https://marcgratch.com | mgratch WordCamp Boston 2017
  • 3. Make sure you’re solving a real problem • Is this behavior self-inflicted or inherent to the plugin? • Does this (will this) behavior bother the client? (Or is it just me?) • Will this impact launch? • Can it be fixed with a bit of CSS? https://marcgratch.com | mgratch WordCamp Boston 2017
  • 4. Be Aware: Dangerous Territory Extending another plugin can get messy https://marcgratch.com | mgratch WordCamp Boston 2017
  • 5. Some “dangers” of Extending/Integrating with a 3rd Party Plugin •Is the plugin regularly maintained? •Are the plugin updates (typically) backwards compatible? •Did you ensure your code is maintainable? https://marcgratch.com | mgratch WordCamp Boston 2017
  • 6. READ THE DOCS! Seriously… https://marcgratch.com | mgratch WordCamp Boston 2017
  • 7. Find a Good Place to Start: Defining your Goal • Making a Change on the Frontend: • Determine what file manages where (or near) your final code will need to output (or need to modify.) • Look at the source code (in the browser) • Find unique strings to search for. (HTML classes or IDs are usually a good place to start.) • Search the plugins code base for this unique string. https://marcgratch.com | mgratch WordCamp Boston 2017
  • 8. Find a Good Place to Start: Defining your Goal • Making a Change on the Backend: • READ THE DOCS • Try to identify the function(s)handling the data you wish to change. • Search All Files in the Plugin for `apply_filters` or `do_action` • USE BREAK POINTS / XDEBUG / STEP THROUGH https://marcgratch.com | mgratch WordCamp Boston 2017
  • 9. Hooks: They’re Magical Nothing clever here… they really are. https://marcgratch.com | mgratch WordCamp Boston 2017
  • 10. Hooks: They’re Magical • Event Driven Programming • Complex Changes Without Modifying Core Files • Modify Data at the Source • Upgrade Safely (typically) • Backwards Compatible!!!! (typically) https://marcgratch.com | mgratch WordCamp Boston 2017
  • 11. Pluggable Functions & Overriding templates The dangers within. https://marcgratch.com | mgratch WordCamp Boston 2017
  • 12. Overriding Functions: Pluggable Functions if ( ! function_exists( ‘some_function’ ) ) { // do something different } • You can only do this once • Only works as long as the pluggable function exists https://marcgratch.com | mgratch WordCamp Boston 2017
  • 13. Pluggable “Template” Files • When the original file is updated… yours will remain. Old & Outdated. • Multiple implementations are problematic. • Only works as long as the original file exists/used or no longer performs its intended function. https://marcgratch.com | mgratch WordCamp Boston 2017
  • 14. Modifying Returned Content • DO NOT MODIFY HTML WITH str_replace() • Browsers are lenient – not all HTML is written the same. • Modifying return HTML requires DOMDocument Class • Make sure the `class_exists(‘DOMDocument’)` https://marcgratch.com | mgratch WordCamp Boston 2017
  • 15. If All Else Fails: Write a Patch Then ask the plugin developers to implement it… https://marcgratch.com | mgratch WordCamp Boston 2017
  • 16. Asking for a Change to the Core Plugin: •Be Polite •Identify if it’s an Edge Case •Explain the Reason for your Patch •Offer to fix another bug if you can… https://marcgratch.com | mgratch WordCamp Boston 2017
  • 17. Asking for a Change to the Core Plugin: …the other reason I was reaching out was in regards to submitting patches. I realize it is likely an edge case, but I am hopeful that you might be willing to consider implementing the attached patch. It simply adds the ability to add custom fields (or content) to the bottom of the `getImageTab` output. I have tested it and written further unit tests for it. The patch appears to work as expected. Furthermore, I am familiar with your code base and I am happy to help with any other bugs or roadmap features as I continue to work with your plugin… https://marcgratch.com | mgratch WordCamp Boston 2017
  • 18. Asking for a Change to the Core Plugin: First let me say I have been using your plugin since 2012 and I am always happy to support good plugins and their authors. I am hopeful you are willing to consider implementing the attached patch. It allows form submission via AJAX. I am building a single page app and honestly your plugin does everything I need except post back is killing the experience. I have tested it on a vanilla WP install and it seems to be working. If you run unit tests I am happy to write a few for this new functionality as well… https://marcgratch.com | mgratch WordCamp Boston 2017
  • 19. Great Resources wptavern.com make.wordpress.org tommcfarlin.com poststatus.com wordpress.tv pippinsplugins.com joshpress.net wpchat.com carriedils.com tuts+ wpbeginner.com carlalexander.ca torquemag.io wpmayor.com yoast.com wpshout.com helenhousandi.com gravitywiz.com wplift.com chrislema.com webdevstudios.com hookr.io https://marcgratch.com | mgratch WordCamp Boston 2017