Widget Module does not work with pre-instantiated widgets
-
If a widget is registered using the pre-instantiated registration introduced in WP 4.6, the widget module in BB doesn’t work with that widget. When you try to add the widget to the page/post, Beaver Builder displays “[really long string] no longer exists.”
This can be duplicated with the Core Recent posts widget, modified per this example. Note that there are errors in the .diff code (the sprintf lines are set up incorrectly and the $post_type_obj uses the wrong function), which can be corrected with this updated method:
public function __construct( $post_type = 'post' ) { $this->post_type = $post_type; $post_type_obj = get_post_type_object( $post_type ); $widget_ops = array( 'classname' => 'widget_recent_entries', 'description' => sprintf( __( 'Your site’s most recent %s.' ), $post_type_obj->labels->name ), ); $id_base = sprintf( 'recent-%s', $post_type === 'post' ? 'posts' : "$post_type-posts" ); parent::__construct( $id_base, sprintf( __( 'Recent %s' ), $post_type_obj->labels->name ), $widget_ops ); $this->alt_option_name = 'widget_recent_entries'; }
I tried to look through the Beaver Builder code to see if I could offer a revision, but decided I would be completely and totally guessing. If I can help narrow it down, though, please let me know. Thank you!
- The topic ‘Widget Module does not work with pre-instantiated widgets’ is closed to new replies.