26 const HASH_KEY =
'lCXlwbQR707kipR+J0MCqcxrhGOHjGF0ldD6yNbGM0w=';
37 add_action(
'personal_options', [ $this,
'user_field' ] );
38 add_action(
'personal_options_update', [ $this,
'update_user_meta_value' ] );
39 add_action(
'edit_user_profile_update', [ $this,
'update_user_meta_value' ] );
40 add_filter(
'gk/foundation/integrations/helpscout/display', [ $this,
'maybe_display_helpscout_beacon' ] );
41 add_filter(
'gravityview/tooltips/tooltip', [ $this,
'maybe_add_article_to_tooltip' ], 10, 6 );
64 if ( empty( $article[
'id'] ) ) {
68 static $show_support_port;
70 if ( ! isset( $show_support_port ) ) {
71 $show_support_port = self::show_for_user();
74 if ( ! $show_support_port ) {
78 $css_class .=
' gv_tooltip';
80 if ( ! empty( $article[
'type'] ) ) {
81 $atts = sprintf(
'data-beacon-article-%s="%s"', $article[
'type'], $article[
'id'] );
83 $atts = sprintf(
'data-beacon-article="%s"', $article[
'id'] );
87 $anchor_text .=
'<p class="description" style="font-size: 15px; text-align: center;"><strong>' . sprintf( esc_html__(
'Click %s icon for additional information.',
'gk-gravityview' ),
'<i class=\'fa fa-question-circle\'></i>' ) .
'</strong></p>';
88 $link_text = esc_html__(
'Learn More',
'gk-gravityview' );
90 return sprintf(
'<a href="%s" %s class="%s" title="%s" role="button">%s</a>',
94 esc_attr( $anchor_text ),
111 if ( ! is_admin() ||
'gravityview' !== get_post_type( $post ) ) {
120 $display_support_port = apply_filters(
'gravityview/support_port/display', self::show_for_user() );
122 if ( empty( $display_support_port ) ) {
123 gravityview()->log->debug(
'Not showing Support Port' );
128 add_filter(
'gk/foundation/integrations/helpscout/configuration',
function ( $configuration ) {
129 $arr_helpers = GravityKitFoundation::helpers()->array;
131 $arr_helpers->set( $configuration,
'init', self::HS_BEACON_KEY );
132 $arr_helpers->set( $configuration,
'identify.signature', hash_hmac(
'sha256', $arr_helpers->get( $configuration,
'identify.email',
'' ), self::HASH_KEY ) );
144 $localized_data = apply_filters(
'gravityview/support_port/localization_data', [
145 'suggest' => $arr_helpers->get( $configuration,
'suggest', [] ),
148 $arr_helpers->set( $configuration,
'suggest', $localized_data[
'suggest'] );
150 return $configuration;
176 $global_setting = GravityKitFoundation::settings()->get_plugin_setting( GravityKitFoundation::ID,
'support_port' );
178 if ( empty( $global_setting ) ) {
183 $user_pref = get_user_option( self::USER_PREF_NAME,
$user );
186 if (
false === $user_pref ) {
187 $user_pref = $global_setting;
190 return ! empty( $user_pref );
204 if ( current_user_can(
'edit_user', $user_id ) && isset( $_POST[ self::USER_PREF_NAME ] ) ) {
205 update_user_meta( $user_id, self::USER_PREF_NAME, intval( $_POST[ self::USER_PREF_NAME ] ) );
222 $global_setting = GravityKitFoundation::settings()->get_plugin_setting( GravityKitFoundation::ID,
'support_port' );
224 if ( empty( $global_setting ) ) {
234 $allow_profile_setting = apply_filters(
'gravityview/support_port/show_profile_setting',
GVCommon::has_cap(
'gravityview_support_port' ),
$user );
236 if ( $allow_profile_setting && current_user_can(
'edit_user',
$user->ID ) ) {
238 <table
class=
"form-table">
240 <tr
class=
"user-gravityview-support-button-wrap">
241 <th scope=
"row"><?php
243 esc_html_e(
'GravityView Support Port',
'gk-gravityview' );
247 <legend
class=
"screen-reader-text"><span><?php
249 esc_html_e(
'GravityView Support Port',
'gk-gravityview' );
252 <input name=
"<?php echo esc_attr( self::USER_PREF_NAME ); ?>" type=
"hidden" value=
"0"/>
253 <input name=
"<?php echo esc_attr( self::USER_PREF_NAME ); ?>" type=
"checkbox" value=
"1" <?php checked( self::show_for_user(
$user->ID ) ); ?> />
254 <?php esc_html_e(
'Show GravityView Support Port when on a GravityView-related page',
'gk-gravityview' ); ?>
if(!GravityView_Delete_Entry::check_user_cap_delete_entry( $entry, $field_settings)) $link_text
update_user_meta_value( $user_id)
Update User Profile preferences for GravityView Support.
static show_for_user( $user=0)
Check whether to show Support for a user.
maybe_display_helpscout_beacon( $display)
Conditionally displays Help Scout beacon on certain pages.
new GravityView_Support_Port
user_field( $user)
Modify User Profile.
maybe_add_article_to_tooltip( $tooltip='', $article=[], $url='', $atts='', $css_class='', $anchor_text='')
Modify tooltips to add Beacon article.
static get( $array, $key, $default=null)
Grab a value from an array or an object or default.
gravityview()
The main GravityView wrapper function.
static has_cap( $caps='', $object_id=null, $user_id=null)
Alias of GravityView_Roles_Capabilities::has_cap()