I am encountering a strange problem which I couldn't solve so far.
I'm calling a .php script via cronjob (Debian/GNU Linux). To use wordpress functionailty I added:
define('WP_USE_THEMES', false); require( '/full/path/to/wp-blog-header.php' );
Now database queries and default wordpress functionality all works fine, but I also call some functions provided by a plugin (namely advanced custom fields, the problem however affects other plugins as well as I tested) the following php error is returned:
PHP Fatal error: Call to undefined function update_field() in executed.php on line 24
Which tells me that the function of that plugin has not been included. So it seems to me that require wp-blog-header.php dies not include plugin functionality (which it did when I started to develop the mentioned script, but now when I tested it, it produced an php error that).
Could it be, that the 3.5 upgrade of wordpress changed something here? Or does anyone of you has some piece of advice for me as to why this problem occures? Thank you!
I made further tests. The problem seems to be, that I am executing the php in the shell using following command:
/usr/bin/php5 -q -d memory_limit=256M /path/to/executed.php
Thus certain variables are not set like
Wordpress would therefore give me warnings in debug-mode. So what I did is, I definied the
DOCUMENT_ROOT variable, and included my function.php (which was alos not loaded) manualy:
$_SERVER['DOCUMENT_ROOT'] = '/full/path/to/my/document/root/'; define('WP_USE_THEMES', false); require( '/full/path/to/wp-blog-header.php' ); require_once( '/full/path/to/themes/mytheme/functions.php' );
Now it is working. Yet it seems to me as a mere unhealthy walkaround ...