class Fieldmanager_Context_Page extends Fieldmanager_Context (View source)

deprecated 1.2.0

Use Fieldmanager on the public-facing theme.

Properties

Fieldmanager_Field $fm

The base field associated with this context.

from  Fieldmanager_Context
string $uniqid

Unique ID of the form. Used for forms that are not built into WordPress.

from  Fieldmanager_Context
array $save_keys

Store the meta keys this field saves to, to catch naming conflicts.

from  Fieldmanager_Context
static array $forms

Array of contexts for rendering forms.

bool $did_save

Was the form saved?

Methods

__construct(string $uniqid, Fieldmanager_Field $fm)

Create page context handler.

string
nonce_key()

Get the nonce key for this field.

array
refresh_nonce(array $response)

Include a fresh nonce for this field in a response with refreshed nonces.

bool
is_valid_nonce()

Check if the nonce is valid. Returns false if the nonce is missing and throws an exception if it's invalid. If all goes well, returns true.

mixed
prepare_data(mixed $old_value = null, mixed $new_value = null, object $fm = null)

Prepare the data for saving.

string
render_field(array $args = array())

Render the field.

save_page_form()

Action to save the form.

render_page_form()

Output HTML for the form.

get_form(string $uniqid)

Get a form by ID, used for rendering.

Details

__construct(string $uniqid, Fieldmanager_Field $fm)

Create page context handler.

Parameters

string $uniqid

Unique form ID.

Fieldmanager_Field $fm

The field instance.

protected string nonce_key()

Get the nonce key for this field.

Return Value

string

array refresh_nonce(array $response)

Since: 1.3.0

Include a fresh nonce for this field in a response with refreshed nonces.

Parameters

array $response

Response data.

Return Value

array

Updated response data.

protected bool is_valid_nonce()

Check if the nonce is valid. Returns false if the nonce is missing and throws an exception if it's invalid. If all goes well, returns true.

Return Value

bool

protected mixed prepare_data(mixed $old_value = null, mixed $new_value = null, object $fm = null)

Prepare the data for saving.

Parameters

mixed $old_value

Optional. The previous value.

mixed $new_value

Optional. The new value for the field.

object $fm

Optional. The Fieldmanager_Field to prepare.

Return Value

mixed

The filtered and sanitized value, safe to save.

protected string render_field(array $args = array())

Render the field.

Parameters

array $args

{ Optional. Arguments to adjust the rendering behavior.

@type mixed $data The existing data to display with the field. If
                  absent, data will be loaded using
                  Fieldmanager_Context::_load().
@type boolean $echo Output if true, return if false. Default is true.

}

Return Value

string

if $args['echo'] == false.

save_page_form()

Action to save the form.

render_page_form()

Output HTML for the form.

static Fieldmanager_Context_Page get_form(string $uniqid)

Get a form by ID, used for rendering.

Parameters

string $uniqid

Unique form ID.

Return Value

Fieldmanager_Context_Page

The page form.