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

169 lines 6.3 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 );
120
121 $options = apply_filters('e2pdf_model_options_get_options_options', $options);
122
123 if ($all) {
124 $opt = array();
125 foreach ($options as $group_key => $group) {
126 foreach ($group['options'] as $option_key => $option) {
127 $opt[$option['key']] = $option['value'];
128 }
129 }
130 return $opt;
131 } else {
132 foreach ($options as $group_key => $group) {
133 if ($exclude) {
134 if (in_array($group_key, $only_group)) {
135 unset($options[$group_key]);
136 }
137 } else {
138 if (!in_array($group_key, $only_group)) {
139 unset($options[$group_key]);
140 }
141 }
142 }
143
144 return $options;
145 }
146 }
147
148 /**
149 * Get Option value
150 *
151 * @param string $key - Option key
152 *
153 * @return mixed - Option value
154 */
155 function get_option($key) {
156 if ($key === 'e2pdf_developer_ips') {
157 $option = get_option($key);
158 $developers = explode("\r\n", $option);
159 if (!empty($developers)) {
160 return $developers;
161 }
162 return array();
163 } else {
164 return get_option($key);
165 }
166 }
167
168 }
169