soderlind/customizer-polylang

Suggestion: require_once get_stylesheet_directory_uri() in functions.php should be STYLESHEETPATH or similar.

Closed this issue · 1 comments

First of all, THANK YOU for sharing your script, it was very useful and worked well for us. I would like to share a suggestion for your install instructions. You recommend adding this line in the child theme functions.php:

require_once get_stylesheet_directory_uri() . '/customizer-polylang.php';

However, that will 'retrieve stylesheet directory URI for the current theme/child theme.' IE: Web address.

REF: https://codex.wordpress.org/Function_Reference/get_stylesheet_directory_uri

I think it's better to use include() because you are attempting to include a php file. I recommend using the following inside your child-theme functions.php file :

include( STYLESHEETPATH . '/customizer-polylang.php');

Also to note, if someone downloads your github repo it will automatically put the repo into a subfolder /customizer-polylang which is the default behavour of github, but users will need to place the files directly into the child-theme root folder (not inside a any sub directory) which you have stated in your instructions, but it's worth repeating here incase someone runs into that issue.

Thanks again. I hope this post was useful.

Thank you. I've been sloppy, it was my intention to use get_stylesheet_directory(). I prefer using functions instead of constants.

I also agree that using include() is better. Eh, I try to follow the WordPress Coding Standard and according to the standard, non conditional includes should use require* not include*, also you shouldn't use parentheses when using require* and include*

I'll update the documentation.