PluginProbe
YayMail – WooCommerce Email Customizer / 4.4.7
YayMail – WooCommerce Email Customizer v4.4.7
4.4.7 4.4.6 4.4.5 4.4.4 4.4.3 4.4.2 4.4.1 trunk 1.9.6 2.1.4 2.1.5 3.2.2 3.2.6 3.2.7.1 3.2.8.1 3.2.9 3.3 3.3.1 3.3.4 3.3.5 3.3.6 3.3.7 3.3.8 3.3.9 3.4 All 58 releases
yaymail / src / Abstracts / BaseSectionTemplate.php

BaseSectionTemplate.php in YayMail – WooCommerce Email Customizer 4.4.7, at src/Abstracts/BaseSectionTemplate.php

89 lines 3.4 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 namespace YayMail\Abstracts;
3
4 /**
5 * BaseSectionTemplate Class
6 */
7 abstract class BaseSectionTemplate {
8
9 protected $icon = '<svg version="1.1" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
10 viewBox="0 0 24 24" style="enable-background:new 0 0 24 24;" xml:space="preserve">
11 <title>Third party elements</title>
12 <path d="M18,2h-7.6c-0.1,0-0.1,0-0.2,0.1l0,0c-0.1,0-0.1,0.1-0.2,0.1L4.6,7.4c0,0-0.1,0.1-0.1,0.2l0,0c0,0.1,0,0.1-0.1,0.2l0,0
13 c0,0.1,0,0.1,0,0.2v12.5C4.4,21.3,5.1,22,6,22h12c0.9,0,1.6-0.7,1.6-1.6l0,0V3.6C19.6,2.7,18.9,2,18,2L18,2z M9.8,4.5v2.7H7L9.8,4.5
14 z M18.1,20.3c0,0.1-0.1,0.2-0.2,0.2c0,0,0,0,0,0H6.1c-0.1,0-0.2-0.1-0.2-0.2c0,0,0,0,0,0V8.7h4.6c0.4,0,0.7-0.3,0.8-0.7V3.5h6.6
15 c0.1,0,0.2,0.1,0.2,0.2c0,0,0,0,0,0L18.1,20.3z M7.4,11.6c0-0.4,0.3-0.7,0.7-0.7c0,0,0,0,0,0h4.8c0.4,0,0.8,0.2,0.8,0.7
16 c0,0.4-0.2,0.8-0.7,0.8c-0.1,0-0.1,0-0.2,0H8.1C7.7,12.4,7.4,12.1,7.4,11.6C7.4,11.7,7.4,11.7,7.4,11.6z M16.6,14.6
17 c0,0.4-0.3,0.7-0.8,0.8H8.1c-0.4,0-0.8-0.3-0.8-0.8s0.3-0.8,0.8-0.8h7.7C16.3,13.9,16.6,14.2,16.6,14.6z M8.6,17.6
18 c0,0.4-0.3,0.7-0.7,0.7S7.2,18,7.2,17.6s0.3-0.7,0.7-0.7S8.6,17.2,8.6,17.6z M11,17.6c0,0.4-0.3,0.7-0.7,0.7S9.6,18,9.6,17.6
19 c0-0.4,0.3-0.7,0.7-0.7C10.7,16.9,11,17.2,11,17.6L11,17.6z M13.4,17.6c0,0.4-0.2,0.7-0.6,0.8c-0.4,0-0.7-0.2-0.8-0.6
20 c0-0.1,0-0.1,0-0.2c0-0.4,0.2-0.7,0.6-0.8c0.4,0,0.7,0.2,0.8,0.6C13.4,17.5,13.4,17.5,13.4,17.6z"/>
21 </svg>';
22
23 protected $id = null;
24 public const TYPE = '';
25 protected $group = null;
26 protected $name = null;
27
28 protected $available = true;
29 protected $position = 10;
30 protected $patterns = [];
31
32 public function get_data() {
33 return [
34 'id' => $this->id,
35 'type' => static::TYPE,
36 'group' => $this->group,
37 'name' => $this->name,
38 'icon' => $this->icon,
39 'available' => $this->available,
40 'position' => $this->position,
41 'patterns' => $this->patterns,
42 ];
43 }
44
45 public function get_id() {
46 return $this->id;
47 }
48
49 public function get_type() {
50 return static::TYPE;
51 }
52
53 public function get_patterns() {
54 return $this->patterns;
55 }
56
57 public function add_pattern( BasePattern $pattern ) {
58 $added_patterns = array_map(
59 function( $item ) {
60 return $item->get_type();
61 },
62 $this->patterns
63 );
64 if ( ! in_array( $pattern->get_type(), $added_patterns, true ) ) {
65 $this->patterns[] = $pattern;
66 }
67 }
68
69 /**
70 * Patterns are referenced by type only: their full data (elements included) is
71 * already localized once in builder.patterns. Embedding it here too doubled the
72 * inline yaymailData script to ~1MB, which some hosts truncate (ModSecurity
73 * response limits, pcre.backtrack_limit in HTML optimizers) and the SPA then
74 * never boots. SettingsPage::get_section_template_patterns_rehydrate_script()
75 * swaps the types back to the objects client-side before any bundle runs.
76 */
77 public function get_raw_data() {
78 $data = $this->get_data();
79 $data['patterns'] = array_map(
80 function( BasePattern $item ) {
81 return $item->get_type();
82 },
83 $data['patterns']
84 );
85 return $data;
86 }
87
88 }
89