social-sharing.php
53 lines
| 1 | <?php |
| 2 | if (isset($options['thank-you']['sharing']) && $options['thank-you']['sharing'] === 'enabled') : ?> |
| 3 | <div class="social-sharing"> |
| 4 | <p class="instruction"> |
| 5 | <?php |
| 6 | echo esc_html($options['thank-you']['sharing_instruction']); ?> |
| 7 | </p> |
| 8 | <div class="btn-row"> |
| 9 | <!-- Use inline onclick listener to avoid popup blockers --> |
| 10 | <button class="give-btn social-btn facebook-btn" |
| 11 | onclick=" |
| 12 | // Retrieve and sanitize url to be shared |
| 13 | let url = parent.window.location.toString(); |
| 14 | if (window.Give.fn.getParameterByName('giveDonationAction', url)) { |
| 15 | url = window.Give.fn.removeURLParameter(url, 'giveDonationAction'); |
| 16 | url = window.Give.fn.removeURLParameter(url, 'payment-confirmation'); |
| 17 | url = window.Give.fn.removeURLParameter(url, 'payment-id'); |
| 18 | } |
| 19 | // Calculate new window position, based on parent window height/width |
| 20 | const top = parent.window.innerHeight / 2 - 365; |
| 21 | const left = parent.window.innerWidth / 2 - 280; |
| 22 | // Open new window with prompt for Facebook sharing |
| 23 | window.Give.share.fn.facebook(url); |
| 24 | return false; |
| 25 | "> |
| 26 | <?php |
| 27 | esc_html_e('Share on Facebook', 'give'); ?><i class="fab fa-facebook"></i> |
| 28 | </button> |
| 29 | <!-- Use inline onclick listener to avoid popup blockers --> |
| 30 | <button |
| 31 | class="give-btn social-btn twitter-btn" |
| 32 | onclick=" |
| 33 | // Retrieve and sanitize url to be shared |
| 34 | let url = parent.window.location.toString(); |
| 35 | if (window.Give.fn.getParameterByName('giveDonationAction', url)) { |
| 36 | url = window.Give.fn.removeURLParameter(url, 'giveDonationAction'); |
| 37 | url = window.Give.fn.removeURLParameter(url, 'payment-confirmation'); |
| 38 | url = window.Give.fn.removeURLParameter(url, 'payment-id'); |
| 39 | } |
| 40 | const text = `<?php |
| 41 | echo $options['thank-you']['twitter_message']; ?>`; |
| 42 | // Open new window with prompt for Twitter sharing |
| 43 | window.Give.share.fn.twitter(url, text); |
| 44 | return false; |
| 45 | "> |
| 46 | <?php |
| 47 | esc_html_e('Share on Twitter', 'give'); ?><i class="fab fa-twitter"></i> |
| 48 | </button> |
| 49 | </div> |
| 50 | </div> |
| 51 | <?php |
| 52 | endif; ?> |
| 53 |