PluginProbe
Prismatic / 2.2
Prismatic v2.2
trunk 1.3 1.4 1.5 1.6 1.6.1 1.7 1.8 1.9 2.0 2.1 2.2 2.3 2.4 2.5 2.6 2.7 2.8 2.9 2.9.1 3.0 3.1 3.1.1 3.2 3.2.1 All 40 releases
prismatic / inc / settings-callbacks.php

settings-callbacks.php in Prismatic 2.2, at inc/settings-callbacks.php

276 lines 7.8 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php // Prismatic - Settings Callbacks
2
3 if (!defined('ABSPATH')) exit;
4
5 function prismatic_section_general() {
6
7 echo '<p>'. esc_html__('Thank you for using the free version of', 'prismatic') .' <a target="_blank" rel="noopener noreferrer" href="https://wordpress.org/plugins/prismatic/">'. esc_html__('Prismatic', 'prismatic') .'</a>.</p>';
8
9 }
10
11 function prismatic_section_prism() {
12
13 echo '<p>'. esc_html__('Settings for syntax highlighting via', 'prismatic') .' <a target="_blank" rel="noopener noreferrer" href="https://prismjs.com/">'. esc_html__('Prism.js', 'prismatic') .'</a>.</p>';
14
15 }
16
17 function prismatic_section_prism_code() {
18
19 echo '<p>'. esc_html__('Settings for code escaping when Prism.js is enabled.', 'prismatic') .'</p>';
20
21 }
22
23 function prismatic_section_highlight() {
24
25 echo '<p>'. esc_html__('Settings for syntax highlighting via', 'prismatic') .' <a target="_blank" rel="noopener noreferrer" href="https://highlightjs.org/">'. esc_html__('Highlight.js', 'prismatic') .'</a>.</p>';
26
27 }
28
29 function prismatic_section_highlight_code() {
30
31 echo '<p>'. esc_html__('Settings for code escaping when Highlight.js is enabled.', 'prismatic') .'</p>';
32
33 }
34
35 function prismatic_section_plain() {
36
37 echo '<p>'. esc_html__('Settings for code escaping without syntax highlighting.', 'prismatic') .'</p>';
38
39 }
40
41 function prismatic_library() {
42
43 $library = array(
44
45 'prism' => array(
46 'value' => 'prism',
47 'label' => esc_html__('Prism.js', 'prismatic'),
48 ),
49 'highlight' => array(
50 'value' => 'highlight',
51 'label' => esc_html__('Highlight.js', 'prismatic'),
52 ),
53 'plain' => array(
54 'value' => 'plain',
55 'label' => esc_html__('Plain Flavor', 'prismatic'),
56 ),
57 'none' => array(
58 'value' => 'none',
59 'label' => esc_html__('None (Disable)', 'prismatic'),
60 ),
61 );
62
63 return $library;
64
65 }
66
67 function prismatic_location() {
68
69 $array = array(
70
71 'front' => array(
72 'value' => 'front',
73 'label' => esc_html__('Frontend only', 'prismatic'),
74 ),
75 'admin' => array(
76 'value' => 'admin',
77 'label' => esc_html__('Admin Area only', 'prismatic'),
78 ),
79 'both' => array(
80 'value' => 'both',
81 'label' => esc_html__('Frontend &amp; Admin Area', 'prismatic'),
82 ),
83 'none' => array(
84 'value' => 'none',
85 'label' => esc_html__('None (Disable)', 'prismatic'),
86 ),
87 );
88
89 return $array;
90
91 }
92
93 function prismatic_prism_theme() {
94
95 $theme = array(
96
97 'coy' => array(
98 'value' => 'coy',
99 'label' => esc_html__('Coy', 'prismatic'),
100 ),
101 'dark' => array(
102 'value' => 'dark',
103 'label' => esc_html__('Dark', 'prismatic'),
104 ),
105 'default' => array(
106 'value' => 'default',
107 'label' => esc_html__('Default', 'prismatic'),
108 ),
109 'funky' => array(
110 'value' => 'funky',
111 'label' => esc_html__('Funky', 'prismatic'),
112 ),
113 'okaidia' => array(
114 'value' => 'okaidia',
115 'label' => esc_html__('Okaidia', 'prismatic'),
116 ),
117 'solarized' => array(
118 'value' => 'solarized',
119 'label' => esc_html__('Solarized', 'prismatic'),
120 ),
121 'tomorrow-night' => array(
122 'value' => 'tomorrow-night',
123 'label' => esc_html__('Tomorrow Night', 'prismatic'),
124 ),
125 'twilight' => array(
126 'value' => 'twilight',
127 'label' => esc_html__('Twilight', 'prismatic'),
128 ),
129 );
130
131 return $theme;
132
133 }
134
135 function prismatic_highlight_theme() {
136
137 require_once PRISMATIC_DIR .'lib/highlight/themes.php';
138
139 return $theme;
140
141 }
142
143 function prismatic_callback_select($args) {
144
145 $id = isset($args['id']) ? $args['id'] : '';
146 $label = isset($args['label']) ? $args['label'] : '';
147 $section = isset($args['section']) ? $args['section'] : '';
148
149 $setting = 'prismatic_options_'. $section;
150
151 $options = prismatic_get_default_options($section);
152
153 $value = isset($options[$id]) ? sanitize_text_field($options[$id]) : '';
154
155 $options_array = array();
156
157 if ($id === 'library') {
158
159 $options_array = prismatic_library();
160
161 } elseif ($id === 'filter_content' || $id === 'filter_excerpts' || $id === 'filter_comments') {
162
163 $options_array = prismatic_location();
164
165 } elseif ($id === 'prism_theme') {
166
167 $options_array = prismatic_prism_theme();
168
169 } elseif ($id === 'highlight_theme') {
170
171 $options_array = prismatic_highlight_theme();
172
173 }
174
175 echo '<select name="'. $setting .'['. $id .']">';
176
177 foreach ($options_array as $option) {
178 echo '<option '. selected($option['value'], $value, false) .' value="'. $option['value'] .'">'. $option['label'] .'</option>';
179 }
180 echo '</select> <label class="prismatic-label inline-block" for="'. $setting .'['. $id .']">'. $label .'</label>';
181
182 }
183
184 function prismatic_callback_text($args) {
185
186 $id = isset($args['id']) ? $args['id'] : '';
187 $label = isset($args['label']) ? $args['label'] : '';
188 $section = isset($args['section']) ? $args['section'] : '';
189
190 $setting = 'prismatic_options_'. $section;
191
192 $options = prismatic_get_default_options($section);
193
194 $value = isset($options[$id]) ? sanitize_text_field($options[$id]) : '';
195
196 echo '<input name="'. $setting .'['. $id .']" type="text" size="40" value="'. $value .'"> ';
197 echo '<label for="'. $setting .'['. $id .']" class="prismatic-label">'. $label .'</label>';
198
199 }
200
201 function prismatic_callback_textarea($args) {
202
203 $id = isset($args['id']) ? $args['id'] : '';
204 $label = isset($args['label']) ? $args['label'] : '';
205 $section = isset($args['section']) ? $args['section'] : '';
206
207 $setting = 'prismatic_options_'. $section;
208
209 $options = prismatic_get_default_options($section);
210
211 $allowed_tags = wp_kses_allowed_html('post');
212
213 $value = isset($options[$id]) ? wp_kses(stripslashes_deep($options[$id]), $allowed_tags) : '';
214
215 echo '<textarea name="'. $setting .'['. $id .']" rows="3" cols="50">'. $value .'</textarea> ';
216 echo '<label for="'. $setting .'['. $id .']" class="prismatic-label" >'. $label .'</label>';
217
218 }
219
220 function prismatic_callback_checkbox($args) {
221
222 $id = isset($args['id']) ? $args['id'] : '';
223 $label = isset($args['label']) ? $args['label'] : '';
224 $section = isset($args['section']) ? $args['section'] : '';
225
226 $setting = 'prismatic_options_'. $section;
227
228 $options = prismatic_get_default_options($section);
229
230 $checked = isset($options[$id]) ? checked($options[$id], 1, false) : '';
231
232 echo '<input name="'. $setting .'['. $id .']" value="1" type="checkbox" '. $checked .'> ';
233 echo '<label for="'. $setting .'['. $id .']" class="prismatic-label inline-block">'. $label .'</label>';
234
235 }
236
237 function prismatic_callback_number($args) {
238
239 $id = isset($args['id']) ? $args['id'] : '';
240 $label = isset($args['label']) ? $args['label'] : '';
241 $section = isset($args['section']) ? $args['section'] : '';
242
243 $setting = 'prismatic_options_'. $section;
244
245 $options = prismatic_get_default_options($section);
246
247 $value = isset($options[$id]) ? sanitize_text_field($options[$id]) : '';
248
249 $min = 0;
250 $max = 999;
251
252 echo '<input name="'. $setting .'['. $id .']" type="number" min="'. $min .'" max="'. $max .'" value="'. $value .'"> ';
253 echo '<label for="'. $setting .'['. $id .']" class="prismatic-label inline-block">'. $label .'</label>';
254
255 }
256
257 function prismatic_callback_reset($args) {
258
259 $nonce = wp_create_nonce('prismatic_reset_options');
260 $url = admin_url('options-general.php?page=prismatic');
261 $href = esc_url(add_query_arg(array('reset-options-verify' => $nonce), $url));
262
263 echo '<a class="prismatic-reset-options" href="'. $href .'">'. esc_html__('Restore default plugin options', 'prismatic') .'</a>';
264
265 }
266
267 function prismatic_callback_rate($args) {
268
269 $href = 'https://wordpress.org/support/plugin/'. PRISMATIC_SLUG .'/reviews/?rate=5#new-post';
270 $title = esc_attr__('Help keep Prismatic going strong! A huge THANK YOU for your support!', 'prismatic');
271 $text = isset($args['label']) ? $args['label'] : esc_html__('Show support with a 5-star rating &raquo;', 'prismatic');
272
273 echo '<a target="_blank" rel="noopener noreferrer" class="prismatic-rate-plugin" href="'. $href .'" title="'. $title .'">'. $text .'</a>';
274
275 }
276