Roots Discourse

Wordpress backoffice doesn't import Carbon fields javascript packages with Bedrock roots stack mu-plugins

I’m setting up a new WordPress project with Trellis roots stack. I tried an installation with carbon fields as must used plugin. But I can’t make it worked. The containers shows up but impossible to have some fields displayed.

I have tried many possibilities from many versions from the carbon fields documentation. But I currently working with the v3 and the trellis stack seems to be a big problem to handle.

`add_action('after_setup_theme', 'crb_load');

function crb_load()
{
\Carbon_Fields\Carbon_Fields::boot();
}

add_action(‘carbon_fields_register_fields’, ‘crb_attach_theme_options’);
function crb_attach_theme_options()
{
Container::make(‘theme_options’, __(‘Theme Options’, ‘crb’))->add_fields(
array(Field::make(‘rich_text’, ‘crb_footer_copyright’, ‘Copyright’))
);

Container::make('post_meta', 'Homepage slider')
    ->show_on_template('templates/custom-template.php')
    ->add_fields(array(
        Field::make('map', 'crb_location')->set_position(
            37.423156,
            -122.084917,
            14
        ),
        Field::make('sidebar', 'crb_custom_sidebar'),
        Field::make('image', 'crb_photo')
    ));

Block::make(__('My Shiny Gutenberg Block'))
    ->add_fields(array(
        Field::make('text', 'heading', __('Block Heading')),
        Field::make('image', 'image', __('Block Image')),
        Field::make('rich_text', 'content', __('Block Content'))
    ))
    ->set_render_callback(function ($block) {
        ?>

    <div class="block">
        <div class="block__heading">
            <h1><?php echo esc_html($block['heading']); ?></h1>
        </div><!– /.block__heading –>
        <div class="block__image">
            <?php echo wp_get_attachment_image($block['image'], 'full'); ?>
        </div><!– /.block__image –>

        <div class="block__content">
            <?php echo apply_filters('the_content', $block['content']); ?>
        </div><!– /.block__content –>
    </div><!– /.block –>

    <?php
    });

}`

`GET http://localhost:3000/wp/core/Libraries/Sidebar_Manager/assets/js/app.js?ver=3.1.3 404 (Not Found)

admin.php?page=crb_carbon_fields_container_theme_options.php:1879 GET http://localhost:3000/wp/build/classic/vendor.js?ver=3.1.3 net::ERR_ABORTED 404 (Not Found)
admin.php?page=crb_carbon_fields_container_theme_options.php:1880 GET http://localhost:3000/wp/build/classic/core.js?ver=3.1.3 net::ERR_ABORTED 404 (Not Found)
admin.php?page=crb_carbon_fields_container_theme_options.php:1881 GET http://localhost:3000/wp/build/classic/metaboxes.js?ver=3.1.3 net::ERR_ABORTED 404 (Not Found)
admin.php?page=crb_carbon_fields_container_theme_options.php:1879 GET http://localhost:3000/wp/build/classic/vendor.js?ver=3.1.3 net::ERR_ABORTED 404 (Not Found)
admin.php?page=crb_carbon_fields_container_theme_options.php:1880 GET http://localhost:3000/wp/build/classic/core.js?ver=3.1.3 net::ERR_ABORTED 404 (Not Found)
admin.php?page=crb_carbon_fields_container_theme_options.php:1881 GET http://localhost:3000/wp/build/classic/metaboxes.js?ver=3.1.3 net::ERR_ABORTED 404 (Not Found)
admin.php?page=crb_carbon_fields_container_theme_options.php:1994 Uncaught TypeError: Cannot read property ‘initialize’ of undefined
at admin.php?page=crb_carbon_fields_container_theme_options.php:1994`

There are the errors, I don’t know how and to clear the path of all of this calls.

Thanks in advance !

Are you installing carbon fields as plugin or as package? And are you loading it using composer?

Because of if you just use this zip you don’t need the autoloader I believe. https://docs.carbonfields.net/#/plugin-quickstart?id=without-composer

1 Like

As package, I don’t have made the difference, it’s now fixed after adding “mnsami/composer-custom-directory-installer”, thanks !

I’ve tried so many things that both where installed at a moment, creating others problems apparently…