__( 'A collection of post tags', 'blogcast' ) ] ); } public function widget( $args, $instance ) { extract( $args ); $widget_title = ( isset( $instance['widget_title'] ) ) ? $instance['widget_title'] : ''; $post_tags = ( isset( $instance['post_tags'] ) ) ? $instance['post_tags'] : ''; echo wp_kses_post( $before_widget ); if( ! empty( $widget_title ) ) echo $before_title . esc_html( $widget_title ) .$after_title; ?>
term_taxonomy_id] = $tags->name .'('. $tags->count .')'; endforeach; $tags_options['type'] = 'tag'; return [ [ 'name' => 'widget_title', 'type' => 'text', 'title' => esc_html( 'Widget Title', 'blogcast' ), 'description' => esc_html__( 'Add the widget title here', 'blogcast' ), 'default' => esc_html__( 'Tags Collection', 'blogcast' ) ], [ 'name' => 'post_tags', 'type' => 'select-two', 'title' => esc_html__( 'Post tags', 'blogcast' ), 'description' => esc_html__( 'Choose the tags to display', 'blogcast' ), 'options' => $tags_options ] ]; } public function form( $instance ) { $widget_fields = $this->widget_fields(); foreach( $widget_fields as $widget_field ) : if( isset( $instance[ $widget_field['name'] ] ) ) : $field_value = $instance[ $widget_field['name'] ]; elseif( isset( $widget_field['default'] ) ) : $field_value = $widget_field['default']; else: $field_value = ''; endif; blogcast_widget_fields( $this, $widget_field, $field_value ); endforeach; } public function update( $new_instance, $old_instance ) { $instance = $old_instance; $widget_fields = $this->widget_fields(); if( ! is_array( $widget_fields ) ) return $instance; foreach( $widget_fields as $widget_field ) : $instance[ $widget_field['name'] ] = blogcast_sanitize_widget_fields( $widget_field, $new_instance ); endforeach; return $instance; } }