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.7 0.2 0.2.1 0.2.2 0.2.3
cf7-conditional-fields / wpcf7cf-options.php
cf7-conditional-fields Last commit date
js 6 years ago Wpcf7cfMailParser.php 6 years ago admin-style.css 6 years ago admin-style.css.map 6 years ago admin-style.scss 6 years ago admin.php 6 years ago cf7cf.php 6 years ago contact-form-7-conditional-fields.php 6 years ago init.php 6 years ago readme.txt 6 years ago style.css 6 years ago tg_pane_group.php 6 years ago wpcf7cf-options.php 6 years ago
wpcf7cf-options.php
333 lines
1 <?php
2
3 define('WPCF7CF_SLUG', 'wpcf7cf');
4 define('WPCF7CF_OPTIONS', WPCF7CF_SLUG.'_options');
5 define('WPCF7CF_TEXT_DOMAIN', WPCF7CF_SLUG.'_text_domain');
6
7 define('WPCF7CF_DEFAULT_ANIMATION', 'yes');
8 define('WPCF7CF_DEFAULT_ANIMATION_INTIME', 200);
9 define('WPCF7CF_DEFAULT_ANIMATION_OUTTIME', 200);
10 define('WPCF7CF_DEFAULT_NOTICE_DISMISSED', false);
11
12 $wpcf7cf_default_options = array(
13 'animation' => WPCF7CF_DEFAULT_ANIMATION,
14 'animation_intime' => WPCF7CF_DEFAULT_ANIMATION_INTIME,
15 'animation_outtime' => WPCF7CF_DEFAULT_ANIMATION_OUTTIME,
16 'notice_dismissed' => WPCF7CF_DEFAULT_NOTICE_DISMISSED
17 );
18
19 if ( ! defined( 'WPCF7_ADMIN_READ_WRITE_CAPABILITY' ) ) {
20 define( 'WPCF7_ADMIN_READ_WRITE_CAPABILITY', 'publish_pages' );
21 }
22
23 $wpcf7cf_default_options = apply_filters('wpcf7cf_default_options', $wpcf7cf_default_options);
24
25 $wpcf7cf_options = get_option(WPCF7CF_OPTIONS);
26
27 if (!is_array($wpcf7cf_options)) {
28 $wpcf7cf_options = $wpcf7cf_default_options;
29 update_option(WPCF7CF_OPTIONS, $wpcf7cf_options);
30 }
31
32
33 // this setting will only be 0 as long as the user has not saved any settings. Once the user has saved the WPCF7CF settings, this value will always remain 1.
34 if (!key_exists('wpcf7cf_settings_saved',$wpcf7cf_options)) $wpcf7cf_options['wpcf7cf_settings_saved'] = 0;
35
36 if ($wpcf7cf_options['wpcf7cf_settings_saved'] == 0) {
37 $wpcf7cf_options = $wpcf7cf_default_options;
38 }
39
40 add_action( 'admin_enqueue_scripts', 'wpcf7cf_load_page_options_wp_admin_style' );
41 function wpcf7cf_load_page_options_wp_admin_style() {
42 wp_register_style( 'wpcf7cf_admin_css', plugins_url('admin-style.css',__FILE__), false, WPCF7CF_VERSION );
43 wp_enqueue_style( 'wpcf7cf_admin_css' );
44 }
45
46
47 add_action('admin_menu', 'wpcf7cf_admin_add_page');
48 function wpcf7cf_admin_add_page() {
49 add_submenu_page('wpcf7', 'Conditional Fields', 'Conditional Fields', WPCF7_ADMIN_READ_WRITE_CAPABILITY, 'wpcf7cf', 'wpcf7cf_options_page' );
50 }
51
52 function wpcf7cf_options_page() {
53 global $wpcf7cf_options;
54
55 // // Include in admin_enqueue_scripts action hook
56 // wp_enqueue_media();
57 // //wp_enqueue_script( 'custom-background' );
58 // wp_enqueue_script( 'wpcf7cf-image-upload', plugins_url('framework/js/bdwm-image-upload.js',__FILE__), array('jquery'), '1.0.0', true );
59
60 if (isset($_POST['reset'])) {
61 echo '<div id="message" class="updated fade"><p><strong>Settings restored to defaults</strong></p></div>';
62 } else if (isset($_REQUEST['settings-updated'])) {
63 echo '<div id="message" class="updated fade"><p><strong>Settings updated</strong></p></div>';
64 }
65
66 ?>
67
68 <div class="wrap wpcf7cf-admin-wrap">
69 <?php screen_icon(); ?>
70 <h2>Contact Form 7 - Conditional Fields Settings</h2>
71 <?php if (!$wpcf7cf_options['notice_dismissed']) { ?>
72 <div class="wpcf7cf-options-notice notice notice-warning is-dismissible"><div style="padding: 10px 0;"><strong>Notice</strong>: These are global settings for Contact Form 7 - Conditional Fields. <br><br><strong>How to create/edit conditional fields?</strong>
73 <ol>
74 <li>Create a new Contact Form or edit an existing one</li>
75 <li>Create at least one [group] inside the form</li>
76 <li>Save the Contact Form</li>
77 <li>go to the <strong><em>Conditional Fields</em></strong> Tab</li>
78 </ol>
79 <a href="https://conditional-fields-cf7.bdwm.be/conditional-fields-for-contact-form-7-tutorial/" target="_blank">Show me an example</a> | <a class="notice-dismiss-2" href="#">Dismiss notice</a>
80 </div></div>
81 <?php } ?>
82 <form action="options.php" method="post">
83 <?php settings_fields(WPCF7CF_OPTIONS); ?>
84
85 <input type="hidden" value="1" id="wpcf7cf_settings_saved" name="<?php echo WPCF7CF_OPTIONS.'[wpcf7cf_settings_saved]' ?>">
86 <input type="hidden" name="<?php echo WPCF7CF_OPTIONS.'[notice_dismissed]' ?>" value="<?php echo $wpcf7cf_options['notice_dismissed'] ?>" />
87
88
89 <h3>Default animation Settings</h3>
90
91 <?php
92
93 wpcf7cf_input_select('animation', array(
94 'label' => 'Animation',
95 'description' => 'Use animations while showing/hiding groups',
96 'options' => array('no'=> 'Disabled', 'yes' => 'Enabled')
97 ));
98
99 wpcf7cf_input_field('animation_intime', array(
100 'label' => 'Animation In time',
101 'description' => 'A positive integer value indicating the time, in milliseconds, it will take for each group to show.',
102 ));
103
104 wpcf7cf_input_field('animation_outtime', array(
105 'label' => 'Animation Out Time',
106 'description' => 'A positive integer value indicating the time, in milliseconds, it will take for each group to hide.',
107 ));
108
109 submit_button();
110
111 if (!WPCF7CF_IS_PRO) {
112 ?>
113 <h3>Conditional Fields PRO</h3>
114 Get conditional Fields PRO to unlock the full potential of CF7
115 <ul class="wpcf7cf-list">
116 <li>Repeaters</li>
117 <li>Regular expressions</li>
118 <li>Togglebuttons</li>
119 <li>Additional operators <code>&lt;</code> <code>&gt;</code> <code>&le;</code> <code>&ge;</code> <code>is empty</code></li>
120 <li>More comming soon (Multistep, Calculated Fields, ...)</li>
121 </ul>
122 <p><a target="_blank" class="button button-primary" href="https://conditional-fields-cf7.bdwm.be/contact-form-7-conditional-fields-pro/">Get PRO</a></p>
123 <?php
124 }
125 do_action('wpcf7cf_after_animation_settings');
126
127 ?>
128
129 </form></div>
130
131 <h3>Restore Default Settings</h3>
132 <form method="post" id="reset-form" action="">
133 <p class="submit">
134 <input name="reset" class="button button-secondary" type="submit" value="Restore defaults" >
135 <input type="hidden" name="action" value="reset" />
136 </p>
137 </form>
138 <script>
139 (function($){
140 $('#reset-form').submit(function() {
141 return confirm('Are you sure you want to reset the plugin settings to the default values? All changes you have previously made will be lost.');
142 });
143 }(jQuery))
144 </script>
145
146 <?php
147 }
148
149
150 function wpcf7cf_image_field($slug, $args) {
151
152 global $wpcf7cf_options, $wpcf7cf_default_options;
153
154 $defaults = array(
155 'title'=>'Image',
156 'description' => '',
157 'choose_text' => 'Choose an image',
158 'update_text' => 'Use image',
159 'default' => $wpcf7cf_default_options[$slug]
160 );
161
162 $args = wp_parse_args( $args, $defaults );
163 extract($args);
164 $label; $description; $choose_text; $update_text; $default;
165
166 if (!key_exists($slug, $wpcf7cf_options)) {
167 $wpcf7cf_options[$slug] = $default;
168 }
169
170 ?>
171 <div class="option-line">
172 <span class="label"><?php echo $label; ?></span>
173 <?php
174 if ($description) {
175 ?>
176 <p><?php echo $description; ?></p>
177 <?php
178 }
179 ?>
180 <div>
181 <div class="image-container" id="default-thumbnail-preview_<?php echo $slug ?>">
182 <?php
183 if ($wpcf7cf_options[$slug] != '') {
184 $img_info = wp_get_attachment_image_src($wpcf7cf_options[$slug], 'full');
185 $img_src = $img_info[0];
186 ?>
187 <img src="<?php echo $img_src ?>" height="100">
188 <?php
189 }
190 ?>
191 </div>
192 <a class="choose-from-library-link" href="#"
193 data-field="<?php echo WPCF7CF_OPTIONS.'_'.$slug ?>"
194 data-image_container="default-thumbnail-preview_<?php echo $slug ?>"
195 data-choose="<?php echo $choose_text; ?>"
196 data-update="<?php echo $update_text; ?>"><?php _e( 'Choose image' ); ?>
197 </a>
198 <input type="hidden" value="<?php echo $wpcf7cf_options[$slug] ?>" id="<?php echo WPCF7CF_OPTIONS.'_'.$slug ?>" name="<?php echo WPCF7CF_OPTIONS.'['.$slug.']' ?>">
199 </div>
200 </div>
201 <?php
202
203 }
204
205 function wpcf7cf_input_field($slug, $args) {
206 global $wpcf7cf_options, $wpcf7cf_default_options;
207
208 $defaults = array(
209 'label'=>'',
210 'desription' => '',
211 'default' => $wpcf7cf_default_options[$slug],
212 'label_editable' => false
213 );
214
215 $args = wp_parse_args( $args, $defaults );
216 extract($args);
217
218 $label; $description; $default; $label_editable;
219
220 if (!key_exists($slug, $wpcf7cf_options)) {
221 $wpcf7cf_options[$slug] = $default;
222 $wpcf7cf_options[$slug.'_label'] = $label;
223 }
224
225 ?>
226 <div class="option-line">
227 <?php if ($label_editable) { ?>
228 <span class="label editable"><input type="text" data-default-value="<?php echo $label ?>" value="<?php echo $wpcf7cf_options[$slug.'_label'] ?>" id="<?php echo WPCF7CF_OPTIONS.'_'.$slug.'_label' ?>" name="<?php echo WPCF7CF_OPTIONS.'['.$slug.'_label]' ?>"></span>
229 <?php } else { ?>
230 <span class="label"><?php echo $label ?></span>
231 <?php } ?>
232 <span class="field"><input type="text" data-default-value="<?php echo $default ?>" value="<?php echo $wpcf7cf_options[$slug] ?>" id="<?php echo WPCF7CF_OPTIONS.'_'.$slug ?>" name="<?php echo WPCF7CF_OPTIONS.'['.$slug.']' ?>"></span>
233 <span class="description"><?php echo $description ?><?php if (!empty($default)) echo ' (Default: '.$default.')' ?></span>
234 </div>
235 <?php
236
237 }
238
239 function wpcf7cf_input_select($slug, $args) {
240 global $wpcf7cf_options, $wpcf7cf_default_options;
241
242 $defaults = array(
243 'label'=>'',
244 'desription' => '',
245 'options' => array(), // array($name => $value)
246 'default' => $wpcf7cf_default_options[$slug],
247 );
248
249 $args = wp_parse_args( $args, $defaults );
250 extract($args);
251
252 $label; $description; $options; $default;
253
254 if (!key_exists($slug, $wpcf7cf_options)) {
255 $wpcf7cf_options[$slug] = $default;
256 }
257
258 // $first_element = array('-1' => '-- Select --');
259 // $options = array_merge($first_element, $options);
260
261 ?>
262 <div class="option-line">
263 <span class="label"><?php echo $label ?></span>
264 <span class="field">
265 <select id="<?php echo WPCF7CF_OPTIONS.'_'.$slug ?>" data-default-value="<?php echo $default ?>" name="<?php echo WPCF7CF_OPTIONS.'['.$slug.']' ?>">
266 <?php
267 foreach($options as $value => $text) {
268 ?>
269 <option value="<?php echo $value ?>" <?php echo $wpcf7cf_options[$slug]==$value?'selected':'' ?>><?php echo $text ?></option>
270 <?php
271 }
272 ?>
273 </select>
274 </span>
275 <span class="description"><?php echo $description ?><?php if (!empty($default)) echo ' (Default: '.$options[$default].')' ?></span>
276 </div>
277 <?php
278
279 }
280
281 function wpcf7cf_checkbox($slug, $args) {
282 global $wpcf7cf_options, $wpcf7cf_default_options;
283
284 $defaults = array(
285 'label'=>'',
286 'desription' => '',
287 'default' => $wpcf7cf_default_options[$slug],
288 );
289
290 $args = wp_parse_args( $args, $defaults );
291 extract($args);
292
293 $label; $description; $default;
294
295 ?>
296 <div class="option-line">
297 <span class="label"><?php echo $label ?></span>
298 <span class="field">
299 <input type="checkbox" data-default-value="<?php echo $default ?>" name="<?php echo WPCF7CF_OPTIONS.'['.$slug.']' ?>" value="1" <?php checked('1', $wpcf7cf_options[$slug]) ?>>
300 </span>
301 <span class="description"><?php echo $description ?><?php if (!empty($default)) echo ' (Default: '.$default.')' ?></span>
302 </div>
303 <?php
304 }
305
306 function wpcf7cf_regex_collection() {
307 global $wpcf7cf_options, $wpcf7cf_default_options;
308
309 }
310
311 add_action('admin_init', 'wpcf7cf_admin_init');
312 function wpcf7cf_admin_init(){
313 global $wpcf7cf_default_options, $wpcf7cf_options;
314
315 if(isset($_POST['reset']) && current_user_can( 'wpcf7_edit_contact_form' ) ) {
316 update_option(WPCF7CF_OPTIONS, $wpcf7cf_default_options);
317 $wpcf7cf_options['wpcf7cf_settings_saved'] = 0;
318 }
319
320 register_setting( WPCF7CF_OPTIONS, WPCF7CF_OPTIONS, 'wpcf7cf_options_sanitize' );
321 }
322
323 function wpcf7cf_options_sanitize($input) {
324 return $input;
325 }
326
327 add_action( 'wp_ajax_wpcf7cf_dismiss_notice', 'wpcf7cf_dismiss_notice' );
328 function wpcf7cf_dismiss_notice() {
329 global $wpcf7cf_options;
330 $wpcf7cf_options['notice_dismissed'] = true;
331 $wpcf7cf_options['wpcf7cf_settings_saved'] = 1;
332 update_option(WPCF7CF_OPTIONS,$wpcf7cf_options);
333 }