Class WPDA_Simple_Form_Item_Media

Handles a database column of type media.

package WPDataAccess\Simple_Form
inherited_from \WPDataAccess\Simple_Form\WPDA_Simple_Form_Item_Media

 Methods

WPDA_Simple_Form_Item_Video constructor.

__construct(array $args = array()

Declare item with all its properties.

inherited_from \WPDataAccess\Simple_Form\WPDA_Simple_Form_Item_Media::__construct()

Parameters

$args

array

WPDA_Simple_Form_Item constructor

__construct(array $args = array()
Inherited

Declare item with all its properties.

since 1.0.0

Parameters

$args

array

[

'item_name' => item name

'data_type' => data type

'item_label' => label

'item_value' => value (in database)

'item_default_value' => default value

'item_extra' => check column extra in information_schema.columns

'item_enum' => enum (if applicable)

'item_enum_options' => enum options (if applicable)

'column_type' => type

'item_event' => JS event(s)

'item_js' => JS code (global)

'item_hide_icon' => icon (showing data type)

'item_class' => css class

'hide_item' => item visibility

'is_nullable' => allow null values?

'is_key_column' => is key column?

].

Get column type

get_column_type() : string
Inherited
since 1.0.0

Returns

string

Get item data type

get_data_type() : string
Inherited
since 1.0.0

Returns

string

Get item visibility

get_hide_item() : boolean
Inherited
since 1.6.9

Returns

boolean

Get item CSS class

get_item_class() : string
Inherited
since 1.0.0

Returns

string

Get item default value

get_item_default_value() : mixed
Inherited
since 1.0.0

Returns

mixed

Get enum values or empty

get_item_enum() : array
Inherited
since 1.0.0

Returns

array

Get enum options or empty

get_item_enum_options() : array
Inherited
since 1.6.9

Returns

array

Get item event

get_item_event() : String
Inherited
since 1.0.0

Returns

String

Get item 'extra' info

get_item_extra() : mixed
Inherited

Hide icon?

get_item_hide_icon() : boolean
Inherited
since 1.0.0

Returns

boolean

Get item Javascript code

get_item_js() : mixed
Inherited
since 1.0.0

Returns

mixed

Get item label

get_item_label() : string
Inherited
since 1.0.0

Returns

string

Het item name

get_item_name() : string
Inherited
since 1.0.0

Returns

string

Get item value

get_item_value() : mixed
Inherited
since 1.0.0

Returns

mixed

Null values allowed?

is_key_column() : boolean
Inherited
since 2.0.0

Returns

boolean

Null values allowed?

is_nullable() : boolean
Inherited
since 2.0.0

Returns

boolean

Check if item is valid

is_valid($pre_insert = false) : boolean
Inherited

Parameters

$pre_insert

Returns

boolean

Set item data_type

set_data_type(string $data_type) 
Inherited
since 1.6.9

Parameters

$data_type

string

Item data type

Set item enum

set_enum(string $item_enum) 
Inherited
since 1.6.9

Parameters

$item_enum

string

Item enum value list

Set item enum options

set_enum_options(string $item_enum_options) 
Inherited
since 1.6.9

Parameters

$item_enum_options

string

Item enum option list

Set item visibility

set_hide_item(boolean $hide_item) 
Inherited
since 1.6.9

Parameters

$hide_item

boolean

TRUE = hide item

Set item is key column

set_is_key_column(boolean $is_key_column) 
Inherited

Parameters

$is_key_column

boolean

TRUE|FALSE

Set item CSS class

set_item_class(string $item_class) 
Inherited
since 1.6.2

Parameters

$item_class

string

HTML class name

Set item default value

set_item_default_value(string $item_default_value) 
Inherited
since 1.6.2

Parameters

$item_default_value

string

Default value

Set item visibility

set_item_hide_icon(boolean $item_hide_icon) 
Inherited
since 2.0.8

Parameters

$item_hide_icon

boolean

TRUE = hide type icon behind text field

Set item js code

set_item_js(string $item_js) 
Inherited
since 1.6.9

Parameters

$item_js

string

Item specific javascript code

Item value

set_item_value(string $value) 
Inherited

Parameters

$value

string

Item value

Item label

set_label(string $label) 
Inherited

Parameters

$label

string

Item label

Show item row

show(string $action, string $update_keys_allowed) 
Inherited

Parameters

$action

string

Requested action

$update_keys_allowed

string

TRUE = allow key updates

Uses the media id to the media

show_item_media() 

Overwrite this method for every new media item.

inherited_from \WPDataAccess\Simple_Form\WPDA_Simple_Form_Item_Media::show_item_media()

Adds media library interaction to media item

add_media_library_interaction() 
Inherited

This method: (1) Adds a hidden item holding the media id(s). (2) Adds an upload button to start the interaction with the media library. (3) Adds a remove button to remove the media. (4) Adds a JS function which implements the selection of media in the media library. Uses the hidden media item to select media. (5) Adds a JS function which removes the media. Uses the hidden media item to remove the media. (6) Adds an on click event to the button previously created. Opens the WordPress media library and selects the media id(s) taken from the hidden media item.

All created items have uniques names to prevent issues between them.

If you change this method all media items will be affected!

Uses the selected media id(s) to update the table media column

add_media_library_selection() 
Inherited

Overwrite this method for every new media item.

Displays default text item

show_item() 
Inherited

Overwrite this method to define specific item processing like enum, set, image and so on.

Uses the media id to the media

show_item_media() 
Inherited

Overwrite this method for every new media item.

 Properties

 

Database column type

$column_type : string

Default

Column type offers more info than data type, like column length or values for enum types.

 

MySQL data type

$data_type : string

Default

 

TRUE = item not shown, FALSE = item shown

$hide_item : boolean

Default

 

TRUE = is auto_increment column

$is_auto_increment : boolean

Default

false
 

TRUE = column is part of primary key, FALSE = column is not part of primary key

$is_key_column : boolean

Default

 

TRUE = null values are allowed, FALSE = no null values allowed

$is_nullable : boolean

Default

 

Item CSS class

$item_class : string

Default

 

Default value

$item_default_value : mixed

Default

 

Enum values for column or empty

$item_enum : array

Default

 

Enum options for column or empty

$item_enum_options : array

Default

 

Array of events

$item_event : array

Default

Add event to item for example: ["onclick" => "check_item_value()"]

 

Database column specific info

$item_extra : string

Default

Like auto_increment, on update, etc

 

Show item icon (data type)

$item_hide_icon : boolean

Default

TRUE = icon is shown after item, FALSE = hide icon (default FALSE)

 

Icon type

$item_icon_type : string

Default

 

Item specific Javascript code

$item_js : string

Default

Code is added to the end of the form.

 

Item label

$item_label : string

Default

 

Database column name

$item_name : string

Default

 

Item placeholder

$item_placeholder : string

Default

''
 

Current column value in the database

$item_value : mixed

Default

 

$media_frame_button

$media_frame_button 

Default

 

$media_frame_remove

$media_frame_remove 

Default

 

$media_frame_title

$media_frame_title 

Default

 

$media_types

$media_types 

Default

''
 

Context variable to keep logic for showing items maintainable

$show_context_action : string

Default

 

Context variable to keep logic for showing items maintainable

$show_context_class_primary_key : string

Default

 

Context variable to keep logic for showing items maintainable

$show_context_column_value : string

Default

 

Context variable to keep logic for showing items maintainable

$show_context_item_events : string

Default

 

Context variable to keep logic for showing items maintainable

$show_context_update_keys_allowed : string

Default