PluginProbe
GetResponse Forms by Optin Cat / 2.4.1
GetResponse Forms by Optin Cat v2.4.1
1.3.4 1.3.5 1.3.6 1.3.8 1.3.9 1.4.0 1.4.1 1.4.2 1.5.0 1.5.1 1.5.2 1.5.4 1.5.5 1.5.6 1.5.7 1.5.8 1.6.1 1.6.2 1.6.3 1.7.0 1.7.1 1.7.2 1.8.0 1.8.1 2.0.0 All 36 releases
getresponse / includes / eoi-layout.php

eoi-layout.php in GetResponse Forms by Optin Cat 2.4.1, at includes/eoi-layout.php

210 lines 5.9 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 class EasyOptInsLayout {
4 public $layout_number;
5 public $layout_type;
6 public $layout_class;
7 public $layout_id;
8
9 private $plugin_dir;
10 private $plugin_url;
11
12 public static function uses_new_css() {
13 return true;
14 }
15
16 public function __construct( $layout_id ) {
17 $this->plugin_dir = FCA_EOI_PLUGIN_DIR;
18 $this->plugin_url = FCA_EOI_PLUGIN_URL . '/';
19
20 list( $layout_type, $layout_number ) = explode( '_', $layout_id );
21
22 $this->layout_number = (int) $layout_number;
23 $this->layout_type = $layout_type == 'layout' ? 'widget' : $layout_type;
24 $this->layout_class = self::generate_layout_class( $this->layout_type );
25 $this->layout_id = $layout_id;
26 }
27
28 public function new_scss_compiler() {
29 $scss = new scssc();
30 $scss->setFormatter( 'scss_formatter_compressed' );
31 $scss->addImportPath( $this->plugin_dir );
32
33 return $scss;
34 }
35
36 public function layout_name( $id = '') {
37
38 if ( empty ( $id ) ) {
39 $id = $this->layout_id;
40 }
41
42 $layout_names = array(
43 0 => __('No CSS', 'easy-opt-ins'),
44 1 => __('Classic', 'easy-opt-ins'),
45 2 => __('Ribbon', 'easy-opt-ins'),
46 3 => __('Chevron', 'easy-opt-ins'),
47 4 => __('Modern', 'easy-opt-ins'),
48 5 => __('Light', 'easy-opt-ins'),
49 6 => __('Dark', 'easy-opt-ins'),
50 7 => __('Natural', 'easy-opt-ins'),
51 8 => __('Elegant', 'easy-opt-ins'),
52 9 => __('Bubble', 'easy-opt-ins'),
53 10 => __( 'Optin Bar Blue', 'easy-opt-ins'),
54 11 => __( 'Optin Bar Orange', 'easy-opt-ins'),
55 12 => __( 'Optin Bar White', 'easy-opt-ins'),
56 13 => __( 'Slide In Light', 'easy-opt-ins'),
57 14 => __( 'Slide In Dark', 'easy-opt-ins'),
58 15 => __( 'Rounded', 'easy-opt-ins'),
59 16 => __( 'Flat', 'easy-opt-ins'),
60 17 => __( 'Content Upgrade', 'easy-opt-ins'),
61 18 => __( 'Image', 'easy-opt-ins'),
62 19 => __( 'Padded Image', 'easy-opt-ins'),
63 20 => __( 'Wide Image', 'easy-opt-ins'),
64 21 => __( 'Content Upgrade - Image', 'easy-opt-ins'),
65 22 => __( 'Content Upgrade - Wide Image', 'easy-opt-ins'),
66 );
67
68 return $layout_names[ $this->layout_number( $id ) ];
69 }
70
71 public function layout_number( $id = '') {
72
73 if ( empty ( $id ) ) {
74 $id = $this->layout_id;
75 }
76
77 return preg_replace( '/[^0-9]/', '', $id );
78
79 }
80
81 public function screenshot_src( $id = '') {
82
83 if ( empty ( $id ) ) {
84 $id = $this->layout_id;
85 }
86
87 if ( $this->layout_type === 'widget' ) {
88 $id = str_replace( 'widget', 'layout', $id );
89 }
90
91 if ( file_exists( FCA_EOI_PLUGIN_DIR . "/layouts/screenshots/$id.png" ) ) {
92 return FCA_EOI_PLUGIN_URL . "/layouts/screenshots/$id.png";
93 }
94
95 return FCA_EOI_PLUGIN_URL . "/assets/admin/no_image.png";
96 }
97
98 public function layout_enabled() {
99
100 $path = FCA_EOI_PLUGIN_DIR . '/layouts/' . $this->layout_type . '/' . $this->layout_id;
101
102 if ( $this->layout_type === 'widget' ) {
103 $path = FCA_EOI_PLUGIN_DIR . '/layouts/' . $this->layout_type . '/layout_' . $this->layout_number;
104 }
105
106 return file_exists( $path );
107
108 }
109
110 public function layout_order( $id = '') {
111
112 if ( empty ( $id ) ) {
113 $id = $this->layout_id;
114 }
115
116 //LAYOUT ID => LAYOUT ORDER
117 $layout_order = array(
118 16, // __( 'Flat', 'easy-opt-ins'),
119 15, // __( 'Rounded', 'easy-opt-ins'),
120 2, // __('Ribbon', 'easy-opt-ins'),
121 5, // __('Light', 'easy-opt-ins'),
122 1, // __('Classic', 'easy-opt-ins'),
123 9, // __('Bubble', 'easy-opt-ins'),
124 18, // __( 'Image', 'easy-opt-ins'),
125 19, // __( 'Padded Image', 'easy-opt-ins'),
126 20, // __( 'Wide Image', 'easy-opt-ins'),
127 17, // __( 'Content Upgrade', 'easy-opt-ins'),
128 21, // __( 'Content Upgrade - Image', 'easy-opt-ins'),
129 22, // __( 'Content Upgrade - Wide Image', 'easy-opt-ins'),
130 3, // __('Chevron', 'easy-opt-ins'),
131 4, // __('Modern', 'easy-opt-ins'),
132 6, // __('Dark', 'easy-opt-ins'),
133 7, // __('Natural', 'easy-opt-ins'),
134 8, // __('Elegant', 'easy-opt-ins'),
135 10, // __( 'Optin Bar Blue', 'easy-opt-ins'),
136 11, // __( 'Optin Bar Orange', 'easy-opt-ins'),
137 12, // __( 'Optin Bar White', 'easy-opt-ins'),
138 13, // __( 'Slide In Light', 'easy-opt-ins'),
139 14, // __( 'Slide In Dark', 'easy-opt-ins'),
140 0, //__('No CSS', 'easy-opt-ins'),
141 );
142
143 return array_search ( $this->layout_number( $id ), $layout_order );
144
145 }
146
147 public function path_to_html_wrapper() {
148 return $this->plugin_dir . $this->common_path() . $this->layout_type . '.html';
149 }
150
151 public function path_to_resource( $resource_name, $resource_type ) {
152 return $this->plugin_dir . $this->subpath_to_resource( $resource_name, $resource_type );
153 }
154
155 public function url_to_resource( $resource_name, $resource_type ) {
156 return $this->plugin_url . $this->subpath_to_resource( $resource_name, $resource_type );
157 }
158
159 private static function generate_layout_class( $layout_type ) {
160 if ( $layout_type == 'lightbox' ) {
161 return 'fca_eoi_layout_popup';
162 } elseif ( $layout_type == 'postbox' ) {
163 return 'fca_eoi_layout_postbox';
164 } elseif ( $layout_type == 'widget' ) {
165 return 'fca_eoi_layout_widget';
166 } elseif ( $layout_type == 'banner' ) {
167 return 'fca_eoi_layout_banner';
168 } elseif ( $layout_type == 'overlay' ) {
169 return 'fca_eoi_layout_overlay';
170 }
171 return '';
172 }
173
174 private function subpath_to_resource( $resource_name, $resource_type ) {
175 if ( self::uses_new_css() ) {
176 if ( $resource_name == 'layout' && $resource_type == 'html' ) {
177 $new_path =
178 $this->common_path() .
179 'layout_' . $this->layout_number . '/' .
180 $resource_name . '.' . $resource_type;
181
182 if ( file_exists( $this->plugin_dir . $new_path ) ) {
183 return $new_path;
184 }
185 }
186
187 $new_path = $this->subpath() . $resource_name . '-new.' . $resource_type;
188 if ( file_exists( $this->plugin_dir . $new_path ) ) {
189 return $new_path;
190 }
191 }
192
193 $path = $this->subpath();
194
195 if ( $resource_type == 'scss' ) {
196 $resource_type = 'css';
197 }
198
199 return $path . $resource_name . '.' . $resource_type;
200 }
201
202 private function subpath() {
203 return 'layouts/' . $this->layout_type . '/' . $this->layout_id . '/';
204 }
205
206 private function common_path() {
207 return 'layouts/common/';
208 }
209 }
210