PluginProbe
E2Pdf – Export Pdf Tool for WordPress / 1.07.11
E2Pdf – Export Pdf Tool for WordPress v1.07.11
1.32.49 1.32.48 1.32.43 1.32.40 1.32.34 1.32.32 1.32.31 1.32.26 1.32.22 1.32.23 1.32.18 1.32.17 1.32.15 trunk 1.00.00 1.00.13 1.01.01 1.02.02 1.03.07 1.04.07 1.05.03 1.06.02 1.07.11 1.08.00 1.08.06 All 72 releases
e2pdf / classes / model / e2pdf-options.php

e2pdf-options.php in E2Pdf – Export Pdf Tool for WordPress 1.07.11, at classes/model/e2pdf-options.php

485 lines 22.9 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 /**
4 * E2pdf Options Helper
5 *
6 * @copyright Copyright 2017 https://e2pdf.com
7 * @license GPL v2
8 * @version 1
9 * @link https://e2pdf.com
10 * @since 0.00.01
11 */
12 if (!defined('ABSPATH')) {
13 die('Access denied.');
14 }
15
16 class Model_E2pdf_Options extends Model_E2pdf_Model {
17
18 /**
19 * Get Options list
20 *
21 * @param bool $all - Get all options
22 * @param array $exclude_group - Array list of groups to exclude from the list
23 *
24 * @return array() - List of options
25 */
26 function __construct() {
27 parent::__construct();
28 }
29
30 public static function get_options($all = true, $only_group = array(), $exclude = false) {
31 $helper = Helper_E2pdf_Helper::instance();
32
33 $extensions_options = array();
34 if ($all) {
35 $extensions_options[] = array(
36 'key' => 'e2pdf_disabled_extensions',
37 'value' => !is_array(get_option('e2pdf_disabled_extensions')) ? array() : get_option('e2pdf_disabled_extensions'),
38 );
39 } else {
40 $model_e2pdf_extension = new Model_E2pdf_Extension();
41 $extensions = $model_e2pdf_extension->extensions(false);
42 $disabled_extensions = !is_array(get_option('e2pdf_disabled_extensions')) ? array() : get_option('e2pdf_disabled_extensions');
43 foreach ($extensions as $extension) {
44 $extensions_options[] = array(
45 'name' => ucfirst($extension),
46 'key' => 'e2pdf_disabled_extensions[]',
47 'value' => in_array($extension, $disabled_extensions) ? $extension : '',
48 'checkbox_value' => $extension,
49 'placeholder' => __('Disable', 'e2pdf'),
50 'type' => 'checkbox',
51 );
52 }
53 if (isset($extensions_options['0'])) {
54 $extensions_options['0']['header'] = __('Extensions', 'e2pdf');
55 }
56 }
57
58 $options = array(
59 'static_group' => array(
60 'name' => __('Static', 'e2pdf'),
61 'options' => array(
62 array(
63 'key' => 'e2pdf_version',
64 'value' => $helper->get('version')
65 ),
66 array(
67 'key' => 'e2pdf_license',
68 'value' => get_option('e2pdf_license') === false ? false : get_option('e2pdf_license'),
69 ),
70 array(
71 'key' => 'e2pdf_email',
72 'value' => get_option('e2pdf_email') === false ? false : get_option('e2pdf_email'),
73 ),
74 array(
75 'key' => 'e2pdf_templates_screen_per_page',
76 'value' => get_option('e2pdf_templates_screen_per_page') === false ? '20' : get_option('e2pdf_templates_screen_per_page'),
77 )
78 )
79 ),
80 'common_group' => array(
81 'name' => __('Common', 'e2pdf'),
82 'options' => array(
83 array(
84 'name' => __('API Server', 'e2pdf'),
85 'key' => 'e2pdf_api',
86 'value' => get_option('e2pdf_api') === false ? 'api.e2pdf.com' : get_option('e2pdf_api'),
87 'default_value' => 'api.e2pdf.com',
88 'type' => 'text',
89 'class' => '',
90 'placeholder' => 'api.e2pdf.com',
91 'readonly' => 'readonly'
92 ),
93 array(
94 'name' => __('PDF Processor', 'e2pdf'),
95 'key' => 'e2pdf_processor',
96 'value' => get_option('e2pdf_processor') === false ? '0' : get_option('e2pdf_processor'),
97 'default_value' => '0',
98 'type' => 'select',
99 'options' => array(
100 'Latest', 'Dev'
101 )
102 ),
103 array(
104 'name' => __('Cache', 'e2pdf'),
105 'key' => 'e2pdf_cache',
106 'value' => get_option('e2pdf_cache') === false ? '1' : get_option('e2pdf_cache'),
107 'default_value' => '0',
108 'type' => 'checkbox',
109 'checkbox_value' => '1',
110 'placeholder' => __('Turn on Cache', 'e2pdf'),
111 ),
112 array(
113 'name' => __('Debug', 'e2pdf'),
114 'key' => 'e2pdf_debug',
115 'value' => get_option('e2pdf_debug') === false ? '0' : get_option('e2pdf_debug'),
116 'default_value' => '0',
117 'type' => 'checkbox',
118 'checkbox_value' => '1',
119 'placeholder' => __('Turn on Debug mode', 'e2pdf'),
120 ),
121 array(
122 'name' => __('Hide warnings', 'e2pdf'),
123 'key' => 'e2pdf_hide_warnings',
124 'value' => get_option('e2pdf_hide_warnings') === false ? '0' : get_option('e2pdf_hide_warnings'),
125 'default_value' => '0',
126 'type' => 'checkbox',
127 'checkbox_value' => '1',
128 'placeholder' => __('Hide warnings', 'e2pdf'),
129 ),
130 array(
131 'name' => __('Connection Timout', 'e2pdf'),
132 'key' => 'e2pdf_connection_timeout',
133 'value' => get_option('e2pdf_connection_timeout') === false ? '300' : get_option('e2pdf_connection_timeout'),
134 'default_value' => '30',
135 'type' => 'text',
136 'class' => 'e2pdf-numbers',
137 'placeholder' => '0'
138 ),
139 array(
140 'name' => __('Memory/Time Usage', 'e2pdf'),
141 'key' => 'e2pdf_memory_time',
142 'value' => get_option('e2pdf_memory_time') === false ? '0' : get_option('e2pdf_memory_time'),
143 'default_value' => '0',
144 'type' => 'checkbox',
145 'checkbox_value' => '1',
146 'placeholder' => __('Show Memory/Time Usage', 'e2pdf'),
147 ),
148 array(
149 'name' => __('Developer Mode', 'e2pdf'),
150 'key' => 'e2pdf_developer',
151 'value' => get_option('e2pdf_developer') === false ? '0' : get_option('e2pdf_developer'),
152 'default_value' => '0',
153 'type' => 'checkbox',
154 'checkbox_value' => '1',
155 'placeholder' => __('Turn on Developer mode', 'e2pdf'),
156 ),
157 array(
158 'name' => __('Developer IPs', 'e2pdf'),
159 'key' => 'e2pdf_developer_ips',
160 'value' => get_option('e2pdf_developer_ips') === false ? '' : get_option('e2pdf_developer_ips'),
161 'default_value' => '',
162 'type' => 'textarea',
163 'placeholder' => __('Developer IPs', 'e2pdf'),
164 )
165 )
166 ),
167 'fonts_group' => array(
168 'name' => __('Fonts', 'e2pdf'),
169 'action' => 'fonts',
170 'options' => array()
171 ),
172 'adobesign_group' => array(
173 'name' => __('Adobe Sign', 'e2pdf'),
174 'action' => 'adobesign',
175 'options' => array(
176 array(
177 'name' => __('Client ID', 'e2pdf'),
178 'key' => 'e2pdf_adobesign_client_id',
179 'value' => get_option('e2pdf_adobesign_client_id') === false ? '' : get_option('e2pdf_adobesign_client_id'),
180 'default_value' => '',
181 'type' => 'text',
182 'placeholder' => ''
183 ),
184 array(
185 'name' => __('Client Secret', 'e2pdf'),
186 'key' => 'e2pdf_adobesign_client_secret',
187 'value' => get_option('e2pdf_adobesign_client_secret') === false ? '' : get_option('e2pdf_adobesign_client_secret'),
188 'default_value' => '',
189 'type' => 'text',
190 'placeholder' => ''
191 ),
192 array(
193 'name' => __('Region', 'e2pdf'),
194 'key' => 'e2pdf_adobesign_region',
195 'value' => get_option('e2pdf_adobesign_region') === false ? '' : get_option('e2pdf_adobesign_region'),
196 'default_value' => '',
197 'type' => 'text',
198 'placeholder' => __('na2', 'e2pdf')
199 ),
200 array(
201 'name' => __('Code', 'e2pdf'),
202 'key' => 'e2pdf_adobesign_code',
203 'value' => get_option('e2pdf_adobesign_code') === false ? '' : get_option('e2pdf_adobesign_code'),
204 'default_value' => '',
205 'type' => get_option('e2pdf_debug') ? 'text' : 'hidden',
206 'placeholder' => ''
207 ),
208 array(
209 'name' => __('Api Access Point', 'e2pdf'),
210 'key' => 'e2pdf_adobesign_api_access_point',
211 'value' => get_option('e2pdf_adobesign_api_access_point') === false ? '' : get_option('e2pdf_adobesign_api_access_point'),
212 'default_value' => '',
213 'type' => get_option('e2pdf_debug') ? 'text' : 'hidden',
214 'placeholder' => ''
215 ),
216 array(
217 'name' => __('Refresh Token', 'e2pdf'),
218 'key' => 'e2pdf_adobesign_refresh_token',
219 'value' => get_option('e2pdf_adobesign_refresh_token') === false ? '' : get_option('e2pdf_adobesign_refresh_token'),
220 'default_value' => '',
221 'type' => get_option('e2pdf_debug') ? 'text' : 'hidden',
222 'placeholder' => ''
223 ),
224 array(
225 'name' => __('Access Token', 'e2pdf'),
226 'key' => 'e2pdf_adobesign_access_token',
227 'value' => get_transient('e2pdf_adobesign_access_token') === false ? '' : get_transient('e2pdf_adobesign_access_token'),
228 'default_value' => '',
229 'type' => get_option('e2pdf_debug') ? 'text' : 'hidden',
230 'placeholder' => ''
231 ),
232 array(
233 'header' => __('Scopes', 'e2pdf'),
234 'name' => __('user_read', 'e2pdf'),
235 'key' => 'e2pdf_adobesign_scope_user_read',
236 'value' => get_option('e2pdf_adobesign_scope_user_read') === false ? '' : get_option('e2pdf_adobesign_scope_user_read'),
237 'default_value' => '',
238 'type' => 'select',
239 'options' => array(
240 '' => __('disabled', 'e2pdf'),
241 'self' => 'self',
242 'group' => 'group',
243 'account' => 'account'
244 )
245 ),
246 array(
247 'name' => __('user_write', 'e2pdf'),
248 'key' => 'e2pdf_adobesign_scope_user_write',
249 'value' => get_option('e2pdf_adobesign_scope_user_write') === false ? '' : get_option('e2pdf_adobesign_scope_user_write'),
250 'default_value' => '',
251 'type' => 'select',
252 'options' => array(
253 '' => __('disabled', 'e2pdf'),
254 'self' => 'self',
255 'group' => 'group',
256 'account' => 'account'
257 )
258 ),
259 array(
260 'name' => __('user_login', 'e2pdf'),
261 'key' => 'e2pdf_adobesign_scope_user_login',
262 'value' => get_option('e2pdf_adobesign_scope_user_login') === false ? '' : get_option('e2pdf_adobesign_scope_user_login'),
263 'default_value' => '',
264 'type' => 'select',
265 'options' => array(
266 '' => __('disabled', 'e2pdf'),
267 'self' => 'self',
268 'group' => 'group',
269 'account' => 'account'
270 )
271 ),
272 array(
273 'name' => __('agreement_read', 'e2pdf'),
274 'key' => 'e2pdf_adobesign_scope_agreement_read',
275 'value' => get_option('e2pdf_adobesign_scope_agreement_read') === false ? '' : get_option('e2pdf_adobesign_scope_agreement_read'),
276 'default_value' => '',
277 'type' => 'select',
278 'options' => array(
279 '' => __('disabled', 'e2pdf'),
280 'self' => 'self',
281 'group' => 'group',
282 'account' => 'account'
283 )
284 ),
285 array(
286 'name' => __('agreement_write', 'e2pdf'),
287 'key' => 'e2pdf_adobesign_scope_agreement_write',
288 'value' => get_option('e2pdf_adobesign_scope_agreement_write') === false ? '' : get_option('e2pdf_adobesign_scope_agreement_write'),
289 'default_value' => '',
290 'type' => 'select',
291 'options' => array(
292 '' => __('disabled', 'e2pdf'),
293 'self' => 'self',
294 'group' => 'group',
295 'account' => 'account'
296 )
297 ),
298 array(
299 'name' => __('agreement_send', 'e2pdf'),
300 'key' => 'e2pdf_adobesign_scope_agreement_send',
301 'value' => get_option('e2pdf_adobesign_scope_agreement_send') === false ? '' : get_option('e2pdf_adobesign_scope_agreement_send'),
302 'default_value' => '',
303 'type' => 'select',
304 'options' => array(
305 '' => __('disabled', 'e2pdf'),
306 'self' => 'self',
307 'group' => 'group',
308 'account' => 'account'
309 )
310 ),
311 array(
312 'name' => __('widget_read', 'e2pdf'),
313 'key' => 'e2pdf_adobesign_scope_widget_read',
314 'value' => get_option('e2pdf_adobesign_scope_widget_read') === false ? '' : get_option('e2pdf_adobesign_scope_widget_read'),
315 'default_value' => '',
316 'type' => 'select',
317 'options' => array(
318 '' => __('disabled', 'e2pdf'),
319 'self' => 'self',
320 'group' => 'group',
321 'account' => 'account'
322 )
323 ),
324 array(
325 'name' => __('widget_write', 'e2pdf'),
326 'key' => 'e2pdf_adobesign_scope_widget_write',
327 'value' => get_option('e2pdf_adobesign_scope_widget_write') === false ? '' : get_option('e2pdf_adobesign_scope_widget_write'),
328 'default_value' => '',
329 'type' => 'select',
330 'options' => array(
331 '' => __('disabled', 'e2pdf'),
332 'self' => 'self',
333 'group' => 'group',
334 'account' => 'account'
335 )
336 ),
337 array(
338 'name' => __('library_read', 'e2pdf'),
339 'key' => 'e2pdf_adobesign_scope_library_read',
340 'value' => get_option('e2pdf_adobesign_scope_library_read') === false ? '' : get_option('e2pdf_adobesign_scope_library_read'),
341 'default_value' => '',
342 'type' => 'select',
343 'options' => array(
344 '' => __('disabled', 'e2pdf'),
345 'self' => 'self',
346 'group' => 'group',
347 'account' => 'account'
348 )
349 ),
350 array(
351 'name' => __('library_write', 'e2pdf'),
352 'key' => 'e2pdf_adobesign_scope_library_write',
353 'value' => get_option('e2pdf_adobesign_scope_library_write') === false ? '' : get_option('e2pdf_adobesign_scope_library_write'),
354 'default_value' => '',
355 'type' => 'select',
356 'options' => array(
357 '' => __('disabled', 'e2pdf'),
358 'self' => 'self',
359 'group' => 'group',
360 'account' => 'account'
361 )
362 ),
363 array(
364 'name' => __('workflow_read', 'e2pdf'),
365 'key' => 'e2pdf_adobesign_scope_workflow_read',
366 'value' => get_option('e2pdf_adobesign_scope_workflow_read') === false ? '' : get_option('e2pdf_adobesign_scope_workflow_read'),
367 'default_value' => '',
368 'type' => 'select',
369 'options' => array(
370 '' => __('disabled', 'e2pdf'),
371 'self' => 'self',
372 'group' => 'group',
373 'account' => 'account'
374 )
375 ),
376 array(
377 'name' => __('workflow_write', 'e2pdf'),
378 'key' => 'e2pdf_adobesign_scope_workflow_write',
379 'value' => get_option('e2pdf_adobesign_scope_workflow_write') === false ? '' : get_option('e2pdf_adobesign_scope_workflow_write'),
380 'default_value' => '',
381 'type' => 'select',
382 'options' => array(
383 '' => __('disabled', 'e2pdf'),
384 'self' => 'self',
385 'group' => 'group',
386 'account' => 'account'
387 )
388 ),
389 array(
390 'name' => __('webhook_read', 'e2pdf'),
391 'key' => 'e2pdf_adobesign_scope_webhook_read',
392 'value' => get_option('e2pdf_adobesign_scope_webhook_read') === false ? '' : get_option('e2pdf_adobesign_scope_webhook_read'),
393 'default_value' => '',
394 'type' => 'select',
395 'options' => array(
396 '' => __('disabled', 'e2pdf'),
397 'self' => 'self',
398 'group' => 'group',
399 'account' => 'account'
400 )
401 ),
402 array(
403 'name' => __('webhook_write', 'e2pdf'),
404 'key' => 'e2pdf_adobesign_scope_webhook_write',
405 'value' => get_option('e2pdf_adobesign_scope_webhook_write') === false ? '' : get_option('e2pdf_adobesign_scope_webhook_write'),
406 'default_value' => '',
407 'type' => 'select',
408 'options' => array(
409 '' => __('disabled', 'e2pdf'),
410 'self' => 'self',
411 'group' => 'group',
412 'account' => 'account'
413 )
414 ),
415 array(
416 'name' => __('webhook_retention', 'e2pdf'),
417 'key' => 'e2pdf_adobesign_scope_webhook_retention',
418 'value' => get_option('e2pdf_adobesign_scope_webhook_retention') === false ? '' : get_option('e2pdf_adobesign_scope_webhook_retention'),
419 'default_value' => '',
420 'type' => 'select',
421 'options' => array(
422 '' => __('disabled', 'e2pdf'),
423 'self' => 'self',
424 'group' => 'group',
425 'account' => 'account'
426 )
427 ),
428 )
429 ),
430 'extensions_group' => array(
431 'name' => __('Extensions', 'e2pdf'),
432 'action' => 'extensions',
433 'options' => $extensions_options
434 ),
435 );
436
437 $options = apply_filters('e2pdf_model_options_get_options_options', $options);
438
439 if ($all) {
440 $opt = array();
441 foreach ($options as $group_key => $group) {
442 foreach ($group['options'] as $option_key => $option) {
443 $opt[$option['key']] = $option['value'];
444 }
445 }
446 return $opt;
447 } else {
448 foreach ($options as $group_key => $group) {
449 if ($exclude) {
450 if (in_array($group_key, $only_group)) {
451 unset($options[$group_key]);
452 }
453 } else {
454 if (!in_array($group_key, $only_group)) {
455 unset($options[$group_key]);
456 }
457 }
458 }
459
460 return $options;
461 }
462 }
463
464 /**
465 * Get Option value
466 *
467 * @param string $key - Option key
468 *
469 * @return mixed - Option value
470 */
471 function get_option($key) {
472 if ($key === 'e2pdf_developer_ips') {
473 $option = get_option($key);
474 $developers = explode("\r\n", $option);
475 if (!empty($developers)) {
476 return $developers;
477 }
478 return array();
479 } else {
480 return get_option($key);
481 }
482 }
483
484 }
485