PluginProbe
Double Opt-In for Contact Form 7 – Secure, GDPR-Compliant Email Verification / 3.0.3
Double Opt-In for Contact Form 7 – Secure, GDPR-Compliant Email Verification v3.0.3
5.6.1 5.6.0 5.5.0 5.4.0 5.3.2 5.3.1 5.1.6 5.1.5 trunk 2.1.5 2.11 2.12 2.13 2.15 3.0.0 3.0.1 3.0.2 3.0.3 3.0.5 3.0.51 3.0.60 3.0.61 3.0.62 3.0.70 3.0.71 All 36 releases
double-opt-in / core / TemplateHandler.class.php

TemplateHandler.class.php in Double Opt-In for Contact Form 7 – Secure, GDPR-Compliant Email Verification 3.0.3, at core/TemplateHandler.class.php

58 lines 1.3 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 namespace forge12\contactform7\CF7DoubleOptIn;
3
4 if(!defined('ABSPATH')){
5 exit;
6 }
7
8 class TemplateHandler{
9 private static ?TemplateHandler $_instance = null;
10
11 public static function getInstance() {
12 if ( self::$_instance == null ) {
13 self::$_instance = new self();
14 }
15
16 return self::$_instance;
17 }
18
19 /**
20 * Get the content of the specified template with the given attributes.
21 *
22 * @param string $template_name The name of the template file.
23 * @param array $atts The parameters sent to the template.
24 *
25 * @return string The content of the template.
26 */
27 public function getTemplate( $template_name, $atts = array() ) {
28 $template_path = plugin_dir_path( dirname(__FILE__) ) . '/templates/' . $template_name . '.php';
29
30 if ( ! is_readable( $template_path ) ) {
31 return '';
32 }
33
34 extract( $atts );
35
36 ob_start();
37 require( $template_path );
38
39 return ob_get_clean();
40 }
41
42 /**
43 * Renders the specified template with the given attributes.
44 *
45 * @param string $template_name The name of the template file.
46 * @param array $atts The parameters sent to the template.
47 */
48 public function renderTemplate( $template_name, $atts = array() ) {
49 $template = $this->getTemplate( $template_name, $atts );
50
51 if ( empty( $template ) ) {
52 return;
53 }
54
55 echo $template;
56 }
57
58 }