The current WordPress Coding Standard does not specify which file extensions should be used for PHP The web scripting language in which WordPress is primarily architected. WordPress requires PHP 7.4 or higher files. This proposal establishes that only the .php file extension should be allowed for PHP files.
Motivation
While web servers like Apache Apache is the most widely used web server software. Developed and maintained by Apache Software Foundation. Apache is an Open Source software available for free. and Nginx NGINX is open source software for web serving, reverse proxying, caching, load balancing, media streaming, and more. It started out as a web server designed for maximum performance and stability. In addition to its HTTP server capabilities, NGINX can also function as a proxy server for email (IMAP, POP3, and SMTP) and a reverse proxy and load balancer for HTTP, TCP, and UDP servers. https://www.nginx.com/. can be configured to execute files with various extensions as PHP (e.g., .php3 and .phtml), the .php extension is the only one universally supported. If PHP files do not use the .php extension, there is a risk that scripts will not work on some web servers. For example, a default Debian installation using Apache and mod_php parses .php, .phtml, and .phar as PHP, whereas a default Fedora installation using Apache and mod_php parses only .php and .phar as PHP. This means that a plugin A plugin is a piece of software containing a group of functions that can be added to a WordPress website. They can extend functionality or add new features to your WordPress websites. WordPress plugins are written in the PHP programming language and integrate seamlessly with WordPress. These can be free in the WordPress.org Plugin Directory https://wordpress.org/plugins/ or can be cost-based plugin from a third-party using .phtml file extensions will work on Debian, but not on Fedora (and may inadvertently render code in plain text). Therefore, for code portability, compatibility, and security, it should be agreed and checkable that only .php extensions are used for PHP files.
Another benefit of the change proposed here is that if all PHP files use the .php extension, we can be sure that they will be checked by tools like PHPCS PHP Code Sniffer, a popular tool for analyzing code quality. The WordPress Coding Standards rely on PHPCS..
Proposed change to the handbook
Add a new item to the General section of the PHP Coding Standard Handbook as follows:
Title: File Extension
Content: PHP files must use the .php file extension.
References
This was originally proposed by Gary Jones in this WPCS issue.
#codingstandards, #php, #wpcs
Props @dingo_d, @garyj, and @jrf for reviewing this post.