-
Notifications
You must be signed in to change notification settings - Fork 77
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1344 from angelleye/PFW-460
Marketing Sidebar - Newsletter Signup Adjustment, PFW-460
- Loading branch information
Showing
2 changed files
with
46 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,24 +1,43 @@ | ||
<?php | ||
|
||
add_action('wp_ajax_angelleye_marketing_mailchimp_subscription', 'own_angelleye_marketing_mailchimp_subscription'); | ||
add_action('wp_ajax_angelleye_marketing_sendy_subscription', 'own_angelleye_marketing_sendy_subscription'); | ||
|
||
function own_angelleye_marketing_mailchimp_subscription() { | ||
$url = 'https://angelleye.us7.list-manage.com/subscribe/post-json?u=4c6d56be138a966cd573c928f&id=84c27e6cd1'; | ||
$url = add_query_arg(array('EMAIL' => $_POST['email']), $url); | ||
function own_angelleye_marketing_sendy_subscription() { | ||
$url = 'https://sendy.angelleye.com/subscribe'; | ||
$response = wp_remote_post($url, array( | ||
'method' => 'POST', | ||
'timeout' => 45, | ||
'redirection' => 5, | ||
'httpversion' => '1.0', | ||
'blocking' => true, | ||
'headers' => array(), | ||
'body' => array(), | ||
'body' => array( 'list' => 'pjFolYKqSdLe57i4uuUz0g', 'boolean' => 'true', 'email' => $_POST['email'], 'gdpr' => 'true', 'silent' => 'true'), | ||
'cookies' => array() | ||
) | ||
); | ||
if (is_wp_error($response)) { | ||
wp_send_json(wp_remote_retrieve_body($response)); | ||
} else { | ||
wp_send_json(wp_remote_retrieve_body($response)); | ||
$body = wp_remote_retrieve_body($response); | ||
$apiResponse = strval($body); | ||
switch ( $apiResponse ) { | ||
case 'true': | ||
case '1': | ||
prepareResponse( "true", 'Thank you for subscribing!' ); | ||
case 'Already subscribed.': | ||
prepareResponse( "true", 'Already subscribed!' ); | ||
default: | ||
prepareResponse( "false", $apiResponse ); | ||
} | ||
} | ||
} | ||
|
||
|
||
} | ||
|
||
function prepareResponse( $status = false, $msg = 'Something went wrong!' ) { | ||
$return = array( | ||
'result' => $status, | ||
'message' => $msg | ||
); | ||
wp_send_json($return); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters