PHP Class Papi_Core_Property, papi

Datei anzeigen Open project: wp-papi/papi Class Usage Examples

Public Properties

Property Type Description
$convert_type string The convert type.
$default_value null Default value.
$tab boolean Determine if is in a tab.

Protected Properties

Property Type Description
$conditional Papi_Core_Conditional The conditional class.
$default_import_settings array Default import settings.
$default_options array Default options.
$display boolean Display the property in WordPress admin.
$options stdClass Current property options object.
$post_id integer The post id.
$slug_required boolean Determine if the property require a slug or not.
$store Papi_Core_Meta_Store The store that the property works with to get data.

Public Methods

Method Description
__construct ( ) The constructor.
__get ( string $key ) : mixed Get option value dynamic.
__isset ( string $key ) : boolean Check if options value exists or not.
__set ( string $key, mixed $value ) Set options value dynamic.
__toString ( ) : string Get a string representation of the object.
current_user_can ( ) : boolean Determine if the current user has capabilities rights.
delete_value ( string $slug, integer $post_id, string $type ) : boolean Delete value from the database.
disabled ( ) : boolean Determine if the property is disabled or not.
display ( ) : boolean Determine if the property should be displayed.
factory ( ) : null | object Create a new instance of the given type or a empty core property if no type is given.
format_value ( mixed $value, string $slug, integer $post_id ) : mixed Format the value of the property before it's returned to WordPress admin or the site.
get_child_properties ( ) : array Get child properties from items in the settings array.
get_child_property ( string $slug, array $items = [] ) : Papi_Core_Property | null Get child property.
get_convert_type ( ) : string Get convert type.
get_default_settings ( ) : array Get default settings.
get_import_settings ( ) : array Get import settings.
get_meta_type ( ) : string Get meta type from the store or the default one.
get_option ( string $key ) : mixed Get option value.
get_options ( ) : stdClass Get the current property options object.
get_post_id ( ) : integer Get post id.
get_rules ( ) : array Get conditional rules.
get_setting ( string $key, mixed $default = null ) : stdClass Get setting value.
get_settings ( ) : stdClass Get custom property settings.
get_slug ( boolean $remove_prefix = false ) : string Get property slug.
get_store ( ) : Papi_Core_Meta_Store | null Get the store that the property will get data from.
get_value ( ) : mixed Get value, no database connections here.
html_id ( object | string $suffix = '', integer $row = null ) : string Get the html id attribute value.
html_name ( array | object $sub_property = null, integer $row = null ) : string Get html name for property with or without sub property and row number.
import_setting ( string $key, mixed $default = null ) : mixed Get the import settings.
import_settings ( ) : object Get the import settings.
import_value ( mixed $value, string $slug, integer $post_id ) : mixed Import value to the property.
load_value ( mixed $value, string $slug, integer $post_id ) : mixed Change value after it's loaded from the database.
match_slug ( string $slug ) : boolean Match property slug with given slug value.
register ( string $type = 'post' ) : boolean Register property with:
register_meta_sanitize_callback ( mixed $value ) : mixed No need for this in Papi, since this is handle different.
render_ajax_request ( ) Render AJAX request.
render_is_allowed_by_rules ( array $rules = [] ) : boolean Check if the property is allowed to render by the conditional rules.
rest_prepare_value ( mixed $value ) : mixed Prepare property value for REST API response.
set_option ( string $key, mixed $value ) Set property option value.
set_options ( array | object $options = [] ) Set the current property options object.
set_post_id ( integer $post_id ) Set post id.
set_setting ( string $key, mixed $value ) Set property setting value.
set_store ( Papi_Core_Meta_Store $store ) Set the store that the property will get data from.
update_value ( mixed $value, string $slug, integer $post_id ) : mixed Update value before it's saved to the database.

Protected Methods

Method Description
prepare_value ( mixed $value ) : mixed Prepare value before database.
setup_actions ( ) Setup actions.
setup_filters ( ) Setup filters.
setup_options ( mixed $options = [] ) : mixed Setup property options.
setup_options_settings ( stdClass $options ) : stdClass Setup options settings.
setup_options_slug ( stdClass $options ) : string Setup options slug.
setup_properties ( ) Setup properties.

Method Details

__construct() public method

The constructor.
public __construct ( )

__get() public method

Get option value dynamic.
public __get ( string $key ) : mixed
$key string
return mixed

__isset() public method

Check if options value exists or not.
public __isset ( string $key ) : boolean
$key string
return boolean

__set() public method

Set options value dynamic.
public __set ( string $key, mixed $value )
$key string
$value mixed

__toString() public method

Get a string representation of the object.
public __toString ( ) : string
return string

current_user_can() public method

Determine if the current user has capabilities rights.
public current_user_can ( ) : boolean
return boolean

delete_value() public method

Delete value from the database.
public delete_value ( string $slug, integer $post_id, string $type ) : boolean
$slug string
$post_id integer
$type string
return boolean

disabled() public method

Determine if the property is disabled or not.
public disabled ( ) : boolean
return boolean

display() public method

Determine if the property should be displayed.
public display ( ) : boolean
return boolean

factory() public static method

Create a new instance of the given type or a empty core property if no type is given.
public static factory ( ) : null | object
return null | object

format_value() public method

Format the value of the property before it's returned to WordPress admin or the site.
public format_value ( mixed $value, string $slug, integer $post_id ) : mixed
$value mixed
$slug string
$post_id integer
return mixed

get_child_properties() public method

Get child properties from items in the settings array.
public get_child_properties ( ) : array
return array

get_child_property() public method

Get child property.
public get_child_property ( string $slug, array $items = [] ) : Papi_Core_Property | null
$slug string
$items array
return Papi_Core_Property | null

get_convert_type() public method

Get convert type.
public get_convert_type ( ) : string
return string

get_default_settings() public method

Get default settings.
public get_default_settings ( ) : array
return array

get_import_settings() public method

Get import settings.
public get_import_settings ( ) : array
return array

get_meta_type() public method

Get meta type from the store or the default one.
public get_meta_type ( ) : string
return string

get_option() public method

Get option value.
public get_option ( string $key ) : mixed
$key string
return mixed

get_options() public method

Get the current property options object.
public get_options ( ) : stdClass
return stdClass

get_post_id() public method

Get post id.
public get_post_id ( ) : integer
return integer

get_rules() public method

Get conditional rules.
public get_rules ( ) : array
return array

get_setting() public method

Get setting value.
public get_setting ( string $key, mixed $default = null ) : stdClass
$key string
$default mixed
return stdClass

get_settings() public method

Get custom property settings.
public get_settings ( ) : stdClass
return stdClass

get_slug() public method

Get property slug.
public get_slug ( boolean $remove_prefix = false ) : string
$remove_prefix boolean
return string

get_store() public method

Get the store that the property will get data from.
public get_store ( ) : Papi_Core_Meta_Store | null
return Papi_Core_Meta_Store | null

get_value() public method

Get value, no database connections here.
public get_value ( ) : mixed
return mixed

html_id() public method

Get the html id attribute value.
public html_id ( object | string $suffix = '', integer $row = null ) : string
$suffix object | string
$row integer
return string

html_name() public method

Get html name for property with or without sub property and row number.
public html_name ( array | object $sub_property = null, integer $row = null ) : string
$sub_property array | object
$row integer
return string

import_setting() public method

Get the import settings.
public import_setting ( string $key, mixed $default = null ) : mixed
$key string
$default mixed
return mixed

import_settings() public method

Get the import settings.
public import_settings ( ) : object
return object

import_value() public method

Import value to the property.
public import_value ( mixed $value, string $slug, integer $post_id ) : mixed
$value mixed
$slug string
$post_id integer
return mixed

load_value() public method

Change value after it's loaded from the database.
public load_value ( mixed $value, string $slug, integer $post_id ) : mixed
$value mixed
$slug string
$post_id integer
return mixed

match_slug() public method

Match property slug with given slug value.
public match_slug ( string $slug ) : boolean
$slug string
return boolean

prepare_value() protected method

Prepare value before database.
protected prepare_value ( mixed $value ) : mixed
$value mixed
return mixed

register() public method

- register_meta (WP 4.6+)
public register ( string $type = 'post' ) : boolean
$type string
return boolean

register_meta_sanitize_callback() public method

No need for this in Papi, since this is handle different.
public register_meta_sanitize_callback ( mixed $value ) : mixed
$value mixed
return mixed

render_ajax_request() public method

Render AJAX request.
public render_ajax_request ( )

render_is_allowed_by_rules() public method

Check if the property is allowed to render by the conditional rules.
public render_is_allowed_by_rules ( array $rules = [] ) : boolean
$rules array
return boolean

rest_prepare_value() public method

Prepare property value for REST API response.
public rest_prepare_value ( mixed $value ) : mixed
$value mixed
return mixed

set_option() public method

Set property option value.
public set_option ( string $key, mixed $value )
$key string
$value mixed

set_options() public method

Set the current property options object.
public set_options ( array | object $options = [] )
$options array | object

set_post_id() public method

Set post id.
public set_post_id ( integer $post_id )
$post_id integer

set_setting() public method

Set property setting value.
public set_setting ( string $key, mixed $value )
$key string
$value mixed

set_store() public method

Set the store that the property will get data from.
public set_store ( Papi_Core_Meta_Store $store )
$store Papi_Core_Meta_Store

setup_actions() protected method

Setup actions.
protected setup_actions ( )

setup_filters() protected method

Setup filters.
protected setup_filters ( )

setup_options() protected method

Setup property options.
protected setup_options ( mixed $options = [] ) : mixed
$options mixed
return mixed

setup_options_settings() protected method

Setup options settings.
protected setup_options_settings ( stdClass $options ) : stdClass
$options stdClass
return stdClass

setup_options_slug() protected method

Setup options slug.
protected setup_options_slug ( stdClass $options ) : string
$options stdClass
return string

setup_properties() protected method

Setup properties.
protected setup_properties ( )

update_value() public method

Update value before it's saved to the database.
public update_value ( mixed $value, string $slug, integer $post_id ) : mixed
$value mixed
$slug string
$post_id integer
return mixed

Property Details

$conditional protected_oe property

The conditional class.
protected Papi_Core_Conditional $conditional
return Papi_Core_Conditional

$convert_type public_oe property

The convert type.
public string $convert_type
return string

$default_import_settings protected_oe property

Default import settings.
protected array $default_import_settings
return array

$default_options protected_oe property

Default options.
protected array $default_options
return array

$default_value public_oe property

Default value.
public null $default_value
return null

$display protected_oe property

Display the property in WordPress admin.
protected bool $display
return boolean

$options protected_oe property

Current property options object.
protected stdClass $options
return stdClass

$post_id protected_oe property

The post id.
protected int $post_id
return integer

$slug_required protected_oe property

Determine if the property require a slug or not.
protected bool $slug_required
return boolean

$store protected_oe property

The store that the property works with to get data.
protected Papi_Core_Meta_Store $store
return Papi_Core_Meta_Store

$tab public_oe property

Determine if is in a tab.
public bool $tab
return boolean