the_widget example

$instance = unserialize( $serialized_instance );
    } else {
        $instance = array();
    }

    $args = array(
        'widget_id'   => $widget_object->id,
        'widget_name' => $widget_object->name,
    );

    ob_start();
    the_widget( $widget_key$instance$args );
    return ob_get_clean();
}

/** * Registers the 'core/legacy-widget' block. */
function register_block_core_legacy_widget() {
    register_block_type_from_metadata(
        __DIR__ . '/legacy-widget',
        array(
            'render_callback' => 'render_block_core_legacy_widget',
        )

    private function get_widget_preview( $widget$instance ) {
        ob_start();
        the_widget( $widget$instance );
        return ob_get_clean();
    }

    /** * Returns the output of WP_Widget::form() when called with the provided * instance. Used by encode_form_data() to preview a widget's form. * * @since 5.8.0 * * @param WP_Widget $widget_object Widget object to call widget() on. * @param array $instance Widget instance settings. * @return string */
Home | Imprint | This part of the site doesn't use cookies.