HelpWidget.php
65 lines
| 1 | <?php |
| 2 | |
| 3 | namespace SureCart\Integrations\HelpWidget; |
| 4 | |
| 5 | /** |
| 6 | * Help Widget. |
| 7 | */ |
| 8 | class HelpWidget { |
| 9 | /** |
| 10 | * Constructor. |
| 11 | */ |
| 12 | public function __construct() { |
| 13 | // Constructor |
| 14 | } |
| 15 | |
| 16 | /** |
| 17 | * Bootstrap. |
| 18 | * |
| 19 | * @return void |
| 20 | */ |
| 21 | public function bootstrap() { |
| 22 | add_action( 'admin_footer', [ $this, 'show' ], 999 ); |
| 23 | } |
| 24 | |
| 25 | /** |
| 26 | * Show Widget script. |
| 27 | * |
| 28 | * @return void |
| 29 | */ |
| 30 | public function show(): void { |
| 31 | // Check if widget is hidden via settings. |
| 32 | if ( get_option( 'surecart_hide_help_widget', false ) ) { |
| 33 | return; |
| 34 | } |
| 35 | |
| 36 | // Check if widget is enabled for the page. |
| 37 | if ( ! apply_filters( 'surecart/help_widget/show', in_array( get_current_screen()->id, \SureCart::pages()->getSureCartPageScreenIds(), true ) ) ) { |
| 38 | return; |
| 39 | } |
| 40 | ?> |
| 41 | |
| 42 | <script> |
| 43 | !function(Gleap,t,i){if(!(Gleap=window.Gleap=window.Gleap||[]).invoked){for(window.GleapActions=[],Gleap.invoked=!0,Gleap.methods=["identify","setEnvironment","setTags","attachCustomData","setCustomData","removeCustomData","clearCustomData","registerCustomAction","trackEvent","setUseCookies","log","preFillForm","showSurvey","sendSilentCrashReport","startFeedbackFlow","startBot","setAppBuildNumber","setAppVersionCode","setApiUrl","setFrameUrl","isOpened","open","close","on","setLanguage","setOfflineMode","startClassicForm","initialize","disableConsoleLogOverwrite","logEvent","hide","enableShortcuts","showFeedbackButton","destroy","getIdentity","isUserIdentified","clearIdentity","openConversations","openConversation","openHelpCenterCollection","openHelpCenterArticle","openHelpCenter","searchHelpCenter","openNewsArticle","openChecklists","startChecklist","openNews","openFeatureRequests","isLiveMode"],Gleap.f=function(e){return function(){var t=Array.prototype.slice.call(arguments);window.GleapActions.push({e:e,a:t})}},t=0;t<Gleap.methods.length;t++)Gleap[i=Gleap.methods[t]]=Gleap.f(i);Gleap.load=function(){var t=document.getElementsByTagName("head")[0],i=document.createElement("script");i.type="text/javascript",i.async=!0,i.src="https://sdk.gleap.io/latest/index.js",t.appendChild(i)},Gleap.load(), |
| 44 | Gleap.initialize("0suyWPJ1PjG0zzzBZPBVkCFUoajlj1jS"); |
| 45 | Gleap.setCustomData("customer_vault_url", "<?php echo esc_url( 'https://app.surecart.com/vault/accounts/' . \SureCart::account()->id ); ?>"); |
| 46 | }}(); |
| 47 | </script> |
| 48 | |
| 49 | <style> |
| 50 | /* Prevent the Gleap feedback button from overlapping WordPress modals */ |
| 51 | .bb-feedback-button { |
| 52 | z-index: 99999 !important; |
| 53 | } |
| 54 | |
| 55 | /* Add bottom padding to admin pages to prevent Gleap widget from overlapping pagination */ |
| 56 | .wrap { |
| 57 | padding-bottom: 45px; |
| 58 | } |
| 59 | </style> |
| 60 | |
| 61 | <?php |
| 62 | do_action( 'surecart/help_widget/loaded' ); |
| 63 | } |
| 64 | } |
| 65 |