Server IP : 172.67.216.182 / Your IP : 104.23.175.160 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/assets/js/api/ |
Upload File : |
/** * API Client for Caldera Forms API for a single form * * @since 1.5.0 * * @param routes URLs for endpoints, should have URL for /entries and /forms * @param perPage How many items to return for page * @param formId Form ID * @param tokens Either WordPress REST API authentication nonce as string, or object with index nonce and token (token is Caldera Forms Entry Token) * @param $ jQuery * * @returns {{getForm: getForm, getEntries: getEntries, paginatedEntryURL: paginatedEntryURL, setPerPage: setPerPage}} * * @constructor */ function CFAPI( routes, perPage, formId, tokens, $ ) { var nonce, token; if( 'object' == typeof tokens ){ nonce = typeof tokens.nonce == 'string' ? tokens.nonce : false; token = typeof tokens.nonce == 'string' ? tokens.token : false; }else{ nonce = tokens; } function addHeaders( xhr ){ xhr.setRequestHeader( 'X-CF-ENTRY-TOKEN', token ); xhr.setRequestHeader( 'X-WP-Nonce', nonce ); } return { getForm: function () { return $.ajax({ url: routes.form + formId, method: 'GET', beforeSend: function ( xhr ) { addHeaders( xhr ); } }).done(function (r) { return r; }).fail(function (r) { console.log(r); }); }, getEntries: function ( page ) { return $.ajax({ url: this.paginatedEntryURL(formId, page, perPage ), method: 'GET', beforeSend: function ( xhr ) { addHeaders( xhr ); } } ).done(function (r) { return r; }).fail(function (r) { console.log(r); }); }, paginatedEntryURL: function (formId, page ) { var params = $.param({ page: page, per_page: perPage }); //If pretty permalinks are enabled params need to be prefixed with "?" //Else there already is a "?" so we need to add a "&" //@see https://github.com/CalderaWP/Caldera-Forms/pull/3576#issuecomment-655563315 var divider = routes.entries.indexOf('?') === -1 ? '?' : '&'; return routes.entries + formId + divider + params }, setPerPage : function( newPerPage ) { perPage = newPerPage; }, getPerPage :function () { return perPage; }, savePerPage: function(){ return $.ajax({ url: routes.entrySettings, method: 'POST', dataType: 'json', beforeSend: function ( xhr ) { addHeaders( xhr ); }, data:{ per_page: perPage } }).done( function( r ){ return r.per_page; }).fail( function( r ){ console.log(r); }) }, } }