SlideShare a Scribd company logo
Jonathan Bossenger
Let’s Code
Learn.WordPress.org
WordPress Coding Standards
2
👋🏽
Welcome!
As you join, please let us know in the chat where
you’re joining us from, and what the weather’s like in
your part of the world…
Hello!
○ My name is Jonathan Bossenger
○ From Cape Town, South Africa
○ Developer educator at Automattic
○ Sponsored to work with the Training Team
○ jonathanbossenger.com
Learn.WordPress.org
WordPress Coding
Standards
Jonathan Bossenger
Announcements
○ A note on today’s presentation…
Announcements
○ Welcome, and thanks to Laura for co-hosting.
○ Please let me know if you can’t see this slide!
○ We are presenting in focus mode, but please feel free to enable your video.
○ You are welcome to ask questions.
○ You are welcome to post questions in the chat, or unmute to ask questions.
Announcements
○ The example code from today’s presentation
• https://github.com/jonathanbossenger/wp-learn-coding-
standards/releases/download/1.0.0/wp-learn-coding-standards.1.0.0.zip
• https://www.howtogeek.com/789559/how-to-stop-safari-from-automatically-
unzipping-downloaded-files-on-mac/
○ If I am going too fast, please let me know!
○ We will be posting this session to https://wordpress.tv/ afterwards
○ For more WordPress focused content please visit https://learn.wordpress.org/
Learning Outcomes
1. What are Coding Standards?
2. Coding Standards for WordPress
• HTML and CSS Coding Standards
⁃ Validating your HTML and CSS code
• PHP and JavaScript Coding Standards
⁃ Linting your PHP and JavaScript code
3. WordPress Code Examples Starter
Let’s code lint.
What are Coding Standards?
1. Wikipedia defines them as a set of guidelines for a specific programming language
that recommend programming style, practices, and methods for each aspect of a
program written in that language
2. Coding standards create a baseline for collaboration and review within various
aspects of an open source project and community
3. Coding standards help avoid common coding errors, improve the readability of
code, and simplify modification
What are Coding Standards?
1. If you are planning to contribute to WordPress core, you need to familiarize
yourself with these standards, as any code you submit will need to comply with
them.
2. While it is not strictly a requirement, it's also a good idea to follow these standards
when developing plugins and themes
3. It will make your code easier to read and understand, and will make it easier for
other developers to contribute to your code.
WordPress Coding Standards
https://developer.wordpress.org/coding-standards/
HTML and CSS Coding Standards:
○ https://developer.wordpress.org/coding-standards/wordpress-coding-standards/html/
○ https://developer.wordpress.org/coding-standards/wordpress-coding-standards/css/
These standards follow the World Wide Web Consortium (or W3C) standards for HTML
and CSS
○ https://www.w3.org/standards/webdesign/htmlcss
○ https://validator.w3.org/
○ https://jigsaw.w3.org/css-validator/
WordPress Coding Standards
https://developer.wordpress.org/coding-standards/
PHP and JavaScript Coding Standards:
○ https://developer.wordpress.org/coding-standards/wordpress-coding-standards/php/
○ https://developer.wordpress.org/coding-standards/wordpress-coding-standards/javascript/
These standards were extended from other style guides at the time, but how now been
formalised and are unique to the WordPress project.
Fortunately, there are some linting tools that the project has made available, to check
your code.
WordPress Code Linters
PHP
○ https://github.com/squizlabs/PHP_CodeSniffer
○ https://github.com/WordPress/WordPress-Coding-Standards
○ Requires https://getcomposer.org/
WordPress Code Linters
PHP - Composer package installation
○ composer require --dev dealerdirect/phpcodesniffer-composer-installer
○ composer require --dev squizlabs/php_codesniffer
○ composer require --dev wp-coding-standards/wpcs
WordPress Code Linters
PHP - phpcs.xml configuration
<?xml version="1.0"?>
<ruleset name="WordPress Coding Standards">
<rule ref="WordPress"/>
<arg name="extensions" value="php"/>
<file>.</file>
<!-- Exclude Vendor directory -->
<exclude-pattern>*/vendor/*</exclude-pattern>
<exclude-pattern>*/node_modules/*</exclude-pattern>
</ruleset>
WordPress Code Linters
PHP - run command
./vendor/bin/phpcs --standard=phpcs.xml
WordPress Code Linters
JavaScript
○ https://developer.wordpress.org/block-editor/reference-guides/packages/packages-
scripts/
○ Requires https://nodejs.org/en
WordPress Code Linters
JavaScript - npm package installation
○ npm init
○ npm install @wordpress/scripts --save-dev
WordPress Code Linters
JavaScript - package.json scripts
"scripts": {
"build": "wp-scripts build",
"check-engines": "wp-scripts check-engines",
"check-licenses": "wp-scripts check-licenses",
"format": "wp-scripts format",
"lint:css": "wp-scripts lint-style",
"lint:js": "wp-scripts lint-js",
"lint:md:docs": "wp-scripts lint-md-docs",
"lint:pkg-json": "wp-scripts lint-pkg-json",
"packages-update": "wp-scripts packages-update",
"plugin-zip": "wp-scripts plugin-zip",
"start": "wp-scripts start",
"test:e2e": "wp-scripts test-e2e",
"test:unit": "wp-scripts test-unit-js"
}
WordPress Code Linters
JavaScript - run command
npm run lint:js
WordPress Code Examples Starter
https://github.com/ryanwelcher/wordpress-project-template
Resources
○ https://github.com/jonathanbossenger/wp-learn-coding-standards/releases/download/1.0.0/wp-
learn-coding-standards.1.0.0.zip
○ https://en.wikipedia.org/wiki/Coding_conventions
○ https://developer.wordpress.org/coding-standards/
○ https://developer.wordpress.org/coding-standards/wordpress-coding-standards/html/
○ https://developer.wordpress.org/coding-standards/wordpress-coding-standards/css/
○ https://www.w3.org/standards/webdesign/htmlcss
○ https://validator.w3.org/
○ https://jigsaw.w3.org/css-validator/
Resources
○ https://github.com/squizlabs/PHP_CodeSniffer
○ https://github.com/WordPress/WordPress-Coding-Standards
○ https://getcomposer.org/
○ https://developer.wordpress.org/block-editor/reference-guides/packages/packages-scripts/
○ https://nodejs.org/en/download

More Related Content

Similar to WordPress Coding Standards

Global Styles Variations in Block Themes.pptx
Global Styles Variations in Block Themes.pptxGlobal Styles Variations in Block Themes.pptx
Global Styles Variations in Block Themes.pptx
Jonathan Bossenger
 
Let's code! Diving into theme.json
Let's code! Diving into theme.jsonLet's code! Diving into theme.json
Let's code! Diving into theme.json
Jonathan Bossenger
 
Developing Blocks without React - Controls.pptx
Developing Blocks without React - Controls.pptxDeveloping Blocks without React - Controls.pptx
Developing Blocks without React - Controls.pptx
Jonathan Bossenger
 
Let's code! Converting a Shortcode into a Block
Let's code! Converting a Shortcode into a BlockLet's code! Converting a Shortcode into a Block
Let's code! Converting a Shortcode into a Block
Jonathan Bossenger
 
Let's code: developing WordPress User Roles and Capabilities
Let's code: developing WordPress User Roles and CapabilitiesLet's code: developing WordPress User Roles and Capabilities
Let's code: developing WordPress User Roles and Capabilities
Jonathan Bossenger
 
Developing Blocks without React - Block Supports.pptx
Developing Blocks without React - Block Supports.pptxDeveloping Blocks without React - Block Supports.pptx
Developing Blocks without React - Block Supports.pptx
Jonathan Bossenger
 
Using Block Patterns in your Block Theme.pptx
Using Block Patterns in your Block Theme.pptxUsing Block Patterns in your Block Theme.pptx
Using Block Patterns in your Block Theme.pptx
Jonathan Bossenger
 
Internationalisation in Block Themes.pptx
Internationalisation in Block Themes.pptxInternationalisation in Block Themes.pptx
Internationalisation in Block Themes.pptx
Jonathan Bossenger
 
Developing Blocks without React - Part 1
Developing Blocks without React - Part 1Developing Blocks without React - Part 1
Developing Blocks without React - Part 1
Jonathan Bossenger
 
Let's code: custom content & custom capabilities
Let's code: custom content & custom capabilitiesLet's code: custom content & custom capabilities
Let's code: custom content & custom capabilities
Jonathan Bossenger
 
Creating a WordPress multisite network
Creating a WordPress multisite networkCreating a WordPress multisite network
Creating a WordPress multisite network
Jonathan Bossenger
 
Debugging in WordPress
Debugging in WordPressDebugging in WordPress
Debugging in WordPress
Jonathan Bossenger
 
Developing Blocks without React - Part 2.pptx
Developing Blocks without React - Part 2.pptxDeveloping Blocks without React - Part 2.pptx
Developing Blocks without React - Part 2.pptx
Jonathan Bossenger
 
Developing Blocks without React - Part 2
Developing Blocks without React - Part 2Developing Blocks without React - Part 2
Developing Blocks without React - Part 2
Jonathan Bossenger
 
Developing Blocks without React - Attributes.pptx
Developing Blocks without React - Attributes.pptxDeveloping Blocks without React - Attributes.pptx
Developing Blocks without React - Attributes.pptx
Jonathan Bossenger
 
Testing plugins for PHP 8
Testing plugins for PHP 8Testing plugins for PHP 8
Testing plugins for PHP 8
Jonathan Bossenger
 
WordPress Plugin Security
WordPress Plugin SecurityWordPress Plugin Security
WordPress Plugin Security
Jonathan Bossenger
 
WP REST API Authentication, custom fields and updating resources
WP REST API Authentication, custom fields and updating resourcesWP REST API Authentication, custom fields and updating resources
WP REST API Authentication, custom fields and updating resources
Jonathan Bossenger
 
Using the WP REST API
Using the WP REST APIUsing the WP REST API
Using the WP REST API
Jonathan Bossenger
 
Let's code: WordPress multisite experiments
Let's code: WordPress multisite experimentsLet's code: WordPress multisite experiments
Let's code: WordPress multisite experiments
Jonathan Bossenger
 

Similar to WordPress Coding Standards (20)

Global Styles Variations in Block Themes.pptx
Global Styles Variations in Block Themes.pptxGlobal Styles Variations in Block Themes.pptx
Global Styles Variations in Block Themes.pptx
 
Let's code! Diving into theme.json
Let's code! Diving into theme.jsonLet's code! Diving into theme.json
Let's code! Diving into theme.json
 
Developing Blocks without React - Controls.pptx
Developing Blocks without React - Controls.pptxDeveloping Blocks without React - Controls.pptx
Developing Blocks without React - Controls.pptx
 
Let's code! Converting a Shortcode into a Block
Let's code! Converting a Shortcode into a BlockLet's code! Converting a Shortcode into a Block
Let's code! Converting a Shortcode into a Block
 
Let's code: developing WordPress User Roles and Capabilities
Let's code: developing WordPress User Roles and CapabilitiesLet's code: developing WordPress User Roles and Capabilities
Let's code: developing WordPress User Roles and Capabilities
 
Developing Blocks without React - Block Supports.pptx
Developing Blocks without React - Block Supports.pptxDeveloping Blocks without React - Block Supports.pptx
Developing Blocks without React - Block Supports.pptx
 
Using Block Patterns in your Block Theme.pptx
Using Block Patterns in your Block Theme.pptxUsing Block Patterns in your Block Theme.pptx
Using Block Patterns in your Block Theme.pptx
 
Internationalisation in Block Themes.pptx
Internationalisation in Block Themes.pptxInternationalisation in Block Themes.pptx
Internationalisation in Block Themes.pptx
 
Developing Blocks without React - Part 1
Developing Blocks without React - Part 1Developing Blocks without React - Part 1
Developing Blocks without React - Part 1
 
Let's code: custom content & custom capabilities
Let's code: custom content & custom capabilitiesLet's code: custom content & custom capabilities
Let's code: custom content & custom capabilities
 
Creating a WordPress multisite network
Creating a WordPress multisite networkCreating a WordPress multisite network
Creating a WordPress multisite network
 
Debugging in WordPress
Debugging in WordPressDebugging in WordPress
Debugging in WordPress
 
Developing Blocks without React - Part 2.pptx
Developing Blocks without React - Part 2.pptxDeveloping Blocks without React - Part 2.pptx
Developing Blocks without React - Part 2.pptx
 
Developing Blocks without React - Part 2
Developing Blocks without React - Part 2Developing Blocks without React - Part 2
Developing Blocks without React - Part 2
 
Developing Blocks without React - Attributes.pptx
Developing Blocks without React - Attributes.pptxDeveloping Blocks without React - Attributes.pptx
Developing Blocks without React - Attributes.pptx
 
Testing plugins for PHP 8
Testing plugins for PHP 8Testing plugins for PHP 8
Testing plugins for PHP 8
 
WordPress Plugin Security
WordPress Plugin SecurityWordPress Plugin Security
WordPress Plugin Security
 
WP REST API Authentication, custom fields and updating resources
WP REST API Authentication, custom fields and updating resourcesWP REST API Authentication, custom fields and updating resources
WP REST API Authentication, custom fields and updating resources
 
Using the WP REST API
Using the WP REST APIUsing the WP REST API
Using the WP REST API
 
Let's code: WordPress multisite experiments
Let's code: WordPress multisite experimentsLet's code: WordPress multisite experiments
Let's code: WordPress multisite experiments
 

More from Jonathan Bossenger

New WordPress Developer APIs The Interactivity API
New WordPress Developer APIs The Interactivity APINew WordPress Developer APIs The Interactivity API
New WordPress Developer APIs The Interactivity API
Jonathan Bossenger
 
The WordPress HTML API
The WordPress HTML APIThe WordPress HTML API
The WordPress HTML API
Jonathan Bossenger
 
The WordPress Create Block tool
The WordPress Create Block toolThe WordPress Create Block tool
The WordPress Create Block tool
Jonathan Bossenger
 
PHP compatibility testing with PHPCompatibilityWP
PHP compatibility testing with PHPCompatibilityWPPHP compatibility testing with PHPCompatibilityWP
PHP compatibility testing with PHPCompatibilityWP
Jonathan Bossenger
 
Common WordPress APIs_ Settings API
Common WordPress APIs_ Settings APICommon WordPress APIs_ Settings API
Common WordPress APIs_ Settings API
Jonathan Bossenger
 
Common WordPress APIs - Options API
Common WordPress APIs - Options APICommon WordPress APIs - Options API
Common WordPress APIs - Options API
Jonathan Bossenger
 
Common WordPress APIs_ HTTP API.pptx
Common WordPress APIs_ HTTP API.pptxCommon WordPress APIs_ HTTP API.pptx
Common WordPress APIs_ HTTP API.pptx
Jonathan Bossenger
 
Common WordPress APIs: Metadata
Common WordPress APIs: MetadataCommon WordPress APIs: Metadata
Common WordPress APIs: Metadata
Jonathan Bossenger
 
What’s new for developers_ (August 2023).pptx
What’s new for developers_ (August 2023).pptxWhat’s new for developers_ (August 2023).pptx
What’s new for developers_ (August 2023).pptx
Jonathan Bossenger
 
Testing your plugins for PHP version compatibility
Testing your plugins for PHP version compatibilityTesting your plugins for PHP version compatibility
Testing your plugins for PHP version compatibility
Jonathan Bossenger
 
Common WordPress APIs_ Global Variables
Common WordPress APIs_ Global VariablesCommon WordPress APIs_ Global Variables
Common WordPress APIs_ Global Variables
Jonathan Bossenger
 
Common WordPress APIs_ Internationalization
Common WordPress APIs_ InternationalizationCommon WordPress APIs_ Internationalization
Common WordPress APIs_ Internationalization
Jonathan Bossenger
 
Testing WordPress 6.3 - Developer edition
Testing WordPress 6.3 - Developer editionTesting WordPress 6.3 - Developer edition
Testing WordPress 6.3 - Developer edition
Jonathan Bossenger
 
Common WordPress APIs: Responsive Images
Common WordPress APIs: Responsive ImagesCommon WordPress APIs: Responsive Images
Common WordPress APIs: Responsive Images
Jonathan Bossenger
 
Common WordPress APIs - Dashboard Widgets
Common WordPress APIs - Dashboard WidgetsCommon WordPress APIs - Dashboard Widgets
Common WordPress APIs - Dashboard Widgets
Jonathan Bossenger
 
The WordPress Database
The WordPress DatabaseThe WordPress Database
The WordPress Database
Jonathan Bossenger
 
Managing a WordPress Multisite Network
Managing a WordPress Multisite NetworkManaging a WordPress Multisite Network
Managing a WordPress Multisite Network
Jonathan Bossenger
 
Introduction to WordPress Multisite Networks
Introduction to WordPress Multisite NetworksIntroduction to WordPress Multisite Networks
Introduction to WordPress Multisite Networks
Jonathan Bossenger
 
Developing for multisite
Developing for multisiteDeveloping for multisite
Developing for multisite
Jonathan Bossenger
 
Custom Post Types and Capabilities.pptx
Custom Post Types and Capabilities.pptxCustom Post Types and Capabilities.pptx
Custom Post Types and Capabilities.pptx
Jonathan Bossenger
 

More from Jonathan Bossenger (20)

New WordPress Developer APIs The Interactivity API
New WordPress Developer APIs The Interactivity APINew WordPress Developer APIs The Interactivity API
New WordPress Developer APIs The Interactivity API
 
The WordPress HTML API
The WordPress HTML APIThe WordPress HTML API
The WordPress HTML API
 
The WordPress Create Block tool
The WordPress Create Block toolThe WordPress Create Block tool
The WordPress Create Block tool
 
PHP compatibility testing with PHPCompatibilityWP
PHP compatibility testing with PHPCompatibilityWPPHP compatibility testing with PHPCompatibilityWP
PHP compatibility testing with PHPCompatibilityWP
 
Common WordPress APIs_ Settings API
Common WordPress APIs_ Settings APICommon WordPress APIs_ Settings API
Common WordPress APIs_ Settings API
 
Common WordPress APIs - Options API
Common WordPress APIs - Options APICommon WordPress APIs - Options API
Common WordPress APIs - Options API
 
Common WordPress APIs_ HTTP API.pptx
Common WordPress APIs_ HTTP API.pptxCommon WordPress APIs_ HTTP API.pptx
Common WordPress APIs_ HTTP API.pptx
 
Common WordPress APIs: Metadata
Common WordPress APIs: MetadataCommon WordPress APIs: Metadata
Common WordPress APIs: Metadata
 
What’s new for developers_ (August 2023).pptx
What’s new for developers_ (August 2023).pptxWhat’s new for developers_ (August 2023).pptx
What’s new for developers_ (August 2023).pptx
 
Testing your plugins for PHP version compatibility
Testing your plugins for PHP version compatibilityTesting your plugins for PHP version compatibility
Testing your plugins for PHP version compatibility
 
Common WordPress APIs_ Global Variables
Common WordPress APIs_ Global VariablesCommon WordPress APIs_ Global Variables
Common WordPress APIs_ Global Variables
 
Common WordPress APIs_ Internationalization
Common WordPress APIs_ InternationalizationCommon WordPress APIs_ Internationalization
Common WordPress APIs_ Internationalization
 
Testing WordPress 6.3 - Developer edition
Testing WordPress 6.3 - Developer editionTesting WordPress 6.3 - Developer edition
Testing WordPress 6.3 - Developer edition
 
Common WordPress APIs: Responsive Images
Common WordPress APIs: Responsive ImagesCommon WordPress APIs: Responsive Images
Common WordPress APIs: Responsive Images
 
Common WordPress APIs - Dashboard Widgets
Common WordPress APIs - Dashboard WidgetsCommon WordPress APIs - Dashboard Widgets
Common WordPress APIs - Dashboard Widgets
 
The WordPress Database
The WordPress DatabaseThe WordPress Database
The WordPress Database
 
Managing a WordPress Multisite Network
Managing a WordPress Multisite NetworkManaging a WordPress Multisite Network
Managing a WordPress Multisite Network
 
Introduction to WordPress Multisite Networks
Introduction to WordPress Multisite NetworksIntroduction to WordPress Multisite Networks
Introduction to WordPress Multisite Networks
 
Developing for multisite
Developing for multisiteDeveloping for multisite
Developing for multisite
 
Custom Post Types and Capabilities.pptx
Custom Post Types and Capabilities.pptxCustom Post Types and Capabilities.pptx
Custom Post Types and Capabilities.pptx
 

Recently uploaded

GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
James Anderson
 
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdfFIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
FIDO Alliance
 
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdfFIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance
 
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdf
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdfSmart TV Buyer Insights Survey 2024 by 91mobiles.pdf
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdf
91mobiles
 
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
Thierry Lestable
 
To Graph or Not to Graph Knowledge Graph Architectures and LLMs
To Graph or Not to Graph Knowledge Graph Architectures and LLMsTo Graph or Not to Graph Knowledge Graph Architectures and LLMs
To Graph or Not to Graph Knowledge Graph Architectures and LLMs
Paul Groth
 
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered Quality
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered QualitySoftware Delivery At the Speed of AI: Inflectra Invests In AI-Powered Quality
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered Quality
Inflectra
 
Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...
Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...
Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...
Product School
 
The Art of the Pitch: WordPress Relationships and Sales
The Art of the Pitch: WordPress Relationships and SalesThe Art of the Pitch: WordPress Relationships and Sales
The Art of the Pitch: WordPress Relationships and Sales
Laura Byrne
 
Accelerate your Kubernetes clusters with Varnish Caching
Accelerate your Kubernetes clusters with Varnish CachingAccelerate your Kubernetes clusters with Varnish Caching
Accelerate your Kubernetes clusters with Varnish Caching
Thijs Feryn
 
FIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance Osaka Seminar: Overview.pdfFIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance
 
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
Tobias Schneck
 
IOS-PENTESTING-BEGINNERS-PRACTICAL-GUIDE-.pptx
IOS-PENTESTING-BEGINNERS-PRACTICAL-GUIDE-.pptxIOS-PENTESTING-BEGINNERS-PRACTICAL-GUIDE-.pptx
IOS-PENTESTING-BEGINNERS-PRACTICAL-GUIDE-.pptx
Abida Shariff
 
State of ICS and IoT Cyber Threat Landscape Report 2024 preview
State of ICS and IoT Cyber Threat Landscape Report 2024 previewState of ICS and IoT Cyber Threat Landscape Report 2024 preview
State of ICS and IoT Cyber Threat Landscape Report 2024 preview
Prayukth K V
 
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdfFIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
FIDO Alliance
 
AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...
AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...
AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...
Product School
 
Epistemic Interaction - tuning interfaces to provide information for AI support
Epistemic Interaction - tuning interfaces to provide information for AI supportEpistemic Interaction - tuning interfaces to provide information for AI support
Epistemic Interaction - tuning interfaces to provide information for AI support
Alan Dix
 
De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...
De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...
De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...
Product School
 
UiPath Test Automation using UiPath Test Suite series, part 4
UiPath Test Automation using UiPath Test Suite series, part 4UiPath Test Automation using UiPath Test Suite series, part 4
UiPath Test Automation using UiPath Test Suite series, part 4
DianaGray10
 
JMeter webinar - integration with InfluxDB and Grafana
JMeter webinar - integration with InfluxDB and GrafanaJMeter webinar - integration with InfluxDB and Grafana
JMeter webinar - integration with InfluxDB and Grafana
RTTS
 

Recently uploaded (20)

GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
 
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdfFIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
 
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdfFIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
 
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdf
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdfSmart TV Buyer Insights Survey 2024 by 91mobiles.pdf
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdf
 
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
 
To Graph or Not to Graph Knowledge Graph Architectures and LLMs
To Graph or Not to Graph Knowledge Graph Architectures and LLMsTo Graph or Not to Graph Knowledge Graph Architectures and LLMs
To Graph or Not to Graph Knowledge Graph Architectures and LLMs
 
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered Quality
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered QualitySoftware Delivery At the Speed of AI: Inflectra Invests In AI-Powered Quality
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered Quality
 
Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...
Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...
Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...
 
The Art of the Pitch: WordPress Relationships and Sales
The Art of the Pitch: WordPress Relationships and SalesThe Art of the Pitch: WordPress Relationships and Sales
The Art of the Pitch: WordPress Relationships and Sales
 
Accelerate your Kubernetes clusters with Varnish Caching
Accelerate your Kubernetes clusters with Varnish CachingAccelerate your Kubernetes clusters with Varnish Caching
Accelerate your Kubernetes clusters with Varnish Caching
 
FIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance Osaka Seminar: Overview.pdfFIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance Osaka Seminar: Overview.pdf
 
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
 
IOS-PENTESTING-BEGINNERS-PRACTICAL-GUIDE-.pptx
IOS-PENTESTING-BEGINNERS-PRACTICAL-GUIDE-.pptxIOS-PENTESTING-BEGINNERS-PRACTICAL-GUIDE-.pptx
IOS-PENTESTING-BEGINNERS-PRACTICAL-GUIDE-.pptx
 
State of ICS and IoT Cyber Threat Landscape Report 2024 preview
State of ICS and IoT Cyber Threat Landscape Report 2024 previewState of ICS and IoT Cyber Threat Landscape Report 2024 preview
State of ICS and IoT Cyber Threat Landscape Report 2024 preview
 
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdfFIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
 
AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...
AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...
AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...
 
Epistemic Interaction - tuning interfaces to provide information for AI support
Epistemic Interaction - tuning interfaces to provide information for AI supportEpistemic Interaction - tuning interfaces to provide information for AI support
Epistemic Interaction - tuning interfaces to provide information for AI support
 
De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...
De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...
De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...
 
UiPath Test Automation using UiPath Test Suite series, part 4
UiPath Test Automation using UiPath Test Suite series, part 4UiPath Test Automation using UiPath Test Suite series, part 4
UiPath Test Automation using UiPath Test Suite series, part 4
 
JMeter webinar - integration with InfluxDB and Grafana
JMeter webinar - integration with InfluxDB and GrafanaJMeter webinar - integration with InfluxDB and Grafana
JMeter webinar - integration with InfluxDB and Grafana
 

WordPress Coding Standards

  • 2. 2 👋🏽 Welcome! As you join, please let us know in the chat where you’re joining us from, and what the weather’s like in your part of the world… Hello! ○ My name is Jonathan Bossenger ○ From Cape Town, South Africa ○ Developer educator at Automattic ○ Sponsored to work with the Training Team ○ jonathanbossenger.com
  • 4. Announcements ○ A note on today’s presentation…
  • 5. Announcements ○ Welcome, and thanks to Laura for co-hosting. ○ Please let me know if you can’t see this slide! ○ We are presenting in focus mode, but please feel free to enable your video. ○ You are welcome to ask questions. ○ You are welcome to post questions in the chat, or unmute to ask questions.
  • 6. Announcements ○ The example code from today’s presentation • https://github.com/jonathanbossenger/wp-learn-coding- standards/releases/download/1.0.0/wp-learn-coding-standards.1.0.0.zip • https://www.howtogeek.com/789559/how-to-stop-safari-from-automatically- unzipping-downloaded-files-on-mac/ ○ If I am going too fast, please let me know! ○ We will be posting this session to https://wordpress.tv/ afterwards ○ For more WordPress focused content please visit https://learn.wordpress.org/
  • 7. Learning Outcomes 1. What are Coding Standards? 2. Coding Standards for WordPress • HTML and CSS Coding Standards ⁃ Validating your HTML and CSS code • PHP and JavaScript Coding Standards ⁃ Linting your PHP and JavaScript code 3. WordPress Code Examples Starter
  • 9. What are Coding Standards? 1. Wikipedia defines them as a set of guidelines for a specific programming language that recommend programming style, practices, and methods for each aspect of a program written in that language 2. Coding standards create a baseline for collaboration and review within various aspects of an open source project and community 3. Coding standards help avoid common coding errors, improve the readability of code, and simplify modification
  • 10. What are Coding Standards? 1. If you are planning to contribute to WordPress core, you need to familiarize yourself with these standards, as any code you submit will need to comply with them. 2. While it is not strictly a requirement, it's also a good idea to follow these standards when developing plugins and themes 3. It will make your code easier to read and understand, and will make it easier for other developers to contribute to your code.
  • 11. WordPress Coding Standards https://developer.wordpress.org/coding-standards/ HTML and CSS Coding Standards: ○ https://developer.wordpress.org/coding-standards/wordpress-coding-standards/html/ ○ https://developer.wordpress.org/coding-standards/wordpress-coding-standards/css/ These standards follow the World Wide Web Consortium (or W3C) standards for HTML and CSS ○ https://www.w3.org/standards/webdesign/htmlcss ○ https://validator.w3.org/ ○ https://jigsaw.w3.org/css-validator/
  • 12. WordPress Coding Standards https://developer.wordpress.org/coding-standards/ PHP and JavaScript Coding Standards: ○ https://developer.wordpress.org/coding-standards/wordpress-coding-standards/php/ ○ https://developer.wordpress.org/coding-standards/wordpress-coding-standards/javascript/ These standards were extended from other style guides at the time, but how now been formalised and are unique to the WordPress project. Fortunately, there are some linting tools that the project has made available, to check your code.
  • 13. WordPress Code Linters PHP ○ https://github.com/squizlabs/PHP_CodeSniffer ○ https://github.com/WordPress/WordPress-Coding-Standards ○ Requires https://getcomposer.org/
  • 14. WordPress Code Linters PHP - Composer package installation ○ composer require --dev dealerdirect/phpcodesniffer-composer-installer ○ composer require --dev squizlabs/php_codesniffer ○ composer require --dev wp-coding-standards/wpcs
  • 15. WordPress Code Linters PHP - phpcs.xml configuration <?xml version="1.0"?> <ruleset name="WordPress Coding Standards"> <rule ref="WordPress"/> <arg name="extensions" value="php"/> <file>.</file> <!-- Exclude Vendor directory --> <exclude-pattern>*/vendor/*</exclude-pattern> <exclude-pattern>*/node_modules/*</exclude-pattern> </ruleset>
  • 16. WordPress Code Linters PHP - run command ./vendor/bin/phpcs --standard=phpcs.xml
  • 17. WordPress Code Linters JavaScript ○ https://developer.wordpress.org/block-editor/reference-guides/packages/packages- scripts/ ○ Requires https://nodejs.org/en
  • 18. WordPress Code Linters JavaScript - npm package installation ○ npm init ○ npm install @wordpress/scripts --save-dev
  • 19. WordPress Code Linters JavaScript - package.json scripts "scripts": { "build": "wp-scripts build", "check-engines": "wp-scripts check-engines", "check-licenses": "wp-scripts check-licenses", "format": "wp-scripts format", "lint:css": "wp-scripts lint-style", "lint:js": "wp-scripts lint-js", "lint:md:docs": "wp-scripts lint-md-docs", "lint:pkg-json": "wp-scripts lint-pkg-json", "packages-update": "wp-scripts packages-update", "plugin-zip": "wp-scripts plugin-zip", "start": "wp-scripts start", "test:e2e": "wp-scripts test-e2e", "test:unit": "wp-scripts test-unit-js" }
  • 20. WordPress Code Linters JavaScript - run command npm run lint:js
  • 21. WordPress Code Examples Starter https://github.com/ryanwelcher/wordpress-project-template
  • 22. Resources ○ https://github.com/jonathanbossenger/wp-learn-coding-standards/releases/download/1.0.0/wp- learn-coding-standards.1.0.0.zip ○ https://en.wikipedia.org/wiki/Coding_conventions ○ https://developer.wordpress.org/coding-standards/ ○ https://developer.wordpress.org/coding-standards/wordpress-coding-standards/html/ ○ https://developer.wordpress.org/coding-standards/wordpress-coding-standards/css/ ○ https://www.w3.org/standards/webdesign/htmlcss ○ https://validator.w3.org/ ○ https://jigsaw.w3.org/css-validator/
  • 23. Resources ○ https://github.com/squizlabs/PHP_CodeSniffer ○ https://github.com/WordPress/WordPress-Coding-Standards ○ https://getcomposer.org/ ○ https://developer.wordpress.org/block-editor/reference-guides/packages/packages-scripts/ ○ https://nodejs.org/en/download

Editor's Notes

  1. TITLE SLIDE: Make a copy of this presentation to your Google Drive, and edit to replace with your details.