Closed
Description
Version
- Carbon Fields: htmlburger/carbon-fields, v3.3.0
- WordPress: 5.7
- PHP: 7.4
Actual Behavior
Pages and posts edit page in WP admin throw this error message in the console:
Could not find DOM element for container "carbon_fields_container_carbon_fields_widget_podcasts-2".
A blank page is loaded, and the WordPress editor is not accessible.
Container definition
class ThemeWidgetExample extends Widget {
// Register widget function. Must have the same name as the class
function __construct() {
$this->setup( 'widget_podcasts', 'Widget Podcasts', 'Widget Podcasts', array(
Field::make( 'text', 'widget_podcasts_title', 'Widget Title' ),
Field::make( 'complex', 'podcasts', 'Podcasts' )
->add_fields( array(
Field::make('text', 'link', 'Podcast Link'),
Field::make('image', 'image_id', 'Podcast Link Image')
) )
) );
}
// Called when rendering the widget in the front-end
function front_end( $args, $instance ) {
echo $args['before_title'] . $instance['widget_podcasts_title'] . $args['after_title'];
$html = '<ul class="podcasts">';
foreach ($instance['podcasts'] as $key => $podcast) {
$html .= '<li class="podcast">';
$html .= '<a href="' . $podcast['link'] . '" rel="noopener nofollow" target="_blank">';
$html .= '<figure class="podcast__image">';
$html .= wp_get_attachment_image($podcast['image_id'], 'medium');
$html .= '</figure> <!-- ./podcast__image -->';
$html .= '</a> ';
$html .= '</li> <!-- ./podcast -->';
}
$html .= '</ul>';
echo $html;
}
}
function load_widgets() {
register_widget( 'ThemeWidgetExample' );
}
add_action( 'widgets_init', 'load_widgets' );
Steps to Reproduce the Problem
- Update htmlburger/carbon-fields to v3.3.0
- Register the widget with the given definition above.
- Add the new widget to a custom wordpress sidebar in the admin panel. The sidebar is registered as it follows:
register_sidebar(array(
'name' => 'Podcast Sidebar',
'id' => 'podcast',
'class' => 'widgets',
'before_widget' => '<li id="%1$s" class="widget %2$s">',
'after_widget' => '</li>',
'before_title' => '<h2 class="widget__title">',
'after_title' => '</h2>',
));
- Go to Pages or Posts and try to edit a post.
Metadata
Metadata
Assignees
Labels
No labels