SlideShare ist ein Scribd-Unternehmen logo
1 von 49
“Just paste this code in your
                           functions.php”




Rick Radko                        WordCamp Toronto
r3df.com                         November 5th, 2011
Slides


Slides will be posted:
   http://www.slideshare.net/r3df




© 2011 Rick Radko, r3df.com          1
Who am I?

I’m
   Rick Radko

   Developer, coder and web designer

   WordPress enthusiast




© 2011 Rick Radko, r3df.com             2
Who are you?




© 2011 Rick Radko, r3df.com   3
“Just paste this code in your functions.php”




© 2011 Rick Radko, r3df.com                    4
Automatic theme updates




© 2011 Rick Radko, r3df.com   5
Oh-oh!




© 2011 Rick Radko, r3df.com   6
Does it change your theme?

Non-Theme related changes
   Like buttons, thickbox effects, fancy jQuery effects
    and addons
   Custom taxonomies, custom post types, at least
    partially.

   These changes should be theme independent.

   Changes get lost in functions.php theme items.

© 2011 Rick Radko, r3df.com                                7
Don’t do it!




                              “Just paste this code in your
                                            functions.php”



© 2011 Rick Radko, r3df.com                                   8
Then where?

Child theme
   All theme related changes.
   Changes that should go away if theme changes.

Personal “Site” plugin
   All other additions/changes.
   Changes that should stay even if theme changes.


*“Site” from Otto: http://ottopress.com/2011/creating-a-site-specific-snippets-plugin

© 2011 Rick Radko, r3df.com                                                             9
Child themes

How do they work?

   Child themes inherit all the features of their parent
    theme.

   Child themes override their parent theme by
    providing alternate code/files.

   If it’s not present in child, WordPress looks in the
    parent theme.
© 2011 Rick Radko, r3df.com                                10
Minimal child theme

What do you need for a minimal child theme?

   A theme folder.

   A file called style.css, with a specific header, and
    usually one line of code.

   Not required for a child theme, but a functions.php
    will be needed to add php snippets.

© 2011 Rick Radko, r3df.com                                11
Creating a child theme

Lots of ways to create the theme content, here are
a few:
   Text editor and ftp the files into place

   Local development environment and ftp
         Tomorrow’s workshops

   Site hosting’s filemanager and editor
         Common and simple

© 2011 Rick Radko, r3df.com                      12
cPanel




© 2011 Rick Radko, r3df.com   13
File manager




© 2011 Rick Radko, r3df.com   14
Create the child theme folder

Create a new folder in /wp-content/themes.




© 2011 Rick Radko, r3df.com                  15
New child-theme folder




© 2011 Rick Radko, r3df.com   16
Creating a style.css

Create style.css in the theme folder.




© 2011 Rick Radko, r3df.com             17
The style.css file




© 2011 Rick Radko, r3df.com   18
Absolute minimum style.css




© 2011 Rick Radko, r3df.com   19
The new child theme

Now you have a new theme!




© 2011 Rick Radko, r3df.com   20
The new theme, not quite right

Child Theme




                                 Twenty Eleven




© 2011 Rick Radko, r3df.com                  21
Practical style.css

A style.css that will work a little better:




© 2011 Rick Radko, r3df.com                   22
Child theme activated




© 2011 Rick Radko, r3df.com   23
Now, it’s the same as the parent




© 2011 Rick Radko, r3df.com        24
Creating a functions.php

Create functions.php in the theme folder.




© 2011 Rick Radko, r3df.com                 25
Edit the functions.php




© 2011 Rick Radko, r3df.com   26
Minimum functions.php




© 2011 Rick Radko, r3df.com   27
It’s done!

We now have a child theme that:
   Looks exactly the same as it’s parent.

   Will maintain updates/changes to it’s:
         style.css
         functions.php
         any other theme file that you want to add
        without fear of having them overwritten!



© 2011 Rick Radko, r3df.com                           28
“Grandchild” issues

You cannot make a child theme of a child theme!

   Use a site plugin.




© 2011 Rick Radko, r3df.com                       29
Site plugins

What do you need for a minimal plugin?

   Only a single php file, of any name.

   Plugin defining header in the file.

   Not required for a plugin, but a folder keeps things
    neater, especially if you want to include css and js
    files.

© 2011 Rick Radko, r3df.com                            30
Creating a site plugin

Go to file manager again




© 2011 Rick Radko, r3df.com   31
Creating the plugin folder




© 2011 Rick Radko, r3df.com   32
The new site-plugin folder




© 2011 Rick Radko, r3df.com   33
Create a site-plugin.php file




© 2011 Rick Radko, r3df.com     34
The site-plugin.php file




© 2011 Rick Radko, r3df.com   35
Minimum plugin file




© 2011 Rick Radko, r3df.com   36
The new plugin




© 2011 Rick Radko, r3df.com   37
Practical plugin file




© 2011 Rick Radko, r3df.com   38
Activated final plugin

activate




© 2011 Rick Radko, r3df.com   39
It’s done!

We now have a complete plugin that:
   Stores code without direct impact from updates.

   Can be extended
         Inject css and javascript files
         Add options pages in admin

   Is portable
         Easily move from one site to another carrying all
          your favorite changes.
© 2011 Rick Radko, r3df.com                                   40
Timing issues

   Plugins load before themes.
   For most snippets that are hooked to an action
    this is not an issue, as the action dictates when
    the code runs.
   Occasionally there are issues with code that is not
    hooked to an action, so the code snippet in the
    plugin may run too early and not work.
   Hook the code to an appropriate action with
    add_action().
    codex.wordpress.org/Plugin_API/Action_Reference

© 2011 Rick Radko, r3df.com                           41
Extras – Theme thumbnail

Image for theme thumbnail:

   Create an image in png format.

   About 300x225px.

   Save as “screenshot.png” in the theme folder.

   Will be loaded automatically.

© 2011 Rick Radko, r3df.com                         42
Extras – Split loading

Split loading
   admin/front/both
         is_admin()
    /* Code needed by both admin and front here*/

    if ( is_admin() ) {
            /* code for admin only here*/

    } else {
          /* code for front only here*/

    }
© 2011 Rick Radko, r3df.com                         43
Extras – Loading css and javascript

  Loading css and scripts

  Use actions
   wp_print_styles for css

   wp_enqueue_scripts for scripts

  See the codex for more detail


© 2011 Rick Radko, r3df.com           44
Key Points

Main theme functions.php is:
   Not the best place to put code snippets.
   Overwritten by automatic updates.
   Not used if theme changes.

Some snippets are not theme related.
   Should have a place that is theme independent to
    store them.


© 2011 Rick Radko, r3df.com                            45
Key Points: Child Themes

Child themes for theme related changes
   They are easy to create:
         Can be really simple, only what you need.
         Minimum is a folder and style.css.
         Probably will need a functions.php.

   Create once per theme.

   Once it’s set-up, just paste in your snippets.

© 2011 Rick Radko, r3df.com                           46
Key Points: Personal Plugins

Personal plugin for all other additions/changes:
   Also easy to create:
         Can be really simple or quite complex
         Minimum is a plugin php file
         Folder helps keep things organized

   Set-up once per site
         copy across sites!

   Once it’s set-up, just paste in your snippets.
© 2011 Rick Radko, r3df.com                          47
Contact

Rick Radko
   email: wpinfo@r3df.com
   twitter: @r3designforge


Slides at:
   www.slideshare.net/r3df

Code at:
   r3df.com/downloads

© 2011 Rick Radko, r3df.com   48

Weitere ähnliche Inhalte

Andere mochten auch

Verification, Slicing and Visualization of Programs with Contracts
Verification, Slicing and Visualization of Programs with ContractsVerification, Slicing and Visualization of Programs with Contracts
Verification, Slicing and Visualization of Programs with Contractspinker
 
презентация о фонде октябрь 2016 г.
презентация о фонде октябрь 2016 г.презентация о фонде октябрь 2016 г.
презентация о фонде октябрь 2016 г.Maxim Olar
 
Ssm final project
Ssm final projectSsm final project
Ssm final projectSetzerma
 
LIFE ElderCare Spring 2012 Newsletter
LIFE ElderCare Spring 2012 NewsletterLIFE ElderCare Spring 2012 Newsletter
LIFE ElderCare Spring 2012 NewsletterLIFE ElderCare
 
1804 car vip protection
1804 car vip protection1804 car vip protection
1804 car vip protectionriskis
 
Charlotte p minibeast
Charlotte p minibeastCharlotte p minibeast
Charlotte p minibeastvwuthrich
 
Lua chon rau cu qua nhóm 1 11_a10_2010
Lua chon rau cu qua  nhóm 1 11_a10_2010Lua chon rau cu qua  nhóm 1 11_a10_2010
Lua chon rau cu qua nhóm 1 11_a10_2010Thuy AI Tran Thi
 
Perkembangan anak sd periode intelektual
Perkembangan anak sd periode intelektualPerkembangan anak sd periode intelektual
Perkembangan anak sd periode intelektualrizka_pratiwi
 
IKEA Folding House
IKEA Folding HouseIKEA Folding House
IKEA Folding HouseMihex
 
Backing up your WordPress website – it’s not optional
Backing up your WordPress website – it’s not optionalBacking up your WordPress website – it’s not optional
Backing up your WordPress website – it’s not optionalR-Cubed Design Forge
 
Endringer i forvaltningsloven og eForvaltningsforskriften
Endringer i forvaltningsloven og eForvaltningsforskriftenEndringer i forvaltningsloven og eForvaltningsforskriften
Endringer i forvaltningsloven og eForvaltningsforskriftenStig Ulfsby
 
د مڼو پرکیفیت او معدنی موادو د کڅوړی کولو اغیزی
د مڼو پرکیفیت او معدنی موادو د کڅوړی کولو اغیزید مڼو پرکیفیت او معدنی موادو د کڅوړی کولو اغیزی
د مڼو پرکیفیت او معدنی موادو د کڅوړی کولو اغیزیAhmad Khasrow
 
Verification Conditions for Single-Assignment Programs
Verification Conditions for Single-Assignment ProgramsVerification Conditions for Single-Assignment Programs
Verification Conditions for Single-Assignment Programspinker
 
Portfolio antonio verdeja 2012
Portfolio antonio verdeja 2012Portfolio antonio verdeja 2012
Portfolio antonio verdeja 2012Antonio Verdeja
 

Andere mochten auch (19)

Verification, Slicing and Visualization of Programs with Contracts
Verification, Slicing and Visualization of Programs with ContractsVerification, Slicing and Visualization of Programs with Contracts
Verification, Slicing and Visualization of Programs with Contracts
 
презентация о фонде октябрь 2016 г.
презентация о фонде октябрь 2016 г.презентация о фонде октябрь 2016 г.
презентация о фонде октябрь 2016 г.
 
Ssm final project
Ssm final projectSsm final project
Ssm final project
 
LIFE ElderCare Spring 2012 Newsletter
LIFE ElderCare Spring 2012 NewsletterLIFE ElderCare Spring 2012 Newsletter
LIFE ElderCare Spring 2012 Newsletter
 
1804 car vip protection
1804 car vip protection1804 car vip protection
1804 car vip protection
 
MasterInfoBiz - 2011
MasterInfoBiz - 2011MasterInfoBiz - 2011
MasterInfoBiz - 2011
 
Charlotte p minibeast
Charlotte p minibeastCharlotte p minibeast
Charlotte p minibeast
 
Lua chon rau cu qua nhóm 1 11_a10_2010
Lua chon rau cu qua  nhóm 1 11_a10_2010Lua chon rau cu qua  nhóm 1 11_a10_2010
Lua chon rau cu qua nhóm 1 11_a10_2010
 
Sesion 3
Sesion 3Sesion 3
Sesion 3
 
Perkembangan anak sd periode intelektual
Perkembangan anak sd periode intelektualPerkembangan anak sd periode intelektual
Perkembangan anak sd periode intelektual
 
IKEA Folding House
IKEA Folding HouseIKEA Folding House
IKEA Folding House
 
Workbook3
Workbook3Workbook3
Workbook3
 
Backing up your WordPress website – it’s not optional
Backing up your WordPress website – it’s not optionalBacking up your WordPress website – it’s not optional
Backing up your WordPress website – it’s not optional
 
Mother's Day
Mother's DayMother's Day
Mother's Day
 
Endringer i forvaltningsloven og eForvaltningsforskriften
Endringer i forvaltningsloven og eForvaltningsforskriftenEndringer i forvaltningsloven og eForvaltningsforskriften
Endringer i forvaltningsloven og eForvaltningsforskriften
 
د مڼو پرکیفیت او معدنی موادو د کڅوړی کولو اغیزی
د مڼو پرکیفیت او معدنی موادو د کڅوړی کولو اغیزید مڼو پرکیفیت او معدنی موادو د کڅوړی کولو اغیزی
د مڼو پرکیفیت او معدنی موادو د کڅوړی کولو اغیزی
 
Catalogo 01
Catalogo 01Catalogo 01
Catalogo 01
 
Verification Conditions for Single-Assignment Programs
Verification Conditions for Single-Assignment ProgramsVerification Conditions for Single-Assignment Programs
Verification Conditions for Single-Assignment Programs
 
Portfolio antonio verdeja 2012
Portfolio antonio verdeja 2012Portfolio antonio verdeja 2012
Portfolio antonio verdeja 2012
 

Mehr von R-Cubed Design Forge

Gutenberg 101/Blocks - How to get along with, and even like WordPress's block...
Gutenberg 101/Blocks - How to get along with, and even like WordPress's block...Gutenberg 101/Blocks - How to get along with, and even like WordPress's block...
Gutenberg 101/Blocks - How to get along with, and even like WordPress's block...R-Cubed Design Forge
 
Setting up a local web server environment
Setting up a local web server environmentSetting up a local web server environment
Setting up a local web server environmentR-Cubed Design Forge
 
Finding themes for your WordPress site
Finding themes for your WordPress siteFinding themes for your WordPress site
Finding themes for your WordPress siteR-Cubed Design Forge
 
Introduction to WordPress - WordCamp Ottawa 2019
Introduction to WordPress - WordCamp Ottawa 2019Introduction to WordPress - WordCamp Ottawa 2019
Introduction to WordPress - WordCamp Ottawa 2019R-Cubed Design Forge
 
Gutenberg: Revolutionizing your WordPress site
Gutenberg: Revolutionizing your WordPress siteGutenberg: Revolutionizing your WordPress site
Gutenberg: Revolutionizing your WordPress siteR-Cubed Design Forge
 
Setting up a local web server environment
Setting up a local web server environmentSetting up a local web server environment
Setting up a local web server environmentR-Cubed Design Forge
 
Gutenberg - The future of WordPress
Gutenberg - The future of WordPressGutenberg - The future of WordPress
Gutenberg - The future of WordPressR-Cubed Design Forge
 
Introduction to WordPress for Beginners
Introduction to WordPress for BeginnersIntroduction to WordPress for Beginners
Introduction to WordPress for BeginnersR-Cubed Design Forge
 
WordPress page builders - a new tool to build awesome pages quickly
WordPress page builders - a new tool to build awesome pages quicklyWordPress page builders - a new tool to build awesome pages quickly
WordPress page builders - a new tool to build awesome pages quicklyR-Cubed Design Forge
 
WordPress page builders a quick introduction
WordPress page builders a quick introductionWordPress page builders a quick introduction
WordPress page builders a quick introductionR-Cubed Design Forge
 
Setting up a local web server for WordPress
Setting up a local web server for WordPressSetting up a local web server for WordPress
Setting up a local web server for WordPressR-Cubed Design Forge
 
WordPress website backups – they're not optional
WordPress website backups – they're not optionalWordPress website backups – they're not optional
WordPress website backups – they're not optionalR-Cubed Design Forge
 
Creating Customizer Options for Themes and Plugins
Creating Customizer Options for Themes and PluginsCreating Customizer Options for Themes and Plugins
Creating Customizer Options for Themes and PluginsR-Cubed Design Forge
 
WordPress customizer: for themes and more
WordPress customizer: for themes and moreWordPress customizer: for themes and more
WordPress customizer: for themes and moreR-Cubed Design Forge
 
A peek into the world of WordPress plugin development
A peek into the world of WordPress plugin developmentA peek into the world of WordPress plugin development
A peek into the world of WordPress plugin developmentR-Cubed Design Forge
 
Intro to development sites and site migration
Intro to development sites and site migrationIntro to development sites and site migration
Intro to development sites and site migrationR-Cubed Design Forge
 

Mehr von R-Cubed Design Forge (20)

Gutenberg 101/Blocks - How to get along with, and even like WordPress's block...
Gutenberg 101/Blocks - How to get along with, and even like WordPress's block...Gutenberg 101/Blocks - How to get along with, and even like WordPress's block...
Gutenberg 101/Blocks - How to get along with, and even like WordPress's block...
 
Setting up a local web server environment
Setting up a local web server environmentSetting up a local web server environment
Setting up a local web server environment
 
Backups, Backups, Backups
Backups, Backups, BackupsBackups, Backups, Backups
Backups, Backups, Backups
 
Finding themes for your WordPress site
Finding themes for your WordPress siteFinding themes for your WordPress site
Finding themes for your WordPress site
 
Introduction to WordPress - WordCamp Ottawa 2019
Introduction to WordPress - WordCamp Ottawa 2019Introduction to WordPress - WordCamp Ottawa 2019
Introduction to WordPress - WordCamp Ottawa 2019
 
Gutenberg: Revolutionizing your WordPress site
Gutenberg: Revolutionizing your WordPress siteGutenberg: Revolutionizing your WordPress site
Gutenberg: Revolutionizing your WordPress site
 
Setting up a local web server environment
Setting up a local web server environmentSetting up a local web server environment
Setting up a local web server environment
 
Gutenberg - The future of WordPress
Gutenberg - The future of WordPressGutenberg - The future of WordPress
Gutenberg - The future of WordPress
 
Introduction to WordPress for Beginners
Introduction to WordPress for BeginnersIntroduction to WordPress for Beginners
Introduction to WordPress for Beginners
 
Backups, Backups, Backups
Backups, Backups, BackupsBackups, Backups, Backups
Backups, Backups, Backups
 
WordPress page builders - a new tool to build awesome pages quickly
WordPress page builders - a new tool to build awesome pages quicklyWordPress page builders - a new tool to build awesome pages quickly
WordPress page builders - a new tool to build awesome pages quickly
 
WordPress page builders a quick introduction
WordPress page builders a quick introductionWordPress page builders a quick introduction
WordPress page builders a quick introduction
 
Setting up a local web server for WordPress
Setting up a local web server for WordPressSetting up a local web server for WordPress
Setting up a local web server for WordPress
 
WordPress website backups – they're not optional
WordPress website backups – they're not optionalWordPress website backups – they're not optional
WordPress website backups – they're not optional
 
Creating Customizer Options for Themes and Plugins
Creating Customizer Options for Themes and PluginsCreating Customizer Options for Themes and Plugins
Creating Customizer Options for Themes and Plugins
 
WordPress customizer: for themes and more
WordPress customizer: for themes and moreWordPress customizer: for themes and more
WordPress customizer: for themes and more
 
Multisite for multilingual
Multisite for multilingualMultisite for multilingual
Multisite for multilingual
 
Introduction to WordPress
Introduction to WordPressIntroduction to WordPress
Introduction to WordPress
 
A peek into the world of WordPress plugin development
A peek into the world of WordPress plugin developmentA peek into the world of WordPress plugin development
A peek into the world of WordPress plugin development
 
Intro to development sites and site migration
Intro to development sites and site migrationIntro to development sites and site migration
Intro to development sites and site migration
 

Kürzlich hochgeladen

Unraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfUnraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfAlex Barbosa Coqueiro
 
"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
 
Commit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyCommit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyAlfredo García Lavilla
 
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
 
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxMerck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxLoriGlavin3
 
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
 
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptxUse of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptxLoriGlavin3
 
DevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenDevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenHervé Boutemy
 
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
 
Developer Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLDeveloper Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLScyllaDB
 
Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Mattias Andersson
 
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
 
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
 
"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr BaganFwdays
 
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
 
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptxThe Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptxLoriGlavin3
 
The State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptxThe State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptxLoriGlavin3
 
Gen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfGen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfAddepto
 
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024BookNet Canada
 

Kürzlich hochgeladen (20)

Unraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfUnraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdf
 
"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
 
Commit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyCommit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easy
 
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
 
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxMerck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
 
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
 
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptxUse of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
 
DevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenDevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache Maven
 
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!
 
Developer Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLDeveloper Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQL
 
Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?
 
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
 
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
 
"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan
 
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
 
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
 
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptxThe Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
 
The State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptxThe State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptx
 
Gen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfGen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdf
 
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
 

Don't "Just paste this code in your functions.php"

  • 1. “Just paste this code in your functions.php” Rick Radko WordCamp Toronto r3df.com November 5th, 2011
  • 2. Slides Slides will be posted:  http://www.slideshare.net/r3df © 2011 Rick Radko, r3df.com 1
  • 3. Who am I? I’m  Rick Radko  Developer, coder and web designer  WordPress enthusiast © 2011 Rick Radko, r3df.com 2
  • 4. Who are you? © 2011 Rick Radko, r3df.com 3
  • 5. “Just paste this code in your functions.php” © 2011 Rick Radko, r3df.com 4
  • 6. Automatic theme updates © 2011 Rick Radko, r3df.com 5
  • 7. Oh-oh! © 2011 Rick Radko, r3df.com 6
  • 8. Does it change your theme? Non-Theme related changes  Like buttons, thickbox effects, fancy jQuery effects and addons  Custom taxonomies, custom post types, at least partially.  These changes should be theme independent.  Changes get lost in functions.php theme items. © 2011 Rick Radko, r3df.com 7
  • 9. Don’t do it! “Just paste this code in your functions.php” © 2011 Rick Radko, r3df.com 8
  • 10. Then where? Child theme  All theme related changes.  Changes that should go away if theme changes. Personal “Site” plugin  All other additions/changes.  Changes that should stay even if theme changes. *“Site” from Otto: http://ottopress.com/2011/creating-a-site-specific-snippets-plugin © 2011 Rick Radko, r3df.com 9
  • 11. Child themes How do they work?  Child themes inherit all the features of their parent theme.  Child themes override their parent theme by providing alternate code/files.  If it’s not present in child, WordPress looks in the parent theme. © 2011 Rick Radko, r3df.com 10
  • 12. Minimal child theme What do you need for a minimal child theme?  A theme folder.  A file called style.css, with a specific header, and usually one line of code.  Not required for a child theme, but a functions.php will be needed to add php snippets. © 2011 Rick Radko, r3df.com 11
  • 13. Creating a child theme Lots of ways to create the theme content, here are a few:  Text editor and ftp the files into place  Local development environment and ftp  Tomorrow’s workshops  Site hosting’s filemanager and editor  Common and simple © 2011 Rick Radko, r3df.com 12
  • 14. cPanel © 2011 Rick Radko, r3df.com 13
  • 15. File manager © 2011 Rick Radko, r3df.com 14
  • 16. Create the child theme folder Create a new folder in /wp-content/themes. © 2011 Rick Radko, r3df.com 15
  • 17. New child-theme folder © 2011 Rick Radko, r3df.com 16
  • 18. Creating a style.css Create style.css in the theme folder. © 2011 Rick Radko, r3df.com 17
  • 19. The style.css file © 2011 Rick Radko, r3df.com 18
  • 20. Absolute minimum style.css © 2011 Rick Radko, r3df.com 19
  • 21. The new child theme Now you have a new theme! © 2011 Rick Radko, r3df.com 20
  • 22. The new theme, not quite right Child Theme Twenty Eleven © 2011 Rick Radko, r3df.com 21
  • 23. Practical style.css A style.css that will work a little better: © 2011 Rick Radko, r3df.com 22
  • 24. Child theme activated © 2011 Rick Radko, r3df.com 23
  • 25. Now, it’s the same as the parent © 2011 Rick Radko, r3df.com 24
  • 26. Creating a functions.php Create functions.php in the theme folder. © 2011 Rick Radko, r3df.com 25
  • 27. Edit the functions.php © 2011 Rick Radko, r3df.com 26
  • 28. Minimum functions.php © 2011 Rick Radko, r3df.com 27
  • 29. It’s done! We now have a child theme that:  Looks exactly the same as it’s parent.  Will maintain updates/changes to it’s:  style.css  functions.php  any other theme file that you want to add without fear of having them overwritten! © 2011 Rick Radko, r3df.com 28
  • 30. “Grandchild” issues You cannot make a child theme of a child theme!  Use a site plugin. © 2011 Rick Radko, r3df.com 29
  • 31. Site plugins What do you need for a minimal plugin?  Only a single php file, of any name.  Plugin defining header in the file.  Not required for a plugin, but a folder keeps things neater, especially if you want to include css and js files. © 2011 Rick Radko, r3df.com 30
  • 32. Creating a site plugin Go to file manager again © 2011 Rick Radko, r3df.com 31
  • 33. Creating the plugin folder © 2011 Rick Radko, r3df.com 32
  • 34. The new site-plugin folder © 2011 Rick Radko, r3df.com 33
  • 35. Create a site-plugin.php file © 2011 Rick Radko, r3df.com 34
  • 36. The site-plugin.php file © 2011 Rick Radko, r3df.com 35
  • 37. Minimum plugin file © 2011 Rick Radko, r3df.com 36
  • 38. The new plugin © 2011 Rick Radko, r3df.com 37
  • 39. Practical plugin file © 2011 Rick Radko, r3df.com 38
  • 40. Activated final plugin activate © 2011 Rick Radko, r3df.com 39
  • 41. It’s done! We now have a complete plugin that:  Stores code without direct impact from updates.  Can be extended  Inject css and javascript files  Add options pages in admin  Is portable  Easily move from one site to another carrying all your favorite changes. © 2011 Rick Radko, r3df.com 40
  • 42. Timing issues  Plugins load before themes.  For most snippets that are hooked to an action this is not an issue, as the action dictates when the code runs.  Occasionally there are issues with code that is not hooked to an action, so the code snippet in the plugin may run too early and not work.  Hook the code to an appropriate action with add_action(). codex.wordpress.org/Plugin_API/Action_Reference © 2011 Rick Radko, r3df.com 41
  • 43. Extras – Theme thumbnail Image for theme thumbnail:  Create an image in png format.  About 300x225px.  Save as “screenshot.png” in the theme folder.  Will be loaded automatically. © 2011 Rick Radko, r3df.com 42
  • 44. Extras – Split loading Split loading  admin/front/both  is_admin() /* Code needed by both admin and front here*/ if ( is_admin() ) { /* code for admin only here*/ } else { /* code for front only here*/ } © 2011 Rick Radko, r3df.com 43
  • 45. Extras – Loading css and javascript Loading css and scripts Use actions  wp_print_styles for css  wp_enqueue_scripts for scripts See the codex for more detail © 2011 Rick Radko, r3df.com 44
  • 46. Key Points Main theme functions.php is:  Not the best place to put code snippets.  Overwritten by automatic updates.  Not used if theme changes. Some snippets are not theme related.  Should have a place that is theme independent to store them. © 2011 Rick Radko, r3df.com 45
  • 47. Key Points: Child Themes Child themes for theme related changes  They are easy to create:  Can be really simple, only what you need.  Minimum is a folder and style.css.  Probably will need a functions.php.  Create once per theme.  Once it’s set-up, just paste in your snippets. © 2011 Rick Radko, r3df.com 46
  • 48. Key Points: Personal Plugins Personal plugin for all other additions/changes:  Also easy to create:  Can be really simple or quite complex  Minimum is a plugin php file  Folder helps keep things organized  Set-up once per site  copy across sites!  Once it’s set-up, just paste in your snippets. © 2011 Rick Radko, r3df.com 47
  • 49. Contact Rick Radko  email: wpinfo@r3df.com  twitter: @r3designforge Slides at:  www.slideshare.net/r3df Code at:  r3df.com/downloads © 2011 Rick Radko, r3df.com 48