File Security Check in wordpress in index.php of theme

if ( ! function_exists( 'wp' ) && ! empty( $_SERVER['SCRIPT_FILENAME'] ) && basename( __FILE__ ) == basename( $_SERVER['SCRIPT_FILENAME'] ) ) {
    die ( 'You do not have sufficient permissions to access this page!' );
}

I find these lines of code in index.php of a theme in WordPress.
What is the logic behind these lines?

Related posts

Leave a Reply

1 comment

  1. Basically Its a check if the index.php file is accessed directly and not by WordPress, if the first is the case then the scripts stops the execution , displays a message

    You do not have sufficient permissions to access this page!

    And stops farther execution for the script.