SlideShare uma empresa Scribd logo
1 de 27
Building a Simple
Theme Framework
by: Joe Casabona
Who am I?
• Native of NYS
• Yankee Fan
• WordPress Developer
• Computer Nerd
• Star Wars Nerd
• Author of
BuildingWordPressThemes from Scratch
Software Reuse
• Some General Principles & Tips
Software Reuse
• What is it? Creating code that can be used
across several projects. Using existing software
to create new software.
• Why is it Important?
• It saves time
• It’s easier to test
• It allows you to focus on more advanced
parts of a project.
Principles of Reuse
• DesignYour Code
• Layout functions, classes, page templates before
hand!
• Generalize Where Possible
• Recognize when you’re reusing code snippets
• Document & Test Thoroughly!
• Testing will ensure your code works before
implementing it 5, 10, or 20 times
DefineYour Needs
• We all have different needs!
• I’ll talk about mine. Keep yours in mind.
• EvaluateYour Process
• ReviewYour Code
• What do you do over and over?
• Look for the same code across recent
projects!
DefineYour Needs (my needs)
• Plugable CSS
• Constants for Theme & Image URLS
• Common WordPress functionality (menus,
sidebars, CPTs, etc.)
• Most Common theme templates (header, footer,
page, index)
• Common Folders
• Lightweight
Now What?
• You know what you needs. Now what?
• Before you code, see what’s out there!
• Can a plugin or other theme fulfill your
needs?
• Is there already some theme you use as a
starting point?
What’s Out There (themes)
• Thematic
• Thesis
• Carrington
• Genesis
• Atahualpa
What’s Out There (Plugins)
• OptionTree
• Custom Post Type UI
• Royal Slider
• Contact Form 7
Building the Framework
• What to do, what to do...
DesigningYour Code
• I noticed I was doing a couple of things over and over
• Copy K2
• Rip out stuff I didn't use
• Replace it with my standard template
• Modify
• Eventually, I would just copy the last theme I created
• I took my common components and created my
framework
Ex: Post Attachments
) { setup_postdata($post);
the_attachment_link($post->ID, false, false,
true); }}}
if ($attachments) {foreach ( $attachments as $post
) { setup_postdata($post);
the_attachment_link($post->ID, false, false,
true); }}}
if ($attachments) {foreach ( $attachments as $post
) { setup_postdata($post);
the_attachment_link($post->ID, false, false,
true); }}}
if ($attachments) {foreach ( $attachments as
$post ) { setup_postdata($post);
the_attachment_link($post->ID, false, false,
true); }}}
if ($attachments) {foreach ( $attachments as $post
) { setup_postdata($post);
the_attachment_link($post->ID, false, false,
true); }}}
if ($attachments) {foreach ( $attachments as $post
Necessary Files
• Style.css
• Functions.php
• Index.php
• That’s it! WordPress will fill in the blanks
with only these.
Recommended Files
• All Necessary files
• header.php & footer.php
• page.php
• single.php
• A Custom Post Type generator/template
• A theme options generator/template
• search.php
• archive.php
• sidebar.php
My CSS
• Single Sheet
• Compressed normalize.css
• Some base styles
• Standard HTML5 Elements
• Basic Navigation CSS
• Mobile first approach
• Basic Media Queries
• Any common classes and IE Fixes
My Functions
• Constants to use throughout the whole theme:
define( 'TEMPPATH', get_bloginfo('stylesheet_directory'));
define( 'IMAGES', TEMPPATH. "/images");
• Calls to include:
• Nav Menus
• Sidebars (2)
• Custom functions I use across multiple themes
(like attachments function from earlier)
Using the Framework
• How and When
• As a Child Theme:
• Cleaner
• Easier to update
• Can overwrite any page
• As a Boilerplate:
• One off jobs you don’t plan on updating
• Largely customized jobs where you want to
reuse only parts of the framework.
2 Ways to Use Framework
As a Child Theme
• Allows you to create themes that will automatically get
updated when you update your framework
• Bug Fixes
• Additional Functionality
• General Theme Updates
• Overwrites
• No need to hack together/delete. Import and overwrite!
As a Boilerplate
• Did this for a while!
• This project started to serve as a simple
boilerplate for me
• Use for one-off projects
• Projects you won't have control over after initial
launch
• Projects that will be deeply different structurally
Which Should I Use?
• Cliche Answer: It Depends!
• As with most things in our field, there is no be-all-
end-all answer.
• Consider the project at hand and make the call
there.
• Practically speaking, a child theme of your
framework will likely work most of the time.
Some Tips
• Test it thoroughly
• You will use this a lot, so make sure things work
as expected across multiple browsers
• Improve and update it
• As you grow as a developer, your needs will
change. Make sure your framework changes with
you.
Some Tips (cont)
• Don't get complacent
• Do let your growth stagnate because you're using
a framework.
• Stay up on new features, best practices, etc.
• Let others try it out
• See how other people use it and get feedback.
if there is time...
<? Show some code! ?>
Thank You!
Any Questions?
Site: casabona.org
Slides: casabona.org/wcphilly/
Twitter: @jcasabona
Resources
• WordPress Codex
• Handcrafted CSS
• Simplebits (Dan C’s site)
• ThemeForest
• WPTuts+

Mais conteúdo relacionado

Mais procurados

Test automation with Cucumber-JVM
Test automation with Cucumber-JVMTest automation with Cucumber-JVM
Test automation with Cucumber-JVMAlan Parkinson
 
Journey To The Front End World - Part3 - The Machine
Journey To The Front End World - Part3 - The MachineJourney To The Front End World - Part3 - The Machine
Journey To The Front End World - Part3 - The MachineIrfan Maulana
 
This is presentation at Mitaka.rb #10.
This is presentation at Mitaka.rb #10.This is presentation at Mitaka.rb #10.
This is presentation at Mitaka.rb #10.Masaki Komagata
 
An easy guide to Plugin Development
An easy guide to Plugin DevelopmentAn easy guide to Plugin Development
An easy guide to Plugin DevelopmentShinichi Nishikawa
 
Make your Rails console AWESOME (Ruby SG meetup 2016-03-29)
Make your Rails console AWESOME (Ruby SG meetup 2016-03-29)Make your Rails console AWESOME (Ruby SG meetup 2016-03-29)
Make your Rails console AWESOME (Ruby SG meetup 2016-03-29)Bruce Li
 
Day 1 - Intro to Ruby
Day 1 - Intro to RubyDay 1 - Intro to Ruby
Day 1 - Intro to RubyBarry Jones
 
Untangling spring week4
Untangling spring week4Untangling spring week4
Untangling spring week4Derek Jacoby
 
Refactoring Workshop (Rails Pacific 2014)
Refactoring Workshop (Rails Pacific 2014)Refactoring Workshop (Rails Pacific 2014)
Refactoring Workshop (Rails Pacific 2014)Bruce Li
 
Web Cache Deception Attack
Web Cache Deception AttackWeb Cache Deception Attack
Web Cache Deception AttackOmer Gil
 
Untangling - fall2017 - week 7
Untangling - fall2017 - week 7Untangling - fall2017 - week 7
Untangling - fall2017 - week 7Derek Jacoby
 
How to Use Selenium, Successfully
How to Use Selenium, SuccessfullyHow to Use Selenium, Successfully
How to Use Selenium, SuccessfullySauce Labs
 
Instagram filters
Instagram filters Instagram filters
Instagram filters Thinkful
 
Untangling spring week11
Untangling spring week11Untangling spring week11
Untangling spring week11Derek Jacoby
 

Mais procurados (20)

Test automation with Cucumber-JVM
Test automation with Cucumber-JVMTest automation with Cucumber-JVM
Test automation with Cucumber-JVM
 
Journey To The Front End World - Part3 - The Machine
Journey To The Front End World - Part3 - The MachineJourney To The Front End World - Part3 - The Machine
Journey To The Front End World - Part3 - The Machine
 
This is presentation at Mitaka.rb #10.
This is presentation at Mitaka.rb #10.This is presentation at Mitaka.rb #10.
This is presentation at Mitaka.rb #10.
 
An easy guide to Plugin Development
An easy guide to Plugin DevelopmentAn easy guide to Plugin Development
An easy guide to Plugin Development
 
Big Websites
Big WebsitesBig Websites
Big Websites
 
Make your Rails console AWESOME (Ruby SG meetup 2016-03-29)
Make your Rails console AWESOME (Ruby SG meetup 2016-03-29)Make your Rails console AWESOME (Ruby SG meetup 2016-03-29)
Make your Rails console AWESOME (Ruby SG meetup 2016-03-29)
 
Day 1 - Intro to Ruby
Day 1 - Intro to RubyDay 1 - Intro to Ruby
Day 1 - Intro to Ruby
 
Day 8 - jRuby
Day 8 - jRubyDay 8 - jRuby
Day 8 - jRuby
 
Untangling spring week4
Untangling spring week4Untangling spring week4
Untangling spring week4
 
Refactoring Workshop (Rails Pacific 2014)
Refactoring Workshop (Rails Pacific 2014)Refactoring Workshop (Rails Pacific 2014)
Refactoring Workshop (Rails Pacific 2014)
 
Why Everyone else writes bad code
Why Everyone else writes bad codeWhy Everyone else writes bad code
Why Everyone else writes bad code
 
Web Cache Deception Attack
Web Cache Deception AttackWeb Cache Deception Attack
Web Cache Deception Attack
 
Cucumber
CucumberCucumber
Cucumber
 
PropErty based testing
PropErty based testingPropErty based testing
PropErty based testing
 
Untangling - fall2017 - week 7
Untangling - fall2017 - week 7Untangling - fall2017 - week 7
Untangling - fall2017 - week 7
 
Intro to EmberJS
Intro to EmberJSIntro to EmberJS
Intro to EmberJS
 
Component-first Applications
Component-first ApplicationsComponent-first Applications
Component-first Applications
 
How to Use Selenium, Successfully
How to Use Selenium, SuccessfullyHow to Use Selenium, Successfully
How to Use Selenium, Successfully
 
Instagram filters
Instagram filters Instagram filters
Instagram filters
 
Untangling spring week11
Untangling spring week11Untangling spring week11
Untangling spring week11
 

Destaque

Responsive Design with WordPress
Responsive Design with WordPressResponsive Design with WordPress
Responsive Design with WordPressJoe Casabona
 
Local Development Environments
Local Development EnvironmentsLocal Development Environments
Local Development EnvironmentsJoe Casabona
 
WordPress Customization and Security
WordPress Customization and SecurityWordPress Customization and Security
WordPress Customization and SecurityJoe Casabona
 
My Top WordPress Plugins
My Top WordPress PluginsMy Top WordPress Plugins
My Top WordPress PluginsJoe Casabona
 
The Dean wants to Make this WordPress Site Responsive
The Dean wants to Make this WordPress Site ResponsiveThe Dean wants to Make this WordPress Site Responsive
The Dean wants to Make this WordPress Site ResponsiveJoe Casabona
 
WCCHS: Responsive Design with WordPress
WCCHS: Responsive Design with WordPressWCCHS: Responsive Design with WordPress
WCCHS: Responsive Design with WordPressJoe Casabona
 
Building Parsec : The Planning Stage
Building Parsec : The Planning StageBuilding Parsec : The Planning Stage
Building Parsec : The Planning StageJoe Casabona
 
Reporting questions 1-D
Reporting questions 1-DReporting questions 1-D
Reporting questions 1-Dcarrascosaurio
 
мыслители
мыслителимыслители
мыслителиhastiya
 
Connecting Custom Post Types
Connecting Custom Post TypesConnecting Custom Post Types
Connecting Custom Post TypesJoe Casabona
 
Responsive Design with WordPress (WCPHX)
Responsive Design with WordPress (WCPHX)Responsive Design with WordPress (WCPHX)
Responsive Design with WordPress (WCPHX)Joe Casabona
 
Using PHP to Create a Web Based Mobile Banner Application
Using PHP to Create a Web Based Mobile Banner ApplicationUsing PHP to Create a Web Based Mobile Banner Application
Using PHP to Create a Web Based Mobile Banner ApplicationJoe Casabona
 
Hacking the Luminis 5 Portal
Hacking the Luminis 5 PortalHacking the Luminis 5 Portal
Hacking the Luminis 5 PortalJoe Casabona
 
Wearable Technology: The Next Big Thing
Wearable Technology: The Next Big ThingWearable Technology: The Next Big Thing
Wearable Technology: The Next Big ThingJoe Casabona
 

Destaque (17)

Where we live 2
Where we live 2Where we live 2
Where we live 2
 
Responsive Design with WordPress
Responsive Design with WordPressResponsive Design with WordPress
Responsive Design with WordPress
 
Local Development Environments
Local Development EnvironmentsLocal Development Environments
Local Development Environments
 
Recipe
RecipeRecipe
Recipe
 
WordPress Customization and Security
WordPress Customization and SecurityWordPress Customization and Security
WordPress Customization and Security
 
My Top WordPress Plugins
My Top WordPress PluginsMy Top WordPress Plugins
My Top WordPress Plugins
 
The Dean wants to Make this WordPress Site Responsive
The Dean wants to Make this WordPress Site ResponsiveThe Dean wants to Make this WordPress Site Responsive
The Dean wants to Make this WordPress Site Responsive
 
WCCHS: Responsive Design with WordPress
WCCHS: Responsive Design with WordPressWCCHS: Responsive Design with WordPress
WCCHS: Responsive Design with WordPress
 
Building Parsec : The Planning Stage
Building Parsec : The Planning StageBuilding Parsec : The Planning Stage
Building Parsec : The Planning Stage
 
Reporting questions 1-D
Reporting questions 1-DReporting questions 1-D
Reporting questions 1-D
 
мыслители
мыслителимыслители
мыслители
 
Connecting Custom Post Types
Connecting Custom Post TypesConnecting Custom Post Types
Connecting Custom Post Types
 
Intro to research
Intro to researchIntro to research
Intro to research
 
Responsive Design with WordPress (WCPHX)
Responsive Design with WordPress (WCPHX)Responsive Design with WordPress (WCPHX)
Responsive Design with WordPress (WCPHX)
 
Using PHP to Create a Web Based Mobile Banner Application
Using PHP to Create a Web Based Mobile Banner ApplicationUsing PHP to Create a Web Based Mobile Banner Application
Using PHP to Create a Web Based Mobile Banner Application
 
Hacking the Luminis 5 Portal
Hacking the Luminis 5 PortalHacking the Luminis 5 Portal
Hacking the Luminis 5 Portal
 
Wearable Technology: The Next Big Thing
Wearable Technology: The Next Big ThingWearable Technology: The Next Big Thing
Wearable Technology: The Next Big Thing
 

Semelhante a Building a Simple Theme Framework

11 Amazing things I Learnt At Word Camp Sydney 2014
11 Amazing things I Learnt At Word Camp Sydney 201411 Amazing things I Learnt At Word Camp Sydney 2014
11 Amazing things I Learnt At Word Camp Sydney 2014WordPressBrisbane
 
Developing Complex WordPress Sites without Fear of Failure (with MVC)
Developing Complex WordPress Sites without Fear of Failure (with MVC)Developing Complex WordPress Sites without Fear of Failure (with MVC)
Developing Complex WordPress Sites without Fear of Failure (with MVC)Mike Schinkel
 
Aki Salmi - Refactoring legacy code: a true story @ I T.A.K.E. Unconference 2...
Aki Salmi - Refactoring legacy code: a true story @ I T.A.K.E. Unconference 2...Aki Salmi - Refactoring legacy code: a true story @ I T.A.K.E. Unconference 2...
Aki Salmi - Refactoring legacy code: a true story @ I T.A.K.E. Unconference 2...Mozaic Works
 
Staging and Deployment
Staging and DeploymentStaging and Deployment
Staging and Deploymentheyrocker
 
Best Practices for Building WordPress Applications
Best Practices for Building WordPress ApplicationsBest Practices for Building WordPress Applications
Best Practices for Building WordPress ApplicationsTaylor Lovett
 
Responsive themeworkshop wcneo2016
Responsive themeworkshop wcneo2016Responsive themeworkshop wcneo2016
Responsive themeworkshop wcneo2016David Brattoli
 
5 Common Mistakes You are Making on your Website
 5 Common Mistakes You are Making on your Website 5 Common Mistakes You are Making on your Website
5 Common Mistakes You are Making on your WebsiteAcquia
 
SE2016 Java Alex Theedom "Java EE revisits design patterns"
SE2016 Java Alex Theedom "Java EE revisits design patterns"SE2016 Java Alex Theedom "Java EE revisits design patterns"
SE2016 Java Alex Theedom "Java EE revisits design patterns"Inhacking
 
Alm with tfs 2013
Alm with tfs 2013Alm with tfs 2013
Alm with tfs 2013MSDEVMTL
 
My first powershell script
My first powershell scriptMy first powershell script
My first powershell scriptDavid Cobb
 
Add-On Development: EE Expects that Every Developer will do his Duty
Add-On Development: EE Expects that Every Developer will do his DutyAdd-On Development: EE Expects that Every Developer will do his Duty
Add-On Development: EE Expects that Every Developer will do his Dutyreedmaniac
 
The things we found in your website
The things we found in your websiteThe things we found in your website
The things we found in your websitehernanibf
 
Driving application development through behavior driven development
Driving application development through behavior driven developmentDriving application development through behavior driven development
Driving application development through behavior driven developmentEinar Ingebrigtsen
 
Devconf 2011 - PHP - How Yii framework is developed
Devconf 2011 - PHP - How Yii framework is developedDevconf 2011 - PHP - How Yii framework is developed
Devconf 2011 - PHP - How Yii framework is developedAlexander Makarov
 
Drupal upgrades and migrations. BAD Camp 2013 version
Drupal upgrades and migrations. BAD Camp 2013 versionDrupal upgrades and migrations. BAD Camp 2013 version
Drupal upgrades and migrations. BAD Camp 2013 versionDavid Lanier
 
Atlanta Drupal User Group (ADUG)
Atlanta Drupal User Group (ADUG) Atlanta Drupal User Group (ADUG)
Atlanta Drupal User Group (ADUG) Mediacurrent
 
Performant Django - Ara Anjargolian
Performant Django - Ara AnjargolianPerformant Django - Ara Anjargolian
Performant Django - Ara AnjargolianHakka Labs
 
Angular 2 overview
Angular 2 overviewAngular 2 overview
Angular 2 overviewJesse Warden
 

Semelhante a Building a Simple Theme Framework (20)

11 Amazing things I Learnt At Word Camp Sydney 2014
11 Amazing things I Learnt At Word Camp Sydney 201411 Amazing things I Learnt At Word Camp Sydney 2014
11 Amazing things I Learnt At Word Camp Sydney 2014
 
Developing Complex WordPress Sites without Fear of Failure (with MVC)
Developing Complex WordPress Sites without Fear of Failure (with MVC)Developing Complex WordPress Sites without Fear of Failure (with MVC)
Developing Complex WordPress Sites without Fear of Failure (with MVC)
 
Aki Salmi - Refactoring legacy code: a true story @ I T.A.K.E. Unconference 2...
Aki Salmi - Refactoring legacy code: a true story @ I T.A.K.E. Unconference 2...Aki Salmi - Refactoring legacy code: a true story @ I T.A.K.E. Unconference 2...
Aki Salmi - Refactoring legacy code: a true story @ I T.A.K.E. Unconference 2...
 
Staging and Deployment
Staging and DeploymentStaging and Deployment
Staging and Deployment
 
Best Practices for Building WordPress Applications
Best Practices for Building WordPress ApplicationsBest Practices for Building WordPress Applications
Best Practices for Building WordPress Applications
 
Responsive themeworkshop wcneo2016
Responsive themeworkshop wcneo2016Responsive themeworkshop wcneo2016
Responsive themeworkshop wcneo2016
 
5 Common Mistakes You are Making on your Website
 5 Common Mistakes You are Making on your Website 5 Common Mistakes You are Making on your Website
5 Common Mistakes You are Making on your Website
 
SE2016 Java Alex Theedom "Java EE revisits design patterns"
SE2016 Java Alex Theedom "Java EE revisits design patterns"SE2016 Java Alex Theedom "Java EE revisits design patterns"
SE2016 Java Alex Theedom "Java EE revisits design patterns"
 
Alex Theedom Java ee revisits design patterns
Alex Theedom	Java ee revisits design patternsAlex Theedom	Java ee revisits design patterns
Alex Theedom Java ee revisits design patterns
 
Alm with tfs 2013
Alm with tfs 2013Alm with tfs 2013
Alm with tfs 2013
 
My first powershell script
My first powershell scriptMy first powershell script
My first powershell script
 
Add-On Development: EE Expects that Every Developer will do his Duty
Add-On Development: EE Expects that Every Developer will do his DutyAdd-On Development: EE Expects that Every Developer will do his Duty
Add-On Development: EE Expects that Every Developer will do his Duty
 
presentation
presentationpresentation
presentation
 
The things we found in your website
The things we found in your websiteThe things we found in your website
The things we found in your website
 
Driving application development through behavior driven development
Driving application development through behavior driven developmentDriving application development through behavior driven development
Driving application development through behavior driven development
 
Devconf 2011 - PHP - How Yii framework is developed
Devconf 2011 - PHP - How Yii framework is developedDevconf 2011 - PHP - How Yii framework is developed
Devconf 2011 - PHP - How Yii framework is developed
 
Drupal upgrades and migrations. BAD Camp 2013 version
Drupal upgrades and migrations. BAD Camp 2013 versionDrupal upgrades and migrations. BAD Camp 2013 version
Drupal upgrades and migrations. BAD Camp 2013 version
 
Atlanta Drupal User Group (ADUG)
Atlanta Drupal User Group (ADUG) Atlanta Drupal User Group (ADUG)
Atlanta Drupal User Group (ADUG)
 
Performant Django - Ara Anjargolian
Performant Django - Ara AnjargolianPerformant Django - Ara Anjargolian
Performant Django - Ara Anjargolian
 
Angular 2 overview
Angular 2 overviewAngular 2 overview
Angular 2 overview
 

Último

Take control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteTake control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteDianaGray10
 
A Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptxA Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptxLoriGlavin3
 
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek SchlawackFwdays
 
Dev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebDev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebUiPathCommunity
 
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Mark Simos
 
TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024Lonnie McRorey
 
Digital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptxDigital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptxLoriGlavin3
 
"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr BaganFwdays
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsSergiu Bodiu
 
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptxThe Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptxLoriGlavin3
 
SAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxSAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxNavinnSomaal
 
"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii SoldatenkoFwdays
 
How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.Curtis Poe
 
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptxPasskey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptxLoriGlavin3
 
SALESFORCE EDUCATION CLOUD | FEXLE SERVICES
SALESFORCE EDUCATION CLOUD | FEXLE SERVICESSALESFORCE EDUCATION CLOUD | FEXLE SERVICES
SALESFORCE EDUCATION CLOUD | FEXLE SERVICESmohitsingh558521
 
Streamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupStreamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupFlorian Wilhelm
 
Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Commit University
 
Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 3652toLead Limited
 
Moving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdfMoving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdfLoriGlavin3
 

Último (20)

Take control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteTake control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test Suite
 
A Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptxA Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptx
 
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
 
Dev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebDev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio Web
 
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
 
TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024
 
Digital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptxDigital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptx
 
DMCC Future of Trade Web3 - Special Edition
DMCC Future of Trade Web3 - Special EditionDMCC Future of Trade Web3 - Special Edition
DMCC Future of Trade Web3 - Special Edition
 
"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platforms
 
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptxThe Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
 
SAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxSAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptx
 
"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko
 
How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.
 
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptxPasskey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptx
 
SALESFORCE EDUCATION CLOUD | FEXLE SERVICES
SALESFORCE EDUCATION CLOUD | FEXLE SERVICESSALESFORCE EDUCATION CLOUD | FEXLE SERVICES
SALESFORCE EDUCATION CLOUD | FEXLE SERVICES
 
Streamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupStreamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project Setup
 
Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!
 
Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365
 
Moving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdfMoving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdf
 

Building a Simple Theme Framework

  • 1. Building a Simple Theme Framework by: Joe Casabona
  • 2. Who am I? • Native of NYS • Yankee Fan • WordPress Developer • Computer Nerd • Star Wars Nerd • Author of BuildingWordPressThemes from Scratch
  • 3. Software Reuse • Some General Principles & Tips
  • 4. Software Reuse • What is it? Creating code that can be used across several projects. Using existing software to create new software. • Why is it Important? • It saves time • It’s easier to test • It allows you to focus on more advanced parts of a project.
  • 5. Principles of Reuse • DesignYour Code • Layout functions, classes, page templates before hand! • Generalize Where Possible • Recognize when you’re reusing code snippets • Document & Test Thoroughly! • Testing will ensure your code works before implementing it 5, 10, or 20 times
  • 6. DefineYour Needs • We all have different needs! • I’ll talk about mine. Keep yours in mind. • EvaluateYour Process • ReviewYour Code • What do you do over and over? • Look for the same code across recent projects!
  • 7. DefineYour Needs (my needs) • Plugable CSS • Constants for Theme & Image URLS • Common WordPress functionality (menus, sidebars, CPTs, etc.) • Most Common theme templates (header, footer, page, index) • Common Folders • Lightweight
  • 8. Now What? • You know what you needs. Now what? • Before you code, see what’s out there! • Can a plugin or other theme fulfill your needs? • Is there already some theme you use as a starting point?
  • 9. What’s Out There (themes) • Thematic • Thesis • Carrington • Genesis • Atahualpa
  • 10. What’s Out There (Plugins) • OptionTree • Custom Post Type UI • Royal Slider • Contact Form 7
  • 11. Building the Framework • What to do, what to do...
  • 12. DesigningYour Code • I noticed I was doing a couple of things over and over • Copy K2 • Rip out stuff I didn't use • Replace it with my standard template • Modify • Eventually, I would just copy the last theme I created • I took my common components and created my framework
  • 13. Ex: Post Attachments ) { setup_postdata($post); the_attachment_link($post->ID, false, false, true); }}} if ($attachments) {foreach ( $attachments as $post ) { setup_postdata($post); the_attachment_link($post->ID, false, false, true); }}} if ($attachments) {foreach ( $attachments as $post ) { setup_postdata($post); the_attachment_link($post->ID, false, false, true); }}} if ($attachments) {foreach ( $attachments as $post ) { setup_postdata($post); the_attachment_link($post->ID, false, false, true); }}} if ($attachments) {foreach ( $attachments as $post ) { setup_postdata($post); the_attachment_link($post->ID, false, false, true); }}} if ($attachments) {foreach ( $attachments as $post
  • 14. Necessary Files • Style.css • Functions.php • Index.php • That’s it! WordPress will fill in the blanks with only these.
  • 15. Recommended Files • All Necessary files • header.php & footer.php • page.php • single.php • A Custom Post Type generator/template • A theme options generator/template • search.php • archive.php • sidebar.php
  • 16. My CSS • Single Sheet • Compressed normalize.css • Some base styles • Standard HTML5 Elements • Basic Navigation CSS • Mobile first approach • Basic Media Queries • Any common classes and IE Fixes
  • 17. My Functions • Constants to use throughout the whole theme: define( 'TEMPPATH', get_bloginfo('stylesheet_directory')); define( 'IMAGES', TEMPPATH. "/images"); • Calls to include: • Nav Menus • Sidebars (2) • Custom functions I use across multiple themes (like attachments function from earlier)
  • 18. Using the Framework • How and When
  • 19. • As a Child Theme: • Cleaner • Easier to update • Can overwrite any page • As a Boilerplate: • One off jobs you don’t plan on updating • Largely customized jobs where you want to reuse only parts of the framework. 2 Ways to Use Framework
  • 20. As a Child Theme • Allows you to create themes that will automatically get updated when you update your framework • Bug Fixes • Additional Functionality • General Theme Updates • Overwrites • No need to hack together/delete. Import and overwrite!
  • 21. As a Boilerplate • Did this for a while! • This project started to serve as a simple boilerplate for me • Use for one-off projects • Projects you won't have control over after initial launch • Projects that will be deeply different structurally
  • 22. Which Should I Use? • Cliche Answer: It Depends! • As with most things in our field, there is no be-all- end-all answer. • Consider the project at hand and make the call there. • Practically speaking, a child theme of your framework will likely work most of the time.
  • 23. Some Tips • Test it thoroughly • You will use this a lot, so make sure things work as expected across multiple browsers • Improve and update it • As you grow as a developer, your needs will change. Make sure your framework changes with you.
  • 24. Some Tips (cont) • Don't get complacent • Do let your growth stagnate because you're using a framework. • Stay up on new features, best practices, etc. • Let others try it out • See how other people use it and get feedback.
  • 25. if there is time... <? Show some code! ?>
  • 26. Thank You! Any Questions? Site: casabona.org Slides: casabona.org/wcphilly/ Twitter: @jcasabona
  • 27. Resources • WordPress Codex • Handcrafted CSS • Simplebits (Dan C’s site) • ThemeForest • WPTuts+