GravityView  2.10.1
The best, easiest way to display Gravity Forms entries on your website.
class-gv-settings-addon.php
Go to the documentation of this file.
1 <?php
2 
3 namespace GV;
4 
6 
7 /** If this file is called directly, abort. */
8 if ( ! defined( 'GRAVITYVIEW_DIR' ) ) {
9  die();
10 }
11 
12 if ( ! class_exists( '\GFAddOn' ) ) {
13  return;
14 }
15 
16 /**
17  * The Addon Settings class.
18  *
19  * Uses internal GFAddOn APIs.
20  */
21 class Addon_Settings extends \GFAddOn {
22 
23  /**
24  * @var string Title of the plugin to be used on the settings page, form settings and plugins page. Example: 'Gravity Forms MailChimp Add-On'
25  */
26  protected $_title = 'GravityView';
27 
28  /**
29  * @var string Short version of the plugin title to be used on menus and other places where a less verbose string is useful. Example: 'MailChimp'
30  */
31  protected $_short_title = 'GravityView';
32 
33  /**
34  * @var string URL-friendly identifier used for form settings, add-on settings, text domain localization...
35  */
36  protected $_slug = 'gravityview';
37 
38  /**
39  * @var string|array A string or an array of capabilities or roles that can uninstall the plugin
40  */
41  protected $_capabilities_uninstall = 'gravityview_uninstall';
42 
43  /**
44  * @var string|array A string or an array of capabilities or roles that have access to the settings page
45  */
46  protected $_capabilities_app_settings = 'gravityview_view_settings';
47 
48  /**
49  * @var string|array A string or an array of capabilities or roles that have access to the settings page
50  */
51  protected $_capabilities_app_menu = 'gravityview_view_settings';
52 
53  /**
54  * @var string The hook suffix for the app menu
55  */
56  public $app_hook_suffix = 'gravityview';
57 
58  /**
59  * @var \GV\License_Handler Process license validation
60  */
62 
63  /**
64  * @var bool Whether we have initialized already or not.
65  */
66  private static $initialized = false;
67 
68  public function __construct() {
69 
70  $this->_version = Plugin::$version;
71  $this->_min_gravityforms_version = Plugin::$min_gf_version;
72 
73  /**
74  * Hook everywhere, but only once.
75  */
76  if ( ! self::$initialized ) {
77  parent::__construct();
78  self::$initialized = true;
79  }
80  }
81 
82  /**
83  * Run actions when initializing admin.
84  *
85  * Triggers the license key notice, etc.
86  *
87  * @return void
88  */
89  public function init_admin() {
90 
91  $this->_load_license_handler();
92 
93  add_filter( 'admin_body_class', array( $this, 'body_class' ) );
94 
95  add_action( 'admin_head', array( $this, 'license_key_notice' ) );
96 
97  add_filter( 'gform_addon_app_settings_menu_gravityview', array( $this, 'modify_app_settings_menu_title' ) );
98 
99  add_filter( 'gform_settings_save_button', array( $this, 'modify_gform_settings_save_button' ), 10, 2 );
100 
101  /** @since 1.7.6 */
102  add_action( 'network_admin_menu', array( $this, 'add_network_menu' ) );
103 
104  add_filter( 'gravityview_noconflict_styles', array( $this, 'register_no_conflict' ) );
105 
106  parent::init_admin();
107  }
108 
109  /**
110  * Return tabs for GV Settings page
111  *
112  * @since XXX
113  *
114  * @return array
115  */
116  public function get_app_settings_tabs() {
117 
118  $setting_tabs = parent::get_app_settings_tabs();
119 
120  foreach ( $setting_tabs as &$tab ) {
121  if ( 'uninstall' !== $tab['name'] ) {
122  continue;
123  }
124 
125  // Do not display uninstall tab if user is lacking permissions/this is a multisite
126  if ( ! ( $this->current_user_can_any( $this->_capabilities_uninstall ) && ( ! function_exists( 'is_multisite' ) || ! is_multisite() || is_super_admin() ) ) ) {
127  $tab = null;
128  continue;
129  }
130 
131  // Add trash can icon to resemble the look and feel of the GF Settings page
132  $tab['icon'] = 'dashicons-trash';
133  }
134 
135  return array_filter( $setting_tabs );
136  }
137 
138  /**
139  * Allow GF styles to load in no-conflict mode
140  *
141  * @param array $items Styles to exclude from no-conflict
142  *
143  * @return array
144  */
145  public function register_no_conflict( $items ) {
146 
147  $items[] = 'gform_settings';
148  $items[] = 'gv-admin-edd-license';
149 
150  return $items;
151  }
152 
153  /**
154  * Adds a CSS class to the <body> of the admin page if running GF 2.5 or newer
155  *
156  * @param $css_class
157  *
158  * @return string
159  */
160  public function body_class( $css_class ) {
161 
162  if ( ! gravityview()->request->is_admin( '', 'settings' ) ) {
163  return $css_class;
164  }
165 
166  if ( gravityview()->plugin->is_GF_25() ) {
167  $css_class .= ' gf-2-5';
168  }
169 
170  return $css_class;
171  }
172 
173  /**
174  * Adds an "Uninstall" button next to the GF 2.5 Save Settings button
175  *
176  * @since 2.9.1
177  *
178  * @param string $html HTML of the save button.
179  * @param \Gravity_Forms\Gravity_Forms\Settings|null $framework Current instance of the Settings Framework. Or null if < 2.5.
180  */
181  public function modify_gform_settings_save_button( $html, $framework = null ) {
182 
183  if ( ! gravityview()->request->is_admin( '', 'settings' ) ) {
184  return $html;
185  }
186 
187  if ( ! ( $this->current_user_can_any( $this->_capabilities_uninstall ) && ( ! function_exists( 'is_multisite' ) || ! is_multisite() || is_super_admin() ) ) ) {
188  return $html;
189  }
190 
191  if ( gravityview()->plugin->is_GF_25() ) {
192  $html_class = 'button outline secondary alignright button-danger';
193  } else {
194  $html_class = 'button button-secondary button-large alignright button-danger';
195  }
196 
197  $href = add_query_arg( array( 'post_type' => 'gravityview', 'page' => 'gravityview_settings', 'view' => 'uninstall' ), admin_url( 'edit.php' ) );
198 
199  $uninstall_button = '<a href="' . esc_url( $href ) . '" class="' . gravityview_sanitize_html_class( $html_class ). '">' . esc_html__( 'Uninstall GravityView', 'gravityview' ) . '</a>';
200 
201  $html .= $uninstall_button;
202 
203  return $html;
204  }
205 
206  /**
207  * Roll our own "Hero" Save button with an Unsubscribe button attached
208  *
209  * @since 2.9.1
210  *
211  * @param array $field
212  * @param bool $echo
213  *
214  * @return string|null HTML of the button.
215  */
216  public function settings_save( $field, $echo = true ) {
217 
218  $field['type'] = 'submit';
219  $field['name'] = 'gform-settings-save';
220  $field['class'] = 'button button-primary primary button-hero';
221  $field['value'] = Utils::get( $field, 'value', __( 'Update Settings', 'gravityview' ) );
222 
223  $html = $this->as_html( $field, false );
224 
225  $html = $this->modify_gform_settings_save_button( $html );
226 
227  if ( $echo ) {
228  echo $html;
229  }
230 
231  return $html;
232  }
233 
234  /**
235  * Change the settings page header title to "GravityView"
236  *
237  * @param $setting_tabs
238  *
239  * @return array
240  */
241  public function modify_app_settings_menu_title( $setting_tabs ) {
242 
243  $setting_tabs[0]['label'] = __( 'GravityView Settings', 'gravityview' );
244  $setting_tabs[0]['icon'] = 'dashicons-admin-settings';
245 
246  return $setting_tabs;
247  }
248 
249  /**
250  * Load license handler in admin-ajax.php
251  *
252  * @return void
253  */
254  public function init_ajax() {
255 
256  $this->_load_license_handler();
257  }
258 
259  /**
260  * Make sure the license handler is available
261  *
262  * @return void
263  */
264  private function _load_license_handler() {
265 
266  if ( ! empty( $this->License_Handler ) ) {
267  return;
268  }
269  $this->License_Handler = License_Handler::get( $this );
270  }
271 
272  /**
273  * Add global Settings page for Multisite
274  *
275  * @since 1.7.6
276  * @return void
277  */
278  public function add_network_menu() {
279 
280  if ( ! gravityview()->plugin->is_network_activated() ) {
281  return;
282  }
283 
284  add_menu_page( __( 'Settings', 'gravityview' ), __( 'GravityView', 'gravityview' ), $this->_capabilities_app_settings, "{$this->_slug}_settings", array( $this, 'app_tab_page' ), 'none' );
285  }
286 
287  /**
288  * Uninstall all traces of GravityView
289  *
290  * Note: method is public because parent method is public
291  *
292  * @return bool
293  */
294  public function uninstall() {
295 
296  gravityview()->plugin->uninstall();
297 
298  /**
299  * Set the path so that Gravity Forms can de-activate GravityView
300  *
301  * @see GFAddOn::uninstall_addon
302  * @uses deactivate_plugins()
303  */
304  $this->_path = GRAVITYVIEW_FILE;
305 
306  return true;
307  }
308 
309  /**
310  * Prevent uninstall tab from being shown by returning false for the uninstall capability check. Otherwise:
311  *
312  * @inheritDoc
313  *
314  * @hack
315  *
316  * @param array|string $caps
317  *
318  * @return bool
319  */
320  public function current_user_can_any( $caps ) {
321 
322  if ( empty( $caps ) ) {
323  $caps = array( 'gravityview_full_access' );
324  }
325 
326  return \GVCommon::has_cap( $caps );
327  }
328 
329  public function uninstall_warning_message() {
330 
331  $heading = esc_html__( 'If you delete then re-install GravityView, it will be like installing GravityView for the first time.', 'gravityview' );
332  $message = esc_html__( 'Delete all Views, GravityView entry approval status, GravityView-generated entry notes (including approval and entry creator changes), and GravityView plugin settings.', 'gravityview' );
333 
334  return sprintf( '<h4>%s</h4><p>%s</p>', $heading, $message );
335  }
336 
337  /**
338  * Get an array of reasons why the plugin might be uninstalled
339  *
340  * @since 1.17.5
341  *
342  * @return array Array of reasons with the label and followup questions for each uninstall reason
343  */
344  private function get_uninstall_reasons() {
345 
346  $reasons = array(
347  'will-continue' => array(
348  'label' => esc_html__( 'I am going to continue using GravityView', 'gravityview' ),
349  ),
350  'no-longer-need' => array(
351  'label' => esc_html__( 'I no longer need GravityView', 'gravityview' ),
352  ),
353  'doesnt-work' => array(
354  'label' => esc_html__( 'The plugin doesn\'t work', 'gravityview' ),
355  ),
356  'found-other' => array(
357  'label' => esc_html__( 'I found a better plugin', 'gravityview' ),
358  'followup' => esc_attr__( 'What plugin you are using, and why?', 'gravityview' ),
359  ),
360  'other' => array(
361  'label' => esc_html__( 'Other', 'gravityview' ),
362  ),
363  );
364 
365  shuffle( $reasons );
366 
367  return $reasons;
368  }
369 
370  /**
371  * Display a feedback form when the plugin is uninstalled
372  *
373  * @since 1.17.5
374  *
375  * @return string HTML of the uninstallation form
376  */
377  public function uninstall_form() {
378 
379  ob_start();
380 
381  $user = wp_get_current_user();
382  ?>
383  <style>
384  #gv-reason-details {
385  min-height: 100px;
386  }
387 
388  .number-scale label {
389  border: 1px solid #cccccc;
390  padding: .5em .75em;
391  margin: .1em;
392  }
393 
394  #gv-uninstall-thanks p {
395  font-size: 1.2em;
396  }
397 
398  .scale-description ul {
399  margin-bottom: 0;
400  padding-bottom: 0;
401  }
402 
403  .scale-description p.description {
404  margin-top: 0 !important;
405  padding-top: 0 !important;
406  }
407 
408  .gv-form-field-wrapper {
409  margin-top: 30px;
410  }
411  </style>
412 
413  <?php
414  if ( gravityview()->plugin->is_GF_25() ) {
415  $uninstall_title = esc_html__( 'Uninstall GravityView', 'gravityview' );
416 
417  echo <<<HTML
418 <div class="gform-settings-panel">
419  <header class="gform-settings-panel__header">
420  <h4 class="gform-settings-panel__title">{$uninstall_title}</h4>
421  </header>
422  <div class="gform-settings-panel__content" style="padding: 0 1rem 1.25rem">
423 
424 HTML;
425  } else {
426  echo '<div class="gv-uninstall-form-wrapper" style="font-size: 110%; padding: 15px 0;">';
427  }
428  ?>
429  <script>
430  jQuery( function( $ ) {
431  $( '#gv-uninstall-feedback' ).on( 'change', function( e ) {
432 
433  if ( ! $( e.target ).is( ':input' ) ) {
434  return;
435  }
436  var $textarea = $( '.gv-followup' ).find( 'textarea' );
437  var followup_text = $( e.target ).attr( 'data-followup' );
438  if ( ! followup_text ) {
439  followup_text = $textarea.attr( 'data-default' );
440  }
441 
442  $textarea.attr( 'placeholder', followup_text );
443 
444  } ).on( 'submit', function( e ) {
445  e.preventDefault();
446 
447  $.post( $( this ).attr( 'action' ), $( this ).serialize() )
448  .done( function( data ) {
449  if ( 'success' !== data.status ) {
450  gv_feedback_append_error_message();
451  } else {
452  $( '#gv-uninstall-thanks' ).fadeIn();
453  }
454  } )
455  .fail( function( data ) {
456  gv_feedback_append_error_message();
457  } )
458  .always( function() {
459  $( e.target ).remove();
460  } );
461 
462  return false;
463  } );
464 
465  function gv_feedback_append_error_message() {
466  $( '#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]', 'gravityview' ) ) ) ?> +'</div>' );
467  }
468  } );
469  </script>
470 
471  <form id="gv-uninstall-feedback" method="post" action="https://hooks.zapier.com/hooks/catch/28670/6haevn/">
472  <h2><?php esc_html_e( 'Why did you uninstall GravityView?', 'gravityview' ); ?></h2>
473  <ul>
474  <?php
475  $reasons = $this->get_uninstall_reasons();
476  foreach ( $reasons as $reason ) {
477  printf( '<li><label><input name="reason" type="radio" value="other" data-followup="%s"> %s</label></li>', Utils::get( $reason, 'followup' ), Utils::get( $reason, 'label' ) );
478  }
479  ?>
480  </ul>
481  <div class="gv-followup widefat">
482  <p><strong><label for="gv-reason-details"><?php esc_html_e( 'Comments', 'gravityview' ); ?></label></strong></p>
483  <textarea id="gv-reason-details" name="reason_details" data-default="<?php esc_attr_e( 'Please share your thoughts about GravityView', 'gravityview' ) ?>" placeholder="<?php esc_attr_e( 'Please share your thoughts about GravityView', 'gravityview' ); ?>" class="large-text"></textarea>
484  </div>
485  <div class="scale-description">
486  <p><strong><?php esc_html_e( 'How likely are you to recommend GravityView?', 'gravityview' ); ?></strong></p>
487  <ul class="inline">
488  <?php
489  $i = 0;
490  while ( $i < 11 ) {
491  echo '<li class="inline number-scale"><label><input name="likely_to_refer" id="likely_to_refer_' . $i . '" value="' . $i . '" type="radio"> ' . $i . '</label></li>';
492  $i ++;
493  }
494  ?>
495  </ul>
496  <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)', 'gravityview' ), '<label for="likely_to_refer_0"><code>0</code></label>', '<label for="likely_to_refer_10"><code>10</code></label>' ); ?></p>
497  </div>
498 
499  <div class="gv-form-field-wrapper">
500  <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', 'gravityview' ); ?></label>
501  </div>
502 
503  <div class="submit">
504  <input type="hidden" name="siteurl" value="<?php echo esc_url( get_bloginfo( 'url' ) ); ?>" />
505  <input type="hidden" name="email" value="<?php echo esc_attr( $user->user_email ); ?>" />
506  <input type="hidden" name="display_name" value="<?php echo esc_attr( $user->display_name ); ?>" />
507  <input type="submit" value="<?php esc_html_e( 'Send Us Your Feedback', 'gravityview' ); ?>" class="button button-primary primary button-hero" />
508  </div>
509  </form>
510 
511  <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;">
512  <h3 class="notice-title"><?php esc_html_e( 'Thank you for using GravityView!', 'gravityview' ); ?></h3>
513  <p><?php echo gravityview_get_floaty(); ?>
514  <?php echo make_clickable( esc_html__( 'Your feedback helps us improve GravityView. If you have any questions or comments, email us: [email protected]', 'gravityview' ) ); ?>
515  </p>
516  <div class="wp-clearfix"></div>
517  </div>
518  </div>
519  <?php
520  if ( gravityview()->plugin->is_GF_25() ) {
521  echo '</div>';
522  }
523 
524  $form = ob_get_clean();
525 
526  return $form;
527  }
528 
529  public function app_settings_tab() {
530 
532 
533  if ( $this->maybe_uninstall() ) {
534  echo $this->uninstall_form();
535  }
536  }
537 
538  /**
539  * The Settings title
540  *
541  * @return string
542  */
543  public function app_settings_title() {
544 
545  return null;
546  }
547 
548  /**
549  * Prevent displaying of any icon
550  *
551  * @return string
552  */
553  public function app_settings_icon() {
554 
555  return '&nbsp;';
556  }
557 
558  /**
559  * Retrieve a setting.
560  *
561  * @param string $setting_name The setting key.
562  *
563  * @return mixed The setting or null
564  * @deprecated Use \GV\Addon_Settings::get
565  */
566  public function get_app_setting( $setting_name ) {
567 
568  return $this->get( $setting_name );
569  }
570 
571  /**
572  * Retrieve a setting.
573  *
574  * @param string $key The setting key.
575  * @param string $default A default if not found.
576  *
577  * @return mixed The setting value.
578  */
579  public function get( $key, $default = null ) {
580 
581  /**
582  * Backward compatibility with Redux
583  */
584  if ( $key === 'license' ) {
585  return array(
586  'license' => $this->get( 'license_key' ),
587  'status' => $this->get( 'license_key_status' ),
588  'response' => $this->get( 'license_key_response' ),
589  );
590  }
591 
592  if ( 'license_key' === $key && defined( 'GRAVITYVIEW_LICENSE_KEY' ) ) {
593  return GRAVITYVIEW_LICENSE_KEY;
594  }
595 
596  return Utils::get( $this->all(), $key, $default );
597  }
598 
599  /**
600  * Get the setting for GravityView by name
601  *
602  * @param string $key Option key to fetch
603  *
604  * @return mixed
605  * @deprecated Use gravityview()->plugin->settings->get()
606  */
607  static public function getSetting( $key ) {
608 
609  if ( gravityview()->plugin->settings instanceof Addon_Settings ) {
610  return gravityview()->plugin->settings->get( $key );
611  }
612  }
613 
614  /**
615  * Get all settings.
616  *
617  * @return array The settings.
618  * @deprecated Use \GV\Addon_Settings::all() or \GV\Addon_Settings::get()
619  *
620  */
621  public function get_app_settings() {
622 
623  return $this->all();
624  }
625 
626  /**
627  * Get all the settings.
628  *
629  * @return array The settings.
630  */
631  public function all() {
632 
633  $option_name = 'gravityformsaddon_' . $this->_slug . '_app_settings';
634 
635  if ( $this->has_site_settings() ) {
636  $defaults = $this->defaults();
637  $option_value = get_option( $option_name, array() );
638  } else {
639  $defaults = get_blog_option( get_main_site_id(), $option_name );
640  $option_value = get_blog_option( get_main_site_id(), $option_name );
641  }
642 
643  return wp_parse_args( $option_value, $defaults );
644  }
645 
646  /**
647  * Default settings.
648  *
649  * @return array The defaults.
650  * @deprecated Use \GV\Addon_Settings::defaults()
651  *
652  */
653  public function get_default_settings() {
654 
655  return $this->defaults();
656  }
657 
658  /**
659  * Default settings.
660  *
661  * @return array The defaults.
662  */
663  private function defaults() {
664 
665  $defaults = array(
666  // Set the default license in wp-config.php
667  'license_key' => defined( 'GRAVITYVIEW_LICENSE_KEY' ) ? GRAVITYVIEW_LICENSE_KEY : '',
668  'license_key_response' => '',
669  'license_key_status' => '',
670  'support-email' => get_bloginfo( 'admin_email' ),
671  'no-conflict-mode' => '1',
672  'support_port' => '1',
673  'flexbox_search' => '1',
674  'lightbox' => 'fancybox',
675  'rest_api' => '0',
676  'beta' => '0',
677  'powered_by' => '0',
678  );
679 
680  /**
681  * @filter `gravityview/settings/default` Filter default global settings.
682  * @param [in,out] array The defaults.
683  */
684  return apply_filters( 'gravityview/settings/defaults', $defaults );
685  }
686 
687  /***
688  * Renders the save button for settings pages
689  *
690  * @param array $field - Field array containing the configuration options of this field
691  * @param bool $echo = true - true to echo the output to the screen, false to simply return the contents as a string
692  *
693  * @return string The HTML
694  */
695  public function as_html( $field, $echo = true ) {
696 
697  $field['type'] = ( isset( $field['type'] ) && in_array( $field['type'], array( 'submit', 'reset', 'button' ) ) ) ? $field['type'] : 'submit';
698 
699  $attributes = $this->get_field_attributes( $field );
700  $default_value = Utils::get( $field, 'value', Utils::get( $field, 'default_value' ) );
701  $value = $this->get( $field['name'], $default_value );
702 
703  $attributes['class'] = isset( $attributes['class'] ) ? esc_attr( $attributes['class'] ) : 'button-primary primary gfbutton';
704  $name = ( $field['name'] === 'gform-settings-save' ) ? $field['name'] : '_gaddon_setting_' . $field['name'];
705 
706  if ( empty( $value ) ) {
707  $value = __( 'Update Settings', 'gravityview' );
708  }
709 
710  $attributes = $this->get_field_attributes( $field );
711 
712  $html = '<input
713  type="' . $field['type'] . '"
714  name="' . esc_attr( $name ) . '"
715  value="' . $value . '" ' .
716  implode( ' ', $attributes ) .
717  ' />';
718 
719  if ( $echo ) {
720  echo $html;
721  }
722 
723  return $html;
724  }
725 
726  /**
727  * @deprecated Use \GV\Addon_Settings::as_html
728  */
729  public function settings_submit( $field, $echo = true ) {
730 
731  gravityview()->log->warning( '\GV\Addon_Settings::settings_submit has been deprecated for \GV\Addon_Settings::as_html' );
732 
733  return $this->as_html( $field, $echo );
734  }
735 
736  /**
737  * Check whether GravityView is being saved
738  *
739  * The generic is_save_postback() is true for all addons
740  *
741  * @since 2.0.8
742  *
743  * @return bool
744  */
745  public function is_save_postback() {
746 
747  return isset( $_POST['gform-settings-save'] ) && isset( $_POST['_gravityview_save_settings_nonce'] );
748  }
749 
750  /**
751  * Display a notice if the plugin is inactive.
752  *
753  * @return void
754  */
755  public function license_key_notice() {
756 
757  if ( 'uninstall' === rgget( 'view' ) ) {
758  return; // Do not display license notice on the uninstall page in GF 2.5
759  }
760 
761  if ( $this->is_save_postback() ) {
762  $settings = $this->get_posted_settings();
763  $license_key = defined( 'GRAVITYVIEW_LICENSE_KEY' ) ? GRAVITYVIEW_LICENSE_KEY : \GV\Utils::get( $settings, 'license_key' );
764  $license_status = \GV\Utils::get( $settings, 'license_key_status', 'inactive' );
765  } else {
766  $license_status = $this->get( 'license_key_status', 'inactive' );
767  $license_key = $this->get( 'license_key' );
768  }
769 
770  $license_id = empty( $license_key ) ? 'license' : $license_key;
771 
772  $message = esc_html__( 'Your GravityView license %s. This means you&rsquo;re missing out on updates and support! %sActivate your license%s or %sget a license here%s.', 'gravityview' );
773 
774  /** @internal Do not use! Will change without notice (pun slightly intended). */
775  $message = apply_filters( 'gravityview/settings/license-key-notice', $message );
776 
777  /**
778  * I wanted to remove the period from after the buttons in the string,
779  * but didn't want to mess up the translation strings for the translators.
780  */
781  $message = mb_substr( $message, 0, mb_strlen( $message ) - 1 );
782  $title = __( 'Inactive License', 'gravityview' );
783  $status = '';
784  $update_below = false;
785  $primary_button_link = admin_url( 'edit.php?post_type=gravityview&amp;page=gravityview_settings' );
786 
787  switch ( $license_status ) {
788  /** @since 1.17 */
789  case 'expired':
790  $title = __( 'Expired License', 'gravityview' );
791  $status = __( 'has expired', 'gravityview' );
792  $message = $this->get_license_handler()->strings( 'expired', $this->get( 'license_key_response' ) );
793  break;
794  case 'invalid':
795  $title = __( 'Invalid License', 'gravityview' );
796  $status = __( 'is invalid', 'gravityview' );
797  break;
798  case 'deactivated':
799  $status = __( 'is inactive', 'gravityview' );
800  $update_below = __( 'Activate your license key below.', 'gravityview' );
801  break;
802  /** @noinspection PhpMissingBreakStatementInspection */
803  case '':
804  $license_status = 'site_inactive';
805  // break intentionally left blank
806  case 'inactive':
807  case 'site_inactive':
808  $status = __( 'has not been activated', 'gravityview' );
809  $update_below = __( 'Activate your license key below.', 'gravityview' );
810  break;
811  }
812  $url = 'https://gravityview.co/pricing/?utm_source=admin_notice&utm_medium=admin&utm_content=' . $license_status . '&utm_campaign=Admin%20Notice';
813 
814  // Show a different notice on settings page for inactive licenses (hide the buttons)
815  if ( $update_below && gravityview()->request->is_admin( '', 'settings' ) ) {
816  $message = sprintf( $message, $status, '<div class="hidden">', '', '', '</div><a href="#" onclick="jQuery(\'#license_key\').focus(); return false;">' . $update_below . '</a>' );
817  } else {
818  $message = sprintf( $message, $status, "\n\n" . '<a href="' . esc_url( $primary_button_link ) . '" class="button button-primary primary">', '</a>', '<a href="' . esc_url( $url ) . '" class="button button-secondary">', '</a>' );
819  }
820 
821  if ( empty( $status ) ) {
822  return;
823  }
824 
826  'message' => $message,
827  'class' => 'notice notice-warning gv-license-warning',
828  'title' => $title,
829  'cap' => 'gravityview_edit_settings',
830  'dismiss' => sha1( $license_status . '_' . $license_id . '_' . date( 'z' ) ), // Show every day, instead of every 8 weeks (which is the default)
831  ) );
832  }
833 
834  /**
835  * Allow public access to the GV\License_Handler class
836  *
837  * @since 1.7.4
838  *
839  * @return \GV\License_Handler
840  */
841  public function get_license_handler() {
842 
843  return $this->License_Handler;
844  }
845 
846  /**
847  * Add tooltip script to app settings page. Not enqueued by Gravity Forms for some reason.
848  *
849  * @since 1.21.5
850  *
851  * @see GFAddOn::scripts()
852  *
853  * @return array Array of scripts
854  */
855  public function scripts() {
856 
857  $scripts = parent::scripts();
858 
859  $scripts[] = array(
860  'handle' => 'gform_tooltip_init',
861  'enqueue' => array(
862  array(
863  'admin_page' => array( 'app_settings' ),
864  ),
865  ),
866  );
867 
868  return $scripts;
869  }
870 
871  /**
872  * Register styles in the app admin page
873  *
874  * @return array
875  */
876  public function styles() {
877 
878  $styles = parent::styles();
879 
880  $deps = array(
881  'gform_admin',
882  'gaddon_form_settings_css',
883  'gform_font_awesome',
884  );
885 
886  // This file was removed from 2.5
887  if( ! gravityview()->plugin->is_GF_25() ) {
888  $deps[] = 'gform_tooltip';
889  }
890 
891  $styles[] = array(
892  'handle' => 'gravityview_settings',
893  'src' => plugins_url( 'assets/css/admin-settings.css', GRAVITYVIEW_FILE ),
894  'version' => Plugin::$version,
895  'deps' => $deps,
896  'enqueue' => array(
897  array(
898  'admin_page' => array(
899  'app_settings',
900  'plugin_settings',
901  ),
902  ),
903  ),
904  );
905 
906  return $styles;
907  }
908 
909  /**
910  * Does the current site have its own settings?
911  *
912  * - If not multisite, returns true.
913  * - If multisite and the plugin is network activated, returns true; we need to register the submenu page for the Network Admin settings to work.
914  * - If multisite and not network admin, return false.
915  *
916  * @since 2.8.2
917  *
918  * @return bool
919  */
920  private function has_site_settings() {
921 
922  return ( ! is_multisite() ) || is_main_site() || ( ! gravityview()->plugin->is_network_activated() ) || ( is_network_admin() && gravityview()->plugin->is_network_activated() );
923  }
924 
925  /**
926  * Add Settings link to GravityView menu
927  *
928  * @return void
929  */
930  public function create_app_menu() {
931 
932  /**
933  * Override whether to show the Settings menu on a per-blog basis.
934  *
935  * @since 1.7.6
936  * @param bool $hide_if_network_activated Default: true
937  */
938  $show_submenu = apply_filters( 'gravityview/show-settings-menu', $this->has_site_settings() );
939 
940  if ( ! $show_submenu ) {
941  return;
942  }
943 
944  add_submenu_page( 'edit.php?post_type=gravityview', __( 'Settings', 'gravityview' ), __( 'Settings', 'gravityview' ), $this->_capabilities_app_settings, $this->_slug . '_settings', array( $this, 'app_tab_page' ) );
945  }
946 
947  /**
948  * Gets the required indicator
949  * Gets the markup of the required indicator symbol to highlight fields that are required
950  *
951  * @param $field - The field meta.
952  *
953  * @return string - Returns markup of the required indicator symbol
954  */
955  public function get_required_indicator( $field ) {
956 
957  return '<span class="required" title="' . esc_attr__( 'Required', 'gravityview' ) . '">*</span>';
958  }
959 
960  /**
961  * Specify the settings fields to be rendered on the plugin settings page
962  *
963  * @return array
964  */
965  public function app_settings_fields() {
966 
967  $default_settings = $this->defaults();
968 
969  $disabled_attribute = \GVCommon::has_cap( 'gravityview_edit_settings' ) ? false : 'disabled';
970 
971  $affiliate_link = 'https://gravityview.co/account/affiliate/?utm_source=in-plugin&utm_medium=setting&utm_content=Register as an affiliate';
972 
973  $fields = array(
974  array(
975  'name' => 'support-email',
976  'type' => 'text',
977  'validate' => 'email',
978  'default_value' => $default_settings['support-email'],
979  'label' => __( 'Support Email', 'gravityview' ),
980  'description' => __( 'In order to provide responses to your support requests, please provide your email address.', 'gravityview' ),
981  'class' => 'code regular-text',
982  ),
983  /**
984  * @since 1.15 Added Support Port support
985  */
986  array(
987  'name' => 'support_port',
988  'type' => 'radio',
989  'label' => __( 'Show Support Port?', 'gravityview' ),
990  'default_value' => $default_settings['support_port'],
991  'horizontal' => 1,
992  'choices' => array(
993  array(
994  'label' => _x( 'Show', 'Setting: Show or Hide', 'gravityview' ),
995  'value' => '1',
996  ),
997  array(
998  'label' => _x( 'Hide', 'Setting: Show or Hide', 'gravityview' ),
999  'value' => '0',
1000  ),
1001  ),
1002  'tooltip' => '<p>' . esc_html__( 'The Support Port provides quick access to how-to articles and tutorials. For administrators, it also makes it easy to contact support.', 'gravityview' ) . '<img src="' . esc_url_raw( plugins_url( 'assets/images/beacon.png', GRAVITYVIEW_FILE ) ) . '" alt="' . esc_attr__( 'The Support Port looks like this.', 'gravityview' ) . '" class="aligncenter" style="display: block; max-width:100%; margin:1em auto;" /></p>',
1003  'description' => __( 'Show the Support Port on GravityView pages?', 'gravityview' ),
1004  ),
1005  array(
1006  'name' => 'no-conflict-mode',
1007  'type' => 'radio',
1008  'label' => __( 'No-Conflict Mode', 'gravityview' ),
1009  'default_value' => $default_settings['no-conflict-mode'],
1010  'horizontal' => 1,
1011  'choices' => array(
1012  array(
1013  'label' => _x( 'On', 'Setting: On or off', 'gravityview' ),
1014  'value' => '1',
1015  ),
1016  array(
1017  'label' => _x( 'Off', 'Setting: On or off', 'gravityview' ),
1018  'value' => '0',
1019  ),
1020  ),
1021  'description' => __( 'Set this to ON to prevent extraneous scripts and styles from being printed on GravityView admin pages, reducing conflicts with other plugins and themes.', 'gravityview' ) . ' ' . __( 'If your Edit View tabs are ugly, enable this setting.', 'gravityview' ),
1022  ),
1023  /**
1024  * @since 2.0 Added REST API
1025  */
1026  gravityview()->plugin->supports( Plugin::FEATURE_REST ) ?
1027  array(
1028  'name' => 'rest_api',
1029  'type' => 'radio',
1030  'label' => __( 'REST API', 'gravityview' ),
1031  'default_value' => $default_settings['rest_api'],
1032  'horizontal' => 1,
1033  'choices' => array(
1034  array(
1035  'label' => _x( 'Enable', 'Setting: Enable or Disable', 'gravityview' ),
1036  'value' => '1',
1037  ),
1038  array(
1039  'label' => _x( 'Disable', 'Setting: Enable or Disable', 'gravityview' ),
1040  'value' => '0',
1041  ),
1042  ),
1043  'description' => __( 'Enable View and Entry access via the REST API? Regular per-View restrictions apply (private, password protected, etc.).', 'gravityview' ),
1044  'tooltip' => '<p>' . esc_html__( 'If you are unsure, choose the Disable setting.', 'gravityview' ) . '</p>',
1045  ) : array(),
1046  array(
1047  'name' => 'powered_by',
1048  'type' => 'checkbox',
1049  'label' => __( 'Display "Powered By" Link', 'gravityview' ),
1050  'default_value' => $default_settings['powered_by'],
1051  'choices' => array(
1052  array(
1053  'label' => esc_html__( 'Display a "Powered by GravityView" link', 'gravityview' ),
1054  'value' => '1',
1055  'name' => 'powered_by',
1056  ),
1057  ),
1058  'description' => __( 'When enabled, a "Powered by GravityView" link will be displayed below Views. Help us spread the word!', 'gravityview' ),
1059  ),
1060  array(
1061  'name' => 'affiliate_id',
1062  'type' => 'text',
1063  'input_type' => 'number',
1064  'default_value' => null,
1065  'label' => __( 'Affiliate ID', 'gravityview' ),
1066  'description' => sprintf( __( 'Earn money when people clicking your links become GravityView customers. <a href="%s" rel="external">Register as an affiliate</a>!', 'gravityview' ), esc_url( $affiliate_link ) ),
1067  'class' => 'code',
1068  'placeholder' => '123',
1069  'data-requires' => 'powered_by',
1070  ),
1071  array(
1072  'name' => 'beta',
1073  'type' => 'checkbox',
1074  'label' => __( 'Become a Beta Tester', 'gravityview' ),
1075  'default_value' => $default_settings['beta'],
1076  'horizontal' => 1,
1077  'choices' => array(
1078  array(
1079  'label' => esc_html__( 'Show me beta versions if they are available.', 'gravityview' ),
1080  'value' => '1',
1081  'name' => 'beta',
1082  ),
1083  ),
1084  'description' => __( 'You will have early access to the latest GravityView features and improvements. There may be bugs! If you encounter an issue, help make GravityView better by reporting it!', 'gravityview' ),
1085  ),
1086  );
1087 
1088  $fields = array_filter( $fields, 'count' );
1089 
1090  /**
1091  * @filter `gravityview_settings_fields` Filter the settings fields.
1092  * @param array $fields The fields to filter.
1093  * @deprecated Use `gravityview/settings/fields`.
1094  */
1095  $fields = apply_filters( 'gravityview_settings_fields', $fields );
1096 
1097  /**
1098  * @filter `gravityview/settings/fields` Filter the settings fields.
1099  * @param array $fields The fields to filter.
1100  */
1101  $fields = apply_filters( 'gravityview/settings/fields', $fields );
1102 
1103  /**
1104  * Redux backward compatibility
1105  *
1106  * @since 1.7.4
1107  */
1108  foreach ( $fields as &$field ) {
1109  $field['name'] = isset( $field['name'] ) ? $field['name'] : Utils::get( $field, 'id' );
1110  $field['label'] = isset( $field['label'] ) ? $field['label'] : Utils::get( $field, 'title' );
1111  $field['default_value'] = isset( $field['default_value'] ) ? $field['default_value'] : Utils::get( $field, 'default' );
1112  $field['description'] = isset( $field['description'] ) ? $field['description'] : Utils::get( $field, 'subtitle' );
1113 
1114  if ( $disabled_attribute ) {
1115  $field['disabled'] = $disabled_attribute;
1116  }
1117 
1118  if ( empty( $field['disabled'] ) ) {
1119  unset( $field['disabled'] );
1120  }
1121  }
1122 
1123  $license_fields = array(
1124  array(
1125  'name' => 'license_key',
1126  'required' => ! defined( 'GRAVITYVIEW_LICENSE_KEY' ) || ! GRAVITYVIEW_LICENSE_KEY,
1127  'label' => __( 'License Key', 'gravityview' ),
1128  'description' => __( 'Enter the license key that was sent to you on purchase. This enables plugin updates &amp; support.', 'gravityview' ),
1129  'type' => 'edd_license',
1130  'data-pending-text' => __( 'Verifying license&hellip;', 'gravityview' ),
1131  'default_value' => $default_settings['license_key'],
1132  'class' => ( '' == $this->get( 'license_key' ) ) ? 'activate code regular-text edd-license-key' : 'deactivate code regular-text edd-license-key',
1133  ),
1134  array(
1135  'name' => 'license_key_response',
1136  'default_value' => $default_settings['license_key_response'],
1137  'type' => 'hidden',
1138  ),
1139  array(
1140  'name' => 'license_key_status',
1141  'default_value' => $default_settings['license_key_status'],
1142  'type' => 'hidden',
1143  ),
1144  );
1145 
1146  if ( defined( 'GRAVITYVIEW_LICENSE_KEY' ) && GRAVITYVIEW_LICENSE_KEY ) {
1147  $license_fields[0] = array_merge( $license_fields[0], array(
1148  'disabled' => true,
1149  'title' => __( 'The license key is defined by your site\'s configuration file.', 'gravityview' ),
1150  ) );
1151  }
1152 
1153  $sections = array();
1154  $version_info = '<span class="gv-version-info" title="' . sprintf( __( 'You are running GravityView version %s', 'gravityview' ), Plugin::$version ) . '">Version ' . esc_html( Plugin::$version ) . '</span>';
1155 
1156  if ( \gravityview()->plugin->is_GF_25() ) {
1157 
1158  $sections[] = array(
1159  'title' => __( 'GravityView License', 'gravityview' ),
1160  'class' => 'gform-settings-panel--full gv-settings-panel--license',
1161  'description' => $version_info,
1162  'fields' => $license_fields,
1163  );
1164 
1165  } else {
1166 
1167  $fields = array_merge( $license_fields, $fields );
1168 
1169  array_unshift( $fields, array(
1170  'name' => 'gv_header',
1171  'value' => $version_info,
1172  'type' => 'html',
1173  ) );
1174  }
1175 
1176  $sections[] = array(
1177  'title' => ( gravityview()->plugin->is_GF_25() ? __( 'GravityView Settings', 'gravityview' ) : null ),
1178  'class' => 'gform-settings-panel--full gv-settings-panel--core',
1179  'fields' => $fields,
1180  );
1181 
1182  /**
1183  * @filter `gravityview/settings/extension/sections` Modify the GravityView settings page
1184  * Extensions can tap in here to insert their own section and settings.
1185  * <code>
1186  * $sections[] = array(
1187  * 'title' => __( 'GravityView My Extension Settings', 'gravityview' ),
1188  * 'fields' => $settings,
1189  * );
1190  * </code>
1191  * @param array $extension_settings Empty array, ready for extension settings!
1192  */
1193  $extension_sections = apply_filters( 'gravityview/settings/extension/sections', array() );
1194 
1195  // If there are extensions, add a section for them
1196  if ( ! empty( $extension_sections ) ) {
1197 
1198  if ( $disabled_attribute ) {
1199  foreach ( $extension_sections as &$section ) {
1200  foreach ( $section['fields'] as &$field ) {
1201  $field['disabled'] = $disabled_attribute;
1202  }
1203  }
1204  }
1205 
1206  $sections = array_merge( $sections, $extension_sections );
1207  }
1208 
1209  return $sections;
1210  }
1211 
1212  /**
1213  * Updates app settings with the provided settings
1214  *
1215  * Same as the GFAddon, except it returns the value from update_option()
1216  *
1217  * @param array $settings - App settings to be saved
1218  *
1219  * @return boolean False if value was not updated and true if value was updated.
1220  * @deprecated Use \GV\Addon_Settings::set or \GV\Addon_Settings::update
1221  *
1222  */
1223  public function update_app_settings( $settings ) {
1224 
1225  return $this->update( $settings );
1226  }
1227 
1228  /**
1229  * Sets a subset of settings.
1230  *
1231  * @param array|string An array of settings to update, or string (key) and $value to update one setting.
1232  * @param mixed $value A value if $settings is string (key). Default: null.
1233  */
1234  public function set( $settings, $value = null ) {
1235 
1236  if ( is_string( $settings ) ) {
1237  $settings = array( $settings => $value );
1238  }
1239  $settings = wp_parse_args( $settings, $this->all() );
1240 
1241  return update_option( 'gravityformsaddon_' . $this->_slug . '_app_settings', $settings );
1242  }
1243 
1244  /**
1245  * Updates settings.
1246  *
1247  * @param array $settings The settings array.
1248  *
1249  * @return boolean False if value was not updated and true if value was updated.
1250  */
1251  public function update( $settings ) {
1252 
1253  return update_option( 'gravityformsaddon_' . $this->_slug . '_app_settings', $settings );
1254  }
1255 
1256  /**
1257  * Register the settings field for the EDD License field type
1258  *
1259  * @param array $field
1260  * @param bool $echo Whether to echo the
1261  *
1262  * @return string
1263  */
1264  public function settings_edd_license( $field, $echo = true ) {
1265 
1266  if ( defined( 'GRAVITYVIEW_LICENSE_KEY' ) && GRAVITYVIEW_LICENSE_KEY ) {
1267  $field['input_type'] = 'password';
1268  }
1269 
1270  $text = $this->settings_text( $field, false );
1271 
1272  $activation = $this->License_Handler->settings_edd_license_activation( $field, false );
1273 
1274  $return = $text . $activation;
1275 
1276  $return .= $this->get_license_handler()->license_details( \GV\Addon_Settings::get( 'license_key_response' ) );
1277 
1278  if ( $echo ) {
1279  echo $return;
1280  }
1281 
1282  return $return;
1283  }
1284 
1285  /**
1286  * Allow pure HTML settings row
1287  *
1288  * @since 2.0.6
1289  *
1290  * @param array $field
1291  * @param bool $echo Whether to echo the
1292  *
1293  * @return string
1294  */
1295  protected function settings_html( $field, $echo = true ) {
1296 
1297  $return = \GV\Utils::get( $field, 'value', '' );
1298 
1299  if ( $echo ) {
1300  echo $return;
1301  }
1302 
1303  return $return;
1304  }
1305 
1306  /**
1307  * No <th> needed for pure HTML settings row
1308  *
1309  * @since 2.0.6
1310  *
1311  * @param array $field
1312  *
1313  * @return void
1314  */
1315  public function single_setting_row_html( $field ) {
1316 
1317  ?>
1318 
1319  <tr id="gaddon-setting-row-<?php echo esc_attr( $field['name'] ); ?>">
1320  <td colspan="2">
1321  <?php $this->single_setting( $field ); ?>
1322  </td>
1323  </tr>
1324 
1325  <?php
1326  }
1327 
1328  /**
1329  * Keep GravityView styling for `$field['description']`, even though Gravity Forms added support for it
1330  *
1331  * Converts `$field['description']` to `$field['gv_description']`
1332  * Converts `$field['subtitle']` to `$field['description']`
1333  *
1334  * @since 1.21.5.2
1335  *
1336  * @see http://share.gravityview.co/P28uGp/2OIRKxog for image that shows subtitle vs description
1337  *
1338  * @see \GV\Addon_Settings::single_setting_label Converts `gv_description` back to `description`
1339  * @param array $field
1340  *
1341  * @return void
1342  */
1343  public function single_setting_row( $field ) {
1344 
1345  $field['gv_description'] = Utils::get( $field, 'description' );
1346  $field['description'] = Utils::get( $field, 'subtitle' );
1348  }
1349 
1350  /**
1351  * The same as the parent, except added support for field descriptions
1352  *
1353  * @inheritDoc
1354  * @param $field array
1355  */
1356  public function single_setting_label( $field ) {
1357 
1359  if ( $description = Utils::get( $field, 'gv_description' ) ) {
1360  echo '<span class="description">' . $description . '</span>';
1361  }
1362  }
1363 
1364  /**
1365  * Check for the `gravityview_edit_settings` capability before saving plugin settings.
1366  * Gravity Forms says you're able to edit if you're able to view settings. GravityView allows two different permissions.
1367  *
1368  * @since 1.15
1369  * @return void
1370  */
1371  public function maybe_save_app_settings() {
1372 
1373  if ( $this->is_save_postback() ) {
1374  if ( ! \GVCommon::has_cap( 'gravityview_edit_settings' ) ) {
1375  $_POST = array(); // If you don't reset the $_POST array, it *looks* like the settings were changed, but they weren't
1376  \GFCommon::add_error_message( __( 'You don\'t have the ability to edit plugin settings.', 'gravityview' ) );
1377 
1378  return;
1379  }
1380  }
1382  }
1383 
1384  /**
1385  * When the settings are saved, make sure the license key matches the previously activated key
1386  *
1387  * @return array settings from parent::get_posted_settings(), with `license_key_response` and `license_key_status` potentially unset
1388  */
1389  public function get_posted_settings() {
1390 
1391  $posted_settings = parent::get_posted_settings();
1392 
1393  $local_key = Utils::get( $posted_settings, 'license_key' );
1394 
1395  if ( ! $local_key && defined( 'GRAVITYVIEW_LICENSE_KEY' ) ) {
1396  $local_key = GRAVITYVIEW_LICENSE_KEY;
1397  }
1398 
1399  $response_key = Utils::get( $posted_settings, 'license_key_response/license_key' );
1400 
1401  static $added_message = false;
1402 
1403  // If the posted key doesn't match the activated/deactivated key (set using the Activate License button, AJAX response),
1404  // then we assume it's changed. If it's changed, unset the status and the previous response.
1405  if ( ! $added_message && ( $local_key !== $response_key ) ) {
1406 
1407  unset( $posted_settings['license_key_response'] );
1408  unset( $posted_settings['license_key_status'] );
1409 
1410  \GFCommon::add_error_message( __( 'The license key you entered has been saved, but not activated. Please activate the license.', 'gravityview' ) );
1411 
1412  $added_message = true;
1413  }
1414 
1415  return $posted_settings;
1416  }
1417 }
get_uninstall_reasons()
Get an array of reasons why the plugin might be uninstalled.
$url
Definition: post_image.php:25
all()
Get all the settings.
If this file is called directly, abort.
gravityview_get_floaty( $height=87, $css_class=null)
Get an image of our intrepid explorer friend.
if(empty( $value)) $user
uninstall()
Uninstall all traces of GravityView.
single_setting_row_html( $field)
No needed for pure HTML settings row.
settings_html( $field, $echo=true)
Allow pure HTML settings row.
is_save_postback()
Check whether GravityView is being saved.
app_settings_icon()
Prevent displaying of any icon.
get_app_settings_tabs()
Return tabs for GV Settings page.
settings_edd_license( $field, $echo=true)
Register the settings field for the EDD License field type.
modify_app_settings_menu_title( $setting_tabs)
Change the settings page header title to "GravityView".
create_app_menu()
Add Settings link to GravityView menu.
gravityview()
Definition: _stubs.php:26
uninstall_form()
Display a feedback form when the plugin is uninstalled.
get( $key, $default=null)
Retrieve a setting.
has_site_settings()
Does the current site have its own settings?
if(gravityview() ->plugin->is_GF_25()) $form
get_app_settings()
Get all settings.
styles()
Register styles in the app admin page.
settings_save( $field, $echo=true)
Roll our own "Hero" Save button with an Unsubscribe button attached.
current_user_can_any( $caps)
Prevent uninstall tab from being shown by returning false for the uninstall capability check...
scale description p description
register_no_conflict( $items)
Allow GF styles to load in no-conflict mode.
single_setting_label( $field)
The same as the parent, except added support for field descriptions.
app_settings_fields()
Specify the settings fields to be rendered on the plugin settings page.
single_setting_row( $field)
Keep GravityView styling for `$field[&#39;description&#39;]`, even though Gravity Forms added support for it...
body_class( $css_class)
Adds a CSS class to the <body> of the admin page if running GF 2.5 or newer.
defaults()
Default settings.
const GRAVITYVIEW_FILE
Full path to the GravityView file "GRAVITYVIEW_FILE" "./gravityview.php".
Definition: gravityview.php:31
get_required_indicator( $field)
Gets the required indicator Gets the markup of the required indicator symbol to highlight fields that...
add_network_menu()
Add global Settings page for Multisite.
scripts()
Add tooltip script to app settings page.
get_app_setting( $setting_name)
Retrieve a setting.
if(empty( $field_settings['email_field'])) $settings
app_settings_title()
The Settings title.
static add_notice( $notice=array())
Add a notice to be displayed in the admin.
init_admin()
Run actions when initializing admin.
update( $settings)
Updates settings.
If this file is called directly, abort.
scale description ul
as_html( $field, $echo=true)
static get( $array, $key, $default=null)
Grab a value from an array or an object or default.
gv form field wrapper
update_app_settings( $settings)
Updates app settings with the provided settings.
maybe_save_app_settings()
Check for the gravityview_edit_settings capability before saving plugin settings. ...
static has_cap( $caps='', $object_id=null, $user_id=null)
Alias of GravityView_Roles_Capabilities::has_cap()
modify_gform_settings_save_button( $html, $framework=null)
Adds an "Uninstall" button next to the GF 2.5 Save Settings button.
static getSetting( $key)
Get the setting for GravityView by name.
init_ajax()
Load license handler in admin-ajax.php.
_load_license_handler()
Make sure the license handler is available.
license_key_notice()
Display a notice if the plugin is inactive.
get_posted_settings()
When the settings are saved, make sure the license key matches the previously activated key...
get_license_handler()
Allow public access to the GV class.
get_default_settings()
Default settings.
settings_submit( $field, $echo=true)
$field
Definition: gquiz_grade.php:11
$description
Definition: post_image.php:28
$title