PluginProbe
CryptX / 4.0.1
CryptX v4.0.1
4.2.1 4.2.0 4.1.1 trunk 1.0 1.1 1.2 1.3 1.4 1.5 1.6 1.7 1.9 2.0 2.1 2.2 2.3 2.3.1 2.3.2 2.3.3 2.4.0 2.4.1 2.4.2 2.4.3 2.4.4 All 93 releases
cryptx / templates / admin / tabs / presentation.php

presentation.php in CryptX 4.0.1, at templates/admin/tabs/presentation.php

275 lines 14.8 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * CryptX Presentation Settings Tab Template
4 * Variables extracted from PresentationSettingsTab:
5 * - $css: CSS settings array
6 * - $emailReplacements: Email replacement settings
7 * - $linkTextOptions: Link text configuration options
8 * - $selectedOption: Currently selected option value
9 */
10 if (!defined('ABSPATH')) {
11 exit;
12 }
13 ?>
14
15 <div class="cryptx-tab-content cryptx-presentation-settings">
16 <table class="form-table">
17
18 <!-- CSS Settings Section -->
19 <tr>
20 <th colspan="2">
21 <h3 style="margin: 20px 0 10px 0; padding: 10px 0; border-bottom: 1px solid #ddd;">
22 <?php _e('CSS Settings', 'cryptx'); ?>
23 </h3>
24 </th>
25 </tr>
26 <tr>
27 <th scope="row"><?php _e("CSS-ID", 'cryptx'); ?></th>
28 <td>
29 <input name="cryptX_var[css_id]" id="css_id" value="<?php echo esc_attr($css['id']); ?>" type="text" class="regular-text" />
30 <p class="description"><?php _e("Please be careful using this feature! IDs should be unique. You should prefer using a CSS class instead.", 'cryptx'); ?></p>
31 </td>
32 </tr>
33 <tr>
34 <th scope="row"><?php _e("CSS-Class", 'cryptx'); ?></th>
35 <td>
36 <input name="cryptX_var[css_class]" id="css_class" value="<?php echo esc_attr($css['class']); ?>" type="text" class="regular-text" />
37 <p class="description"><?php _e("Add custom CSS class to encrypted email links.", 'cryptx'); ?></p>
38 </td>
39 </tr>
40
41 <!-- Link Text Options Section -->
42 <tr>
43 <th colspan="2">
44 <h3 style="margin: 20px 0 10px 0; padding: 10px 0; border-bottom: 1px solid #ddd;">
45 <?php _e('Link Text Options', 'cryptx'); ?>
46 </h3>
47 </th>
48 </tr>
49 <tr>
50 <th scope="row"><?php _e('Presentation Method', 'cryptx'); ?></th>
51 <td>
52 <fieldset>
53 <!-- Option 0: Replacement Text -->
54 <label>
55 <input name="cryptX_var[opt_linktext]" type="radio" value="0" <?php checked($selectedOption, 0); ?> />
56 <strong><?php _e("Show Email with text replacement", 'cryptx'); ?></strong>
57 </label>
58 <div style="margin-left: 25px; margin-top: 10px; margin-bottom: 20px;">
59 <table class="form-table" style="margin: 0;">
60 <?php foreach ($linkTextOptions['replacement']['fields'] as $field => $config): ?>
61 <tr>
62 <th scope="row" style="padding-left: 0;"><?php echo $config['label']; ?></th>
63 <td style="padding-left: 10px;">
64 <input name="cryptX_var[<?php echo esc_attr($field); ?>]"
65 value="<?php echo esc_attr($config['value']); ?>"
66 type="text" class="regular-text" />
67 </td>
68 </tr>
69 <?php endforeach; ?>
70 </table>
71 </div>
72
73 <!-- Option 1: Custom Text -->
74 <label>
75 <input name="cryptX_var[opt_linktext]" type="radio" value="1" <?php checked($selectedOption, 1); ?> />
76 <strong><?php _e("Show custom text", 'cryptx'); ?></strong>
77 </label>
78 <div style="margin-left: 25px; margin-top: 10px; margin-bottom: 20px;">
79 <table class="form-table" style="margin: 0;">
80 <?php foreach ($linkTextOptions['customText']['fields'] as $field => $config): ?>
81 <tr>
82 <th scope="row" style="padding-left: 0;"><?php echo $config['label']; ?></th>
83 <td style="padding-left: 10px;">
84 <input name="cryptX_var[<?php echo esc_attr($field); ?>]"
85 value="<?php echo esc_attr($config['value']); ?>"
86 type="text" class="regular-text" />
87 </td>
88 </tr>
89 <?php endforeach; ?>
90 </table>
91 </div>
92
93 <!-- Option 2: External Image -->
94 <label>
95 <input name="cryptX_var[opt_linktext]" type="radio" value="2" <?php checked($selectedOption, 2); ?> />
96 <strong><?php _e("Show external image", 'cryptx'); ?></strong>
97 </label>
98 <div style="margin-left: 25px; margin-top: 10px; margin-bottom: 20px;">
99 <table class="form-table" style="margin: 0;">
100 <?php foreach ($linkTextOptions['externalImage']['fields'] as $field => $config): ?>
101 <tr>
102 <th scope="row" style="padding-left: 0;"><?php echo $config['label']; ?></th>
103 <td style="padding-left: 10px;">
104 <?php if ($field === 'alt_linkimage'): ?>
105 <input name="cryptX_var[<?php echo esc_attr($field); ?>]"
106 value="<?php echo esc_attr($config['value']); ?>"
107 type="url" class="regular-text"
108 placeholder="https://example.com/image.png" />
109 <?php else: ?>
110 <input name="cryptX_var[<?php echo esc_attr($field); ?>]"
111 value="<?php echo esc_attr($config['value']); ?>"
112 type="text" class="regular-text" />
113 <?php endif; ?>
114 </td>
115 </tr>
116 <?php endforeach; ?>
117 </table>
118 </div>
119
120 <!-- Option 3: Uploaded Image -->
121 <label>
122 <input name="cryptX_var[opt_linktext]" type="radio" value="3" <?php checked($selectedOption, 3); ?> />
123 <strong><?php _e("Show uploaded image", 'cryptx'); ?></strong>
124 </label>
125 <div style="margin-left: 25px; margin-top: 10px; margin-bottom: 20px;">
126 <table class="form-table" style="margin: 0;">
127 <tr>
128 <th scope="row" style="padding-left: 0;"><?php _e("Select Image", 'cryptx'); ?></th>
129 <td style="padding-left: 10px;">
130 <input name="cryptX_var[alt_uploadedimage]" id="alt_uploadedimage"
131 value="<?php echo esc_attr($linkTextOptions['uploadedImage']['fields']['alt_uploadedimage']['value']); ?>"
132 type="hidden" />
133 <button type="button" class="button" id="upload_image_button">
134 <?php _e("Choose Image", 'cryptx'); ?>
135 </button>
136 <div id="image_preview" style="margin-top: 10px;"></div>
137 </td>
138 </tr>
139 <tr>
140 <th scope="row" style="padding-left: 0;">
141 <?php echo $linkTextOptions['uploadedImage']['fields']['alt_linkimage_title']['label']; ?>
142 </th>
143 <td style="padding-left: 10px;">
144 <input name="cryptX_var[alt_linkimage_title]"
145 value="<?php echo esc_attr($linkTextOptions['uploadedImage']['fields']['alt_linkimage_title']['value']); ?>"
146 type="text" class="regular-text" />
147 </td>
148 </tr>
149 </table>
150 </div>
151
152 <!-- Option 4: Scrambled Text -->
153 <label>
154 <input name="cryptX_var[opt_linktext]" type="radio" value="4" <?php checked($selectedOption, 4); ?> />
155 <strong><?php echo $linkTextOptions['scrambled']['label']; ?></strong>
156 </label><br/><br/>
157
158 <!-- Option 5: PNG Image -->
159 <label>
160 <input name="cryptX_var[opt_linktext]" type="radio" value="5" <?php checked($selectedOption, 5); ?> />
161 <strong><?php echo $linkTextOptions['pngImage']['label']; ?></strong>
162 </label>
163 <div style="margin-left: 25px; margin-top: 10px; margin-bottom: 20px;">
164 <table class="form-table" style="margin: 0;">
165 <?php foreach ($linkTextOptions['pngImage']['fields'] as $field => $config): ?>
166 <tr>
167 <th scope="row" style="padding-left: 0;"><?php echo $config['label']; ?></th>
168 <td style="padding-left: 10px;">
169 <?php if ($field === 'c2i_font'): ?>
170 <select name="cryptX_var[<?php echo esc_attr($field); ?>]">
171 <?php foreach ($config['options'] as $value => $label): ?>
172 <option value="<?php echo esc_attr($value); ?>" <?php selected($config['value'], $value); ?>>
173 <?php echo esc_html($label); ?>
174 </option>
175 <?php endforeach; ?>
176 </select>
177 <?php elseif ($field === 'c2i_fontRGB'): ?>
178 <input name="cryptX_var[<?php echo esc_attr($field); ?>]"
179 id="c2i_fontRGB"
180 value="<?php echo esc_attr($config['value']); ?>"
181 type="text" class="color-field" />
182 <?php elseif ($field === 'c2i_fontSize'): ?>
183 <input name="cryptX_var[<?php echo esc_attr($field); ?>]"
184 value="<?php echo esc_attr($config['value']); ?>"
185 type="number" min="8" max="72" />
186 <?php else: ?>
187 <input name="cryptX_var[<?php echo esc_attr($field); ?>]"
188 value="<?php echo esc_attr($config['value']); ?>"
189 type="text" class="regular-text" />
190 <?php endif; ?>
191 </td>
192 </tr>
193 <?php endforeach; ?>
194 </table>
195 </div>
196 </fieldset>
197 </td>
198 </tr>
199 </table>
200
201 <!-- Submit Button -->
202 <p class="submit">
203 <input type="submit"
204 name="cryptX_save_presentation_settings"
205 class="button-primary"
206 value="<?php _e('Save Changes', 'cryptx'); ?>" />
207 <input type="submit"
208 name="cryptX_var_reset"
209 class="button-secondary"
210 value="<?php _e('Reset to Defaults', 'cryptx'); ?>"
211 onclick="return confirm('<?php _e('Are you sure you want to reset all presentation settings to defaults?', 'cryptx'); ?>');" />
212 </p>
213 </div>
214
215 <script>
216 document.addEventListener('DOMContentLoaded', function() {
217 // Initialize WordPress Color Picker
218 if (typeof jQuery !== 'undefined' && jQuery.fn.wpColorPicker) {
219 jQuery('.color-field').wpColorPicker();
220 }
221
222 // Handle image upload functionality
223 const uploadButton = document.getElementById('upload_image_button');
224 const imageField = document.getElementById('alt_uploadedimage');
225 const imagePreview = document.getElementById('image_preview');
226
227 if (uploadButton && typeof wp !== 'undefined' && wp.media) {
228 let mediaUploader;
229
230 uploadButton.addEventListener('click', function(e) {
231 e.preventDefault();
232
233 if (mediaUploader) {
234 mediaUploader.open();
235 return;
236 }
237
238 mediaUploader = wp.media({
239 title: '<?php _e("Choose Image", "cryptx"); ?>',
240 button: {
241 text: '<?php _e("Choose Image", "cryptx"); ?>'
242 },
243 multiple: false,
244 library: {
245 type: 'image'
246 }
247 });
248
249 mediaUploader.on('select', function() {
250 const attachment = mediaUploader.state().get('selection').first().toJSON();
251 imageField.value = attachment.id;
252
253 if (attachment.sizes && attachment.sizes.thumbnail) {
254 imagePreview.innerHTML = '<img src="' + attachment.sizes.thumbnail.url + '" style="max-width: 150px; height: auto;" />';
255 } else {
256 imagePreview.innerHTML = '<img src="' + attachment.url + '" style="max-width: 150px; height: auto;" />';
257 }
258 });
259
260 mediaUploader.open();
261 });
262
263 // Show current image if one is selected
264 if (imageField.value && imageField.value !== '0') {
265 wp.media.attachment(imageField.value).fetch().then(function(attachment) {
266 if (attachment.attributes.sizes && attachment.attributes.sizes.thumbnail) {
267 imagePreview.innerHTML = '<img src="' + attachment.attributes.sizes.thumbnail.url + '" style="max-width: 150px; height: auto;" />';
268 } else {
269 imagePreview.innerHTML = '<img src="' + attachment.attributes.url + '" style="max-width: 150px; height: auto;" />';
270 }
271 });
272 }
273 }
274 });
275 </script>