'allioc-chatbot-widget', 'description' => __( 'Adds a chatbot powered by Dialogflow.', 'Allio' ) ); $control_ops = array( 'width' => 400, 'height' => 350 ); parent::__construct( $id_base, $name, $widget_opts, $control_ops ); } /** * (non-PHPdoc) * @see WP_Widget::widget() */ function widget( $args, $instance ) { extract( $args ); $general_settings = (array) get_option( 'allioc_general_settings' ); $debug = isset( $general_settings['debug'] ) ? $general_settings['debug'] : false; $header = isset( $instance['header'] ) ? $instance['header'] : 'h3'; $title = apply_filters( 'widget_title', ! isset( $instance['title'] ) ? __( 'Chatbot', 'Allio' ) : $instance['title'], $instance, $this->id_base ); $before_title = '<' . $header . ' class="widget-title">'; $after_title = ''; echo $before_widget; allioc_get_template_part( 'chatbot-widget', null, true, array( 'title' => $title, 'before_title' => $before_title, 'after_title' => $after_title, 'class' => 'allioc-chatbot-widget', 'debug' => $debug, 'input_text' => $general_settings['input_text'], 'sequence' => Allio::$sequence++ ) ); echo $after_widget; } /** * (non-PHPdoc) * @see WP_Widget::update() */ function update( $new_instance, $old_instance ) { $instance = $old_instance; $headers = array ('h1', 'h2', 'h3', 'h4', 'h5', 'h6' ); if ( in_array( $new_instance['header'], $headers ) ) { $instance['header'] = $new_instance['header']; } $instance['title'] = strip_tags( $new_instance['title'] ); return $instance; } /** * (non-PHPdoc) * @see WP_Widget::form() */ function form( $instance ) { $instance = wp_parse_args( (array) $instance, array( 'title' => __( 'Chatbot', 'Allio'), 'header' => 'h3' ) ); $header = $instance['header']; $title = $instance['title']; ?>