Skip to content
This repository has been archived by the owner on Mar 20, 2023. It is now read-only.

Class not found #3

Open
rachidaitouaissi opened this issue Jun 26, 2020 · 4 comments
Open

Class not found #3

rachidaitouaissi opened this issue Jun 26, 2020 · 4 comments

Comments

@rachidaitouaissi
Copy link

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
Copy link

dgwyer commented Aug 10, 2020

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

@rachidaitouaissi
Copy link
Author

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
Copy link

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
Copy link

dariuszwit commented Mar 19, 2023

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?

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants