/** * Format the profile field value. * This function simply checks whether an output method for the field class is available. * If no output method is available, we return the original string. * * @param mixed $value the value of a field. * @param string $type the field type string. * @return string the value of a field. * @since 1.2.0 */ function wpaam_format_profile_field_value($value, $field) { $type_object = wpaam_get_field_type_object($field->type); if (method_exists($type_object->class, "output_html")) { $value = call_user_func($type_object->class . "::output_html", $value, $field); } return $value; }
/** * Get submitted fields values. * * @access public * @since 1.0.0 * @return $values array of data from the fields. */ public static function get_posted_fields() { $values = array(); foreach (self::$fields as $group_key => $group_fields) { foreach ($group_fields as $key => $field) { // Get the type $field_type = str_replace('-', '_', $field['type']); // Get the type object $field_object = wpaam_get_field_type_object($field_type); if (method_exists($field_object->class, "sanitization")) { $values[$group_key][$key] = call_user_func($field_object->class . "::sanitization", $key, $field); } elseif (method_exists(__CLASS__, "get_posted_{$field_type}_field")) { $values[$group_key][$key] = call_user_func(__CLASS__ . "::get_posted_{$field_type}_field", $key, $field); } else { $values[$group_key][$key] = self::get_posted_field($key, $field); } // Set fields value self::$fields[$group_key][$key]['value'] = $values[$group_key][$key]; } } return $values; }
/** * __construct function. * * @access public * @return void */ public function __construct() { $this->db = new WPAAM_DB_Field_Groups(); // Detect if a group is being edited if (isset($_GET['group']) && is_numeric($_GET['group'])) { $this->groupd_id = intval($_GET['group']); } // Get selected group - set it as primary if no group is selected if (isset($_GET['group']) && is_numeric($_GET['group'])) { // Get primary group $this->group = $this->db->get_group_by('id', $_GET['group']); } else { // Get primary group $this->group = $this->db->get_group_by('primary'); } // Detect if a field is being edited if (isset($_GET['field']) && isset($_GET['action']) && $_GET['action'] == 'edit_field') { $this->field_db = new WPAAM_DB_Fields(); $this->field = $this->field_db->get((int) $_GET['field']); $this->field_object = wpaam_get_field_type_object($this->field->type); } // loads metaboxes functions add_action('load-' . self::editor_hook, array($this, 'load_editor')); add_action('add_meta_boxes_' . self::editor_hook, array($this, 'add_meta_box')); // Build the main section of the editor add_action('wpaam/fields/editor/single', array($this, 'field_title_editor')); add_action('wpaam/fields/editor/single', array($this, 'field_description_editor')); // Loads metaboxes functions for single field editor page add_action('load-' . self::single_field_hook, array($this, 'single_field_load_editor')); add_action('add_meta_boxes_' . self::single_field_hook, array($this, 'single_field_add_meta_box')); // Append group saving process add_action('wpaam_edit_group', array($this, 'process_group')); // Append groupfield saving process add_action('wpaam_save_field', array($this, 'process_field')); // Load WP_List_Table if (!class_exists('WP_List_Table')) { require_once ABSPATH . 'wp-admin/includes/class-wp-list-table.php'; } // Extedn WP_List_Table require_once WPAAM_PLUGIN_DIR . 'includes/admin/fields/class-wpaam-groups-fields.php'; }
/** * Displays a translatable string for the field type column. * * @access public * @return string the field type name. */ public function parse_type($type) { $text = esc_html__('Text', 'wpaam'); switch ($type) { case 'select': $text = esc_html__('Dropdown', 'wpaam'); break; case 'display_name': $text = esc_html__('Dropdown', 'wpaam'); break; case 'file': $text = esc_html__('Upload', 'wpaam'); break; case 'avatar': $text = esc_html__('Upload', 'wpaam'); break; case 'username': $text = esc_html__('Text', 'wpaam'); break; case 'nickname': $text = esc_html__('Text', 'wpaam'); break; default: $object = wpaam_get_field_type_object($type); $text = $object->name; break; } return ucfirst(apply_filters('wpaam_fields_editor_types', $text)); }