| Server IP : 78.24.162.143 / Your IP : 216.73.217.150 Web Server : Apache System : Linux hosting.cormo.systems 5.15.0-179-generic #189-Ubuntu SMP Tue May 5 18:20:56 UTC 2026 x86_64 User : web63 ( 5058) PHP Version : 7.4.33 Disable Function : create_functions,pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_get_handler,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,pcntl_async_signals,pcntl_unshare, MySQL : OFF | cURL : ON | WGET : OFF | Perl : OFF | Python : OFF | Sudo : OFF | Pkexec : OFF Directory : /var/www/clients/client34/web63/web/wp-content/plugins/pods/src/Pods/REST/V1/ |
Upload File : |
<?php
namespace Pods\REST\V1;
use Tribe__REST__Messages_Interface as REST_Messages_Interface;
use Tribe__REST__Post_Repository as REST_Post_Repository;
use WP_Post;
/**
* Class Post_Repository
*
* @since 2.8.0
*/
class Post_Repository extends REST_Post_Repository {
/**
* A post type to get data request handler map.
*
* @var array
*/
protected $types_get_map = [];
/**
* @var REST_Messages_Interface
*/
protected $messages;
/**
* Post_Repository constructor.
*
* @since 2.8.0
*
* @param REST_Messages_Interface|null $messages The messages object.
*/
public function __construct( REST_Messages_Interface $messages = null ) {
$this->types_get_map = [
'_pods_pod' => [ $this, 'get_pod_data' ],
'_pods_group' => [ $this, 'get_group_data' ],
'_pods_field' => [ $this, 'get_field_data' ],
];
$this->messages = $messages ? $messages : pods_container( 'pods.rest-v1.messages' );
}
/**
* Retrieves an array representation of the object.
*
* @since 2.8.0
*
* @param int $id The ID.
* @param string $type The type of content.
* @param string $context Context of data.
*
* @return array|WP_Error An array representation of the object or an WP_Error with the error message.
*/
public function get_data( $id, $type = '', $context = 'default' ) {
$object = null;
if ( empty( $type ) ) {
$object = get_post( $id );
if ( ! $object instanceof WP_Post ) {
return [];
}
$type = $object->post_type;
}
if ( ! isset( $this->types_get_map[ $type ] ) ) {
return (array) $object;
}
return call_user_func( $this->types_get_map[ $type ], $id, $object, $context );
}
/**
* Get pod data.
*
* @since 2.8.0
*
* @param int $id The ID.
* @param WP_Post|object $object The object.
* @param string $context The context.
*
* @return array|WP_Error
*/
public function get_pod_data( $id, $object = null, $context = 'default' ) {
if ( null === $object ) {
$object = get_post( $id );
if ( ! $object instanceof WP_Post ) {
return new WP_Error( 'pod-not-found', $this->messages->get_message( 'pod-not-found' ), [ 'status' => 404 ] );
}
}
// @todo Fill this out.
return [];
}
/**
* Get group data.
*
* @since 2.8.0
*
* @param int $id The ID.
* @param WP_Post|object $object The object.
* @param string $context The context.
*
* @return array|WP_Error
*/
public function get_group_data( $id, $object = null, $context = 'default' ) {
if ( null === $object ) {
$object = get_post( $id );
if ( ! $object instanceof WP_Post ) {
return new WP_Error( 'group-not-found', $this->messages->get_message( 'group-not-found' ), [ 'status' => 404 ] );
}
}
// @todo Fill this out.
return [];
}
/**
* Get field data.
*
* @since 2.8.0
*
* @param int $id The ID.
* @param WP_Post|object $object The object.
* @param string $context The context.
*
* @return array|WP_Error
*/
public function get_field_data( $id, $object = null, $context = 'default' ) {
if ( null === $object ) {
$object = get_post( $id );
if ( ! $object instanceof WP_Post ) {
return new WP_Error( 'group-not-found', $this->messages->get_message( 'group-not-found' ), [ 'status' => 404 ] );
}
}
// @todo Fill this out.
return [];
}
}