Exemplo n.º 1
0
/**
 * Get Caldera Forms
 *
 * Includes backwards compat for pre-Caldera Forms 1.3.4
 *
 * @since 2.0.5
 *
 * @return array|void
 */
function cf_custom_fields_get_forms()
{
    if (class_exists('Caldera_Forms_Forms')) {
        $forms = Caldera_Forms_Forms::get_forms(true);
    } else {
        $forms = Caldera_Forms::get_forms();
    }
    return $forms;
}
Exemplo n.º 2
0
/**
 * Disable mailer/ form AJAX/ DB support for metabox forms.
 *
 * @since 1.?.?
 *
 * @uses "caldera_forms_save_form_register" action
 *
 * @param $form
 */
function cf_custom_fields_metabox_save_form($form)
{
    if (!empty($form['is_metabox'])) {
        // disable DB support
        $form['db_support'] = 0;
        // no ajax forms
        if (isset($form['form_ajax'])) {
            unset($form['form_ajax']);
        }
        // disable mailer
        $form['mailer']['enable_mailer'] = 0;
        // update form
        update_option($form['ID'], $form);
        // update register
        $forms = Caldera_Forms::get_forms(true);
        $forms[$form['ID']]['db_support'] = 0;
        $forms[$form['ID']]['mailer']['enable_mailer'] = 0;
        update_option('_caldera_forms', $forms);
    }
}
Exemplo n.º 3
0
 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::get_forms();
     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);
 }
<div class="caldera-backdrop caldera-forms-insert-modal" style="display: none;"></div>
<div id="calderaf_forms_shortcode_modal" class="caldera-modal-wrap caldera-forms-insert-modal" style="display: none; width: 600px; max-height: 500px; margin-left: -300px;">
	<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">
		<div class="modal-body">
		<?php 
$forms = Caldera_Forms::get_forms();
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 '<span class="description"> ' . $form['description'] . ' </span>';
        }
        echo ' </label></div>';
        //dump($form,0);
    }
} else {
    echo '<p>' . __('You don\'t have any forms to insert.', 'caldera-forms') . '</p>';
}
?>
		</div>
	</div>
	<div class="caldera-modal-footer" id="calderaf_forms_shortcode_modalFooter" style="display: block;">
	<?php 
if (!empty($forms)) {
Exemplo n.º 5
0
 /**
  * Get all forms running on the site
  *
  * @since 1.0.0
  *
  * @param $form_list
  *
  * @return mixed
  */
 public function get_forms($form_list)
 {
     if (class_exists('Caldera_Forms')) {
         $forms = \Caldera_Forms::get_forms();
         $form_list['caldera'] = array('name' => __('Caldera Forms', 'caldera-forms'), 'forms' => array());
         foreach ($forms as $form) {
             $form_list['caldera']['forms'][$form['ID']] = $form['name'];
         }
     }
     if (class_exists('RGFormsModel')) {
         $forms = \RGFormsModel::get_forms(null, 'title');
         $form_list['gform'] = array('name' => __('Gravity Forms', 'gravityforms'), 'forms' => array());
         foreach ($forms as $form) {
             $form_list['gform']['forms'][$form->id] = $form->title;
         }
     }
     if (class_exists('NF_Forms')) {
         $nforms = new \NF_Forms();
         $nforms = $nforms->get_all();
         $form_list['ninja'] = array('name' => __('Ninja Forms', 'ninja-forms'), 'forms' => array());
         foreach ($nforms as $form) {
             $form_list['ninja']['forms'][$form] = Ninja_Forms()->form($form)->get_setting('form_title');
         }
     }
     if (class_exists('WPCF7_ContactForm')) {
         $cforms = \WPCF7_ContactForm::find(array('posts_per_page' => -1));
         $form_list['cf7'] = array('name' => __('Contact Form 7', 'contact-form-7'), 'forms' => array());
         foreach ($cforms as $form) {
             $form_list['cf7']['forms'][$form->id()] = $form->title();
         }
     }
     if (class_exists('FrmForm')) {
         $fforms = \FrmForm::getAll();
         $form_list['frmid'] = array('name' => __('Formidable', 'formidable'), 'forms' => array());
         foreach ($fforms as $form) {
             if (!empty($form->is_template)) {
                 continue;
             }
             $form_list['frmid']['forms'][$form->id] = $form->name;
         }
     }
     // jetpack
     if (function_exists('grunion_display_form_view')) {
         global $wpdb;
         $shortcodes = $wpdb->get_results("SELECT `post_id` FROM `" . $wpdb->postmeta . "` WHERE `meta_key` = '_g_feedback_shortcode';", ARRAY_A);
         if (!empty($shortcodes)) {
             $form_list['jp'] = array('name' => __('Jetpack Contact Form', 'jetpack'), 'forms' => array());
             foreach ($shortcodes as $post_id) {
                 $form = get_post($post_id['post_id']);
                 $form_list['jp']['forms'][$post_id['post_id']] = $form->post_title;
             }
         }
     }
     return $form_list;
 }
Exemplo n.º 6
0
 public static function create_form()
 {
     parse_str($_POST['data'], $newform);
     // get form templates
     $form_templates = self::internal_form_templates();
     // get form registry
     $forms = Caldera_Forms::get_forms(true);
     if (empty($forms)) {
         $forms = array();
     }
     if (!empty($newform['clone'])) {
         $clone = $newform['clone'];
     }
     // load template if any
     if (!empty($newform['template'])) {
         if (isset($form_templates[$newform['template']]) && !empty($form_templates[$newform['template']]['template'])) {
             $form_template = $form_templates[$newform['template']]['template'];
         }
     }
     $newform = array("ID" => uniqid('CF'), "name" => $newform['name'], "description" => $newform['description'], "success" => __('Form has been successfully submitted. Thank you.', 'caldera-forms'), "form_ajax" => 1, "hide_form" => 1);
     // is template?
     if (!empty($form_template) && is_array($form_template)) {
         $newform = array_merge($form_template, $newform);
     }
     // add from to list
     $newform = apply_filters('caldera_forms_create_form', $newform);
     $forms[$newform['ID']] = $newform;
     update_option('_caldera_forms', $forms);
     if (!empty($clone)) {
         $clone_form = get_option($clone);
         if (!empty($clone_form['ID']) && $clone == $clone_form['ID']) {
             $newform = array_merge($clone_form, $newform);
         }
     }
     // add form to db
     update_option($newform['ID'], $newform);
     do_action('caldera_forms_create_form', $newform);
     echo $newform['ID'];
     exit;
 }
Exemplo n.º 7
0
 /**
  * Get all forms
  *
  * @return \WP_REST_Response
  */
 public function get_forms()
 {
     return new \WP_REST_Response(\Caldera_Forms::get_forms(), 200);
 }
<?php

// Connection builder
$all_forms = \Caldera_Forms::get_forms();
$forms = array();
foreach ($all_forms as $form_id => $form_details) {
    $form = \Caldera_Forms::get_form($form_id);
    if (!empty($form['is_connected_form'])) {
        continue;
    }
    if (!empty($form['fields'])) {
        foreach ($form['fields'] as $field_id => $field) {
            if ($field['type'] == 'html') {
                $form['fields'][$field_id]['config']['default'] = '';
            }
        }
    }
    $forms[$form_id] = $form;
}
if (!empty($element['condition_points']['conditions'])) {
    foreach ($element['condition_points']['conditions'] as $condition_point) {
        if (empty($element['node'][$condition_point['connect']])) {
            // dont output points for nonexistant forms
            continue;
        }
        if ($condition_point['connect'] == $condition_point['parent']) {
            unset($element['node'][$condition_point['connect']]);
            continue;
        }
        ?>