Exemplo n.º 1
0
 public static function get_default_value($value, $field, $dynamic_default = true, $allow_array = false)
 {
     if (is_array(maybe_unserialize($value))) {
         if (FrmAppHelper::is_empty_value($value) || count(array_filter($value)) === 0) {
             $value = '';
         } else {
             return $value;
         }
     }
     $prev_val = '';
     if ($field && $dynamic_default) {
         if (FrmField::is_option_value_in_object($field, 'dyn_default_value')) {
             $prev_val = $value;
             $value = $field->field_options['dyn_default_value'];
         }
     }
     $matches = self::get_shortcodes_from_string($value);
     if (!isset($matches[0])) {
         return do_shortcode($value);
     }
     $args = array('matches' => $matches, 'allow_array' => $allow_array, 'field' => $field, 'prev_val' => $prev_val);
     foreach ($matches[1] as $match_key => $shortcode) {
         $args['shortcode'] = $shortcode;
         $args['match_key'] = $match_key;
         self::replace_shortcode_in_string($value, $args);
     }
     unset($matches);
     self::replace_field_id_shortcodes($value, $allow_array);
     self::do_shortcode($value, $allow_array);
     self::maybe_force_array($value, $field, $allow_array);
     return $value;
 }
Exemplo n.º 2
0
 /**
  * Remove form_select from all non-repeating sections
  */
 private static function migrate_to_30()
 {
     // Get all section fields
     $dividers = FrmField::getAll(array('fi.type' => 'divider'));
     // Remove form_select for non-repeating sections
     foreach ($dividers as $d) {
         if (FrmField::is_repeating_field($d)) {
             continue;
         }
         if (FrmField::is_option_value_in_object($d, 'form_select')) {
             $d->field_options['form_select'] = '';
             FrmField::update($d->id, array('field_options' => maybe_serialize($d->field_options)));
         }
     }
 }