When to use “if ( ! defined( ‘ABSPATH’ ) ) exit;”
-
Most plugins and many theme files use the following code:
if ( ! defined( ‘ABSPATH’ ) ) exit; // Exit if accessed directly
I understand the reason is to keep these files from being accessed directly and generating error messages that reveal the WordPress install path.
I don’t think I’ve ever seen this code in any main theme functions.php file. I’ve seen it in other functions.php files in a theme’s subfolders, but not in the theme’s main functions.php file.
Is there a reason to use / not use this code in a theme’s functions.php file to prevent direct access?
Viewing 12 replies - 1 through 12 (of 12 total)
Viewing 12 replies - 1 through 12 (of 12 total)
- The topic ‘When to use “if ( ! defined( ‘ABSPATH’ ) ) exit;”’ is closed to new replies.