Commit inicial - WordPress Análisis de Precios Unitarios

- WordPress core y plugins
- Tema Twenty Twenty-Four configurado
- Plugin allow-unfiltered-html.php simplificado
- .gitignore configurado para excluir wp-config.php y uploads

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
root
2025-11-03 21:04:30 -06:00
commit a22573bf0b
24068 changed files with 4993111 additions and 0 deletions

View File

@@ -0,0 +1,202 @@
<?php
#[AllowDynamicProperties]
class BWFCRM_Form_Breakdance extends BWFCRM_Form_Base {
private $total_selections = 1;
private $source = 'breakdance';
/** Form Submission Captured Data */
public $form_id = 0;
public $form_title = '';
public $fields = [];
public $email = '';
public $first_name = '';
public $last_name = '';
public $contact_phone = '';
public $mark_subscribe = false;
public $entry = [];
private $autonami_event = '';
public function get_source() {
return $this->source;
}
/**
* Get the Breakdance form editor link.
*
* @param BWFCRM_Form_Feed $feed
*
* @return string
*/
public function get_form_link( $feed ) {
$form_id = $feed->get_data( 'form_id' );
$page_id = $feed->get_data( 'page_id' );
if ( $form_id && $page_id ) {
return admin_url( 'post.php?post=' . absint( $page_id ) . '&action=edit' ); // Fixed missing closing parenthesis
}
return '';
}
/**
* Capture asynchronous form submission.
*/
public function capture_async_submission() {
$this->form_post_id = isset( BWFAN_Common::$events_async_data['form_post_id'] ) ? BWFAN_Common::$events_async_data['form_post_id'] : '';
$this->form_id = get_post_meta( $this->form_post_id, '_breakdance_form_id', true );
$form_fields = get_post_meta( $this->form_post_id, '_breakdance_fields', true );
$this->email = sanitize_email( $form_fields['email'] ?? '' );
$this->entry = $form_fields;
$this->find_feeds_and_create_contacts();
}
/**
* Filter feeds for the current form entry.
*
* @return array
*/
public function filter_feeds_for_current_entry() {
return array_filter( $this->feeds, function ( $feed ) {
$feed_form_id = $feed->get_data( 'form_id' );
return absint( $this->form_id ) === absint( $feed_form_id );
} );
}
/**
* Prepare contact data from mapped fields.
*
* @param array $mapped_fields
*
* @return array
*/
public function prepare_contact_data_from_feed_entry( $mapped_fields ) {
$contact_data = [];
foreach ( $this->entry as $key => $item ) {
if ( isset( $mapped_fields[ $key ] ) ) {
$contact_field = is_numeric( $mapped_fields[ $key ] ) ? absint( $mapped_fields[ $key ] ) : sanitize_text_field( $mapped_fields[ $key ] );
$contact_data[ $contact_field ] = sanitize_text_field( $this->entry[ $key ] );
}
}
return $contact_data;
}
/**
* Get form fields for a specific feed.
*
* @param BWFCRM_Form_Feed $feed
*
* @return array|WP_Error
*/
public function get_form_fields( $feed ) {
$form_id = $feed->get_data( 'form_id' );
if ( empty( $form_id ) ) {
return BWFCRM_Common::crm_error( __( 'No Form ID provided', 'wp-marketing-automations-pro' ) );
}
return $this->get_breakdance_form_fields( $form_id );
}
/**
* Get Breakdance form fields by form ID.
*
* @param int $form_id
*
* @return array|WP_Error
*/
public function get_breakdance_form_fields( $form_id ) {
if ( empty( $form_id ) ) {
return BWFCRM_Common::crm_error( __( 'Form Feed doesn\'t have sufficient data to get fields: ' . $form_id, 'wp-marketing-automations-pro' ) );
}
/** @var BWFAN_Breakdance_Form_Submit $event */
$event = BWFAN_Core()->sources->get_event( 'breakdance_form_submit' );
if ( ! $event instanceof BWFAN_Breakdance_Form_Submit ) {
return BWFCRM_Common::crm_error( __( 'Form Funnelkit Automations Event not found for Feed: ' . $form_id, 'wp-marketing-automations-pro' ) );
}
$final_arr = [];
$form_fields = BWFAN_PRO_Common::get_breakdance_form_fields( $form_id );
if ( ! empty( $form_fields ) ) {
foreach ( $form_fields as $key => $field_name ) {
if ( ! empty( $key ) && ! empty( $field_name ) ) {
$final_arr[ $key ] = sanitize_text_field( $field_name );
}
}
}
return $final_arr;
}
/**
* Get form selection options.
*
* @param array $args
* @param bool $return_all_available
*
* @return array
*/
public function get_form_selection( $args, $return_all_available = false ) {
$form_options = [];
$forms = BWFAN_PRO_Common::get_all_breakdance_forms();
if ( ! empty( $forms ) ) {
foreach ( $forms as $form ) {
$form_options[ $form['id'] ] = esc_html( $form['title'] );
}
}
return $this->get_step_selection_array( 'Form', 'form_id', 1, [ 'default' => $form_options ] );
}
public function get_total_selection_steps() {
return $this->total_selections;
}
public function get_meta() {
return [
'form_selection_fields' => [
'form_id' => 'Form ID'
]
];
}
/**
* Update form selection for a feed.
*
* @param array $args
* @param int $feed_id
*
* @return bool|WP_Error
*/
public function update_form_selection( $args, $feed_id ) {
if ( empty( $feed_id ) ) {
return BWFCRM_Common::crm_error( __( 'Empty Feed ID provided', 'wp-marketing-automations-pro' ) );
}
$form_id = isset( $args['form_id'] ) && ! empty( $args['form_id'] ) ? absint( $args['form_id'] ) : false;
$feed = new BWFCRM_Form_Feed( $feed_id );
if ( ! $feed->is_feed_exists() ) {
return BWFCRM_Common::crm_error( __( 'Feed with ID does not exist: ' . $feed_id, 'wp-marketing-automations-pro' ) );
}
if ( empty( $form_id ) && $this->source === $feed->get_source() ) {
return false;
}
$feed->unset_data( 'form_id' );
$feed->get_source() !== $this->source && $feed->set_source( $this->source );
! empty( $form_id ) && $feed->set_data( 'form_id', $form_id );
return $feed->save( true );
}
}
if ( function_exists( 'bwfan_is_breakdance_active' ) && bwfan_is_breakdance_active() ) {
BWFCRM_Core()->forms->register( 'breakdance', 'BWFCRM_Form_Breakdance', 'Breakdance', [ 'breakdance_form_submit' ] );
}

View File

@@ -0,0 +1,163 @@
<?php
#[AllowDynamicProperties]
class BWFCRM_Form_Divi extends BWFCRM_Form_Base {
private $total_selections = 1;
private $source = 'divi_form';
/** Form Submission Captured Data */
private $form_id = '';
private $form_title = '';
private $fields = [];
private $entry = [];
private $email = [];
private $autonami_event = '';
public function get_source() {
return $this->source;
}
/**
* @param BWFCRM_Form_Feed $feed
*
* @return string|void
*/
public function get_form_link( $feed ) {
$url = '';
$form_id = $feed->get_data( 'form_id' );
if ( $form_id ) {
$url = admin_url( 'post.php?post=' . absint( $form_id ) . '&action=edit' );
}
return $url;
}
public function capture_async_submission() {
$this->form_id = BWFAN_Common::$events_async_data['form_id'];
$this->form_title = BWFAN_Common::$events_async_data['form_title'];
$this->entry = BWFAN_Common::$events_async_data['entry'];
$this->fields = BWFAN_Common::$events_async_data['fields'];
$this->email = isset( BWFAN_Common::$events_async_data['email'] ) ? BWFAN_Common::$events_async_data['email'] : '';
$this->autonami_event = BWFAN_Common::$events_async_data['event'];
$this->find_feeds_and_create_contacts();
}
public function filter_feeds_for_current_entry() {
return array_filter( array_map( function ( $feed ) {
$feed_form_id = $feed->get_data( 'form_id' );
$submitted_unique_id = BWFAN_Divi_Forms_Common::extract_unique_form_id( $this->form_id );
$saved_unique_id = BWFAN_Divi_Forms_Common::extract_unique_form_id( $feed_form_id );
if ( strval( $this->form_id ) !== strval( $feed_form_id ) && strval( $submitted_unique_id ) !== strval( $saved_unique_id ) ) {
return false;
}
return $feed;
}, $this->feeds ) );
}
public function prepare_contact_data_from_feed_entry( $mapped_fields ) {
$contact_data = array();
foreach ( $this->entry as $key => $item ) {
if ( isset( $mapped_fields[ $key ] ) ) {
$contact_field = is_numeric( $mapped_fields[ $key ] ) ? absint( $mapped_fields[ $key ] ) : $mapped_fields[ $key ];
$contact_data[ $contact_field ] = $this->entry[ $key ];
}
}
return $contact_data;
}
public function get_form_fields( $feed ) {
if ( ! $feed instanceof BWFCRM_Form_Feed ) {
return BWFCRM_Common::crm_error( __( 'Feed not Exists: ', 'wp-marketing-automations-pro' ) );
}
$feed_id = $feed->get_id();
if ( ! $feed->is_feed_exists() ) {
return BWFCRM_Common::crm_error( __( 'No Feed Exists: ' . $feed_id, 'wp-marketing-automations-pro' ) );
}
$form_id = $feed->get_data( 'form_id' );
if ( empty( $form_id ) ) {
return BWFCRM_Common::crm_error( __( 'Form Feed doesn\'t have sufficient data to get fields: ' . $feed_id, 'wp-marketing-automations-pro' ) );
}
return $this->get_divi_form_fields( $form_id );
}
public function get_divi_form_fields( $form_id ) {
if ( empty( $form_id ) ) {
return BWFCRM_Common::crm_error( __( 'Form Feed doesn\'t have sufficient data to get fields: ' . $feed_id, 'wp-marketing-automations-pro' ) );
}
/** @var BWFAN_Divi_Form_Submit $event */
$event = BWFAN_Core()->sources->get_event( 'divi_form_submit' );
if ( ! $event instanceof BWFAN_Divi_Form_Submit ) {
return BWFCRM_Common::crm_error( __( 'Form Funnelkit Automations Event doesn\'t found for Feed: ' . $feed_id, 'wp-marketing-automations-pro' ) );
}
return $event->get_form_fields( $form_id );
}
public function get_form_selection( $args, $return_all_available = false ) {
/** @var BWFAN_Fluent_Form_Submit $event */
$event = BWFAN_Core()->sources->get_event( 'divi_form_submit' );
if ( ! $event instanceof BWFAN_Divi_Form_Submit ) {
return BWFCRM_Common::crm_error( __( 'Form FunnelKit Automations Event doesn\'t found for Feed: ' . $feed_id, 'wp-marketing-automations-pro' ) );
}
$form_options = $event->get_view_data();
$form_options = array( 'default' => $form_options );
$form_options = $this->get_step_selection_array( 'Form', 'form_id', 1, $form_options );
return $form_options;
}
public function get_total_selection_steps() {
return $this->total_selections;
}
public function get_meta() {
return array(
'form_selection_fields' => array(
'form_id' => 'Form ID'
)
);
}
/**
* @param $args
* @param $feed_id
*
* @return bool|WP_Error
*/
public function update_form_selection( $args, $feed_id ) {
if ( empty( $feed_id ) ) {
return BWFCRM_Common::crm_error( __( 'Empty Feed ID provided', 'wp-marketing-automations-pro' ) );
}
$form_id = isset( $args['form_id'] ) && ! empty( $args['form_id'] ) ? $args['form_id'] : false;
$feed = new BWFCRM_Form_Feed( $feed_id );
if ( ! $feed->is_feed_exists() ) {
return BWFCRM_Common::crm_error( __( 'Feed with ID not exists: ' . $feed_id, 'wp-marketing-automations-pro' ) );
}
if ( empty( $form_id ) && $this->source === $feed->get_source() ) {
return false;
}
$feed->unset_data( 'form_id' );
$feed->get_source() !== $this->source && $feed->set_source( $this->source );
! empty( $form_id ) && $feed->set_data( 'form_id', $form_id );
return ! ! $feed->save( true );
}
}
if ( function_exists( 'bwfan_is_divi_forms_active' ) && bwfan_is_divi_forms_active() ) {
BWFCRM_Core()->forms->register( 'divi_form', 'BWFCRM_Form_Divi', 'Divi Forms', array(
'divi_form_submit'
) );
}

View File

@@ -0,0 +1,431 @@
<?php
#[AllowDynamicProperties]
class BWFCRM_Form_Elementor extends BWFCRM_Form_Base {
public static $TYPE_FORM = 'form';
public static $TYPE_POPUP_FORM = 'popup';
private $total_selections = 3;
private $source = 'elementor';
/** Form Submission Captured Data */
private $form_id = '';
private $page_id = 0;
private $form_title = '';
private $fields = array();
private $entry = array();
private $autonami_event = '';
private $post_id = 0;
/** Form WP ID of the Submitted Form, obtained from form's page_id and form_id */
private $submitted_form_wp_id = 0;
public function get_source() {
return $this->source;
}
/**
* @param BWFCRM_Form_Feed $feed
*
* @return string|void
*/
public function get_form_link( $feed ) {
$url = '';
$page_id = $feed->get_data( 'page_id' );
if ( $page_id ) {
$url = admin_url( 'post.php?post=' . absint( $page_id ) . '&action=elementor' );
}
return $url;
}
public function capture_async_submission() {
$this->form_id = isset( BWFAN_Common::$events_async_data['form_id'] ) ? BWFAN_Common::$events_async_data['form_id'] : 0;
$this->page_id = isset( BWFAN_Common::$events_async_data['page_id'] ) ? BWFAN_Common::$events_async_data['page_id'] : 0;
$this->form_title = isset( BWFAN_Common::$events_async_data['form_title'] ) ? BWFAN_Common::$events_async_data['form_title'] : '';
$this->fields = isset( BWFAN_Common::$events_async_data['fields'] ) ? BWFAN_Common::$events_async_data['fields'] : [];
$this->entry = isset( BWFAN_Common::$events_async_data['entry'] ) ? BWFAN_Common::$events_async_data['entry'] : [];
$this->post_id = isset( BWFAN_Common::$events_async_data['post_id'] ) ? BWFAN_Common::$events_async_data['post_id'] : 0;
$this->autonami_event = BWFAN_Common::$events_async_data['event'];
$this->find_feeds_and_create_contacts();
}
public function filter_feeds_for_current_entry() {
/** @var BWFAN_Elementor_PopUp_Form_Submit|BWFAN_Elementor_Form_Submit $event */
$event = BWFAN_Core()->sources->get_event( $this->autonami_event );
if ( is_null( $event ) ) {
return false;
}
return array_filter( array_map( function ( $feed ) use ( $event ) {
if ( $event instanceof BWFAN_Elementor_Form_Submit ) {
return $this->elementor_form_submits_is_feed_valid( $feed, $event );
} else {
return $this->elementor_popup_form_submits_is_feed_valid( $feed, $event );
}
}, $this->feeds ) );
}
/**
* @param BWFCRM_Form_Feed $feed
* @param BWFAN_Elementor_PopUp_Form_Submit|BWFAN_Elementor_Form_Submit $event
*
* @return BWFCRM_Form_Feed|false
*/
private function elementor_form_submits_is_feed_valid( $feed, $event ) {
$feed_form_id = $feed->get_data( 'form_id' );
$feed_page_id = $feed->get_data( 'page_id' );
$type = $feed->get_data( 'form_type' );
if ( $type !== 'form' ) {
return false;
}
/** Simple Form Submission (not from Global Widget's Form) */
if ( ( $feed_form_id === $this->form_id ) && ( absint( $feed_page_id ) === absint( $this->post_id ) ) ) {
return $feed;
}
/** Now Check if the form is submitted from Global Widget */
/** Step 1: Fetch the form_wp_id of Submitted Form, with form's page_id and form_id */
if ( empty( $this->submitted_form_wp_id ) ) {
$this->submitted_form_wp_id = $event->maybe_get_global_form_wp_id( $this->page_id, $this->form_id );
}
/** Step 2: If submitted_form_wp_id is empty then fetch form using post id */
if ( empty( $this->submitted_form_wp_id ) ) {
$this->submitted_form_wp_id = $event->maybe_get_global_form_wp_id( $this->post_id, $this->form_id );
}
/**
* Step 3: Check if the Submitted Form's form_wp_id matches with the Feed's Form ID,
* then it's a Global Widget Form Submission, and it is a match
*/
if ( ! empty( $this->submitted_form_wp_id ) && absint( $this->submitted_form_wp_id ) === absint( $feed_form_id ) ) {
return $feed;
}
/** Return false on no match from either of the Simple Form, or Global Form */
return false;
}
/**
* @param BWFCRM_Form_Feed $feed
*
* @return BWFCRM_Form_Feed|false
*/
private function elementor_popup_form_submits_is_feed_valid( $feed, $event ) {
$form_id = $feed->get_data( 'form_id' );
$page_id = $feed->get_data( 'page_id' );
$type = $feed->get_data( 'form_type' );
if ( $type !== 'popup' ) {
return false;
}
/** Simple Form Submission (not from Global Widget's Form) */
if ( ( $form_id === $this->form_id ) && ( absint( $page_id ) === absint( $this->post_id ) ) ) {
return $feed;
}
/** Now Check if the form is submitted from Global Widget */
/** Step 1: Fetch the form_wp_id of Submitted Form, with form's page_id and form_id */
if ( empty( $this->submitted_form_wp_id ) ) {
$this->submitted_form_wp_id = $event->maybe_get_global_form_wp_id( $this->page_id, $this->form_id );
}
/**
* Step 2: Check if the Submitted Form's form_wp_id matches with the Feed's Form ID,
* then it's a Global Widget Form Submission, and it is a match
*/
if ( ! empty( $this->submitted_form_wp_id ) && absint( $this->submitted_form_wp_id ) === absint( $form_id ) ) {
return $feed;
}
/** Return false on no match from either of the Simple Form, or Global Form */
return false;
}
public function prepare_contact_data_from_feed_entry( $mapped_fields ) {
$contact_data = array();
foreach ( $this->entry as $key => $item ) {
if ( isset( $mapped_fields[ $key ] ) ) {
$contact_field = is_numeric( $mapped_fields[ $key ] ) ? absint( $mapped_fields[ $key ] ) : $mapped_fields[ $key ];
$contact_data[ $contact_field ] = is_array( $this->entry[ $key ] ) ? wp_json_encode( $this->entry[ $key ] ) : $this->entry[ $key ];
}
}
return $contact_data;
}
public function get_form_fields( $feed ) {
if ( ! $feed instanceof BWFCRM_Form_Feed ) {
return BWFCRM_Common::crm_error( __( 'Feed not Exists: ', 'wp-marketing-automations-pro' ) );
}
$feed_id = $feed->get_id();
if ( ! $feed->is_feed_exists() ) {
return BWFCRM_Common::crm_error( __( 'No Feed Exists ', 'wp-marketing-automations-pro' ) );
}
$form_type = $feed->get_data( 'form_type' );
$page_id = absint( $feed->get_data( 'page_id' ) );
$form_id = $feed->get_data( 'form_id' );
if ( empty( $form_type ) || empty( $page_id ) || empty( $form_id ) ) {
return BWFCRM_Common::crm_error( __( 'Form Feed doesn\'t have sufficient data to get fields: ' . $feed_id, 'wp-marketing-automations-pro' ) );
}
$forms = $this->get_form_options( $page_id, $form_type, 'other' );
$form = is_array( $forms ) && isset( $forms[ $form_id ] ) ? $forms[ $form_id ] : array();
$form_fields = is_array( $form ) && is_array( $form['form_fields'] ) ? $form['form_fields'] : array();
$return_fields = array();
foreach ( $form_fields as $field ) {
$return_fields[ $field['field_slug'] ] = $field['field_label'];
}
return $return_fields;
}
public function is_selected_form_valid( $feed ) {
if ( ! $feed instanceof BWFCRM_Form_Feed ) {
return false;
}
$data = $feed->get_data();
if ( ! is_array( $data ) || empty( $data ) ) {
return false;
}
$steps = $this->get_form_selection_valaidation( $data, true );
return $this->verify_selected_data( $steps, $data );
}
public function get_form_selection_valaidation( $args, $return_all_available = false ) {
$all_selections = array();
/** Form Type Handling */
$form_type = ! empty( $args['form_type'] ) ? $args['form_type'] : false;
if ( empty( $form_type ) || true === $return_all_available ) {
$type_options = $this->get_step_selection_array( __( 'Form Type', 'wp-marketing-automations-pro' ), 'form_type', 1, array(
'default' => array( // default (No Option Group Heading)
self::$TYPE_FORM => __( 'Form (Page/Global Widget)', 'wp-marketing-automations-pro' ),
self::$TYPE_POPUP_FORM => __( 'Popup Form', 'wp-marketing-automations-pro' ),
),
) );
if ( ! $return_all_available ) {
return $type_options;
} else {
$all_selections = array_replace( $all_selections, $type_options );
}
}
/** Page ID Handling */
$page_id = isset( $args['page_id'] ) && ! empty( $args['page_id'] ) ? $args['page_id'] : false;
if ( ( empty( $page_id ) || true === $return_all_available ) && ! empty( $form_type ) ) {
global $wpdb;
$query = $wpdb->prepare( "SELECT p.id as post_id, p.post_title as post_title, p.post_type as type FROM {$wpdb->prefix}posts as p JOIN {$wpdb->prefix}postmeta as pm WHERE p.id = pm.post_id AND p.id = %d AND pm.meta_key = %s AND pm.meta_value LIKE %s", $page_id, '_elementor_data', '%"widgetType":"form"%' );
$page_options = $wpdb->get_results( $query, ARRAY_A );//phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching
$return_options = array();
foreach ( $page_options as $post ) {
$return_options['Page'][ $post['post_id'] ] = $post['post_title'];;
}
$type_text = self::$TYPE_FORM === $form_type ? __( 'Page', 'wp-marketing-automations-pro' ) : __( 'Popup', 'wp-marketing-automations-pro' );
$return_options = $this->get_step_selection_array( $type_text, 'page_id', 2, $return_options );
if ( ! $return_all_available ) {
return $return_options;
} else {
$all_selections = array_replace( $all_selections, $return_options );
}
}
/** Form ID Handling */
$form_id = isset( $args['form_id'] ) && ! empty( $args['form_id'] ) ? $args['form_id'] : false;
if ( ( empty( $form_id ) || true === $return_all_available ) && ! empty( $page_id ) ) {
$form_options = $this->get_form_options( absint( $page_id ), $form_type );
$form_options = array( 'default' => $form_options );
$form_options = $this->get_step_selection_array( __( 'Form', 'wp-marketing-automations-pro' ), 'form_id', 3, $form_options );
if ( ! $return_all_available ) {
return $form_options;
} else {
$all_selections = array_replace( $all_selections, $form_options );
}
}
/** $return_all_available is true; */
return $all_selections;
}
public function get_form_selection( $args, $return_all_available = false ) {
$all_selections = array();
/** Form Type Handling */
$form_type = isset( $args['form_type'] ) && ! empty( $args['form_type'] ) ? $args['form_type'] : false;
if ( empty( $form_type ) || true === $return_all_available ) {
$type_options = $this->get_step_selection_array( __( 'Form Type', 'wp-marketing-automations-pro' ), 'form_type', 1, array(
'default' => array( // default (No Option Group Heading)
self::$TYPE_FORM => __( 'Form (Page/Global Widget)', 'wp-marketing-automations-pro' ),
self::$TYPE_POPUP_FORM => __( 'Popup Form', 'wp-marketing-automations-pro' ),
),
) );
if ( ! $return_all_available ) {
return $type_options;
} else {
$all_selections = array_replace( $all_selections, $type_options );
}
}
/** Page ID Handling */
$page_id = isset( $args['page_id'] ) && ! empty( $args['page_id'] ) ? $args['page_id'] : false;
if ( ( empty( $page_id ) || true === $return_all_available ) && ! empty( $form_type ) ) {
$page_options = $this->get_page_options( $form_type );
$type_text = self::$TYPE_FORM === $form_type ? __( 'Page', 'wp-marketing-automations-pro' ) : __( 'Popup', 'wp-marketing-automations-pro' );
$page_options = $this->get_step_selection_array( $type_text, 'page_id', 2, $page_options );
if ( ! $return_all_available ) {
return $page_options;
} else {
$all_selections = array_replace( $all_selections, $page_options );
}
}
/** Form ID Handling */
$form_id = isset( $args['form_id'] ) && ! empty( $args['form_id'] ) ? $args['form_id'] : false;
if ( ( empty( $form_id ) || true === $return_all_available ) && ! empty( $page_id ) ) {
$form_options = $this->get_form_options( absint( $page_id ), $form_type );
$form_options = array( 'default' => $form_options );
$form_options = $this->get_step_selection_array( __( 'Form', 'wp-marketing-automations-pro' ), 'form_id', 3, $form_options );
if ( ! $return_all_available ) {
return $form_options;
} else {
$all_selections = array_replace( $all_selections, $form_options );
}
}
/** $return_all_available is true; */
return $all_selections;
}
public function get_total_selection_steps() {
return $this->total_selections;
}
public function get_meta() {
return array(
'form_selection_fields' => array(
'form_type' => __( 'Form Type', 'wp-marketing-automations-pro' ),
'page_id' => __( 'Page ID', 'wp-marketing-automations-pro' ),
'form_id' => __( 'Form ID', 'wp-marketing-automations-pro' ),
),
);
}
public function get_page_options( $form_type ) {
$is_popup = self::$TYPE_POPUP_FORM === $form_type;
$page_options = BWFAN_Elementor_Common::get_elementor_form_by_type( $is_popup, true );
if ( ! is_array( $page_options ) && empty( $page_options ) ) {
return array();
}
$return_options = array();
foreach ( $page_options as $option_group ) {
$title = $option_group['title'];
if ( ! isset( $option_group['posts'] ) || ! is_array( $option_group['posts'] ) || empty( $option_group['posts'] ) ) {
continue;
}
$group = array();
foreach ( $option_group['posts'] as $post ) {
$group[ $post['post_id'] ] = $post['post_title'];
}
$return_options[ $title ] = $group;
}
return $return_options;
}
/**
* @param $page_id
* @param $form_type
* @param string $context
*
* @return array
*/
public function get_form_options( $page_id, $form_type, $context = 'selection' ) {
$event = $form_type === self::$TYPE_FORM ? 'elementor_form_submit' : 'elementor_popup_form_submit';
/** @var BWFAN_Elementor_Form_Submit|BWFAN_Elementor_PopUp_Form_Submit $event */
$event = BWFAN_Core()->sources->get_event( $event );
if ( is_null( $event ) ) {
return array();
}
$forms = $event->get_page_form_data( absint( $page_id ) );
$return_forms = array();
foreach ( $forms as $form ) {
switch ( $context ) {
case 'selection':
$return_forms[ $form['form_id'] ] = $form['form_name'];
break;
case 'other':
default:
$return_forms[ $form['form_id'] ] = $form;
}
}
return $return_forms;
}
/**
* @param $args
* @param $feed_id
*
* @return bool|WP_Error
*/
public function update_form_selection( $args, $feed_id ) {
if ( empty( $feed_id ) ) {
return BWFCRM_Common::crm_error( __( 'Empty Feed ID provided', 'wp-marketing-automations-pro' ) );
}
$form_type = ! empty( $args['form_type'] ) ? $args['form_type'] : false;
$page_id = ! empty( $args['page_id'] ) ? $args['page_id'] : false;
$form_id = ! empty( $args['form_id'] ) ? $args['form_id'] : false;
$feed = new BWFCRM_Form_Feed( $feed_id );
if ( ! $feed->is_feed_exists() ) {
return BWFCRM_Common::crm_error( sprintf( __( 'Feed with ID not exists: %d', 'wp-marketing-automations-pro' ), $feed_id ) );
}
if ( empty( $form_type ) && empty( $page_id ) && empty( $form_id ) && 'elementor' === $feed->get_source() ) {
return false;
}
$feed->unset_data( 'form_type' );
$feed->unset_data( 'page_id' );
$feed->unset_data( 'form_id' );
$feed->get_source() !== 'elementor' && $feed->set_source( 'elementor' );
! empty( $form_type ) && $feed->set_data( 'form_type', $form_type );
! empty( $page_id ) && $feed->set_data( 'page_id', absint( $page_id ) );
! empty( $form_id ) && $feed->set_data( 'form_id', $form_id );
return ! ! $feed->save( true );
}
}
if ( bwfan_is_elementorpro_active() ) {
BWFCRM_Core()->forms->register( 'elementor', 'BWFCRM_Form_Elementor', 'Elementor', array(
'elementor_form_submit',
'elementor_popup_form_submit',
) );
}

View File

@@ -0,0 +1,183 @@
<?php
#[AllowDynamicProperties]
class BWFCRM_Form_Fluent_Forms extends BWFCRM_Form_Base {
private $total_selections = 1;
private $source = 'fluent';
/** Form Submission Captured Data */
private $form_id = '';
private $form_title = '';
private $fields = [];
private $insert_id = '';
private $autonami_event = '';
public function get_source() {
return $this->source;
}
/**
* @param BWFCRM_Form_Feed $feed
*
* @return string|void
*/
public function get_form_link( $feed ) {
$url = '';
$form_id = $feed->get_data( 'form_id' );
if ( $form_id ) {
$url = admin_url( 'admin.php?page=fluent_forms&route=editor&form_id=' . absint( $form_id ) );
}
return $url;
}
public function capture_async_submission() {
$this->form_id = BWFAN_Common::$events_async_data['form_id'];
$this->form_title = BWFAN_Common::$events_async_data['form_title'];
$this->fields = BWFAN_Common::$events_async_data['fields'];
$this->insert_id = BWFAN_Common::$events_async_data['insert_id'];
$this->autonami_event = BWFAN_Common::$events_async_data['event'];
$this->find_feeds_and_create_contacts();
}
public function filter_feeds_for_current_entry() {
return array_filter( array_map( function ( $feed ) {
$feed_form_id = $feed->get_data( 'form_id' );
if ( absint( $this->form_id ) !== absint( $feed_form_id ) ) {
return false;
}
return $feed;
}, $this->feeds ) );
}
public function prepare_contact_data_from_feed_entry( $mapped_fields ) {
$contact_data = [];
foreach ( $this->fields as $key => $item ) {
/** If Entry field is not group of field values ie: name[first, last] */
if ( ! is_array( $item ) && isset( $mapped_fields[ $key ] ) ) {
$contact_field = is_numeric( $mapped_fields[ $key ] ) ? absint( $mapped_fields[ $key ] ) : $mapped_fields[ $key ];
$contact_data[ $contact_field ] = $item;
continue;
}
/** If Entry field is a group of field values ie: name[first, last] */
if ( is_array( $item ) ) {
$key_value = $this->maybe_get_key_value_from_grouped_field( $key, $item, $mapped_fields );
if ( is_array( $key_value ) && ! empty( $key_value ) ) {
$contact_data = array_replace( $contact_data, $key_value );
}
}
}
return $contact_data;
}
public function maybe_get_key_value_from_grouped_field( $entry_key, $entry_value, $mapped_fields ) {
$key_value = [];
foreach ( $mapped_fields as $key => $crm_field ) {
/** Entry Group not matched with $mapped_field key's group */
if ( false === strpos( $key, $entry_key . ':' ) ) {
if ( $key === $entry_key && isset( $mapped_fields[ $key ] ) ) {
$key_value[ $crm_field ] = is_array( $entry_value ) ? wp_json_encode( $entry_value ) : $entry_value;
}
continue;
}
$mapped_array = explode( ':', $key );
//$mapped_group = $mapped_array[0];
$mapped_field = $mapped_array[1];
if ( isset( $entry_value[ $mapped_field ] ) ) {
$key_value[ $crm_field ] = is_array( $entry_value[ $mapped_field ] ) ? wp_json_encode( $entry_value[ $mapped_field ] ) : $entry_value[ $mapped_field ];
}
}
return $key_value;
}
public function get_form_fields( $feed ) {
if ( ! $feed instanceof BWFCRM_Form_Feed ) {
return BWFCRM_Common::crm_error( __( 'Feed Not Exists ', 'wp-marketing-automations-pro' ) );
}
$feed_id = $feed->get_id();
if ( ! $feed->is_feed_exists() ) {
return BWFCRM_Common::crm_error( __( 'No Feed Exists: ' . $feed_id, 'wp-marketing-automations-pro' ) );
}
$form_id = $feed->get_data( 'form_id' );
if ( empty( $form_id ) ) {
return BWFCRM_Common::crm_error( __( 'Form Feed doesn\'t have sufficient data to get fields: ' . $feed_id, 'wp-marketing-automations-pro' ) );
}
/** @var BWFAN_Fluent_Form_Submit $event */
$event = BWFAN_Core()->sources->get_event( 'fluent_form_submit' );
if ( ! $event instanceof BWFAN_Fluent_Form_Submit ) {
return BWFCRM_Common::crm_error( __( 'Form FunnelKit Automations Event doesn\'t found for Feed: ' . $feed_id, 'wp-marketing-automations-pro' ) );
}
return $event->get_form_fields( $form_id );
}
public function get_form_selection( $args, $return_all_available = false ) {
/** Form ID Handling */
$fluent_forms = wpFluent()->table( 'fluentform_forms' )->select( [ 'id', 'title' ] )->orderBy( 'id', 'DESC' )->get();
$form_options = [];
foreach ( $fluent_forms as $form ) {
$form_options[ $form->id ] = $form->title;
}
$form_options = array( 'default' => $form_options );
$form_options = $this->get_step_selection_array( 'Form', 'form_id', 1, $form_options );
return $form_options;
}
public function get_total_selection_steps() {
return $this->total_selections;
}
public function get_meta() {
return array(
'form_selection_fields' => array(
'form_id' => 'Form ID'
)
);
}
/**
* @param $args
* @param $feed_id
*
* @return bool|WP_Error
*/
public function update_form_selection( $args, $feed_id ) {
if ( empty( $feed_id ) ) {
return BWFCRM_Common::crm_error( __( 'Empty Feed ID provided', 'wp-marketing-automations-pro' ) );
}
$form_id = isset( $args['form_id'] ) && ! empty( $args['form_id'] ) ? $args['form_id'] : false;
$feed = new BWFCRM_Form_Feed( $feed_id );
if ( ! $feed->is_feed_exists() ) {
return BWFCRM_Common::crm_error( __( 'Feed with ID not exists: ' . $feed_id, 'wp-marketing-automations-pro' ) );
}
if ( empty( $form_id ) && $this->source === $feed->get_source() ) {
return false;
}
$feed->unset_data( 'form_id' );
$feed->get_source() !== $this->source && $feed->set_source( $this->source );
! empty( $form_id ) && $feed->set_data( 'form_id', $form_id );
return ! ! $feed->save( true );
}
}
if ( bwfan_is_fluent_forms_active() ) {
BWFCRM_Core()->forms->register( 'fluent', 'BWFCRM_Form_Fluent_Forms', 'Fluent Forms', array(
'fluent_form_submit'
) );
}

View File

@@ -0,0 +1,198 @@
<?php
#[AllowDynamicProperties]
class BWFCRM_Form_Formidable extends BWFCRM_Form_Base {
private $total_selections = 1;
private $source = 'formidable';
/** Form Submission Captured Data */
public $form_id = 0;
public $form_title = '';
public $entry = [];
public $fields = [];
public $email = '';
public $entry_id = '';
public $first_name = '';
public $last_name = '';
public $contact_phone = '';
public $mark_subscribe = false;
private $autonami_event = '';
public function get_source() {
return $this->source;
}
/**
* @param BWFCRM_Form_Feed $feed
*
* @return string|void
*/
public function get_form_link( $feed ) {
$url = '';
$form_id = $feed->get_data( 'form_id' );
if ( $form_id ) {
$url = admin_url( 'admin.php?page=formidable-cform-wizard&id=' . absint( $form_id ) );
}
return $url;
}
/**
* Async
*
*/
public function capture_async_submission() {
$this->entry = isset( BWFAN_Common::$events_async_data['entry'] ) ? BWFAN_Common::$events_async_data['entry'] : array();
$this->fields = isset( BWFAN_Common::$events_async_data['fields'] ) ? BWFAN_Common::$events_async_data['fields'] : array();
$this->autonami_event = isset( BWFAN_Common::$events_async_data['event'] ) ? BWFAN_Common::$events_async_data['event'] : '';
$this->form_id = isset( BWFAN_Common::$events_async_data['form_id'] ) ? BWFAN_Common::$events_async_data['form_id'] : '';
$this->form_title = isset( BWFAN_Common::$events_async_data['form_title'] ) ? BWFAN_Common::$events_async_data['form_title'] : '';
$this->first_name = isset( BWFAN_Common::$events_async_data['first_name'] ) ? BWFAN_Common::$events_async_data['first_name'] : '';
$this->last_name = isset( BWFAN_Common::$events_async_data['last_name'] ) ? BWFAN_Common::$events_async_data['last_name'] : '';
$this->contact_phone = isset( BWFAN_Common::$events_async_data['contact_phone'] ) ? BWFAN_Common::$events_async_data['contact_phone'] : '';
$this->entry_id = isset( BWFAN_Common::$events_async_data['entry_id'] ) ? BWFAN_Common::$events_async_data['entry_id'] : '';
$this->email = isset( BWFAN_Common::$events_async_data['email'] ) ? BWFAN_Common::$events_async_data['email'] : '';
$this->find_feeds_and_create_contacts();
}
public function filter_feeds_for_current_entry() {
return array_filter( array_map( function ( $feed ) {
$feed_form_id = $feed->get_data( 'form_id' );
if ( absint( $this->form_id ) !== absint( $feed_form_id ) ) {
return false;
}
return $feed;
}, $this->feeds ) );
}
public function prepare_contact_data_from_feed_entry( $mapped_fields ) {
$contact_data = array();
foreach ( $this->entry as $key => $item ) {
if ( isset( $mapped_fields[ $key ] ) ) {
$contact_field = is_numeric( $mapped_fields[ $key ] ) ? absint( $mapped_fields[ $key ] ) : $mapped_fields[ $key ];
$contact_data[ $contact_field ] = $this->entry[ $key ];
}
}
return $contact_data;
}
public function get_form_fields( $feed ) {
if ( ! $feed instanceof BWFCRM_Form_Feed ) {
return BWFCRM_Common::crm_error( __( 'Feed not Exists: ', 'wp-marketing-automations-pro' ) );
}
$feed_id = $feed->get_id();
if ( ! $feed->is_feed_exists() ) {
return BWFCRM_Common::crm_error( __( 'No Feed Exists: ' . $feed_id, 'wp-marketing-automations-pro' ) );
}
$form_id = $feed->get_data( 'form_id' );
if ( empty( $form_id ) ) {
return BWFCRM_Common::crm_error( __( 'Form Feed doesn\'t have sufficient data to get fields: ' . $feed_id, 'wp-marketing-automations-pro' ) );
}
return $this->get_formidable_form_fields( $form_id );
}
public function get_formidable_form_fields( $form_id ) {
if ( empty( $form_id ) ) {
return BWFCRM_Common::crm_error( __( 'Form Feed doesn\'t have sufficient data to get fields: ' . $form_id, 'wp-marketing-automations-pro' ) );
}
/** @var BWFAN_Formidable_Form_Submit $event */
$event = BWFAN_Core()->sources->get_event( 'formidable_form_submit' );
if ( ! $event instanceof BWFAN_Formidable_Form_Submit ) {
return BWFCRM_Common::crm_error( __( 'Form Funnelkit Automations Event doesn\'t found for Feed: ' . $form_id, 'wp-marketing-automations-pro' ) );
}
$final_arr = [];
$form_fields = FrmField::get_all_for_form( $form_id );
// get id and name of non-hidden fields
if ( ! empty( $form_fields ) ) {
foreach ( $form_fields as $field ) {
if ( ! isset( $field->name ) || ! isset( $field->id ) ) {
continue;
}
$final_arr[ $field->id ] = $field->name;
}
}
return $final_arr;
}
/**
* Select form
*
* @param $args
* @param $return_all_available
*
* @return array[]
*/
public function get_form_selection( $args, $return_all_available = false ) {
/** Form ID Handling */
$form_options = [];
$forms = FrmForm::getAll();
if ( ! empty( $forms ) ) {
foreach ( $forms as $form ) {
if ( $form->status !== 'published' ) {
continue;
}
$form_options[ $form->id ] = $form->name;
}
}
$form_options = array( 'default' => $form_options );
$form_options = $this->get_step_selection_array( 'Form', 'form_id', 1, $form_options );
return $form_options;
}
public function get_total_selection_steps() {
return $this->total_selections;
}
public function get_meta() {
return array(
'form_selection_fields' => array(
'form_id' => 'Form ID'
)
);
}
/**
* @param $args
* @param $feed_id
*
* @return bool|WP_Error
*/
public function update_form_selection( $args, $feed_id ) {
if ( empty( $feed_id ) ) {
return BWFCRM_Common::crm_error( __( 'Empty Feed ID provided', 'wp-marketing-automations-pro' ) );
}
$form_id = isset( $args['form_id'] ) && ! empty( $args['form_id'] ) ? $args['form_id'] : false;
$feed = new BWFCRM_Form_Feed( $feed_id );
if ( ! $feed->is_feed_exists() ) {
return BWFCRM_Common::crm_error( __( 'Feed with ID not exists: ' . $feed_id, 'wp-marketing-automations-pro' ) );
}
if ( empty( $form_id ) && $this->source === $feed->get_source() ) {
return false;
}
$feed->unset_data( 'form_id' );
$feed->get_source() !== $this->source && $feed->set_source( $this->source );
! empty( $form_id ) && $feed->set_data( 'form_id', $form_id );
return ! ! $feed->save( true );
}
}
if ( function_exists( 'bwfan_is_formidable_forms_active' ) && bwfan_is_formidable_forms_active() ) {
BWFCRM_Core()->forms->register( 'formidable', 'BWFCRM_Form_Formidable', 'Formidable', array(
'formidable_form_submit'
) );
}

View File

@@ -0,0 +1,174 @@
<?php
#[AllowDynamicProperties]
class BWFCRM_Form_Gravity extends BWFCRM_Form_Base {
private $total_selections = 1;
private $source = 'gforms';
/** Form Submission Captured Data */
private $form_id = '';
private $form_title = '';
private $fields = [];
private $entry = [];
private $autonami_event = '';
public function get_source() {
return $this->source;
}
/**
* @param BWFCRM_Form_Feed $feed
*
* @return string|void
*/
public function get_form_link( $feed ) {
$url = '';
$form_id = $feed->get_data( 'form_id' );
if ( $form_id ) {
$url = admin_url( 'admin.php?page=gf_edit_forms&id=' . absint( $form_id ) );
}
return $url;
}
public function capture_async_submission() {
$this->form_id = BWFAN_Common::$events_async_data['form_id'];
$this->form_title = BWFAN_Common::$events_async_data['form_title'];
$this->entry = BWFAN_Common::$events_async_data['entry'];
$this->fields = BWFAN_Common::$events_async_data['fields'];
$this->autonami_event = BWFAN_Common::$events_async_data['event'];
$this->find_feeds_and_create_contacts();
}
public function filter_feeds_for_current_entry() {
return array_filter( array_map( function ( $feed ) {
$feed_form_id = $feed->get_data( 'form_id' );
if ( absint( $this->form_id ) !== absint( $feed_form_id ) ) {
return false;
}
return $feed;
}, $this->feeds ) );
}
public function prepare_contact_data_from_feed_entry( $mapped_fields ) {
$contact_data = [];
foreach ( $this->entry as $key => $item ) {
if ( isset( $mapped_fields[ $key ] ) ) {
$contact_field = is_numeric( $mapped_fields[ $key ] ) ? absint( $mapped_fields[ $key ] ) : $mapped_fields[ $key ];
if ( 'country' === $contact_field ) {
$contact_data[ $contact_field ] = BWFAN_PRO_Common::get_country_iso_code( $this->entry[ $key ] );
} else {
$field_value = $this->entry[ $key ];
if ( is_array( $field_value ) ) {
$field_value = array_filter( $field_value );
sort( $field_value );
}
$contact_data[ $contact_field ] = is_array( $field_value ) ? wp_json_encode( $field_value ) : $field_value;
}
}
}
return $contact_data;
}
public function get_form_fields( $feed ) {
if ( ! $feed instanceof BWFCRM_Form_Feed ) {
return BWFCRM_Common::crm_error( __( 'Feed not Exists: ', 'wp-marketing-automations-pro' ) );
}
$feed_id = $feed->get_id();
if ( ! $feed->is_feed_exists() ) {
return BWFCRM_Common::crm_error( __( 'No Feed Exists: ' . $feed_id, 'wp-marketing-automations-pro' ) );
}
$form_id = $feed->get_data( 'form_id' );
if ( empty( $form_id ) ) {
return BWFCRM_Common::crm_error( __( 'Form Feed doesn\'t have sufficient data to get fields: ' . $feed_id, 'wp-marketing-automations-pro' ) );
}
return $this->get_gravity_form_fields( $form_id );
}
public function get_gravity_form_fields( $gform_id ) {
$form = GFAPI::get_form( $gform_id );
$fields = [];
foreach ( $form['fields'] as $field ) {
$inputs = $field->get_entry_inputs();
if ( is_array( $inputs ) && 'checkbox' !== $field['type'] ) {
foreach ( $inputs as $input ) {
if ( isset( $input['isHidden'] ) && $input['isHidden'] ) {
continue;
}
$fields[ $input['id'] ] = $field->label . ': ' . $input['label'];
}
} else {
$fields[ $field->id ] = $field->label;
}
}
return $fields;
}
public function get_form_selection( $args, $return_all_available = false ) {
/** Form ID Handling */
$gforms = GFAPI::get_forms();
$form_options = [];
foreach ( $gforms as $form ) {
$form_options[ $form['id'] ] = $form['title'];
}
$form_options = array( 'default' => $form_options );
$form_options = $this->get_step_selection_array( 'Form', 'form_id', 1, $form_options );
return $form_options;
}
public function get_total_selection_steps() {
return $this->total_selections;
}
public function get_meta() {
return array(
'form_selection_fields' => array(
'form_id' => 'Form ID'
)
);
}
/**
* @param $args
* @param $feed_id
*
* @return bool|WP_Error
*/
public function update_form_selection( $args, $feed_id ) {
if ( empty( $feed_id ) ) {
return BWFCRM_Common::crm_error( __( 'Empty Feed ID provided', 'wp-marketing-automations-pro' ) );
}
$form_id = isset( $args['form_id'] ) && ! empty( $args['form_id'] ) ? $args['form_id'] : false;
$feed = new BWFCRM_Form_Feed( $feed_id );
if ( ! $feed->is_feed_exists() ) {
return BWFCRM_Common::crm_error( __( 'Feed with ID not exists: ' . $feed_id, 'wp-marketing-automations-pro' ) );
}
if ( empty( $form_id ) && 'gforms' === $feed->get_source() ) {
return false;
}
$feed->unset_data( 'form_id' );
$feed->get_source() !== 'gforms' && $feed->set_source( 'gforms' );
! empty( $form_id ) && $feed->set_data( 'form_id', $form_id );
return ! ! $feed->save( true );
}
}
if ( bwfan_is_gforms_active() ) {
BWFCRM_Core()->forms->register( 'gforms', 'BWFCRM_Form_Gravity', 'Gravity Forms', array(
'gf_form_submit'
) );
}

View File

@@ -0,0 +1,195 @@
<?php
#[AllowDynamicProperties]
class BWFCRM_Form_Funnel_Optin extends BWFCRM_Form_Base {
private $total_selections = 1;
private $source = 'funnel_optin';
/** Form Submission Captured Data */
private $form_id = '';
private $form_title = '';
private $fields = [];
private $autonami_event = '';
public function get_source() {
return $this->source;
}
/**
* @param BWFCRM_Form_Feed $feed
*
* @return string|void
*/
public function get_form_link( $feed ) {
$form_id = intval( $feed->get_data( 'form_id' ) );
if ( empty( $form_id ) ) {
return '';
}
$url = admin_url( 'admin.php?page=wf-op&edit=' . $form_id );
if ( version_compare( WFFN_VERSION, 3.0, '>=' ) ) {
$url = admin_url( 'admin.php?page=bwf&path=/funnel-optin/' . $form_id . '/design' );
}
return $url;
}
public function capture_async_submission() {
$this->form_id = BWFAN_Common::$events_async_data['form_id'];
$this->form_title = BWFAN_Common::$events_async_data['form_title'];
$this->fields = BWFAN_Common::$events_async_data['fields'];
$this->cid = isset( BWFAN_Common::$events_async_data['cid'] ) ? absint( BWFAN_Common::$events_async_data['cid'] ) : 0;
$this->autonami_event = BWFAN_Common::$events_async_data['event'];
$this->find_feeds_and_create_contacts();
}
public function filter_feeds_for_current_entry() {
return array_filter( array_map( function ( $feed ) {
$feed_form_id = $feed->get_data( 'form_id' );
if ( absint( $this->form_id ) !== absint( $feed_form_id ) ) {
return false;
}
return $feed;
}, $this->feeds ) );
}
public function prepare_contact_data_from_feed_entry( $mapped_fields ) {
$contact_data = [];
$field_types = $this->get_field_types();
foreach ( $this->fields as $key => $item ) {
if ( ! isset( $mapped_fields[ $key ] ) ) {
continue;
}
$contact_field = is_numeric( $mapped_fields[ $key ] ) ? intval( $mapped_fields[ $key ] ) : $mapped_fields[ $key ];
$value = $this->fields[ $key ];
/** If field type checkbox */
if ( isset( $field_types[ $key ] ) && 'checkbox' === $field_types[ $key ] ) {
$value = ( 'on' === $this->fields[ $key ] ) ? 'yes' : 'no';
}
$contact_data[ $contact_field ] = $value;
}
return $contact_data;
}
public function get_form_fields( $feed ) {
if ( ! $feed instanceof BWFCRM_Form_Feed ) {
return BWFCRM_Common::crm_error( __( 'Feed not Exists: ', 'wp-marketing-automations-pro' ) );
}
$feed_id = $feed->get_id();
if ( ! $feed->is_feed_exists() ) {
return BWFCRM_Common::crm_error( __( 'No Feed Exists: ' . $feed_id, 'wp-marketing-automations-pro' ) );
}
$form_id = $feed->get_data( 'form_id' );
if ( empty( $form_id ) ) {
return BWFCRM_Common::crm_error( __( 'Form Feed does not have the sufficient data to get fields: ' . $feed_id, 'wp-marketing-automations-pro' ) );
}
return $this->get_optin_form_fields( $form_id );
}
/**
* Get optin form fields
*
* @param $form_id
*
* @return mixed | Array
*/
public function get_optin_form_fields( $form_id ) {
$optin_form_instance = BWFAN_Core()->sources->get_event( 'funnel_optin_form_submit' );
$fields = $optin_form_instance->get_form_fields( $form_id );
return $fields;
}
public function get_form_selection( $args, $return_all_available = false ) {
/** Form ID Handling */
$optin_form_instance = BWFAN_Core()->sources->get_event( 'funnel_optin_form_submit' );
$data = $optin_form_instance->get_view_data();
$form_options = array( 'default' => $data );
$form_options = $this->get_step_selection_array( 'Form', 'form_id', 1, $form_options );
return $form_options;
}
public function get_total_selection_steps() {
return $this->total_selections;
}
public function get_meta() {
return array(
'form_selection_fields' => array(
'form_id' => 'Form ID'
)
);
}
/**
* @param $args
* @param $feed_id
*
* @return bool|WP_Error
*/
public function update_form_selection( $args, $feed_id ) {
if ( empty( $feed_id ) ) {
return BWFCRM_Common::crm_error( __( 'Empty Feed ID provided', 'wp-marketing-automations-pro' ) );
}
$form_id = isset( $args['form_id'] ) && ! empty( $args['form_id'] ) ? $args['form_id'] : false;
$feed = new BWFCRM_Form_Feed( $feed_id );
if ( ! $feed->is_feed_exists() ) {
return BWFCRM_Common::crm_error( __( 'Feed with ID not exists: ' . $feed_id, 'wp-marketing-automations-pro' ) );
}
if ( empty( $form_id ) && 'funnel_optin' === $feed->get_source() ) {
return false;
}
$feed->unset_data( 'form_id' );
$feed->get_source() !== 'funnel_optin' && $feed->set_source( 'funnel_optin' );
! empty( $form_id ) && $feed->set_data( 'form_id', $form_id );
return ! ! $feed->save( true );
}
/**
* Get field types
*
* @return array
*/
public function get_field_types() {
if ( empty( $this->form_id ) || ! function_exists( 'WFOPP_Core' ) ) {
return [];
}
$form_fields = WFOPP_Core()->optin_pages->form_builder->get_optin_layout( $this->form_id );
if ( empty( $form_fields ) ) {
return [];
}
$types = [];
foreach ( $form_fields as $step_field ) {
/** empty step fields than continue */
if ( empty( $step_field ) ) {
continue;
}
foreach ( $step_field as $field ) {
$types[ $field['InputName'] ] = $field['type'];
}
}
return $types;
}
}
if ( bwfan_is_optin_forms_active() ) {
BWFCRM_Core()->forms->register( 'funnel_optin', 'BWFCRM_Form_Funnel_Optin', 'FunnelKit Optin', array(
'funnel_optin_form_submit'
) );
}

View File

@@ -0,0 +1,166 @@
<?php
#[AllowDynamicProperties]
class BWFCRM_Form_ThriveArchitect extends BWFCRM_Form_Base {
private $total_selections = 1;
private $source = 'thrive-architect';
/** Form Submission Captured Data */
private $form_id = '';
private $fields = [];
private $entry = [];
private $autonami_event = '';
public function get_source() {
return $this->source;
}
/**
* @param BWFCRM_Form_Feed $feed
*
* @return string|void
*/
public function get_form_link( $feed ) {
$form_id = $feed->get_data( 'form_id' );
if ( $form_id ) {
$post = get_post( $form_id );
if ( $post && $post->post_parent > 0 ) {
return admin_url( '/post.php?post=' . absint( $post->post_parent ) . '&action=edit' );
}
}
return ''; // Return an empty string if conditions are not met
}
public function capture_async_submission() {
$this->form_id = BWFAN_Common::$events_async_data['tcb_id'];
$this->entry = BWFAN_Common::$events_async_data['fields'] ?? [];
$this->autonami_event = BWFAN_Common::$events_async_data['event'];
$this->find_feeds_and_create_contacts();
}
public function filter_feeds_for_current_entry() {
return array_filter( array_map( function ( $feed ) {
$feed_form_id = $feed->get_data( 'form_id' );
if ( absint( $this->form_id ) !== absint( $feed_form_id ) ) {
return false;
}
return $feed;
}, $this->feeds ) );
}
public function prepare_contact_data_from_feed_entry( $mapped_fields ) {
$contact_data = array();
foreach ( $this->entry as $key => $item ) {
if ( ! isset( $mapped_fields[ $key ] ) ) {
continue;
}
$contact_field = is_numeric( $mapped_fields[ $key ] ) ? absint( $mapped_fields[ $key ] ) : $mapped_fields[ $key ];
if ( 'country' === $contact_field ) {
$contact_data[ $contact_field ] = BWFAN_PRO_Common::get_country_iso_code( $this->entry[ $key ] );
continue;
}
$contact_data[ $contact_field ] = $this->entry[ $key ];
}
return $contact_data;
}
public function get_form_fields( $feed ) {
$form_id = $feed->get_data( 'form_id' );
if ( empty( $form_id ) ) {
return BWFCRM_Common::crm_error( __( 'No Form ID provided', 'wp-marketing-automations-pro' ) );
}
return $this->get_tve_form_fields( $form_id );
}
public function get_tve_form_fields( $form_id ) {
$event = BWFAN_Core()->sources->get_event( 'tve_architect_form_submit' );
if ( ! $event instanceof BWFAN_TVE_Architect_Form_Submit ) {
return BWFCRM_Common::crm_error( __( 'Thrive From integration not found', 'wp-marketing-automations-pro' ) );
}
$fields = $event->get_form_fields( $form_id );
$updated_fields = array();
foreach ( $fields as $field ) {
if ( isset( $field['key'] ) && isset( $field['value'] ) ) {
$updated_fields[ $field['key'] ] = $field['value'];
}
}
return $updated_fields;
}
public function get_form_selection( $args, $return_all_available = false ) {
/** @var BWFAN_TVE_Lead_Form_Submit $event */
$event = BWFAN_Core()->sources->get_event( 'tve_architect_form_submit' );
if ( ! $event instanceof BWFAN_TVE_Architect_Form_Submit ) {
return BWFCRM_Common::crm_error( __( 'Thrive From integration not found', 'wp-marketing-automations-pro' ) );
}
$form_options = $event->get_view_data();
$form_options = array( 'default' => $form_options );
$form_options = $this->get_step_selection_array( 'Form', 'form_id', 1, $form_options );
return $form_options;
}
public function get_total_selection_steps() {
return $this->total_selections;
}
public function get_meta() {
return array(
'form_selection_fields' => array(
'form_id' => 'Form ID'
)
);
}
/**
* @param $args
* @param $feed_id
*
* @return bool|WP_Error
*/
public function update_form_selection( $args, $feed_id ) {
if ( empty( $feed_id ) ) {
return BWFCRM_Common::crm_error( __( 'Empty Feed ID provided', 'wp-marketing-automations-pro' ) );
}
/** Get the submitted Form ID */
$form_id = isset( $args['form_id'] ) && ! empty( $args['form_id'] ) ? $args['form_id'] : false;
/** Check if the feed with the provided ID exists */
$feed = new BWFCRM_Form_Feed( $feed_id );
if ( ! $feed->is_feed_exists() ) {
return BWFCRM_Common::crm_error( __( 'Feed with ID not exists: ' . $feed_id, 'wp-marketing-automations-pro' ) );
}
/** Check If submitted Form ID is valid */
if ( empty( $form_id ) ) {
return false;
}
/** Unset previous data (if exists), and set new data and save */
$feed->unset_data( 'form_id' );
$feed->get_source() !== $this->source && $feed->set_source( $this->source );
! empty( $form_id ) && $feed->set_data( 'form_id', $form_id );
return ! ! $feed->save( true );
}
}
if ( bwfan_is_tve_architect_active() ) {
BWFCRM_Core()->forms->register( 'thrive-architect', 'BWFCRM_Form_ThriveArchitect', 'Thrive Architect Forms', [ 'tve_architect_form_submit' ] );
}

View File

@@ -0,0 +1,160 @@
<?php
#[AllowDynamicProperties]
class BWFCRM_Form_Thrive extends BWFCRM_Form_Base {
private $total_selections = 1;
private $source = 'thrive';
/** Form Submission Captured Data */
private $form_id = '';
private $form_title = '';
private $fields = [];
private $entry = [];
private $autonami_event = '';
public function get_source() {
return $this->source;
}
/**
* @param BWFCRM_Form_Feed $feed
*
* @return string|void
*/
public function get_form_link( $feed ) {
$url = '';
$form_id = $feed->get_data( 'form_id' );
if ( $form_id ) {
$url = admin_url( 'admin.php?page=thrive_leads_dashboard#form-type/' . absint( $form_id ) );
}
return $url;
}
public function capture_async_submission() {
$this->form_id = BWFAN_Common::$events_async_data['form_id'];
$this->form_title = BWFAN_Common::$events_async_data['form_title'];
$this->entry = BWFAN_Common::$events_async_data['entry'];
$this->fields = BWFAN_Common::$events_async_data['fields'];
$this->autonami_event = BWFAN_Common::$events_async_data['event'];
$this->find_feeds_and_create_contacts();
}
public function filter_feeds_for_current_entry() {
return array_filter( array_map( function ( $feed ) {
$feed_form_id = $feed->get_data( 'form_id' );
if ( absint( $this->form_id ) !== absint( $feed_form_id ) ) {
return false;
}
return $feed;
}, $this->feeds ) );
}
public function prepare_contact_data_from_feed_entry( $mapped_fields ) {
$contact_data = array();
foreach ( $this->entry as $key => $item ) {
if ( ! isset( $mapped_fields[ $key ] ) ) {
continue;
}
$contact_field = is_numeric( $mapped_fields[ $key ] ) ? absint( $mapped_fields[ $key ] ) : $mapped_fields[ $key ];
if ( 'country' === $contact_field ) {
$contact_data[ $contact_field ] = BWFAN_PRO_Common::get_country_iso_code( $this->entry[ $key ] );
continue;
}
$contact_data[ $contact_field ] = $this->entry[ $key ];
}
return $contact_data;
}
public function get_form_fields( $feed ) {
if ( ! $feed instanceof BWFCRM_Form_Feed ) {
return BWFCRM_Common::crm_error( __( 'Feed Not Exists ', 'wp-marketing-automations-pro' ) );
}
$feed_id = $feed->get_id();
if ( ! $feed->is_feed_exists() ) {
return BWFCRM_Common::crm_error( __( 'No Feed Exists: ' . $feed_id, 'wp-marketing-automations-pro' ) );
}
$form_id = $feed->get_data( 'form_id' );
/** @var BWFAN_TVE_Lead_Form_Submit $event */
$event = BWFAN_Core()->sources->get_event( 'tve_lead_form_submit' );
if ( ! $event instanceof BWFAN_TVE_Lead_Form_Submit ) {
return BWFCRM_Common::crm_error( __( 'Thrive From integration not found', 'wp-marketing-automations-pro' ) );
}
return $event->get_form_fields( $form_id );
}
public function get_form_selection( $args, $return_all_available = false ) {
/** @var BWFAN_TVE_Lead_Form_Submit $event */
$event = BWFAN_Core()->sources->get_event( 'tve_lead_form_submit' );
if ( ! $event instanceof BWFAN_TVE_Lead_Form_Submit ) {
return BWFCRM_Common::crm_error( __( 'Thrive From integration not found', 'wp-marketing-automations-pro' ) );
}
$form_options = $event->get_view_data();
$form_options = array( 'default' => $form_options );
$form_options = $this->get_step_selection_array( 'Form', 'form_id', 1, $form_options );
return $form_options;
}
public function get_total_selection_steps() {
return $this->total_selections;
}
public function get_meta() {
return array(
'form_selection_fields' => array(
'form_id' => 'Form ID'
)
);
}
/**
* @param $args
* @param $feed_id
*
* @return bool|WP_Error
*/
public function update_form_selection( $args, $feed_id ) {
if ( empty( $feed_id ) ) {
return BWFCRM_Common::crm_error( __( 'Empty Feed ID provided', 'wp-marketing-automations-pro' ) );
}
/** Get the submitted Form ID */
$form_id = isset( $args['form_id'] ) && ! empty( $args['form_id'] ) ? $args['form_id'] : false;
/** Check if the feed with the provided ID exists */
$feed = new BWFCRM_Form_Feed( $feed_id );
if ( ! $feed->is_feed_exists() ) {
return BWFCRM_Common::crm_error( __( 'Feed with ID not exists: ' . $feed_id, 'wp-marketing-automations-pro' ) );
}
/** Check If submitted Form ID is valid */
if ( empty( $form_id ) ) {
return false;
}
/** Unset previous data (if exists), and set new data and save */
$feed->unset_data( 'form_id' );
$feed->get_source() !== $this->source && $feed->set_source( $this->source );
! empty( $form_id ) && $feed->set_data( 'form_id', $form_id );
return ! ! $feed->save( true );
}
}
if ( bwfan_is_tve_active() ) {
BWFCRM_Core()->forms->register( 'thrive', 'BWFCRM_Form_Thrive', 'Thrive Lead Forms', array(
'tve_lead_form_submit'
) );
}

View File

@@ -0,0 +1,216 @@
<?php
#[AllowDynamicProperties]
class BWFCRM_Form_WPForms extends BWFCRM_Form_Base {
private $total_selections = 1;
private $source = 'wpforms';
/** Form Submission Captured Data */
private $form_id = '';
private $form_title = '';
private $fields = [];
private $entry = [];
private $entry_id = [];
private $email = [];
private $autonami_event = '';
public function get_source() {
return $this->source;
}
/**
* @param BWFCRM_Form_Feed $feed
*
* @return string|void
*/
public function get_form_link( $feed ) {
$url = '';
$form_id = $feed->get_data( 'form_id' );
if ( absint( $form_id ) > 0 ) {
$url = admin_url( 'admin.php?page=wpforms-builder&view=fields&form_id=' . absint( $form_id ) );
}
return $url;
}
public function capture_async_submission() {
$this->form_id = BWFAN_Common::$events_async_data['form_id'];
$this->form_title = BWFAN_Common::$events_async_data['form_title'];
$this->entry = BWFAN_Common::$events_async_data['entry'];
$this->fields = BWFAN_Common::$events_async_data['fields'];
$this->entry_id = BWFAN_Common::$events_async_data['entry_id'];
$this->email = isset( BWFAN_Common::$events_async_data['email'] ) ? BWFAN_Common::$events_async_data['email'] : '';
$this->autonami_event = BWFAN_Common::$events_async_data['event'];
$this->find_feeds_and_create_contacts();
}
public function filter_feeds_for_current_entry() {
return array_filter( array_map( function ( $feed ) {
$feed_form_id = $feed->get_data( 'form_id' );
if ( absint( $this->form_id ) !== absint( $feed_form_id ) ) {
return false;
}
return $feed;
}, $this->feeds ) );
}
public function prepare_contact_data_from_feed_entry( $mapped_fields ) {
$contact_data = [];
foreach ( $this->entry['fields'] as $key => $item ) {
/** for first_name and last_name*/
if ( isset( $mapped_fields[ $key . '.1' ] ) ) {
$first_name_key = $key . '.1';
$contact_field = is_numeric( $mapped_fields[ $first_name_key ] ) ? absint( $mapped_fields[ $first_name_key ] ) : $mapped_fields[ $first_name_key ];
$field_value = isset( $item['first'] ) ? $item['first'] : '';
$contact_data[ $contact_field ] = $field_value;
}
if ( isset( $mapped_fields[ $key . '.2' ] ) ) {
$last_name_key = $key . '.2';
$contact_field = is_numeric( $mapped_fields[ $last_name_key ] ) ? absint( $mapped_fields[ $last_name_key ] ) : $mapped_fields[ $last_name_key ];
$field_value = isset( $item['last'] ) ? $item['last'] : '';
$contact_data[ $contact_field ] = $field_value;
}
if ( isset( $mapped_fields[ $key . '.3' ] ) ) {
$middle_name_key = $key . '.3';
$contact_field = is_numeric( $mapped_fields[ $middle_name_key ] ) ? absint( $mapped_fields[ $middle_name_key ] ) : $mapped_fields[ $middle_name_key ];
$field_value = isset( $item['middle'] ) ? $item['middle'] : '';
$contact_data[ $contact_field ] = $field_value;
}
if ( isset( $mapped_fields[ $key ] ) ) {
$contact_field = is_numeric( $mapped_fields[ $key ] ) ? absint( $mapped_fields[ $key ] ) : $mapped_fields[ $key ];
if ( is_array( $item ) && $contact_field === 'email' ) {
$contact_data[ $contact_field ] = isset( $item['primary'] ) ? $item['primary'] : '';
continue;
}
if ( is_array( $item ) && $contact_field === 'f_name' ) {
$contact_data[ $contact_field ] = isset( $item['first'] ) ? $item['first'] : '';
continue;
}
/** if value is in array */
if ( is_array( $item ) ) {
$item = wp_json_encode( $item );
}
$contact_data[ $contact_field ] = $item;
}
}
return $contact_data;
}
public function get_form_fields( $feed ) {
if ( ! $feed instanceof BWFCRM_Form_Feed ) {
return BWFCRM_Common::crm_error( __( 'Feed not Exists: ', 'wp-marketing-automations-pro' ) );
}
$feed_id = $feed->get_id();
if ( ! $feed->is_feed_exists() ) {
return BWFCRM_Common::crm_error( __( 'No Feed Exists: ' . $feed_id, 'wp-marketing-automations-pro' ) );
}
$form_id = $feed->get_data( 'form_id' );
if ( empty( $form_id ) ) {
return BWFCRM_Common::crm_error( __( 'Form Feed doesn\'t have sufficient data to get fields: ' . $feed_id, 'wp-marketing-automations-pro' ) );
}
return $this->get_wp_form_fields( $form_id );
}
public function get_wp_form_fields( $form_id ) {
$form = wpforms()->form->get( $form_id );
$form_content = wpforms_decode( $form->post_content );
$fields = array();
if ( ! empty( $form_content['fields'] ) ) {
foreach ( $form_content['fields'] as $field ) {
if ( isset( $field['isHidden'] ) && $field['isHidden'] ) {
continue;
}
$fields[ $field['id'] ] = $field['label'];
if ( ! isset( $field['format'] ) || 'name' !== $field['type'] || 'simple' === $field['format'] ) {
continue;
}
unset( $fields[ $field['id'] ] );
$fields[ $field['id'] . '.1' ] = $field['label'] . ': First Name';
$fields[ $field['id'] . '.2' ] = $field['label'] . ': Last Name';
if ( 'first-middle-last' === $field['format'] ) {
$fields[ $field['id'] . '.3' ] = $field['label'] . ': Middle Name';
}
}
}
return $fields;
}
public function get_form_selection( $args, $return_all_available = false ) {
/** Form ID Handling */
$wpforms = wpforms()->form->get();
$form_options = [];
foreach ( $wpforms as $form ) {
$form_options[ $form->ID ] = $form->post_title;
}
$form_options = array( 'default' => $form_options );
$form_options = $this->get_step_selection_array( 'Form', 'form_id', 1, $form_options );
return $form_options;
}
public function get_total_selection_steps() {
return $this->total_selections;
}
public function get_meta() {
return array(
'form_selection_fields' => array(
'form_id' => 'Form ID'
)
);
}
/**
* @param $args
* @param $feed_id
*
* @return bool|WP_Error
*/
public function update_form_selection( $args, $feed_id ) {
if ( empty( $feed_id ) ) {
return BWFCRM_Common::crm_error( __( 'Empty Feed ID provided', 'wp-marketing-automations-pro' ) );
}
$form_id = isset( $args['form_id'] ) && ! empty( $args['form_id'] ) ? $args['form_id'] : false;
$feed = new BWFCRM_Form_Feed( $feed_id );
if ( ! $feed->is_feed_exists() ) {
return BWFCRM_Common::crm_error( __( 'Feed with ID not exists: ' . $feed_id, 'wp-marketing-automations-pro' ) );
}
if ( empty( $form_id ) && $this->source === $feed->get_source() ) {
return false;
}
$feed->unset_data( 'form_id' );
$feed->get_source() !== $this->source && $feed->set_source( $this->source );
! empty( $form_id ) && $feed->set_data( 'form_id', $form_id );
return ! ! $feed->save( true );
}
}
if ( bwfan_is_wpforms_active() ) {
BWFCRM_Core()->forms->register( 'wpforms', 'BWFCRM_Form_WPForms', 'WP Forms', array(
'wpforms_form_submit'
) );
}

View File

@@ -0,0 +1,184 @@
<?php
#[AllowDynamicProperties]
class BWFCRM_Form_Ninja extends BWFCRM_Form_Base {
private $total_selections = 1;
private $source = 'ninja';
/** Form Submission Captured Data */
private $form_id = '';
private $form_title = '';
private $fields = [];
private $autonami_event = '';
public function get_source() {
return $this->source;
}
/**
* @param BWFCRM_Form_Feed $feed
*
* @return string|void
*/
public function get_form_link( $feed ) {
$url = '';
$form_id = $feed->get_data( 'form_id' );
if ( $form_id ) {
$url = admin_url( 'admin.php?page=ninja-forms&form_id=' . absint( $form_id ) );
}
return $url;
}
public function capture_async_submission() {
$this->form_id = BWFAN_Common::$events_async_data['form_id'];
$this->form_title = BWFAN_Common::$events_async_data['form_title'];
$this->fields = BWFAN_Common::$events_async_data['fields'];
$this->autonami_event = BWFAN_Common::$events_async_data['event'];
$this->find_feeds_and_create_contacts();
}
public function filter_feeds_for_current_entry() {
return array_filter( array_map( function ( $feed ) {
$feed_form_id = $feed->get_data( 'form_id' );
if ( absint( $this->form_id ) !== absint( $feed_form_id ) ) {
return false;
}
return $feed;
}, $this->feeds ) );
}
public function prepare_contact_data_from_feed_entry( $mapped_fields ) {
$contact_data = [];
foreach ( $this->fields as $key => $item ) {
/** If Entry field is not group of field values ie: name[first, last] */
if ( ! is_array( $item ) && isset( $mapped_fields[ $key ] ) ) {
$contact_field = is_numeric( $mapped_fields[ $key ] ) ? absint( $mapped_fields[ $key ] ) : $mapped_fields[ $key ];
$contact_data[ $contact_field ] = $item;
continue;
}
/** If Entry field is a group of field values ie: name[first, last] */
if ( is_array( $item ) ) {
$key_value = $this->maybe_get_key_value_from_grouped_field( $key, $item, $mapped_fields );
if ( is_array( $key_value ) && ! empty( $key_value ) ) {
$contact_data = array_replace( $contact_data, $key_value );
}
}
}
return $contact_data;
}
public function maybe_get_key_value_from_grouped_field( $entry_key, $entry_value, $mapped_fields ) {
$key_value = [];
foreach ( $mapped_fields as $key => $crm_field ) {
/** Entry Group not matched with $mapped_field key's group */
if ( false === strpos( $key, $entry_key . ':' ) ) {
if ( $key === $entry_key && isset( $mapped_fields[ $key ] ) ) {
$key_value[ $crm_field ] = is_array( $entry_value ) ? wp_json_encode( $entry_value ) : $entry_value;
}
continue;
}
$mapped_array = explode( ':', $key );
//$mapped_group = $mapped_array[0];
$mapped_field = $mapped_array[1];
if ( isset( $entry_value[ $mapped_field ] ) ) {
$key_value[ $crm_field ] = is_array( $entry_value[ $mapped_field ] ) ? wp_json_encode( $entry_value[ $mapped_field ] ) : $entry_value[ $mapped_field ];
}
}
return $key_value;
}
public function get_form_fields( $feed ) {
if ( ! $feed instanceof BWFCRM_Form_Feed ) {
return BWFCRM_Common::crm_error( __( 'Feed not Exists: ', 'wp-marketing-automations-pro' ) );
}
$feed_id = $feed->get_id();
if ( ! $feed->is_feed_exists() ) {
return BWFCRM_Common::crm_error( __( 'No Feed Exists: ' . $feed_id, 'wp-marketing-automations-pro' ) );
}
$form_id = $feed->get_data( 'form_id' );
if ( empty( $form_id ) ) {
return BWFCRM_Common::crm_error( __( 'Form Feed doesn\'t have sufficient data to get fields: ' . $feed_id, 'wp-marketing-automations-pro' ) );
}
/** @var BWFAN_Ninja_Form_Submit $event */
$event = BWFAN_Core()->sources->get_event( 'ninja_form_submit' );
if ( ! $event instanceof BWFAN_Ninja_Form_Submit ) {
return BWFCRM_Common::crm_error( __( 'Form FunnelKit Automations Event doesn\'t found for Feed: ' . $feed_id, 'wp-marketing-automations-pro' ) );
}
return $event->get_form_fields( $form_id );
}
public function get_form_selection( $args, $return_all_available = false ) {
/** Form ID Handling */
global $wpdb;
$all_forms = $wpdb->get_results( 'SELECT id, title FROM `' . $wpdb->prefix . 'nf3_forms` ORDER BY title', ARRAY_A ); //phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching
$form_options = [];
if ( ! empty( $all_forms ) ) {
foreach ( $all_forms as $form ) {
$form_options[ $form['id'] ] = $form['title'];
}
}
$form_options = array( 'default' => $form_options );
$form_options = $this->get_step_selection_array( 'Form', 'form_id', 1, $form_options );
return $form_options;
}
public function get_total_selection_steps() {
return $this->total_selections;
}
public function get_meta() {
return array(
'form_selection_fields' => array(
'form_id' => 'Form ID'
)
);
}
/**
* @param $args
* @param $feed_id
*
* @return bool|WP_Error
*/
public function update_form_selection( $args, $feed_id ) {
if ( empty( $feed_id ) ) {
return BWFCRM_Common::crm_error( __( 'Empty Feed ID provided', 'wp-marketing-automations-pro' ) );
}
$form_id = isset( $args['form_id'] ) && ! empty( $args['form_id'] ) ? $args['form_id'] : false;
$feed = new BWFCRM_Form_Feed( $feed_id );
if ( ! $feed->is_feed_exists() ) {
return BWFCRM_Common::crm_error( __( 'Feed with ID not exists: ' . $feed_id, 'wp-marketing-automations-pro' ) );
}
if ( empty( $form_id ) && $this->source === $feed->get_source() ) {
return false;
}
$feed->unset_data( 'form_id' );
$feed->get_source() !== $this->source && $feed->set_source( $this->source );
! empty( $form_id ) && $feed->set_data( 'form_id', $form_id );
return ! ! $feed->save( true );
}
}
if ( bwfan_is_ninja_forms_active() ) {
BWFCRM_Core()->forms->register( 'ninja', 'BWFCRM_Form_Ninja', 'Ninja Forms', array(
'ninja_form_submit'
) );
}