public static function get_field_value_shortcode($sc_atts)
 {
     $atts = shortcode_atts(array('entry' => false, 'field_id' => false, 'user_id' => false, 'ip' => false, 'show' => '', 'format' => '', 'return_array' => false, 'default' => ''), $sc_atts);
     // Include all user-defined atts as well
     $atts = (array) $atts + (array) $sc_atts;
     // For reverse compatibility
     if (isset($atts['entry_id']) && !$atts['entry']) {
         $atts['entry'] = $atts['entry_id'];
     }
     if (!$atts['field_id']) {
         return __('You are missing options in your shortcode. field_id is required.', 'formidable');
     }
     $field = FrmField::getOne($atts['field_id']);
     if (!$field) {
         return $atts['default'];
     }
     $entry = self::get_frm_field_value_entry($field, $atts);
     if (!$entry) {
         return $atts['default'];
     }
     $value = FrmProEntryMetaHelper::get_post_or_meta_value($entry, $field, $atts);
     $atts['type'] = $field->type;
     $atts['post_id'] = $entry->post_id;
     $atts['entry_id'] = $entry->id;
     if (!isset($atts['show_filename'])) {
         $atts['show_filename'] = false;
     }
     if ($field->type == 'file' && !isset($atts['html'])) {
         // default to show the image instead of the url
         $atts['html'] = 1;
     }
     if (!empty($atts['format']) || isset($atts['show']) && !empty($atts['show'])) {
         $value = FrmFieldsHelper::get_display_value($value, $field, $atts);
     } else {
         $value = FrmEntriesHelper::display_value($value, $field, $atts);
     }
     return $value;
 }
Exemplo n.º 2
0
 private static function eval_equals_condition($atts, &$replace_with, $field)
 {
     if ($replace_with != $atts['equals']) {
         if ($field && $field->type == 'data') {
             $replace_with = FrmFieldsHelper::get_display_value($replace_with, $field, $atts);
             if ($replace_with != $atts['equals']) {
                 $replace_with = '';
             }
         } else {
             if (isset($field->field_options['post_field']) && $field->field_options['post_field'] == 'post_category') {
                 $cats = explode(', ', $replace_with);
                 $replace_with = '';
                 foreach ($cats as $cat) {
                     if ($atts['equals'] == strip_tags($cat)) {
                         $replace_with = true;
                         return;
                     }
                 }
             } else {
                 $replace_with = '';
             }
         }
     } else {
         if ($atts['equals'] == '' && $replace_with == '' || $atts['equals'] == '0' && $replace_with == '0') {
             //if the field is blank, give it a value
             $replace_with = true;
         }
     }
 }
Exemplo n.º 3
0
 public static function ajax_get_data()
 {
     //check_ajax_referer( 'frm_ajax', 'nonce' );
     $entry_id = FrmAppHelper::get_param('entry_id');
     if (is_array($entry_id)) {
         $entry_id = implode(',', $entry_id);
     }
     $entry_id = trim($entry_id, ',');
     $field_id = FrmAppHelper::get_param('field_id', '', 'get', 'sanitize_title');
     $current_field = FrmAppHelper::get_param('current_field', '', 'get', 'absint');
     $hidden_field_id = FrmAppHelper::get_param('hide_id');
     $data_field = FrmField::getOne($field_id);
     $current = FrmField::getOne($current_field);
     if (strpos($entry_id, ',')) {
         $entry_id = explode(',', $entry_id);
         $meta_value = array();
         foreach ($entry_id as $eid) {
             $new_meta = FrmProEntryMetaHelper::get_post_or_meta_value($eid, $data_field);
             if ($new_meta) {
                 foreach ((array) $new_meta as $nm) {
                     array_push($meta_value, $nm);
                     unset($nm);
                 }
             }
             unset($new_meta, $eid);
         }
         $meta_value = array_unique($meta_value);
     } else {
         $meta_value = FrmProEntryMetaHelper::get_post_or_meta_value($entry_id, $data_field);
     }
     $data_display_opts = apply_filters('frm_display_data_opts', array('html' => true));
     $value = FrmFieldsHelper::get_display_value($meta_value, $data_field, $data_display_opts);
     if (is_array($value)) {
         $value = implode(', ', $value);
     }
     if (is_array($meta_value)) {
         $meta_value = implode(', ', $meta_value);
     }
     if ($value && !empty($value)) {
         echo apply_filters('frm_show_it', "<p class='frm_show_it'>" . $value . "</p>\n", $value, array('field' => $data_field, 'value' => $meta_value, 'entry_id' => $entry_id));
     }
     $current_field = (array) $current;
     foreach ($current->field_options as $o => $v) {
         if (!isset($current_field[$o])) {
             $current_field[$o] = $v;
         }
         unset($o, $v);
     }
     // Set up HTML ID and HTML name
     $html_id = '';
     $field_name = 'item_meta';
     FrmProFieldsHelper::get_html_id_from_container($field_name, $html_id, (array) $current, $hidden_field_id);
     echo '<input type="hidden" id="' . esc_attr($html_id) . '" name="' . esc_attr($field_name) . '" value="' . esc_attr($value) . '" ' . do_action('frm_field_input_html', $current_field, false) . '/>';
     wp_die();
 }