We all know WordPress as a CMS. But nowadays WordPress is evolving rapidly as a framework, with its newer release in every 2 months or even less. There are few(or many) things about WordPress that even experienced developers haven’t heard about. In this article let’s get familiar to few such things:-
- .maintenance File: You have a website with thousands of users and ten thousands of pageviews every month. Now if you want to upgrade some features of your website, then it’s going to be a trouble for you being the developer because in the process if you commit a mistake that will be reflected to users that are viewing your site at the time, that doesn’t sound like a good thing. Now what do you do? The solution is .maintenance file. Just create a file named .maintenance on the root of your WordPress installation and put the following content in it.
<?php $upgrading = time(); ?>
Now you can make any changes to your WordPress site at any level and your visitors will be shown a message “Briefly unavailable for scheduled maintenance. Check back in a minute”. When you are done with the maintenance of your site, just delete the .maintenance file. If you want to change this message, create a file named maintenance.php inside wp-content folder and write your message inside it.
- wp_remote_get(): Often would you need to fetch HTML source of some other website and scrap it. Usually we have to prepare a CURL request that requires few lines of code that looks something like below:-
$curl = curl_init($url);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
$result = curl_exec($curl);
WordPress provides an easy function wp_remote_get to execute the same task with far less efforts.
wp_remote_get( $url, $args );
- antispambot(): This is another little-known function. This function can be extremely helpful in hiding your email from spam-bots making it invisible to them. Internally it will encode the characters in your email with their respective HTML codes (like %61 for ‘a’, %62 for ‘b’ ) that can fool spambots, while email ID will be shown to the user intact.
- zeroise(): A simple function with simpler functionality. If you ever need to put zeros before a number to make it n digit this function will be handy. Lets see how it works:
- Silence is golden: Have you ever in your free time tried to explore WordPress files? Like index.php file inside wp-content? No. Let’s see what’s inside the file:
<?php // Silence is golden.
Yeah, that’s it. That’s all inside the index file. Just an empty file with no code and a single line comment saying “Silence is golden”. Congratulation!! You have been trolled by WordPress…but wait, there exists nothing for no reason, there has got to be some reason for this file being empty, what’s it? The answer is security. If this index file is not there than anyone can access site’s directory listing by navigating to and he can get all the assets used in your site, that is not desirable at any condition.
PS: You can turn directory listing off using .htaacess
PSS: If desired you can change name of wp-content folder of your site, that will make your site less WordPressish and of course, it adds to the security layer of your beloved site.