SlideShare une entreprise Scribd logo
1  sur  13
Functions.php
                   It’s Not Just for Developers



@10up http://10up.com                             Eric A Mann @ericmann
Who’s This Guy?
•   Senior Web Engineer at 10up
•   WordPress Core Contributor
•   Plugin developer
•   Self-taught PHP dev


@10up http://10up.com             Eric A Mann @ericmann
And You Are?
•   Use WordPress
•   Want to tweak your site
•   Know a little about code
•   Don’t want to become a hard-core dev


@10up http://10up.com                Eric A Mann @ericmann
So, What’s PHP?
•   WP Core language
•   Used everywhere
•   Ugly
•   Beautiful


@10up http://10up.com   Eric A Mann @ericmann
WordPress Actions
“[H]ooks that the WordPress core launches
at specific points during execution, or when
specific events occur.” 1

• do_action()
• add_action()

@10up http://10up.com                 Eric A Mann @ericmann
WordPress Filters
“[H]ooks that WordPress launches to modify
text of various types before adding it to the
database or sending it to the browser
screen.” 1
• apply_filters()
• add_filter()
@10up http://10up.com                 Eric A Mann @ericmann
What’s Functions.php
•   Core part of your theme
•   Registers sidebars
•   Sets up special functionality
•   Lets you add plugin-like code


@10up http://10up.com               Eric A Mann @ericmann
Code Snippets
function wps_first_post_class( $classes ) {
    global $wp_query;
    if( 0 === $wp_query->current_post ) {
        $classes[] = 'first';
        return $classes;
    }
}
add_filter( 'post_class', 'wps_first_post_class' );



@10up http://10up.com                           Eric A Mann @ericmann
Manipulating WordPress
• Filters let you change output
• Actions let you add magic

• Both let you control the tool


@10up http://10up.com             Eric A Mann @ericmann
Live Examples
1. Clean up <head> output
2. Rename Posts
3. Add Pinterest to user profile




@10up http://10up.com              Eric A Mann @ericmann
Where to Find Snippets
•   Official Support Forums
•   WordPress Stack Exchange
•   WPSnipp
•   Google


@10up http://10up.com          Eric A Mann @ericmann
How to Cheat




           http://eam.me/code-snippet-plugin
@10up http://10up.com                     Eric A Mann @ericmann
Questions?



@10up http://10up.com                Eric A Mann @ericmann

Contenu connexe

Tendances

WordCamp Miami 2015 beginner course plugins
WordCamp Miami 2015 beginner course pluginsWordCamp Miami 2015 beginner course plugins
WordCamp Miami 2015 beginner course pluginsSouth Florida Web Studio
 
Client Side Applications with WP-API WordPress - WCMTL 2015
Client Side Applications with WP-API WordPress - WCMTL 2015Client Side Applications with WP-API WordPress - WCMTL 2015
Client Side Applications with WP-API WordPress - WCMTL 2015Roy Sivan
 
WordPress News, Views and Stuff October 2016
WordPress News, Views and Stuff October 2016WordPress News, Views and Stuff October 2016
WordPress News, Views and Stuff October 2016WordPress Sydney
 
Interns What Is DevOps
Interns What Is DevOpsInterns What Is DevOps
Interns What Is DevOpsAaron Blythe
 
Queue System and Zend\Queue implementation
Queue System and Zend\Queue implementationQueue System and Zend\Queue implementation
Queue System and Zend\Queue implementationGianluca Arbezzano
 
WordPress updates - Why You Can't Live Without Them
WordPress updates - Why You Can't Live Without ThemWordPress updates - Why You Can't Live Without Them
WordPress updates - Why You Can't Live Without ThemWarren Denley
 
Extending OnDemand with Atlassian Connect Add-ons
Extending OnDemand with Atlassian Connect Add-onsExtending OnDemand with Atlassian Connect Add-ons
Extending OnDemand with Atlassian Connect Add-onscolleenfry
 
The Power of RxJS in Nativescript + Angular
The Power of RxJS in Nativescript + AngularThe Power of RxJS in Nativescript + Angular
The Power of RxJS in Nativescript + AngularTracy Lee
 
AWS Customer Presentation - Mediafed
AWS Customer Presentation - MediafedAWS Customer Presentation - Mediafed
AWS Customer Presentation - MediafedAmazon Web Services
 
Techical Workflow for a Startup
Techical Workflow for a StartupTechical Workflow for a Startup
Techical Workflow for a StartupSébastien Saunier
 
How to build Client Side Applications with WordPress and WP-API | #wcmia
How to build Client Side Applications with WordPress and WP-API | #wcmiaHow to build Client Side Applications with WordPress and WP-API | #wcmia
How to build Client Side Applications with WordPress and WP-API | #wcmiaRoy Sivan
 
WordPress for Govt Blogs & Microsites
WordPress for Govt Blogs & MicrositesWordPress for Govt Blogs & Microsites
WordPress for Govt Blogs & MicrositesKristy Fifelski
 
How to Evaluate WordPress Plugins Before Activating
How to Evaluate WordPress Plugins Before ActivatingHow to Evaluate WordPress Plugins Before Activating
How to Evaluate WordPress Plugins Before ActivatingChristian Nolen
 
How to submit sitemap by Ravi
How to submit sitemap by RaviHow to submit sitemap by Ravi
How to submit sitemap by RaviNeha Nayak
 
API101 Workshop - APIStrat Amsterdam 2014
API101 Workshop - APIStrat Amsterdam 2014API101 Workshop - APIStrat Amsterdam 2014
API101 Workshop - APIStrat Amsterdam 20143scale
 

Tendances (20)

WordCamp Miami 2015 beginner course plugins
WordCamp Miami 2015 beginner course pluginsWordCamp Miami 2015 beginner course plugins
WordCamp Miami 2015 beginner course plugins
 
Client Side Applications with WP-API WordPress - WCMTL 2015
Client Side Applications with WP-API WordPress - WCMTL 2015Client Side Applications with WP-API WordPress - WCMTL 2015
Client Side Applications with WP-API WordPress - WCMTL 2015
 
WordPress News, Views and Stuff October 2016
WordPress News, Views and Stuff October 2016WordPress News, Views and Stuff October 2016
WordPress News, Views and Stuff October 2016
 
Interns What Is DevOps
Interns What Is DevOpsInterns What Is DevOps
Interns What Is DevOps
 
Queue System and Zend\Queue implementation
Queue System and Zend\Queue implementationQueue System and Zend\Queue implementation
Queue System and Zend\Queue implementation
 
WordPress updates - Why You Can't Live Without Them
WordPress updates - Why You Can't Live Without ThemWordPress updates - Why You Can't Live Without Them
WordPress updates - Why You Can't Live Without Them
 
Extending OnDemand with Atlassian Connect Add-ons
Extending OnDemand with Atlassian Connect Add-onsExtending OnDemand with Atlassian Connect Add-ons
Extending OnDemand with Atlassian Connect Add-ons
 
The Power of RxJS in Nativescript + Angular
The Power of RxJS in Nativescript + AngularThe Power of RxJS in Nativescript + Angular
The Power of RxJS in Nativescript + Angular
 
AWS Customer Presentation - Mediafed
AWS Customer Presentation - MediafedAWS Customer Presentation - Mediafed
AWS Customer Presentation - Mediafed
 
Techical Workflow for a Startup
Techical Workflow for a StartupTechical Workflow for a Startup
Techical Workflow for a Startup
 
Send Mail
Send MailSend Mail
Send Mail
 
How to build Client Side Applications with WordPress and WP-API | #wcmia
How to build Client Side Applications with WordPress and WP-API | #wcmiaHow to build Client Side Applications with WordPress and WP-API | #wcmia
How to build Client Side Applications with WordPress and WP-API | #wcmia
 
WordPress for Govt Blogs & Microsites
WordPress for Govt Blogs & MicrositesWordPress for Govt Blogs & Microsites
WordPress for Govt Blogs & Microsites
 
How to Evaluate WordPress Plugins Before Activating
How to Evaluate WordPress Plugins Before ActivatingHow to Evaluate WordPress Plugins Before Activating
How to Evaluate WordPress Plugins Before Activating
 
Automation Zaman Now
Automation Zaman NowAutomation Zaman Now
Automation Zaman Now
 
Practical REST API
Practical REST APIPractical REST API
Practical REST API
 
How to submit sitemap by Ravi
How to submit sitemap by RaviHow to submit sitemap by Ravi
How to submit sitemap by Ravi
 
New Theme Directory
New Theme DirectoryNew Theme Directory
New Theme Directory
 
5 W's of Hookin'
5 W's of Hookin'5 W's of Hookin'
5 W's of Hookin'
 
API101 Workshop - APIStrat Amsterdam 2014
API101 Workshop - APIStrat Amsterdam 2014API101 Workshop - APIStrat Amsterdam 2014
API101 Workshop - APIStrat Amsterdam 2014
 

En vedette

Contributing to core
Contributing to coreContributing to core
Contributing to coreEric Mann
 
Mayo vs. Owatonna Oct 9, 2009
Mayo vs. Owatonna Oct 9, 2009Mayo vs. Owatonna Oct 9, 2009
Mayo vs. Owatonna Oct 9, 2009krsorenson
 
Social media brochure 1
Social media brochure 1Social media brochure 1
Social media brochure 1IDGA
 
Mayo Vs Winona Football Sept 18 2009
Mayo Vs Winona Football Sept 18 2009Mayo Vs Winona Football Sept 18 2009
Mayo Vs Winona Football Sept 18 2009krsorenson
 
Chicago Band Trip
Chicago Band TripChicago Band Trip
Chicago Band Tripkrsorenson
 
Playing nice with others
Playing nice with othersPlaying nice with others
Playing nice with othersEric Mann
 
10 lessons from wal mart
10 lessons from wal mart10 lessons from wal mart
10 lessons from wal martDougal Thompson
 
Questions you’re too afraid to ask
Questions you’re too afraid to askQuestions you’re too afraid to ask
Questions you’re too afraid to askEric Mann
 

En vedette (9)

Contributing to core
Contributing to coreContributing to core
Contributing to core
 
Mayo vs. Owatonna Oct 9, 2009
Mayo vs. Owatonna Oct 9, 2009Mayo vs. Owatonna Oct 9, 2009
Mayo vs. Owatonna Oct 9, 2009
 
Social media brochure 1
Social media brochure 1Social media brochure 1
Social media brochure 1
 
Case study v7.2
Case study v7.2Case study v7.2
Case study v7.2
 
Mayo Vs Winona Football Sept 18 2009
Mayo Vs Winona Football Sept 18 2009Mayo Vs Winona Football Sept 18 2009
Mayo Vs Winona Football Sept 18 2009
 
Chicago Band Trip
Chicago Band TripChicago Band Trip
Chicago Band Trip
 
Playing nice with others
Playing nice with othersPlaying nice with others
Playing nice with others
 
10 lessons from wal mart
10 lessons from wal mart10 lessons from wal mart
10 lessons from wal mart
 
Questions you’re too afraid to ask
Questions you’re too afraid to askQuestions you’re too afraid to ask
Questions you’re too afraid to ask
 

Similaire à Functions.php - It's Not Just For Developers

Building a WordPress Plugin
Building a WordPress PluginBuilding a WordPress Plugin
Building a WordPress PluginEric Mann
 
Word press interview question and answer tops technologies
Word press interview question and answer   tops technologiesWord press interview question and answer   tops technologies
Word press interview question and answer tops technologiesTOPS Technologies
 
WordPress Security & Backup
WordPress Security & Backup WordPress Security & Backup
WordPress Security & Backup Randy Barnes
 
Everything WordPress
Everything WordPressEverything WordPress
Everything WordPressEric Myers
 
WordPress
WordPressWordPress
WordPressrisager
 
Writing Your First Plugin
Writing Your First PluginWriting Your First Plugin
Writing Your First PluginGeorge Ornbo
 
Best Practices for Building WordPress Applications
Best Practices for Building WordPress ApplicationsBest Practices for Building WordPress Applications
Best Practices for Building WordPress ApplicationsTaylor Lovett
 
Magento 2 Best Practice Workfow // David Lambauer // Meet Magento 2017 // Lei...
Magento 2 Best Practice Workfow // David Lambauer // Meet Magento 2017 // Lei...Magento 2 Best Practice Workfow // David Lambauer // Meet Magento 2017 // Lei...
Magento 2 Best Practice Workfow // David Lambauer // Meet Magento 2017 // Lei...AOE
 
Things you should know about WordPress (but were always too afraid to ask): W...
Things you should know about WordPress (but were always too afraid to ask): W...Things you should know about WordPress (but were always too afraid to ask): W...
Things you should know about WordPress (but were always too afraid to ask): W...Michael McNeill
 
Most widely used WordPress tips and tricks of 2016
Most widely used WordPress tips and tricks of 2016Most widely used WordPress tips and tricks of 2016
Most widely used WordPress tips and tricks of 2016Reegan
 
WordPress Security and Best Practices
WordPress Security and Best PracticesWordPress Security and Best Practices
WordPress Security and Best PracticesRobert Vidal
 
Wordpress beyond blogging
Wordpress beyond bloggingWordpress beyond blogging
Wordpress beyond bloggingJulien Minguely
 
Demystifying WordPress
Demystifying WordPressDemystifying WordPress
Demystifying WordPressMykl Roventine
 
Phpworks enterprise-php-1227605806710884-9
Phpworks enterprise-php-1227605806710884-9Phpworks enterprise-php-1227605806710884-9
Phpworks enterprise-php-1227605806710884-9PrinceGuru MS
 
From WordPress With Love
From WordPress With LoveFrom WordPress With Love
From WordPress With LoveUp2 Technology
 
Getting Started with WordPress Development
Getting Started with WordPress DevelopmentGetting Started with WordPress Development
Getting Started with WordPress DevelopmentRyan Welcher
 
Your Site Has Been Hacked, Now What?
Your Site Has Been Hacked, Now What?Your Site Has Been Hacked, Now What?
Your Site Has Been Hacked, Now What?Michele Butcher-Jones
 
Owning word press all you need to know as a wordpress developer by lutaaya ...
Owning word press   all you need to know as a wordpress developer by lutaaya ...Owning word press   all you need to know as a wordpress developer by lutaaya ...
Owning word press all you need to know as a wordpress developer by lutaaya ...Lutaaya Shafiq
 
Drupal8 for Symfony developers - Dutch PHP
Drupal8 for Symfony developers - Dutch PHPDrupal8 for Symfony developers - Dutch PHP
Drupal8 for Symfony developers - Dutch PHPAntonio Peric-Mazar
 

Similaire à Functions.php - It's Not Just For Developers (20)

Building a WordPress Plugin
Building a WordPress PluginBuilding a WordPress Plugin
Building a WordPress Plugin
 
Word press interview question and answer tops technologies
Word press interview question and answer   tops technologiesWord press interview question and answer   tops technologies
Word press interview question and answer tops technologies
 
WordPress Security & Backup
WordPress Security & Backup WordPress Security & Backup
WordPress Security & Backup
 
Everything WordPress
Everything WordPressEverything WordPress
Everything WordPress
 
WordPress
WordPressWordPress
WordPress
 
Writing Your First Plugin
Writing Your First PluginWriting Your First Plugin
Writing Your First Plugin
 
Best Practices for Building WordPress Applications
Best Practices for Building WordPress ApplicationsBest Practices for Building WordPress Applications
Best Practices for Building WordPress Applications
 
Magento 2 Best Practice Workfow // David Lambauer // Meet Magento 2017 // Lei...
Magento 2 Best Practice Workfow // David Lambauer // Meet Magento 2017 // Lei...Magento 2 Best Practice Workfow // David Lambauer // Meet Magento 2017 // Lei...
Magento 2 Best Practice Workfow // David Lambauer // Meet Magento 2017 // Lei...
 
Things you should know about WordPress (but were always too afraid to ask): W...
Things you should know about WordPress (but were always too afraid to ask): W...Things you should know about WordPress (but were always too afraid to ask): W...
Things you should know about WordPress (but were always too afraid to ask): W...
 
Most widely used WordPress tips and tricks of 2016
Most widely used WordPress tips and tricks of 2016Most widely used WordPress tips and tricks of 2016
Most widely used WordPress tips and tricks of 2016
 
WordPress Security and Best Practices
WordPress Security and Best PracticesWordPress Security and Best Practices
WordPress Security and Best Practices
 
Wordpress beyond blogging
Wordpress beyond bloggingWordpress beyond blogging
Wordpress beyond blogging
 
Demystifying WordPress
Demystifying WordPressDemystifying WordPress
Demystifying WordPress
 
&lt;?php + WordPress
&lt;?php + WordPress&lt;?php + WordPress
&lt;?php + WordPress
 
Phpworks enterprise-php-1227605806710884-9
Phpworks enterprise-php-1227605806710884-9Phpworks enterprise-php-1227605806710884-9
Phpworks enterprise-php-1227605806710884-9
 
From WordPress With Love
From WordPress With LoveFrom WordPress With Love
From WordPress With Love
 
Getting Started with WordPress Development
Getting Started with WordPress DevelopmentGetting Started with WordPress Development
Getting Started with WordPress Development
 
Your Site Has Been Hacked, Now What?
Your Site Has Been Hacked, Now What?Your Site Has Been Hacked, Now What?
Your Site Has Been Hacked, Now What?
 
Owning word press all you need to know as a wordpress developer by lutaaya ...
Owning word press   all you need to know as a wordpress developer by lutaaya ...Owning word press   all you need to know as a wordpress developer by lutaaya ...
Owning word press all you need to know as a wordpress developer by lutaaya ...
 
Drupal8 for Symfony developers - Dutch PHP
Drupal8 for Symfony developers - Dutch PHPDrupal8 for Symfony developers - Dutch PHP
Drupal8 for Symfony developers - Dutch PHP
 

Dernier

Powerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time ClashPowerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time Clashcharlottematthew16
 
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
 
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024BookNet Canada
 
My INSURER PTE LTD - Insurtech Innovation Award 2024
My INSURER PTE LTD - Insurtech Innovation Award 2024My INSURER PTE LTD - Insurtech Innovation Award 2024
My INSURER PTE LTD - Insurtech Innovation Award 2024The Digital Insurer
 
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
 
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
 
Install Stable Diffusion in windows machine
Install Stable Diffusion in windows machineInstall Stable Diffusion in windows machine
Install Stable Diffusion in windows machinePadma Pradeep
 
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage CostLeverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage CostZilliz
 
AI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsAI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsMemoori
 
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
 
Vector Databases 101 - An introduction to the world of Vector Databases
Vector Databases 101 - An introduction to the world of Vector DatabasesVector Databases 101 - An introduction to the world of Vector Databases
Vector Databases 101 - An introduction to the world of Vector DatabasesZilliz
 
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationBeyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationSafe Software
 
Search Engine Optimization SEO PDF for 2024.pdf
Search Engine Optimization SEO PDF for 2024.pdfSearch Engine Optimization SEO PDF for 2024.pdf
Search Engine Optimization SEO PDF for 2024.pdfRankYa
 
Vertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering TipsVertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering TipsMiki Katsuragi
 
CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):comworks
 
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
 
Unleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubUnleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubKalema Edgar
 
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
 
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
 

Dernier (20)

Powerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time ClashPowerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time Clash
 
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
 
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
 
My INSURER PTE LTD - Insurtech Innovation Award 2024
My INSURER PTE LTD - Insurtech Innovation Award 2024My INSURER PTE LTD - Insurtech Innovation Award 2024
My INSURER PTE LTD - Insurtech Innovation Award 2024
 
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
 
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
 
Install Stable Diffusion in windows machine
Install Stable Diffusion in windows machineInstall Stable Diffusion in windows machine
Install Stable Diffusion in windows machine
 
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage CostLeverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
 
AI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsAI as an Interface for Commercial Buildings
AI as an Interface for Commercial Buildings
 
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
 
Vector Databases 101 - An introduction to the world of Vector Databases
Vector Databases 101 - An introduction to the world of Vector DatabasesVector Databases 101 - An introduction to the world of Vector Databases
Vector Databases 101 - An introduction to the world of Vector Databases
 
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationBeyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
 
Search Engine Optimization SEO PDF for 2024.pdf
Search Engine Optimization SEO PDF for 2024.pdfSearch Engine Optimization SEO PDF for 2024.pdf
Search Engine Optimization SEO PDF for 2024.pdf
 
Vertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering TipsVertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering Tips
 
CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):
 
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?
 
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptxE-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
 
Unleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubUnleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding Club
 
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)
 
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
 

Functions.php - It's Not Just For Developers

  • 1. Functions.php It’s Not Just for Developers @10up http://10up.com Eric A Mann @ericmann
  • 2. Who’s This Guy? • Senior Web Engineer at 10up • WordPress Core Contributor • Plugin developer • Self-taught PHP dev @10up http://10up.com Eric A Mann @ericmann
  • 3. And You Are? • Use WordPress • Want to tweak your site • Know a little about code • Don’t want to become a hard-core dev @10up http://10up.com Eric A Mann @ericmann
  • 4. So, What’s PHP? • WP Core language • Used everywhere • Ugly • Beautiful @10up http://10up.com Eric A Mann @ericmann
  • 5. WordPress Actions “[H]ooks that the WordPress core launches at specific points during execution, or when specific events occur.” 1 • do_action() • add_action() @10up http://10up.com Eric A Mann @ericmann
  • 6. WordPress Filters “[H]ooks that WordPress launches to modify text of various types before adding it to the database or sending it to the browser screen.” 1 • apply_filters() • add_filter() @10up http://10up.com Eric A Mann @ericmann
  • 7. What’s Functions.php • Core part of your theme • Registers sidebars • Sets up special functionality • Lets you add plugin-like code @10up http://10up.com Eric A Mann @ericmann
  • 8. Code Snippets function wps_first_post_class( $classes ) { global $wp_query; if( 0 === $wp_query->current_post ) { $classes[] = 'first'; return $classes; } } add_filter( 'post_class', 'wps_first_post_class' ); @10up http://10up.com Eric A Mann @ericmann
  • 9. Manipulating WordPress • Filters let you change output • Actions let you add magic • Both let you control the tool @10up http://10up.com Eric A Mann @ericmann
  • 10. Live Examples 1. Clean up <head> output 2. Rename Posts 3. Add Pinterest to user profile @10up http://10up.com Eric A Mann @ericmann
  • 11. Where to Find Snippets • Official Support Forums • WordPress Stack Exchange • WPSnipp • Google @10up http://10up.com Eric A Mann @ericmann
  • 12. How to Cheat http://eam.me/code-snippet-plugin @10up http://10up.com Eric A Mann @ericmann
  • 13. Questions? @10up http://10up.com Eric A Mann @ericmann

Notes de l'éditeur

  1. Personal IntroductionSenior Web Engineer @ 10upPreviously worked on .NetprojectsFormer freelance PHP/JS developerContributed to every major WP release since 2.3Build plugins and other custom WP code for clientsLike many of you, I’m primarily self-taught in PHP.
  2. PHP is one of the 5 core “languages” used in WordPress. The other four being JavaScript, MySQL, HTML, and CSS.It’s also one of the most widely used interpreted languages on the Internet because it’s preinstalled by a vast majority of web hosts.The syntax is a big ugly. PHP is open source, so there are contributions from literally hundreds of developers, all with different ideas of how to do things. Some functions are easier to understand than others. Some documentation just doesn’t make sense.But there’s also a huge community supporting it. So if something doesn’t make sense, you can probably find someone to explain it. The fact that it’s interpreted rather than compiled means we can get away with a lot of advanced hackery that wouldn’t fly elsewhere.Duck Typing lets us do some powerful and amazing things.
  3. What exactly is an action in WordPress? Well, it’s code that does something.Think of it as an event notification system – whenever WordPress does X, trigger any events that are listening for X to happen.Actions can pass data to listeners so they can act accordingly.
  4. What exactly is a filter in WordPress? Well, it’s code that filters something.Think of it as an approval system. Before doing something with data (i.e. Content), WordPress checks to see if anyone else cares about doing something to that data first and gives you the opportunity to manipulate things.Filters can pass contextual data along with the data being manipulated so you can make further decisions on it.
  5. This chunk of code comes in two parts:A function that does something based on passed data and the global state of WordPressA filter that applies this function to a specific data check in WordPress
  6. Remember, WordPress is a tool, albeit a rich one. You don’t have to fit the tool; you can manipulate the tool to fit you.
  7. The &lt;head&gt; element includes a lot of content that you don’t need. If you’re a Mac user, you probably don’t need the Windows Live Writer manifest in the header. If you don’t use comments, you don’t need a link to the comments feed. You can get rid of this cruft easily.If you’re building a news site, using the word “Article” might make more sense than “Post.”If you’re in to Pinterest, you might want it added to your user profile.Live Examples