SlideShare ist ein Scribd-Unternehmen logo
1 von 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

Weitere ähnliche Inhalte

Was ist angesagt?

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
 

Was ist angesagt? (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
 

Andere mochten auch

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
 

Andere mochten auch (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
 

Ähnlich wie 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
 

Ähnlich wie 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
 

Kürzlich hochgeladen

How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.Curtis Poe
 
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
 
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
 
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
 
The Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsThe Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsPixlogix Infotech
 
SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024Lorenzo Miniero
 
Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Enterprise Knowledge
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsMark Billinghurst
 
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdfHyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdfPrecisely
 
How to write a Business Continuity Plan
How to write a Business Continuity PlanHow to write a Business Continuity Plan
How to write a Business Continuity PlanDatabarracks
 
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
 
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
 
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
 
WordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your BrandWordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your Brandgvaughan
 
Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationSlibray Presentation
 
Artificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptxArtificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptxhariprasad279825
 
Advanced Computer Architecture – An Introduction
Advanced Computer Architecture – An IntroductionAdvanced Computer Architecture – An Introduction
Advanced Computer Architecture – An IntroductionDilum Bandara
 
Scanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsScanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsRizwan Syed
 

Kürzlich hochgeladen (20)

How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.
 
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
 
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
 
Commit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyCommit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easy
 
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
 
The Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsThe Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and Cons
 
SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024
 
Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR Systems
 
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
 
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdfHyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
 
How to write a Business Continuity Plan
How to write a Business Continuity PlanHow to write a Business Continuity Plan
How to write a Business Continuity Plan
 
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
 
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
 
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)
 
WordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your BrandWordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your Brand
 
Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck Presentation
 
Artificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptxArtificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptx
 
Advanced Computer Architecture – An Introduction
Advanced Computer Architecture – An IntroductionAdvanced Computer Architecture – An Introduction
Advanced Computer Architecture – An Introduction
 
Scanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsScanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL Certs
 

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

Hinweis der Redaktion

  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