説明なし

Form.php 1.7KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. <?php
  2. /*******************************************************************************
  3. * Copyright (c) 2020, WP Popup Maker
  4. ******************************************************************************/
  5. abstract class PUM_Abstract_Integration_Form extends PUM_Abstract_Integration implements PUM_Interface_Integration_Form {
  6. /**
  7. * @var string
  8. */
  9. public $type = 'form';
  10. /**
  11. * @return array
  12. */
  13. abstract public function get_forms();
  14. /**
  15. * @param string $id
  16. *
  17. * @return mixed
  18. */
  19. abstract public function get_form( $id );
  20. /**
  21. * @return array
  22. */
  23. abstract public function get_form_selectlist();
  24. /**
  25. * @param array $js
  26. *
  27. * @return array
  28. */
  29. public function custom_scripts( $js = []) {
  30. return $js;
  31. }
  32. /**
  33. * @param array $css
  34. *
  35. * @return array
  36. */
  37. public function custom_styles( $css = [] ) {
  38. return $css;
  39. }
  40. /**
  41. * Retrieves the popup ID associated with the form, if any
  42. *
  43. * @return false|int
  44. * @since 1.13.0
  45. */
  46. public function get_popup_id() {
  47. return isset( $_REQUEST['pum_form_popup_id'] ) && absint( $_REQUEST['pum_form_popup_id'] ) > 0 ? absint( $_REQUEST['pum_form_popup_id'] ) : false;
  48. }
  49. /**
  50. * Increase the conversion count for popup
  51. *
  52. * @param int $popup_id The ID for the popup.
  53. * @since 1.13.0
  54. */
  55. public function increase_conversion( $popup_id ) {
  56. $popup_id = intval( $popup_id );
  57. $popup = pum_get_popup( $popup_id );
  58. $popup->increase_event_count( 'conversion' );
  59. }
  60. /**
  61. * Returns whether or now we should process any form submissions
  62. *
  63. * @return bool True if we should process the form submission
  64. * @since 1.13.0
  65. */
  66. public function should_process_submission() {
  67. if ( wp_doing_ajax() || defined( 'REST_REQUEST' ) ) {
  68. return false;
  69. }
  70. return true;
  71. }
  72. }