How to start a cron that refers to a plugin class

Suppose there is a task to run a method on a crown. In this method, there is a call to a method of some plugin.

To implement this, you need to connect this class separately and create an object for it.

Otherwise, a fatal error may occur stating that the class was not found. This is due to the order in which WordPress files and classes are activated.

The functions.php file is activated before the plugin files. Without this, it will not be possible to connect classes through this file, but to refer from them to the plugins folder. This is especially true for the launch of crowns.

// Especially for the crown, we initialize it separately
if (defined(‘DOING_CRON’)) {
require_once ABSPATH ‘wp-content / plugins / some-plugin / someClass.php’;
new PLOSHADKA someClass();
}

Similar Posts

Leave a Reply

Your email address will not be published. Required fields are marked *