diff --git a/assets/css/deactivation-modal.css b/assets/css/deactivation-modal.css new file mode 100644 index 000000000..1ab862052 --- /dev/null +++ b/assets/css/deactivation-modal.css @@ -0,0 +1 @@ +@font-face{font-family:'deactivation-icomoon';src:url("../fonts/icomoon.eot?-4yq2oj");src:url("../fonts/icomoon.eot?#iefix-4yq2oj") format("embedded-opentype"),url("../fonts/icomoon.woff?-4yq2oj") format("woff"),url("../fonts/icomoon.ttf?-4yq2oj") format("truetype"),url("../fonts/icomoon.svg?-4yq2oj#icomoon") format("svg");font-weight:normal;font-style:normal}[class^="deactivation-icon-"]:before,[class*=" deactivation-icon-"]:after,[class^="deactivation-icon-"]:after,[class*=" deactivation-icon-"]:before,[id^="deactivation-nav-"]:before,[id*=" deactivation-nav-"]:after,[id^="deactivation-nav-"]:after,[id*=" deactivation-nav-"]:before{font-family:'deactivation-icomoon';speak:none;font-style:normal;font-weight:normal;font-variant:normal;text-transform:none;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale}[class^="deactivation-icon-"] span.hidden,[class*=" deactivation-icon-"] span.hidden{display:inline-block;height:0;width:0;overflow:hidden}.deactivation-icon-chevron-right:before{content:"\e900"}.deactivation-icon-chevron-left:before{content:"\e900";transform:rotate(180deg)}.deactivation-icon-chevron-down:before{content:"\e901";transform:scale(0.6)}.deactivation-icon-chevron-up:before{content:"\e902";top:50%;transform:translateY(-50%) scale(0.6)}.deactivation-icon-rollback:before{content:"\e903"}.deactivation-icon-addon:before{content:"\e904"}.deactivation-icon-addons:before{content:"\e905"}.deactivation-icon-book:before{content:"\e906"}.deactivation-icon-cdn:before{content:"\e907"}.deactivation-icon-database:before{content:"\e908"}.deactivation-icon-export:before{content:"\e909"}.deactivation-icon-files:before{content:"\e90a"}.deactivation-icon-help:before{content:"\e90b"}.deactivation-icon-home:before{content:"\e90c"}.deactivation-icon-import:before{content:"\e90d"}.deactivation-icon-important:before{content:"\e90e"}.deactivation-icon-information:before{content:"\e90f"}.deactivation-icon-information2:before{content:"\e910"}.deactivation-icon-interrogation:before{content:"\e911"}.deactivation-icon-media:before{content:"\e912"}.deactivation-icon-plus:before{content:"\e913"}.deactivation-icon-refresh:before{content:"\e914"}.deactivation-icon-rules:before{content:"\e915"}.deactivation-icon-stack:before{content:"\e916"}.deactivation-icon-tools:before{content:"\e917"}.deactivation-icon-trash:before{content:"\e918"}.deactivation-icon-user:before{content:"\e919"}.deactivation-icon-check:before{content:"\e920"}.deactivation-icon-check2:before{content:"\e921"}.deactivation-icon-close:before{content:"\e922"}.deactivation-Modal{display:none;position:fixed;width:550px;height:auto;top:50%;left:50%;background:#fff;color:#444;transform:translateX(-50%) translateY(-50%);z-index:100000;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale;-ms-interpolation-mode:nearest-neighbor;image-rendering:optimizeQuality;text-rendering:optimizeLegibility}.deactivation-Modal-overlay{display:none;position:fixed;width:100%;height:100%;top:0;left:0;background:rgba(0,0,0,0.7);z-index:99999}.deactivation-Modal-header{display:flex;align-items:center;justify-content:space-between;padding:0 16px 0 32px;border-bottom:1px solid #EEE}.deactivation-Modal-header>div{display:flex}.deactivation-Modal-footer{display:flex;align-items:center;justify-content:space-between;height:64px;padding:0 32px;background:#F5F5F5}.deactivation-Modal-close{font-size:0;color:#AAA;border:none;background:none;cursor:pointer}.deactivation-Modal-close:hover{color:#008ec2}.deactivation-Modal-close:before{font-size:1.25rem;line-height:1}.deactivation-Modal-return{display:none;border:none;background:none;cursor:pointer;font-size:0;color:#777;position:relative;width:28px;left:-12px}.deactivation-Modal-return.deactivation-isOpen{display:inline-block}.deactivation-Modal-return:before{font-size:14px;display:inline-block}.deactivation-Modal-return:hover,.deactivation-Modal-return:focus{outline:none;color:#008ec2}.deactivation-Modal-cancel{color:#0073aa;text-decoration:underline;margin-left:8px;line-height:28px;border:none;background:none;cursor:pointer;font-weight:500}.deactivation-Modal-cancel:hover{color:#008ec2}.deactivation-Modal-question{display:none}.deactivation-Modal-question.deactivation-isOpen{display:block}.deactivation-Modal-content{padding:8px 32px}.deactivation-Modal-fieldHidden{display:none;padding-left:26px;margin-top:8px}.deactivation-Modal-fieldHidden.deactivation-isOpen{display:block}.deactivation-Modal-fieldHidden input[type=text],.deactivation-Modal-fieldHidden textarea{border:2px solid #A9ADB0;font-size:12px;border-radius:3px;transition:border 150ms ease-out;-webkit-transition:border 150ms ease-out}.deactivation-Modal-fieldHidden input[type=text]:focus,.deactivation-Modal-fieldHidden textarea:focus{outline:none;box-shadow:none;border-color:#777}.deactivation-Modal-fieldHidden input[type=text]::-webkit-input-placeholder,.deactivation-Modal-fieldHidden textarea::-webkit-input-placeholder{color:#ccc}.deactivation-Modal-fieldHidden input[type=text] :-moz-placeholder,.deactivation-Modal-fieldHidden textarea :-moz-placeholder{color:#ccc;opacity:1}.deactivation-Modal-fieldHidden input[type=text]::-moz-placeholder,.deactivation-Modal-fieldHidden textarea::-moz-placeholder{color:#ccc;opacity:1}.deactivation-Modal-fieldHidden input[type=text] :-ms-input-placeholder,.deactivation-Modal-fieldHidden textarea :-ms-input-placeholder{color:#ccc}.deactivation-Modal-fieldHidden input[type=text]::-ms-input-placeholder,.deactivation-Modal-fieldHidden textarea::-ms-input-placeholder{color:#ccc}.deactivation-Modal-fieldHidden input[type=text]::placeholder,.deactivation-Modal-fieldHidden textarea::placeholder{color:#ccc}.deactivation-Modal-fieldHidden input[type=text]{width:300px;height:30px}.deactivation-Modal-fieldHidden textarea{width:100%;height:60px;padding:5px}.deactivation-Modal-hidden{display:none}.deactivation-Modal-hidden.deactivation-isOpen{display:block}.deactivation-Modal-hidden button{cursor:pointer;border:none;margin-bottom:24px}.deactivation-Modal-hidden .text-center{text-align:center}.deactivation-Modal-hidden h3{display:none !important}.deactivation-Modal-hidden a{color:#1B9AAA !important}.deactivation-Modal-hidden a:hover{color:#0073aa !important}.deactivation-Modal-safeMode{position:relative;padding:10px 12px 10px 52px;background:#EBFAF5;color:#00A66B;border-radius:2px;font-size:.8125rem;line-height:1.38462}.deactivation-Modal-safeMode:before{position:absolute;display:block;width:24px;height:24px;left:12px;top:50%;margin-top:-14px;border-radius:50%;text-align:center;border:2px solid #00A66B;font-size:.875rem;line-height:1.71429}.deactivation-Modal-safeMode-title{font-weight:bold;letter-spacing:0.011em;text-transform:uppercase}.deactivation-Modal .button{font-weight:500;box-shadow:none;height:30px;border-bottom-width:3px}.deactivation-Modal .button-primary.deactivation-isDisabled{opacity:0.2;color:#fff !important;cursor:not-allowed;pointer-events:none}.deactivation-Modal ul li{padding:4px 0}.deactivation-Modal h2,.deactivation-Modal h3{display:inline-block;font-size:1rem;line-height:1.1875}.deactivation-Modal h2{max-width:430px;font-weight:600;color:#23282D;margin:12px 0}.deactivation-Modal h3{font-weight:bold;color:#3D474E;margin:8px 0}.deactivation-Modal input[type=radio]{margin-top:1px;margin-right:8px}.deactivation-Modal .show-if-safe-mode{display:none}.deactivation-button{position:relative;display:inline-block;width:auto;padding:8px 24px;text-align:center;background:#F56640;box-shadow:0 4px 6px rgba(50,50,93,0.11),0 1px 3px rgba(0,0,0,0.08);text-transform:uppercase;text-decoration:none;letter-spacing:-0.08px;font-weight:bold;border-radius:4px;color:#fff !important;white-space:nowrap;-webkit-backface-visibility:hidden;backface-visibility:hidden;transition:all 200ms ease-out;-webkit-transition:all 200ms ease-out;font-size:.8125rem;line-height:1.53846}.deactivation-button:hover,.deactivation-button:focus{color:#fff !important;transform:translateY(-2px);box-shadow:0 7px 14px rgba(50,50,93,0.25),0 3px 6px rgba(0,0,0,0.2)}.deactivation-button--small{padding:5px 0;letter-spacing:-0.08px;font-size:.6875rem;line-height:1.81818}.deactivation-button--icon{min-width:160px;padding-left:8px;padding-right:40px;text-align:left}.deactivation-button--icon:before{position:absolute;right:8px;font-size:.9375rem;line-height:1.33333}.deactivation-button--fixed{position:fixed;display:flex;padding:8px 16px;right:24px;bottom:32px;border-radius:16px}.deactivation-button--fixed:before{font-size:1.125rem;line-height:1;margin-right:8px}.deactivation-button--purple{background:#2D1656}.deactivation-button--blue{min-width:inherit;background:#1EADBF}.deactivation-button--lightBlue{min-width:inherit;background:#40BACB}.deactivation-button--red{background:#D33F49}.deactivation-button--blueDark{background:#02707F}.deactivation-button:focus{outline:none;color:#fff !important}html[dir=rtl] .deactivation-Modal-header{padding:0 32px 0 16px}html[dir=rtl] .deactivation-Modal-return{left:12px;transform:rotate(180deg)}html[dir=rtl] .deactivation-Modal-safeMode{padding:10px 52px 10px 12px}html[dir=rtl] .deactivation-Modal-safeMode:before{left:inherit;right:12px} diff --git a/assets/fonts/icomoon.eot b/assets/fonts/icomoon.eot new file mode 100644 index 000000000..ca87b377d Binary files /dev/null and b/assets/fonts/icomoon.eot differ diff --git a/assets/fonts/icomoon.svg b/assets/fonts/icomoon.svg new file mode 100644 index 000000000..6a4cc83f7 --- /dev/null +++ b/assets/fonts/icomoon.svg @@ -0,0 +1,39 @@ + + + +Generated by IcoMoon + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/assets/fonts/icomoon.ttf b/assets/fonts/icomoon.ttf new file mode 100644 index 000000000..6a0202c55 Binary files /dev/null and b/assets/fonts/icomoon.ttf differ diff --git a/assets/fonts/icomoon.woff b/assets/fonts/icomoon.woff new file mode 100644 index 000000000..5da2c2cbd Binary files /dev/null and b/assets/fonts/icomoon.woff differ diff --git a/assets/js/deactivation-form-modal.js b/assets/js/deactivation-form-modal.js new file mode 100644 index 000000000..192cc5c50 --- /dev/null +++ b/assets/js/deactivation-form-modal.js @@ -0,0 +1,121 @@ +var $ = jQuery; +$(document).ready(function () { + var $deactivationModal = $(".deactivation-Modal"); + if ($deactivationModal) { + new ModalWpr($deactivationModal); + } + $("#mixpanel-send-deactivation").click(function (e) { + e.preventDefault(); + + var data = { + action: 'angelleye_send_deactivation', + reason_details: $("#reason-other-details").val(), + reason: $("input[name='reason']:checked"). val() + + }; + $.post(ajaxurl, data, function () { + }) + .done(function (response) { + window.location.replace($('#mixpanel-send-deactivation').attr("href")); + }) + .fail(function (response) { + window.location.replace($('#mixpanel-send-deactivation').attr("href")); + }); + }); +}); +function ModalWpr(aElem) { + var refThis = this; + this.elem = aElem; + this.overlay = $('.deactivation-Modal-overlay'); + this.radio = $('input[name=reason]', aElem); + this.closer = $('.deactivation-Modal-close, .deactivation-Modal-cancel', aElem); + this.return = $('.deactivation-Modal-return', aElem); + this.opener = $('.plugins [data-slug="paypal-for-woocommerce"] .deactivate'); + this.question = $('.deactivation-Modal-question', aElem); + this.button = $('.button-primary', aElem); + this.title = $('.deactivation-Modal-header h2', aElem); + this.textFields = $('input[type=text], textarea', aElem); + this.hiddenReason = $('#deactivation-reason', aElem); + this.hiddenDetails = $('#deactivation-details', aElem); + this.titleText = this.title.text(); + this.opener.click(function () { + refThis.open(); + return false; + }); + this.closer.click(function () { + refThis.close(); + return false; + }); + aElem.bind('keyup', function (event) { + if (event.keyCode == 27) { + refThis.close(); + return false; + } + }); + this.return.click(function () { + refThis.returnToQuestion(); + return false; + }); + this.radio.change(function () { + refThis.change($(this)); + }); + this.textFields.keyup(function () { + refThis.hiddenDetails.val($(this).val()); + if (refThis.hiddenDetails.val() != '') { + refThis.button.removeClass('deactivation-isDisabled'); + refThis.button.removeAttr("disabled"); + } else { + refThis.button.addClass('deactivation-isDisabled'); + refThis.button.attr("disabled", true); + } + }); +} +ModalWpr.prototype.change = function (aElem) { + var id = aElem.attr('id'); + var refThis = this; + this.hiddenReason.val(aElem.val()); + this.hiddenDetails.val(''); + this.textFields.val(''); + $('.deactivation-Modal-fieldHidden').removeClass('deactivation-isOpen'); + $('.deactivation-Modal-hidden').removeClass('deactivation-isOpen'); + this.button.removeClass('deactivation-isDisabled'); + this.button.removeAttr("disabled"); + switch (id) { + case 'reason-temporary': + break; + case 'reason-broke': + break; + case 'reason-complicated': + break; + break; + case 'reason-other': + var field = aElem.siblings('.deactivation-Modal-fieldHidden'); + field.addClass('deactivation-isOpen'); + field.find('input, textarea').focus(); + refThis.button.addClass('deactivation-isDisabled'); + refThis.button.attr("disabled", true); + break; + } +}; +ModalWpr.prototype.returnToQuestion = function () { + $('.deactivation-Modal-fieldHidden').removeClass('deactivation-isOpen'); + $('.deactivation-Modal-hidden').removeClass('deactivation-isOpen'); + this.question.addClass('deactivation-isOpen'); + this.return.removeClass('deactivation-isOpen'); + this.title.text(this.titleText); + this.hiddenReason.val(''); + this.hiddenDetails.val(''); + this.radio.attr('checked', false); + this.button.addClass('deactivation-isDisabled'); + this.button.attr("disabled", true); +}; +ModalWpr.prototype.open = function () { + this.elem.css('display', 'block'); + this.overlay.css('display', 'block'); + localStorage.setItem('deactivation-hash', ''); +}; +ModalWpr.prototype.close = function () { + this.returnToQuestion(); + this.elem.css('display', 'none'); + this.overlay.css('display', 'none'); +}; \ No newline at end of file diff --git a/paypal-for-woocommerce.php b/paypal-for-woocommerce.php index ed018b920..5de27ed3d 100644 --- a/paypal-for-woocommerce.php +++ b/paypal-for-woocommerce.php @@ -138,7 +138,9 @@ public function __construct() add_action('woocommerce_product_data_panels', array( $this, 'angelleye_paypal_for_woo_product_date_panels' )); add_action('woocommerce_process_product_meta', array( $this, 'angelleye_paypal_for_woo_product_process_product_meta' )); add_action('angelleye_paypal_for_woocommerce_multi_account_api_paypal_payflow', array( $this, 'angelleye_paypal_for_woo_product_level_payment_action' ), 10, 3); - add_action( 'wp_head', array( $this, 'paypal_for_woo_head_mark' ), 1 ); + add_action( 'wp_head', array( $this, 'paypal_for_woo_head_mark' ), 1 ); + add_action( 'admin_footer', array($this, 'angelleye_add_deactivation_form')); + add_action( 'wp_ajax_angelleye_send_deactivation', array($this, 'angelleye_handle_plugin_deactivation_request')); $this->customer_id; } @@ -399,6 +401,7 @@ function activate_paypal_for_woocommerce() { if(!in_array( 'woocommerce/woocommerce.php',apply_filters('active_plugins',get_option('active_plugins'))) && !is_plugin_active_for_network( 'woocommerce/woocommerce.php' )) { deactivate_plugins(plugin_basename(__FILE__)); } + delete_option('angelleye_paypal_woocommerce_submited_feedback'); $opt_in_log = get_option('angelleye_send_opt_in_logging_details', 'no'); if($opt_in_log == 'yes') { $log_url = $_SERVER['HTTP_HOST']; @@ -414,11 +417,14 @@ function activate_paypal_for_woocommerce() { function deactivate_paypal_for_woocommerce() { // Log activation in Angell EYE database via web service. $opt_in_log = get_option('angelleye_send_opt_in_logging_details', 'no'); + $is_submited_feedback = get_option('angelleye_paypal_woocommerce_submited_feedback', 'no'); if($opt_in_log == 'yes') { - $log_url = $_SERVER['HTTP_HOST']; - $log_plugin_id = 1; - $log_activation_status = 0; - wp_remote_request('http://www.angelleye.com/web-services/wordpress/update-plugin-status.php?url='.$log_url.'&plugin_id='.$log_plugin_id.'&activation_status='.$log_activation_status); + if($is_submited_feedback == 'no') { + $log_url = $_SERVER['HTTP_HOST']; + $log_plugin_id = 1; + $log_activation_status = 0; + wp_remote_request('http://www.angelleye.com/web-services/wordpress/update-plugin-status.php?url='.$log_url.'&plugin_id='.$log_plugin_id.'&activation_status='.$log_activation_status); + } } } @@ -631,8 +637,13 @@ public function angelleye_woocommerce_add_to_cart_sold_individually_quantity($qt } } - public function angelleye_woocommerce_admin_enqueue_scripts() { + public function angelleye_woocommerce_admin_enqueue_scripts($hook) { wp_enqueue_style( 'ppe_cart', plugins_url( 'assets/css/admin.css' , __FILE__ ), array(), VERSION_PFW ); + if ( 'plugins.php' === $hook ) { + wp_enqueue_style( 'deactivation-modal', PAYPAL_FOR_WOOCOMMERCE_ASSET_URL . 'assets/css/deactivation-modal.css', null, VERSION_PFW ); + wp_enqueue_script( 'deactivation-modal', PAYPAL_FOR_WOOCOMMERCE_ASSET_URL . 'assets/js/deactivation-form-modal.js', null, VERSION_PFW, true ); + wp_localize_script( 'deactivation-modal', 'angelleye_ajax_data', array( 'nonce' => wp_create_nonce( 'angelleye-ajax' ) ) ); + } wp_enqueue_style( 'angelleye_marketing_css', plugins_url( 'assets/css/angelleye-marketing-sidebar.css' , __FILE__ ), array(), VERSION_PFW ); } @@ -1233,6 +1244,34 @@ public function angelleye_paypal_for_woo_product_level_payment_action($gateways, } } } + + public function angelleye_add_deactivation_form() { + $current_screen = get_current_screen(); + if ( 'plugins' !== $current_screen->id && 'plugins-network' !== $current_screen->id ) { + return; + } + include_once ( PAYPAL_FOR_WOOCOMMERCE_PLUGIN_DIR . '/template/deactivation-form.php'); + } + + public function angelleye_handle_plugin_deactivation_request() { + $log_url = wc_clean($_SERVER['HTTP_HOST']); + $log_plugin_id = 1; + $web_services_url = 'http://www.angelleye.com/web-services/wordpress/update-plugin-status.php'; + $request_url = add_query_arg( array( + 'url' => $log_url, + 'plugin_id' => $log_plugin_id, + 'activation_status' => 0, + 'reason' => wc_clean($_POST['reason']), + 'reason_details' => wc_clean($_POST['reason_details']), + ), $web_services_url ); + $response = wp_remote_request($request_url); + update_option('angelleye_paypal_woocommerce_submited_feedback', 'yes'); + if (is_wp_error($response)) { + wp_send_json(wp_remote_retrieve_body($response)); + } else { + wp_send_json(wp_remote_retrieve_body($response)); + } + } } } new AngellEYE_Gateway_Paypal(); \ No newline at end of file diff --git a/template/deactivation-form.php b/template/deactivation-form.php new file mode 100644 index 000000000..ee95065c9 --- /dev/null +++ b/template/deactivation-form.php @@ -0,0 +1,49 @@ + +
+
+
+ +

+
+ +
+
+
+

+
    +
  • + + +
  • +
  • + + +
  • +
  • + + +
  • +
  • + + +
    + +
    +
  • +
+ + +
+
+ +
+