SlideShare ist ein Scribd-Unternehmen logo
1 von 26
Creating Customizable
Widgets for
Unpredictable Needs
Amanda Giles
http://bit.ly/boswp1115
WordPress Boston – Nov 30, 2015 - #BostonWP
Who am I?
• Independent IT Consultant
• WordPress Developer (Themes and Plugins)
• Run the Seacoast NH WordPress Meetup
• Lover
• Fighter
• Sneezer
• Teacher / Trainer
• My favorite quote is from Calvin & Hobbes:
“Virtue isn’t better than vice, it’s just different.
http://bit.ly/boswp1115
And I have cats!
http://bit.ly/boswp1115
Information Gathering…
• Who here has used a widget?
• Who here has created a widget?
• Who has lost hours trying widget after widget
to find the “right” one?
http://bit.ly/boswp1115
Who is this talk geared towards?
Developers
http://bit.ly/boswp1115
But what if I’m not a
developer?
http://bit.ly/boswp1115
http://bit.ly/boswp1115
Why you should stay
(even if you’re not a developer)
• Might convince a plugin developer to modify a
widget to address your needs
• Might find a widget that’s close to your needs
and hire someone to modify it
• Might decide to roll up your sleeves and try your
hand at coding
http://bit.ly/boswp1115
What is a widget?
• A way to take [inputted] criteria from a WordPress user
and convert that to into output for a website visitor.
• Drag and Drop widgets into widget areas under
Appearance > Widgets
• Collect input [criteria] from user via a form
• When website is viewed, content is displayed to a
website visitor
http://bit.ly/boswp1115
Widget Examples
http://bit.ly/boswp1115
Why create your own widgets?
http://bit.ly/boswp1115
But seriously…
Creating widgets is a way to control
the content of what's being presented
while giving the user choices about
that content, its presentation, and its
location.
http://bit.ly/boswp1115
How do we do this?
For Users:
Anticipate what choices or variations
the user might want
For Developers:
Offer ways to adjust the
output where feasible
http://bit.ly/boswp1115
What does that mean?
For Users:
Anticipate what choices or variations
the user might want
• Offer choices to filter the content shown
• Offer choices about how that content is shown
• Offer style choices
• Provide basic clean styling or no styling
http://bit.ly/boswp1115
What does that mean?
For Developers:
Offer ways to adjust the
output where feasible
• Be sure to tag output elements with id/class so
styles can be easily overridden
• Use hooks to allow filtering of output (for
developers)
http://bit.ly/boswp1115
Anatomy of a widget
1. Declaration/Construct
Tell WordPress some information about your widget and how to identify it
2. User Interface / Form
Define the form that will gather user's choices about the widget instance
3. Update/Save Logic
Save the user's choices about the widget instance
4. Widget/Output Logic
Display the widget instance to the website visitor
5. Register the Widget
Tell WordPress to register your widget and include it on the
Appearance > Widgets page
http://bit.ly/boswp1115
Widget Code Structure
1. Declaration/Construct
2. User Interface / Form
3. Update/Save Logic
4. Widget/Output Logic
5. Register Widget using Widget Name
0. Widget Name & “extends WP_Widget”
http://bit.ly/boswp1115
“Show Posts” widget
We’re going to look at a widget that displays posts.
Our first pass, we’ll focus on the basic user choices:
• Specify Widget Title (or not)
• Choose one or more specific post IDs
• Choose post type (post, page, custom post types)
• Choose # of posts to show
• Choose what to sort by
• Choose the sort order (ascending, descending)
• Choose whether to show the post thumbnail/featured image
• Choose whether to display the full post content or excerpt
http://bit.ly/boswp1115
On to the coding!
http://bit.ly/boswp1115
Second Pass
On our second pass through the widget we will
add the following touches to flush it out further:
• Add CSS for the widget output on website
• Add CSS for the Admin User Interface/Form
• Place hooks to allow filtering on several
elements
http://bit.ly/boswp1115
What is a hook?
A hook is an "event" which allows for additional
code to be run when it occurs.
One or more functions can be associated with a
hook and they will all run when the hook is
triggered.
http://bit.ly/boswp1115
Why use hooks?
Hooks are placed within WordPress core, plugins,
and themes to allow customization by developers
without direct edits of the code.
Hooks are the proper way to alter the default
behavior of code which is not yours to edit.
http://bit.ly/boswp1115
Types of hooks
Action hooks allow you to run code at a certain
point within the code.
Examples in WP core include initialization, before
main query is run, header or footer of a page/post.
Filter hooks allow you to alter data, content,
parameters. A filter hook is passed information to
filter and returns it altered (or not).
Examples in WP code include displaying content,
page/post title, pre-saving content (admin).
http://bit.ly/boswp1115
http://bit.ly/boswp1115
Questions?
http://bit.ly/boswp1115
Thank You!
Find these slides and all related files at:
http://bit.ly/boswp1115
www.AmandaGiles.com
@AmandaGilesNH on Twitter
amanda@amandagiles.com
Please feel free to send me feedback or questions

Weitere ähnliche Inhalte

Was ist angesagt?

WordPress Child Themes
WordPress Child ThemesWordPress Child Themes
WordPress Child Themesrfair404
 
WordPress Developers Israel Meetup #1
WordPress Developers Israel Meetup #1WordPress Developers Israel Meetup #1
WordPress Developers Israel Meetup #1Yoav Farhi
 
WordPress Custom Fields: Control your content presentation by breaking out of...
WordPress Custom Fields: Control your content presentation by breaking out of...WordPress Custom Fields: Control your content presentation by breaking out of...
WordPress Custom Fields: Control your content presentation by breaking out of...Denise Williams
 
WordPress Theme Structure
WordPress Theme StructureWordPress Theme Structure
WordPress Theme Structurekeithdevon
 
Becoming a better WordPress Developer
Becoming a better WordPress DeveloperBecoming a better WordPress Developer
Becoming a better WordPress DeveloperJoey Kudish
 
Custom Post Types in Depth at WordCamp Montreal
Custom Post Types in Depth at WordCamp MontrealCustom Post Types in Depth at WordCamp Montreal
Custom Post Types in Depth at WordCamp MontrealJoey Kudish
 
Theming Wordpress with Adobe
Theming Wordpress with AdobeTheming Wordpress with Adobe
Theming Wordpress with AdobeGrace Solivan
 
Introduction to WordPress Theme Development
Introduction to WordPress Theme DevelopmentIntroduction to WordPress Theme Development
Introduction to WordPress Theme DevelopmentSitdhibong Laokok
 
Introduction to Custom WordPress Themeing
Introduction to Custom WordPress ThemeingIntroduction to Custom WordPress Themeing
Introduction to Custom WordPress ThemeingJamie Schmid
 
Theme development essentials columbus oh word camp 2012
Theme development essentials   columbus oh word camp 2012Theme development essentials   columbus oh word camp 2012
Theme development essentials columbus oh word camp 2012Joe Querin
 
How to Prepare a WordPress Theme for Public Release
How to Prepare a WordPress Theme for Public ReleaseHow to Prepare a WordPress Theme for Public Release
How to Prepare a WordPress Theme for Public ReleaseDavid Yeiser
 
The Future Of WordPress Presentation
The Future Of WordPress PresentationThe Future Of WordPress Presentation
The Future Of WordPress PresentationDougal Campbell
 
WordPress Theme Development
WordPress Theme DevelopmentWordPress Theme Development
WordPress Theme DevelopmentWisdmLabs
 
WordPress Custom Post Types
WordPress Custom Post TypesWordPress Custom Post Types
WordPress Custom Post TypesNile Flores
 
WordCamp Boston 2012 - Creating Content With Shortcodes
WordCamp Boston 2012 - Creating Content With ShortcodesWordCamp Boston 2012 - Creating Content With Shortcodes
WordCamp Boston 2012 - Creating Content With ShortcodesJon Bishop
 

Was ist angesagt? (20)

Rebrand WordPress Admin
Rebrand WordPress AdminRebrand WordPress Admin
Rebrand WordPress Admin
 
WordPress Child Themes
WordPress Child ThemesWordPress Child Themes
WordPress Child Themes
 
WordPress Developers Israel Meetup #1
WordPress Developers Israel Meetup #1WordPress Developers Israel Meetup #1
WordPress Developers Israel Meetup #1
 
WordPress Custom Fields: Control your content presentation by breaking out of...
WordPress Custom Fields: Control your content presentation by breaking out of...WordPress Custom Fields: Control your content presentation by breaking out of...
WordPress Custom Fields: Control your content presentation by breaking out of...
 
WordPress Theme Structure
WordPress Theme StructureWordPress Theme Structure
WordPress Theme Structure
 
Seven deadly theming sins
Seven deadly theming sinsSeven deadly theming sins
Seven deadly theming sins
 
Becoming a better WordPress Developer
Becoming a better WordPress DeveloperBecoming a better WordPress Developer
Becoming a better WordPress Developer
 
Custom Post Types in Depth at WordCamp Montreal
Custom Post Types in Depth at WordCamp MontrealCustom Post Types in Depth at WordCamp Montreal
Custom Post Types in Depth at WordCamp Montreal
 
Theming Wordpress with Adobe
Theming Wordpress with AdobeTheming Wordpress with Adobe
Theming Wordpress with Adobe
 
Introduction to WordPress Theme Development
Introduction to WordPress Theme DevelopmentIntroduction to WordPress Theme Development
Introduction to WordPress Theme Development
 
Introduction to Custom WordPress Themeing
Introduction to Custom WordPress ThemeingIntroduction to Custom WordPress Themeing
Introduction to Custom WordPress Themeing
 
Theming 101
Theming 101Theming 101
Theming 101
 
Theme development essentials columbus oh word camp 2012
Theme development essentials   columbus oh word camp 2012Theme development essentials   columbus oh word camp 2012
Theme development essentials columbus oh word camp 2012
 
How to Prepare a WordPress Theme for Public Release
How to Prepare a WordPress Theme for Public ReleaseHow to Prepare a WordPress Theme for Public Release
How to Prepare a WordPress Theme for Public Release
 
What is (not) WordPress
What is (not) WordPressWhat is (not) WordPress
What is (not) WordPress
 
The Future Of WordPress Presentation
The Future Of WordPress PresentationThe Future Of WordPress Presentation
The Future Of WordPress Presentation
 
WordPress Theme Development
WordPress Theme DevelopmentWordPress Theme Development
WordPress Theme Development
 
WordPress Custom Post Types
WordPress Custom Post TypesWordPress Custom Post Types
WordPress Custom Post Types
 
WordCamp Boston 2012 - Creating Content With Shortcodes
WordCamp Boston 2012 - Creating Content With ShortcodesWordCamp Boston 2012 - Creating Content With Shortcodes
WordCamp Boston 2012 - Creating Content With Shortcodes
 
WordPress plugins
WordPress pluginsWordPress plugins
WordPress plugins
 

Ähnlich wie Creating Customizable Widgets for Unpredictable Needs

Technical SEO for WordPress Developers, Designers and Webmasters
Technical SEO for WordPress Developers, Designers and WebmastersTechnical SEO for WordPress Developers, Designers and Webmasters
Technical SEO for WordPress Developers, Designers and WebmastersHenry Visotski
 
Should you use WordPress for your non-profit websites?
Should you use WordPress for your non-profit websites?Should you use WordPress for your non-profit websites?
Should you use WordPress for your non-profit websites?Bethany Siegler
 
WordPress Workshop with Tadpole, SATW 2013 Conference
WordPress Workshop with Tadpole, SATW 2013 ConferenceWordPress Workshop with Tadpole, SATW 2013 Conference
WordPress Workshop with Tadpole, SATW 2013 ConferenceTadpole Collective
 
HTML Purifier, WYSIWYG, and TinyMCE
HTML Purifier, WYSIWYG, and TinyMCEHTML Purifier, WYSIWYG, and TinyMCE
HTML Purifier, WYSIWYG, and TinyMCEcgmonroe
 
How to deliver a WordPress website to your client ...the RIGHT way
How to deliver a WordPress website to your client ...the RIGHT wayHow to deliver a WordPress website to your client ...the RIGHT way
How to deliver a WordPress website to your client ...the RIGHT wayCath Hughes
 
Creating Customizable Widgets for Unpredictable Needs
Creating Customizable Widgets for Unpredictable NeedsCreating Customizable Widgets for Unpredictable Needs
Creating Customizable Widgets for Unpredictable NeedsAmanda Giles
 
A word press site even your mother can use
A word press site even your mother can useA word press site even your mother can use
A word press site even your mother can useJerrett Farmer
 
A word press site even your mother can use
A word press site even your mother can useA word press site even your mother can use
A word press site even your mother can useInMotion Hosting
 
A word press site even your mother can use
A word press site even your mother can useA word press site even your mother can use
A word press site even your mother can useJerrett Farmer
 
How To Get Started After Installing Wordpress ( Wordcamp, Delhi )
How To Get Started After Installing Wordpress ( Wordcamp, Delhi )How To Get Started After Installing Wordpress ( Wordcamp, Delhi )
How To Get Started After Installing Wordpress ( Wordcamp, Delhi )abhim12
 
WordPress Plugins to add style to your website
WordPress Plugins to add style to your websiteWordPress Plugins to add style to your website
WordPress Plugins to add style to your websiteBelinda Johnstone
 
Developing Blocks without React - Attributes.pptx
Developing Blocks without React - Attributes.pptxDeveloping Blocks without React - Attributes.pptx
Developing Blocks without React - Attributes.pptxJonathan Bossenger
 
How to build a Project Hub with Hubsites and Sitedesign and Sitescripts
How to build a Project Hub with Hubsites and Sitedesign and Sitescripts How to build a Project Hub with Hubsites and Sitedesign and Sitescripts
How to build a Project Hub with Hubsites and Sitedesign and Sitescripts Knut Relbe-Moe [MVP, MCT]
 
Maintaining Retainers as a WordPress Developer
Maintaining Retainers as a WordPress DeveloperMaintaining Retainers as a WordPress Developer
Maintaining Retainers as a WordPress DeveloperDevinVinson
 
WordPress Basics
WordPress BasicsWordPress Basics
WordPress BasicsDoug Fisher
 
MA Magazines: City Uni - Further Wordpress customisations, process and plugin...
MA Magazines: City Uni - Further Wordpress customisations, process and plugin...MA Magazines: City Uni - Further Wordpress customisations, process and plugin...
MA Magazines: City Uni - Further Wordpress customisations, process and plugin...Dan Davies
 
Salesforce CI (Continuous Integration) - SFDX + Bitbucket Pipelines
Salesforce CI (Continuous Integration) - SFDX + Bitbucket PipelinesSalesforce CI (Continuous Integration) - SFDX + Bitbucket Pipelines
Salesforce CI (Continuous Integration) - SFDX + Bitbucket PipelinesAbhinav Gupta
 

Ähnlich wie Creating Customizable Widgets for Unpredictable Needs (20)

Technical SEO for WordPress Developers, Designers and Webmasters
Technical SEO for WordPress Developers, Designers and WebmastersTechnical SEO for WordPress Developers, Designers and Webmasters
Technical SEO for WordPress Developers, Designers and Webmasters
 
Should you use WordPress for your non-profit websites?
Should you use WordPress for your non-profit websites?Should you use WordPress for your non-profit websites?
Should you use WordPress for your non-profit websites?
 
WordPress Workshop with Tadpole, SATW 2013 Conference
WordPress Workshop with Tadpole, SATW 2013 ConferenceWordPress Workshop with Tadpole, SATW 2013 Conference
WordPress Workshop with Tadpole, SATW 2013 Conference
 
HTML Purifier, WYSIWYG, and TinyMCE
HTML Purifier, WYSIWYG, and TinyMCEHTML Purifier, WYSIWYG, and TinyMCE
HTML Purifier, WYSIWYG, and TinyMCE
 
How to deliver a WordPress website to your client ...the RIGHT way
How to deliver a WordPress website to your client ...the RIGHT wayHow to deliver a WordPress website to your client ...the RIGHT way
How to deliver a WordPress website to your client ...the RIGHT way
 
WordPress Complete Tutorial
WordPress Complete TutorialWordPress Complete Tutorial
WordPress Complete Tutorial
 
Creating Customizable Widgets for Unpredictable Needs
Creating Customizable Widgets for Unpredictable NeedsCreating Customizable Widgets for Unpredictable Needs
Creating Customizable Widgets for Unpredictable Needs
 
A word press site even your mother can use
A word press site even your mother can useA word press site even your mother can use
A word press site even your mother can use
 
A word press site even your mother can use
A word press site even your mother can useA word press site even your mother can use
A word press site even your mother can use
 
A word press site even your mother can use
A word press site even your mother can useA word press site even your mother can use
A word press site even your mother can use
 
How To Get Started After Installing Wordpress ( Wordcamp, Delhi )
How To Get Started After Installing Wordpress ( Wordcamp, Delhi )How To Get Started After Installing Wordpress ( Wordcamp, Delhi )
How To Get Started After Installing Wordpress ( Wordcamp, Delhi )
 
WordPress Plugins to add style to your website
WordPress Plugins to add style to your websiteWordPress Plugins to add style to your website
WordPress Plugins to add style to your website
 
Wordpress Shortcode
Wordpress ShortcodeWordpress Shortcode
Wordpress Shortcode
 
937079
937079937079
937079
 
Developing Blocks without React - Attributes.pptx
Developing Blocks without React - Attributes.pptxDeveloping Blocks without React - Attributes.pptx
Developing Blocks without React - Attributes.pptx
 
How to build a Project Hub with Hubsites and Sitedesign and Sitescripts
How to build a Project Hub with Hubsites and Sitedesign and Sitescripts How to build a Project Hub with Hubsites and Sitedesign and Sitescripts
How to build a Project Hub with Hubsites and Sitedesign and Sitescripts
 
Maintaining Retainers as a WordPress Developer
Maintaining Retainers as a WordPress DeveloperMaintaining Retainers as a WordPress Developer
Maintaining Retainers as a WordPress Developer
 
WordPress Basics
WordPress BasicsWordPress Basics
WordPress Basics
 
MA Magazines: City Uni - Further Wordpress customisations, process and plugin...
MA Magazines: City Uni - Further Wordpress customisations, process and plugin...MA Magazines: City Uni - Further Wordpress customisations, process and plugin...
MA Magazines: City Uni - Further Wordpress customisations, process and plugin...
 
Salesforce CI (Continuous Integration) - SFDX + Bitbucket Pipelines
Salesforce CI (Continuous Integration) - SFDX + Bitbucket PipelinesSalesforce CI (Continuous Integration) - SFDX + Bitbucket Pipelines
Salesforce CI (Continuous Integration) - SFDX + Bitbucket Pipelines
 

Kürzlich hochgeladen

HR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.comHR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.comFatema Valibhai
 
Optimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTVOptimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTVshikhaohhpro
 
LEVEL 5 - SESSION 1 2023 (1).pptx - PDF 123456
LEVEL 5   - SESSION 1 2023 (1).pptx - PDF 123456LEVEL 5   - SESSION 1 2023 (1).pptx - PDF 123456
LEVEL 5 - SESSION 1 2023 (1).pptx - PDF 123456KiaraTiradoMicha
 
%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein
%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein
%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfonteinmasabamasaba
 
Direct Style Effect Systems - The Print[A] Example - A Comprehension Aid
Direct Style Effect Systems -The Print[A] Example- A Comprehension AidDirect Style Effect Systems -The Print[A] Example- A Comprehension Aid
Direct Style Effect Systems - The Print[A] Example - A Comprehension AidPhilip Schwarz
 
%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisa%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisamasabamasaba
 
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdfLearn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdfkalichargn70th171
 
A Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docxA Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docxComplianceQuest1
 
The title is not connected to what is inside
The title is not connected to what is insideThe title is not connected to what is inside
The title is not connected to what is insideshinachiaurasa2
 
VTU technical seminar 8Th Sem on Scikit-learn
VTU technical seminar 8Th Sem on Scikit-learnVTU technical seminar 8Th Sem on Scikit-learn
VTU technical seminar 8Th Sem on Scikit-learnAmarnathKambale
 
%in ivory park+277-882-255-28 abortion pills for sale in ivory park
%in ivory park+277-882-255-28 abortion pills for sale in ivory park %in ivory park+277-882-255-28 abortion pills for sale in ivory park
%in ivory park+277-882-255-28 abortion pills for sale in ivory park masabamasaba
 
Right Money Management App For Your Financial Goals
Right Money Management App For Your Financial GoalsRight Money Management App For Your Financial Goals
Right Money Management App For Your Financial GoalsJhone kinadey
 
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️Delhi Call girls
 
introduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdf
introduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdfintroduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdf
introduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdfVishalKumarJha10
 
The Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdfThe Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdfkalichargn70th171
 
MarTech Trend 2024 Book : Marketing Technology Trends (2024 Edition) How Data...
MarTech Trend 2024 Book : Marketing Technology Trends (2024 Edition) How Data...MarTech Trend 2024 Book : Marketing Technology Trends (2024 Edition) How Data...
MarTech Trend 2024 Book : Marketing Technology Trends (2024 Edition) How Data...Jittipong Loespradit
 
10 Trends Likely to Shape Enterprise Technology in 2024
10 Trends Likely to Shape Enterprise Technology in 202410 Trends Likely to Shape Enterprise Technology in 2024
10 Trends Likely to Shape Enterprise Technology in 2024Mind IT Systems
 
AI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
AI Mastery 201: Elevating Your Workflow with Advanced LLM TechniquesAI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
AI Mastery 201: Elevating Your Workflow with Advanced LLM TechniquesVictorSzoltysek
 
Software Quality Assurance Interview Questions
Software Quality Assurance Interview QuestionsSoftware Quality Assurance Interview Questions
Software Quality Assurance Interview QuestionsArshad QA
 

Kürzlich hochgeladen (20)

HR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.comHR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.com
 
Optimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTVOptimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTV
 
LEVEL 5 - SESSION 1 2023 (1).pptx - PDF 123456
LEVEL 5   - SESSION 1 2023 (1).pptx - PDF 123456LEVEL 5   - SESSION 1 2023 (1).pptx - PDF 123456
LEVEL 5 - SESSION 1 2023 (1).pptx - PDF 123456
 
%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein
%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein
%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein
 
Direct Style Effect Systems - The Print[A] Example - A Comprehension Aid
Direct Style Effect Systems -The Print[A] Example- A Comprehension AidDirect Style Effect Systems -The Print[A] Example- A Comprehension Aid
Direct Style Effect Systems - The Print[A] Example - A Comprehension Aid
 
%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisa%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisa
 
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdfLearn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
 
A Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docxA Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docx
 
The title is not connected to what is inside
The title is not connected to what is insideThe title is not connected to what is inside
The title is not connected to what is inside
 
VTU technical seminar 8Th Sem on Scikit-learn
VTU technical seminar 8Th Sem on Scikit-learnVTU technical seminar 8Th Sem on Scikit-learn
VTU technical seminar 8Th Sem on Scikit-learn
 
%in ivory park+277-882-255-28 abortion pills for sale in ivory park
%in ivory park+277-882-255-28 abortion pills for sale in ivory park %in ivory park+277-882-255-28 abortion pills for sale in ivory park
%in ivory park+277-882-255-28 abortion pills for sale in ivory park
 
Right Money Management App For Your Financial Goals
Right Money Management App For Your Financial GoalsRight Money Management App For Your Financial Goals
Right Money Management App For Your Financial Goals
 
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
 
introduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdf
introduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdfintroduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdf
introduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdf
 
The Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdfThe Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdf
 
MarTech Trend 2024 Book : Marketing Technology Trends (2024 Edition) How Data...
MarTech Trend 2024 Book : Marketing Technology Trends (2024 Edition) How Data...MarTech Trend 2024 Book : Marketing Technology Trends (2024 Edition) How Data...
MarTech Trend 2024 Book : Marketing Technology Trends (2024 Edition) How Data...
 
Microsoft AI Transformation Partner Playbook.pdf
Microsoft AI Transformation Partner Playbook.pdfMicrosoft AI Transformation Partner Playbook.pdf
Microsoft AI Transformation Partner Playbook.pdf
 
10 Trends Likely to Shape Enterprise Technology in 2024
10 Trends Likely to Shape Enterprise Technology in 202410 Trends Likely to Shape Enterprise Technology in 2024
10 Trends Likely to Shape Enterprise Technology in 2024
 
AI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
AI Mastery 201: Elevating Your Workflow with Advanced LLM TechniquesAI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
AI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
 
Software Quality Assurance Interview Questions
Software Quality Assurance Interview QuestionsSoftware Quality Assurance Interview Questions
Software Quality Assurance Interview Questions
 

Creating Customizable Widgets for Unpredictable Needs

  • 1. Creating Customizable Widgets for Unpredictable Needs Amanda Giles http://bit.ly/boswp1115 WordPress Boston – Nov 30, 2015 - #BostonWP
  • 2. Who am I? • Independent IT Consultant • WordPress Developer (Themes and Plugins) • Run the Seacoast NH WordPress Meetup • Lover • Fighter • Sneezer • Teacher / Trainer • My favorite quote is from Calvin & Hobbes: “Virtue isn’t better than vice, it’s just different. http://bit.ly/boswp1115
  • 3. And I have cats! http://bit.ly/boswp1115
  • 4. Information Gathering… • Who here has used a widget? • Who here has created a widget? • Who has lost hours trying widget after widget to find the “right” one? http://bit.ly/boswp1115
  • 5. Who is this talk geared towards? Developers http://bit.ly/boswp1115
  • 6. But what if I’m not a developer? http://bit.ly/boswp1115
  • 8. Why you should stay (even if you’re not a developer) • Might convince a plugin developer to modify a widget to address your needs • Might find a widget that’s close to your needs and hire someone to modify it • Might decide to roll up your sleeves and try your hand at coding http://bit.ly/boswp1115
  • 9. What is a widget? • A way to take [inputted] criteria from a WordPress user and convert that to into output for a website visitor. • Drag and Drop widgets into widget areas under Appearance > Widgets • Collect input [criteria] from user via a form • When website is viewed, content is displayed to a website visitor http://bit.ly/boswp1115
  • 11. Why create your own widgets? http://bit.ly/boswp1115
  • 12. But seriously… Creating widgets is a way to control the content of what's being presented while giving the user choices about that content, its presentation, and its location. http://bit.ly/boswp1115
  • 13. How do we do this? For Users: Anticipate what choices or variations the user might want For Developers: Offer ways to adjust the output where feasible http://bit.ly/boswp1115
  • 14. What does that mean? For Users: Anticipate what choices or variations the user might want • Offer choices to filter the content shown • Offer choices about how that content is shown • Offer style choices • Provide basic clean styling or no styling http://bit.ly/boswp1115
  • 15. What does that mean? For Developers: Offer ways to adjust the output where feasible • Be sure to tag output elements with id/class so styles can be easily overridden • Use hooks to allow filtering of output (for developers) http://bit.ly/boswp1115
  • 16. Anatomy of a widget 1. Declaration/Construct Tell WordPress some information about your widget and how to identify it 2. User Interface / Form Define the form that will gather user's choices about the widget instance 3. Update/Save Logic Save the user's choices about the widget instance 4. Widget/Output Logic Display the widget instance to the website visitor 5. Register the Widget Tell WordPress to register your widget and include it on the Appearance > Widgets page http://bit.ly/boswp1115
  • 17. Widget Code Structure 1. Declaration/Construct 2. User Interface / Form 3. Update/Save Logic 4. Widget/Output Logic 5. Register Widget using Widget Name 0. Widget Name & “extends WP_Widget” http://bit.ly/boswp1115
  • 18. “Show Posts” widget We’re going to look at a widget that displays posts. Our first pass, we’ll focus on the basic user choices: • Specify Widget Title (or not) • Choose one or more specific post IDs • Choose post type (post, page, custom post types) • Choose # of posts to show • Choose what to sort by • Choose the sort order (ascending, descending) • Choose whether to show the post thumbnail/featured image • Choose whether to display the full post content or excerpt http://bit.ly/boswp1115
  • 19. On to the coding! http://bit.ly/boswp1115
  • 20. Second Pass On our second pass through the widget we will add the following touches to flush it out further: • Add CSS for the widget output on website • Add CSS for the Admin User Interface/Form • Place hooks to allow filtering on several elements http://bit.ly/boswp1115
  • 21. What is a hook? A hook is an "event" which allows for additional code to be run when it occurs. One or more functions can be associated with a hook and they will all run when the hook is triggered. http://bit.ly/boswp1115
  • 22. Why use hooks? Hooks are placed within WordPress core, plugins, and themes to allow customization by developers without direct edits of the code. Hooks are the proper way to alter the default behavior of code which is not yours to edit. http://bit.ly/boswp1115
  • 23. Types of hooks Action hooks allow you to run code at a certain point within the code. Examples in WP core include initialization, before main query is run, header or footer of a page/post. Filter hooks allow you to alter data, content, parameters. A filter hook is passed information to filter and returns it altered (or not). Examples in WP code include displaying content, page/post title, pre-saving content (admin). http://bit.ly/boswp1115
  • 26. Thank You! Find these slides and all related files at: http://bit.ly/boswp1115 www.AmandaGiles.com @AmandaGilesNH on Twitter amanda@amandagiles.com Please feel free to send me feedback or questions