What is meant by [if ( ! defined( ‘ABSPATH’ ) )]

I am currently building a WordPress Theme from scratch, as a means to ‘learn on the job’. I have moderate experience with backend work, though I have been heavily reliant of PageBuilders in the past. I now wish to create a Theme without any Pagebuilders as a means to increase its Load Speed etc.

For now, I am currently looking at security for website files and came across the following term:

<?php 
    if ( ! defined( 'ABSPATH' ) ) {
        exit; // Exit if accessed directly
    }
?>

I am of the understanding that this would prevent direct access to the web files. I am not entirely sure what is meant by this. For example, I could still access the file(s) via FTP, through the Server and via the WordPress Dashboard. Is there some other direct access that this prevents? Maybe preventing access via WordPress Plugins etc?

With this in mind, would I be right to assume that the above code should be placed on every file within the theme as standard? Would there be any exceptions?

Any further explanation on this, would be greatly appreciated.

Read more here: What is meant by [if ( ! defined( ‘ABSPATH’ ) )]

Leave a Reply

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