20 const HASH_KEY =
't4MTtLRuIH74gBuQ/2OVpj0NscYAjdg9nY1rw67PiT8=';
30 add_filter(
'gk/foundation/inline-scripts', [ $this,
'enqueue_beacon_script' ] );
41 if ( ! self::$_instance ) {
42 self::$_instance =
new self();
45 return self::$_instance;
65 !
function(e,t,n){
function a(){var e=t.getElementsByTagName(
'script')[0],n=t.createElement(
'script');n.type=
'text/javascript',n.async=!0,n.src=
'https://beacon-v2.helpscout.net',e.parentNode.insertBefore(n,e)}
if(e.Beacon=n=
function(t,n,a){e.Beacon.readyQueue.push({method:t,options:n,data:a})},n.readyQueue=[],
'complete'===t.readyState)
return a();e.attachEvent?e.attachEvent(
'onload',a):e.addEventListener(
'load',a,!1)}(window,document,window.Beacon||
function(){});
66 var beaconConfig = {$beacon_configuration};
for (var param in beaconConfig) { window.Beacon( param, beaconConfig[param]); }
84 $is_enabled = SettingsFramework::get_instance()->get_plugin_setting( FoundationCore::ID,
'support_port' );
86 if ( ! $is_enabled ) {
99 $page =
Arr::get( $_REQUEST,
'page' );
100 $post_type =
Arr::get( $_REQUEST,
'post_type' );
102 $display_beacon =
false;
104 if ( in_array( $page, [ SettingsFramework::ID, LicensesFramework::ID ],
true ) ) {
105 $display_beacon =
true;
117 return apply_filters(
'gk/foundation/integrations/helpscout/display', $display_beacon, $page, $post_type );
128 $foundation_settings = SettingsFramework::get_instance()->get_plugin_settings( FoundationCore::ID );
130 $current_user = wp_get_current_user();
132 $beacon_configuration = [
133 'init' => self::HS_BEACON_KEY,
135 'color' =>
'#4d9bbe',
136 'poweredBy' =>
false,
137 'docsEnabled' =>
true,
138 'topArticles' =>
true,
139 'iconImage' =>
'question',
140 'zIndex' => 10000 + 10,
143 'chatEnabled' => ( ! is_multisite() && current_user_can(
'manage_options' ) ) ||
144 ( is_multisite() && current_user_can(
'manage_network_options' ) && CoreHelpers::is_network_admin() ),
149 'WP Version' => mb_substr( get_bloginfo(
'version',
'display' ), 0, 10000 ),
150 'PHP Version' => mb_substr( PHP_VERSION .
' on ' . esc_html(
Arr::get( $_SERVER,
'SERVER_SOFTWARE' ) ), 0, 10000 ),
153 'name' => mb_substr( $current_user->display_name, 0, 80 ),
154 'email' => mb_substr( $current_user->user_email, 0, 80 ),
157 'email' => mb_substr( $current_user->user_email, 0, 80 ),
158 'name' => mb_substr( $current_user->display_name, 0, 80 ),
159 'signature' => hash_hmac(
'sha256', mb_substr( $current_user->user_email, 0, 80 ), self::HASH_KEY ),
160 'affiliate_id' => mb_substr(
Arr::get( $foundation_settings,
'affiliate_id',
'' ), 0, 255 ),
161 'is_super_admin' => is_super_admin(),
162 'alt_emails' => mb_substr( sprintf(
'Admin: %s / GV Support: %s', get_bloginfo(
'admin_email' ),
Arr::get( $foundation_settings,
'support_email' ) ), 0, 255 ),
163 'wordpress_version' => mb_substr( get_bloginfo(
'version',
'display' ), 0, 255 ),
164 'php_version' => mb_substr( PHP_VERSION .
' on ' . esc_html( $_SERVER[
'SERVER_SOFTWARE'] ), 0, 255 ),
165 'no_conflict_mode' =>
Arr::get( $foundation_settings,
'no_conflict_mode' ) ?
'Disabled' :
'Enabled',
166 'gravityview_version' => mb_substr( class_exists(
'\GV\Plugin' ) ? \
GV\Plugin::$version :
'Not Installed', 0, 255 ),
167 'gravity_forms_version' => mb_substr( class_exists(
'\GFForms' ) ? \GFForms::$version :
'Not Installed', 0, 255 ),
168 'locale' => get_user_locale(),
169 'is_support_contact' => ( $current_user->user_email ===
Arr::get( $foundation_settings,
'support_email' ) ),
181 return apply_filters(
'gk/foundation/integrations/helpscout/configuration', $beacon_configuration );
197 'suggestedForYou' => __(
'Instant Answers',
'gk-gravityview' ),
198 'getInTouch' => __(
'Get in touch',
'gk-gravityview' ),
199 'searchLabel' => __(
'Search GravityKit Docs',
'gk-gravityview' ),
200 'tryAgain' => __(
'Try again',
'gk-gravityview' ),
201 'defaultMessageErrorText' => __(
'There was a problem sending your message. Please try again in a moment.',
'gk-gravityview' ),
202 'beaconButtonClose' => __(
'Close',
'gk-gravityview' ),
203 'beaconButtonChatMinimize' => __(
'Minimize chat',
'gk-gravityview' ),
204 'beaconButtonChatOpen' => __(
'Open chat',
'gk-gravityview' ),
206 'answer' => __(
'Answer',
'gk-gravityview' ),
207 'ask' => __(
'Ask',
'gk-gravityview' ),
208 'messageButtonLabel' => __(
'Email',
'gk-gravityview' ),
209 'noTimeToWaitAround' => __(
'No time to wait around? We usually respond within a few hours',
'gk-gravityview' ),
210 'chatButtonLabel' => __(
'Chat',
'gk-gravityview' ),
211 'chatButtonDescription' => __(
'We\'re online right now, talk with our team in real-time',
'gk-gravityview' ),
212 'wereHereToHelp' => __(
'Start a conversation',
'gk-gravityview' ),
213 'whatMethodWorks' => __(
'What channel do you prefer?',
'gk-gravityview' ),
214 'previousMessages ' => __(
'Previous Conversations',
'gk-gravityview' ),
216 'cantFindAnswer' => __(
'Can\'t find the answer?',
'gk-gravityview' ),
217 'relatedArticles' => __(
'Related Articles',
'gk-gravityview' ),
218 'nothingFound' => __(
'Hmm…',
'gk-gravityview' ),
219 'docsSearchEmptyText' => __(
'We couldn\'t find any articles that match your search.',
'gk-gravityview' ),
220 'tryBroaderTerm' => __(
'Try a broader term, or',
'gk-gravityview' ),
221 'docsArticleErrorText' => __(
'There was a problem loading this article. Please double-check your internet connection and try again.',
'gk-gravityview' ),
222 'docsSearchErrorText' => __(
'Your search timed out. Please double-check your internet connection and try again.',
'gk-gravityview' ),
223 'escalationQuestionFeedback' => __(
'Did this answer your question?',
'gk-gravityview' ),
224 'escalationQuestionFeedbackNo' => __(
'No',
'gk-gravityview' ),
225 'escalationQuestionFeedbackYes' => __(
'Yes',
'gk-gravityview' ),
226 'escalationSearchText' => __(
'Browse our help docs for an answer to your question',
'gk-gravityview' ),
227 'escalationSearchTitle' => __(
'Keep searching',
'gk-gravityview' ),
228 'escalationTalkText' => __(
'Talk with a friendly member of our support team',
'gk-gravityview' ),
229 'escalationTalkTitle' => __(
'Talk to us',
'gk-gravityview' ),
230 'escalationThanksFeedback' => __(
'Thanks for the feedback',
'gk-gravityview' ),
231 'escalationWhatNext' => __(
'What next?',
'gk-gravityview' ),
233 'sendAMessage' => __(
'Send a message',
'gk-gravityview' ),
234 'firstAFewQuestions' => __(
'Let\'s begin with a few questions',
'gk-gravityview' ),
235 'howCanWeHelp' => __(
'How can we help?',
'gk-gravityview' ),
236 'responseTime' => __(
'We usually respond in a few hours',
'gk-gravityview' ),
237 'history' => __(
'History',
'gk-gravityview' ),
238 'uploadAnImage' => __(
'Upload an image',
'gk-gravityview' ),
239 'attachAFile' => __(
'Attach a screenshot or file',
'gk-gravityview' ),
240 'continueEditing' => __(
'Continue writing…',
'gk-gravityview' ),
241 'lastUpdated' => __(
'Last updated',
'gk-gravityview' ),
242 'you' => __(
'You',
'gk-gravityview' ),
243 'nameLabel' => __(
'Your Name',
'gk-gravityview' ),
244 'subjectLabel' => __(
'Subject',
'gk-gravityview' ),
245 'emailLabel' => __(
'Email address',
'gk-gravityview' ),
246 'messageLabel' => __(
'How can we help?',
'gk-gravityview' ),
247 'messageSubmitLabel' => __(
'Send a message',
'gk-gravityview' ),
248 'next' => __(
'Next',
'gk-gravityview' ),
249 'weAreOnIt' => __(
'Message sent!',
'gk-gravityview' ),
250 'messageConfirmationText' => __(
'You\'ll receive an email reply within a few hours.',
'gk-gravityview' ),
251 'viewAndUpdateMessage' => __(
'You can view and update your message in',
'gk-gravityview' ),
252 'mayNotBeEmpty' => __(
'May not be empty',
'gk-gravityview' ),
253 'customFieldsValidationLabel' => __(
'Please complete all fields',
'gk-gravityview' ),
254 'emailValidationLabel' => __(
'Please enter a valid email address',
'gk-gravityview' ),
255 'attachmentErrorText' => __(
'There was a problem uploading your attachment. Please try again in a moment.',
'gk-gravityview' ),
256 'attachmentSizeErrorText' => strtr(
257 _x(
'The maximum file size is [size]',
'Placeholders inside [] are not to be translated.',
'gk-gravityview' ),
258 [
'[size]' => size_format( 10485760 ) ]
261 'addReply' => __(
'Add a reply',
'gk-gravityview' ),
262 'addYourMessageHere' => __(
'Add your message here…',
'gk-gravityview' ),
263 'sendMessage' => __(
'Send message',
'gk-gravityview' ),
264 'received' => __(
'Received',
'gk-gravityview' ),
265 'waitingForAnAnswer' => __(
'Waiting for an answer',
'gk-gravityview' ),
266 'previousMessageErrorText' => __(
'There was a problem retrieving your previous messages. Please double-check your Internet connection and try again.',
'gk-gravityview' ),
267 'justNow' => __(
'Just Now',
'gk-gravityview' ),
269 'chatHeadingTitle' => __(
'Chat with our team',
'gk-gravityview' ),
270 'chatHeadingSublabel' => __(
'We\'ll be with you soon',
'gk-gravityview' ),
271 'chatEndCalloutHeading' => __(
'All done!',
'gk-gravityview' ),
272 'chatEndCalloutMessage' => __(
'A copy of this conversation will land in your inbox shortly.',
'gk-gravityview' ),
273 'chatEndCalloutLink' => __(
'Return home',
'gk-gravityview' ),
274 'chatEndUnassignedCalloutHeading' => __(
'Sorry about that',
'gk-gravityview' ),
275 'chatEndUnassignedCalloutMessage' => __(
'It looks like nobody made it to your chat. We\'ll send you an email response as soon as possible.',
'gk-gravityview' ),
276 'chatEndWaitingCustomerHeading' => __(
'Sorry about that',
'gk-gravityview' ),
277 'chatEndWaitingCustomerMessage' => __(
'Your question has been added to our email queue and we\'ll get back to you shortly.',
'gk-gravityview' ),
278 'ending' => __(
'Ending…',
'gk-gravityview' ),
279 'endChat' => __(
'End chat',
'gk-gravityview' ),
280 'chatEnded' => strtr(
281 _x(
'[name] ended the chat',
'Placeholders inside [] are not to be translated.',
'gk-gravityview' ),
284 'chatConnected' => strtr(
285 _x(
'Connected to [name]',
'Placeholders inside [] are not to be translated.',
'gk-gravityview' ),
288 'chatbotName' => __(
'Help Bot',
'gk-gravityview' ),
289 'chatbotGreet' => __(
'Hi there! You can begin by asking your question below. Someone will be with you shortly.',
'gk-gravityview' ),
290 'chatbotPromptEmail' => __(
'Got it. Real quick, what\'s your email address? We\'ll use it for any follow-up messages.',
'gk-gravityview' ),
291 'chatbotConfirmationMessage' => __(
'Thanks! Someone from our team will jump into the chat soon.',
'gk-gravityview' ),
292 'chatbotGenericErrorMessage' => __(
'Something went wrong sending your message, please try again in a few minutes.',
'gk-gravityview' ),
293 'chatbotInactivityPrompt' => __(
'Since the chat has gone idle, I\'ll end this chat in a few minutes.',
'gk-gravityview' ),
294 'chatbotInvalidEmailMessage' => __(
'Looks like you\'ve entered an invalid email address. Want to try again?',
'gk-gravityview' ),
295 'chatbotAgentDisconnectedMessage' => strtr(
296 _x(
'[name] has disconnected from the chat. It\'s possible they lost their internet connection, so I\'m looking for someone else to take over. Sorry for the delay!',
'Placeholders inside [] are not to be translated.',
'gk-gravityview' ),
299 'chatAvailabilityChangeMessage' => __(
'Our team\'s availability has changed and there\'s no longer anyone available to chat. Send us a message instead and we\'ll get back to you.',
'gk-gravityview' ),
301 'emailHeading' => strtr(
302 _x(
'Today\'s chat with [name]',
'Placeholders inside [] are not to be translated.',
'gk-gravityview' ),
305 'emailGreeting' => strtr(
306 _x(
'Hey [name]',
'Placeholders inside [] are not to be translated.',
'gk-gravityview' ),
309 'emailCopyOfDiscussion' => __(
'Here\'s a copy of your discussion',
'gk-gravityview' ),
310 'emailContinueConversation' => __(
'If you\'ve got any other questions, feel free to hit reply and continue the conversation.',
'gk-gravityview' ),
311 'emailJoinedLineItem' => strtr( _x(
'[name] joined the chat',
'Placeholders inside [] are not to be translated.',
'gk-gravityview' ),
314 'emailEndedLineItem' => strtr(
315 _x(
'[name] ended the chat',
'Placeholders inside [] are not to be translated.',
'gk-gravityview' ),
318 'emailYou' => __(
'You',
'gk-gravityview' ),
321 foreach ( $translations as &$translation ) {
322 $translation = mb_substr( $translation, 0, 160 );
325 return $translations;
static get( $array, $key, $default=null)
{}
enqueue_beacon_script( $scripts)
Outputs inline JS code that initializes the HS beacon.
get_beacon_configuration()
Returns HS beacon configuration options.
get_beacon_label_translations()
Returns translated labels.
should_display_beacon()
Determines if the HS beacon should be displayed.
static get_instance()
Returns class instance.