Accessing WP core with my PHP script

I’m trying to create a script that would download and install wordpress + plugins + themes automatically.

All the stages until installing are working out. The files are downloaded and the wp-config.php is working – but when I try to run the wp install I get the following error:

Read More

Fatal error: Call to undefined method stdClass::add_query_var() in C:Apache24htdocswpwpwp-includestaxonomy.php on line 371

From doing some research – it seems that the problem is finding the right way to include wordpress functions in my script – this is my code

define( 'WP_INSTALLING', true );
global $wp;
require_once( $directory . 'wp-blog-header.php' );
/** Load WordPress Bootstrap */
require_once( $directory . 'wp-load.php' );

/** Load WordPress Administration Upgrade API */
require_once( $directory . 'wp-admin/includes/upgrade.php' );

/** Load wpdb */
require_once( $directory . 'wp-includes/wp-db.php' );

var_dump($wp);
// WordPress installation
wp_install( $data[ 'weblog_title' ], $data['user_login'], $data['admin_email'], (int) $data[ 'blog_public' ], '', $data['admin_password'] );

in taxonomy line 371 theres a function call :

$wp->add_query_var( $args['query_var'] );

I suspect that $wp never gets defined.
Does anyone know what I should change to do that?

I made sure that it crashes on the wp_install – never goes past that in my script.

Related posts