/** * 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']; } }