Пример #1
0
 public static function dropdown_categories($args)
 {
     $defaults = array('field' => false, 'name' => false, 'show_option_all' => ' ');
     $args = wp_parse_args($args, $defaults);
     if (!$args['field']) {
         return;
     }
     if (!$args['name']) {
         $args['name'] = 'item_meta[' . $args['field']['id'] . ']';
     }
     $id = self::get_html_id($args['field']);
     $class = $args['field']['type'];
     $exclude = is_array($args['field']['exclude_cat']) ? implode(',', $args['field']['exclude_cat']) : $args['field']['exclude_cat'];
     $exclude = apply_filters('frm_exclude_cats', $exclude, $args['field']);
     if (is_array($args['field']['value'])) {
         if (!empty($exclude)) {
             $args['field']['value'] = array_diff($args['field']['value'], explode(',', $exclude));
         }
         $selected = reset($args['field']['value']);
     } else {
         $selected = $args['field']['value'];
     }
     $tax_atts = array('show_option_all' => $args['show_option_all'], 'hierarchical' => 1, 'name' => $args['name'], 'id' => $id, 'exclude' => $exclude, 'class' => $class, 'selected' => $selected, 'hide_empty' => false, 'echo' => 0, 'orderby' => 'name');
     $tax_atts = apply_filters('frm_dropdown_cat', $tax_atts, $args['field']);
     if (FrmAppHelper::pro_is_installed()) {
         $post_type = FrmProFormsHelper::post_type($args['field']['form_id']);
         $tax_atts['taxonomy'] = FrmProAppHelper::get_custom_taxonomy($post_type, $args['field']);
         if (!$tax_atts['taxonomy']) {
             return;
         }
         // If field type is dropdown (not Dynamic), exclude children when parent is excluded
         if ($args['field']['type'] != 'data' && is_taxonomy_hierarchical($tax_atts['taxonomy'])) {
             $tax_atts['exclude_tree'] = $exclude;
         }
     }
     $dropdown = wp_dropdown_categories($tax_atts);
     $add_html = FrmFieldsController::input_html($args['field'], false);
     if (FrmAppHelper::pro_is_installed()) {
         $add_html .= FrmProFieldsController::input_html($args['field'], false);
     }
     $dropdown = str_replace("<select name='" . esc_attr($args['name']) . "' id='" . esc_attr($id) . "' class='" . esc_attr($class) . "'", "<select name='" . esc_attr($args['name']) . "' id='" . esc_attr($id) . "' " . $add_html, $dropdown);
     if (is_array($args['field']['value'])) {
         $skip = true;
         foreach ($args['field']['value'] as $v) {
             if ($skip) {
                 $skip = false;
                 continue;
             }
             $dropdown = str_replace(' value="' . esc_attr($v) . '"', ' value="' . esc_attr($v) . '" selected="selected"', $dropdown);
             unset($v);
         }
     }
     return $dropdown;
 }
Пример #2
0
 public static function add_option()
 {
     global $frm_field;
     $id = $_POST['field_id'];
     $t = isset($_POST['t']) ? $_POST['t'] : false;
     if ($t == 'row' or $t == 'col') {
         $field = $frm_field->getOne($id);
         $options = maybe_unserialize($field->options);
         list($columns, $rows) = FrmProFieldsHelper::get_table_options($options);
         if ($t == 'col') {
             $last = count($columns) ? array_pop(array_keys($columns)) : 'col_0';
             preg_match('/[0-9]+$/', $last, $matches);
             $opt_key = 'col_' . ($matches[0] + 1);
             $opt = 'Column ' . (count($columns) + 1);
             $columns[$opt_key] = $opt;
             $row_num = count($rows) - 1;
             $col_num = count($columns);
         } else {
             $last = count($rows) ? array_pop(array_keys($rows)) : 'row_0';
             preg_match('/[0-9]+$/', $last, $matches);
             $opt_key = 'row_' . ($matches[0] + 1);
             $opt = 'Row ' . (count($rows) + 1);
             $rows[$opt_key] = $opt;
             $row_num = count($rows);
         }
         $options = FrmProFieldsHelper::set_table_options($options, $columns, $rows);
         $frm_field->update($id, array('options' => maybe_serialize($options)));
         $field_data = $frm_field->getOne($id);
         $field = (array) $field_data;
         $field['value'] = null;
         $field_name = "item_meta[{$id}]";
         $include_js = true;
         /*if($t == 'row')
                  require(FrmAppHelper::plugin_path() .'/pro/classes/views/frmpro-fields/grid-single-row.php');
              else
               require(FrmAppHelper::plugin_path() .'/pro/classes/views/frmpro-fields/grid-option.php'); 
           */
         die;
     } else {
         FrmFieldsController::add_option();
     }
 }
Пример #3
0
 public static function duplicate_section($section_field, $form_id)
 {
     check_ajax_referer('frm_ajax', 'nonce');
     global $wpdb;
     if (isset($_POST['children'])) {
         $children = array_filter((array) $_POST['children'], 'is_numeric');
         $fields = FrmField::getAll(array('fi.id' => $children), 'field_order');
     } else {
         $fields = array();
     }
     array_unshift($fields, $section_field);
     $field_count = FrmDb::get_count($wpdb->prefix . 'frm_fields fi LEFT JOIN ' . $wpdb->prefix . 'frm_forms fr ON (fi.form_id = fr.id)', array('or' => 1, 'fr.id' => $form_id, 'fr.parent_form_id' => $form_id));
     $ended = false;
     if (isset($section_field->field_options['repeat']) && $section_field->field_options['repeat']) {
         // create the repeatable form
         $new_form_id = FrmProField::create_repeat_form(0, array('parent_form_id' => $form_id, 'field_name' => $section_field->name));
     } else {
         $new_form_id = $form_id;
     }
     foreach ($fields as $field) {
         // keep the current form id or give it the id of the newly created form
         $this_form_id = $field->form_id == $form_id ? $form_id : $new_form_id;
         $values = array();
         FrmFieldsHelper::fill_field($values, $field, $this_form_id);
         if (FrmField::is_repeating_field($field)) {
             $values['field_options']['form_select'] = $new_form_id;
         }
         $field_count++;
         $values['field_order'] = $field_count;
         $field_id = FrmField::create($values);
         if (!$field_id) {
             continue;
         }
         if ('end_divider' == $field->type) {
             $ended = true;
         }
         $values['id'] = $this_form_id;
         FrmFieldsController::include_single_field($field_id, $values);
     }
     if (!$ended) {
         //make sure the section is ended
         self::create_multiple_fields((array) $section_field, $form_id);
     }
     // Prevent the function in the free version from completing
     wp_die();
 }
Пример #4
0
 public static function dropdown_categories($args)
 {
     global $frm_vars;
     $defaults = array('field' => false, 'name' => false, 'show_option_all' => ' ');
     extract(wp_parse_args($args, $defaults));
     if (!$field) {
         return;
     }
     if (!$name) {
         $name = "item_meta[{$field['id']}]";
     }
     $id = 'field_' . $field['field_key'];
     $class = $field['type'];
     $exclude = is_array($field['exclude_cat']) ? implode(',', $field['exclude_cat']) : $field['exclude_cat'];
     $exclude = apply_filters('frm_exclude_cats', $exclude, $field);
     if (is_array($field['value'])) {
         if (!empty($exclude)) {
             $field['value'] = array_diff($field['value'], explode(',', $exclude));
         }
         $selected = reset($field['value']);
     } else {
         $selected = $field['value'];
     }
     $args = array('show_option_all' => $show_option_all, 'hierarchical' => 1, 'name' => $name, 'id' => $id, 'exclude' => $exclude, 'class' => $class, 'selected' => $selected, 'hide_empty' => false, 'echo' => 0, 'orderby' => 'name');
     $args = apply_filters('frm_dropdown_cat', $args, $field);
     if (class_exists('FrmProFormsHelper')) {
         $post_type = FrmProFormsHelper::post_type($field['form_id']);
         $args['taxonomy'] = FrmProAppHelper::get_custom_taxonomy($post_type, $field);
         if (!$args['taxonomy']) {
             return;
         }
         if (is_taxonomy_hierarchical($args['taxonomy'])) {
             $args['exclude_tree'] = $exclude;
         }
     }
     $dropdown = wp_dropdown_categories($args);
     $add_html = FrmFieldsController::input_html($field, false);
     if ($frm_vars['pro_is_installed']) {
         $add_html .= FrmProFieldsController::input_html($field, false);
     }
     $dropdown = str_replace("<select name='{$name}' id='{$id}' class='{$class}'", "<select name='{$name}' id='{$id}' " . $add_html, $dropdown);
     if (is_array($field['value'])) {
         $skip = true;
         foreach ($field['value'] as $v) {
             if ($skip) {
                 $skip = false;
                 continue;
             }
             $dropdown = str_replace(' value="' . $v . '"', ' value="' . $v . '" selected="selected"', $dropdown);
             unset($v);
         }
     }
     return $dropdown;
 }
Пример #5
0
 function dropdown_categories($args)
 {
     global $frmpro_is_installed;
     $defaults = array('field' => false, 'name' => false);
     extract(wp_parse_args($args, $defaults));
     if (!$field) {
         return;
     }
     if (!$name) {
         $name = "item_meta[{$field['id']}]";
     }
     $id = 'field_' . $field['field_key'];
     $class = $field['type'];
     $selected = is_array($field['value']) ? reset($field['value']) : $field['value'];
     $exclude = is_array($field['exclude_cat']) ? implode(',', $field['exclude_cat']) : $field['exclude_cat'];
     $exclude = apply_filters('frm_exclude_cats', $exclude, $field);
     $args = array('show_option_all' => ' ', 'hierarchical' => 1, 'name' => $name, 'id' => $id, 'exclude' => $exclude, 'class' => $class, 'selected' => $selected, 'hide_empty' => false, 'echo' => 0, 'orderby' => 'name');
     if (class_exists('FrmProForm')) {
         $post_type = FrmProForm::post_type($field['form_id']);
         if (function_exists('get_object_taxonomies')) {
             $args['taxonomy'] = FrmProAppHelper::get_custom_taxonomy($post_type, $field);
             if (!$args['taxonomy']) {
                 return;
             }
         }
     }
     $dropdown = wp_dropdown_categories($args);
     $add_html = FrmFieldsController::input_html($field, false);
     if ($frmpro_is_installed) {
         $add_html .= FrmProFieldsController::input_html($field, false);
     }
     $dropdown = str_replace("<select name='{$name}' id='{$id}' class='{$class}'", "<select name='{$name}' id='{$id}' " . $add_html, $dropdown);
     return $dropdown;
 }
Пример #6
0
global $frm_entry;
global $frm_entry_meta;
$frmdb = new FrmDb();
$frm_field = new FrmField();
$frm_form = new FrmForm();
$frm_entry = new FrmEntry();
$frm_entry_meta = new FrmEntryMeta();
$obj = new FrmNotification();
// Instansiate Controllers
require_once $frm_path . '/classes/controllers/FrmAppController.php';
require_once $frm_path . '/classes/controllers/FrmFieldsController.php';
require_once $frm_path . '/classes/controllers/FrmFormsController.php';
require_once $frm_path . '/classes/controllers/FrmEntriesController.php';
FrmAppController::load_hooks();
FrmEntriesController::load_hooks();
FrmFieldsController::load_hooks();
FrmFormsController::load_hooks();
if (is_admin()) {
    require_once $frm_path . '/classes/controllers/FrmSettingsController.php';
    FrmSettingsController::load_hooks();
    require_once $frm_path . '/classes/controllers/FrmStatisticsController.php';
    FrmStatisticsController::load_hooks();
    require_once $frm_path . '/classes/controllers/FrmXMLController.php';
    FrmXMLController::load_hooks();
}
// Instansiate Helpers
require_once $frm_path . '/classes/helpers/FrmEntriesHelper.php';
require_once $frm_path . '/classes/helpers/FrmFieldsHelper.php';
require_once $frm_path . '/classes/helpers/FrmFormsHelper.php';
if (file_exists($frm_path . '/pro/formidable-pro.php')) {
    require_once $frm_path . '/pro/formidable-pro.php';