SlideShare une entreprise Scribd logo
1  sur  26
Télécharger pour lire hors ligne
WordPress
as an
Application
Framework
Dustin Filippini
Developer @ WebDevStudios
@dustyf
dustyf.com
WWhat Makes a Framework Good?
• Easy
• Well Supported
• Extensible
EASY
It does work
for you
Well
Supported
We are here to help!
Extensible
Add on More Dogs
A Real World Example
Create a billing/invoicing system using WordPress!
Think… FreshBooks
“I need an easy,
reusable way to
store, access,
and categorize
structured data”
Custom Post Types &
Custom Taxonomies.
function register_invoice() {
$args = array(
'public' => true,
'label' => 'Invoices'
);
register_post_type( 'invoice',$args );
}
add_action(‘init','register_invoice');
function create_invoice_status() {
register_taxonomy(
'status',
'invoice',
array(
'label' => ‘Invoice Status',
'rewrite' => array( 'slug' =>
‘invoice_status' ),
'hierarchical' => false,
)
);
}
add_action( 'init',
‘create_invoice_status' );
“I need to store
data related to
my structured
data and users.”
Post Meta and User Meta.
update_post_meta( $post_id,
‘purchase_order_number’, $value );
update_user_meta( $user_id, ‘job_title’,
$value );
“I need users to
be able to access
data and limit
access to
different users”
Create users and assign
roles and capabilities to
access different parts of
your application.
Built-in User Management panel and
ability to manipulate through your code.
ADD A NEW ROLE
add_role(
‘client',
‘Client',
array(
'read' => true,
'edit_posts' => true,
)
);
ADD A CAPABILITY TO THE ROLE
$role = get_role( ‘client' );
$role->add_cap( ‘view_invoices’ );
RESTRICT ACTION
if ( current_user_can( ‘view_invoices’ )
{
// Do Something
}
“I need to create
custom views
for different
types of data"
Templating through
WordPress Theme API.
Allows you to define different
templates for different types
of content and views.
BASIC WORDPRESS PAGE LOOP
get_header();
if (have_posts()) :
while (have_posts()) :
the_post();
the_content();
endwhile;
endif;
get_sidebar();
get_footer();
TEMPLATE FILE NAMING
single-invoices.php - Single Invoice
View
archive-invoices.php - Archive of
Invoices
LOADING CUSTOM TEMPLATES
get_template_part( 'loop', 'index' );
will do a PHP require() for the first
file that exists among these, in this
priority:
wp-content/themes/themename/loop-
index.php
wp-content/themes/themename/loop.php
“I need to
customize
default actions
of my app”
WordPress has hooks for nearly
everything that happens.
Use ‘add_action’ to do execute
custom code at a certain time.
Use ‘add_filter’ to change
default values.
function email_invoice( $post_id ) {
$to = ‘dusty@dustyf.com’;
$subject = get_the_title( $post_id );
$message =
get_the_permalink( $post_id );
wp_mail( $to, $subject, $message );
}
add_action(‘save_post’,‘email_invoice’);
function mod_title( $title, $post_id ) {
if (
‘invoice’ == get_post_type($post_id) &&
has_term( ‘paid’,
‘invoice_status’, $post_id
) {
$title = ‘PAID: ‘ . $title;
}
return $title;
}
add_filter( ‘the title’, ‘mod_title’,
10, 2 );
“I need easy,
secure, access
to the
database”
The wpdb class provides
easy, secure database
interaction for those times
you need it.
global $wpdb;
$results = $wpdb->get_results( 'SELECT *
FROM wp_options WHERE option_id = 1');
$wpdb->insert(
‘payments_made',
array(
'client' => 'Apple',
‘invoice_num' => 123
),
array(
'%s',
'%d'
)
);
// PROTECT FROM SQL INJECTION
$metakey = ‘purchase_order_num’;
$metavalue = ‘12345’;
$wpdb->query( $wpdb->prepare(
"INSERT INTO $wpdb->postmeta
( post_id, meta_key, meta_value )
VALUES ( %d, %s, %s )",
10,
$metakey,
$metavalue
) );
“I need to have
a reliable way
to rewrite
URLs”
WordPress rewrites posts,
pages, taxonomies, and
custom post types by
default. But, you can use
the Rewrite API to make
custom rules.
function custom_rewrite() {
add_rewrite_rule('^invoice/
([0-9]+)/?',
'index.php?page_id=$matches[1]',
'top');
}
add_action(‘init','custom_rewrite');
Now, you can access the same page as
http://example.com/invoice/95
“Different app
instances for
different users/
clients/
companies.”
WordPress multisite allows
you to create multiple site/
app instances. Each can
share or have different
functionality, views, settings,
userbases, and more.
Add the following to your wp-config.php
and follow the instructions in wp-admin
under Settings > Network Setup
define( 'WP_ALLOW_MULTISITE', true );
Use Case: Each company using this
invoice system can have their own
instance at their own url…
google.example.com or example.com/google
“I need to be
able to connect
with third-party
services”
Built in HTTP API supports
multiple transport methods
for your HTTP requests
because different hosting
environments support
different things.
$response = wp_remote_post( $url, array(
'method' => 'POST',
'timeout' => 45,
'redirection' => 5,
'httpversion' => '1.0',
'blocking' => true,
'headers' => array(),
'body' => array( 'username' =>
'bob', 'password' => '1234xyz' ),
'cookies' => array()
)
);
$response returns a nice array
AlSO:
wp_remote_request()
wp_remote_get()
wp_remote_post()
wp_remote_head()
wp_remote_retrieve_body()
wp_remote_retrieve_header()
wp_remote_retrieve_headers()
wp_remote_retrieve_response_code()
wp_remote_retrieve_response_message()
“I need to
improve
performance by
limiting requests”
Transients allow you quickly
store data with an expiration
for quick access.
Get more in depth with
caching plugins.
set_transient(
‘special_query’,
$special_query,
60*60*12
);
get_transient( 'special_query' );
//EXAMPLE
if ( false === ( $special_query =
get_transient( 'special_query' ) ) ) {
$special_query_results = new WP_Query(
'cat=5&order=random&tag=tech&post_met
a_key=thumbnail'
);
set_transient(
'special_query',
$special_query,
4 * HOUR_IN_SECONDS
);
}
- get_transient
- set_transient
- wp_cache_set
- wp_cache_get
“I need to be
able to open
my application
to third parties”
Create an API for your app
using the XML-RPC API or
the new JSON REST API
JSON REST API will be in WP Core soon,
but is now available in a stable plugin.
Out of the box provides:
• Endpoints for retrieving, creating,
editing, and deleting all built-in post
types and registered custom post types

• Also, media, users, taxonomies and meta

• Can be extended to support your other
types of data
“I don’t want to
create things that
have been done
hundreds of times
before”
Thousands of WordPress
Plugins both free and
premium. Also, feel free to
use other PHP Libraries.
35,000+ Free Plugins at wordpress.org/
plugins/ and many great premium plugins.
BuddyPress - Social Network
BBPress - Forums
BadgeOS - Award Achievements
CMB2 - Custom Fields and Metaboxes
Gravity Forms - Form Building
Posts 2 Posts - Relational post linking
WooCommerce - eCommerce
Events Calendar Pro - Calendar
Or build your own to use over and over
(or to share or sell!)
MOAR

EXAMPLES
WordPress is being used as
an application framework all
over the web.
Reactor by AppPresser
(http://reactor.apppresser.com/)
WP Powered application that builds
mobile applications from your WP site.
DesktopServer 4.0
(http://serverpress.com/)
Desktop application to create local
development sites.
ManageWP
(http://managewp.com/)
Upgrade, perform backups, monitor, track
statistics, and manage multiple WP
sites.
YMCA Y-MVP App
(http://www.ymcanyc.org/association/
pages/y-mvp)
iPad application used as a kiosk at YMCA
to allow members to scan card and log
exercise activities.
Frito-Lay Project Management
(http://liftux.com/portfolio/frito-lay-
creative-project-management-app/)
Custom project management app.
Easy
Well
Supported
Extensible
Go Forth
& Create Apps
Dustin Filippini
dusty@dustyf.com
@dustyf
dustyf.com
webdevstudios.com

Contenu connexe

Tendances

Doctrine 2
Doctrine 2Doctrine 2
Doctrine 2zfconfua
 
Be lazy, be ESI: HTTP caching and Symfony2 @ PHPDay 2011 05-13-2011
 Be lazy, be ESI: HTTP caching and Symfony2 @ PHPDay 2011 05-13-2011 Be lazy, be ESI: HTTP caching and Symfony2 @ PHPDay 2011 05-13-2011
Be lazy, be ESI: HTTP caching and Symfony2 @ PHPDay 2011 05-13-2011Alessandro Nadalin
 
Symfony2, creare bundle e valore per il cliente
Symfony2, creare bundle e valore per il clienteSymfony2, creare bundle e valore per il cliente
Symfony2, creare bundle e valore per il clienteLeonardo Proietti
 
Advanced php testing in action
Advanced php testing in actionAdvanced php testing in action
Advanced php testing in actionJace Ju
 
Moving a high traffic ZF1 Enterprise Application to SF2 - Lessons learned
Moving a high traffic ZF1 Enterprise Application to SF2 - Lessons learnedMoving a high traffic ZF1 Enterprise Application to SF2 - Lessons learned
Moving a high traffic ZF1 Enterprise Application to SF2 - Lessons learnedBaldur Rensch
 
Intro to advanced caching in WordPress
Intro to advanced caching in WordPressIntro to advanced caching in WordPress
Intro to advanced caching in WordPressMaor Chasen
 
Dependency Injection with PHP and PHP 5.3
Dependency Injection with PHP and PHP 5.3Dependency Injection with PHP and PHP 5.3
Dependency Injection with PHP and PHP 5.3Fabien Potencier
 
Decouple Your Code For Reusability (International PHP Conference / IPC 2008)
Decouple Your Code For Reusability (International PHP Conference / IPC 2008)Decouple Your Code For Reusability (International PHP Conference / IPC 2008)
Decouple Your Code For Reusability (International PHP Conference / IPC 2008)Fabien Potencier
 
Dependency Injection in Laravel
Dependency Injection in LaravelDependency Injection in Laravel
Dependency Injection in LaravelHAO-WEN ZHANG
 
PHPUnit でよりよくテストを書くために
PHPUnit でよりよくテストを書くためにPHPUnit でよりよくテストを書くために
PHPUnit でよりよくテストを書くためにYuya Takeyama
 
“Writing code that lasts” … or writing code you won’t hate tomorrow. - PHPKonf
“Writing code that lasts” … or writing code you won’t hate tomorrow. - PHPKonf“Writing code that lasts” … or writing code you won’t hate tomorrow. - PHPKonf
“Writing code that lasts” … or writing code you won’t hate tomorrow. - PHPKonfRafael Dohms
 
Command Bus To Awesome Town
Command Bus To Awesome TownCommand Bus To Awesome Town
Command Bus To Awesome TownRoss Tuck
 
Система рендеринга в Magento
Система рендеринга в MagentoСистема рендеринга в Magento
Система рендеринга в MagentoMagecom Ukraine
 
WooCommerce CRUD and Data Store by Akeda Bagus
WooCommerce CRUD and Data Store by Akeda BagusWooCommerce CRUD and Data Store by Akeda Bagus
WooCommerce CRUD and Data Store by Akeda BagusWordCamp Indonesia
 
Design how your objects talk through mocking
Design how your objects talk through mockingDesign how your objects talk through mocking
Design how your objects talk through mockingKonstantin Kudryashov
 
Command-Oriented Architecture
Command-Oriented ArchitectureCommand-Oriented Architecture
Command-Oriented ArchitectureLuiz Messias
 
Adding Dependency Injection to Legacy Applications
Adding Dependency Injection to Legacy ApplicationsAdding Dependency Injection to Legacy Applications
Adding Dependency Injection to Legacy ApplicationsSam Hennessy
 

Tendances (20)

Doctrine 2
Doctrine 2Doctrine 2
Doctrine 2
 
Be lazy, be ESI: HTTP caching and Symfony2 @ PHPDay 2011 05-13-2011
 Be lazy, be ESI: HTTP caching and Symfony2 @ PHPDay 2011 05-13-2011 Be lazy, be ESI: HTTP caching and Symfony2 @ PHPDay 2011 05-13-2011
Be lazy, be ESI: HTTP caching and Symfony2 @ PHPDay 2011 05-13-2011
 
Symfony2, creare bundle e valore per il cliente
Symfony2, creare bundle e valore per il clienteSymfony2, creare bundle e valore per il cliente
Symfony2, creare bundle e valore per il cliente
 
Advanced php testing in action
Advanced php testing in actionAdvanced php testing in action
Advanced php testing in action
 
Moving a high traffic ZF1 Enterprise Application to SF2 - Lessons learned
Moving a high traffic ZF1 Enterprise Application to SF2 - Lessons learnedMoving a high traffic ZF1 Enterprise Application to SF2 - Lessons learned
Moving a high traffic ZF1 Enterprise Application to SF2 - Lessons learned
 
Intro to advanced caching in WordPress
Intro to advanced caching in WordPressIntro to advanced caching in WordPress
Intro to advanced caching in WordPress
 
Dependency Injection with PHP and PHP 5.3
Dependency Injection with PHP and PHP 5.3Dependency Injection with PHP and PHP 5.3
Dependency Injection with PHP and PHP 5.3
 
Decouple Your Code For Reusability (International PHP Conference / IPC 2008)
Decouple Your Code For Reusability (International PHP Conference / IPC 2008)Decouple Your Code For Reusability (International PHP Conference / IPC 2008)
Decouple Your Code For Reusability (International PHP Conference / IPC 2008)
 
Perl object ?
Perl object ?Perl object ?
Perl object ?
 
Dependency Injection in Laravel
Dependency Injection in LaravelDependency Injection in Laravel
Dependency Injection in Laravel
 
PHPUnit でよりよくテストを書くために
PHPUnit でよりよくテストを書くためにPHPUnit でよりよくテストを書くために
PHPUnit でよりよくテストを書くために
 
Separation of concerns - DPC12
Separation of concerns - DPC12Separation of concerns - DPC12
Separation of concerns - DPC12
 
“Writing code that lasts” … or writing code you won’t hate tomorrow. - PHPKonf
“Writing code that lasts” … or writing code you won’t hate tomorrow. - PHPKonf“Writing code that lasts” … or writing code you won’t hate tomorrow. - PHPKonf
“Writing code that lasts” … or writing code you won’t hate tomorrow. - PHPKonf
 
Daily notes
Daily notesDaily notes
Daily notes
 
Command Bus To Awesome Town
Command Bus To Awesome TownCommand Bus To Awesome Town
Command Bus To Awesome Town
 
Система рендеринга в Magento
Система рендеринга в MagentoСистема рендеринга в Magento
Система рендеринга в Magento
 
WooCommerce CRUD and Data Store by Akeda Bagus
WooCommerce CRUD and Data Store by Akeda BagusWooCommerce CRUD and Data Store by Akeda Bagus
WooCommerce CRUD and Data Store by Akeda Bagus
 
Design how your objects talk through mocking
Design how your objects talk through mockingDesign how your objects talk through mocking
Design how your objects talk through mocking
 
Command-Oriented Architecture
Command-Oriented ArchitectureCommand-Oriented Architecture
Command-Oriented Architecture
 
Adding Dependency Injection to Legacy Applications
Adding Dependency Injection to Legacy ApplicationsAdding Dependency Injection to Legacy Applications
Adding Dependency Injection to Legacy Applications
 

En vedette

how can we control our self???
how can we control our self???how can we control our self???
how can we control our self???Uttam Trasadiya
 
Ética empresarial
Ética empresarialÉtica empresarial
Ética empresarialmjverza
 
Evaluation-Codes and Conventions
Evaluation-Codes and ConventionsEvaluation-Codes and Conventions
Evaluation-Codes and Conventionsmarciamediastudies
 
Untitled Presentation
Untitled PresentationUntitled Presentation
Untitled PresentationMMM GLOBAL
 
Research Week 2014: CIHR: Opportunities, Eligibility, and Strategies for Success
Research Week 2014: CIHR: Opportunities, Eligibility, and Strategies for SuccessResearch Week 2014: CIHR: Opportunities, Eligibility, and Strategies for Success
Research Week 2014: CIHR: Opportunities, Eligibility, and Strategies for SuccessWilfrid Laurier University
 
K5 kepelbagaian budaya
K5 kepelbagaian budayaK5 kepelbagaian budaya
K5 kepelbagaian budayanormazua
 
Performance Audit of CanIUse by PerfAudit
Performance Audit of CanIUse by PerfAuditPerformance Audit of CanIUse by PerfAudit
Performance Audit of CanIUse by PerfAuditPerfAudit
 
Innovations in Analytics for Academic Publishing and Research Networking
Innovations in Analytics for Academic Publishing and Research NetworkingInnovations in Analytics for Academic Publishing and Research Networking
Innovations in Analytics for Academic Publishing and Research NetworkingSandra Hausmann
 

En vedette (13)

Vritti Product pictures
Vritti Product picturesVritti Product pictures
Vritti Product pictures
 
how can we control our self???
how can we control our self???how can we control our self???
how can we control our self???
 
SoPact-Social Impact
SoPact-Social ImpactSoPact-Social Impact
SoPact-Social Impact
 
Ética empresarial
Ética empresarialÉtica empresarial
Ética empresarial
 
Evaluation-Codes and Conventions
Evaluation-Codes and ConventionsEvaluation-Codes and Conventions
Evaluation-Codes and Conventions
 
Untitled Presentation
Untitled PresentationUntitled Presentation
Untitled Presentation
 
Батрак А.В.
Батрак А.В.Батрак А.В.
Батрак А.В.
 
Degree
DegreeDegree
Degree
 
Research Week 2014: CIHR: Opportunities, Eligibility, and Strategies for Success
Research Week 2014: CIHR: Opportunities, Eligibility, and Strategies for SuccessResearch Week 2014: CIHR: Opportunities, Eligibility, and Strategies for Success
Research Week 2014: CIHR: Opportunities, Eligibility, and Strategies for Success
 
K5 kepelbagaian budaya
K5 kepelbagaian budayaK5 kepelbagaian budaya
K5 kepelbagaian budaya
 
Performance Audit of CanIUse by PerfAudit
Performance Audit of CanIUse by PerfAuditPerformance Audit of CanIUse by PerfAudit
Performance Audit of CanIUse by PerfAudit
 
Innovations in Analytics for Academic Publishing and Research Networking
Innovations in Analytics for Academic Publishing and Research NetworkingInnovations in Analytics for Academic Publishing and Research Networking
Innovations in Analytics for Academic Publishing and Research Networking
 
K11 stres
K11 stresK11 stres
K11 stres
 

Similaire à WordPress as an application framework

WordPress REST API hacking
WordPress REST API hackingWordPress REST API hacking
WordPress REST API hackingJeroen van Dijk
 
laravel tricks in 50minutes
laravel tricks in 50minuteslaravel tricks in 50minutes
laravel tricks in 50minutesBarang CK
 
Doctrine For Beginners
Doctrine For BeginnersDoctrine For Beginners
Doctrine For BeginnersJonathan Wage
 
WordPress Kitchen 2014 - Александр Стриха: Кеширование в WordPress
WordPress Kitchen 2014 - Александр Стриха: Кеширование в WordPress WordPress Kitchen 2014 - Александр Стриха: Кеширование в WordPress
WordPress Kitchen 2014 - Александр Стриха: Кеширование в WordPress WordCamp Kyiv
 
The Zen of Lithium
The Zen of LithiumThe Zen of Lithium
The Zen of LithiumNate Abele
 
[WLDN] Supercharging word press development in 2018
[WLDN] Supercharging word press development in 2018[WLDN] Supercharging word press development in 2018
[WLDN] Supercharging word press development in 2018Adam Tomat
 
Dependency Injection
Dependency InjectionDependency Injection
Dependency InjectionRifat Nabi
 
Introduction to Zend Framework web services
Introduction to Zend Framework web servicesIntroduction to Zend Framework web services
Introduction to Zend Framework web servicesMichelangelo van Dam
 
Как получить чёрный пояс по WordPress?
Как получить чёрный пояс по WordPress?Как получить чёрный пояс по WordPress?
Как получить чёрный пояс по WordPress?Yevhen Kotelnytskyi
 
Speed Things Up with Transients
Speed Things Up with TransientsSpeed Things Up with Transients
Speed Things Up with TransientsCliff Seal
 
DrupalCamp Foz - Novas APIs Drupal 7
DrupalCamp Foz - Novas APIs Drupal 7DrupalCamp Foz - Novas APIs Drupal 7
DrupalCamp Foz - Novas APIs Drupal 7chuvainc
 
PHPSpec - the only Design Tool you need - 4Developers
PHPSpec - the only Design Tool you need - 4DevelopersPHPSpec - the only Design Tool you need - 4Developers
PHPSpec - the only Design Tool you need - 4DevelopersKacper Gunia
 
You Don't Know Query (WordCamp Netherlands 2012)
You Don't Know Query (WordCamp Netherlands 2012)You Don't Know Query (WordCamp Netherlands 2012)
You Don't Know Query (WordCamp Netherlands 2012)andrewnacin
 
Gail villanueva add muscle to your wordpress site
Gail villanueva   add muscle to your wordpress siteGail villanueva   add muscle to your wordpress site
Gail villanueva add muscle to your wordpress sitereferences
 
You code sucks, let's fix it
You code sucks, let's fix itYou code sucks, let's fix it
You code sucks, let's fix itRafael Dohms
 
How to Create Login and Registration API in PHP.pdf
How to Create Login and Registration API in PHP.pdfHow to Create Login and Registration API in PHP.pdf
How to Create Login and Registration API in PHP.pdfAppweb Coders
 

Similaire à WordPress as an application framework (20)

WordPress REST API hacking
WordPress REST API hackingWordPress REST API hacking
WordPress REST API hacking
 
laravel tricks in 50minutes
laravel tricks in 50minuteslaravel tricks in 50minutes
laravel tricks in 50minutes
 
Doctrine For Beginners
Doctrine For BeginnersDoctrine For Beginners
Doctrine For Beginners
 
WordPress Kitchen 2014 - Александр Стриха: Кеширование в WordPress
WordPress Kitchen 2014 - Александр Стриха: Кеширование в WordPress WordPress Kitchen 2014 - Александр Стриха: Кеширование в WordPress
WordPress Kitchen 2014 - Александр Стриха: Кеширование в WordPress
 
The Zen of Lithium
The Zen of LithiumThe Zen of Lithium
The Zen of Lithium
 
CakePHP workshop
CakePHP workshopCakePHP workshop
CakePHP workshop
 
Unit testing zend framework apps
Unit testing zend framework appsUnit testing zend framework apps
Unit testing zend framework apps
 
[WLDN] Supercharging word press development in 2018
[WLDN] Supercharging word press development in 2018[WLDN] Supercharging word press development in 2018
[WLDN] Supercharging word press development in 2018
 
Dependency Injection
Dependency InjectionDependency Injection
Dependency Injection
 
Introduction to Zend Framework web services
Introduction to Zend Framework web servicesIntroduction to Zend Framework web services
Introduction to Zend Framework web services
 
Как получить чёрный пояс по WordPress?
Как получить чёрный пояс по WordPress?Как получить чёрный пояс по WordPress?
Как получить чёрный пояс по WordPress?
 
Speed Things Up with Transients
Speed Things Up with TransientsSpeed Things Up with Transients
Speed Things Up with Transients
 
DrupalCamp Foz - Novas APIs Drupal 7
DrupalCamp Foz - Novas APIs Drupal 7DrupalCamp Foz - Novas APIs Drupal 7
DrupalCamp Foz - Novas APIs Drupal 7
 
PHPSpec - the only Design Tool you need - 4Developers
PHPSpec - the only Design Tool you need - 4DevelopersPHPSpec - the only Design Tool you need - 4Developers
PHPSpec - the only Design Tool you need - 4Developers
 
You Don't Know Query (WordCamp Netherlands 2012)
You Don't Know Query (WordCamp Netherlands 2012)You Don't Know Query (WordCamp Netherlands 2012)
You Don't Know Query (WordCamp Netherlands 2012)
 
Zend framework service
Zend framework serviceZend framework service
Zend framework service
 
Zend framework service
Zend framework serviceZend framework service
Zend framework service
 
Gail villanueva add muscle to your wordpress site
Gail villanueva   add muscle to your wordpress siteGail villanueva   add muscle to your wordpress site
Gail villanueva add muscle to your wordpress site
 
You code sucks, let's fix it
You code sucks, let's fix itYou code sucks, let's fix it
You code sucks, let's fix it
 
How to Create Login and Registration API in PHP.pdf
How to Create Login and Registration API in PHP.pdfHow to Create Login and Registration API in PHP.pdf
How to Create Login and Registration API in PHP.pdf
 

Dernier

Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...apidays
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAndrey Devyatkin
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobeapidays
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FMESafe Software
 
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
 
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
 
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...apidays
 
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Victor Rentea
 
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWEREMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWERMadyBayot
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProduct Anonymous
 
ICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesrafiqahmad00786416
 
Introduction to Multilingual Retrieval Augmented Generation (RAG)
Introduction to Multilingual Retrieval Augmented Generation (RAG)Introduction to Multilingual Retrieval Augmented Generation (RAG)
Introduction to Multilingual Retrieval Augmented Generation (RAG)Zilliz
 
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...Jeffrey Haguewood
 
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
 
Vector Search -An Introduction in Oracle Database 23ai.pptx
Vector Search -An Introduction in Oracle Database 23ai.pptxVector Search -An Introduction in Oracle Database 23ai.pptx
Vector Search -An Introduction in Oracle Database 23ai.pptxRemote DBA Services
 
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
 
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
 
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
 

Dernier (20)

Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of Terraform
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
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
 
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 New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
 
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
 
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWEREMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
+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...
 
ICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesICT role in 21st century education and its challenges
ICT role in 21st century education and its challenges
 
Introduction to Multilingual Retrieval Augmented Generation (RAG)
Introduction to Multilingual Retrieval Augmented Generation (RAG)Introduction to Multilingual Retrieval Augmented Generation (RAG)
Introduction to Multilingual Retrieval Augmented Generation (RAG)
 
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
 
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
 
Vector Search -An Introduction in Oracle Database 23ai.pptx
Vector Search -An Introduction in Oracle Database 23ai.pptxVector Search -An Introduction in Oracle Database 23ai.pptx
Vector Search -An Introduction in Oracle Database 23ai.pptx
 
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
 
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
 
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
 

WordPress as an application framework

  • 2.
  • 3.
  • 4.
  • 5. WWhat Makes a Framework Good? • Easy • Well Supported • Extensible
  • 9. A Real World Example Create a billing/invoicing system using WordPress! Think… FreshBooks
  • 10. “I need an easy, reusable way to store, access, and categorize structured data” Custom Post Types & Custom Taxonomies. function register_invoice() { $args = array( 'public' => true, 'label' => 'Invoices' ); register_post_type( 'invoice',$args ); } add_action(‘init','register_invoice'); function create_invoice_status() { register_taxonomy( 'status', 'invoice', array( 'label' => ‘Invoice Status', 'rewrite' => array( 'slug' => ‘invoice_status' ), 'hierarchical' => false, ) ); } add_action( 'init', ‘create_invoice_status' );
  • 11. “I need to store data related to my structured data and users.” Post Meta and User Meta. update_post_meta( $post_id, ‘purchase_order_number’, $value ); update_user_meta( $user_id, ‘job_title’, $value );
  • 12. “I need users to be able to access data and limit access to different users” Create users and assign roles and capabilities to access different parts of your application. Built-in User Management panel and ability to manipulate through your code. ADD A NEW ROLE add_role( ‘client', ‘Client', array( 'read' => true, 'edit_posts' => true, ) ); ADD A CAPABILITY TO THE ROLE $role = get_role( ‘client' ); $role->add_cap( ‘view_invoices’ ); RESTRICT ACTION if ( current_user_can( ‘view_invoices’ ) { // Do Something }
  • 13. “I need to create custom views for different types of data" Templating through WordPress Theme API. Allows you to define different templates for different types of content and views. BASIC WORDPRESS PAGE LOOP get_header(); if (have_posts()) : while (have_posts()) : the_post(); the_content(); endwhile; endif; get_sidebar(); get_footer(); TEMPLATE FILE NAMING single-invoices.php - Single Invoice View archive-invoices.php - Archive of Invoices LOADING CUSTOM TEMPLATES get_template_part( 'loop', 'index' ); will do a PHP require() for the first file that exists among these, in this priority: wp-content/themes/themename/loop- index.php wp-content/themes/themename/loop.php
  • 14. “I need to customize default actions of my app” WordPress has hooks for nearly everything that happens. Use ‘add_action’ to do execute custom code at a certain time. Use ‘add_filter’ to change default values. function email_invoice( $post_id ) { $to = ‘dusty@dustyf.com’; $subject = get_the_title( $post_id ); $message = get_the_permalink( $post_id ); wp_mail( $to, $subject, $message ); } add_action(‘save_post’,‘email_invoice’); function mod_title( $title, $post_id ) { if ( ‘invoice’ == get_post_type($post_id) && has_term( ‘paid’, ‘invoice_status’, $post_id ) { $title = ‘PAID: ‘ . $title; } return $title; } add_filter( ‘the title’, ‘mod_title’, 10, 2 );
  • 15. “I need easy, secure, access to the database” The wpdb class provides easy, secure database interaction for those times you need it. global $wpdb; $results = $wpdb->get_results( 'SELECT * FROM wp_options WHERE option_id = 1'); $wpdb->insert( ‘payments_made', array( 'client' => 'Apple', ‘invoice_num' => 123 ), array( '%s', '%d' ) ); // PROTECT FROM SQL INJECTION $metakey = ‘purchase_order_num’; $metavalue = ‘12345’; $wpdb->query( $wpdb->prepare( "INSERT INTO $wpdb->postmeta ( post_id, meta_key, meta_value ) VALUES ( %d, %s, %s )", 10, $metakey, $metavalue ) );
  • 16. “I need to have a reliable way to rewrite URLs” WordPress rewrites posts, pages, taxonomies, and custom post types by default. But, you can use the Rewrite API to make custom rules. function custom_rewrite() { add_rewrite_rule('^invoice/ ([0-9]+)/?', 'index.php?page_id=$matches[1]', 'top'); } add_action(‘init','custom_rewrite'); Now, you can access the same page as http://example.com/invoice/95
  • 17. “Different app instances for different users/ clients/ companies.” WordPress multisite allows you to create multiple site/ app instances. Each can share or have different functionality, views, settings, userbases, and more. Add the following to your wp-config.php and follow the instructions in wp-admin under Settings > Network Setup define( 'WP_ALLOW_MULTISITE', true ); Use Case: Each company using this invoice system can have their own instance at their own url… google.example.com or example.com/google
  • 18. “I need to be able to connect with third-party services” Built in HTTP API supports multiple transport methods for your HTTP requests because different hosting environments support different things. $response = wp_remote_post( $url, array( 'method' => 'POST', 'timeout' => 45, 'redirection' => 5, 'httpversion' => '1.0', 'blocking' => true, 'headers' => array(), 'body' => array( 'username' => 'bob', 'password' => '1234xyz' ), 'cookies' => array() ) ); $response returns a nice array AlSO: wp_remote_request() wp_remote_get() wp_remote_post() wp_remote_head() wp_remote_retrieve_body() wp_remote_retrieve_header() wp_remote_retrieve_headers() wp_remote_retrieve_response_code() wp_remote_retrieve_response_message()
  • 19. “I need to improve performance by limiting requests” Transients allow you quickly store data with an expiration for quick access. Get more in depth with caching plugins. set_transient( ‘special_query’, $special_query, 60*60*12 ); get_transient( 'special_query' ); //EXAMPLE if ( false === ( $special_query = get_transient( 'special_query' ) ) ) { $special_query_results = new WP_Query( 'cat=5&order=random&tag=tech&post_met a_key=thumbnail' ); set_transient( 'special_query', $special_query, 4 * HOUR_IN_SECONDS ); } - get_transient - set_transient - wp_cache_set - wp_cache_get
  • 20. “I need to be able to open my application to third parties” Create an API for your app using the XML-RPC API or the new JSON REST API JSON REST API will be in WP Core soon, but is now available in a stable plugin. Out of the box provides: • Endpoints for retrieving, creating, editing, and deleting all built-in post types and registered custom post types
 • Also, media, users, taxonomies and meta
 • Can be extended to support your other types of data
  • 21. “I don’t want to create things that have been done hundreds of times before” Thousands of WordPress Plugins both free and premium. Also, feel free to use other PHP Libraries. 35,000+ Free Plugins at wordpress.org/ plugins/ and many great premium plugins. BuddyPress - Social Network BBPress - Forums BadgeOS - Award Achievements CMB2 - Custom Fields and Metaboxes Gravity Forms - Form Building Posts 2 Posts - Relational post linking WooCommerce - eCommerce Events Calendar Pro - Calendar Or build your own to use over and over (or to share or sell!)
  • 22. MOAR
 EXAMPLES WordPress is being used as an application framework all over the web. Reactor by AppPresser (http://reactor.apppresser.com/) WP Powered application that builds mobile applications from your WP site. DesktopServer 4.0 (http://serverpress.com/) Desktop application to create local development sites. ManageWP (http://managewp.com/) Upgrade, perform backups, monitor, track statistics, and manage multiple WP sites. YMCA Y-MVP App (http://www.ymcanyc.org/association/ pages/y-mvp) iPad application used as a kiosk at YMCA to allow members to scan card and log exercise activities. Frito-Lay Project Management (http://liftux.com/portfolio/frito-lay- creative-project-management-app/) Custom project management app.
  • 23. Easy
  • 26. Go Forth & Create Apps Dustin Filippini dusty@dustyf.com @dustyf dustyf.com webdevstudios.com