PluginProbe
EmailKit – Email Customizer for WooCommerce & WP / 1.2.0
EmailKit – Email Customizer for WooCommerce & WP v1.2.0
1.6.9 1.6.8 1.6.7 trunk 1.0.0 1.2.0 1.4.0 1.4.5 1.5.0 1.5.1 1.5.2 1.5.3 1.5.4 1.5.5 1.5.6 1.5.7 1.5.8 1.5.9 1.6.0 1.6.1 1.6.2 1.6.3 1.6.4 1.6.5 1.6.6
emailkit / includes / Admin / TemplateList.php

TemplateList.php in EmailKit – Email Customizer for WooCommerce & WP 1.2.0, at includes/Admin/TemplateList.php

185 lines 7.5 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 namespace EmailKit\Admin;
3
4 use EmailKit\Admin\Emails\EmailLists;
5 defined( 'ABSPATH' ) || exit;
6
7 Class TemplateList{
8 const EMAILKIT_URL_TEMAPLTE_DIR = EMAILKIT_DIR. "includes/";
9 const EMAILKIT_URL_TEMAPLTE_URL = EMAILKIT_URL. "includes/";
10
11 public static function get_templates(){
12
13
14 $template_list = [
15 'template-1' => [
16 'id' => 1,
17 'package' => 'free',
18 'mail_type' => 'woocomerce-email',
19 'title' => EmailLists::NEW_ORDER,
20 'preview-thumb' => self::EMAILKIT_URL_TEMAPLTE_URL . 'templates/1/preview-thumb.svg',
21 'demo-url' => 'https://wpmet.com/',
22 'file' => self::EMAILKIT_URL_TEMAPLTE_DIR . 'templates/1/content.json',
23 ],
24 'template-2' => [
25 'id' => 2,
26 'package' => 'free',
27 'mail_type' => 'woocomerce-email',
28 'title' => EmailLists::CANCELLED_ORDER,
29 'preview-thumb' => self::EMAILKIT_URL_TEMAPLTE_URL . 'templates/2/preview-thumb.svg',
30 'demo-url' => 'https://wpmet.com/',
31 'file' => self::EMAILKIT_URL_TEMAPLTE_DIR . 'templates/2/content.json',
32
33 ],
34 'template-3' => [
35 'id' => 3,
36 'package' => 'free',
37 'mail_type' => 'woocomerce-email',
38 'title' => EmailLists::FAILED_ORDER,
39 'preview-thumb' => self::EMAILKIT_URL_TEMAPLTE_URL . 'templates/3/preview-thumb.svg',
40 'demo-url' => 'https://wpmet.com/',
41 'file' => self::EMAILKIT_URL_TEMAPLTE_DIR . 'templates/3/content.json',
42 ],
43 'template-4' => [
44 'id' => 4,
45 'package' => 'free',
46 'mail_type' => 'woocomerce-email',
47 'title' => EmailLists::ORDER_ON_HOLD,
48 'preview-thumb' => self::EMAILKIT_URL_TEMAPLTE_URL . 'templates/4/preview-thumb.svg',
49 'demo-url' => 'https://wpmet.com/',
50 'file' => self::EMAILKIT_URL_TEMAPLTE_DIR . 'templates/4/content.json',
51 ],
52 'template-5' => [
53 'id' => 5,
54 'package' => 'free',
55 'mail_type' => 'woocomerce-email',
56 'title' => EmailLists::PROCESSING_ORDER,
57 'preview-thumb' => self::EMAILKIT_URL_TEMAPLTE_URL . 'templates/5/preview-thumb.svg',
58 'demo-url' => 'https://wpmet.com/',
59 'file' => self::EMAILKIT_URL_TEMAPLTE_DIR . 'templates/5/content.json',
60 ],
61 'template-6' => [
62 'id' => 6,
63 'package' => 'free',
64 'mail_type' => 'woocomerce-email',
65 'title' => EmailLists::COMPLETED_ORDER,
66 'preview-thumb' => self::EMAILKIT_URL_TEMAPLTE_URL . 'templates/6/preview-thumb.svg',
67 'demo-url' => 'https://wpmet.com/',
68 'file' => self::EMAILKIT_URL_TEMAPLTE_DIR . 'templates/6/content.json'
69 ],
70 'template-7' => [
71 'id' => 7,
72 'package' => 'free',
73 'mail_type' => 'woocomerce-email',
74 'title' => EmailLists::REFUNDED_ORDER,
75 'preview-thumb' => self::EMAILKIT_URL_TEMAPLTE_URL . 'templates/7/preview-thumb.svg',
76 'demo-url' => 'https://wpmet.com/',
77 'file' => self::EMAILKIT_URL_TEMAPLTE_DIR . 'templates/7/content.json'
78 ],
79 'template-8' => [
80 'id' => 8,
81 'package' => 'free',
82 'mail_type' => 'woocomerce-email',
83 'title' => EmailLists::CUSTOMER_INVOICE_OR_ORDER_DETAILS,
84 'preview-thumb' => self::EMAILKIT_URL_TEMAPLTE_URL . 'templates/8/preview-thumb.svg',
85 'demo-url' => 'https://products.wpmet.com/metform/job-listing-form/',
86 'file' => self::EMAILKIT_URL_TEMAPLTE_DIR . 'templates/8/content.json'
87 ],
88 'template-9' => [
89 'id' => 9,
90 'package' => 'free',
91 'mail_type' => 'woocomerce-email',
92 'title' => EmailLists::CUSTOMER_NOTE,
93 'preview-thumb' => self::EMAILKIT_URL_TEMAPLTE_URL . 'templates/9/preview-thumb.svg',
94 'demo-url' => 'https://wpmet.com/',
95 'file' => self::EMAILKIT_URL_TEMAPLTE_DIR . 'templates/9/content.json'
96 ],
97 'template-10' => [
98 'id' => 10,
99 'package' => 'free',
100 'mail_type' => 'woocomerce-email',
101 'title' => EmailLists::NEW_ACCOUNT,
102 'preview-thumb' => self::EMAILKIT_URL_TEMAPLTE_URL . 'templates/10/preview-thumb.svg',
103 'demo-url' => 'https://wpmet.com/',
104 'file' => self::EMAILKIT_URL_TEMAPLTE_DIR . 'templates/10/content.json'
105 ],
106
107 'template-11' => [
108 'id' => 11,
109 'package' => 'free',
110 'mail_type' => 'woocomerce-email',
111 'title' => EmailLists::RESET_PASSWORD,
112 'preview-thumb' => self::EMAILKIT_URL_TEMAPLTE_URL . 'templates/11/preview-thumb.svg',
113 'demo-url' => 'https://wpmet.com/',
114 'file' => self::EMAILKIT_URL_TEMAPLTE_DIR . 'templates/11/content.json'
115 ],
116 'template-12' => [
117 'id' => 12,
118 'package' => 'pro',
119 'mail_type' => 'wordpress-email',
120 'title' => EmailLists::WP_NEW_REGISTER,
121 'preview-thumb' => self::EMAILKIT_URL_TEMAPLTE_URL . 'templates/10/preview-thumb.svg',
122 'demo-url' => 'https://wpmet.com/',
123 'file' => '',
124 ],
125 'template-13' => [
126 'id' => 13,
127 'package' => 'pro',
128 'mail_type' => 'wordpress-email',
129 'title' => EmailLists::WP_RESET_PASSWORD,
130 'preview-thumb' => self::EMAILKIT_URL_TEMAPLTE_URL . 'templates/10/preview-thumb.svg',
131 'demo-url' => 'https://wpmet.com/',
132 'file' => ''
133 ],
134
135
136 ];
137
138 return apply_filters( 'emailkit/editor/templates', $template_list );
139 }
140
141
142 /**
143 * Get template list by form type
144 *
145 * @param string $mail_type
146 * @return array
147 */
148 public function get_templates_by_mail_type( $mail_type ) {
149 $templates_list = [];
150
151 // array filter
152 $templates_list = array_filter( $this->get_templates(), function( $template ) use ( $mail_type ) {
153 if(isset($template['mail_type'])){
154 return $template['mail_type'] === $mail_type;
155 }
156
157 return true;
158 } );
159
160 return $templates_list;
161 }
162
163 public function get_template_contents($id){
164
165 if(!array_key_exists($id, $this->get_templates()) || !file_exists($this->get_templates()[$id]['file'])){
166 return null;
167 }
168
169 $template_file_url = self::abs_path_to_url($this->get_templates()[$id]['file']);
170 $content = wp_remote_get($template_file_url, ['sslverify' => false]);
171 $content = json_decode(wp_remote_retrieve_body($content));
172
173 return (!isset($content->content)) ? null : $content->content;
174 }
175
176 public static function abs_path_to_url( $path = '' ) {
177 $url = str_replace(
178 wp_normalize_path( untrailingslashit( ABSPATH ) ),
179 site_url(),
180 wp_normalize_path( $path )
181 );
182 return esc_url_raw( $url );
183 }
184
185 }