Skip to content

Commit

Permalink
Add conversion counter increase to PHP side of form integration
Browse files Browse the repository at this point in the history
Issue #775
  • Loading branch information
fpcorso committed Oct 9, 2020
1 parent 6f89bac commit 3965e98
Show file tree
Hide file tree
Showing 7 changed files with 103 additions and 12 deletions.
14 changes: 13 additions & 1 deletion classes/Integration/Form/CalderaForms.php
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,20 @@ public function get_form_selectlist() {
* @param array $form
*/
public function on_success( $form ) {
if ( ! isset( $_REQUEST['pum_form_popup_id'] ) ) {
return;
}

$popup_id = absint( $_REQUEST['pum_form_popup_id'] );
if ( 0 === $popup_id ) {
return;
}

$popup = pum_get_popup( $popup_id );
$popup->increase_event_count( 'conversion' );

pum_integrated_form_submission( [
'popup_id' => isset( $_REQUEST['pum_form_popup_id'] ) && absint( $_REQUEST['pum_form_popup_id'] ) > 0 ? absint( $_REQUEST['pum_form_popup_id'] ) : false,
'popup_id' => $popup_id,
'form_provider' => $this->key,
'form_id' => $form['ID'],
] );
Expand Down
18 changes: 14 additions & 4 deletions classes/Integration/Form/ContactForm7.php
Original file line number Diff line number Diff line change
Expand Up @@ -87,11 +87,21 @@ public function get_form_selectlist() {
* @param WPCF7_ContactForm $cfdata
*/
public function on_success( $cfdata ) {
/**
* @see pum_integrated_form_submission
*/

if ( ! isset( $_REQUEST['pum_form_popup_id'] ) ) {
return;
}

$popup_id = absint( $_REQUEST['pum_form_popup_id'] );
if ( 0 === $popup_id ) {
return;
}

$popup = pum_get_popup( $popup_id );
$popup->increase_event_count( 'conversion' );

pum_integrated_form_submission( [
'popup_id' => isset( $_REQUEST['pum_form_popup_id'] ) && absint( $_REQUEST['pum_form_popup_id'] ) > 0 ? absint( $_REQUEST['pum_form_popup_id'] ) : false,
'popup_id' => $popup_id,
'form_provider' => $this->key,
'form_id' => $cfdata->id(),
] );
Expand Down
15 changes: 13 additions & 2 deletions classes/Integration/Form/FormidableForms.php
Original file line number Diff line number Diff line change
Expand Up @@ -95,10 +95,21 @@ public function on_success( $entry_id, $form_id ) {
return;
}

// @see pum_integrated_form_submission
if ( ! isset( $_REQUEST['pum_form_popup_id'] ) ) {
return;
}

$popup_id = absint( $_REQUEST['pum_form_popup_id'] );
if ( 0 === $popup_id ) {
return;
}

$popup = pum_get_popup( $popup_id );
$popup->increase_event_count( 'conversion' );

pum_integrated_form_submission(
[
'popup_id' => isset( $_REQUEST['pum_form_popup_id'] ) && absint( $_REQUEST['pum_form_popup_id'] ) > 0 ? absint( $_REQUEST['pum_form_popup_id'] ) : false,
'popup_id' => $popup_id,
'form_provider' => $this->key,
'form_id' => $form_id,
]
Expand Down
14 changes: 13 additions & 1 deletion classes/Integration/Form/GravityForms.php
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,20 @@ public function get_form_selectlist() {
* @param $form
*/
public function on_success( $entry, $form ) {
if ( ! isset( $_REQUEST['pum_form_popup_id'] ) ) {
return;
}

$popup_id = absint( $_REQUEST['pum_form_popup_id'] );
if ( 0 === $popup_id ) {
return;
}

$popup = pum_get_popup( $popup_id );
$popup->increase_event_count( 'conversion' );

pum_integrated_form_submission( [
'popup_id' => isset( $_REQUEST['pum_form_popup_id'] ) && absint( $_REQUEST['pum_form_popup_id'] ) > 0 ? absint( $_REQUEST['pum_form_popup_id'] ) : false,
'popup_id' => $popup_id,
'form_provider' => $this->key,
'form_id' => $form['id'],
] );
Expand Down
28 changes: 26 additions & 2 deletions classes/Integration/Form/NinjaForms.php
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,21 @@ public function get_form_selectlist() {
*/
public function on_success_v2() {
global $ninja_forms_processing;

if ( ! isset( $_REQUEST['pum_form_popup_id'] ) ) {
return;
}

$popup_id = absint( $_REQUEST['pum_form_popup_id'] );
if ( 0 === $popup_id ) {
return;
}

$popup = pum_get_popup( $popup_id );
$popup->increase_event_count( 'conversion' );

pum_integrated_form_submission( [
'popup_id' => isset( $_REQUEST['pum_form_popup_id'] ) && absint( $_REQUEST['pum_form_popup_id'] ) > 0 ? absint( $_REQUEST['pum_form_popup_id'] ) : false,
'popup_id' => $popup_id,
'form_provider' => $this->key,
'form_id' => $ninja_forms_processing->get_form_ID(),
] );
Expand All @@ -76,8 +89,19 @@ public function on_success_v2() {
* @param $form_data
*/
public function on_success_v3( $form_data ) {
if ( ! isset( $_REQUEST['pum_form_popup_id'] ) ) {
return;
}

$popup_id = absint( $_REQUEST['pum_form_popup_id'] );
if ( 0 === $popup_id ) {
return;
}

$popup = pum_get_popup( $popup_id );
$popup->increase_event_count( 'conversion' );
pum_integrated_form_submission( [
'popup_id' => isset( $_REQUEST['pum_form_popup_id'] ) && absint( $_REQUEST['pum_form_popup_id'] ) > 0 ? absint( $_REQUEST['pum_form_popup_id'] ) : false,
'popup_id' => $popup_id,
'form_provider' => $this->key,
'form_id' => $form_data['form_id'],
] );
Expand Down
13 changes: 12 additions & 1 deletion classes/Integration/Form/PirateForms.php
Original file line number Diff line number Diff line change
Expand Up @@ -127,8 +127,19 @@ public function get_form_selectlist() {
* @param int $entry_id Entry ID. Will return 0 if entry storage is disabled or using WPForms Lite.
*/
public function on_success( $fields, $entry, $form_data, $entry_id ) {
if ( ! isset( $_REQUEST['pum_form_popup_id'] ) ) {
return;
}

$popup_id = absint( $_REQUEST['pum_form_popup_id'] );
if ( 0 === $popup_id ) {
return;
}

$popup = pum_get_popup( $popup_id );
$popup->increase_event_count( 'conversion' );
pum_integrated_form_submission( [
'popup_id' => isset( $_REQUEST['pum_form_popup_id'] ) && absint( $_REQUEST['pum_form_popup_id'] ) > 0 ? absint( $_REQUEST['pum_form_popup_id'] ) : false,
'popup_id' => $popup_id,
'form_provider' => $this->key,
'form_id' => $form_data['id'],
] );
Expand Down
13 changes: 12 additions & 1 deletion classes/Integration/Form/WPForms.php
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,19 @@ public function get_form_selectlist() {
* @param int $entry_id Entry ID. Will return 0 if entry storage is disabled or using WPForms Lite.
*/
public function on_success( $fields, $entry, $form_data, $entry_id ) {
if ( ! isset( $_REQUEST['pum_form_popup_id'] ) ) {
return;
}

$popup_id = absint( $_REQUEST['pum_form_popup_id'] );
if ( 0 === $popup_id ) {
return;
}

$popup = pum_get_popup( $popup_id );
$popup->increase_event_count( 'conversion' );
pum_integrated_form_submission( [
'popup_id' => isset( $_REQUEST['pum_form_popup_id'] ) && absint( $_REQUEST['pum_form_popup_id'] ) > 0 ? absint( $_REQUEST['pum_form_popup_id'] ) : false,
'popup_id' => $popup_id,
'form_provider' => $this->key,
'form_id' => $form_data['id'],
] );
Expand Down

0 comments on commit 3965e98

Please sign in to comment.