__( 'A sign-up form for a mailing list of your GruVer organisation, with double opt-in.', 'gruver-subscribe' ), 'customize_selective_refresh' => true, ) ); } /** * Front end. * * @param array $args Sidebar arguments. * @param array $instance Widget settings. */ public function widget( $args, $instance ): void { $instance = self::defaults( $instance ); $output = Renderer::render( array( 'list' => $instance['list'], 'view' => $instance['view'], 'name' => $instance['name'], ) ); if ( '' === $output ) { return; } $title = apply_filters( 'widget_title', $instance['title'], $instance, $this->id_base ); echo wp_kses_post( $args['before_widget'] ?? '' ); if ( '' !== (string) $title ) { echo wp_kses_post( ( $args['before_title'] ?? '' ) . esc_html( (string) $title ) . ( $args['after_title'] ?? '' ) ); } echo $output; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- escaped while rendering. echo wp_kses_post( $args['after_widget'] ?? '' ); } /** * Admin form. * * @param array $instance Widget settings. */ public function form( $instance ): string { $instance = self::defaults( $instance ); $lists = Settings::lists(); ?>

1 ) : ?>

' . esc_html__( 'settings', 'gruver-subscribe' ) . '' ); ?>

>

$new_instance Submitted settings. * @param array $old_instance Previous settings. * @return array{title: string, list: string, view: string, name: bool} */ public function update( $new_instance, $old_instance ): array { return self::defaults( array( 'title' => sanitize_text_field( (string) ( $new_instance['title'] ?? '' ) ), 'list' => sanitize_key( (string) ( $new_instance['list'] ?? '' ) ), 'view' => sanitize_key( (string) ( $new_instance['view'] ?? '' ) ), 'name' => ! empty( $new_instance['name'] ), ) ); } /** * Settings with defaults and valid values. * * @param mixed $instance Stored settings. * @return array{title: string, list: string, view: string, name: bool} */ public static function defaults( mixed $instance ): array { $instance = is_array( $instance ) ? $instance : array(); $view = (string) ( $instance['view'] ?? '' ); return array( 'title' => (string) ( $instance['title'] ?? '' ), 'list' => (string) ( $instance['list'] ?? '' ), 'view' => in_array( $view, Renderer::VIEWS, true ) ? $view : Renderer::VIEW_COMPACT, 'name' => (bool) ( $instance['name'] ?? false ), ); } }