SlideShare uma empresa Scribd logo
1 de 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

Mais conteúdo relacionado

Mais procurados

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
 

Mais procurados (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
 

Destaque

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
 

Destaque (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
 

Semelhante a 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
 

Semelhante a 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
 

Último

Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native ApplicationsWSO2
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherRemote DBA Services
 
[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdfSandro Moreira
 
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...apidays
 
Exploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with MilvusExploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with MilvusZilliz
 
Elevate Developer Efficiency & build GenAI Application with Amazon Q​
Elevate Developer Efficiency & build GenAI Application with Amazon Q​Elevate Developer Efficiency & build GenAI Application with Amazon Q​
Elevate Developer Efficiency & build GenAI Application with Amazon Q​Bhuvaneswari Subramani
 
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Victor Rentea
 
Platformless Horizons for Digital Adaptability
Platformless Horizons for Digital AdaptabilityPlatformless Horizons for Digital Adaptability
Platformless Horizons for Digital AdaptabilityWSO2
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businesspanagenda
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProduct Anonymous
 
Corporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxCorporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxRustici Software
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoffsammart93
 
Six Myths about Ontologies: The Basics of Formal Ontology
Six Myths about Ontologies: The Basics of Formal OntologySix Myths about Ontologies: The Basics of Formal Ontology
Six Myths about Ontologies: The Basics of Formal Ontologyjohnbeverley2021
 
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...apidays
 
DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 AmsterdamDEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 AmsterdamUiPathCommunity
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century educationjfdjdjcjdnsjd
 
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...Orbitshub
 
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...Angeliki Cooney
 

Último (20)

Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 
[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf
 
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
 
Exploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with MilvusExploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with Milvus
 
Elevate Developer Efficiency & build GenAI Application with Amazon Q​
Elevate Developer Efficiency & build GenAI Application with Amazon Q​Elevate Developer Efficiency & build GenAI Application with Amazon Q​
Elevate Developer Efficiency & build GenAI Application with Amazon Q​
 
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
 
Platformless Horizons for Digital Adaptability
Platformless Horizons for Digital AdaptabilityPlatformless Horizons for Digital Adaptability
Platformless Horizons for Digital Adaptability
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
Corporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxCorporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptx
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
 
Six Myths about Ontologies: The Basics of Formal Ontology
Six Myths about Ontologies: The Basics of Formal OntologySix Myths about Ontologies: The Basics of Formal Ontology
Six Myths about Ontologies: The Basics of Formal Ontology
 
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
 
DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 AmsterdamDEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
 
Understanding the FAA Part 107 License ..
Understanding the FAA Part 107 License ..Understanding the FAA Part 107 License ..
Understanding the FAA Part 107 License ..
 
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
 

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

Notas do Editor

  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