register_widget( self::class ) ); add_filter( 'widget_types_to_hide_from_legacy_widget_block', static fn( $types ) => array_merge( (array) $types, [ 'remaily_form' ] ) ); } /** * Constructor */ public function __construct() { parent::__construct( 'remaily_form', __( 'Re:Maily Contact Form', 'remaily' ), [ 'description' => __( 'A form made with Re:Maily.', 'remaily' ), 'customize_selective_refresh' => true, ] ); } /** * Front end * * @param array $args Sidebar arguments * @param array $instance Settings */ public function widget( $args, $instance ) { $html = Renderer::render( (string) ( $instance['form'] ?? '' ) ); if ( '' === $html ) { return; } $title = apply_filters( 'widget_title', (string) ( $instance['title'] ?? '' ), $instance, $this->id_base ); echo wp_kses_post( $args['before_widget'] ); if ( '' !== $title ) { echo wp_kses_post( $args['before_title'] ) . esc_html( $title ) . wp_kses_post( $args['after_title'] ); } echo wp_kses( $html, remaily_allowed_html( $html ) ); echo wp_kses_post( $args['after_widget'] ); } /** * Settings form * * @param array $instance Settings * * @return string */ public function form( $instance ) { $forms = get_posts( [ 'post_type' => PostType::NAME, 'post_status' => 'publish', 'posts_per_page' => 200, 'orderby' => 'title', 'order' => 'ASC' ] ); ?>
sanitize_text_field( (string) ( $new_instance['title'] ?? '' ) ), 'form' => sanitize_key( (string) ( $new_instance['form'] ?? '' ) ), ]; } }