Tip #7 : WordPress constants
Posted by Leonid Mamchenkov on October 5, 2007
ABSPATH is one of the most known WordPress constants. It holds filesystem path to WordPress installation and is often used to construct filesystem paths relative to WordPress. But what other constants are there in WordPress? The answer is easy to get than it might seem. You can see a full list here.
(Thanks to Benedict Eastaugh over at wp-hackers mailing list for the above link)
October 5, 2007 at 12:35 pm
The link is broken :(
October 5, 2007 at 12:38 pm
Here’s the correct link. It seems that dont like direct access to the generated url (after click on this).
October 5, 2007 at 12:40 pm
Samuel,
thanks for letting me know. I’ve fixed the link in the post. It was a copy-pasto. :)
October 5, 2007 at 6:09 pm
Thanks for the tip
October 5, 2007 at 7:29 pm
Good reference. It would be nice to see some info on what the constants are used for (e.g. definition, purpose), but this is a good start.
October 5, 2007 at 7:35 pm
davidrpotter,
constants hold a value which cannot be changed during the execution of the script. Sometimes these values come handy. When writing plugins for example. Like with ABSPATH example above. Instead of trying to figure out in which directory WordPress is installed, just use the value in ABSPATH.
October 6, 2007 at 7:20 pm
[...] Bits is such a blog. A recent article, Tip #7 : WordPress constants, showed up on my WordPress dashboard and I just had to take a look. While the article points to a [...]
October 7, 2007 at 10:39 am
Thanks - i’ve never experimented with changing constants yet. /me enjoys post.
October 7, 2007 at 11:56 am
Thanks for the tip, some constants are a popular target for malicious hacker bots/scripts!
October 9, 2007 at 5:52 am
thanks for your tips
October 11, 2007 at 1:55 pm
Sometimes ABSPATH is your enemy, for example, when you want to go ONE DIRECTORY UP from WordPress;-)
I had this problem with file uploads, because my upload dir is one level up from my WordPress install dirs… Still didn’t resolve it :(