If you find yourself doing a lot of work with the same value in WordPress development, perhaps you should consider creating a global definition.
Here’s how:
Assuming that you find yourself writing something like this with the theme path:
[cc lang=”php”]
$my_path = ABSPATH . ‘wp-content/themes/’ . get_template();
[/cc]
You can create a global definition:
[cc lang=”php”]
if(!defined(‘THEME_PATH’)) {
define(‘THEME_PATH’, ABSPATH . ‘wp-content/themes/’ . get_template());
}
[/cc]
And then reference it anywhere in your code like this:
[cc lang=”php”]
$path = THEME_PATH . ‘/js/admin.js’;
[/cc]
Convenient.
John Saddington says
hawt!