[wp-hackers] Bootstrapping WordPress
Brian Layman
wp-hackers at thecodecave.com
Tue Oct 4 15:48:46 UTC 2011
On 10/4/2011 11:37 AM, Tom Barrett wrote:
> On 4 October 2011 16:19, Dagan Henderson<Dagan.Henderson at epyllion.com>wrote:
>> I'm working on a process that requires a cron job and would prefer to
>> execute the PHP script directly instead of using cURL to execute the code
>> via the Web server.
> I was shown this method (assuming PHP script is in the docroot):
>
> // Require the standard WordPress header
> require(dirname(__FILE__).'/wp-blog-header.php');
If you don't plan on doing something that visually themed like your
site, you can just include wp-load.php.
I put a sample script for doing this sort of thing up on GitHub.
Here:
https://github.com/brianlayman/WordPress-Manipulator/blob/master/wpmanip.php
It demonstrates a bunch of techniques. It takes parameters from CLI or
your browser. It loads the WP environment and access the WP API
directly as well as demonstrates how to curl into the wp-admin area of a
site to automate things.
Maybe you'll find it helpful.
--
Brian Layman
More information about the wp-hackers
mailing list