function processor_wrapper_template($id = '{{id}}', $type = '{{type}}', $config_str = '{"default":"default value"}', $conditions_str = '{"type" : ""}') { global $form_processors; $type_name = __('New Form Processor', 'caldera-forms'); if (!empty($type) && $type != '{{type}}') { if (empty($form_processors[$type])) { return; } if (isset($form_processors[$type]['name'])) { $type_name = $form_processors[$type]['name']; } } if (is_array($config_str)) { $config = $config_str; $config_str = json_encode($config_str); } else { $config = json_decode($config_str, true); } $condition_type = ''; if (!empty($conditions_str)) { $conditions = json_decode($conditions_str, true); if (!empty($conditions['type'])) { $condition_type = $conditions['type']; } if (!empty($conditions['group'])) { $groups = array(); foreach ($conditions['group'] as $groupid => $group) { $group_tmp = array('id' => $groupid, 'type' => 'processors', 'lines' => array()); if (!empty($group)) { foreach ($group as $line_id => $line) { $group_line = $line; $group_line['id'] = $line_id; $group_tmp['lines'][] = $group_line; } } $groups[] = $group_tmp; } $conditions['group'] = $groups; $conditions_str = json_encode($conditions); } } ?> <div class="caldera-editor-processor-config-wrapper caldera-editor-config-wrapper processor-<?php echo $type; ?> " id="<?php echo $id; ?> " data-type="<?php echo $type; ?> " style="display:none;"> <div class="toggle_option_tab"> <a href="#<?php echo $id; ?> _settings_pane" class="button button-primary">Settings</a> <a href="#<?php echo $id; ?> _conditions_pane" class="button ">Conditions</a> </div> <h3 data-title="<?php echo __('New Form Processor', 'caldera-forms'); ?> " class="caldera-editor-processor-title"><?php echo $type_name; ?> </h3> <div id="<?php echo $id; ?> _settings_pane" class="wrapper-instance-pane"> <div class="caldera-config-group" style="display:none;"> <label for="<?php echo $id; ?> _type"><?php echo __('Processor Type', 'caldera-forms'); ?> </label> <div class="caldera-config-field"> <select class="block-input caldera-select-processor-type" id="<?php echo $id; ?> _type" name="config[processors][<?php echo $id; ?> ][type]" data-type="<?php echo $type; ?> "> <?php echo build_processor_types($type); ?> </select> </div> </div> <div class="caldera-config-processor-setup"> </div> <input type="hidden" class="processor_config_string block-input" value="<?php echo htmlentities($config_str); ?> "> <br> <br> <button class="button block-button delete-processor" data-confirm="<?php echo __('Are you sure you want to remove this processor?', 'caldera-forms'); ?> " type="button"><?php echo __('Remove Processor', 'caldera-forms'); ?> </button> </div> <div id="<?php echo $id; ?> _conditions_pane" style="display:none;" class="wrapper-instance-pane"> <p> <select name="config[processors][<?php echo $id; ?> ][conditions][type]" data-id="<?php echo $id; ?> " class="caldera-conditionals-usetype"> <option value=""></option> <option value="use" <?php if ($condition_type == 'use') { echo 'selected="selected"'; } ?> ><?php echo __('Use', 'caldera-forms'); ?> </option> <option value="not" <?php if ($condition_type == 'not') { echo 'selected="selected"'; } ?> ><?php echo __('Don\'t Use', 'caldera-forms'); ?> </option> </select> <button id="<?php echo $id; ?> _condition_group_add" style="display:none;" type="button" data-id="<?php echo $id; ?> " class="pull-right button button-small add-conditional-group ajax-trigger" data-type="processors" data-template="#conditional-group-tmpl" data-target-insert="append" data-request="new_conditional_group" data-callback="rebuild_field_binding" data-target="#<?php echo $id; ?> _conditional_wrap"><?php echo __('Add Conditional Group', 'caldera-forms'); ?> </button> </p> <div class="caldera-conditionals-wrapper" id="<?php echo $id; ?> _conditional_wrap"></div> <?php do_action('caldera_forms_processor_conditionals_template', $id); ?> <input type="hidden" class="processor_conditions_config_string block-input ajax-trigger" data-event="none" data-type="processors" data-autoload="true" data-request="build_conditions_config" data-template="#conditional-group-tmpl" data-id="<?php echo $id; ?> " data-target="#<?php echo $id; ?> _conditional_wrap" data-callback="rebuild_field_binding" value="<?php echo htmlentities($conditions_str); ?> "> </div> </div> <?php }
function processor_wrapper_template($id = '{{id}}', $type = '{{type}}', $config_str = '{"default":"default value"}', $run_times = false, $conditions_str = '{"type" : ""}') { global $form_processors; if (false === $run_times || !is_array($run_times)) { $run_times = array('insert' => 1); } $type_name = __('New Form Processor', 'caldera-forms'); if (!empty($type) && $type != '{{type}}') { if (empty($form_processors[$type])) { return; } if (isset($form_processors[$type]['name'])) { $type_name = $form_processors[$type]['name']; } } if (is_array($config_str)) { $config = $config_str; $config_str = json_encode($config_str); } else { $config = json_decode($config_str, true); } $condition_type = ''; if (!empty($conditions_str)) { $conditions = json_decode($conditions_str, true); if (!empty($conditions['type'])) { $condition_type = $conditions['type']; } if (!empty($conditions['group'])) { $groups = array(); foreach ($conditions['group'] as $groupid => $group) { $group_tmp = array('id' => $groupid, 'type' => 'processors', 'lines' => array()); if (!empty($group)) { foreach ($group as $line_id => $line) { $group_line = $line; $group_line['id'] = $line_id; $group_tmp['lines'][] = $group_line; } } $groups[] = $group_tmp; } $conditions['group'] = $groups; $conditions_str = json_encode($conditions); } } ?> <div class="caldera-editor-processor-config-wrapper caldera-editor-config-wrapper processor-<?php echo $type; ?> " id="<?php echo $id; ?> " data-type="<?php echo $type; ?> " style="display:none;"> <div class="toggle_option_tab"> <a href="#<?php echo $id; ?> _settings_pane" class="button button-primary"><?php echo esc_html__('Settings', 'caldera-forms'); ?> </a> <a href="#<?php echo $id; ?> _conditions_pane" class="button "><?php echo esc_html__('Conditions', 'caldera-forms'); ?> </a> </div> <h3 data-title="<?php esc_html_e('New Form Processor', 'caldera-forms'); ?> " class="caldera-editor-processor-title"><?php echo $type_name; ?> </h3> <div id="<?php echo $id; ?> _settings_pane" class="wrapper-instance-pane"> <div class="toggle_processor_event"> <label title="<?php echo esc_attr(__('Enable / Disable Processor', 'caldera-forms')); ?> " class="button button-small <?php if (!empty($run_times['insert'])) { echo 'activated'; } ?> "><input type="checkbox" style="display:none;" value="1" name="config[processors][<?php echo $id; ?> ][runtimes][insert]" <?php if (!empty($run_times['insert'])) { echo 'checked="checked"'; } ?> > <span class="is_active" style="<?php if (empty($run_times)) { ?> display:none;<?php } ?> "><?php esc_html_e('Disable Processor', 'caldera-forms'); ?> </span> <span class="not_active" style="<?php if (!empty($run_times)) { ?> display:none;<?php } ?> "><?php esc_html_e('Enable Processor', 'caldera-forms'); ?> </span> </label> <?php /*<label title="<?php echo esc_attr( __('Run processor on Update', 'caldera-forms') ); ?>" class="button button-small <?php if( !empty( $run_times['update'] )){ echo 'button-primary'; } ?> "><input type="checkbox" style="display:none;" value="1" name="config[processors][<?php echo $id; ?>][runtimes][update]" <?php if( !empty( $run_times['update'] )){ echo 'checked="checked"'; } ?>>Update</label> <label class="button button-small <?php if( !empty( $run_times['delete'] )){ echo 'button-primary'; } ?> "><input type="checkbox" style="display:none;" value="1" name="config[processors][<?php echo $id; ?>][runtimes][delete]" <?php if( !empty( $run_times['delete'] )){ echo 'checked="checked"'; } ?>>Delete</label> */ ?> </div> <div class="caldera-config-processor-notice" style="<?php if (!empty($run_times)) { ?> display:none;<?php } ?> clear: both; padding: 20px 0px 0px;"> <p style="padding:12px; text-align:center;background:#e7e7e7;" class="description"><?php esc_html_e('Processor is currently disabled', 'caldera-forms'); ?> </p> </div> <div class="caldera-config-group" style="display:none;"> <label for="<?php echo $id; ?> _type"><?php esc_html_e('Processor Type', 'caldera-forms'); ?> </label> <div class="caldera-config-field"> <select class="block-input caldera-select-processor-type" id="<?php echo $id; ?> _type" name="config[processors][<?php echo $id; ?> ][type]" data-type="<?php echo $type; ?> "> <?php echo build_processor_types($type); ?> </select> </div> </div> <div class="caldera-config-processor-setup" <?php if (empty($run_times)) { ?> style="display:none;"<?php } ?> > </div> <input type="hidden" class="processor_config_string block-input" value="<?php echo htmlentities($config_str); ?> "> <br> <br> <button class="button block-button delete-processor" data-confirm="<?php esc_html_e('Are you sure you want to remove this processor?', 'caldera-forms'); ?> " type="button"><?php esc_html_e('Remove Processor', 'caldera-forms'); ?> </button> </div> <div id="<?php echo $id; ?> _conditions_pane" style="display:none;" class="wrapper-instance-pane"> <p> <select name="config[processors][<?php echo $id; ?> ][conditions][type]" data-id="<?php echo $id; ?> " class="caldera-conditionals-usetype"> <option value=""></option> <option value="use" <?php if ($condition_type == 'use') { echo 'selected="selected"'; } ?> ><?php esc_html_e('Use', 'caldera-forms'); ?> </option> <option value="not" <?php if ($condition_type == 'not') { echo 'selected="selected"'; } ?> ><?php esc_html_e('Don\'t Use', 'caldera-forms'); ?> </option> </select> <button id="<?php echo $id; ?> _condition_group_add" style="display:none;" type="button" data-id="<?php echo $id; ?> " class="pull-right button button-small add-conditional-group ajax-trigger" data-type="processors" data-template="#conditional-group-tmpl" data-target-insert="append" data-request="new_conditional_group" data-callback="rebuild_field_binding" data-target="#<?php echo $id; ?> _conditional_wrap"><?php esc_html_e('Add Conditional Group', 'caldera-forms'); ?> </button> </p> <div class="caldera-conditionals-wrapper" id="<?php echo $id; ?> _conditional_wrap"></div> <?php do_action('caldera_forms_processor_conditionals_template', $id); ?> <input type="hidden" class="processor_conditions_config_string block-input ajax-trigger" data-event="none" data-type="processors" data-autoload="true" data-request="build_conditions_config" data-template="#conditional-group-tmpl" data-id="<?php echo $id; ?> " data-target="#<?php echo $id; ?> _conditional_wrap" data-callback="rebuild_field_binding" value="<?php echo htmlentities($conditions_str); ?> "> </div> </div> <?php }