Нет описания

developers.php 1.9KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. <?php
  2. /*******************************************************************************
  3. * Copyright (c) 2019, Code Atlantic LLC
  4. ******************************************************************************/
  5. if ( ! defined( 'ABSPATH' ) ) {
  6. exit; // Exit if accessed directly
  7. }
  8. /**
  9. * Call this with a popup ID and it will trigger the
  10. * JS based forms.success function with your settings
  11. * on the next page load.
  12. *
  13. * @since 1.7.0
  14. *
  15. * @param int $popup_id
  16. * @param array $settings
  17. */
  18. function pum_trigger_popup_form_success( $popup_id = null, $settings = array() ) {
  19. if ( ! isset( $popup_id ) ) {
  20. $popup_id = isset( $_REQUEST['pum_form_popup_id'] ) && absint( $_REQUEST['pum_form_popup_id'] ) > 0 ? absint( $_REQUEST['pum_form_popup_id'] ) : false;
  21. }
  22. if ( $popup_id ) {
  23. PUM_Integrations::$form_success = array(
  24. 'popup_id' => $popup_id,
  25. 'settings'=> $settings
  26. );
  27. }
  28. }
  29. /**
  30. * @param array $args {
  31. * An array of parameters that customize the way the parser works.
  32. *
  33. * @type string $form_provider Key indicating which form provider this form belongs to.
  34. * @type string|int $form_id Form ID, usually numeric, but can be hash based.
  35. * @type int $form_instance_id Optional form instance ID.
  36. * @type int $popup_id Optional popup ID.
  37. * @type bool $ajax If the submission was processed via AJAX. Generally gonna be false outside of JavaScript.
  38. * @type bool $tracked Whether the submission has been handled by tracking code or not. Prevents duplicates.
  39. * }
  40. */
  41. function pum_integrated_form_submission( $args = [] ) {
  42. $args = wp_parse_args( $args, [
  43. 'popup_id' => null,
  44. 'form_provider' => null,
  45. 'form_id' => null,
  46. 'form_instance_id' => null,
  47. 'ajax' => false,
  48. 'tracked' => false,
  49. ] );
  50. $args = apply_filters( 'pum_integrated_form_submission_args', $args );
  51. PUM_Integrations::$form_submission = $args;
  52. do_action( 'pum_integrated_form_submission', $args );
  53. }