| Server IP : 151.101.66.159 / Your IP : 216.73.216.66 Web Server : Flywheel/5.1.0 System : Linux wordpress 6.12.113+ #1 SMP Thu Oct 22 02:38:20 UTC 2026 x86_64 User : root ( ) PHP Version : 7.4.33.18 Disable Function : disk_free_space,diskfreespace,dl,exec,fpassthru,getmypid,getmyuid,highlight_file,link,opcache_compile_file,opcache_get_configuration,opcache_is_script_cached,passthru,pcntl_alarm,pcntl_exec,pcntl_fork,pcntl_get_last_error,pcntl_getpriority,pcntl_setpriority,pcntl_signal,pcntl_signal_dispatch,pcntl_sigprocmask,pcntl_sigtimedwait,pcntl_sigwaitinfo,pcntl_strerror,pcntl_wait,pcntl_waitpid,pcntl_wexitstatus,pcntl_wifcontinued,pcntl_wifexited,pcntl_wifsignaled,pcntl_wifstopped,pcntl_wstopsig,pcntl_wtermsig,phpinfo,popen,posix_ctermid,posix_getcwd,posix_getegid,posix_geteuid,posix_getgid,posix_getgrgid,posix_getgrnam,posix_getgroups,posix_getlogin,posix_getpgid,posix_getpgrp,posix_getpid,posix_getppid,posix_getpwnam,posix_getpwuid,posix_getrlimit,posix_getsid,posix_getuid,posix_isatty,posix_kill,posix_mkfifo,posix_setegid,posix_seteuid,posix_setgid,posix_setpgid,posix_setsid,posix_setuid,posix_times,posix_ttyname,posix_uname,proc_close,proc_get_status,proc_nice,proc_open,proc_terminate,shell_exec,show_source,socket_listen,source,system,virtual MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : OFF | Sudo : OFF | Pkexec : OFF Directory : /www/wp-content/plugins/pods/src/Pods/REST/V1/Validator/ |
Upload File : |
<?php
namespace Pods\REST\V1\Validator;
// Don't load directly.
if ( ! defined( 'ABSPATH' ) ) {
die( '-1' );
}
use Pods\REST\Interfaces\Validator_Interface;
/**
* Class Base
*
* @credit The Events Calendar team - https://github.com/the-events-calendar/tribe-common
*
* @since 2.8.0
*/
class Base implements Validator_Interface {
/**
* Whether the value corresponds to an existing post ID or not.
*
* @since 2.8.0
*
* @param mixed $value
*
* @return bool
*/
public function is_post_id( $value ) {
return is_numeric( $value ) && get_post( (int) $value );
}
/**
* Determine whether a Pod / Item ID is valid.
*
* @since 2.8.11
*
* @param string $pod The pod name.
* @param int|string $id_or_slug The Item ID or slug.
*
* @return bool Whether the Pod / Item ID is valid.
*/
public function is_pod_item_id_or_slug_valid( $pod, $id_or_slug ) {
$pod = pods_get_instance( $pod, $id_or_slug );
return $pod && ! is_wp_error( $pod ) && $pod->valid() && $pod->exists();
}
/**
* Determine whether a Pod / Item ID is valid.
*
* @since 2.8.11
*
* @param string $pod The pod name.
* @param int|string $id The item ID.
*
* @return bool Whether the Pod / Item ID is valid.
*/
public function is_pod_item_id_valid( $pod, $id ) {
return is_numeric( $id ) && $this->is_pod_id_or_slug_valid( $pod, (int) $id );
}
/**
* Determine whether a Pod / Item slug is valid.
*
* @since 2.8.11
*
* @param string $pod The pod name.
* @param int|string $slug The Item slug.
*
* @return bool Whether the Pod / Item slug is valid.
*/
public function is_pod_item_slug_valid( $pod, $slug ) {
return $this->is_pod_id_or_slug_valid( $pod, $slug );
}
/**
* Whether the value corresponds to an existing Pod slug or not.
*
* @since 2.8.0
*
* @param mixed $value
*
* @return bool
*/
public function is_pod_slug( $value ) {
return null !== get_page_by_path( $value, OBJECT, '_pods_pod' );
}
/**
* Whether the value corresponds to an existing Group slug or not.
*
* @since 2.8.0
*
* @param mixed $value
*
* @return bool
*/
public function is_group_slug( $value ) {
return null !== get_page_by_path( $value, OBJECT, '_pods_group' );
}
/**
* Whether the value corresponds to an existing Field slug or not.
*
* @since 2.8.0
*
* @param mixed $value
*
* @return bool
*/
public function is_field_slug( $value ) {
return null !== get_page_by_path( $value, OBJECT, '_pods_field' );
}
/**
* Whether the value corresponds to an existing Pod ID or not.
*
* @since 2.8.0
*
* @param mixed $value
*
* @return bool
*/
public function is_pod_id( $value ) {
if ( ! is_numeric( $value ) ) {
return false;
}
return '_pods_pod' === get_post_type( (int) $value );
}
/**
* Whether the value corresponds to an existing Group ID or not.
*
* @since 2.8.0
*
* @param mixed $value
*
* @return bool
*/
public function is_group_id( $value ) {
if ( ! is_numeric( $value ) ) {
return false;
}
return '_pods_group' === get_post_type( (int) $value );
}
/**
* Whether the value corresponds to an existing Field ID or not.
*
* @since 2.8.0
*
* @param mixed $value
*
* @return bool
*/
public function is_field_id( $value ) {
if ( ! is_numeric( $value ) ) {
return false;
}
return '_pods_field' === get_post_type( (int) $value );
}
/**
* Determine whether the value is valid JSON.
*
* @since 2.8.0
*
* @param mixed $value The value.
*
* @return bool Whether the value is valid JSON.
*/
public function is_json( $value ) {
return is_string( $value ) && ! is_scalar( json_decode( $value ) );
}
/**
* Handle other potential methods automatically if possible.
*
* @since 2.8.11
*
* @param string $name The method name.
* @param array $arguments The arguments provided to the method.
*
* @return mixed The method return response.
*/
#[\ReturnTypeWillChange]
public function __call( $name, array $arguments ) {
$mapped = [
'is_pod_item_id_valid_for_pod_' => 'is_pod_item_id_valid',
'is_pod_item_slug_valid_for_pod_' => 'is_pod_item_slug_valid',
'is_pod_item_id_or_slug_valid_for_pod_' => 'is_pod_item_id_or_slug_valid',
];
foreach ( $mapped as $prefix_method => $mapped_method ) {
if ( 0 === strpos( (string) $name, $prefix_method ) ) {
$pod_name = str_replace( $prefix_method, '', (string) $name );
array_unshift( $pod_name, $arguments );
return $this->{$mapped_method}( ...$arguments );
}
}
}
/**
* Determine whether the value is not null.
*
* @since 3.0
*
* @param mixed $value
*
* @return bool
*/
public function is_not_null( $value ) {
return null !== $value;
}
}