PHP Class Pods, pods

Inheritance: implements Iterator
Afficher le fichier Open project: pods-framework/pods Class Usage Examples

Méthodes publiques

Свойство Type Description
$alt_data PodsData
$api PodsAPI
$body_classes
$data PodsData
$datatype
$datatype_id
$deprecated
$detail_page string
$display_errors boolean
$fields array
$filters array
$id integer
$limit integer
$meta
$meta_extra
$meta_properties
$offset integer
$page integer | mixed
$page_template SEO related vars for Pod Pages
$page_var string
$pagination boolean
$params array
$pod string
$pod_data array | boolean | mixed | null | void
$pod_id integer
$row Current pod item array
$row_override Override pod item array
$rows Array of pod item arrays
$search boolean
$search_mode string
$search_var string
$sql Last SQL query used by a find()
$total integer
$total_found integer
$ui array

Méthodes publiques

Méthode Description
__call ( $name, $args ) : mixed Handle methods that have been deprecated and any aliasing
__construct ( string $pod = null, mixed $id = null ) : Pods Constructor - Pods Framework core
__get ( $name ) : mixed Handle variables that have been deprecated and PodsData vars
add ( array | string $data = null, mixed $value = null ) : integer Add an item to a Pod by giving an array of field data or set a specific field to a specific value if you're just wanting to add a new item but only set one field.
add_to ( string $field, mixed $value, integer $id = null ) : integer Add an item to the values of a relationship field, add a value to a number field (field+1), add time to a date field, or add text to a text field
current ( ) : mixed | boolean Get current Iterator row
data ( ) : array | boolean Return an array of all rows returned from a find() call.
delete ( integer $id = null ) : boolean Delete an item
display ( string | array $name, boolean $single = null ) : string | null | false Return the output for a field. If you want the raw value for use in PHP for custom manipulation, you will want to use field() instead. This function will automatically convert arrays into a list of text such as "Rick, John, and Gary"
do_magic_tags ( string $code ) : string Replace magic tags with their values
duplicate ( integer $id = null ) : integer | boolean Duplicate an item
exists ( ) : boolean Whether a Pod item exists or not when using fetch() or construct with an ID or slug
export ( array $fields = null, integer $id = null, $format = null ) : array | boolean Export an item's data
export_data ( array $params = null ) : array Export data from all items
fetch ( integer $id = null, boolean $explicit_set = true ) : array Fetch an item from a Pod. If $id is null, it will return the next item in the list after running find().
field ( string | array $name, boolean $single = null, boolean $raw = false ) : mixed | null Return the value for a field.
fields ( null $field = null, null $option = null ) : boolean | mixed Return field array from a Pod, a field's data, or a field option
filters ( $params = null ) : string Return a filter form for searching a Pod
find ( array $params = null, integer $limit = 15, string $where = null, string $sql = null ) : Pods Find items of a pod, much like WP_Query, but with advanced table handling.
first_id ( array $params_override = null ) : integer Return the first item ID
form ( array $params = null, string $label = null, string $thank_you = null ) : boolean | mixed Embed a form to add / edit a pod item from within your theme. Provide an array of $fields to include and override options where needed. For WP object based Pods, you can pass through the WP object field names too, such as "post_title" or "post_content" for example.
has ( string $field, mixed $value, integer $id = null ) : boolean Check if an item field has a specific value in it
helper ( string $helper, string $value = null, string $name = null ) : mixed Run a helper within a Pod Page or WP Template
id ( ) : integer Return the item ID
import ( mixed $import_data, boolean $numeric_mode = false, string $format = null ) : array Import data / Save multiple rows of data at once
index ( ) : string Return the item name
input ( string | array $field, $input_name = null, mixed $value = '__null' ) : string Return a field input for a specific field
is ( string $field, mixed $value, integer $id = null ) : boolean Check if an item field is a specific value
is_iterator ( ) : boolean Check if in Iterator mode
key ( ) : integer | boolean Get current Iterator key
last_id ( array $params_override = null ) : integer Return the last item ID
next ( ) : void | boolean Move onto the next Iterator row
next_id ( integer $id = null, $params_override = null ) : integer Return the next item ID, loops at the first id to return the last
nth ( integer | string $nth = null ) : boolean Fetch the nth state
pagination ( $params = null ) : string Display the pagination controls, types supported by default are simple, paginate and advanced. The base and format parameters are used only for the paginate view.
position ( ) : integer Fetch the current position in the loop (starting at 1)
prev_id ( integer $id = null, array $params_override = null ) : integer Return the previous item ID, loops at the last id to return the first
raw ( string | array $name, boolean $single = null ) : string | null | false Return the raw output for a field If you want the raw value for use in PHP for custom manipulation, you will want to use field() instead. This function will automatically convert arrays into a list of text such as "Rick, John, and Gary"
remove_from ( string $field, mixed $value = null, integer $id = null ) : integer Remove an item from the values of a relationship field, remove a value from a number field (field-1), remove time to a date field
reset ( integer $row = null ) : Pods (Re)set the MySQL result pointer
reset_pod ( ) : boolean Reset Pod
rewind ( ) : void | boolean Rewind Iterator
row ( ) : array Return row array for an item
save ( array | string $data = null, mixed $value = null, integer $id = null, array $params = null ) : integer Save an item by giving an array of field data or set a specific field to a specific value.
stop_iterator ( ) : void Turn off Iterator mode to off
template ( $template_name, string $code = null, boolean $deprecated = false ) : mixed Display the page template
total ( ) : integer Fetch the total row count returned by the last call to find(), based on the 'limit' parameter set.
total_found ( ) : integer Fetch the total amount of rows found by the last call to find(), regardless of the 'limit' parameter set.
total_pages ( null | integer $limit = null, null | integer $offset = null, null | integer $total = null ) : integer Fetch the total number of pages, based on total rows found and the last find() limit
ui ( mixed $options = null, boolean $amend = false ) : PodsUI | void Generate UI for Data Management
valid ( ) : boolean Whether this Pod object is valid or not
view ( array $fields = null ) : mixed
zebra ( ) : boolean Fetch the zebra switch

Private Methods

Méthode Description
do_hook ( ) : mixed Handle filters / actions for the class
process_magic_tags ( string $tag ) : string Replace magic tags with their values

Method Details

__call() public méthode

Handle methods that have been deprecated and any aliasing
Since: 2.0
public __call ( $name, $args ) : mixed
Résultat mixed

__construct() public méthode

Constructor - Pods Framework core
Since: 1.0.0
public __construct ( string $pod = null, mixed $id = null ) : Pods
$pod string The pod name
$id mixed (optional) The ID or slug, to load a single record; Provide array of $params to run 'find'
Résultat Pods

__get() public méthode

Handle variables that have been deprecated and PodsData vars
Since: 2.0
public __get ( $name ) : mixed
Résultat mixed

add() public méthode

You may be looking for save() in most cases where you're setting a specific field.
See also: PodsAPI::save_pod_item
Since: 2.0
public add ( array | string $data = null, mixed $value = null ) : integer
$data array | string Either an associative array of field information or a field name
$value mixed (optional) Value of the field, if $data is a field name
Résultat integer The item ID

add_to() public méthode

Add an item to the values of a relationship field, add a value to a number field (field+1), add time to a date field, or add text to a text field
See also: PodsAPI::save_pod_item
Since: 2.3
public add_to ( string $field, mixed $value, integer $id = null ) : integer
$field string Field name
$value mixed ID(s) to add, int|float to add to number field, string for dates (+1 week), or string for text
$id integer (optional) ID of the pod item to update
Résultat integer The item ID

current() public méthode

Get current Iterator row
public current ( ) : mixed | boolean
Résultat mixed | boolean

data() public méthode

Most of the time, you will want to loop through data using fetch() instead of using this function.
Since: 2.0
public data ( ) : array | boolean
Résultat array | boolean An array of all rows returned from a find() call, or false if no items returned

delete() public méthode

Delete an item
See also: PodsAPI::delete_pod_item
Since: 2.0
public delete ( integer $id = null ) : boolean
$id integer ID of the Pod item to delete
Résultat boolean Whether the item was successfully deleted

display() public méthode

Return the output for a field. If you want the raw value for use in PHP for custom manipulation, you will want to use field() instead. This function will automatically convert arrays into a list of text such as "Rick, John, and Gary"
Since: 2.0
public display ( string | array $name, boolean $single = null ) : string | null | false
$name string | array The field name, or an associative array of parameters
$single boolean (optional) For tableless fields, to return an array or the first
Résultat string | null | false The output from the field, null if the field doesn't exist, false if no value returned for tableless fields

do_magic_tags() public méthode

Replace magic tags with their values
Since: 2.0
public do_magic_tags ( string $code ) : string
$code string The content to evaluate
Résultat string Code with Magic Tags evaluated

duplicate() public méthode

Duplicate an item
See also: PodsAPI::duplicate_pod_item
Since: 2.0
public duplicate ( integer $id = null ) : integer | boolean
$id integer ID of the pod item to duplicate
Résultat integer | boolean ID of the new pod item

exists() public méthode

Whether a Pod item exists or not when using fetch() or construct with an ID or slug
Since: 2.0
public exists ( ) : boolean
Résultat boolean

export() public méthode

Export an item's data
See also: PodsAPI::export_pod_item
Since: 2.0
public export ( array $fields = null, integer $id = null, $format = null ) : array | boolean
$fields array (optional) Fields to export
$id integer (optional) ID of the pod item to export
Résultat array | boolean Data array of the exported pod item

export_data() public méthode

Export data from all items
See also: PodsAPI::export
Since: 2.3
public export_data ( array $params = null ) : array
$params array An associative array of parameters
Résultat array Data arrays of all exported pod items

fetch() public méthode

You can rewind the list back to the start by using reset(). Providing an $id will fetch a specific item from a Pod, much like a call to pods(), and can handle either an id or slug.
See also: PodsData::fetch
Since: 2.0
public fetch ( integer $id = null, boolean $explicit_set = true ) : array
$id integer ID or slug of the item to fetch
$explicit_set boolean Whether to set explicitly (use false when in loop)
Résultat array An array of fields from the row

field() public méthode

If you are getting a field for output in a theme, most of the time you will want to use display() instead. This function will return arrays for relationship and file fields.
Since: 2.0
public field ( string | array $name, boolean $single = null, boolean $raw = false ) : mixed | null
$name string | array The field name, or an associative array of parameters
$single boolean (optional) For tableless fields, to return the whole array or the just the first item, or an associative array of parameters
$raw boolean (optional) Whether to return the raw value, or to run through the field type's display method, or an associative array of parameters
Résultat mixed | null Value returned depends on the field type, null if the field doesn't exist, false if no value returned for tableless fields

fields() public méthode

Return field array from a Pod, a field's data, or a field option
Since: 2.0
public fields ( null $field = null, null $option = null ) : boolean | mixed
$field null
$option null
Résultat boolean | mixed

filters() public méthode

Return a filter form for searching a Pod
Since: 2.0
public filters ( $params = null ) : string
Résultat string Filters HTML

find() public méthode

Find items of a pod, much like WP_Query, but with advanced table handling.
Since: 2.0
public find ( array $params = null, integer $limit = 15, string $where = null, string $sql = null ) : Pods
$params array An associative array of parameters
$limit integer (optional) (deprecated) Limit the number of items to find, use -1 to return all items with no limit
$where string (optional) (deprecated) SQL WHERE declaration to use
$sql string (optional) (deprecated) For advanced use, a custom SQL query to run
Résultat Pods The pod object

first_id() public méthode

Return the first item ID
Since: 2.3
public first_id ( array $params_override = null ) : integer
$params_override array
Résultat integer

form() public méthode

Embed a form to add / edit a pod item from within your theme. Provide an array of $fields to include and override options where needed. For WP object based Pods, you can pass through the WP object field names too, such as "post_title" or "post_content" for example.
Since: 2.0
public form ( array $params = null, string $label = null, string $thank_you = null ) : boolean | mixed
$params array (optional) Fields to show on the form, defaults to all fields
$label string (optional) Save button label, defaults to "Save Changes"
$thank_you string (optional) Thank you URL to send to upon success
Résultat boolean | mixed

has() public méthode

Check if an item field has a specific value in it
Since: 2.3.3
public has ( string $field, mixed $value, integer $id = null ) : boolean
$field string Field name
$value mixed Value to check
$id integer (optional) ID of the pod item to check
Résultat boolean Whether the value was found

helper() public méthode

Run a helper within a Pod Page or WP Template
See also: Pods_Helpers::helper
Since: 2.0
public helper ( string $helper, string $value = null, string $name = null ) : mixed
$helper string Helper name
$value string Value to run the helper on
$name string Field name
Résultat mixed Anything returned by the helper

id() public méthode

Return the item ID
Since: 2.0
public id ( ) : integer
Résultat integer

import() public méthode

Import data / Save multiple rows of data at once
See also: PodsAPI::import
Since: 2.3
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
Résultat array IDs of imported items

index() public méthode

Return the item name
Since: 2.0
public index ( ) : string
Résultat string

input() public méthode

Return a field input for a specific field
Since: 2.3.10
public input ( string | array $field, $input_name = null, mixed $value = '__null' ) : string
$field string | array Field name or Field data array
$value mixed Current value to use
Résultat string Field Input HTML

is() public méthode

Check if an item field is a specific value
Since: 2.3.3
public is ( string $field, mixed $value, integer $id = null ) : boolean
$field string Field name
$value mixed Value to check
$id integer (optional) ID of the pod item to check
Résultat boolean Whether the value was found

is_iterator() public méthode

Check if in Iterator mode
public is_iterator ( ) : boolean
Résultat boolean

key() public méthode

Get current Iterator key
public key ( ) : integer | boolean
Résultat integer | boolean

last_id() public méthode

Return the last item ID
Since: 2.3
public last_id ( array $params_override = null ) : integer
$params_override array
Résultat integer

next() public méthode

Move onto the next Iterator row
public next ( ) : void | boolean
Résultat void | boolean

next_id() public méthode

Return the next item ID, loops at the first id to return the last
Since: 2.0
public next_id ( integer $id = null, $params_override = null ) : integer
$id integer
Résultat integer

nth() public méthode

Fetch the nth state
See also: PodsData::nth
Since: 2.3
public nth ( integer | string $nth = null ) : boolean
$nth integer | string The $nth to match on the PodsData::row_number
Résultat boolean Whether $nth matches

pagination() public méthode

Display the pagination controls, types supported by default are simple, paginate and advanced. The base and format parameters are used only for the paginate view.
Since: 2.0
public pagination ( $params = null ) : string
Résultat string Pagination HTML

position() public méthode

Fetch the current position in the loop (starting at 1)
See also: PodsData::position
Since: 2.3
public position ( ) : integer
Résultat integer Current row number (+1)

prev_id() public méthode

Return the previous item ID, loops at the last id to return the first
Since: 2.0
public prev_id ( integer $id = null, array $params_override = null ) : integer
$id integer
$params_override array
Résultat integer

raw() public méthode

Return the raw output for a field If you want the raw value for use in PHP for custom manipulation, you will want to use field() instead. This function will automatically convert arrays into a list of text such as "Rick, John, and Gary"
Since: 2.0
public raw ( string | array $name, boolean $single = null ) : string | null | false
$name string | array The field name, or an associative array of parameters
$single boolean (optional) For tableless fields, to return an array or the first
Résultat string | null | false The output from the field, null if the field doesn't exist, false if no value returned for tableless fields

remove_from() public méthode

Remove an item from the values of a relationship field, remove a value from a number field (field-1), remove time to a date field
See also: PodsAPI::save_pod_item
Since: 2.3.3
public remove_from ( string $field, mixed $value = null, integer $id = null ) : integer
$field string Field name
$value mixed ID(s) to add, int|float to add to number field, string for dates (-1 week), or string for text
$id integer (optional) ID of the pod item to update
Résultat integer The item ID

reset() public méthode

(Re)set the MySQL result pointer
See also: PodsData::reset
Since: 2.0
public reset ( integer $row = null ) : Pods
$row integer ID of the row to reset to
Résultat Pods The pod object

reset_pod() public méthode

Reset Pod
See also: PodsAPI::reset_pod
Since: 2.1.1
public reset_pod ( ) : boolean
Résultat boolean Whether the Pod was successfully reset

rewind() public méthode

Rewind Iterator
public rewind ( ) : void | boolean
Résultat void | boolean

row() public méthode

Return row array for an item
Since: 2.0
public row ( ) : array
Résultat array

save() public méthode

Though this function has the capacity to add new items, best practice should direct you to use add() for that instead.
See also: PodsAPI::save_pod_item
Since: 2.0
public save ( array | string $data = null, mixed $value = null, integer $id = null, array $params = null ) : integer
$data array | string Either an associative array of field information or a field name
$value mixed (optional) Value of the field, if $data is a field name
$id integer (optional) ID of the pod item to update
$params array (optional) Additional params to send to save_pod_item
Résultat integer The item ID

stop_iterator() public méthode

Turn off Iterator mode to off
public stop_iterator ( ) : void
Résultat void

template() public méthode

Display the page template
See also: Pods_Templates::template
Since: 2.0
public template ( $template_name, string $code = null, boolean $deprecated = false ) : mixed
$code string Custom template code to use instead
$deprecated boolean Whether to use deprecated functionality based on old function usage
Résultat mixed Template output

total() public méthode

This is different than the total number of rows found in the database, which you can get with total_found().
See also: PodsData::total
Since: 2.0
public total ( ) : integer
Résultat integer Number of rows returned by find(), based on the 'limit' parameter set

total_found() public méthode

This is different than the total number of rows limited by the current call, which you can get with total().
See also: PodsData::total_found
Since: 2.0
public total_found ( ) : integer
Résultat integer Number of rows returned by find(), regardless of the 'limit' parameter

total_pages() public méthode

Fetch the total number of pages, based on total rows found and the last find() limit
Since: 2.3.10
public total_pages ( null | integer $limit = null, null | integer $offset = null, null | integer $total = null ) : integer
$limit null | integer Rows per page
$offset null | integer Offset of rows
$total null | integer Total rows
Résultat integer Number of pages

ui() public méthode

Generate UI for Data Management
Since: 2.3.10
public ui ( mixed $options = null, boolean $amend = false ) : PodsUI | void
$options mixed Array or String containing Pod or Options to be used
$amend boolean Whether to amend the default UI options or replace entirely
Résultat PodsUI | void UI object or void if custom UI used

valid() public méthode

Whether this Pod object is valid or not
Since: 2.0
public valid ( ) : boolean
Résultat boolean

view() public méthode

Since: 2.3.10
public view ( array $fields = null ) : mixed
$fields array (optional) Fields to show in the view, defaults to all fields
Résultat mixed

zebra() public méthode

Fetch the zebra switch
See also: PodsData::zebra
Since: 1.12
public zebra ( ) : boolean
Résultat boolean Zebra state

Property Details

$alt_data public_oe property

public PodsData $alt_data
Résultat PodsData

$api public_oe property

public PodsAPI $api
Résultat PodsAPI

$body_classes public_oe property

public $body_classes

$data public_oe property

public PodsData $data
Résultat PodsData

$datatype public_oe property

public $datatype

$datatype_id public_oe property

public $datatype_id

$deprecated public_oe property

public $deprecated

$detail_page public_oe property

public string $detail_page
Résultat string

$display_errors public_oe property

public bool $display_errors
Résultat boolean

$fields public_oe property

public array $fields
Résultat array

$filters public_oe property

public array $filters
Résultat array

$id public_oe property

public int $id
Résultat integer

$limit public_oe property

public int $limit
Résultat integer

$meta public_oe property

public $meta

$meta_extra public_oe property

public $meta_extra

$meta_properties public_oe property

public $meta_properties

$offset public_oe property

public int $offset
Résultat integer

$page public_oe property

public int|mixed $page
Résultat integer | mixed

$page_template public_oe property

SEO related vars for Pod Pages
public $page_template

$page_var public_oe property

public string $page_var
Résultat string

$pagination public_oe property

public bool $pagination
Résultat boolean

$params public_oe property

public array $params
Résultat array

$pod public_oe property

public string $pod
Résultat string

$pod_data public_oe property

public array|bool|mixed|null|void $pod_data
Résultat array | boolean | mixed | null | void

$pod_id public_oe property

public int $pod_id
Résultat integer

$row public_oe property

Current pod item array
public $row

$row_override public_oe property

Override pod item array
public $row_override

$rows public_oe property

Array of pod item arrays
public $rows

$search_mode public_oe property

public string $search_mode
Résultat string

$search_var public_oe property

public string $search_var
Résultat string

$sql public_oe property

Last SQL query used by a find()
public $sql

$total public_oe property

public int $total
Résultat integer

$total_found public_oe property

public int $total_found
Résultat integer

$ui public_oe property

public array $ui
Résultat array