/** * Constructor */ public function __construct($id_base, $title, $field_options = array()) { $this->id_base = $id_base; $this->title = $title; $this->field_options = array_merge($this->field_options, $field_options); $this->post_type = jcf_get_post_type(); }
/** * Constructor */ function Just_Field($id_base, $title, $field_options = array()) { $this->id_base = $id_base; $this->title = $title; $this->field_options = array_merge($this->field_options, $field_options); $this->post_type = jcf_get_post_type(); }
function jcf_fields_get_option_name() { $post_type = jcf_get_post_type(); return 'jcf_fields-' . $post_type; }
/** * update order fieldsets * @param array $keys Fieldsets keys */ function jcf_fieldsets_order($keys = array()) { $option_name = jcf_fieldsets_get_option_name(); $new_fieldsets = array(); $jcf_read_settings = jcf_get_read_settings(); if ($jcf_read_settings != JCF_CONF_SOURCE_DB) { $jcf_settings = jcf_get_all_settings_from_file(); $post_type = jcf_get_post_type(); foreach ($keys as $key) { $new_fieldsets[$key] = $jcf_settings['fieldsets'][$post_type][$key]; unset($jcf_settings['fieldsets'][$post_type][$key]); } $jcf_settings['fieldsets'][$post_type] = $new_fieldsets; jcf_save_all_settings_in_file($jcf_settings); } else { $fieldsets = jcf_get_options($option_name); foreach ($keys as $key) { $new_fieldsets[$key] = $fieldsets[$key]; unset($fieldsets[$key]); } jcf_update_options($option_name, $new_fieldsets); } }
/** * delete field from collection */ public function delete_field($field_id) { $option_name = jcf_fields_get_option_name(); $jcf_read_settings = jcf_get_read_settings(); if ($jcf_read_settings != JCF_CONF_SOURCE_DB) { $jcf_settings = jcf_get_all_settings_from_file(); $post_type = jcf_get_post_type(); $fieldset = $jcf_settings['fieldsets'][$post_type][$this->fieldset_id]; $field_settings = $jcf_settings['field_settings'][$post_type]; if (isset($field_settings[$this->id]['fields'][$field_id])) { unset($field_settings[$this->id]['fields'][$field_id]); } $jcf_settings['fieldsets'][$post_type][$this->fieldset_id] = $fieldset; $jcf_settings['field_settings'][$post_type] = $field_settings; jcf_save_all_settings_in_file($jcf_settings); } else { $field_settings = jcf_get_options($option_name); if (isset($field_settings[$this->id]['fields'][$field_id])) { unset($field_settings[$this->id]['fields'][$field_id]); } jcf_update_options($option_name, $field_settings); } }