Whats the difference between these two code snippets, and which one should I use for a WordPress plugin?
require_once(dirname(__FILE__).'/inc/canagan_admin_functions.php');
require_once( '/inc/canagan_admin_functions.php' );
Thanks,
Matt
|
Whats the difference between these two code snippets, and which one should I use for a WordPress plugin?
Thanks, Matt |
|||||
|
|
The first one is like saying...
The second statement is saying...
The first one will work, the second won't. In the second you're looking in the root of the entire file system, where you file certainly won't be. As a side note, whenever I start a plugin that's going to span multiple files, and/or enqueues CSS or JS files, I usually set up a few constant to help me along the way. Here's an example.
Then to include/require files, I use the constants. Keeps from having to call You can then use the constants to include files...
or to enqueue scripts/styles...
|
|||
|
|