Skip to content

Commit

Permalink
Merge branch 'develop' into release/7.1.2
Browse files Browse the repository at this point in the history
pvpcookie committed Feb 24, 2024

Unverified

This user has not yet uploaded their public signing key.
2 parents 52b3cdb + 4fe9eea commit d329cae
Showing 5 changed files with 31 additions and 24 deletions.
1 change: 1 addition & 0 deletions admin/page/class-dotdigital-wordpress-settings-admin.php
Original file line number Diff line number Diff line change
@@ -56,6 +56,7 @@ public function legacy_redirect() {
wp_redirect(
admin_url( 'admin.php?page=' . $this->get_slug() . ( $tab ? '&tab=' . $tab : '' ) )
);
exit();
}

/**
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "dotdigital/dotdigital-for-wordpress",
"version": "7.1.1",
"version": "7.1.2",
"authors": [
{
"name": "Dotdigital",
4 changes: 2 additions & 2 deletions dm_signup_form.php
Original file line number Diff line number Diff line change
@@ -8,7 +8,7 @@
* Plugin Name: Dotdigital for WordPress
* Plugin URI: https://integrations.dotdigital.com/technology-partners/wordpress
* Description: Add a "Subscribe to Newsletter" widget to your website that will insert your contact in one of your Dotdigital lists.
* Version: 7.1.1
* Version: 7.1.2
* Author: dotdigital
* Author URI: https://www.dotdigital.com/
* License: GPL-2.0+
@@ -24,7 +24,7 @@

require_once __DIR__ . '/vendor/autoload.php';

define( 'DOTDIGITAL_WORDPRESS_VERSION', '7.1.1' );
define( 'DOTDIGITAL_WORDPRESS_VERSION', '7.1.2' );
define( 'DOTDIGITAL_WORDPRESS_PLUGIN_NAME', 'dotdigital-for-wordpress' );
define( 'DOTDIGITAL_WORDPRESS_PLUGIN_SLUG', 'dotdigital_for_wordpress' );
define( 'DOTDIGITAL_WORDPRESS_PLUGIN_PATH', plugin_dir_path( __FILE__ ) );
Original file line number Diff line number Diff line change
@@ -84,39 +84,40 @@ public function get( \WP_REST_Request $request ) {
*
* @param \WP_REST_Request $request
*
* @return bool|null
* @return null
*/
public function post( \WP_REST_Request $request ) {
$data = $request->get_params();

if ( $data['is_ajax'] && ( ! isset( $_SERVER['HTTP_X_WP_NONCE'] ) || ! wp_verify_nonce( wp_unslash( $_SERVER['HTTP_X_WP_NONCE'] ), 'wp_rest' ) ) ) { // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized
return $this->process_response( false, Dotdigital_WordPress_Sign_Up_Widget::get_fill_required_message(), $data );
$this->process_response( false, Dotdigital_WordPress_Sign_Up_Widget::get_fill_required_message(), $data );
}

$email = isset( $_POST['email'] ) ? sanitize_email( wp_unslash( $_POST['email'] ) ) : '';
$datafields = isset( $_POST['datafields'] ) ? wp_unslash( $_POST['datafields'] ) : array(); // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized
$lists = isset( $_POST['lists'] ) ? wp_unslash( $_POST['lists'] ) : array(); // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized

if ( $this->has_invalid_email( $email ) ) {
return $this->process_response( false, Dotdigital_WordPress_Sign_Up_Widget::get_invalid_email_message(), $data );
$this->process_response( false, Dotdigital_WordPress_Sign_Up_Widget::get_invalid_email_message(), $data );
}

if ( $this->has_no_lists_but_should_have( $lists ) ) {
return $this->process_response( false, Dotdigital_WordPress_Sign_Up_Widget::get_nobook_message(), $data );
$this->process_response( false, Dotdigital_WordPress_Sign_Up_Widget::get_nobook_message(), $data );
}

if ( $this->has_missing_required_data_fields( $datafields ) ) {
return $this->process_response( false, Dotdigital_WordPress_Sign_Up_Widget::get_fill_required_message(), $data );
$this->process_response( false, Dotdigital_WordPress_Sign_Up_Widget::get_fill_required_message(), $data );
}

return $this->create_contact( $data );
$this->create_contact( $data );
return null;
}

/**
* Create and subscribe the contact.
*
* @param array $data
* @return bool|null
* @return void
*/
private function create_contact( $data ) {
try {
@@ -127,9 +128,9 @@ private function create_contact( $data ) {
$this->dotdigital_contact->create_or_update( $contact );
} catch ( \Exception $e ) {
error_log( $e->getMessage() );
return $this->process_response( false, Dotdigital_WordPress_Sign_Up_Widget::get_failure_message(), $data );
$this->process_response( false, Dotdigital_WordPress_Sign_Up_Widget::get_failure_message(), $data );
}
return $this->process_response( true, Dotdigital_WordPress_Sign_Up_Widget::get_success_message(), $data );
$this->process_response( true, Dotdigital_WordPress_Sign_Up_Widget::get_success_message(), $data );
}

/**
@@ -220,29 +221,29 @@ private function prepare_data_fields_for_http_post( array $datafields ) {
* @param bool $success
* @param string $message
* @param array $data
* @return bool|null
* @return void
*/
private function process_response( bool $success, string $message, array $data ) {
if ( $data['is_ajax'] ) {
$this->ajax_response( $success, $message, $data['redirection'] );
return null;
} else {
return $this->post_response( $success, $message, $data );
$this->post_response( $success, $message, $data );
}
}

/**
* @param bool $success
* @param string $message
* @param array $data
* @return bool|null
* @return void
*/
private function post_response( $success, $message, $data ) {
if ( ! empty( $data['redirection'] ) ) {
return wp_redirect( $data['redirection'] );
wp_redirect( $data['redirection'] );
exit();
}

return wp_redirect(
wp_redirect(
add_query_arg(
array(
'success' => (int) $success,
@@ -252,13 +253,14 @@ private function post_response( $success, $message, $data ) {
$data['origin']
)
);
exit();
}

/**
* @param bool $success
* @param string $message
* @param string $redirection
* @return null
* @return void
*/
private function ajax_response( $success, $message, $redirection ) {
$data = array(
@@ -271,6 +273,5 @@ private function ajax_response( $success, $message, $redirection ) {
}

wp_send_json( $data );
return null;
}
}
13 changes: 9 additions & 4 deletions readme.txt
Original file line number Diff line number Diff line change
@@ -2,11 +2,11 @@
Contributors: dotMailer, bsstaveley, amucklow, fstrezos, pvpcookie
Tags: email marketing, newsletter signup
Requires at least: 5.3
Tested up to: 6.4.1
Tested up to: 6.4.3
Requires PHP: 7.4
Stable tag: 7.1.1
License: GPLv2 or later
License URI: http://www.gnu.org/licenses/gpl-2.0.html
Stable tag: 7.1.2
License: MIT
License URI: https://opensource.org/licenses/MIT


== Description ==
@@ -61,6 +61,11 @@ Example: [dotdigital-signup showtitle=0 showdesc=0 redirection="http://www.examp

== Changelog ==

= 7.1.2 =

**Bug fixes**
- We fixed a problem with form submissions not redirecting from the REST endpoint.

= 7.1.1 =

**Improvements**

0 comments on commit d329cae

Please sign in to comment.