anniesp04
Forum Replies Created
-
Forum: Plugins
In reply to: [Carbon Fields] Load carbon fields with theme if plugin is not activeThanks, but unfortunatelly it’s still not working as expected.
If the plugin is active, the widget code works. If i require carbon-fields.php from the themes folder as suggest on the last reply (with the plugin deactivated) it also works.
The problem is if an already registered user has the plugin activated, it gives me the “Fatal error: Class ‘Carbon_Fields\Widget’ not found in C:\xampp\htdocs\new\wp-content\themes\newtheme\widgets.php on line 7” error even using this code:
add_action( 'after_setup_theme', 'crb_setup_theme' ); function crb_setup_theme() { // check if Carbon Fields is not already installed if ( ! class_exists( '\\Carbon_Fields\\Field\\Field' ) ) { require( __DIR__ . '/libs/carbon-fields/carbon-fields-plugin.php' ); } }
Ideally, I’d have Carbon Fields installed by default on every blog, but I’m not allowed to do it this way, so I have to check it and only load it from the theme only if the plugin is not already activated. Sorry for bothering you with this, but php isn’t very advanced.
Thanks!
Forum: Plugins
In reply to: [Carbon Fields] Load carbon fields with theme if plugin is not activeThansks for the reply!
I was told to load a copy of the plugin with the theme, so i have to stick to that instead of Composer.
I’ve added the above code and it gave me the following error:
Fatal error: Class ‘Carbon_Fields\Widget’ not found in C:\xampp\htdocs\new\wp-content\themes\newtheme\widgets.php on line 7
Before adding the code, the site was loading fine, any suggestions on how to fix it?
Thanks!