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

Widget issue after update to 3.3.0 #984

Closed
dy-git-hub opened this issue Apr 5, 2021 · 2 comments
Closed

Widget issue after update to 3.3.0 #984

dy-git-hub opened this issue Apr 5, 2021 · 2 comments
Assignees

Comments

@dy-git-hub
Copy link

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

  1. Update htmlburger/carbon-fields to v3.3.0
  2. Register the widget with the given definition above.
  3. 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>',
        ));
  1. Go to Pages or Posts and try to edit a post.
@daniloalvess
Copy link

I've got the same problem after upgrade to 3.3 version...

@jorostoyanov jorostoyanov self-assigned this Apr 6, 2021
@jorostoyanov
Copy link
Contributor

Fixed in v3.3.1 :)

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

3 participants