Server IP : 172.67.216.182 / Your IP : 172.70.142.117 Web Server : Apache System : Linux krdc-ubuntu-s-2vcpu-4gb-amd-blr1-01.localdomain 5.15.0-142-generic #152-Ubuntu SMP Mon May 19 10:54:31 UTC 2025 x86_64 User : www ( 1000) PHP Version : 7.4.33 Disable Function : passthru,exec,system,putenv,chroot,chgrp,chown,shell_exec,popen,proc_open,pcntl_exec,ini_alter,ini_restore,dl,openlog,syslog,readlink,symlink,popepassthru,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_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,imap_open,apache_setenv MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : OFF | Sudo : ON | Pkexec : ON Directory : /www/wwwroot/coircraft.com/wp-content/plugins/caldera-forms/classes/api/ |
Upload File : |
<?php /** * Utility functions for Caldera Forms REST API * * @package Caldera_Forms * @author Josh Pollock <[email protected]> * @license GPL-2.0+ * @link * @copyright 2016 CalderaWP LLC */ class Caldera_Forms_API_Util { /** * The namespace for Caldera Forms REST API * * @since 1.4.4 * * @param string $version Optional. API version. Default is v2. Can be v3 or v2 only * @return string */ public static function api_namespace($version = 'v2'){ $version = in_array( $version, ['v2', 'v3' ] ) ? $version : 'v2'; return "cf-api/$version"; } /** * The URL for Caldera Forms REST API * * @since 1.4.4 * * @param string $endpoint Optional. Endpoint. * @param bool $add_nonce Optional. If true, _wp_nonce is set with WP REST API nonce. Default is false * @param string $version Optional. @since 1.8.0 * @return string */ public static function url( $endpoint = '', $add_nonce = false, $version = 'v2' ){ if( ! function_exists( 'rest_url' ) ){ return ''; } $url = rest_url( self::api_namespace($version) . '/' . $endpoint ); if( $add_nonce ){ $url = add_query_arg( '_wpnonce', self::get_core_nonce(), $url ); } return $url; } public static function check_api_token( WP_REST_Request $request ){ $allowed = false; if( false != ( $token = $request->get_header( 'x_cf_entry_token') ) && is_string( $request[ 'form_id' ] ) ){ $allowed = Caldera_Forms_API_Token::check_token( $token, $request[ 'form_id' ] ); } return $allowed; } /** * Get the nonce for the WP REST API * * @since 1.5.3 * * @return string */ public static function get_core_nonce(){ return wp_create_nonce( 'wp_rest' ); } /** * Given an array of field IDs and form config, reduce field IDs array to fields that form has * * @since 1.7.0 * * @param array $field_ids * @param array $form * @return array */ public static function validate_array_of_field_ids(array $field_ids, array $form ) { $valid_fields = []; $form_fields = array_keys(Caldera_Forms_Forms::get_fields( $form, false )); if (! empty( $field_ids )) { foreach ($field_ids as $field_id) { $field_id = trim( $field_id ); if( in_array( $field_id, $form_fields ) ){ $valid_fields[] = $field_id; } } } return $valid_fields; } }