SlideShare ist ein Scribd-Unternehmen logo
1 von 23
Intro To Plugin
Development
Emptying out functions.php
Intro To Plugin Development
Topher DeRosia
@topher1kenobe
Hi, my name is Topher
I’m a WordPress developer from
Grand Rapids MI
@topher1kenobe
Intro To Plugin Development
Topher DeRosia
@topher1kenobe
“Just put this code in your theme’s
functions.php file…”
JUST SAY NO
Intro To Plugin Development
Topher DeRosia
@topher1kenobe
Plugins are packages of code that
affect your site’s functionality.
Themes are packages of code that
affect your site’s design.
DO NOT MIX.
Intro To Plugin Development
Topher DeRosia
@topher1kenobe
Plugins are either single files or
folders in /wp-content/plugins
Intro To Plugin Development
Topher DeRosia
@topher1kenobe
Typically inside each plugin folder is a file
with the same name as the folder, plus any
other files it needs.
Intro To Plugin Development
Topher DeRosia
@topher1kenobe
In the top of every main plugin file is a header
block with information about the plugin.
Intro To Plugin Development
Topher DeRosia
@topher1kenobe
The only option absolutely required is the
“Plugin Name”. The others are merely
strongly recommended.
VERY strongly recommended:
License: GNU General Public License v2 or later
License URI: http://www.gnu.org/licenses/gpl-2.0.html
Tags: custom-header, custom-menu, editor-style,
featured-images (etc)
Intro To Plugin Development
Topher DeRosia
@topher1kenobe
The Secret Sauce:
Any code you might have put into
functions.php in your theme could
go into a plugin.*
*with a few exceptions
Intro To Plugin Development
Topher DeRosia
@topher1kenobe
Example:
<?php
/*
Plugin Name: Topher’s Little Plugin
Description: Does things I want to my site
Version: 1.0
Author: Topher
*/
// 220 pixels wide by 180 pixels tall, hard crop mode
add_image_size( 'custom-size', 220, 180, true );
?> Intro To Plugin Development
Topher DeRosia
@topher1kenobe
Longer Example:
<?php
/*
Plugin Name: Topher’s Little Plugin
Description: Does things I want to my site
Version: 1.0
Author: Topher
*/
// 220 pixels wide by 180 pixels tall, hard crop mode
add_image_size( 'custom-size', 220, 180, true );
// Make shortcodes work inside text widgets
add_filter('widget_text', 'do_shortcode');
// Fix styling in old content
function phlog_scripts() {
wp_enqueue_style( 'phlog_styles', plugins_url( '/css/phlog.css' , __FILE__ ) );
}
add_action( 'wp_enqueue_scripts', 'phlog_scripts' );
?> Intro To Plugin Development
Topher DeRosia
@topher1kenobe
Explanation:
function phlog_scripts() {
wp_enqueue_style( 'phlog_styles', plugins_url( '/css/phlog.css' , __FILE__ ) );
}
add_action( 'wp_enqueue_scripts', 'phlog_scripts' );
I made a function called `phlog_scripts()`
Inside it is a function that properly enqueues a CSS file.
wp_enqueue_style takes 2 arguments, a name I made up and the path
to the CSS file.
The path to the CSS file is determined with the WordPress function
plugins_url().
Intro To Plugin Development
Topher DeRosia
@topher1kenobe
Releasing a Plugin
A plugin built for release on WordPress.org must meet a list of
requirements. The requirements are listed at
https://developer.wordpress.org/plugins/wordpress-org/
Best practices are found in the WordPress Plugin Handbook
https://developer.wordpress.org/plugins/
Intro To Plugin Development
Topher DeRosia
@topher1kenobe
mu-plugins: mu == must use
Plugins that are stored in mu-plugins are automatically activated, and
cannot be deactivated. The main file of a plugin must be stored
directly in the /mu-plugins/ directory, OR be included.
Intro To Plugin Development
Topher DeRosia
@topher1kenobe
mu-plugins
Intro To Plugin Development
Topher DeRosia
@topher1kenobe
mu-plugins
To convert a regular plugin to mu-plugins, put it in the /mu-plugins
directory and then make a new, single-file plugin that looks like this:
<?php
/*
Plugin Name: mu-plugins inclusion plugin
Description: Includes the main files of any plugins that are in mu-plugins
Author: Topher
Version: 1.0
*/
// include widget_logic
include WP_CONTENT_DIR . '/mu-plugins/widget-logic/widget_logic.php';
?>
Intro To Plugin Development
Topher DeRosia
@topher1kenobe
Extra Credit: WP-CLI
WP-CLI is the command line tool for WordPress. It can create an
empty plugin with the proper header in place:
wp scaffold plugin --prompt
This will ask questions like this:
1/4 <slug>: topher-test
2/4 [--plugin_name=<title>]: Topher's Test
3/4 [--skip-tests] (Y/n): Y
4/4 [--activate] (Y/n): Y
Success: Created /home/topher1/topher1kenobe.com/wp-content/plugins/topher-test
1/1 <plugin>: topher-test
Success: Created test files.
Intro To Plugin Development
Topher DeRosia
@topher1kenobe
Real World Example
Easy Digital Downloads - Customer Contact
Intro To Plugin Development
Topher DeRosia
@topher1kenobe
Easy Digital Downloads - Customer Contact
<?php
/*
Plugin Name: Easy Digital Downloads - Customer Contact
Version: 1.0
Description: Creates a tab on the Customer page for sending an email to that customer.
Author: Topher
Author URI: http://topher1kenobe.com
Plugin URI: http://topher1kenobe.com
Text Domain: edd-customer-contact
Domain Path: /languages
License: GNU General Public License v2 or later
License URI: http://www.gnu.org/licenses/gpl-2.0.html
*/
Intro To Plugin Development
Topher DeRosia
@topher1kenobe
Easy Digital Downloads - Customer Contact
Comment everything!
Docblock
/**
* Contact a customer
*
* @since 2.3
* @param array $args The $_POST array being passeed
* @return int Whether it was a successful email
*/
Inline
// make sure we're allowed to be here at all
if ( ! is_admin() || ! current_user_can( $customer_edit_role ) ) {
wp_die( __( 'You do not have permission to contact this customer.', 'edd' ) );
} Intro To Plugin Development
Topher DeRosia
@topher1kenobe
Easy Digital Downloads - Customer Contact
Insert Code Review Here
Intro To Plugin Development
Topher DeRosia
@topher1kenobe
Easy Digital Downloads - Customer Contact
Get Help
From other developers (Slack, Stack Overflow, friends)
From parent plugin developer (if making an Addon they probably want to
help)
From documentation (https://developer.wordpress.org/plugins/)
From code (read through plugins doing similar things)
Intro To Plugin Development
Topher DeRosia
@topher1kenobe
THANKS FOR
LISTENING
Intro To Plugin Development
Topher DeRosia
@topher1kenobe
http://topher1kenobe.com
Follow me @topher1kenobe

Weitere ähnliche Inhalte

Was ist angesagt?

Week 12 - Search Engine Optimization
Week 12 -  Search Engine OptimizationWeek 12 -  Search Engine Optimization
Week 12 - Search Engine Optimizationhenri_makembe
 
Week 11 - Hosting and Migration
Week 11 - Hosting and MigrationWeek 11 - Hosting and Migration
Week 11 - Hosting and Migrationhenri_makembe
 
Reno-Tahoe WordCamp 2011 - WordPress End User Security - Dre Armeda
Reno-Tahoe WordCamp 2011 - WordPress End User Security - Dre ArmedaReno-Tahoe WordCamp 2011 - WordPress End User Security - Dre Armeda
Reno-Tahoe WordCamp 2011 - WordPress End User Security - Dre ArmedaDre Armeda
 
Week 7 introduction to theme development
Week 7   introduction to theme developmentWeek 7   introduction to theme development
Week 7 introduction to theme developmenthenri_makembe
 
Intro to WordPress Plugin Development
Intro to WordPress Plugin DevelopmentIntro to WordPress Plugin Development
Intro to WordPress Plugin DevelopmentBrad Williams
 
Step by step guide for creating wordpress plugin
Step by step guide for creating wordpress pluginStep by step guide for creating wordpress plugin
Step by step guide for creating wordpress pluginMainak Goswami
 
Building the basics (WordPress Ottawa 2014)
Building the basics (WordPress Ottawa 2014)Building the basics (WordPress Ottawa 2014)
Building the basics (WordPress Ottawa 2014)christopherfross
 
Elastic: Why WYSIWYG is the future of WordPress themes — WordCamp NYC 2009
Elastic: Why WYSIWYG is the future of WordPress themes — WordCamp NYC 2009Elastic: Why WYSIWYG is the future of WordPress themes — WordCamp NYC 2009
Elastic: Why WYSIWYG is the future of WordPress themes — WordCamp NYC 2009Daryl Koopersmith
 
Don't Fear the Custom Theme: How to build a custom WordPress theme with only ...
Don't Fear the Custom Theme: How to build a custom WordPress theme with only ...Don't Fear the Custom Theme: How to build a custom WordPress theme with only ...
Don't Fear the Custom Theme: How to build a custom WordPress theme with only ...LinnAlexandra
 
Meetup child-themes
Meetup child-themesMeetup child-themes
Meetup child-themesDaisyOlsen
 
The Future Of WordPress Presentation
The Future Of WordPress PresentationThe Future Of WordPress Presentation
The Future Of WordPress PresentationDougal Campbell
 
Plugins at WordCamp Phoenix
Plugins at WordCamp PhoenixPlugins at WordCamp Phoenix
Plugins at WordCamp PhoenixAndrew Ryno
 
WordPress Theme Development for Designers
WordPress Theme Development for DesignersWordPress Theme Development for Designers
WordPress Theme Development for Designerselliotjaystocks
 
WordPress Standardized Loop API
WordPress Standardized Loop APIWordPress Standardized Loop API
WordPress Standardized Loop APIChris Jean
 
Wordpress Plugin Development Short Tutorial
Wordpress Plugin Development Short TutorialWordpress Plugin Development Short Tutorial
Wordpress Plugin Development Short TutorialChristos Zigkolis
 
WordPress Plugin Development For Beginners
WordPress Plugin Development For BeginnersWordPress Plugin Development For Beginners
WordPress Plugin Development For Beginnersjohnpbloch
 
WordPress plugin development
WordPress plugin developmentWordPress plugin development
WordPress plugin developmentLuc De Brouwer
 
DrupalEasy: Intro to Theme Development
DrupalEasy: Intro to Theme DevelopmentDrupalEasy: Intro to Theme Development
DrupalEasy: Intro to Theme Developmentultimike
 
PHPをさわらず作る!デザイナーさんのためのWordPress【超!初級】
PHPをさわらず作る!デザイナーさんのためのWordPress【超!初級】PHPをさわらず作る!デザイナーさんのためのWordPress【超!初級】
PHPをさわらず作る!デザイナーさんのためのWordPress【超!初級】Mami Kuroki
 

Was ist angesagt? (20)

Week 12 - Search Engine Optimization
Week 12 -  Search Engine OptimizationWeek 12 -  Search Engine Optimization
Week 12 - Search Engine Optimization
 
Week 11 - Hosting and Migration
Week 11 - Hosting and MigrationWeek 11 - Hosting and Migration
Week 11 - Hosting and Migration
 
Reno-Tahoe WordCamp 2011 - WordPress End User Security - Dre Armeda
Reno-Tahoe WordCamp 2011 - WordPress End User Security - Dre ArmedaReno-Tahoe WordCamp 2011 - WordPress End User Security - Dre Armeda
Reno-Tahoe WordCamp 2011 - WordPress End User Security - Dre Armeda
 
Week 7 introduction to theme development
Week 7   introduction to theme developmentWeek 7   introduction to theme development
Week 7 introduction to theme development
 
Intro to WordPress Plugin Development
Intro to WordPress Plugin DevelopmentIntro to WordPress Plugin Development
Intro to WordPress Plugin Development
 
Step by step guide for creating wordpress plugin
Step by step guide for creating wordpress pluginStep by step guide for creating wordpress plugin
Step by step guide for creating wordpress plugin
 
Building the basics (WordPress Ottawa 2014)
Building the basics (WordPress Ottawa 2014)Building the basics (WordPress Ottawa 2014)
Building the basics (WordPress Ottawa 2014)
 
Elastic: Why WYSIWYG is the future of WordPress themes — WordCamp NYC 2009
Elastic: Why WYSIWYG is the future of WordPress themes — WordCamp NYC 2009Elastic: Why WYSIWYG is the future of WordPress themes — WordCamp NYC 2009
Elastic: Why WYSIWYG is the future of WordPress themes — WordCamp NYC 2009
 
Don't Fear the Custom Theme: How to build a custom WordPress theme with only ...
Don't Fear the Custom Theme: How to build a custom WordPress theme with only ...Don't Fear the Custom Theme: How to build a custom WordPress theme with only ...
Don't Fear the Custom Theme: How to build a custom WordPress theme with only ...
 
Meetup child-themes
Meetup child-themesMeetup child-themes
Meetup child-themes
 
The Future Of WordPress Presentation
The Future Of WordPress PresentationThe Future Of WordPress Presentation
The Future Of WordPress Presentation
 
Plugins at WordCamp Phoenix
Plugins at WordCamp PhoenixPlugins at WordCamp Phoenix
Plugins at WordCamp Phoenix
 
WordPress Theme Development for Designers
WordPress Theme Development for DesignersWordPress Theme Development for Designers
WordPress Theme Development for Designers
 
WordPress Standardized Loop API
WordPress Standardized Loop APIWordPress Standardized Loop API
WordPress Standardized Loop API
 
Wordpress Plugin Development Short Tutorial
Wordpress Plugin Development Short TutorialWordpress Plugin Development Short Tutorial
Wordpress Plugin Development Short Tutorial
 
WordPress Plugin Development For Beginners
WordPress Plugin Development For BeginnersWordPress Plugin Development For Beginners
WordPress Plugin Development For Beginners
 
WordPress plugin development
WordPress plugin developmentWordPress plugin development
WordPress plugin development
 
Secure All The Things!
Secure All The Things!Secure All The Things!
Secure All The Things!
 
DrupalEasy: Intro to Theme Development
DrupalEasy: Intro to Theme DevelopmentDrupalEasy: Intro to Theme Development
DrupalEasy: Intro to Theme Development
 
PHPをさわらず作る!デザイナーさんのためのWordPress【超!初級】
PHPをさわらず作る!デザイナーさんのためのWordPress【超!初級】PHPをさわらず作る!デザイナーさんのためのWordPress【超!初級】
PHPをさわらず作る!デザイナーさんのためのWordPress【超!初級】
 

Ähnlich wie Intro to Plugin Development, Miami WordCamp, 2015

Getting started with WordPress development
Getting started with WordPress developmentGetting started with WordPress development
Getting started with WordPress developmentSteve Mortiboy
 
Creating Your First WordPress Plugin
Creating Your First WordPress PluginCreating Your First WordPress Plugin
Creating Your First WordPress PluginBrad Williams
 
WordPress theme development from scratch : ICT MeetUp 2013 Nepal
WordPress theme development from scratch : ICT MeetUp 2013 NepalWordPress theme development from scratch : ICT MeetUp 2013 Nepal
WordPress theme development from scratch : ICT MeetUp 2013 NepalChandra Prakash Thapa
 
Plugin development demystified 2017
Plugin development demystified 2017Plugin development demystified 2017
Plugin development demystified 2017ylefebvre
 
Plugin Development Practices
Plugin Development PracticesPlugin Development Practices
Plugin Development Practicesdanpastori
 
WordPress basic fundamental of plugin development and creating shortcode
WordPress basic fundamental of plugin development and creating shortcodeWordPress basic fundamental of plugin development and creating shortcode
WordPress basic fundamental of plugin development and creating shortcodeRakesh Kushwaha
 
How to make a WordPress theme
How to make a WordPress themeHow to make a WordPress theme
How to make a WordPress themeHardeep Asrani
 
WordPress Theme Workshop: Part 3
WordPress Theme Workshop: Part 3WordPress Theme Workshop: Part 3
WordPress Theme Workshop: Part 3David Bisset
 
Word press Plugins by WordPress Experts
Word press Plugins by WordPress ExpertsWord press Plugins by WordPress Experts
Word press Plugins by WordPress ExpertsYameen Khan
 
Plug in development
Plug in developmentPlug in development
Plug in developmentLucky Ali
 
Childthemes ottawa-word camp-1919
Childthemes ottawa-word camp-1919Childthemes ottawa-word camp-1919
Childthemes ottawa-word camp-1919Paul Bearne
 
PSD to WordPress
PSD to WordPressPSD to WordPress
PSD to WordPressNile Flores
 
Now That's What I Call WordPress Security 2010
Now That's What I Call WordPress Security 2010Now That's What I Call WordPress Security 2010
Now That's What I Call WordPress Security 2010Brad Williams
 
Wordpress Custom Child theme
Wordpress Custom Child themeWordpress Custom Child theme
Wordpress Custom Child themeYouSaf HasSan
 
Introduction to WordPress Hooks 2016
Introduction to WordPress Hooks 2016Introduction to WordPress Hooks 2016
Introduction to WordPress Hooks 2016Ian Wilson
 
WordPress Structure and Best Practices
WordPress Structure and Best PracticesWordPress Structure and Best Practices
WordPress Structure and Best Practicesmarkparolisi
 
Best practices in WordPress Development
Best practices in WordPress DevelopmentBest practices in WordPress Development
Best practices in WordPress DevelopmentMindfire Solutions
 

Ähnlich wie Intro to Plugin Development, Miami WordCamp, 2015 (20)

Getting started with WordPress development
Getting started with WordPress developmentGetting started with WordPress development
Getting started with WordPress development
 
Creating Your First WordPress Plugin
Creating Your First WordPress PluginCreating Your First WordPress Plugin
Creating Your First WordPress Plugin
 
WordPress theme development from scratch : ICT MeetUp 2013 Nepal
WordPress theme development from scratch : ICT MeetUp 2013 NepalWordPress theme development from scratch : ICT MeetUp 2013 Nepal
WordPress theme development from scratch : ICT MeetUp 2013 Nepal
 
Plugin development demystified 2017
Plugin development demystified 2017Plugin development demystified 2017
Plugin development demystified 2017
 
Plugin Development Practices
Plugin Development PracticesPlugin Development Practices
Plugin Development Practices
 
Theming 101
Theming 101Theming 101
Theming 101
 
WordPress basic fundamental of plugin development and creating shortcode
WordPress basic fundamental of plugin development and creating shortcodeWordPress basic fundamental of plugin development and creating shortcode
WordPress basic fundamental of plugin development and creating shortcode
 
Extending WordPress
Extending WordPressExtending WordPress
Extending WordPress
 
How to make a WordPress theme
How to make a WordPress themeHow to make a WordPress theme
How to make a WordPress theme
 
WordPress Theme Workshop: Part 3
WordPress Theme Workshop: Part 3WordPress Theme Workshop: Part 3
WordPress Theme Workshop: Part 3
 
Word press Plugins by WordPress Experts
Word press Plugins by WordPress ExpertsWord press Plugins by WordPress Experts
Word press Plugins by WordPress Experts
 
Plug in development
Plug in developmentPlug in development
Plug in development
 
Childthemes ottawa-word camp-1919
Childthemes ottawa-word camp-1919Childthemes ottawa-word camp-1919
Childthemes ottawa-word camp-1919
 
WordPress Plugins
WordPress PluginsWordPress Plugins
WordPress Plugins
 
PSD to WordPress
PSD to WordPressPSD to WordPress
PSD to WordPress
 
Now That's What I Call WordPress Security 2010
Now That's What I Call WordPress Security 2010Now That's What I Call WordPress Security 2010
Now That's What I Call WordPress Security 2010
 
Wordpress Custom Child theme
Wordpress Custom Child themeWordpress Custom Child theme
Wordpress Custom Child theme
 
Introduction to WordPress Hooks 2016
Introduction to WordPress Hooks 2016Introduction to WordPress Hooks 2016
Introduction to WordPress Hooks 2016
 
WordPress Structure and Best Practices
WordPress Structure and Best PracticesWordPress Structure and Best Practices
WordPress Structure and Best Practices
 
Best practices in WordPress Development
Best practices in WordPress DevelopmentBest practices in WordPress Development
Best practices in WordPress Development
 

Mehr von topher1kenobe

How To Increase Ecommerce Conversions
How To Increase Ecommerce ConversionsHow To Increase Ecommerce Conversions
How To Increase Ecommerce Conversionstopher1kenobe
 
Build Ecommerce Sites With Confidence (Demystifying Ecommerce), WordCamp Los ...
Build Ecommerce Sites With Confidence (Demystifying Ecommerce), WordCamp Los ...Build Ecommerce Sites With Confidence (Demystifying Ecommerce), WordCamp Los ...
Build Ecommerce Sites With Confidence (Demystifying Ecommerce), WordCamp Los ...topher1kenobe
 
Build Ecommerce Sites With Confidence (Demystifying Ecommerce)
Build Ecommerce Sites With Confidence (Demystifying Ecommerce)Build Ecommerce Sites With Confidence (Demystifying Ecommerce)
Build Ecommerce Sites With Confidence (Demystifying Ecommerce)topher1kenobe
 
6 Ecommerce Trends Altering the Ecommerce Landscape, and changing which strat...
6 Ecommerce Trends Altering the Ecommerce Landscape, and changing which strat...6 Ecommerce Trends Altering the Ecommerce Landscape, and changing which strat...
6 Ecommerce Trends Altering the Ecommerce Landscape, and changing which strat...topher1kenobe
 
Introduction to the WordPress Transients API
Introduction to the WordPress Transients APIIntroduction to the WordPress Transients API
Introduction to the WordPress Transients APItopher1kenobe
 
Talking to Other Sites with the WP HTTP API
Talking to Other Sites with the WP HTTP APITalking to Other Sites with the WP HTTP API
Talking to Other Sites with the WP HTTP APItopher1kenobe
 
What’s a REST API and why should I care?
What’s a REST API and why should I care?What’s a REST API and why should I care?
What’s a REST API and why should I care?topher1kenobe
 
Working with WP_Query in WordPress
Working with WP_Query in WordPressWorking with WP_Query in WordPress
Working with WP_Query in WordPresstopher1kenobe
 
HeroPress: A Case Study
HeroPress: A Case StudyHeroPress: A Case Study
HeroPress: A Case Studytopher1kenobe
 
Custom Database Queries in WordPress
Custom Database Queries in WordPressCustom Database Queries in WordPress
Custom Database Queries in WordPresstopher1kenobe
 
Introduction to WordPress Child Theming, WordCamp Kansas City, 2015
Introduction to WordPress Child Theming, WordCamp Kansas City, 2015Introduction to WordPress Child Theming, WordCamp Kansas City, 2015
Introduction to WordPress Child Theming, WordCamp Kansas City, 2015topher1kenobe
 
WordCamp Ann Arbor 2014: Site Caching, From Nothing to Everything
WordCamp Ann Arbor 2014: Site Caching, From Nothing to EverythingWordCamp Ann Arbor 2014: Site Caching, From Nothing to Everything
WordCamp Ann Arbor 2014: Site Caching, From Nothing to Everythingtopher1kenobe
 
Command Line Awesome, WordCamp Grand Rapids 2014
Command Line Awesome, WordCamp Grand Rapids 2014Command Line Awesome, WordCamp Grand Rapids 2014
Command Line Awesome, WordCamp Grand Rapids 2014topher1kenobe
 

Mehr von topher1kenobe (13)

How To Increase Ecommerce Conversions
How To Increase Ecommerce ConversionsHow To Increase Ecommerce Conversions
How To Increase Ecommerce Conversions
 
Build Ecommerce Sites With Confidence (Demystifying Ecommerce), WordCamp Los ...
Build Ecommerce Sites With Confidence (Demystifying Ecommerce), WordCamp Los ...Build Ecommerce Sites With Confidence (Demystifying Ecommerce), WordCamp Los ...
Build Ecommerce Sites With Confidence (Demystifying Ecommerce), WordCamp Los ...
 
Build Ecommerce Sites With Confidence (Demystifying Ecommerce)
Build Ecommerce Sites With Confidence (Demystifying Ecommerce)Build Ecommerce Sites With Confidence (Demystifying Ecommerce)
Build Ecommerce Sites With Confidence (Demystifying Ecommerce)
 
6 Ecommerce Trends Altering the Ecommerce Landscape, and changing which strat...
6 Ecommerce Trends Altering the Ecommerce Landscape, and changing which strat...6 Ecommerce Trends Altering the Ecommerce Landscape, and changing which strat...
6 Ecommerce Trends Altering the Ecommerce Landscape, and changing which strat...
 
Introduction to the WordPress Transients API
Introduction to the WordPress Transients APIIntroduction to the WordPress Transients API
Introduction to the WordPress Transients API
 
Talking to Other Sites with the WP HTTP API
Talking to Other Sites with the WP HTTP APITalking to Other Sites with the WP HTTP API
Talking to Other Sites with the WP HTTP API
 
What’s a REST API and why should I care?
What’s a REST API and why should I care?What’s a REST API and why should I care?
What’s a REST API and why should I care?
 
Working with WP_Query in WordPress
Working with WP_Query in WordPressWorking with WP_Query in WordPress
Working with WP_Query in WordPress
 
HeroPress: A Case Study
HeroPress: A Case StudyHeroPress: A Case Study
HeroPress: A Case Study
 
Custom Database Queries in WordPress
Custom Database Queries in WordPressCustom Database Queries in WordPress
Custom Database Queries in WordPress
 
Introduction to WordPress Child Theming, WordCamp Kansas City, 2015
Introduction to WordPress Child Theming, WordCamp Kansas City, 2015Introduction to WordPress Child Theming, WordCamp Kansas City, 2015
Introduction to WordPress Child Theming, WordCamp Kansas City, 2015
 
WordCamp Ann Arbor 2014: Site Caching, From Nothing to Everything
WordCamp Ann Arbor 2014: Site Caching, From Nothing to EverythingWordCamp Ann Arbor 2014: Site Caching, From Nothing to Everything
WordCamp Ann Arbor 2014: Site Caching, From Nothing to Everything
 
Command Line Awesome, WordCamp Grand Rapids 2014
Command Line Awesome, WordCamp Grand Rapids 2014Command Line Awesome, WordCamp Grand Rapids 2014
Command Line Awesome, WordCamp Grand Rapids 2014
 

Kürzlich hochgeladen

Call Girls Ludhiana Just Call 98765-12871 Top Class Call Girl Service Available
Call Girls Ludhiana Just Call 98765-12871 Top Class Call Girl Service AvailableCall Girls Ludhiana Just Call 98765-12871 Top Class Call Girl Service Available
Call Girls Ludhiana Just Call 98765-12871 Top Class Call Girl Service AvailableSeo
 
VIP Call Girls Pollachi 7001035870 Whatsapp Number, 24/07 Booking
VIP Call Girls Pollachi 7001035870 Whatsapp Number, 24/07 BookingVIP Call Girls Pollachi 7001035870 Whatsapp Number, 24/07 Booking
VIP Call Girls Pollachi 7001035870 Whatsapp Number, 24/07 Bookingdharasingh5698
 
Sarola * Female Escorts Service in Pune | 8005736733 Independent Escorts & Da...
Sarola * Female Escorts Service in Pune | 8005736733 Independent Escorts & Da...Sarola * Female Escorts Service in Pune | 8005736733 Independent Escorts & Da...
Sarola * Female Escorts Service in Pune | 8005736733 Independent Escorts & Da...SUHANI PANDEY
 
Microsoft Azure Arc Customer Deck Microsoft
Microsoft Azure Arc Customer Deck MicrosoftMicrosoft Azure Arc Customer Deck Microsoft
Microsoft Azure Arc Customer Deck MicrosoftAanSulistiyo
 
Pune Airport ( Call Girls ) Pune 6297143586 Hot Model With Sexy Bhabi Ready...
Pune Airport ( Call Girls ) Pune  6297143586  Hot Model With Sexy Bhabi Ready...Pune Airport ( Call Girls ) Pune  6297143586  Hot Model With Sexy Bhabi Ready...
Pune Airport ( Call Girls ) Pune 6297143586 Hot Model With Sexy Bhabi Ready...tanu pandey
 
20240508 QFM014 Elixir Reading List April 2024.pdf
20240508 QFM014 Elixir Reading List April 2024.pdf20240508 QFM014 Elixir Reading List April 2024.pdf
20240508 QFM014 Elixir Reading List April 2024.pdfMatthew Sinclair
 
( Pune ) VIP Pimpri Chinchwad Call Girls 🎗️ 9352988975 Sizzling | Escorts | G...
( Pune ) VIP Pimpri Chinchwad Call Girls 🎗️ 9352988975 Sizzling | Escorts | G...( Pune ) VIP Pimpri Chinchwad Call Girls 🎗️ 9352988975 Sizzling | Escorts | G...
( Pune ) VIP Pimpri Chinchwad Call Girls 🎗️ 9352988975 Sizzling | Escorts | G...nilamkumrai
 
VIP Model Call Girls Hadapsar ( Pune ) Call ON 9905417584 Starting High Prof...
VIP Model Call Girls Hadapsar ( Pune ) Call ON 9905417584 Starting  High Prof...VIP Model Call Girls Hadapsar ( Pune ) Call ON 9905417584 Starting  High Prof...
VIP Model Call Girls Hadapsar ( Pune ) Call ON 9905417584 Starting High Prof...singhpriety023
 
➥🔝 7737669865 🔝▻ mehsana Call-girls in Women Seeking Men 🔝mehsana🔝 Escorts...
➥🔝 7737669865 🔝▻ mehsana Call-girls in Women Seeking Men  🔝mehsana🔝   Escorts...➥🔝 7737669865 🔝▻ mehsana Call-girls in Women Seeking Men  🔝mehsana🔝   Escorts...
➥🔝 7737669865 🔝▻ mehsana Call-girls in Women Seeking Men 🔝mehsana🔝 Escorts...nirzagarg
 
Call Girls Sangvi Call Me 7737669865 Budget Friendly No Advance BookingCall G...
Call Girls Sangvi Call Me 7737669865 Budget Friendly No Advance BookingCall G...Call Girls Sangvi Call Me 7737669865 Budget Friendly No Advance BookingCall G...
Call Girls Sangvi Call Me 7737669865 Budget Friendly No Advance BookingCall G...roncy bisnoi
 
APNIC Updates presented by Paul Wilson at ARIN 53
APNIC Updates presented by Paul Wilson at ARIN 53APNIC Updates presented by Paul Wilson at ARIN 53
APNIC Updates presented by Paul Wilson at ARIN 53APNIC
 
2nd Solid Symposium: Solid Pods vs Personal Knowledge Graphs
2nd Solid Symposium: Solid Pods vs Personal Knowledge Graphs2nd Solid Symposium: Solid Pods vs Personal Knowledge Graphs
2nd Solid Symposium: Solid Pods vs Personal Knowledge GraphsEleniIlkou
 
Busty Desi⚡Call Girls in Vasundhara Ghaziabad >༒8448380779 Escort Service
Busty Desi⚡Call Girls in Vasundhara Ghaziabad >༒8448380779 Escort ServiceBusty Desi⚡Call Girls in Vasundhara Ghaziabad >༒8448380779 Escort Service
Busty Desi⚡Call Girls in Vasundhara Ghaziabad >༒8448380779 Escort ServiceDelhi Call girls
 
Pirangut | Call Girls Pune Phone No 8005736733 Elite Escort Service Available...
Pirangut | Call Girls Pune Phone No 8005736733 Elite Escort Service Available...Pirangut | Call Girls Pune Phone No 8005736733 Elite Escort Service Available...
Pirangut | Call Girls Pune Phone No 8005736733 Elite Escort Service Available...SUHANI PANDEY
 
20240510 QFM016 Irresponsible AI Reading List April 2024.pdf
20240510 QFM016 Irresponsible AI Reading List April 2024.pdf20240510 QFM016 Irresponsible AI Reading List April 2024.pdf
20240510 QFM016 Irresponsible AI Reading List April 2024.pdfMatthew Sinclair
 
Real Escorts in Al Nahda +971524965298 Dubai Escorts Service
Real Escorts in Al Nahda +971524965298 Dubai Escorts ServiceReal Escorts in Al Nahda +971524965298 Dubai Escorts Service
Real Escorts in Al Nahda +971524965298 Dubai Escorts ServiceEscorts Call Girls
 
VVIP Pune Call Girls Sinhagad WhatSapp Number 8005736733 With Elite Staff And...
VVIP Pune Call Girls Sinhagad WhatSapp Number 8005736733 With Elite Staff And...VVIP Pune Call Girls Sinhagad WhatSapp Number 8005736733 With Elite Staff And...
VVIP Pune Call Girls Sinhagad WhatSapp Number 8005736733 With Elite Staff And...SUHANI PANDEY
 
Ganeshkhind ! Call Girls Pune - 450+ Call Girl Cash Payment 8005736733 Neha T...
Ganeshkhind ! Call Girls Pune - 450+ Call Girl Cash Payment 8005736733 Neha T...Ganeshkhind ! Call Girls Pune - 450+ Call Girl Cash Payment 8005736733 Neha T...
Ganeshkhind ! Call Girls Pune - 450+ Call Girl Cash Payment 8005736733 Neha T...SUHANI PANDEY
 

Kürzlich hochgeladen (20)

Russian Call Girls in %(+971524965298 )# Call Girls in Dubai
Russian Call Girls in %(+971524965298  )#  Call Girls in DubaiRussian Call Girls in %(+971524965298  )#  Call Girls in Dubai
Russian Call Girls in %(+971524965298 )# Call Girls in Dubai
 
Call Girls Ludhiana Just Call 98765-12871 Top Class Call Girl Service Available
Call Girls Ludhiana Just Call 98765-12871 Top Class Call Girl Service AvailableCall Girls Ludhiana Just Call 98765-12871 Top Class Call Girl Service Available
Call Girls Ludhiana Just Call 98765-12871 Top Class Call Girl Service Available
 
VIP Call Girls Pollachi 7001035870 Whatsapp Number, 24/07 Booking
VIP Call Girls Pollachi 7001035870 Whatsapp Number, 24/07 BookingVIP Call Girls Pollachi 7001035870 Whatsapp Number, 24/07 Booking
VIP Call Girls Pollachi 7001035870 Whatsapp Number, 24/07 Booking
 
Sarola * Female Escorts Service in Pune | 8005736733 Independent Escorts & Da...
Sarola * Female Escorts Service in Pune | 8005736733 Independent Escorts & Da...Sarola * Female Escorts Service in Pune | 8005736733 Independent Escorts & Da...
Sarola * Female Escorts Service in Pune | 8005736733 Independent Escorts & Da...
 
Microsoft Azure Arc Customer Deck Microsoft
Microsoft Azure Arc Customer Deck MicrosoftMicrosoft Azure Arc Customer Deck Microsoft
Microsoft Azure Arc Customer Deck Microsoft
 
Pune Airport ( Call Girls ) Pune 6297143586 Hot Model With Sexy Bhabi Ready...
Pune Airport ( Call Girls ) Pune  6297143586  Hot Model With Sexy Bhabi Ready...Pune Airport ( Call Girls ) Pune  6297143586  Hot Model With Sexy Bhabi Ready...
Pune Airport ( Call Girls ) Pune 6297143586 Hot Model With Sexy Bhabi Ready...
 
20240508 QFM014 Elixir Reading List April 2024.pdf
20240508 QFM014 Elixir Reading List April 2024.pdf20240508 QFM014 Elixir Reading List April 2024.pdf
20240508 QFM014 Elixir Reading List April 2024.pdf
 
( Pune ) VIP Pimpri Chinchwad Call Girls 🎗️ 9352988975 Sizzling | Escorts | G...
( Pune ) VIP Pimpri Chinchwad Call Girls 🎗️ 9352988975 Sizzling | Escorts | G...( Pune ) VIP Pimpri Chinchwad Call Girls 🎗️ 9352988975 Sizzling | Escorts | G...
( Pune ) VIP Pimpri Chinchwad Call Girls 🎗️ 9352988975 Sizzling | Escorts | G...
 
VIP Model Call Girls Hadapsar ( Pune ) Call ON 9905417584 Starting High Prof...
VIP Model Call Girls Hadapsar ( Pune ) Call ON 9905417584 Starting  High Prof...VIP Model Call Girls Hadapsar ( Pune ) Call ON 9905417584 Starting  High Prof...
VIP Model Call Girls Hadapsar ( Pune ) Call ON 9905417584 Starting High Prof...
 
➥🔝 7737669865 🔝▻ mehsana Call-girls in Women Seeking Men 🔝mehsana🔝 Escorts...
➥🔝 7737669865 🔝▻ mehsana Call-girls in Women Seeking Men  🔝mehsana🔝   Escorts...➥🔝 7737669865 🔝▻ mehsana Call-girls in Women Seeking Men  🔝mehsana🔝   Escorts...
➥🔝 7737669865 🔝▻ mehsana Call-girls in Women Seeking Men 🔝mehsana🔝 Escorts...
 
Call Girls Sangvi Call Me 7737669865 Budget Friendly No Advance BookingCall G...
Call Girls Sangvi Call Me 7737669865 Budget Friendly No Advance BookingCall G...Call Girls Sangvi Call Me 7737669865 Budget Friendly No Advance BookingCall G...
Call Girls Sangvi Call Me 7737669865 Budget Friendly No Advance BookingCall G...
 
APNIC Updates presented by Paul Wilson at ARIN 53
APNIC Updates presented by Paul Wilson at ARIN 53APNIC Updates presented by Paul Wilson at ARIN 53
APNIC Updates presented by Paul Wilson at ARIN 53
 
2nd Solid Symposium: Solid Pods vs Personal Knowledge Graphs
2nd Solid Symposium: Solid Pods vs Personal Knowledge Graphs2nd Solid Symposium: Solid Pods vs Personal Knowledge Graphs
2nd Solid Symposium: Solid Pods vs Personal Knowledge Graphs
 
Busty Desi⚡Call Girls in Vasundhara Ghaziabad >༒8448380779 Escort Service
Busty Desi⚡Call Girls in Vasundhara Ghaziabad >༒8448380779 Escort ServiceBusty Desi⚡Call Girls in Vasundhara Ghaziabad >༒8448380779 Escort Service
Busty Desi⚡Call Girls in Vasundhara Ghaziabad >༒8448380779 Escort Service
 
Pirangut | Call Girls Pune Phone No 8005736733 Elite Escort Service Available...
Pirangut | Call Girls Pune Phone No 8005736733 Elite Escort Service Available...Pirangut | Call Girls Pune Phone No 8005736733 Elite Escort Service Available...
Pirangut | Call Girls Pune Phone No 8005736733 Elite Escort Service Available...
 
20240510 QFM016 Irresponsible AI Reading List April 2024.pdf
20240510 QFM016 Irresponsible AI Reading List April 2024.pdf20240510 QFM016 Irresponsible AI Reading List April 2024.pdf
20240510 QFM016 Irresponsible AI Reading List April 2024.pdf
 
valsad Escorts Service ☎️ 6378878445 ( Sakshi Sinha ) High Profile Call Girls...
valsad Escorts Service ☎️ 6378878445 ( Sakshi Sinha ) High Profile Call Girls...valsad Escorts Service ☎️ 6378878445 ( Sakshi Sinha ) High Profile Call Girls...
valsad Escorts Service ☎️ 6378878445 ( Sakshi Sinha ) High Profile Call Girls...
 
Real Escorts in Al Nahda +971524965298 Dubai Escorts Service
Real Escorts in Al Nahda +971524965298 Dubai Escorts ServiceReal Escorts in Al Nahda +971524965298 Dubai Escorts Service
Real Escorts in Al Nahda +971524965298 Dubai Escorts Service
 
VVIP Pune Call Girls Sinhagad WhatSapp Number 8005736733 With Elite Staff And...
VVIP Pune Call Girls Sinhagad WhatSapp Number 8005736733 With Elite Staff And...VVIP Pune Call Girls Sinhagad WhatSapp Number 8005736733 With Elite Staff And...
VVIP Pune Call Girls Sinhagad WhatSapp Number 8005736733 With Elite Staff And...
 
Ganeshkhind ! Call Girls Pune - 450+ Call Girl Cash Payment 8005736733 Neha T...
Ganeshkhind ! Call Girls Pune - 450+ Call Girl Cash Payment 8005736733 Neha T...Ganeshkhind ! Call Girls Pune - 450+ Call Girl Cash Payment 8005736733 Neha T...
Ganeshkhind ! Call Girls Pune - 450+ Call Girl Cash Payment 8005736733 Neha T...
 

Intro to Plugin Development, Miami WordCamp, 2015

  • 1. Intro To Plugin Development Emptying out functions.php Intro To Plugin Development Topher DeRosia @topher1kenobe
  • 2. Hi, my name is Topher I’m a WordPress developer from Grand Rapids MI @topher1kenobe Intro To Plugin Development Topher DeRosia @topher1kenobe
  • 3. “Just put this code in your theme’s functions.php file…” JUST SAY NO Intro To Plugin Development Topher DeRosia @topher1kenobe
  • 4. Plugins are packages of code that affect your site’s functionality. Themes are packages of code that affect your site’s design. DO NOT MIX. Intro To Plugin Development Topher DeRosia @topher1kenobe
  • 5. Plugins are either single files or folders in /wp-content/plugins Intro To Plugin Development Topher DeRosia @topher1kenobe
  • 6. Typically inside each plugin folder is a file with the same name as the folder, plus any other files it needs. Intro To Plugin Development Topher DeRosia @topher1kenobe
  • 7. In the top of every main plugin file is a header block with information about the plugin. Intro To Plugin Development Topher DeRosia @topher1kenobe
  • 8. The only option absolutely required is the “Plugin Name”. The others are merely strongly recommended. VERY strongly recommended: License: GNU General Public License v2 or later License URI: http://www.gnu.org/licenses/gpl-2.0.html Tags: custom-header, custom-menu, editor-style, featured-images (etc) Intro To Plugin Development Topher DeRosia @topher1kenobe
  • 9. The Secret Sauce: Any code you might have put into functions.php in your theme could go into a plugin.* *with a few exceptions Intro To Plugin Development Topher DeRosia @topher1kenobe
  • 10. Example: <?php /* Plugin Name: Topher’s Little Plugin Description: Does things I want to my site Version: 1.0 Author: Topher */ // 220 pixels wide by 180 pixels tall, hard crop mode add_image_size( 'custom-size', 220, 180, true ); ?> Intro To Plugin Development Topher DeRosia @topher1kenobe
  • 11. Longer Example: <?php /* Plugin Name: Topher’s Little Plugin Description: Does things I want to my site Version: 1.0 Author: Topher */ // 220 pixels wide by 180 pixels tall, hard crop mode add_image_size( 'custom-size', 220, 180, true ); // Make shortcodes work inside text widgets add_filter('widget_text', 'do_shortcode'); // Fix styling in old content function phlog_scripts() { wp_enqueue_style( 'phlog_styles', plugins_url( '/css/phlog.css' , __FILE__ ) ); } add_action( 'wp_enqueue_scripts', 'phlog_scripts' ); ?> Intro To Plugin Development Topher DeRosia @topher1kenobe
  • 12. Explanation: function phlog_scripts() { wp_enqueue_style( 'phlog_styles', plugins_url( '/css/phlog.css' , __FILE__ ) ); } add_action( 'wp_enqueue_scripts', 'phlog_scripts' ); I made a function called `phlog_scripts()` Inside it is a function that properly enqueues a CSS file. wp_enqueue_style takes 2 arguments, a name I made up and the path to the CSS file. The path to the CSS file is determined with the WordPress function plugins_url(). Intro To Plugin Development Topher DeRosia @topher1kenobe
  • 13. Releasing a Plugin A plugin built for release on WordPress.org must meet a list of requirements. The requirements are listed at https://developer.wordpress.org/plugins/wordpress-org/ Best practices are found in the WordPress Plugin Handbook https://developer.wordpress.org/plugins/ Intro To Plugin Development Topher DeRosia @topher1kenobe
  • 14. mu-plugins: mu == must use Plugins that are stored in mu-plugins are automatically activated, and cannot be deactivated. The main file of a plugin must be stored directly in the /mu-plugins/ directory, OR be included. Intro To Plugin Development Topher DeRosia @topher1kenobe
  • 15. mu-plugins Intro To Plugin Development Topher DeRosia @topher1kenobe
  • 16. mu-plugins To convert a regular plugin to mu-plugins, put it in the /mu-plugins directory and then make a new, single-file plugin that looks like this: <?php /* Plugin Name: mu-plugins inclusion plugin Description: Includes the main files of any plugins that are in mu-plugins Author: Topher Version: 1.0 */ // include widget_logic include WP_CONTENT_DIR . '/mu-plugins/widget-logic/widget_logic.php'; ?> Intro To Plugin Development Topher DeRosia @topher1kenobe
  • 17. Extra Credit: WP-CLI WP-CLI is the command line tool for WordPress. It can create an empty plugin with the proper header in place: wp scaffold plugin --prompt This will ask questions like this: 1/4 <slug>: topher-test 2/4 [--plugin_name=<title>]: Topher's Test 3/4 [--skip-tests] (Y/n): Y 4/4 [--activate] (Y/n): Y Success: Created /home/topher1/topher1kenobe.com/wp-content/plugins/topher-test 1/1 <plugin>: topher-test Success: Created test files. Intro To Plugin Development Topher DeRosia @topher1kenobe
  • 18. Real World Example Easy Digital Downloads - Customer Contact Intro To Plugin Development Topher DeRosia @topher1kenobe
  • 19. Easy Digital Downloads - Customer Contact <?php /* Plugin Name: Easy Digital Downloads - Customer Contact Version: 1.0 Description: Creates a tab on the Customer page for sending an email to that customer. Author: Topher Author URI: http://topher1kenobe.com Plugin URI: http://topher1kenobe.com Text Domain: edd-customer-contact Domain Path: /languages License: GNU General Public License v2 or later License URI: http://www.gnu.org/licenses/gpl-2.0.html */ Intro To Plugin Development Topher DeRosia @topher1kenobe
  • 20. Easy Digital Downloads - Customer Contact Comment everything! Docblock /** * Contact a customer * * @since 2.3 * @param array $args The $_POST array being passeed * @return int Whether it was a successful email */ Inline // make sure we're allowed to be here at all if ( ! is_admin() || ! current_user_can( $customer_edit_role ) ) { wp_die( __( 'You do not have permission to contact this customer.', 'edd' ) ); } Intro To Plugin Development Topher DeRosia @topher1kenobe
  • 21. Easy Digital Downloads - Customer Contact Insert Code Review Here Intro To Plugin Development Topher DeRosia @topher1kenobe
  • 22. Easy Digital Downloads - Customer Contact Get Help From other developers (Slack, Stack Overflow, friends) From parent plugin developer (if making an Addon they probably want to help) From documentation (https://developer.wordpress.org/plugins/) From code (read through plugins doing similar things) Intro To Plugin Development Topher DeRosia @topher1kenobe
  • 23. THANKS FOR LISTENING Intro To Plugin Development Topher DeRosia @topher1kenobe http://topher1kenobe.com Follow me @topher1kenobe