PluginProbe
E2Pdf – Export Pdf Tool for WordPress / 1.04.07
E2Pdf – Export Pdf Tool for WordPress v1.04.07
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.04.07, at classes/model/e2pdf-options.php

461 lines 21.6 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 'type' => 'checkbox',
50 );
51 }
52 if (isset($extensions_options['0'])) {
53 $extensions_options['0']['header'] = __('Disable Extensions', 'e2pdf');
54 }
55 }
56
57 $options = array(
58 'static_group' => array(
59 'name' => __('Static', 'e2pdf'),
60 'options' => array(
61 array(
62 'key' => 'e2pdf_version',
63 'value' => $helper->get('version')
64 ),
65 array(
66 'key' => 'e2pdf_license',
67 'value' => get_option('e2pdf_license') === false ? false : get_option('e2pdf_license'),
68 ),
69 array(
70 'key' => 'e2pdf_email',
71 'value' => get_option('e2pdf_email') === false ? false : get_option('e2pdf_email'),
72 )
73 )
74 ),
75 'common_group' => array(
76 'name' => __('Common', 'e2pdf'),
77 'options' => array(
78 array(
79 'name' => __('PDF Processor', 'e2pdf'),
80 'key' => 'e2pdf_processor',
81 'value' => get_option('e2pdf_processor') === false ? '0' : get_option('e2pdf_processor'),
82 'default_value' => 0,
83 'type' => 'select',
84 'options' => array(
85 'Latest', 'Dev'
86 )
87 ),
88 array(
89 'name' => __('Debug', 'e2pdf'),
90 'key' => 'e2pdf_debug',
91 'value' => get_option('e2pdf_debug') === false ? '0' : get_option('e2pdf_debug'),
92 'default_value' => '0',
93 'type' => 'checkbox',
94 'checkbox_value' => '1',
95 'placeholder' => __('Turn on Debug mode', 'e2pdf'),
96 ),
97 array(
98 'name' => __('Hide warnings', 'e2pdf'),
99 'key' => 'e2pdf_hide_warnings',
100 'value' => get_option('e2pdf_hide_warnings') === false ? '0' : get_option('e2pdf_hide_warnings'),
101 'default_value' => '0',
102 'type' => 'checkbox',
103 'checkbox_value' => '1',
104 'placeholder' => __('Hide warnings', 'e2pdf'),
105 ),
106 array(
107 'name' => __('Connection Timout', 'e2pdf'),
108 'key' => 'e2pdf_connection_timeout',
109 'value' => get_option('e2pdf_connection_timeout') === false ? '300' : get_option('e2pdf_connection_timeout'),
110 'default_value' => '30',
111 'type' => 'text',
112 'class' => 'e2pdf-numbers',
113 'placeholder' => '0'
114 ),
115 array(
116 'name' => __('Memory/Time Usage', 'e2pdf'),
117 'key' => 'e2pdf_memory_time',
118 'value' => get_option('e2pdf_memory_time') === false ? 0 : get_option('e2pdf_memory_time'),
119 'default_value' => '0',
120 'type' => 'checkbox',
121 'checkbox_value' => '1',
122 'placeholder' => __('Show Memory/Time Usage', 'e2pdf'),
123 ),
124 array(
125 'name' => __('Developer Mode', 'e2pdf'),
126 'key' => 'e2pdf_developer',
127 'value' => get_option('e2pdf_developer') === false ? 0 : get_option('e2pdf_developer'),
128 'default_value' => '0',
129 'type' => 'checkbox',
130 'checkbox_value' => '1',
131 'placeholder' => __('Turn on Developer mode', 'e2pdf'),
132 ),
133 array(
134 'name' => __('Developer IPs', 'e2pdf'),
135 'key' => 'e2pdf_developer_ips',
136 'value' => get_option('e2pdf_developer_ips') === false ? '' : get_option('e2pdf_developer_ips'),
137 'default_value' => '',
138 'type' => 'textarea',
139 'placeholder' => __('Developer IPs', 'e2pdf'),
140 )
141 )
142 ),
143 'fonts_group' => array(
144 'name' => __('Fonts', 'e2pdf'),
145 'action' => 'fonts',
146 'options' => array()
147 ),
148 'adobesign_group' => array(
149 'name' => __('Adobe Sign', 'e2pdf'),
150 'action' => 'adobesign',
151 'options' => array(
152 array(
153 'name' => __('Client ID', 'e2pdf'),
154 'key' => 'e2pdf_adobesign_client_id',
155 'value' => get_option('e2pdf_adobesign_client_id') === false ? '' : get_option('e2pdf_adobesign_client_id'),
156 'default_value' => '',
157 'type' => 'text',
158 'placeholder' => ''
159 ),
160 array(
161 'name' => __('Client Secret', 'e2pdf'),
162 'key' => 'e2pdf_adobesign_client_secret',
163 'value' => get_option('e2pdf_adobesign_client_secret') === false ? '' : get_option('e2pdf_adobesign_client_secret'),
164 'default_value' => '',
165 'type' => 'text',
166 'placeholder' => ''
167 ),
168 array(
169 'name' => __('Region', 'e2pdf'),
170 'key' => 'e2pdf_adobesign_region',
171 'value' => get_option('e2pdf_adobesign_region') === false ? '' : get_option('e2pdf_adobesign_region'),
172 'default_value' => '',
173 'type' => 'text',
174 'placeholder' => __('na2', 'e2pdf')
175 ),
176 array(
177 'name' => __('Code', 'e2pdf'),
178 'key' => 'e2pdf_adobesign_code',
179 'value' => get_option('e2pdf_adobesign_code') === false ? '' : get_option('e2pdf_adobesign_code'),
180 'default_value' => '',
181 'type' => get_option('e2pdf_debug') ? 'text' : 'hidden',
182 'placeholder' => ''
183 ),
184 array(
185 'name' => __('Api Access Point', 'e2pdf'),
186 'key' => 'e2pdf_adobesign_api_access_point',
187 'value' => get_option('e2pdf_adobesign_api_access_point') === false ? '' : get_option('e2pdf_adobesign_api_access_point'),
188 'default_value' => '',
189 'type' => get_option('e2pdf_debug') ? 'text' : 'hidden',
190 'placeholder' => ''
191 ),
192 array(
193 'name' => __('Refresh Token', 'e2pdf'),
194 'key' => 'e2pdf_adobesign_refresh_token',
195 'value' => get_option('e2pdf_adobesign_refresh_token') === false ? '' : get_option('e2pdf_adobesign_refresh_token'),
196 'default_value' => '',
197 'type' => get_option('e2pdf_debug') ? 'text' : 'hidden',
198 'placeholder' => ''
199 ),
200 array(
201 'name' => __('Access Token', 'e2pdf'),
202 'key' => 'e2pdf_adobesign_access_token',
203 'value' => get_transient('e2pdf_adobesign_access_token') === false ? '' : get_transient('e2pdf_adobesign_access_token'),
204 'default_value' => '',
205 'type' => get_option('e2pdf_debug') ? 'text' : 'hidden',
206 'placeholder' => ''
207 ),
208 array(
209 'header' => __('Scopes', 'e2pdf'),
210 'name' => __('user_read', 'e2pdf'),
211 'key' => 'e2pdf_adobesign_scope_user_read',
212 'value' => get_option('e2pdf_adobesign_scope_user_read') === false ? '' : get_option('e2pdf_adobesign_scope_user_read'),
213 'default_value' => '',
214 'type' => 'select',
215 'options' => array(
216 '' => __('disabled', 'e2pdf'),
217 'self' => 'self',
218 'group' => 'group',
219 'account' => 'account'
220 )
221 ),
222 array(
223 'name' => __('user_write', 'e2pdf'),
224 'key' => 'e2pdf_adobesign_scope_user_write',
225 'value' => get_option('e2pdf_adobesign_scope_user_write') === false ? '' : get_option('e2pdf_adobesign_scope_user_write'),
226 'default_value' => '',
227 'type' => 'select',
228 'options' => array(
229 '' => __('disabled', 'e2pdf'),
230 'self' => 'self',
231 'group' => 'group',
232 'account' => 'account'
233 )
234 ),
235 array(
236 'name' => __('user_login', 'e2pdf'),
237 'key' => 'e2pdf_adobesign_scope_user_login',
238 'value' => get_option('e2pdf_adobesign_scope_user_login') === false ? '' : get_option('e2pdf_adobesign_scope_user_login'),
239 'default_value' => '',
240 'type' => 'select',
241 'options' => array(
242 '' => __('disabled', 'e2pdf'),
243 'self' => 'self',
244 'group' => 'group',
245 'account' => 'account'
246 )
247 ),
248 array(
249 'name' => __('agreement_read', 'e2pdf'),
250 'key' => 'e2pdf_adobesign_scope_agreement_read',
251 'value' => get_option('e2pdf_adobesign_scope_agreement_read') === false ? '' : get_option('e2pdf_adobesign_scope_agreement_read'),
252 'default_value' => '',
253 'type' => 'select',
254 'options' => array(
255 '' => __('disabled', 'e2pdf'),
256 'self' => 'self',
257 'group' => 'group',
258 'account' => 'account'
259 )
260 ),
261 array(
262 'name' => __('agreement_write', 'e2pdf'),
263 'key' => 'e2pdf_adobesign_scope_agreement_write',
264 'value' => get_option('e2pdf_adobesign_scope_agreement_write') === false ? '' : get_option('e2pdf_adobesign_scope_agreement_write'),
265 'default_value' => '',
266 'type' => 'select',
267 'options' => array(
268 '' => __('disabled', 'e2pdf'),
269 'self' => 'self',
270 'group' => 'group',
271 'account' => 'account'
272 )
273 ),
274 array(
275 'name' => __('agreement_send', 'e2pdf'),
276 'key' => 'e2pdf_adobesign_scope_agreement_send',
277 'value' => get_option('e2pdf_adobesign_scope_agreement_send') === false ? '' : get_option('e2pdf_adobesign_scope_agreement_send'),
278 'default_value' => '',
279 'type' => 'select',
280 'options' => array(
281 '' => __('disabled', 'e2pdf'),
282 'self' => 'self',
283 'group' => 'group',
284 'account' => 'account'
285 )
286 ),
287 array(
288 'name' => __('widget_read', 'e2pdf'),
289 'key' => 'e2pdf_adobesign_scope_widget_read',
290 'value' => get_option('e2pdf_adobesign_scope_widget_read') === false ? '' : get_option('e2pdf_adobesign_scope_widget_read'),
291 'default_value' => '',
292 'type' => 'select',
293 'options' => array(
294 '' => __('disabled', 'e2pdf'),
295 'self' => 'self',
296 'group' => 'group',
297 'account' => 'account'
298 )
299 ),
300 array(
301 'name' => __('widget_write', 'e2pdf'),
302 'key' => 'e2pdf_adobesign_scope_widget_write',
303 'value' => get_option('e2pdf_adobesign_scope_widget_write') === false ? '' : get_option('e2pdf_adobesign_scope_widget_write'),
304 'default_value' => '',
305 'type' => 'select',
306 'options' => array(
307 '' => __('disabled', 'e2pdf'),
308 'self' => 'self',
309 'group' => 'group',
310 'account' => 'account'
311 )
312 ),
313 array(
314 'name' => __('library_read', 'e2pdf'),
315 'key' => 'e2pdf_adobesign_scope_library_read',
316 'value' => get_option('e2pdf_adobesign_scope_library_read') === false ? '' : get_option('e2pdf_adobesign_scope_library_read'),
317 'default_value' => '',
318 'type' => 'select',
319 'options' => array(
320 '' => __('disabled', 'e2pdf'),
321 'self' => 'self',
322 'group' => 'group',
323 'account' => 'account'
324 )
325 ),
326 array(
327 'name' => __('library_write', 'e2pdf'),
328 'key' => 'e2pdf_adobesign_scope_library_write',
329 'value' => get_option('e2pdf_adobesign_scope_library_write') === false ? '' : get_option('e2pdf_adobesign_scope_library_write'),
330 'default_value' => '',
331 'type' => 'select',
332 'options' => array(
333 '' => __('disabled', 'e2pdf'),
334 'self' => 'self',
335 'group' => 'group',
336 'account' => 'account'
337 )
338 ),
339 array(
340 'name' => __('workflow_read', 'e2pdf'),
341 'key' => 'e2pdf_adobesign_scope_workflow_read',
342 'value' => get_option('e2pdf_adobesign_scope_workflow_read') === false ? '' : get_option('e2pdf_adobesign_scope_workflow_read'),
343 'default_value' => '',
344 'type' => 'select',
345 'options' => array(
346 '' => __('disabled', 'e2pdf'),
347 'self' => 'self',
348 'group' => 'group',
349 'account' => 'account'
350 )
351 ),
352 array(
353 'name' => __('workflow_write', 'e2pdf'),
354 'key' => 'e2pdf_adobesign_scope_workflow_write',
355 'value' => get_option('e2pdf_adobesign_scope_workflow_write') === false ? '' : get_option('e2pdf_adobesign_scope_workflow_write'),
356 'default_value' => '',
357 'type' => 'select',
358 'options' => array(
359 '' => __('disabled', 'e2pdf'),
360 'self' => 'self',
361 'group' => 'group',
362 'account' => 'account'
363 )
364 ),
365 array(
366 'name' => __('webhook_read', 'e2pdf'),
367 'key' => 'e2pdf_adobesign_scope_webhook_read',
368 'value' => get_option('e2pdf_adobesign_scope_webhook_read') === false ? '' : get_option('e2pdf_adobesign_scope_webhook_read'),
369 'default_value' => '',
370 'type' => 'select',
371 'options' => array(
372 '' => __('disabled', 'e2pdf'),
373 'self' => 'self',
374 'group' => 'group',
375 'account' => 'account'
376 )
377 ),
378 array(
379 'name' => __('webhook_write', 'e2pdf'),
380 'key' => 'e2pdf_adobesign_scope_webhook_write',
381 'value' => get_option('e2pdf_adobesign_scope_webhook_write') === false ? '' : get_option('e2pdf_adobesign_scope_webhook_write'),
382 'default_value' => '',
383 'type' => 'select',
384 'options' => array(
385 '' => __('disabled', 'e2pdf'),
386 'self' => 'self',
387 'group' => 'group',
388 'account' => 'account'
389 )
390 ),
391 array(
392 'name' => __('webhook_retention', 'e2pdf'),
393 'key' => 'e2pdf_adobesign_scope_webhook_retention',
394 'value' => get_option('e2pdf_adobesign_scope_webhook_retention') === false ? '' : get_option('e2pdf_adobesign_scope_webhook_retention'),
395 'default_value' => '',
396 'type' => 'select',
397 'options' => array(
398 '' => __('disabled', 'e2pdf'),
399 'self' => 'self',
400 'group' => 'group',
401 'account' => 'account'
402 )
403 ),
404 )
405 ),
406 'extensions_group' => array(
407 'name' => __('Extensions', 'e2pdf'),
408 'action' => 'extensions',
409 'options' => $extensions_options
410 ),
411 );
412
413 $options = apply_filters('e2pdf_model_options_get_options_options', $options);
414
415 if ($all) {
416 $opt = array();
417 foreach ($options as $group_key => $group) {
418 foreach ($group['options'] as $option_key => $option) {
419 $opt[$option['key']] = $option['value'];
420 }
421 }
422 return $opt;
423 } else {
424 foreach ($options as $group_key => $group) {
425 if ($exclude) {
426 if (in_array($group_key, $only_group)) {
427 unset($options[$group_key]);
428 }
429 } else {
430 if (!in_array($group_key, $only_group)) {
431 unset($options[$group_key]);
432 }
433 }
434 }
435
436 return $options;
437 }
438 }
439
440 /**
441 * Get Option value
442 *
443 * @param string $key - Option key
444 *
445 * @return mixed - Option value
446 */
447 function get_option($key) {
448 if ($key === 'e2pdf_developer_ips') {
449 $option = get_option($key);
450 $developers = explode("\r\n", $option);
451 if (!empty($developers)) {
452 return $developers;
453 }
454 return array();
455 } else {
456 return get_option($key);
457 }
458 }
459
460 }
461