TEST DRIVE TEST LATER

5 WordPress things, you should know (but you probably don’t)

Author
27.January.2014| 1 Comment

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:-

  1. .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]

    <?php $upgrading = time(); ?>

    [/php]

    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.

  2. 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:-

    [php]

    $curl = curl_init($url);
    curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
    $result = curl_exec($curl);
    curl_close($curl);

    [/php]

    WordPress provides an easy function wp_remote_get to execute the same task with far less efforts.

    [php]

    wp_remote_get( $url, $args );

    [/php]

  3. 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.

    [php]

    <a href="mailto:<?php echo antispambot("[email protected]"); ?>">
    <?php echo antispambot(“[email protected]”); ?> </a>

    [/php]

  4. 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:

    [php]

    zeroise(9,5); //00009
    zeroise(19,5); //00019
    zeroise(199,5); //00199
    zeroise(1999,5); //01999

    [/php]

  5. 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]

    <?php // Silence is golden.

    [/php]

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.

COMMENTS

One Comment so far:

  1. Joseph Raja says:

    Good Information thank you

Leave a Reply

Your email address will not be published. Required fields are marked *

X

Subscribe Now

Get free download on your email

Send me new freebies, offers & news
X

Subscribe Now

Get free download on your email

Send me new freebies, offers & news