tamagokun / pomander-wordpress

Wordpress tasks for use with Pomander
http://ripeworks.com/pomander/wordpress.html
MIT License
36 stars 5 forks source link

utility to load WP core #19

Open tamagokun opened 11 years ago

tamagokun commented 11 years ago

Pomander is a great place to write util scripts for interacting with Wordpress. It might even be a good idea to utilize some WP core functions in this plugin itself.

In doing so, we need a way to boot up the Wordpress core, something like this should work:

        define('BASE_PATH', dirname(__DIR__)."/wordpress/");
        define('WP_USE_THEMES', false);
        $_SERVER = array(
            "HTTP_HOST" => "http://localhost",
            "SERVER_NAME" => "http://localhost",
            "REQUEST_URI" => "/",
            "REQUEST_METHOD" => "GET",
            "SCRIPT_NAME" => "index.php",
            "PHP_SELF" => BASE_PATH
        );
        global $wp, $wp_query, $wp_the_query, $wp_rewrite, $wp_did_header;
        require(BASE_PATH . 'wp-load.php');
tamagokun commented 11 years ago

Things like HTTP_HOST SERVER_NAME and BASE_PATH will need to be dynamic based on the Environment