/**
 * Output a template part.
 *
 * This function is functionally identical to `get_template_part()`. In addition, it allows you to pass in
 * variables for use in the template part using the `$vars` argument, which will then be available in the
 * `$this->vars` property from within the template part.
 *
 * @param string $slug The slug name for the generic template.
 * @param string $name The name of the specialised template.
 * @param array  $vars Variables for use within the template part.
 * @param array  $args {
 *     Arguments for the template part.
 *
 *     @type int|false $cache The number of seconds this template part should be cached for, or boolean false
 *                            for no caching. Default false.
 *     @type string    $dir   The theme subdirectory to look in for template parts. Default 'template-parts'.
 * }
 */
function get_extended_template_part($slug, $name = '', array $vars = [], array $args = [])
{
    $template = new Extended_Template_Part($slug, $name, $vars, $args);
    echo $template->get_output();
    // WPCS: XSS ok.
}
 /**
  * Output the widget.
  *
  * This method controls locating the template, handling caching, and outputting the widget's contents.
  *
  * @param array $args     Display arguments including 'before_title', 'after_title',
  *                        'before_widget', and 'after_widget'.
  * @param array $instance The settings for the particular instance of the widget.
  */
 public final function widget($args, $instance)
 {
     $this->args = $args;
     $this->instance = $instance;
     $template_args = ['dir' => 'widgets'];
     if (isset($this->widget_options['cache'])) {
         $template_args['cache'] = absint($this->widget_options['cache']);
     }
     if (!class_exists('Extended_Template_Part')) {
         return;
     }
     $template_vars = array_merge($this->args, $this->instance);
     $template = new Extended_Template_Part($this->get_template_slug(), $this->get_template_name(), $template_vars, $template_args);
     if (!$template->has_template()) {
         return;
     }
     if ($this->has_wrapper()) {
         echo $this->args['before_widget'];
     }
     if ($title = $this->get_title()) {
         echo $this->args['before_title'] . esc_html($title) . $this->args['after_title'];
     }
     if (false === $template->args['cache'] || !($output = $template->get_cache())) {
         $template->set_vars($this->get_vars());
         $output = $template->get_output();
     }
     echo $output;
     if ($this->has_wrapper()) {
         echo $this->args['after_widget'];
     }
 }