A5hleyRich / wp-background-processing-example

120 stars 42 forks source link

Class not found #3

Open rachidaitouaissi opened 4 years ago

rachidaitouaissi commented 4 years ago

Hello!

Thank you for this great library!

I tried to activate your plugin but it won't activate!!, the PHP log shows

Class 'WP_Async_Request' not found in .. Class 'WP_Background_Process' not found in ...

Could you please help me fix this issue!

Thank you

dgwyer commented 4 years ago

I'm getting the same error. Can't test the plugin properly because of this.

rachidaitouaissi commented 4 years ago

Well! I fixed this issue by including the messing classes

public function __construct() {

require 'classes/wp-async-request.php'; require 'classes/wp-background-process.php';

}

Then create a folder named classes in your plugin and add these two PHP files inside the folder "download the files in the link below":

https://github.com/boonebgorges/wp-background-processing/tree/master/classes

I hope this fixes your problem.

jagirbahesh commented 4 years ago

I have also fixed this error.

First, create a new folder named classes in the plugin and add these two files to the classes folder. Here I have shared the link for downloading the files. Class files

After that, you need to add the below code in your plugin main file's construct

require_once plugin_dir_path( __FILE__ ) . 'classes/wp-async-request.php';
require_once plugin_dir_path( __FILE__ ) . 'classes/wp-background-process.php';

I have checked in my local and its working perfectly.

I hope its resolved your issue.

dariuszwit commented 1 year ago

Hello,

Here is another way to solve this issue. Actually, it is a list of "must be done" steps to connect library this the plugin. Any plugin.

  1. Run the command below in the plugin directory: ...\wp-content\plugins\wp-background-processing-example-master composer require deliciousbrains/wp-background-processing A new directory should appear: vendor wp-content\plugins\wp-background-processing-example-master\vendor

  2. Paste the line below into the file: example-plugin.php, as the first line in init function. require_once plugin_dir_path( __FILE__ ) . 'vendor/autoload.php';

You will get: public function init() { require_once plugin_dir_path( __FILE__ ) . 'vendor/autoload.php'; require_once plugin_dir_path( __FILE__ ) . 'class-logger.php'; require_once plugin_dir_path( __FILE__ ) . 'async-requests/class-example-request.php'; require_once plugin_dir_path( __FILE__ ) . 'background-processes/class-example-process.php';

Regards, Dariusz

PS. @A5hleyRich , maybe you can add this as a part of Readme.dm instruction?