Skip to content

Commit

Permalink
Merge pull request #12 from vidmantaskiro/omnisend-sdk-update
Browse files Browse the repository at this point in the history
Omnisend sdk update
  • Loading branch information
nerijuszaniauskas authored Feb 20, 2024
2 parents a16bb83 + f17b7b0 commit c654d0d
Show file tree
Hide file tree
Showing 13 changed files with 155 additions and 431 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
/**
* Plugin Name: Omnisend for Formidable Forms Add-On
* Description: A Formidable forms add-on to sync contacts with Omnisend. In collaboration with Omnisnnd for WooCommerce plugin it enables better customer tracking
* Version: 1.0.4
* Version: 1.1.0
* Author: Omnisend
* Author URI: https://www.omnisend.com
* Developer: Omnisend
Expand All @@ -21,9 +21,10 @@
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
define( 'OMNISEND_FORMIDABLE_ADDON_VERSION', '1.0.1' );

add_action( 'frm_registered_form_actions', array( 'Omnisend_FormidableFormsAddOn_Bootstrap', 'register_actions' ), 10, 1 );
define( 'OMNISEND_FORMIDABLE_ADDON_NAME', 'Omnisend for Formidable Forms Add-On' );
define( 'OMNISEND_FORMIDABLE_ADDON_VERSION', '1.1.0' );

spl_autoload_register( array( 'Omnisend_FormidableFormsAddOn_Bootstrap', 'autoloader' ) );
add_action( 'plugins_loaded', array( 'Omnisend_FormidableFormsAddOn_Bootstrap', 'check_plugin_requirements' ) );
add_action( 'admin_enqueue_scripts', array( 'Omnisend_FormidableFormsAddOn_Bootstrap', 'load_custom_wp_admin_style' ) );
Expand Down Expand Up @@ -77,11 +78,11 @@ public static function check_plugin_requirements() {
require_once ABSPATH . '/wp-admin/includes/plugin.php';
$formidable_addon_plugin = 'omnisend-for-formidable-forms-add-on/class-omnisend-formidableformsaddon-bootstrap.php';

$omnisend_plugin = 'omnisend-connect/omnisend-woocommerce.php';
$omnisend_plugin = 'omnisend/class-omnisend-core-bootstrap.php';

if ( ! file_exists( WP_PLUGIN_DIR . '/' . $omnisend_plugin ) || ! is_plugin_active( $omnisend_plugin ) ) {
deactivate_plugins( $formidable_addon_plugin );
add_action( 'admin_notices', array( 'Omnisend_FormidableFormsAddOn_Bootstrap', 'omnisend_woocommerce_notice' ) );
add_action( 'admin_notices', array( 'Omnisend_FormidableFormsAddOn_Bootstrap', 'omnisend_notice' ) );

return;
}
Expand All @@ -90,7 +91,7 @@ public static function check_plugin_requirements() {

if ( is_null( $api_key ) ) {
deactivate_plugins( $formidable_addon_plugin );
add_action( 'admin_notices', array( 'Omnisend_FormidableFormsAddOn_Bootstrap', 'omnisend_woocommerce_api_key_notice' ) );
add_action( 'admin_notices', array( 'Omnisend_FormidableFormsAddOn_Bootstrap', 'omnisend_api_key_notice' ) );

return;
}
Expand All @@ -101,20 +102,22 @@ public static function check_plugin_requirements() {
deactivate_plugins( $formidable_addon_plugin );
add_action( 'admin_notices', array( 'Omnisend_FormidableFormsAddOn_Bootstrap', 'formidable_forms_notice' ) );
}

add_action( 'frm_registered_form_actions', array( 'Omnisend_FormidableFormsAddOn_Bootstrap', 'register_actions' ), 10, 1 );
}

/**
* Display a notice for the missing Omnisend WooCommerce API key.
* Display a notice for the missing Omnisend API key.
*/
public static function omnisend_woocommerce_api_key_notice() {
echo '<div class="error"><p>' . esc_html__( 'Your Email Marketing for WooCommerce by Omnisend is not configured properly. Please configure it firstly', 'omnisend-formidable' ) . '</p></div>';
public static function omnisend_api_key_notice() {
echo '<div class="error"><p>' . esc_html__( 'Your Omnisend is not configured properly. Please configure it firstly', 'omnisend-formidable' ) . '</p></div>';
}

/**
* Display a notice for the missing Omnisend For WooCommerce Plugin.
* Display a notice for the missing Omnisend Plugin.
*/
public static function omnisend_woocommerce_notice() {
echo '<div class="error"><p>' . esc_html__( 'Plugin Omnisend for WooCommerce is deactivated. Please install and activate', 'omnisend-formidable' ) . '<a href="https://wordpress.org/plugins/omnisend-connect/">' . esc_html__( 'Omnisend for Woocommerce plugin.', 'omnisend-formidable' ) . '</a></p></div>';
public static function omnisend_notice() {
echo '<div class="error"><p>' . esc_html__( 'Plugin Omnisend is deactivated. Please install and activate ', 'omnisend-formidable' ) . '<a href="https://wordpress.org/plugins/omnisend/">' . esc_html__( 'Omnisend plugin.', 'omnisend-formidable' ) . '</a></p></div>';
}

/**
Expand All @@ -128,7 +131,7 @@ public static function formidable_forms_notice() {
* Loading styles in admin.
*/
public static function load_custom_wp_admin_style() {
wp_register_style( 'omnisend-formidable-forms-addon', plugins_url( 'css/omnisend-formidableforms-addon.css', __FILE__ ), array(), '1.0.0' );
wp_register_style( 'omnisend-formidable-forms-addon', plugins_url( 'css/omnisend-formidableforms-addon.css', __FILE__ ), array(), OMNISEND_FORMIDABLE_ADDON_VERSION );
wp_enqueue_style( 'omnisend-formidable-forms-addon' );
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,6 @@
use FrmFormAction;
use FrmForm;
use FrmEntry;
use Omnisend\FormidableFormsAddon\Builder\RequestBodyBuilder;
use Omnisend\FormidableFormsAddon\Mapper\FormFieldsMapper;
use Omnisend\FormidableFormsAddon\OmnisendResponse;
use Omnisend\FormidableFormsAddon\Provider\OmnisendActionSettingsProvider;
use Omnisend\FormidableFormsAddon\Service\OmnisendApiService;
use Omnisend\FormidableFormsAddon\Service\TrackerService;
Expand Down Expand Up @@ -119,19 +116,19 @@ public function process( int $entry_id, int $form_id ): void {
$form_name = FrmForm::getOne( $form_id )->name;

/**
* Response object for Omnisend.
* Response array for tracker.
*
* @var OmnisendResponse $response
*/
$response = $this->omnisend_service->create_omnisend_contact( $form_name, $form_id, $args );

if ( ! $response->get_success() ) {
if ( empty( $response ) ) {
return;
}

$this->tracker_service->enable_web_tracking(
$response->get_email(),
$response->get_phone() ?? '',
$response[ self::EMAIL ],
$response[ self::PHONE_NUMBER ] ?? '',
$this->snippet_path
);
}
Expand Down

This file was deleted.

This file was deleted.

This file was deleted.

Loading

0 comments on commit c654d0d

Please sign in to comment.