| @@ -1,3425 +1,4482 @@ | ||
| 1 | -<?php | |
| 2 | -add_action('admin_menu', 'accua_forms_menu', -95); | |
| 3 | -function accua_forms_menu(){ | |
| 4 | - $dashboard_admin_page=add_menu_page('Wordpress Contact Forms by Cimatti', 'Forms', 10, 'accua_forms', 'accua_dashboard_page', plugin_dir_url( __FILE__ ).'img/cimatti-16-icon.png'); | |
| 5 | - add_action('load-'.$dashboard_admin_page, 'accua_dashboard_page_head'); | |
| 6 | - | |
| 7 | - add_submenu_page('accua_forms', 'Wordpress Contact Forms by Cimatti', 'Dashboard', 10, "accua_forms", 'accua_dashboard_page'); | |
| 8 | - | |
| 9 | - $form_edit_page = add_submenu_page('accua_forms', 'Forms', 'Forms', 10, "accua_forms_list", 'accua_forms_list_page'); | |
| 10 | - add_action('admin_head-'.$form_edit_page, 'accua_forms_edit_page_head'); | |
| 11 | - add_action( 'admin_print_styles-'.$form_edit_page, 'accua_forms_edit_page_head_styles'); | |
| 12 | - add_action( 'admin_print_scripts-'.$form_edit_page, 'accua_forms_edit_page_head_scripts'); | |
| 13 | - | |
| 14 | - $form_add_page = add_submenu_page('accua_forms', __('Add new form', 'accua-form-api'), __('Add new', 'accua-form-api'), 10, "accua_forms_add", 'accua_forms_add_page'); | |
| 15 | - add_action('admin_head-'.$form_add_page, 'accua_forms_edit_page_head'); | |
| 16 | - add_action( 'admin_print_styles-'.$form_add_page, 'accua_forms_edit_page_head_styles'); | |
| 17 | - add_action( 'admin_print_scripts-'.$form_add_page, 'accua_forms_edit_page_head_scripts'); | |
| 18 | - | |
| 19 | - $form_submissions_page = add_submenu_page('accua_forms', __('Forms submissions', 'accua-form-api') , __('Submissions', 'accua-form-api'), 10, "accua_forms_submissions_list", 'accua_forms_submissions_list_page'); | |
| 20 | - add_action('admin_head-'.$form_submissions_page, 'accua_forms_submissions_list_page_head'); | |
| 21 | - | |
| 22 | - $form_fields_page = add_submenu_page('accua_forms', __( 'Form fields', 'accua-form-api'), __('Fields', 'accua-form-api'), 10, "accua_forms_fields", 'accua_forms_fields_page'); | |
| 23 | - //add_action('admin_head-'.$form_fields_page, 'accua_forms_fields_page_head'); | |
| 24 | - add_action( 'admin_print_styles-'.$form_fields_page, 'accua_forms_edit_page_head_styles'); | |
| 25 | - | |
| 26 | - $settings_page = add_submenu_page('accua_forms', __( 'Default Forms settings', 'accua-form-api'), __('Settings', 'accua-form-api'), 10, "accua_forms_settings", 'accua_forms_settings_page'); | |
| 27 | - add_action( 'admin_print_styles-'.$settings_page, 'accua_forms_edit_page_head_styles'); | |
| 28 | - add_action( 'admin_print_scripts-'.$settings_page, 'accua_forms_settings_page_head_scripts'); | |
| 29 | - | |
| 30 | - wp_enqueue_script('jquery-form'); | |
| 31 | - wp_enqueue_script('jquery-color'); | |
| 32 | - wp_enqueue_script('jquery-ui-core'); | |
| 33 | - wp_enqueue_script('jquery-ui-tabs'); | |
| 34 | - wp_enqueue_script('jquery-ui-sortable'); | |
| 35 | - wp_enqueue_script('jquery-ui-draggable'); | |
| 36 | - wp_enqueue_script('jquery-ui-droppable'); | |
| 37 | - wp_enqueue_script('jquery-ui-selectable'); | |
| 38 | - wp_enqueue_script('jquery-ui-resizable'); | |
| 39 | - wp_enqueue_script('jquery-ui-dialog'); | |
| 40 | - wp_enqueue_style('wp-jquery-ui-dialog'); | |
| 41 | -} | |
| 42 | - | |
| 43 | -function accua_forms_report_page_head(){ | |
| 44 | - $column_list = array( | |
| 45 | - 'month' => __( 'Month', 'accua-form-api'), | |
| 46 | - 'unique_submissions' => __( 'Unique submissions', 'accua-form-api') , | |
| 47 | - 'submissions' => __('Total submissions', 'accua-form-api'), | |
| 48 | - ); | |
| 49 | - global $hook_suffix; | |
| 50 | - register_column_headers($hook_suffix, $column_list); | |
| 51 | - | |
| 52 | - //$baseurl = WP_PLUGIN_URL.'/'.substr(plugin_basename(__FILE__),0,-strlen(basename(__FILE__))); | |
| 53 | - //echo '<link href="'.$baseurl.'/flot/layout.css" rel="stylesheet" type="text/css">'; | |
| 54 | - //echo '<!--[if lte IE 8]><script language="javascript" type="text/javascript" src="'.$baseurl.'/flot/excanvas.min.js"></script><![endif]-->'; | |
| 55 | - //echo '<script language="javascript" type="text/javascript" src="'.$baseurl.'/flot/jquery.flot.js"></script>'; | |
| 56 | - | |
| 57 | -} | |
| 58 | - | |
| 59 | - | |
| 60 | -function accua_forms_report_page() { | |
| 61 | -?> | |
| 62 | - <div id="accua_forms_report_page" class="accua_forms_admin_page wrap"> | |
| 63 | - <h2>Forms submissions report</h2> | |
| 64 | - | |
| 65 | -<?php | |
| 66 | - global $wpdb, $hook_suffix; | |
| 67 | - $months = array(1 => 'January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December'); | |
| 68 | - | |
| 69 | - $query = "SELECT YEAR(sub_date) AS `year`, MONTH(sub_date) AS `month`, COUNT(DISTINCT `email`) AS `unique_submissions`, COUNT(*) AS `submissions` | |
| 70 | - FROM `{$wpdb->prefix}cformssubmissions` | |
| 71 | - GROUP BY `year`, `month` | |
| 72 | - ORDER BY `year` DESC, `month` DESC"; | |
| 73 | - | |
| 74 | - $results = $wpdb->get_results($query); | |
| 75 | - | |
| 76 | - if ($results) { | |
| 77 | -?> | |
| 78 | - <style type="text/css"> | |
| 79 | - .column-submissions, .column-unique_submissions { | |
| 80 | - text-align: right !important; | |
| 81 | - } | |
| 82 | - </style> | |
| 83 | - <div id="accua-form-report-graph" style="height:300px;"></div> | |
| 84 | - <table class="widefat" id="stnl_review_reviewed"> | |
| 85 | - <thead> | |
| 86 | - <tr><?php print_column_headers($hook_suffix); ?></tr> | |
| 87 | - </thead> | |
| 88 | - | |
| 89 | - <tfoot> | |
| 90 | - <tr><?php print_column_headers($hook_suffix, false); ?></tr> | |
| 91 | - </tfoot> | |
| 92 | - | |
| 93 | - <tbody> | |
| 94 | -<?php | |
| 95 | - $alternate = false; | |
| 96 | - $hidden = get_hidden_columns($hook_suffix); | |
| 97 | - $data = array( | |
| 98 | - array( 'label' => __( 'Unique submissions', 'accua-form-api'), 'data' => array()), | |
| 99 | - array( 'label' => __( 'Total submissions', 'accua-form-api'), 'data' => array()), | |
| 100 | - ); | |
| 101 | - foreach ($results as $result){ | |
| 102 | - $month = $months[$result->month]; | |
| 103 | - echo "<tr class='iedit ".(($alternate = !$alternate)?'alternate':'')."'>\n"; | |
| 104 | - echo "<td class='column-month'".(in_array('month', $hidden)?" style='display:none;'":'').">$month {$result->year}</td>\n"; | |
| 105 | - echo "<td class='column-unique_submissions'".(in_array('unique_submissions', $hidden)?" style='display:none;'":'').">{$result->unique_submissions}</td>\n"; | |
| 106 | - echo "<td class='column-submissions'".(in_array('submissions', $hidden)?" style='display:none;'":'').">{$result->submissions}</td>\n"; | |
| 107 | - echo "</tr>\n"; | |
| 108 | - $time = mktime(0, 0, 0, $result->month, 1, $result->year) * 1000; | |
| 109 | - $data[0]['data'][] = array($time, (int)$result->unique_submissions); | |
| 110 | - $data[1]['data'][] = array($time, (int)$result->submissions); | |
| 111 | - } | |
| 112 | - /* | |
| 113 | - $year = $results[0]->year; | |
| 114 | - $month = $results[0]->month; | |
| 115 | - while ($year <= $result->year || $month <= $result->month) { | |
| 116 | - | |
| 117 | - $month++; | |
| 118 | - if ($month > 12) { | |
| 119 | - $year++; | |
| 120 | - $month = 1; | |
| 121 | - } | |
| 122 | - } | |
| 123 | - */ | |
| 124 | -?> | |
| 125 | - </tbody> | |
| 126 | - </table> | |
| 127 | -<script type="text/javascript"> | |
| 128 | -jQuery(function($){ | |
| 129 | - var data = <?php echo json_encode($data); ?> ; | |
| 130 | - var options = { | |
| 131 | - xaxis: { | |
| 132 | - //autoscaleMargin: 0.005, | |
| 133 | - mode: "time", | |
| 134 | - timeformat: "%b %y", | |
| 135 | - minTickSize: [1, "month"] | |
| 136 | - }, | |
| 137 | - legend: { | |
| 138 | - position: "nw" | |
| 139 | - } | |
| 140 | - }; | |
| 141 | - $.plot($("#accua-form-report-graph"), data, options); | |
| 142 | -}); | |
| 143 | -</script> | |
| 144 | -<?php | |
| 145 | - } | |
| 146 | -?> | |
| 147 | - | |
| 148 | - </div> | |
| 149 | -<?php | |
| 150 | -} | |
| 151 | - | |
| 152 | -function accua_forms_edit_page_head_styles() { | |
| 153 | - wp_admin_css( 'widgets' ); | |
| 154 | - wp_enqueue_style( 'accua-forms-admin', plugins_url('accua-forms-admin.css', __FILE__), array('wp-color-picker'), '1'); | |
| 155 | -} | |
| 156 | - | |
| 157 | -function accua_forms_edit_page_head_scripts() { | |
| 158 | - //wp_enqueue_script('admin-widgets'); | |
| 159 | - /*wp_enqueue_script('jquery-ui-sortable'); | |
| 160 | - wp_enqueue_script('jquery-ui-draggable'); | |
| 161 | - wp_enqueue_script('jquery-ui-droppable');*/ | |
| 162 | - wp_enqueue_script( 'accua-form-fields', plugins_url( 'form-fields.js' , __FILE__ ), array( 'jquery-ui-sortable', 'jquery-ui-draggable', 'jquery-ui-droppable' ) ); | |
| 163 | - wp_enqueue_script( 'accua-form-settings', plugins_url( 'form-settings.js' , __FILE__ ), array( 'jquery', 'wp-color-picker' ), '1.1'); | |
| 164 | -} | |
| 165 | - | |
| 166 | -function accua_forms_settings_page_head_scripts() { | |
| 167 | - wp_enqueue_script('wp-color-picker'); | |
| 168 | -} | |
| 169 | - | |
| 170 | -function accua_forms_edit_page_head() { | |
| 171 | -if (isset($_POST['accua-form-edit-action']) || (!isset($_GET['fid']))) { | |
| 172 | - _accua_forms_form_edit_action(); | |
| 173 | - require_once('accua-forms-list-page.php'); | |
| 174 | - accua_forms_list_page_table(true); | |
| 175 | -} | |
| 176 | - | |
| 177 | -?> | |
| 178 | - <style type="text/css"> | |
| 179 | - .container > div { | |
| 180 | - padding: 0px; | |
| 181 | - margin-bottom: 6px; | |
| 182 | - } | |
| 183 | - .widget-liquid-right .widget, #wp_inactive_widgets .widget, .widget-liquid-right .sidebar-description, .widget-placeholder { | |
| 184 | - width: 95%; | |
| 185 | - } | |
| 186 | - .column-submissions { | |
| 187 | - text-align: right !important; | |
| 188 | - } | |
| 189 | - </style> | |
| 190 | -<?php | |
| 191 | -} | |
| 192 | - | |
| 193 | -add_action( 'wp_ajax_accua-form-fields-order' , 'accua_forms_form_fields_order'); | |
| 194 | -function accua_forms_form_fields_order() { | |
| 195 | - $post = stripslashes_deep($_POST); | |
| 196 | - //update_option('accua_forms_form_fields_order_post', $post); | |
| 197 | - | |
| 198 | - if (empty($post['sidebars'])) { | |
| 199 | - die('-1'); | |
| 200 | - } | |
| 201 | - | |
| 202 | - $forms_data = get_option('accua_forms_saved_forms', array()); | |
| 203 | - | |
| 204 | - foreach ($post['sidebars'] as $fid => $order) { | |
| 205 | - if (strpos($fid, 'cimatti-accua-fields-form-area-') !== 0){ | |
| 206 | - die('-1'); | |
| 207 | - } | |
| 208 | - $fid = substr($fid, 31); | |
| 209 | - | |
| 210 | - $old_fields = $forms_data[$fid]['fields']; | |
| 211 | - unset($forms_data[$fid]['fields']); | |
| 212 | - $new_fields = array(); | |
| 213 | - | |
| 214 | - $order = explode(',', $order); | |
| 215 | - | |
| 216 | - foreach ($order as $i) { | |
| 217 | - $i = preg_replace('/^(new-)?widget-\\d+_/', '', $i); | |
| 218 | - if (isset($old_fields[$i])) { | |
| 219 | - $new_fields[$i] = $old_fields[$i]; | |
| 220 | - unset($old_fields[$i]); | |
| 221 | - } | |
| 222 | - } | |
| 223 | - | |
| 224 | - if($old_fields){ | |
| 225 | - $new_fields += $old_fields; | |
| 226 | - } | |
| 227 | - $forms_data[$fid]['fields'] = $new_fields; | |
| 228 | - } | |
| 229 | - | |
| 230 | - update_option('accua_forms_saved_forms', $forms_data); | |
| 231 | - | |
| 232 | - die('1'); | |
| 233 | -} | |
| 234 | - | |
| 235 | -add_action( 'wp_ajax_accua-save-form-field', 'accua_forms_save_form_field'); | |
| 236 | -function accua_forms_save_form_field() { | |
| 237 | - $post = stripslashes_deep($_POST); | |
| 238 | - | |
| 239 | - //update_option('accua_forms_save_form_field_post', $post); | |
| 240 | - | |
| 241 | - $forms_data = get_option('accua_forms_saved_forms', array()); | |
| 242 | - $fid = $post['form-id']; | |
| 243 | - if (empty($forms_data[$fid]['fields'])) { | |
| 244 | - $forms_data[$fid]['fields'] = array(); | |
| 245 | - } | |
| 246 | - | |
| 247 | - @ $wid = $post['widget-id']; | |
| 248 | - if (empty($post['delete_widget'])) { | |
| 249 | - //$istance_id = $post['multi_number']; | |
| 250 | - @ $ref = $post['id_base']; | |
| 251 | - $required = !empty($post["form-field-{$wid}-required"]); | |
| 252 | - $widget_number = empty($post['multi_number']) ? (empty($post['widget_number']) ? '' : $post['widget_number']) : $post['multi_number']; | |
| 253 | - | |
| 254 | - $forms_data[$fid]['fields'][$wid] = array ( | |
| 255 | - 'istance_id' => $wid, | |
| 256 | - 'widget_number' => $widget_number, | |
| 257 | - 'ref' => $ref, | |
| 258 | - 'required' => $required, | |
| 259 | - ); | |
| 260 | - | |
| 261 | - if (!empty($post["form-field-{$wid}-override-label"])) { | |
| 262 | - @ $label = (string) $post["form-field-{$wid}-label"]; | |
| 263 | - $forms_data[$fid]['fields'][$wid]['label'] = $label; | |
| 264 | - } | |
| 265 | - | |
| 266 | - if (!empty($post["form-field-{$wid}-override-default-value"])) { | |
| 267 | - @ $default_value = (string) $post["form-field-{$wid}-default-value"]; | |
| 268 | - $forms_data[$fid]['fields'][$wid]['default_value'] = $default_value; | |
| 269 | - } | |
| 270 | - | |
| 271 | - if (!empty($post["form-field-{$wid}-override-allowed-values"])) { | |
| 272 | - @ $allowed_values = (string) $post["form-field-{$wid}-allowed-values"]; | |
| 273 | - $forms_data[$fid]['fields'][$wid]['allowed_values'] = $allowed_values; | |
| 274 | - } | |
| 275 | - | |
| 276 | - | |
| 277 | - } else { | |
| 278 | - unset($forms_data[$fid]['fields'][$wid]); | |
| 279 | - } | |
| 280 | - | |
| 281 | - update_option('accua_forms_saved_forms', $forms_data); | |
| 282 | - | |
| 283 | - die('1'); | |
| 284 | -} | |
| 285 | - | |
| 286 | -add_action( 'wp_ajax_accua-save-form-settings', 'accua_forms_save_form_settings'); | |
| 287 | -function accua_forms_save_form_settings() { | |
| 288 | - $post = stripslashes_deep($_POST); | |
| 289 | - | |
| 290 | - $forms_data = get_option('accua_forms_saved_forms', array()); | |
| 291 | - $fid = $post['form-id']; | |
| 292 | - | |
| 293 | - | |
| 294 | - $settings = array( | |
| 295 | - 'title', | |
| 296 | - 'success_message', | |
| 297 | - 'success_message_no_message', | |
| 298 | - 'error_message', | |
| 299 | - 'error_message_no_message', | |
| 300 | - 'emails_from', | |
| 301 | - 'admin_emails_to', | |
| 302 | - 'emails_bcc', | |
| 303 | - 'admin_emails_subject', | |
| 304 | - 'admin_emails_message', | |
| 305 | - 'admin_emails_message_no_message', | |
| 306 | - 'confirmation_emails_subject', | |
| 307 | - 'confirmation_emails_message', | |
| 308 | - 'confirmation_emails_message_no_message', | |
| 309 | - //'use_ajax', | |
| 310 | - | |
| 311 | - 'layout', | |
| 312 | - 'style_margin', | |
| 313 | - 'style_border_color', | |
| 314 | - 'style_border_width', | |
| 315 | - 'style_border_radius', | |
| 316 | - 'style_background_color', | |
| 317 | - 'style_padding', | |
| 318 | - 'style_color', | |
| 319 | - 'style_font_size', | |
| 320 | - 'style_field_spacing', | |
| 321 | - 'style_field_border_color', | |
| 322 | - 'style_field_border_width', | |
| 323 | - 'style_field_border_radius', | |
| 324 | - 'style_field_background_color', | |
| 325 | - 'style_field_padding', | |
| 326 | - 'style_field_color', | |
| 327 | - 'style_submit_border_color', | |
| 328 | - 'style_submit_border_width', | |
| 329 | - 'style_submit_border_radius', | |
| 330 | - 'style_submit_background_color', | |
| 331 | - 'style_submit_padding', | |
| 332 | - 'style_submit_color', | |
| 333 | - 'style_submit_font_size', | |
| 334 | - ); | |
| 335 | - | |
| 336 | - // print_r($post); | |
| 337 | - | |
| 338 | - foreach($settings as $i) { | |
| 339 | - if (isset($post[$i])) { | |
| 340 | - $forms_data[$fid][$i] = $post[$i]; | |
| 341 | - } else { | |
| 342 | - unset($forms_data[$fid][$i]); | |
| 343 | - } | |
| 344 | - } | |
| 345 | - | |
| 346 | - | |
| 347 | - $forms_data[$fid]['use_ajax'] = !empty($post['use_ajax']); | |
| 348 | - | |
| 349 | - update_option('accua_forms_saved_forms', $forms_data); | |
| 350 | - | |
| 351 | - print_r($forms_data[$fid]); | |
| 352 | - | |
| 353 | - die(''); | |
| 354 | -} | |
| 355 | - | |
| 356 | -function accua_forms_field_settings_form_counter() { | |
| 357 | - static $i = 0; | |
| 358 | - $i++; | |
| 359 | - return $i; | |
| 360 | -} | |
| 361 | - | |
| 362 | -function accua_forms_field_text_settings_form($fid, $field_data=array(), $istance_data=array()){ | |
| 363 | - static $html_multi_number = 1; | |
| 364 | - $i = accua_forms_field_settings_form_counter(); | |
| 365 | - | |
| 366 | - $hidden = ''; | |
| 367 | - if (!is_array($istance_data)) { | |
| 368 | - if ($istance_data === 'hidden') { | |
| 369 | - $hidden = 'style="display:none"'; | |
| 370 | - } | |
| 371 | - $istance_data = array(); | |
| 372 | - $empty_istance = true; | |
| 373 | - } else { | |
| 374 | - $empty_istance = empty($istance_data); | |
| 375 | - } | |
| 376 | - | |
| 377 | - if (!is_array($field_data)){ | |
| 378 | - $field_data = array(); | |
| 379 | - } | |
| 380 | - | |
| 381 | - $field_data += array( | |
| 382 | - 'id' => '__html', | |
| 383 | - 'name' => __( 'Custom HTML content', 'accua-form-api'), | |
| 384 | - 'type' => 'html', | |
| 385 | - 'description' => __('Use this special field to inject raw HTML in the form. You can use this multiple times.', 'accua-form-api'), | |
| 386 | - 'default_value' => '', | |
| 387 | - 'allowed_values' => '', | |
| 388 | - ); | |
| 389 | - | |
| 390 | - $override_label = isset($istance_data['label']) ? 'checked="checked"' : ''; | |
| 391 | - $override_default_value = isset($istance_data['default_value']) ? 'checked="checked"' : ''; | |
| 392 | - $override_allowed_values = isset($istance_data['allowed_values']) ? 'checked="checked"' : ''; | |
| 393 | - | |
| 394 | - if (($field_data['type'] === 'file') && ($field_data['allowed_values'] === '')) { | |
| 395 | - $file_data = get_option('accua_forms_default_file_field_data',array()); | |
| 396 | - if (isset($file_data['valid_extensions'])){ | |
| 397 | - $field_data['allowed_values'] = $file_data['valid_extensions']; | |
| 398 | - } | |
| 399 | - } | |
| 400 | - | |
| 401 | - $istance_data += array( | |
| 402 | - 'istance_id' => $field_data['id'], | |
| 403 | - 'widget_number' => '', | |
| 404 | - 'ref' => $field_data['id'], | |
| 405 | - 'label' => $field_data['name'], | |
| 406 | - 'default_value' => $field_data['default_value'], | |
| 407 | - 'allowed_values' => $field_data['allowed_values'], | |
| 408 | - 'required' => false, | |
| 409 | - ); | |
| 410 | - | |
| 411 | - | |
| 412 | - | |
| 413 | - foreach ($istance_data as $key => $value) { | |
| 414 | - $istance_data[$key] = htmlspecialchars($istance_data[$key], ENT_QUOTES); | |
| 415 | - } | |
| 416 | - | |
| 417 | - foreach ($field_data as $key => $value) { | |
| 418 | - $field_data[$key] = htmlspecialchars($field_data[$key], ENT_QUOTES); | |
| 419 | - } | |
| 420 | - | |
| 421 | - $multi_number = ''; | |
| 422 | - | |
| 423 | - if ($istance_data['ref'] == '__html') { | |
| 424 | - if ($empty_istance) { | |
| 425 | - $add_new = 'multi'; | |
| 426 | - $istance_data['istance_id'] .= '-__i__'; | |
| 427 | - $istance_data['widget_number'] = 1; | |
| 428 | - $multi_number = 1 + $html_multi_number; | |
| 429 | - } else { | |
| 430 | - if ($html_multi_number < $istance_data['widget_number']) { | |
| 431 | - $html_multi_number = $istance_data['widget_number']; | |
| 432 | - } | |
| 433 | - } | |
| 434 | - } else { | |
| 435 | - $add_new = $empty_istance ? 'single' : ''; | |
| 436 | - } | |
| 437 | - | |
| 438 | - $fid = htmlspecialchars($fid, ENT_QUOTES); | |
| 439 | - $testi_eot = array ( | |
| 440 | - 'label' => __( 'Label', 'accua-form-api'), | |
| 441 | - 'override' => __( 'override', 'accua-form-api'), | |
| 442 | - 'default_value' => __( 'Default value', 'accua-form-api'), | |
| 443 | - 'default_values' => __( 'Default value(s)', 'accua-form-api'), | |
| 444 | - 'desc_def' => __( 'For multiple default values, use | as separator.', 'accua-form-api'), | |
| 445 | - 'allowed_values' => __( 'Allowed values', 'accua-form-api'), | |
| 446 | - 'desc_all' => __( 'The possible values this field can contain. Enter one value per line, in the format key|label. The key is the value that will be stored in the database. The label is optional, and the key will be used as the label if no label is specified.', 'accua-form-api'), | |
| 447 | - 'allowed_extensions' => __( 'Allowed extensions', 'accua-form-api'), | |
| 448 | - 'desc_all_ext' => __( 'Accepted file extensions. One per line, without dots.', 'accua-form-api'), | |
| 449 | - 'required' => __( 'Required', 'accua-form-api'), | |
| 450 | - 'custom_HTML_content' => __( 'Custom HTML content', 'accua-form-api'), | |
| 451 | - 'remove' => __( 'Remove', 'accua-form-api'), | |
| 452 | - 'close' => __( 'Close', 'accua-form-api'), | |
| 453 | - 'save' => __( 'Save', 'accua-form-api') | |
| 454 | - ); | |
| 455 | - | |
| 456 | - | |
| 457 | - | |
| 458 | - | |
| 459 | - $content = <<<EOT | |
| 460 | - <p><label for="widget-{$istance_data['istance_id']}-label">{$testi_eot['label']}:</label> | |
| 461 | - ({$testi_eot['override']}: <input type="checkbox" name="form-field-{$istance_data['istance_id']}-override-label" value="1" {$override_label} />)<br> | |
| 462 | - <input type="text" value="{$istance_data['label']}" name="form-field-{$istance_data['istance_id']}-label" id="widget-{$istance_data['istance_id']}-label" class="widefat"></p> | |
| 463 | -EOT; | |
| 464 | - | |
| 465 | - $default_value = <<<EOT | |
| 466 | - <p><label for="widget-{$istance_data['istance_id']}-default-value">{$testi_eot['default_value']}:</label> | |
| 467 | - ({$testi_eot['override']}: <input type="checkbox" name="form-field-{$istance_data['istance_id']}-override-default-value" value="1" {$override_default_value} />)<br> | |
| 468 | - <input type="text" value="{$istance_data['default_value']}" name="form-field-{$istance_data['istance_id']}-default-value" id="widget-{$istance_data['istance_id']}-default-value" class="widefat"></p> | |
| 469 | -EOT; | |
| 470 | - | |
| 471 | - $default_values = <<<EOT | |
| 472 | - <p><label for="widget-{$istance_data['istance_id']}-default-value">{$testi_eot['default_value']}:</label> | |
| 473 | - ({$testi_eot['override']}: <input type="checkbox" name="form-field-{$istance_data['istance_id']}-override-default-value" value="1" {$override_default_value} />)<br> | |
| 474 | - <input type="text" value="{$istance_data['default_value']}" name="form-field-{$istance_data['istance_id']}-default-value" id="widget-{$istance_data['istance_id']}-default-value" class="widefat"><br /> | |
| 475 | - </p> | |
| 476 | -EOT; | |
| 477 | - | |
| 478 | - $allowed_values = <<<EOT | |
| 479 | - <p><label for="widget-{$istance_data['istance_id']}-allowed-values">{$testi_eot['allowed_values']}:</label> | |
| 480 | - ({$testi_eot['override']}: <input type="checkbox" name="form-field-{$istance_data['istance_id']}-override-allowed-values" value="1" {$override_allowed_values} />)<br> | |
| 481 | - <textarea rows="6" cols="50" name="form-field-{$istance_data['istance_id']}-allowed-values" id="widget-{$istance_data['istance_id']}-allowed-values" class="widefat">{$istance_data['allowed_values']}</textarea><br /> | |
| 482 | - {$testi_eot['desc_all']}</p> | |
| 483 | -EOT; | |
| 484 | - | |
| 485 | - $allowed_ext = <<<EOT | |
| 486 | - <p><label for="widget-{$istance_data['istance_id']}-allowed-values">{$testi_eot['allowed_extensions']}:</label> | |
| 487 | - ({$testi_eot['override']}: <input type="checkbox" name="form-field-{$istance_data['istance_id']}-override-allowed-values" value="1" {$override_allowed_values} />)<br> | |
| 488 | - <textarea rows="6" cols="50" name="form-field-{$istance_data['istance_id']}-allowed-values" id="widget-{$istance_data['istance_id']}-allowed-values" class="widefat">{$istance_data['allowed_values']}</textarea><br /> | |
| 489 | - {$testi_eot['desc_all_ext']}</p> | |
| 490 | -EOT; | |
| 491 | - | |
| 492 | - $required_checked = empty($istance_data['required']) ? '' : 'checked="checked"'; | |
| 493 | - $required = <<<EOT | |
| 494 | - <p><label for="widget-{$istance_data['istance_id']}-required">{$testi_eot['required']}:</label> <input type="checkbox" value="1" {$required_checked} name="form-field-{$istance_data['istance_id']}-required" id="widget-{$istance_data['istance_id']}-required"></p> | |
| 495 | -EOT; | |
| 496 | - | |
| 497 | - switch ($field_data['type']) { | |
| 498 | - case 'textarea': | |
| 499 | - $content .= <<<EOT | |
| 500 | - <p><label for="widget-{$istance_data['istance_id']}-default-value">{$testi_eot['default_value']}:</label> | |
| 501 | - ({$testi_eot['override']}: <input type="checkbox" name="form-field-{$istance_data['istance_id']}-override-default-value" value="1" {$override_default_value} />)<br> | |
| 502 | - <textarea rows="6" cols="50" name="form-field-{$istance_data['istance_id']}-default-value" id="widget-{$istance_data['istance_id']}-default-value" class="widefat">{$istance_data['default_value']}</textarea></p> | |
| 503 | - $required | |
| 504 | -EOT; | |
| 505 | - break; | |
| 506 | - case 'hidden': | |
| 507 | - $content = $default_value; | |
| 508 | - break; | |
| 509 | - case 'checkbox': | |
| 510 | - $content .= $default_value . $required; | |
| 511 | - break; | |
| 512 | - case 'select': | |
| 513 | - case 'radio': | |
| 514 | - $content .= $default_value . $allowed_values . $required; | |
| 515 | - break; | |
| 516 | - case 'multiselect': | |
| 517 | - case 'multicheckbox': | |
| 518 | - case 'post-multicheckbox': | |
| 519 | - $content .= $default_values . $allowed_values . $required; | |
| 520 | - break; | |
| 521 | - case 'file': | |
| 522 | - $content .= $allowed_ext . $required; | |
| 523 | - case 'submit': | |
| 524 | - //just the label | |
| 525 | - break; | |
| 526 | - case 'html': | |
| 527 | - $content = <<<EOT | |
| 528 | - <p><label for="widget-{$istance_data['istance_id']}-default-value">{$testi_eot['custom_HTML_content']}</label> | |
| 529 | - ({$testi_eot['override']}: <input type="checkbox" name="form-field-{$istance_data['istance_id']}-override-default-value" value="1" {$override_default_value} />)<br> | |
| 530 | - <textarea rows="6" cols="50" name="form-field-{$istance_data['istance_id']}-default-value" id="widget-{$istance_data['istance_id']}-default-value" class="widefat">{$istance_data['default_value']}</textarea></p> | |
| 531 | -EOT; | |
| 532 | - break; | |
| 533 | - case 'email': | |
| 534 | - case 'autoreply_email': | |
| 535 | - case 'textfield': | |
| 536 | - default: | |
| 537 | - $content .= $default_value . $required; | |
| 538 | - break; | |
| 539 | - } | |
| 540 | - $adminurl = admin_url(); | |
| 541 | - return <<<EOT | |
| 542 | -<div class="widget ui-draggable" id="widget-{$i}_{$istance_data['istance_id']}" $hidden> <div class="widget-top"> | |
| 543 | - <div class="widget-title-action"> | |
| 544 | - <a href="#available-widgets" class="widget-action hide-if-no-js"></a> | |
| 545 | - </div> | |
| 546 | - <div class="widget-title"><h4>{$field_data['name']}<span class="in-widget-title"></span></h4></div> | |
| 547 | - </div> | |
| 548 | - | |
| 549 | - <div class="widget-inside"> | |
| 550 | - <form method="post" action=""> | |
| 551 | - <div class="widget-content"> | |
| 552 | - $content | |
| 553 | - </div> | |
| 554 | - <input type="hidden" value="{$fid}" name="form-id"> | |
| 555 | - <input type="hidden" value="{$istance_data['istance_id']}" class="widget-id" name="widget-id"> | |
| 556 | - <input type="hidden" value="{$field_data['id']}" class="id_base" name="id_base"> | |
| 557 | - <input type="hidden" value="250" class="widget-width" name="widget-width"> | |
| 558 | - <input type="hidden" value="200" class="widget-height" name="widget-height"> | |
| 559 | - <input type="hidden" value="{$istance_data['widget_number']}" class="widget_number" name="widget_number"> | |
| 560 | - <input type="hidden" value="{$multi_number}" class="multi_number" name="multi_number"> | |
| 561 | - <input type="hidden" value="{$add_new}" class="add_new" name="add_new"> | |
| 562 | - | |
| 563 | - <div class="widget-control-actions"> | |
| 564 | - <div class="alignleft"> | |
| 565 | - <a href="#remove" class="widget-control-remove">{$testi_eot['remove']}</a> | | |
| 566 | - <a href="#close" class="widget-control-close">{$testi_eot['close']}</a> | |
| 567 | - </div> | |
| 568 | - <div class="alignright"> | |
| 569 | - <img alt="" title="" class="ajax-feedback" src="{$adminurl}images/wpspin_light.gif"> | |
| 570 | - <input type="submit" value="{$testi_eot['save']}" class="button-primary widget-control-save" id="widget-{$istance_data['istance_id']}-savewidget" name="savewidget"> | |
| 571 | - </div> | |
| 572 | - <br class="clear"> | |
| 573 | - </div> | |
| 574 | - </form> | |
| 575 | - </div> | |
| 576 | - | |
| 577 | - <!--<div class="widget-description"> | |
| 578 | - {$field_data['description']} | |
| 579 | - </div>--> | |
| 580 | -</div> | |
| 581 | - | |
| 582 | -EOT; | |
| 583 | -} | |
| 584 | - | |
| 585 | -function accua_forms_add_page($message='') { | |
| 586 | - $forms_data = get_option('accua_forms_saved_forms', array()); | |
| 587 | - if (!empty($_GET['fid'])) { | |
| 588 | - $fid = htmlspecialchars(stripslashes($_GET['fid']), ENT_QUOTES); | |
| 589 | - } else { | |
| 590 | - if ($message === '') { | |
| 591 | - $fid = 1 + ((int) get_option('accua_forms_lastid', 0)); | |
| 592 | - while (isset($forms_data[$fid])) { | |
| 593 | - $fid++; | |
| 594 | - } | |
| 595 | - update_option('accua_forms_lastid', $fid); | |
| 596 | - $message = _accua_forms_test_clonefrom($fid); | |
| 597 | - if ($message === '') { | |
| 598 | - return accua_forms_edit_page($fid); | |
| 599 | - } | |
| 600 | - } else { | |
| 601 | - $fid = ''; | |
| 602 | - } | |
| 603 | - } | |
| 604 | - if (!empty($_GET['clonefrom'])) { | |
| 605 | - $clonefrom = stripslashes($_GET['clonefrom']); | |
| 606 | - } else { | |
| 607 | - $clonefrom = ''; | |
| 608 | - } | |
| 609 | -?> | |
| 610 | - | |
| 611 | -<div id="accua_forms_add_page" class="accua_forms_admin_page wrap"> | |
| 612 | -<h2><?php _e( 'Create a form', 'accua-form-api'); ?> </h2> | |
| 613 | -<?php if ($message !== '') { | |
| 614 | - echo "<div style='border:1px solid; padding: 10px;'>$message</div>"; | |
| 615 | -} ?> | |
| 616 | -<form action="admin.php" method="GET"> | |
| 617 | -<input type="hidden" name="page" value="accua_forms" /> | |
| 618 | -<p>Form id: <input type="text" name="fid" value="<?php echo $fid; ?>" /></p> | |
| 619 | -<?php | |
| 620 | - if ($forms_data) { | |
| 621 | - echo '<p><select name="clonefrom"> | |
| 622 | - <option value="">'.__( 'Empty form', 'accua-form-api').'</option> | |
| 623 | - <optgroup label="'.__( 'Clone form:', 'accua-form-api').'">'; | |
| 624 | - foreach ($forms_data as $i => $formdata) { | |
| 625 | - $sel = ($i == $clonefrom) ? " selected='selected'" : ''; | |
| 626 | - $i = htmlspecialchars($i, ENT_QUOTES); | |
| 627 | - if (isset($formdata['title']) && ('' !== trim($formdata['title']))) { | |
| 628 | - $formtitle = htmlspecialchars($formdata['title']); | |
| 629 | - } else { | |
| 630 | - $formtitle = $i; | |
| 631 | - } | |
| 632 | - echo "<option value='$i'$sel>$formtitle</option>\n"; | |
| 633 | - } | |
| 634 | - echo '</optgroup></select></p>'; | |
| 635 | - } | |
| 636 | -?> | |
| 637 | -<p><input type="submit" value="<?php _e( 'Create', 'accua-form-api'); ?>" /></p> | |
| 638 | -</form> | |
| 639 | -</div> | |
| 640 | -<?php | |
| 641 | -} | |
| 642 | - | |
| 643 | -function _accua_forms_test_clonefrom($fid){ | |
| 644 | - $error = ''; | |
| 645 | - if (isset($_GET['clonefrom'])&&$_GET['clonefrom']!=='') { | |
| 646 | - $clonefrom = stripslashes($_GET['clonefrom']); | |
| 647 | - $forms_data = get_option('accua_forms_saved_forms', array()); | |
| 648 | - if (isset($forms_data[$fid])){ | |
| 649 | - $error .= "<p>".__( 'Form already exists', 'accua-form-api')."</p>"; | |
| 650 | - } else if (empty($forms_data[$clonefrom])) { | |
| 651 | - $error .= "<p>".__( 'Source form doesn\'t exists.', 'accua-form-api')."</p>"; | |
| 652 | - } else { | |
| 653 | - $forms_data[$fid] = $forms_data[$clonefrom]; | |
| 654 | - if (!isset($forms_data[$fid]['title'])) { | |
| 655 | - $forms_data[$fid]['title'] = $clonefrom ." ".__( 'clone', 'accua-form-api'); | |
| 656 | - } else { | |
| 657 | - $forms_data[$fid]['title'] .= " ". __( 'clone', 'accua-form-api'); | |
| 658 | - } | |
| 659 | - update_option('accua_forms_saved_forms', $forms_data); | |
| 660 | - } | |
| 661 | - } | |
| 662 | - return $error; | |
| 663 | -} | |
| 664 | - | |
| 665 | -function _accua_forms_form_edit_action() { | |
| 666 | - static $message = null; | |
| 667 | - if ($message === null) { | |
| 668 | - $message = ''; | |
| 669 | - if (isset($_POST['accua-form-edit-action'])){ | |
| 670 | - $post = stripslashes_deep($_POST); | |
| 671 | - switch ($post['accua-form-edit-action']) { | |
| 672 | - case 'delete': | |
| 673 | - $fid = $post['form-id']; | |
| 674 | - $forms_data = get_option('accua_forms_saved_forms', array()); | |
| 675 | - unset($forms_data[$fid]); | |
| 676 | - update_option('accua_forms_saved_forms', $forms_data); | |
| 677 | - $fid = htmlspecialchars($fid); | |
| 678 | - $message .= sprintf( __( 'Form \"%s\" deleted','accua-form-api' ), $fid ); | |
| 679 | - break; | |
| 680 | - } | |
| 681 | - } | |
| 682 | - } | |
| 683 | - return $message; | |
| 684 | -} | |
| 685 | - | |
| 686 | -function accua_forms_list_page() { | |
| 687 | - $message = ''; | |
| 688 | - if (isset($_POST['accua-form-edit-action'])){ | |
| 689 | - $message = _accua_forms_form_edit_action(); | |
| 690 | - } else if (isset($_GET['fid'])) { | |
| 691 | - if (!isset($fid)) { | |
| 692 | - $fid = stripslashes($_GET['fid']); | |
| 693 | - } | |
| 694 | - $error = ''; | |
| 695 | - if (!preg_match('/^[a-z0-9_-]+$/i', $fid)) { | |
| 696 | - $error .= "<p>".__( 'Only letters, numbers, hyphen and underscores allowed in form identificative name', 'accua-form-api')."</p>"; | |
| 697 | - } | |
| 698 | - if (substr($fid,0,2) == '__') { | |
| 699 | - $error .= "<p>".__( 'The identificative name can\'t start with two underscores (__)', 'accua-form-api')."</p>"; | |
| 700 | - } | |
| 701 | - if (strlen($fid) > 70) { | |
| 702 | - $error .= "<p>".__( 'You cannot use more than 70 characters for the identificative name', 'accua-form-api')."</p>"; | |
| 703 | - } | |
| 704 | - if ($error === '' && (isset($_GET['clonefrom'])&&$_GET['clonefrom']!=='')) { | |
| 705 | - $error .= _accua_forms_test_clonefrom($fid); | |
| 706 | - } | |
| 707 | - if ($error === '') { | |
| 708 | - return accua_forms_edit_page($fid); | |
| 709 | - } else { | |
| 710 | - return accua_forms_add_page($error); | |
| 711 | - } | |
| 712 | - } | |
| 713 | -?> | |
| 714 | -<div id="accua_forms_list_page" class="accua_forms_admin_page wrap"> | |
| 715 | -<?php if ($message !== '') { | |
| 716 | - echo "<div style='border:1px solid; padding: 10px;'>$message</div>"; | |
| 717 | -} ?> | |
| 718 | -<div id="icon-contact-forms-cimatti-logo" class="icon32"></div> | |
| 719 | -<h2><?php _e( 'Contact Forms by Cimatti', 'accua-form-api'); ?> | |
| 720 | - <a class="add-new-h2" href="<?php echo get_admin_url(); ?>admin.php?page=accua_forms_add"><?php _e('Add New','accua-form-api'); ?></a> | |
| 721 | -</h2> | |
| 722 | -<div ><?php | |
| 723 | - echo strtr(__( 'Use the orange %img_c button in the TinyMCE editor to include the forms in posts, pages or other content types (shortcode and php functions also available)', 'accua-form-api'), | |
| 724 | - array('%img_c'=>'<img alt="C" src="' . plugins_url('img/cimatti-16-icon.png', __FILE__ ) . '" />') | |
| 725 | - ); | |
| 726 | -?></div> | |
| 727 | -<?php | |
| 728 | -accua_forms_list_page_table(); | |
| 729 | -?> | |
| 730 | -</div> | |
| 731 | -<?php | |
| 732 | -} | |
| 733 | - | |
| 734 | -function accua_forms_edit_page($fid) { | |
| 735 | - wp_enqueue_script('jquery-ui-tabs','','','',true); | |
| 736 | - wp_enqueue_script('accua_tabs', plugins_url('accua_tabs.js', __FILE__ ), array( 'jquery' )); | |
| 737 | - | |
| 738 | - /* | |
| 739 | - $avail_fields = array( | |
| 740 | - 'first_name' => array ( | |
| 741 | - 'id' => "first_name", | |
| 742 | - 'name' => "First Name", | |
| 743 | - 'type' => "textfield", | |
| 744 | - 'description' => 'This is the first name', | |
| 745 | - ), | |
| 746 | - 'last_name' => array ( | |
| 747 | - 'id' => "last_name", | |
| 748 | - 'name' => "Last Name", | |
| 749 | - 'type' => "textfield", | |
| 750 | - 'description' => 'This is the last name', | |
| 751 | - ), | |
| 752 | - 'email' => array ( | |
| 753 | - 'id' => "email", | |
| 754 | - 'name' => "Email", | |
| 755 | - 'type' => "email", | |
| 756 | - 'description' => 'This is the email', | |
| 757 | - ), | |
| 758 | - ); | |
| 759 | - */ | |
| 760 | - | |
| 761 | - $avail_fields = get_option('accua_forms_avail_fields', array()); | |
| 762 | - $default_form_data = get_option('accua_forms_default_form_data',array()); | |
| 763 | - | |
| 764 | - | |
| 765 | - | |
| 766 | - $form_data = _accua_forms_get_form_data($fid, true, !empty($_GET['restore'])); | |
| 767 | - $form_overrided_data = $form_data['_overrided']; | |
| 768 | - | |
| 769 | - $fid_esc = htmlspecialchars($fid, ENT_QUOTES); | |
| 770 | - | |
| 771 | - $adminurl = admin_url(); | |
| 772 | - | |
| 773 | -?> | |
| 774 | -<div id="accua_forms_edit_page" class="accua_forms_admin_page wrap"> | |
| 775 | -<div id="icon-contact-forms-cimatti-logo" class="icon32"></div> | |
| 776 | -<h2><?php _e( 'Edit Form', 'accua-form-api'); ?></h2> | |
| 777 | -<div id="titlediv"><br /> | |
| 778 | - <label id="title-prompt-text" class="screen-reader-text" for="title"><?php _e( 'Enter title here', 'accua-form-api'); ?></label> | |
| 779 | - <input id="title" type="text" autocomplete="off" value="<?php echo htmlspecialchars($form_data['title'], ENT_QUOTES) ?>" size="30" name="post_title"> | |
| 780 | - | |
| 781 | - <script type="text/javascript"> | |
| 782 | - jQuery(function($){ | |
| 783 | - if ( jQuery('#titlediv #title').val() == '' ) | |
| 784 | - jQuery('#title-prompt-text').removeClass('screen-reader-text'); | |
| 785 | - | |
| 786 | - jQuery('#titlediv #title').focus(function() { | |
| 787 | - jQuery('#title-prompt-text').addClass('screen-reader-text'); | |
| 788 | - }); | |
| 789 | - jQuery('#titlediv #title').blur(function() { | |
| 790 | - if ( jQuery('#titlediv #title').val() == '' ) | |
| 791 | - jQuery('#title-prompt-text').removeClass('screen-reader-text'); | |
| 792 | - }); | |
| 793 | - }); | |
| 794 | - </script> | |
| 795 | -</div> | |
| 796 | - | |
| 797 | - <div id="accua_tabs"> | |
| 798 | - <div id="save_settings_top" class="accua_forms_save_settings_top"> | |
| 799 | - <form id="delete_form" action="admin.php?page=accua_forms_list" method="POST" onsubmit="return confirm('<?php _e('Do you really want to delete this form?'); ?>');"> | |
| 800 | - <input type="hidden" name="accua-form-edit-action" value="delete" /> | |
| 801 | - <input type="hidden" name="form-id" value="<?php echo $fid_esc; ?>" /> | |
| 802 | - <input type="submit" value="<?php _e( 'Delete this form', 'accua-form-api'); ?>" /> | |
| 803 | - </form> | |
| 804 | - <input class="button button-primary button-large accua_form_save_settings_button" id="accua_form_save_settings" type="button" value="<?php _e( 'Save settings', 'accua-form-api'); ?>" /> | |
| 805 | - <span class="accua_form_save_settings_status"></span> | |
| 806 | - </div> | |
| 807 | - <ul id="ul_accua_tabs"> | |
| 808 | - <li class="tabs"><a href="#accua_tab_fields"><?php _e( 'Fields', 'accua-form-api'); ?></a></li> | |
| 809 | - <li class="tabs"><a href="#accua_tab_messages"><?php _e( 'Messages', 'accua-form-api'); ?></a></li> | |
| 810 | - <li class="tabs"><a href="#accua_tab_preview"><?php _e( 'Preview/Test', 'accua-form-api'); ?></a></li> | |
| 811 | - </ul> | |
| 812 | - <div id="accua_tab_fields" class="content_tab"> | |
| 813 | - <div style="width:69%; float:right;" class="container"> | |
| 814 | - <!-- | |
| 815 | - <h3>Form Fields</h3> | |
| 816 | - <div id="form_fields_container"> | |
| 817 | - </div> | |
| 818 | - --> | |
| 819 | - | |
| 820 | - <div class="widget-liquid-right" style="width:100%"> | |
| 821 | - <div id="widgets-right" style="width:100%"> | |
| 822 | - <div class="widgets-holder-wrap"> | |
| 823 | - <div class="sidebar-name"> | |
| 824 | - <div class="sidebar-name-arrow"><br></div> | |
| 825 | - <h3><?php _e( 'Form fields', 'accua-form-api'); ?> <span><img alt="" title="" class="ajax-feedback" src="<?php echo $adminurl;?>images/wpspin_dark.gif"></span></h3> | |
| 826 | - </div> | |
| 827 | - <div class="widgets-sortables ui-sortable" id="cimatti-accua-fields-form-area-<?php echo $fid_esc ?>"> | |
| 828 | - <div class="sidebar-description" style="width: 95%"> | |
| 829 | - <p class="description"><?php _e( 'Drop fields here', 'accua-form-api'); ?></p> | |
| 830 | - </div> | |
| 831 | - <?php | |
| 832 | - foreach ($form_data['fields'] as $field) { | |
| 833 | - if (empty($avail_fields[$field['ref']])) { | |
| 834 | - $ref = array(); | |
| 835 | - } else { | |
| 836 | - $ref = $avail_fields[$field['ref']]; | |
| 837 | - } | |
| 838 | - echo accua_forms_field_text_settings_form($fid, $ref, $field); | |
| 839 | - } | |
| 840 | - ?> | |
| 841 | - </div> | |
| 842 | - </div> | |
| 843 | - </div> | |
| 844 | - </div> | |
| 845 | - | |
| 846 | - </div> | |
| 847 | - | |
| 848 | - <div style="width:30%; float:left;"> | |
| 849 | - <!-- | |
| 850 | - <h3>Available fields</h3> | |
| 851 | - <div id="available_fields_container" class="container"> | |
| 852 | - </div> | |
| 853 | - --> | |
| 854 | -<!-- Begin available fields --> | |
| 855 | - | |
| 856 | -<div class="widget-liquid-left" style="margin-right:0"> | |
| 857 | -<!-- <div id="widgets-left"> --> | |
| 858 | -<div id="widgets-left" style="margin-right:5px;"> | |
| 859 | - <div id="available-widgets" class="widgets-holder-wrap"> | |
| 860 | - <div class="sidebar-name"> | |
| 861 | - <div class="sidebar-name-arrow"><br /></div> | |
| 862 | - <h3><?php _e( 'Available fields', 'accua-form-api'); ?> <span id="removing-widget"><?php _ex('Deactivate', 'removing-widget'); ?> <span></span></span></h3></div> | |
| 863 | - <div class="widget-holder"> | |
| 864 | - <p class="description"><?php _e( 'Drag fields from here to a sidebar on the right to activate them. Drag fields back here to deactivate them.', 'accua-form-api'); ?><br/><br/> | |
| 865 | - <a href="admin.php?page=accua_forms_fields"><strong><?php _e( 'Create new fields here', 'accua-form-api'); ?></strong></a></p> | |
| 866 | - | |
| 867 | - <div id="widget-list"> | |
| 868 | -<!-- begin fields list --> | |
| 869 | - | |
| 870 | -<?php | |
| 871 | - foreach ($avail_fields as $avail_field) { | |
| 872 | - $hidden = (empty($form_data['fields'][$avail_field['id']])) ? false : 'hidden'; | |
| 873 | - echo accua_forms_field_text_settings_form($fid, $avail_field, $hidden); | |
| 874 | - } | |
| 875 | - //Custom HTML field | |
| 876 | - echo accua_forms_field_text_settings_form($fid); | |
| 877 | -?> | |
| 878 | - | |
| 879 | -<!-- end fields list --> | |
| 880 | - </div> | |
| 881 | - | |
| 882 | - <br class='clear' /> | |
| 883 | - </div> | |
| 884 | - <br class="clear" /> | |
| 885 | - </div> | |
| 886 | - | |
| 887 | -</div> | |
| 888 | -</div> | |
| 889 | -<!-- End available fields --> | |
| 890 | - </div> | |
| 891 | - | |
| 892 | - | |
| 893 | -<div style="clear:both;"> </div> | |
| 894 | - | |
| 895 | -<?php /* * / ?> | |
| 896 | -<pre> | |
| 897 | -accua_forms_form_fields_order_post: <?php echo htmlspecialchars(print_r(get_option('accua_forms_form_fields_order_post'), true)); ?> | |
| 898 | - | |
| 899 | -accua_forms_save_form_field_post: <?php echo htmlspecialchars(print_r(get_option('accua_forms_save_form_field_post'), true)); ?> | |
| 900 | - | |
| 901 | -accua_forms_saved_form_data: <?php echo htmlspecialchars(print_r($form_data, true)); ?> | |
| 902 | - | |
| 903 | -</pre> | |
| 904 | -<?php /* */ ?> | |
| 905 | -</div> | |
| 906 | - <div id="accua_tab_messages" class="content_tab"> | |
| 907 | - <?php | |
| 908 | - $settings_editor = array( | |
| 909 | - 'teeny' => true, | |
| 910 | - 'editor_class' => 'accua_form_value', | |
| 911 | - 'tinymce' => array( | |
| 912 | - 'theme_advanced_buttons1' => 'bold,italic,underline,|,bullist,numlist,')); | |
| 913 | - ?> | |
| 914 | - | |
| 915 | - <div class="metabox-holder accua-forms-metabox-holder"> | |
| 916 | - <div class="postbox "> | |
| 917 | - <h3 class="hndle"><span><?php _e('1. On-screen success message', 'accua-form-api'); ?></span></h3> | |
| 918 | - <div class="inside" id="dashboard_right_now"> | |
| 919 | - <div id="accua_form_success_message"> | |
| 920 | - <input class="accua_form_check_override" name="accua_form_success_message" type="radio" value="0" <?php if (!isset($form_overrided_data['success_message'])) {echo ' checked ';} ?>> <?php _e( 'Use the default message', 'accua-form-api'); ?> | |
| 921 | - <input class="accua_form_check_override" name="accua_form_success_message" type="radio" value="1" <?php if (isset($form_overrided_data['success_message']) && !isset($form_overrided_data['success_message_no_message'])) {echo ' checked ';} ?>/> <?php _e( 'Customize', 'accua-form-api'); ?> | |
| 922 | - <input class="accua_form_check_override" name="accua_form_success_message" type="radio" value="-1" <?php if (isset($form_overrided_data['success_message_no_message'])) {echo ' checked ';} ?>/> <?php _e( 'Don\'t show any messages', 'accua-form-api'); ?><br /> | |
| 923 | - <div class="defalut_message"> | |
| 924 | - <?php _e( 'Default Success message', 'accua-form-api'); ?> | |
| 925 | - <div class="defalut_content_message"><?php echo wpautop($default_form_data['success_message']); ?></div> | |
| 926 | - </div> | |
| 927 | - <?php wp_editor( $form_data['success_message'] , 'accua_form_success_message_textarea' , $settings_editor); ?> | |
| 928 | - <!-- <textarea class="accua_form_value" style="width:95%"; cols="80" rows="8"><?php echo htmlspecialchars($form_data['success_message'], ENT_QUOTES) ?></textarea> --> | |
| 929 | - </div> | |
| 930 | - </div> | |
| 931 | - </div> | |
| 932 | - </div> | |
| 933 | - | |
| 934 | - <div class="metabox-holder accua-forms-metabox-holder"> | |
| 935 | - <div class="postbox "> | |
| 936 | - <h3 class="hndle"><span><?php _e('2. On-screen error message', 'accua-form-api'); ?></span></h3> | |
| 937 | - <div class="inside" id="dashboard_right_now"> | |
| 938 | - <div id="accua_form_error_message"> | |
| 939 | - <input class="accua_form_check_override" name="accua_form_error_message" type="radio" value="0" <?php if (!isset($form_overrided_data['error_message'])) {echo ' checked ';} ?>> <?php _e( 'Use the default message', 'accua-form-api'); ?> | |
| 940 | - <input class="accua_form_check_override" name="accua_form_error_message" type="radio" value="1" <?php if (isset($form_overrided_data['error_message']) && !isset($form_overrided_data['error_message_no_message'])) {echo ' checked ';} ?>/> <?php _e( 'Customize', 'accua-form-api'); ?> | |
| 941 | - <input class="accua_form_check_override" name="accua_form_error_message" type="radio" value="-1" <?php if (isset($form_overrided_data['error_message_no_message'])) {echo ' checked ';} ?>/> <?php _e( 'Don\'t show any messages', 'accua-form-api'); ?><br /> | |
| 942 | - <div class="defalut_message"> | |
| 943 | - <?php _e( 'Default error message', 'accua-form-api'); ?> <br /> | |
| 944 | - <div class="defalut_content_message" ><?php echo wpautop($default_form_data['error_message']); ?></div> | |
| 945 | - </div> | |
| 946 | - <?php wp_editor( $form_data['error_message'] , 'accua_form_error_message_textarea' , $settings_editor); ?> | |
| 947 | - </div> | |
| 948 | - </div> | |
| 949 | - </div> | |
| 950 | - </div> | |
| 951 | - <br clear="all"/> | |
| 952 | - <div class="metabox-holder accua-forms-metabox-holder"> | |
| 953 | - <div class="postbox "> | |
| 954 | - <h3 class="hndle"><span><?php _e('3. Email to notify administrator', 'accua-form-api'); ?></span></h3> | |
| 955 | - <div class="inside" id="dashboard_right_now"> | |
| 956 | - <div id="accua_form_admin_emails_to" class="label_input"> | |
| 957 | - <label><?php _e( 'To', 'accua-form-api'); ?></label> | |
| 958 | - <div class="default_value"><?php echo $default_form_data['admin_emails_to']; ?></div> | |
| 959 | - <input class="accua_form_value" type="text" value="<?php echo htmlspecialchars($form_data['admin_emails_to'], ENT_QUOTES) ?>" /> | |
| 960 | - <input name="accua_form_admin_emails_to" class="accua_form_check_override" type="checkbox" value="1" <?php if (isset($form_overrided_data['admin_emails_to'])) {echo 'checked="checked" ';} ?>/><?php _e( 'Customize', 'accua-form-api'); ?> | |
| 961 | - </div> | |
| 962 | - <div id="accua_form_emails_bcc" class="label_input"> | |
| 963 | - <label><?php _e( 'Bcc', 'accua-form-api'); ?></label> | |
| 964 | - <div class="default_value"><?php echo $default_form_data['emails_bcc']; ?></div> | |
| 965 | - <input class="accua_form_value" type="text" value="<?php echo htmlspecialchars($form_data['emails_bcc'], ENT_QUOTES) ?>" /> | |
| 966 | - <input name ="accua_form_emails_bcc" class="accua_form_check_override" type="checkbox" value="1" <?php if (isset($form_overrided_data['emails_bcc'])) {echo 'checked="checked" ';} ?>/><?php _e( 'Customize', 'accua-form-api'); ?> | |
| 967 | - </div> | |
| 968 | - | |
| 969 | - <div id="accua_form_admin_emails_subject" class="label_input"> | |
| 970 | - <label><?php _e( 'Subject', 'accua-form-api'); ?></label> | |
| 971 | - <div class="default_value"><?php echo $default_form_data['admin_emails_subject']; ?></div> | |
| 972 | - <input class="accua_form_value" type="text" value="<?php echo htmlspecialchars($form_data['admin_emails_subject'], ENT_QUOTES) ?>" /> | |
| 973 | - <input name="accua_form_admin_emails_subject" class="accua_form_check_override" type="checkbox" value="1" <?php if (isset($form_overrided_data['admin_emails_subject'])) {echo 'checked="checked" ';} ?>/><?php _e( 'Customize', 'accua-form-api'); ?> | |
| 974 | - </div> | |
| 975 | - | |
| 976 | - <div id="accua_form_admin_emails_message"> | |
| 977 | - <input class="accua_form_check_override" name="accua_form_admin_emails_message" type="radio" value="0" <?php if (!isset($form_overrided_data['admin_emails_message'])) {echo ' checked ';} ?>> <?php _e( 'Use the default message', 'accua-form-api'); ?> | |
| 978 | - <input class="accua_form_check_override" name="accua_form_admin_emails_message" type="radio" value="1" <?php if (isset($form_overrided_data['admin_emails_message']) && !isset($form_overrided_data['admin_emails_message_no_message'])) {echo ' checked ';} ?>/> <?php _e( 'Customize', 'accua-form-api'); ?> | |
| 979 | - <input class="accua_form_check_override" name="accua_form_admin_emails_message" type="radio" value="-1" <?php if (isset($form_overrided_data['admin_emails_message_no_message'])) {echo ' checked ';} ?>/> <?php _e( 'Don\'t show any messages', 'accua-form-api'); ?><br /> | |
| 980 | - <div class="defalut_message"> | |
| 981 | - <?php _e( 'Default message', 'accua-form-api'); ?> | |
| 982 | - <div class="defalut_content_message"><?php echo wpautop($default_form_data['admin_emails_message']); ?></div> | |
| 983 | - </div> | |
| 984 | - <?php wp_editor( $form_data['admin_emails_message'] , 'accua_form_admin_emails_message_textarea' , $settings_editor); ?> | |
| 985 | - </div> | |
| 986 | - | |
| 987 | - </div> | |
| 988 | - </div> | |
| 989 | - </div> | |
| 990 | - | |
| 991 | - <div class="metabox-holder accua-forms-metabox-holder"> | |
| 992 | - <div class="postbox "> | |
| 993 | - <h3 class="hndle"><span><?php _e('4. Email confirmation to the person who completed the form', 'accua-form-api'); ?></span></h3> | |
| 994 | - <div class="inside" id="dashboard_right_now"> | |
| 995 | - <div id="accua_form_emails_from" class="label_input"> | |
| 996 | - <label><?php _e( 'From', 'accua-form-api'); ?></label> | |
| 997 | - <div class="default_value"><?php echo $default_form_data['emails_from']; ?></div> | |
| 998 | - <input class="accua_form_value" type="text" value="<?php echo htmlspecialchars($form_data['emails_from'], ENT_QUOTES) ?>" /> | |
| 999 | - <input name="accua_form_emails_from" class="accua_form_check_override" type="checkbox" value="1" <?php if (isset($form_overrided_data['emails_from'])) {echo 'checked="checked" ';} ?>/><?php _e( 'Customize', 'accua-form-api'); ?> | |
| 1000 | - </div> | |
| 1001 | - <div id="accua_form_confirmation_emails_subject" class="label_input"> | |
| 1002 | - <label><?php _e( 'Subject', 'accua-form-api'); ?></label> | |
| 1003 | - <div class="default_value"><?php echo $default_form_data['confirmation_emails_subject']; ?></div> | |
| 1004 | - <input class="accua_form_value" type="text" value="<?php echo htmlspecialchars($form_data['confirmation_emails_subject'], ENT_QUOTES) ?>" /> | |
| 1005 | - <input name="accua_form_confirmation_emails_subject" class="accua_form_check_override" type="checkbox" value="1" <?php if (isset($form_overrided_data['confirmation_emails_subject'])) {echo 'checked="checked" ';} ?>/><?php _e( 'Customize', 'accua-form-api'); ?> | |
| 1006 | - </div> | |
| 1007 | - | |
| 1008 | - <div id="accua_form_confirmation_emails_message"> | |
| 1009 | - <input class="accua_form_check_override" name="accua_form_confirmation_emails_message" type="radio" value="0" <?php if (!isset($form_overrided_data['confirmation_emails_message'])) {echo ' checked ';} ?>> <?php _e( 'Use the default message', 'accua-form-api'); ?> | |
| 1010 | - <input class="accua_form_check_override" name="accua_form_confirmation_emails_message" type="radio" value="1" <?php if (isset($form_overrided_data['confirmation_emails_message']) && !isset($form_overrided_data['confirmation_emails_message_no_message'])) {echo ' checked ';} ?>/> <?php _e( 'Customize', 'accua-form-api'); ?> | |
| 1011 | - <input class="accua_form_check_override" name="accua_form_confirmation_emails_message" type="radio" value="-1" <?php if (isset($form_overrided_data['confirmation_emails_message_no_message'])) {echo ' checked ';} ?>/> <?php _e( 'Don\'t show any messages', 'accua-form-api'); ?><br /> | |
| 1012 | - <div class="defalut_message"> | |
| 1013 | - <?php _e( 'Default message', 'accua-form-api'); ?> | |
| 1014 | - <div class="defalut_content_message"><?php echo wpautop($default_form_data['confirmation_emails_message']); ?></div> | |
| 1015 | - </div> | |
| 1016 | - <?php wp_editor( $form_data['confirmation_emails_message'] , 'accua_form_confirmation_emails_message_textarea' , $settings_editor); ?> | |
| 1017 | - </div> | |
| 1018 | - </div> | |
| 1019 | - </div> | |
| 1020 | - </div> | |
| 1021 | - <br clear="all"/> | |
| 1022 | - | |
| 1023 | -<?php accua_forms_print_tokens(); ?> | |
| 1024 | - | |
| 1025 | -<input type="hidden" id="accua_form_save_settings_id" value="<?php echo $fid_esc; ?>" /> | |
| 1026 | -</div> | |
| 1027 | - | |
| 1028 | -<div id="accua_tab_preview" class="content_tab"> | |
| 1029 | - | |
| 1030 | -<p style="clear:both;"><?php _e( 'Preview is updated when you click on "Save settings" button', 'accua-form-api'); ?></p> | |
| 1031 | -<div id="accua_form_preview_area_wrapper"> | |
| 1032 | -<iframe id="accua_form_preview_area" src="admin-ajax.php?action=accua_forms_preview&fid=<?php echo htmlspecialchars($fid,ENT_QUOTES);?>" ></iframe> | |
| 1033 | -</div> | |
| 1034 | - | |
| 1035 | -<p id="accua_form_use_ajax"><input class="accua_form_value" type="checkbox" value="1" <?php if (!empty($form_data['use_ajax'])) {echo 'checked="checked" ';} ?>/><?php _e( 'Use AJAX to avoid page reload when submitting form', 'accua-form-api'); ?></p> | |
| 1036 | - | |
| 1037 | -<h4><?php _e( 'Forms', 'accua-form-api'); ?></h4> | |
| 1038 | - | |
| 1039 | -<p id="accua_form_layout"><?php _e('Layout', 'accua-form-api'); ?> <select name="layout" class="accua_form_value"> | |
| 1040 | - <option value="" <?php if (isset($form_overrided_data['layout'])) { echo 'selected="selected"'; } ?>>default (<?php if($default_form_data['layout']=='sidebyside') _e( 'Labels on the left of the fields', 'accua-form-api'); else _e( 'Labels on top of the fields', 'accua-form-api'); ?>)</option><option value="sidebyside" <?php if ((isset($form_overrided_data['layout'])) && ($form_data['layout'] == 'sidebyside')) { echo 'selected="selected"'; } ?>><?php _e( 'Labels on the left of the fields', 'accua-form-api'); ?></option><option value="toplabel" <?php if ((isset($form_overrided_data['layout'])) && ($form_data['layout'] == 'toplabel')) { echo 'selected="selected"'; } ?>><?php _e( 'Labels on top of the fields', 'accua-form-api'); ?></option></select> | |
| 1041 | -</p> | |
| 1042 | - | |
| 1043 | -<div id="accua_form_style_margin" class="label_input"> | |
| 1044 | - <label><?php _e( 'Margin', 'accua-form-api'); ?></label> | |
| 1045 | - <div class="default_value"><?php echo $default_form_data['style_margin']; ?></div> | |
| 1046 | - <input class="accua_form_value" type="text" value="<?php echo htmlspecialchars($form_data['style_margin'], ENT_QUOTES) ?>" /> | |
| 1047 | - <input name="accua_form_style_margin" class="accua_form_check_override" type="checkbox" value="1" <?php if (isset($form_overrided_data['style_margin'])) {echo 'checked="checked" ';} ?>/><?php _e( 'Customize', 'accua-form-api'); ?> | |
| 1048 | -</div> | |
| 1049 | - | |
| 1050 | -<div id="accua_form_style_border_color" class="label_input"> | |
| 1051 | - <label><?php _e( 'Border color', 'accua-form-api'); ?></label> | |
| 1052 | - <div class="default_value"><?php echo $default_form_data['style_border_color']; ?></div> | |
| 1053 | - <input class="accua_form_value" type="text" value="<?php echo htmlspecialchars($form_data['style_border_color'], ENT_QUOTES) ?>" /> | |
| 1054 | - <input name="accua_form_style_border_color" class="accua_form_check_override" type="checkbox" value="1" <?php if (isset($form_overrided_data['style_border_color'])) {echo 'checked="checked" ';} ?>/><?php _e( 'Customize', 'accua-form-api'); ?> | |
| 1055 | -</div> | |
| 1056 | - | |
| 1057 | -<div id="accua_form_style_border_width" class="label_input"> | |
| 1058 | - <label><?php _e( 'Border width', 'accua-form-api'); ?></label> | |
| 1059 | - <div class="default_value"><?php echo $default_form_data['style_border_width']; ?></div> | |
| 1060 | - <input class="accua_form_value" type="text" value="<?php echo htmlspecialchars($form_data['style_border_width'], ENT_QUOTES) ?>" /> | |
| 1061 | - <input name="accua_form_style_border_width" class="accua_form_check_override" type="checkbox" value="1" <?php if (isset($form_overrided_data['style_border_width'])) {echo 'checked="checked" ';} ?>/><?php _e( 'Customize', 'accua-form-api'); ?> | |
| 1062 | -</div> | |
| 1063 | - | |
| 1064 | -<div id="accua_form_style_border_radius" class="label_input"> | |
| 1065 | - <label><?php _e( 'Rounded corner radius', 'accua-form-api'); ?></label> | |
| 1066 | - <div class="default_value"><?php echo $default_form_data['style_border_radius']; ?></div> | |
| 1067 | - <input class="accua_form_value" type="text" value="<?php echo htmlspecialchars($form_data['style_border_radius'], ENT_QUOTES) ?>" /> | |
| 1068 | - <input name="accua_form_style_border_radius" class="accua_form_check_override" type="checkbox" value="1" <?php if (isset($form_overrided_data['style_border_radius'])) {echo 'checked="checked" ';} ?>/><?php _e( 'Customize', 'accua-form-api'); ?> | |
| 1069 | -</div> | |
| 1070 | - | |
| 1071 | -<div id="accua_form_style_background_color" class="label_input"> | |
| 1072 | - <label><?php _e( 'Background color', 'accua-form-api'); ?></label> | |
| 1073 | - <div class="default_value"><?php echo $default_form_data['style_background_color']; ?></div> | |
| 1074 | - <input class="accua_form_value" type="text" value="<?php echo htmlspecialchars($form_data['style_background_color'], ENT_QUOTES) ?>" /> | |
| 1075 | - <input name="accua_form_style_background_color" class="accua_form_check_override" type="checkbox" value="1" <?php if (isset($form_overrided_data['style_background_color'])) {echo 'checked="checked" ';} ?>/><?php _e( 'Customize', 'accua-form-api'); ?> | |
| 1076 | -</div> | |
| 1077 | - | |
| 1078 | -<div id="accua_form_style_padding" class="label_input"> | |
| 1079 | - <label><?php _e( 'Padding', 'accua-form-api'); ?></label> | |
| 1080 | - <div class="default_value"><?php echo $default_form_data['style_padding']; ?></div> | |
| 1081 | - <input class="accua_form_value" type="text" value="<?php echo htmlspecialchars($form_data['style_padding'], ENT_QUOTES) ?>" /> | |
| 1082 | - <input name="accua_form_style_padding" class="accua_form_check_override" type="checkbox" value="1" <?php if (isset($form_overrided_data['style_padding'])) {echo 'checked="checked" ';} ?>/><?php _e( 'Customize', 'accua-form-api'); ?> | |
| 1083 | -</div> | |
| 1084 | - | |
| 1085 | -<div id="accua_form_style_color" class="label_input"> | |
| 1086 | - <label><?php _e( 'Text color', 'accua-form-api'); ?></label> | |
| 1087 | - <div class="default_value"><?php echo $default_form_data['style_color']; ?></div> | |
| 1088 | - <input class="accua_form_value" type="text" value="<?php echo htmlspecialchars($form_data['style_color'], ENT_QUOTES) ?>" /> | |
| 1089 | - <input name="accua_form_style_color" class="accua_form_check_override" type="checkbox" value="1" <?php if (isset($form_overrided_data['style_color'])) {echo 'checked="checked" ';} ?>/><?php _e( 'Customize', 'accua-form-api'); ?> | |
| 1090 | -</div> | |
| 1091 | - | |
| 1092 | -<div id="accua_form_style_font_size" class="label_input"> | |
| 1093 | - <label><?php _e( 'Font size', 'accua-form-api'); ?></label> | |
| 1094 | - <div class="default_value"><?php echo $default_form_data['style_font_size']; ?></div> | |
| 1095 | - <input class="accua_form_value" type="text" value="<?php echo htmlspecialchars($form_data['style_font_size'], ENT_QUOTES) ?>" /> | |
| 1096 | - <input name="accua_form_style_font_size" class="accua_form_check_override" type="checkbox" value="1" <?php if (isset($form_overrided_data['style_font_size'])) {echo 'checked="checked" ';} ?>/><?php _e( 'Customize', 'accua-form-api'); ?> | |
| 1097 | -</div> | |
| 1098 | - | |
| 1099 | -<h4><?php _e( 'Fields', 'accua-form-api'); ?></h4> | |
| 1100 | - | |
| 1101 | -<div id="accua_form_style_field_spacing" class="label_input"> | |
| 1102 | - <label><?php _e( 'Spacing', 'accua-form-api'); ?></label> | |
| 1103 | - <div class="default_value"><?php echo $default_form_data['style_field_spacing']; ?></div> | |
| 1104 | - <input class="accua_form_value" type="text" value="<?php echo htmlspecialchars($form_data['style_field_spacing'], ENT_QUOTES) ?>" /> | |
| 1105 | - <input name="accua_form_style_field_spacing" class="accua_form_check_override" type="checkbox" value="1" <?php if (isset($form_overrided_data['style_field_spacing'])) {echo 'checked="checked" ';} ?>/><?php _e( 'Customize', 'accua-form-api'); ?> | |
| 1106 | -</div> | |
| 1107 | - | |
| 1108 | -<div id="accua_form_style_field_border_color" class="label_input"> | |
| 1109 | - <label><?php _e( 'Border color', 'accua-form-api'); ?></label> | |
| 1110 | - <div class="default_value"><?php echo $default_form_data['style_field_border_color']; ?></div> | |
| 1111 | - <input class="accua_form_value" type="text" value="<?php echo htmlspecialchars($form_data['style_field_border_color'], ENT_QUOTES) ?>" /> | |
| 1112 | - <input name="accua_form_style_field_border_color" class="accua_form_check_override" type="checkbox" value="1" <?php if (isset($form_overrided_data['style_field_border_color'])) {echo 'checked="checked" ';} ?>/><?php _e( 'Customize', 'accua-form-api'); ?> | |
| 1113 | -</div> | |
| 1114 | - | |
| 1115 | -<div id="accua_form_style_field_border_width" class="label_input"> | |
| 1116 | - <label><?php _e( 'Border width', 'accua-form-api'); ?></label> | |
| 1117 | - <div class="default_value"><?php echo $default_form_data['style_field_border_width']; ?></div> | |
| 1118 | - <input class="accua_form_value" type="text" value="<?php echo htmlspecialchars($form_data['style_field_border_width'], ENT_QUOTES) ?>" /> | |
| 1119 | - <input name="accua_form_style_field_border_width" class="accua_form_check_override" type="checkbox" value="1" <?php if (isset($form_overrided_data['style_field_border_width'])) {echo 'checked="checked" ';} ?>/><?php _e( 'Customize', 'accua-form-api'); ?> | |
| 1120 | -</div> | |
| 1121 | - | |
| 1122 | -<div id="accua_form_style_field_border_radius" class="label_input"> | |
| 1123 | - <label><?php _e( 'Rounded corner radius', 'accua-form-api'); ?></label> | |
| 1124 | - <div class="default_value"><?php echo $default_form_data['style_field_border_radius']; ?></div> | |
| 1125 | - <input class="accua_form_value" type="text" value="<?php echo htmlspecialchars($form_data['style_field_border_radius'], ENT_QUOTES) ?>" /> | |
| 1126 | - <input name="accua_form_style_field_border_radius" class="accua_form_check_override" type="checkbox" value="1" <?php if (isset($form_overrided_data['style_field_border_radius'])) {echo 'checked="checked" ';} ?>/><?php _e( 'Customize', 'accua-form-api'); ?> | |
| 1127 | -</div> | |
| 1128 | - | |
| 1129 | -<div id="accua_form_style_field_background_color" class="label_input"> | |
| 1130 | - <label><?php _e( 'Background color', 'accua-form-api'); ?></label> | |
| 1131 | - <div class="default_value"><?php echo $default_form_data['style_field_background_color']; ?></div> | |
| 1132 | - <input class="accua_form_value" type="text" value="<?php echo htmlspecialchars($form_data['style_field_background_color'], ENT_QUOTES) ?>" /> | |
| 1133 | - <input name="accua_form_style_field_background_color" class="accua_form_check_override" type="checkbox" value="1" <?php if (isset($form_overrided_data['style_field_background_color'])) {echo 'checked="checked" ';} ?>/><?php _e( 'Customize', 'accua-form-api'); ?> | |
| 1134 | -</div> | |
| 1135 | - | |
| 1136 | -<div id="accua_form_style_field_padding" class="label_input"> | |
| 1137 | - <label><?php _e( 'Padding', 'accua-form-api'); ?></label> | |
| 1138 | - <div class="default_value"><?php echo $default_form_data['style_field_padding']; ?></div> | |
| 1139 | - <input class="accua_form_value" type="text" value="<?php echo htmlspecialchars($form_data['style_field_padding'], ENT_QUOTES) ?>" /> | |
| 1140 | - <input name="accua_form_style_field_padding" class="accua_form_check_override" type="checkbox" value="1" <?php if (isset($form_overrided_data['style_field_padding'])) {echo 'checked="checked" ';} ?>/><?php _e( 'Customize', 'accua-form-api'); ?> | |
| 1141 | -</div> | |
| 1142 | - | |
| 1143 | -<div id="accua_form_style_field_color" class="label_input"> | |
| 1144 | - <label><?php _e( 'Text color', 'accua-form-api'); ?></label> | |
| 1145 | - <div class="default_value"><?php echo $default_form_data['style_field_color']; ?></div> | |
| 1146 | - <input class="accua_form_value" type="text" value="<?php echo htmlspecialchars($form_data['style_field_color'], ENT_QUOTES) ?>" /> | |
| 1147 | - <input name="accua_form_style_field_color" class="accua_form_check_override" type="checkbox" value="1" <?php if (isset($form_overrided_data['style_field_color'])) {echo 'checked="checked" ';} ?>/><?php _e( 'Customize', 'accua-form-api'); ?> | |
| 1148 | -</div> | |
| 1149 | - | |
| 1150 | - | |
| 1151 | -<h4><?php _e( 'Submit button', 'accua-form-api'); ?></h4> | |
| 1152 | - | |
| 1153 | -<div id="accua_form_style_submit_border_color" class="label_input"> | |
| 1154 | - <label><?php _e( 'Border color', 'accua-form-api'); ?></label> | |
| 1155 | - <div class="default_value"><?php echo $default_form_data['style_submit_border_color']; ?></div> | |
| 1156 | - <input class="accua_form_value" type="text" value="<?php echo htmlspecialchars($form_data['style_submit_border_color'], ENT_QUOTES) ?>" /> | |
| 1157 | - <input name="accua_form_style_submit_border_color" class="accua_form_check_override" type="checkbox" value="1" <?php if (isset($form_overrided_data['style_submit_border_color'])) {echo 'checked="checked" ';} ?>/><?php _e( 'Customize', 'accua-form-api'); ?> | |
| 1158 | -</div> | |
| 1159 | - | |
| 1160 | -<div id="accua_form_style_submit_border_width" class="label_input"> | |
| 1161 | - <label><?php _e( 'Border width', 'accua-form-api'); ?></label> | |
| 1162 | - <div class="default_value"><?php echo $default_form_data['style_submit_border_width']; ?></div> | |
| 1163 | - <input class="accua_form_value" type="text" value="<?php echo htmlspecialchars($form_data['style_submit_border_width'], ENT_QUOTES) ?>" /> | |
| 1164 | - <input name="accua_form_style_submit_border_width" class="accua_form_check_override" type="checkbox" value="1" <?php if (isset($form_overrided_data['style_submit_border_width'])) {echo 'checked="checked" ';} ?>/><?php _e( 'Customize', 'accua-form-api'); ?> | |
| 1165 | -</div> | |
| 1166 | - | |
| 1167 | -<div id="accua_form_style_submit_border_radius" class="label_input"> | |
| 1168 | - <label><?php _e( 'Rounded corner radius', 'accua-form-api'); ?></label> | |
| 1169 | - <div class="default_value"><?php echo $default_form_data['style_submit_border_radius']; ?></div> | |
| 1170 | - <input class="accua_form_value" type="text" value="<?php echo htmlspecialchars($form_data['style_submit_border_radius'], ENT_QUOTES) ?>" /> | |
| 1171 | - <input name="accua_form_style_submit_border_radius" class="accua_form_check_override" type="checkbox" value="1" <?php if (isset($form_overrided_data['style_submit_border_radius'])) {echo 'checked="checked" ';} ?>/><?php _e( 'Customize', 'accua-form-api'); ?> | |
| 1172 | -</div> | |
| 1173 | - | |
| 1174 | -<div id="accua_form_style_submit_background_color" class="label_input"> | |
| 1175 | - <label><?php _e( 'Background color', 'accua-form-api'); ?></label> | |
| 1176 | - <div class="default_value"><?php echo $default_form_data['style_submit_background_color']; ?></div> | |
| 1177 | - <input class="accua_form_value" type="text" value="<?php echo htmlspecialchars($form_data['style_submit_background_color'], ENT_QUOTES) ?>" /> | |
| 1178 | - <input name="accua_form_style_submit_background_color" class="accua_form_check_override" type="checkbox" value="1" <?php if (isset($form_overrided_data['style_submit_background_color'])) {echo 'checked="checked" ';} ?>/><?php _e( 'Customize', 'accua-form-api'); ?> | |
| 1179 | -</div> | |
| 1180 | - | |
| 1181 | -<div id="accua_form_style_submit_padding" class="label_input"> | |
| 1182 | - <label><?php _e( 'Padding', 'accua-form-api'); ?></label> | |
| 1183 | - <div class="default_value"><?php echo $default_form_data['style_submit_padding']; ?></div> | |
| 1184 | - <input class="accua_form_value" type="text" value="<?php echo htmlspecialchars($form_data['style_submit_padding'], ENT_QUOTES) ?>" /> | |
| 1185 | - <input name="accua_form_style_submit_padding" class="accua_form_check_override" type="checkbox" value="1" <?php if (isset($form_overrided_data['style_submit_padding'])) {echo 'checked="checked" ';} ?>/><?php _e( 'Customize', 'accua-form-api'); ?> | |
| 1186 | -</div> | |
| 1187 | - | |
| 1188 | -<div id="accua_form_style_submit_color" class="label_input"> | |
| 1189 | - <label><?php _e( 'Text color', 'accua-form-api'); ?></label> | |
| 1190 | - <div class="default_value"><?php echo $default_form_data['style_submit_color']; ?></div> | |
| 1191 | - <input class="accua_form_value" type="text" value="<?php echo htmlspecialchars($form_data['style_submit_color'], ENT_QUOTES) ?>" /> | |
| 1192 | - <input name="accua_form_style_submit_color" class="accua_form_check_override" type="checkbox" value="1" <?php if (isset($form_overrided_data['style_submit_color'])) {echo 'checked="checked" ';} ?>/><?php _e( 'Customize', 'accua-form-api'); ?> | |
| 1193 | -</div> | |
| 1194 | - | |
| 1195 | -<div id="accua_form_style_submit_font_size" class="label_input"> | |
| 1196 | - <label><?php _e( 'Font size', 'accua-form-api'); ?></label> | |
| 1197 | - <div class="default_value"><?php echo $default_form_data['style_submit_font_size']; ?></div> | |
| 1198 | - <input class="accua_form_value" type="text" value="<?php echo htmlspecialchars($form_data['style_submit_font_size'], ENT_QUOTES) ?>" /> | |
| 1199 | - <input name="accua_form_style_submit_font_size" class="accua_form_check_override" type="checkbox" value="1" <?php if (isset($form_overrided_data['style_submit_font_size'])) {echo 'checked="checked" ';} ?>/><?php _e( 'Customize', 'accua-form-api'); ?> | |
| 1200 | -</div> | |
| 1201 | - | |
| 1202 | - | |
| 1203 | -</div> | |
| 1204 | -<p></p> | |
| 1205 | -<input class="button button-primary button-large accua_form_save_settings_button" id="accua_form_save_settings_2" type="button" value="<?php _e( 'Save settings', 'accua-form-api'); ?>" /> <span class="accua_form_save_settings_status"></span> | |
| 1206 | - | |
| 1207 | -</div> | |
| 1208 | -<script> | |
| 1209 | -jQuery('input[type=radio]').change(function() { | |
| 1210 | - var name = jQuery(this).attr('name'); | |
| 1211 | - if (jQuery(this).val() == '1') { | |
| 1212 | - jQuery('#'+name+' .defalut_message').hide(); | |
| 1213 | - jQuery('#'+name+' .wp-editor-wrap').show(); | |
| 1214 | - } | |
| 1215 | - else { | |
| 1216 | - if(jQuery(this).val() != '-1') | |
| 1217 | - jQuery('#'+name+' .defalut_message').show(); | |
| 1218 | - else | |
| 1219 | - jQuery('#'+name+' .defalut_message').hide(); | |
| 1220 | - jQuery('#'+name+' .wp-editor-wrap').hide(); | |
| 1221 | - } | |
| 1222 | -}); | |
| 1223 | - | |
| 1224 | -jQuery('input[type=checkbox]').click(function() { | |
| 1225 | - var name = jQuery(this).attr('name'); | |
| 1226 | - if (!this.checked) { | |
| 1227 | - jQuery('#'+name+' .default_value').show(); | |
| 1228 | - jQuery('#'+name+' .accua_form_value, #'+name+' .wp-picker-container').hide(); | |
| 1229 | - } | |
| 1230 | - else { | |
| 1231 | - jQuery('#'+name+' .default_value').hide(); | |
| 1232 | - jQuery('#'+name+' .accua_form_value, #'+name+' .wp-picker-container').show(); | |
| 1233 | - } | |
| 1234 | -}); | |
| 1235 | - | |
| 1236 | -jQuery(".token_link").click(function() { | |
| 1237 | - jQuery("#dialog_token").dialog("open"); | |
| 1238 | - return false; | |
| 1239 | -}); | |
| 1240 | - | |
| 1241 | -//inizializzazione | |
| 1242 | -jQuery(document).ready(function($){ | |
| 1243 | - $('#accua_form_preview_area_wrapper').resizable({handles: 's'}); | |
| 1244 | - $('#accua_form_preview_area').css({ | |
| 1245 | - 'width': '100%', | |
| 1246 | - 'height': '100%' | |
| 1247 | - }); | |
| 1248 | - $.each( | |
| 1249 | - ['success_message','error_message','admin_emails_message','confirmation_emails_message'], | |
| 1250 | - function(i,key){ | |
| 1251 | - var value = $('#accua_form_'+key+' .accua_form_check_override:checked').val(); | |
| 1252 | - if(value!=undefined && value!=0) { | |
| 1253 | - if(value!=-1) | |
| 1254 | - jQuery('#accua_form_'+key+' .wp-editor-wrap').show(); | |
| 1255 | - else | |
| 1256 | - jQuery('#accua_form_'+key+' .wp-editor-wrap').hide(); | |
| 1257 | - jQuery('#accua_form_'+key+' .defalut_message').hide(); | |
| 1258 | - | |
| 1259 | - } | |
| 1260 | - else { | |
| 1261 | - jQuery('#accua_form_'+key+' .wp-editor-wrap').hide(); | |
| 1262 | - jQuery('#accua_form_'+key+' .defalut_message').show(); | |
| 1263 | - } | |
| 1264 | - } | |
| 1265 | - ); | |
| 1266 | - $.each( | |
| 1267 | - ['emails_from','admin_emails_to','emails_bcc','admin_emails_subject','confirmation_emails_subject','style_margin','style_border_color','style_border_width','style_border_radius','style_background_color','style_padding','style_color','style_font_size','style_field_spacing','style_field_border_color','style_field_border_width','style_field_border_radius','style_field_background_color','style_field_padding','style_field_color','style_submit_border_color','style_submit_border_width','style_submit_border_radius','style_submit_background_color','style_submit_padding','style_submit_color','style_submit_font_size'], | |
| 1268 | - function(i,key){ | |
| 1269 | - if(!$('#accua_form_'+key+' .accua_form_check_override').is(':checked')) { | |
| 1270 | - jQuery('#accua_form_'+key+' .default_value').show(); | |
| 1271 | - jQuery('#accua_form_'+key+' .accua_form_value, #accua_form_'+key+' .wp-picker-container').hide(); | |
| 1272 | - } | |
| 1273 | - else { | |
| 1274 | - jQuery('#accua_form_'+key+' .default_value').hide(); | |
| 1275 | - jQuery('#accua_form_'+key+' .accua_form_value, #accua_form_'+key+' .wp-picker-container').show(); | |
| 1276 | - } | |
| 1277 | - }); | |
| 1278 | - $("#dialog_token").dialog({ dialogClass:'wp-dialog' ,autoOpen : false, modal : true, show : "blind", hide : "blind"}); | |
| 1279 | - | |
| 1280 | - $('#accua_token a').appendTo('.wp-media-buttons'); | |
| 1281 | - | |
| 1282 | -}); | |
| 1283 | - | |
| 1284 | -jQuery(document).ready(function($){ | |
| 1285 | - | |
| 1286 | - var originalWidth = $(document).width(); | |
| 1287 | - if(originalWidth <= 883) { //iphone | |
| 1288 | - $(".metabox-holder").width('98%'); | |
| 1289 | - } | |
| 1290 | - | |
| 1291 | - $(window).resize(function (e) { | |
| 1292 | - var newWidth = $(document).width(); | |
| 1293 | - if(newWidth <= 883) { | |
| 1294 | - if (originalWidth > 883) { | |
| 1295 | - $(".metabox-holder").width('98%'); | |
| 1296 | - } | |
| 1297 | - } else if (originalWidth<=883) { | |
| 1298 | - $(".metabox-holder").width('47%'); | |
| 1299 | - } | |
| 1300 | - originalWidth = newWidth; | |
| 1301 | - }); | |
| 1302 | -}); | |
| 1303 | - | |
| 1304 | -</script> | |
| 1305 | - | |
| 1306 | -<?php | |
| 1307 | -} | |
| 1308 | - | |
| 1309 | -function accua_forms_fields_page_head() { | |
| 1310 | -/* | |
| 1311 | - $baseurl = WP_PLUGIN_URL.'/'.substr(plugin_basename(__FILE__),0,-strlen(basename(__FILE__))); | |
| 1312 | -?> | |
| 1313 | - <script type="text/javascript" src="<?php echo $baseurl.'/qtip/jquery.qtip-1.0.0-rc3.js'; ?>"></script> | |
| 1314 | - <script type="text/javascript"> | |
| 1315 | - var avail_fields = { | |
| 1316 | - first_name: { | |
| 1317 | - id: "first_name", | |
| 1318 | - name: "First Name", | |
| 1319 | - type: "textfield" | |
| 1320 | - }, | |
| 1321 | - last_name: { | |
| 1322 | - id: "last_name", | |
| 1323 | - name: "Last Name", | |
| 1324 | - type: "textfield" | |
| 1325 | - }, | |
| 1326 | - email: { | |
| 1327 | - id: "email", | |
| 1328 | - name: "Email", | |
| 1329 | - type: "email" | |
| 1330 | - } | |
| 1331 | - }; | |
| 1332 | - | |
| 1333 | - jQuery(function($){ | |
| 1334 | - $avail = $('#available_fields_container'); | |
| 1335 | - for(var id in avail_fields) { | |
| 1336 | - var field = avail_fields[id]; | |
| 1337 | - var el = $('<div></div>').text(field.name); | |
| 1338 | - el.prepend('<input type="checkbox" />'); | |
| 1339 | - var content = $('<div><span>Id: </span></div>'); | |
| 1340 | - content.append($('<input type="text" />').val(field.id)); | |
| 1341 | - content.append($('<br /><span>Name: </span>')); | |
| 1342 | - content.append($('<input type="text" />').val(field.name)); | |
| 1343 | - content.append($('<br /><span>Type: </span>')); | |
| 1344 | - content.append($('<select><option value="textfield">Textfield</option><option value="textarea">Textarea</option><option value="email">Email</option></select>').val(field.type)); | |
| 1345 | - el.qtip({ | |
| 1346 | - content: { | |
| 1347 | - text: content | |
| 1348 | - }, | |
| 1349 | - position: { | |
| 1350 | - target: 'mouse', | |
| 1351 | - corner: { | |
| 1352 | - target: 'bottomRight', | |
| 1353 | - tooltip: 'topLeft' | |
| 1354 | - }, | |
| 1355 | - adjust: { | |
| 1356 | - mouse: false | |
| 1357 | - } | |
| 1358 | - }, | |
| 1359 | - show: { | |
| 1360 | - when: { | |
| 1361 | - event: 'mouseover' | |
| 1362 | - }, | |
| 1363 | - solo: true | |
| 1364 | - }, | |
| 1365 | - hide: { | |
| 1366 | - when: { | |
| 1367 | - event: 'unfocus' | |
| 1368 | - } | |
| 1369 | - } | |
| 1370 | - }); | |
| 1371 | - $avail.append(el); | |
| 1372 | - } | |
| 1373 | - }); | |
| 1374 | - </script> | |
| 1375 | - <style type="text/css"> | |
| 1376 | - .container > div { | |
| 1377 | - padding: 0px; | |
| 1378 | - margin-bottom: 6px; | |
| 1379 | - } | |
| 1380 | - </style> | |
| 1381 | -<?php | |
| 1382 | -*/ | |
| 1383 | -} | |
| 1384 | - | |
| 1385 | -function accua_forms_fields_page() { | |
| 1386 | -/* | |
| 1387 | -?> | |
| 1388 | -<div class="wrap"><h2>Edit Form Fields</h2> | |
| 1389 | - <div id="available_fields_container" class="container"></div> | |
| 1390 | -</div> | |
| 1391 | -<?php | |
| 1392 | -*/ | |
| 1393 | - $message = ''; | |
| 1394 | - | |
| 1395 | - /* | |
| 1396 | - $avail_fields = array( | |
| 1397 | - 'first_name' => array ( | |
| 1398 | - 'id' => "first_name", | |
| 1399 | - 'name' => "First Name", | |
| 1400 | - 'type' => "textfield", | |
| 1401 | - 'description' => 'This is the first name', | |
| 1402 | - ), | |
| 1403 | - 'last_name' => array ( | |
| 1404 | - 'id' => "last_name", | |
| 1405 | - 'name' => "Last Name", | |
| 1406 | - 'type' => "textfield", | |
| 1407 | - 'description' => 'This is the last name', | |
| 1408 | - ), | |
| 1409 | - 'email' => array ( | |
| 1410 | - 'id' => "email", | |
| 1411 | - 'name' => "Email", | |
| 1412 | - 'type' => "email", | |
| 1413 | - 'description' => 'This is the email', | |
| 1414 | - ), | |
| 1415 | - ); | |
| 1416 | - */ | |
| 1417 | - | |
| 1418 | - $avail_fields = get_option('accua_forms_avail_fields', array()); | |
| 1419 | - | |
| 1420 | - $default_form_values = array( | |
| 1421 | - 'id' => '', | |
| 1422 | - 'name' => '', | |
| 1423 | - 'type' => 'textfield', | |
| 1424 | - 'description' => '', | |
| 1425 | - 'default_value' => '', | |
| 1426 | - 'allowed_values' => '', | |
| 1427 | - ); | |
| 1428 | - | |
| 1429 | - $editing = false; | |
| 1430 | - $adding = true; | |
| 1431 | - | |
| 1432 | - if (!empty($_POST['action'])) { | |
| 1433 | - $post = stripslashes_deep($_POST); | |
| 1434 | - switch($post['action']) { | |
| 1435 | - case 'edit-form-field': | |
| 1436 | - if (empty($avail_fields[$post['form-field-id']])) { | |
| 1437 | - $message .= 'Field "'.htmlspecialchars($post['form-field-id']).'" doesn\'t exists'; | |
| 1438 | - } else { | |
| 1439 | - if (empty($post['delete-field'])) { | |
| 1440 | - $avail_fields[$post['form-field-id']] = array( | |
| 1441 | - 'id' => $post['form-field-id'], | |
| 1442 | - 'name' => $post['form-field-name'], | |
| 1443 | - 'type' => $post['form-field-type'], | |
| 1444 | - 'description' => $post['form-field-description'], | |
| 1445 | - 'default_value' => $post['form-field-default-value'], | |
| 1446 | - 'allowed_values' => $post['form-field-allowed-values'], | |
| 1447 | - ); | |
| 1448 | - $message .= sprintf( __( 'Field "%s" updated', 'accua-form-api'), htmlspecialchars($post['form-field-id']) ); | |
| 1449 | - } else { | |
| 1450 | - unset ($avail_fields[$post['form-field-id']]); | |
| 1451 | - $message .= sprintf( __( 'Field "%s" deleted', 'accua-form-api'), htmlspecialchars($post['form-field-id']) ); | |
| 1452 | - } | |
| 1453 | - update_option('accua_forms_avail_fields', $avail_fields); | |
| 1454 | - } | |
| 1455 | - break; | |
| 1456 | - case 'add-form-field': | |
| 1457 | - $fill_form_fields = true; | |
| 1458 | - $valid = true; | |
| 1459 | - if (empty($post['form-field-id']) || !preg_match('/^[a-z0-9_-]+$/i', $post['form-field-id'])) { | |
| 1460 | - $message .= "<p>".__( 'Only letters, numbers, hyphen and underscores allowed in field identificative slug', 'accua-form-api')."</p>"; | |
| 1461 | - $valid = false; | |
| 1462 | - } | |
| 1463 | - if(substr($post['form-field-id'], 0, 2) == '__') { | |
| 1464 | - $message .= "<p>".__( 'The field identificative slug can\'t start with two underscores (__)', 'accua-form-api')."</p>"; | |
| 1465 | - $valid = false; | |
| 1466 | - } | |
| 1467 | - if (!empty($avail_fields[$post['form-field-id']])) { | |
| 1468 | - $message .= sprintf( __( '<p>A field with identificative slug "%s" already exists</p> Field "%s" deleted', 'accua-form-api'), htmlspecialchars($post['form-field-id']) ); | |
| 1469 | - $valid = false; | |
| 1470 | - } | |
| 1471 | - if (strlen($post['form-field-id']) > 70) { | |
| 1472 | - $message .= "<p>".__( 'The identificative slug cannot be longer than 70 characters', 'accua-form-api')."</p>"; | |
| 1473 | - $valid = false; | |
| 1474 | - } | |
| 1475 | - if ($valid) { | |
| 1476 | - $fill_form_fields = false; | |
| 1477 | - $avail_fields[$post['form-field-id']] = array( | |
| 1478 | - 'id' => $post['form-field-id'], | |
| 1479 | - 'name' => $post['form-field-name'], | |
| 1480 | - 'type' => $post['form-field-type'], | |
| 1481 | - 'description' => $post['form-field-description'], | |
| 1482 | - 'default_value' => $post['form-field-default-value'], | |
| 1483 | - 'allowed_values' => $post['form-field-allowed-values'], | |
| 1484 | - ); | |
| 1485 | - update_option('accua_forms_avail_fields', $avail_fields); | |
| 1486 | - $message .= sprintf( __( 'Field "%s" created', 'accua-form-api'), htmlspecialchars($post['form-field-id']) ); | |
| 1487 | - } | |
| 1488 | - if ($fill_form_fields) { | |
| 1489 | - $editing = true; | |
| 1490 | - $default_form_values = array( | |
| 1491 | - 'id' => $post['form-field-id'], | |
| 1492 | - 'name' => $post['form-field-name'], | |
| 1493 | - 'type' => $post['form-field-type'], | |
| 1494 | - 'description' => $post['form-field-description'], | |
| 1495 | - 'default_value' => $post['form-field-default-value'], | |
| 1496 | - 'allowed_values' => $post['form-field-allowed-values'], | |
| 1497 | - ); | |
| 1498 | - } | |
| 1499 | - break; | |
| 1500 | - } | |
| 1501 | - } else if (!empty($_GET['edit-fid'])) { | |
| 1502 | - $fid = stripslashes($_GET['edit-fid']); | |
| 1503 | - if (empty($avail_fields[$fid])) { | |
| 1504 | - $message .= sprintf( __( 'Field "%s" doesn\'t exists', 'accua-form-api'), $fid ); | |
| 1505 | - } else { | |
| 1506 | - $adding = false; | |
| 1507 | - $editing = true; | |
| 1508 | - $default_form_values = $avail_fields[$fid]; | |
| 1509 | - } | |
| 1510 | - } | |
| 1511 | - | |
| 1512 | -?> | |
| 1513 | -<div id="accua_forms_fields_page" class="accua_forms_admin_page wrap nosubsub"> | |
| 1514 | -<div id="icon-contact-forms-cimatti-logo" class="icon32"></div> | |
| 1515 | -<h2><?php _e( 'Form fields', 'accua-form-api'); ?></h2> | |
| 1516 | -<?php /* screen_icon(); ?> | |
| 1517 | -<h2><?php echo esc_html( $title ); | |
| 1518 | -if ( !empty($_REQUEST['s']) ) | |
| 1519 | - printf( '<span class="subtitle">' . __('Search results for “%s”') . '</span>', esc_html( stripslashes($_REQUEST['s']) ) ); ?> | |
| 1520 | -</h2> | |
| 1521 | - | |
| 1522 | -<?php if ( isset($_REQUEST['message']) && ( $msg = (int) $_REQUEST['message'] ) ) : ?> | |
| 1523 | -<div id="message" class="updated"><p><?php echo $messages[$msg]; ?></p></div> | |
| 1524 | -<?php $_SERVER['REQUEST_URI'] = remove_query_arg(array('message'), $_SERVER['REQUEST_URI']); | |
| 1525 | -endif; */ ?> | |
| 1526 | -<div id="ajax-response"><?php echo $message?></div> | |
| 1527 | - | |
| 1528 | -<?php /* | |
| 1529 | -<form class="search-form" action="" method="get"> | |
| 1530 | -<input type="hidden" name="taxonomy" value="<?php echo esc_attr($taxonomy); ?>" /> | |
| 1531 | -<input type="hidden" name="post_type" value="<?php echo esc_attr($post_type); ?>" /> | |
| 1532 | - | |
| 1533 | -<?php $wp_list_table->search_box( $tax->labels->search_items, 'tag' ); ?> | |
| 1534 | - | |
| 1535 | -</form> | |
| 1536 | -*/ ?> | |
| 1537 | - | |
| 1538 | -<br class="clear" /> | |
| 1539 | - | |
| 1540 | -<div id="col-container"> | |
| 1541 | - | |
| 1542 | -<div id="col-right"> | |
| 1543 | -<div class="col-wrap"> | |
| 1544 | -<?php if (!$editing) { ?> | |
| 1545 | -<form id="posts-filter" action="" method="post"> | |
| 1546 | -<input type="hidden" name="taxonomy" value="<?php echo esc_attr($taxonomy); ?>" /> | |
| 1547 | -<input type="hidden" name="post_type" value="<?php echo esc_attr($post_type); ?>" /> | |
| 1548 | - | |
| 1549 | -<?php /* $wp_list_table->display(); */ ?> | |
| 1550 | - | |
| 1551 | -<table cellspacing="0" class="wp-list-table widefat fixed tags"> | |
| 1552 | - <thead> | |
| 1553 | - <tr> | |
| 1554 | - <th style="" class="manage-column column-cb check-column" id="cb" scope="col"><input type="checkbox" /></th> | |
| 1555 | - <th style="" class="manage-column column-name" id="name" scope="col"><?php _e( 'Label', 'accua-form-api'); ?></th> | |
| 1556 | - <th style="" class="manage-column column-description" id="description" scope="col"><?php _e( 'Description', 'accua-form-api'); ?></th> | |
| 1557 | - <th style="" class="manage-column column-slug" id="slug" scope="col"><?php _e( 'Slug', 'accua-form-api'); ?></th> | |
| 1558 | - <th style="" class="manage-column column-type" id="type" scope="col"><?php _e( 'Type', 'accua-form-api'); ?></th> | |
| 1559 | - </tr> | |
| 1560 | - </thead> | |
| 1561 | - | |
| 1562 | - <tfoot> | |
| 1563 | - <tr> | |
| 1564 | - <th style="" class="manage-column column-cb check-column" scope="col"><input type="checkbox" /></th> | |
| 1565 | - <th style="" class="manage-column column-name" scope="col"><?php _e( 'Label', 'accua-form-api'); ?></th> | |
| 1566 | - <th style="" class="manage-column column-description" scope="col"><?php _e( 'Description', 'accua-form-api'); ?></th> | |
| 1567 | - <th style="" class="manage-column column-slug" scope="col"><?php _e( 'Slug', 'accua-form-api'); ?></th> | |
| 1568 | - <th style="" class="manage-column column-type" scope="col"><?php _e( 'Type', 'accua-form-api'); ?></th> | |
| 1569 | - </tr> | |
| 1570 | - </tfoot> | |
| 1571 | - | |
| 1572 | - <tbody class="list:tag" id="the-list"> | |
| 1573 | -<?php | |
| 1574 | - foreach ($avail_fields as $id => $field) { | |
| 1575 | - foreach (array('id', 'name', 'type', 'description') as $i) { | |
| 1576 | - $field[$i] = htmlspecialchars($field[$i], ENT_QUOTES); | |
| 1577 | - } | |
| 1578 | - echo <<<END_OF_ROW | |
| 1579 | - <tr id="field-{$field['id']}"> | |
| 1580 | - <th class="check-column" scope="row"><input type="checkbox" /></th> | |
| 1581 | - <td class="name column-name"><strong><a title="Edit “{$field['name']}”" href="admin.php?page=accua_forms_fields&edit-fid={$field['id']}" class="row-title">{$field['name']}</a></strong><br><div class="row-actions"><span class="edit"><a href="admin.php?page=accua_forms_fields&edit-fid={$field['id']}">Edit</a></span></div></td> | |
| 1582 | - <td class="description column-description">{$field['description']}</td> | |
| 1583 | - <td class="slug column-slug">{$field['id']}</td> | |
| 1584 | - <td class="type column-type">{$field['type']}</td> | |
| 1585 | - </tr> | |
| 1586 | -END_OF_ROW; | |
| 1587 | - } | |
| 1588 | -?> | |
| 1589 | - </tbody> | |
| 1590 | -</table> | |
| 1591 | - | |
| 1592 | -<br class="clear" /> | |
| 1593 | -</form> | |
| 1594 | -<?php } ?> | |
| 1595 | -<?php /* if ( 'category' == $taxonomy ) : ?> | |
| 1596 | -<div class="form-wrap"> | |
| 1597 | -<p><?php printf(__('<strong>Note:</strong><br />Deleting a category does not delete the posts in that category. Instead, posts that were only assigned to the deleted category are set to the category <strong>%s</strong>.'), apply_filters('the_category', get_cat_name(get_option('default_category')))) ?></p> | |
| 1598 | -<?php if ( current_user_can( 'import' ) ) : ?> | |
| 1599 | -<p><?php printf(__('Categories can be selectively converted to tags using the <a href="%s">category to tag converter</a>.'), 'import.php') ?></p> | |
| 1600 | -<?php endif; ?> | |
| 1601 | -</div> | |
| 1602 | -<?php elseif ( 'post_tag' == $taxonomy && current_user_can( 'import' ) ) : ?> | |
| 1603 | -<div class="form-wrap"> | |
| 1604 | -<p><?php printf(__('Tags can be selectively converted to categories using the <a href="%s">tag to category converter</a>'), 'import.php') ;?>.</p> | |
| 1605 | -</div> | |
| 1606 | -<?php endif; | |
| 1607 | -do_action('after-' . $taxonomy . '-table', $taxonomy); | |
| 1608 | -*/ ?> | |
| 1609 | - | |
| 1610 | -</div> | |
| 1611 | -</div><!-- /col-right --> | |
| 1612 | - | |
| 1613 | -<div id="col-left"> | |
| 1614 | -<div class="col-wrap"> | |
| 1615 | - | |
| 1616 | -<?php | |
| 1617 | -/* | |
| 1618 | -if ( !is_null( $tax->labels->popular_items ) ) { | |
| 1619 | - if ( current_user_can( $tax->cap->edit_terms ) ) | |
| 1620 | - $tag_cloud = wp_tag_cloud( array( 'taxonomy' => $taxonomy, 'echo' => false, 'link' => 'edit' ) ); | |
| 1621 | - else | |
| 1622 | - $tag_cloud = wp_tag_cloud( array( 'taxonomy' => $taxonomy, 'echo' => false ) ); | |
| 1623 | - | |
| 1624 | - if ( $tag_cloud ) : | |
| 1625 | - ?> | |
| 1626 | -<div class="tagcloud"> | |
| 1627 | -<h3><?php echo $tax->labels->popular_items; ?></h3> | |
| 1628 | -<?php echo $tag_cloud; unset( $tag_cloud ); ?> | |
| 1629 | -</div> | |
| 1630 | -<?php | |
| 1631 | -endif; | |
| 1632 | -} | |
| 1633 | -*/ | |
| 1634 | - | |
| 1635 | -/* | |
| 1636 | -if ( current_user_can($tax->cap->edit_terms) ) { | |
| 1637 | - // Back compat hooks. Deprecated in preference to {$taxonomy}_pre_add_form | |
| 1638 | - if ( 'category' == $taxonomy ) | |
| 1639 | - do_action('add_category_form_pre', (object)array('parent' => 0) ); | |
| 1640 | - elseif ( 'link_category' == $taxonomy ) | |
| 1641 | - do_action('add_link_category_form_pre', (object)array('parent' => 0) ); | |
| 1642 | - else | |
| 1643 | - do_action('add_tag_form_pre', $taxonomy); | |
| 1644 | - | |
| 1645 | - do_action($taxonomy . '_pre_add_form', $taxonomy); | |
| 1646 | -*/ | |
| 1647 | - | |
| 1648 | -$types = array( | |
| 1649 | - 'textfield' => __( 'Text Field', 'accua-form-api'), | |
| 1650 | - 'textarea' => __( 'Text Area', 'accua-form-api'), | |
| 1651 | - 'email' => __( 'Email', 'accua-form-api'), | |
| 1652 | - 'autoreply_email' => __( 'Autoreply Email', 'accua-form-api'), | |
| 1653 | - 'checkbox' => __( 'Checkbox','accua-form-api'), | |
| 1654 | - 'select' => __('Select', 'accua-form-api'), | |
| 1655 | - 'radio' => __( 'Radio buttons', 'accua-form-api'), | |
| 1656 | - 'multiselect' => __( 'Multiple selections area', 'accua-form-api'), | |
| 1657 | - 'multicheckbox' => __( 'Multiple checkboxes', 'accua-form-api'), | |
| 1658 | - 'post-multicheckbox' => __( 'Multiple post checkboxes', 'accua-form-api'), | |
| 1659 | - 'hidden' => __('Hidden value', 'accua-form-api'), | |
| 1660 | - 'file' => __('File upload', 'accua-form-api'), | |
| 1661 | - 'submit' => __( 'Submit button', 'accua-form-api'), | |
| 1662 | - 'html' => __( 'Custom HTML', 'accua-form-api'), | |
| 1663 | - 'captcha' => __( 'Captcha', 'accua-form-api'), | |
| 1664 | - 'password' => 'Password', | |
| 1665 | - 'password-and-confirm' => __( 'Password and password confirmation','accua-form-api'), | |
| 1666 | -); | |
| 1667 | - | |
| 1668 | - | |
| 1669 | -?> | |
| 1670 | -<div class="form-wrap"> | |
| 1671 | -<h3><?php echo $adding? __( 'Add new field','accua-form-api'): __( 'Edit field','accua-form-api') ; ?></h3> | |
| 1672 | -<form id="addtag" method="post" action="admin.php?page=accua_forms_fields" class="validate"> | |
| 1673 | -<input type="hidden" name="action" value="<?php echo $adding?'add':'edit'; ?>-form-field" /> | |
| 1674 | -<?php /* | |
| 1675 | -<input type="hidden" name="screen" value="<?php echo esc_attr($current_screen->id); ?>" /> | |
| 1676 | -<input type="hidden" name="taxonomy" value="<?php echo esc_attr($taxonomy); ?>" /> | |
| 1677 | -<input type="hidden" name="post_type" value="<?php echo esc_attr($post_type); ?>" /> | |
| 1678 | -*/ ?> | |
| 1679 | -<?php wp_nonce_field('add-tag', '_wpnonce_add-form-field'); ?> | |
| 1680 | - | |
| 1681 | -<div class="form-field form-required"> | |
| 1682 | - <label for="tag-name"><?php _e( 'Field label', 'accua-form-api'); ?></label> | |
| 1683 | - <input name="form-field-name" id="tag-name" type="text" value="<?php echo htmlspecialchars($default_form_values['name'], ENT_QUOTES) ?>" size="40" aria-required="true" /> | |
| 1684 | - <p><?php _e('The name is how it appears on your site.', 'accua-form-api'); ?></p> | |
| 1685 | -</div> | |
| 1686 | -<?php /* if ( ! global_terms_enabled() ) : */ ?> | |
| 1687 | -<div class="form-field"> | |
| 1688 | - <label for="tag-slug"><?php _e( 'Field slug (identificative)', 'accua-form-api'); ?></label> | |
| 1689 | - <input name="form-field-id" id="tag-slug" type="text" value="<?php echo htmlspecialchars($default_form_values['id'], ENT_QUOTES) ?>" <?php if (!$adding) { echo 'disabled="disabled"'; } ?> size="40" /> | |
| 1690 | - <?php if (!$adding) { echo '<input type="hiden" name="form-field-id" value="'.htmlspecialchars($default_form_values['id'], ENT_QUOTES).'" />'; } ?> | |
| 1691 | - <p><?php _e('The “slug” is the URL-friendly version of the name. It is used as an identificator, and is unchangeable. It is usually all lowercase and it must contains only letters, numbers, and underscores.', 'accua-form-api'); ?></p> | |
| 1692 | -</div> | |
| 1693 | -<div class="form-field"> | |
| 1694 | - <label for="parent"><?php _e( 'Field type', 'accua-form-api'); ?></label> | |
| 1695 | - <select class="postform" id="parent" name="form-field-type"> | |
| 1696 | - <?php /* | |
| 1697 | - <option value="textfield" class="level-0" <?php echo ($default_form_values['type'] == 'textfield')?'selected="selected"':'';?> >Text Field</option> | |
| 1698 | - <option value="textarea" class="level-0" <?php echo ($default_form_values['type'] == 'textarea')?'selected="selected"':'';?> >Text Area</option> | |
| 1699 | - <option value="email" class="level-0" <?php echo ($default_form_values['type'] == 'email')?'selected="selected"':'';?> >Email</option> | |
| 1700 | - <option value="checkbox" class="level-0" <?php echo ($default_form_values['type'] == 'checkbox')?'selected="selected"':'';?> >Checkbox</option> | |
| 1701 | - <option value="select" class="level-0" <?php echo ($default_form_values['type'] == 'select')?'selected="selected"':'';?> >Select</option> | |
| 1702 | - */ | |
| 1703 | - foreach ($types as $typeid => $typename) { | |
| 1704 | - $selected = ($default_form_values['type'] == $typeid)?'selected="selected"':''; | |
| 1705 | - echo <<<EOT | |
| 1706 | -<option value="{$typeid}" class="level-0" {$selected} >{$typename}</option> | |
| 1707 | -EOT; | |
| 1708 | - } | |
| 1709 | - | |
| 1710 | - ?> | |
| 1711 | - </select> | |
| 1712 | -</div> | |
| 1713 | -<?php /* endif; // global_terms_enabled() */ ?> | |
| 1714 | -<?php /* if ( is_taxonomy_hierarchical($taxonomy) ) : ?> | |
| 1715 | -<div class="form-field"> | |
| 1716 | - <label for="parent"><?php _ex('Parent', 'Taxonomy Parent'); ?></label> | |
| 1717 | - <?php wp_dropdown_categories(array('hide_empty' => 0, 'hide_if_empty' => false, 'taxonomy' => $taxonomy, 'name' => 'parent', 'orderby' => 'name', 'hierarchical' => true, 'show_option_none' => __('None'))); ?> | |
| 1718 | - <?php if ( 'category' == $taxonomy ) : // @todo: Generic text for hierarchical taxonomies ?> | |
| 1719 | - <p><?php _e('Categories, unlike tags, can have a hierarchy. You might have a Jazz category, and under that have children categories for Bebop and Big Band. Totally optional.'); ?></p> | |
| 1720 | - <?php endif; ?> | |
| 1721 | -</div> | |
| 1722 | -<?php endif; // is_taxonomy_hierarchical() */ ?> | |
| 1723 | -<div class="form-field"> | |
| 1724 | - <label for="tag-description"><?php _e( 'Field description', 'accua-form-api'); ?></label> | |
| 1725 | - <textarea name="form-field-description" id="tag-description" rows="5" cols="40"><?php echo htmlspecialchars($default_form_values['description'], ENT_QUOTES) ?></textarea> | |
| 1726 | - <p><?php _e('The description is not prominent by default; however, some themes may show it.', 'accua-form-api'); ?></p> | |
| 1727 | -</div> | |
| 1728 | - | |
| 1729 | -<div class="form-field"> | |
| 1730 | - <label for="form-field-default-value"><?php _e( 'Default value(s)', 'accua-form-api'); ?>:</label> | |
| 1731 | - <textarea name="form-field-default-value" id="form-field-default-value" rows="5" cols="40"><?php echo htmlspecialchars($default_form_values['default_value'], ENT_QUOTES) ?></textarea> | |
| 1732 | - <p><?php _e( 'For multiple default values in multiple select and multiple checkboxes, use | as separator.', 'accua-form-api'); ?></p> | |
| 1733 | -</div> | |
| 1734 | - | |
| 1735 | -<div class="form-field"> | |
| 1736 | - <label for="form-field-allowed-values"><?php _e( 'Allowed values', 'accua-form-api'); ?>:</label> | |
| 1737 | - <textarea rows="5" cols="40" name="form-field-allowed-values" id=form-field-allowed-values"><?php echo htmlspecialchars($default_form_values['allowed_values'], ENT_QUOTES) ?></textarea> | |
| 1738 | - <p><?php _e( 'Options used in select, radio and multiple checkboxes. Enter one value per line, in the format key|label. The key is the value that will be stored in the database. The label is optional, and the key will be used as the label if no label is specified. For file fields, this indicates allowed extensions (one per line without dot)', 'accua-form-api'); ?></p> | |
| 1739 | -</div> | |
| 1740 | - | |
| 1741 | - | |
| 1742 | -<?php | |
| 1743 | -/* | |
| 1744 | -if ( ! is_taxonomy_hierarchical($taxonomy) ) | |
| 1745 | - do_action('add_tag_form_fields', $taxonomy); | |
| 1746 | -do_action($taxonomy . '_add_form_fields', $taxonomy); | |
| 1747 | -*/ | |
| 1748 | - | |
| 1749 | -if ($adding) { | |
| 1750 | - submit_button( __( 'Add new field', 'accua-form-api'), 'button' ); | |
| 1751 | -} else { | |
| 1752 | - submit_button( __( 'Save changes', 'accua-form-api'), 'button' ); | |
| 1753 | - submit_button( __( 'Delete field', 'accua-form-api'), 'button', 'delete-field'); | |
| 1754 | -} | |
| 1755 | - | |
| 1756 | -/* | |
| 1757 | -// Back compat hooks. Deprecated in preference to {$taxonomy}_add_form | |
| 1758 | -if ( 'category' == $taxonomy ) | |
| 1759 | - do_action('edit_category_form', (object)array('parent' => 0) ); | |
| 1760 | -elseif ( 'link_category' == $taxonomy ) | |
| 1761 | - do_action('edit_link_category_form', (object)array('parent' => 0) ); | |
| 1762 | -else | |
| 1763 | - do_action('add_tag_form', $taxonomy); | |
| 1764 | - | |
| 1765 | -do_action($taxonomy . '_add_form', $taxonomy); | |
| 1766 | -*/ | |
| 1767 | -?> | |
| 1768 | -</form></div> | |
| 1769 | -<?php /* } */ ?> | |
| 1770 | - | |
| 1771 | -</div> | |
| 1772 | -</div><!-- /col-left --> | |
| 1773 | - | |
| 1774 | -</div><!-- /col-container --> | |
| 1775 | -</div><!-- /wrap --> | |
| 1776 | -<?php | |
| 1777 | - /* echo '<pre>accua_forms_avail_fields:', htmlspecialchars(print_r($avail_fields, true)), '</pre>'; */ | |
| 1778 | -} | |
| 1779 | - | |
| 1780 | -function accua_forms_settings_page() { | |
| 1781 | -?> | |
| 1782 | -<div id="accua_forms_settings_page" class="accua_forms_admin_page wrap"> | |
| 1783 | -<div id="icon-contact-forms-cimatti-logo" class="icon32"></div> | |
| 1784 | -<h2><?php _e( 'Default Form settings', 'accua-form-api'); ?></h2> | |
| 1785 | -<?php | |
| 1786 | - $empty_form_data = array( | |
| 1787 | - 'success_message' => '', | |
| 1788 | - 'error_message' => '', | |
| 1789 | - 'emails_from' => '', | |
| 1790 | - 'admin_emails_to' => '', | |
| 1791 | - 'emails_bcc' => '', | |
| 1792 | - 'admin_emails_subject' => '', | |
| 1793 | - 'admin_emails_message' => '', | |
| 1794 | - 'confirmation_emails_subject' => '', | |
| 1795 | - 'confirmation_emails_message' => '', | |
| 1796 | - 'layout' => 'sidebyside', | |
| 1797 | - 'style_margin' => '', | |
| 1798 | - 'style_border_color' => '', | |
| 1799 | - 'style_border_width' => '', | |
| 1800 | - 'style_border_radius' => '', | |
| 1801 | - 'style_background_color' => '', | |
| 1802 | - 'style_padding' => '', | |
| 1803 | - 'style_color' => '', | |
| 1804 | - 'style_font_size' => '', | |
| 1805 | - 'style_field_spacing' => '', | |
| 1806 | - 'style_field_border_color' => '', | |
| 1807 | - 'style_field_border_width' => '', | |
| 1808 | - 'style_field_border_radius' => '', | |
| 1809 | - 'style_field_background_color' => '', | |
| 1810 | - 'style_field_padding' => '', | |
| 1811 | - 'style_field_color' => '', | |
| 1812 | - 'style_submit_border_color' => '', | |
| 1813 | - 'style_submit_border_width' => '', | |
| 1814 | - 'style_submit_border_radius' => '', | |
| 1815 | - 'style_submit_background_color' => '', | |
| 1816 | - 'style_submit_padding' => '', | |
| 1817 | - 'style_submit_color' => '', | |
| 1818 | - 'style_submit_font_size' => '', | |
| 1819 | - ); | |
| 1820 | - | |
| 1821 | - $empty_file_data = array( | |
| 1822 | - 'valid_extensions' => '', | |
| 1823 | - 'max_size' => '', | |
| 1824 | - 'dest_path' => '', | |
| 1825 | - ); | |
| 1826 | - | |
| 1827 | - if($_SERVER['REQUEST_METHOD'] == 'POST' && !empty($_POST['accua_form_save_form_settings'])) { | |
| 1828 | - $post = stripslashes_deep($_POST); | |
| 1829 | - $post += $empty_form_data; | |
| 1830 | - $post += $empty_file_data; | |
| 1831 | - $form_data = array(); | |
| 1832 | - $file_data = array(); | |
| 1833 | - foreach($empty_form_data as $key=>$val){ | |
| 1834 | - $form_data[$key] = $post[$key]; | |
| 1835 | - } | |
| 1836 | - foreach($empty_file_data as $key=>$val){ | |
| 1837 | - $file_data[$key] = $post[$key]; | |
| 1838 | - } | |
| 1839 | - | |
| 1840 | - | |
| 1841 | - | |
| 1842 | - update_option('accua_forms_default_form_data', $form_data); | |
| 1843 | - update_option('accua_forms_default_file_field_data', $file_data); | |
| 1844 | - } else { | |
| 1845 | - $form_data = get_option('accua_forms_default_form_data',array()) + $empty_form_data; | |
| 1846 | - $file_data = get_option('accua_forms_default_file_field_data',array()) + $empty_file_data; | |
| 1847 | - } | |
| 1848 | -?> | |
| 1849 | -<form method="post"> | |
| 1850 | -<input type="hidden" name="accua_form_save_form_settings" value="1" /> | |
| 1851 | -<?php /* | |
| 1852 | -<p id="accua_form_layout"><?php _e( 'Layout', 'accua-form-api'); ?>: <select name="layout" class="accua_form_value"><option value="sidebyside" <?php if ($form_data['layout'] == 'sidebyside') { echo 'selected="selected"'; } ?>>Labels on the left of the fields</option><option value="toplabel" <?php if ($form_data['layout'] == 'toplabel') { echo 'selected="selected"'; } ?>>Labels on top of the fields</option></select></p> | |
| 1853 | -<p id="accua_form_success_message"><?php _e( 'Success message', 'accua-form-api'); ?>:<br /><textarea name="success_message" class="accua_form_value" style="width:95%"; cols="80" rows="8"><?php echo htmlspecialchars($form_data['success_message'], ENT_QUOTES) ?></textarea></p> | |
| 1854 | -<p id="accua_form_error_message"><?php _e( 'Error message', 'accua-form-api'); ?>:<br /><textarea name="error_message" class="accua_form_value" style="width:95%"; cols="80" rows="8"><?php echo htmlspecialchars($form_data['error_message'], ENT_QUOTES) ?></textarea></p> | |
| 1855 | -<p id="accua_form_emails_from"><?php _e( 'Emails from', 'accua-form-api'); ?>: <input name="emails_from" class="accua_form_value" type="text" value="<?php echo htmlspecialchars($form_data['emails_from'], ENT_QUOTES) ?>" /></p> | |
| 1856 | -<p id="accua_form_admin_emails_to"><?php _e( 'Admin emails to', 'accua-form-api'); ?>: <input name="admin_emails_to" class="accua_form_value" type="text" value="<?php echo htmlspecialchars($form_data['admin_emails_to'], ENT_QUOTES) ?>" /></p> | |
| 1857 | -<p id="accua_form_emails_bcc"><?php _e( 'Emails bcc', 'accua-form-api'); ?>: <input name="emails_bcc" class="accua_form_value" type="text" value="<?php echo htmlspecialchars($form_data['emails_bcc'], ENT_QUOTES) ?>" /></p> | |
| 1858 | -<p id="accua_form_admin_emails_subject"><?php _e( 'Admin email subject', 'accua-form-api'); ?>: <input name="admin_emails_subject" class="accua_form_value" type="text" value="<?php echo htmlspecialchars($form_data['admin_emails_subject'], ENT_QUOTES) ?>" /></p> | |
| 1859 | -<p id="accua_form_admin_emails_message"><?php _e( 'Admin email message', 'accua-form-api'); ?>:<br /><textarea name="admin_emails_message" class="accua_form_value" style="width:95%"; cols="80" rows="8"><?php echo htmlspecialchars($form_data['admin_emails_message'], ENT_QUOTES) ?></textarea></p> | |
| 1860 | -<p id="accua_form_confirmation_emails_subject"><?php _e( 'Confirmation email subject', 'accua-form-api'); ?>: <input name="confirmation_emails_subject" class="accua_form_value" type="text" value="<?php echo htmlspecialchars($form_data['confirmation_emails_subject'], ENT_QUOTES) ?>" /></p> | |
| 1861 | -<p id="accua_form_confirmation_emails_message"><?php _e( 'Confirmation email message', 'accua-form-api'); ?>:<br /><textarea name="confirmation_emails_message" class="accua_form_value" style="width:95%"; cols="80" rows="8"><?php echo htmlspecialchars($form_data['confirmation_emails_message'], ENT_QUOTES) ?></textarea></p> | |
| 1862 | -*/ ?> | |
| 1863 | -<div id="accua_tab_messages" class="content_tab"> | |
| 1864 | - <?php | |
| 1865 | - $settings_editor = array( | |
| 1866 | - 'teeny' => true, | |
| 1867 | - 'editor_class' => 'accua_form_value', | |
| 1868 | - 'tinymce' => array( | |
| 1869 | - 'theme_advanced_buttons1' => 'bold,italic,underline,|,bullist,numlist,')); | |
| 1870 | - ?> | |
| 1871 | - <div class="metabox-holder accua-forms-metabox-holder"> | |
| 1872 | - <div class="postbox "> | |
| 1873 | - <h3 class="hndle"><span><?php _e('1. On-screen success message', 'accua-form-api'); ?></span></h3> | |
| 1874 | - <div class="inside" id="dashboard_right_now"> | |
| 1875 | - <div id="accua_form_success_message"> | |
| 1876 | - <?php wp_editor( $form_data['success_message'] , 'success_message' , $settings_editor); ?> | |
| 1877 | - </div> | |
| 1878 | - </div> | |
| 1879 | - </div> | |
| 1880 | - </div> | |
| 1881 | - | |
| 1882 | - <div class="metabox-holder accua-forms-metabox-holder"> | |
| 1883 | - <div class="postbox "> | |
| 1884 | - <h3 class="hndle"><span><?php _e('2. On-screen error message', 'accua-form-api'); ?></span></h3> | |
| 1885 | - <div class="inside" id="dashboard_right_now"> | |
| 1886 | - <div id="accua_form_error_message"> | |
| 1887 | - <?php wp_editor( $form_data['error_message'] , 'error_message' , $settings_editor); ?> | |
| 1888 | - </div> | |
| 1889 | - </div> | |
| 1890 | - </div> | |
| 1891 | - </div> | |
| 1892 | - <br clear="all"/> | |
| 1893 | - <div class="metabox-holder accua-forms-metabox-holder"> | |
| 1894 | - <div class="postbox "> | |
| 1895 | - <h3 class="hndle"><span><?php _e('3. Email to notify administrator', 'accua-form-api'); ?></span></h3> | |
| 1896 | - <div class="inside" id="dashboard_right_now"> | |
| 1897 | - <div id="accua_form_admin_emails_to" class="label_input"> | |
| 1898 | - <label><?php _e( 'To', 'accua-form-api'); ?></label> | |
| 1899 | - <input name="admin_emails_to" class="accua_form_value" type="text" value="<?php echo htmlspecialchars($form_data['admin_emails_to'], ENT_QUOTES) ?>" /> | |
| 1900 | - </div> | |
| 1901 | - <br clear="all" /> | |
| 1902 | - <div id="accua_form_emails_bcc" class="label_input"> | |
| 1903 | - <label><?php _e( 'Bcc', 'accua-form-api'); ?></label> | |
| 1904 | - <input name="emails_bcc" class="accua_form_value" type="text" value="<?php echo htmlspecialchars($form_data['emails_bcc'], ENT_QUOTES) ?>" /> | |
| 1905 | - </div> | |
| 1906 | - <br clear="all" /> | |
| 1907 | - <div id="accua_form_admin_emails_subject" class="label_input"> | |
| 1908 | - <label><?php _e( 'Subject', 'accua-form-api'); ?></label> | |
| 1909 | - <input name="admin_emails_subject" class="accua_form_value" type="text" value="<?php echo htmlspecialchars($form_data['admin_emails_subject'], ENT_QUOTES) ?>" /> | |
| 1910 | - </div> | |
| 1911 | - <br clear="all" /> | |
| 1912 | - <div id="accua_form_admin_emails_message"> | |
| 1913 | - <?php wp_editor( $form_data['admin_emails_message'] , 'admin_emails_message' , $settings_editor); ?> | |
| 1914 | - </div> | |
| 1915 | - | |
| 1916 | - </div> | |
| 1917 | - </div> | |
| 1918 | - </div> | |
| 1919 | - | |
| 1920 | - <div class="metabox-holder accua-forms-metabox-holder"> | |
| 1921 | - <div class="postbox "> | |
| 1922 | - <h3 class="hndle"><span><?php _e('4. Email confirmation to the person who completed the form', 'accua-form-api'); ?></span></h3> | |
| 1923 | - <div class="inside" id="dashboard_right_now"> | |
| 1924 | - <div id="accua_form_emails_from" class="label_input"> | |
| 1925 | - <label><?php _e( 'From', 'accua-form-api'); ?></label> | |
| 1926 | - <input class="accua_form_value" name="emails_from" type="text" value="<?php echo htmlspecialchars($form_data['emails_from'], ENT_QUOTES) ?>" /> | |
| 1927 | - </div> | |
| 1928 | - <br clear="all" /> | |
| 1929 | - <div id="accua_form_confirmation_emails_subject" class="label_input"> | |
| 1930 | - <label><?php _e( 'Subject', 'accua-form-api'); ?></label> | |
| 1931 | - <input class="accua_form_value" type="text" name="confirmation_emails_subject" value="<?php echo htmlspecialchars($form_data['confirmation_emails_subject'], ENT_QUOTES) ?>" /> | |
| 1932 | - </div> | |
| 1933 | - <br clear="all" /> | |
| 1934 | - <div id="accua_form_confirmation_emails_message"> | |
| 1935 | - <?php wp_editor( $form_data['confirmation_emails_message'] , 'confirmation_emails_message' , $settings_editor); ?> | |
| 1936 | - </div> | |
| 1937 | - </div> | |
| 1938 | - </div> | |
| 1939 | - </div> | |
| 1940 | - <br clear="all"/> | |
| 1941 | - | |
| 1942 | - <div class="metabox-holder accua-forms-metabox-holder"> | |
| 1943 | - <div class="postbox "> | |
| 1944 | - <h3 class="hndle"><span><?php _e( 'File upload default settings', 'accua-form-api'); ?></span></h3> | |
| 1945 | - <div class="inside" id="dashboard_right_now"> | |
| 1946 | - <div id="accua_form_valid_extensions"><?php _e( 'Valid extensions', 'accua-form-api'); ?> <br /><textarea name="valid_extensions" class="accua_form_value" style="width:95%"; cols="80" rows="8"><?php echo htmlspecialchars($file_data['valid_extensions'], ENT_QUOTES) ?></textarea> | |
| 1947 | - <small><?php _e( 'List of valid extensions, without dot, one per line.', 'accua-form-api'); ?></small> | |
| 1948 | - </div> | |
| 1949 | - <div id="accua_form_max_size"><?php _e( 'Maximum file size:', 'accua-form-api'); ?> <input name="max_size" class="accua_form_value" type="text" value="<?php echo htmlspecialchars($file_data['max_size'], ENT_QUOTES) ?>" /><br /> | |
| 1950 | - <small><?php _e( 'You can use suffix K, M or G for kilobyte, megabyte or gigabyte.', 'accua-form-api'); ?> | |
| 1951 | - <?php | |
| 1952 | - $server_max_size = AccuaForm_Element_File::file_upload_max_size(); | |
| 1953 | - if ($server_max_size > 0) { | |
| 1954 | - _e( 'This value is limited by server upload limits of ', 'accua-form-api'); | |
| 1955 | - echo AccuaForm_Element_File::format_size($server_max_size).". "; | |
| 1956 | - _e( 'If you need a greater limit you should ask to the server administrator.', 'accua-form-api'); | |
| 1957 | - } | |
| 1958 | - ?> | |
| 1959 | - </small> | |
| 1960 | - </div> | |
| 1961 | - <div id="accua_form_dest_path"><?php _e( 'Upload path', 'accua-form-api');?> : <input name="dest_path" class="accua_form_value" type="text" value="<?php echo htmlspecialchars($file_data['dest_path'], ENT_QUOTES) ?>" /> | |
| 1962 | - <small><?php _e( 'If it stars with \'/\' an absolute path is used, otherwise a path relative to the WordPress installation directory. Default value is "wp-content/uploads/accua-forms"', 'accua-form-api');?>.</small> | |
| 1963 | - </div> | |
| 1964 | - </div> | |
| 1965 | - </div> | |
| 1966 | - </div> | |
| 1967 | - | |
| 1968 | - <div class="metabox-holder accua-forms-metabox-holder"> | |
| 1969 | - <div class="postbox "> | |
| 1970 | - <h3 class="hndle"><span><?php _e( 'Layout & Styling', 'accua-form-api'); ?></span></h3> | |
| 1971 | - <div class="inside" id="dashboard_right_now"> | |
| 1972 | - <p><?php _e( 'Customize the look and feel of your forms. Leave fields empty if you wish to use the native styles of your WordPress Theme.', 'accua-form-api'); ?><p> | |
| 1973 | - <h4><?php _e( 'Forms', 'accua-form-api'); ?></h4> | |
| 1974 | - <div id="accua_form_layout"> <?php _e( 'Layout', 'accua-form-api'); ?> | |
| 1975 | - <select name="layout" class="accua_form_value"><option value="sidebyside" <?php if ($form_data['layout'] == 'sidebyside') { echo 'selected="selected"'; } ?>>Labels on the left of the fields</option><option value="toplabel" <?php if ($form_data['layout'] == 'toplabel') { echo 'selected="selected"'; } ?>>Labels on top of the fields</option></select> | |
| 1976 | - </div> | |
| 1977 | - <div id="accua_form_style_margin" class="label_input"> | |
| 1978 | - <label><?php _e( 'Margin', 'accua-form-api'); ?></label> | |
| 1979 | - <input name="style_margin" class="accua_form_value" type="text" value="<?php echo htmlspecialchars($form_data['style_margin'], ENT_QUOTES) ?>" /> | |
| 1980 | - </div> | |
| 1981 | - <div id="accua_form_style_border_color" class="label_input"> | |
| 1982 | - <label><?php _e( 'Border color', 'accua-form-api'); ?></label> | |
| 1983 | - <input name="style_border_color" class="accua_form_value" type="text" value="<?php echo htmlspecialchars($form_data['style_border_color'], ENT_QUOTES) ?>" /> | |
| 1984 | - </div> | |
| 1985 | - <div id="accua_form_style_border_width" class="label_input"> | |
| 1986 | - <label><?php _e( 'Border width', 'accua-form-api'); ?></label> | |
| 1987 | - <input name="style_border_width" class="accua_form_value" type="text" value="<?php echo htmlspecialchars($form_data['style_border_width'], ENT_QUOTES) ?>" /> | |
| 1988 | - </div> | |
| 1989 | - <div id="accua_form_style_border_radius" class="label_input"> | |
| 1990 | - <label><?php _e( 'Rounded corner radius', 'accua-form-api'); ?></label> | |
| 1991 | - <input name="style_border_radius" class="accua_form_value" type="text" value="<?php echo htmlspecialchars($form_data['style_border_radius'], ENT_QUOTES) ?>" /> | |
| 1992 | - </div> | |
| 1993 | - <div id="accua_form_style_background_color" class="label_input"> | |
| 1994 | - <label><?php _e( 'Background color', 'accua-form-api'); ?></label> | |
| 1995 | - <input name="style_background_color" class="accua_form_value" type="text" value="<?php echo htmlspecialchars($form_data['style_background_color'], ENT_QUOTES) ?>" /> | |
| 1996 | - </div> | |
| 1997 | - <div id="accua_form_style_padding" class="label_input"> | |
| 1998 | - <label><?php _e( 'Padding', 'accua-form-api'); ?></label> | |
| 1999 | - <input name="style_padding" class="accua_form_value" type="text" value="<?php echo htmlspecialchars($form_data['style_padding'], ENT_QUOTES) ?>" /> | |
| 2000 | - </div> | |
| 2001 | - <div id="accua_form_style_color" class="label_input"> | |
| 2002 | - <label><?php _e( 'Text color', 'accua-form-api'); ?></label> | |
| 2003 | - <input name="style_color" class="accua_form_value" type="text" value="<?php echo htmlspecialchars($form_data['style_color'], ENT_QUOTES) ?>" /> | |
| 2004 | - </div> | |
| 2005 | - <div id="accua_form_style_font_size" class="label_input"> | |
| 2006 | - <label><?php _e( 'Font size', 'accua-form-api'); ?></label> | |
| 2007 | - <input name="style_font_size" class="accua_form_value" type="text" value="<?php echo htmlspecialchars($form_data['style_font_size'], ENT_QUOTES) ?>" /> | |
| 2008 | - </div> | |
| 2009 | - | |
| 2010 | - <h4><?php _e( 'Fields', 'accua-form-api'); ?></h4> | |
| 2011 | - <div id="accua_form_style_field_spacing" class="label_input"> | |
| 2012 | - <label><?php _e( 'Spacing', 'accua-form-api'); ?></label> | |
| 2013 | - <input name="style_field_spacing" class="accua_form_value" type="text" value="<?php echo htmlspecialchars($form_data['style_field_spacing'], ENT_QUOTES) ?>" /> | |
| 2014 | - </div> | |
| 2015 | - <div id="accua_form_style_field_border_color" class="label_input"> | |
| 2016 | - <label><?php _e( 'Border color', 'accua-form-api'); ?></label> | |
| 2017 | - <input name="style_field_border_color" class="accua_form_value" type="text" value="<?php echo htmlspecialchars($form_data['style_field_border_color'], ENT_QUOTES) ?>" /> | |
| 2018 | - </div> | |
| 2019 | - <div id="accua_form_style_field_border_width" class="label_input"> | |
| 2020 | - <label><?php _e( 'Border width', 'accua-form-api'); ?></label> | |
| 2021 | - <input name="style_field_border_width" class="accua_form_value" type="text" value="<?php echo htmlspecialchars($form_data['style_field_border_width'], ENT_QUOTES) ?>" /> | |
| 2022 | - </div> | |
| 2023 | - <div id="accua_form_style_field_border_radius" class="label_input"> | |
| 2024 | - <label><?php _e( 'Rounded corner radius', 'accua-form-api'); ?></label> | |
| 2025 | - <input name="style_field_border_radius" class="accua_form_value" type="text" value="<?php echo htmlspecialchars($form_data['style_field_border_radius'], ENT_QUOTES) ?>" /> | |
| 2026 | - </div> | |
| 2027 | - <div id="accua_form_style_field_background_color" class="label_input"> | |
| 2028 | - <label><?php _e( 'Background color', 'accua-form-api'); ?></label> | |
| 2029 | - <input name="style_field_background_color" class="accua_form_value" type="text" value="<?php echo htmlspecialchars($form_data['style_field_background_color'], ENT_QUOTES) ?>" /> | |
| 2030 | - </div> | |
| 2031 | - <div id="accua_form_style_field_padding" class="label_input"> | |
| 2032 | - <label><?php _e( 'Padding', 'accua-form-api'); ?></label> | |
| 2033 | - <input name="style_field_padding" class="accua_form_value" type="text" value="<?php echo htmlspecialchars($form_data['style_field_padding'], ENT_QUOTES) ?>" /> | |
| 2034 | - </div> | |
| 2035 | - <div id="accua_form_style_field_color" class="label_input"> | |
| 2036 | - <label><?php _e( 'Text color', 'accua-form-api'); ?></label> | |
| 2037 | - <input name="style_field_color" class="accua_form_value" type="text" value="<?php echo htmlspecialchars($form_data['style_field_color'], ENT_QUOTES) ?>" /> | |
| 2038 | - </div> | |
| 2039 | - | |
| 2040 | - <h4><?php _e( 'Submit button', 'accua-form-api'); ?></h4> | |
| 2041 | - <div id="accua_form_style_submit_border_color" class="label_input"> | |
| 2042 | - <label><?php _e( 'Border color', 'accua-form-api'); ?></label> | |
| 2043 | - <input name="style_submit_border_color" class="accua_form_value" type="text" value="<?php echo htmlspecialchars($form_data['style_submit_border_color'], ENT_QUOTES) ?>" /> | |
| 2044 | - </div> | |
| 2045 | - <div id="accua_form_style_submit_border_width" class="label_input"> | |
| 2046 | - <label><?php _e( 'Border width', 'accua-form-api'); ?></label> | |
| 2047 | - <input name="style_submit_border_width" class="accua_form_value" type="text" value="<?php echo htmlspecialchars($form_data['style_submit_border_width'], ENT_QUOTES) ?>" /> | |
| 2048 | - </div> | |
| 2049 | - <div id="accua_form_style_submit_border_radius" class="label_input"> | |
| 2050 | - <label><?php _e( 'Rounded corner radius', 'accua-form-api'); ?></label> | |
| 2051 | - <input name="style_submit_border_radius" class="accua_form_value" type="text" value="<?php echo htmlspecialchars($form_data['style_submit_border_radius'], ENT_QUOTES) ?>" /> | |
| 2052 | - </div> | |
| 2053 | - <div id="accua_form_style_submit_background_color" class="label_input"> | |
| 2054 | - <label><?php _e( 'Background color', 'accua-form-api'); ?></label> | |
| 2055 | - <input name="style_submit_background_color" class="accua_form_value" type="text" value="<?php echo htmlspecialchars($form_data['style_submit_background_color'], ENT_QUOTES) ?>" /> | |
| 2056 | - </div> | |
| 2057 | - <div id="accua_form_style_submit_padding" class="label_input"> | |
| 2058 | - <label><?php _e( 'Padding', 'accua-form-api'); ?></label> | |
| 2059 | - <input name="style_submit_padding" class="accua_form_value" type="text" value="<?php echo htmlspecialchars($form_data['style_submit_padding'], ENT_QUOTES) ?>" /> | |
| 2060 | - </div> | |
| 2061 | - <div id="accua_form_style_submit_color" class="label_input"> | |
| 2062 | - <label><?php _e( 'Text color', 'accua-form-api'); ?></label> | |
| 2063 | - <input name="style_submit_color" class="accua_form_value" type="text" value="<?php echo htmlspecialchars($form_data['style_submit_color'], ENT_QUOTES) ?>" /> | |
| 2064 | - </div> | |
| 2065 | - <div id="accua_form_style_submit_font_size" class="label_input"> | |
| 2066 | - <label><?php _e( 'Font size', 'accua-form-api'); ?></label> | |
| 2067 | - <input name="style_submit_font_size" class="accua_form_value" type="text" value="<?php echo htmlspecialchars($form_data['style_submit_font_size'], ENT_QUOTES) ?>" /> | |
| 2068 | - </div> | |
| 2069 | - <br clear="all" /> | |
| 2070 | - </div> | |
| 2071 | - </div> | |
| 2072 | - </div> | |
| 2073 | - | |
| 2074 | - | |
| 2075 | - <br clear="all"/> | |
| 2076 | - | |
| 2077 | -</div> | |
| 2078 | - | |
| 2079 | -<?php /* | |
| 2080 | -<h3><?php _e( 'File upload default settings', 'accua-form-api'); ?></h3> | |
| 2081 | -<p id="accua_form_valid_extensions"><?php _e( 'Valid extensions', 'accua-form-api'); ?> <br /><textarea name="valid_extensions" class="accua_form_value" style="width:95%"; cols="80" rows="8"><?php echo htmlspecialchars($file_data['valid_extensions'], ENT_QUOTES) ?></textarea> | |
| 2082 | - <small><?php _e( 'List of valid extensions, without dot, one per line.', 'accua-form-api'); ?></small> | |
| 2083 | -</p> | |
| 2084 | -<p id="accua_form_max_size"><?php _e( 'Maximum file size:', 'accua-form-api'); ?> <input name="max_size" class="accua_form_value" type="text" value="<?php echo htmlspecialchars($file_data['max_size'], ENT_QUOTES) ?>" /><br /> | |
| 2085 | - <small><?php _e( 'You can use suffix K, M or G for kilobyte, megabyte or gigabyte.', 'accua-form-api'); ?> | |
| 2086 | -<?php | |
| 2087 | - $server_max_size = AccuaForm_Element_File::file_upload_max_size(); | |
| 2088 | - if ($server_max_size > 0) { | |
| 2089 | - _e( 'This value is limited by server upload limits of ', 'accua-form-api'); | |
| 2090 | - echo AccuaForm_Element_File::format_size($server_max_size).". "; | |
| 2091 | - _e( 'If you need a greater limit you should ask to the server administrator.', 'accua-form-api'); | |
| 2092 | - } | |
| 2093 | -?> | |
| 2094 | - </small></p> | |
| 2095 | -<p id="accua_form_dest_path"><?php _e( 'Upload path', 'accua-form-api');?> : <input name="dest_path" class="accua_form_value" type="text" value="<?php echo htmlspecialchars($file_data['dest_path'], ENT_QUOTES) ?>" /> | |
| 2096 | - <small><?php _e( 'If it stars with \'/\' an absolute path is used, otherwise a path relative to the WordPress installation directory. Default value is "wp-content/uploads/accua-forms"', 'accua-form-api');?>.</small> | |
| 2097 | -</p> */ ?> | |
| 2098 | -<p><input class="button button-primary button-large" id="accua_form_save_settings" type="submit" value="Save settings" /></p> | |
| 2099 | -</form> | |
| 2100 | -</div> | |
| 2101 | - | |
| 2102 | -<script type='text/javascript'> | |
| 2103 | -jQuery(function($) { | |
| 2104 | - $('#accua_form_style_border_color .accua_form_value').wpColorPicker(); | |
| 2105 | - $('#accua_form_style_background_color .accua_form_value').wpColorPicker(); | |
| 2106 | - $('#accua_form_style_color .accua_form_value').wpColorPicker(); | |
| 2107 | - $('#accua_form_style_field_border_color .accua_form_value').wpColorPicker(); | |
| 2108 | - $('#accua_form_style_field_background_color .accua_form_value').wpColorPicker(); | |
| 2109 | - $('#accua_form_style_field_color .accua_form_value').wpColorPicker(); | |
| 2110 | - $('#accua_form_style_submit_border_color .accua_form_value').wpColorPicker(); | |
| 2111 | - $('#accua_form_style_submit_background_color .accua_form_value').wpColorPicker(); | |
| 2112 | - $('#accua_form_style_submit_color .accua_form_value').wpColorPicker(); | |
| 2113 | -}); | |
| 2114 | -</script> | |
| 2115 | - | |
| 2116 | -<?php | |
| 2117 | -} | |
| 2118 | - | |
| 2119 | -function _accua_forms_get_abs_dest_path($dest_path = '') { | |
| 2120 | - if ($dest_path === '') { | |
| 2121 | - return realpath(ABSPATH) . '/wp-content/uploads/accua-forms'; | |
| 2122 | - } else if (substr($dest_path,0,1) === '/') { | |
| 2123 | - return $dest_path; | |
| 2124 | - } else { | |
| 2125 | - return realpath(ABSPATH) . '/' . $dest_path; | |
| 2126 | - } | |
| 2127 | -} | |
| 2128 | - | |
| 2129 | -function _accua_forms_get_form_data($fid = false, $return_empty = true, $restore_trash = false){ | |
| 2130 | - $empty_form_data = array( | |
| 2131 | - 'fields' => array(), | |
| 2132 | - 'title' => '', | |
| 2133 | - 'success_message' => '', | |
| 2134 | - 'error_message' => '', | |
| 2135 | - 'emails_from' => '', | |
| 2136 | - 'admin_emails_to' => '', | |
| 2137 | - 'emails_bcc' => '', | |
| 2138 | - 'admin_emails_subject' => '', | |
| 2139 | - 'admin_emails_message' => '', | |
| 2140 | - 'confirmation_emails_subject' => '', | |
| 2141 | - 'confirmation_emails_message' => '', | |
| 2142 | - 'use_ajax' => true, | |
| 2143 | - 'layout' => 'sidebyside', | |
| 2144 | - 'style_margin' => '', | |
| 2145 | - 'style_border_color' => '', | |
| 2146 | - 'style_border_width' => '', | |
| 2147 | - 'style_border_radius' => '', | |
| 2148 | - 'style_background_color' => '', | |
| 2149 | - 'style_padding' => '', | |
| 2150 | - 'style_color' => '', | |
| 2151 | - 'style_font_size' => '', | |
| 2152 | - 'style_field_spacing' => '', | |
| 2153 | - 'style_field_border_color' => '', | |
| 2154 | - 'style_field_border_width' => '', | |
| 2155 | - 'style_field_border_radius' => '', | |
| 2156 | - 'style_field_background_color' => '', | |
| 2157 | - 'style_field_padding' => '', | |
| 2158 | - 'style_field_color' => '', | |
| 2159 | - 'style_submit_border_color' => '', | |
| 2160 | - 'style_submit_border_width' => '', | |
| 2161 | - 'style_submit_border_radius' => '', | |
| 2162 | - 'style_submit_background_color' => '', | |
| 2163 | - 'style_submit_padding' => '', | |
| 2164 | - 'style_submit_color' => '', | |
| 2165 | - 'style_submit_font_size' => '', | |
| 2166 | - ); | |
| 2167 | - | |
| 2168 | - if ($fid === false) { | |
| 2169 | - return $empty_form_data; | |
| 2170 | - } | |
| 2171 | - | |
| 2172 | - $default_form_data = get_option('accua_forms_default_form_data',array()); | |
| 2173 | - | |
| 2174 | - if ($fid === null) { | |
| 2175 | - return $default_form_data + $empty_form_data; | |
| 2176 | - } | |
| 2177 | - | |
| 2178 | - $forms_data = get_option('accua_forms_saved_forms', array()); | |
| 2179 | - if ($restore_trash) { | |
| 2180 | - $trash_data = get_option('accua_forms_trash_forms', array()); | |
| 2181 | - if (isset($trash_data[$fid])) { | |
| 2182 | - $forms_data[$fid] = $trash_data[$fid]; | |
| 2183 | - update_option('accua_forms_saved_forms', $forms_data); | |
| 2184 | - unset($trash_data[$fid]); | |
| 2185 | - update_option('accua_forms_trash_forms', $trash_data); | |
| 2186 | - } | |
| 2187 | - } | |
| 2188 | - | |
| 2189 | - if (isset($forms_data[$fid])) { | |
| 2190 | - $form_data = array( | |
| 2191 | - '_overrided' => $forms_data[$fid] | |
| 2192 | - ) + $forms_data[$fid] + $default_form_data + $empty_form_data; | |
| 2193 | - /* | |
| 2194 | - if ($form_data['fields']) { | |
| 2195 | - foreach ($form_data['fields'] as $i => $istance_data) { | |
| 2196 | - // TODO: popuplate default fields data? | |
| 2197 | - } | |
| 2198 | - } | |
| 2199 | - */ | |
| 2200 | - return $form_data; | |
| 2201 | - } else if ($return_empty) { | |
| 2202 | - return array( | |
| 2203 | - '_overrided' => array() | |
| 2204 | - ) + $default_form_data + $empty_form_data; | |
| 2205 | - } else { | |
| 2206 | - return null; | |
| 2207 | - } | |
| 2208 | - | |
| 2209 | -} | |
| 2210 | - | |
| 2211 | -function _accua_forms_style_parameters($params) { | |
| 2212 | - $ret = ''; | |
| 2213 | - foreach ($params as $key => $value) { | |
| 2214 | - $value = trim($value); | |
| 2215 | - if ($value !== '') { | |
| 2216 | - if (is_numeric($value)) { | |
| 2217 | - $ret .= "{$key}:{$value}px;"; | |
| 2218 | - } else { | |
| 2219 | - $ret .= "{$key}:{$value};"; | |
| 2220 | - } | |
| 2221 | - if ($key == 'border-width') { | |
| 2222 | - $ret .= "border-style:solid;"; | |
| 2223 | - } | |
| 2224 | - } | |
| 2225 | - } | |
| 2226 | - return $ret; | |
| 2227 | -} | |
| 2228 | - | |
| 2229 | -add_action('accua_form_alter', 'accua_forms_form_generate', -999, 2); | |
| 2230 | -function accua_forms_form_generate($baseid, $form) { | |
| 2231 | - if (substr($baseid, 0, 14) == '__accua-form__') { | |
| 2232 | - $fid = substr($baseid,14); | |
| 2233 | - $form_data = _accua_forms_get_form_data($fid, false); | |
| 2234 | - /* | |
| 2235 | - echo '<!-- fid = '; | |
| 2236 | - print_r($fid); | |
| 2237 | - echo "\n\nform_data = "; | |
| 2238 | - print_r($form_data); | |
| 2239 | - echo "\n-->"; | |
| 2240 | - */ | |
| 2241 | - if ($form_data) { | |
| 2242 | - $form_style = _accua_forms_style_parameters(array( | |
| 2243 | - 'margin' => $form_data['style_margin'], | |
| 2244 | - 'border-color' => $form_data['style_border_color'], | |
| 2245 | - 'border-width' => $form_data['style_border_width'], | |
| 2246 | - 'border-radius' => $form_data['style_border_radius'], | |
| 2247 | - 'background' => $form_data['style_background_color'], | |
| 2248 | - 'padding' => $form_data['style_padding'], | |
| 2249 | - 'color' => $form_data['style_color'], | |
| 2250 | - 'font-size' => $form_data['style_font_size'], | |
| 2251 | - )); | |
| 2252 | - | |
| 2253 | - $field_style = _accua_forms_style_parameters(array( | |
| 2254 | - 'margin-bottom' => $form_data['style_field_spacing'], | |
| 2255 | - 'border-color' => $form_data['style_field_border_color'], | |
| 2256 | - 'border-width' => $form_data['style_field_border_width'], | |
| 2257 | - 'border-radius' => $form_data['style_field_border_radius'], | |
| 2258 | - 'background' => (trim($form_data['style_field_background_color']) === '')?'transparent':$form_data['style_field_background_color'], | |
| 2259 | - 'padding' => $form_data['style_field_padding'], | |
| 2260 | - 'color' => (trim($form_data['style_field_color']) === '')?$form_data['style_color']:$form_data['style_field_color'], | |
| 2261 | - 'font-size' => $form_data['style_font_size'], | |
| 2262 | - )); | |
| 2263 | - $field_properties = array(); | |
| 2264 | - if ($field_style !== '') { | |
| 2265 | - $field_properties['style'] = $field_style; | |
| 2266 | - } | |
| 2267 | - | |
| 2268 | - $submit_style = _accua_forms_style_parameters(array( | |
| 2269 | - 'border-color' => $form_data['style_submit_border_color'], | |
| 2270 | - 'border-width' => $form_data['style_submit_border_width'], | |
| 2271 | - 'border-radius' => $form_data['style_submit_border_radius'], | |
| 2272 | - 'background' => $form_data['style_submit_background_color'], | |
| 2273 | - 'padding' => $form_data['style_submit_padding'], | |
| 2274 | - 'color' => $form_data['style_submit_color'], | |
| 2275 | - 'font-size' => $form_data['style_submit_font_size'], | |
| 2276 | - )); | |
| 2277 | - $submit_properties = array(); | |
| 2278 | - if ($submit_style !== '') { | |
| 2279 | - $submit_properties['style'] = $submit_style; | |
| 2280 | - } | |
| 2281 | - | |
| 2282 | - if ($form_style !== '') { | |
| 2283 | - $form->configure(array('style' => $form_style)); | |
| 2284 | - } | |
| 2285 | - | |
| 2286 | - if (!empty($form_data['use_ajax'])){ | |
| 2287 | - $form->configure(array( | |
| 2288 | - "accua_ajax" => 1, | |
| 2289 | - )); | |
| 2290 | - } | |
| 2291 | - | |
| 2292 | - $add_submit = true; | |
| 2293 | - $avail_fields = get_option('accua_forms_avail_fields', array()); | |
| 2294 | - | |
| 2295 | - foreach ($form_data['fields'] as $istance_data) { | |
| 2296 | - | |
| 2297 | - if (empty($avail_fields[$istance_data['ref']])) { | |
| 2298 | - $field_data = array(); | |
| 2299 | - } else { | |
| 2300 | - $field_data = $avail_fields[$istance_data['ref']]; | |
| 2301 | - } | |
| 2302 | - | |
| 2303 | - $field_data += array( | |
| 2304 | - 'id' => '__html', | |
| 2305 | - 'name' => __( 'Custom HTML content', 'accua-form-api'), | |
| 2306 | - 'type' => 'html', | |
| 2307 | - 'description' => __('Use this special field to inject raw HTML in the form. You can use this multiple times.', 'accua-form-api'), | |
| 2308 | - 'default_value' => '', | |
| 2309 | - 'allowed_values' => '', | |
| 2310 | - ); | |
| 2311 | - | |
| 2312 | - $istance_data += array( | |
| 2313 | - 'istance_id' => $field_data['id'], | |
| 2314 | - 'widget_number' => '', | |
| 2315 | - 'ref' => $field_data['id'], | |
| 2316 | - 'label' => $field_data['name'], | |
| 2317 | - 'default_value' => $field_data['default_value'], | |
| 2318 | - 'allowed_values' => $field_data['allowed_values'], | |
| 2319 | - ); | |
| 2320 | - | |
| 2321 | - $element = null; | |
| 2322 | - | |
| 2323 | - $allowed_val = trim($istance_data['allowed_values']); | |
| 2324 | - | |
| 2325 | - | |
| 2326 | - if ($field_data['type'] == 'post-multicheckbox') { | |
| 2327 | - $posts = accua_get_pages($allowed_val); | |
| 2328 | - $allowed_values = array(); | |
| 2329 | - foreach ($posts as $p) { | |
| 2330 | - //$allowed_values[$p->ID] = apply_filters( 'the_title', $p->post_title, $p->ID ); | |
| 2331 | - $allowed_values[$p->ID] = $p->post_title; | |
| 2332 | - } | |
| 2333 | - } else { | |
| 2334 | - if ($field_data['type'] == 'file') { | |
| 2335 | - $filedata = get_option('accua_forms_default_file_field_data',array()); | |
| 2336 | - $filedata += array( | |
| 2337 | - 'valid_extensions' => '', | |
| 2338 | - 'max_filesize' => '', | |
| 2339 | - 'dest_path' => '', | |
| 2340 | - ); | |
| 2341 | - if ($allowed_val == '') { | |
| 2342 | - $allowed_val = trim($filedata['valid_extensions']); | |
| 2343 | - } | |
| 2344 | - } | |
| 2345 | - | |
| 2346 | - $allowed_val = explode("\n",$allowed_val); | |
| 2347 | - $allowed_values = array(); | |
| 2348 | - foreach ($allowed_val as $val) { | |
| 2349 | - $val = explode('|',$val,2); | |
| 2350 | - $val[0] = trim($val[0]); | |
| 2351 | - /* | |
| 2352 | - if (empty($val[0])) { | |
| 2353 | - continue; | |
| 2354 | - } | |
| 2355 | - */ | |
| 2356 | - if ((!isset($val[1])) || (trim($val[1])==='')) { | |
| 2357 | - if ($val[0] === '') { | |
| 2358 | - continue; | |
| 2359 | - } else { | |
| 2360 | - $val[1] = $val[0]; | |
| 2361 | - } | |
| 2362 | - } | |
| 2363 | - $allowed_values[$val[0]] = $val[1]; | |
| 2364 | - } | |
| 2365 | - } | |
| 2366 | - | |
| 2367 | - switch ($field_data['type']) { | |
| 2368 | - case 'textarea': | |
| 2369 | - $element = new Element_Textarea($istance_data['label'], $istance_data['istance_id'], $field_properties+array('cols' => '50')); | |
| 2370 | - break; | |
| 2371 | - case 'hidden': | |
| 2372 | - $element = new Element_Hidden($istance_data['istance_id'], $istance_data['default_value']); | |
| 2373 | - break; | |
| 2374 | - case 'checkbox': | |
| 2375 | - $val = empty($istance_data['default_value'])?'1':$istance_data['default_value']; | |
| 2376 | - $lab = $istance_data['label']; | |
| 2377 | - if (!empty($istance_data['required'])) { | |
| 2378 | - $lab .= ' <strong>*</strong>'; | |
| 2379 | - } | |
| 2380 | - $element = new AccuaForm_Element_Checkbox('', $istance_data['istance_id'], array($val => $lab)); | |
| 2381 | - break; | |
| 2382 | - case 'select': | |
| 2383 | - if (!isset($allowed_values[''])) { | |
| 2384 | - $allowed_values = array('' => '') + $allowed_values; | |
| 2385 | - } | |
| 2386 | - $element = new Element_Select($istance_data['label'], $istance_data['istance_id'], $allowed_values, $field_properties); | |
| 2387 | - break; | |
| 2388 | - case 'radio': | |
| 2389 | - $element = new AccuaForm_Element_Radio($istance_data['label'], $istance_data['istance_id'], $allowed_values); | |
| 2390 | - break; | |
| 2391 | - case 'multiselect': | |
| 2392 | - $element = new Element_Select($istance_data['label'], $istance_data['istance_id'], $allowed_values, $field_properties+array('multiple' => true)); | |
| 2393 | - break; | |
| 2394 | - case 'multicheckbox': | |
| 2395 | - $element = new AccuaForm_Element_Checkbox($istance_data['label'], $istance_data['istance_id'], $allowed_values); | |
| 2396 | - case 'post-multicheckbox': | |
| 2397 | - $element = new AccuaForm_Element_Checkbox($istance_data['label'], $istance_data['istance_id'], $allowed_values); | |
| 2398 | - break; | |
| 2399 | - case 'file': | |
| 2400 | - $fdata = array(); | |
| 2401 | - | |
| 2402 | - if ($allowed_values) { | |
| 2403 | - $fdata['validExtensions'] = array_keys($allowed_values); | |
| 2404 | - } | |
| 2405 | - | |
| 2406 | - if ($filedata['max_size'] !== ''){ | |
| 2407 | - $fdata['maxSize'] = $filedata['max_size']; | |
| 2408 | - } | |
| 2409 | - | |
| 2410 | - $fdata['destPath'] = _accua_forms_get_abs_dest_path($filedata['dest_path']); | |
| 2411 | - | |
| 2412 | - $element = new AccuaForm_Element_File($istance_data['label'], $istance_data['istance_id'], $field_properties+$fdata); | |
| 2413 | - break; | |
| 2414 | - case 'html': | |
| 2415 | - $element = new Element_HTML($istance_data['default_value']); | |
| 2416 | - break; | |
| 2417 | - case 'email': | |
| 2418 | - case 'autoreply_email': | |
| 2419 | - $element = new AccuaForm_Element_Email($istance_data['label'], $istance_data['istance_id'], $field_properties); | |
| 2420 | - $element->setValidation(new Validation_Email( | |
| 2421 | - str_replace('%element%', $istance_data['label'], __("Attention: '%element%' must contain an email address.", 'accua-form-api')) | |
| 2422 | - )); | |
| 2423 | - //"Errore: '{$istance_data['label']}' deve contenere un indirizzo email valido." | |
| 2424 | - break; | |
| 2425 | - case 'submit': | |
| 2426 | - $add_submit = false; | |
| 2427 | - $element = new Element_Button($istance_data['label'], 'submit', $submit_properties+array('name' => $istance_data['istance_id'], 'value' => $istance_data['default_value'])); | |
| 2428 | - break; | |
| 2429 | - case 'captcha': | |
| 2430 | - $element = new AccuaForm_Element_Captcha ($istance_data['label'], array("description" => "")); | |
| 2431 | - break; | |
| 2432 | - case 'password': | |
| 2433 | - $element = new Element_Password($istance_data['label'], $istance_data['istance_id'], $field_properties); | |
| 2434 | - break; | |
| 2435 | - case 'password-and-confirm': | |
| 2436 | - $id_2 = "___{$istance_data['istance_id']}___confirmpass"; | |
| 2437 | - $element = new Element_Password(__("Password", 'accua-form-api'), $istance_data['istance_id'], $field_properties); | |
| 2438 | - $element_conf = new Element_Password(__("Confirm password", 'accua-form-api'), $id_2, $field_properties); | |
| 2439 | - $element_conf->setValidation(new AccuaForm_Validation_Password()); | |
| 2440 | - break; | |
| 2441 | - //case 'textfield': | |
| 2442 | - default: | |
| 2443 | - $element = new Element_Textbox($istance_data['label'], $istance_data['istance_id'], $field_properties); | |
| 2444 | - break; | |
| 2445 | - } | |
| 2446 | - | |
| 2447 | - if (!empty($istance_data['required'])) { | |
| 2448 | - $element->setClass('accuaforms-field-required'); | |
| 2449 | - if($field_data['type']!='password-and-confirm') { | |
| 2450 | - $element->setValidation(new Validation_Required( | |
| 2451 | - str_replace('%element%', $istance_data['label'], __("Attention: '%element%' is a required field.", 'accua-form-api')) | |
| 2452 | - )); | |
| 2453 | - } else { | |
| 2454 | - $element->setValidation(new Validation_Required( | |
| 2455 | - str_replace('%element%', $istance_data['label'], __("Attention: Passwords are required fields.", 'accua-form-api')) | |
| 2456 | - )); | |
| 2457 | - } | |
| 2458 | - } | |
| 2459 | - | |
| 2460 | - if ($elementName = $element->getName()) { | |
| 2461 | - $element->setClass('accuaform-fieldname-'.$elementName); | |
| 2462 | - } | |
| 2463 | - | |
| 2464 | - if ($field_data['type']) { | |
| 2465 | - $element->setClass('accuaform-fieldtype-'.$field_data['type']); | |
| 2466 | - } | |
| 2467 | - | |
| 2468 | - $form->addElement($element); | |
| 2469 | - if($element_conf!=NULL) { | |
| 2470 | - $form->addElement($element_conf); | |
| 2471 | - $element_conf=NULL; | |
| 2472 | - } | |
| 2473 | - } | |
| 2474 | - | |
| 2475 | - if ($add_submit) { | |
| 2476 | - $form->addElement(new Element_Button(__('Submit', 'accua-form-api'), 'submit', $submit_properties)); | |
| 2477 | - } | |
| 2478 | - } | |
| 2479 | - | |
| 2480 | - } | |
| 2481 | -} | |
| 2482 | - | |
| 2483 | -function accua_forms_aggregate_submitted_data(&$replace_map, $params = array()) { | |
| 2484 | - if (empty($params['txt']) && empty($params['html']) && empty($params['json']) && empty($params['email'])) { | |
| 2485 | - $params += array( | |
| 2486 | - 'txt' => true, | |
| 2487 | - 'html' => true, | |
| 2488 | - 'json' => true, | |
| 2489 | - 'email' => true, | |
| 2490 | - ); | |
| 2491 | - } | |
| 2492 | - | |
| 2493 | - if (!empty($params['txt'])) { | |
| 2494 | - $replace_map['__submitted_txt'] = implode("\n",$replace_map['__submitted_txt_raw']); | |
| 2495 | - } | |
| 2496 | - if (!empty($params['html'])) { | |
| 2497 | - $replace_map['__submitted_html'] = implode('</td></tr><tr><td>',$replace_map['__submitted_html_raw']); | |
| 2498 | - } | |
| 2499 | - if (!empty($params['json'])) { | |
| 2500 | - $replace_map['__submitted_json'] = json_encode($replace_map['__submitted_json_raw']); | |
| 2501 | - } | |
| 2502 | - if (!empty($params['email'])) { | |
| 2503 | - $replace_map['__autoreply_email'] = implode('; ', $replace_map['__autoreply_email_raw']); | |
| 2504 | - } | |
| 2505 | - | |
| 2506 | -} | |
| 2507 | - | |
| 2508 | -add_filter('accua_form_validate', 'accua_forms_validation_handler', 10, 4); | |
| 2509 | -function accua_forms_validation_handler($valid, $submittedID, $submittedData, $form){ | |
| 2510 | - if (substr($submittedID, 0, 14) == '__accua-form__') { | |
| 2511 | - $fid = substr($submittedID,14); | |
| 2512 | - $form_data = _accua_forms_get_form_data($fid, false); | |
| 2513 | - if ($form_data) { | |
| 2514 | - return apply_filters('accua_forms_validation', $valid, $fid, $submittedData, $form); | |
| 2515 | - } | |
| 2516 | - } | |
| 2517 | - return $valid; | |
| 2518 | -} | |
| 2519 | - | |
| 2520 | -add_action('accua_form_submit', 'accua_forms_form_submission_handler', -10, 3); | |
| 2521 | -function accua_forms_form_submission_handler($submittedID, $submittedData, $form) { | |
| 2522 | - if ( empty( $GLOBALS['wp_rewrite'] ) ) | |
| 2523 | - $GLOBALS['wp_rewrite'] = new WP_Rewrite(); | |
| 2524 | - | |
| 2525 | - if (!class_exists('AccuaConditionalReplacer')){ | |
| 2526 | - require_once('AccuaConditionalReplacer.php'); | |
| 2527 | - } | |
| 2528 | - if (substr($submittedID, 0, 14) == '__accua-form__') { | |
| 2529 | - $fid = substr($submittedID,14); | |
| 2530 | - $form_data = _accua_forms_get_form_data($fid, false); | |
| 2531 | - if ($form_data) { | |
| 2532 | - global $wpdb; | |
| 2533 | - | |
| 2534 | - $time = time(); | |
| 2535 | - | |
| 2536 | - $wpdb->insert( | |
| 2537 | - $wpdb->prefix . 'accua_forms_submissions', | |
| 2538 | - array ( | |
| 2539 | - 'afs_form_id' => $fid, | |
| 2540 | - 'afs_post_id' => $form->stats['pid'], | |
| 2541 | - 'afs_ip' => $form->stats['ip'], | |
| 2542 | - 'afs_uri' => $form->stats['uri'], | |
| 2543 | - 'afs_referrer' => $form->stats['referrer'], | |
| 2544 | - 'afs_lang' => $form->stats['lang'], | |
| 2545 | - 'afs_created' => gmdate('Y-m-d H:i:s', $form->stats['created']), | |
| 2546 | - 'afs_submitted' => gmdate('Y-m-d H:i:s', $time), | |
| 2547 | - 'afs_stats' => json_encode(array( | |
| 2548 | - 'user_agent' => $form->stats['user_agent'], | |
| 2549 | - 'platform' => $form->stats['platform'], | |
| 2550 | - 'tentatives' => $form->stats['tentatives'], | |
| 2551 | - 'submit_method' => $form->stats['submit_method'], | |
| 2552 | - )), | |
| 2553 | - ) | |
| 2554 | - ); | |
| 2555 | - | |
| 2556 | - $submission_id = $form->stats['submission_id'] = $wpdb->insert_id; | |
| 2557 | - | |
| 2558 | - | |
| 2559 | - | |
| 2560 | - $replace_map = array( | |
| 2561 | - '__fid' => $fid, | |
| 2562 | - '__subid' => $submission_id, | |
| 2563 | - '__pid' => $form->stats['pid'], | |
| 2564 | - '__ip' => $form->stats['ip'], | |
| 2565 | - '__uri' => $form->stats['uri'], | |
| 2566 | - '__url' => $form->stats['url'], | |
| 2567 | - '__referrer' => $form->stats['referrer'], | |
| 2568 | - '__lang' => $form->stats['lang'], | |
| 2569 | - '__locale' => $form->stats['locale'], | |
| 2570 | - '__created' => $form->stats['created'], | |
| 2571 | - '__created_day' => date('l j F Y', $form->stats['created']), | |
| 2572 | - '__created_day_month_year' => date('j F Y', $form->stats['created']), | |
| 2573 | - '__created_hour' => date('G:i', $form->stats['created']), | |
| 2574 | - '__submitted' => $time, | |
| 2575 | - '__submitted_day' => date('l j F Y', $time), | |
| 2576 | - '__submitted_day_month_year' => date('j F Y', $time), | |
| 2577 | - '__submitted_hour' => date('G:i', $time), | |
| 2578 | - '__confirmation_emails_message' => $form_data['confirmation_emails_message'], | |
| 2579 | - '__user_agent' => $form->stats['user_agent'], | |
| 2580 | - '__platform' => $form->stats['platform'], | |
| 2581 | - '__tentatives' => $form->stats['tentatives'], | |
| 2582 | - '__submit_method' => $form->stats['submit_method'], | |
| 2583 | - ); | |
| 2584 | - | |
| 2585 | - $avail_fields = get_option('accua_forms_avail_fields', array()); | |
| 2586 | - | |
| 2587 | - $replace_map['__autoreply_email_raw'] = array(); | |
| 2588 | - $replace_map['__submitted_txt_raw'] = array(); | |
| 2589 | - $replace_map['__submitted_html_raw'] = array(); | |
| 2590 | - $replace_map['__submitted_json_raw'] = array(); | |
| 2591 | - | |
| 2592 | - $_field_data = array(); | |
| 2593 | - $_istance_data = array(); | |
| 2594 | - | |
| 2595 | - foreach ($submittedData as $istance_id => $value) { | |
| 2596 | - if (empty($form_data['fields'][$istance_id])) { | |
| 2597 | - continue; | |
| 2598 | - } | |
| 2599 | - $istance_data = $form_data['fields'][$istance_id]; | |
| 2600 | - | |
| 2601 | - if (empty($avail_fields[$istance_data['ref']])) { | |
| 2602 | - $field_data = array(); | |
| 2603 | - } else { | |
| 2604 | - $field_data = $avail_fields[$istance_data['ref']]; | |
| 2605 | - } | |
| 2606 | - | |
| 2607 | - $field_data += array( | |
| 2608 | - 'id' => '__html', | |
| 2609 | - 'name' => __( 'Custom HTML content', 'accua-form-api'), | |
| 2610 | - 'type' => 'html', | |
| 2611 | - 'description' => __( 'Use this special field to inject raw HTML in the form. You can use this multiple times.', 'accua-form-api'), | |
| 2612 | - 'default_value' => '', | |
| 2613 | - 'allowed_values' => '', | |
| 2614 | - ); | |
| 2615 | - | |
| 2616 | - /* | |
| 2617 | - echo "<!-- istance_data: " | |
| 2618 | - , print_r($istance_data, true) | |
| 2619 | - , "\nfield_data: " | |
| 2620 | - , print_r($field_data, true) | |
| 2621 | - , "\nvalue: " | |
| 2622 | - , print_r($value, true) | |
| 2623 | - , "\n-->\n"; | |
| 2624 | - */ | |
| 2625 | - | |
| 2626 | - $istance_data += array( | |
| 2627 | - 'istance_id' => $field_data['id'], | |
| 2628 | - 'widget_number' => '', | |
| 2629 | - 'ref' => $field_data['id'], | |
| 2630 | - 'label' => $field_data['name'], | |
| 2631 | - 'default_value' => $field_data['default_value'], | |
| 2632 | - 'allowed_values' => $field_data['allowed_values'], | |
| 2633 | - ); | |
| 2634 | - | |
| 2635 | - switch ($field_data['type']) { | |
| 2636 | - case 'checkbox': | |
| 2637 | - case 'submit': | |
| 2638 | - if (empty($value)) { | |
| 2639 | - $replace_map[$istance_data['istance_id']] = $value = ''; | |
| 2640 | - } else { | |
| 2641 | - if (empty($istance_data['default_value'])) { | |
| 2642 | - $replace_map[$istance_data['istance_id']] = 'Checked'; | |
| 2643 | - $value = '1'; | |
| 2644 | - } else { | |
| 2645 | - $replace_map[$istance_data['istance_id']] = $value = $istance_data['default_value']; | |
| 2646 | - } | |
| 2647 | - } | |
| 2648 | - break; | |
| 2649 | - case 'multiselect': | |
| 2650 | - case 'multicheckbox': | |
| 2651 | - $replace_map[$istance_data['istance_id']] = implode(', ',$value); | |
| 2652 | - $value = implode('|',$value); | |
| 2653 | - break; | |
| 2654 | - case 'post-multicheckbox': | |
| 2655 | - $el = $form->getElementByName($istance_id); | |
| 2656 | - $opts = $el->getOptions(); | |
| 2657 | - $value2 = array(); | |
| 2658 | - foreach ($value as $val) { | |
| 2659 | - if (isset($opts[$val])) { | |
| 2660 | - $value2[] = $val . ': ' . trim(preg_replace('/[\s\n\r]+/', ' ', $opts[$val])); | |
| 2661 | - } | |
| 2662 | - } | |
| 2663 | - $replace_map[$istance_data['istance_id']] = $value = implode("\n", $value2); | |
| 2664 | - break; | |
| 2665 | - /* | |
| 2666 | - case 'file': | |
| 2667 | - //URL to file, or attach | |
| 2668 | - break; | |
| 2669 | - */ | |
| 2670 | - case 'autoreply_email': | |
| 2671 | - if ($value !== '') { | |
| 2672 | - $replace_map['__autoreply_email_raw'][] = $value; | |
| 2673 | - } | |
| 2674 | - $replace_map[$istance_data['istance_id']] = $value; | |
| 2675 | - break; | |
| 2676 | - case 'file': | |
| 2677 | - //TODO: move temp file to "{$submission_id}_{$field_data['id']}_{$file['name']}"; value is $file['name'] | |
| 2678 | - $buildid = $submittedData['_AccuaForm_buildID']; | |
| 2679 | - $file_download_url = ''; | |
| 2680 | - $file = $form->getFile($istance_id); | |
| 2681 | - if ($value !== null && $value !== '' && $file) { | |
| 2682 | - if ($form->renameFile($istance_id, "{$submission_id}_{$field_data['id']}_{$file['name']}")) { | |
| 2683 | - $urlfield = rawurlencode($istance_data['istance_id']); | |
| 2684 | - $urlfile = rawurlencode($value); | |
| 2685 | - $file_download_url = admin_url('admin-ajax.php') . "?action=accua_forms_download_submitted_file&subid={$submission_id}&field={$urlfield}&file={$urlfile}"; | |
| 2686 | - } | |
| 2687 | - } | |
| 2688 | - $replace_map[$istance_data['istance_id']] = $value; | |
| 2689 | - $replace_map['__download_'.$istance_data['istance_id']] = $file_download_url; | |
| 2690 | - break; | |
| 2691 | - default: | |
| 2692 | - $replace_map[$istance_data['istance_id']] = $value; | |
| 2693 | - } | |
| 2694 | - | |
| 2695 | - switch ($field_data['type']) { | |
| 2696 | - case 'file': | |
| 2697 | - $replace_map['__submitted_txt_raw'][$istance_data['istance_id']] = "{$istance_data['istance_id']}\t$value\t$file_download_url"; | |
| 2698 | - $replace_map['__submitted_json_raw'][$istance_data['istance_id']] = "$value\t$file_download_url"; | |
| 2699 | - $replace_map['__submitted_html_raw'][$istance_data['istance_id']] = "<strong>{$istance_data['istance_id']}</strong></td><td class='valori_submitted'><a href='".htmlspecialchars($file_download_url,ENT_QUOTES)."'>".htmlspecialchars($value)."</a>"; | |
| 2700 | - break; | |
| 2701 | - | |
| 2702 | - case 'email': | |
| 2703 | - case 'autoreply_email': | |
| 2704 | - $replace_map['__submitted_txt_raw'][$istance_data['istance_id']] = "{$istance_data['istance_id']}\t$value"; | |
| 2705 | - $replace_map['__submitted_json_raw'][$istance_data['istance_id']] = $value; | |
| 2706 | - $replace_map['__submitted_html_raw'][$istance_data['istance_id']] = "<strong>{$istance_data['istance_id']}</strong></td><td class='valori_submitted'><a href='mailto:".htmlspecialchars($value,ENT_QUOTES)."'>".htmlspecialchars($value)."</a>"; | |
| 2707 | - break; | |
| 2708 | - case 'submit': | |
| 2709 | - break; | |
| 2710 | - default: | |
| 2711 | - $replace_map['__submitted_txt_raw'][$istance_data['istance_id']] = "{$istance_data['istance_id']}\t$value"; | |
| 2712 | - $replace_map['__submitted_json_raw'][$istance_data['istance_id']] = $value; | |
| 2713 | - $replace_map['__submitted_html_raw'][$istance_data['istance_id']] = "<strong>{$istance_data['istance_id']}</strong></td><td class='valori_submitted'>".htmlspecialchars($value); | |
| 2714 | - } | |
| 2715 | - | |
| 2716 | - $wpdb->insert( | |
| 2717 | - $wpdb->prefix . 'accua_forms_submissions_values', | |
| 2718 | - array ( | |
| 2719 | - 'afsv_sub_id' => $submission_id, | |
| 2720 | - 'afsv_field_id' => $istance_data['istance_id'], | |
| 2721 | - 'afsv_type' => $field_data['type'], | |
| 2722 | - 'afsv_value' => $value, | |
| 2723 | - ), | |
| 2724 | - array('%d','%s','%s','%s') | |
| 2725 | - ); | |
| 2726 | - | |
| 2727 | - $_field_data[$istance_data['istance_id']] = $field_data; | |
| 2728 | - $_istance_data[$istance_data['istance_id']] = $istance_data; | |
| 2729 | - | |
| 2730 | - } | |
| 2731 | - | |
| 2732 | - $replace_map['__autoreply'] = (bool) ($replace_map['__autoreply_email_raw'] | |
| 2733 | - && $form_data['confirmation_emails_subject'] | |
| 2734 | - && $form_data['confirmation_emails_message']); | |
| 2735 | - | |
| 2736 | - accua_forms_aggregate_submitted_data($replace_map); | |
| 2737 | - | |
| 2738 | - //Older undocumented filter, maintained for backward compatibility. In fact filter accua_forms_form_submission_handler is called before accua_forms_submission, but for the rest they are the same | |
| 2739 | - $replace_map = apply_filters('accua_forms_form_submission_handler', $replace_map, $fid, $submittedData, $form, $_field_data, $_istance_data); | |
| 2740 | - | |
| 2741 | - //Newer filter, with an easier name | |
| 2742 | - $replace_map = apply_filters('accua_forms_submission', $replace_map, $fid, $submittedData, $form, $_field_data, $_istance_data); | |
| 2743 | - | |
| 2744 | - $replace_map['__submitted_html'] = $submitted_html = '<table><tr><td>' . $replace_map['__submitted_html'] . '</td></tr></table>'; | |
| 2745 | - unset($replace_map['__submitted_txt_raw'], $replace_map['__submitted_html_raw'], $replace_map['__submitted_json_raw'], $replace_map['__autoreply_email_raw']); | |
| 2746 | - | |
| 2747 | - $replacer = new AccuaConditionalReplacer($replace_map); | |
| 2748 | - | |
| 2749 | - $confirmation_emails_message = $replace_map['__confirmation_emails_message']; | |
| 2750 | - | |
| 2751 | - unset($replace_map['__submitted_html'], $replace_map['__confirmation_emails_message']); | |
| 2752 | - foreach($replace_map as $key => $value) { | |
| 2753 | - $replace_map[$key] = htmlspecialchars($value, ENT_QUOTES); | |
| 2754 | - } | |
| 2755 | - $replace_map['__submitted_html'] = $submitted_html; | |
| 2756 | - | |
| 2757 | - $replacer_html = new AccuaConditionalReplacer($replace_map); | |
| 2758 | - | |
| 2759 | - $confirmation_emails_message = $replacer_html->doReplace($confirmation_emails_message); | |
| 2760 | - $replacer_html->appendPattern(array('__confirmation_emails_message' => $confirmation_emails_message)); | |
| 2761 | - | |
| 2762 | - $form_data_replaced = array(); | |
| 2763 | - | |
| 2764 | - $settings = array( | |
| 2765 | - 'emails_from', | |
| 2766 | - 'admin_emails_to', | |
| 2767 | - 'emails_bcc', | |
| 2768 | - 'admin_emails_subject', | |
| 2769 | - 'confirmation_emails_subject', | |
| 2770 | - ); | |
| 2771 | - | |
| 2772 | - foreach($settings as $i) { | |
| 2773 | - $form_data_replaced[$i] = $replacer->doReplace($form_data[$i]); | |
| 2774 | - } | |
| 2775 | - | |
| 2776 | - $settings_html = array( | |
| 2777 | - 'success_message', | |
| 2778 | - 'admin_emails_message', | |
| 2779 | - ); | |
| 2780 | - | |
| 2781 | - foreach($settings_html as $i) { | |
| 2782 | - $form_data_replaced[$i] = $replacer_html->doReplace($form_data[$i]); | |
| 2783 | - } | |
| 2784 | - | |
| 2785 | - AccuaForm::appendSubmittedMessages(wpautop($form_data_replaced['success_message'])); | |
| 2786 | - | |
| 2787 | - $header = array("Content-Type: text/html; charset=".get_option('blog_charset')); | |
| 2788 | - | |
| 2789 | - | |
| 2790 | - if ($form_data_replaced['emails_from']) { | |
| 2791 | - $header[] = 'From: '.$form_data_replaced['emails_from']; | |
| 2792 | - } | |
| 2793 | - | |
| 2794 | - if ($form_data_replaced['emails_bcc']) { | |
| 2795 | - $header[] = 'Bcc: '.$form_data_replaced['emails_bcc']; | |
| 2796 | - } | |
| 2797 | - | |
| 2798 | - if ($form_data_replaced['admin_emails_to'] | |
| 2799 | - && $form_data_replaced['admin_emails_subject']) { | |
| 2800 | - /* | |
| 2801 | - $admin_tos = explode(',', strtr($form_data_replaced['admin_emails_to'], "\n\t\r;", ',,,,')); | |
| 2802 | - foreach ($admin_tos as $admin_to) { | |
| 2803 | - $mail1 = wp_mail(trim($admin_to), $form_data_replaced['admin_emails_subject'], $form_data_replaced['admin_emails_message'], $header); | |
| 2804 | - } | |
| 2805 | - */ | |
| 2806 | - $mail1 = wp_mail($form_data_replaced['admin_emails_to'], $form_data_replaced['admin_emails_subject'],'<html><head></head><body style="background:#f9f8f8;font-size: 12px;font-family: "Lucida Sans","Lucida Grande", Verdana, Arial, Sans-Serif;"">'.wpautop($form_data_replaced['admin_emails_message']).'</body></html>', $header); | |
| 2807 | - } | |
| 2808 | - | |
| 2809 | - if ($replace_map['__autoreply'] && $replace_map['__autoreply_email'] | |
| 2810 | - && $form_data_replaced['confirmation_emails_subject'] | |
| 2811 | - && $confirmation_emails_message) { | |
| 2812 | - $mail2 = wp_mail($replace_map['__autoreply_email'], $form_data_replaced['confirmation_emails_subject'], '<html><head></head><body>'.wpautop($confirmation_emails_message).'</body></html>', $header); | |
| 2813 | - } | |
| 2814 | - | |
| 2815 | - /* | |
| 2816 | - echo "<!-- replace_map: " | |
| 2817 | - , print_r($replace_map, true) | |
| 2818 | - , "\nreplace_map: " | |
| 2819 | - , print_r($replace_map, true) | |
| 2820 | - , "\nform_data_replaced: " | |
| 2821 | - , print_r($form_data_replaced, true) | |
| 2822 | - , "\nautoreply_email: " | |
| 2823 | - , print_r($autoreply_email, true) | |
| 2824 | - , "\nmail1: " | |
| 2825 | - , print_r($mail1, true) | |
| 2826 | - , "\nmail2: " | |
| 2827 | - , print_r($mail2, true) | |
| 2828 | - ,"\n-->"; | |
| 2829 | - */ | |
| 2830 | - } | |
| 2831 | - } | |
| 2832 | -} | |
| 2833 | - | |
| 2834 | -function accua_forms_get_submission_data($subid, $options = array()){ | |
| 2835 | - //TODO: Completa e usa per sostituire i campi | |
| 2836 | - global $wpdb; | |
| 2837 | - $subid = (int) $subid; | |
| 2838 | - $options += array( | |
| 2839 | - 'extra' => true, | |
| 2840 | - 'file_format' => 'name', | |
| 2841 | - ); | |
| 2842 | - $ret = array(); | |
| 2843 | - if ($options['extra']) { | |
| 2844 | - $query1 = "SELECT * | |
| 2845 | - FROM `{$wpdb->prefix}accua_forms_submissions` | |
| 2846 | - WHERE afs_id = $subid"; | |
| 2847 | - $data = $wpdb->get_row($query1); | |
| 2848 | - if (!empty($data)) { | |
| 2849 | - $created = $data->afs_created; | |
| 2850 | - $created[10] = 'T'; | |
| 2851 | - $created.='.00+00:00'; | |
| 2852 | - $created = strtotime($created); | |
| 2853 | - $submitted = $data->afs_submitted; | |
| 2854 | - $submitted[10] = 'T'; | |
| 2855 | - $submitted.='.00+00:00'; | |
| 2856 | - $submitted = strtotime($submitted); | |
| 2857 | - $ret += array( | |
| 2858 | - '__fid' => $data->afs_form_id, | |
| 2859 | - '__subid' => $subid, | |
| 2860 | - '__pid' => $data->afs_post_id, | |
| 2861 | - '__ip' => $data->afs_id, | |
| 2862 | - '__uri' => $data->afs_uri, | |
| 2863 | - '__referrer' => $data->afs_referrer, | |
| 2864 | - '__lang' => $data->afs_lang, | |
| 2865 | - '__created' => $created, | |
| 2866 | - '__created_day' => date('l j F Y', $created), | |
| 2867 | - '__created_hour' => date('G:i', $created), | |
| 2868 | - '__submitted' => $submitted, | |
| 2869 | - '__submitted_day' => date('l j F Y', $submitted), | |
| 2870 | - '__submitted_hour' => date('G:i', $submitted), | |
| 2871 | - ); | |
| 2872 | - } | |
| 2873 | - } | |
| 2874 | - | |
| 2875 | - $query2 = "SELECT * | |
| 2876 | - FROM `{$wpdb->prefix}accua_forms_submissions_values` | |
| 2877 | - WHERE afsv_sub_id = $subid"; | |
| 2878 | - | |
| 2879 | - $data2 = $wpdb->get_results($query2, OBJECT); | |
| 2880 | - | |
| 2881 | - foreach ($data2 as $row) { | |
| 2882 | - switch ($row->afsv_type) { | |
| 2883 | - case 'file' : | |
| 2884 | - if ($options['file_format'] == 'url' || $options['file_format'] == 'link') { | |
| 2885 | - $fieldid = rawurlencode($row->afsv_field_id); | |
| 2886 | - $filename = rawurlencode($row->afsv_value); | |
| 2887 | - $url = admin_url('admin-ajax.php') . "?action=accua_forms_download_submitted_file&subid={$row->afsv_sub_id}&field={$fieldid}&file={$filename}"; | |
| 2888 | - if ($options['file_format'] == 'url'){ | |
| 2889 | - $url = htmlspecialchars($url,ENT_QUOTES); | |
| 2890 | - $filename = htmlspecialchars($row->afsv_value,ENT_QUOTES); | |
| 2891 | - $fielddata = "<a href='{$url}' target='_blank'>{$filename}</a>"; | |
| 2892 | - } else { | |
| 2893 | - $fielddata = $url; | |
| 2894 | - } | |
| 2895 | - } else { // $options['file_format'] == 'name' | |
| 2896 | - $fielddata = $row->afsv_value; | |
| 2897 | - } | |
| 2898 | - break; | |
| 2899 | - default: | |
| 2900 | - $fielddata = $row->afsv_value; | |
| 2901 | - } | |
| 2902 | - $ret[$row->afsv_field_id] = $fielddata; | |
| 2903 | - } | |
| 2904 | - return $ret; | |
| 2905 | -} | |
| 2906 | - | |
| 2907 | -add_shortcode( 'accua-form', 'accua_forms_shortcode_handler' ); | |
| 2908 | -function accua_forms_shortcode_handler($atts, $content = '', $code = '') { | |
| 2909 | - if (empty($atts['fid'])) { | |
| 2910 | - return ''; | |
| 2911 | - } | |
| 2912 | - | |
| 2913 | - $fid = $atts['fid']; | |
| 2914 | - $form_data = _accua_forms_get_form_data($fid, false); | |
| 2915 | - | |
| 2916 | - if (! $form_data) { | |
| 2917 | - return ''; | |
| 2918 | - } | |
| 2919 | - | |
| 2920 | - $fid = '__accua-form__'.$fid; | |
| 2921 | - | |
| 2922 | - $out = ''; | |
| 2923 | - | |
| 2924 | - if (AccuaForm::getSubmittedID() == $fid) { | |
| 2925 | - /* return "<pre>Form submitted.\n\nData: " . print_r(AccuaForm::getSubmittedData(), true) . '</pre>'; */ | |
| 2926 | - $messages = AccuaForm::getSubmittedMessages(); | |
| 2927 | - if ($messages) { | |
| 2928 | - $out .= '<div id="_response_messages_'.$fid.'" class="accua-form-messages">'.$messages.'</div>'; | |
| 2929 | - } | |
| 2930 | - if (AccuaForm::isValid()) { | |
| 2931 | - return $out; | |
| 2932 | - } | |
| 2933 | - $form = AccuaForm::getSubmittedForm(); | |
| 2934 | - } else { | |
| 2935 | - $form = AccuaForm::create($fid, array('layout'=>$form_data['layout'])); | |
| 2936 | - } | |
| 2937 | - | |
| 2938 | - return $out . $form->render(true); | |
| 2939 | -} | |
| 2940 | - | |
| 2941 | -function accua_forms_include($fid, $atts=array(), $content = '', $code = '') { | |
| 2942 | - $atts['fid'] = $fid; | |
| 2943 | - echo accua_forms_shortcode_handler($atts, $content, $code); | |
| 2944 | -} | |
| 2945 | - | |
| 2946 | -function accua_forms_submissions_list_page_head(){ | |
| 2947 | - require_once('accua-forms-submissions-page.php'); | |
| 2948 | - accua_forms_submissions_list_page(true); | |
| 2949 | -} | |
| 2950 | - | |
| 2951 | -add_action('wp_ajax_accua_forms_download_submitted_file', 'accua_forms_download_submitted_file'); | |
| 2952 | -add_action('wp_ajax_nopriv_accua_forms_download_submitted_file', 'accua_forms_download_submitted_file'); | |
| 2953 | -function accua_forms_download_submitted_file(){ | |
| 2954 | - $get = stripslashes_deep($_GET); | |
| 2955 | - if (isset($get['subid'],$get['field'],$get['file'])) { | |
| 2956 | - global $wpdb; | |
| 2957 | - $subid = (int) $get['subid']; | |
| 2958 | - $field = $get['field']; | |
| 2959 | - $file = $get['file']; | |
| 2960 | - $query = "SELECT * | |
| 2961 | - FROM `{$wpdb->prefix}accua_forms_submissions_values` | |
| 2962 | - WHERE afsv_sub_id = %d | |
| 2963 | - AND afsv_field_id = %s | |
| 2964 | - AND afsv_value = %s | |
| 2965 | - "; | |
| 2966 | - $query = $wpdb->prepare($query, $subid, $field, $file); | |
| 2967 | - $subval = $wpdb->get_results($query, OBJECT); | |
| 2968 | - if ($subval) { | |
| 2969 | - $file_data = get_option('accua_forms_default_file_field_data',array()) + array('dest_path' => ''); | |
| 2970 | - $dest_path = _accua_forms_get_abs_dest_path($file_data['dest_path']); | |
| 2971 | - $filename = "{$dest_path}/{$subid}_{$field}_{$file}"; | |
| 2972 | - if (is_file($filename) && is_readable($filename)){ | |
| 2973 | - if (function_exists('finfo_open')){ | |
| 2974 | - @ $finfo = finfo_open(FILEINFO_MIME); | |
| 2975 | - if ($finfo) { | |
| 2976 | - @ $filetype = finfo_file($finfo, $filename); | |
| 2977 | - @ finfo_close($finfo); | |
| 2978 | - } | |
| 2979 | - } | |
| 2980 | - if (empty($filetype) && function_exists('mime_content_type')){ | |
| 2981 | - @ $filetype = mime_content_type($filename); | |
| 2982 | - } | |
| 2983 | - if (empty($filetype)) { | |
| 2984 | - $filetype = "application/octet-stream"; | |
| 2985 | - } | |
| 2986 | - header("Content-type: $filetype"); | |
| 2987 | - header("Content-length: ".filesize($filename)); | |
| 2988 | - header("Content-disposition: attachment; filename=\"$file\""); | |
| 2989 | - readfile($filename); | |
| 2990 | - die; | |
| 2991 | - } | |
| 2992 | - } | |
| 2993 | - } | |
| 2994 | - header("HTTP/1.0 404 Not Found"); | |
| 2995 | - //header("Status: 404 Not Found"); | |
| 2996 | - die('File not found'); | |
| 2997 | -} | |
| 2998 | - | |
| 2999 | -function accua_forms_buildConditionalReplacer($map = array()) { | |
| 3000 | - if (!class_exists('AccuaConditionalReplacer')){ | |
| 3001 | - require_once('AccuaConditionalReplacer.php'); | |
| 3002 | - } | |
| 3003 | - return new AccuaConditionalReplacer($map); | |
| 3004 | -} | |
| 3005 | - | |
| 3006 | - | |
| 3007 | -add_action('wp_ajax_accua_forms_preview', 'accua_forms_preview'); | |
| 3008 | -function accua_forms_preview() { | |
| 3009 | - if (!current_user_can(10)){ | |
| 3010 | - die (''); | |
| 3011 | - } | |
| 3012 | - wp_enqueue_script('jquery'); | |
| 3013 | - echo '<html><head>'; | |
| 3014 | - wp_print_styles(); | |
| 3015 | - wp_print_head_scripts(); | |
| 3016 | - echo '</head><body>'; | |
| 3017 | - echo accua_forms_shortcode_handler(array('fid'=>$_REQUEST['fid'])); | |
| 3018 | - wp_print_footer_scripts(); | |
| 3019 | - echo '</body></html>'; | |
| 3020 | - die; | |
| 3021 | -} | |
| 3022 | - | |
| 3023 | -//salvataggio file excel | |
| 3024 | -add_action('wp_ajax_accua_forms_submission_page_save_excel', 'accua_forms_submission_page_save_excel'); | |
| 3025 | -//add_action('wp_ajax_nopriv_accua_forms_submission_page_save_excel', 'accua_forms_submission_page_save_excel'); | |
| 3026 | - | |
| 3027 | -function accua_forms_submission_page_save_excel() { | |
| 3028 | - require_once('accua-forms-submissions-page.php'); | |
| 3029 | - $listTable = new Accua_Forms_Submissions_List_Table(); | |
| 3030 | - $listTable->prepare_items(true); | |
| 3031 | - $show_col = explode( ',', $_GET['accua_show_field']); | |
| 3032 | - accua_forms_submission_page_save_excel_general($listTable,$show_col,''); | |
| 3033 | -} | |
| 3034 | - | |
| 3035 | - | |
| 3036 | - | |
| 3037 | -function accua_forms_submission_page_save_excel_general(Accua_Forms_Submissions_List_Table $listTable,array $show_col,$file_name='') { | |
| 3038 | - | |
| 3039 | - if (!current_user_can(10)){ | |
| 3040 | - header("HTTP/1.0 401 Access Denied"); | |
| 3041 | - //header("Status: 401 Access Denied"); | |
| 3042 | - die('You are not authorized to access this page.'); | |
| 3043 | - } | |
| 3044 | - | |
| 3045 | - global $wpdb; | |
| 3046 | - | |
| 3047 | - //creo il file excel | |
| 3048 | - header("Content-disposition: attachment; filename=downloads-report".$file_name.".xls"); | |
| 3049 | - header("Content-type: application/vnd.ms-excel"); | |
| 3050 | - ?><html xmlns:o="urn:schemas-microsoft-com:office:office" | |
| 3051 | - xmlns:x="urn:schemas-microsoft-com:office:excel" | |
| 3052 | - xmlns="http://www.w3.org/TR/REC-html40"> | |
| 3053 | - <head> | |
| 3054 | - <meta http-equiv=Content-Type content="text/html; charset=<?php echo get_option('blog_charset'); ?>" /> | |
| 3055 | - <meta name=ProgId content=Excel.Sheet /> | |
| 3056 | - <style> | |
| 3057 | - <!-- | |
| 3058 | - td {vertical-align:top;} | |
| 3059 | - .head_row {font-weight:bold;} | |
| 3060 | - .column-date { mso-number-format:"Short Date"; } | |
| 3061 | - .datetime_cell { mso-number-format:"yyyy\\-mm\\-dd\\ hh\:mm\:ss"; } | |
| 3062 | - --> | |
| 3063 | - </style> | |
| 3064 | - <!--[if gte mso 9]><xml> | |
| 3065 | - <x:ExcelWorkbook> | |
| 3066 | - <x:ExcelWorksheets> | |
| 3067 | - <x:ExcelWorksheet> | |
| 3068 | - <x:WorksheetOptions> | |
| 3069 | - <x:FreezePanes/> | |
| 3070 | - <x:FilterOn/> | |
| 3071 | - <x:SplitHorizontal>1</x:SplitHorizontal> | |
| 3072 | - <x:TopRowBottomPane>1</x:TopRowBottomPane> | |
| 3073 | - <x:ActivePane>2</x:ActivePane> | |
| 3074 | - <x:Panes> | |
| 3075 | - <x:Pane> | |
| 3076 | - <x:Number>3</x:Number> | |
| 3077 | - </x:Pane> | |
| 3078 | - <x:Pane> | |
| 3079 | - <x:Number>2</x:Number> | |
| 3080 | - </x:Pane> | |
| 3081 | - </x:Panes> | |
| 3082 | - </x:WorksheetOptions> | |
| 3083 | - </x:ExcelWorksheet> | |
| 3084 | - </x:ExcelWorksheets> | |
| 3085 | - </x:ExcelWorkbook> | |
| 3086 | - </xml><![endif]--> | |
| 3087 | - </head> | |
| 3088 | - <body> | |
| 3089 | - <table x:str border=1 > | |
| 3090 | - <tr class='head-row'> | |
| 3091 | - <?php | |
| 3092 | - $cols = $listTable->get_columns(); | |
| 3093 | - foreach($cols as $col_key=>$col_value) { | |
| 3094 | - if(in_array($col_key, $show_col)) { ?> | |
| 3095 | - <td x:autofilter="all"><?php echo $col_value; ?></td> | |
| 3096 | - <?php } | |
| 3097 | - } ?> | |
| 3098 | - </tr> | |
| 3099 | - | |
| 3100 | - <?php | |
| 3101 | - /* gestire la data | |
| 3102 | - $ut_date = $result->date; | |
| 3103 | - $ut_date[10] = 'T'; | |
| 3104 | - $ut_date.='.00+00:00'; | |
| 3105 | - $excel_date = (strtotime($ut_date) / 86400 + 25569); | |
| 3106 | - $parts_date = explode('-', substr($result->date, 0, 10)); | |
| 3107 | - $date = "{$parts_date[2]}/{$parts_date[1]}/{$parts_date[0]}"; | |
| 3108 | - echo "<td class='column-date' x:num='$excel_date' SDVAL=\"$excel_date\" SDNUM=\"1033;0;DD/MM/YYYY\">$date</td>\n"; | |
| 3109 | - */ | |
| 3110 | - ?> | |
| 3111 | - <?php | |
| 3112 | - | |
| 3113 | - | |
| 3114 | - foreach($listTable->items as $id_submission=>$single_submission) { | |
| 3115 | - echo "<tr>"; | |
| 3116 | - foreach($cols as $col_key=>$col_value) { | |
| 3117 | - if(in_array($col_key, $show_col)) { | |
| 3118 | - echo "<td class='.$col_key.'>"; | |
| 3119 | - if(isset($single_submission[$col_key])) { | |
| 3120 | - if ( method_exists( $this, 'column_' . $column_name ) ) { | |
| 3121 | - echo call_user_func( array( &$listTable, 'column_' . $col_key ), $single_submission ); | |
| 3122 | - } | |
| 3123 | - else { | |
| 3124 | - echo $listTable->column_default( $single_submission, $col_key ); | |
| 3125 | - } | |
| 3126 | - } | |
| 3127 | - echo "</td>"; | |
| 3128 | - } | |
| 3129 | - | |
| 3130 | - } | |
| 3131 | - echo "</tr>"; | |
| 3132 | - } | |
| 3133 | - | |
| 3134 | - ?> | |
| 3135 | - </table> | |
| 3136 | - </body> | |
| 3137 | - </html> | |
| 3138 | - <?php | |
| 3139 | -} | |
| 3140 | - | |
| 3141 | -function accua_forms_print_tokens() { | |
| 3142 | - $avail_fields = get_option('accua_forms_avail_fields', array()); | |
| 3143 | - $tokens = ''; | |
| 3144 | - foreach($avail_fields as $key=>$value) { | |
| 3145 | - $tokens .= $value['name'] . ": {" . $key . "}\n"; | |
| 3146 | - if ($value['type'] == 'file') { | |
| 3147 | - $tokens .= $value['name'] . " (download link): {__download_" . $key . "}\n"; | |
| 3148 | - } | |
| 3149 | - } | |
| 3150 | - | |
| 3151 | - echo <<<EOT | |
| 3152 | -<div class="accua_forms_token_list"> | |
| 3153 | -<h2>Tokens</h2> | |
| 3154 | -<h3>Fields</h3> | |
| 3155 | -<em>These tokens are available only if the field is added to the form</em> | |
| 3156 | -<pre>$tokens</pre> | |
| 3157 | -<h3>Generic tokens</h3> | |
| 3158 | -<pre>{__fid} | |
| 3159 | -{__subid} | |
| 3160 | -{__pid} | |
| 3161 | -{__ip} | |
| 3162 | -{__uri} | |
| 3163 | -{__url} | |
| 3164 | -{__referrer} | |
| 3165 | -{__lang} | |
| 3166 | -{__locale} | |
| 3167 | -{__created} | |
| 3168 | -{__created_day} | |
| 3169 | -{__created_day_month_year} | |
| 3170 | -{__created_hour} | |
| 3171 | -{__submitted} | |
| 3172 | -{__submitted_day} | |
| 3173 | -{__submitted_day_month_year} | |
| 3174 | -{__submitted_hour} | |
| 3175 | -{__user_agent} | |
| 3176 | -{__platform} | |
| 3177 | -{__tentatives} | |
| 3178 | -{__submit_method} | |
| 3179 | -{__submitted_txt} | |
| 3180 | -{__submitted_html} | |
| 3181 | -{__submitted_json} | |
| 3182 | -{__autoreply} | |
| 3183 | -{__autoreply_email} | |
| 3184 | -{__confirmation_emails_message}</pre> | |
| 3185 | -</div> | |
| 3186 | -EOT; | |
| 3187 | - do_action('accua_forms_print_tokens'); | |
| 3188 | -} | |
| 3189 | - | |
| 3190 | -function &accua_get_pages($args = '') { | |
| 3191 | - global $wpdb; | |
| 3192 | - | |
| 3193 | - $defaults = array( | |
| 3194 | - 'child_of' => 0, 'sort_order' => 'ASC', | |
| 3195 | - 'sort_column' => 'post_title', 'hierarchical' => 1, | |
| 3196 | - 'exclude' => array(), 'include' => array(), | |
| 3197 | - 'meta_key' => '', 'meta_value' => '', | |
| 3198 | - 'authors' => '', 'parent' => -1, 'exclude_tree' => '', | |
| 3199 | - 'number' => '', 'offset' => 0, | |
| 3200 | - 'post_type' => 'page', 'post_status' => 'publish', | |
| 3201 | - ); | |
| 3202 | - | |
| 3203 | - $r = wp_parse_args( $args, $defaults ); | |
| 3204 | - extract( $r, EXTR_SKIP ); | |
| 3205 | - $number = (int) $number; | |
| 3206 | - $offset = (int) $offset; | |
| 3207 | - | |
| 3208 | - /* | |
| 3209 | - // Make sure the post type is hierarchical | |
| 3210 | - $hierarchical_post_types = get_post_types( array( 'hierarchical' => true ) ); | |
| 3211 | - if ( !in_array( $post_type, $hierarchical_post_types ) ) | |
| 3212 | - return false; | |
| 3213 | - */ | |
| 3214 | - | |
| 3215 | - // Make sure we have a valid post type | |
| 3216 | - if ( !is_array( $post_type ) ) | |
| 3217 | - $post_type = explode( ',', $post_type ); | |
| 3218 | - if ( array_diff( $post_type, get_post_types() ) ) | |
| 3219 | - return false; | |
| 3220 | - | |
| 3221 | - // Make sure we have a valid post status | |
| 3222 | - if ( !is_array( $post_status ) ) | |
| 3223 | - $post_status = explode( ',', $post_status ); | |
| 3224 | - if ( array_diff( $post_status, get_post_stati() ) ) | |
| 3225 | - return false; | |
| 3226 | - | |
| 3227 | - /* | |
| 3228 | - $cache = array(); | |
| 3229 | - $key = md5( serialize( compact(array_keys($defaults)) ) ); | |
| 3230 | - if ( $cache = wp_cache_get( 'get_pages', 'posts' ) ) { | |
| 3231 | - if ( is_array($cache) && isset( $cache[ $key ] ) ) { | |
| 3232 | - $pages = apply_filters('get_pages', $cache[ $key ], $r ); | |
| 3233 | - return $pages; | |
| 3234 | - } | |
| 3235 | - } | |
| 3236 | - | |
| 3237 | - if ( !is_array($cache) ) | |
| 3238 | - $cache = array(); | |
| 3239 | - */ | |
| 3240 | - | |
| 3241 | - $inclusions = ''; | |
| 3242 | - if ( !empty($include) ) { | |
| 3243 | - $child_of = 0; //ignore child_of, parent, exclude, meta_key, and meta_value params if using include | |
| 3244 | - $parent = -1; | |
| 3245 | - $exclude = ''; | |
| 3246 | - $meta_key = ''; | |
| 3247 | - $meta_value = ''; | |
| 3248 | - $hierarchical = false; | |
| 3249 | - $incpages = wp_parse_id_list( $include ); | |
| 3250 | - if ( ! empty( $incpages ) ) { | |
| 3251 | - foreach ( $incpages as $incpage ) { | |
| 3252 | - if (empty($inclusions)) | |
| 3253 | - $inclusions = $wpdb->prepare(' AND ( ID = %d ', $incpage); | |
| 3254 | - else | |
| 3255 | - $inclusions .= $wpdb->prepare(' OR ID = %d ', $incpage); | |
| 3256 | - } | |
| 3257 | - } | |
| 3258 | - } | |
| 3259 | - if (!empty($inclusions)) | |
| 3260 | - $inclusions .= ')'; | |
| 3261 | - | |
| 3262 | - $exclusions = ''; | |
| 3263 | - if ( !empty($exclude) ) { | |
| 3264 | - $expages = wp_parse_id_list( $exclude ); | |
| 3265 | - if ( ! empty( $expages ) ) { | |
| 3266 | - foreach ( $expages as $expage ) { | |
| 3267 | - if (empty($exclusions)) | |
| 3268 | - $exclusions = $wpdb->prepare(' AND ( ID <> %d ', $expage); | |
| 3269 | - else | |
| 3270 | - $exclusions .= $wpdb->prepare(' AND ID <> %d ', $expage); | |
| 3271 | - } | |
| 3272 | - } | |
| 3273 | - } | |
| 3274 | - if (!empty($exclusions)) | |
| 3275 | - $exclusions .= ')'; | |
| 3276 | - | |
| 3277 | - $author_query = ''; | |
| 3278 | - if (!empty($authors)) { | |
| 3279 | - $post_authors = preg_split('/[\s,]+/',$authors); | |
| 3280 | - | |
| 3281 | - if ( ! empty( $post_authors ) ) { | |
| 3282 | - foreach ( $post_authors as $post_author ) { | |
| 3283 | - //Do we have an author id or an author login? | |
| 3284 | - if ( 0 == intval($post_author) ) { | |
| 3285 | - $post_author = get_user_by('login', $post_author); | |
| 3286 | - if ( empty($post_author) ) | |
| 3287 | - continue; | |
| 3288 | - if ( empty($post_author->ID) ) | |
| 3289 | - continue; | |
| 3290 | - $post_author = $post_author->ID; | |
| 3291 | - } | |
| 3292 | - | |
| 3293 | - if ( '' == $author_query ) | |
| 3294 | - $author_query = $wpdb->prepare(' post_author = %d ', $post_author); | |
| 3295 | - else | |
| 3296 | - $author_query .= $wpdb->prepare(' OR post_author = %d ', $post_author); | |
| 3297 | - } | |
| 3298 | - if ( '' != $author_query ) | |
| 3299 | - $author_query = " AND ($author_query)"; | |
| 3300 | - } | |
| 3301 | - } | |
| 3302 | - | |
| 3303 | - $join = ''; | |
| 3304 | - $where = "$exclusions $inclusions "; | |
| 3305 | - if ( ! empty( $meta_key ) || ! empty( $meta_value ) ) { | |
| 3306 | - $join = " LEFT JOIN $wpdb->postmeta ON ( $wpdb->posts.ID = $wpdb->postmeta.post_id )"; | |
| 3307 | - | |
| 3308 | - // meta_key and meta_value might be slashed | |
| 3309 | - $meta_key = stripslashes($meta_key); | |
| 3310 | - $meta_value = stripslashes($meta_value); | |
| 3311 | - if ( ! empty( $meta_key ) ) | |
| 3312 | - $where .= $wpdb->prepare(" AND $wpdb->postmeta.meta_key = %s", $meta_key); | |
| 3313 | - if ( ! empty( $meta_value ) ) | |
| 3314 | - $where .= $wpdb->prepare(" AND $wpdb->postmeta.meta_value = %s", $meta_value); | |
| 3315 | - | |
| 3316 | - } | |
| 3317 | - | |
| 3318 | - if ( $parent >= 0 ) | |
| 3319 | - $where .= $wpdb->prepare(' AND post_parent = %d ', $parent); | |
| 3320 | - | |
| 3321 | - | |
| 3322 | - if ( 1 == count ( $post_type ) ) { | |
| 3323 | - $where_post_type = $wpdb->prepare( "post_type = %s", array_shift( $post_type ) ); | |
| 3324 | - } else { | |
| 3325 | - $post_type = implode( "', '", $post_type ); | |
| 3326 | - $where_post_type = "post_type IN ('$post_type')"; | |
| 3327 | - } | |
| 3328 | - | |
| 3329 | - if ( 1 == count( $post_status ) ) { | |
| 3330 | - $where_post_type .= $wpdb->prepare( " AND post_status = %s", array_shift( $post_status ) ); | |
| 3331 | - } else { | |
| 3332 | - $post_status = implode( "', '", $post_status ); | |
| 3333 | - $where_post_type .= " AND post_status IN ('$post_status')"; | |
| 3334 | - } | |
| 3335 | - | |
| 3336 | - $orderby_array = array(); | |
| 3337 | - $allowed_keys = array('author', 'post_author', 'date', 'post_date', 'title', 'post_title', 'name', 'post_name', 'modified', | |
| 3338 | - 'post_modified', 'modified_gmt', 'post_modified_gmt', 'menu_order', 'parent', 'post_parent', | |
| 3339 | - 'ID', 'rand', 'comment_count'); | |
| 3340 | - foreach ( explode( ',', $sort_column ) as $orderby ) { | |
| 3341 | - $orderby = trim( $orderby ); | |
| 3342 | - if ( !in_array( $orderby, $allowed_keys ) ) | |
| 3343 | - continue; | |
| 3344 | - | |
| 3345 | - switch ( $orderby ) { | |
| 3346 | - case 'menu_order': | |
| 3347 | - break; | |
| 3348 | - case 'ID': | |
| 3349 | - $orderby = "$wpdb->posts.ID"; | |
| 3350 | - break; | |
| 3351 | - case 'rand': | |
| 3352 | - $orderby = 'RAND()'; | |
| 3353 | - break; | |
| 3354 | - case 'comment_count': | |
| 3355 | - $orderby = "$wpdb->posts.comment_count"; | |
| 3356 | - break; | |
| 3357 | - default: | |
| 3358 | - if ( 0 === strpos( $orderby, 'post_' ) ) | |
| 3359 | - $orderby = "$wpdb->posts." . $orderby; | |
| 3360 | - else | |
| 3361 | - $orderby = "$wpdb->posts.post_" . $orderby; | |
| 3362 | - } | |
| 3363 | - | |
| 3364 | - $orderby_array[] = $orderby; | |
| 3365 | - | |
| 3366 | - } | |
| 3367 | - $sort_column = ! empty( $orderby_array ) ? implode( ',', $orderby_array ) : "$wpdb->posts.post_title"; | |
| 3368 | - | |
| 3369 | - $sort_order = strtoupper( $sort_order ); | |
| 3370 | - if ( '' !== $sort_order && !in_array( $sort_order, array( 'ASC', 'DESC' ) ) ) | |
| 3371 | - $sort_order = 'ASC'; | |
| 3372 | - | |
| 3373 | - $query = "SELECT * FROM $wpdb->posts $join WHERE ($where_post_type) $where "; | |
| 3374 | - $query .= $author_query; | |
| 3375 | - $query .= " ORDER BY " . $sort_column . " " . $sort_order ; | |
| 3376 | - | |
| 3377 | - if ( !empty($number) ) | |
| 3378 | - $query .= ' LIMIT ' . $offset . ',' . $number; | |
| 3379 | - | |
| 3380 | - //echo "<!-- accua_forms_query:\n$query\n-->"; | |
| 3381 | - | |
| 3382 | - $pages = $wpdb->get_results($query); | |
| 3383 | - | |
| 3384 | - if ( empty($pages) ) { | |
| 3385 | - $pages = apply_filters('get_pages', array(), $r); | |
| 3386 | - return $pages; | |
| 3387 | - } | |
| 3388 | - | |
| 3389 | - // Sanitize before caching so it'll only get done once | |
| 3390 | - $num_pages = count($pages); | |
| 3391 | - for ($i = 0; $i < $num_pages; $i++) { | |
| 3392 | - $pages[$i] = sanitize_post($pages[$i], 'raw'); | |
| 3393 | - } | |
| 3394 | - | |
| 3395 | - /* | |
| 3396 | - // Update cache. | |
| 3397 | - update_post_cache( $pages ); | |
| 3398 | - */ | |
| 3399 | - | |
| 3400 | - if ( $child_of || $hierarchical ) | |
| 3401 | - $pages = & get_page_children($child_of, $pages); | |
| 3402 | - | |
| 3403 | - if ( !empty($exclude_tree) ) { | |
| 3404 | - $exclude = (int) $exclude_tree; | |
| 3405 | - $children = get_page_children($exclude, $pages); | |
| 3406 | - $excludes = array(); | |
| 3407 | - foreach ( $children as $child ) | |
| 3408 | - $excludes[] = $child->ID; | |
| 3409 | - $excludes[] = $exclude; | |
| 3410 | - $num_pages = count($pages); | |
| 3411 | - for ( $i = 0; $i < $num_pages; $i++ ) { | |
| 3412 | - if ( in_array($pages[$i]->ID, $excludes) ) | |
| 3413 | - unset($pages[$i]); | |
| 3414 | - } | |
| 3415 | - } | |
| 3416 | - | |
| 3417 | - /* | |
| 3418 | - $cache[ $key ] = $pages; | |
| 3419 | - wp_cache_set( 'get_pages', $cache, 'posts' ); | |
| 3420 | - */ | |
| 3421 | - | |
| 3422 | - $pages = apply_filters('get_pages', $pages, $r); | |
| 3423 | - | |
| 3424 | - return $pages; | |
| 3425 | -} | |
| 1 | +<?php | |
| 2 | +add_action('admin_menu', 'accua_forms_menu', -95); | |
| 3 | +function accua_forms_menu(){ | |
| 4 | + $dashboard_admin_page=add_menu_page('Wordpress Contact Forms by Cimatti', 'Contact Forms', 'manage_options', 'accua_forms', 'accua_forms_dashboard_page', ACCUA_FORMS_DIR_URL.'img/cimatti-icon-10.png', '90.90300'); | |
| 5 | + add_action('load-'.$dashboard_admin_page, 'accua_forms_dashboard_page_head'); | |
| 6 | + | |
| 7 | + add_submenu_page('accua_forms', 'Wordpress Contact Forms by Cimatti', 'Dashboard', 'manage_options', "accua_forms", 'accua_forms_dashboard_page'); | |
| 8 | + | |
| 9 | + $form_edit_page = add_submenu_page('accua_forms', 'Forms', 'Forms', 'manage_options', "accua_forms_list", 'accua_forms_list_page'); | |
| 10 | + add_action('admin_head-'.$form_edit_page, 'accua_forms_edit_page_head'); | |
| 11 | + add_action( 'admin_print_styles-'.$form_edit_page, 'accua_forms_edit_page_head_styles'); | |
| 12 | + add_action( 'admin_print_scripts-'.$form_edit_page, 'accua_forms_edit_page_head_scripts'); | |
| 13 | + | |
| 14 | + $form_add_page = add_submenu_page('accua_forms', __('Add new form', 'contact-forms'), __('Add new', 'contact-forms'), 'manage_options', "accua_forms_add", 'accua_forms_add_page'); | |
| 15 | + add_action('admin_head-'.$form_add_page, 'accua_forms_edit_page_head'); | |
| 16 | + add_action( 'admin_print_styles-'.$form_add_page, 'accua_forms_edit_page_head_styles'); | |
| 17 | + add_action( 'admin_print_scripts-'.$form_add_page, 'accua_forms_edit_page_head_scripts'); | |
| 18 | + | |
| 19 | + $form_submissions_page = add_submenu_page('accua_forms', __('Forms submissions', 'contact-forms') , __('Submissions', 'contact-forms'), 'manage_options', "accua_forms_submissions_list", '__accua_forms_submissions_list_page'); | |
| 20 | + add_action('admin_head-'.$form_submissions_page, 'accua_forms_submissions_list_page_head'); | |
| 21 | + add_action( 'admin_print_styles-'.$form_submissions_page, 'accua_forms_edit_page_head_styles'); | |
| 22 | + | |
| 23 | + $form_fields_page = add_submenu_page('accua_forms', __( 'Form fields', 'contact-forms'), __('Fields', 'contact-forms'), 'manage_options', "accua_forms_fields", 'accua_forms_fields_page'); | |
| 24 | + //add_action('admin_head-'.$form_fields_page, 'accua_forms_fields_page_head'); | |
| 25 | + add_action( 'admin_print_styles-'.$form_fields_page, 'accua_forms_edit_page_head_styles'); | |
| 26 | + | |
| 27 | + $settings_page = add_submenu_page('accua_forms', __( 'Default Forms settings', 'contact-forms'), __('Settings', 'contact-forms'), 'manage_options', "accua_forms_settings", 'accua_forms_settings_page'); | |
| 28 | + add_action( 'admin_print_styles-'.$settings_page, 'accua_forms_edit_page_head_styles'); | |
| 29 | + add_action( 'admin_print_scripts-'.$settings_page, 'accua_forms_settings_page_head_scripts'); | |
| 30 | + | |
| 31 | + wp_enqueue_script('jquery-form'); | |
| 32 | + wp_enqueue_script('jquery-color'); | |
| 33 | + wp_enqueue_script('jquery-ui-core'); | |
| 34 | + wp_enqueue_script('jquery-ui-tabs'); | |
| 35 | + wp_enqueue_script('jquery-ui-sortable'); | |
| 36 | + wp_enqueue_script('jquery-ui-draggable'); | |
| 37 | + wp_enqueue_script('jquery-ui-droppable'); | |
| 38 | + wp_enqueue_script('jquery-ui-selectable'); | |
| 39 | + wp_enqueue_script('jquery-ui-resizable'); | |
| 40 | + wp_enqueue_script('jquery-ui-dialog'); | |
| 41 | + wp_enqueue_style('wp-jquery-ui-dialog'); | |
| 42 | +} | |
| 43 | + | |
| 44 | +function accua_forms_report_page_head(){ | |
| 45 | + $column_list = array( | |
| 46 | + 'month' => __( 'Month', 'contact-forms'), | |
| 47 | + 'unique_submissions' => __( 'Unique submissions', 'contact-forms') , | |
| 48 | + 'submissions' => __('Total submissions', 'contact-forms'), | |
| 49 | + ); | |
| 50 | + global $hook_suffix; | |
| 51 | + register_column_headers($hook_suffix, $column_list); | |
| 52 | + | |
| 53 | + //$baseurl = WP_PLUGIN_URL.'/'.substr(plugin_basename(__FILE__),0,-strlen(basename(__FILE__))); | |
| 54 | + //echo '<link href="'.$baseurl.'/flot/layout.css" rel="stylesheet" type="text/css">'; | |
| 55 | + //echo '<!--[if lte IE 8]><script language="javascript" type="text/javascript" src="'.$baseurl.'/flot/excanvas.min.js"></script><![endif]-->'; | |
| 56 | + //echo '<script language="javascript" type="text/javascript" src="'.$baseurl.'/flot/jquery.flot.js"></script>'; | |
| 57 | + | |
| 58 | +} | |
| 59 | + | |
| 60 | + | |
| 61 | +function accua_forms_report_page() { | |
| 62 | +?> | |
| 63 | + <div id="accua_forms_report_page" class="accua_forms_admin_page wrap"> | |
| 64 | + <h2>Forms submissions report</h2> | |
| 65 | + | |
| 66 | +<?php | |
| 67 | + global $wpdb, $hook_suffix; | |
| 68 | + $months = array(1 => 'January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December'); | |
| 69 | + | |
| 70 | + $query = "SELECT YEAR(sub_date) AS `year`, MONTH(sub_date) AS `month`, COUNT(DISTINCT `email`) AS `unique_submissions`, COUNT(*) AS `submissions` | |
| 71 | + FROM `{$wpdb->prefix}cformssubmissions` | |
| 72 | + GROUP BY `year`, `month` | |
| 73 | + ORDER BY `year` DESC, `month` DESC"; | |
| 74 | + | |
| 75 | + $results = $wpdb->get_results($query); | |
| 76 | + | |
| 77 | + if ($results) { | |
| 78 | +?> | |
| 79 | + <style type="text/css"> | |
| 80 | + .column-submissions, .column-unique_submissions { | |
| 81 | + text-align: right !important; | |
| 82 | + } | |
| 83 | + </style> | |
| 84 | + <div id="accua-form-report-graph" style="height:300px;"></div> | |
| 85 | + <table class="widefat" id="stnl_review_reviewed"> | |
| 86 | + <thead> | |
| 87 | + <tr><?php print_column_headers($hook_suffix); ?></tr> | |
| 88 | + </thead> | |
| 89 | + | |
| 90 | + <tfoot> | |
| 91 | + <tr><?php print_column_headers($hook_suffix, false); ?></tr> | |
| 92 | + </tfoot> | |
| 93 | + | |
| 94 | + <tbody> | |
| 95 | +<?php | |
| 96 | + $alternate = false; | |
| 97 | + $hidden = get_hidden_columns($hook_suffix); | |
| 98 | + $data = array( | |
| 99 | + array( 'label' => __( 'Unique submissions', 'contact-forms'), 'data' => array()), | |
| 100 | + array( 'label' => __( 'Total submissions', 'contact-forms'), 'data' => array()), | |
| 101 | + ); | |
| 102 | + foreach ($results as $result){ | |
| 103 | + $month = $months[$result->month]; | |
| 104 | + echo "<tr class='iedit ".(($alternate = !$alternate)?'alternate':'')."'>\n"; | |
| 105 | + echo "<td class='column-month'".(in_array('month', $hidden)?" style='display:none;'":'').">$month {$result->year}</td>\n"; | |
| 106 | + echo "<td class='column-unique_submissions'".(in_array('unique_submissions', $hidden)?" style='display:none;'":'').">{$result->unique_submissions}</td>\n"; | |
| 107 | + echo "<td class='column-submissions'".(in_array('submissions', $hidden)?" style='display:none;'":'').">{$result->submissions}</td>\n"; | |
| 108 | + echo "</tr>\n"; | |
| 109 | + $time = mktime(0, 0, 0, $result->month, 1, $result->year) * 1000; | |
| 110 | + $data[0]['data'][] = array($time, (int)$result->unique_submissions); | |
| 111 | + $data[1]['data'][] = array($time, (int)$result->submissions); | |
| 112 | + } | |
| 113 | + /* | |
| 114 | + $year = $results[0]->year; | |
| 115 | + $month = $results[0]->month; | |
| 116 | + while ($year <= $result->year || $month <= $result->month) { | |
| 117 | + | |
| 118 | + $month++; | |
| 119 | + if ($month > 12) { | |
| 120 | + $year++; | |
| 121 | + $month = 1; | |
| 122 | + } | |
| 123 | + } | |
| 124 | + */ | |
| 125 | +?> | |
| 126 | + </tbody> | |
| 127 | + </table> | |
| 128 | +<script type="text/javascript"> | |
| 129 | +jQuery(function($){ | |
| 130 | + var data = <?php print _accua_forms_json_encode($data); ?> ; | |
| 131 | + var options = { | |
| 132 | + xaxis: { | |
| 133 | + //autoscaleMargin: 0.005, | |
| 134 | + mode: "time", | |
| 135 | + timeformat: "%b %y", | |
| 136 | + minTickSize: [1, "month"] | |
| 137 | + }, | |
| 138 | + legend: { | |
| 139 | + position: "nw" | |
| 140 | + } | |
| 141 | + }; | |
| 142 | + $.plot($("#accua-form-report-graph"), data, options); | |
| 143 | +}); | |
| 144 | +</script> | |
| 145 | +<?php | |
| 146 | + } | |
| 147 | +?> | |
| 148 | + | |
| 149 | + </div> | |
| 150 | +<?php | |
| 151 | +} | |
| 152 | + | |
| 153 | +function accua_forms_edit_page_head_styles() { | |
| 154 | + //wp_admin_css( 'widgets' ); | |
| 155 | + wp_enqueue_style( 'wp-pointer' ); //for tooltips | |
| 156 | + wp_enqueue_style( 'accua-forms-admin', plugins_url('accua-forms-admin.css', ACCUA_FORMS_FILE), array(), ACCUA_FORMS_CSS_VERSION); // | |
| 157 | +} | |
| 158 | + | |
| 159 | +function accua_forms_edit_page_head_scripts() { | |
| 160 | + //wp_enqueue_script('admin-widgets'); | |
| 161 | + /*wp_enqueue_script('jquery-ui-sortable'); | |
| 162 | + wp_enqueue_script('jquery-ui-draggable'); | |
| 163 | + wp_enqueue_script('jquery-ui-droppable');*/ | |
| 164 | + wp_enqueue_script( 'wp-pointer' ); //for tooltips | |
| 165 | + wp_enqueue_script('accua-jqColorPicker', plugins_url('/js/jqColorPicker.min.js', ACCUA_FORMS_FILE ), array( 'jquery' ), ACCUA_FORMS_JS_VERSION); | |
| 166 | + | |
| 167 | + wp_enqueue_script( 'accua-form-fields', plugins_url( 'form-fields.js' , ACCUA_FORMS_FILE ), array( 'jquery-ui-sortable', 'jquery-ui-draggable', 'jquery-ui-droppable' ), ACCUA_FORMS_JS_VERSION); | |
| 168 | + wp_enqueue_script( 'accua-form-settings', plugins_url('form-settings.js', ACCUA_FORMS_FILE), array('jquery'), ACCUA_FORMS_JS_VERSION); | |
| 169 | +} | |
| 170 | + | |
| 171 | +function accua_forms_settings_page_head_scripts() { | |
| 172 | + wp_enqueue_script('accua-jqColorPicker', plugins_url('/js/jqColorPicker.min.js', ACCUA_FORMS_FILE ), array( 'jquery' ), ACCUA_FORMS_JS_VERSION); | |
| 173 | +} | |
| 174 | + | |
| 175 | +function accua_forms_edit_page_head() { | |
| 176 | +if (isset($_POST['accua-form-edit-action']) || (!isset($_GET['fid']))) { | |
| 177 | + _accua_forms_form_edit_action(); | |
| 178 | + require_once('accua-forms-list-page.php'); | |
| 179 | + accua_forms_list_page_table(true); | |
| 180 | +} | |
| 181 | + | |
| 182 | +?> | |
| 183 | + <style type="text/css"> | |
| 184 | + .container > div { | |
| 185 | + padding: 0px; | |
| 186 | + margin-bottom: 6px; | |
| 187 | + } | |
| 188 | + .widget-liquid-right .widget, #wp_inactive_widgets .widget, .widget-liquid-right .sidebar-description, .widget-placeholder { | |
| 189 | + width: 95%; | |
| 190 | + } | |
| 191 | + .column-submissions { | |
| 192 | + text-align: right !important; | |
| 193 | + } | |
| 194 | + </style> | |
| 195 | +<?php | |
| 196 | +} | |
| 197 | + | |
| 198 | +add_action( 'wp_ajax_accua-form-fields-order' , 'accua_forms_form_fields_order'); | |
| 199 | +function accua_forms_form_fields_order() { | |
| 200 | + if (!current_user_can('manage_options')){ | |
| 201 | + wp_die( -1, 403 ); | |
| 202 | + } | |
| 203 | + check_ajax_referer('edit_form', '_nonce_edit_form'); | |
| 204 | + | |
| 205 | + $post = stripslashes_deep($_POST); | |
| 206 | + //update_option('accua_forms_form_fields_order_post', $post); | |
| 207 | + | |
| 208 | + if (empty($post['sidebars'])) { | |
| 209 | + die('-1'); | |
| 210 | + } | |
| 211 | + | |
| 212 | + $forms_data = get_option('accua_forms_saved_forms', array()); | |
| 213 | + | |
| 214 | + foreach ($post['sidebars'] as $fid => $order) { | |
| 215 | + if (strpos($fid, 'cimatti-accua-fields-form-area-') !== 0){ | |
| 216 | + die('-1'); | |
| 217 | + } | |
| 218 | + $fid = substr($fid, 31); | |
| 219 | + | |
| 220 | + if (empty($forms_data[$fid]['fields'])) { | |
| 221 | + die('-1'); | |
| 222 | + } | |
| 223 | + | |
| 224 | + $old_fields = $forms_data[$fid]['fields']; | |
| 225 | + unset($forms_data[$fid]['fields']); | |
| 226 | + $new_fields = array(); | |
| 227 | + | |
| 228 | + $order = explode(',', $order); | |
| 229 | + | |
| 230 | + foreach ($order as $i) { | |
| 231 | + $i = preg_replace('/^(new-)?widget-\\d+_/', '', $i); | |
| 232 | + if (isset($old_fields[$i])) { | |
| 233 | + $new_fields[$i] = $old_fields[$i]; | |
| 234 | + unset($old_fields[$i]); | |
| 235 | + } | |
| 236 | + } | |
| 237 | + | |
| 238 | + if($old_fields){ | |
| 239 | + $new_fields += $old_fields; | |
| 240 | + } | |
| 241 | + $forms_data[$fid]['fields'] = $new_fields; | |
| 242 | + } | |
| 243 | + | |
| 244 | + update_option('accua_forms_saved_forms', $forms_data); | |
| 245 | + | |
| 246 | + die('1'); | |
| 247 | +} | |
| 248 | + | |
| 249 | +add_action( 'wp_ajax_accua-save-form-field', 'accua_forms_save_form_field'); | |
| 250 | +/* azione dove vengono salvati i campi dei un form */ | |
| 251 | +function accua_forms_save_form_field() { | |
| 252 | + if (!current_user_can('manage_options')){ | |
| 253 | + wp_die( -1, 403 ); | |
| 254 | + } | |
| 255 | + check_ajax_referer('edit_form', '_nonce_edit_form'); | |
| 256 | + | |
| 257 | + $post = stripslashes_deep($_POST); | |
| 258 | + | |
| 259 | + //update_option('accua_forms_save_form_field_post', $post); | |
| 260 | + | |
| 261 | + $forms_data = get_option('accua_forms_saved_forms', array()); | |
| 262 | + $fid = $post['form-id']; | |
| 263 | + if (accua_forms_validate_form_id($fid) !== '') { | |
| 264 | + die('-1'); | |
| 265 | + } | |
| 266 | + if (empty($forms_data[$fid]['fields'])) { | |
| 267 | + $forms_data[$fid]['fields'] = array(); | |
| 268 | + } | |
| 269 | + | |
| 270 | + $avail_fields = get_option('accua_forms_avail_fields', array()); | |
| 271 | + @ $wid = (string) $post['widget-id']; | |
| 272 | + if (isset($avail_fields[$wid])) { | |
| 273 | + $check_ref = $wid; | |
| 274 | + } else { | |
| 275 | + if (preg_match('/^(__html|__fieldset-begin|__fieldset-end)-\d+$/', $wid, $matches)) { | |
| 276 | + $check_ref = $matches[1]; | |
| 277 | + } else { | |
| 278 | + die('-1'); | |
| 279 | + } | |
| 280 | + } | |
| 281 | + if (empty($post['delete_widget'])) { | |
| 282 | + //$istance_id = $post['multi_number']; | |
| 283 | + @ $ref = $post['id_base']; | |
| 284 | + if ($ref !== $check_ref) { | |
| 285 | + die('-1'); | |
| 286 | + } | |
| 287 | + $required = !empty($post["form-field-{$wid}-required"]); | |
| 288 | + $widget_number = empty($post['multi_number']) ? (empty($post['widget_number']) ? '' : (int)$post['widget_number']) : (int)$post['multi_number']; | |
| 289 | + | |
| 290 | + if (isset($forms_data[$fid]['fields'][$wid])) { | |
| 291 | + $old_istance_data = $forms_data[$fid]['fields'][$wid]; | |
| 292 | + } else { | |
| 293 | + $old_istance_data = array(); | |
| 294 | + } | |
| 295 | + | |
| 296 | + $forms_data[$fid]['fields'][$wid] = array ( | |
| 297 | + 'version' => 2, | |
| 298 | + 'istance_id' => $wid, | |
| 299 | + 'widget_number' => $widget_number, | |
| 300 | + 'ref' => $ref, | |
| 301 | + 'required' => $required, | |
| 302 | + ); | |
| 303 | + | |
| 304 | + if (!empty($post["form-field-{$wid}-override-label"])) { | |
| 305 | + @ $label = (string) $post["form-field-{$wid}-label"]; | |
| 306 | + if (!current_user_can('unfiltered_html')) { | |
| 307 | + $label = wp_kses($label, 'post'); | |
| 308 | + } | |
| 309 | + $forms_data[$fid]['fields'][$wid]['label'] = $label; | |
| 310 | + } | |
| 311 | + | |
| 312 | + $is_file = false; | |
| 313 | + $is_date = false; | |
| 314 | + if (isset($avail_fields[$wid]['type'])) { | |
| 315 | + if ($avail_fields[$wid]['type'] == 'file') { | |
| 316 | + $is_file = true; | |
| 317 | + } else if ($avail_fields[$wid]['type'] == 'date') { | |
| 318 | + $is_date = true; | |
| 319 | + } | |
| 320 | + } | |
| 321 | + | |
| 322 | + if (!empty($post["form-field-{$wid}-override-default-value"])) { | |
| 323 | + @ $default_value = (string) $post["form-field-{$wid}-default-value"]; | |
| 324 | + if ($is_date) { | |
| 325 | + $default_value = accua_forms_filter_date($default_value); | |
| 326 | + } else if (!current_user_can('unfiltered_html')) { | |
| 327 | + //This is filtered in any case because field type can change | |
| 328 | + $default_value = wp_kses($default_value, 'post'); | |
| 329 | + } | |
| 330 | + $forms_data[$fid]['fields'][$wid]['default_value'] = $default_value; | |
| 331 | + } | |
| 332 | + | |
| 333 | + if (!empty($post["form-field-{$wid}-override-allowed-values"])) { | |
| 334 | + @ $allowed_values = (string) $post["form-field-{$wid}-allowed-values"]; | |
| 335 | + if ($is_file){ | |
| 336 | + $forms_data[$fid]['fields'][$wid]['allowed_extensions'] = accua_forms_filter_extensions($allowed_values); | |
| 337 | + } else { | |
| 338 | + $forms_data[$fid]['fields'][$wid]['allowed_values'] = $allowed_values; | |
| 339 | + } | |
| 340 | + } | |
| 341 | + if (!empty($post["form-field-{$wid}-override-datemin-values"])) { | |
| 342 | + @ $mindate_values = (string) $post["form-field-{$wid}-min-of-date"]; | |
| 343 | + $forms_data[$fid]['fields'][$wid]['min_date'] = accua_forms_filter_date($mindate_values); | |
| 344 | + } | |
| 345 | + if (!empty($post["form-field-{$wid}-override-datemax-values"])) { | |
| 346 | + @ $maxdate_values = (string) $post["form-field-{$wid}-max-of-date"]; | |
| 347 | + $forms_data[$fid]['fields'][$wid]['max_date'] = accua_forms_filter_date($maxdate_values); | |
| 348 | + } | |
| 349 | + } else { | |
| 350 | + unset($forms_data[$fid]['fields'][$wid]); | |
| 351 | + } | |
| 352 | + | |
| 353 | + update_option('accua_forms_saved_forms', $forms_data); | |
| 354 | + | |
| 355 | + die('1'); | |
| 356 | +} | |
| 357 | + | |
| 358 | +function accua_forms_filter_text($text) { | |
| 359 | + if ( is_object( $text ) || is_array( $text ) ) { | |
| 360 | + return ''; | |
| 361 | + } | |
| 362 | + | |
| 363 | + $text = (string) $text; | |
| 364 | + $text = wp_check_invalid_utf8( $text ); | |
| 365 | + $text = preg_replace( '/[ \t\n\r\0\x0B]+/', ' ', $text ); | |
| 366 | + $text = trim( $text ); | |
| 367 | + | |
| 368 | + return $text; | |
| 369 | +} | |
| 370 | + | |
| 371 | +function accua_forms_filter_email($email) { | |
| 372 | + $parts = explode('<', $email); | |
| 373 | + if (isset($parts[1])) { | |
| 374 | + $email = accua_forms_filter_text(trim($parts[1], "<> \t\n\r\0\x0B")); | |
| 375 | + $display_name = accua_forms_filter_text(trim($parts[0])); | |
| 376 | + return "$display_name <$email>"; | |
| 377 | + } else { | |
| 378 | + return accua_forms_filter_text($email); | |
| 379 | + } | |
| 380 | +} | |
| 381 | + | |
| 382 | +function accua_forms_filter_emails($emails) { | |
| 383 | + $split_emails = preg_split("/\s*[,;]\s*/", $emails); | |
| 384 | + $emails = array(); | |
| 385 | + foreach ($split_emails as $email) { | |
| 386 | + $emails[] = accua_forms_filter_email($email); | |
| 387 | + } | |
| 388 | + return implode(', ', $emails); | |
| 389 | +} | |
| 390 | + | |
| 391 | +function accua_forms_filter_extensions($extensions) { | |
| 392 | + $cleaned_extensions = array(); | |
| 393 | + $mimes = get_allowed_mime_types(); | |
| 394 | + $extensions = explode("\n", $extensions); | |
| 395 | + foreach ($extensions as $extension) { | |
| 396 | + $extension = trim($extension); | |
| 397 | + if ($extension !== '') { | |
| 398 | + foreach ( $mimes as $ext_preg => $mime_match ) { | |
| 399 | + $ext_preg = '!^' . $ext_preg . '$!i'; | |
| 400 | + if ( preg_match( $ext_preg, $extension ) ) { | |
| 401 | + $cleaned_extensions[] = $extension; | |
| 402 | + break; | |
| 403 | + } | |
| 404 | + } | |
| 405 | + } | |
| 406 | + } | |
| 407 | + return implode("\n", $cleaned_extensions); | |
| 408 | +} | |
| 409 | + | |
| 410 | +function accua_forms_filter_settings($form_settings) { | |
| 411 | + foreach($form_settings as $k => $v) { | |
| 412 | + switch ($k) { | |
| 413 | + case 'success_message_no_message': | |
| 414 | + case 'error_message_no_message': | |
| 415 | + case 'admin_emails_message_no_message': | |
| 416 | + case 'confirmation_emails_message_no_message': | |
| 417 | + case 'use_ajax': | |
| 418 | + //boolean | |
| 419 | + $form_settings[$k] = (bool) $v; | |
| 420 | + break; | |
| 421 | + case 'layout': | |
| 422 | + $form_settings[$k] = ($v === 'toplabel') ? 'toplabel' : 'sidebyside'; | |
| 423 | + break; | |
| 424 | + case 'emails_from': | |
| 425 | + // single email | |
| 426 | + $form_settings[$k] = accua_forms_filter_email($v); | |
| 427 | + break; | |
| 428 | + case 'admin_emails_to': | |
| 429 | + case 'emails_bcc': | |
| 430 | + //emails list | |
| 431 | + $form_settings[$k] = accua_forms_filter_email($v); | |
| 432 | + break; | |
| 433 | + case 'success_message': | |
| 434 | + case 'error_message': | |
| 435 | + case 'admin_emails_message': | |
| 436 | + case 'confirmation_emails_message': | |
| 437 | + //HTML | |
| 438 | + if (!current_user_can('unfiltered_html')) { | |
| 439 | + $form_settings[$k] = wp_kses($v, 'post'); | |
| 440 | + } | |
| 441 | + break; | |
| 442 | + //case 'title': | |
| 443 | + //case 'emails_from_name': | |
| 444 | + //case 'admin_emails_subject': | |
| 445 | + //case 'confirmation_emails_subject': | |
| 446 | + //case 'style_*': | |
| 447 | + default: | |
| 448 | + // text field | |
| 449 | + $form_settings[$k] = accua_forms_filter_text($v); | |
| 450 | + } | |
| 451 | + } | |
| 452 | + return $form_settings; | |
| 453 | +} | |
| 454 | + | |
| 455 | +add_action( 'wp_ajax_accua-save-form-settings', 'accua_forms_save_form_settings'); | |
| 456 | +function accua_forms_save_form_settings() { | |
| 457 | + if (!current_user_can('manage_options')){ | |
| 458 | + wp_die( -1, 403 ); | |
| 459 | + } | |
| 460 | + check_ajax_referer('edit_form', '_nonce_edit_form'); | |
| 461 | + | |
| 462 | + $post = stripslashes_deep($_POST); | |
| 463 | + | |
| 464 | + $forms_data = get_option('accua_forms_saved_forms', array()); | |
| 465 | + $fid = $post['form-id']; | |
| 466 | + if (accua_forms_validate_form_id($fid) !== '') { | |
| 467 | + die('-1'); | |
| 468 | + } | |
| 469 | + | |
| 470 | + $settings = array( | |
| 471 | + 'title', | |
| 472 | + 'success_message', | |
| 473 | + 'success_message_no_message', | |
| 474 | + 'error_message', | |
| 475 | + 'error_message_no_message', | |
| 476 | + 'emails_from_name', | |
| 477 | + 'emails_from', | |
| 478 | + 'admin_emails_to', | |
| 479 | + 'emails_bcc', | |
| 480 | + 'admin_emails_subject', | |
| 481 | + 'admin_emails_message', | |
| 482 | + 'admin_emails_message_no_message', | |
| 483 | + 'confirmation_emails_subject', | |
| 484 | + 'confirmation_emails_message', | |
| 485 | + 'confirmation_emails_message_no_message', | |
| 486 | + //'use_ajax', | |
| 487 | + | |
| 488 | + 'layout', | |
| 489 | + 'style_margin', | |
| 490 | + 'style_border_color', | |
| 491 | + 'style_border_width', | |
| 492 | + 'style_border_radius', | |
| 493 | + 'style_background_color', | |
| 494 | + 'style_padding', | |
| 495 | + 'style_color', | |
| 496 | + 'style_font_size', | |
| 497 | + 'style_field_spacing', | |
| 498 | + 'style_field_border_color', | |
| 499 | + 'style_field_border_width', | |
| 500 | + 'style_field_border_radius', | |
| 501 | + 'style_field_background_color', | |
| 502 | + 'style_field_padding', | |
| 503 | + 'style_field_color', | |
| 504 | + 'style_submit_border_color', | |
| 505 | + 'style_submit_border_width', | |
| 506 | + 'style_submit_border_radius', | |
| 507 | + 'style_submit_background_color', | |
| 508 | + 'style_submit_padding', | |
| 509 | + 'style_submit_color', | |
| 510 | + 'style_submit_font_size', | |
| 511 | + ); | |
| 512 | + | |
| 513 | + // print_r($post); | |
| 514 | + | |
| 515 | + $new_form_settings = array(); | |
| 516 | + foreach($settings as $i) { | |
| 517 | + if (isset($post[$i])) { | |
| 518 | + $new_form_settings[$i] = $post[$i]; | |
| 519 | + } | |
| 520 | + unset($forms_data[$fid][$i]); | |
| 521 | + } | |
| 522 | + | |
| 523 | + $forms_data[$fid] += accua_forms_filter_settings($new_form_settings); | |
| 524 | + | |
| 525 | + $forms_data[$fid]['use_ajax'] = !empty($post['use_ajax']); | |
| 526 | + | |
| 527 | + update_option('accua_forms_saved_forms', $forms_data); | |
| 528 | + | |
| 529 | + //print_r($forms_data[$fid]); | |
| 530 | + | |
| 531 | + die(''); | |
| 532 | +} | |
| 533 | + | |
| 534 | +function accua_forms_field_settings_form_counter() { | |
| 535 | + static $i = 0; | |
| 536 | + $i++; | |
| 537 | + return $i; | |
| 538 | +} | |
| 539 | + | |
| 540 | +/* impostazioni dei campi */ | |
| 541 | +function accua_forms_field_text_settings_form($fid, $field_data=array(), $istance_data=array()){ | |
| 542 | + static $html_multi_number = 0; | |
| 543 | + $i = accua_forms_field_settings_form_counter(); | |
| 544 | + | |
| 545 | + $hidden = ''; | |
| 546 | + if (!is_array($istance_data)) { | |
| 547 | + if ($istance_data === 'hidden') { | |
| 548 | + $hidden = 'style="display:none"'; | |
| 549 | + } | |
| 550 | + $istance_data = array(); | |
| 551 | + $empty_istance = true; | |
| 552 | + } else { | |
| 553 | + $empty_istance = empty($istance_data); | |
| 554 | + } | |
| 555 | + | |
| 556 | + if (!is_array($field_data)){ | |
| 557 | + $field_data = array(); | |
| 558 | + } | |
| 559 | + | |
| 560 | + $field_data += array( | |
| 561 | + 'version' => '1', | |
| 562 | + 'id' => '__html', | |
| 563 | + 'name' => __( 'Custom HTML content', 'contact-forms'), | |
| 564 | + 'type' => 'html', | |
| 565 | + 'description' => __('Use this special field to inject raw HTML in the form. You can use this multiple times.', 'contact-forms'), | |
| 566 | + 'default_value' => '', | |
| 567 | + 'allowed_values' => '', | |
| 568 | + 'allowed_extensions' => '', | |
| 569 | + ); | |
| 570 | + | |
| 571 | + $override_label = isset($istance_data['label']) ? 'checked="checked"' : ''; | |
| 572 | + $override_default_value = isset($istance_data['default_value']) ? 'checked="checked"' : ''; | |
| 573 | + $override_allowed_values = isset($istance_data['allowed_values']) ? 'checked="checked"' : ''; | |
| 574 | + $override_allowed_extensions = ''; | |
| 575 | + | |
| 576 | + if ($field_data['type'] == 'file') { | |
| 577 | + if (isset($istance_data['version']) && $istance_data['version'] >= 2) { | |
| 578 | + if (isset($istance_data['allowed_extensions'])) { | |
| 579 | + $override_allowed_extensions = 'checked="checked"'; | |
| 580 | + } | |
| 581 | + } else { | |
| 582 | + if (isset($istance_data['allowed_values'])) { | |
| 583 | + $istance_data['allowed_extensions'] = $istance_data['allowed_values']; | |
| 584 | + $override_allowed_extensions = 'checked="checked"'; | |
| 585 | + } | |
| 586 | + } | |
| 587 | + | |
| 588 | + if ($field_data['version'] < 2) { | |
| 589 | + $field_data['allowed_extensions'] = $field_data['allowed_values']; | |
| 590 | + } | |
| 591 | + | |
| 592 | + if ($field_data['allowed_extensions'] === '') { | |
| 593 | + $file_data = get_option('accua_forms_default_file_field_data',array()); | |
| 594 | + if (isset($file_data['valid_extensions'])){ | |
| 595 | + $field_data['allowed_extensions'] = $file_data['valid_extensions']; | |
| 596 | + } | |
| 597 | + } | |
| 598 | + } | |
| 599 | + | |
| 600 | + if ($field_data['type'] == 'date') { | |
| 601 | + $override_mindate_values = isset($istance_data['min_date']) ? 'checked="checked"' : ''; | |
| 602 | + $override_maxdate_values = isset($istance_data['max_date']) ? 'checked="checked"' : ''; | |
| 603 | + //$override_default_value = isset($istance_data['default_date_value']) ? 'checked="checked"' : ''; | |
| 604 | + | |
| 605 | + $istance_data += array( | |
| 606 | + 'min_date' => $field_data['min_date'], | |
| 607 | + 'max_date' => $field_data['max_date'], | |
| 608 | + 'default_value' => $field_data['default_date_value'], | |
| 609 | + ); | |
| 610 | + } | |
| 611 | + | |
| 612 | + $istance_data += array( | |
| 613 | + //'version' => 1, | |
| 614 | + 'istance_id' => $field_data['id'], | |
| 615 | + 'widget_number' => '', | |
| 616 | + 'ref' => $field_data['id'], | |
| 617 | + 'label' => $field_data['name'], | |
| 618 | + 'default_value' => $field_data['default_value'], | |
| 619 | + 'allowed_values' => $field_data['allowed_values'], | |
| 620 | + 'allowed_extensions' => $field_data['allowed_extensions'], | |
| 621 | + 'required' => false, | |
| 622 | + ); | |
| 623 | + | |
| 624 | + foreach ($istance_data as $key => $value) { | |
| 625 | + $istance_data[$key] = htmlspecialchars($istance_data[$key], ENT_QUOTES); | |
| 626 | + } | |
| 627 | + | |
| 628 | + foreach ($field_data as $key => $value) { | |
| 629 | + $field_data[$key] = htmlspecialchars($field_data[$key], ENT_QUOTES); | |
| 630 | + } | |
| 631 | + | |
| 632 | + $multi_number = ''; | |
| 633 | + $add_new = ''; | |
| 634 | + | |
| 635 | + if (in_array($istance_data['ref'], array('__html','__fieldset-begin','__fieldset-end'))) { | |
| 636 | + $forceoverride_field = true; | |
| 637 | + if ($empty_istance) { | |
| 638 | + $add_new = 'multi'; | |
| 639 | + $istance_data['istance_id'] .= '-__i__'; | |
| 640 | + $istance_data['widget_number'] = 1; | |
| 641 | + $multi_number = 1 + $html_multi_number; | |
| 642 | + } else { | |
| 643 | + if ($html_multi_number < $istance_data['widget_number']) { | |
| 644 | + $html_multi_number = $istance_data['widget_number']; | |
| 645 | + } | |
| 646 | + } | |
| 647 | + } else { | |
| 648 | + $forceoverride_field = false; | |
| 649 | + $add_new = $empty_istance ? 'single' : ''; | |
| 650 | + } | |
| 651 | + | |
| 652 | + $fid = htmlspecialchars($fid, ENT_QUOTES); | |
| 653 | + $testi_eot = array ( | |
| 654 | + 'label' => __( 'Label', 'contact-forms'), | |
| 655 | + 'override' => __( 'override', 'contact-forms'), | |
| 656 | + 'default_value' => __( 'Default value', 'contact-forms'), | |
| 657 | + 'default_values' => __( 'Default value(s)', 'contact-forms'), | |
| 658 | + 'desc_def' => __( 'For multiple default values, use | as separator.', 'contact-forms'), | |
| 659 | + 'allowed_values' => __( 'Allowed values', 'contact-forms'), | |
| 660 | + 'desc_all' => __( 'The possible values this field can contain. Enter one value per line, in the format key|label. The key is the value that will be stored in the database. The label is optional, and the key will be used as the label if no label is specified.', 'contact-forms'), | |
| 661 | + 'allowed_extensions' => __( 'Allowed extensions', 'contact-forms'), | |
| 662 | + 'desc_all_ext' => __( 'Accepted file extensions. One per line, without dots.', 'contact-forms'), | |
| 663 | + 'required' => __( 'Required', 'contact-forms'), | |
| 664 | + 'custom_HTML_content' => __( 'Custom HTML content', 'contact-forms'), | |
| 665 | + 'remove' => __( 'Remove', 'contact-forms'), | |
| 666 | + 'close' => __( 'Close', 'contact-forms'), | |
| 667 | + 'save' => __( 'Save', 'contact-forms'), | |
| 668 | + 'min-of-date' => __( 'Min date', 'contact-forms'), | |
| 669 | + 'max-of-date' => __( 'Max date', 'contact-forms') | |
| 670 | + ); | |
| 671 | + | |
| 672 | + if ($forceoverride_field) { | |
| 673 | + $override_begin = ''; | |
| 674 | + $override_type = 'hidden'; | |
| 675 | + $override_end = ''; | |
| 676 | + } else { | |
| 677 | + $override_begin = "({$testi_eot['override']}: "; | |
| 678 | + $override_type = 'checkbox'; | |
| 679 | + $override_end = ')'; | |
| 680 | + } | |
| 681 | + | |
| 682 | + $content = <<<EOT | |
| 683 | + <p><label for="widget-{$istance_data['istance_id']}-label">{$testi_eot['label']}:</label> | |
| 684 | + {$override_begin}<input type="{$override_type}" name="form-field-{$istance_data['istance_id']}-override-label" value="1" {$override_label} />{$override_end}<br> | |
| 685 | + <input type="text" value="{$istance_data['label']}" name="form-field-{$istance_data['istance_id']}-label" id="widget-{$istance_data['istance_id']}-label" class="widefat"></p> | |
| 686 | +EOT; | |
| 687 | + | |
| 688 | + $default_value = <<<EOT | |
| 689 | + <p><label for="widget-{$istance_data['istance_id']}-default-value">{$testi_eot['default_value']}:</label> | |
| 690 | + {$override_begin}<input type="{$override_type}" name="form-field-{$istance_data['istance_id']}-override-default-value" value="1" {$override_default_value} />{$override_end}<br> | |
| 691 | + <input type="text" value="{$istance_data['default_value']}" name="form-field-{$istance_data['istance_id']}-default-value" id="widget-{$istance_data['istance_id']}-default-value" class="widefat"></p> | |
| 692 | +EOT; | |
| 693 | + | |
| 694 | + $default_values = <<<EOT | |
| 695 | + <p><label for="widget-{$istance_data['istance_id']}-default-value">{$testi_eot['default_value']}:</label> | |
| 696 | + {$override_begin}<input type="{$override_type}" name="form-field-{$istance_data['istance_id']}-override-default-value" value="1" {$override_default_value} />{$override_end}<br> | |
| 697 | + <input type="text" value="{$istance_data['default_value']}" name="form-field-{$istance_data['istance_id']}-default-value" id="widget-{$istance_data['istance_id']}-default-value" class="widefat"><br /> | |
| 698 | + </p> | |
| 699 | +EOT; | |
| 700 | + | |
| 701 | + $allowed_values = <<<EOT | |
| 702 | + <p><label for="widget-{$istance_data['istance_id']}-allowed-values">{$testi_eot['allowed_values']}:</label> | |
| 703 | + {$override_begin}<input type="{$override_type}" name="form-field-{$istance_data['istance_id']}-override-allowed-values" value="1" {$override_allowed_values} />{$override_end}<br> | |
| 704 | + <textarea rows="6" cols="50" name="form-field-{$istance_data['istance_id']}-allowed-values" id="widget-{$istance_data['istance_id']}-allowed-values" class="widefat">{$istance_data['allowed_values']}</textarea><br /> | |
| 705 | + {$testi_eot['desc_all']}</p> | |
| 706 | +EOT; | |
| 707 | + | |
| 708 | + $allowed_ext = <<<EOT | |
| 709 | + <p><label for="widget-{$istance_data['istance_id']}-allowed-values">{$testi_eot['allowed_extensions']}:</label> | |
| 710 | + {$override_begin}<input type="{$override_type}" name="form-field-{$istance_data['istance_id']}-override-allowed-values" value="1" {$override_allowed_extensions} />{$override_end}<br> | |
| 711 | + <textarea rows="6" cols="50" name="form-field-{$istance_data['istance_id']}-allowed-values" id="widget-{$istance_data['istance_id']}-allowed-values" class="widefat">{$istance_data['allowed_extensions']}</textarea><br /> | |
| 712 | + {$testi_eot['desc_all_ext']}</p> | |
| 713 | +EOT; | |
| 714 | + | |
| 715 | + $required_checked = empty($istance_data['required']) ? '' : 'checked="checked"'; | |
| 716 | + $required = <<<EOT | |
| 717 | + <p><label for="widget-{$istance_data['istance_id']}-required">{$testi_eot['required']}:</label> | |
| 718 | + <input type="checkbox" value="1" {$required_checked} name="form-field-{$istance_data['istance_id']}-required" id="widget-{$istance_data['istance_id']}-required"></p> | |
| 719 | +EOT; | |
| 720 | + | |
| 721 | + if ($field_data['type'] == 'date'){ | |
| 722 | + $default_date_value = <<<EOT | |
| 723 | + <p><label for="widget-{$istance_data['istance_id']}-default-value">{$testi_eot['default_value']}:</label> | |
| 724 | + {$override_begin}<input type="{$override_type}" name="form-field-{$istance_data['istance_id']}-override-default-value" value="1" {$override_default_value} />{$override_end}<br> | |
| 725 | + <input type="date" value="{$istance_data['default_value']}" name="form-field-{$istance_data['istance_id']}-default-value" id="widget-{$istance_data['istance_id']}-default-value" class="widefat"></p> | |
| 726 | +EOT; | |
| 727 | + $min_date = <<<EOT | |
| 728 | + <p><label for="widget-{$istance_data['istance_id']}-min-of-date">{$testi_eot['min-of-date']}:</label> | |
| 729 | + {$override_begin}<input type="{$override_type}" name="form-field-{$istance_data['istance_id']}-override-datemin-values" value="1" {$override_mindate_values} />{$override_end}<br> | |
| 730 | + <input type="date" value="{$istance_data['min_date']}" name="form-field-{$istance_data['istance_id']}-min-of-date" id="widget-{$istance_data['istance_id']}-min-of-date"></p> | |
| 731 | +EOT; | |
| 732 | + $max_date = <<<EOT | |
| 733 | + <p><label for="widget-{$istance_data['istance_id']}-max-of-date">{$testi_eot['max-of-date']}:</label> | |
| 734 | + {$override_begin}<input type="{$override_type}" name="form-field-{$istance_data['istance_id']}-override-datemax-values" value="1" {$override_maxdate_values} />{$override_end}<br> | |
| 735 | + <input type="date" value="{$istance_data['max_date']}" name="form-field-{$istance_data['istance_id']}-max-of-date" id="widget-{$istance_data['istance_id']}-max-of-date"></p> | |
| 736 | +EOT; | |
| 737 | + } | |
| 738 | + | |
| 739 | + switch ($field_data['type']) { | |
| 740 | + case 'textarea': | |
| 741 | + $content .= <<<EOT | |
| 742 | + <p><label for="widget-{$istance_data['istance_id']}-default-value">{$testi_eot['default_value']}:</label> | |
| 743 | + {$override_begin}<input type="{$override_type}" name="form-field-{$istance_data['istance_id']}-override-default-value" value="1" {$override_default_value} />{$override_end}<br> | |
| 744 | + <textarea rows="6" cols="50" name="form-field-{$istance_data['istance_id']}-default-value" id="widget-{$istance_data['istance_id']}-default-value" class="widefat">{$istance_data['default_value']}</textarea></p> | |
| 745 | + $required | |
| 746 | +EOT; | |
| 747 | + break; | |
| 748 | + case 'hidden': | |
| 749 | + $content = $default_value; | |
| 750 | + break; | |
| 751 | + case 'checkbox': | |
| 752 | + $content .= $default_value . $required; | |
| 753 | + break; | |
| 754 | + case 'select': | |
| 755 | + case 'radio': | |
| 756 | + case 'post-select': | |
| 757 | + $content .= $default_value . $allowed_values . $required; | |
| 758 | + break; | |
| 759 | + case 'multiselect': | |
| 760 | + case 'multicheckbox': | |
| 761 | + case 'post-multicheckbox': | |
| 762 | + $content .= $default_values . $allowed_values . $required; | |
| 763 | + break; | |
| 764 | + case 'file': | |
| 765 | + $content .= $allowed_ext . $required; | |
| 766 | + case 'submit': | |
| 767 | + case 'fieldset-begin': | |
| 768 | + //just the label | |
| 769 | + break; | |
| 770 | + case 'fieldset-end': | |
| 771 | + //Nothing! | |
| 772 | + $content = ''; | |
| 773 | + break; | |
| 774 | + case 'html': | |
| 775 | + $content = <<<EOT | |
| 776 | + <p><label for="widget-{$istance_data['istance_id']}-default-value">{$testi_eot['custom_HTML_content']}</label> | |
| 777 | + {$override_begin}<input type="{$override_type}" name="form-field-{$istance_data['istance_id']}-override-default-value" value="1" {$override_default_value} />{$override_end}<br> | |
| 778 | + <textarea rows="6" cols="50" name="form-field-{$istance_data['istance_id']}-default-value" id="widget-{$istance_data['istance_id']}-default-value" class="widefat">{$istance_data['default_value']}</textarea></p> | |
| 779 | +EOT; | |
| 780 | + break; | |
| 781 | + case 'date': | |
| 782 | + $content .= $default_date_value . $min_date . $max_date . $required; | |
| 783 | + break; | |
| 784 | + case 'email': | |
| 785 | + case 'autoreply_email': | |
| 786 | + case 'textfield': | |
| 787 | + case 'colorpicker': | |
| 788 | + case 'datepicker': | |
| 789 | + case 'dateselect': | |
| 790 | + default: | |
| 791 | + $content .= $default_value . $required; | |
| 792 | + break; | |
| 793 | + } | |
| 794 | + $adminurl = admin_url(); | |
| 795 | + | |
| 796 | + return <<<EOT | |
| 797 | +<div class="widget ui-draggable" id="widget-{$i}_{$istance_data['istance_id']}" $hidden> <div class="widget-top"> | |
| 798 | + <div class="widget-title-action"> | |
| 799 | + <a href="#available-widgets" class="widget-action hide-if-no-js"></a> | |
| 800 | + </div> | |
| 801 | + <div class="widget-title"><h4>{$field_data['name']}<span class="in-widget-title"></span></h4></div> | |
| 802 | + </div> | |
| 803 | + | |
| 804 | + <div class="widget-inside"> | |
| 805 | + <form method="post" action=""> | |
| 806 | + <div class="widget-content"> | |
| 807 | + $content | |
| 808 | + </div> | |
| 809 | + <input type="hidden" value="{$fid}" name="form-id"> | |
| 810 | + <input type="hidden" value="{$istance_data['istance_id']}" class="widget-id" name="widget-id"> | |
| 811 | + <input type="hidden" value="{$field_data['id']}" class="id_base" name="id_base"> | |
| 812 | + <input type="hidden" value="250" class="widget-width" name="widget-width"> | |
| 813 | + <input type="hidden" value="200" class="widget-height" name="widget-height"> | |
| 814 | + <input type="hidden" value="{$istance_data['widget_number']}" class="widget_number" name="widget_number"> | |
| 815 | + <input type="hidden" value="{$multi_number}" class="multi_number" name="multi_number"> | |
| 816 | + <input type="hidden" value="{$add_new}" class="add_new" name="add_new"> | |
| 817 | + | |
| 818 | + <div class="widget-control-actions"> | |
| 819 | + <div class="alignleft"> | |
| 820 | + <a href="#remove" class="widget-control-remove delete">{$testi_eot['remove']}</a> | | |
| 821 | + <a href="#close" class="widget-control-close">{$testi_eot['close']}</a> | |
| 822 | + </div> | |
| 823 | + <div class="alignright"> | |
| 824 | + <img alt="" title="" class="ajax-feedback" src="{$adminurl}images/wpspin_light.gif"> | |
| 825 | + <input type="submit" value="{$testi_eot['save']}" class="button-primary widget-control-save" id="widget-{$istance_data['istance_id']}-savewidget" name="savewidget"> | |
| 826 | + </div> | |
| 827 | + <br class="clear"> | |
| 828 | + </div> | |
| 829 | + </form> | |
| 830 | + </div> | |
| 831 | + | |
| 832 | + <!--<div class="widget-description"> | |
| 833 | + {$field_data['description']} | |
| 834 | + </div>--> | |
| 835 | +</div> | |
| 836 | + | |
| 837 | +EOT; | |
| 838 | +} | |
| 839 | + | |
| 840 | +function accua_forms_add_page($message='') { | |
| 841 | + $forms_data = get_option('accua_forms_saved_forms', array()); | |
| 842 | + $trash_data = get_option('accua_forms_trash_forms', array()); | |
| 843 | + if (!empty($_GET['fid'])) { | |
| 844 | + $fid = htmlspecialchars(stripslashes($_GET['fid']), ENT_QUOTES); | |
| 845 | + } else { | |
| 846 | + if ($message === '') { | |
| 847 | + $fid = 1 + ((int) get_option('accua_forms_lastid', 0)); | |
| 848 | + while (isset($forms_data[$fid]) || isset($trash_data[$fid])) { | |
| 849 | + $fid++; | |
| 850 | + } | |
| 851 | + update_option('accua_forms_lastid', $fid); | |
| 852 | + $message = _accua_forms_test_clonefrom($fid); | |
| 853 | + if ($message === '') { | |
| 854 | + return accua_forms_edit_page($fid); | |
| 855 | + } | |
| 856 | + } else { | |
| 857 | + $fid = ''; | |
| 858 | + } | |
| 859 | + } | |
| 860 | + if (!empty($_GET['clonefrom'])) { | |
| 861 | + check_admin_referer('clone_posts'); | |
| 862 | + $clonefrom = stripslashes($_GET['clonefrom']); | |
| 863 | + } else { | |
| 864 | + $clonefrom = ''; | |
| 865 | + } | |
| 866 | +?> | |
| 867 | + | |
| 868 | +<div id="accua_forms_add_page" class="accua_forms_admin_page wrap"> | |
| 869 | +<h2><?php _e( 'Create a form', 'contact-forms'); ?> </h2> | |
| 870 | +<?php if ($message !== '') { | |
| 871 | + echo "<div style='border:1px solid; padding: 10px;'>$message</div>"; | |
| 872 | +} ?> | |
| 873 | +<form action="admin.php" method="GET"> | |
| 874 | +<?php wp_nonce_field('edit_posts', '_wpnonce', false, true) ?> | |
| 875 | +<input type="hidden" name="page" value="accua_forms_list" /> | |
| 876 | +<p>Form id: <input type="text" name="fid" value="<?php echo $fid; ?>" /></p> | |
| 877 | +<?php | |
| 878 | + if ($forms_data) { | |
| 879 | + echo '<p><select name="clonefrom"> | |
| 880 | + <option value="">'.__( 'Empty form', 'contact-forms').'</option> | |
| 881 | + <optgroup label="'.__( 'Clone form:', 'contact-forms').'">'; | |
| 882 | + foreach ($forms_data as $i => $formdata) { | |
| 883 | + $sel = ($i == $clonefrom) ? " selected='selected'" : ''; | |
| 884 | + $i = htmlspecialchars($i, ENT_QUOTES); | |
| 885 | + if (isset($formdata['title']) && ('' !== trim($formdata['title']))) { | |
| 886 | + $formtitle = htmlspecialchars($formdata['title']); | |
| 887 | + } else { | |
| 888 | + $formtitle = $i; | |
| 889 | + } | |
| 890 | + echo "<option value='$i'$sel>$formtitle</option>\n"; | |
| 891 | + } | |
| 892 | + echo '</optgroup></select></p>'; | |
| 893 | + } | |
| 894 | +?> | |
| 895 | +<p><input type="submit" value="<?php _e( 'Create', 'contact-forms'); ?>" /></p> | |
| 896 | +</form> | |
| 897 | +</div> | |
| 898 | +<?php | |
| 899 | +} | |
| 900 | + | |
| 901 | +function _accua_forms_test_clonefrom($fid){ | |
| 902 | + $error = ''; | |
| 903 | + if (isset($_GET['clonefrom'])&&$_GET['clonefrom']!=='') { | |
| 904 | + $clonefrom = stripslashes($_GET['clonefrom']); | |
| 905 | + $forms_data = get_option('accua_forms_saved_forms', array()); | |
| 906 | + if (isset($forms_data[$fid])){ | |
| 907 | + $error .= "<p>".__( 'Form already exists', 'contact-forms')."</p>"; | |
| 908 | + } else if (empty($forms_data[$clonefrom])) { | |
| 909 | + $error .= "<p>".__( 'Source form doesn\'t exists.', 'contact-forms')."</p>"; | |
| 910 | + } else { | |
| 911 | + $forms_data[$fid] = $forms_data[$clonefrom]; | |
| 912 | + if (!isset($forms_data[$fid]['title'])) { | |
| 913 | + $forms_data[$fid]['title'] = $clonefrom ." ".__( 'clone', 'contact-forms'); | |
| 914 | + } else { | |
| 915 | + $forms_data[$fid]['title'] .= " ". __( 'clone', 'contact-forms'); | |
| 916 | + } | |
| 917 | + update_option('accua_forms_saved_forms', $forms_data); | |
| 918 | + } | |
| 919 | + } | |
| 920 | + return $error; | |
| 921 | +} | |
| 922 | + | |
| 923 | +function _accua_forms_form_edit_action() { | |
| 924 | + static $message = null; | |
| 925 | + if ($message === null) { | |
| 926 | + $message = ''; | |
| 927 | + if (isset($_POST['accua-form-edit-action'])){ | |
| 928 | + $post = stripslashes_deep($_POST); | |
| 929 | + switch ($post['accua-form-edit-action']) { | |
| 930 | + case 'delete': | |
| 931 | + $fid = $post['form-id']; | |
| 932 | + check_admin_referer('contact-forms-delete_'.$fid); | |
| 933 | + $forms_data = get_option('accua_forms_saved_forms', array()); | |
| 934 | + unset($forms_data[$fid]); | |
| 935 | + update_option('accua_forms_saved_forms', $forms_data); | |
| 936 | + $fid = htmlspecialchars($fid); | |
| 937 | + $message .= sprintf( __( 'Form "%s" deleted','contact-forms' ), $fid ); | |
| 938 | + break; | |
| 939 | + } | |
| 940 | + } | |
| 941 | + } | |
| 942 | + return $message; | |
| 943 | +} | |
| 944 | + | |
| 945 | +function accua_forms_validate_form_id($fid) { | |
| 946 | + $error = ''; | |
| 947 | + if (!preg_match('/^[a-z0-9_-]+$/i', $fid)) { | |
| 948 | + $error .= "<p>".__( 'Only letters, numbers, hyphen and underscores allowed in form identificative name', 'contact-forms')."</p>"; | |
| 949 | + } | |
| 950 | + if (substr($fid,0,2) == '__') { | |
| 951 | + $error .= "<p>".__( 'The identificative name can\'t start with two underscores (__)', 'contact-forms')."</p>"; | |
| 952 | + } | |
| 953 | + if (strlen($fid) > 70) { | |
| 954 | + $error .= "<p>".__( 'You cannot use more than 70 characters for the identificative name', 'contact-forms')."</p>"; | |
| 955 | + } | |
| 956 | + return $error; | |
| 957 | +} | |
| 958 | + | |
| 959 | +function accua_forms_list_page() { | |
| 960 | + $message = ''; | |
| 961 | + if (isset($_POST['accua-form-edit-action'])){ | |
| 962 | + $message = _accua_forms_form_edit_action(); | |
| 963 | + } else if (isset($_GET['fid'])) { | |
| 964 | + check_admin_referer('edit_posts'); | |
| 965 | + $fid = stripslashes($_GET['fid']); | |
| 966 | + $error = accua_forms_validate_form_id($fid); | |
| 967 | + if ($error === '' && (isset($_GET['clonefrom'])&&$_GET['clonefrom']!=='')) { | |
| 968 | + $error .= _accua_forms_test_clonefrom($fid); | |
| 969 | + } | |
| 970 | + if ($error === '') { | |
| 971 | + return accua_forms_edit_page($fid); | |
| 972 | + } else { | |
| 973 | + return accua_forms_add_page($error); | |
| 974 | + } | |
| 975 | + } | |
| 976 | +?> | |
| 977 | +<div id="accua_forms_list_page" class="accua_forms_admin_page wrap"> | |
| 978 | +<?php if ($message !== '') { | |
| 979 | + echo "<div style='border:1px solid; padding: 10px;'>$message</div>"; | |
| 980 | +} ?> | |
| 981 | +<h2><img src="<?php echo ACCUA_FORMS_DIR_URL.'img/cimatti-icon-20.png'; ?>"/> <?php _e( 'Contact Forms', 'contact-forms'); ?> | |
| 982 | + <a class="add-new-h2" href="<?php echo get_admin_url(); ?>admin.php?page=accua_forms_add"><?php _e('Add New','contact-forms'); ?></a> | |
| 983 | +</h2> | |
| 984 | +<div ><?php | |
| 985 | + echo strtr(__( 'Use the turquoise blue %img_c button in the TinyMCE editor to include the forms in posts, pages or other content types (shortcode and php functions also available)', 'contact-forms'), | |
| 986 | + array('%img_c'=>'<img alt="C" src="' . plugins_url('img/cimatti-icon-16.png', ACCUA_FORMS_FILE ) . '" />') | |
| 987 | + ); | |
| 988 | +?></div> | |
| 989 | +<?php | |
| 990 | +accua_forms_list_page_table(); | |
| 991 | +?> | |
| 992 | +</div> | |
| 993 | +<?php | |
| 994 | +} | |
| 995 | + | |
| 996 | +function accua_forms_edit_page($fid) { | |
| 997 | + wp_enqueue_script('jquery-ui-tabs','','','',true); | |
| 998 | + wp_enqueue_script('contact_forms_tabs', plugins_url('accua_tabs.js', ACCUA_FORMS_FILE ), array( 'jquery' ), ACCUA_FORMS_JS_VERSION); | |
| 999 | + | |
| 1000 | + if (!class_exists('AccuaFormsHelp')) { | |
| 1001 | + require_once('accua-forms-help.php'); | |
| 1002 | + } | |
| 1003 | + $accuaHelp = AccuaFormsHelp::getInstance(); | |
| 1004 | + /* | |
| 1005 | + $avail_fields = array( | |
| 1006 | + 'first_name' => array ( | |
| 1007 | + 'id' => "first_name", | |
| 1008 | + 'name' => "First Name", | |
| 1009 | + 'type' => "textfield", | |
| 1010 | + 'description' => 'This is the first name', | |
| 1011 | + ), | |
| 1012 | + 'last_name' => array ( | |
| 1013 | + 'id' => "last_name", | |
| 1014 | + 'name' => "Last Name", | |
| 1015 | + 'type' => "textfield", | |
| 1016 | + 'description' => 'This is the last name', | |
| 1017 | + ), | |
| 1018 | + 'email' => array ( | |
| 1019 | + 'id' => "email", | |
| 1020 | + 'name' => "Email", | |
| 1021 | + 'type' => "email", | |
| 1022 | + 'description' => 'This is the email', | |
| 1023 | + ), | |
| 1024 | + ); | |
| 1025 | + */ | |
| 1026 | + | |
| 1027 | + $avail_fields = get_option('accua_forms_avail_fields', array()); | |
| 1028 | + $default_form_data = get_option('accua_forms_default_form_data',array()); | |
| 1029 | + | |
| 1030 | + | |
| 1031 | + | |
| 1032 | + $form_data = _accua_forms_get_form_data($fid, true, !empty($_GET['restore'])); | |
| 1033 | + $form_overrided_data = $form_data['_overrided']; | |
| 1034 | + | |
| 1035 | + $fid_esc = htmlspecialchars($fid, ENT_QUOTES); | |
| 1036 | + | |
| 1037 | + $adminurl = admin_url(); | |
| 1038 | + | |
| 1039 | + global $wp_version; | |
| 1040 | + if (version_compare($wp_version, '4') >= 0) { | |
| 1041 | +?> | |
| 1042 | +<style> | |
| 1043 | +#widgets-right .accua-form-widget-scroll-wrapper .widget.ui-draggable { | |
| 1044 | + height: auto !important; | |
| 1045 | +} | |
| 1046 | +</style> | |
| 1047 | +<?php | |
| 1048 | + } | |
| 1049 | + | |
| 1050 | +?> | |
| 1051 | +<div id="accua_forms_edit_page" class="accua_forms_admin_page wrap"> | |
| 1052 | +<h2><img src="<?php echo ACCUA_FORMS_DIR_URL.'img/cimatti-icon-20.png'; ?>"/> <?php _e('Contact Forms - Edit Form', 'contact-forms'); ?></h2> | |
| 1053 | +<div class="accua_form_save_settings_status"></div> | |
| 1054 | +<?php wp_nonce_field('edit_form', '_nonce_edit_form'); ?> | |
| 1055 | +<div id="titlediv"><br /> | |
| 1056 | + <label id="title-prompt-text" class="screen-reader-text" for="title"><?php _e( 'Enter title here', 'contact-forms'); ?></label> | |
| 1057 | + <input id="title" type="text" autocomplete="off" value="<?php echo htmlspecialchars($form_data['title'], ENT_QUOTES) ?>" size="30" name="post_title"> | |
| 1058 | + <script type="text/javascript"> | |
| 1059 | + jQuery(function($){ | |
| 1060 | + if ( jQuery('#titlediv #title').val() == '' ) | |
| 1061 | + jQuery('#title-prompt-text').removeClass('screen-reader-text'); | |
| 1062 | + | |
| 1063 | + jQuery('#titlediv #title').focus(function() { | |
| 1064 | + jQuery('#title-prompt-text').addClass('screen-reader-text'); | |
| 1065 | + }); | |
| 1066 | + jQuery('#titlediv #title').blur(function() { | |
| 1067 | + if ( jQuery('#titlediv #title').val() == '' ) | |
| 1068 | + jQuery('#title-prompt-text').removeClass('screen-reader-text'); | |
| 1069 | + }); | |
| 1070 | + }); | |
| 1071 | + </script> | |
| 1072 | +</div> | |
| 1073 | + <div id="accua_tabs"> | |
| 1074 | + <div id="save_settings_top" class="accua_forms_save_settings_top"> | |
| 1075 | + <form id="delete_form" action="admin.php?page=accua_forms_list" method="POST" onsubmit="return confirm(<?php print htmlspecialchars(_accua_forms_json_encode(__('Do you really want to delete this form?', 'contact-forms')), ENT_QUOTES); ?>);"> | |
| 1076 | + <input type="hidden" name="accua-form-edit-action" value="delete" /> | |
| 1077 | + <input type="hidden" name="form-id" value="<?php echo $fid_esc; ?>" /> | |
| 1078 | + <input type="submit" value="<?php _e( 'Delete this form', 'contact-forms'); ?>" /> | |
| 1079 | + <?php wp_nonce_field( 'contact-forms-delete_'.$fid ); ?> | |
| 1080 | + </form> | |
| 1081 | + <?php /*<input class="button button-primary button-large accua_form_save_settings_button" id="accua_form_save_settings" type="button" value="<?php echo htmlspecialchars(__( 'Save settings', 'contact-forms'), ENT_QUOTES); ?>" /> */ ?> | |
| 1082 | + </div> | |
| 1083 | + <ul id="ul_accua_tabs"> | |
| 1084 | + <li class="tabs"><a href="#accua_tab_fields"><?php _e( 'Fields', 'contact-forms'); ?></a></li> | |
| 1085 | + <li class="tabs"><a href="#accua_tab_messages"><?php _e( 'Messages', 'contact-forms'); ?></a></li> | |
| 1086 | + <?php /*<li class="tabs"><a href="#accua_tab_preview"><?php _e( 'Preview/Test', 'contact-forms'); ?></a></li> */ ?> | |
| 1087 | + </ul> | |
| 1088 | + <div id="accua_tab_fields" class="content_tab"> | |
| 1089 | + <div style="width:50%; float:left;background: #f4f4f4;"> | |
| 1090 | + <div style="padding: 20px;"> | |
| 1091 | + <input class="button button-primary button-large accua_form_save_settings_button" id="accua_form_save_settings_inside" type="button" value="<?php echo htmlspecialchars(__( 'Save', 'contact-forms'), ENT_QUOTES); ?>" /> | |
| 1092 | + <div id="accua_tabs2"> | |
| 1093 | + <ul> | |
| 1094 | + <li class="tabs"><a href="#accua_tab_fields2"><?php _e( 'Fields', 'contact-forms'); ?></a></li> | |
| 1095 | + <li class="tabs"><a href="#accua_tab_customise"><?php _e( 'Appearance', 'contact-forms'); ?></a></li> | |
| 1096 | + </ul> | |
| 1097 | + <div id="accua_tab_fields2"> | |
| 1098 | + <h2><?php _e( 'Drag & Drop Form Fields', 'contact-forms'); ?></h2> | |
| 1099 | + <?php /*<a href="admin.php?page=accua_forms_fields" target="_blank"><strong><?php _e( 'Create new fields here', 'contact-forms'); ?></strong></a></p> */ ?> | |
| 1100 | + <div style="width:30%; float:left;"> | |
| 1101 | + <!-- Begin available fields --> | |
| 1102 | + | |
| 1103 | + <div class="widget-liquid-left" style="margin-right:0"> | |
| 1104 | + <!-- <div id="widgets-left"> --> | |
| 1105 | + <div id="widgets-left" style="margin-right:5px;"> | |
| 1106 | + <div id="available-widgets" class="widgets-holder-wrap"> | |
| 1107 | + <div class="widget-holder"> | |
| 1108 | + <div id="widget-list"> | |
| 1109 | + <!-- begin fields list --> | |
| 1110 | + | |
| 1111 | + <?php | |
| 1112 | + | |
| 1113 | + //This block must be executed before the output of available fields so accua_forms_field_text_settings_form() can initialize $html_multi_number for further html and fieldset fields | |
| 1114 | + $form_fields_html = ''; | |
| 1115 | + foreach ($form_data['fields'] as $field) { | |
| 1116 | + if (empty($avail_fields[$field['ref']])) { | |
| 1117 | + $ref = array(); | |
| 1118 | + if (!empty($field['ref'])) { | |
| 1119 | + if ($field['ref'] == '__fieldset-begin') { | |
| 1120 | + $ref = array( | |
| 1121 | + 'id' => '__fieldset-begin', | |
| 1122 | + 'name' => __('Fieldset begin', 'contact-forms'), | |
| 1123 | + 'type' => 'fieldset-begin', | |
| 1124 | + 'description' => '', | |
| 1125 | + ); | |
| 1126 | + } else if ($field['ref'] == '__fieldset-end') { | |
| 1127 | + $ref = array( | |
| 1128 | + 'id' => '__fieldset-end', | |
| 1129 | + 'name' => __('Fieldset end', 'contact-forms'), | |
| 1130 | + 'type' => 'fieldset-end', | |
| 1131 | + 'description' => '', | |
| 1132 | + ); | |
| 1133 | + } | |
| 1134 | + } | |
| 1135 | + } else { | |
| 1136 | + $ref = $avail_fields[$field['ref']]; | |
| 1137 | + } | |
| 1138 | + | |
| 1139 | + //print_r($ref); | |
| 1140 | + $form_fields_html .= accua_forms_field_text_settings_form($fid, $ref, $field); | |
| 1141 | + } | |
| 1142 | + | |
| 1143 | + | |
| 1144 | + foreach ($avail_fields as $avail_field) { | |
| 1145 | + $hidden = (empty($form_data['fields'][$avail_field['id']])) ? false : 'hidden'; | |
| 1146 | + echo accua_forms_field_text_settings_form($fid, $avail_field, $hidden); | |
| 1147 | + } | |
| 1148 | + //Custom HTML field | |
| 1149 | + echo accua_forms_field_text_settings_form($fid); | |
| 1150 | + //Fieldset begin | |
| 1151 | + echo accua_forms_field_text_settings_form($fid, array( | |
| 1152 | + 'id' => '__fieldset-begin', | |
| 1153 | + 'name' => __( 'Fieldset begin', 'contact-forms'), | |
| 1154 | + 'type' => 'fieldset-begin', | |
| 1155 | + 'description' => __('You can use this field multiple times.', 'contact-forms'), | |
| 1156 | + 'default_value' => '', | |
| 1157 | + 'allowed_values' => '', | |
| 1158 | + )); | |
| 1159 | + //Fieldset end | |
| 1160 | + echo accua_forms_field_text_settings_form($fid, array( | |
| 1161 | + 'id' => '__fieldset-end', | |
| 1162 | + 'name' => __( 'Fieldset end', 'contact-forms'), | |
| 1163 | + 'type' => 'fieldset-end', | |
| 1164 | + 'description' => __('You can use this field multiple times.', 'contact-forms'), | |
| 1165 | + 'default_value' => '', | |
| 1166 | + 'allowed_values' => '', | |
| 1167 | + )); | |
| 1168 | + ?> | |
| 1169 | + | |
| 1170 | + <!-- end fields list --> | |
| 1171 | + </div> | |
| 1172 | + | |
| 1173 | + <br class='clear' /> | |
| 1174 | + </div> | |
| 1175 | + <br class="clear" /> | |
| 1176 | + </div> | |
| 1177 | + | |
| 1178 | + </div> | |
| 1179 | + </div> | |
| 1180 | + <!-- End available fields --> | |
| 1181 | + </div> | |
| 1182 | + | |
| 1183 | + <div style="width:70%; float:left;" class="container"> | |
| 1184 | + <!-- | |
| 1185 | + <h3>Form Fields</h3> | |
| 1186 | + <div id="form_fields_container"> | |
| 1187 | + </div> | |
| 1188 | + --> | |
| 1189 | + | |
| 1190 | + <div class="widget-liquid-right" style="width:100%"> | |
| 1191 | + <div id="widgets-right" style="width:100%"> | |
| 1192 | + <div class="widgets-holder-wrap dashed"> | |
| 1193 | + <div class="sidebar-name"> | |
| 1194 | + <div class="sidebar-name-arrow"><br></div> | |
| 1195 | + <h3><?php _e( 'Drop fields here', 'contact-forms'); ?> <span><img alt="" title="" class="ajax-feedback" src="<?php echo $adminurl;?>images/wpspin_light.gif"></span></h3> | |
| 1196 | + </div> | |
| 1197 | + <div class="widgets-sortables ui-sortable" id="cimatti-accua-fields-form-area-<?php echo $fid_esc ?>"> | |
| 1198 | + <?php echo $form_fields_html; ?> | |
| 1199 | + </div> | |
| 1200 | + </div> | |
| 1201 | + </div> | |
| 1202 | + </div> | |
| 1203 | + | |
| 1204 | + </div> | |
| 1205 | + </div> | |
| 1206 | + <div id="accua_tab_customise"> | |
| 1207 | + <div style="width: 48%; float:left;"> | |
| 1208 | + <h3><?php _e( 'General', 'contact-forms'); ?></h3> | |
| 1209 | + <p id="accua_form_use_ajax"><input class="accua_form_value" type="checkbox" value="1" <?php if (!empty($form_data['use_ajax'])) {echo 'checked="checked" ';} ?>/><?php _e('Do not reload the page on form submission', 'contact-forms'); ?></p> | |
| 1210 | + | |
| 1211 | + <p id="accua_form_layout"><?php _e( 'Labels', 'contact-forms'); ?> <select name="layout" class="accua_form_value"> | |
| 1212 | + <option value="" <?php if (isset($form_overrided_data['layout'])) { echo 'selected="selected"'; } ?>>default (<?php if($default_form_data['layout']=='sidebyside') _e( 'Labels on the left of the fields', 'contact-forms'); else _e( 'Labels on top of the fields', 'contact-forms'); ?>)</option><option value="sidebyside" <?php if ((isset($form_overrided_data['layout'])) && ($form_data['layout'] == 'sidebyside')) { echo 'selected="selected"'; } ?>><?php _e( 'Labels on the left of the fields', 'contact-forms'); ?></option><option value="toplabel" <?php if ((isset($form_overrided_data['layout'])) && ($form_data['layout'] == 'toplabel')) { echo 'selected="selected"'; } ?>><?php _e( 'Labels on top of the fields', 'contact-forms'); ?></option></select> | |
| 1213 | + </p> | |
| 1214 | + | |
| 1215 | + <div id="accua_form_style_margin" class="label_input" class="label_container"> | |
| 1216 | + <input name="accua_form_style_margin" class="accua_form_check_override" type="checkbox" value="1" <?php if (isset($form_overrided_data['style_margin'])) {echo 'checked="checked" ';} ?>/><strong><?php _e( 'Margin', 'contact-forms'); ?></strong> | |
| 1217 | + <div class="default_value"><?php echo htmlspecialchars($default_form_data['style_margin']); ?></div> | |
| 1218 | + <input class="accua_form_value" type="text" value="<?php echo htmlspecialchars($form_data['style_margin'], ENT_QUOTES) ?>" /> | |
| 1219 | + | |
| 1220 | + </div> | |
| 1221 | + | |
| 1222 | + <div class="label_input"> | |
| 1223 | + <div id="accua_form_style_border_color" class="label_container"> | |
| 1224 | + <input name="accua_form_style_border_color" class="accua_form_check_override" type="checkbox" value="1" <?php if (isset($form_overrided_data['style_border_color'])) {echo 'checked="checked" ';} ?>/><strong><?php _e( 'Border color', 'contact-forms'); ?></strong> | |
| 1225 | + <div class="default_value"><?php echo htmlspecialchars($default_form_data['style_border_color']); ?></div> | |
| 1226 | + <input class="accua_form_value" type="text" value="<?php echo htmlspecialchars($form_data['style_border_color'], ENT_QUOTES) ?>" /> | |
| 1227 | + </div> | |
| 1228 | + <div id="accua_form_style_border_width" class="label_container"> | |
| 1229 | + <input name="accua_form_style_border_width" class="accua_form_check_override" type="checkbox" value="1" <?php if (isset($form_overrided_data['style_border_width'])) {echo 'checked="checked" ';} ?>/><?php _e( 'Width', 'contact-forms'); ?> | |
| 1230 | + <div class="default_value"><?php echo htmlspecialchars($default_form_data['style_border_width']); ?></div> | |
| 1231 | + <input class="accua_form_value" type="text" value="<?php echo htmlspecialchars($form_data['style_border_width'], ENT_QUOTES) ?>" /> | |
| 1232 | + </div> | |
| 1233 | + <div id="accua_form_style_border_radius" class="label_container"> | |
| 1234 | + <input name="accua_form_style_border_radius" class="accua_form_check_override" type="checkbox" value="1" <?php if (isset($form_overrided_data['style_border_radius'])) {echo 'checked="checked" ';} ?>/><?php _e( 'Radius', 'contact-forms'); ?> | |
| 1235 | + <div class="default_value"><?php echo htmlspecialchars($default_form_data['style_border_radius']); ?></div> | |
| 1236 | + <input class="accua_form_value" type="text" value="<?php echo htmlspecialchars($form_data['style_border_radius'], ENT_QUOTES) ?>" /> | |
| 1237 | + </div> | |
| 1238 | + </div> | |
| 1239 | + | |
| 1240 | + <div class="label_input"> | |
| 1241 | + <div id="accua_form_style_background_color" class="label_container"> | |
| 1242 | + <input name="accua_form_style_background_color" class="accua_form_check_override" type="checkbox" value="1" <?php if (isset($form_overrided_data['style_background_color'])) {echo 'checked="checked" ';} ?>/><strong><?php _e( 'Background', 'contact-forms'); ?></strong> | |
| 1243 | + <div class="default_value"><?php echo htmlspecialchars($default_form_data['style_background_color']); ?></div> | |
| 1244 | + <input class="accua_form_value" type="text" value="<?php echo htmlspecialchars($form_data['style_background_color'], ENT_QUOTES) ?>" /> | |
| 1245 | + </div> | |
| 1246 | + | |
| 1247 | + <div id="accua_form_style_padding" class="label_container"> | |
| 1248 | + <input name="accua_form_style_padding" class="accua_form_check_override" type="checkbox" value="1" <?php if (isset($form_overrided_data['style_padding'])) {echo 'checked="checked" ';} ?>/><strong><?php _e( 'Padding', 'contact-forms'); ?></strong> | |
| 1249 | + <div class="default_value"><?php echo htmlspecialchars($default_form_data['style_padding']); ?></div> | |
| 1250 | + <input class="accua_form_value" type="text" value="<?php echo htmlspecialchars($form_data['style_padding'], ENT_QUOTES) ?>" /> | |
| 1251 | + </div> | |
| 1252 | + </div> | |
| 1253 | + <div class="label_input"> | |
| 1254 | + <div id="accua_form_style_color" class="label_container"> | |
| 1255 | + <input name="accua_form_style_color" class="accua_form_check_override" type="checkbox" value="1" <?php if (isset($form_overrided_data['style_color'])) {echo 'checked="checked" ';} ?>/><strong><?php _e( 'Font', 'contact-forms'); ?></strong> | |
| 1256 | + <div class="default_value"><?php echo htmlspecialchars($default_form_data['style_color']); ?></div> | |
| 1257 | + <input class="accua_form_value" type="text" value="<?php echo htmlspecialchars($form_data['style_color'], ENT_QUOTES) ?>" /> | |
| 1258 | + </div> | |
| 1259 | + | |
| 1260 | + <div id="accua_form_style_font_size" class="label_container"> | |
| 1261 | + <input name="accua_form_style_font_size" class="accua_form_check_override" type="checkbox" value="1" <?php if (isset($form_overrided_data['style_font_size'])) {echo 'checked="checked" ';} ?>/><?php _e( 'Size', 'contact-forms'); ?> | |
| 1262 | + <div class="default_value"><?php echo htmlspecialchars($default_form_data['style_font_size']); ?></div> | |
| 1263 | + <input class="accua_form_value" type="text" value="<?php echo htmlspecialchars($form_data['style_font_size'], ENT_QUOTES) ?>" /> | |
| 1264 | + </div> | |
| 1265 | + </div> | |
| 1266 | + </div> | |
| 1267 | + <div style="width: 48%; float:left;"> | |
| 1268 | + | |
| 1269 | + <h3><?php _e( 'Fields', 'contact-forms'); ?></h3> | |
| 1270 | + | |
| 1271 | + <div id="accua_form_style_field_spacing" class="label_input"> | |
| 1272 | + <input name="accua_form_style_field_spacing" class="accua_form_check_override" type="checkbox" value="1" <?php if (isset($form_overrided_data['style_field_spacing'])) {echo 'checked="checked" ';} ?>/><?php _e( 'Spacing', 'contact-forms'); ?> | |
| 1273 | + <div class="default_value"><?php echo htmlspecialchars($default_form_data['style_field_spacing']); ?></div> | |
| 1274 | + <input class="accua_form_value" type="text" value="<?php echo htmlspecialchars($form_data['style_field_spacing'], ENT_QUOTES) ?>" /> | |
| 1275 | + </div> | |
| 1276 | + | |
| 1277 | + <div id="accua_form_style_field_border_color" class="label_input"> | |
| 1278 | + <input name="accua_form_style_field_border_color" class="accua_form_check_override" type="checkbox" value="1" <?php if (isset($form_overrided_data['style_field_border_color'])) {echo 'checked="checked" ';} ?>/><?php _e( 'Border color', 'contact-forms'); ?> | |
| 1279 | + <div class="default_value"><?php echo htmlspecialchars($default_form_data['style_field_border_color']); ?></div> | |
| 1280 | + <input class="accua_form_value" type="text" value="<?php echo htmlspecialchars($form_data['style_field_border_color'], ENT_QUOTES) ?>" /> | |
| 1281 | + </div> | |
| 1282 | + | |
| 1283 | + <div id="accua_form_style_field_border_width" class="label_input"> | |
| 1284 | + <input name="accua_form_style_field_border_width" class="accua_form_check_override" type="checkbox" value="1" <?php if (isset($form_overrided_data['style_field_border_width'])) {echo 'checked="checked" ';} ?>/><?php _e( 'Border width', 'contact-forms'); ?> | |
| 1285 | + <div class="default_value"><?php echo htmlspecialchars($default_form_data['style_field_border_width']); ?></div> | |
| 1286 | + <input class="accua_form_value" type="text" value="<?php echo htmlspecialchars($form_data['style_field_border_width'], ENT_QUOTES) ?>" /> | |
| 1287 | + </div> | |
| 1288 | + | |
| 1289 | + <div id="accua_form_style_field_border_radius" class="label_input"> | |
| 1290 | + <input name="accua_form_style_field_border_radius" class="accua_form_check_override" type="checkbox" value="1" <?php if (isset($form_overrided_data['style_field_border_radius'])) {echo 'checked="checked" ';} ?>/><?php _e( 'Rounded corner radius', 'contact-forms'); ?> | |
| 1291 | + <div class="default_value"><?php echo htmlspecialchars($default_form_data['style_field_border_radius']); ?></div> | |
| 1292 | + <input class="accua_form_value" type="text" value="<?php echo htmlspecialchars($form_data['style_field_border_radius'], ENT_QUOTES) ?>" /> | |
| 1293 | + </div> | |
| 1294 | + | |
| 1295 | + <div id="accua_form_style_field_background_color" class="label_input"> | |
| 1296 | + <input name="accua_form_style_field_background_color" class="accua_form_check_override" type="checkbox" value="1" <?php if (isset($form_overrided_data['style_field_background_color'])) {echo 'checked="checked" ';} ?>/><?php _e( 'Background color', 'contact-forms'); ?> | |
| 1297 | + <div class="default_value"><?php echo htmlspecialchars($default_form_data['style_field_background_color']); ?></div> | |
| 1298 | + <input class="accua_form_value" type="text" value="<?php echo htmlspecialchars($form_data['style_field_background_color'], ENT_QUOTES) ?>" /> | |
| 1299 | + </div> | |
| 1300 | + | |
| 1301 | + <div id="accua_form_style_field_padding" class="label_input"> | |
| 1302 | + <input name="accua_form_style_field_padding" class="accua_form_check_override" type="checkbox" value="1" <?php if (isset($form_overrided_data['style_field_padding'])) {echo 'checked="checked" ';} ?>/><?php _e( 'Padding', 'contact-forms'); ?> | |
| 1303 | + <div class="default_value"><?php echo htmlspecialchars($default_form_data['style_field_padding']); ?></div> | |
| 1304 | + <input class="accua_form_value" type="text" value="<?php echo htmlspecialchars($form_data['style_field_padding'], ENT_QUOTES) ?>" /> | |
| 1305 | + </div> | |
| 1306 | + | |
| 1307 | + <div id="accua_form_style_field_color" class="label_input"> | |
| 1308 | + <input name="accua_form_style_field_color" class="accua_form_check_override" type="checkbox" value="1" <?php if (isset($form_overrided_data['style_field_color'])) {echo 'checked="checked" ';} ?>/><?php _e( 'Text color', 'contact-forms'); ?> | |
| 1309 | + <div class="default_value"><?php echo htmlspecialchars($default_form_data['style_field_color']); ?></div> | |
| 1310 | + <input class="accua_form_value" type="text" value="<?php echo htmlspecialchars($form_data['style_field_color'], ENT_QUOTES) ?>" /> | |
| 1311 | + </div> | |
| 1312 | + | |
| 1313 | + | |
| 1314 | + <h3><?php _e( 'Submit button', 'contact-forms'); ?></h3> | |
| 1315 | + | |
| 1316 | + <div id="accua_form_style_submit_border_color" class="label_input"> | |
| 1317 | + <input name="accua_form_style_submit_border_color" class="accua_form_check_override" type="checkbox" value="1" <?php if (isset($form_overrided_data['style_submit_border_color'])) {echo 'checked="checked" ';} ?>/><?php _e( 'Border color', 'contact-forms'); ?> | |
| 1318 | + <div class="default_value"><?php echo htmlspecialchars($default_form_data['style_submit_border_color']); ?></div> | |
| 1319 | + <input class="accua_form_value" type="text" value="<?php echo htmlspecialchars($form_data['style_submit_border_color'], ENT_QUOTES) ?>" /> | |
| 1320 | + <?php _e( 'Customize', 'contact-forms'); ?> | |
| 1321 | + </div> | |
| 1322 | + | |
| 1323 | + <div id="accua_form_style_submit_border_width" class="label_input"> | |
| 1324 | + <input name="accua_form_style_submit_border_width" class="accua_form_check_override" type="checkbox" value="1" <?php if (isset($form_overrided_data['style_submit_border_width'])) {echo 'checked="checked" ';} ?>/><?php _e( 'Border width', 'contact-forms'); ?> | |
| 1325 | + <div class="default_value"><?php echo htmlspecialchars($default_form_data['style_submit_border_width']); ?></div> | |
| 1326 | + <input class="accua_form_value" type="text" value="<?php echo htmlspecialchars($form_data['style_submit_border_width'], ENT_QUOTES) ?>" /> | |
| 1327 | + </div> | |
| 1328 | + | |
| 1329 | + <div id="accua_form_style_submit_border_radius" class="label_input"> | |
| 1330 | + <input name="accua_form_style_submit_border_radius" class="accua_form_check_override" type="checkbox" value="1" <?php if (isset($form_overrided_data['style_submit_border_radius'])) {echo 'checked="checked" ';} ?>/><?php _e( 'Rounded corner radius', 'contact-forms'); ?> | |
| 1331 | + <div class="default_value"><?php echo htmlspecialchars($default_form_data['style_submit_border_radius']); ?></div> | |
| 1332 | + <input class="accua_form_value" type="text" value="<?php echo htmlspecialchars($form_data['style_submit_border_radius'], ENT_QUOTES) ?>" /> | |
| 1333 | + </div> | |
| 1334 | + | |
| 1335 | + <div id="accua_form_style_submit_background_color" class="label_input"> | |
| 1336 | + <input name="accua_form_style_submit_background_color" class="accua_form_check_override" type="checkbox" value="1" <?php if (isset($form_overrided_data['style_submit_background_color'])) {echo 'checked="checked" ';} ?>/><?php _e( 'Background color', 'contact-forms'); ?> | |
| 1337 | + <div class="default_value"><?php echo htmlspecialchars($default_form_data['style_submit_background_color']); ?></div> | |
| 1338 | + <input class="accua_form_value" type="text" value="<?php echo htmlspecialchars($form_data['style_submit_background_color'], ENT_QUOTES) ?>" /> | |
| 1339 | + </div> | |
| 1340 | + | |
| 1341 | + <div id="accua_form_style_submit_padding" class="label_input"> | |
| 1342 | + <input name="accua_form_style_submit_padding" class="accua_form_check_override" type="checkbox" value="1" <?php if (isset($form_overrided_data['style_submit_padding'])) {echo 'checked="checked" ';} ?>/><?php _e( 'Padding', 'contact-forms'); ?> | |
| 1343 | + <div class="default_value"><?php echo htmlspecialchars($default_form_data['style_submit_padding']); ?></div> | |
| 1344 | + <input class="accua_form_value" type="text" value="<?php echo htmlspecialchars($form_data['style_submit_padding'], ENT_QUOTES) ?>" /> | |
| 1345 | + </div> | |
| 1346 | + | |
| 1347 | + <div id="accua_form_style_submit_color" class="label_input"> | |
| 1348 | + <input name="accua_form_style_submit_color" class="accua_form_check_override" type="checkbox" value="1" <?php if (isset($form_overrided_data['style_submit_color'])) {echo 'checked="checked" ';} ?>/><?php _e( 'Text color', 'contact-forms'); ?> | |
| 1349 | + <div class="default_value"><?php echo htmlspecialchars($default_form_data['style_submit_color']); ?></div> | |
| 1350 | + <input class="accua_form_value" type="text" value="<?php echo htmlspecialchars($form_data['style_submit_color'], ENT_QUOTES) ?>" /> | |
| 1351 | + </div> | |
| 1352 | + | |
| 1353 | + <div id="accua_form_style_submit_font_size" class="label_input"> | |
| 1354 | + <input name="accua_form_style_submit_font_size" class="accua_form_check_override" type="checkbox" value="1" <?php if (isset($form_overrided_data['style_submit_font_size'])) {echo 'checked="checked" ';} ?>/><?php _e( 'Font size', 'contact-forms'); ?> | |
| 1355 | + <div class="default_value"><?php echo htmlspecialchars($default_form_data['style_submit_font_size']); ?></div> | |
| 1356 | + <input class="accua_form_value" type="text" value="<?php echo htmlspecialchars($form_data['style_submit_font_size'], ENT_QUOTES) ?>" /> | |
| 1357 | + </div> | |
| 1358 | + | |
| 1359 | + <br clear="all"/> | |
| 1360 | + </div> | |
| 1361 | + </div> | |
| 1362 | + </div> | |
| 1363 | + | |
| 1364 | + | |
| 1365 | + | |
| 1366 | + </div> | |
| 1367 | + </div> | |
| 1368 | + <div style="width:50%; float:right;"> | |
| 1369 | + <div style="padding: 15px;"> | |
| 1370 | + <h2><?php _e('Preview', 'contact-forms'); ?> | |
| 1371 | + <?php echo $accuaHelp->add_pointer('form_edit_preview'); ?> | |
| 1372 | + </h2> | |
| 1373 | + <div id="accua_form_preview_area_wrapper"> | |
| 1374 | + <?php | |
| 1375 | + echo "<script> | |
| 1376 | + function resizeIframe(obj) { | |
| 1377 | + altezza = obj.contentWindow.document.documentElement.scrollHeight + 200; | |
| 1378 | + obj.style.height = altezza + 'px'; | |
| 1379 | + } | |
| 1380 | + </script>"; | |
| 1381 | + | |
| 1382 | + ?> | |
| 1383 | + <iframe id="accua_form_preview_area" src="admin-ajax.php?action=accua_forms_preview&fid=<?php echo htmlspecialchars($fid,ENT_QUOTES);?>" frameborder="0" scrolling="no" onload="resizeIframe(this)" ></iframe> | |
| 1384 | + <?php //todo: posso usare lo stile del sito? font ecc ?> | |
| 1385 | + </div> | |
| 1386 | + | |
| 1387 | + </div> | |
| 1388 | + </div> | |
| 1389 | + | |
| 1390 | + <div style="clear:both;"> </div> | |
| 1391 | + | |
| 1392 | + <?php /* * / ?> | |
| 1393 | + <pre> | |
| 1394 | + accua_forms_form_fields_order_post: <?php echo htmlspecialchars(print_r(get_option('accua_forms_form_fields_order_post'), true)); ?> | |
| 1395 | + | |
| 1396 | + accua_forms_save_form_field_post: <?php echo htmlspecialchars(print_r(get_option('accua_forms_save_form_field_post'), true)); ?> | |
| 1397 | + | |
| 1398 | + accua_forms_saved_form_data: <?php echo htmlspecialchars(print_r($form_data, true)); ?> | |
| 1399 | + | |
| 1400 | + </pre> | |
| 1401 | + <?php /* */ ?> | |
| 1402 | +</div> | |
| 1403 | + <div id="accua_tab_messages" class="content_tab"> | |
| 1404 | + <?php | |
| 1405 | + $settings_editor = array( | |
| 1406 | + 'teeny' => true, | |
| 1407 | + 'editor_class' => 'accua_form_value', | |
| 1408 | + 'tinymce' => array( | |
| 1409 | + 'theme_advanced_buttons1' => 'bold,italic,underline,|,bullist,numlist,')); | |
| 1410 | + ?> | |
| 1411 | + | |
| 1412 | + <div class="metabox-holder accua-forms-metabox-holder"> | |
| 1413 | + <div class="postbox "> | |
| 1414 | + <h3 class="hndle"><span><?php _e('1. On-screen success message', 'contact-forms'); ?></span></h3> | |
| 1415 | + <div class="inside" id="dashboard_right_now"> | |
| 1416 | + <div id="accua_form_success_message"> | |
| 1417 | + <input class="accua_form_check_override" name="accua_form_success_message" type="radio" value="0" <?php if (!isset($form_overrided_data['success_message'])) {echo ' checked ';} ?>> <?php _e( 'Use the default message', 'contact-forms'); ?> | |
| 1418 | + <input class="accua_form_check_override" name="accua_form_success_message" type="radio" value="1" <?php if (isset($form_overrided_data['success_message']) && !isset($form_overrided_data['success_message_no_message'])) {echo ' checked ';} ?>/> <?php _e( 'Customize', 'contact-forms'); ?> | |
| 1419 | + <input class="accua_form_check_override" name="accua_form_success_message" type="radio" value="-1" <?php if (isset($form_overrided_data['success_message_no_message'])) {echo ' checked ';} ?>/> <?php _e( 'Don\'t show any messages', 'contact-forms'); ?><br /> | |
| 1420 | + <div class="defalut_message"> | |
| 1421 | + <?php _e( 'Default Success message', 'contact-forms'); ?> | |
| 1422 | + <div class="defalut_content_message"><?php echo wpautop($default_form_data['success_message']); ?></div> | |
| 1423 | + </div> | |
| 1424 | + <?php wp_editor( $form_data['success_message'] , 'accua_form_success_message_textarea' , $settings_editor); ?> | |
| 1425 | + <!-- <textarea class="accua_form_value" style="width:95%"; cols="80" rows="8"><?php echo htmlspecialchars($form_data['success_message'], ENT_QUOTES) ?></textarea> --> | |
| 1426 | + </div> | |
| 1427 | + </div> | |
| 1428 | + </div> | |
| 1429 | + </div> | |
| 1430 | + | |
| 1431 | + <div class="metabox-holder accua-forms-metabox-holder"> | |
| 1432 | + <div class="postbox "> | |
| 1433 | + <h3 class="hndle"><span><?php _e('2. On-screen error message', 'contact-forms'); ?></span></h3> | |
| 1434 | + <div class="inside" id="dashboard_right_now"> | |
| 1435 | + <div id="accua_form_error_message"> | |
| 1436 | + <input class="accua_form_check_override" name="accua_form_error_message" type="radio" value="0" <?php if (!isset($form_overrided_data['error_message'])) {echo ' checked ';} ?>> <?php _e( 'Use the default message', 'contact-forms'); ?> | |
| 1437 | + <input class="accua_form_check_override" name="accua_form_error_message" type="radio" value="1" <?php if (isset($form_overrided_data['error_message']) && !isset($form_overrided_data['error_message_no_message'])) {echo ' checked ';} ?>/> <?php _e( 'Customize', 'contact-forms'); ?> | |
| 1438 | + <input class="accua_form_check_override" name="accua_form_error_message" type="radio" value="-1" <?php if (isset($form_overrided_data['error_message_no_message'])) {echo ' checked ';} ?>/> <?php _e( 'Don\'t show any messages', 'contact-forms'); ?><br /> | |
| 1439 | + <div class="defalut_message"> | |
| 1440 | + <?php _e( 'Default error message', 'contact-forms'); ?> <br /> | |
| 1441 | + <div class="defalut_content_message" ><?php echo wpautop($default_form_data['error_message']); ?></div> | |
| 1442 | + </div> | |
| 1443 | + <?php wp_editor( $form_data['error_message'] , 'accua_form_error_message_textarea' , $settings_editor); ?> | |
| 1444 | + </div> | |
| 1445 | + </div> | |
| 1446 | + </div> | |
| 1447 | + </div> | |
| 1448 | + <br clear="all"/> | |
| 1449 | + <div class="metabox-holder accua-forms-metabox-holder"> | |
| 1450 | + <div class="postbox "> | |
| 1451 | + <h3 class="hndle"><span><?php _e('3. Email to notify administrator', 'contact-forms'); ?></span></h3> | |
| 1452 | + <div class="inside" id="dashboard_right_now"> | |
| 1453 | + <div id="accua_form_admin_emails_to" class="label_input"> | |
| 1454 | + <label><?php _e('To', 'contact-forms'); ?></label> | |
| 1455 | + <div class="default_value"><?php echo htmlspecialchars($default_form_data['admin_emails_to']); ?></div> | |
| 1456 | + <input class="accua_form_value" type="text" value="<?php echo htmlspecialchars($form_data['admin_emails_to'], ENT_QUOTES) ?>" /> | |
| 1457 | + <input name="accua_form_admin_emails_to" class="accua_form_check_override" type="checkbox" value="1" <?php if (isset($form_overrided_data['admin_emails_to'])) {echo 'checked="checked" ';} ?>/><?php _e( 'Customize', 'contact-forms'); ?> | |
| 1458 | + </div> | |
| 1459 | + <div id="accua_form_emails_bcc" class="label_input"> | |
| 1460 | + <label><?php _e('Bcc', 'contact-forms'); ?></label> | |
| 1461 | + <div class="default_value"><?php echo htmlspecialchars($default_form_data['emails_bcc']); ?></div> | |
| 1462 | + <input class="accua_form_value" type="text" value="<?php echo htmlspecialchars($form_data['emails_bcc'], ENT_QUOTES) ?>" /> | |
| 1463 | + <input name ="accua_form_emails_bcc" class="accua_form_check_override" type="checkbox" value="1" <?php if (isset($form_overrided_data['emails_bcc'])) {echo 'checked="checked" ';} ?>/><?php _e( 'Customize', 'contact-forms'); ?> | |
| 1464 | + </div> | |
| 1465 | + | |
| 1466 | + <div id="accua_form_admin_emails_subject" class="label_input"> | |
| 1467 | + <label><?php _e( 'Subject', 'contact-forms'); ?></label> | |
| 1468 | + <div class="default_value"><?php echo htmlspecialchars($default_form_data['admin_emails_subject']); ?></div> | |
| 1469 | + <input class="accua_form_value" type="text" value="<?php echo htmlspecialchars($form_data['admin_emails_subject'], ENT_QUOTES) ?>" /> | |
| 1470 | + <input name="accua_form_admin_emails_subject" class="accua_form_check_override" type="checkbox" value="1" <?php if (isset($form_overrided_data['admin_emails_subject'])) {echo 'checked="checked" ';} ?>/><?php _e( 'Customize', 'contact-forms'); ?> | |
| 1471 | + </div> | |
| 1472 | + | |
| 1473 | + <div id="accua_form_admin_emails_message"> | |
| 1474 | + <input class="accua_form_check_override" name="accua_form_admin_emails_message" type="radio" value="0" <?php if (!isset($form_overrided_data['admin_emails_message'])) {echo ' checked ';} ?>> <?php _e( 'Use the default message', 'contact-forms'); ?> | |
| 1475 | + <input class="accua_form_check_override" name="accua_form_admin_emails_message" type="radio" value="1" <?php if (isset($form_overrided_data['admin_emails_message']) && !isset($form_overrided_data['admin_emails_message_no_message'])) {echo ' checked ';} ?>/> <?php _e( 'Customize', 'contact-forms'); ?> | |
| 1476 | + <input class="accua_form_check_override" name="accua_form_admin_emails_message" type="radio" value="-1" <?php if (isset($form_overrided_data['admin_emails_message_no_message'])) {echo ' checked ';} ?>/> <?php _e( 'Don\'t show any messages', 'contact-forms'); ?><br /> | |
| 1477 | + <div class="defalut_message"> | |
| 1478 | + <?php _e( 'Default message', 'contact-forms'); ?> | |
| 1479 | + <div class="defalut_content_message"><?php echo wpautop($default_form_data['admin_emails_message']); ?></div> | |
| 1480 | + </div> | |
| 1481 | + <?php wp_editor( $form_data['admin_emails_message'] , 'accua_form_admin_emails_message_textarea' , $settings_editor); ?> | |
| 1482 | + </div> | |
| 1483 | + | |
| 1484 | + </div> | |
| 1485 | + </div> | |
| 1486 | + </div> | |
| 1487 | + | |
| 1488 | + <div class="metabox-holder accua-forms-metabox-holder"> | |
| 1489 | + <div class="postbox "> | |
| 1490 | + <h3 class="hndle"><span><?php _e('4. Email confirmation to the person who completed the form', 'contact-forms'); ?></span></h3> | |
| 1491 | + <div class="inside" id="dashboard_right_now"> | |
| 1492 | + <div id="accua_form_emails_from_name" class="label_input"> | |
| 1493 | + <label><?php _e( 'From name', 'contact-forms'); ?></label> | |
| 1494 | + <div class="default_value"><?php echo htmlspecialchars($default_form_data['emails_from_name']); ?></div> | |
| 1495 | + <input class="accua_form_value" type="text" value="<?php echo htmlspecialchars($form_data['emails_from_name'], ENT_QUOTES) ?>" /> | |
| 1496 | + <input name="accua_form_emails_from_name" class="accua_form_check_override" type="checkbox" value="1" <?php if (isset($form_overrided_data['emails_from_name'])) {echo 'checked="checked" ';} ?>/><?php _e( 'Customize', 'contact-forms'); ?> | |
| 1497 | + </div> | |
| 1498 | + <div id="accua_form_emails_from" class="label_input"> | |
| 1499 | + <label><?php _e( 'From email', 'contact-forms'); ?></label> | |
| 1500 | + <div class="default_value"><?php echo htmlspecialchars($default_form_data['emails_from']); ?></div> | |
| 1501 | + <input class="accua_form_value" type="text" value="<?php echo htmlspecialchars($form_data['emails_from'], ENT_QUOTES) ?>" /> | |
| 1502 | + <input name="accua_form_emails_from" class="accua_form_check_override" type="checkbox" value="1" <?php if (isset($form_overrided_data['emails_from'])) {echo 'checked="checked" ';} ?>/><?php _e( 'Customize', 'contact-forms'); ?> | |
| 1503 | + </div> | |
| 1504 | + <div id="accua_form_confirmation_emails_subject" class="label_input"> | |
| 1505 | + <label><?php _e( 'Subject', 'contact-forms'); ?></label> | |
| 1506 | + <div class="default_value"><?php echo htmlspecialchars($default_form_data['confirmation_emails_subject']); ?></div> | |
| 1507 | + <input class="accua_form_value" type="text" value="<?php echo htmlspecialchars($form_data['confirmation_emails_subject'], ENT_QUOTES) ?>" /> | |
| 1508 | + <input name="accua_form_confirmation_emails_subject" class="accua_form_check_override" type="checkbox" value="1" <?php if (isset($form_overrided_data['confirmation_emails_subject'])) {echo 'checked="checked" ';} ?>/><?php _e( 'Customize', 'contact-forms'); ?> | |
| 1509 | + </div> | |
| 1510 | + | |
| 1511 | + <div id="accua_form_confirmation_emails_message"> | |
| 1512 | + <input class="accua_form_check_override" name="accua_form_confirmation_emails_message" type="radio" value="0" <?php if (!isset($form_overrided_data['confirmation_emails_message'])) {echo ' checked ';} ?>> <?php _e( 'Use the default message', 'contact-forms'); ?> | |
| 1513 | + <input class="accua_form_check_override" name="accua_form_confirmation_emails_message" type="radio" value="1" <?php if (isset($form_overrided_data['confirmation_emails_message']) && !isset($form_overrided_data['confirmation_emails_message_no_message'])) {echo ' checked ';} ?>/> <?php _e( 'Customize', 'contact-forms'); ?> | |
| 1514 | + <input class="accua_form_check_override" name="accua_form_confirmation_emails_message" type="radio" value="-1" <?php if (isset($form_overrided_data['confirmation_emails_message_no_message'])) {echo ' checked ';} ?>/> <?php _e( 'Don\'t show any messages', 'contact-forms'); ?><br /> | |
| 1515 | + <div class="defalut_message"> | |
| 1516 | + <?php _e( 'Default message', 'contact-forms'); ?> | |
| 1517 | + <div class="defalut_content_message"><?php echo wpautop($default_form_data['confirmation_emails_message']); ?></div> | |
| 1518 | + </div> | |
| 1519 | + <?php wp_editor( $form_data['confirmation_emails_message'] , 'accua_form_confirmation_emails_message_textarea' , $settings_editor); ?> | |
| 1520 | + </div> | |
| 1521 | + </div> | |
| 1522 | + </div> | |
| 1523 | + </div> | |
| 1524 | + <br clear="all"/> | |
| 1525 | + | |
| 1526 | +<?php accua_forms_print_tokens(); ?> | |
| 1527 | + | |
| 1528 | +<input type="hidden" id="accua_form_save_settings_id" value="<?php echo $fid_esc; ?>" /> | |
| 1529 | +</div> | |
| 1530 | +<?php /* | |
| 1531 | +<div id="accua_tab_preview" class="content_tab"> | |
| 1532 | +</div> */?> | |
| 1533 | +<p></p> | |
| 1534 | +<input class="button button-primary button-large accua_form_save_settings_button" id="accua_form_save_settings_2" type="button" value="<?php _e( 'Save settings', 'contact-forms'); ?>" /> <span class="accua_form_save_settings_status"></span> | |
| 1535 | + | |
| 1536 | +</div> | |
| 1537 | +<script> | |
| 1538 | +jQuery('input[type=radio]').change(function() { | |
| 1539 | + var name = jQuery(this).attr('name'); | |
| 1540 | + if (jQuery(this).val() == '1') { | |
| 1541 | + jQuery('#'+name+' .defalut_message').hide(); | |
| 1542 | + jQuery('#'+name+' .wp-editor-wrap').show(); | |
| 1543 | + } | |
| 1544 | + else { | |
| 1545 | + if(jQuery(this).val() != '-1') | |
| 1546 | + jQuery('#'+name+' .defalut_message').show(); | |
| 1547 | + else | |
| 1548 | + jQuery('#'+name+' .defalut_message').hide(); | |
| 1549 | + jQuery('#'+name+' .wp-editor-wrap').hide(); | |
| 1550 | + } | |
| 1551 | +}); | |
| 1552 | + | |
| 1553 | +jQuery('input[type=checkbox]').click(function() { | |
| 1554 | + var name = jQuery(this).attr('name'); | |
| 1555 | + if (!this.checked) { | |
| 1556 | + jQuery('#'+name+' .default_value').show(); | |
| 1557 | + jQuery('#'+name+' .accua_form_value, #'+name+' .cp-color-picker').hide(); | |
| 1558 | + } | |
| 1559 | + else { | |
| 1560 | + jQuery('#'+name+' .default_value').hide(); | |
| 1561 | + jQuery('#'+name+' .accua_form_value, #'+name+' .cp-color-picker').show(); | |
| 1562 | + //cp-color-picker | |
| 1563 | + } | |
| 1564 | +}); | |
| 1565 | + | |
| 1566 | +jQuery(".token_link").click(function() { | |
| 1567 | + jQuery("#dialog_token").dialog("open"); | |
| 1568 | + return false; | |
| 1569 | +}); | |
| 1570 | + | |
| 1571 | +//inizializzazione | |
| 1572 | +jQuery(document).ready(function($){ | |
| 1573 | + $('#accua_form_preview_area_wrapper').resizable({handles: 's'}); | |
| 1574 | + $('#accua_form_preview_area').css({ | |
| 1575 | + 'width': '100%', | |
| 1576 | + 'height': '100%' | |
| 1577 | + }); | |
| 1578 | + $.each( | |
| 1579 | + ['success_message','error_message','admin_emails_message','confirmation_emails_message'], | |
| 1580 | + function(i,key){ | |
| 1581 | + var value = $('#accua_form_'+key+' .accua_form_check_override:checked').val(); | |
| 1582 | + if(value!=undefined && value!=0) { | |
| 1583 | + if(value!=-1) | |
| 1584 | + jQuery('#accua_form_'+key+' .wp-editor-wrap').show(); | |
| 1585 | + else | |
| 1586 | + jQuery('#accua_form_'+key+' .wp-editor-wrap').hide(); | |
| 1587 | + jQuery('#accua_form_'+key+' .defalut_message').hide(); | |
| 1588 | + | |
| 1589 | + } | |
| 1590 | + else { | |
| 1591 | + jQuery('#accua_form_'+key+' .wp-editor-wrap').hide(); | |
| 1592 | + jQuery('#accua_form_'+key+' .defalut_message').show(); | |
| 1593 | + } | |
| 1594 | + } | |
| 1595 | + ); | |
| 1596 | + $.each( | |
| 1597 | + ['emails_from_name','emails_from','admin_emails_to','emails_bcc','admin_emails_subject','confirmation_emails_subject','style_margin','style_border_color','style_border_width','style_border_radius','style_background_color','style_padding','style_color','style_font_size','style_field_spacing','style_field_border_color','style_field_border_width','style_field_border_radius','style_field_background_color','style_field_padding','style_field_color','style_submit_border_color','style_submit_border_width','style_submit_border_radius','style_submit_background_color','style_submit_padding','style_submit_color','style_submit_font_size'], | |
| 1598 | + function(i,key){ | |
| 1599 | + if(!$('#accua_form_'+key+' .accua_form_check_override').is(':checked')) { | |
| 1600 | + jQuery('#accua_form_'+key+' .default_value').show(); | |
| 1601 | + jQuery('#accua_form_'+key+' .accua_form_value, #accua_form_'+key+' .wp-picker-container').hide(); | |
| 1602 | + } | |
| 1603 | + else { | |
| 1604 | + jQuery('#accua_form_'+key+' .default_value').hide(); | |
| 1605 | + jQuery('#accua_form_'+key+' .accua_form_value, #accua_form_'+key+' .wp-picker-container').show(); | |
| 1606 | + } | |
| 1607 | + }); | |
| 1608 | + $("#dialog_token").dialog({ dialogClass:'wp-dialog' ,autoOpen : false, modal : true, show : "blind", hide : "blind"}); | |
| 1609 | + | |
| 1610 | + $('#accua_token a').appendTo('.wp-media-buttons'); | |
| 1611 | + | |
| 1612 | +}); | |
| 1613 | + | |
| 1614 | +jQuery(document).ready(function($){ | |
| 1615 | + | |
| 1616 | + var originalWidth = $(document).width(); | |
| 1617 | + if(originalWidth <= 883) { //iphone | |
| 1618 | + $(".metabox-holder").width('98%'); | |
| 1619 | + } | |
| 1620 | + | |
| 1621 | + $(window).resize(function (e) { | |
| 1622 | + var newWidth = $(document).width(); | |
| 1623 | + if(newWidth <= 883) { | |
| 1624 | + if (originalWidth > 883) { | |
| 1625 | + $(".metabox-holder").width('98%'); | |
| 1626 | + } | |
| 1627 | + } else if (originalWidth<=883) { | |
| 1628 | + $(".metabox-holder").width('47%'); | |
| 1629 | + } | |
| 1630 | + originalWidth = newWidth; | |
| 1631 | + }); | |
| 1632 | +}); | |
| 1633 | + | |
| 1634 | +</script> | |
| 1635 | + | |
| 1636 | +<?php | |
| 1637 | + $accuaHelp->finished(); | |
| 1638 | +} | |
| 1639 | + | |
| 1640 | +function accua_forms_fields_page_head() { | |
| 1641 | +/* | |
| 1642 | + $baseurl = WP_PLUGIN_URL.'/'.substr(plugin_basename(__FILE__),0,-strlen(basename(__FILE__))); | |
| 1643 | +?> | |
| 1644 | + <script type="text/javascript" src="<?php echo $baseurl.'/qtip/jquery.qtip-1.0.0-rc3.js'; ?>"></script> | |
| 1645 | + <script type="text/javascript"> | |
| 1646 | + var avail_fields = { | |
| 1647 | + first_name: { | |
| 1648 | + id: "first_name", | |
| 1649 | + name: "First Name", | |
| 1650 | + type: "textfield" | |
| 1651 | + }, | |
| 1652 | + last_name: { | |
| 1653 | + id: "last_name", | |
| 1654 | + name: "Last Name", | |
| 1655 | + type: "textfield" | |
| 1656 | + }, | |
| 1657 | + email: { | |
| 1658 | + id: "email", | |
| 1659 | + name: "Email", | |
| 1660 | + type: "email" | |
| 1661 | + } | |
| 1662 | + }; | |
| 1663 | + | |
| 1664 | + jQuery(function($){ | |
| 1665 | + $avail = $('#available_fields_container'); | |
| 1666 | + for(var id in avail_fields) { | |
| 1667 | + var field = avail_fields[id]; | |
| 1668 | + var el = $('<div></div>').text(field.name); | |
| 1669 | + el.prepend('<input type="checkbox" />'); | |
| 1670 | + var content = $('<div><span>Id: </span></div>'); | |
| 1671 | + content.append($('<input type="text" />').val(field.id)); | |
| 1672 | + content.append($('<br /><span>Name: </span>')); | |
| 1673 | + content.append($('<input type="text" />').val(field.name)); | |
| 1674 | + content.append($('<br /><span>Type: </span>')); | |
| 1675 | + content.append($('<select><option value="textfield">Textfield</option><option value="textarea">Textarea</option><option value="email">Email</option></select>').val(field.type)); | |
| 1676 | + el.qtip({ | |
| 1677 | + content: { | |
| 1678 | + text: content | |
| 1679 | + }, | |
| 1680 | + position: { | |
| 1681 | + target: 'mouse', | |
| 1682 | + corner: { | |
| 1683 | + target: 'bottomRight', | |
| 1684 | + tooltip: 'topLeft' | |
| 1685 | + }, | |
| 1686 | + adjust: { | |
| 1687 | + mouse: false | |
| 1688 | + } | |
| 1689 | + }, | |
| 1690 | + show: { | |
| 1691 | + when: { | |
| 1692 | + event: 'mouseover' | |
| 1693 | + }, | |
| 1694 | + solo: true | |
| 1695 | + }, | |
| 1696 | + hide: { | |
| 1697 | + when: { | |
| 1698 | + event: 'unfocus' | |
| 1699 | + } | |
| 1700 | + } | |
| 1701 | + }); | |
| 1702 | + $avail.append(el); | |
| 1703 | + } | |
| 1704 | + }); | |
| 1705 | + </script> | |
| 1706 | + <style type="text/css"> | |
| 1707 | + .container > div { | |
| 1708 | + padding: 0px; | |
| 1709 | + margin-bottom: 6px; | |
| 1710 | + } | |
| 1711 | + </style> | |
| 1712 | +<?php | |
| 1713 | +*/ | |
| 1714 | +} | |
| 1715 | + | |
| 1716 | +function accua_forms_fields_get_types() { | |
| 1717 | + return array( | |
| 1718 | + 'textfield' => __( 'Text Field', 'contact-forms'), | |
| 1719 | + 'textarea' => __( 'Text Area', 'contact-forms'), | |
| 1720 | + 'email' => __( 'Email', 'contact-forms'), | |
| 1721 | + 'autoreply_email' => __( 'Autoreply Email', 'contact-forms'), | |
| 1722 | + 'checkbox' => __( 'Checkbox','contact-forms'), | |
| 1723 | + 'select' => __('Select', 'contact-forms'), | |
| 1724 | + 'radio' => __( 'Radio buttons', 'contact-forms'), | |
| 1725 | + 'multiselect' => __( 'Multiple selections area', 'contact-forms'), | |
| 1726 | + 'multicheckbox' => __( 'Multiple checkboxes', 'contact-forms'), | |
| 1727 | + 'post-select' => __( 'Post select', 'contact-forms'), | |
| 1728 | + 'post-multicheckbox' => __( 'Multiple post checkboxes', 'contact-forms'), | |
| 1729 | + 'colorpicker' => __( 'Color picker', 'contact-forms'), | |
| 1730 | + 'hidden' => __('Hidden value', 'contact-forms'), | |
| 1731 | + 'file' => __('File upload', 'contact-forms'), | |
| 1732 | + 'submit' => __( 'Submit button', 'contact-forms'), | |
| 1733 | + 'html' => __( 'Custom HTML', 'contact-forms'), | |
| 1734 | + 'captcha' => __( 'Captcha', 'contact-forms'), | |
| 1735 | + 'password' => 'Password', | |
| 1736 | + 'password-and-confirm' => __( 'Password and password confirmation','contact-forms'), | |
| 1737 | + 'date' => __( 'Date','contact-forms'), | |
| 1738 | + ); | |
| 1739 | +} | |
| 1740 | + | |
| 1741 | +function accua_forms_filter_date($value){ | |
| 1742 | + if (($value !== '') && preg_match('/^\d{4}-\d{2}-\d{2}$/', $value)) { | |
| 1743 | + try { | |
| 1744 | + $date = new DateTime($value); | |
| 1745 | + if ($date) { | |
| 1746 | + return $value; | |
| 1747 | + } | |
| 1748 | + } catch (Exception $e) { | |
| 1749 | + } | |
| 1750 | + } | |
| 1751 | + return ''; | |
| 1752 | +} | |
| 1753 | + | |
| 1754 | +function accua_forms_fields_filter_values($post, $old_data = array()) { | |
| 1755 | + //TODO: funzione di validazione dei field | |
| 1756 | + $data = array( | |
| 1757 | + 'version' => 2, | |
| 1758 | + 'id' => $post['form-field-id'], | |
| 1759 | + 'name' => $post['form-field-name'], | |
| 1760 | + 'type' => $post['form-field-type'], | |
| 1761 | + 'description' => $post['form-field-description'], | |
| 1762 | + 'default_value' => $post['form-field-default-value'], | |
| 1763 | + 'default_date_value' => $post['form-field-default-date-value'], | |
| 1764 | + 'allowed_values' => $post['form-field-allowed-values'], | |
| 1765 | + 'allowed_extensions' => '', | |
| 1766 | + 'min_date' => $post['form-field-min-of-date'], | |
| 1767 | + 'max_date' => $post['form-field-max-of-date'], | |
| 1768 | + ); | |
| 1769 | + $valid = true; | |
| 1770 | + $message = ''; | |
| 1771 | + | |
| 1772 | + $types = accua_forms_fields_get_types(); | |
| 1773 | + if (!isset($types[$data['type']])) { | |
| 1774 | + $message .= "<p>".__('Invalid type', 'contact-forms')."</p>"; | |
| 1775 | + $valid = false; | |
| 1776 | + $data['type'] = 'textfield'; | |
| 1777 | + } | |
| 1778 | + | |
| 1779 | + if (!current_user_can('unfiltered_html')) { | |
| 1780 | + $filter_fields = array('name', 'description', 'default_value', 'allowed_values'); | |
| 1781 | + foreach ($filter_fields as $k) { | |
| 1782 | + $data[$k] = wp_kses($data[$k], 'post'); | |
| 1783 | + } | |
| 1784 | + } | |
| 1785 | + | |
| 1786 | + if ($data['type'] == 'file') { | |
| 1787 | + $data['allowed_extensions'] = accua_forms_filter_extensions($data['allowed_values']); | |
| 1788 | + } | |
| 1789 | + | |
| 1790 | + $dates = array( | |
| 1791 | + 'default_date_value' => __('Invalid default date', 'contact-forms'), | |
| 1792 | + 'min_date' => __('Invalid min date', 'contact-forms'), | |
| 1793 | + 'max_date' => __('Invalid max date', 'contact-forms'), | |
| 1794 | + ); | |
| 1795 | + foreach ($dates as $k => $errormsg) { | |
| 1796 | + if ($data[$k] !== '') { | |
| 1797 | + $data[$k] = accua_forms_filter_date($data[$k]); | |
| 1798 | + if ($data[$k] === '') { | |
| 1799 | + $message .= "<p>".$errormsg."</p>"; | |
| 1800 | + $valid = false; | |
| 1801 | + } | |
| 1802 | + } | |
| 1803 | + } | |
| 1804 | + | |
| 1805 | + return array( | |
| 1806 | + 'data' => $data, | |
| 1807 | + 'valid' => $valid, | |
| 1808 | + 'message' => $message, | |
| 1809 | + ); | |
| 1810 | +} | |
| 1811 | + | |
| 1812 | +function accua_forms_fields_page() { | |
| 1813 | +/* | |
| 1814 | +?> | |
| 1815 | +<div class="wrap"><h2>Edit Form Fields</h2> | |
| 1816 | + <div id="available_fields_container" class="container"></div> | |
| 1817 | +</div> | |
| 1818 | +<?php | |
| 1819 | +*/ | |
| 1820 | + $message = ''; | |
| 1821 | + $taxonomy = ''; | |
| 1822 | + $post_type = ''; | |
| 1823 | + | |
| 1824 | + /* | |
| 1825 | + $avail_fields = array( | |
| 1826 | + 'first_name' => array ( | |
| 1827 | + 'id' => "first_name", | |
| 1828 | + 'name' => "First Name", | |
| 1829 | + 'type' => "textfield", | |
| 1830 | + 'description' => 'This is the first name', | |
| 1831 | + ), | |
| 1832 | + 'last_name' => array ( | |
| 1833 | + 'id' => "last_name", | |
| 1834 | + 'name' => "Last Name", | |
| 1835 | + 'type' => "textfield", | |
| 1836 | + 'description' => 'This is the last name', | |
| 1837 | + ), | |
| 1838 | + 'email' => array ( | |
| 1839 | + 'id' => "email", | |
| 1840 | + 'name' => "Email", | |
| 1841 | + 'type' => "email", | |
| 1842 | + 'description' => 'This is the email', | |
| 1843 | + ), | |
| 1844 | + ); | |
| 1845 | + */ | |
| 1846 | + | |
| 1847 | + $avail_fields = get_option('accua_forms_avail_fields', array()); | |
| 1848 | + | |
| 1849 | + $default_form_values = array( | |
| 1850 | + 'version' => 1, | |
| 1851 | + 'id' => '', | |
| 1852 | + 'name' => '', | |
| 1853 | + 'type' => 'textfield', | |
| 1854 | + 'description' => '', | |
| 1855 | + 'default_value' => '', | |
| 1856 | + 'default_date_value' => '', | |
| 1857 | + 'allowed_values' => '', | |
| 1858 | + 'allowed_extensions' => '', | |
| 1859 | + 'min_date' => '', | |
| 1860 | + 'max_date' => '', | |
| 1861 | + ); | |
| 1862 | + | |
| 1863 | + $editing = false; | |
| 1864 | + $adding = true; | |
| 1865 | + | |
| 1866 | + if (!empty($_POST['action'])) { | |
| 1867 | + check_admin_referer('edit_form_field', '_wpnonce_edit_form_field'); | |
| 1868 | + $post = stripslashes_deep($_POST) + $default_form_values; | |
| 1869 | + switch($post['action']) { | |
| 1870 | + case 'edit-form-field': | |
| 1871 | + if (empty($avail_fields[$post['form-field-id']])) { | |
| 1872 | + $message .= 'Field "'.htmlspecialchars(sanitize_text_field($post['form-field-id'])).'" doesn\'t exists'; | |
| 1873 | + } else { | |
| 1874 | + if (empty($post['delete-field'])) { | |
| 1875 | + $filtered_data = accua_forms_fields_filter_values($post, $avail_fields[$post['form-field-id']]); | |
| 1876 | + $avail_fields[$post['form-field-id']] = $filtered_data['data']; | |
| 1877 | + $message .= sprintf( __( 'Field "%s" updated', 'contact-forms'), htmlspecialchars($post['form-field-id']) ); | |
| 1878 | + do_action('accua_forms_field_updated', $avail_fields[$post['form-field-id']]); | |
| 1879 | + } else { | |
| 1880 | + $deleting_field = $avail_fields[$post['form-field-id']]; | |
| 1881 | + unset ($avail_fields[$post['form-field-id']]); | |
| 1882 | + $message .= sprintf( __( 'Field "%s" deleted', 'contact-forms'), htmlspecialchars($post['form-field-id']) ); | |
| 1883 | + do_action('accua_forms_field_deleted', $deleting_field); | |
| 1884 | + } | |
| 1885 | + update_option('accua_forms_avail_fields', $avail_fields); | |
| 1886 | + } | |
| 1887 | + break; | |
| 1888 | + case 'add-form-field': | |
| 1889 | + $fill_form_fields = true; | |
| 1890 | + $valid = true; | |
| 1891 | + if (empty($post['form-field-id']) || !preg_match('/^[a-z0-9_-]+$/i', $post['form-field-id'])) { | |
| 1892 | + $message .= "<p>".__( 'Only letters, numbers, hyphen and underscores allowed in field identificative slug', 'contact-forms')."</p>"; | |
| 1893 | + $valid = false; | |
| 1894 | + } | |
| 1895 | + if(substr($post['form-field-id'], 0, 2) == '__') { | |
| 1896 | + $message .= "<p>".__( 'The field identificative slug can\'t start with two underscores (__)', 'contact-forms')."</p>"; | |
| 1897 | + $valid = false; | |
| 1898 | + } | |
| 1899 | + if (!empty($avail_fields[$post['form-field-id']])) { | |
| 1900 | + $message .= sprintf( __( '<p>A field with identificative slug "%s" already exists</p> Field "%s" deleted', 'contact-forms'), htmlspecialchars($post['form-field-id']) ); | |
| 1901 | + $valid = false; | |
| 1902 | + } | |
| 1903 | + if (strlen($post['form-field-id']) > 70) { | |
| 1904 | + $message .= "<p>".__( 'The identificative slug cannot be longer than 70 characters', 'contact-forms')."</p>"; | |
| 1905 | + $valid = false; | |
| 1906 | + } | |
| 1907 | + $filtered_data = accua_forms_fields_filter_values($post); | |
| 1908 | + $message .= $filtered_data['message']; | |
| 1909 | + $valid = $valid && $filtered_data['valid']; | |
| 1910 | + if ($valid) { | |
| 1911 | + $fill_form_fields = false; | |
| 1912 | + $avail_fields[$post['form-field-id']] = $filtered_data['data']; | |
| 1913 | + update_option('accua_forms_avail_fields', $avail_fields); | |
| 1914 | + $message .= sprintf( __( 'Field "%s" created', 'contact-forms'), htmlspecialchars($post['form-field-id']) ); | |
| 1915 | + do_action('accua_forms_field_added', $avail_fields[$post['form-field-id']]); | |
| 1916 | + } | |
| 1917 | + if ($fill_form_fields) { | |
| 1918 | + $editing = true; | |
| 1919 | + $default_form_values = $filtered_data['data']; | |
| 1920 | + } | |
| 1921 | + break; | |
| 1922 | + } | |
| 1923 | + } else if (!empty($_GET['edit-fid'])) { | |
| 1924 | + $fid = stripslashes($_GET['edit-fid']); | |
| 1925 | + if (empty($avail_fields[$fid])) { | |
| 1926 | + $message .= sprintf( __( 'Field "%s" doesn\'t exists', 'contact-forms'), htmlspecialchars($fid) ); | |
| 1927 | + } else { | |
| 1928 | + $adding = false; | |
| 1929 | + $editing = true; | |
| 1930 | + $default_form_values = $avail_fields[$fid] + $default_form_values; | |
| 1931 | + } | |
| 1932 | + } | |
| 1933 | + if ($default_form_values['version'] >= 2 && $default_form_values['type'] == 'file') { | |
| 1934 | + //Show allowed_extensions value in allowed_values field | |
| 1935 | + $default_form_values['allowed_values'] = $default_form_values['allowed_extensions']; | |
| 1936 | + } | |
| 1937 | + | |
| 1938 | +?> | |
| 1939 | +<div id="accua_forms_fields_page" class="accua_forms_admin_page wrap nosubsub"> | |
| 1940 | +<h2><img src="<?php echo ACCUA_FORMS_DIR_URL.'img/cimatti-icon-20.png'; ?>"/> <?php _e('Contact Forms - Fields', 'contact-forms'); ?></h2> | |
| 1941 | +<?php /* screen_icon(); ?> | |
| 1942 | +<h2><?php echo esc_html( $title ); | |
| 1943 | +if ( !empty($_REQUEST['s']) ) | |
| 1944 | + printf( '<span class="subtitle">' . __('Search results for “%s”') . '</span>', esc_html( stripslashes($_REQUEST['s']) ) ); ?> | |
| 1945 | +</h2> | |
| 1946 | + | |
| 1947 | +<?php if ( isset($_REQUEST['message']) && ( $msg = (int) $_REQUEST['message'] ) ) : ?> | |
| 1948 | +<div id="message" class="updated"><p><?php echo $messages[$msg]; ?></p></div> | |
| 1949 | +<?php $_SERVER['REQUEST_URI'] = remove_query_arg(array('message'), $_SERVER['REQUEST_URI']); | |
| 1950 | +endif; */ ?> | |
| 1951 | +<div id="ajax-response"><?php echo $message?></div> | |
| 1952 | + | |
| 1953 | +<?php /* | |
| 1954 | +<form class="search-form" action="" method="get"> | |
| 1955 | +<input type="hidden" name="taxonomy" value="<?php echo esc_attr($taxonomy); ?>" /> | |
| 1956 | +<input type="hidden" name="post_type" value="<?php echo esc_attr($post_type); ?>" /> | |
| 1957 | + | |
| 1958 | +<?php $wp_list_table->search_box( $tax->labels->search_items, 'tag' ); ?> | |
| 1959 | + | |
| 1960 | +</form> | |
| 1961 | +*/ ?> | |
| 1962 | + | |
| 1963 | +<br class="clear" /> | |
| 1964 | + | |
| 1965 | +<div id="col-container"> | |
| 1966 | + | |
| 1967 | +<div id="col-right"> | |
| 1968 | +<div class="col-wrap"> | |
| 1969 | +<?php if (!$editing) { ?> | |
| 1970 | +<form id="posts-filter" action="" method="post"> | |
| 1971 | +<input type="hidden" name="taxonomy" value="<?php echo esc_attr($taxonomy); /* TODO: Is this needed? */ ?>" /> | |
| 1972 | +<input type="hidden" name="post_type" value="<?php echo esc_attr($post_type); /* TODO: Is this needed? */ ?>" /> | |
| 1973 | + | |
| 1974 | +<?php /* $wp_list_table->display(); */ ?> | |
| 1975 | + | |
| 1976 | +<table cellspacing="0" class="wp-list-table widefat fixed tags"> | |
| 1977 | + <thead> | |
| 1978 | + <tr> | |
| 1979 | + <th style="" class="manage-column column-cb check-column" id="cb" scope="col"><input type="checkbox" /></th> | |
| 1980 | + <th style="" class="manage-column column-name" id="name" scope="col"><?php _e( 'Label', 'contact-forms'); ?></th> | |
| 1981 | + <th style="" class="manage-column column-description" id="description" scope="col"><?php _e( 'Description', 'contact-forms'); ?></th> | |
| 1982 | + <th style="" class="manage-column column-slug" id="slug" scope="col"><?php _e( 'Slug', 'contact-forms'); ?></th> | |
| 1983 | + <th style="" class="manage-column column-type" id="type" scope="col"><?php _e( 'Type', 'contact-forms'); ?></th> | |
| 1984 | + </tr> | |
| 1985 | + </thead> | |
| 1986 | + | |
| 1987 | + <tfoot> | |
| 1988 | + <tr> | |
| 1989 | + <th style="" class="manage-column column-cb check-column" scope="col"><input type="checkbox" /></th> | |
| 1990 | + <th style="" class="manage-column column-name" scope="col"><?php _e( 'Label', 'contact-forms'); ?></th> | |
| 1991 | + <th style="" class="manage-column column-description" scope="col"><?php _e( 'Description', 'contact-forms'); ?></th> | |
| 1992 | + <th style="" class="manage-column column-slug" scope="col"><?php _e( 'Slug', 'contact-forms'); ?></th> | |
| 1993 | + <th style="" class="manage-column column-type" scope="col"><?php _e( 'Type', 'contact-forms'); ?></th> | |
| 1994 | + </tr> | |
| 1995 | + </tfoot> | |
| 1996 | + | |
| 1997 | + <tbody class="list:tag" id="the-list"> | |
| 1998 | +<?php | |
| 1999 | + foreach ($avail_fields as $id => $field) { | |
| 2000 | + foreach (array('id', 'name', 'type', 'description') as $i) { | |
| 2001 | + $field[$i] = htmlspecialchars($field[$i], ENT_QUOTES); | |
| 2002 | + $field[$i] = sanitize_text_field($field[$i]); | |
| 2003 | + } | |
| 2004 | + echo <<<END_OF_ROW | |
| 2005 | + <tr id="field-{$field['id']}"> | |
| 2006 | + <th class="check-column" scope="row"><input type="checkbox" /></th> | |
| 2007 | + <td class="name column-name"><strong><a title="Edit “{$field['name']}”" href="admin.php?page=accua_forms_fields&edit-fid={$field['id']}" class="row-title">{$field['name']}</a></strong><br><div class="row-actions"><span class="edit"><a href="admin.php?page=accua_forms_fields&edit-fid={$field['id']}">Edit</a></span></div></td> | |
| 2008 | + <td class="description column-description">{$field['description']}</td> | |
| 2009 | + <td class="slug column-slug">{$field['id']}</td> | |
| 2010 | + <td class="type column-type">{$field['type']}</td> | |
| 2011 | + </tr> | |
| 2012 | +END_OF_ROW; | |
| 2013 | + } | |
| 2014 | +?> | |
| 2015 | + </tbody> | |
| 2016 | +</table> | |
| 2017 | + | |
| 2018 | +<br class="clear" /> | |
| 2019 | +</form> | |
| 2020 | +<?php } ?> | |
| 2021 | +<?php /* if ( 'category' == $taxonomy ) : ?> | |
| 2022 | +<div class="form-wrap"> | |
| 2023 | +<p><?php printf(__('<strong>Note:</strong><br />Deleting a category does not delete the posts in that category. Instead, posts that were only assigned to the deleted category are set to the category <strong>%s</strong>.'), apply_filters('the_category', get_cat_name(get_option('default_category')))) ?></p> | |
| 2024 | +<?php if ( current_user_can( 'import' ) ) : ?> | |
| 2025 | +<p><?php printf(__('Categories can be selectively converted to tags using the <a href="%s">category to tag converter</a>.'), 'import.php') ?></p> | |
| 2026 | +<?php endif; ?> | |
| 2027 | +</div> | |
| 2028 | +<?php elseif ( 'post_tag' == $taxonomy && current_user_can( 'import' ) ) : ?> | |
| 2029 | +<div class="form-wrap"> | |
| 2030 | +<p><?php printf(__('Tags can be selectively converted to categories using the <a href="%s">tag to category converter</a>'), 'import.php') ;?>.</p> | |
| 2031 | +</div> | |
| 2032 | +<?php endif; | |
| 2033 | +do_action('after-' . $taxonomy . '-table', $taxonomy); | |
| 2034 | +*/ ?> | |
| 2035 | + | |
| 2036 | +</div> | |
| 2037 | +</div><!-- /col-right --> | |
| 2038 | + | |
| 2039 | +<div id="col-left"> | |
| 2040 | +<div class="col-wrap"> | |
| 2041 | + | |
| 2042 | +<?php | |
| 2043 | +/* | |
| 2044 | +if ( !is_null( $tax->labels->popular_items ) ) { | |
| 2045 | + if ( current_user_can( $tax->cap->edit_terms ) ) | |
| 2046 | + $tag_cloud = wp_tag_cloud( array( 'taxonomy' => $taxonomy, 'echo' => false, 'link' => 'edit' ) ); | |
| 2047 | + else | |
| 2048 | + $tag_cloud = wp_tag_cloud( array( 'taxonomy' => $taxonomy, 'echo' => false ) ); | |
| 2049 | + | |
| 2050 | + if ( $tag_cloud ) : | |
| 2051 | + ?> | |
| 2052 | +<div class="tagcloud"> | |
| 2053 | +<h3><?php echo $tax->labels->popular_items; ?></h3> | |
| 2054 | +<?php echo $tag_cloud; unset( $tag_cloud ); ?> | |
| 2055 | +</div> | |
| 2056 | +<?php | |
| 2057 | +endif; | |
| 2058 | +} | |
| 2059 | +*/ | |
| 2060 | + | |
| 2061 | +/* | |
| 2062 | +if ( current_user_can($tax->cap->edit_terms) ) { | |
| 2063 | + // Back compat hooks. Deprecated in preference to {$taxonomy}_pre_add_form | |
| 2064 | + if ( 'category' == $taxonomy ) | |
| 2065 | + do_action('add_category_form_pre', (object)array('parent' => 0) ); | |
| 2066 | + elseif ( 'link_category' == $taxonomy ) | |
| 2067 | + do_action('add_link_category_form_pre', (object)array('parent' => 0) ); | |
| 2068 | + else | |
| 2069 | + do_action('add_tag_form_pre', $taxonomy); | |
| 2070 | + | |
| 2071 | + do_action($taxonomy . '_pre_add_form', $taxonomy); | |
| 2072 | +*/ | |
| 2073 | + | |
| 2074 | +$types = accua_forms_fields_get_types(); | |
| 2075 | +?> | |
| 2076 | +<div class="form-wrap"> | |
| 2077 | +<h3><?php echo $adding? __( 'Add new field','contact-forms'): __( 'Edit field','contact-forms') ; ?></h3> | |
| 2078 | +<form id="addtag" method="post" action="admin.php?page=accua_forms_fields" class="validate"> | |
| 2079 | +<input type="hidden" name="action" value="<?php echo $adding?'add':'edit'; ?>-form-field" /> | |
| 2080 | +<?php /* | |
| 2081 | +<input type="hidden" name="screen" value="<?php echo esc_attr($current_screen->id); ?>" /> | |
| 2082 | +<input type="hidden" name="taxonomy" value="<?php echo esc_attr($taxonomy); ?>" /> | |
| 2083 | +<input type="hidden" name="post_type" value="<?php echo esc_attr($post_type); ?>" /> | |
| 2084 | +*/ ?> | |
| 2085 | +<?php wp_nonce_field('edit_form_field', '_wpnonce_edit_form_field'); ?> | |
| 2086 | + | |
| 2087 | +<div class="form-field form-required"> | |
| 2088 | + <label for="tag-name"><?php _e( 'Field label', 'contact-forms'); ?></label> | |
| 2089 | + <input name="form-field-name" id="tag-name" type="text" value="<?php echo htmlspecialchars($default_form_values['name'], ENT_QUOTES) ?>" size="40" aria-required="true" /> | |
| 2090 | + <p><?php _e('The name is how it appears on your site.', 'contact-forms'); ?></p> | |
| 2091 | +</div> | |
| 2092 | +<?php /* if ( ! global_terms_enabled() ) : */ ?> | |
| 2093 | +<div class="form-field"> | |
| 2094 | + <label for="tag-slug"><?php _e( 'Field slug (identificative)', 'contact-forms'); ?></label> | |
| 2095 | + <input name="form-field-id" id="tag-slug" type="text" value="<?php echo htmlspecialchars($default_form_values['id'], ENT_QUOTES) ?>" <?php if (!$adding) { echo 'disabled="disabled"'; } ?> size="40" /> | |
| 2096 | + <?php if (!$adding) { echo '<input type="hidden" name="form-field-id" value="'.htmlspecialchars($default_form_values['id'], ENT_QUOTES).'" />'; } ?> | |
| 2097 | + <p><?php _e('The “slug” is the URL-friendly version of the name. It is used as an identificator, and is unchangeable. It is usually all lowercase and it must contains only letters, numbers, and underscores.', 'contact-forms'); ?></p> | |
| 2098 | +</div> | |
| 2099 | +<div class="form-field"> | |
| 2100 | + <label for="parent"><?php _e( 'Field type', 'contact-forms'); ?></label> | |
| 2101 | + <select class="postform" id="parent" name="form-field-type"> | |
| 2102 | + <?php /* | |
| 2103 | + <option value="textfield" class="level-0" <?php echo ($default_form_values['type'] == 'textfield')?'selected="selected"':'';?> >Text Field</option> | |
| 2104 | + <option value="textarea" class="level-0" <?php echo ($default_form_values['type'] == 'textarea')?'selected="selected"':'';?> >Text Area</option> | |
| 2105 | + <option value="email" class="level-0" <?php echo ($default_form_values['type'] == 'email')?'selected="selected"':'';?> >Email</option> | |
| 2106 | + <option value="checkbox" class="level-0" <?php echo ($default_form_values['type'] == 'checkbox')?'selected="selected"':'';?> >Checkbox</option> | |
| 2107 | + <option value="select" class="level-0" <?php echo ($default_form_values['type'] == 'select')?'selected="selected"':'';?> >Select</option> | |
| 2108 | + */ | |
| 2109 | + foreach ($types as $typeid => $typename) { | |
| 2110 | + $selected = ($default_form_values['type'] == $typeid)?'selected="selected"':''; | |
| 2111 | + echo <<<EOT | |
| 2112 | +<option value="{$typeid}" class="level-0" {$selected} >{$typename}</option> | |
| 2113 | +EOT; | |
| 2114 | + } | |
| 2115 | + | |
| 2116 | + ?> | |
| 2117 | + </select> | |
| 2118 | +</div> | |
| 2119 | +<?php /* endif; // global_terms_enabled() */ ?> | |
| 2120 | +<?php /* if ( is_taxonomy_hierarchical($taxonomy) ) : ?> | |
| 2121 | +<div class="form-field"> | |
| 2122 | + <label for="parent"><?php _ex('Parent', 'Taxonomy Parent'); ?></label> | |
| 2123 | + <?php wp_dropdown_categories(array('hide_empty' => 0, 'hide_if_empty' => false, 'taxonomy' => $taxonomy, 'name' => 'parent', 'orderby' => 'name', 'hierarchical' => true, 'show_option_none' => __('None'))); ?> | |
| 2124 | + <?php if ( 'category' == $taxonomy ) : // @todo: Generic text for hierarchical taxonomies ?> | |
| 2125 | + <p><?php _e('Categories, unlike tags, can have a hierarchy. You might have a Jazz category, and under that have children categories for Bebop and Big Band. Totally optional.'); ?></p> | |
| 2126 | + <?php endif; ?> | |
| 2127 | +</div> | |
| 2128 | +<?php endif; // is_taxonomy_hierarchical() */ ?> | |
| 2129 | +<div class="form-field"> | |
| 2130 | + <label for="tag-description"><?php _e( 'Field description', 'contact-forms'); ?></label> | |
| 2131 | + <textarea name="form-field-description" id="tag-description" rows="5" cols="40"><?php echo htmlspecialchars($default_form_values['description'], ENT_QUOTES) ?></textarea> | |
| 2132 | + <p><?php _e('The description is not prominent by default; however, some themes may show it.', 'contact-forms'); ?></p> | |
| 2133 | +</div> | |
| 2134 | + | |
| 2135 | +<div class="form-field"> | |
| 2136 | + <label for="form-field-default-value"><?php _e( 'Default value(s)', 'contact-forms'); ?>:</label> | |
| 2137 | + <textarea name="form-field-default-value" id="form-field-default-value" rows="5" cols="40"><?php echo htmlspecialchars($default_form_values['default_value'], ENT_QUOTES) ?></textarea> | |
| 2138 | + <p><?php _e( 'For multiple default values in multiple select and multiple checkboxes, use | as separator.', 'contact-forms'); ?></p> | |
| 2139 | +</div> | |
| 2140 | + | |
| 2141 | +<div class="form-field"> | |
| 2142 | + <label for="form-field-allowed-values"><?php _e( 'Allowed values', 'contact-forms'); ?>:</label> | |
| 2143 | + <textarea rows="5" cols="40" name="form-field-allowed-values" id=form-field-allowed-values"><?php echo htmlspecialchars($default_form_values['allowed_values'], ENT_QUOTES) ?></textarea> | |
| 2144 | + <p><?php _e( 'Options used in select, radio and multiple checkboxes. Enter one value per line, in the format key|label. The key is the value that will be stored in the database. The label is optional, and the key will be used as the label if no label is specified. For file fields, this indicates allowed extensions (one per line without dot)', 'contact-forms'); ?></p> | |
| 2145 | +</div> | |
| 2146 | + | |
| 2147 | +<div class="form-field"> | |
| 2148 | +<?php _e( 'Settings for date fields', 'contact-forms'); ?> | |
| 2149 | +<div class="form-field"> | |
| 2150 | + <label for="form-field-default-date-value"><?php _e( 'Default value', 'contact-forms'); ?>:</label> | |
| 2151 | + <input type="date" name="form-field-default-date-value" id="form-field-default-date-value" value="<?php echo htmlspecialchars($default_form_values['default_date_value'], ENT_QUOTES) ?>"> | |
| 2152 | +</div> | |
| 2153 | + | |
| 2154 | + | |
| 2155 | +<label for="form-field-min-of-date"><?php _e( 'Min date', 'contact-forms'); ?>:</label> | |
| 2156 | +<input type="date" id="form-field-min-of-date" name="form-field-min-of-date" value="<?php echo htmlspecialchars($default_form_values['min_date'], ENT_QUOTES) ?>"> | |
| 2157 | + | |
| 2158 | +<label for="form-field-max-of-date"><?php _e( 'Max date', 'contact-forms'); ?>:</label> | |
| 2159 | +<input type="date" id="form-field-max-of-date" name="form-field-max-of-date" value="<?php echo htmlspecialchars($default_form_values['max_date'], ENT_QUOTES) ?>"> | |
| 2160 | + | |
| 2161 | +</div> | |
| 2162 | + | |
| 2163 | + | |
| 2164 | +<?php | |
| 2165 | +/* | |
| 2166 | +if ( ! is_taxonomy_hierarchical($taxonomy) ) | |
| 2167 | + do_action('add_tag_form_fields', $taxonomy); | |
| 2168 | +do_action($taxonomy . '_add_form_fields', $taxonomy); | |
| 2169 | +*/ | |
| 2170 | + | |
| 2171 | +if ($adding) { | |
| 2172 | + submit_button( __( 'Add new field', 'contact-forms'), 'button' ); | |
| 2173 | +} else { | |
| 2174 | + submit_button( __( 'Save changes', 'contact-forms'), 'button' ); | |
| 2175 | + submit_button( __( 'Delete field', 'contact-forms'), 'button', 'delete-field'); | |
| 2176 | +} | |
| 2177 | + | |
| 2178 | +/* | |
| 2179 | +// Back compat hooks. Deprecated in preference to {$taxonomy}_add_form | |
| 2180 | +if ( 'category' == $taxonomy ) | |
| 2181 | + do_action('edit_category_form', (object)array('parent' => 0) ); | |
| 2182 | +elseif ( 'link_category' == $taxonomy ) | |
| 2183 | + do_action('edit_link_category_form', (object)array('parent' => 0) ); | |
| 2184 | +else | |
| 2185 | + do_action('add_tag_form', $taxonomy); | |
| 2186 | + | |
| 2187 | +do_action($taxonomy . '_add_form', $taxonomy); | |
| 2188 | +*/ | |
| 2189 | +?> | |
| 2190 | +</form></div> | |
| 2191 | +<?php /* } */ ?> | |
| 2192 | + | |
| 2193 | +</div> | |
| 2194 | +</div><!-- /col-left --> | |
| 2195 | + | |
| 2196 | +</div><!-- /col-container --> | |
| 2197 | +</div><!-- /wrap --> | |
| 2198 | +<?php | |
| 2199 | + /* echo '<pre>accua_forms_avail_fields:', htmlspecialchars(print_r($avail_fields, true)), '</pre>'; */ | |
| 2200 | +} | |
| 2201 | + | |
| 2202 | +function accua_forms_settings_page() { | |
| 2203 | +?> | |
| 2204 | +<div id="accua_forms_settings_page" class="accua_forms_admin_page wrap"> | |
| 2205 | +<h2><img src="<?php echo ACCUA_FORMS_DIR_URL.'img/cimatti-icon-20.png'; ?>"/> <?php _e('Contact Forms - Default Settings', 'contact-forms'); ?></h2> | |
| 2206 | +<?php | |
| 2207 | + $empty_form_data = array( | |
| 2208 | + 'success_message' => '', | |
| 2209 | + 'error_message' => '', | |
| 2210 | + 'emails_from_name' => '', | |
| 2211 | + 'emails_from' => '', | |
| 2212 | + 'admin_emails_to' => '', | |
| 2213 | + 'emails_bcc' => '', | |
| 2214 | + 'admin_emails_subject' => '', | |
| 2215 | + 'admin_emails_message' => '', | |
| 2216 | + 'confirmation_emails_subject' => '', | |
| 2217 | + 'confirmation_emails_message' => '', | |
| 2218 | + 'layout' => 'sidebyside', | |
| 2219 | + 'style_margin' => '', | |
| 2220 | + 'style_border_color' => '', | |
| 2221 | + 'style_border_width' => '', | |
| 2222 | + 'style_border_radius' => '', | |
| 2223 | + 'style_background_color' => '', | |
| 2224 | + 'style_padding' => '', | |
| 2225 | + 'style_color' => '', | |
| 2226 | + 'style_font_size' => '', | |
| 2227 | + 'style_field_spacing' => '', | |
| 2228 | + 'style_field_border_color' => '', | |
| 2229 | + 'style_field_border_width' => '', | |
| 2230 | + 'style_field_border_radius' => '', | |
| 2231 | + 'style_field_background_color' => '', | |
| 2232 | + 'style_field_padding' => '', | |
| 2233 | + 'style_field_color' => '', | |
| 2234 | + 'style_submit_border_color' => '', | |
| 2235 | + 'style_submit_border_width' => '', | |
| 2236 | + 'style_submit_border_radius' => '', | |
| 2237 | + 'style_submit_background_color' => '', | |
| 2238 | + 'style_submit_padding' => '', | |
| 2239 | + 'style_submit_color' => '', | |
| 2240 | + 'style_submit_font_size' => '', | |
| 2241 | + ); | |
| 2242 | + | |
| 2243 | + $empty_file_data = array( | |
| 2244 | + 'valid_extensions' => '', | |
| 2245 | + 'max_size' => '', | |
| 2246 | + 'dest_path' => '', | |
| 2247 | + ); | |
| 2248 | + | |
| 2249 | + $empty_captcha_data = array( | |
| 2250 | + 'recaptcha_force_v1' => '', | |
| 2251 | + 'recaptcha_public_key' => '', | |
| 2252 | + 'recaptcha_private_key' => '', | |
| 2253 | + ); | |
| 2254 | + | |
| 2255 | + $empty_analytics_data = array( | |
| 2256 | + 'analytics_track_submit' => false, | |
| 2257 | + 'analytics_track_fields' => false, | |
| 2258 | + ); | |
| 2259 | + | |
| 2260 | + $empty_anonymize_ip_data = array( | |
| 2261 | + 'anonymize_ip_bytes' => 0, | |
| 2262 | + ); | |
| 2263 | + | |
| 2264 | + if($_SERVER['REQUEST_METHOD'] == 'POST' && !empty($_POST['accua_form_save_form_settings'])) { | |
| 2265 | + check_admin_referer('accua_form_save_settings', '_nonce_accua_form_save_settings'); | |
| 2266 | + $post = stripslashes_deep($_POST); | |
| 2267 | + $post += $empty_form_data; | |
| 2268 | + $post += $empty_file_data; | |
| 2269 | + $post += $empty_captcha_data; | |
| 2270 | + $post += $empty_analytics_data; | |
| 2271 | + $post += $empty_anonymize_ip_data; | |
| 2272 | + $form_data = array(); | |
| 2273 | + $file_data = array(); | |
| 2274 | + $captcha_data = array(); | |
| 2275 | + $analytics_data = array(); | |
| 2276 | + $anonymize_ip_data = array(); | |
| 2277 | + foreach($empty_form_data as $key=>$val){ | |
| 2278 | + $form_data[$key] = $post[$key]; | |
| 2279 | + } | |
| 2280 | + $form_data = accua_forms_filter_settings($form_data); | |
| 2281 | + | |
| 2282 | + $file_data['valid_extensions'] = accua_forms_filter_extensions($post['valid_extensions']); | |
| 2283 | + $file_data['max_size'] = $post['max_size']; | |
| 2284 | + if (current_user_can('edit_files') || current_user_can('install_plugins')) { | |
| 2285 | + $file_data['dest_path'] = $post['dest_path']; | |
| 2286 | + } else { | |
| 2287 | + $old_file_data = get_option('accua_forms_default_file_field_data',array()); | |
| 2288 | + $file_data['dest_path'] = isset($old_file_data['dest_path']) ? $old_file_data['dest_path'] : ''; | |
| 2289 | + } | |
| 2290 | + | |
| 2291 | + $captcha_data['recaptcha_force_v1'] = (bool) $post['recaptcha_force_v1']; | |
| 2292 | + $captcha_data['recaptcha_public_key'] = sanitize_text_field($post['recaptcha_public_key']); | |
| 2293 | + $captcha_data['recaptcha_private_key'] = sanitize_text_field($post['recaptcha_private_key']); | |
| 2294 | + | |
| 2295 | + foreach($empty_analytics_data as $key=>$val){ | |
| 2296 | + $analytics_data[$key] = (bool) $post[$key]; | |
| 2297 | + } | |
| 2298 | + | |
| 2299 | + /* foreach($empty_anonymize_ip_data as $key=>$val){ | |
| 2300 | + $anonymize_ip_data[$key] = $post[$key]; | |
| 2301 | + } */ | |
| 2302 | + $anonymize_ip_bytes = (int) $post['anonymize_ip_bytes']; | |
| 2303 | + if ($anonymize_ip_bytes < 0) { | |
| 2304 | + $anonymize_ip_bytes = 0; | |
| 2305 | + } else if ($anonymize_ip_bytes > 4) { | |
| 2306 | + $anonymize_ip_bytes = 4; | |
| 2307 | + } | |
| 2308 | + $anonymize_ip_data['anonymize_ip_bytes'] = $anonymize_ip_bytes; | |
| 2309 | + | |
| 2310 | + update_option('accua_forms_default_form_data', $form_data); | |
| 2311 | + update_option('accua_forms_default_file_field_data', $file_data); | |
| 2312 | + update_option('accua_forms_default_captcha_field_data', $captcha_data); | |
| 2313 | + update_option('accua_forms_default_analytics_data', $analytics_data); | |
| 2314 | + update_option('accua_forms_anonymize_ip_data', $anonymize_ip_data); | |
| 2315 | + | |
| 2316 | + if (!empty($post['delete_previous_ip_values'])) { | |
| 2317 | + global $wpdb; | |
| 2318 | + $wpdb->query("UPDATE `{$wpdb->prefix}accua_forms_submissions` SET afs_ip = ''"); | |
| 2319 | + } | |
| 2320 | + } else { | |
| 2321 | + $form_data = get_option('accua_forms_default_form_data',array()) + $empty_form_data; | |
| 2322 | + $file_data = get_option('accua_forms_default_file_field_data',array()) + $empty_file_data; | |
| 2323 | + $captcha_data = get_option('accua_forms_default_captcha_field_data',array()) + $empty_captcha_data; | |
| 2324 | + $analytics_data = get_option('accua_forms_default_analytics_data',array()) + $empty_analytics_data; | |
| 2325 | + $anonymize_ip_data = get_option('accua_forms_anonymize_ip_data',array()) + $empty_anonymize_ip_data; | |
| 2326 | + } | |
| 2327 | + if ($captcha_data['recaptcha_force_v1']) { | |
| 2328 | + $captcha_data = $empty_captcha_data; | |
| 2329 | + } | |
| 2330 | +?> | |
| 2331 | +<form method="post"> | |
| 2332 | +<?php wp_nonce_field('accua_form_save_settings', '_nonce_accua_form_save_settings'); ?> | |
| 2333 | +<input type="hidden" name="accua_form_save_form_settings" value="1" /> | |
| 2334 | +<?php /* | |
| 2335 | +<p id="accua_form_layout"><?php _e( 'Layout', 'contact-forms'); ?>: <select name="layout" class="accua_form_value"><option value="sidebyside" <?php if ($form_data['layout'] == 'sidebyside') { echo 'selected="selected"'; } ?>>Labels on the left of the fields</option><option value="toplabel" <?php if ($form_data['layout'] == 'toplabel') { echo 'selected="selected"'; } ?>>Labels on top of the fields</option></select></p> | |
| 2336 | +<p id="accua_form_success_message"><?php _e( 'Success message', 'contact-forms'); ?>:<br /><textarea name="success_message" class="accua_form_value" style="width:95%"; cols="80" rows="8"><?php echo htmlspecialchars($form_data['success_message'], ENT_QUOTES) ?></textarea></p> | |
| 2337 | +<p id="accua_form_error_message"><?php _e( 'Error message', 'contact-forms'); ?>:<br /><textarea name="error_message" class="accua_form_value" style="width:95%"; cols="80" rows="8"><?php echo htmlspecialchars($form_data['error_message'], ENT_QUOTES) ?></textarea></p> | |
| 2338 | +<p id="accua_form_emails_from"><?php _e( 'Emails from', 'contact-forms'); ?>: <input name="emails_from" class="accua_form_value" type="text" value="<?php echo htmlspecialchars($form_data['emails_from'], ENT_QUOTES) ?>" /></p> | |
| 2339 | +<p id="accua_form_admin_emails_to"><?php _e( 'Admin emails to', 'contact-forms'); ?>: <input name="admin_emails_to" class="accua_form_value" type="text" value="<?php echo htmlspecialchars($form_data['admin_emails_to'], ENT_QUOTES) ?>" /></p> | |
| 2340 | +<p id="accua_form_emails_bcc"><?php _e( 'Emails bcc', 'contact-forms'); ?>: <input name="emails_bcc" class="accua_form_value" type="text" value="<?php echo htmlspecialchars($form_data['emails_bcc'], ENT_QUOTES) ?>" /></p> | |
| 2341 | +<p id="accua_form_admin_emails_subject"><?php _e( 'Admin email subject', 'contact-forms'); ?>: <input name="admin_emails_subject" class="accua_form_value" type="text" value="<?php echo htmlspecialchars($form_data['admin_emails_subject'], ENT_QUOTES) ?>" /></p> | |
| 2342 | +<p id="accua_form_admin_emails_message"><?php _e( 'Admin email message', 'contact-forms'); ?>:<br /><textarea name="admin_emails_message" class="accua_form_value" style="width:95%"; cols="80" rows="8"><?php echo htmlspecialchars($form_data['admin_emails_message'], ENT_QUOTES) ?></textarea></p> | |
| 2343 | +<p id="accua_form_confirmation_emails_subject"><?php _e( 'Confirmation email subject', 'contact-forms'); ?>: <input name="confirmation_emails_subject" class="accua_form_value" type="text" value="<?php echo htmlspecialchars($form_data['confirmation_emails_subject'], ENT_QUOTES) ?>" /></p> | |
| 2344 | +<p id="accua_form_confirmation_emails_message"><?php _e( 'Confirmation email message', 'contact-forms'); ?>:<br /><textarea name="confirmation_emails_message" class="accua_form_value" style="width:95%"; cols="80" rows="8"><?php echo htmlspecialchars($form_data['confirmation_emails_message'], ENT_QUOTES) ?></textarea></p> | |
| 2345 | +*/ ?> | |
| 2346 | +<div id="accua_tab_messages" class="content_tab"> | |
| 2347 | + <?php | |
| 2348 | + $settings_editor = array( | |
| 2349 | + 'teeny' => true, | |
| 2350 | + 'editor_class' => 'accua_form_value', | |
| 2351 | + 'tinymce' => array( | |
| 2352 | + 'theme_advanced_buttons1' => 'bold,italic,underline,|,bullist,numlist,')); | |
| 2353 | + ?> | |
| 2354 | + <div class="metabox-holder accua-forms-metabox-holder"> | |
| 2355 | + <div class="postbox "> | |
| 2356 | + <h3 class="hndle"><span><?php _e('1. On-screen success message', 'contact-forms'); ?></span></h3> | |
| 2357 | + <div class="inside" id="dashboard_right_now"> | |
| 2358 | + <div id="accua_form_success_message"> | |
| 2359 | + <?php wp_editor( $form_data['success_message'] , 'success_message' , $settings_editor); ?> | |
| 2360 | + </div> | |
| 2361 | + </div> | |
| 2362 | + </div> | |
| 2363 | + </div> | |
| 2364 | + | |
| 2365 | + <div class="metabox-holder accua-forms-metabox-holder"> | |
| 2366 | + <div class="postbox "> | |
| 2367 | + <h3 class="hndle"><span><?php _e('2. On-screen error message', 'contact-forms'); ?></span></h3> | |
| 2368 | + <div class="inside" id="dashboard_right_now"> | |
| 2369 | + <div id="accua_form_error_message"> | |
| 2370 | + <?php wp_editor( $form_data['error_message'] , 'error_message' , $settings_editor); ?> | |
| 2371 | + </div> | |
| 2372 | + </div> | |
| 2373 | + </div> | |
| 2374 | + </div> | |
| 2375 | + <br clear="all"/> | |
| 2376 | + <div class="metabox-holder accua-forms-metabox-holder"> | |
| 2377 | + <div class="postbox "> | |
| 2378 | + <h3 class="hndle"><span><?php _e('3. Email to notify administrator', 'contact-forms'); ?></span></h3> | |
| 2379 | + <div class="inside" id="dashboard_right_now"> | |
| 2380 | + <div id="accua_form_admin_emails_to" class="label_input"> | |
| 2381 | + <label><?php _e( 'To', 'contact-forms'); ?></label> | |
| 2382 | + <input name="admin_emails_to" class="accua_form_value" type="text" value="<?php echo htmlspecialchars($form_data['admin_emails_to'], ENT_QUOTES) ?>" /> | |
| 2383 | + </div> | |
| 2384 | + <br clear="all" /> | |
| 2385 | + <div id="accua_form_emails_bcc" class="label_input"> | |
| 2386 | + <label><?php _e( 'Bcc', 'contact-forms'); ?></label> | |
| 2387 | + <input name="emails_bcc" class="accua_form_value" type="text" value="<?php echo htmlspecialchars($form_data['emails_bcc'], ENT_QUOTES) ?>" /> | |
| 2388 | + </div> | |
| 2389 | + <br clear="all" /> | |
| 2390 | + <div id="accua_form_admin_emails_subject" class="label_input"> | |
| 2391 | + <label><?php _e( 'Subject', 'contact-forms'); ?></label> | |
| 2392 | + <input name="admin_emails_subject" class="accua_form_value" type="text" value="<?php echo htmlspecialchars($form_data['admin_emails_subject'], ENT_QUOTES) ?>" /> | |
| 2393 | + </div> | |
| 2394 | + <br clear="all" /> | |
| 2395 | + <div id="accua_form_admin_emails_message"> | |
| 2396 | + <?php wp_editor( $form_data['admin_emails_message'] , 'admin_emails_message' , $settings_editor); ?> | |
| 2397 | + </div> | |
| 2398 | + | |
| 2399 | + </div> | |
| 2400 | + </div> | |
| 2401 | + </div> | |
| 2402 | + | |
| 2403 | + <div class="metabox-holder accua-forms-metabox-holder"> | |
| 2404 | + <div class="postbox "> | |
| 2405 | + <h3 class="hndle"><span><?php _e('4. Email confirmation to the person who completed the form', 'contact-forms'); ?></span></h3> | |
| 2406 | + <div class="inside" id="dashboard_right_now"> | |
| 2407 | + <div id="accua_form_emails_from_name" class="label_input"> | |
| 2408 | + <label><?php _e( 'From name', 'contact-forms'); ?></label> | |
| 2409 | + <input class="accua_form_value" name="emails_from_name" type="text" value="<?php echo htmlspecialchars($form_data['emails_from_name'], ENT_QUOTES) ?>" /> | |
| 2410 | + </div> | |
| 2411 | + <div id="accua_form_emails_from" class="label_input"> | |
| 2412 | + <label><?php _e( 'From email', 'contact-forms'); ?></label> | |
| 2413 | + <input class="accua_form_value" name="emails_from" type="text" value="<?php echo htmlspecialchars($form_data['emails_from'], ENT_QUOTES) ?>" /> | |
| 2414 | + </div> | |
| 2415 | + <br clear="all" /> | |
| 2416 | + <div id="accua_form_confirmation_emails_subject" class="label_input"> | |
| 2417 | + <label><?php _e( 'Subject', 'contact-forms'); ?></label> | |
| 2418 | + <input class="accua_form_value" type="text" name="confirmation_emails_subject" value="<?php echo htmlspecialchars($form_data['confirmation_emails_subject'], ENT_QUOTES) ?>" /> | |
| 2419 | + </div> | |
| 2420 | + <br clear="all" /> | |
| 2421 | + <div id="accua_form_confirmation_emails_message"> | |
| 2422 | + <?php wp_editor( $form_data['confirmation_emails_message'] , 'confirmation_emails_message' , $settings_editor); ?> | |
| 2423 | + </div> | |
| 2424 | + </div> | |
| 2425 | + </div> | |
| 2426 | + </div> | |
| 2427 | + <br clear="all"/> | |
| 2428 | + | |
| 2429 | + <div class="metabox-holder accua-forms-metabox-holder"> | |
| 2430 | + <div class="postbox "> | |
| 2431 | + <h3 class="hndle"><span><?php _e( 'File upload default settings', 'contact-forms'); ?></span></h3> | |
| 2432 | + <div class="inside" id="dashboard_right_now"> | |
| 2433 | + <div id="accua_form_valid_extensions"><?php _e( 'Valid extensions', 'contact-forms'); ?> <br /><textarea name="valid_extensions" class="accua_form_value" style="width:95%"; cols="80" rows="8"><?php echo htmlspecialchars($file_data['valid_extensions'], ENT_QUOTES) ?></textarea> | |
| 2434 | + <small><?php _e( 'List of valid extensions, without dot, one per line.', 'contact-forms'); ?></small> | |
| 2435 | + </div> | |
| 2436 | + <div id="accua_form_max_size"><?php _e( 'Maximum file size:', 'contact-forms'); ?> <input name="max_size" class="accua_form_value" type="text" value="<?php echo htmlspecialchars($file_data['max_size'], ENT_QUOTES) ?>" /><br /> | |
| 2437 | + <small><?php _e( 'You can use suffix K, M or G for kilobyte, megabyte or gigabyte.', 'contact-forms'); ?> | |
| 2438 | + <?php | |
| 2439 | + $server_max_size = AccuaForm_Element_File::file_upload_max_size(); | |
| 2440 | + if ($server_max_size > 0) { | |
| 2441 | + _e( 'This value is limited by server upload limits of ', 'contact-forms'); | |
| 2442 | + echo AccuaForm_Element_File::format_size($server_max_size).". "; | |
| 2443 | + _e( 'If you need a greater limit you should ask to the server administrator.', 'contact-forms'); | |
| 2444 | + } | |
| 2445 | + ?> | |
| 2446 | + </small> | |
| 2447 | + </div> | |
| 2448 | + <?php if (current_user_can('edit_files') || current_user_can('install_plugins')) { ?> | |
| 2449 | + <div id="accua_form_dest_path"><?php _e( 'Upload path', 'contact-forms');?> : <input name="dest_path" class="accua_form_value" type="text" value="<?php echo htmlspecialchars($file_data['dest_path'], ENT_QUOTES) ?>" /> | |
| 2450 | + <small><?php _e( 'If it stars with \'/\' an absolute path is used, otherwise a path relative to the WordPress installation directory. Default value is "wp-content/uploads/accua-forms"', 'contact-forms');?>.</small> | |
| 2451 | + </div> | |
| 2452 | + <?php } ?> | |
| 2453 | + </div> | |
| 2454 | + </div> | |
| 2455 | + | |
| 2456 | + <div class="postbox "> | |
| 2457 | + <h3 class="hndle"><span><?php _e( 'reCaptcha settings', 'contact-forms'); ?></span></h3> | |
| 2458 | + <div class="inside" id="dashboard_right_now"> | |
| 2459 | + <p><?php _e( 'As reCAPTCHA v1 is discontinued, only reCAPTCHA v2 is supported', 'contact-forms');?></p> | |
| 2460 | + <p><?php echo strtr(__('Please register this site for reCAPTCHA v2 on %REGISTERURL%, then enter the keys for this site in the following fields', 'contact-forms'), array('%REGISTERURL%' => '<a href="https://www.google.com/recaptcha" target="_blank">google.com/recaptcha</a>'));?></p> | |
| 2461 | + <div id="accua_form_recaptcha_public_key"><?php _e('Site key', 'contact-forms');?> : <input name="recaptcha_public_key" class="accua_form_value" type="text" value="<?php echo htmlspecialchars($captcha_data['recaptcha_public_key'], ENT_QUOTES) ?>" /> | |
| 2462 | + </div> | |
| 2463 | + <div id="accua_form_recaptcha_private_key"><?php _e('Secret key', 'contact-forms');?> : <input name="recaptcha_private_key" class="accua_form_value" type="text" value="<?php echo htmlspecialchars($captcha_data['recaptcha_private_key'], ENT_QUOTES) ?>" /> | |
| 2464 | + </div> | |
| 2465 | + </div> | |
| 2466 | + </div> | |
| 2467 | + | |
| 2468 | + <div class="postbox "> | |
| 2469 | + <h3 class="hndle"><span><?php _e( 'IP address tracking', 'contact-forms'); ?></span></h3> | |
| 2470 | + <div class="inside" id="dashboard_accua_form_anonymize_ip_addresses"> | |
| 2471 | + <p> | |
| 2472 | + <?php _e("Select how many bytes of the visitor's IPs should be masked.", 'contact-forms');?> | |
| 2473 | + </p> | |
| 2474 | + <p> | |
| 2475 | + <input type="radio" name="anonymize_ip_bytes" id="anonymize_ip_bytes_0" value="0" <?php if($anonymize_ip_data['anonymize_ip_bytes'] == 0) { echo 'checked="checked"'; } ?> /> | |
| 2476 | + <label for="anonymize_ip_bytes_0"><?php _e('No mask - e.g. 192.168.1.1', 'contact-forms');?></label><br /> | |
| 2477 | + </p> | |
| 2478 | + <p> | |
| 2479 | + <input type="radio" name="anonymize_ip_bytes" id="anonymize_ip_bytes_1" value="1" <?php if($anonymize_ip_data['anonymize_ip_bytes'] == 1) { echo 'checked="checked"'; } ?> /> | |
| 2480 | + <label for="anonymize_ip_bytes_1"><?php _e('1 byte - e.g. 192.168.1.xxx', 'contact-forms');?></label><br /> | |
| 2481 | + </p> | |
| 2482 | + <p> | |
| 2483 | + <input type="radio" name="anonymize_ip_bytes" id="anonymize_ip_bytes_2" value="2" <?php if($anonymize_ip_data['anonymize_ip_bytes'] == 2) { echo 'checked="checked"'; } ?> /> | |
| 2484 | + <label for="anonymize_ip_bytes_2"><?php _e('2 byte - e.g. 192.168.xxx.xxx', 'contact-forms');?></label><br /> | |
| 2485 | + </p> | |
| 2486 | + <p> | |
| 2487 | + <input type="radio" name="anonymize_ip_bytes" id="anonymize_ip_bytes_3" value="3" <?php if($anonymize_ip_data['anonymize_ip_bytes'] == 3) { echo 'checked="checked"'; } ?> /> | |
| 2488 | + <label for="anonymize_ip_bytes_3"><?php _e('3 byte - e.g. 192.xxx.xxx.xxx', 'contact-forms');?></label><br /> | |
| 2489 | + </p> | |
| 2490 | + <p> | |
| 2491 | + <input type="radio" name="anonymize_ip_bytes" id="anonymize_ip_bytes_4" value="4" <?php if($anonymize_ip_data['anonymize_ip_bytes'] == 4) { echo 'checked="checked"'; } ?> /> | |
| 2492 | + <label for="anonymize_ip_bytes_4"><?php _e('Fully mask IP address', 'contact-forms');?></label><br /> | |
| 2493 | + </p> | |
| 2494 | + <h4><?php _e( 'Delete IP addresses', 'contact-forms'); ?></h4> | |
| 2495 | + <p> | |
| 2496 | + <input type="checkbox" id="delete_previous_ip_values" name="delete_previous_ip_values" class="accua_form_value" value="1" /> | |
| 2497 | + <label for="delete_previous_ip_values"><?php _e('Delete all previous IP values', 'contact-forms');?></label><br /> | |
| 2498 | + </p> | |
| 2499 | + <br clear="all"> | |
| 2500 | + </div> | |
| 2501 | + </div> | |
| 2502 | + | |
| 2503 | + <div class="postbox "> | |
| 2504 | + <h3 class="hndle"><span><?php _e( 'Track actions with Google Analytics', 'contact-forms'); ?></span></h3> | |
| 2505 | + <div class="inside" id="dashboard_right_now"> | |
| 2506 | + <p> | |
| 2507 | + <input type="checkbox" id="accua_form_analytics_track_submit" name="analytics_track_submit" class="accua_form_value" value="1" <?php if($analytics_data['analytics_track_submit']) { echo 'checked="checked"'; } ?> /> | |
| 2508 | + <label for="accua_form_analytics_track_submit"><?php _e('Track submissions', 'contact-forms');?></label> | |
| 2509 | + </p> | |
| 2510 | + <p> | |
| 2511 | + <input type="checkbox" id="accua_form_analytics_track_fields" name="analytics_track_fields" class="accua_form_value" value="1" <?php if($analytics_data['analytics_track_fields']) { echo 'checked="checked"'; } ?> /> | |
| 2512 | + <label for="accua_form_analytics_track_fields"><?php _e('Track fields filled in', 'contact-forms');?></label> | |
| 2513 | + </p> | |
| 2514 | + </div> | |
| 2515 | + </div> | |
| 2516 | + | |
| 2517 | + </div> | |
| 2518 | + | |
| 2519 | + <div class="metabox-holder accua-forms-metabox-holder"> | |
| 2520 | + <div class="postbox "> | |
| 2521 | + <h3 class="hndle"><span><?php _e( 'Layout & Styling', 'contact-forms'); ?></span></h3> | |
| 2522 | + <div class="inside" id="dashboard_right_now"> | |
| 2523 | + <p><?php _e( 'Customize the look and feel of your forms. Leave fields empty if you wish to use the native styles of your WordPress Theme.', 'contact-forms'); ?><p> | |
| 2524 | + <h4><?php _e( 'Forms', 'contact-forms'); ?></h4> | |
| 2525 | + <div id="accua_form_layout"> <?php _e( 'Layout', 'contact-forms'); ?> | |
| 2526 | + <select name="layout" class="accua_form_value"><option value="sidebyside" <?php if ($form_data['layout'] == 'sidebyside') { echo 'selected="selected"'; } ?>>Labels on the left of the fields</option><option value="toplabel" <?php if ($form_data['layout'] == 'toplabel') { echo 'selected="selected"'; } ?>>Labels on top of the fields</option></select> | |
| 2527 | + </div> | |
| 2528 | + <div id="accua_form_style_margin" class="label_input"> | |
| 2529 | + <label><?php _e( 'Margin', 'contact-forms'); ?></label> | |
| 2530 | + <input name="style_margin" class="accua_form_value" type="text" value="<?php echo htmlspecialchars($form_data['style_margin'], ENT_QUOTES) ?>" /> | |
| 2531 | + </div> | |
| 2532 | + <div id="accua_form_style_border_color" class="label_input"> | |
| 2533 | + <label><?php _e( 'Border color', 'contact-forms'); ?></label> | |
| 2534 | + <input name="style_border_color" class="accua_form_value" type="text" value="<?php echo htmlspecialchars($form_data['style_border_color'], ENT_QUOTES) ?>" /> | |
| 2535 | + </div> | |
| 2536 | + <div id="accua_form_style_border_width" class="label_input"> | |
| 2537 | + <label><?php _e( 'Border width', 'contact-forms'); ?></label> | |
| 2538 | + <input name="style_border_width" class="accua_form_value" type="text" value="<?php echo htmlspecialchars($form_data['style_border_width'], ENT_QUOTES) ?>" /> | |
| 2539 | + </div> | |
| 2540 | + <div id="accua_form_style_border_radius" class="label_input"> | |
| 2541 | + <label><?php _e( 'Rounded corner radius', 'contact-forms'); ?></label> | |
| 2542 | + <input name="style_border_radius" class="accua_form_value" type="text" value="<?php echo htmlspecialchars($form_data['style_border_radius'], ENT_QUOTES) ?>" /> | |
| 2543 | + </div> | |
| 2544 | + <div id="accua_form_style_background_color" class="label_input"> | |
| 2545 | + <label><?php _e( 'Background color', 'contact-forms'); ?></label> | |
| 2546 | + <input name="style_background_color" class="accua_form_value" type="text" value="<?php echo htmlspecialchars($form_data['style_background_color'], ENT_QUOTES) ?>" /> | |
| 2547 | + </div> | |
| 2548 | + <div id="accua_form_style_padding" class="label_input"> | |
| 2549 | + <label><?php _e( 'Padding', 'contact-forms'); ?></label> | |
| 2550 | + <input name="style_padding" class="accua_form_value" type="text" value="<?php echo htmlspecialchars($form_data['style_padding'], ENT_QUOTES) ?>" /> | |
| 2551 | + </div> | |
| 2552 | + <div id="accua_form_style_color" class="label_input"> | |
| 2553 | + <label><?php _e( 'Text color', 'contact-forms'); ?></label> | |
| 2554 | + <input name="style_color" class="accua_form_value" type="text" value="<?php echo htmlspecialchars($form_data['style_color'], ENT_QUOTES) ?>" /> | |
| 2555 | + </div> | |
| 2556 | + <div id="accua_form_style_font_size" class="label_input"> | |
| 2557 | + <label><?php _e( 'Font size', 'contact-forms'); ?></label> | |
| 2558 | + <input name="style_font_size" class="accua_form_value" type="text" value="<?php echo htmlspecialchars($form_data['style_font_size'], ENT_QUOTES) ?>" /> | |
| 2559 | + </div> | |
| 2560 | + | |
| 2561 | + <h4><?php _e( 'Fields', 'contact-forms'); ?></h4> | |
| 2562 | + <div id="accua_form_style_field_spacing" class="label_input"> | |
| 2563 | + <label><?php _e( 'Spacing', 'contact-forms'); ?></label> | |
| 2564 | + <input name="style_field_spacing" class="accua_form_value" type="text" value="<?php echo htmlspecialchars($form_data['style_field_spacing'], ENT_QUOTES) ?>" /> | |
| 2565 | + </div> | |
| 2566 | + <div id="accua_form_style_field_border_color" class="label_input"> | |
| 2567 | + <label><?php _e( 'Border color', 'contact-forms'); ?></label> | |
| 2568 | + <input name="style_field_border_color" class="accua_form_value" type="text" value="<?php echo htmlspecialchars($form_data['style_field_border_color'], ENT_QUOTES) ?>" /> | |
| 2569 | + </div> | |
| 2570 | + <div id="accua_form_style_field_border_width" class="label_input"> | |
| 2571 | + <label><?php _e( 'Border width', 'contact-forms'); ?></label> | |
| 2572 | + <input name="style_field_border_width" class="accua_form_value" type="text" value="<?php echo htmlspecialchars($form_data['style_field_border_width'], ENT_QUOTES) ?>" /> | |
| 2573 | + </div> | |
| 2574 | + <div id="accua_form_style_field_border_radius" class="label_input"> | |
| 2575 | + <label><?php _e( 'Rounded corner radius', 'contact-forms'); ?></label> | |
| 2576 | + <input name="style_field_border_radius" class="accua_form_value" type="text" value="<?php echo htmlspecialchars($form_data['style_field_border_radius'], ENT_QUOTES) ?>" /> | |
| 2577 | + </div> | |
| 2578 | + <div id="accua_form_style_field_background_color" class="label_input"> | |
| 2579 | + <label><?php _e( 'Background color', 'contact-forms'); ?></label> | |
| 2580 | + <input name="style_field_background_color" class="accua_form_value" type="text" value="<?php echo htmlspecialchars($form_data['style_field_background_color'], ENT_QUOTES) ?>" /> | |
| 2581 | + </div> | |
| 2582 | + <div id="accua_form_style_field_padding" class="label_input"> | |
| 2583 | + <label><?php _e( 'Padding', 'contact-forms'); ?></label> | |
| 2584 | + <input name="style_field_padding" class="accua_form_value" type="text" value="<?php echo htmlspecialchars($form_data['style_field_padding'], ENT_QUOTES) ?>" /> | |
| 2585 | + </div> | |
| 2586 | + <div id="accua_form_style_field_color" class="label_input"> | |
| 2587 | + <label><?php _e( 'Text color', 'contact-forms'); ?></label> | |
| 2588 | + <input name="style_field_color" class="accua_form_value" type="text" value="<?php echo htmlspecialchars($form_data['style_field_color'], ENT_QUOTES) ?>" /> | |
| 2589 | + </div> | |
| 2590 | + | |
| 2591 | + <h4><?php _e( 'Submit button', 'contact-forms'); ?></h4> | |
| 2592 | + <div id="accua_form_style_submit_border_color" class="label_input"> | |
| 2593 | + <label><?php _e( 'Border color', 'contact-forms'); ?></label> | |
| 2594 | + <input name="style_submit_border_color" class="accua_form_value" type="text" value="<?php echo htmlspecialchars($form_data['style_submit_border_color'], ENT_QUOTES) ?>" /> | |
| 2595 | + </div> | |
| 2596 | + <div id="accua_form_style_submit_border_width" class="label_input"> | |
| 2597 | + <label><?php _e( 'Border width', 'contact-forms'); ?></label> | |
| 2598 | + <input name="style_submit_border_width" class="accua_form_value" type="text" value="<?php echo htmlspecialchars($form_data['style_submit_border_width'], ENT_QUOTES) ?>" /> | |
| 2599 | + </div> | |
| 2600 | + <div id="accua_form_style_submit_border_radius" class="label_input"> | |
| 2601 | + <label><?php _e( 'Rounded corner radius', 'contact-forms'); ?></label> | |
| 2602 | + <input name="style_submit_border_radius" class="accua_form_value" type="text" value="<?php echo htmlspecialchars($form_data['style_submit_border_radius'], ENT_QUOTES) ?>" /> | |
| 2603 | + </div> | |
| 2604 | + <div id="accua_form_style_submit_background_color" class="label_input"> | |
| 2605 | + <label><?php _e( 'Background color', 'contact-forms'); ?></label> | |
| 2606 | + <input name="style_submit_background_color" class="accua_form_value" type="text" value="<?php echo htmlspecialchars($form_data['style_submit_background_color'], ENT_QUOTES) ?>" /> | |
| 2607 | + </div> | |
| 2608 | + <div id="accua_form_style_submit_padding" class="label_input"> | |
| 2609 | + <label><?php _e( 'Padding', 'contact-forms'); ?></label> | |
| 2610 | + <input name="style_submit_padding" class="accua_form_value" type="text" value="<?php echo htmlspecialchars($form_data['style_submit_padding'], ENT_QUOTES) ?>" /> | |
| 2611 | + </div> | |
| 2612 | + <div id="accua_form_style_submit_color" class="label_input"> | |
| 2613 | + <label><?php _e( 'Text color', 'contact-forms'); ?></label> | |
| 2614 | + <input name="style_submit_color" class="accua_form_value" type="text" value="<?php echo htmlspecialchars($form_data['style_submit_color'], ENT_QUOTES) ?>" /> | |
| 2615 | + </div> | |
| 2616 | + <div id="accua_form_style_submit_font_size" class="label_input"> | |
| 2617 | + <label><?php _e( 'Font size', 'contact-forms'); ?></label> | |
| 2618 | + <input name="style_submit_font_size" class="accua_form_value" type="text" value="<?php echo htmlspecialchars($form_data['style_submit_font_size'], ENT_QUOTES) ?>" /> | |
| 2619 | + </div> | |
| 2620 | + <br clear="all" /> | |
| 2621 | + </div> | |
| 2622 | + </div> | |
| 2623 | + </div> | |
| 2624 | + | |
| 2625 | + | |
| 2626 | + <br clear="all"/> | |
| 2627 | + | |
| 2628 | +</div> | |
| 2629 | + | |
| 2630 | +<?php /* | |
| 2631 | +<h3><?php _e( 'File upload default settings', 'contact-forms'); ?></h3> | |
| 2632 | +<p id="accua_form_valid_extensions"><?php _e( 'Valid extensions', 'contact-forms'); ?> <br /><textarea name="valid_extensions" class="accua_form_value" style="width:95%"; cols="80" rows="8"><?php echo htmlspecialchars($file_data['valid_extensions'], ENT_QUOTES) ?></textarea> | |
| 2633 | + <small><?php _e( 'List of valid extensions, without dot, one per line.', 'contact-forms'); ?></small> | |
| 2634 | +</p> | |
| 2635 | +<p id="accua_form_max_size"><?php _e( 'Maximum file size:', 'contact-forms'); ?> <input name="max_size" class="accua_form_value" type="text" value="<?php echo htmlspecialchars($file_data['max_size'], ENT_QUOTES) ?>" /><br /> | |
| 2636 | + <small><?php _e( 'You can use suffix K, M or G for kilobyte, megabyte or gigabyte.', 'contact-forms'); ?> | |
| 2637 | +<?php | |
| 2638 | + $server_max_size = AccuaForm_Element_File::file_upload_max_size(); | |
| 2639 | + if ($server_max_size > 0) { | |
| 2640 | + _e( 'This value is limited by server upload limits of ', 'contact-forms'); | |
| 2641 | + echo AccuaForm_Element_File::format_size($server_max_size).". "; | |
| 2642 | + _e( 'If you need a greater limit you should ask to the server administrator.', 'contact-forms'); | |
| 2643 | + } | |
| 2644 | +?> | |
| 2645 | + </small></p> | |
| 2646 | +<p id="accua_form_dest_path"><?php _e( 'Upload path', 'contact-forms');?> : <input name="dest_path" class="accua_form_value" type="text" value="<?php echo htmlspecialchars($file_data['dest_path'], ENT_QUOTES) ?>" /> | |
| 2647 | + <small><?php _e( 'If it stars with \'/\' an absolute path is used, otherwise a path relative to the WordPress installation directory. Default value is "wp-content/uploads/accua-forms"', 'contact-forms');?>.</small> | |
| 2648 | +</p> */ ?> | |
| 2649 | +<p><input class="button button-primary button-large" id="accua_form_save_settings" type="submit" value="Save settings" /></p> | |
| 2650 | + | |
| 2651 | +<?php accua_forms_print_tokens(); ?> | |
| 2652 | + | |
| 2653 | +</form> | |
| 2654 | +</div> | |
| 2655 | + | |
| 2656 | +<script type='text/javascript'> | |
| 2657 | +jQuery(function($) { | |
| 2658 | + $('#accua_form_style_border_color .accua_form_value').colorPicker(); | |
| 2659 | + $('#accua_form_style_background_color .accua_form_value').colorPicker(); | |
| 2660 | + $('#accua_form_style_color .accua_form_value').colorPicker(); | |
| 2661 | + $('#accua_form_style_field_border_color .accua_form_value').colorPicker(); | |
| 2662 | + $('#accua_form_style_field_background_color .accua_form_value').colorPicker(); | |
| 2663 | + $('#accua_form_style_field_color .accua_form_value').colorPicker(); | |
| 2664 | + $('#accua_form_style_submit_border_color .accua_form_value').colorPicker(); | |
| 2665 | + $('#accua_form_style_submit_background_color .accua_form_value').colorPicker(); | |
| 2666 | + $('#accua_form_style_submit_color .accua_form_value').colorPicker(); | |
| 2667 | +}); | |
| 2668 | +</script> | |
| 2669 | + | |
| 2670 | +<?php | |
| 2671 | +} | |
| 2672 | + | |
| 2673 | +function _accua_forms_get_abs_dest_path($dest_path = '') { | |
| 2674 | + if ($dest_path === '') { | |
| 2675 | + return realpath(ABSPATH) . '/wp-content/uploads/accua-forms'; | |
| 2676 | + } else if (substr($dest_path,0,1) === '/') { | |
| 2677 | + return $dest_path; | |
| 2678 | + } else { | |
| 2679 | + return realpath(ABSPATH) . '/' . $dest_path; | |
| 2680 | + } | |
| 2681 | +} | |
| 2682 | + | |
| 2683 | +function _accua_forms_get_form_data($fid = false, $return_empty = true, $restore_trash = false){ | |
| 2684 | + $empty_form_data = array( | |
| 2685 | + 'fields' => array(), | |
| 2686 | + 'title' => '', | |
| 2687 | + 'success_message' => '', | |
| 2688 | + 'error_message' => '', | |
| 2689 | + 'emails_from_name' => '', | |
| 2690 | + 'emails_from' => '', | |
| 2691 | + 'admin_emails_to' => '', | |
| 2692 | + 'emails_bcc' => '', | |
| 2693 | + 'admin_emails_subject' => '', | |
| 2694 | + 'admin_emails_message' => '', | |
| 2695 | + 'confirmation_emails_subject' => '', | |
| 2696 | + 'confirmation_emails_message' => '', | |
| 2697 | + 'use_ajax' => true, | |
| 2698 | + 'layout' => 'sidebyside', | |
| 2699 | + 'style_margin' => '', | |
| 2700 | + 'style_border_color' => '', | |
| 2701 | + 'style_border_width' => '', | |
| 2702 | + 'style_border_radius' => '', | |
| 2703 | + 'style_background_color' => '', | |
| 2704 | + 'style_padding' => '', | |
| 2705 | + 'style_color' => '', | |
| 2706 | + 'style_font_size' => '', | |
| 2707 | + 'style_field_spacing' => '', | |
| 2708 | + 'style_field_border_color' => '', | |
| 2709 | + 'style_field_border_width' => '', | |
| 2710 | + 'style_field_border_radius' => '', | |
| 2711 | + 'style_field_background_color' => '', | |
| 2712 | + 'style_field_padding' => '', | |
| 2713 | + 'style_field_color' => '', | |
| 2714 | + 'style_submit_border_color' => '', | |
| 2715 | + 'style_submit_border_width' => '', | |
| 2716 | + 'style_submit_border_radius' => '', | |
| 2717 | + 'style_submit_background_color' => '', | |
| 2718 | + 'style_submit_padding' => '', | |
| 2719 | + 'style_submit_color' => '', | |
| 2720 | + 'style_submit_font_size' => '', | |
| 2721 | + ); | |
| 2722 | + | |
| 2723 | + if ($fid === false) { | |
| 2724 | + return $empty_form_data; | |
| 2725 | + } | |
| 2726 | + | |
| 2727 | + $default_form_data = get_option('accua_forms_default_form_data',array()); | |
| 2728 | + | |
| 2729 | + if ($fid === null) { | |
| 2730 | + return $default_form_data + $empty_form_data; | |
| 2731 | + } | |
| 2732 | + | |
| 2733 | + $forms_data = get_option('accua_forms_saved_forms', array()); | |
| 2734 | + if ($restore_trash) { | |
| 2735 | + $trash_data = get_option('accua_forms_trash_forms', array()); | |
| 2736 | + if (isset($trash_data[$fid])) { | |
| 2737 | + $forms_data[$fid] = $trash_data[$fid]; | |
| 2738 | + update_option('accua_forms_saved_forms', $forms_data); | |
| 2739 | + unset($trash_data[$fid]); | |
| 2740 | + update_option('accua_forms_trash_forms', $trash_data); | |
| 2741 | + } | |
| 2742 | + } | |
| 2743 | + | |
| 2744 | + if (isset($forms_data[$fid])) { | |
| 2745 | + $form_data = array( | |
| 2746 | + '_overrided' => $forms_data[$fid] | |
| 2747 | + ) + $forms_data[$fid] + $default_form_data + $empty_form_data; | |
| 2748 | + /* | |
| 2749 | + if ($form_data['fields']) { | |
| 2750 | + foreach ($form_data['fields'] as $i => $istance_data) { | |
| 2751 | + // TODO: popuplate default fields data? | |
| 2752 | + } | |
| 2753 | + } | |
| 2754 | + */ | |
| 2755 | + return $form_data; | |
| 2756 | + } else if ($return_empty) { | |
| 2757 | + return array( | |
| 2758 | + '_overrided' => array() | |
| 2759 | + ) + $default_form_data + $empty_form_data; | |
| 2760 | + } else { | |
| 2761 | + return null; | |
| 2762 | + } | |
| 2763 | + | |
| 2764 | +} | |
| 2765 | + | |
| 2766 | +function _accua_forms_style_parameters($params) { | |
| 2767 | + $ret = ''; | |
| 2768 | + foreach ($params as $key => $value) { | |
| 2769 | + $value = trim($value); | |
| 2770 | + if ($value !== '') { | |
| 2771 | + if (is_numeric($value)) { | |
| 2772 | + $ret .= "{$key}:{$value}px;"; | |
| 2773 | + } else { | |
| 2774 | + $ret .= "{$key}:{$value};"; | |
| 2775 | + } | |
| 2776 | + if ($key == 'border-width') { | |
| 2777 | + $ret .= "border-style:solid;"; | |
| 2778 | + } | |
| 2779 | + } | |
| 2780 | + } | |
| 2781 | + return $ret; | |
| 2782 | +} | |
| 2783 | + | |
| 2784 | +/* | |
| 2785 | + * generazione del form (e della preview) | |
| 2786 | + * */ | |
| 2787 | +add_action('accua_form_alter', 'accua_forms_form_generate', -999, 2); | |
| 2788 | +function accua_forms_form_generate($baseid, $form) { | |
| 2789 | + if (substr($baseid, 0, 14) == '__accua-form__') { | |
| 2790 | + $fid = substr($baseid,14); | |
| 2791 | + $form_data = _accua_forms_get_form_data($fid, false); | |
| 2792 | + /* | |
| 2793 | + echo '<!-- fid = '; | |
| 2794 | + print_r($fid); | |
| 2795 | + echo "\n\nform_data = "; | |
| 2796 | + print_r($form_data); | |
| 2797 | + echo "\n-->"; | |
| 2798 | + */ | |
| 2799 | + if ($form_data) { | |
| 2800 | + $form_style = _accua_forms_style_parameters(array( | |
| 2801 | + 'margin' => $form_data['style_margin'], | |
| 2802 | + 'border-color' => $form_data['style_border_color'], | |
| 2803 | + 'border-width' => $form_data['style_border_width'], | |
| 2804 | + 'border-radius' => $form_data['style_border_radius'], | |
| 2805 | + 'background' => $form_data['style_background_color'], | |
| 2806 | + 'padding' => $form_data['style_padding'], | |
| 2807 | + 'color' => $form_data['style_color'], | |
| 2808 | + 'font-size' => $form_data['style_font_size'], | |
| 2809 | + )); | |
| 2810 | + | |
| 2811 | + $field_style = _accua_forms_style_parameters(array( | |
| 2812 | + 'margin-bottom' => $form_data['style_field_spacing'], | |
| 2813 | + 'border-color' => $form_data['style_field_border_color'], | |
| 2814 | + 'border-width' => $form_data['style_field_border_width'], | |
| 2815 | + 'border-radius' => $form_data['style_field_border_radius'], | |
| 2816 | + 'background' => (trim($form_data['style_field_background_color']) === '')?'transparent':$form_data['style_field_background_color'], | |
| 2817 | + 'padding' => $form_data['style_field_padding'], | |
| 2818 | + 'color' => (trim($form_data['style_field_color']) === '')?$form_data['style_color']:$form_data['style_field_color'], | |
| 2819 | + 'font-size' => $form_data['style_font_size'], | |
| 2820 | + )); | |
| 2821 | + $field_properties = array(); | |
| 2822 | + if ($field_style !== '') { | |
| 2823 | + $field_properties['style'] = $field_style; | |
| 2824 | + } | |
| 2825 | + | |
| 2826 | + $submit_style = _accua_forms_style_parameters(array( | |
| 2827 | + 'border-color' => $form_data['style_submit_border_color'], | |
| 2828 | + 'border-width' => $form_data['style_submit_border_width'], | |
| 2829 | + 'border-radius' => $form_data['style_submit_border_radius'], | |
| 2830 | + 'background' => $form_data['style_submit_background_color'], | |
| 2831 | + 'padding' => $form_data['style_submit_padding'], | |
| 2832 | + 'color' => $form_data['style_submit_color'], | |
| 2833 | + 'font-size' => $form_data['style_submit_font_size'], | |
| 2834 | + )); | |
| 2835 | + $submit_properties = array(); | |
| 2836 | + if ($submit_style !== '') { | |
| 2837 | + $submit_properties['style'] = $submit_style; | |
| 2838 | + } | |
| 2839 | + | |
| 2840 | + if ($form_style !== '') { | |
| 2841 | + $form->configure(array('style' => $form_style)); | |
| 2842 | + } | |
| 2843 | + | |
| 2844 | + if (!empty($form_data['use_ajax'])){ | |
| 2845 | + $form->configure(array( | |
| 2846 | + "accua_ajax" => 1, | |
| 2847 | + )); | |
| 2848 | + } | |
| 2849 | + | |
| 2850 | + $add_submit = true; | |
| 2851 | + $fieldset_open = false; | |
| 2852 | + $avail_fields = get_option('accua_forms_avail_fields', array()); | |
| 2853 | + | |
| 2854 | + foreach ($form_data['fields'] as $istance_data) { | |
| 2855 | + if (empty($avail_fields[$istance_data['ref']])) { | |
| 2856 | + $field_data = array(); | |
| 2857 | + if (!empty($istance_data['ref'])) { | |
| 2858 | + if ($istance_data['ref'] == '__fieldset-begin') { | |
| 2859 | + $field_data = array( | |
| 2860 | + 'id' => '__fieldset-begin', | |
| 2861 | + 'name' => __('Fieldset begin', 'contact-forms'), | |
| 2862 | + 'type' => 'fieldset-begin', | |
| 2863 | + 'description' => '', | |
| 2864 | + ); | |
| 2865 | + } else if ($istance_data['ref'] == '__fieldset-end') { | |
| 2866 | + $field_data = array( | |
| 2867 | + 'id' => '__fieldset-end', | |
| 2868 | + 'name' => __('Fieldset end', 'contact-forms'), | |
| 2869 | + 'type' => 'fieldset-end', | |
| 2870 | + 'description' => '', | |
| 2871 | + ); | |
| 2872 | + } | |
| 2873 | + } | |
| 2874 | + } else { | |
| 2875 | + $field_data = $avail_fields[$istance_data['ref']]; | |
| 2876 | + } | |
| 2877 | + | |
| 2878 | + $field_data += array( | |
| 2879 | + 'version' => 1, | |
| 2880 | + 'id' => '__html', | |
| 2881 | + 'name' => __( 'Custom HTML content', 'contact-forms'), | |
| 2882 | + 'type' => 'html', | |
| 2883 | + 'description' => __('Use this special field to inject raw HTML in the form. You can use this multiple times.', 'contact-forms'), | |
| 2884 | + 'default_value' => '', | |
| 2885 | + 'allowed_values' => '', | |
| 2886 | + 'allowed_extensions' => '', | |
| 2887 | + ); | |
| 2888 | + | |
| 2889 | + $istance_data += array( | |
| 2890 | + 'version' => 1, | |
| 2891 | + ); | |
| 2892 | + | |
| 2893 | + if ($field_data['type'] == 'file') { | |
| 2894 | + if ($field_data['version'] < 2) { | |
| 2895 | + $field_data['allowed_extensions'] = $field_data['allowed_values']; | |
| 2896 | + } | |
| 2897 | + if ($istance_data['version'] < 2 && isset($istance_data['allowed_values'])) { | |
| 2898 | + $istance_data['allowed_extensions'] = $istance_data['allowed_values']; | |
| 2899 | + } | |
| 2900 | + } | |
| 2901 | + | |
| 2902 | + /* prendo i dati relativi ai campi di tipo date | |
| 2903 | + lo faccio prima, così default value in questo modo viene sovrascritto se un campo è di un tipo diverso | |
| 2904 | + | |
| 2905 | + NB: se i campi sono già sovrascritti, si trovano già in istance_data */ | |
| 2906 | + if ($field_data['type'] == 'date'){ | |
| 2907 | + $istance_data += array( | |
| 2908 | + 'default_value' => $field_data['default_date_value'], | |
| 2909 | + 'min_date' => $field_data['min_date'], | |
| 2910 | + 'max_date' => $field_data['max_date'], | |
| 2911 | + ); | |
| 2912 | + } | |
| 2913 | + | |
| 2914 | + $istance_data += array( | |
| 2915 | + 'istance_id' => $field_data['id'], | |
| 2916 | + 'widget_number' => '', | |
| 2917 | + 'ref' => $field_data['id'], | |
| 2918 | + 'label' => $field_data['name'], | |
| 2919 | + 'default_value' => $field_data['default_value'], /* viene impostato il valore di defualt se non è un campo data */ | |
| 2920 | + 'allowed_values' => $field_data['allowed_values'], | |
| 2921 | + 'allowed_extensions' => $field_data['allowed_extensions'], | |
| 2922 | + ); | |
| 2923 | + | |
| 2924 | + $element = NULL; | |
| 2925 | + $element_conf = NULL; | |
| 2926 | + | |
| 2927 | + $allowed_val = trim($istance_data['allowed_values']); | |
| 2928 | + | |
| 2929 | + if ($field_data['type'] == 'post-multicheckbox' || $field_data['type'] == 'post-select') { | |
| 2930 | + $posts = accua_get_pages($allowed_val); | |
| 2931 | + $allowed_values = array(); | |
| 2932 | + foreach ($posts as $p) { | |
| 2933 | + //$allowed_values[$p->ID] = apply_filters( 'the_title', $p->post_title, $p->ID ); | |
| 2934 | + $allowed_values[$p->ID] = $p->post_title; | |
| 2935 | + } | |
| 2936 | + } else { | |
| 2937 | + if ($field_data['type'] == 'file') { | |
| 2938 | + $filedata = get_option('accua_forms_default_file_field_data',array()); | |
| 2939 | + $filedata += array( | |
| 2940 | + 'valid_extensions' => '', | |
| 2941 | + 'max_filesize' => '', | |
| 2942 | + 'dest_path' => '', | |
| 2943 | + ); | |
| 2944 | + $allowed_val = accua_forms_filter_extensions($istance_data['allowed_extensions']); | |
| 2945 | + if ($allowed_val == '') { | |
| 2946 | + $allowed_val = accua_forms_filter_extensions($filedata['valid_extensions']); | |
| 2947 | + } | |
| 2948 | + } | |
| 2949 | + | |
| 2950 | + $allowed_val = explode("\n",$allowed_val); | |
| 2951 | + $allowed_values = array(); | |
| 2952 | + foreach ($allowed_val as $val) { | |
| 2953 | + $val = explode('|',$val,2); | |
| 2954 | + $val[0] = trim($val[0]); | |
| 2955 | + /* | |
| 2956 | + if (empty($val[0])) { | |
| 2957 | + continue; | |
| 2958 | + } | |
| 2959 | + */ | |
| 2960 | + if ((!isset($val[1])) || (trim($val[1])==='')) { | |
| 2961 | + if ($val[0] === '') { | |
| 2962 | + continue; | |
| 2963 | + } else { | |
| 2964 | + $val[1] = $val[0]; | |
| 2965 | + } | |
| 2966 | + } | |
| 2967 | + $allowed_values[$val[0]] = $val[1]; | |
| 2968 | + } | |
| 2969 | + } | |
| 2970 | + | |
| 2971 | + switch ($field_data['type']) { | |
| 2972 | + case 'textarea': | |
| 2973 | + $element = new Element_Textarea($istance_data['label'], $istance_data['istance_id'], $field_properties+array('cols' => '50', 'value'=>$istance_data['default_value'])); | |
| 2974 | + break; | |
| 2975 | + case 'hidden': | |
| 2976 | + $element = new Element_Hidden($istance_data['istance_id'], $istance_data['default_value']); | |
| 2977 | + break; | |
| 2978 | + case 'checkbox': | |
| 2979 | + $lab = $istance_data['label']; | |
| 2980 | + if (!empty($istance_data['required'])) { | |
| 2981 | + $lab .= ' <strong>*</strong>'; | |
| 2982 | + } | |
| 2983 | + if ($allowed_values) { | |
| 2984 | + reset($allowed_values); | |
| 2985 | + $val = (string) key($allowed_values); | |
| 2986 | + $defval = trim($istance_data['default_value']); | |
| 2987 | + } else if ($istance_data['default_value'] == '1') { | |
| 2988 | + $defval = $val = '1'; | |
| 2989 | + } else { | |
| 2990 | + $val = empty($istance_data['default_value'])?'1':$istance_data['default_value']; | |
| 2991 | + $defval = ''; | |
| 2992 | + } | |
| 2993 | + $element = new AccuaForm_Element_Checkbox('', $istance_data['istance_id'], array($val => $lab), array('value' => $defval)); | |
| 2994 | + break; | |
| 2995 | + case 'select': | |
| 2996 | + case 'post-select': | |
| 2997 | + if (!isset($allowed_values[''])) { | |
| 2998 | + $allowed_values = array('' => '') + $allowed_values; | |
| 2999 | + } | |
| 3000 | + $defval = trim($istance_data['default_value']); | |
| 3001 | + $element = new AccuaForm_Element_Select($istance_data['label'], $istance_data['istance_id'], $allowed_values, $field_properties+array('value'=>$defval)); | |
| 3002 | + break; | |
| 3003 | + case 'radio': | |
| 3004 | + $defval = trim($istance_data['default_value']); | |
| 3005 | + $element = new AccuaForm_Element_Radio($istance_data['label'], $istance_data['istance_id'], $allowed_values, array('value'=>$defval)); | |
| 3006 | + break; | |
| 3007 | + case 'multiselect': | |
| 3008 | + $defval = explode('|', $istance_data['default_value']); | |
| 3009 | + foreach ($defval as $k => $v) { | |
| 3010 | + $defval[$k] = trim($v); | |
| 3011 | + } | |
| 3012 | + $element = new AccuaForm_Element_Select($istance_data['label'], $istance_data['istance_id'], $allowed_values, $field_properties+array('multiple' => true, 'value'=>$defval)); | |
| 3013 | + break; | |
| 3014 | + case 'multicheckbox': | |
| 3015 | + case 'post-multicheckbox': | |
| 3016 | + $defval = explode('|', $istance_data['default_value']); | |
| 3017 | + foreach ($defval as $k => $v) { | |
| 3018 | + $defval[$k] = trim($v); | |
| 3019 | + } | |
| 3020 | + $element = new AccuaForm_Element_Checkbox($istance_data['label'], $istance_data['istance_id'], $allowed_values, array('value'=>$defval)); | |
| 3021 | + break; | |
| 3022 | + case 'file': | |
| 3023 | + $fdata = array(); | |
| 3024 | + | |
| 3025 | + if ($allowed_values) { | |
| 3026 | + $fdata['validExtensions'] = array_keys($allowed_values); | |
| 3027 | + } | |
| 3028 | + | |
| 3029 | + if (!empty($filedata['max_size'])){ | |
| 3030 | + $fdata['maxSize'] = $filedata['max_size']; | |
| 3031 | + } | |
| 3032 | + | |
| 3033 | + $fdata['destPath'] = _accua_forms_get_abs_dest_path($filedata['dest_path']); | |
| 3034 | + | |
| 3035 | + $element = new AccuaForm_Element_File($istance_data['label'], $istance_data['istance_id'], $field_properties+$fdata); | |
| 3036 | + break; | |
| 3037 | + case 'html': | |
| 3038 | + $element = new Element_HTML($istance_data['default_value']); | |
| 3039 | + break; | |
| 3040 | + case 'email': | |
| 3041 | + case 'autoreply_email': | |
| 3042 | + $element = new AccuaForm_Element_Email($istance_data['label'], $istance_data['istance_id'], $field_properties+array('value'=>$istance_data['default_value'])); | |
| 3043 | + $element->setValidation(new Validation_Email( | |
| 3044 | + str_replace('%element%', $istance_data['label'], __("Attention: '%element%' must contain an email address.", 'contact-forms')) | |
| 3045 | + )); | |
| 3046 | + //"Errore: '{$istance_data['label']}' deve contenere un indirizzo email valido." | |
| 3047 | + break; | |
| 3048 | + case 'colorpicker': | |
| 3049 | + $element = new AccuaForm_Element_ColorPicker($istance_data['label'], $istance_data['istance_id'], $field_properties+array('value'=>$istance_data['default_value'])); | |
| 3050 | + break; | |
| 3051 | + case 'fieldset-begin': | |
| 3052 | + if ($fieldset_open) { | |
| 3053 | + $form->addElement(new AccuaForm_Element_FieldsetEnd()); | |
| 3054 | + } else { | |
| 3055 | + $fieldset_open = true; | |
| 3056 | + } | |
| 3057 | + $element = new AccuaForm_Element_FieldsetBegin($istance_data['label'], $istance_data['istance_id']); | |
| 3058 | + break; | |
| 3059 | + case 'fieldset-end': | |
| 3060 | + if ($fieldset_open) { | |
| 3061 | + $element = new AccuaForm_Element_FieldsetEnd(); | |
| 3062 | + $fieldset_open = false; | |
| 3063 | + } | |
| 3064 | + break; | |
| 3065 | + case 'submit': | |
| 3066 | + $add_submit = false; | |
| 3067 | + $element = new Element_Button($istance_data['label'], 'submit', $submit_properties+array('name' => $istance_data['istance_id'], 'value' => $istance_data['default_value'])); | |
| 3068 | + break; | |
| 3069 | + case 'captcha': | |
| 3070 | + $empty_captcha_data = array( | |
| 3071 | + 'recaptcha_force_v1' => '', | |
| 3072 | + 'recaptcha_public_key' => '', | |
| 3073 | + 'recaptcha_private_key' => '', | |
| 3074 | + ); | |
| 3075 | + $captcha_data = get_option('accua_forms_default_captcha_field_data',array()) + $empty_captcha_data; | |
| 3076 | + $captcha_properties = array("description" => ""); | |
| 3077 | + $captcha_use_v1 = true; | |
| 3078 | + if (($captcha_data['recaptcha_public_key'] !== '') && ($captcha_data['recaptcha_private_key'] !== '')) { | |
| 3079 | + $captcha_properties['privateKey'] = $captcha_data['recaptcha_private_key']; | |
| 3080 | + $captcha_properties['publicKey'] = $captcha_data['recaptcha_public_key']; | |
| 3081 | + $captcha_use_v1 = $captcha_data['recaptcha_force_v1']; | |
| 3082 | + } | |
| 3083 | + if ($captcha_use_v1) { | |
| 3084 | + $element = new Element_HTML("\n\n<!-- ReCaptcha 1 is discontinued, please go to Contact Forms settings page and set reCaptcha v2 keys -->\n\n"); | |
| 3085 | + } else { | |
| 3086 | + $element = new AccuaForm_Element_Captcha2 ($istance_data['label'], '', $captcha_properties); | |
| 3087 | + } | |
| 3088 | + break; | |
| 3089 | + case 'password': | |
| 3090 | + $element = new Element_Password($istance_data['label'], $istance_data['istance_id'], $field_properties+array('value'=>$istance_data['default_value'])); | |
| 3091 | + break; | |
| 3092 | + case 'password-and-confirm': | |
| 3093 | + $id_2 = "___{$istance_data['istance_id']}___confirmpass"; | |
| 3094 | + $element = new Element_Password(__("Password", 'contact-forms'), $istance_data['istance_id'], $field_properties+array('value'=>$istance_data['default_value'])); | |
| 3095 | + $element_conf = new Element_Password(__("Confirm password", 'contact-forms'), $id_2, $field_properties+array('value'=>$istance_data['default_value'])); | |
| 3096 | + $element_conf_validator = new AccuaForm_Validation_Password(); | |
| 3097 | + $element_conf_validator->configure(array('otherPasswordFieldName'=>$istance_data['istance_id'])); | |
| 3098 | + $element_conf->setValidation($element_conf_validator); | |
| 3099 | + break; | |
| 3100 | + case 'date': | |
| 3101 | + $element = new AccuaForm_Element_Date($istance_data['label'], $istance_data['istance_id'], $field_properties+array('value'=>$istance_data['default_value'], 'minDate'=>$istance_data['min_date'], 'maxDate'=>$istance_data['max_date'])); | |
| 3102 | + break; | |
| 3103 | + //case 'textfield': | |
| 3104 | + default: | |
| 3105 | + $element = new Element_Textbox($istance_data['label'], $istance_data['istance_id'], $field_properties+array('value'=>$istance_data['default_value'])); | |
| 3106 | + break; | |
| 3107 | + } | |
| 3108 | + if ($element) { | |
| 3109 | + if (!empty($istance_data['required'])) { | |
| 3110 | + $element->setClass('accuaforms-field-required'); | |
| 3111 | + if($field_data['type'] == 'captcha' && empty($captcha_use_v1)) { | |
| 3112 | + //nothing | |
| 3113 | + } else if($field_data['type'] == 'password-and-confirm') { | |
| 3114 | + $element->setValidation(new Validation_Required( | |
| 3115 | + str_replace('%element%', $istance_data['label'], __("Attention: Passwords are required fields.", 'contact-forms')) | |
| 3116 | + )); | |
| 3117 | + } else { | |
| 3118 | + $element->setValidation(new Validation_Required( | |
| 3119 | + str_replace('%element%', $istance_data['label'], __("Attention: '%element%' is a required field.", 'contact-forms')) | |
| 3120 | + )); | |
| 3121 | + } | |
| 3122 | + } | |
| 3123 | + | |
| 3124 | + if ($elementName = $element->getName()) { | |
| 3125 | + $element->setClass('accuaform-fieldname-'.$elementName); | |
| 3126 | + } | |
| 3127 | + | |
| 3128 | + if ($field_data['type']) { | |
| 3129 | + $element->setClass('accuaform-fieldtype-'.$field_data['type']); | |
| 3130 | + } | |
| 3131 | + | |
| 3132 | + $form->addElement($element); | |
| 3133 | + if($element_conf!=NULL) { | |
| 3134 | + $form->addElement($element_conf); | |
| 3135 | + $element_conf=NULL; | |
| 3136 | + } | |
| 3137 | + } | |
| 3138 | + } | |
| 3139 | + if ($fieldset_open) { | |
| 3140 | + $form->addElement(new AccuaForm_Element_FieldsetEnd()); | |
| 3141 | + $fieldset_open = false; | |
| 3142 | + } | |
| 3143 | + if ($add_submit) { | |
| 3144 | + $form->addElement(new Element_Button(__('Submit', 'contact-forms'), 'submit', $submit_properties)); | |
| 3145 | + } | |
| 3146 | + } | |
| 3147 | + | |
| 3148 | + } | |
| 3149 | +} | |
| 3150 | + | |
| 3151 | +function accua_forms_aggregate_submitted_data(&$replace_map, $params = array()) { | |
| 3152 | + if (empty($params['txt']) && empty($params['html']) && empty($params['json']) && empty($params['email'])) { | |
| 3153 | + $params += array( | |
| 3154 | + 'txt' => true, | |
| 3155 | + 'html' => true, | |
| 3156 | + 'json' => true, | |
| 3157 | + 'email' => true, | |
| 3158 | + ); | |
| 3159 | + } | |
| 3160 | + | |
| 3161 | + if (!empty($params['txt'])) { | |
| 3162 | + $replace_map['__submitted_txt'] = implode("\n",$replace_map['__submitted_txt_raw']); | |
| 3163 | + } | |
| 3164 | + if (!empty($params['html'])) { | |
| 3165 | + $replace_map['__submitted_html'] = implode('</td></tr><tr><td>',$replace_map['__submitted_html_raw']); | |
| 3166 | + } | |
| 3167 | + if (!empty($params['json'])) { | |
| 3168 | + $replace_map['__submitted_json'] = _accua_forms_json_encode($replace_map['__submitted_json_raw']); | |
| 3169 | + } | |
| 3170 | + if (!empty($params['email'])) { | |
| 3171 | + $replace_map['__autoreply_email'] = implode('; ', $replace_map['__autoreply_email_raw']); | |
| 3172 | + } | |
| 3173 | + | |
| 3174 | +} | |
| 3175 | + | |
| 3176 | +add_filter('accua_form_validate', 'accua_forms_validation_handler', 10, 4); | |
| 3177 | +function accua_forms_validation_handler($valid, $submittedID, $submittedData, $form){ | |
| 3178 | + if (substr($submittedID, 0, 14) == '__accua-form__') { | |
| 3179 | + $fid = substr($submittedID,14); | |
| 3180 | + $form_data = _accua_forms_get_form_data($fid, false); | |
| 3181 | + if ($form_data) { | |
| 3182 | + return apply_filters('accua_forms_validation', $valid, $fid, $submittedData, $form); | |
| 3183 | + } | |
| 3184 | + } | |
| 3185 | + return $valid; | |
| 3186 | +} | |
| 3187 | + | |
| 3188 | +function accua_forms_anonymize_ip($ip) { | |
| 3189 | + $ip = (string) $ip; | |
| 3190 | + $anonymize_ip_data = get_option('accua_forms_anonymize_ip_data',array()); | |
| 3191 | + if (empty($anonymize_ip_data['anonymize_ip_bytes'])) { | |
| 3192 | + return $ip; | |
| 3193 | + } | |
| 3194 | + switch ($anonymize_ip_data['anonymize_ip_bytes']) { | |
| 3195 | + case 1: | |
| 3196 | + $ip = preg_replace('/\.[^.]+$/', '.xxx', $ip); | |
| 3197 | + break; | |
| 3198 | + case 2: | |
| 3199 | + $ip = preg_replace('/\.[^.]+\.[^.]+$/', '.xxx.xxx', $ip); | |
| 3200 | + break; | |
| 3201 | + case 3: | |
| 3202 | + $ip = preg_replace('/\.[^.]+\.[^.]+\.[^.]+$/', '.xxx.xxx.xxx', $ip); | |
| 3203 | + break; | |
| 3204 | + case 4: | |
| 3205 | + $ip = ''; | |
| 3206 | + } | |
| 3207 | + return $ip; | |
| 3208 | +} | |
| 3209 | + | |
| 3210 | +add_action('accua_form_submit', 'accua_forms_form_submission_handler', -10, 3); | |
| 3211 | +function accua_forms_form_submission_handler($submittedID, $submittedData, $form) { | |
| 3212 | + if (empty($GLOBALS['wp_rewrite'])) { | |
| 3213 | + $GLOBALS['wp_rewrite'] = new WP_Rewrite(); | |
| 3214 | + } | |
| 3215 | + | |
| 3216 | + if (!class_exists('AccuaConditionalReplacer')){ | |
| 3217 | + require_once('AccuaConditionalReplacer.php'); | |
| 3218 | + } | |
| 3219 | + | |
| 3220 | + if (substr($submittedID, 0, 14) == '__accua-form__') { | |
| 3221 | + $fid = substr($submittedID,14); | |
| 3222 | + $form_data = _accua_forms_get_form_data($fid, false); | |
| 3223 | + if ($form_data) { | |
| 3224 | + global $wpdb; | |
| 3225 | + | |
| 3226 | + $time = time(); | |
| 3227 | + | |
| 3228 | + $afs_stats = _accua_forms_json_encode(array( | |
| 3229 | + 'user_agent' => $form->stats['user_agent'], | |
| 3230 | + 'platform' => $form->stats['platform'], | |
| 3231 | + 'tentatives' => $form->stats['tentatives'], | |
| 3232 | + 'submit_method' => $form->stats['submit_method'], | |
| 3233 | + )); | |
| 3234 | + | |
| 3235 | + $anonymized_ip = accua_forms_anonymize_ip($form->stats['ip']); | |
| 3236 | + | |
| 3237 | + $insert_ret = $wpdb->insert( | |
| 3238 | + $wpdb->prefix . 'accua_forms_submissions', | |
| 3239 | + array ( | |
| 3240 | + 'afs_form_id' => (string) $fid, | |
| 3241 | + 'afs_post_id' => (string) $form->stats['pid'], | |
| 3242 | + 'afs_ip' => $anonymized_ip, | |
| 3243 | + 'afs_uri' => (string) $form->stats['uri'], | |
| 3244 | + 'afs_referrer' => (string) $form->stats['referrer'], | |
| 3245 | + 'afs_lang' => (string) $form->stats['lang'], | |
| 3246 | + 'afs_created' => (string) gmdate('Y-m-d H:i:s', $form->stats['created']), | |
| 3247 | + 'afs_submitted' => (string) gmdate('Y-m-d H:i:s', $time), | |
| 3248 | + 'afs_stats' => (string) $afs_stats, | |
| 3249 | + ) | |
| 3250 | + ); | |
| 3251 | + | |
| 3252 | + if ($insert_ret) { | |
| 3253 | + $submission_id = $form->stats['submission_id'] = $wpdb->insert_id; | |
| 3254 | + } else { | |
| 3255 | + $submission_id = $form->stats['submission_id'] = 0; | |
| 3256 | + error_log("[WordPress Contact Forms] unable to save submitted form data"); | |
| 3257 | + } | |
| 3258 | + | |
| 3259 | + $review_submission_url = admin_url('admin.php').'?page=accua_forms_submissions_list&sid='.$submission_id; | |
| 3260 | + | |
| 3261 | + $replace_map = array( | |
| 3262 | + '__fid' => $fid, | |
| 3263 | + '__subid' => $submission_id, | |
| 3264 | + '__pid' => $form->stats['pid'], | |
| 3265 | + '__ip' => $form->stats['ip'], | |
| 3266 | + '__anonymized_ip' => $anonymized_ip, | |
| 3267 | + '__uri' => $form->stats['uri'], | |
| 3268 | + '__url' => $form->stats['url'], | |
| 3269 | + '__referrer' => $form->stats['referrer'], | |
| 3270 | + '__lang' => $form->stats['lang'], | |
| 3271 | + '__locale' => $form->stats['locale'], | |
| 3272 | + '__created' => $form->stats['created'], | |
| 3273 | + '__created_day' => date('l j F Y', $form->stats['created']), | |
| 3274 | + '__created_day_month_year' => date('j F Y', $form->stats['created']), | |
| 3275 | + '__created_hour' => date('G:i', $form->stats['created']), | |
| 3276 | + '__submitted' => $time, | |
| 3277 | + '__submitted_day' => date('l j F Y', $time), | |
| 3278 | + '__submitted_day_month_year' => date('j F Y', $time), | |
| 3279 | + '__submitted_hour' => date('G:i', $time), | |
| 3280 | + '__confirmation_emails_message' => $form_data['confirmation_emails_message'], | |
| 3281 | + '__user_agent' => $form->stats['user_agent'], | |
| 3282 | + '__platform' => $form->stats['platform'], | |
| 3283 | + '__tentatives' => $form->stats['tentatives'], | |
| 3284 | + '__submit_method' => $form->stats['submit_method'], | |
| 3285 | + '__review_submission_url' => $review_submission_url, | |
| 3286 | + ); | |
| 3287 | + | |
| 3288 | + $avail_fields = get_option('accua_forms_avail_fields', array()); | |
| 3289 | + | |
| 3290 | + $replace_map['__autoreply_email_raw'] = array(); | |
| 3291 | + $replace_map['__submitted_txt_raw'] = array(); | |
| 3292 | + $replace_map['__submitted_html_raw'] = array(); | |
| 3293 | + $replace_map['__submitted_json_raw'] = array(); | |
| 3294 | + | |
| 3295 | + $_field_data = array(); | |
| 3296 | + $_istance_data = array(); | |
| 3297 | + $field_data = array(); | |
| 3298 | + | |
| 3299 | + foreach ($submittedData as $istance_id => $value) { | |
| 3300 | + if (empty($form_data['fields'][$istance_id])) { | |
| 3301 | + continue; | |
| 3302 | + } | |
| 3303 | + $istance_data = $form_data['fields'][$istance_id]; | |
| 3304 | + | |
| 3305 | + if (empty($avail_fields[$istance_data['ref']])) { | |
| 3306 | + $fieldset_data = array(); | |
| 3307 | + if (!empty($istance_data['ref'])) { | |
| 3308 | + if ($istance_data['ref'] == '__fieldset-begin') { | |
| 3309 | + $field_data = array( | |
| 3310 | + 'id' => '__fieldset-begin', | |
| 3311 | + 'name' => __('Fieldset begin', 'contact-forms'), | |
| 3312 | + 'type' => 'fieldset-begin', | |
| 3313 | + 'description' => '', | |
| 3314 | + ); | |
| 3315 | + } else if ($istance_data['ref'] == '__fieldset-end') { | |
| 3316 | + $field_data = array( | |
| 3317 | + 'id' => '__fieldset-end', | |
| 3318 | + 'name' => __('Fieldset end', 'contact-forms'), | |
| 3319 | + 'type' => 'fieldset-end', | |
| 3320 | + 'description' => '', | |
| 3321 | + ); | |
| 3322 | + } | |
| 3323 | + } | |
| 3324 | + } else { | |
| 3325 | + $field_data = $avail_fields[$istance_data['ref']]; | |
| 3326 | + } | |
| 3327 | + | |
| 3328 | + $field_data += array( | |
| 3329 | + 'id' => '__html', | |
| 3330 | + 'name' => __( 'Custom HTML content', 'contact-forms'), | |
| 3331 | + 'type' => 'html', | |
| 3332 | + 'description' => __( 'Use this special field to inject raw HTML in the form. You can use this multiple times.', 'contact-forms'), | |
| 3333 | + 'default_value' => '', | |
| 3334 | + 'allowed_values' => '', | |
| 3335 | + ); | |
| 3336 | + | |
| 3337 | + /* | |
| 3338 | + echo "<!-- istance_data: " | |
| 3339 | + , print_r($istance_data, true) | |
| 3340 | + , "\nfield_data: " | |
| 3341 | + , print_r($field_data, true) | |
| 3342 | + , "\nvalue: " | |
| 3343 | + , print_r($value, true) | |
| 3344 | + , "\n-->\n"; | |
| 3345 | + */ | |
| 3346 | + | |
| 3347 | + $istance_data += array( | |
| 3348 | + 'istance_id' => $field_data['id'], | |
| 3349 | + 'widget_number' => '', | |
| 3350 | + 'ref' => $field_data['id'], | |
| 3351 | + 'label' => $field_data['name'], | |
| 3352 | + 'default_value' => $field_data['default_value'], | |
| 3353 | + 'allowed_values' => $field_data['allowed_values'], | |
| 3354 | + ); | |
| 3355 | + | |
| 3356 | + $type = $field_data['type']; | |
| 3357 | + $file_download_url = ''; | |
| 3358 | + | |
| 3359 | + switch ($field_data['type']) { | |
| 3360 | + case 'checkbox': | |
| 3361 | + case 'submit': | |
| 3362 | + if (empty($value)) { | |
| 3363 | + $replace_map[$istance_data['istance_id']] = $value = ''; | |
| 3364 | + } else { | |
| 3365 | + if (empty($istance_data['default_value'])) { | |
| 3366 | + $replace_map[$istance_data['istance_id']] = 'Checked'; | |
| 3367 | + $value = '1'; | |
| 3368 | + } else { | |
| 3369 | + $replace_map[$istance_data['istance_id']] = $value = $istance_data['default_value']; | |
| 3370 | + } | |
| 3371 | + } | |
| 3372 | + break; | |
| 3373 | + case 'multiselect': | |
| 3374 | + case 'multicheckbox': | |
| 3375 | + case 'select': | |
| 3376 | + case 'radio': | |
| 3377 | + $el = $form->getElementByName($istance_id); | |
| 3378 | + $opts = $el->getOptions(); | |
| 3379 | + if (!is_array($value)) { | |
| 3380 | + $value = array($value); | |
| 3381 | + } | |
| 3382 | + $label = array(); | |
| 3383 | + foreach ($value as $val) { | |
| 3384 | + if (isset($opts[$val])) { | |
| 3385 | + $label[] = $opts[$val]; | |
| 3386 | + } | |
| 3387 | + } | |
| 3388 | + $replace_map['__label_'.$istance_data['istance_id']] = implode(", ", $label); | |
| 3389 | + $replace_map[$istance_data['istance_id']] = implode(', ',$value); | |
| 3390 | + $value = implode('|',$value); | |
| 3391 | + break; | |
| 3392 | + case 'post-multicheckbox': | |
| 3393 | + if (is_array($value) && $value) { | |
| 3394 | + $el = $form->getElementByName($istance_id); | |
| 3395 | + $opts = $el->getOptions(); | |
| 3396 | + $value2 = array(); | |
| 3397 | + $titles = array(); | |
| 3398 | + $ids = array(); | |
| 3399 | + $urls = array(); | |
| 3400 | + foreach ($value as $val) { | |
| 3401 | + if (isset($opts[$val])) { | |
| 3402 | + $titles[] = $opts[$val]; | |
| 3403 | + $ids[] = $value; | |
| 3404 | + $urls[] = get_permalink($value); | |
| 3405 | + $value2[] = $val . ': ' . trim(preg_replace('/[\s\n\r]+/', ' ', $opts[$val])); | |
| 3406 | + } | |
| 3407 | + } | |
| 3408 | + $replace_map['__label_'.$istance_data['istance_id']] = $replace_map['__post_title_'.$istance_data['istance_id']] = implode("\n", $titles); | |
| 3409 | + $replace_map['__post_id_'.$istance_data['istance_id']] = implode("\n", $ids); | |
| 3410 | + $replace_map['__post_url_'.$istance_data['istance_id']] = implode("\n", $urls); | |
| 3411 | + $replace_map[$istance_data['istance_id']] = $value = implode("\n", $value2); | |
| 3412 | + } else { | |
| 3413 | + $replace_map['__label_'.$istance_data['istance_id']] = $replace_map['__post_title_'.$istance_data['istance_id']] = ''; | |
| 3414 | + $replace_map['__post_id_'.$istance_data['istance_id']] = ''; | |
| 3415 | + $replace_map['__post_url_'.$istance_data['istance_id']] = ''; | |
| 3416 | + $replace_map[$istance_data['istance_id']] = $value = ''; | |
| 3417 | + } | |
| 3418 | + break; | |
| 3419 | + case 'post-select': | |
| 3420 | + if ($value !== '') { | |
| 3421 | + $el = $form->getElementByName($istance_id); | |
| 3422 | + $opts = $el->getOptions(); | |
| 3423 | + if (isset($opts[$value])) { | |
| 3424 | + $replace_map['__label_'.$istance_data['istance_id']] = $replace_map['__post_title_'.$istance_data['istance_id']] = $opts[$value]; | |
| 3425 | + $replace_map['__post_id_'.$istance_data['istance_id']] = $value; | |
| 3426 | + $replace_map['__post_url_'.$istance_data['istance_id']] = get_permalink($value); | |
| 3427 | + $value = $value . ': ' . trim(preg_replace('/[\s\n\r]+/', ' ', $opts[$value])); | |
| 3428 | + } else { | |
| 3429 | + $replace_map['__label_'.$istance_data['istance_id']] = $replace_map['__post_title_'.$istance_data['istance_id']] = ''; | |
| 3430 | + $replace_map['__post_id_'.$istance_data['istance_id']] = ''; | |
| 3431 | + $replace_map['__post_url_'.$istance_data['istance_id']] = ''; | |
| 3432 | + $value = ''; | |
| 3433 | + } | |
| 3434 | + } | |
| 3435 | + $replace_map[$istance_data['istance_id']] = $value; | |
| 3436 | + break; | |
| 3437 | + case 'autoreply_email': | |
| 3438 | + if ($value !== '') { | |
| 3439 | + $replace_map['__autoreply_email_raw'][] = $value; | |
| 3440 | + } | |
| 3441 | + $replace_map[$istance_data['istance_id']] = $value; | |
| 3442 | + break; | |
| 3443 | + case 'file': | |
| 3444 | + //TODO: move temp file to "{$submission_id}_{$field_data['id']}_{$file['name']}"; value is $file['name'] | |
| 3445 | + $buildid = $submittedData['_AccuaForm_buildID']; | |
| 3446 | + $file = $form->getFile($istance_id); | |
| 3447 | + if ($value !== null && $value !== '' && $file) { | |
| 3448 | + if ($form->renameFile($istance_id, "{$submission_id}_{$field_data['id']}_{$file['name']}")) { | |
| 3449 | + $urlfield = rawurlencode($istance_data['istance_id']); | |
| 3450 | + $urlfile = rawurlencode($value); | |
| 3451 | + $file_download_url = admin_url('admin-ajax.php') . "?action=accua_forms_download_submitted_file&subid={$submission_id}&field={$urlfield}&file={$urlfile}"; | |
| 3452 | + } | |
| 3453 | + } | |
| 3454 | + $replace_map[$istance_data['istance_id']] = $value; | |
| 3455 | + $replace_map['__download_'.$istance_data['istance_id']] = $file_download_url; | |
| 3456 | + break; | |
| 3457 | + case 'password': | |
| 3458 | + case 'password-and-confirm': | |
| 3459 | + $value = trim($value); | |
| 3460 | + $replace_map[$istance_data['istance_id']] = $value; | |
| 3461 | + $type = 'hashed-password'; | |
| 3462 | + if ($value !== '') { | |
| 3463 | + $value = wp_hash_password($value); | |
| 3464 | + } | |
| 3465 | + $replace_map['__hashed_'.$istance_data['istance_id']] = $value; | |
| 3466 | + break; | |
| 3467 | + default: | |
| 3468 | + $replace_map[$istance_data['istance_id']] = $value; | |
| 3469 | + } | |
| 3470 | + | |
| 3471 | + switch ($field_data['type']) { | |
| 3472 | + case 'file': | |
| 3473 | + $replace_map['__submitted_txt_raw'][$istance_data['istance_id']] = "{$istance_data['istance_id']}\t$value\t$file_download_url"; | |
| 3474 | + $replace_map['__submitted_json_raw'][$istance_data['istance_id']] = "$value\t$file_download_url"; | |
| 3475 | + $replace_map['__submitted_html_raw'][$istance_data['istance_id']] = "<strong>{$istance_data['istance_id']}</strong></td><td class='valori_submitted'><a href='".htmlspecialchars($file_download_url,ENT_QUOTES)."'>".htmlspecialchars($value)."</a>"; | |
| 3476 | + break; | |
| 3477 | + | |
| 3478 | + case 'email': | |
| 3479 | + case 'autoreply_email': | |
| 3480 | + $replace_map['__submitted_txt_raw'][$istance_data['istance_id']] = "{$istance_data['istance_id']}\t$value"; | |
| 3481 | + $replace_map['__submitted_json_raw'][$istance_data['istance_id']] = $value; | |
| 3482 | + $replace_map['__submitted_html_raw'][$istance_data['istance_id']] = "<strong>{$istance_data['istance_id']}</strong></td><td class='valori_submitted'><a href='mailto:".htmlspecialchars($value,ENT_QUOTES)."'>".htmlspecialchars($value)."</a>"; | |
| 3483 | + break; | |
| 3484 | + case 'submit': | |
| 3485 | + break; | |
| 3486 | + case 'colorpicker': | |
| 3487 | + $replace_map['__submitted_txt_raw'][$istance_data['istance_id']] = "{$istance_data['istance_id']}\t$value"; | |
| 3488 | + $replace_map['__submitted_json_raw'][$istance_data['istance_id']] = $value; | |
| 3489 | + if ($value === '') { | |
| 3490 | + $value_html = ''; | |
| 3491 | + } else { | |
| 3492 | + $value_esc = htmlspecialchars($value, ENT_QUOTES); | |
| 3493 | + $value_html = "<span style='color: $value_esc'><font color='$value_esc'>█</font></span> $value_esc"; | |
| 3494 | + } | |
| 3495 | + $replace_map['__submitted_html_raw'][$istance_data['istance_id']] = "<strong>{$istance_data['istance_id']}</strong></td><td class='valori_submitted'>$value_html"; | |
| 3496 | + break; | |
| 3497 | + case 'password': | |
| 3498 | + case 'password-and-confirm': | |
| 3499 | + break; | |
| 3500 | + default: | |
| 3501 | + $replace_map['__submitted_txt_raw'][$istance_data['istance_id']] = "{$istance_data['istance_id']}\t$value"; | |
| 3502 | + $replace_map['__submitted_json_raw'][$istance_data['istance_id']] = $value; | |
| 3503 | + $replace_map['__submitted_html_raw'][$istance_data['istance_id']] = "<strong>{$istance_data['istance_id']}</strong></td><td class='valori_submitted'>".htmlspecialchars($value); | |
| 3504 | + } | |
| 3505 | + | |
| 3506 | + if ($submission_id) { | |
| 3507 | + $wpdb->insert( | |
| 3508 | + $wpdb->prefix . 'accua_forms_submissions_values', | |
| 3509 | + array ( | |
| 3510 | + 'afsv_sub_id' => $submission_id, | |
| 3511 | + 'afsv_field_id' => $istance_data['istance_id'], | |
| 3512 | + 'afsv_type' => $type, | |
| 3513 | + 'afsv_value' => $value, | |
| 3514 | + ), | |
| 3515 | + array('%d','%s','%s','%s') | |
| 3516 | + ); | |
| 3517 | + } | |
| 3518 | + | |
| 3519 | + $_field_data[$istance_data['istance_id']] = $field_data; | |
| 3520 | + $_istance_data[$istance_data['istance_id']] = $istance_data; | |
| 3521 | + | |
| 3522 | + } | |
| 3523 | + | |
| 3524 | + $replace_map['__autoreply'] = (bool) ($replace_map['__autoreply_email_raw'] | |
| 3525 | + && $form_data['confirmation_emails_subject'] | |
| 3526 | + && $form_data['confirmation_emails_message']); | |
| 3527 | + | |
| 3528 | + accua_forms_aggregate_submitted_data($replace_map); | |
| 3529 | + | |
| 3530 | + //Older undocumented filter, maintained for backward compatibility. In fact filter accua_forms_form_submission_handler is called before accua_forms_submission, but for the rest they are the same | |
| 3531 | + $replace_map = apply_filters('accua_forms_form_submission_handler', $replace_map, $fid, $submittedData, $form, $_field_data, $_istance_data); | |
| 3532 | + | |
| 3533 | + //Newer filter, with an easier name | |
| 3534 | + $replace_map = apply_filters('accua_forms_submission', $replace_map, $fid, $submittedData, $form, $_field_data, $_istance_data); | |
| 3535 | + | |
| 3536 | + $submitted_html = '<table><tr><td>' . $replace_map['__submitted_html'] . '</td></tr></table>'; | |
| 3537 | + $confirmation_emails_message = $replace_map['__confirmation_emails_message']; | |
| 3538 | + unset($replace_map['__submitted_html'], $replace_map['__confirmation_emails_message'], $replace_map['__submitted_txt_raw'], $replace_map['__submitted_html_raw'], $replace_map['__submitted_json_raw'], $replace_map['__autoreply_email_raw']); | |
| 3539 | + | |
| 3540 | + $replace_map_html = array(); | |
| 3541 | + foreach($replace_map as $key => $value) { | |
| 3542 | + $replace_map_html["!$key"] = wp_kses($value, 'post'); | |
| 3543 | + $replace_map_html[$key] = htmlspecialchars($value, ENT_QUOTES); | |
| 3544 | + } | |
| 3545 | + | |
| 3546 | + $replace_map['__submitted_html'] = $replace_map_html['__submitted_html'] = $replace_map_html['!__submitted_html'] = $submitted_html; | |
| 3547 | + $replacer_html = new AccuaConditionalReplacer($replace_map_html); | |
| 3548 | + | |
| 3549 | + $confirmation_emails_message = $replace_map['__confirmation_emails_message'] = $replacer_html->doReplace($confirmation_emails_message); | |
| 3550 | + $replacer_html->appendPattern(array('__confirmation_emails_message' => $confirmation_emails_message, '!__confirmation_emails_message' => $confirmation_emails_message)); | |
| 3551 | + $replacer = new AccuaConditionalReplacer($replace_map); | |
| 3552 | + | |
| 3553 | + $form_data_replaced = array(); | |
| 3554 | + | |
| 3555 | + $settings = array( | |
| 3556 | + 'emails_from_name', | |
| 3557 | + 'emails_from', | |
| 3558 | + 'admin_emails_to', | |
| 3559 | + 'emails_bcc', | |
| 3560 | + 'admin_emails_subject', | |
| 3561 | + 'confirmation_emails_subject', | |
| 3562 | + ); | |
| 3563 | + | |
| 3564 | + foreach($settings as $i) { | |
| 3565 | + $form_data_replaced[$i] = $replacer->doReplace($form_data[$i]); | |
| 3566 | + } | |
| 3567 | + | |
| 3568 | + $settings_html = array( | |
| 3569 | + 'success_message', | |
| 3570 | + 'admin_emails_message', | |
| 3571 | + ); | |
| 3572 | + | |
| 3573 | + foreach($settings_html as $i) { | |
| 3574 | + $form_data_replaced[$i] = $replacer_html->doReplace($form_data[$i]); | |
| 3575 | + } | |
| 3576 | + | |
| 3577 | + AccuaForm::appendSubmittedMessages(wpautop($form_data_replaced['success_message'])); | |
| 3578 | + | |
| 3579 | + $header = array("Content-Type: text/html; charset=".get_option('blog_charset')); | |
| 3580 | + | |
| 3581 | + $emails_from = trim($form_data_replaced['emails_from']); | |
| 3582 | + if (strpos($emails_from, '@') !== false) { | |
| 3583 | + if ((strpos($emails_from, '<') === false) && is_email($emails_from)) { | |
| 3584 | + $emails_from_name = trim($form_data_replaced['emails_from_name']); | |
| 3585 | + if ($emails_from_name !== '') { | |
| 3586 | + $emails_from = "=?" . get_bloginfo('charset') . "?B?" . base64_encode($emails_from_name) . "?= <$emails_from>"; | |
| 3587 | + } | |
| 3588 | + } | |
| 3589 | + $header[] = 'From: '.$emails_from; | |
| 3590 | + } | |
| 3591 | + | |
| 3592 | + if ($form_data_replaced['emails_bcc']) { | |
| 3593 | + $header[] = 'Bcc: '.$form_data_replaced['emails_bcc']; | |
| 3594 | + } | |
| 3595 | + | |
| 3596 | + if ($form_data_replaced['admin_emails_to'] | |
| 3597 | + && $form_data_replaced['admin_emails_subject']) { | |
| 3598 | + /* | |
| 3599 | + $admin_tos = explode(',', strtr($form_data_replaced['admin_emails_to'], "\n\t\r;", ',,,,')); | |
| 3600 | + foreach ($admin_tos as $admin_to) { | |
| 3601 | + $mail1 = wp_mail(trim($admin_to), $form_data_replaced['admin_emails_subject'], $form_data_replaced['admin_emails_message'], $header); | |
| 3602 | + } | |
| 3603 | + */ | |
| 3604 | + $mail1 = wp_mail($form_data_replaced['admin_emails_to'], $form_data_replaced['admin_emails_subject'],'<html><head></head><body style="background:#f9f8f8;font-size: 12px;font-family: "Lucida Sans","Lucida Grande", Verdana, Arial, Sans-Serif;"">'.wpautop($form_data_replaced['admin_emails_message']).'</body></html>', $header); | |
| 3605 | + } | |
| 3606 | + | |
| 3607 | + if ($replace_map['__autoreply'] && $replace_map['__autoreply_email'] | |
| 3608 | + && $form_data_replaced['confirmation_emails_subject'] | |
| 3609 | + && $confirmation_emails_message) { | |
| 3610 | + $mail2 = wp_mail($replace_map['__autoreply_email'], $form_data_replaced['confirmation_emails_subject'], '<html><head></head><body>'.wpautop($confirmation_emails_message).'</body></html>', $header); | |
| 3611 | + } | |
| 3612 | + | |
| 3613 | + /* | |
| 3614 | + echo "<!-- replace_map: " | |
| 3615 | + , print_r($replace_map, true) | |
| 3616 | + , "\nreplace_map: " | |
| 3617 | + , print_r($replace_map, true) | |
| 3618 | + , "\nform_data_replaced: " | |
| 3619 | + , print_r($form_data_replaced, true) | |
| 3620 | + , "\nautoreply_email: " | |
| 3621 | + , print_r($autoreply_email, true) | |
| 3622 | + , "\nmail1: " | |
| 3623 | + , print_r($mail1, true) | |
| 3624 | + , "\nmail2: " | |
| 3625 | + , print_r($mail2, true) | |
| 3626 | + ,"\n-->"; | |
| 3627 | + */ | |
| 3628 | + } | |
| 3629 | + } | |
| 3630 | +} | |
| 3631 | + | |
| 3632 | +function accua_forms_get_submission_data($subid, $options = array()){ | |
| 3633 | + //TODO: Completa e usa per sostituire i campi | |
| 3634 | + global $wpdb; | |
| 3635 | + $subid = (int) $subid; | |
| 3636 | + $options += array( | |
| 3637 | + 'extra' => true, | |
| 3638 | + 'file_format' => 'name', | |
| 3639 | + ); | |
| 3640 | + $ret = array(); | |
| 3641 | + if ($options['extra']) { | |
| 3642 | + $query1 = "SELECT * | |
| 3643 | + FROM `{$wpdb->prefix}accua_forms_submissions` | |
| 3644 | + WHERE afs_id = $subid"; | |
| 3645 | + $data = $wpdb->get_row($query1); | |
| 3646 | + if (!empty($data)) { | |
| 3647 | + $created = $data->afs_created; | |
| 3648 | + $created[10] = 'T'; | |
| 3649 | + $created.='.00+00:00'; | |
| 3650 | + $created = strtotime($created); | |
| 3651 | + $submitted = $data->afs_submitted; | |
| 3652 | + $submitted[10] = 'T'; | |
| 3653 | + $submitted.='.00+00:00'; | |
| 3654 | + $submitted = strtotime($submitted); | |
| 3655 | + if ($data->afs_stats) { | |
| 3656 | + $stats = json_decode($data->afs_stats, true); | |
| 3657 | + if (!$stats) { | |
| 3658 | + $stats = array(); | |
| 3659 | + } | |
| 3660 | + } else { | |
| 3661 | + $stats = array(); | |
| 3662 | + } | |
| 3663 | + $stats += array( | |
| 3664 | + 'user_agent' => '', | |
| 3665 | + 'platform' => '', | |
| 3666 | + 'tentatives' => '', | |
| 3667 | + 'submit_method' => '', | |
| 3668 | + ); | |
| 3669 | + $ret += array( | |
| 3670 | + '__fid' => $data->afs_form_id, | |
| 3671 | + '__subid' => $subid, | |
| 3672 | + '__pid' => $data->afs_post_id, | |
| 3673 | + '__ip' => $data->afs_ip, | |
| 3674 | + '__anonymized_ip' => accua_forms_anonymize_ip($data->afs_ip), | |
| 3675 | + '__uri' => $data->afs_uri, | |
| 3676 | + '__referrer' => $data->afs_referrer, | |
| 3677 | + '__lang' => $data->afs_lang, | |
| 3678 | + '__created' => $created, | |
| 3679 | + '__created_day' => date('l j F Y', $created), | |
| 3680 | + '__created_hour' => date('G:i', $created), | |
| 3681 | + '__submitted' => $submitted, | |
| 3682 | + '__submitted_day' => date('l j F Y', $submitted), | |
| 3683 | + '__submitted_hour' => date('G:i', $submitted), | |
| 3684 | + '__user_agent' => $stats['user_agent'], | |
| 3685 | + '__platform' => $stats['platform'], | |
| 3686 | + '__tentatives' => $stats['tentatives'], | |
| 3687 | + '__submit_method' => $stats['submit_method'], | |
| 3688 | + ); | |
| 3689 | + } | |
| 3690 | + } | |
| 3691 | + | |
| 3692 | + $query2 = "SELECT * | |
| 3693 | + FROM `{$wpdb->prefix}accua_forms_submissions_values` | |
| 3694 | + WHERE afsv_sub_id = $subid"; | |
| 3695 | + | |
| 3696 | + $data2 = $wpdb->get_results($query2, OBJECT); | |
| 3697 | + | |
| 3698 | + foreach ($data2 as $row) { | |
| 3699 | + switch ($row->afsv_type) { | |
| 3700 | + case 'file' : | |
| 3701 | + if ($options['file_format'] == 'url' || $options['file_format'] == 'link') { | |
| 3702 | + $fieldid = rawurlencode($row->afsv_field_id); | |
| 3703 | + $filename = rawurlencode($row->afsv_value); | |
| 3704 | + $url = admin_url('admin-ajax.php') . "?action=accua_forms_download_submitted_file&subid={$row->afsv_sub_id}&field={$fieldid}&file={$filename}"; | |
| 3705 | + if ($options['file_format'] == 'link'){ | |
| 3706 | + $url = htmlspecialchars($url,ENT_QUOTES); | |
| 3707 | + $filename = htmlspecialchars($row->afsv_value,ENT_QUOTES); | |
| 3708 | + $fielddata = "<a href='{$url}' target='_blank'>{$filename}</a>"; | |
| 3709 | + } else { | |
| 3710 | + $fielddata = $url; | |
| 3711 | + } | |
| 3712 | + } else { // $options['file_format'] == 'name' | |
| 3713 | + $fielddata = $row->afsv_value; | |
| 3714 | + } | |
| 3715 | + break; | |
| 3716 | + default: | |
| 3717 | + $fielddata = $row->afsv_value; | |
| 3718 | + } | |
| 3719 | + $ret[$row->afsv_field_id] = $fielddata; | |
| 3720 | + } | |
| 3721 | + return $ret; | |
| 3722 | +} | |
| 3723 | + | |
| 3724 | +add_shortcode( 'accua-form', 'accua_forms_shortcode_handler' ); | |
| 3725 | +function accua_forms_shortcode_handler($atts, $content = '', $code = '') { | |
| 3726 | + if (empty($atts['fid'])) { | |
| 3727 | + return ''; | |
| 3728 | + } | |
| 3729 | + | |
| 3730 | + $fid = $atts['fid']; | |
| 3731 | + $form_data = _accua_forms_get_form_data($fid, false); | |
| 3732 | + | |
| 3733 | + if (! $form_data) { | |
| 3734 | + return ''; | |
| 3735 | + } | |
| 3736 | + | |
| 3737 | + $fid = '__accua-form__'.$fid; | |
| 3738 | + | |
| 3739 | + $out = ''; | |
| 3740 | + | |
| 3741 | + if (AccuaForm::getSubmittedID() == $fid) { | |
| 3742 | + /* return "<pre>Form submitted.\n\nData: " . print_r(AccuaForm::getSubmittedData(), true) . '</pre>'; */ | |
| 3743 | + $messages = AccuaForm::getSubmittedMessages(); | |
| 3744 | + if ($messages) { | |
| 3745 | + $out .= '<div id="_response_messages_'.$fid.'" class="accua-form-messages">'.$messages.'</div>'; | |
| 3746 | + } | |
| 3747 | + if (AccuaForm::isValid()) { | |
| 3748 | + return $out; | |
| 3749 | + } | |
| 3750 | + $form = AccuaForm::getSubmittedForm(); | |
| 3751 | + } else { | |
| 3752 | + $analytics_data = get_option('accua_forms_default_analytics_data',array()); | |
| 3753 | + $params = array( | |
| 3754 | + 'layout' => $form_data['layout'], | |
| 3755 | + 'title' => $form_data['title'], | |
| 3756 | + 'track_submit' => !empty($analytics_data['analytics_track_submit']), | |
| 3757 | + 'track_fields' => !empty($analytics_data['analytics_track_fields']), | |
| 3758 | + ); | |
| 3759 | + $form = AccuaForm::create($fid, $params); | |
| 3760 | + } | |
| 3761 | + | |
| 3762 | + $out .= $form->render(true); | |
| 3763 | + | |
| 3764 | + $doing_ajax = function_exists('wp_doing_ajax') ? wp_doing_ajax() : (defined( 'DOING_AJAX' ) && DOING_AJAX); | |
| 3765 | + if ($doing_ajax && ($_REQUEST['action'] === 'wpseo_filter_shortcodes')) { | |
| 3766 | + $strip_regexp = '/(<iframe[^>]*>(.*?)<\/iframe>|<script[^>]*>(.*?)<\/script>|<input([^>]*)type="hidden"[^>]*>)/is'; | |
| 3767 | + $out = preg_replace($strip_regexp, '', $out); | |
| 3768 | + } | |
| 3769 | + | |
| 3770 | + return $out; | |
| 3771 | + | |
| 3772 | +} | |
| 3773 | + | |
| 3774 | +function accua_forms_include($fid, $atts=array(), $content = '', $code = '') { | |
| 3775 | + $atts['fid'] = $fid; | |
| 3776 | + echo accua_forms_shortcode_handler($atts, $content, $code); | |
| 3777 | +} | |
| 3778 | + | |
| 3779 | +function __accua_forms_submissions_list_page(){ | |
| 3780 | + if(isset($_GET['sid'])) { | |
| 3781 | + accua_forms_single_submission(); | |
| 3782 | + } else { | |
| 3783 | + accua_forms_submissions_list_page(); | |
| 3784 | + } | |
| 3785 | +} | |
| 3786 | +function accua_forms_submissions_list_page_head(){ | |
| 3787 | + if(isset($_GET['sid'])) { | |
| 3788 | + require_once('accua-forms-single-submission.php'); | |
| 3789 | + accua_forms_single_submission(true); | |
| 3790 | + } else { | |
| 3791 | + require_once('accua-forms-submissions-page.php'); | |
| 3792 | + accua_forms_submissions_list_page(true); | |
| 3793 | + } | |
| 3794 | + | |
| 3795 | +} | |
| 3796 | + | |
| 3797 | +add_action('wp_ajax_accua_forms_download_submitted_file', 'accua_forms_download_submitted_file'); | |
| 3798 | +add_action('wp_ajax_nopriv_accua_forms_download_submitted_file', 'accua_forms_download_submitted_file'); | |
| 3799 | +function accua_forms_download_submitted_file(){ | |
| 3800 | + $get = stripslashes_deep($_GET); | |
| 3801 | + if (isset($get['subid'],$get['field'],$get['file'])) { | |
| 3802 | + if (!empty($get['html'])) { | |
| 3803 | + header("Content-type: text/html"); | |
| 3804 | + $subid = rawurlencode($get['subid']); | |
| 3805 | + $fieldid = rawurlencode($get['field']); | |
| 3806 | + $filename = rawurlencode($get['file']); | |
| 3807 | + $url = admin_url('admin-ajax.php') . "?action=accua_forms_download_submitted_file&subid={$subid}&field={$fieldid}&file={$filename}"; | |
| 3808 | + $url = htmlspecialchars($url,ENT_QUOTES); | |
| 3809 | + $filename = htmlspecialchars($get['file'],ENT_QUOTES); | |
| 3810 | + die("<html><head><title>{$filename}</title><meta http-equiv='refresh' content='0;URL={$url}'></head><body><a href='{$url}'>{$filename}</a></body></html>"); | |
| 3811 | + } | |
| 3812 | + global $wpdb; | |
| 3813 | + $subid = (int) $get['subid']; | |
| 3814 | + $field = $get['field']; | |
| 3815 | + $file = $get['file']; | |
| 3816 | + $query = "SELECT * | |
| 3817 | + FROM `{$wpdb->prefix}accua_forms_submissions_values` | |
| 3818 | + WHERE afsv_sub_id = %d | |
| 3819 | + AND afsv_field_id = %s | |
| 3820 | + AND afsv_value = %s | |
| 3821 | + "; | |
| 3822 | + $query = $wpdb->prepare($query, $subid, $field, $file); | |
| 3823 | + $subval = $wpdb->get_results($query, OBJECT); | |
| 3824 | + if ($subval) { | |
| 3825 | + $file_data = get_option('accua_forms_default_file_field_data',array()) + array('dest_path' => ''); | |
| 3826 | + $dest_path = _accua_forms_get_abs_dest_path($file_data['dest_path']); | |
| 3827 | + $filename = "{$dest_path}/{$subid}_{$field}_{$file}"; | |
| 3828 | + if (is_file($filename) && is_readable($filename)){ | |
| 3829 | + if (function_exists('finfo_open')){ | |
| 3830 | + @ $finfo = finfo_open(FILEINFO_MIME); | |
| 3831 | + if ($finfo) { | |
| 3832 | + @ $filetype = finfo_file($finfo, $filename); | |
| 3833 | + @ finfo_close($finfo); | |
| 3834 | + } | |
| 3835 | + } | |
| 3836 | + if (empty($filetype) && function_exists('mime_content_type')){ | |
| 3837 | + @ $filetype = mime_content_type($filename); | |
| 3838 | + } | |
| 3839 | + if (empty($filetype)) { | |
| 3840 | + $filetype = "application/octet-stream"; | |
| 3841 | + } | |
| 3842 | + header("Content-type: $filetype"); | |
| 3843 | + header("Content-length: ".filesize($filename)); | |
| 3844 | + if (empty($_GET['view'])) { | |
| 3845 | + header("Content-disposition: attachment; filename=\"$file\""); | |
| 3846 | + } | |
| 3847 | + readfile($filename); | |
| 3848 | + die(''); | |
| 3849 | + } | |
| 3850 | + } | |
| 3851 | + } | |
| 3852 | + header("HTTP/1.0 404 Not Found"); | |
| 3853 | + //header("Status: 404 Not Found"); | |
| 3854 | + die('File not found'); | |
| 3855 | +} | |
| 3856 | + | |
| 3857 | +function accua_forms_buildConditionalReplacer($map = array()) { | |
| 3858 | + if (!class_exists('AccuaConditionalReplacer')){ | |
| 3859 | + require_once('AccuaConditionalReplacer.php'); | |
| 3860 | + } | |
| 3861 | + return new AccuaConditionalReplacer($map); | |
| 3862 | +} | |
| 3863 | + | |
| 3864 | + | |
| 3865 | +add_action('wp_ajax_accua_forms_preview', 'accua_forms_preview'); | |
| 3866 | +function accua_forms_preview() { | |
| 3867 | + if (!current_user_can('manage_options')){ | |
| 3868 | + die (''); | |
| 3869 | + } | |
| 3870 | + | |
| 3871 | + echo '<html><head> | |
| 3872 | + <style> | |
| 3873 | + body {font-family: -apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,Oxygen-Sans,Ubuntu,Cantarell,"Helvetica Neue",sans-serif;} | |
| 3874 | + </style>'; | |
| 3875 | + wp_print_styles(); | |
| 3876 | + wp_print_head_scripts(); | |
| 3877 | + echo '</head><body>'; | |
| 3878 | + echo accua_forms_shortcode_handler(array('fid'=>$_REQUEST['fid'])); | |
| 3879 | + wp_print_footer_scripts(); | |
| 3880 | + echo '</body></html>'; | |
| 3881 | + die(''); | |
| 3882 | +} | |
| 3883 | + | |
| 3884 | +//salvataggio file excel | |
| 3885 | +add_action('wp_ajax_accua_forms_submission_page_save_excel', 'accua_forms_submission_page_save_excel'); | |
| 3886 | +//add_action('wp_ajax_nopriv_accua_forms_submission_page_save_excel', 'accua_forms_submission_page_save_excel'); | |
| 3887 | + | |
| 3888 | +function accua_forms_submission_page_save_excel() { | |
| 3889 | + if (!current_user_can('manage_options')){ | |
| 3890 | + header("HTTP/1.0 401 Access Denied"); | |
| 3891 | + //header("Status: 401 Access Denied"); | |
| 3892 | + die('You are not authorized to access this page.'); | |
| 3893 | + } | |
| 3894 | + | |
| 3895 | + require_once('accua-forms-submissions-page.php'); | |
| 3896 | + $listTable = new Accua_Forms_Submissions_List_Table(); | |
| 3897 | + $listTable->export_xls = true; | |
| 3898 | + $listTable->prepare_items(true); | |
| 3899 | + $show_col = explode( ',', $_GET['accua_show_field']); | |
| 3900 | + $show_col = array_diff($show_col, array('singlesub')); | |
| 3901 | + header("Content-disposition: attachment; filename=downloads-report.xls"); | |
| 3902 | + header("Content-type: application/vnd.ms-excel"); | |
| 3903 | + accua_forms_submission_page_save_excel_general($listTable,$show_col); | |
| 3904 | + die(''); | |
| 3905 | +} | |
| 3906 | + | |
| 3907 | + | |
| 3908 | + | |
| 3909 | +function accua_forms_submission_page_save_excel_general(Accua_Forms_Submissions_List_Table $listTable,array $show_col,array $options=array()) { | |
| 3910 | + global $wpdb; | |
| 3911 | + | |
| 3912 | + $content_type = 'text/html; charset=' . get_option('blog_charset'); | |
| 3913 | + | |
| 3914 | + //creo il file excel | |
| 3915 | + ?><html xmlns:o="urn:schemas-microsoft-com:office:office" | |
| 3916 | + xmlns:x="urn:schemas-microsoft-com:office:excel" | |
| 3917 | + xmlns="http://www.w3.org/TR/REC-html40"> | |
| 3918 | + <head> | |
| 3919 | + <meta http-equiv=Content-Type content="<?php echo $content_type; ?>" /> | |
| 3920 | + <meta name=ProgId content=Excel.Sheet /> | |
| 3921 | + <style> | |
| 3922 | + <!-- | |
| 3923 | + td {vertical-align:top;} | |
| 3924 | + .head_row {font-weight:bold;} | |
| 3925 | + .column-date { mso-number-format:"Short Date"; } | |
| 3926 | + .datetime_cell { mso-number-format:"yyyy\\-mm\\-dd\\ hh\:mm\:ss"; } | |
| 3927 | + --> | |
| 3928 | + </style> | |
| 3929 | + <!--[if gte mso 9]><xml> | |
| 3930 | + <x:ExcelWorkbook> | |
| 3931 | + <x:ExcelWorksheets> | |
| 3932 | + <x:ExcelWorksheet> | |
| 3933 | + <x:WorksheetOptions> | |
| 3934 | + <x:FreezePanes/> | |
| 3935 | + <x:FilterOn/> | |
| 3936 | + <x:SplitHorizontal>1</x:SplitHorizontal> | |
| 3937 | + <x:TopRowBottomPane>1</x:TopRowBottomPane> | |
| 3938 | + <x:ActivePane>2</x:ActivePane> | |
| 3939 | + <x:Panes> | |
| 3940 | + <x:Pane> | |
| 3941 | + <x:Number>3</x:Number> | |
| 3942 | + </x:Pane> | |
| 3943 | + <x:Pane> | |
| 3944 | + <x:Number>2</x:Number> | |
| 3945 | + </x:Pane> | |
| 3946 | + </x:Panes> | |
| 3947 | + </x:WorksheetOptions> | |
| 3948 | + </x:ExcelWorksheet> | |
| 3949 | + </x:ExcelWorksheets> | |
| 3950 | + </x:ExcelWorkbook> | |
| 3951 | + </xml><![endif]--> | |
| 3952 | + </head> | |
| 3953 | + <body> | |
| 3954 | + <table x:str border=1 > | |
| 3955 | + <tr class='head-row'> | |
| 3956 | + <?php | |
| 3957 | + $cols = $listTable->get_columns(); | |
| 3958 | + foreach($cols as $col_key=>$col_value) { | |
| 3959 | + if(in_array($col_key, $show_col)) { ?> | |
| 3960 | + <td x:autofilter="all"><?php echo $col_value; ?></td> | |
| 3961 | + <?php } | |
| 3962 | + } ?> | |
| 3963 | + </tr> | |
| 3964 | + | |
| 3965 | + <?php | |
| 3966 | + $lead_statuses = accua_forms_get_lead_statuses(); | |
| 3967 | + | |
| 3968 | + foreach($listTable->items as $id_submission=>$single_submission) { | |
| 3969 | + @ set_time_limit(10); | |
| 3970 | + echo "<tr>"; | |
| 3971 | + foreach($cols as $col_key=>$col_value) { | |
| 3972 | + if(in_array($col_key, $show_col)) { | |
| 3973 | + echo "<td class='.$col_key.'>"; | |
| 3974 | + if ($col_key == 'lead_status') { | |
| 3975 | + if (isset($lead_statuses[$single_submission['lead_status']])) { | |
| 3976 | + echo htmlspecialchars($lead_statuses[$single_submission['lead_status']]); | |
| 3977 | + } | |
| 3978 | + } else if(isset($single_submission[$col_key])) { | |
| 3979 | + if ( method_exists( $listTable, 'column_' . $col_key ) ) { | |
| 3980 | + echo call_user_func( array( &$listTable, 'column_' . $col_key ), $single_submission ); | |
| 3981 | + } | |
| 3982 | + else { | |
| 3983 | + echo $listTable->column_default( $single_submission, $col_key ); | |
| 3984 | + } | |
| 3985 | + } | |
| 3986 | + echo "</td>"; | |
| 3987 | + } | |
| 3988 | + | |
| 3989 | + } | |
| 3990 | + echo "</tr>"; | |
| 3991 | + } | |
| 3992 | + | |
| 3993 | + ?> | |
| 3994 | + </table> | |
| 3995 | + </body> | |
| 3996 | + </html> | |
| 3997 | + <?php | |
| 3998 | +} | |
| 3999 | + | |
| 4000 | +function accua_forms_print_tokens() { | |
| 4001 | + $avail_fields = get_option('accua_forms_avail_fields', array()); | |
| 4002 | + $tokens = ''; | |
| 4003 | + foreach($avail_fields as $key=>$value) { | |
| 4004 | + $tokens .= $value['name'] . ": {" . $key . "}\n"; | |
| 4005 | + switch ($value['type']) { | |
| 4006 | + case 'file': | |
| 4007 | + $tokens .= $value['name'] . " (download link): {__download_" . $key . "}\n"; | |
| 4008 | + break; | |
| 4009 | + case 'multiselect': | |
| 4010 | + case 'multicheckbox': | |
| 4011 | + $tokens .= $value['name'] . " (labels): {__label_" . $key . "}\n"; | |
| 4012 | + break; | |
| 4013 | + case 'select': | |
| 4014 | + case 'radio': | |
| 4015 | + $tokens .= $value['name'] . " (label): {__label_" . $key . "}\n"; | |
| 4016 | + break; | |
| 4017 | + case 'post-multicheckbox': | |
| 4018 | + $tokens .= $value['name'] . " (posts titles): {__label_" . $key . "}\n"; | |
| 4019 | + $tokens .= $value['name'] . " (posts ids): {__post_id_" . $key . "}\n"; | |
| 4020 | + $tokens .= $value['name'] . " (posts urls): {__post_url_" . $key . "}\n"; | |
| 4021 | + break; | |
| 4022 | + case 'post-select': | |
| 4023 | + $tokens .= $value['name'] . " (post title): {__label_" . $key . "}\n"; | |
| 4024 | + $tokens .= $value['name'] . " (post id): {__post_id_" . $key . "}\n"; | |
| 4025 | + $tokens .= $value['name'] . " (post url): {__post_url_" . $key . "}\n"; | |
| 4026 | + break; | |
| 4027 | + } | |
| 4028 | + } | |
| 4029 | + | |
| 4030 | + echo <<<EOT | |
| 4031 | +<div class="accua_forms_token_list"> | |
| 4032 | +<h2>Tokens</h2> | |
| 4033 | +<em>In HTML text, use {!token_name} to insert unfiltered token value</em> | |
| 4034 | +<h3>Fields</h3> | |
| 4035 | +<em>These tokens are available only if the field is added to the form</em> | |
| 4036 | +<pre>$tokens</pre> | |
| 4037 | +<h3>Generic tokens</h3> | |
| 4038 | +<pre>{__fid} | |
| 4039 | +{__subid} | |
| 4040 | +{__pid} | |
| 4041 | +{__ip} | |
| 4042 | +{__anonymized_ip} | |
| 4043 | +{__uri} | |
| 4044 | +{__url} | |
| 4045 | +{__referrer} | |
| 4046 | +{__lang} | |
| 4047 | +{__locale} | |
| 4048 | +{__created} | |
| 4049 | +{__created_day} | |
| 4050 | +{__created_day_month_year} | |
| 4051 | +{__created_hour} | |
| 4052 | +{__submitted} | |
| 4053 | +{__submitted_day} | |
| 4054 | +{__submitted_day_month_year} | |
| 4055 | +{__submitted_hour} | |
| 4056 | +{__user_agent} | |
| 4057 | +{__platform} | |
| 4058 | +{__tentatives} | |
| 4059 | +{__submit_method} | |
| 4060 | +{__submitted_txt} | |
| 4061 | +{__submitted_html} | |
| 4062 | +{__submitted_json} | |
| 4063 | +{__autoreply} | |
| 4064 | +{__autoreply_email} | |
| 4065 | +{__confirmation_emails_message} | |
| 4066 | +{__review_submission_url}</pre> | |
| 4067 | +</div> | |
| 4068 | +EOT; | |
| 4069 | + do_action('accua_forms_print_tokens'); | |
| 4070 | +} | |
| 4071 | + | |
| 4072 | +function accua_get_pages($args = '') { | |
| 4073 | + global $wpdb; | |
| 4074 | + | |
| 4075 | + $defaults = array( | |
| 4076 | + 'child_of' => 0, | |
| 4077 | + 'sort_order' => 'ASC', | |
| 4078 | + 'sort_column' => 'post_title', | |
| 4079 | + 'hierarchical' => 1, | |
| 4080 | + 'exclude' => array(), | |
| 4081 | + 'include' => array(), | |
| 4082 | + 'meta_key' => '', | |
| 4083 | + 'meta_value' => '', | |
| 4084 | + 'meta_value_lt' => '', | |
| 4085 | + 'meta_value_gt' => '', | |
| 4086 | + 'meta_value_le' => '', | |
| 4087 | + 'meta_value_ge' => '', | |
| 4088 | + 'meta_value_like' => '', | |
| 4089 | + 'meta_value_format' => 'string', | |
| 4090 | + 'authors' => '', | |
| 4091 | + 'parent' => -1, | |
| 4092 | + 'exclude_tree' => '', | |
| 4093 | + 'number' => '', | |
| 4094 | + 'offset' => 0, | |
| 4095 | + 'post_type' => 'page', | |
| 4096 | + 'post_status' => 'publish', | |
| 4097 | + ); | |
| 4098 | + | |
| 4099 | + $r = wp_parse_args( $args, $defaults ); | |
| 4100 | + $child_of = (int) $r['child_of']; | |
| 4101 | + $sort_order = $r['sort_order']; | |
| 4102 | + $sort_column = $r['sort_column']; | |
| 4103 | + $hierarchical = $r['hierarchical']; | |
| 4104 | + $exclude = $r['exclude']; | |
| 4105 | + $include = $r['include']; | |
| 4106 | + $meta_key = $r['meta_key']; | |
| 4107 | + $meta_value = $r['meta_value']; | |
| 4108 | + $meta_value_lt = $r['meta_value_lt']; | |
| 4109 | + $meta_value_gt = $r['meta_value_gt']; | |
| 4110 | + $meta_value_le = $r['meta_value_le']; | |
| 4111 | + $meta_value_ge = $r['meta_value_ge']; | |
| 4112 | + $meta_value_like = $r['meta_value_like']; | |
| 4113 | + $meta_value_format = $r['meta_value_format']; | |
| 4114 | + $authors = $r['authors']; | |
| 4115 | + $parent = $r['parent']; | |
| 4116 | + $exclude_tree = $r['exclude_tree']; | |
| 4117 | + $number = (int) $r['number']; | |
| 4118 | + $offset = (int) $r['offset']; | |
| 4119 | + $post_type = $r['post_type']; | |
| 4120 | + $post_status = $r['post_status']; | |
| 4121 | + | |
| 4122 | + /* | |
| 4123 | + // Make sure the post type is hierarchical | |
| 4124 | + $hierarchical_post_types = get_post_types( array( 'hierarchical' => true ) ); | |
| 4125 | + if ( !in_array( $post_type, $hierarchical_post_types ) ) | |
| 4126 | + return false; | |
| 4127 | + */ | |
| 4128 | + | |
| 4129 | + // Make sure we have a valid post type | |
| 4130 | + if ( !is_array( $post_type ) ) | |
| 4131 | + $post_type = explode( ',', $post_type ); | |
| 4132 | + if ( array_diff( $post_type, get_post_types() ) ) | |
| 4133 | + return false; | |
| 4134 | + | |
| 4135 | + // Make sure we have a valid post status | |
| 4136 | + if ( !is_array( $post_status ) ) | |
| 4137 | + $post_status = explode( ',', $post_status ); | |
| 4138 | + if ( array_diff( $post_status, get_post_stati() ) ) | |
| 4139 | + return false; | |
| 4140 | + | |
| 4141 | + /* | |
| 4142 | + $cache = array(); | |
| 4143 | + $key = md5( serialize( compact(array_keys($defaults)) ) ); | |
| 4144 | + if ( $cache = wp_cache_get( 'get_pages', 'posts' ) ) { | |
| 4145 | + if ( is_array($cache) && isset( $cache[ $key ] ) ) { | |
| 4146 | + $pages = apply_filters('get_pages', $cache[ $key ], $r ); | |
| 4147 | + return $pages; | |
| 4148 | + } | |
| 4149 | + } | |
| 4150 | + | |
| 4151 | + if ( !is_array($cache) ) | |
| 4152 | + $cache = array(); | |
| 4153 | + */ | |
| 4154 | + | |
| 4155 | + $inclusions = ''; | |
| 4156 | + if ( !empty($include) ) { | |
| 4157 | + $child_of = 0; //ignore child_of, parent, exclude, meta_key, and meta_value params if using include | |
| 4158 | + $parent = -1; | |
| 4159 | + $exclude = ''; | |
| 4160 | + $meta_key = ''; | |
| 4161 | + $meta_value = ''; | |
| 4162 | + $meta_value_lt = ''; | |
| 4163 | + $meta_value_gt = ''; | |
| 4164 | + $meta_value_le = ''; | |
| 4165 | + $meta_value_ge = ''; | |
| 4166 | + $meta_value_like = ''; | |
| 4167 | + $hierarchical = false; | |
| 4168 | + $incpages = wp_parse_id_list( $include ); | |
| 4169 | + if ( ! empty( $incpages ) ) { | |
| 4170 | + foreach ( $incpages as $incpage ) { | |
| 4171 | + if (empty($inclusions)) | |
| 4172 | + $inclusions = $wpdb->prepare(' AND ( ID = %d ', $incpage); | |
| 4173 | + else | |
| 4174 | + $inclusions .= $wpdb->prepare(' OR ID = %d ', $incpage); | |
| 4175 | + } | |
| 4176 | + } | |
| 4177 | + } | |
| 4178 | + if (!empty($inclusions)) | |
| 4179 | + $inclusions .= ')'; | |
| 4180 | + | |
| 4181 | + $exclusions = ''; | |
| 4182 | + if ( !empty($exclude) ) { | |
| 4183 | + $expages = wp_parse_id_list( $exclude ); | |
| 4184 | + if ( ! empty( $expages ) ) { | |
| 4185 | + foreach ( $expages as $expage ) { | |
| 4186 | + if (empty($exclusions)) | |
| 4187 | + $exclusions = $wpdb->prepare(' AND ( ID <> %d ', $expage); | |
| 4188 | + else | |
| 4189 | + $exclusions .= $wpdb->prepare(' AND ID <> %d ', $expage); | |
| 4190 | + } | |
| 4191 | + } | |
| 4192 | + } | |
| 4193 | + if (!empty($exclusions)) | |
| 4194 | + $exclusions .= ')'; | |
| 4195 | + | |
| 4196 | + $author_query = ''; | |
| 4197 | + if (!empty($authors)) { | |
| 4198 | + $post_authors = preg_split('/[\s,]+/',$authors); | |
| 4199 | + | |
| 4200 | + if ( ! empty( $post_authors ) ) { | |
| 4201 | + foreach ( $post_authors as $post_author ) { | |
| 4202 | + //Do we have an author id or an author login? | |
| 4203 | + if ( 0 == intval($post_author) ) { | |
| 4204 | + $post_author = get_user_by('login', $post_author); | |
| 4205 | + if ( empty($post_author) ) | |
| 4206 | + continue; | |
| 4207 | + if ( empty($post_author->ID) ) | |
| 4208 | + continue; | |
| 4209 | + $post_author = $post_author->ID; | |
| 4210 | + } | |
| 4211 | + | |
| 4212 | + if ( '' == $author_query ) | |
| 4213 | + $author_query = $wpdb->prepare(' post_author = %d ', $post_author); | |
| 4214 | + else | |
| 4215 | + $author_query .= $wpdb->prepare(' OR post_author = %d ', $post_author); | |
| 4216 | + } | |
| 4217 | + if ( '' != $author_query ) | |
| 4218 | + $author_query = " AND ($author_query)"; | |
| 4219 | + } | |
| 4220 | + } | |
| 4221 | + | |
| 4222 | + $allowed_keys = array('author', 'post_author', 'date', 'post_date', 'title', 'post_title', 'name', 'post_name', 'modified', | |
| 4223 | + 'post_modified', 'modified_gmt', 'post_modified_gmt', 'menu_order', 'parent', 'post_parent', | |
| 4224 | + 'ID', 'rand', 'comment_count'); | |
| 4225 | + | |
| 4226 | + $join = ''; | |
| 4227 | + $where = "$exclusions $inclusions "; | |
| 4228 | + if ( ! ( empty( $meta_key ) && empty( $meta_value ) | |
| 4229 | + && empty( $meta_value_lt ) && empty( $meta_value_gt ) | |
| 4230 | + && empty( $meta_value_le ) && empty( $meta_value_ge ) | |
| 4231 | + && empty( $meta_value_like ) ) ) { | |
| 4232 | + $join = " LEFT JOIN $wpdb->postmeta ON ( $wpdb->posts.ID = $wpdb->postmeta.post_id )"; | |
| 4233 | + $allowed_keys[] = 'meta_key'; | |
| 4234 | + $allowed_keys[] = 'meta_value'; | |
| 4235 | + | |
| 4236 | + // meta_key and meta_value might be slashed | |
| 4237 | + $meta_key = stripslashes($meta_key); | |
| 4238 | + $meta_value = stripslashes($meta_value); | |
| 4239 | + $meta_value_lt = stripslashes($meta_value_lt); | |
| 4240 | + $meta_value_gt = stripslashes($meta_value_gt); | |
| 4241 | + $meta_value_le = stripslashes($meta_value_le); | |
| 4242 | + $meta_value_ge = stripslashes($meta_value_ge); | |
| 4243 | + $meta_value_like = stripslashes($meta_value_like); | |
| 4244 | + | |
| 4245 | + if ( ! empty( $meta_key ) ) { | |
| 4246 | + $where .= $wpdb->prepare(" AND $wpdb->postmeta.meta_key = %s", $meta_key); | |
| 4247 | + } | |
| 4248 | + | |
| 4249 | + $meta_value_field = "$wpdb->postmeta.meta_value"; | |
| 4250 | + $meta_value_timestamp = false; | |
| 4251 | + switch($meta_value_format) { | |
| 4252 | + case 'timestamp': | |
| 4253 | + $meta_value_field = "TIMESTAMP( $meta_value_field )"; | |
| 4254 | + $meta_value_param = "FROM_UNIXTIME( %s )"; | |
| 4255 | + $meta_value_timestamp = true; | |
| 4256 | + break; | |
| 4257 | + case 'int': | |
| 4258 | + $meta_value_param = "%d"; | |
| 4259 | + break; | |
| 4260 | + case 'float': | |
| 4261 | + $meta_value_param = "%f"; | |
| 4262 | + break; | |
| 4263 | + //case 'string': | |
| 4264 | + default: | |
| 4265 | + $meta_value_param = "%s"; | |
| 4266 | + } | |
| 4267 | + | |
| 4268 | + if ( ! empty( $meta_value ) ) { | |
| 4269 | + if ($meta_value_timestamp) { | |
| 4270 | + $meta_value = strtotime($meta_value); | |
| 4271 | + } | |
| 4272 | + $where .= $wpdb->prepare(" AND $meta_value_field = $meta_value_param", $meta_value); | |
| 4273 | + } | |
| 4274 | + if ( ! empty( $meta_value_lt ) ) { | |
| 4275 | + if ($meta_value_timestamp) { | |
| 4276 | + $meta_value_lt = strtotime($meta_value_lt); | |
| 4277 | + } | |
| 4278 | + $where .= $wpdb->prepare(" AND $meta_value_field < $meta_value_param", $meta_value_lt); | |
| 4279 | + } | |
| 4280 | + if ( ! empty( $meta_value_gt ) ) { | |
| 4281 | + if ($meta_value_timestamp) { | |
| 4282 | + $meta_value_gt = strtotime($meta_value_gt); | |
| 4283 | + } | |
| 4284 | + $where .= $wpdb->prepare(" AND $meta_value_field > $meta_value_param", $meta_value_gt); | |
| 4285 | + } | |
| 4286 | + if ( ! empty( $meta_value_le ) ) { | |
| 4287 | + if ($meta_value_timestamp) { | |
| 4288 | + $meta_value_le = strtotime($meta_value_le); | |
| 4289 | + } | |
| 4290 | + $where .= $wpdb->prepare(" AND $meta_value_field <= $meta_value_param", $meta_value_le); | |
| 4291 | + } | |
| 4292 | + if ( ! empty( $meta_value_ge ) ) { | |
| 4293 | + if ($meta_value_timestamp) { | |
| 4294 | + $meta_value_ge = strtotime($meta_value_ge); | |
| 4295 | + } | |
| 4296 | + $where .= $wpdb->prepare(" AND $meta_value_field >= $meta_value_param", $meta_value_ge); | |
| 4297 | + } | |
| 4298 | + if ( ! empty( $meta_value_like ) ) { | |
| 4299 | + if ($meta_value_timestamp) { | |
| 4300 | + $meta_value_like = strtotime($meta_value_like); | |
| 4301 | + } | |
| 4302 | + $where .= $wpdb->prepare(" AND $meta_value_field like $meta_value_param", $meta_value_like); | |
| 4303 | + } | |
| 4304 | + } | |
| 4305 | + | |
| 4306 | + if ( $parent >= 0 ) | |
| 4307 | + $where .= $wpdb->prepare(' AND post_parent = %d ', $parent); | |
| 4308 | + | |
| 4309 | + | |
| 4310 | + if ( 1 == count ( $post_type ) ) { | |
| 4311 | + $where_post_type = $wpdb->prepare( "post_type = %s", array_shift( $post_type ) ); | |
| 4312 | + } else { | |
| 4313 | + $post_type = implode( "', '", $post_type ); | |
| 4314 | + $where_post_type = "post_type IN ('$post_type')"; | |
| 4315 | + } | |
| 4316 | + | |
| 4317 | + if ( 1 == count( $post_status ) ) { | |
| 4318 | + $where_post_type .= $wpdb->prepare( " AND post_status = %s", array_shift( $post_status ) ); | |
| 4319 | + } else { | |
| 4320 | + $post_status = implode( "', '", $post_status ); | |
| 4321 | + $where_post_type .= " AND post_status IN ('$post_status')"; | |
| 4322 | + } | |
| 4323 | + | |
| 4324 | + $orderby_array = array(); | |
| 4325 | + foreach ( explode( ',', $sort_column ) as $orderby ) { | |
| 4326 | + $orderby = trim( $orderby ); | |
| 4327 | + if ( !in_array( $orderby, $allowed_keys ) ) | |
| 4328 | + continue; | |
| 4329 | + | |
| 4330 | + switch ( $orderby ) { | |
| 4331 | + case 'menu_order': | |
| 4332 | + break; | |
| 4333 | + case 'ID': | |
| 4334 | + $orderby = "$wpdb->posts.ID"; | |
| 4335 | + break; | |
| 4336 | + case 'rand': | |
| 4337 | + $orderby = 'RAND()'; | |
| 4338 | + break; | |
| 4339 | + case 'comment_count': | |
| 4340 | + $orderby = "$wpdb->posts.comment_count"; | |
| 4341 | + break; | |
| 4342 | + case 'meta_key': | |
| 4343 | + case 'meta_value': | |
| 4344 | + $orderby = "$wpdb->postmeta.$orderby"; | |
| 4345 | + break; | |
| 4346 | + default: | |
| 4347 | + if ( 0 === strpos( $orderby, 'post_' ) ) | |
| 4348 | + $orderby = "$wpdb->posts." . $orderby; | |
| 4349 | + else | |
| 4350 | + $orderby = "$wpdb->posts.post_" . $orderby; | |
| 4351 | + } | |
| 4352 | + | |
| 4353 | + $orderby_array[] = $orderby; | |
| 4354 | + | |
| 4355 | + } | |
| 4356 | + $sort_column = ! empty( $orderby_array ) ? implode( ',', $orderby_array ) : "$wpdb->posts.post_title"; | |
| 4357 | + | |
| 4358 | + $sort_order = strtoupper( $sort_order ); | |
| 4359 | + if ( '' !== $sort_order && !in_array( $sort_order, array( 'ASC', 'DESC' ) ) ) | |
| 4360 | + $sort_order = 'ASC'; | |
| 4361 | + | |
| 4362 | + $query = "SELECT * FROM $wpdb->posts $join WHERE ($where_post_type) $where "; | |
| 4363 | + $query .= $author_query; | |
| 4364 | + $query .= " ORDER BY " . $sort_column . " " . $sort_order ; | |
| 4365 | + | |
| 4366 | + if ( !empty($number) && !empty($offset) ) { | |
| 4367 | + $query .= $wpdb->prepare(' LIMIT %d, %d', $offset, $number); | |
| 4368 | + } | |
| 4369 | + | |
| 4370 | + //echo "<!-- accua_forms_query:\n$query\n-->"; | |
| 4371 | + | |
| 4372 | + $pages = $wpdb->get_results($query); | |
| 4373 | + | |
| 4374 | + if ( empty($pages) ) { | |
| 4375 | + $pages = apply_filters('get_pages', array(), $r); | |
| 4376 | + return $pages; | |
| 4377 | + } | |
| 4378 | + | |
| 4379 | + // Sanitize before caching so it'll only get done once | |
| 4380 | + $num_pages = count($pages); | |
| 4381 | + for ($i = 0; $i < $num_pages; $i++) { | |
| 4382 | + $pages[$i] = sanitize_post($pages[$i], 'raw'); | |
| 4383 | + } | |
| 4384 | + | |
| 4385 | + /* | |
| 4386 | + // Update cache. | |
| 4387 | + update_post_cache( $pages ); | |
| 4388 | + */ | |
| 4389 | + | |
| 4390 | + if ( $child_of || $hierarchical ) | |
| 4391 | + $pages = get_page_children($child_of, $pages); | |
| 4392 | + | |
| 4393 | + if ( !empty($exclude_tree) ) { | |
| 4394 | + $exclude = (int) $exclude_tree; | |
| 4395 | + $children = get_page_children($exclude, $pages); | |
| 4396 | + $excludes = array(); | |
| 4397 | + foreach ( $children as $child ) | |
| 4398 | + $excludes[] = $child->ID; | |
| 4399 | + $excludes[] = $exclude; | |
| 4400 | + $num_pages = count($pages); | |
| 4401 | + for ( $i = 0; $i < $num_pages; $i++ ) { | |
| 4402 | + if ( in_array($pages[$i]->ID, $excludes) ) | |
| 4403 | + unset($pages[$i]); | |
| 4404 | + } | |
| 4405 | + } | |
| 4406 | + | |
| 4407 | + $pages = apply_filters('get_pages', $pages, $r); | |
| 4408 | + | |
| 4409 | + return $pages; | |
| 4410 | +} | |
| 4411 | + | |
| 4412 | +function accua_forms_trash_submission($id_sub){ | |
| 4413 | + global $wpdb; | |
| 4414 | + return $wpdb->query($wpdb->prepare("UPDATE `{$wpdb->prefix}accua_forms_submissions` SET afs_status = -1 WHERE afs_id = %d", $id_sub)) !== FALSE; | |
| 4415 | +} | |
| 4416 | + | |
| 4417 | +function accua_forms_get_lead_statuses() { | |
| 4418 | + static $statuses = NULL; | |
| 4419 | + if ($statuses === NULL) { | |
| 4420 | + $statuses = array( | |
| 4421 | + 0 => __('Undefined', 'contact-forms'), | |
| 4422 | + -1 => __('Spam', 'contact-forms'), | |
| 4423 | + 1 => __('Job Candidate', 'contact-forms'), | |
| 4424 | + 2 => __('Lead', 'contact-forms'), | |
| 4425 | + 3 => __('Prospect', 'contact-forms'), | |
| 4426 | + 4 => __('Opportunity', 'contact-forms'), | |
| 4427 | + 5 => __('Customer', 'contact-forms'), | |
| 4428 | + 6 => __('Supplier', 'contact-forms'), | |
| 4429 | + 7 => __('Other', 'contact-forms'), | |
| 4430 | + ); | |
| 4431 | + } | |
| 4432 | + return $statuses; | |
| 4433 | +} | |
| 4434 | + | |
| 4435 | +function accua_forms_select_lead_status($subid, $original_lead_status) { | |
| 4436 | + static $accuaHelp = NULL; | |
| 4437 | + if ($accuaHelp === NULL) { | |
| 4438 | + if (!class_exists('AccuaFormsHelp')) { | |
| 4439 | + require_once('accua-forms-help.php'); | |
| 4440 | + } | |
| 4441 | + $accuaHelp = AccuaFormsHelp::getInstance(); | |
| 4442 | + } | |
| 4443 | + $nonce = htmlspecialchars(_accua_forms_json_encode(wp_create_nonce( "set_lead_status_$subid" )),ENT_QUOTES); | |
| 4444 | + $ret = "<select onchange=\"accua_forms_set_lead_status(this, $subid, $nonce, $original_lead_status)\">"; | |
| 4445 | + $statuses = accua_forms_get_lead_statuses(); | |
| 4446 | + foreach ($statuses as $k => $l) { | |
| 4447 | + $selected = ($k == $original_lead_status) ? ' selected="selected" ' : ''; | |
| 4448 | + $ret .= "<option value=\"$k\"$selected>" . htmlspecialchars($l) . "</option>"; | |
| 4449 | + } | |
| 4450 | + $ret .= "</select>" . $accuaHelp->add_pointer('contact_forms_lead_statuses') . "<span class='accua-forms-select-lead-status-progress'></span>"; | |
| 4451 | + return $ret; | |
| 4452 | +} | |
| 4453 | + | |
| 4454 | +add_action( 'wp_ajax_accua-forms-set-lead-status' , 'accua_forms_set_lead_status'); | |
| 4455 | +function accua_forms_set_lead_status() { | |
| 4456 | + if (!current_user_can('manage_options')){ | |
| 4457 | + wp_die(0, 403); | |
| 4458 | + } | |
| 4459 | + $post = $_POST + array( | |
| 4460 | + 'subid' => 0, | |
| 4461 | + 'lead_status' => 0, | |
| 4462 | + ); | |
| 4463 | + $subid = (int) $post['subid']; | |
| 4464 | + | |
| 4465 | + if ($subid) { | |
| 4466 | + check_ajax_referer("set_lead_status_$subid", '_nonce_set_lead_status'); | |
| 4467 | + $lead_status = (int) $post['lead_status']; | |
| 4468 | + $statuses = accua_forms_get_lead_statuses(); | |
| 4469 | + if (isset($statuses[$lead_status])) { | |
| 4470 | + global $wpdb; | |
| 4471 | + $ret = $wpdb->update("{$wpdb->prefix}accua_forms_submissions", | |
| 4472 | + array('afs_lead_status' => $lead_status), | |
| 4473 | + array('afs_id' => $subid), | |
| 4474 | + '%d', '%d' | |
| 4475 | + ); | |
| 4476 | + if ($ret !== FALSE) { | |
| 4477 | + wp_die(1, 200); | |
| 4478 | + } | |
| 4479 | + } | |
| 4480 | + } | |
| 4481 | + wp_die(0, 500); | |
| 4482 | +} | |