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

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