esc_html__( 'Forminator Widget', 'forminator' ) ) ); } /** * Outputs the content of the widget * * @since 1.0 * * @param array $args Arguments. * @param array $instance Instance. */ public function widget( $args, $instance ) { // Print widget before markup. if ( isset( $args['before_widget'] ) && ! empty( $args['before_widget'] ) ) { echo wp_kses_post( $args['before_widget'] ); } // widget title. $title = isset( $instance['title'] ) ? $instance['title'] : ''; $title = apply_filters( 'widget_title', $title, $instance, $this->id_base ); if ( ! empty( $title ) ) { $full_title = ( isset( $args['before_title'] ) ? $args['before_title'] : '' ) . $instance['title'] . ( isset( $args['after_title'] ) ? $args['after_title'] : '' ); echo wp_kses_post( $full_title ); } // Make sure $form_type is set. if ( isset( $instance['form_type'] ) && ! empty( $instance['form_type'] ) ) { switch ( $instance['form_type'] ) { case 'form': if ( isset( $instance['form_id'] ) && ! empty( $instance['form_id'] ) ) { echo forminator_form( $instance['form_id'], false ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- Content loaded from template file. } break; case 'poll': if ( isset( $instance['poll_id'] ) && ! empty( $instance['poll_id'] ) ) { echo forminator_poll( $instance['poll_id'], false ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- Content loaded from template file. } break; case 'quiz': if ( isset( $instance['quiz_id'] ) && ! empty( $instance['quiz_id'] ) ) { echo forminator_quiz( $instance['quiz_id'], false ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- Content loaded from template file. } break; default: break; } } // Print widget after markup. if ( isset( $args['after_widget'] ) && ! empty( $args['after_widget'] ) ) { echo wp_kses_post( $args['after_widget'] ); } } /** * Outputs the options form on admin * * @since 1.0 * @since 1.3 add return empty string to comply with WP_Widget * * @param array $instance The widget options. * * @return string */ public function form( $instance ) { $widget_title = ''; $form_type = ''; $form_id = ''; $poll_id = ''; $quiz_id = ''; if ( isset( $instance['title'] ) ) { $widget_title = $instance['title']; } if ( isset( $instance['form_type'] ) ) { $form_type = $instance['form_type']; } if ( isset( $instance['form_id'] ) ) { $form_id = $instance['form_id']; } if ( isset( $instance['poll_id'] ) ) { $poll_id = $instance['poll_id']; } if ( isset( $instance['quiz_id'] ) ) { $quiz_id = $instance['quiz_id']; } $form_style = '' === $form_type || 'form' === $form_type ? 'block' : 'none'; $poll_style = 'poll' === $form_type ? 'block' : 'none'; $quiz_style = 'quiz' === $form_type ? 'block' : 'none'; ?>