- Rules vs Standards
- PHP code sniffer
- Plugins : the first step
Rules vs Standards
When we are writing code, we are making something that will be used by other people. As we go on writing code, it becomes a huge mess if everyone just wrote whatever they want however they want as long as it works.
To stop this from happening and make code readable and manageable we follow some rules while writing code. Rules may be like using tabs instead of spaces for indentation or using camel case for naming functions etc.
There are many rules we can follow, but if in a large group of people, everyone is following those rules it becomes a standard. The standard that is followed within an organization or by a small group of developers or a huge community of open source devs.
When writing PHP code, to enforce the standards we use PHP code sniffer
PHP Code Sniffer
We can set custom standards to be followed and the PHP code sniffer detects in our code where we have violated them. PHPCS can detect standards violations in CSS and JS also but in WordPress we use it only for PHP as there are other tools for those languages too.
We can install multiple standards like for WP VIP, for WP core etc
Plugins : the first step
After learning how to use WordPress, we are going to learn how to extend its functionality using plugins.
one huge rule for WordPress : Never touch the core
There can be incredible things to be done without ever having to touch the core of WordPress. We can extend the functionality of our WordPress using plugins.
How to create a plugin ?
- Go into
wp-contents/plugins - You can create plugins even using just one php file
- create a php file :
plugin-name.php - To make this file interpreted as a plugin we have to put a header doc in the php
/*
* Plugin Name: Test
* Plugin URI: https://example.com/plugins/the-basics/
* Description: Testing if this works
* Version: 1.0.0
* Requires at least: 6.2
* Requires PHP: 7.2
* Author: Pratik Londhe
*/
Leave a Reply