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; } }
/** * Find out what type of field the user asks for. * */ static function get_field_type($meta_name = false, $field_name = false) { // get all CFC's $args = array('post_type' => 'wck-meta-box', 'posts_per_page' => -1, 'post_status' => array('publish'), 'fields' => 'ids'); $all_cfc = get_posts($args); foreach ($all_cfc as $post_id) { $queried_meta_name = WCK_Template_API::get_meta('wck_cfc_args', $post_id); $queried_meta_name = $queried_meta_name[0]['meta-name']; if ($meta_name == $queried_meta_name) { $available_fields = WCK_Template_API::get_meta('wck_cfc_fields', $post_id); foreach ($available_fields as $key => $field_data) { $current_field = WCK_Template_API::generate_slug($field_data['field-title']); if ($current_field == $field_name) { return $field_data['field-type']; } } } } return 'text'; }