function the_cfc_field($meta_name, $field_name, $post_id = false, $key = 0, $do_echo = true) { $current_field = WCK_Template_API::get_field($meta_name, $field_name, $post_id, $key); $field_type = WCK_Template_API::generate_slug(WCK_Template_API::get_field_type($meta_name, $field_name)); // use this filter to modify the return var in order to output text, links or urls $current_field = apply_filters('wck_output_the_field_' . $field_type, $current_field); if ($current_field === false) { return; } // Echoing objects with error out. // Thus we're echoing an empty string so we don't brake the front-end, if (is_object($current_field)) { return; } // Echoing arrays will echo 'Array'. // Thus we're echoing an empty string so we don't brake the front-end. if (is_array($current_field)) { return; } if ($do_echo) { echo $current_field; } else { return $current_field; } }
/** * Returns the value of a field from CFC single and repeater. * */ static function get_field($meta_name = false, $field_name = false, $post_id = false, $key = 0) { $post_meta = WCK_Template_API::get_meta($meta_name, $post_id); if (isset($post_meta[$key][$field_name])) { $field_type = WCK_Template_API::generate_slug(WCK_Template_API::get_field_type($meta_name, $field_name)); // use this filter to modify the return var in order to output text, arrays or objects $output = apply_filters('wck_output_get_field_' . $field_type, $post_meta[$key][$field_name]); return $output; } return ''; }