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

Is this framework dead ? #1249

Open
mark-alexandre opened this issue Aug 17, 2024 · 3 comments
Open

Is this framework dead ? #1249

mark-alexandre opened this issue Aug 17, 2024 · 3 comments

Comments

@mark-alexandre
Copy link

Version

  • Carbon Fields: 3.6.5
  • WordPress: 6.6.1
  • PHP: 8.2

Expected Behavior

The plugin/framework has to work

Actual Behavior

The plugin is detected and activated, Carbon classes are correctly loaded, and the options page I have created appears... but without any fields.

Container definition

use Carbon_Fields\Container;
use Carbon_Fields\Field;

add_action( 'carbon_fields_register_fields', 'crb_attach_theme_options' );
function crb_attach_theme_options() {
    error_log('carbon_fields_register_fields hook called');
    Container::make( 'theme_options', __( 'Theme Options' ) )
        ->add_fields( array(
            Field::make( 'text', 'crb_text', 'Text Field' ),
            Field::make( 'text', 'crb_text2', 'Text Field 2' ),
        ) );
}

add_action( 'after_setup_theme', 'crb_load' );
function crb_load() {
    \Carbon_Fields\Carbon_Fields::boot();
}

Comments

Just tried the framework, but if a simple code like this one which comes from the documentation doesn't work, it's because the plugin itself seems to have problems. The only error I have spotted with this plugin active is this very generic one : "[17-Aug-2024 15:58:52 UTC] PHP Warning: foreach() argument must be of type array|object, null given in /var/www/public/wordpress/wp-admin/includes/plugin.php on line 1853"

Is this a problem with the latest Wordpress version ? Is this plugin mainained or not ?

Regards.

@akvedi
Copy link

akvedi commented Aug 18, 2024

It looks like you are using Composer to install the plugin, but forgot to require the Composer autoload.php file.

Look here:

use Carbon_Fields\Container;
use Carbon_Fields\Field;

add_action( 'carbon_fields_register_fields', 'crb_attach_theme_options' );
function crb_attach_theme_options() {
    error_log('carbon_fields_register_fields hook called');
    Container::make( 'theme_options', __( 'Theme Options' ) )
        ->add_fields( array(
            Field::make( 'text', 'crb_text', 'Text Field' ),
            Field::make( 'text', 'crb_text2', 'Text Field 2' ),
        ) );
}

add_action( 'after_setup_theme', 'crb_load' );
function crb_load() {
    require_once( 'vendor/autoload.php' );  // required to boot the plugin
    \Carbon_Fields\Carbon_Fields::boot();
}

@mark-alexandre
Copy link
Author

mark-alexandre commented Aug 18, 2024

It looks like you are using Composer to install the plugin, but forgot to require the Composer autoload.php file.

Hi,
Thanks but I'm requiring correctly the Composer autoload... but elsewhere. I use Vinkla/Wordplate, and the Composer autoload is just loaded in the wp-config.php file :

image

@akvedi
Copy link

akvedi commented Aug 18, 2024

It looks like you are using Composer to install the plugin, but forgot to require the Composer autoload.php file.

Hi, Thanks but I'm requiring correctly the Composer autoload... but elsewhere. I use Vinkla/Wordplate, and the Composer autoload is just loaded in the wp-config.php file :

Oh then the composer version will not work. The only option you have is to use non composer version.

Download the latest zip file form https://carbonfields.net/zip/latest/ and extract it into public/plugins/ folder

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