15 const SETTINGS_PLUGIN_ID =
'gravityview';
33 private $_plugin_settings = [];
37 $this->_foundation_settings = SettingsFramework::get_instance();
39 add_action(
'gk/foundation/initialized',
function () {
40 $this->_foundation_settings = GravityKitFoundation::settings();
43 add_filter(
'gk/foundation/settings/data/plugins', [ $this,
'add_settings' ] );
55 return $this->
get( $setting_name );
66 public function get( $key, $default = null ) {
67 return Arr::get( $this->all(), $key, $default );
80 return gravityview()->plugin->settings->get( $key );
99 public function all() {
100 if ( ! empty( $this->_plugin_settings ) ) {
101 return $this->_plugin_settings;
104 $this->_plugin_settings = $this->_foundation_settings->get_plugin_settings( self::SETTINGS_PLUGIN_ID );
107 if ( empty( $this->_plugin_settings ) ) {
108 $this->_plugin_settings = $this->migrate_legacy_settings();
111 $this->_plugin_settings = wp_parse_args( $this->_plugin_settings, $this->defaults() );
113 return $this->_plugin_settings;
123 $option_name =
'gravityformsaddon_' . self::SETTINGS_PLUGIN_ID .
'_app_settings';
126 $site_has_settings = ( ! is_multisite() ) || is_main_site() || ( !
gravityview()->plugin->is_network_activated() ) || ( is_network_admin() &&
gravityview()->plugin->is_network_activated() );
128 if ( $site_has_settings ) {
129 $legacy_settings = get_option( $option_name, array() );
131 $legacy_settings = get_blog_option( get_main_site_id(), $option_name );
134 if ( empty( $legacy_settings ) ) {
140 'rest_api' => (int) Arr::get( $legacy_settings,
'rest_api' ),
143 $this->_foundation_settings->save_plugin_settings( self::SETTINGS_PLUGIN_ID, $plugin_settings );
146 $gk_settings_id = class_exists(
'GravityKitFoundation' ) ? GravityKitFoundation::ID : FoundationCore::ID;
150 $gk_settings = $this->_foundation_settings->get_plugin_settings( $gk_settings_id );
152 if ( empty( $gk_settings ) ) {
154 'support_email' => Arr::get( $legacy_settings,
'support-email' ),
155 'support_port' => Arr::get( $legacy_settings,
'support_port' ),
156 'powered_by' => (int) Arr::get( $legacy_settings,
'powered_by' ),
157 'affiliate_id' => Arr::get( $legacy_settings,
'affiliate_id' ),
158 'beta' => (int) Arr::get( $legacy_settings,
'beta' ),
159 'support_email' => Arr::get( $legacy_settings,
'support-email' ),
160 'support_port' => (int) Arr::get( $legacy_settings,
'support_port' ),
161 'no_conflict_mode' => (int) Arr::get( $legacy_settings,
'no-conflict-mode' ),
164 $this->_foundation_settings->save_plugin_settings( $gk_settings_id, $gk_settings );
167 return $plugin_settings;
179 $gk_settings_id = class_exists(
'GravityKitFoundation' ) ? GravityKitFoundation::ID : FoundationCore::ID;
181 return $this->_foundation_settings->get_plugin_setting( $gk_settings_id, $setting, $default );
192 'public_entry_moderation' => 0,
200 return apply_filters(
'gravityview/settings/defaults', $defaults );
220 $show_settings = apply_filters(
'gravityview/show-settings-menu',
true );
222 if ( ! $show_settings ) {
223 return $plugins_data;
226 $default_settings = $this->defaults();
229 'id' => self::SETTINGS_PLUGIN_ID,
230 'title' =>
'GravityView',
231 'defaults' => $default_settings,
232 'icon' =>
'data:image/svg+xml,%3Csvg width="80" height="80" viewBox="0 0 80 80" fill="none" xmlns="http://www.w3.org/2000/svg"%3E%3Crect width="80" height="80" rx="8" fill="%23FF1B67"/%3E%3Cg clip-path="url(%23clip0_16_27)"%3E%3Cpath fill-rule="evenodd" clip-rule="evenodd" d="M58.4105 54.6666H52.8824V56.4999C52.8824 59.5375 50.3902 61.9999 47.3544 61.9999H32.6134C29.5375 61.9999 27.0853 59.5375 27.0853 56.4999V29H21.5572C20.5144 29 19.7148 29.8207 19.7148 30.8333V49.1666C19.7148 50.1792 20.5144 51 21.5572 51H22.4788C22.9629 51 23.3997 51.4104 23.3997 51.9167V53.75C23.3997 54.2562 22.9629 54.6666 22.4788 54.6666H21.5572C18.4786 54.6666 16.0292 52.2042 16.0292 49.1666V30.8333C16.0292 27.7957 18.4786 25.3333 21.5572 25.3333H27.0853V23.5C27.0853 20.4624 29.5375 18 32.6134 18H47.3544C50.3902 18 52.8824 20.4624 52.8824 23.5V51H58.4105C59.4132 51 60.2529 50.1792 60.2529 49.1666V30.8333C60.2529 29.8207 59.4132 29 58.4105 29H57.4889C56.9647 29 56.5673 28.5896 56.5673 28.0833V26.2499C56.5673 25.7437 56.9647 25.3333 57.4889 25.3333H58.4105C61.449 25.3333 63.9378 27.7957 63.9378 30.8333V49.1666C63.9378 52.2042 61.449 54.6666 58.4105 54.6666ZM49.1968 23.5C49.1968 22.4874 48.3544 21.6667 47.3544 21.6667H32.6134C31.5733 21.6667 30.7709 22.4874 30.7709 23.5V56.4999C30.7709 57.5125 31.5733 58.3333 32.6134 58.3333H47.3544C48.3544 58.3333 49.1968 57.5125 49.1968 56.4999V23.5Z" fill="white"/%3E%3C/g%3E%3Cdefs%3E%3CclipPath id="clip0_16_27"%3E%3Crect width="48" height="44" fill="white" transform="translate(16 18)"/%3E%3C/clipPath%3E%3C/defs%3E%3C/svg%3E%0A',
235 'title' => esc_html__(
'General',
'gk-gravityview' ),
239 'type' =>
'checkbox',
240 'title' => esc_html__(
'REST API',
'gk-gravityview' ),
241 'description' => esc_html__(
'Enable View and Entry access via the REST API? Regular per-View restrictions apply (private, password protected, etc.).',
'gk-gravityview' ) .
' ' . esc_html__(
'If you are unsure, disable this setting.',
'gk-gravityview' ),
242 'value' => $this->
get(
'rest_api', $default_settings[
'rest_api'] ),
247 'title' => esc_html__(
'Permissions',
'gk-gravityview' ),
250 'id' =>
'public_entry_moderation',
251 'type' =>
'checkbox',
252 'title' => esc_html__(
'Enable Public Entry Moderation',
'gk-gravityview' ),
253 'description' => strtr(
255 __(
'If enabled, adding {public} to {link}entry moderation merge tags{/link} will allow logged-out users to approve or reject entries. If disabled, all entry moderation actions require the user to be logged-in and have the ability to edit the entry.',
'gk-gravityview' ),
257 '{public}' =>
'<code style="font-size: .9em">:public</code>',
258 '{link}' =>
'<a href="https://docs.gravitykit.com/article/904-entry-moderation-merge-tags" target="_blank" rel="noopener noreferrer">',
259 '{/link}' =>
'<span class="screen-reader-text"> ' . esc_html__(
'(This link opens in a new window.)',
'gk-gravityview' ) .
'</span></a>',
262 'value' => $this->
get(
'public_entry_moderation', $default_settings[
'public_entry_moderation'] ),
269 return array_merge( (array) $plugins_data, [ self::SETTINGS_PLUGIN_ID =>
$settings ] );
299 return $this->_foundation_settings->save_plugin_settings( self::SETTINGS_PLUGIN_ID,
$settings );
310 $result = $this->_foundation_settings->save_plugin_settings( self::SETTINGS_PLUGIN_ID,
$settings );
316 $this->_plugin_settings = $this->_foundation_settings->get_plugin_settings( self::SETTINGS_PLUGIN_ID );
329 if ( $this->is_save_postback() ) {
332 \GFCommon::add_error_message( __(
'You don\'t have the ability to edit plugin settings.',
'gk-gravityview' ) );
343 $heading = esc_html__(
'If you delete then re-install GravityView, it will be like installing GravityView for the first time.',
'gk-gravityview' );
344 $message = esc_html__(
'Delete all Views, GravityView entry approval status, GravityView-generated entry notes (including approval and entry creator changes), and GravityView plugin settings.',
'gk-gravityview' );
346 return sprintf(
'<h4>%s</h4><p>%s</p>', $heading, $message );
355 'label' => esc_html__(
'I am going to continue using GravityView',
'gk-gravityview' ),
357 'no-longer-need' => [
358 'label' => esc_html__(
'I no longer need GravityView',
'gk-gravityview' ),
361 'label' => esc_html__(
'The plugin doesn\'t work',
'gk-gravityview' ),
364 'label' => esc_html__(
'I found a better plugin',
'gk-gravityview' ),
365 'followup' => esc_attr__(
'What plugin you are using, and why?',
'gk-gravityview' ),
368 'label' => esc_html__(
'Other',
'gk-gravityview' ),
383 $user = wp_get_current_user();
390 .number-scale label {
391 border: 1px solid #cccccc;
396 #gv-uninstall-thanks p { 406 margin-
top: 0 !important;
407 padding-
top: 0 !important;
417 $uninstall_title = esc_html__(
'Uninstall GravityView',
'gk-gravityview' );
420 <div
class=
"gform-settings-panel">
421 <header
class=
"gform-settings-panel__header">
422 <h4
class=
"gform-settings-panel__title">{$uninstall_title}</h4>
424 <div
class=
"gform-settings-panel__content" style=
"padding: 0 1rem 1.25rem">
428 echo
'<div class="gv-uninstall-form-wrapper" style="font-size: 110%; padding: 15px 0;">';
432 jQuery(
function ( $ ) {
433 $(
'#gv-uninstall-feedback' ).on(
'change',
function ( e ) {
435 if ( !$( e.target ).is(
':input' ) ) {
438 var $textarea = $(
'.gv-followup' ).find(
'textarea' );
439 var followup_text = $( e.target ).attr(
'data-followup' );
440 if ( !followup_text ) {
441 followup_text = $textarea.attr(
'data-default' );
444 $textarea.attr(
'placeholder', followup_text );
446 } ).on(
'submit',
function ( e ) {
449 $.post( $(
this ).attr(
'action' ), $(
this ).serialize() )
450 .done(
function ( data ) {
451 if (
'success' !== data.status ) {
452 gv_feedback_append_error_message();
454 $(
'#gv-uninstall-thanks' ).fadeIn();
457 .fail(
function ( data ) {
458 gv_feedback_append_error_message();
460 .always(
function () {
461 $( e.target ).
remove();
467 function gv_feedback_append_error_message() {
468 $(
'#gv-uninstall-thanks' ).append(
'<div class="notice error">' + <?php echo json_encode( esc_html( __(
'There was an error sharing your feedback. Sorry! Please email us at [email protected]',
'gk-gravityview' ) ) ) ?> +
'</div>' );
473 <form
id=
"gv-uninstall-feedback" method=
"post" action=
"https://hooks.zapier.com/hooks/catch/28670/6haevn/">
474 <h2><?php esc_html_e(
'Why did you uninstall GravityView?',
'gk-gravityview' ); ?></h2>
479 printf(
'<li><label><input name="reason" type="radio" value="other" data-followup="%s"> %s</label></li>', Arr::get( $reason,
'followup' ), Arr::get( $reason,
'label' ) );
483 <div
class=
"gv-followup widefat">
484 <p><strong><label
for=
"gv-reason-details"><?php esc_html_e(
'Comments',
'gk-gravityview' ); ?></label></strong></p>
485 <textarea
id=
"gv-reason-details" name=
"reason_details" data-
default=
"<?php esc_attr_e( 'Please share your thoughts about GravityView', 'gk-gravityview' ) ?>" placeholder=
"<?php esc_attr_e( 'Please share your thoughts about GravityView', 'gk-gravityview' ); ?>" class=
"large-text"></textarea>
487 <div
class=
"scale-description">
488 <p><strong><?php esc_html_e(
'How likely are you to recommend GravityView?',
'gk-gravityview' ); ?></strong></p>
493 echo
'<li class="inline number-scale"><label><input name="likely_to_refer" id="likely_to_refer_' .
$i .
'" value="' .
$i .
'" type="radio"> ' .
$i .
'</label></li>';
498 <p
class=
"description"><?php printf( esc_html_x(
'%s ("Not at all likely") to %s ("Extremely likely")',
'A scale from 0 (bad) to 10 (good)',
'gk-gravityview' ),
'<label for="likely_to_refer_0"><code>0</code></label>',
'<label for="likely_to_refer_10"><code>10</code></label>' ); ?></p>
501 <div
class=
"gv-form-field-wrapper">
502 <label><input type=
"checkbox" class=
"checkbox" name=
"follow_up_with_me" value=
"1" /> <?php esc_html_e(
'Please follow up with me about my feedback',
'gk-gravityview' ); ?></label>
506 <input type=
"hidden" name=
"siteurl" value=
"<?php echo esc_url( get_bloginfo( 'url' ) ); ?>" />
507 <input type=
"hidden" name=
"email" value=
"<?php echo esc_attr( $user->user_email ); ?>" />
508 <input type=
"hidden" name=
"display_name" value=
"<?php echo esc_attr( $user->display_name ); ?>" />
509 <input type=
"submit" value=
"<?php esc_html_e( 'Send Us Your Feedback', 'gk-gravityview' ); ?>" class=
"button button-primary primary button-hero" />
513 <div
id=
"gv-uninstall-thanks" class=
"<?php echo ( gravityview()->plugin->is_GF_25() ) ? 'notice-large' : 'notice notice-large notice-updated below-h2'; ?>" style=
"display:none;">
514 <h3
class=
"notice-title"><?php esc_html_e(
'Thank you for using GravityView!',
'gk-gravityview' ); ?></h3>
516 <?php echo make_clickable( esc_html__(
'Your feedback helps us improve GravityView. If you have any questions or comments, email us: [email protected]',
'gk-gravityview' ) ); ?>
518 <div
class=
"wp-clearfix"></div>
get_app_setting( $setting_name)
Returns a setting.
gravityview_get_floaty( $height=87, $css_class=null)
Get an image of our intrepid explorer friend.
static getSetting( $key)
Returns setting by its name.
get_app_settings()
Returns all settings.
_uninstall_form()
Reimplement elsewhere.
_uninstall_warning_message()
if(gravityview() ->plugin->is_GF_25()) $form
migrate_legacy_settings()
Migrates GravityView <2.16 settings to the new settings framework.
update_app_settings( $settings)
Updates app settings with the provided settings.
update( $settings)
Updates settings.
_get_uninstall_reasons()
Reimplement elsewhere.
scale description p description
all()
Returns all settings.
get_gravitykit_setting( $setting, $default=null)
Returns a GravityKit general setting.
defaults()
Returns default settings.
maybe_save_app_settings()
Check for the gravityview_edit_settings capability before saving plugin settings. ...
gravityview()
The main GravityView wrapper function.
static has_cap( $caps='', $object_id=null, $user_id=null)
Alias of GravityView_Roles_Capabilities::has_cap()
Ex-GF Addon Settings class that's been stripped of GF functionality.
add_settings( $plugins_data)
Adds GravityView settings to Foundation.