ReviewsUI.php
258 lines
| 1 | <?php |
| 2 | |
| 3 | namespace Wpae\Reviews; |
| 4 | |
| 5 | class ReviewsUI |
| 6 | { |
| 7 | |
| 8 | private $reviewLogic; |
| 9 | |
| 10 | public function __construct() |
| 11 | { |
| 12 | $this->reviewLogic = new ReviewLogic(); |
| 13 | } |
| 14 | |
| 15 | public function render() |
| 16 | { |
| 17 | |
| 18 | if($this->reviewLogic->shouldShowReviewModal()) { |
| 19 | |
| 20 | ?> |
| 21 | <style type="text/css"> |
| 22 | .wpallexport-plugin .wpae-reviews-notice { |
| 23 | margin-top: 40px; |
| 24 | padding-top: 18px; |
| 25 | padding-bottom: 22px; |
| 26 | } |
| 27 | |
| 28 | .wpae-reviews-notice h1 { |
| 29 | color: #435F9A; |
| 30 | font-size: 1.4em; |
| 31 | font-weight: 500; |
| 32 | padding: 0; |
| 33 | } |
| 34 | |
| 35 | .wpae-buttons-container { |
| 36 | margin-top: 10px; |
| 37 | } |
| 38 | |
| 39 | .wpae-reviews-notice .wpae-buttons-container button, #wpae-feedback button { |
| 40 | padding: 6px 10px; |
| 41 | margin-right: 9px; |
| 42 | position: relative; |
| 43 | text-decoration: none; |
| 44 | border: 1px solid #435F9A; |
| 45 | border-radius: 2px; |
| 46 | text-shadow: none; |
| 47 | font-weight: 500; |
| 48 | font-size: 1.1em; |
| 49 | line-height: normal; |
| 50 | color: #435F9A; |
| 51 | cursor: pointer; |
| 52 | background-color: white; |
| 53 | } |
| 54 | |
| 55 | .wpae-reviews-notice .wpae-buttons-container button:hover, #wpae-feedback button:hover { |
| 56 | background: #f0f0f1; |
| 57 | border-color: #0a4b78; |
| 58 | color: #0a4b78; |
| 59 | } |
| 60 | .wpae-reviews-notice .wpae-buttons-container button:focus, #wpae-feedback button:focus { |
| 61 | border: 1px solid rgba(0, 0, 0, 0.5); |
| 62 | outline: none; |
| 63 | } |
| 64 | |
| 65 | .wpae-reviews-notice button:hover { |
| 66 | background-color: #FAFAFA; |
| 67 | } |
| 68 | |
| 69 | #wpae-review { |
| 70 | display: none; |
| 71 | justify-content: flex-start; |
| 72 | align-items: baseline; |
| 73 | } |
| 74 | |
| 75 | #wpae-review p, #wpae-feedback p { |
| 76 | display: block; |
| 77 | font-size: 1.1em; |
| 78 | } |
| 79 | |
| 80 | #wpae-review .wpae-buttons-container { |
| 81 | justify-content: flex-start; |
| 82 | |
| 83 | } |
| 84 | |
| 85 | #wpae-feedback { |
| 86 | display: none; |
| 87 | justify-content: flex-start; |
| 88 | align-items: baseline; |
| 89 | } |
| 90 | |
| 91 | #wpae-feedback textarea { |
| 92 | width: 100%; |
| 93 | height: 100px; |
| 94 | } |
| 95 | |
| 96 | #wpae-feedback .wpae-submit-feedback { |
| 97 | display: flex; |
| 98 | flex-direction: row; |
| 99 | align-items: center; |
| 100 | margin-top: 10px; |
| 101 | } |
| 102 | |
| 103 | #wpae-feedback .wpae-submit-feedback button { |
| 104 | margin-right: 10px; |
| 105 | } |
| 106 | |
| 107 | .wpae-reviews-notice .notice-dismiss { |
| 108 | position: relative; |
| 109 | float: right; |
| 110 | top: -15px; |
| 111 | right: -10px; |
| 112 | } |
| 113 | .wpae-reviews-notice .notice-dismiss:focus { |
| 114 | border: none; |
| 115 | box-shadow: none; |
| 116 | } |
| 117 | |
| 118 | |
| 119 | .wpae-submit-confirmation { |
| 120 | padding-top: 20px; |
| 121 | padding-bottom: 20px; |
| 122 | display: none; |
| 123 | } |
| 124 | </style> |
| 125 | <script type="text/javascript"> |
| 126 | jQuery(document).ready(function () { |
| 127 | jQuery('.wpae-review-buttons button').on('click', function (e) { |
| 128 | |
| 129 | e.preventDefault(); |
| 130 | var val = jQuery(this).data('review'); |
| 131 | |
| 132 | if (val === 'good') { |
| 133 | jQuery('#wpae-ask-for-review').fadeOut(function () { |
| 134 | jQuery('#wpae-review').fadeIn(); |
| 135 | }); |
| 136 | } else { |
| 137 | jQuery('#wpae-ask-for-review').fadeOut(function () { |
| 138 | jQuery('#wpae-feedback').fadeIn(); |
| 139 | }); |
| 140 | } |
| 141 | |
| 142 | return false; |
| 143 | }); |
| 144 | |
| 145 | jQuery('.wpae-reviews-notice .notice-dismiss').on('click', function(e){ |
| 146 | |
| 147 | e.preventDefault(); |
| 148 | e.stopImmediatePropagation(); |
| 149 | var request = { |
| 150 | action: 'dismiss_review_modal', |
| 151 | security: wp_all_export_security, |
| 152 | modal_type: jQuery('#wpae-modal-type').val() |
| 153 | }; |
| 154 | |
| 155 | jQuery.ajax({ |
| 156 | type: 'POST', |
| 157 | url: '<?php echo esc_url( admin_url( "admin-ajax.php" ) ); ?>', |
| 158 | data: request, |
| 159 | success: function(response) {}, |
| 160 | dataType: "json" |
| 161 | }); |
| 162 | |
| 163 | jQuery('.wpae-reviews-notice').slideUp(); |
| 164 | }); |
| 165 | |
| 166 | jQuery('.review-link').on('click', function(){ |
| 167 | |
| 168 | var request = { |
| 169 | action: 'dismiss_review_modal', |
| 170 | security: wp_all_export_security, |
| 171 | modal_type: jQuery('#wpae-modal-type').val() |
| 172 | }; |
| 173 | |
| 174 | jQuery.ajax({ |
| 175 | type: 'POST', |
| 176 | url: '<?php echo esc_url( admin_url( "admin-ajax.php" ) ); ?>', |
| 177 | data: request, |
| 178 | success: function(response) {}, |
| 179 | dataType: "json" |
| 180 | }); |
| 181 | |
| 182 | jQuery('.wpae-reviews-notice').slideUp(); |
| 183 | |
| 184 | }); |
| 185 | |
| 186 | jQuery('.wpae-submit-feedback button').on('click', function(){ |
| 187 | |
| 188 | jQuery(this).prop("disabled", true); |
| 189 | |
| 190 | var request = { |
| 191 | action: 'send_feedback', |
| 192 | modal_type: jQuery('#wpae-modal-type').val(), |
| 193 | security: wp_all_export_security, |
| 194 | plugin: jQuery('#wpae-modal-type').val(), |
| 195 | message: jQuery('#wpae-feedback-message').val() |
| 196 | }; |
| 197 | |
| 198 | jQuery.ajax({ |
| 199 | type: 'POST', |
| 200 | url: '<?php echo esc_url( admin_url( "admin-ajax.php" ) ); ?>', |
| 201 | data: request, |
| 202 | success: function(response) { |
| 203 | jQuery('.wpae-submit-confirmation').show(); |
| 204 | jQuery('.wpae-review-form').hide(); |
| 205 | |
| 206 | }, |
| 207 | dataType: "json" |
| 208 | }); |
| 209 | |
| 210 | }); |
| 211 | }); |
| 212 | </script> |
| 213 | <input type="hidden" id="wpae-modal-type" value="<?php echo esc_attr($this->reviewLogic->getModalType()); ?>" /> |
| 214 | <div style="" class="notice notice-info wpae-reviews-notice"> |
| 215 | <button type="button" class="notice-dismiss"><span class="screen-reader-text">Dismiss this notice.</span></button> |
| 216 | <div id="wpae-ask-for-review"> |
| 217 | <h1><?php echo esc_html($this->reviewLogic->getModalText()); ?></h1> |
| 218 | |
| 219 | <div class="wpae-buttons-container wpae-review-buttons"> |
| 220 | <button data-review="good"><?php esc_html_e('Good', 'wp-all-export'); ?></button> |
| 221 | <button data-review="ok"><?php esc_html_e('Just Ok', 'wp-all-export'); ?></button> |
| 222 | <button data-review="bad"><?php esc_html_e('Bad', 'wp-all-export'); ?></button> |
| 223 | </div> |
| 224 | </div> |
| 225 | <div id="wpae-review"> |
| 226 | <h1><?php esc_html_e('That is great to hear, thank you for the feedback!', 'wp-all-export'); ?></h1> |
| 227 | <p> |
| 228 | <?php esc_html_e("Would you be willing to do us a small favor? Unhappy customers are quick to publicly complain, but happy customers rarely speak up and share their good experiences.", 'wp-all-export'); ?> |
| 229 | </br> |
| 230 | <?php esc_html_e("If you have a moment, we would love for you to review our add-on in the WordPress.org plugin repository.", 'wp-all-export'); ?> |
| 231 | </p> |
| 232 | <div class="wpae-buttons-container"> |
| 233 | <a class="review-link" href="<?php echo esc_attr($this->reviewLogic->getReviewLink()); ?>" target="_blank"> |
| 234 | <?php /* translators: %s: plugin name */ ?> |
| 235 | <button><?php printf(esc_html__('Review the %s', 'wp-all-export'), esc_html($this->reviewLogic->getPluginName()) ); ?></button> |
| 236 | </a> |
| 237 | </div> |
| 238 | </div> |
| 239 | <div id="wpae-feedback"> |
| 240 | <div class="wpae-review-form"> |
| 241 | <h1><?php esc_html_e('Thank you for your feedback, it really helps us improve our products.', 'wp-all-export'); ?></h1> |
| 242 | <p><?php esc_html_e('If you could improve one thing about WP All Export, what would it be?', 'wp-all-export'); ?></p> |
| 243 | <textarea id="wpae-feedback-message"></textarea> |
| 244 | <div class="wpae-submit-feedback"> |
| 245 | <button><?php esc_html_e('Submit', 'wp-all-export'); ?></button> |
| 246 | </div> |
| 247 | </div> |
| 248 | <div class="wpae-submit-confirmation"> |
| 249 | Thank you for your feedback. Your message was emailed to support@wpallimport.com from <?php echo esc_html(get_option('admin_email')); ?>. If you do not receive a confirmation email, it means we didn't receive your message for some reason. |
| 250 | </div> |
| 251 | |
| 252 | </div> |
| 253 | </div> |
| 254 | <?php |
| 255 | } |
| 256 | } |
| 257 | |
| 258 | } |