Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to load dependencies that extend other classes #569

Open
sc00 opened this issue Aug 31, 2021 · 2 comments
Open

How to load dependencies that extend other classes #569

sc00 opened this issue Aug 31, 2021 · 2 comments

Comments

@sc00
Copy link

sc00 commented Aug 31, 2021

I'd like to load ColorAlpha as a dependency in my plugin.

I've tried to use...

require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-color-alpha.php';

... in includes/class-my-plugin.php with the load_dependencies() method, but I get a critical error.

Apparently the problem lies with the dependency being a class, that extends another class:

namespace WPTRT\Customize\Control;

use WP_Customize_Color_Control;

class ColorAlpha extends WP_Customize_Color_Control { 
   ...
}

Does anyone know how to solve this?

@VoHoTv
Copy link

VoHoTv commented Sep 1, 2021

The fact that the class simple extends another class cannot be the issue. Do you have any error message? Did you make sure WP_Customize_Color_Control is available when extending it? Is the file path to the class correct?

@sc00
Copy link
Author

sc00 commented Sep 1, 2021

The fact that the class simple extends another class cannot be the issue. Do you have any error message? Did you make sure WP_Customize_Color_Control is available when extending it? Is the file path to the class correct?

No specific error message - only the generic wordpress one (critical error). The file path is correct. Once I omit the "extends"-part, I can access the CMS with no issues. I guess WP_Customize_Color_Control is not available when the dependencies are being loaded then. Do you know how I can check for that or make it available? Or is it perhaps recommended to load the dependency from a $plugin_admin method?

I was actually able to make it work with this method. But it feels like it's the wrong location to place it..

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

No branches or pull requests

2 participants