Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update to use core #2

Merged
merged 10 commits into from
Feb 13, 2024
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file removed .wordpress-org/icon-256x256.gif
Binary file not shown.
Binary file added .wordpress-org/icon-256x256.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
16 changes: 8 additions & 8 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
*
* Plugin Name: Omnisend for Contact Form 7
* Description: A Contact Form 7 add-on to sync contacts with Omnisend. In collaboration with Omnisnnd for WooCommerce plugin it enables better customer tracking
* Version: 1.0.2
* Version: 1.1.0
nerijuszaniauskas marked this conversation as resolved.
Show resolved Hide resolved
* Author: Omnisend
* Author URI: https://www.omnisend.com
* Developer: Omnisend
Expand All @@ -25,6 +25,7 @@
add_action( 'wpcf7_init', array( 'WPCF7_Omnisend_Bootstrap', 'load' ), 5 );

const WPCP7_OMNISEND_PLUGIN_NAME = 'Omnisend for Contact Form 7';
const WPCP7_OMNISEND_PLUGIN_VERSION = '1.1.0';
const WPCP7_OMNISEND_SUPPORT_ARTICLE_LINK = 'https://support.omnisend.com/en/articles/8672359-integration-with-contact-form-7';
const WPCP7_OMNISEND_WELCOME_AUTOMATION_ARTICLE_LINK = 'https://support.omnisend.com/en/articles/1061818-welcome-email-automation';

Expand All @@ -37,7 +38,6 @@ public static function load(): void {
require_once 'module/class-wpcf7-omnisend-utils.php';
require_once 'module/class-wpcf7-omnisend-service.php';
require_once 'module/class-wpcf7-omnisend.php';
require_once 'module/class-wpcf7-omnisend-contact.php';
require_once 'module/class-wpcf7-omnisend-form-meta-data.php';

WPCF7_Integration::get_instance()->add_service(
Expand Down
224 changes: 0 additions & 224 deletions omnisend-for-contact-form-7/module/class-wpcf7-omnisend-contact.php

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
* @package OmnisendContactFrom7Plugin
*/

use Omnisend\Public\V1\Omnisend;

if ( ! defined( 'ABSPATH' ) ) {
exit;
}
Expand All @@ -13,7 +15,6 @@ class WPCF7_Omnisend_Service extends WPCF7_Service {


private static $instance;
private $api_key;

public static function get_instance() {
if ( empty( self::$instance ) ) {
Expand All @@ -23,9 +24,6 @@ public static function get_instance() {
return self::$instance;
}

private function __construct() {
$this->api_key = get_option( 'omnisend_api_key', '' );
}

public function get_title() {
return 'Omnisend';
Expand All @@ -36,7 +34,7 @@ public function is_active() {
return false;
}

return $this->api_key != '';
return Omnisend::is_connected();
}

public function get_categories() {
Expand Down Expand Up @@ -87,20 +85,21 @@ public function display( $action = '' ) {
}
}

public function get_api_key() {
return $this->api_key;
public function is_required_plugin_active(): bool {
return is_plugin_active( 'omnisend/class-omnisend-core-bootstrap.php' );
}

public function is_required_plugin_active(): bool {
return is_plugin_active( 'omnisend-connect/omnisend-woocommerce.php' );
public function is_required_plugin_updated(): bool {

nerijuszaniauskas marked this conversation as resolved.
Show resolved Hide resolved
return class_exists( 'Omnisend\Public\V1\Omnisend' );
}

private function display_setup() {
echo '<strong>To integrate your Contact Form 7 with Omnisend, complete these steps:</strong>
<br />
<br />
<li>Install the <a href="https://wordpress.org/plugins/omnisend-connect/">Email Marketing for WooCommerce by Omnisend</a> plugin</li>
<li>Connect your WooCommerce store to your Omnisend account</li>
<li>Install the <a href="https://wordpress.org/plugins/omnisend/">Email Marketing by Omnisend</a> plugin</li>
<li>Connect your WordPress site to your Omnisend account</li>
<br />';

printf(
Expand All @@ -112,10 +111,13 @@ private function display_setup() {

private function check_setup(): void {
if ( ! $this->is_required_plugin_active() ) {
echo '<div class="notice notice-error"><p><strong>Error</strong>: <a href="https://wordpress.org/plugins/omnisend-connect/">Email Marketing for WooCommerce by Omnisend</a> plugin is not installed or activated</p></div>';
echo '<div class="notice notice-error"><p><strong>Error</strong>: <a href="https://wordpress.org/plugins/omnisend/">Email Marketing by Omnisend</a> plugin is not installed or activated</p></div>';
$this->display_setup();
} elseif ( ! $this->is_required_plugin_updated() ) {
echo '<div class="notice notice-error"><p><strong>Error</strong>:Your Email Marketing by Omnisend is not up to date. Please update plugins </p></div>';
$this->display_setup();
} elseif ( empty( $this->api_key ) ) {
echo '<div class="notice notice-error"><p><strong>Error</strong>: WooCommerce store is not connected to your Omnisend account</p></div>';
} elseif ( ! Omnisend::is_connected() ) {
echo '<div class="notice notice-error"><p><strong>Error</strong>: WordPress site is not connected to your Omnisend account</p></div>';
$this->display_setup();
} else {
echo '<div class="notice notice-success"><p><strong>Omnisend</strong> integration for Contact form 7 is set up!</p></div>';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,19 +11,6 @@

class WPCF7_Omnisend_Utils {

public static function is_valid_custom_property_ame( $name ): bool {
return preg_match( '/^[a-zA-Z0-9_]{1,128}$/', $name );
}

public static function is_valid_tag( $tag ): bool {
return preg_match( '/^[a-zA-Z0-9_\- ]{1,128}$/', $tag );
}

public static function clean_up_tag( $tag ): string {
$tag = preg_replace( '/[^A-Za-z0-9_\- ]/', '', $tag );
return mb_strimwidth( $tag, 0, 128 );
}

public static function debug( $arg ) {
$bt = debug_backtrace(); // phpcs:ignore
$caller = array_shift( $bt );
Expand Down
Loading
Loading