wp config - where should I write constants in wordpress?

admin2025-06-05  1

I have to define a constants to use all over the entire project(i.e: single.php, category.php, my-template.php). Suppose I define a array constant to declare a list of browser name. i.e: array('firefox'=>'Mozilla Firefox','google_chrome'=>'Google Chrome'). Now this constant will be accessible within any php file in my project. I can do this in several ways. But what is the best practice?

I have to define a constants to use all over the entire project(i.e: single.php, category.php, my-template.php). Suppose I define a array constant to declare a list of browser name. i.e: array('firefox'=>'Mozilla Firefox','google_chrome'=>'Google Chrome'). Now this constant will be accessible within any php file in my project. I can do this in several ways. But what is the best practice?

Share Improve this question asked Dec 7, 2018 at 7:11 Abdus Sattar BhuiyanAbdus Sattar Bhuiyan 2232 silver badges16 bronze badges
Add a comment  | 

1 Answer 1

Reset to default 3

Depends on what your project is. If you're developing a theme you would define them at the top of your theme's functions.php file, and if you were developing a plugin you would put them at the top of your main plugin file.

转载请注明原文地址:http://conceptsofalgorithm.com/Algorithm/1749121648a316547.html

最新回复(0)