/**
  * Front-end display of widget.
  *
  * @see WP_Widget::widget()
  *
  * @param array $args
  * @param array $instance
  */
 public function widget($args, $instance)
 {
     // Prepare data for mustache template
     $page_id = absint($instance['page_id']);
     /**
      * Support for the Polylang plugin.
      * https://proteusthemes.zendesk.com/agent/tickets/5175
      * https://polylang.wordpress.com/documentation/documentation-for-developers/functions-reference/#pll_get_post
      */
     if (function_exists('pll_get_post')) {
         $page_id = pll_get_post($page_id);
     }
     $instance['layout'] = sanitize_key($instance['layout']);
     $instance['read_more_text'] = empty($instance['read_more_text']) ? esc_html__('Read more', 'proteuswidgets') : sanitize_text_field($instance['read_more_text']);
     $thumbnail_size = 'inline' === $instance['layout'] ? 'pw-inline' : 'pw-page-box';
     // Get basic page info
     if ($page_id) {
         $page = (array) get_post($page_id);
     }
     // Prepare the excerpt text
     $excerpt = !empty($page['post_excerpt']) ? $page['post_excerpt'] : $page['post_content'];
     if ('inline' === $instance['layout'] && strlen($excerpt) > $this->excerpt_lengths['inline_excerpt']) {
         $strpos = strpos($excerpt, ' ', $this->excerpt_lengths['inline_excerpt']);
         $excerpt = false !== $strpos ? substr($excerpt, 0, $strpos) . ' …' : $excerpt;
     } elseif (strlen($excerpt) > $this->excerpt_lengths['block_excerpt']) {
         $strpos = strpos($excerpt, ' ', $this->excerpt_lengths['block_excerpt']);
         $excerpt = false !== $strpos ? substr($excerpt, 0, $strpos) . ' …' : $excerpt;
     }
     $page['post_excerpt'] = sanitize_text_field($excerpt);
     $page['link'] = get_permalink($page_id);
     $page['thumbnail'] = get_the_post_thumbnail($page_id, $thumbnail_size);
     if ('block' === $instance['layout']) {
         $attachment_image_id = get_post_thumbnail_id($page_id);
         $attachment_image_data = wp_get_attachment_image_src($attachment_image_id, 'pw-page-box');
         $page['image_url'] = $attachment_image_data[0];
         $page['image_width'] = $attachment_image_data[1];
         $page['image_height'] = $attachment_image_data[2];
         $page['srcset'] = PW_Functions::get_attachment_image_srcs($attachment_image_id, array('pw-page-box', 'full'));
     }
     // Mustache widget-featured-page template rendering
     echo $this->mustache->render(apply_filters('pw/widget_featured_page_view', 'widget-featured-page'), array('args' => $args, 'page' => $page, 'instance' => $instance, 'block' => 'block' === $instance['layout']));
 }