Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
…erce into release
  • Loading branch information
angelleye committed Feb 18, 2019
2 parents 5c6c2a8 + d5fc417 commit 8ebdfd7
Show file tree
Hide file tree
Showing 3 changed files with 66 additions and 1 deletion.
44 changes: 44 additions & 0 deletions angelleye-includes/angelleye-utility.php
Expand Up @@ -2225,4 +2225,48 @@ public static function angelleye_add_paypal_payment_meta($order_id, $payment_met
update_post_meta($order_id, $key, wc_clean($value));
}
}

public static function angelleye_get_push_notifications() {
$args = array(
'plugin_name' => 'paypal-for-woocommerce',
);
$api_url = PAYPAL_FOR_WOOCOMMERCE_PUSH_NOTIFICATION_WEB_URL . '?Wordpress_Plugin_Notification_Sender';
$api_url .= '&action=angelleye_get_plugin_notification';
$request = wp_remote_post($api_url, array(
'method' => 'POST',
'timeout' => 45,
'redirection' => 5,
'httpversion' => '1.0',
'blocking' => true,
'headers' => array('user-agent' => 'AngellEYE'),
'body' => $args,
'cookies' => array(),
'sslverify' => false
));
if (is_wp_error($request) or wp_remote_retrieve_response_code($request) != 200) {
return false;
}
if ($request != '') {
$response = json_decode(wp_remote_retrieve_body($request));
} else {
$response = false;
}
return $response;
}

public static function angelleye_display_push_notification($response_data) {
echo '<div class="notice notice-success angelleye-notice" style="display:none;">'
. '<div class="angelleye-notice-logo-push"><span> <img src="'.$response_data->ans_company_logo.'"> </span></div>'
. '<div class="angelleye-notice-message">'
. '<h3>' . $response_data->ans_message_title .'</h3>'
. '<div class="angelleye-notice-message-inner">'
. $response_data->ans_message_description
. '</div>'
. '</div>'
. '<div class="angelleye-notice-cta">'
. '<a href="'.$response_data->ans_button_url.'" class="button button-primary">'.$response_data->ans_button_label.'</a>'
. '<button class="angelleye-notice-dismiss angelleye-dismiss-welcome" data-msg="'.$response_data->id.'">Dismiss</button>'
. '</div>'
. '</div>';
}
}
7 changes: 7 additions & 0 deletions assets/css/admin.css
Expand Up @@ -359,7 +359,14 @@ label[for=woocommerce_paypal_express_paypal_marketing_solutions_enabled] {
.angelleye-notice-message-inner {
margin-bottom: 10px;
}
.angelleye-notice-logo-push {
background-repeat: no-repeat;
background-position: 50% 50%;
}

.angelleye-notice-logo-push span {
display: block;
}
@media only all and (max-width: 1200px) {
.angelleye-notice-dismiss {
display: block;
Expand Down
16 changes: 15 additions & 1 deletion paypal-for-woocommerce.php
Expand Up @@ -50,6 +50,10 @@
if (!defined('PAYPAL_FOR_WOOCOMMERCE_DIR_PATH')) {
define('PAYPAL_FOR_WOOCOMMERCE_DIR_PATH', untrailingslashit( plugin_dir_path( __FILE__ ) ));
}
if (!defined('PAYPAL_FOR_WOOCOMMERCE_PUSH_NOTIFICATION_WEB_URL')) {
define('PAYPAL_FOR_WOOCOMMERCE_PUSH_NOTIFICATION_WEB_URL', 'https://www.angelleye.com/');
}


/**
* Set global parameters
Expand Down Expand Up @@ -314,6 +318,15 @@ function admin_notices() {
wp_redirect($set_ignore_tag_url);
}

$response = AngellEYE_Utility::angelleye_get_push_notifications();
if(is_object($response)) {
foreach ($response->data as $key => $response_data) {
if(!get_user_meta($user_id, $response_data->id)) {
AngellEYE_Utility::angelleye_display_push_notification($response_data);
}
}
}

}

//init function
Expand Down Expand Up @@ -1085,13 +1098,14 @@ public function angelleye_dismiss_notice() {
$user_id = $current_user->ID;
if( !empty($_POST['action']) && $_POST['action'] == 'angelleye_dismiss_notice' ) {
$notices = array('ignore_pp_ssl', 'ignore_pp_sandbox', 'ignore_pp_woo', 'ignore_pp_check', 'ignore_pp_donate', 'ignore_paypal_plus_move_notice', 'ignore_billing_agreement_notice', 'ignore_paypal_pro_payflow_reference_transaction_notice', 'is_disable_pw_premium_extension_notice');

foreach ($notices as $notice) {
if ( !empty($_POST['data']) && $_POST['data'] == $notice) {
add_user_meta($user_id, $notice, 'true', true);
wp_send_json_success();
}
}
add_user_meta($user_id, wc_clean($_POST['data']), 'true', true);
wp_send_json_success();
}
}

Expand Down

0 comments on commit 8ebdfd7

Please sign in to comment.