As we all know WordPress makes it’s API functions such as
get_header();
get_sidebar();
get_footer();
and others as you may define in your own functions.php file available anywhere in your theme files.
How do you create similar functionality as this in your own external PHP applications/scripts without having to write an include or require statement at the top of every PHP file to access your own functions?
WordPress makes it’s API functions and those defined in your themes functions.php file constantly available to you, so you can happily theme away without having to include multiple files each time.
I understand that the magic starts with WordPress’ index.php which then includes wp-blog-header.php and then wp-load.php and a bunch of require/include statements are made at this point which setup the environment and make such functions available to us…
But I’m having trouble understanding how WordPress serves you the theme files whilst all the time throwing you back through it’s original loop process of wp-blog-header.php and so forth to ensure those functions are made available to you…
I hope this makes sense!
Regards
WP
The theme files are included, by the process you describe (index.php, etc.), after the files that contain those function definitions.