PluginProbe
E2Pdf – Export Pdf Tool for WordPress / 1.32.49
E2Pdf – Export Pdf Tool for WordPress v1.32.49
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
← All changes | classes/model/e2pdf-options.php +602 -191 1.08.001.32.49 View file →
@@ -1,14 +1,12 @@
1 1 <?php
2 2
3 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
4 + * File: /model/e2pdf-options.php
5 + *
6 + * @package E2Pdf
7 + * @license GPLv3
8 + * @link https://e2pdf.com
11 9 */
12 10 if (!defined('ABSPATH')) {
13 11 die('Access denied.');
14 12 }
@@ -14,41 +12,86 @@
14 12 }
15 13
16 14 class Model_E2pdf_Options extends Model_E2pdf_Model {
17 15
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 -
16 + // get options
30 17 public static function get_options($all = true, $only_group = array(), $exclude = false) {
31 -
32 18 $helper = Helper_E2pdf_Helper::instance();
33 19 $extensions_options = array();
34 20 if ($all) {
35 21 $extensions_options[] = array(
36 22 'key' => 'e2pdf_disabled_extensions',
37 - 'value' => !is_array(get_option('e2pdf_disabled_extensions')) ? array() : get_option('e2pdf_disabled_extensions'),
23 + 'value' => get_option('e2pdf_disabled_extensions', array()),
38 24 );
39 25 } else {
40 26 $model_e2pdf_extension = new Model_E2pdf_Extension();
41 27 $extensions = $model_e2pdf_extension->extensions(false);
42 - $disabled_extensions = !is_array(get_option('e2pdf_disabled_extensions')) ? array() : get_option('e2pdf_disabled_extensions');
28 + $disabled_extensions = get_option('e2pdf_disabled_extensions', array());
43 29 foreach ($extensions as $extension) {
30 + $extension_title = ucfirst($extension);
31 + switch ($extension) {
32 + case 'caldera':
33 + $extension_title = 'Caldera Forms';
34 + break;
35 + case 'calc':
36 + $extension_title = 'Cost Calculator Builder';
37 + break;
38 + case 'divi':
39 + $extension_title = 'Divi Contact Forms';
40 + break;
41 + case 'elementor':
42 + $extension_title = 'Elementor Forms';
43 + break;
44 + case 'fluent':
45 + $extension_title = 'Fluent Forms';
46 + break;
47 + case 'formidable':
48 + $extension_title = 'Formidable Forms';
49 + break;
50 + case 'forminator':
51 + $extension_title = 'Forminator Forms';
52 + break;
53 + case 'gravity':
54 + $extension_title = 'Gravity Forms';
55 + break;
56 + case 'ninja':
57 + $extension_title = 'Ninja Forms';
58 + break;
59 + case 'woocommerce':
60 + $extension_title = 'WooCommerce';
61 + break;
62 + // phpcs:ignore WordPress.WP.CapitalPDangit.Misspelled
63 + case 'wordpress':
64 + $extension_title = 'WordPress';
65 + break;
66 + case 'wpcf7':
67 + $extension_title = 'Contact Form 7';
68 + break;
69 + case 'wpforms':
70 + $extension_title = 'WPForms';
71 + break;
72 + case 'jetformbuilder':
73 + $extension_title = 'JetFormBuilder';
74 + break;
75 + default:
76 + break;
77 + }
44 78 $extensions_options[] = array(
45 - 'name' => ucfirst($extension),
79 + 'name' => $extension_title,
46 80 'key' => 'e2pdf_disabled_extensions[]',
47 - 'value' => in_array($extension, $disabled_extensions) ? $extension : '',
48 - 'checkbox_value' => $extension,
49 - 'placeholder' => __('Disable', 'e2pdf'),
50 - 'type' => 'checkbox',
81 + 'value' => is_array($disabled_extensions) && in_array($extension, $disabled_extensions, true) ? $extension : '',
82 + 'default_value' => '',
83 + 'type' => 'select',
84 + 'options' => array(
85 + array(
86 + 'key' => '',
87 + 'value' => __('Enabled', 'e2pdf'),
88 + ),
89 + array(
90 + 'key' => $extension,
91 + 'value' => __('Disabled', 'e2pdf'),
92 + ),
93 + ),
51 94 );
52 95 }
53 96 if (isset($extensions_options['0'])) {
54 97 $extensions_options['0']['header'] = __('Extensions', 'e2pdf');
@@ -54,387 +97,749 @@
54 97 $extensions_options['0']['header'] = __('Extensions', 'e2pdf');
55 98 }
56 99 }
57 100
101 + $processors = array(
102 + '0' => 'Default (Stable Version)',
103 + );
104 + if (get_option('e2pdf_debug', '0')) {
105 + $processors = array(
106 + '0' => 'Default (Stable Version)',
107 + '2' => 'Backport (1.16.19 Version)',
108 + '1' => 'Release Candidate (Debug Mode)',
109 + );
110 + }
111 +
58 112 $options = array(
59 113 'static_group' => array(
60 - 'name' => __('Static', 'e2pdf'),
114 + 'name' => '',
61 115 'options' => array(
62 116 array(
63 117 'key' => 'e2pdf_version',
64 - 'value' => $helper->get('version')
118 + 'value' => $helper->get('version'),
65 119 ),
66 120 array(
67 121 'key' => 'e2pdf_license',
68 - 'value' => get_option('e2pdf_license') === false ? false : get_option('e2pdf_license'),
122 + 'value' => get_option('e2pdf_license', false),
69 123 ),
70 124 array(
71 125 'key' => 'e2pdf_email',
72 - 'value' => get_option('e2pdf_email') === false ? false : get_option('e2pdf_email'),
126 + 'value' => get_option('e2pdf_email', ''),
73 127 ),
74 128 array(
75 129 '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 - )
130 + 'value' => get_option('e2pdf_templates_screen_per_page', '20'),
131 + ),
132 + array(
133 + 'key' => 'e2pdf_cached_fonts',
134 + 'value' => get_option('e2pdf_cached_fonts', array()),
135 + ),
136 + array(
137 + 'key' => 'e2pdf_nonce_key',
138 + 'value' => get_option('e2pdf_nonce_key', wp_generate_password('64')),
139 + ),
140 + ),
79 141 ),
80 142 'common_group' => array(
81 143 'name' => __('Common', 'e2pdf'),
82 144 'options' => array(
83 145 array(
146 + 'name' => __('E2Pdf.com Account E-mail Address', 'e2pdf'),
147 + 'key' => 'e2pdf_user_email',
148 + 'default_value' => '',
149 + 'value' => get_option('e2pdf_user_email', ''),
150 + 'type' => 'text',
151 + 'placeholder' => __('E2Pdf.com Account E-mail Address', 'e2pdf'),
152 + ),
153 + array(
84 154 'name' => __('API Server', 'e2pdf'),
155 + 'key' => 'e2pdf_api_custom',
156 + 'value' => apply_filters('e2pdf_api', get_option('e2pdf_api', 'api.e2pdf.com')),
157 + 'default_value' => 'api.e2pdf.com',
158 + 'type' => get_option('e2pdf_api', 'api.e2pdf.com') !== apply_filters('e2pdf_api', get_option('e2pdf_api', 'api.e2pdf.com')) ? 'text' : 'hidden',
159 + 'readonly' => 'readonly',
160 + ),
161 + array(
162 + 'name' => __('API Server', 'e2pdf'),
85 163 'key' => 'e2pdf_api',
86 - 'value' => apply_filters('e2pdf_api_server', 'api.e2pdf.com'),
164 + 'value' => get_option('e2pdf_api', 'api.e2pdf.com'),
87 165 'default_value' => 'api.e2pdf.com',
166 + 'type' => get_option('e2pdf_api', 'api.e2pdf.com') !== apply_filters('e2pdf_api', get_option('e2pdf_api', 'api.e2pdf.com')) ? 'hidden' : 'select',
167 + 'options' => array(
168 + 'api.e2pdf.com' => 'api.e2pdf.com (US, Cloudflare)',
169 + 'api2.e2pdf.com' => 'api2.e2pdf.com (US)',
170 + 'api3.e2pdf.com' => 'api3.e2pdf.com (EU, Cloudflare)',
171 + 'api4.e2pdf.com' => 'api4.e2pdf.com (EU)',
172 + ),
173 + ),
174 + array(
175 + 'name' => __('API Transfer', 'e2pdf'),
176 + 'key' => 'e2pdf_api_protocol',
177 + 'value' => get_option('e2pdf_api_protocol', '0'),
178 + 'default_value' => '0',
179 + 'type' => 'select',
180 + 'options' => array(
181 + '0' => 'Base64 Encoding',
182 + '1' => 'Raw Encoding',
183 + ),
184 + ),
185 + array(
186 + 'name' => __('API Connection Timout (sec)', 'e2pdf'),
187 + 'key' => 'e2pdf_connection_timeout',
188 + 'value' => get_option('e2pdf_connection_timeout', '300'),
189 + 'default_value' => '300',
88 190 'type' => 'text',
89 - 'class' => '',
90 - 'placeholder' => 'api.e2pdf.com',
91 - 'readonly' => 'readonly'
191 + 'class' => 'e2pdf-numbers',
192 + 'placeholder' => '0',
92 193 ),
93 194 array(
94 195 'name' => __('PDF Processor', 'e2pdf'),
95 196 'key' => 'e2pdf_processor',
96 - 'value' => get_option('e2pdf_processor') === false ? '0' : get_option('e2pdf_processor'),
197 + 'value' => get_option('e2pdf_processor', '0'),
97 198 'default_value' => '0',
98 199 'type' => 'select',
200 + 'options' => $processors,
201 + ),
202 + array(
203 + 'name' => __('Font Processor', 'e2pdf'),
204 + 'key' => 'e2pdf_font_processor',
205 + 'value' => get_option('e2pdf_font_processor', '0'),
206 + 'default_value' => '0',
207 + 'type' => 'hidden',
99 208 'options' => array(
100 - 'Latest', 'Dev'
101 - )
209 + 'Plain Fonts',
210 + 'Complex Fonts',
211 + ),
102 212 ),
103 213 array(
214 + 'name' => __('Release Candidate Builds', 'e2pdf'),
215 + 'key' => 'e2pdf_dev_update',
216 + 'value' => get_option('e2pdf_dev_update', '0'),
217 + 'default_value' => '0',
218 + 'type' => 'checkbox',
219 + 'checkbox_value' => '1',
220 + 'placeholder' => __('Update from E2Pdf.com', 'e2pdf'),
221 + ),
222 + array(
223 + 'name' => __('URL Format', 'e2pdf'),
224 + 'key' => 'e2pdf_url_format',
225 + 'value' => get_option('e2pdf_url_format', 'auto'),
226 + 'default_value' => 'auto',
227 + 'type' => 'select',
228 + 'options' => array(
229 + 'auto' => 'Auto',
230 + 'siteurl' => 'WordPress Address (URL)',
231 + 'home' => 'Site Address (URL)',
232 + ),
233 + ),
234 + array(
235 + 'name' => __('URL Rewrite', 'e2pdf'),
236 + 'key' => 'e2pdf_mod_rewrite',
237 + 'value' => get_option('e2pdf_mod_rewrite', '0'),
238 + 'default_value' => '0',
239 + 'type' => 'checkbox',
240 + 'checkbox_value' => '1',
241 + 'placeholder' => __('URL Rewrite', 'e2pdf'),
242 + ),
243 + array(
244 + 'name' => '',
245 + 'key' => 'e2pdf_mod_rewrite_url',
246 + 'default_value' => '',
247 + 'value' => get_option('e2pdf_mod_rewrite_url', 'e2pdf/%uid%/'),
248 + 'type' => 'text',
249 + 'class' => 'e2pdf-mod-rewrite-url',
250 + 'placeholder' => 'e2pdf/%uid%/',
251 + 'prefield' => rtrim($helper->get_frontend_site_url(), '/') . '/',
252 + ),
253 + array(
104 254 'name' => __('Cache', 'e2pdf'),
105 255 'key' => 'e2pdf_cache',
106 - 'value' => get_option('e2pdf_cache') === false ? '1' : get_option('e2pdf_cache'),
256 + 'value' => get_option('e2pdf_cache', '1'),
107 257 'default_value' => '0',
108 258 'type' => 'checkbox',
109 259 'checkbox_value' => '1',
110 - 'placeholder' => __('Turn on Cache', 'e2pdf'),
260 + 'placeholder' => __('Objects Cache', 'e2pdf'),
111 261 ),
112 262 array(
113 - 'name' => __('Debug', 'e2pdf'),
114 - 'key' => 'e2pdf_debug',
115 - 'value' => get_option('e2pdf_debug') === false ? '0' : get_option('e2pdf_debug'),
263 + 'name' => '',
264 + 'key' => 'e2pdf_cache_fonts',
265 + 'value' => get_option('e2pdf_cache_fonts', '1'),
116 266 'default_value' => '0',
117 267 'type' => 'checkbox',
118 268 'checkbox_value' => '1',
119 - 'placeholder' => __('Turn on Debug mode', 'e2pdf'),
269 + 'placeholder' => __('Fonts Cache', 'e2pdf'),
120 270 ),
121 271 array(
122 - 'name' => __('Hide warnings', 'e2pdf'),
272 + 'name' => '',
273 + 'key' => 'e2pdf_cache_pdfs',
274 + 'value' => get_option('e2pdf_cache_pdfs', '0'),
275 + 'default_value' => '0',
276 + 'type' => 'checkbox',
277 + 'checkbox_value' => '1',
278 + 'placeholder' => __('PDFs Cache', 'e2pdf'),
279 + ),
280 + array(
281 + 'name' => '',
282 + 'key' => 'e2pdf_cache_pdfs_ttl',
283 + 'default_value' => '',
284 + 'value' => max(10, (int) get_option('e2pdf_cache_pdfs_ttl', '180')),
285 + 'type' => 'text',
286 + 'placeholder' => '10',
287 + 'prefield' => __('TTL (sec)', 'e2pdf') . ':',
288 + ),
289 + array(
290 + 'name' => __('PDF Ajax Loader', 'e2pdf'),
291 + 'key' => 'e2pdf_download_loader',
292 + 'value' => get_option('e2pdf_download_loader', '0'),
293 + 'default_value' => '0',
294 + 'type' => 'select',
295 + 'options' => array(
296 + '0' => __('Disabled', 'e2pdf'),
297 + '1' => __('Enabled', 'e2pdf'),
298 + ),
299 + ),
300 + array(
301 + 'name' => __('Fallback PDF Viewer', 'e2pdf'),
302 + 'key' => 'e2pdf_download_inline_fallback_viewer',
303 + 'value' => get_option('e2pdf_download_inline_fallback_viewer', '0'),
304 + 'default_value' => '0',
305 + 'type' => 'select',
306 + 'options' => array(
307 + '0' => __('Disabled', 'e2pdf'),
308 + '1' => 'PDF.js',
309 + ),
310 + ),
311 + array(
312 + 'name' => '',
313 + 'key' => 'e2pdf_download_inline_chrome_ios_fix',
314 + 'value' => get_option('e2pdf_download_inline_chrome_ios_fix', '0'),
315 + 'default_value' => '0',
316 + 'type' => 'checkbox',
317 + 'checkbox_value' => '1',
318 + 'placeholder' => __('Fix Chrome iOS Download Name (might be not compatible with certain setups)', 'e2pdf'),
319 + ),
320 + array(
321 + 'name' => __('New Edit Layout', 'e2pdf'),
322 + 'key' => 'e2pdf_new_edit_layout',
323 + 'value' => get_option('e2pdf_new_edit_layout', '1'),
324 + 'default_value' => '0',
325 + 'type' => 'checkbox',
326 + 'checkbox_value' => '1',
327 + 'placeholder' => __('New Edit Layout', 'e2pdf'),
328 + ),
329 + array(
330 + 'name' => __('Hide Warnings', 'e2pdf'),
123 331 'key' => 'e2pdf_hide_warnings',
124 - 'value' => get_option('e2pdf_hide_warnings') === false ? '0' : get_option('e2pdf_hide_warnings'),
332 + 'value' => get_option('e2pdf_hide_warnings', '0'),
125 333 'default_value' => '0',
126 334 'type' => 'checkbox',
127 335 'checkbox_value' => '1',
128 - 'placeholder' => __('Hide warnings', 'e2pdf'),
336 + 'placeholder' => __('Hide Warnings', 'e2pdf'),
129 337 ),
130 338 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'),
339 + 'name' => __('Local Images', 'e2pdf'),
340 + 'key' => 'e2pdf_images_remote_request',
341 + 'value' => get_option('e2pdf_images_remote_request', '0'),
342 + 'default_value' => '0',
343 + 'type' => 'checkbox',
344 + 'checkbox_value' => '1',
345 + 'placeholder' => __('Load via Remote Request', 'e2pdf'),
346 + ),
347 + array(
348 + 'name' => __('Images Timout (sec)', 'e2pdf'),
349 + 'key' => 'e2pdf_images_timeout',
350 + 'value' => get_option('e2pdf_images_timeout', '30'),
134 351 'default_value' => '30',
135 352 'type' => 'text',
136 353 'class' => 'e2pdf-numbers',
137 - 'placeholder' => '0'
354 + 'placeholder' => '0',
138 355 ),
139 356 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'),
357 + 'name' => __('Bulk Export Interval (sec)', 'e2pdf'),
358 + 'key' => 'e2pdf_bulk_export_interval',
359 + 'value' => max(10, (int) get_option('e2pdf_bulk_export_interval', '10')),
360 + 'default_value' => '10',
361 + 'type' => 'text',
362 + 'class' => 'e2pdf-numbers',
363 + 'placeholder' => '10',
364 + ),
365 + array(
366 + 'name' => __('Undo Limit', 'e2pdf'),
367 + 'key' => 'e2pdf_undo_limit',
368 + 'value' => get_option('e2pdf_undo_limit', '20'),
369 + 'default_value' => '20',
370 + 'type' => 'text',
371 + 'class' => 'e2pdf-numbers',
372 + 'placeholder' => '0',
373 + ),
374 + array(
375 + 'name' => __('Revisions Limit', 'e2pdf'),
376 + 'key' => 'e2pdf_revisions_limit',
377 + 'value' => get_option('e2pdf_revisions_limit', '3'),
378 + 'default_value' => '3',
379 + 'type' => 'text',
380 + 'class' => 'e2pdf-numbers',
381 + 'placeholder' => '0',
382 + ),
383 + array(
384 + 'name' => __('Debug Mode', 'e2pdf'),
385 + 'key' => 'e2pdf_debug',
386 + 'value' => get_option('e2pdf_debug', '0'),
143 387 'default_value' => '0',
144 388 'type' => 'checkbox',
145 389 'checkbox_value' => '1',
146 - 'placeholder' => __('Show Memory/Time Usage', 'e2pdf'),
390 + 'placeholder' => __('Enable Debug Mode', 'e2pdf'),
147 391 ),
148 392 array(
149 - 'name' => __('Developer Mode', 'e2pdf'),
150 - 'key' => 'e2pdf_developer',
151 - 'value' => get_option('e2pdf_developer') === false ? '0' : get_option('e2pdf_developer'),
393 + 'name' => __('Recovery Mode E-mail', 'e2pdf'),
394 + 'key' => 'e2pdf_recovery_mode_email',
395 + 'value' => get_option('e2pdf_recovery_mode_email', ''),
396 + 'default_value' => '',
397 + 'type' => get_option('e2pdf_debug', '0') ? 'text' : 'hidden',
398 + 'placeholder' => __('Recovery Mode E-mail', 'e2pdf'),
399 + ),
400 + array(
401 + 'name' => __('Memory/Time Usage', 'e2pdf'),
402 + 'key' => 'e2pdf_memory_time',
403 + 'value' => get_option('e2pdf_memory_time', '0'),
152 404 'default_value' => '0',
153 - 'type' => 'checkbox',
405 + 'type' => get_option('e2pdf_debug', '0') ? 'checkbox' : 'hidden',
154 406 'checkbox_value' => '1',
155 - 'placeholder' => __('Turn on Developer mode', 'e2pdf'),
407 + 'placeholder' => __('Show Memory/Time Usage', 'e2pdf'),
156 408 ),
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 - )
409 + ),
166 410 ),
411 + 'maintenance_group' => array(
412 + 'name' => __('Maintenance', 'e2pdf'),
413 + 'action' => 'maintenance',
414 + 'options' => array(),
415 + ),
167 416 'fonts_group' => array(
168 417 'name' => __('Fonts', 'e2pdf'),
169 418 'action' => 'fonts',
170 - 'options' => array()
419 + 'options' => array(),
171 420 ),
421 + 'permissions_group' => array(
422 + 'name' => __('Permissions', 'e2pdf'),
423 + 'action' => 'permissions',
424 + 'options' => array(),
425 + ),
426 + 'zapier_group' => array(
427 + 'name' => 'Zapier',
428 + 'options' => array(
429 + array(
430 + 'name' => 'Site URL',
431 + 'value' => $helper->get_site_url(),
432 + 'default_value' => '',
433 + 'type' => 'text',
434 + 'readonly' => 'readonly',
435 + 'class' => 'e2pdf-copy-field',
436 + ),
437 + array(
438 + 'name' => 'API Key',
439 + 'key' => 'e2pdf_zapier_api_key',
440 + 'value' => get_option('e2pdf_zapier_api_key'),
441 + 'default_value' => '',
442 + 'type' => 'text',
443 + 'readonly' => 'readonly',
444 + 'class' => 'e2pdf-copy-field',
445 + ),
446 + ),
447 + ),
448 + 'gdrive_group' => array(
449 + 'name' => 'Google Drive',
450 + 'action' => 'gdrive',
451 + 'options' => array(
452 + array(
453 + 'name' => 'Redirect URI',
454 + 'value' =>
455 + site_url('/e2pdf-rpc/v1/gdrive/auth?api_key=' . get_option('e2pdf_gdrive_api_key')),
456 + 'default_value' => '',
457 + 'type' => 'text',
458 + 'readonly' => 'readonly',
459 + 'class' => 'e2pdf-copy-field',
460 + ),
461 + array(
462 + 'name' => 'Status',
463 + 'key' => 'e2pdf_gdrive_status',
464 + 'value' => get_option('e2pdf_gdrive_refresh_token') ? __('Authorized', 'e2pdf') : __('Not Authorized', 'e2pdf'),
465 + 'default_value' => '',
466 + 'type' => 'text',
467 + 'readonly' => 'readonly',
468 + ),
469 + array(
470 + 'name' => 'Refresh Token',
471 + 'key' => 'e2pdf_gdrive_refresh_token',
472 + 'value' => get_option('e2pdf_gdrive_refresh_token', ''),
473 + 'default_value' => '',
474 + 'type' => 'text',
475 + 'placeholder' => '',
476 + 'type' => get_option('e2pdf_debug', '0') ? 'text' : 'hidden',
477 + 'readonly' => 'readonly',
478 + ),
479 + array(
480 + 'name' => 'Access Token',
481 + 'key' => 'e2pdf_gdrive_access_token',
482 + 'value' => get_transient('e2pdf_gdrive_access_token') === false ? '' : get_transient('e2pdf_gdrive_access_token'),
483 + 'default_value' => '',
484 + 'type' => get_option('e2pdf_debug', '0') ? 'text' : 'hidden',
485 + 'placeholder' => '',
486 + 'readonly' => 'readonly',
487 + ),
488 + array(
489 + 'header' => 'Configuration',
490 + 'name' => 'Client ID',
491 + 'key' => 'e2pdf_gdrive_client_id',
492 + 'value' => get_option('e2pdf_gdrive_client_id', ''),
493 + 'default_value' => '',
494 + 'type' => 'text',
495 + 'placeholder' => '',
496 + ),
497 + array(
498 + 'name' => 'Client Secret',
499 + 'key' => 'e2pdf_gdrive_client_secret',
500 + 'value' => get_option('e2pdf_gdrive_client_secret', ''),
501 + 'default_value' => '',
502 + 'type' => 'password',
503 + 'placeholder' => '',
504 + ),
505 + )
506 + ),
172 507 'adobesign_group' => array(
173 - 'name' => __('Adobe Sign', 'e2pdf'),
508 + 'name' => 'Adobe Sign',
174 509 'action' => 'adobesign',
175 510 'options' => array(
176 511 array(
177 - 'name' => __('Client ID', 'e2pdf'),
512 + 'name' => 'Redirect URI',
513 + 'value' =>
514 + get_option('e2pdf_adobe_api_version') == '1' ? site_url('/e2pdf-rpc/v1/adobe/auth?api_key=' . get_option('e2pdf_adobe_api_key')) : $helper->get_url(
515 + array(
516 + 'page' => 'e2pdf-settings',
517 + 'action' => 'adobesign',
518 + )
519 + ),
520 + 'default_value' => '',
521 + 'type' => 'text',
522 + 'readonly' => 'readonly',
523 + 'class' => 'e2pdf-copy-field',
524 + ),
525 + array(
526 + 'name' => 'API Version',
527 + 'value' => get_option('e2pdf_adobe_api_version'),
528 + 'default_value' => '',
529 + 'type' => 'hidden',
530 + ),
531 + array(
532 + 'name' => 'Status',
533 + 'key' => 'e2pdf_adobesign_status',
534 + 'value' => get_option('e2pdf_adobesign_refresh_token') ? __('Authorized', 'e2pdf') : __('Not Authorized', 'e2pdf'),
535 + 'default_value' => '',
536 + 'type' => 'text',
537 + 'readonly' => 'readonly',
538 + ),
539 + array(
540 + 'header' => 'Configuration',
541 + 'name' => 'Client ID',
178 542 'key' => 'e2pdf_adobesign_client_id',
179 543 'value' => get_option('e2pdf_adobesign_client_id') === false ? '' : get_option('e2pdf_adobesign_client_id'),
180 544 'default_value' => '',
181 545 'type' => 'text',
182 - 'placeholder' => ''
546 + 'placeholder' => '',
183 547 ),
184 548 array(
185 - 'name' => __('Client Secret', 'e2pdf'),
549 + 'name' => 'Client Secret',
186 550 'key' => 'e2pdf_adobesign_client_secret',
187 551 'value' => get_option('e2pdf_adobesign_client_secret') === false ? '' : get_option('e2pdf_adobesign_client_secret'),
188 552 'default_value' => '',
189 - 'type' => 'text',
190 - 'placeholder' => ''
553 + 'type' => 'password',
554 + 'placeholder' => '',
191 555 ),
192 556 array(
193 - 'name' => __('Region', 'e2pdf'),
557 + 'name' => 'Region',
194 558 'key' => 'e2pdf_adobesign_region',
195 559 'value' => get_option('e2pdf_adobesign_region') === false ? '' : get_option('e2pdf_adobesign_region'),
196 560 'default_value' => '',
197 561 'type' => 'text',
198 - 'placeholder' => __('na2', 'e2pdf')
562 + 'placeholder' => 'na2',
199 563 ),
200 564 array(
201 - 'name' => __('Code', 'e2pdf'),
565 + 'name' => 'Code',
202 566 'key' => 'e2pdf_adobesign_code',
203 567 'value' => get_option('e2pdf_adobesign_code') === false ? '' : get_option('e2pdf_adobesign_code'),
204 568 'default_value' => '',
205 - 'type' => get_option('e2pdf_debug') ? 'text' : 'hidden',
206 - 'placeholder' => ''
569 + 'type' => get_option('e2pdf_debug', '0') ? 'text' : 'hidden',
570 + 'placeholder' => '',
571 + 'readonly' => 'readonly',
207 572 ),
208 573 array(
209 - 'name' => __('Api Access Point', 'e2pdf'),
574 + 'name' => 'Web Access Point',
575 + 'key' => 'e2pdf_adobesign_web_access_point',
576 + 'value' => get_option('e2pdf_adobesign_web_access_point') === false ? '' : get_option('e2pdf_adobesign_web_access_point'),
577 + 'default_value' => '',
578 + 'type' => get_option('e2pdf_debug', '0') ? 'text' : 'hidden',
579 + 'placeholder' => '',
580 + 'readonly' => 'readonly',
581 + ),
582 + array(
583 + 'name' => 'Api Access Point',
210 584 'key' => 'e2pdf_adobesign_api_access_point',
211 585 'value' => get_option('e2pdf_adobesign_api_access_point') === false ? '' : get_option('e2pdf_adobesign_api_access_point'),
212 586 'default_value' => '',
213 - 'type' => get_option('e2pdf_debug') ? 'text' : 'hidden',
214 - 'placeholder' => ''
587 + 'type' => get_option('e2pdf_debug', '0') ? 'text' : 'hidden',
588 + 'placeholder' => '',
589 + 'readonly' => 'readonly',
215 590 ),
216 591 array(
217 - 'name' => __('Refresh Token', 'e2pdf'),
592 + 'name' => 'Refresh Token',
218 593 'key' => 'e2pdf_adobesign_refresh_token',
219 594 'value' => get_option('e2pdf_adobesign_refresh_token') === false ? '' : get_option('e2pdf_adobesign_refresh_token'),
220 595 'default_value' => '',
221 - 'type' => get_option('e2pdf_debug') ? 'text' : 'hidden',
222 - 'placeholder' => ''
596 + 'type' => 'text',
597 + 'placeholder' => '',
598 + 'type' => get_option('e2pdf_debug', '0') ? 'text' : 'hidden',
599 + 'readonly' => 'readonly',
223 600 ),
224 601 array(
225 - 'name' => __('Access Token', 'e2pdf'),
602 + 'name' => 'Access Token',
226 603 'key' => 'e2pdf_adobesign_access_token',
227 604 'value' => get_transient('e2pdf_adobesign_access_token') === false ? '' : get_transient('e2pdf_adobesign_access_token'),
228 605 'default_value' => '',
229 - 'type' => get_option('e2pdf_debug') ? 'text' : 'hidden',
230 - 'placeholder' => ''
606 + 'type' => get_option('e2pdf_debug', '0') ? 'text' : 'hidden',
607 + 'placeholder' => '',
608 + 'readonly' => 'readonly',
231 609 ),
232 610 array(
233 - 'header' => __('Scopes', 'e2pdf'),
234 - 'name' => __('user_read', 'e2pdf'),
611 + 'header' => 'Scopes',
612 + 'name' => 'user_read',
235 613 'key' => 'e2pdf_adobesign_scope_user_read',
236 - 'value' => get_option('e2pdf_adobesign_scope_user_read') === false ? '' : get_option('e2pdf_adobesign_scope_user_read'),
614 + 'value' => get_option('e2pdf_adobesign_scope_user_read', ''),
237 615 'default_value' => '',
238 616 'type' => 'select',
239 617 'options' => array(
240 - '' => __('disabled', 'e2pdf'),
618 + '' => 'disabled',
241 619 'self' => 'self',
242 620 'group' => 'group',
243 - 'account' => 'account'
244 - )
621 + 'account' => 'account',
622 + ),
245 623 ),
246 624 array(
247 - 'name' => __('user_write', 'e2pdf'),
625 + 'name' => 'user_write',
248 626 'key' => 'e2pdf_adobesign_scope_user_write',
249 - 'value' => get_option('e2pdf_adobesign_scope_user_write') === false ? '' : get_option('e2pdf_adobesign_scope_user_write'),
627 + 'value' => get_option('e2pdf_adobesign_scope_user_write', ''),
250 628 'default_value' => '',
251 629 'type' => 'select',
252 630 'options' => array(
253 - '' => __('disabled', 'e2pdf'),
631 + '' => 'disabled',
254 632 'self' => 'self',
255 633 'group' => 'group',
256 - 'account' => 'account'
257 - )
634 + 'account' => 'account',
635 + ),
258 636 ),
259 637 array(
260 - 'name' => __('user_login', 'e2pdf'),
638 + 'name' => 'user_login',
261 639 'key' => 'e2pdf_adobesign_scope_user_login',
262 - 'value' => get_option('e2pdf_adobesign_scope_user_login') === false ? '' : get_option('e2pdf_adobesign_scope_user_login'),
640 + 'value' => get_option('e2pdf_adobesign_scope_user_login', ''),
263 641 'default_value' => '',
264 642 'type' => 'select',
265 643 'options' => array(
266 - '' => __('disabled', 'e2pdf'),
644 + '' => 'disabled',
267 645 'self' => 'self',
268 646 'group' => 'group',
269 - 'account' => 'account'
270 - )
647 + 'account' => 'account',
648 + ),
271 649 ),
272 650 array(
273 - 'name' => __('agreement_read', 'e2pdf'),
651 + 'name' => 'agreement_read',
274 652 'key' => 'e2pdf_adobesign_scope_agreement_read',
275 - 'value' => get_option('e2pdf_adobesign_scope_agreement_read') === false ? '' : get_option('e2pdf_adobesign_scope_agreement_read'),
653 + 'value' => get_option('e2pdf_adobesign_scope_agreement_read', ''),
276 654 'default_value' => '',
277 655 'type' => 'select',
278 656 'options' => array(
279 - '' => __('disabled', 'e2pdf'),
657 + '' => 'disabled',
280 658 'self' => 'self',
281 659 'group' => 'group',
282 - 'account' => 'account'
283 - )
660 + 'account' => 'account',
661 + ),
284 662 ),
285 663 array(
286 - 'name' => __('agreement_write', 'e2pdf'),
664 + 'name' => 'agreement_write',
287 665 'key' => 'e2pdf_adobesign_scope_agreement_write',
288 - 'value' => get_option('e2pdf_adobesign_scope_agreement_write') === false ? '' : get_option('e2pdf_adobesign_scope_agreement_write'),
666 + 'value' => get_option('e2pdf_adobesign_scope_agreement_write', ''),
289 667 'default_value' => '',
290 668 'type' => 'select',
291 669 'options' => array(
292 - '' => __('disabled', 'e2pdf'),
670 + '' => 'disabled',
293 671 'self' => 'self',
294 672 'group' => 'group',
295 - 'account' => 'account'
296 - )
673 + 'account' => 'account',
674 + ),
297 675 ),
298 676 array(
299 - 'name' => __('agreement_send', 'e2pdf'),
677 + 'name' => 'agreement_send',
300 678 'key' => 'e2pdf_adobesign_scope_agreement_send',
301 - 'value' => get_option('e2pdf_adobesign_scope_agreement_send') === false ? '' : get_option('e2pdf_adobesign_scope_agreement_send'),
679 + 'value' => get_option('e2pdf_adobesign_scope_agreement_send', ''),
302 680 'default_value' => '',
303 681 'type' => 'select',
304 682 'options' => array(
305 - '' => __('disabled', 'e2pdf'),
683 + '' => 'disabled',
306 684 'self' => 'self',
307 685 'group' => 'group',
308 - 'account' => 'account'
309 - )
686 + 'account' => 'account',
687 + ),
310 688 ),
311 689 array(
312 - 'name' => __('widget_read', 'e2pdf'),
690 + 'name' => 'widget_read',
313 691 'key' => 'e2pdf_adobesign_scope_widget_read',
314 - 'value' => get_option('e2pdf_adobesign_scope_widget_read') === false ? '' : get_option('e2pdf_adobesign_scope_widget_read'),
692 + 'value' => get_option('e2pdf_adobesign_scope_widget_read', ''),
315 693 'default_value' => '',
316 694 'type' => 'select',
317 695 'options' => array(
318 - '' => __('disabled', 'e2pdf'),
696 + '' => 'disabled',
319 697 'self' => 'self',
320 698 'group' => 'group',
321 - 'account' => 'account'
322 - )
699 + 'account' => 'account',
700 + ),
323 701 ),
324 702 array(
325 - 'name' => __('widget_write', 'e2pdf'),
703 + 'name' => 'widget_write',
326 704 'key' => 'e2pdf_adobesign_scope_widget_write',
327 - 'value' => get_option('e2pdf_adobesign_scope_widget_write') === false ? '' : get_option('e2pdf_adobesign_scope_widget_write'),
705 + 'value' => get_option('e2pdf_adobesign_scope_widget_write', ''),
328 706 'default_value' => '',
329 707 'type' => 'select',
330 708 'options' => array(
331 - '' => __('disabled', 'e2pdf'),
709 + '' => 'disabled',
332 710 'self' => 'self',
333 711 'group' => 'group',
334 - 'account' => 'account'
335 - )
712 + 'account' => 'account',
713 + ),
336 714 ),
337 715 array(
338 - 'name' => __('library_read', 'e2pdf'),
716 + 'name' => 'library_read',
339 717 'key' => 'e2pdf_adobesign_scope_library_read',
340 - 'value' => get_option('e2pdf_adobesign_scope_library_read') === false ? '' : get_option('e2pdf_adobesign_scope_library_read'),
718 + 'value' => get_option('e2pdf_adobesign_scope_library_read', ''),
341 719 'default_value' => '',
342 720 'type' => 'select',
343 721 'options' => array(
344 - '' => __('disabled', 'e2pdf'),
722 + '' => 'disabled',
345 723 'self' => 'self',
346 724 'group' => 'group',
347 - 'account' => 'account'
348 - )
725 + 'account' => 'account',
726 + ),
349 727 ),
350 728 array(
351 - 'name' => __('library_write', 'e2pdf'),
729 + 'name' => 'library_write',
352 730 'key' => 'e2pdf_adobesign_scope_library_write',
353 - 'value' => get_option('e2pdf_adobesign_scope_library_write') === false ? '' : get_option('e2pdf_adobesign_scope_library_write'),
731 + 'value' => get_option('e2pdf_adobesign_scope_library_write', ''),
354 732 'default_value' => '',
355 733 'type' => 'select',
356 734 'options' => array(
357 - '' => __('disabled', 'e2pdf'),
735 + '' => 'disabled',
358 736 'self' => 'self',
359 737 'group' => 'group',
360 - 'account' => 'account'
361 - )
738 + 'account' => 'account',
739 + ),
362 740 ),
363 741 array(
364 - 'name' => __('workflow_read', 'e2pdf'),
742 + 'name' => 'workflow_read',
365 743 'key' => 'e2pdf_adobesign_scope_workflow_read',
366 - 'value' => get_option('e2pdf_adobesign_scope_workflow_read') === false ? '' : get_option('e2pdf_adobesign_scope_workflow_read'),
744 + 'value' => get_option('e2pdf_adobesign_scope_workflow_read', ''),
367 745 'default_value' => '',
368 746 'type' => 'select',
369 747 'options' => array(
370 - '' => __('disabled', 'e2pdf'),
748 + '' => 'disabled',
371 749 'self' => 'self',
372 750 'group' => 'group',
373 - 'account' => 'account'
374 - )
751 + 'account' => 'account',
752 + ),
375 753 ),
376 754 array(
377 - 'name' => __('workflow_write', 'e2pdf'),
755 + 'name' => 'workflow_write',
378 756 'key' => 'e2pdf_adobesign_scope_workflow_write',
379 - 'value' => get_option('e2pdf_adobesign_scope_workflow_write') === false ? '' : get_option('e2pdf_adobesign_scope_workflow_write'),
757 + 'value' => get_option('e2pdf_adobesign_scope_workflow_write', ''),
380 758 'default_value' => '',
381 759 'type' => 'select',
382 760 'options' => array(
383 - '' => __('disabled', 'e2pdf'),
761 + '' => 'disabled',
384 762 'self' => 'self',
385 763 'group' => 'group',
386 - 'account' => 'account'
387 - )
764 + 'account' => 'account',
765 + ),
388 766 ),
389 767 array(
390 - 'name' => __('webhook_read', 'e2pdf'),
768 + 'name' => 'webhook_read',
391 769 'key' => 'e2pdf_adobesign_scope_webhook_read',
392 - 'value' => get_option('e2pdf_adobesign_scope_webhook_read') === false ? '' : get_option('e2pdf_adobesign_scope_webhook_read'),
770 + 'value' => get_option('e2pdf_adobesign_scope_webhook_read', ''),
393 771 'default_value' => '',
394 772 'type' => 'select',
395 773 'options' => array(
396 - '' => __('disabled', 'e2pdf'),
774 + '' => 'disabled',
397 775 'self' => 'self',
398 776 'group' => 'group',
399 - 'account' => 'account'
400 - )
777 + 'account' => 'account',
778 + ),
401 779 ),
402 780 array(
403 - 'name' => __('webhook_write', 'e2pdf'),
781 + 'name' => 'webhook_write',
404 782 'key' => 'e2pdf_adobesign_scope_webhook_write',
405 - 'value' => get_option('e2pdf_adobesign_scope_webhook_write') === false ? '' : get_option('e2pdf_adobesign_scope_webhook_write'),
783 + 'value' => get_option('e2pdf_adobesign_scope_webhook_write', ''),
406 784 'default_value' => '',
407 785 'type' => 'select',
408 786 'options' => array(
409 - '' => __('disabled', 'e2pdf'),
787 + '' => 'disabled',
410 788 'self' => 'self',
411 789 'group' => 'group',
412 - 'account' => 'account'
413 - )
790 + 'account' => 'account',
791 + ),
414 792 ),
415 793 array(
416 - 'name' => __('webhook_retention', 'e2pdf'),
794 + 'name' => 'webhook_retention',
417 795 'key' => 'e2pdf_adobesign_scope_webhook_retention',
418 - 'value' => get_option('e2pdf_adobesign_scope_webhook_retention') === false ? '' : get_option('e2pdf_adobesign_scope_webhook_retention'),
796 + 'value' => get_option('e2pdf_adobesign_scope_webhook_retention', ''),
419 797 'default_value' => '',
420 798 'type' => 'select',
421 799 'options' => array(
422 - '' => __('disabled', 'e2pdf'),
800 + '' => 'disabled',
423 801 'self' => 'self',
424 802 'group' => 'group',
425 - 'account' => 'account'
426 - )
803 + 'account' => 'account',
804 + ),
427 805 ),
428 - )
806 + ),
429 807 ),
430 808 'extensions_group' => array(
431 809 'name' => __('Extensions', 'e2pdf'),
432 810 'action' => 'extensions',
433 - 'options' => $extensions_options
811 + 'options' => $extensions_options,
434 812 ),
435 813 );
436 814
815 + if (
816 + class_exists('TRP_Translate_Press') ||
817 + class_exists('WeglotWP\Services\Translate_Service_Weglot') ||
818 + (function_exists('icl_register_string') && !defined('POLYLANG_VERSION')) ||
819 + defined('POLYLANG_VERSION') ||
820 + $all
821 + ) {
822 + $options['translation_group'] = array(
823 + 'name' => __('Translation', 'e2pdf'),
824 + 'action' => 'translation',
825 + 'options' => array(
826 + array(
827 + 'name' => __('PDF Translation', 'e2pdf'),
828 + 'key' => 'e2pdf_pdf_translation',
829 + 'value' => get_option('e2pdf_pdf_translation', '2'),
830 + 'default_value' => '2',
831 + 'type' => 'select',
832 + 'options' => array(
833 + '0' => __('No Translation', 'e2pdf'),
834 + '1' => __('Partial Translation', 'e2pdf'),
835 + '2' => __('Full Translation', 'e2pdf'),
836 + ),
837 + ),
838 + ),
839 + );
840 + }
841 +
437 842 $options = apply_filters('e2pdf_model_options_get_options_options', $options);
438 843
439 844 if ($all) {
440 845 $opt = array();
@@ -439,9 +844,11 @@
439 844 if ($all) {
440 845 $opt = array();
441 846 foreach ($options as $group_key => $group) {
442 847 foreach ($group['options'] as $option_key => $option) {
443 - $opt[$option['key']] = $option['value'];
848 + if (isset($option['key'])) {
849 + $opt[$option['key']] = isset($option['value']) ? $option['value'] : '';
850 + }
444 851 }
445 852 }
446 853 return $opt;
447 854 } else {
@@ -446,13 +853,13 @@
446 853 return $opt;
447 854 } else {
448 855 foreach ($options as $group_key => $group) {
449 856 if ($exclude) {
450 - if (in_array($group_key, $only_group)) {
857 + if (in_array($group_key, $only_group, true)) {
451 858 unset($options[$group_key]);
452 859 }
453 860 } else {
454 - if (!in_array($group_key, $only_group)) {
861 + if (!in_array($group_key, $only_group, true)) {
455 862 unset($options[$group_key]);
456 863 }
457 864 }
458 865 }
@@ -460,25 +867,29 @@
460 867 return $options;
461 868 }
462 869 }
463 870
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;
871 + // update options
872 + public static function update_options($group = '', $data = array()) {
873 + $options = self::get_options(false, array($group));
874 + foreach ($options as $group_key => $group) {
875 + foreach ($group['options'] as $option_key => $option_value) {
876 + if (isset($option_value['key']) && array_key_exists($option_value['key'], $data)) {
877 + if (isset($option_value['readonly']) && $option_value['readonly'] == 'readonly') { // phpcs:ignore Generic.CodeAnalysis.EmptyStatement.DetectedIf
878 + } else {
879 + if ($option_value['key'] == 'e2pdf_mod_rewrite_url') {
880 + if (false === strpos($data[$option_value['key']], '%uid%')) {
881 + $data[$option_value['key']] = rtrim($data[$option_value['key']], '/') . '/%uid%/';
882 + }
883 + if (!trim(str_replace(array('/', '%uid%'), array('', ''), $data[$option_value['key']]))) {
884 + $data[$option_value['key']] = 'e2pdf/%uid%/';
885 + }
886 + $data[$option_value['key']] = ltrim($data[$option_value['key']], '/');
887 + }
888 + update_option($option_value['key'], $data[$option_value['key']]);
889 + }
890 + }
477 891 }
478 - return array();
479 - } else {
480 - return get_option($key);
481 892 }
893 + return true;
482 894 }
483 -
484 895 }