Simple Fields API Documentation
Class

simple_fields_field

class simple_fields_field

Class that represents a Simple Fields Field Extend this class to add your own fields.

See field_types/example.php

Properties

$key
$name
$description
$field_url

Methods

__construct()

string options_output($existing_vals = array())

Output on options screen

options_save()

string edit_output($saved_value, $options)

Output fields and stuff on post edit page This is the output a regular user will see

mixed, edit_save(array $values = NULL)

Called when saving fields, i.e.

set_options_base_id(string $string)

Sets the base for the generation of input ids in options screen Called by options screen.

set_options_base_name($string)

Sets the base for the generation of input names in options screen Called by options screen.

string get_options_id($name $name)

Get the id to use in input or label or similiar to be used in options screen

string get_options_name($name $name)

Get the name to use in input or label or similiar to be used in options screen

get_class_name(string $class)

Return a classname prefixed with simple fields and our field type, to be used in edit post screen Use this to generate class names to make sure they don't collide with other class names in WordPress (from other plugins for example)

return_values($values = null, $parsed_options_for_this_field = null)

Possibly modify values before returning them Used from functions simplefieldsvalue and simplefieldsvalues $values is an array beginning at 0, for each field, so loop to change all your values (there are several if using repeatable)

Details

at line 22
public __construct()

at line 31
public string options_output($existing_vals = array())

Output on options screen

Parameters

$existing_vals

Return Value

string

at line 34
public options_save()

at line 46
public string edit_output($saved_value, $options)

Output fields and stuff on post edit page This is the output a regular user will see

Parameters

$saved_value
$options

Return Value

string

at line 62
public mixed, edit_save(array $values = NULL)

Called when saving fields, i.e.

when clicking the Publish-button on a edit post screen Was is returned from this method will be what is saved in the database, so this is the place to change from array (the default) to for example a single string value that is good for sorting.

Override this in the fields class to modify the value being saved.

Parameters

array $values The values that we receive from the post screen. It's the same names as the ones that has been added with $this->getoptionsname()

Return Value

mixed, array or string of values to save in db

at line 71
public set_options_base_id(string $string)

Sets the base for the generation of input ids in options screen Called by options screen.

Parameters

string $string

at line 80
public set_options_base_name($string)

Sets the base for the generation of input names in options screen Called by options screen.

Parameters

$string

at line 89
public string get_options_id($name $name)

Get the id to use in input or label or similiar to be used in options screen

Parameters

$name $name a-z

Return Value

string

at line 98
public string get_options_name($name $name)

Get the name to use in input or label or similiar to be used in options screen

Parameters

$name $name a-z

Return Value

string

at line 107
public get_class_name(string $class)

Return a classname prefixed with simple fields and our field type, to be used in edit post screen Use this to generate class names to make sure they don't collide with other class names in WordPress (from other plugins for example)

Parameters

string $class Name of class to append

at line 120
public return_values($values = null, $parsed_options_for_this_field = null)

Possibly modify values before returning them Used from functions simplefieldsvalue and simplefieldsvalues $values is an array beginning at 0, for each field, so loop to change all your values (there are several if using repeatable)

Parameters

$values
$parsed_options_for_this_field