示例#1
0
/**
 * Get Caldera Forms
 *
 * Includes backwards compat for pre-Caldera Forms 1.3.4
 *
 * @since 2.0.5
 *
 * @param string $id_name ID or name of form
 *
 * @return array|void
 */
function cf_custom_fields_get_form($id_name)
{
    if (class_exists('Caldera_Forms_Forms')) {
        $form = Caldera_Forms_Forms::get_form($id_name);
    } else {
        $form = Caldera_Forms::get_form($id_name);
    }
    if (isset($form['ID']) && !isset($form['id'])) {
        $form['id'] = $form['ID'];
    }
    return $form;
}
示例#2
0
 /**
  * Widget UI form
  *
  * @since unknown
  *
  * @param array $instance
  */
 function form($instance)
 {
     $instance = wp_parse_args((array) $instance, array('title' => ''));
     $title = strip_tags($instance['title']);
     do_action('caldera_forms_widget_form_start', $instance);
     echo "<p><label for=\" " . $this->get_field_id('title') . "\">" . __('Title', 'caldera-forms') . ": <input class=\"widefat\" id=\"" . $this->get_field_id('title') . "\" name=\"" . $this->get_field_name('title') . "\" type=\"text\" value=\"" . esc_attr($title) . "\" /></label></p>\r\n";
     // get forms
     $forms = Caldera_Forms_Forms::get_forms(true);
     echo "<p><label for=\" " . $this->get_field_id('title') . "\">" . __('Form', 'caldera-forms') . ": </label><select style=\"width:100%;\" name=\"" . $this->get_field_name('form') . "\">\r\n";
     echo "<option value=\"\"></option>\r\n";
     if (!empty($forms)) {
         foreach ($forms as $formid => $form) {
             $sel = "";
             if (!empty($instance['form'])) {
                 if ($instance['form'] == $formid) {
                     $sel = ' selected="selected"';
                 }
             }
             echo "<option value=\"" . $formid . "\"" . $sel . ">" . $form['name'] . "</option>\r\n";
         }
     }
     echo "</select></p>\r\n";
     do_action('caldera_forms_widget_form_end', $instance, $this);
 }
示例#3
0
<div class="caldera-backdrop caldera-forms-insert-modal" style="display: none;"></div>
<form id="calderaf_forms_shortcode_modal" class="caldera-modal-wrap caldera-forms-insert-modal" style="display: none; width: 700px; max-height: 500px; margin-left: -350px;">
	<div class="caldera-modal-title" id="calderaf_forms_shortcode_modalTitle" style="display: block;">
		<a href="#close" class="caldera-modal-closer" data-dismiss="modal" aria-hidden="true" id="calderaf_forms_shortcode_modalCloser">×</a>
		<h3 class="modal-label" id="calderaf_forms_shortcode_modalLable"><?php 
echo __('Insert Caldera Form', 'caldera-forms');
?>
</h3>
	</div>
	<div class="caldera-modal-body none" id="calderaf_forms_shortcode_modalBody" style="width: 70%;">
		<div class="modal-body modal-forms-list">
		<?php 
$forms = Caldera_Forms_Forms::get_forms(true);
if (!empty($forms)) {
    foreach ($forms as $form_id => $form) {
        echo '<div class="modal-list-item"><label><input name="insert_form_id" autocomplete="off" class="selected-form-shortcode" value="' . $form_id . '" type="radio">' . $form['name'];
        if (!empty($form['description'])) {
            echo '<p style="margin-left: 20px;" class="description"> ' . $form['description'] . ' </p>';
        }
        echo ' </label></div>';
    }
} else {
    echo '<p>' . __('You don\'t have any forms to insert.', 'caldera-forms') . '</p>';
}
?>
		</div>
	</div>
	<div class="caldera-modal-body none" id="calderaf_forms_shortcode_modalBody_options" style="left: 70%;">
		<div class="modal-body modal-shortcode-options">
			<h4><?php 
esc_html_e('Options', 'caldera-forms');
function cf_conn_form_get_all_fields($connected_form)
{
    $fields = array();
    if (isset($connected_form['node'])) {
        foreach ($connected_form['node'] as $connected_form) {
            $_form = Caldera_Forms_Forms::get_form($connected_form['form']);
            $fields = array_merge(Caldera_Forms_Forms::get_fields($_form), $fields);
        }
    }
    return $fields;
}
示例#5
0
 /**
  * Handler for shortcode
  *
  * @since 1.3.1
  *
  * @param array $atts
  * @param string $content
  * @param string $shortcode
  *
  * @return string|void
  */
 public static function shortcode_handler($atts, $content, $shortcode)
 {
     if (!isset($atts['id'])) {
         return;
     }
     if ($shortcode === 'caldera_form_modal') {
         $atts['modal'] = true;
     }
     if (isset($atts['modal']) && $atts['modal']) {
         $form = Caldera_Forms_Forms::get_form($atts['id']);
         if (!is_array($form)) {
             return;
         }
         if (empty($content)) {
             $content = $form['name'];
         }
         $tag_atts = sprintf('data-form="%1s"', $form['ID']);
         if (empty($atts['preview'])) {
             $tag_atts .= sprintf('data-remodal-target="modal-%1s"', $form['ID']);
         }
         if (!empty($atts['width'])) {
             $tag_atts .= sprintf(' data-width="%1s"', $atts['width']);
         }
         if (!empty($atts['height'])) {
             $tag_atts .= sprintf(' data-height="%1s"', $atts['height']);
         }
         $title = __(sprintf('Click to open the form %1s in a modal', $form['name']), 'caldera-forms');
         if (!empty($atts['type']) && $atts['type'] == 'button') {
             $form = sprintf('<button class="caldera-forms-modal" %1s title="%2s">%3s</button>', $tag_atts, $title, $content);
         } else {
             $form = sprintf('<a href="#" class="caldera-forms-modal" %1s title="%2s">%3s</a>', $tag_atts, $title, $content);
         }
         wp_enqueue_script('cf-dynamic');
     } else {
         $form = self::render_form($atts);
     }
     return $form;
 }
示例#6
0
 public static function create_form()
 {
     parse_str($_POST['data'], $newform);
     $newform = Caldera_Forms_Forms::create_form($newform);
     echo $newform['ID'];
     exit;
 }
示例#7
0
 /**
  * Clear the caching performed by this class
  *
  * @since 1.3.4
  */
 protected static function clear_cache()
 {
     self::$index = array();
     self::$registry_cache = array();
     self::$stored_forms = array();
     wp_cache_delete('_caldera_forms_forms', 'options');
     delete_transient(self::$registry_cache_key);
 }
示例#8
0
<?php

global $field_type_list, $field_type_templates;
if (!isset($_GET['edit']) || !is_string($_GET['edit'])) {
    wp_die(esc_html__('Invalid form ID', 'caldera-forms'));
}
// Load element
$element = Caldera_Forms_Forms::get_form($_GET['edit']);
if (empty($element) || !is_array($element)) {
    wp_die(esc_html__('Invalid form', 'caldera-forms'));
}
/**
 * Filter which Magic Tags are available in the form editor
 *
 *
 * @since 1.3.2
 *
 * @param array $tags Array of magic registered tags 
 * @param array $form_id for which this applies.
 */
$magic_tags = apply_filters('caldera_forms_get_magic_tags', array(), $element['ID']);
//dump($element);
if (empty($element['success'])) {
    $element['success'] = __('Form has successfully been submitted. Thank you.', 'caldera-forms');
}
if (!isset($element['db_support'])) {
    $element['db_support'] = 1;
}
/**
 * Convert existing field conditions if old method used
 *