SlideShare a Scribd company logo
Wordpress Develompent
A Modern Approach
Who am I ?
Backend Developer
@Populis
@whitekross on twitter
Alessandro Fiore
The most used PHP software
https://wordpress.org/download/counter/
24,5%(of the Web)
http://w3techs.com/technologies/overview/content_management/all
Innovator’s Dilemma ?
Wordpress, we have some problems
● Poor Core Codebase
● 3th Party Codebase even poorer
● Lack of standards
Use Better Tools!
Wordpress ❤ Composer
Custom Installers
At times it may be necessary for a
package to require additional actions
during installation, such as installing
packages outside of the default
vendor library.
{
"name": "my-vendor/my-lib-plugin",
"type": "my-lib-plugin",
"require": {
"my-vendor/my-lib-installer": "*"
}
}
ComposerInstallerInstallerInterface
interface InstallerInterface
{
//Decides if the installer supports the given type
public function supports($packageType);
//Checks that provided package is installed.
public function isInstalled(InstalledRepositoryInterface $repo, PackageInterface $package);
//Installs specific package.
public function install(InstalledRepositoryInterface $repo, PackageInterface $package);
//Updates specific package.
public function update(InstalledRepositoryInterface $repo, PackageInterface $initial, PackageInterface $target);
//Uninstalls specific package.
public function uninstall(InstalledRepositoryInterface $repo, PackageInterface $package);
//Returns the installation path of a package
public function getInstallPath(PackageInterface $package);
}
A basic Installer Plugin
1. The package file: composer.json
2. The Plugin class, e.g.: MyProjectComposerPlugin.php, implements
ComposerPluginPluginInterface.
3. The Installer class, e.g.: MyProjectComposerInstaller.php, implements
ComposerInstallerInstallerInterface.
Wordpress Core itself is a dependency
2) johnpbloch/wordpress
A fork of WordPress with Composer support added. Synced every 15
minutes.
1) johnpbloch/wordpress-core-installer
A custom installer to handle deploying WordPress with composer.
Wordpress Core itself is a dependency
use ComposerInstallerLibraryInstaller;
use ComposerPackagePackageInterface;
class WordPressCoreInstaller extends LibraryInstaller {
const TYPE = 'wordpress-core';
public function getInstallPath( PackageInterface $package ) {
$extra = $package->getExtra();
if ( ! $installationDir && ! empty( $extra['wordpress-install-dir'] ) ) {
$installationDir = $extra['wordpress-install-dir'];
}
return $installationDir;
}
public function supports( $packageType ) {
return self::TYPE === $packageType;
}
}
Wordpress Core itself is a dependency
"require": {
"johnpbloch/wordpress": "4.3.1"
},
"extra": {
"wordpress-install-dir": "wp"
},
Manage Plugins with Composer
composer/installers
A Multi-Framework Composer Library Installer. It will magically install their package to the
correct location based on the specified package type.
● wordpress-plugin => wp-content/plugins/{$name}
● wordpress-theme => wp-content/themes/{$name}
● wordpress-muplugin => wp-content/mu-plugins/{$name}
Manage Plugins with Composer
"extra": {
"installer-paths": {
"src/mu-plugins/{$name}/": ["type:wordpress-muplugin"],
"src/plugins/{$name}/": ["type:wordpress-plugin"],
"src/themes/{$name}/": ["type:wordpress-theme"]
},
}
Manage Plugins with Composer
Limited to plugins that already have a
composer.json.
What about 3th party plugins from
https://wordpress.org/plugins/ ?
Wordpress Packagist
Mirrors the WordPress Plugin and
Theme directories as a Composer
repository.
Manage Plugins with Composer
"repositories":[{
"type":"composer",
"url":"http://wpackagist.org"
}
],
"require": {
"aws/aws-sdk-php":"*",
"wpackagist-plugin/akismet":"dev",
"wpackagist-plugin/captcha":"3.9",
"wpackagist-theme/hueman":"*"
},
Wordpress ❤ Composer
├── composer.json
├── composer.lock
├── index.php
├── src/
├── vendor/
└── wp/
├── index.php
├── wp-activate.php
├── wp-admin/
├── wp-blog-header.php
├── wp-comments-post.php
├── wp-config.php
├── wp-content/
├── wp-cron.php
├── wp-includes/
├── wp-links-opml.php
├── wp-load.php
├── wp-login.php
├── wp-mail.php
├── wp-settings.php
├── wp-signup.php
├── wp-trackback.php
└── xmlrpc.php
Change WP Directory Structure
// INDEX.php (under our new webroot)
/** Loads the WordPress Environment and Template */
require( dirname( __FILE__ ) . '/wp/wp-blog-header.php' );
/** Change Content dir */
define( 'WP_CONTENT_DIR', dirname(__FILE__) . '/../src' );
define( 'WP_CONTENT_URL', 'http://<domain>//src' );
// WP_CONFIG.php
/** Change WORDPRESS url */
define( 'WP_SITEURL','http://<domain>/wp');
define( 'WP_HOME','http://<domain>/');
A CLI for Wordpress
composer require wp-cli/wp-cli
WP-CLI is a set of command-line tools for managing WordPress installations.
Run Commands with WP-CLI
wp <command> <sub-command> <params>
● core: Download, install, update, manage WordPress.
● db: Perform basic database operations.
● plugin: Manage, install, activate, deactivate plugins.
● post: Manage, generate, publish posts.
● scaffold: Generate code for post types, plugins, etc.
● and many more... http://wp-cli.org/commands/
Wordpress Automated Testing
Official test suite repository.
https://develop.svn.wordpress.org/trunk/
Time: 4.58 minutes, Memory: 97.75Mb
There was 1 failure:
FAILURES!
Tests: 4251, Assertions: 15938, Failures: 1, Skipped: 65.
https://make.wordpress.org/core/handbook/testing/automated-testing/
Test Your Plugins!
$ wp scaffold plugin test_plugin
├──bin/
│ └──install-wp-tests.sh
├──phpunit.xml
├──test_plugin.php
└──tests/
├──bootstrap.php
└──test-sample.php
└──.travis.yml
// This will install WP test suite
// under “/tmp/wordpress”
$ bash bin/install-wp-tests.sh wordpress_test root ''
Test Your Plugins!
class FooTest extends WP_UnitTestCase
{
function test_bar() {
// replace this your test
$this->assertTrue( true );
}
}
● Object Factories:
$this->factory->post->create();
● Custom Asserts:
$response = wp_remote_get( $url );
$this->assertWPError( $response );
$this->assertQueryTrue( 'is_tag', 'is_archive' );
● Useful Methods:
setUp() | tearDown() | go_to() |
remove_added_uploads() ecc..
Grazie!
Code Samples:
● https://github.com/whitekross/wp-composer
● https://github.com/whitekross/wp-badge-poser
Useful Links:
● https://roots.io/bedrock/
● http://composer.rarst.net/
● http://codesymphony.co/writing-wordpress-plugin-unit-tests/

More Related Content

What's hot

Die .htaccess richtig nutzen
Die .htaccess richtig nutzenDie .htaccess richtig nutzen
Die .htaccess richtig nutzen
Walter Ebert
 
DevHub 3 - Composer plus Magento
DevHub 3 - Composer plus MagentoDevHub 3 - Composer plus Magento
DevHub 3 - Composer plus MagentoMagento Dev
 
WordPress Theme & Plugin development best practices - phpXperts seminar 2011
WordPress Theme & Plugin development best practices - phpXperts seminar 2011WordPress Theme & Plugin development best practices - phpXperts seminar 2011
WordPress Theme & Plugin development best practices - phpXperts seminar 2011
Tareq Hasan
 
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
 
Dependency management in Magento with Composer
Dependency management in Magento with ComposerDependency management in Magento with Composer
Dependency management in Magento with Composer
Manuele Menozzi
 
HTTPS + Let's Encrypt
HTTPS + Let's EncryptHTTPS + Let's Encrypt
HTTPS + Let's Encrypt
Walter Ebert
 
How to develope plugin in wordpress: 6 simple steps.
How to develope plugin in wordpress: 6 simple steps.How to develope plugin in wordpress: 6 simple steps.
How to develope plugin in wordpress: 6 simple steps.
Jay Bharat
 
The wp config.php
The wp config.phpThe wp config.php
The wp config.php
Anthony Montalbano
 
Creating Your First WordPress Plugin
Creating Your First WordPress PluginCreating Your First WordPress Plugin
Creating Your First WordPress Plugin
Brad Williams
 
Intro to WordPress Plugin Development
Intro to WordPress Plugin DevelopmentIntro to WordPress Plugin Development
Intro to WordPress Plugin Development
Brad Williams
 
Getting started with WordPress development
Getting started with WordPress developmentGetting started with WordPress development
Getting started with WordPress development
Steve Mortiboy
 
Nahlédněte za oponu VersionPressu
Nahlédněte za oponu VersionPressuNahlédněte za oponu VersionPressu
Nahlédněte za oponu VersionPressu
Jan Voracek
 
Mastering WordPress Vol.1
Mastering WordPress Vol.1Mastering WordPress Vol.1
Mastering WordPress Vol.1
Wataru OKAMOTO
 
Using composer with WordPress
Using composer with WordPressUsing composer with WordPress
Using composer with WordPress
Micah Wood
 
Webinar: 5 Tricks for WordPress web administrators
Webinar: 5 Tricks for WordPress web administratorsWebinar: 5 Tricks for WordPress web administrators
Webinar: 5 Tricks for WordPress web administrators
Tomasz Dziuda
 
WordPress Structure and Best Practices
WordPress Structure and Best PracticesWordPress Structure and Best Practices
WordPress Structure and Best Practices
markparolisi
 
PHP SA 2014 - Releasing Your Open Source Project
PHP SA 2014 - Releasing Your Open Source ProjectPHP SA 2014 - Releasing Your Open Source Project
PHP SA 2014 - Releasing Your Open Source Project
xsist10
 
WordPress Realtime - WordCamp São Paulo 2015
WordPress Realtime - WordCamp São Paulo 2015WordPress Realtime - WordCamp São Paulo 2015
WordPress Realtime - WordCamp São Paulo 2015
Fernando Daciuk
 
Why it's dangerous to turn off automatic updates and here's how to do it
Why it's dangerous to turn off automatic updates and here's how to do itWhy it's dangerous to turn off automatic updates and here's how to do it
Why it's dangerous to turn off automatic updates and here's how to do it
Onni Hakala
 
Drupal Development Tips
Drupal Development TipsDrupal Development Tips
Drupal Development Tips
Chris Tankersley
 

What's hot (20)

Die .htaccess richtig nutzen
Die .htaccess richtig nutzenDie .htaccess richtig nutzen
Die .htaccess richtig nutzen
 
DevHub 3 - Composer plus Magento
DevHub 3 - Composer plus MagentoDevHub 3 - Composer plus Magento
DevHub 3 - Composer plus Magento
 
WordPress Theme & Plugin development best practices - phpXperts seminar 2011
WordPress Theme & Plugin development best practices - phpXperts seminar 2011WordPress Theme & Plugin development best practices - phpXperts seminar 2011
WordPress Theme & Plugin development best practices - phpXperts seminar 2011
 
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
 
Dependency management in Magento with Composer
Dependency management in Magento with ComposerDependency management in Magento with Composer
Dependency management in Magento with Composer
 
HTTPS + Let's Encrypt
HTTPS + Let's EncryptHTTPS + Let's Encrypt
HTTPS + Let's Encrypt
 
How to develope plugin in wordpress: 6 simple steps.
How to develope plugin in wordpress: 6 simple steps.How to develope plugin in wordpress: 6 simple steps.
How to develope plugin in wordpress: 6 simple steps.
 
The wp config.php
The wp config.phpThe wp config.php
The wp config.php
 
Creating Your First WordPress Plugin
Creating Your First WordPress PluginCreating Your First WordPress Plugin
Creating Your First WordPress Plugin
 
Intro to WordPress Plugin Development
Intro to WordPress Plugin DevelopmentIntro to WordPress Plugin Development
Intro to WordPress Plugin Development
 
Getting started with WordPress development
Getting started with WordPress developmentGetting started with WordPress development
Getting started with WordPress development
 
Nahlédněte za oponu VersionPressu
Nahlédněte za oponu VersionPressuNahlédněte za oponu VersionPressu
Nahlédněte za oponu VersionPressu
 
Mastering WordPress Vol.1
Mastering WordPress Vol.1Mastering WordPress Vol.1
Mastering WordPress Vol.1
 
Using composer with WordPress
Using composer with WordPressUsing composer with WordPress
Using composer with WordPress
 
Webinar: 5 Tricks for WordPress web administrators
Webinar: 5 Tricks for WordPress web administratorsWebinar: 5 Tricks for WordPress web administrators
Webinar: 5 Tricks for WordPress web administrators
 
WordPress Structure and Best Practices
WordPress Structure and Best PracticesWordPress Structure and Best Practices
WordPress Structure and Best Practices
 
PHP SA 2014 - Releasing Your Open Source Project
PHP SA 2014 - Releasing Your Open Source ProjectPHP SA 2014 - Releasing Your Open Source Project
PHP SA 2014 - Releasing Your Open Source Project
 
WordPress Realtime - WordCamp São Paulo 2015
WordPress Realtime - WordCamp São Paulo 2015WordPress Realtime - WordCamp São Paulo 2015
WordPress Realtime - WordCamp São Paulo 2015
 
Why it's dangerous to turn off automatic updates and here's how to do it
Why it's dangerous to turn off automatic updates and here's how to do itWhy it's dangerous to turn off automatic updates and here's how to do it
Why it's dangerous to turn off automatic updates and here's how to do it
 
Drupal Development Tips
Drupal Development TipsDrupal Development Tips
Drupal Development Tips
 

Similar to Wordpress development: A Modern Approach

WordPress Plugin Development- Rich Media Institute Workshop
WordPress Plugin Development- Rich Media Institute WorkshopWordPress Plugin Development- Rich Media Institute Workshop
WordPress Plugin Development- Rich Media Institute Workshop
Brendan Sera-Shriar
 
Making the Most of Plug-ins - WordCamp Toronto 2008
Making the Most of Plug-ins - WordCamp Toronto 2008Making the Most of Plug-ins - WordCamp Toronto 2008
Making the Most of Plug-ins - WordCamp Toronto 2008
Brendan Sera-Shriar
 
Composer
ComposerComposer
Vagrant WordCamp Hamilton
Vagrant  WordCamp HamiltonVagrant  WordCamp Hamilton
Vagrant WordCamp Hamilton
Paul Bearne
 
Take Command of WordPress With WP-CLI at WordCamp Long Beach
Take Command of WordPress With WP-CLI at WordCamp Long BeachTake Command of WordPress With WP-CLI at WordCamp Long Beach
Take Command of WordPress With WP-CLI at WordCamp Long Beach
Diana Thompson
 
Beginning WordPress Plugin Development
Beginning WordPress Plugin DevelopmentBeginning WordPress Plugin Development
Beginning WordPress Plugin Development
Aizat Faiz
 
PHP Dependency Management with Composer
PHP Dependency Management with ComposerPHP Dependency Management with Composer
PHP Dependency Management with Composer
Adam Englander
 
Take Command of WordPress With WP-CLI
Take Command of WordPress With WP-CLITake Command of WordPress With WP-CLI
Take Command of WordPress With WP-CLI
Diana Thompson
 
Take Command of WordPress With WP-CLI
Take Command of WordPress With WP-CLITake Command of WordPress With WP-CLI
Take Command of WordPress With WP-CLI
Diana Thompson
 
Managing a WordPress Site as a Composer Project by Rahul Bansal @ WordCamp Na...
Managing a WordPress Site as a Composer Project by Rahul Bansal @ WordCamp Na...Managing a WordPress Site as a Composer Project by Rahul Bansal @ WordCamp Na...
Managing a WordPress Site as a Composer Project by Rahul Bansal @ WordCamp Na...
rtCamp
 
Using Composer to create manageable WordPress websites
Using Composer to create manageable WordPress websitesUsing Composer to create manageable WordPress websites
Using Composer to create manageable WordPress websites
Anna Ladoshkina
 
Composer
ComposerComposer
Composer
Tom Corrigan
 
Web development automatisation for fun and profit (Artem Daniliants)
Web development automatisation for fun and profit (Artem Daniliants)Web development automatisation for fun and profit (Artem Daniliants)
Web development automatisation for fun and profit (Artem Daniliants)
LumoSpark
 
WordPress Plugin Development 201
WordPress Plugin Development 201WordPress Plugin Development 201
WordPress Plugin Development 201ylefebvre
 
WordPress Plugin development
WordPress Plugin developmentWordPress Plugin development
WordPress Plugin development
Mostafa Soufi
 
Composer & Drupal
Composer & DrupalComposer & Drupal
Composer & Drupal
drubb
 
Deploying WP Multisite to Heroku
Deploying WP Multisite to HerokuDeploying WP Multisite to Heroku
Deploying WP Multisite to Heroku
Jussi Kinnula
 
CICON2010: Adam Griffiths - CodeIgniter 2
CICON2010: Adam Griffiths - CodeIgniter 2CICON2010: Adam Griffiths - CodeIgniter 2
CICON2010: Adam Griffiths - CodeIgniter 2
CodeIgniter Conference
 
Using Composer with Drupal and Drush
Using Composer with Drupal and DrushUsing Composer with Drupal and Drush
Using Composer with Drupal and Drush
Pantheon
 

Similar to Wordpress development: A Modern Approach (20)

WordPress Plugin Development- Rich Media Institute Workshop
WordPress Plugin Development- Rich Media Institute WorkshopWordPress Plugin Development- Rich Media Institute Workshop
WordPress Plugin Development- Rich Media Institute Workshop
 
Making the Most of Plug-ins - WordCamp Toronto 2008
Making the Most of Plug-ins - WordCamp Toronto 2008Making the Most of Plug-ins - WordCamp Toronto 2008
Making the Most of Plug-ins - WordCamp Toronto 2008
 
Composer
ComposerComposer
Composer
 
Vagrant WordCamp Hamilton
Vagrant  WordCamp HamiltonVagrant  WordCamp Hamilton
Vagrant WordCamp Hamilton
 
Take Command of WordPress With WP-CLI at WordCamp Long Beach
Take Command of WordPress With WP-CLI at WordCamp Long BeachTake Command of WordPress With WP-CLI at WordCamp Long Beach
Take Command of WordPress With WP-CLI at WordCamp Long Beach
 
Beginning WordPress Plugin Development
Beginning WordPress Plugin DevelopmentBeginning WordPress Plugin Development
Beginning WordPress Plugin Development
 
PHP Dependency Management with Composer
PHP Dependency Management with ComposerPHP Dependency Management with Composer
PHP Dependency Management with Composer
 
Take Command of WordPress With WP-CLI
Take Command of WordPress With WP-CLITake Command of WordPress With WP-CLI
Take Command of WordPress With WP-CLI
 
Take Command of WordPress With WP-CLI
Take Command of WordPress With WP-CLITake Command of WordPress With WP-CLI
Take Command of WordPress With WP-CLI
 
Managing a WordPress Site as a Composer Project by Rahul Bansal @ WordCamp Na...
Managing a WordPress Site as a Composer Project by Rahul Bansal @ WordCamp Na...Managing a WordPress Site as a Composer Project by Rahul Bansal @ WordCamp Na...
Managing a WordPress Site as a Composer Project by Rahul Bansal @ WordCamp Na...
 
WPDay Bologna 2013
WPDay Bologna 2013WPDay Bologna 2013
WPDay Bologna 2013
 
Using Composer to create manageable WordPress websites
Using Composer to create manageable WordPress websitesUsing Composer to create manageable WordPress websites
Using Composer to create manageable WordPress websites
 
Composer
ComposerComposer
Composer
 
Web development automatisation for fun and profit (Artem Daniliants)
Web development automatisation for fun and profit (Artem Daniliants)Web development automatisation for fun and profit (Artem Daniliants)
Web development automatisation for fun and profit (Artem Daniliants)
 
WordPress Plugin Development 201
WordPress Plugin Development 201WordPress Plugin Development 201
WordPress Plugin Development 201
 
WordPress Plugin development
WordPress Plugin developmentWordPress Plugin development
WordPress Plugin development
 
Composer & Drupal
Composer & DrupalComposer & Drupal
Composer & Drupal
 
Deploying WP Multisite to Heroku
Deploying WP Multisite to HerokuDeploying WP Multisite to Heroku
Deploying WP Multisite to Heroku
 
CICON2010: Adam Griffiths - CodeIgniter 2
CICON2010: Adam Griffiths - CodeIgniter 2CICON2010: Adam Griffiths - CodeIgniter 2
CICON2010: Adam Griffiths - CodeIgniter 2
 
Using Composer with Drupal and Drush
Using Composer with Drupal and DrushUsing Composer with Drupal and Drush
Using Composer with Drupal and Drush
 

Recently uploaded

Advanced Flow Concepts Every Developer Should Know
Advanced Flow Concepts Every Developer Should KnowAdvanced Flow Concepts Every Developer Should Know
Advanced Flow Concepts Every Developer Should Know
Peter Caitens
 
Field Employee Tracking System| MiTrack App| Best Employee Tracking Solution|...
Field Employee Tracking System| MiTrack App| Best Employee Tracking Solution|...Field Employee Tracking System| MiTrack App| Best Employee Tracking Solution|...
Field Employee Tracking System| MiTrack App| Best Employee Tracking Solution|...
informapgpstrackings
 
TROUBLESHOOTING 9 TYPES OF OUTOFMEMORYERROR
TROUBLESHOOTING 9 TYPES OF OUTOFMEMORYERRORTROUBLESHOOTING 9 TYPES OF OUTOFMEMORYERROR
TROUBLESHOOTING 9 TYPES OF OUTOFMEMORYERROR
Tier1 app
 
BoxLang: Review our Visionary Licenses of 2024
BoxLang: Review our Visionary Licenses of 2024BoxLang: Review our Visionary Licenses of 2024
BoxLang: Review our Visionary Licenses of 2024
Ortus Solutions, Corp
 
Into the Box 2024 - Keynote Day 2 Slides.pdf
Into the Box 2024 - Keynote Day 2 Slides.pdfInto the Box 2024 - Keynote Day 2 Slides.pdf
Into the Box 2024 - Keynote Day 2 Slides.pdf
Ortus Solutions, Corp
 
Explore Modern SharePoint Templates for 2024
Explore Modern SharePoint Templates for 2024Explore Modern SharePoint Templates for 2024
Explore Modern SharePoint Templates for 2024
Sharepoint Designs
 
Innovating Inference - Remote Triggering of Large Language Models on HPC Clus...
Innovating Inference - Remote Triggering of Large Language Models on HPC Clus...Innovating Inference - Remote Triggering of Large Language Models on HPC Clus...
Innovating Inference - Remote Triggering of Large Language Models on HPC Clus...
Globus
 
Vitthal Shirke Microservices Resume Montevideo
Vitthal Shirke Microservices Resume MontevideoVitthal Shirke Microservices Resume Montevideo
Vitthal Shirke Microservices Resume Montevideo
Vitthal Shirke
 
Globus Compute wth IRI Workflows - GlobusWorld 2024
Globus Compute wth IRI Workflows - GlobusWorld 2024Globus Compute wth IRI Workflows - GlobusWorld 2024
Globus Compute wth IRI Workflows - GlobusWorld 2024
Globus
 
How Does XfilesPro Ensure Security While Sharing Documents in Salesforce?
How Does XfilesPro Ensure Security While Sharing Documents in Salesforce?How Does XfilesPro Ensure Security While Sharing Documents in Salesforce?
How Does XfilesPro Ensure Security While Sharing Documents in Salesforce?
XfilesPro
 
Exploring Innovations in Data Repository Solutions - Insights from the U.S. G...
Exploring Innovations in Data Repository Solutions - Insights from the U.S. G...Exploring Innovations in Data Repository Solutions - Insights from the U.S. G...
Exploring Innovations in Data Repository Solutions - Insights from the U.S. G...
Globus
 
Understanding Globus Data Transfers with NetSage
Understanding Globus Data Transfers with NetSageUnderstanding Globus Data Transfers with NetSage
Understanding Globus Data Transfers with NetSage
Globus
 
Globus Compute Introduction - GlobusWorld 2024
Globus Compute Introduction - GlobusWorld 2024Globus Compute Introduction - GlobusWorld 2024
Globus Compute Introduction - GlobusWorld 2024
Globus
 
SOCRadar Research Team: Latest Activities of IntelBroker
SOCRadar Research Team: Latest Activities of IntelBrokerSOCRadar Research Team: Latest Activities of IntelBroker
SOCRadar Research Team: Latest Activities of IntelBroker
SOCRadar
 
Dominate Social Media with TubeTrivia AI’s Addictive Quiz Videos.pdf
Dominate Social Media with TubeTrivia AI’s Addictive Quiz Videos.pdfDominate Social Media with TubeTrivia AI’s Addictive Quiz Videos.pdf
Dominate Social Media with TubeTrivia AI’s Addictive Quiz Videos.pdf
AMB-Review
 
Climate Science Flows: Enabling Petabyte-Scale Climate Analysis with the Eart...
Climate Science Flows: Enabling Petabyte-Scale Climate Analysis with the Eart...Climate Science Flows: Enabling Petabyte-Scale Climate Analysis with the Eart...
Climate Science Flows: Enabling Petabyte-Scale Climate Analysis with the Eart...
Globus
 
Providing Globus Services to Users of JASMIN for Environmental Data Analysis
Providing Globus Services to Users of JASMIN for Environmental Data AnalysisProviding Globus Services to Users of JASMIN for Environmental Data Analysis
Providing Globus Services to Users of JASMIN for Environmental Data Analysis
Globus
 
Gamify Your Mind; The Secret Sauce to Delivering Success, Continuously Improv...
Gamify Your Mind; The Secret Sauce to Delivering Success, Continuously Improv...Gamify Your Mind; The Secret Sauce to Delivering Success, Continuously Improv...
Gamify Your Mind; The Secret Sauce to Delivering Success, Continuously Improv...
Shahin Sheidaei
 
Large Language Models and the End of Programming
Large Language Models and the End of ProgrammingLarge Language Models and the End of Programming
Large Language Models and the End of Programming
Matt Welsh
 
Lecture 1 Introduction to games development
Lecture 1 Introduction to games developmentLecture 1 Introduction to games development
Lecture 1 Introduction to games development
abdulrafaychaudhry
 

Recently uploaded (20)

Advanced Flow Concepts Every Developer Should Know
Advanced Flow Concepts Every Developer Should KnowAdvanced Flow Concepts Every Developer Should Know
Advanced Flow Concepts Every Developer Should Know
 
Field Employee Tracking System| MiTrack App| Best Employee Tracking Solution|...
Field Employee Tracking System| MiTrack App| Best Employee Tracking Solution|...Field Employee Tracking System| MiTrack App| Best Employee Tracking Solution|...
Field Employee Tracking System| MiTrack App| Best Employee Tracking Solution|...
 
TROUBLESHOOTING 9 TYPES OF OUTOFMEMORYERROR
TROUBLESHOOTING 9 TYPES OF OUTOFMEMORYERRORTROUBLESHOOTING 9 TYPES OF OUTOFMEMORYERROR
TROUBLESHOOTING 9 TYPES OF OUTOFMEMORYERROR
 
BoxLang: Review our Visionary Licenses of 2024
BoxLang: Review our Visionary Licenses of 2024BoxLang: Review our Visionary Licenses of 2024
BoxLang: Review our Visionary Licenses of 2024
 
Into the Box 2024 - Keynote Day 2 Slides.pdf
Into the Box 2024 - Keynote Day 2 Slides.pdfInto the Box 2024 - Keynote Day 2 Slides.pdf
Into the Box 2024 - Keynote Day 2 Slides.pdf
 
Explore Modern SharePoint Templates for 2024
Explore Modern SharePoint Templates for 2024Explore Modern SharePoint Templates for 2024
Explore Modern SharePoint Templates for 2024
 
Innovating Inference - Remote Triggering of Large Language Models on HPC Clus...
Innovating Inference - Remote Triggering of Large Language Models on HPC Clus...Innovating Inference - Remote Triggering of Large Language Models on HPC Clus...
Innovating Inference - Remote Triggering of Large Language Models on HPC Clus...
 
Vitthal Shirke Microservices Resume Montevideo
Vitthal Shirke Microservices Resume MontevideoVitthal Shirke Microservices Resume Montevideo
Vitthal Shirke Microservices Resume Montevideo
 
Globus Compute wth IRI Workflows - GlobusWorld 2024
Globus Compute wth IRI Workflows - GlobusWorld 2024Globus Compute wth IRI Workflows - GlobusWorld 2024
Globus Compute wth IRI Workflows - GlobusWorld 2024
 
How Does XfilesPro Ensure Security While Sharing Documents in Salesforce?
How Does XfilesPro Ensure Security While Sharing Documents in Salesforce?How Does XfilesPro Ensure Security While Sharing Documents in Salesforce?
How Does XfilesPro Ensure Security While Sharing Documents in Salesforce?
 
Exploring Innovations in Data Repository Solutions - Insights from the U.S. G...
Exploring Innovations in Data Repository Solutions - Insights from the U.S. G...Exploring Innovations in Data Repository Solutions - Insights from the U.S. G...
Exploring Innovations in Data Repository Solutions - Insights from the U.S. G...
 
Understanding Globus Data Transfers with NetSage
Understanding Globus Data Transfers with NetSageUnderstanding Globus Data Transfers with NetSage
Understanding Globus Data Transfers with NetSage
 
Globus Compute Introduction - GlobusWorld 2024
Globus Compute Introduction - GlobusWorld 2024Globus Compute Introduction - GlobusWorld 2024
Globus Compute Introduction - GlobusWorld 2024
 
SOCRadar Research Team: Latest Activities of IntelBroker
SOCRadar Research Team: Latest Activities of IntelBrokerSOCRadar Research Team: Latest Activities of IntelBroker
SOCRadar Research Team: Latest Activities of IntelBroker
 
Dominate Social Media with TubeTrivia AI’s Addictive Quiz Videos.pdf
Dominate Social Media with TubeTrivia AI’s Addictive Quiz Videos.pdfDominate Social Media with TubeTrivia AI’s Addictive Quiz Videos.pdf
Dominate Social Media with TubeTrivia AI’s Addictive Quiz Videos.pdf
 
Climate Science Flows: Enabling Petabyte-Scale Climate Analysis with the Eart...
Climate Science Flows: Enabling Petabyte-Scale Climate Analysis with the Eart...Climate Science Flows: Enabling Petabyte-Scale Climate Analysis with the Eart...
Climate Science Flows: Enabling Petabyte-Scale Climate Analysis with the Eart...
 
Providing Globus Services to Users of JASMIN for Environmental Data Analysis
Providing Globus Services to Users of JASMIN for Environmental Data AnalysisProviding Globus Services to Users of JASMIN for Environmental Data Analysis
Providing Globus Services to Users of JASMIN for Environmental Data Analysis
 
Gamify Your Mind; The Secret Sauce to Delivering Success, Continuously Improv...
Gamify Your Mind; The Secret Sauce to Delivering Success, Continuously Improv...Gamify Your Mind; The Secret Sauce to Delivering Success, Continuously Improv...
Gamify Your Mind; The Secret Sauce to Delivering Success, Continuously Improv...
 
Large Language Models and the End of Programming
Large Language Models and the End of ProgrammingLarge Language Models and the End of Programming
Large Language Models and the End of Programming
 
Lecture 1 Introduction to games development
Lecture 1 Introduction to games developmentLecture 1 Introduction to games development
Lecture 1 Introduction to games development
 

Wordpress development: A Modern Approach

  • 2. Who am I ? Backend Developer @Populis @whitekross on twitter Alessandro Fiore
  • 3. The most used PHP software https://wordpress.org/download/counter/
  • 6.
  • 7. Wordpress, we have some problems ● Poor Core Codebase ● 3th Party Codebase even poorer ● Lack of standards
  • 9. Wordpress ❤ Composer Custom Installers At times it may be necessary for a package to require additional actions during installation, such as installing packages outside of the default vendor library. { "name": "my-vendor/my-lib-plugin", "type": "my-lib-plugin", "require": { "my-vendor/my-lib-installer": "*" } }
  • 10. ComposerInstallerInstallerInterface interface InstallerInterface { //Decides if the installer supports the given type public function supports($packageType); //Checks that provided package is installed. public function isInstalled(InstalledRepositoryInterface $repo, PackageInterface $package); //Installs specific package. public function install(InstalledRepositoryInterface $repo, PackageInterface $package); //Updates specific package. public function update(InstalledRepositoryInterface $repo, PackageInterface $initial, PackageInterface $target); //Uninstalls specific package. public function uninstall(InstalledRepositoryInterface $repo, PackageInterface $package); //Returns the installation path of a package public function getInstallPath(PackageInterface $package); }
  • 11. A basic Installer Plugin 1. The package file: composer.json 2. The Plugin class, e.g.: MyProjectComposerPlugin.php, implements ComposerPluginPluginInterface. 3. The Installer class, e.g.: MyProjectComposerInstaller.php, implements ComposerInstallerInstallerInterface.
  • 12. Wordpress Core itself is a dependency 2) johnpbloch/wordpress A fork of WordPress with Composer support added. Synced every 15 minutes. 1) johnpbloch/wordpress-core-installer A custom installer to handle deploying WordPress with composer.
  • 13. Wordpress Core itself is a dependency use ComposerInstallerLibraryInstaller; use ComposerPackagePackageInterface; class WordPressCoreInstaller extends LibraryInstaller { const TYPE = 'wordpress-core'; public function getInstallPath( PackageInterface $package ) { $extra = $package->getExtra(); if ( ! $installationDir && ! empty( $extra['wordpress-install-dir'] ) ) { $installationDir = $extra['wordpress-install-dir']; } return $installationDir; } public function supports( $packageType ) { return self::TYPE === $packageType; } }
  • 14. Wordpress Core itself is a dependency "require": { "johnpbloch/wordpress": "4.3.1" }, "extra": { "wordpress-install-dir": "wp" },
  • 15. Manage Plugins with Composer composer/installers A Multi-Framework Composer Library Installer. It will magically install their package to the correct location based on the specified package type. ● wordpress-plugin => wp-content/plugins/{$name} ● wordpress-theme => wp-content/themes/{$name} ● wordpress-muplugin => wp-content/mu-plugins/{$name}
  • 16. Manage Plugins with Composer "extra": { "installer-paths": { "src/mu-plugins/{$name}/": ["type:wordpress-muplugin"], "src/plugins/{$name}/": ["type:wordpress-plugin"], "src/themes/{$name}/": ["type:wordpress-theme"] }, }
  • 17. Manage Plugins with Composer Limited to plugins that already have a composer.json. What about 3th party plugins from https://wordpress.org/plugins/ ? Wordpress Packagist Mirrors the WordPress Plugin and Theme directories as a Composer repository.
  • 18. Manage Plugins with Composer "repositories":[{ "type":"composer", "url":"http://wpackagist.org" } ], "require": { "aws/aws-sdk-php":"*", "wpackagist-plugin/akismet":"dev", "wpackagist-plugin/captcha":"3.9", "wpackagist-theme/hueman":"*" },
  • 19. Wordpress ❤ Composer ├── composer.json ├── composer.lock ├── index.php ├── src/ ├── vendor/ └── wp/ ├── index.php ├── wp-activate.php ├── wp-admin/ ├── wp-blog-header.php ├── wp-comments-post.php ├── wp-config.php ├── wp-content/ ├── wp-cron.php ├── wp-includes/ ├── wp-links-opml.php ├── wp-load.php ├── wp-login.php ├── wp-mail.php ├── wp-settings.php ├── wp-signup.php ├── wp-trackback.php └── xmlrpc.php
  • 20. Change WP Directory Structure // INDEX.php (under our new webroot) /** Loads the WordPress Environment and Template */ require( dirname( __FILE__ ) . '/wp/wp-blog-header.php' ); /** Change Content dir */ define( 'WP_CONTENT_DIR', dirname(__FILE__) . '/../src' ); define( 'WP_CONTENT_URL', 'http://<domain>//src' ); // WP_CONFIG.php /** Change WORDPRESS url */ define( 'WP_SITEURL','http://<domain>/wp'); define( 'WP_HOME','http://<domain>/');
  • 21. A CLI for Wordpress composer require wp-cli/wp-cli WP-CLI is a set of command-line tools for managing WordPress installations.
  • 22. Run Commands with WP-CLI wp <command> <sub-command> <params> ● core: Download, install, update, manage WordPress. ● db: Perform basic database operations. ● plugin: Manage, install, activate, deactivate plugins. ● post: Manage, generate, publish posts. ● scaffold: Generate code for post types, plugins, etc. ● and many more... http://wp-cli.org/commands/
  • 23. Wordpress Automated Testing Official test suite repository. https://develop.svn.wordpress.org/trunk/ Time: 4.58 minutes, Memory: 97.75Mb There was 1 failure: FAILURES! Tests: 4251, Assertions: 15938, Failures: 1, Skipped: 65. https://make.wordpress.org/core/handbook/testing/automated-testing/
  • 24. Test Your Plugins! $ wp scaffold plugin test_plugin ├──bin/ │ └──install-wp-tests.sh ├──phpunit.xml ├──test_plugin.php └──tests/ ├──bootstrap.php └──test-sample.php └──.travis.yml // This will install WP test suite // under “/tmp/wordpress” $ bash bin/install-wp-tests.sh wordpress_test root ''
  • 25. Test Your Plugins! class FooTest extends WP_UnitTestCase { function test_bar() { // replace this your test $this->assertTrue( true ); } } ● Object Factories: $this->factory->post->create(); ● Custom Asserts: $response = wp_remote_get( $url ); $this->assertWPError( $response ); $this->assertQueryTrue( 'is_tag', 'is_archive' ); ● Useful Methods: setUp() | tearDown() | go_to() | remove_added_uploads() ecc..
  • 26. Grazie! Code Samples: ● https://github.com/whitekross/wp-composer ● https://github.com/whitekross/wp-badge-poser Useful Links: ● https://roots.io/bedrock/ ● http://composer.rarst.net/ ● http://codesymphony.co/writing-wordpress-plugin-unit-tests/