My script needs to load the whole WP in order to work probably. I'm currently doing it this way
if ( !defined('ABSPATH') ) {
/** Load WordPress Bootstrap */
@ini_set('include_path', '../../../');
require_once('../../../wp-load.php');
}
//additional html stuff
do_action('my_custom_hook');
//more html stuff
which works most of the time. Sometimes people get a Fatal error for a missing file though.
The script is located at
wp-content/plugins/my-plugin-slug/script.php
What's the best way to load it?
../../../
, ever! Instead, you need to find the proper hook to use for your function. Your plugin is already in the WordPress environment. Why do you need to load it again?DISABLE_WP_CRON
on that pagescript.php
file. It's fine if the server cron runs the file; but you're trying to get WP information by re-loading the entire platform. I'm suggesting there is a hook you can run from yourscript.php
file, which can perform your processing on each cron run without having to reload WP.