PageRenderTime 42ms CodeModel.GetById 17ms RepoModel.GetById 0ms app.codeStats 0ms

/wp-content/plugins/kali-forms/Inc/Backend/class-predefined-forms.php

https://gitlab.com/chernushov881/charity-fund
PHP | 267 lines | 213 code | 26 blank | 28 comment | 19 complexity | 8cc46ae54b6be223c9e148eb117e3b54 MD5 | raw file
  1. <?php
  2. namespace KaliForms\Inc\Backend;
  3. if (!defined('ABSPATH')) {
  4. exit;
  5. }
  6. /**
  7. * Class Predefined_Forms is used to translate stuff
  8. *
  9. * @package App\Libraries
  10. */
  11. class Predefined_Forms
  12. {
  13. /**
  14. * Plugin slug
  15. *
  16. * @var string
  17. */
  18. public $slug = 'kaliforms';
  19. /**
  20. * Forms array
  21. *
  22. * @var array
  23. */
  24. public $forms = [];
  25. /**
  26. * Class constructor
  27. */
  28. public function __construct()
  29. {
  30. add_action(
  31. 'wp_ajax_kaliforms_get_form_data',
  32. [$this, 'get_form_data']
  33. );
  34. }
  35. /**
  36. * Gets form data
  37. *
  38. * @return void
  39. */
  40. public function get_form_data()
  41. {
  42. if (!isset($_POST['args'], $_POST['args']['nonce'])) {
  43. wp_die('Denied');
  44. }
  45. if (!wp_verify_nonce(sanitize_key(wp_unslash($_POST['args']['nonce'])), 'kaliforms_nonce')) {
  46. wp_die('Denied');
  47. }
  48. $this->set_forms(true);
  49. $_POST['args'] = stripslashes_deep($_POST['args']);
  50. if (!isset($this->forms[$_POST['args']['id']])) {
  51. wp_die('wrong id');
  52. }
  53. $form = $this->forms[$_POST['args']['id']]['instance'];
  54. if ($form === null) {
  55. wp_die('something went wrong');
  56. }
  57. wp_die(wp_json_encode(
  58. [
  59. 'name' => $form->name,
  60. 'emails' => $form->emails,
  61. 'thank_you_message' => $form->thank_you_message,
  62. 'conditional_logic' => isset($form->conditional_logic) ? $form->conditional_logic : [],
  63. 'form_calculator' => isset($form->form_calculator) ? $form->form_calculator : [],
  64. 'grid' => $form->grid,
  65. 'field_components' => $form->field_components,
  66. 'form_info' => $form->form_info,
  67. ]
  68. ));
  69. }
  70. /**
  71. * Sets the default forms
  72. *
  73. * @return void
  74. */
  75. public function set_forms($full = false)
  76. {
  77. $contactForm = new PredefinedForms\Contact_Form();
  78. $this->forms['contact'] = [
  79. 'name' => $contactForm->name,
  80. 'description' => $contactForm->description,
  81. 'class' => 'PredefinedForms\Contact_Form',
  82. 'pro' => false,
  83. 'premium' => false,
  84. 'instance' => $full ? $contactForm : null,
  85. 'thumb' => KALIFORMS_URL . '/assets/img/predefined-forms/contact-form.png',
  86. 'demo' => 'https://kaliforms.dev/contact-form/',
  87. ];
  88. $employeeInformation = new PredefinedForms\Employee_Information_Form();
  89. $this->forms['employeeInformation'] = [
  90. 'name' => $employeeInformation->name,
  91. 'description' => $employeeInformation->description,
  92. 'pro' => false,
  93. 'premium' => false,
  94. 'class' => 'PredefinedForms\Employee_Information_Form',
  95. 'instance' => $full ? $employeeInformation : null,
  96. 'thumb' => KALIFORMS_URL . '/assets/img/predefined-forms/employee-info-form.png',
  97. 'demo' => 'https://kaliforms.dev/employee-information-form/',
  98. ];
  99. $this->forms['gdpr-contact'] = [
  100. 'name' => esc_html__('GDPR-Friendly contact form', 'kaliforms'),
  101. 'description' => esc_html__('A simple gdpr-friendly form meant to help you comunicate with your site users.', 'kaliforms'),
  102. 'class' => 'PredefinedForms\GDPR_Friendly_Contact_Form',
  103. 'pro' => true,
  104. 'premium' => true,
  105. 'thumb' => KALIFORMS_URL . '/assets/img/predefined-forms/gdpr-contact-form.png',
  106. 'instance' => $full && class_exists('KaliForms\Inc\Backend\PredefinedForms\GDPR_Friendly_Contact_Form') ? new PredefinedForms\GDPR_Friendly_Contact_Form() : null,
  107. 'demo' => 'https://kaliforms.dev/gdpr-friendly-contact-form/',
  108. ];
  109. $this->forms['appointment'] = [
  110. 'name' => esc_html__('Appointment form', 'kaliforms'),
  111. 'description' => esc_html__('Use this as a starting point in building an appointment service on your site.', 'kaliforms'),
  112. 'class' => 'PredefinedForms\Appointment_Form',
  113. 'pro' => true,
  114. 'premium' => true,
  115. 'thumb' => KALIFORMS_URL . '/assets/img/predefined-forms/appointment-form.png',
  116. 'instance' => $full && class_exists('KaliForms\Inc\Backend\PredefinedForms\Appointment_Form') ? new PredefinedForms\Appointment_Form() : null,
  117. 'demo' => 'https://kaliforms.dev/appointment-form/',
  118. ];
  119. $this->forms['customerSatisfaction'] = [
  120. 'name' => esc_html__('Customer feedback form', 'kaliforms'),
  121. 'description' => esc_html__('Collect feedback from customers and improve your services.', 'kaliforms'),
  122. 'pro' => true,
  123. 'premium' => true,
  124. 'class' => 'PredefinedForms\Customer_Satisfaction_Form',
  125. 'thumb' => KALIFORMS_URL . '/assets/img/predefined-forms/customer-feedback-form.png',
  126. 'instance' => $full && class_exists('KaliForms\Inc\Backend\PredefinedForms\Customer_Satisfaction_Form') ? new PredefinedForms\Customer_Satisfaction_Form() : null,
  127. 'demo' => 'https://kaliforms.dev/customer-feedback-form/',
  128. ];
  129. $this->forms['artContest'] = [
  130. 'name' => esc_html__('Art contest', 'kaliforms'),
  131. 'description' => esc_html__('This form will help you accept registrations for an art contest event.', 'kaliforms'),
  132. 'pro' => true,
  133. 'premium' => true,
  134. 'class' => 'PredefinedForms\Art_Contest_Form',
  135. 'thumb' => KALIFORMS_URL . '/assets/img/predefined-forms/art-contest.png',
  136. 'instance' => $full && class_exists('KaliForms\Inc\Backend\PredefinedForms\Art_Contest_Form') ? new PredefinedForms\Art_Contest_Form() : null,
  137. 'demo' => 'https://kaliforms.dev/art-contest/',
  138. ];
  139. $this->forms['jobApplication'] = [
  140. 'name' => esc_html__('Job application', 'kaliforms'),
  141. 'description' => esc_html__('Collect resumes for the positions available in your company', 'kaliforms'),
  142. 'pro' => true,
  143. 'premium' => true,
  144. 'class' => 'PredefinedForms\Job_Application_Form',
  145. 'thumb' => KALIFORMS_URL . '/assets/img/predefined-forms/job-application.png',
  146. 'instance' => $full && class_exists('KaliForms\Inc\Backend\PredefinedForms\Job_Application_Form') ? new PredefinedForms\Job_Application_Form() : null,
  147. 'demo' => 'https://kaliforms.dev/job-application/',
  148. ];
  149. $this->forms['gamingTournamentRegistration'] = [
  150. 'name' => esc_html__('Gaming tournament registration', 'kaliforms'),
  151. 'description' => esc_html__('Allow ESL teams to join your tournament through this form.', 'kaliforms'),
  152. 'pro' => true,
  153. 'premium' => true,
  154. 'class' => 'PredefinedForms\Gaming_Tournament_Registration_Form',
  155. 'thumb' => KALIFORMS_URL . '/assets/img/predefined-forms/gaming-tournament.png',
  156. 'instance' => $full && class_exists('KaliForms\Inc\Backend\PredefinedForms\Gaming_Tournament_Registration_Form') ? new PredefinedForms\Gaming_Tournament_Registration_Form() : null,
  157. 'demo' => 'https://kaliforms.dev/gaming-tournament-registration/',
  158. ];
  159. $this->forms['runningCalculators'] = [
  160. 'name' => esc_html__('Running calculator form', 'kaliforms'),
  161. 'description' => esc_html__('Easily calculate pace/time/distance using our calculator.', 'kaliforms'),
  162. 'pro' => true,
  163. 'premium' => true,
  164. 'class' => 'PredefinedForms\Running_Calculators',
  165. 'thumb' => KALIFORMS_URL . '/assets/img/predefined-forms/pace-calculator.jpg',
  166. 'instance' => $full && class_exists('KaliForms\Inc\Backend\PredefinedForms\Running_Calculators') ? new PredefinedForms\Running_Calculators() : null,
  167. 'demo' => 'https://kaliforms.dev/running-calculators/',
  168. ];
  169. $this->forms['donationForm'] = [
  170. 'name' => esc_html__('Donation form', 'kaliforms'),
  171. 'description' => esc_html__('Create donation collect form.', 'kaliforms'),
  172. 'pro' => true,
  173. 'premium' => true,
  174. 'class' => 'PredefinedForms\Donation_Form',
  175. 'thumb' => KALIFORMS_URL . '/assets/img/predefined-forms/donation-form.jpg',
  176. 'instance' => $full && class_exists('KaliForms\Inc\Backend\PredefinedForms\Donation_Form') ? new PredefinedForms\Donation_Form() : null,
  177. 'demo' => 'https://kaliforms.dev/donation_form/',
  178. ];
  179. $this->forms['requestAQuote'] = [
  180. 'name' => esc_html__('Request quote form', 'kaliforms'),
  181. 'description' => esc_html__('A simple example of using the calculator to create a quote estimate and request.', 'kaliforms'),
  182. 'pro' => true,
  183. 'premium' => true,
  184. 'class' => 'PredefinedForms\Request_A_Quote',
  185. 'thumb' => KALIFORMS_URL . '/assets/img/predefined-forms/request-a-quote.jpg',
  186. 'instance' => $full && class_exists('KaliForms\Inc\Backend\PredefinedForms\Request_A_Quote') ? new PredefinedForms\Request_A_Quote() : null,
  187. 'demo' => 'https://kaliforms.dev/request-a-quote/',
  188. ];
  189. $this->forms['reservationForm'] = [
  190. 'name' => esc_html__('Reservation form', 'kaliforms'),
  191. 'description' => esc_html__('A form that can be used as to reserve rooms at your hotel.', 'kaliforms'),
  192. 'pro' => true,
  193. 'premium' => true,
  194. 'class' => 'PredefinedForms\Reservation_Form',
  195. 'thumb' => KALIFORMS_URL . '/assets/img/predefined-forms/hotel-reservation-form.jpg',
  196. 'instance' => $full && class_exists('KaliForms\Inc\Backend\PredefinedForms\Reservation_Form') ? new PredefinedForms\Reservation_Form() : null,
  197. 'demo' => 'https://kaliforms.dev/reservation-form/',
  198. ];
  199. $this->forms['gymMembershipApplication'] = [
  200. 'name' => esc_html__('Gym membership form', 'kaliforms'),
  201. 'description' => esc_html__('A form that can collect information about your gym customers.', 'kaliforms'),
  202. 'pro' => true,
  203. 'premium' => true,
  204. 'class' => 'PredefinedForms\Gym_Membership_Application',
  205. 'thumb' => KALIFORMS_URL . '/assets/img/predefined-forms/gym-membership-application.jpg',
  206. 'instance' => $full && class_exists('KaliForms\Inc\Backend\PredefinedForms\Gym_Membership_Application') ? new PredefinedForms\Gym_Membership_Application() : null,
  207. 'demo' => 'https://kaliforms.dev/gym-membership-application/',
  208. ];
  209. $this->forms['simpleBookingForm'] = [
  210. 'name' => esc_html__('Simple booking form', 'kaliforms'),
  211. 'description' => esc_html__('Use our date picker to book certain dates in a calendar. Dates are disabled automatically based on previous submissions.', 'kaliforms'),
  212. 'pro' => true,
  213. 'premium' => true,
  214. 'class' => 'PredefinedForms\Simple_Booking_Form',
  215. 'thumb' => KALIFORMS_URL . '/assets/img/predefined-forms/simple-booking-form.jpg',
  216. 'instance' => $full && class_exists('KaliForms\Inc\Backend\PredefinedForms\Simple_Booking_Form') ? new PredefinedForms\Simple_Booking_Form() : null,
  217. 'demo' => 'https://kaliforms.dev/simple-booking-form/',
  218. ];
  219. $this->forms['simpleBookingFormWithPayment'] = [
  220. 'name' => esc_html__('Simple booking form with payment', 'kaliforms'),
  221. 'description' => esc_html__('Use our date picker to book certain dates in a calendar. Dates are disabled automatically based on previous submissions.', 'kaliforms'),
  222. 'pro' => true,
  223. 'premium' => true,
  224. 'class' => 'PredefinedForms\Simple_Booking_Form_With_Payment',
  225. 'thumb' => KALIFORMS_URL . '/assets/img/predefined-forms/simple-booking-form-with-payment.jpg',
  226. 'instance' => $full && class_exists('KaliForms\Inc\Backend\PredefinedForms\Simple_Booking_Form_With_Payment') ? new PredefinedForms\Simple_Booking_Form_With_Payment() : null,
  227. 'demo' => 'https://kaliforms.dev/simple-booking-form-with-payment/',
  228. ];
  229. $this->forms['packageDeliveryRequestForm'] = [
  230. 'name' => esc_html__('Package delivery request', 'kaliforms'),
  231. 'description' => esc_html__('A simple form to fill up some details to pick up a package from a certain location.', 'kaliforms'),
  232. 'pro' => true,
  233. 'premium' => true,
  234. 'class' => 'PredefinedForms\Package_Delivery_Request_Form',
  235. 'thumb' => KALIFORMS_URL . '/assets/img/predefined-forms/package-delivery-request-form.jpg',
  236. 'instance' => $full && class_exists('KaliForms\Inc\Backend\PredefinedForms\Package_Delivery_Request_Form') ? new PredefinedForms\Package_Delivery_Request_Form() : null,
  237. 'demo' => 'https://kaliforms.dev/package-delivery-request-form/',
  238. ];
  239. $this->forms = apply_filters($this->slug . '_predefined_forms', $this->forms);
  240. }
  241. }