Can a theme use ABSPATH

wordpress

#1

Hi,

Can my theme use ABSPATH to include files? Example:

require_once ABSPATH . ‘wp-admin/includes/import.php’;

The reviewer did not specifically mention ABSPATH however they did state the following (I have fixed the obvious violations):

##################

Use an appropriate path when including theme files:

  • get_template_directory(): Returns the absolute template directory path.
  • get_template_directory_uri(): Returns the template directory URI.
  • get_stylesheet_directory(): Returns the absolute stylesheet directory path.
  • get_stylesheet_directory_uri(): Returns the stylesheet directory URI.

Don’t use: dirname(FILE), basename( FILE ) or anything else not listed above.

##################

Thanks in advance!


#2

why not use site_url ?

https://codex.wordpress.org/Function_Reference/site_url


#3

Unfortunately site_url() returns the site URL and ABSPATH returns the file location. Example:
ABSPATH - /Applications/MAMP/htdocs/theme/
site_url() - http://localhost/theme/ (wont work for including)

Thanks anyways!


#4

Yes. It’s can.


#5

Awesome thanks!