PHP Class PodsAPI, pods

Show file Open project: pods-framework/pods Class Usage Examples

Public Properties

Property Type Description
$display_errors boolean
$fields
$format
$instance PodsAPI
$instances PodsAPI
$pod
$pod_data array | boolean | mixed | null | void
$pod_id

Public Methods

Method Description
__call ( $name, $args ) Handle methods that have been deprecated
__construct ( string $pod = null, string $format = null ) : PodsAPI Store and retrieve data programatically
__get ( $name ) Handle variables that have been deprecated
add_pod ( array $params ) : boolean | integer
cache_flush_pods ( array $pod = null ) : void Clear Pod-related cache
csv_to_php ( string $data, $delimiter = ',' ) : array Convert CSV to a PHP array
delete_field ( array $params, boolean $table_operation = true ) : boolean Drop a field within a Pod
delete_helper ( array $params ) : boolean
delete_object ( array | object $params ) : boolean Drop a Pod Object
delete_object_from_relationships ( integer $id, $object, string $name = null ) : boolean Delete an object from tableless fields
delete_page ( array $params ) : boolean
delete_pod ( array $params, boolean $strict = false, boolean $delete_all = false ) : boolean Delete a Pod and all its content
delete_pod_item ( array $params, boolean $wp = true ) : boolean Drop a single pod item
delete_relationships ( integer | array $related_id, integer | array $id, array $related_pod, array $related_field ) : void Delete relationships
delete_template ( array $params ) : boolean
delete_wp_object ( string $object_type, integer $id, boolean $force_delete = true ) : boolean | mixed Delete a WP object
detect_pod_field_from_sql_data_type ( string $sql_field ) : string Takes a sql field such as tinyint and returns the pods field type, such as num.
duplicate_field ( array $params, boolean $strict = false ) : integer Duplicate a Field
duplicate_pod ( array $params, boolean $strict = false ) : integer Duplicate a Pod
duplicate_pod_item ( array $params ) : integer
export ( string | object $pod = null, array $params = null ) : array Export data from a Pod
export_package ( array $params ) : array | boolean Export a package
export_pod_item ( array $params, object $pod = null ) : integer
field_exists ( array $params ) : boolean Check if a Pod's field exists
get_changed_fields ( array $pieces ) : array Get the fields that have changed during a save
get_current_language ( ) : array Get current language information from Multilingual plugins
get_field_types ( ) : array Gets all field types
get_pod_type_count ( string $type ) : integer Get number of pods for a specific pod type
get_table_info ( string $object_type, string $object, null $name = null, array $pod = null, array $field = null ) : array | boolean Get information about an objects MySQL table
get_table_info_load ( $object_type, string $object, null $name = null, array $pod = null ) : array Load the information about an objects MySQL table
get_wp_object_fields ( string $object = 'post_type', array $pod = null, boolean $refresh = false ) : array Get a list of core WP object fields for a specific object
handle_field_validation ( mixed &$value, string $field, array $object_fields, array $fields, array | Pods $pod, array | object $params ) : array | boolean
import ( mixed $import_data, boolean $numeric_mode = false, string $format = null ) : array Import data from an array or a CSV file.
import_package ( mixed $data = false, boolean $replace = false ) : boolean Import a package
init ( string $pod = null, string $format = null ) : PodsAPI Singleton-ish handling for a basic pods_api() request
load_field ( array $params, boolean $strict = false ) : array | boolean Load a field
load_fields ( array $params, boolean $strict = false ) : array Load fields by Pod, ID, Name, and/or Type
load_helper ( array $params ) : array | boolean
load_helpers ( array $params = null ) : array
load_object ( array | object $params, boolean $strict = false ) : array | boolean Load a Pods Object
load_objects ( array | object $params ) : array Load Multiple Pods Objects
load_page ( array $params ) : array | boolean
load_pages ( array $params = null ) : array
load_pod ( array | object $params, boolean $strict = true ) : array | boolean | mixed | void Load a Pod and all of its fields
load_pod_item ( array $params ) : boolean | Pods Load the pod item object
load_pods ( array $params = null ) : array | mixed Load a list of Pods based on filters specified.
load_sister_fields ( array $params, array $pod = null ) : array | boolean Load potential sister fields for a specific field
load_template ( array $params ) : array | boolean
load_templates ( array $params = null ) : array
lookup_related_items ( integer $field_id, integer $pod_id, mixed $ids, array $field = null, array $pod = null ) : array Find items related to a parent field
lookup_related_items_from ( integer $field_id, integer $pod_id, integer $id, array $field = null, array $pod = null ) : array | boolean Find related items related to an item
pod_exists ( array $params, $type = null ) : boolean Check if a Pod exists
process_form ( mixed $params, object $obj = null, array $fields = null, string $thank_you = null ) : mixed Process a Pod-based form
rename_wp_object_type ( string $object_type, string $old_name, string $new_name ) : boolean Rename a WP object's type
reorder_pod_item ( array $params ) : boolean Reorder a Pod
replace_package ( mixed $data = false ) : boolean Replace an existing package
reset_pod ( array $params, array $pod = false ) : boolean Delete all content for a Pod
save_comment ( array $comment_data, array $comment_meta = null, boolean $strict = false, boolean $sanitized = false, array $fields = [] ) : integer Save a comment and it's meta
save_comment_meta ( integer $id, array $comment_meta = null, boolean $strict = false, array $fields = [] ) : integer Save a comment meta
save_field ( array $params, boolean $table_operation = true, boolean $sanitized = false, boolean | integer $db = true ) : integer | array Add or edit a field within a Pod
save_helper ( array $params, boolean $sanitized = false ) : integer
save_object ( array | object $params, boolean $sanitized = false ) : integer Add or Edit a Pods Object
save_page ( array | object $params, boolean $sanitized = false ) : integer
save_pod ( array $params, boolean $sanitized = false, boolean | integer $db = true ) : integer Add or edit a Pod
save_pod_item ( array | object $params ) : integer Add or edit a single pod item
save_pod_items ( array | object $params, array $data ) : integer
save_post ( array $post_data, array $post_meta = null, boolean $strict = false, boolean $sanitized = false, array $fields = [] ) : mixed | void Save a post and it's meta
save_post_meta ( integer $id, array $post_meta = null, boolean $strict = false, array $fields = [] ) : integer Save a post's meta
save_relationships ( integer $id, $related_ids, array $pod, array $field ) Save relationships
save_setting ( string $setting, array $option_data, boolean $sanitized = false ) : boolean Save a set of options
save_slug_fix ( string $slug, integer $post_ID, string $post_status, string $post_type, integer $post_parent, string $original_slug = null ) : string Fix Pod / Field post_name to ensure they are exactly as saved (allow multiple posts w/ same post_name)
save_template ( array | object $params, boolean $sanitized = false ) : integer
save_term ( array $term_data, array $term_meta, boolean $strict = false, boolean $sanitized = false, array $fields = [] ) : integer Save a taxonomy's term
save_term_meta ( integer $id, array $term_meta = null, boolean $strict = false, array $fields = [] ) : integer Save a term's meta
save_user ( array $user_data, array $user_meta = null, boolean $strict = false, boolean $sanitized = false, array $fields = [] ) : integer Save a user and it's meta
save_user_meta ( integer $id, array $user_meta = null, boolean $strict = false, array $fields = [] ) : integer Save a user meta
save_wp_object ( string $object_type, array $data, array $meta = [], boolean $strict = false, boolean $sanitized = false, array $fields = [] ) : boolean | mixed Save a WP object and its meta
validate_package ( array | string $data = false, boolean $output = false ) : array | boolean Validate a package

Private Methods

Method Description
do_hook ( ) Handle filters / actions for the class
export_pod_item_level ( Pods $pod, array $fields, integer $depth, boolean $flatten = false, integer $current_depth = 1 ) : array Export a pod item by depth level
get_field_definition ( string $type, array $options = null ) : array | boolean | mixed | null Gets the schema definition of a field.

Method Details

__call() public method

Handle methods that have been deprecated
Since: 2.0
public __call ( $name, $args )

__construct() public method

Store and retrieve data programatically
Since: 1.7.1
public __construct ( string $pod = null, string $format = null ) : PodsAPI
$pod string (optional) The pod name
$format string (deprecated) Format for import/export, "php" or "csv"
return PodsAPI

__get() public method

Handle variables that have been deprecated
Since: 2.0
public __get ( $name )

add_pod() public method

See also: PodsAPI::save_pod Add a Pod via the Wizard $params['create_extend'] string Create or Extend a Content Type $params['create_pod_type'] string Pod Type (for Creating) $params['create_name'] string Pod Name (for Creating) $params['create_label_plural'] string Plural Label (for Creating) $params['create_label_singular'] string Singular Label (for Creating) $params['create_storage'] string Storage Type (for Creating Post Types) $params['create_storage_taxonomy'] string Storage Type (for Creating Taxonomies) $params['extend_pod_type'] string Pod Type (for Extending) $params['extend_post_type'] string Post Type (for Extending Post Types) $params['extend_taxonomy'] string Taxonomy (for Extending Taxonomies) $params['extend_storage'] string Storage Type (for Extending Post Types / Users / Comments)
Since: 2.0
public add_pod ( array $params ) : boolean | integer
$params array An associative array of parameters
return boolean | integer Pod ID

cache_flush_pods() public method

Clear Pod-related cache
Since: 2.0
public cache_flush_pods ( array $pod = null ) : void
$pod array
return void

csv_to_php() public method

Convert CSV to a PHP array
Deprecation: 2.3.5
Since: 1.7.1
public csv_to_php ( string $data, $delimiter = ',' ) : array
$data string The CSV input
return array

delete_field() public method

$params['id'] int The field ID $params['name'] int The field name $params['pod'] string The Pod name $params['pod_id'] string The Pod name
Since: 1.7.9
public delete_field ( array $params, boolean $table_operation = true ) : boolean
$params array An associative array of parameters
$table_operation boolean Whether or not to handle table operations
return boolean

delete_helper() public method

See also: PodsAPI::delete_object Drop a Pod Helper $params['id'] int The helper ID $params['name'] string The helper name
Since: 1.7.9
public delete_helper ( array $params ) : boolean
$params array An associative array of parameters
return boolean

delete_object() public method

$params['id'] int The object ID $params['name'] string The object name $params['type'] string The object type
Since: 2.0
public delete_object ( array | object $params ) : boolean
$params array | object An associative array of parameters
return boolean

delete_object_from_relationships() public method

Delete an object from tableless fields
Since: 2.3
public delete_object_from_relationships ( integer $id, $object, string $name = null ) : boolean
$id integer
$name string
return boolean

delete_page() public method

See also: PodsAPI::delete_object Drop a Pod Page $params['id'] int The page ID $params['uri'] string The page URI
Since: 1.7.9
public delete_page ( array $params ) : boolean
$params array An associative array of parameters
return boolean

delete_pod() public method

$params['id'] int The Pod ID $params['name'] string The Pod name
Since: 1.7.9
public delete_pod ( array $params, boolean $strict = false, boolean $delete_all = false ) : boolean
$params array An associative array of parameters
$strict boolean (optional) Makes sure a pod exists, if it doesn't throws an error
$delete_all boolean (optional) Whether to delete all content from a WP object
return boolean

delete_pod_item() public method

$params['id'] int (optional) The item's ID from the wp_pod_* table (used with datatype parameter) $params['pod'] string (optional) The Pod name (used with id parameter) $params['pod_id'] int (optional) The Pod ID (used with id parameter) $params['bypass_helpers'] bool Set to true to bypass running pre-save and post-save helpers
Since: 1.7.9
public delete_pod_item ( array $params, boolean $wp = true ) : boolean
$params array An associative array of parameters
$wp boolean Whether to run WP object delete action
return boolean

delete_relationships() public method

Delete relationships
Since: 2.3
public delete_relationships ( integer | array $related_id, integer | array $id, array $related_pod, array $related_field ) : void
$related_id integer | array IDs for items to save
$id integer | array ID or IDs to remove
$related_pod array Pod data
$related_field array Field data
return void

delete_template() public method

See also: PodsAPI::delete_object Drop a Pod Template $params['id'] int The template ID $params['name'] string The template name
Since: 1.7.9
public delete_template ( array $params ) : boolean
$params array An associative array of parameters
return boolean

delete_wp_object() public method

Delete a WP object
Since: 2.0
public delete_wp_object ( string $object_type, integer $id, boolean $force_delete = true ) : boolean | mixed
$object_type string Object type: post|user|comment
$id integer Object ID
$force_delete boolean (optional) Force deletion instead of trashing (post types only)
return boolean | mixed

detect_pod_field_from_sql_data_type() public static method

Takes a sql field such as tinyint and returns the pods field type, such as num.
Since: 2.0
public static detect_pod_field_from_sql_data_type ( string $sql_field ) : string
$sql_field string The SQL field to look for
return string The field type

duplicate_field() public method

$params['pod_id'] int The Pod ID $params['pod'] string The Pod name $params['id'] int The Field ID $params['name'] string The Field name $params['new_name'] string The new Field name
Since: 2.3.10
public duplicate_field ( array $params, boolean $strict = false ) : integer
$params array An associative array of parameters
$strict boolean (optional) Makes sure a field exists, if it doesn't throws an error
return integer New Field ID

duplicate_pod() public method

$params['id'] int The Pod ID $params['name'] string The Pod name $params['new_name'] string The new Pod name
Since: 2.3
public duplicate_pod ( array $params, boolean $strict = false ) : integer
$params array An associative array of parameters
$strict boolean (optional) Makes sure a pod exists, if it doesn't throws an error
return integer New Pod ID

duplicate_pod_item() public method

See also: PodsAPI::save_pod_item Duplicate a pod item $params['pod'] string The Pod name $params['id'] int The item's ID from the wp_pods_* table
Since: 1.12
public duplicate_pod_item ( array $params ) : integer
$params array An associative array of parameters
return integer The table row ID

export() public method

Export data from a Pod
Since: 1.7.1
public export ( string | object $pod = null, array $params = null ) : array
$pod string | object The pod name or Pods object
$params array An associative array of parameters
return array Data arrays of all exported pod items

export_package() public method

$params['pod'] string Pod Type IDs to export $params['template'] string Template IDs to export $params['podpage'] string Pod Page IDs to export $params['helper'] string Helper IDs to export
Deprecation: 2.0
Since: 1.9.0
public export_package ( array $params ) : array | boolean
$params array An associative array of parameters
return array | boolean

export_pod_item() public method

See also: pods() Export a pod item $params['pod'] string The Pod name $params['id'] int The item's ID from the wp_pods_* table $params['fields'] array The fields to export $params['depth'] int How many levels deep to export data
Since: 1.12
public export_pod_item ( array $params, object $pod = null ) : integer
$params array An associative array of parameters
$pod object (optional) Pods object
return integer The table row ID

field_exists() public method

$params['pod_id'] int The Pod ID $params['id'] int The field ID $params['name'] string The field name
Since: 1.12
public field_exists ( array $params ) : boolean
$params array An associative array of parameters
return boolean

get_changed_fields() public method

Get the fields that have changed during a save
public get_changed_fields ( array $pieces ) : array
$pieces array Pieces array from save_pod_item
return array Array of fields and values that have changed

get_current_language() public static method

Get current language information from Multilingual plugins
Since: 2.6.6
public static get_current_language ( ) : array
return array

get_field_types() public method

Gets all field types
Deprecation:
Since: 2.0
public get_field_types ( ) : array
return array Array of field types

get_pod_type_count() public method

Get number of pods for a specific pod type
Since: 2.6.6
public get_pod_type_count ( string $type ) : integer
$type string Type to get count
return integer Total number of pods for a type

get_table_info() public method

Get information about an objects MySQL table
Since: 2.0
public get_table_info ( string $object_type, string $object, null $name = null, array $pod = null, array $field = null ) : array | boolean
$object_type string
$object string The object to look for
$name null (optional) Name of the pod to load
$pod array (optional) Array with pod information
$field array (optional) Array with field information
return array | boolean

get_table_info_load() public method

Load the information about an objects MySQL table
Since: 2.5
public get_table_info_load ( $object_type, string $object, null $name = null, array $pod = null ) : array
$object_type
$object string The object to look for
$name null (optional) Name of the pod to load
$pod array (optional) Array with pod information
return array

get_wp_object_fields() public method

Get a list of core WP object fields for a specific object
Since: 2.0
public get_wp_object_fields ( string $object = 'post_type', array $pod = null, boolean $refresh = false ) : array
$object string The pod type to look for, possible values: post_type, user, comment, taxonomy
$pod array Array of Pod data
$refresh boolean Whether to force refresh the information
return array Array of fields

handle_field_validation() public method

Since: 2.0
public handle_field_validation ( mixed &$value, string $field, array $object_fields, array $fields, array | Pods $pod, array | object $params ) : array | boolean
$value mixed The value to validate
$field string Field to use for validation
$object_fields array Fields of the object we're validating
$fields array Array of all fields data
$pod array | Pods Array of pod data (or Pods object)
$params array | object Extra parameters to pass to the validation function of the field.
return array | boolean

import() public method

Import data from an array or a CSV file.
Since: 1.7.1
public import ( mixed $import_data, boolean $numeric_mode = false, string $format = null ) : array
$import_data mixed PHP associative array or CSV input
$numeric_mode boolean Use IDs instead of the name field when matching
$format string Format of import data, options are php or csv
return array IDs of imported items

import_package() public method

Import a package
Deprecation: 2.0
Since: 1.9.0
public import_package ( mixed $data = false, boolean $replace = false ) : boolean
$data mixed (optional) An associative array containing a package, or the json encoded package
$replace boolean (optional) Replace existing items when found
return boolean

init() public static method

Singleton-ish handling for a basic pods_api() request
Since: 2.3.5
public static init ( string $pod = null, string $format = null ) : PodsAPI
$pod string (optional) The pod name
$format string (deprecated) Format for import/export, "php" or "csv"
return PodsAPI

load_field() public method

$params['pod_id'] int The Pod ID $params['pod'] string The Pod name $params['id'] int The field ID $params['name'] string The field name $params['table_info'] boolean Whether to lookup a pick field's table info
Since: 1.7.9
public load_field ( array $params, boolean $strict = false ) : array | boolean
$params array An associative array of parameters
$strict boolean Whether to require a field exist or not when loading the info
return array | boolean Array with field data, false if field not found

load_fields() public method

$params['pod_id'] int The Pod ID $params['pod'] string The Pod name $params['id'] array The field IDs $params['name'] array The field names $params['type'] array The field types $params['options'] array Field Option(s) key=>value array to filter by $params['where'] string WHERE clause of query
Since: 1.7.9
public load_fields ( array $params, boolean $strict = false ) : array
$params array An associative array of parameters
$strict boolean Whether to require a field exist or not when loading the info
return array Array of field data.

load_helper() public method

See also: PodsAPI::load_object Load a Pod Helper $params['id'] int The helper ID $params['name'] string The helper name
Since: 1.7.9
public load_helper ( array $params ) : array | boolean
$params array An associative array of parameters
return array | boolean

load_helpers() public method

See also: PodsAPI::load_objects Load Multiple Pod Helpers $params['where'] string The WHERE clause of query $params['options'] array Pod Option(s) key=>value array to filter by $params['orderby'] string ORDER BY clause of query $params['limit'] string Number of pages to return
Since: 2.0
public load_helpers ( array $params = null ) : array
$params array (optional) An associative array of parameters
return array

load_object() public method

$params['id'] int The Object ID $params['name'] string The Object name $params['type'] string The Object type
Since: 2.0
public load_object ( array | object $params, boolean $strict = false ) : array | boolean
$params array | object An associative array of parameters
$strict boolean
return array | boolean

load_objects() public method

$params['type'] string The Object type $params['options'] array Pod Option(s) key=>value array to filter by $params['orderby'] string ORDER BY clause of query $params['limit'] string Number of objects to return $params['where'] string WHERE clause of query $params['ids'] string|array IDs of Objects
Since: 2.0
public load_objects ( array | object $params ) : array
$params array | object An associative array of parameters
return array

load_page() public method

See also: PodsAPI::load_object Load a Pod Page $params['id'] int The page ID $params['name'] string The page URI
Since: 1.7.9
public load_page ( array $params ) : array | boolean
$params array An associative array of parameters
return array | boolean

load_pages() public method

See also: PodsAPI::load_objects Load Multiple Pod Pages $params['where'] string The WHERE clause of query $params['options'] array Pod Option(s) key=>value array to filter by $params['orderby'] string ORDER BY clause of query $params['limit'] string Number of pages to return
Since: 2.0
public load_pages ( array $params = null ) : array
$params array (optional) An associative array of parameters
return array

load_pod() public method

$params['id'] int The Pod ID $params['name'] string The Pod name $params['fields'] bool Whether to load fields (default is true)
Since: 1.7.9
public load_pod ( array | object $params, boolean $strict = true ) : array | boolean | mixed | void
$params array | object An associative array of parameters or pod name as a string
$strict boolean Makes sure the pod exists, throws an error if it doesn't work
return array | boolean | mixed | void

load_pod_item() public method

$params['pod'] string The datatype name $params['id'] int (optional) The item's ID
Since: 2.0
public load_pod_item ( array $params ) : boolean | Pods
$params array An associative array of parameters
return boolean | Pods

load_pods() public method

$params['type'] string/array Pod Type(s) to filter by $params['object'] string/array Pod Object(s) to filter by $params['options'] array Pod Option(s) key=>value array to filter by $params['orderby'] string ORDER BY clause of query $params['limit'] string Number of Pods to return $params['where'] string WHERE clause of query $params['ids'] string|array IDs of Objects $params['count'] boolean Return only a count of Pods $params['names'] boolean Return only an array of name => label $params['ids'] boolean Return only an array of ID => label $params['fields'] boolean Return pod fields with Pods (default is true) $params['key_names'] boolean Return pods keyed by name
Since: 2.0
public load_pods ( array $params = null ) : array | mixed
$params array An associative array of parameters
return array | mixed

load_sister_fields() public method

$params['pod'] int The Pod name $params['related_pod'] string The related Pod name
Since: 1.7.9
public load_sister_fields ( array $params, array $pod = null ) : array | boolean
$params array An associative array of parameters
$pod array (optional) Array of Pod data to use (to avoid lookup)
return array | boolean

load_template() public method

See also: PodsAPI::load_object Load a Pod Template $params['id'] int The template ID $params['name'] string The template name
Since: 1.7.9
public load_template ( array $params ) : array | boolean
$params array An associative array of parameters
return array | boolean

load_templates() public method

See also: PodsAPI::load_objects Load Multiple Pod Templates $params['where'] string The WHERE clause of query $params['options'] array Pod Option(s) key=>value array to filter by $params['orderby'] string ORDER BY clause of query $params['limit'] string Number of templates to return
Since: 2.0
public load_templates ( array $params = null ) : array
$params array (optional) An associative array of parameters
return array

pod_exists() public method

$params['id'] int Pod ID $params['name'] string Pod name
Since: 1.12
public pod_exists ( array $params, $type = null ) : boolean
$params array An associative array of parameters
return boolean True if exists

process_form() public method

Process a Pod-based form
Since: 2.0
public process_form ( mixed $params, object $obj = null, array $fields = null, string $thank_you = null ) : mixed
$params mixed
$obj object Pod object
$fields array Fields being submitted in form ( key => settings )
$thank_you string URL to send to upon success
return mixed

rename_wp_object_type() public method

Rename a WP object's type
Since: 2.0
public rename_wp_object_type ( string $object_type, string $old_name, string $new_name ) : boolean
$object_type string Object type: post|taxonomy|comment|setting
$old_name string The old name
$new_name string The new name
return boolean

reorder_pod_item() public method

$params['pod'] string The Pod name $params['field'] string The field name of the field to reorder $params['order'] array The key => value array of items to reorder (key should be an integer)
Since: 1.9.0
public reorder_pod_item ( array $params ) : boolean
$params array An associative array of parameters
return boolean

replace_package() public method

Replace an existing package
Deprecation: 2.0
Since: 1.9.8
public replace_package ( mixed $data = false ) : boolean
$data mixed (optional) An associative array containing a package, or the json encoded package
return boolean

reset_pod() public method

$params['id'] int The Pod ID $params['name'] string The Pod name
Since: 1.9.0
public reset_pod ( array $params, array $pod = false ) : boolean
$params array An associative array of parameters
$pod array Pod data
return boolean

save_comment() public method

Save a comment and it's meta
Since: 2.0
public save_comment ( array $comment_data, array $comment_meta = null, boolean $strict = false, boolean $sanitized = false, array $fields = [] ) : integer
$comment_data array All comment data to be saved (using wp_insert_comment / wp_update_comment)
$comment_meta array (optional) All meta to be saved (set value to null to delete)
$strict boolean (optional) Whether to delete previously saved meta not in $comment_meta
$sanitized boolean (optional) Will unsanitize the data, should be passed if the data is sanitized before sending.
$fields array (optional) The array of fields and their options, for further processing with
return integer Comment ID

save_comment_meta() public method

Save a comment meta
Since: 2.0
public save_comment_meta ( integer $id, array $comment_meta = null, boolean $strict = false, array $fields = [] ) : integer
$id integer Comment ID
$comment_meta array (optional) All meta to be saved (set value to null to delete)
$strict boolean (optional) Whether to delete previously saved meta not in $comment_meta
$fields array (optional) The array of fields and their options, for further processing with
return integer Comment ID

save_field() public method

$params['id'] int Field ID (id OR pod_id+pod+name required) $params['pod_id'] int Pod ID (id OR pod_id+pod+name required) $params['pod'] string Pod name (id OR pod_id+pod+name required) $params['name'] string Field name (id OR pod_id+pod+name required) $params['label'] string (optional) Field label $params['type'] string (optional) Field type (avatar, boolean, code, color, currency, date, datetime, email, file, number, paragraph, password, phone, pick, slug, text, time, website, wysiwyg) $params['pick_object'] string (optional) Related Object (for relationships) $params['pick_val'] string (optional) Related Object name (for relationships) $params['sister_id'] int (optional) Related Field ID (for bidirectional relationships) $params['weight'] int (optional) Order in which the field appears $params['options'] array (optional) Options
Since: 1.7.9
public save_field ( array $params, boolean $table_operation = true, boolean $sanitized = false, boolean | integer $db = true ) : integer | array
$params array An associative array of parameters
$table_operation boolean (optional) Whether or not to handle table operations
$sanitized boolean (optional) Decides wether the params have been sanitized before being passed, will sanitize them if false.
$db boolean | integer (optional) Whether to save into the DB or just return field array.
return integer | array The field ID or field array (if !$db)

save_helper() public method

See also: PodsAPI::save_object Add or edit a Pod Helper $params['id'] int The helper ID $params['name'] string The helper name $params['helper_type'] string The helper type ("pre_save", "display", etc) $params['code'] string The helper code
Since: 1.7.9
public save_helper ( array $params, boolean $sanitized = false ) : integer
$params array An associative array of parameters
$sanitized boolean (optional) Decides wether the params have been sanitized before being passed, will sanitize them if false.
return integer The helper ID

save_object() public method

$params['id'] int The Object ID $params['name'] string The Object name $params['type'] string The Object type $params['options'] Associative array of Object options
Since: 2.0
public save_object ( array | object $params, boolean $sanitized = false ) : integer
$params array | object An associative array of parameters
$sanitized boolean (optional) Decides whether the params have been sanitized before being passed, will sanitize them if false.
return integer The Object ID

save_page() public method

See also: PodsAPI::save_object Add or edit a Pod Page $params['id'] int The page ID $params['name'] string The page URI $params['code'] string The page code
Since: 1.7.9
public save_page ( array | object $params, boolean $sanitized = false ) : integer
$params array | object An associative array of parameters
$sanitized boolean (optional) Decides wether the params have been sanitized before being passed, will sanitize them if false.
return integer The page ID

save_pod() public method

$params['id'] int The Pod ID $params['name'] string The Pod name $params['label'] string The Pod label $params['type'] string The Pod type $params['object'] string The object being extended (if any) $params['storage'] string The Pod storage $params['options'] array Options
Since: 1.7.9
public save_pod ( array $params, boolean $sanitized = false, boolean | integer $db = true ) : integer
$params array An associative array of parameters
$sanitized boolean (optional) Decides whether the params have been sanitized before being passed, will sanitize them if false.
$db boolean | integer (optional) Whether to save into the DB or just return Pod array.
return integer Pod ID

save_pod_item() public method

$params['pod'] string The Pod name (pod or pod_id is required) $params['pod_id'] string The Pod ID (pod or pod_id is required) $params['id'] int The item ID $params['data'] array (optional) Associative array of field names + values $params['bypass_helpers'] bool Set to true to bypass running pre-save and post-save helpers $params['track_changed_fields'] bool Set to true to enable tracking of saved fields via PodsAPI::get_changed_fields()
Since: 1.7.9
public save_pod_item ( array | object $params ) : integer
$params array | object An associative array of parameters
return integer The item ID

save_pod_items() public method

See also: PodsAPI::save_pod_item Add multiple pod items $params['pod'] string The Pod name (pod or pod_id is required) $params['pod_id'] string The Pod ID (pod or pod_id is required) $params['bypass_helpers'] bool Set to true to bypass running pre-save and post-save helpers $data['id'] int The item ID (optional) $data['data'] array An associative array of field names + values
Since: 2.0
public save_pod_items ( array | object $params, array $data ) : integer
$params array | object An associative array of parameters, data excluded
$data array An associative array of pod ids and field names + values (arrays of field data)
return integer The item ID

save_post() public method

Save a post and it's meta
Since: 2.0
public save_post ( array $post_data, array $post_meta = null, boolean $strict = false, boolean $sanitized = false, array $fields = [] ) : mixed | void
$post_data array All post data to be saved (using wp_insert_post / wp_update_post)
$post_meta array (optional) All meta to be saved (set value to null to delete)
$strict boolean (optional) Whether to delete previously saved meta not in $post_meta
$sanitized boolean (optional) Will unsanitize the data, should be passed if the data is sanitized before sending.
$fields array (optional) The array of fields and their options, for further processing with
return mixed | void

save_post_meta() public method

Save a post's meta
Since: 2.0
public save_post_meta ( integer $id, array $post_meta = null, boolean $strict = false, array $fields = [] ) : integer
$id integer Post ID
$post_meta array All meta to be saved (set value to null to delete)
$strict boolean Whether to delete previously saved meta not in $post_meta
$fields array (optional) The array of fields and their options, for further processing with
return integer Id of the post with the meta

save_relationships() public method

Save relationships
public save_relationships ( integer $id, $related_ids, array $pod, array $field )
$id integer ID of item
$pod array Pod data
$field array Field data

save_setting() public method

Save a set of options
Since: 2.3
public save_setting ( string $setting, array $option_data, boolean $sanitized = false ) : boolean
$setting string Setting group name
$option_data array All option data to be saved
$sanitized boolean (optional) Will unsanitize the data, should be passed if the data is sanitized before sending.
return boolean

save_slug_fix() public method

Fix Pod / Field post_name to ensure they are exactly as saved (allow multiple posts w/ same post_name)
Since: 2.3.3
public save_slug_fix ( string $slug, integer $post_ID, string $post_status, string $post_type, integer $post_parent, string $original_slug = null ) : string
$slug string Unique slug value
$post_ID integer Post ID
$post_status string Post Status
$post_type string Post Type
$post_parent integer Post Parent ID
$original_slug string Original slug value
return string Final slug value

save_template() public method

See also: PodsAPI::save_object Add or edit a Pod Template $params['id'] int The template ID $params['name'] string The template name $params['code'] string The template code
Since: 1.7.9
public save_template ( array | object $params, boolean $sanitized = false ) : integer
$params array | object An associative array of parameters
$sanitized boolean (optional) Decides wether the params have been sanitized before being passed, will sanitize them if false.
return integer The Template ID

save_term() public method

Save a taxonomy's term
Since: 2.0
public save_term ( array $term_data, array $term_meta, boolean $strict = false, boolean $sanitized = false, array $fields = [] ) : integer
$term_data array All term data to be saved (using wp_insert_term / wp_update_term)
$term_meta array All meta to be saved (set value to null to delete)
$strict boolean (optional) Whether to delete previously saved meta not in $post_meta
$sanitized boolean (optional) Will unsanitize the data, should be passed if the data is sanitized before sending.
$fields array (optional) The array of fields and their options, for further processing with
return integer Term ID

save_term_meta() public method

Save a term's meta
Since: 2.0
public save_term_meta ( integer $id, array $term_meta = null, boolean $strict = false, array $fields = [] ) : integer
$id integer Term ID
$term_meta array All meta to be saved (set value to null to delete)
$strict boolean Whether to delete previously saved meta not in $term_meta
$fields array (optional) The array of fields and their options, for further processing with
return integer Id of the term with the meta

save_user() public method

Save a user and it's meta
Since: 2.0
public save_user ( array $user_data, array $user_meta = null, boolean $strict = false, boolean $sanitized = false, array $fields = [] ) : integer
$user_data array All user data to be saved (using wp_insert_user / wp_update_user)
$user_meta array (optional) All meta to be saved (set value to null to delete)
$strict boolean (optional) Whether to delete previously saved meta not in $user_meta
$sanitized boolean (optional) Will unsanitize the data, should be passed if the data is sanitized before sending.
$fields array (optional) The array of fields and their options, for further processing with
return integer Returns user id on success

save_user_meta() public method

Save a user meta
Since: 2.0
public save_user_meta ( integer $id, array $user_meta = null, boolean $strict = false, array $fields = [] ) : integer
$id integer User ID
$user_meta array (optional) All meta to be saved (set value to null to delete)
$strict boolean (optional) Whether to delete previously saved meta not in $user_meta
$fields array (optional) The array of fields and their options, for further processing with
return integer User ID

save_wp_object() public method

Save a WP object and its meta
Since: 2.0
public save_wp_object ( string $object_type, array $data, array $meta = [], boolean $strict = false, boolean $sanitized = false, array $fields = [] ) : boolean | mixed
$object_type string Object type: post|taxonomy|user|comment|setting
$data array All post data to be saved
$meta array (optional) Associative array of meta keys and values
$strict boolean (optional) Decides whether the previous saved meta should be deleted or not
$sanitized boolean (optional) Will unsanitize the data, should be passed if the data is sanitized before sending.
$fields array (optional) The array of fields and their options, for further processing with
return boolean | mixed

validate_package() public method

Validate a package
Deprecation: 2.0
Since: 1.9.0
public validate_package ( array | string $data = false, boolean $output = false ) : array | boolean
$data array | string (optional) An associative array containing a package, or the json encoded package
$output boolean (optional)
return array | boolean

Property Details

$display_errors public property

public bool $display_errors
return boolean

$fields public property

public $fields

$format public property

Deprecation: 2.0
public $format

$instance static public property

static public PodsAPI $instance
return PodsAPI

$instances static public property

PodsAPI
static public $instances

$pod public property

public $pod

$pod_data public property

public array|bool|mixed|null|void $pod_data
return array | boolean | mixed | null | void

$pod_id public property

public $pod_id