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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 7 years ago admin-style.css 7 years ago admin-style.css.map 7 years ago admin-style.scss 7 years ago admin.php 7 years ago cf7cf.php 7 years ago contact-form-7-conditional-fields.php 7 years ago init.php 7 years ago readme.txt 7 years ago style.css 7 years ago tg_pane_group.php 7 years ago wpcf7cf-options.php 7 years ago
wpcf7cf-options.php
317 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)) $wpcf7cf_options = array();
28
29 if(isset($_POST['reset'])) {
30 update_option(WPCF7CF_OPTIONS, $wpcf7cf_default_options);
31 $wpcf7cf_options['wpcf7cf_settings_saved'] = 0;
32 }
33
34 // 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.
35 if (!key_exists('wpcf7cf_settings_saved',$wpcf7cf_options)) $wpcf7cf_options['wpcf7cf_settings_saved'] = 0;
36
37 if ($wpcf7cf_options['wpcf7cf_settings_saved'] == 0) {
38 $wpcf7cf_options = $wpcf7cf_default_options;
39 }
40
41 // LINE 37: removed some ninja_forms related code. Not sure what it was doing here. Keep this reminder here for a while in case problems pop up.
42 // Remove in future update. (Jules 17/02/2018)
43
44 add_action( 'admin_enqueue_scripts', 'wpcf7cf_load_page_options_wp_admin_style' );
45 function wpcf7cf_load_page_options_wp_admin_style() {
46 wp_register_style( 'wpcf7cf_admin_css', plugins_url('admin-style.css',__FILE__), false, WPCF7CF_VERSION );
47 wp_enqueue_style( 'wpcf7cf_admin_css' );
48 }
49
50
51 add_action('admin_menu', 'wpcf7cf_admin_add_page');
52 function wpcf7cf_admin_add_page() {
53 add_submenu_page('wpcf7', 'Conditional Fields', 'Conditional Fields', WPCF7_ADMIN_READ_WRITE_CAPABILITY, 'wpcf7cf', 'wpcf7cf_options_page' );
54 }
55
56 function wpcf7cf_options_page() {
57 global $wpcf7cf_options;
58
59 // // Include in admin_enqueue_scripts action hook
60 // wp_enqueue_media();
61 // //wp_enqueue_script( 'custom-background' );
62 // wp_enqueue_script( 'wpcf7cf-image-upload', plugins_url('framework/js/bdwm-image-upload.js',__FILE__), array('jquery'), '1.0.0', true );
63
64 if (isset($_POST['reset'])) {
65 echo '<div id="message" class="updated fade"><p><strong>Settings restored to defaults</strong></p></div>';
66 } else if (isset($_REQUEST['settings-updated'])) {
67 echo '<div id="message" class="updated fade"><p><strong>Settings updated</strong></p></div>';
68 }
69
70 ?>
71
72 <div class="wrap wpcf7cf-admin-wrap">
73 <?php screen_icon(); ?>
74 <h2>Conditional Fields for Contact Form 7 Settings</h2>
75 <?php if (!$wpcf7cf_options['notice_dismissed']) { ?>
76 <div class="wpcf7cf-options-notice notice notice-warning is-dismissible"><div style="padding: 10px 0;"><strong>Notice</strong>: These are global settings for Conditional Fields for Contact Form 7. <br><br><strong>How to create/edit conditional fields?</strong>
77 <ol>
78 <li>Create a new Contact Form or edit an existing one</li>
79 <li>Create at least one [group] inside the form</li>
80 <li>Save the Contact Form</li>
81 <li>go to the <strong><em>Conditional Fields</em></strong> Tab</li>
82 </ol>
83 <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>
84 </div></div>
85 <?php } ?>
86 <form action="options.php" method="post">
87 <?php settings_fields(WPCF7CF_OPTIONS); ?>
88
89 <input type="hidden" value="1" id="wpcf7cf_settings_saved" name="<?php echo WPCF7CF_OPTIONS.'[wpcf7cf_settings_saved]' ?>">
90 <input type="hidden" name="<?php echo WPCF7CF_OPTIONS.'[notice_dismissed]' ?>" value="<?php echo $wpcf7cf_options['notice_dismissed'] ?>" />
91
92
93 <h3>Default animation Settings</h3>
94
95 <?php
96
97 wpcf7cf_input_select('animation', array(
98 'label' => 'Animation',
99 'description' => 'Use animations while showing/hiding groups',
100 'options' => array('no'=> 'Disabled', 'yes' => 'Enabled')
101 ));
102
103 wpcf7cf_input_field('animation_intime', array(
104 'label' => 'Animation In time',
105 'description' => 'A positive integer value indicating the time, in milliseconds, it will take for each group to show.',
106 ));
107
108 wpcf7cf_input_field('animation_outtime', array(
109 'label' => 'Animation Out Time',
110 'description' => 'A positive integer value indicating the time, in milliseconds, it will take for each group to hide.',
111 ));
112
113 submit_button();
114
115 do_action('wpcf7cf_after_animation_settings');
116
117 ?>
118
119 </form></div>
120
121 <h3>Restore Default Settings</h3>
122 <form method="post" id="reset-form" action="">
123 <p class="submit">
124 <input name="reset" class="button button-secondary" type="submit" value="Restore defaults" >
125 <input type="hidden" name="action" value="reset" />
126 </p>
127 </form>
128 <script>
129 (function($){
130 $('#reset-form').submit(function() {
131 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.');
132 });
133 }(jQuery))
134 </script>
135
136 <?php
137 }
138
139
140 function wpcf7cf_image_field($slug, $args) {
141
142 global $wpcf7cf_options, $wpcf7cf_default_options;
143
144 $defaults = array(
145 'title'=>'Image',
146 'description' => '',
147 'choose_text' => 'Choose an image',
148 'update_text' => 'Use image',
149 'default' => $wpcf7cf_default_options[$slug]
150 );
151
152 $args = wp_parse_args( $args, $defaults );
153 extract($args);
154 $label; $description; $choose_text; $update_text; $default;
155
156 if (!key_exists($slug, $wpcf7cf_options)) {
157 $wpcf7cf_options[$slug] = $default;
158 }
159
160 ?>
161 <div class="option-line">
162 <span class="label"><?php echo $label; ?></span>
163 <?php
164 if ($description) {
165 ?>
166 <p><?php echo $description; ?></p>
167 <?php
168 }
169 ?>
170 <div>
171 <div class="image-container" id="default-thumbnail-preview_<?php echo $slug ?>">
172 <?php
173 if ($wpcf7cf_options[$slug] != '') {
174 $img_info = wp_get_attachment_image_src($wpcf7cf_options[$slug], 'full');
175 $img_src = $img_info[0];
176 ?>
177 <img src="<?php echo $img_src ?>" height="100">
178 <?php
179 }
180 ?>
181 </div>
182 <a class="choose-from-library-link" href="#"
183 data-field="<?php echo WPCF7CF_OPTIONS.'_'.$slug ?>"
184 data-image_container="default-thumbnail-preview_<?php echo $slug ?>"
185 data-choose="<?php echo $choose_text; ?>"
186 data-update="<?php echo $update_text; ?>"><?php _e( 'Choose image' ); ?>
187 </a>
188 <input type="hidden" value="<?php echo $wpcf7cf_options[$slug] ?>" id="<?php echo WPCF7CF_OPTIONS.'_'.$slug ?>" name="<?php echo WPCF7CF_OPTIONS.'['.$slug.']' ?>">
189 </div>
190 </div>
191 <?php
192
193 }
194
195 function wpcf7cf_input_field($slug, $args) {
196 global $wpcf7cf_options, $wpcf7cf_default_options;
197
198 $defaults = array(
199 'label'=>'',
200 'desription' => '',
201 'default' => $wpcf7cf_default_options[$slug],
202 'label_editable' => false
203 );
204
205 $args = wp_parse_args( $args, $defaults );
206 extract($args);
207
208 $label; $description; $default; $label_editable;
209
210 if (!key_exists($slug, $wpcf7cf_options)) {
211 $wpcf7cf_options[$slug] = $default;
212 $wpcf7cf_options[$slug.'_label'] = $label;
213 }
214
215 ?>
216 <div class="option-line">
217 <?php if ($label_editable) { ?>
218 <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>
219 <?php } else { ?>
220 <span class="label"><?php echo $label ?></span>
221 <?php } ?>
222 <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>
223 <span class="description"><?php echo $description ?><?php if (!empty($default)) echo ' (Default: '.$default.')' ?></span>
224 </div>
225 <?php
226
227 }
228
229 function wpcf7cf_input_select($slug, $args) {
230 global $wpcf7cf_options, $wpcf7cf_default_options;
231
232 $defaults = array(
233 'label'=>'',
234 'desription' => '',
235 'options' => array(), // array($name => $value)
236 'default' => $wpcf7cf_default_options[$slug],
237 );
238
239 $args = wp_parse_args( $args, $defaults );
240 extract($args);
241
242 $label; $description; $options; $default;
243
244 if (!key_exists($slug, $wpcf7cf_options)) {
245 $wpcf7cf_options[$slug] = $default;
246 }
247
248 // $first_element = array('-1' => '-- Select --');
249 // $options = array_merge($first_element, $options);
250
251 ?>
252 <div class="option-line">
253 <span class="label"><?php echo $label ?></span>
254 <span class="field">
255 <select id="<?php echo WPCF7CF_OPTIONS.'_'.$slug ?>" data-default-value="<?php echo $default ?>" name="<?php echo WPCF7CF_OPTIONS.'['.$slug.']' ?>">
256 <?php
257 foreach($options as $value => $text) {
258 ?>
259 <option value="<?php echo $value ?>" <?php echo $wpcf7cf_options[$slug]==$value?'selected':'' ?>><?php echo $text ?></option>
260 <?php
261 }
262 ?>
263 </select>
264 </span>
265 <span class="description"><?php echo $description ?><?php if (!empty($default)) echo ' (Default: '.$options[$default].')' ?></span>
266 </div>
267 <?php
268
269 }
270
271 function wpcf7cf_checkbox($slug, $args) {
272 global $wpcf7cf_options, $wpcf7cf_default_options;
273
274 $defaults = array(
275 'label'=>'',
276 'desription' => '',
277 'default' => $wpcf7cf_default_options[$slug],
278 );
279
280 $args = wp_parse_args( $args, $defaults );
281 extract($args);
282
283 $label; $description; $default;
284
285 ?>
286 <div class="option-line">
287 <span class="label"><?php echo $label ?></span>
288 <span class="field">
289
290 <input type="checkbox" data-default-value="<?php echo $default ?>" name="<?php echo WPCF7CF_OPTIONS.'['.$slug.']' ?>" value="1" <?php checked('1', $wpcf7cf_options[$slug]) ?>>
291 </span>
292 <span class="description"><?php echo $description ?><?php if (!empty($default)) echo ' (Default: '.$default.')' ?></span>
293 </div>
294 <?php
295 }
296
297 function wpcf7cf_regex_collection() {
298 global $wpcf7cf_options, $wpcf7cf_default_options;
299
300 }
301
302 add_action('admin_init', 'wpcf7cf_admin_init');
303 function wpcf7cf_admin_init(){
304 register_setting( WPCF7CF_OPTIONS, WPCF7CF_OPTIONS, 'wpcf7cf_options_sanitize' );
305 }
306
307 function wpcf7cf_options_sanitize($input) {
308 return $input;
309 }
310
311 add_action( 'wp_ajax_wpcf7cf_dismiss_notice', 'wpcf7cf_dismiss_notice' );
312 function wpcf7cf_dismiss_notice() {
313 global $wpcf7cf_options;
314 $wpcf7cf_options['notice_dismissed'] = true;
315 $wpcf7cf_options['wpcf7cf_settings_saved'] = 1;
316 update_option(WPCF7CF_OPTIONS,$wpcf7cf_options);
317 }