omnisend-for-contact-form-7
Last commit date
fonts
2 years ago
img
2 years ago
module
1 year ago
styles
2 years ago
class-wpcf7-omnisend-bootstrap.php
11 months ago
readme.txt
11 months ago
class-wpcf7-omnisend-bootstrap.php
81 lines
| 1 | <?php |
| 2 | /** |
| 3 | * Omnisend Contact form 7 plugin |
| 4 | * |
| 5 | * Plugin Name: Omnisend for Contact Form 7 Add-On |
| 6 | * Description: A Contact Form 7 add-on to sync contacts with Omnisend. In collaboration with Omnisend for WooCommerce plugin it enables better customer tracking |
| 7 | * Version: 1.1.5 |
| 8 | * Author: Omnisend |
| 9 | * Author URI: https://www.omnisend.com |
| 10 | * Developer: Omnisend |
| 11 | * Developer URI: https://developers.omnisend.com |
| 12 | * Text Domain: omnisend-for-contact-form-7 |
| 13 | * ------------------------------------------------------------------------ |
| 14 | * Copyright 2023 Omnisend |
| 15 | * License: GNU General Public License v3.0 |
| 16 | * License URI: http://www.gnu.org/licenses/gpl-3.0.html |
| 17 | * |
| 18 | * @package OmnisendContactFrom7Plugin |
| 19 | */ |
| 20 | |
| 21 | if ( ! defined( 'ABSPATH' ) ) { |
| 22 | exit; |
| 23 | } |
| 24 | |
| 25 | add_action( 'wpcf7_init', array( 'WPCF7_Omnisend_Bootstrap', 'load' ), 5 ); |
| 26 | |
| 27 | const WPCP7_OMNISEND_PLUGIN_NAME = 'Omnisend for Contact Form 7'; |
| 28 | const WPCP7_OMNISEND_PLUGIN_VERSION = '1.1.5'; |
| 29 | const WPCP7_OMNISEND_SUPPORT_ARTICLE_LINK = 'https://support.omnisend.com/en/articles/8672359-integration-with-contact-form-7'; |
| 30 | const WPCP7_OMNISEND_WELCOME_AUTOMATION_ARTICLE_LINK = 'https://support.omnisend.com/en/articles/1061818-welcome-email-automation'; |
| 31 | |
| 32 | class WPCF7_Omnisend_Bootstrap { |
| 33 | public static function load(): void { |
| 34 | if ( self::has_breaking_changes() ) { |
| 35 | return; |
| 36 | } |
| 37 | |
| 38 | require_once 'module/class-wpcf7-omnisend-service.php'; |
| 39 | require_once 'module/class-wpcf7-omnisend.php'; |
| 40 | require_once 'module/class-wpcf7-omnisend-form-meta-data.php'; |
| 41 | |
| 42 | WPCF7_Integration::get_instance()->add_service( |
| 43 | 'omnisend', |
| 44 | WPCF7_Omnisend_Service::get_instance() |
| 45 | ); |
| 46 | |
| 47 | WPCF7_Omnisend::get_instance()->load(); |
| 48 | } |
| 49 | |
| 50 | public static function has_breaking_changes(): bool { |
| 51 | if ( ! method_exists( 'WPCF7_Integration', 'add_service' ) ) { |
| 52 | return true; |
| 53 | } |
| 54 | |
| 55 | if ( ! method_exists( 'WPCF7_ContactForm', 'scan_form_tags' ) ) { |
| 56 | return true; |
| 57 | } |
| 58 | |
| 59 | if ( ! method_exists( 'WPCF7_ContactForm', 'id' ) ) { |
| 60 | return true; |
| 61 | } |
| 62 | |
| 63 | if ( ! method_exists( 'WPCF7_Submission', 'get_posted_data' ) ) { |
| 64 | return true; |
| 65 | } |
| 66 | |
| 67 | return false; |
| 68 | } |
| 69 | } |
| 70 | |
| 71 | add_action( |
| 72 | 'admin_notices', |
| 73 | function () { |
| 74 | if ( ! is_plugin_active( 'contact-form-7/wp-contact-form-7.php' ) ) { |
| 75 | echo '<div class="notice notice-error"><strong>' . esc_html( WPCP7_OMNISEND_PLUGIN_NAME ) . '</strong> requires <strong>Contact form 7</strong> to be installed and active.</p></div>'; |
| 76 | } elseif ( WPCF7_Omnisend_Bootstrap::has_breaking_changes() ) { |
| 77 | echo '<div class="notice notice-error"><strong>' . esc_html( WPCP7_OMNISEND_PLUGIN_NAME ) . '</strong> plugin is not loaded due compatibility issue with <strong>Contact Form 7</strong> plugin. Please update <strong>' . esc_html( WPCP7_OMNISEND_PLUGIN_NAME ) . '</strong> plugin to latest version.</p></div>'; |
| 78 | } |
| 79 | } |
| 80 | ); |
| 81 |