'widget_gso_newsletter', 'description' => __( 'Exibe o formulário global de newsletter configurado no Portfólio.', 'gustavoo-portfolio-core' ), 'customize_selective_refresh' => true, ) ); } /** * Render the widget. * * @param array $args Sidebar wrappers. * @param array $instance Saved settings. * @return void */ public function widget( $args, $instance ) { $settings = GSO_Portfolio_Settings::get_settings(); $title = ! empty( $instance['title'] ) ? (string) $instance['title'] : (string) $settings['newsletter_heading']; $text = ! empty( $instance['text'] ) ? (string) $instance['text'] : (string) $settings['newsletter_text']; $form_id = ! empty( $instance['form_id'] ) ? absint( $instance['form_id'] ) : absint( $settings['newsletter_form_id'] ); echo $args['before_widget']; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- Registered sidebar wrapper. if ( $title ) { echo $args['before_title']; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- Registered sidebar wrapper. echo esc_html( $title ); echo $args['after_title']; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- Registered sidebar wrapper. } if ( $text ) { printf( '

%s

', esc_html( $text ) ); } $form = gso_render_fluent_form( $form_id ); if ( $form ) { echo $form; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- Output is generated by Fluent Forms. } elseif ( current_user_can( 'manage_options' ) ) { printf( '

%2$s

', esc_url( admin_url( 'edit.php?post_type=' . GSO_Projects::POST_TYPE . '&page=' . GSO_Portfolio_Settings::PAGE_SLUG ) ), esc_html__( 'Configure o formulário de newsletter.', 'gustavoo-portfolio-core' ) ); } echo $args['after_widget']; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- Registered sidebar wrapper. } /** * Render widget settings. * * @param array $instance Saved settings. * @return void */ public function form( $instance ) { $title = isset( $instance['title'] ) ? (string) $instance['title'] : ''; $text = isset( $instance['text'] ) ? (string) $instance['text'] : ''; $form_id = isset( $instance['form_id'] ) ? absint( $instance['form_id'] ) : 0; ?>

$new_instance New values. * @param array $old_instance Previous values. * @return array */ public function update( $new_instance, $old_instance ) { unset( $old_instance ); return array( 'title' => isset( $new_instance['title'] ) ? sanitize_text_field( $new_instance['title'] ) : '', 'text' => isset( $new_instance['text'] ) ? sanitize_textarea_field( $new_instance['text'] ) : '', 'form_id' => isset( $new_instance['form_id'] ) ? absint( $new_instance['form_id'] ) : 0, ); } }