PHP Класс Pods, pods

Наследование: implements Iterator
Показать файл Открыть проект Примеры использования класса

Открытые свойства

Свойство Тип Описание
$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

Открытые методы

Метод Описание
__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

Приватные методы

Метод Описание
do_hook ( ) : mixed Handle filters / actions for the class
process_magic_tags ( string $tag ) : string Replace magic tags with their values

Описание методов

__call() публичный Метод

Handle methods that have been deprecated and any aliasing
С версии: 2.0
public __call ( $name, $args ) : mixed
Результат mixed

__construct() публичный Метод

Constructor - Pods Framework core
С версии: 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'
Результат Pods

__get() публичный Метод

Handle variables that have been deprecated and PodsData vars
С версии: 2.0
public __get ( $name ) : mixed
Результат mixed

add() публичный Метод

You may be looking for save() in most cases where you're setting a specific field.
См. также: PodsAPI::save_pod_item
С версии: 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
Результат integer The item ID

add_to() публичный Метод

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
См. также: PodsAPI::save_pod_item
С версии: 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
Результат integer The item ID

current() публичный Метод

Get current Iterator row
С версии: 2.3.4
public current ( ) : mixed | boolean
Результат mixed | boolean

data() публичный Метод

Most of the time, you will want to loop through data using fetch() instead of using this function.
С версии: 2.0
public data ( ) : array | boolean
Результат array | boolean An array of all rows returned from a find() call, or false if no items returned

delete() публичный Метод

Delete an item
См. также: PodsAPI::delete_pod_item
С версии: 2.0
public delete ( integer $id = null ) : boolean
$id integer ID of the Pod item to delete
Результат boolean Whether the item was successfully deleted

display() публичный Метод

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"
С версии: 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
Результат 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() публичный Метод

Replace magic tags with their values
С версии: 2.0
public do_magic_tags ( string $code ) : string
$code string The content to evaluate
Результат string Code with Magic Tags evaluated

duplicate() публичный Метод

Duplicate an item
См. также: PodsAPI::duplicate_pod_item
С версии: 2.0
public duplicate ( integer $id = null ) : integer | boolean
$id integer ID of the pod item to duplicate
Результат integer | boolean ID of the new pod item

exists() публичный Метод

Whether a Pod item exists or not when using fetch() or construct with an ID or slug
С версии: 2.0
public exists ( ) : boolean
Результат boolean

export() публичный Метод

Export an item's data
См. также: PodsAPI::export_pod_item
С версии: 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
Результат array | boolean Data array of the exported pod item

export_data() публичный Метод

Export data from all items
См. также: PodsAPI::export
С версии: 2.3
public export_data ( array $params = null ) : array
$params array An associative array of parameters
Результат array Data arrays of all exported pod items

fetch() публичный Метод

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.
См. также: PodsData::fetch
С версии: 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)
Результат array An array of fields from the row

field() публичный Метод

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.
С версии: 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
Результат 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() публичный Метод

Return field array from a Pod, a field's data, or a field option
С версии: 2.0
public fields ( null $field = null, null $option = null ) : boolean | mixed
$field null
$option null
Результат boolean | mixed

filters() публичный Метод

Return a filter form for searching a Pod
С версии: 2.0
public filters ( $params = null ) : string
Результат string Filters HTML

find() публичный Метод

Find items of a pod, much like WP_Query, but with advanced table handling.
С версии: 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
Результат Pods The pod object

first_id() публичный Метод

Return the first item ID
С версии: 2.3
public first_id ( array $params_override = null ) : integer
$params_override array
Результат integer

form() публичный Метод

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.
С версии: 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
Результат boolean | mixed

has() публичный Метод

Check if an item field has a specific value in it
С версии: 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
Результат boolean Whether the value was found

helper() публичный Метод

Run a helper within a Pod Page or WP Template
См. также: Pods_Helpers::helper
С версии: 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
Результат mixed Anything returned by the helper

id() публичный Метод

Return the item ID
С версии: 2.0
public id ( ) : integer
Результат integer

import() публичный Метод

Import data / Save multiple rows of data at once
См. также: PodsAPI::import
С версии: 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
Результат array IDs of imported items

index() публичный Метод

Return the item name
С версии: 2.0
public index ( ) : string
Результат string

input() публичный Метод

Return a field input for a specific field
С версии: 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
Результат string Field Input HTML

is() публичный Метод

Check if an item field is a specific value
С версии: 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
Результат boolean Whether the value was found

is_iterator() публичный Метод

Check if in Iterator mode
С версии: 2.3.4
public is_iterator ( ) : boolean
Результат boolean

key() публичный Метод

Get current Iterator key
С версии: 2.3.4
public key ( ) : integer | boolean
Результат integer | boolean

last_id() публичный Метод

Return the last item ID
С версии: 2.3
public last_id ( array $params_override = null ) : integer
$params_override array
Результат integer

next() публичный Метод

Move onto the next Iterator row
С версии: 2.3.4
public next ( ) : void | boolean
Результат void | boolean

next_id() публичный Метод

Return the next item ID, loops at the first id to return the last
С версии: 2.0
public next_id ( integer $id = null, $params_override = null ) : integer
$id integer
Результат integer

nth() публичный Метод

Fetch the nth state
См. также: PodsData::nth
С версии: 2.3
public nth ( integer | string $nth = null ) : boolean
$nth integer | string The $nth to match on the PodsData::row_number
Результат boolean Whether $nth matches

pagination() публичный Метод

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.
С версии: 2.0
public pagination ( $params = null ) : string
Результат string Pagination HTML

position() публичный Метод

Fetch the current position in the loop (starting at 1)
См. также: PodsData::position
С версии: 2.3
public position ( ) : integer
Результат integer Current row number (+1)

prev_id() публичный Метод

Return the previous item ID, loops at the last id to return the first
С версии: 2.0
public prev_id ( integer $id = null, array $params_override = null ) : integer
$id integer
$params_override array
Результат integer

raw() публичный Метод

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"
С версии: 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
Результат 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() публичный Метод

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
См. также: PodsAPI::save_pod_item
С версии: 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
Результат integer The item ID

reset() публичный Метод

(Re)set the MySQL result pointer
См. также: PodsData::reset
С версии: 2.0
public reset ( integer $row = null ) : Pods
$row integer ID of the row to reset to
Результат Pods The pod object

reset_pod() публичный Метод

Reset Pod
См. также: PodsAPI::reset_pod
С версии: 2.1.1
public reset_pod ( ) : boolean
Результат boolean Whether the Pod was successfully reset

rewind() публичный Метод

Rewind Iterator
С версии: 2.3.4
public rewind ( ) : void | boolean
Результат void | boolean

row() публичный Метод

Return row array for an item
С версии: 2.0
public row ( ) : array
Результат array

save() публичный Метод

Though this function has the capacity to add new items, best practice should direct you to use add() for that instead.
См. также: PodsAPI::save_pod_item
С версии: 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
Результат integer The item ID

stop_iterator() публичный Метод

Turn off Iterator mode to off
С версии: 2.3.4
public stop_iterator ( ) : void
Результат void

template() публичный Метод

Display the page template
См. также: Pods_Templates::template
С версии: 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
Результат mixed Template output

total() публичный Метод

This is different than the total number of rows found in the database, which you can get with total_found().
См. также: PodsData::total
С версии: 2.0
public total ( ) : integer
Результат integer Number of rows returned by find(), based on the 'limit' parameter set

total_found() публичный Метод

This is different than the total number of rows limited by the current call, which you can get with total().
См. также: PodsData::total_found
С версии: 2.0
public total_found ( ) : integer
Результат integer Number of rows returned by find(), regardless of the 'limit' parameter

total_pages() публичный Метод

Fetch the total number of pages, based on total rows found and the last find() limit
С версии: 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
Результат integer Number of pages

ui() публичный Метод

Generate UI for Data Management
С версии: 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
Результат PodsUI | void UI object or void if custom UI used

valid() публичный Метод

Whether this Pod object is valid or not
С версии: 2.0
public valid ( ) : boolean
Результат boolean

view() публичный Метод

С версии: 2.3.10
public view ( array $fields = null ) : mixed
$fields array (optional) Fields to show in the view, defaults to all fields
Результат mixed

zebra() публичный Метод

Fetch the zebra switch
См. также: PodsData::zebra
С версии: 1.12
public zebra ( ) : boolean
Результат boolean Zebra state

Описание свойств

$alt_data публичное свойство

public PodsData $alt_data
Результат PodsData

$api публичное свойство

public PodsAPI $api
Результат PodsAPI

$body_classes публичное свойство

public $body_classes

$data публичное свойство

public PodsData $data
Результат PodsData

$datatype публичное свойство

public $datatype

$datatype_id публичное свойство

public $datatype_id

$deprecated публичное свойство

public $deprecated

$detail_page публичное свойство

public string $detail_page
Результат string

$display_errors публичное свойство

public bool $display_errors
Результат boolean

$fields публичное свойство

public array $fields
Результат array

$filters публичное свойство

public array $filters
Результат array

$id публичное свойство

public int $id
Результат integer

$limit публичное свойство

public int $limit
Результат integer

$meta публичное свойство

public $meta

$meta_extra публичное свойство

public $meta_extra

$meta_properties публичное свойство

public $meta_properties

$offset публичное свойство

public int $offset
Результат integer

$page публичное свойство

public int|mixed $page
Результат integer | mixed

$page_template публичное свойство

SEO related vars for Pod Pages
public $page_template

$page_var публичное свойство

public string $page_var
Результат string

$pagination публичное свойство

public bool $pagination
Результат boolean

$params публичное свойство

public array $params
Результат array

$pod публичное свойство

public string $pod
Результат string

$pod_data публичное свойство

public array|bool|mixed|null|void $pod_data
Результат array | boolean | mixed | null | void

$pod_id публичное свойство

public int $pod_id
Результат integer

$row публичное свойство

Current pod item array
public $row

$row_override публичное свойство

Override pod item array
public $row_override

$rows публичное свойство

Array of pod item arrays
public $rows

$search_mode публичное свойство

public string $search_mode
Результат string

$search_var публичное свойство

public string $search_var
Результат string

$sql публичное свойство

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

$total публичное свойство

public int $total
Результат integer

$total_found публичное свойство

public int $total_found
Результат integer

$ui публичное свойство

public array $ui
Результат array