/** * Editor callback form submit. */ function wpcf_fields_checkboxes_editor_submit() { $add = ''; $field = wpcf_admin_fields_get_field($_GET['field_id']); $shortcode = ''; if (!empty($field)) { if (!empty($_POST['options'])) { if ($_POST['display'] == 'display_all') { $separator = !empty($_POST['separator']) ? $_POST['separator'] : ''; $shortcode .= '[types field="' . $field['slug'] . '" separator="' . $separator . '"]' . '[/types] '; } else { $i = 0; foreach ($_POST['options'] as $option_key => $option) { if ($_POST['display'] == 'value') { $shortcode .= '[types field="' . $field['slug'] . '" option="' . $i . '" state="checked"]' . $option['display_value_selected'] . '[/types] '; $shortcode .= '[types field="' . $field['slug'] . '" option="' . $i . '" state="unchecked"]' . $option['display_value_not_selected'] . '[/types] '; } else { $add = ' option="' . $i . '"'; $shortcode .= wpcf_fields_get_shortcode($field, $add) . ' '; } $i++; } } } echo editor_admin_popup_insert_shortcode_js($shortcode); die; } }
/** * Editor callback form submit. */ function wpcf_fields_numeric_editor_submit() { $add = ''; if (!empty($_POST['format'])) { $add .= ' format="' . strval($_POST['format']) . '"'; } $field = wpcf_admin_fields_get_field($_GET['field_id']); if (!empty($field)) { $shortcode = wpcf_fields_get_shortcode($field, $add); wpcf_admin_fields_save_field_last_settings($_GET['field_id'], array('format' => $_POST['format'])); echo editor_admin_popup_insert_shortcode_js($shortcode); die; } }
/** * Editor callback form submit. */ function wpcf_fields_checkbox_editor_submit() { $add = ''; $field = wpcf_admin_fields_get_field($_GET['field_id']); if (!empty($field)) { if ($_POST['display'] == 'value') { $shortcode = '[types field="' . $field['slug'] . '" state="checked"]' . $_POST['display_value_selected'] . '[/types] '; $shortcode .= '[types field="' . $field['slug'] . '" state="unchecked"]' . $_POST['display_value_not_selected'] . '[/types]'; } else { $shortcode = wpcf_fields_get_shortcode($field, $add); } echo editor_admin_popup_insert_shortcode_js($shortcode); die; } }
/** * Editor callback form submit. */ function wpcf_fields_url_editor_submit() { $add = ''; if (!empty($_POST['title'])) { $add .= ' title="' . strval($_POST['title']) . '"'; } if (!empty($_POST['class'])) { $add .= ' class="' . $_POST['class'] . '"'; } if (!empty($_POST['style'])) { $add .= ' style="' . $_POST['style'] . '"'; } $field = wpcf_admin_fields_get_field($_GET['field_id']); if (!empty($field)) { $shortcode = wpcf_fields_get_shortcode($field, $add); wpcf_admin_fields_save_field_last_settings($_GET['field_id'], $_POST); echo editor_admin_popup_insert_shortcode_js($shortcode); die; } }
/** * Processes editor popup submit */ function wpcf_fields_google_map_editor_submit() { // Get field $field = wpcf_admin_fields_get_field(strval($_GET['field_id'])); if (!empty($field)) { $add = ''; // Add parameters if (!empty($_POST['width'])) { $add .= ' width="' . strval($_POST['width']) . '"'; } if (!empty($_POST['height'])) { $add .= ' height="' . strval($_POST['height']) . '"'; } // Generate shortcode $shortcode = wpcf_fields_get_shortcode($field, $add); // Save settings wpcf_admin_fields_save_field_last_settings($_GET['field_id'], $_POST); // Trigger inserting shortcode in parent editor echo editor_admin_popup_insert_shortcode_js($shortcode); } die; }
/** * Editor callback form submit. */ function wpcf_fields_radio_editor_submit() { $add = ''; $field = wpcf_admin_fields_get_field($_GET['field_id']); if (!empty($field)) { if ($_POST['display'] == 'value' && !empty($_POST['options'])) { $shortcode = ''; foreach ($_POST['options'] as $option_id => $value) { $shortcode .= '[types field="' . $field['slug'] . '" option="' . $option_id . '"]' . $value . '[/types] '; } } else { $shortcode = wpcf_fields_get_shortcode($field, $add); } echo editor_admin_popup_insert_shortcode_js($shortcode); die; } }
/** * Inserts shortcode in editor. * * @return type */ function wpcf_fields_date_editor_form_submit() { require_once WPCF_EMBEDDED_INC_ABSPATH . '/fields.php'; if (!isset($_POST['wpcf']['field_id'])) { return false; } $field = wpcf_admin_fields_get_field($_POST['wpcf']['field_id']); if (empty($field)) { return false; } $add = ' '; $style = isset($_POST['wpcf']['style']) ? $_POST['wpcf']['style'] : 'text'; $add .= 'style="' . $style . '"'; $format = ''; if ($style == 'text') { if ($_POST['wpcf']['format'] == 'custom') { $format = $_POST['wpcf']['format-custom']; } else { $format = $_POST['wpcf']['format']; } if (empty($format)) { $format = get_option('date_format'); } $add .= ' format="' . $format . '"'; } $shortcode = wpcf_fields_get_shortcode($field, $add); wpcf_admin_fields_save_field_last_settings($_POST['wpcf']['field_id'], array('style' => $style, 'format' => $_POST['wpcf']['format'], 'format-custom' => $_POST['wpcf']['format-custom'])); echo editor_admin_popup_insert_shortcode_js($shortcode); die; }
function wp_ajax_wpv_insert_form_shortcode() { if (wp_verify_nonce($_POST['_wpnonce'], 'wpv_editor_callback')) { global $wpdb; $view_id = $_POST['view_id']; $target = $_POST['target']; $title = $wpdb->get_var("SELECT post_title FROM {$wpdb->posts} WHERE ID={$view_id}"); editor_admin_popup_insert_shortcode_js('[wpv-form-view name="' . $title . '" target_id="' . $target . '"]'); } die; }
/** * Editor callback form submit. */ function wpcf_fields_image_editor_submit() { $add = ''; if (!empty($_POST['alt'])) { $add .= ' alt="' . strval($_POST['alt']) . '"'; } if (!empty($_POST['title'])) { $add .= ' title="' . strval($_POST['title']) . '"'; } $size = !empty($_POST['image-size']) ? $_POST['image-size'] : false; if ($size == 'wpcf-custom') { if (!empty($_POST['width'])) { $add .= ' width="' . intval($_POST['width']) . '"'; } if (!empty($_POST['height'])) { $add .= ' height="' . intval($_POST['height']) . '"'; } if (!empty($_POST['proportional'])) { $add .= ' proportional="true"'; } } else { if (!empty($size)) { $add .= ' size="' . $size . '"'; } } if (!empty($_POST['alignment'])) { $add .= ' align="' . $_POST['alignment'] . '"'; } if (!empty($_POST['class'])) { $add .= ' class="' . $_POST['class'] . '"'; } if (!empty($_POST['style'])) { $add .= ' style="' . $_POST['style'] . '"'; } $field = wpcf_admin_fields_get_field($_GET['field_id']); if (!empty($field)) { $shortcode = wpcf_fields_get_shortcode($field, $add); wpcf_admin_fields_save_field_last_settings($_GET['field_id'], $_POST); echo editor_admin_popup_insert_shortcode_js($shortcode); die; } }