From e8337775bead3e12cc87bab20c7972f5e7217156 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Arnas=20Gec=CC=8Cas?= Date: Mon, 5 Feb 2024 11:49:20 +0200 Subject: [PATCH] Fix logic --- composer.lock | 16 ++++++++-------- .../class-omnisendaddon.php | 15 +++++++++++---- 2 files changed, 19 insertions(+), 12 deletions(-) diff --git a/composer.lock b/composer.lock index bed8850..15e1992 100644 --- a/composer.lock +++ b/composer.lock @@ -253,16 +253,16 @@ }, { "name": "squizlabs/php_codesniffer", - "version": "3.8.0", + "version": "3.8.1", "source": { "type": "git", "url": "https://github.com/PHPCSStandards/PHP_CodeSniffer.git", - "reference": "5805f7a4e4958dbb5e944ef1e6edae0a303765e7" + "reference": "14f5fff1e64118595db5408e946f3a22c75807f7" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/PHPCSStandards/PHP_CodeSniffer/zipball/5805f7a4e4958dbb5e944ef1e6edae0a303765e7", - "reference": "5805f7a4e4958dbb5e944ef1e6edae0a303765e7", + "url": "https://api.github.com/repos/PHPCSStandards/PHP_CodeSniffer/zipball/14f5fff1e64118595db5408e946f3a22c75807f7", + "reference": "14f5fff1e64118595db5408e946f3a22c75807f7", "shasum": "" }, "require": { @@ -272,11 +272,11 @@ "php": ">=5.4.0" }, "require-dev": { - "phpunit/phpunit": "^4.0 || ^5.0 || ^6.0 || ^7.0 || ^8.0 || ^9.0" + "phpunit/phpunit": "^4.0 || ^5.0 || ^6.0 || ^7.0 || ^8.0 || ^9.3.4" }, "bin": [ - "bin/phpcs", - "bin/phpcbf" + "bin/phpcbf", + "bin/phpcs" ], "type": "library", "extra": { @@ -329,7 +329,7 @@ "type": "open_collective" } ], - "time": "2023-12-08T12:32:31+00:00" + "time": "2024-01-11T20:47:48+00:00" }, { "name": "wp-coding-standards/wpcs", diff --git a/omnisend-for-gravity-forms/class-omnisendaddon.php b/omnisend-for-gravity-forms/class-omnisendaddon.php index 7bc0077..b8ba1b5 100644 --- a/omnisend-for-gravity-forms/class-omnisendaddon.php +++ b/omnisend-for-gravity-forms/class-omnisendaddon.php @@ -31,13 +31,14 @@ public function minimum_requirements() { 'plugins' => array( 'omnisend/class-omnisend-core-bootstrap.php' => 'Email Marketing by Omnisend', ), - array( $this, 'omnisend_connected' ), + array( $this, 'omnisend_custom_requirement_callback' ), ); } - public function omnisend_connected( $meets_requirements ) { + public function omnisend_custom_requirement_callback( $meets_requirements ) { + if ( ! is_plugin_active( 'omnisend/class-omnisend-core-bootstrap.php' ) ) { - return array( 'meets_requirements' => true ); // Covered with "minimum_requirements" function, no plugin - no need to check more. + return $meets_requirements; } if ( ! class_exists( 'Omnisend\Public\V1\Omnisend' ) ) { @@ -351,7 +352,13 @@ public function after_submission( $entry, $form ) { $this->mapCustomProperties( $form, $entry, $settings, $contact ); $response = \Omnisend\Public\V1\Omnisend::get_client( OMNISEND_GRAVITY_ADDON_NAME, OMNISEND_GRAVITY_ADDON_VERSION )->create_contact( $contact ); + if ( is_wp_error( $response ) ) { + error_log( 'Error in after_submission: ' . $response->get_error_message()); // phpcs:ignore + return; + } + if ( ! is_string( $response ) ) { + error_log( 'Unexpected error. Please contact Omnisend support.'); // phpcs:ignore return; } @@ -398,7 +405,7 @@ private function mapCustomProperties( $form, $entry, $settings, Contact $contact } public function get_menu_icon() { - return wp_remote_get( $this->get_base_path() . '/images/menu-icon.svg' ); + return file_get_contents( $this->get_base_path() . '/images/menu-icon.svg' ); // phpcs:ignore } private function enableWebTracking( $email, $phone ) {