PHP Class PodsRESTHandlers, pods

Handlers for reading and writing Pods fields via REST API
Since: 2.5.6
Exibir arquivo Open project: pods-framework/pods Class Usage Examples

Public Methods

Method Description
get_handler ( array $object, string $field_name, WP_REST_Request $request, string $object_type ) : mixed Handler for getting custom field data.
pod_extends_core_route ( array | Pods $pod ) : boolean Check if a Pod supports extending core REST response.
post_type_rest_support ( string $post_type_name, boolean | false $rest_base = false, string $controller = 'WP_REST_Posts_Controller' ) Add REST API support to a post type
taxonomy_rest_support ( string $taxonomy_name, boolean | false $rest_base = false, string $controller = 'WP_REST_Terms_Controller' ) Add REST API support to an already registered taxonomy.
write_handler ( mixed $value, object $object, string $field_name, WP_REST_Request $request, string $object_type ) : boolean | integer Handler for updating custom field data.

Protected Methods

Method Description
get_pod ( $pod_name, $id ) : boolean | Pods Get Pod object

Method Details

get_handler() public static method

Handler for getting custom field data.
Since: 2.5.6
public static get_handler ( array $object, string $field_name, WP_REST_Request $request, string $object_type ) : mixed
$object array The object from the response
$field_name string Name of field
$request WP_REST_Request Current request
$object_type string Type of object
return mixed

get_pod() protected static method

Get Pod object
Since: 2.5.6
protected static get_pod ( $pod_name, $id ) : boolean | Pods
$pod_name
$id
return boolean | Pods

pod_extends_core_route() public static method

Check if a Pod supports extending core REST response.
Since: 2.5.6
public static pod_extends_core_route ( array | Pods $pod ) : boolean
$pod array | Pods Pod object or the pod_data array
return boolean

post_type_rest_support() public static method

Add REST API support to a post type
Since: 2.5.6
public static post_type_rest_support ( string $post_type_name, boolean | false $rest_base = false, string $controller = 'WP_REST_Posts_Controller' )
$post_type_name string Name of post type
$rest_base boolean | false Optional. Base url segment. If not set, post type name is used
$controller string Optional, controller class for route. If not set "WP_REST_Posts_Controller" is used.

taxonomy_rest_support() public static method

Add REST API support to an already registered taxonomy.
Since: 2.5.6
public static taxonomy_rest_support ( string $taxonomy_name, boolean | false $rest_base = false, string $controller = 'WP_REST_Terms_Controller' )
$taxonomy_name string Taxonomy name.
$rest_base boolean | false Optional. Base url segment. If not set, taxonomy name is used.
$controller string Optional, controller class for route. If not set "WP_REST_Terms_Controller" is used.

write_handler() public static method

Handler for updating custom field data.
Since: 2.5.6
public static write_handler ( mixed $value, object $object, string $field_name, WP_REST_Request $request, string $object_type ) : boolean | integer
$value mixed Value to write
$object object The object from the response
$field_name string Name of field
$request WP_REST_Request Current request
$object_type string Type of object
return boolean | integer