How to fix (Use an appropriate path when including theme files:) issues?



I have submitted a WordPress in ThemeForest and got some soft reject issues. But one of the problems I can’t get any solution.
The soft reject issues is:
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.

Note: I include TGM and Redux plugin in my theme. the dirname(FILE) and basename( FILE ) has in TGM and redux plugin. And I also want to know without dirname() and basename() this functions how to get file name and files location in WordPress or PHP.

Thanks In Advance


You will need to replace all dirname(__FILE__) and basename(__FILE__) with get_template_directory() for TGM or any other framework.
Also, to spare you from more soft rejects, theme MUST have only one textdomain, no matter that frameworks use their textdomains and have their .pot files.

Theme check plugin simply must have no errors or warnings, that is absolutely imperative. Learn from our mistakes :wink:


Just went through the same hoops. You will need to do something along these lines:
require_once (get_template_directory() .’/inc/required/class-tgm-plugin-activation.php’);

Just for FYI, I eventually moved redux and the extension loader out and pull them in as a required plugins :frowning:


If redux is inside plugin you don’t need to change anything in redux. If redux is inside your theme you should probably consider moving it to plugin. :slight_smile:


Seems now that TGMPA needs to be modified as before it was treated as an exception. That includes replacing all ( with esc_html( and not adding the page in the same way ie not using add_submenu_page to it doesn’t cause a themecheck error as micemade said.

I do find this pretty odd that we have to modify TGMPA considering that we are requested to use it.


BTW there is a generator now that customises the textdomain and prefix and doesn’t seem to use dirname and basename however you have to choose the option not the themeforest option as the themeforest option doesn’t adapt the textdomain.

It also doesn’t trigger the sub_menu themecheck warning.

You’ll still need to replace ( with esc_html( though.