Skip to content

Commit

Permalink
Improve GRAVITYVIEW_LICENSE_KEY experience
Browse files Browse the repository at this point in the history
- Always use the license when defined in `GRAVITYVIEW_LICENSE_KEY `
- When defined, set the input type to "password" instead of "text"
- Disable updating the license key setting when it's defined in the code
- And if `$field['disabled']` is false, unset the key so Gravity Forms
knows what to do with it.

Fixes #917
  • Loading branch information
zackkatz committed Sep 1, 2017
1 parent a8554cd commit a1e7b88
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 3 deletions.
21 changes: 18 additions & 3 deletions includes/class-gravityview-settings.php
Original file line number Diff line number Diff line change
Expand Up @@ -632,7 +632,14 @@ public function get_app_setting( $setting_name ) {
* @return array
*/
public function get_app_settings() {
return get_option( 'gravityformsaddon_' . $this->_slug . '_app_settings', $this->get_default_settings() );

$settings = get_option( 'gravityformsaddon_' . $this->_slug . '_app_settings', $this->get_default_settings() );

if( defined( 'GRAVITYVIEW_LICENSE_KEY' ) ) {
$settings['license_key'] = GRAVITYVIEW_LICENSE_KEY;
}

return $settings;
}


Expand Down Expand Up @@ -667,7 +674,11 @@ public function set_field_error( $field, $error_message = '' ) {
*/
protected function settings_edd_license( $field, $echo = true ) {

$text = self::settings_text( $field, false );
if( defined('GRAVITYVIEW_LICENSE_KEY') && ! empty( GRAVITYVIEW_LICENSE_KEY ) ) {

This comment has been minimized.

Copy link
@soulseekah

soulseekah Sep 2, 2017

Contributor

Bad syntax for anything lower than PHP 5.5, sorry :(

http://php.net/empty only accepts variables, anything else is a syntax error.

Fix incoming.

$field['input_type'] = 'password';
}

$text = $this->settings_text( $field, false );

$activation = $this->License_Handler->settings_edd_license_activation( $field, false );

Expand Down Expand Up @@ -895,6 +906,7 @@ public function app_settings_fields() {
'label' => __( 'License Key', 'gravityview' ),
'description' => __( 'Enter the license key that was sent to you on purchase. This enables plugin updates & support.', 'gravityview' ) . $this->get_license_handler()->license_details( $this->get_app_setting( 'license_key_response' ) ),
'type' => 'edd_license',
'disabled' => ( defined('GRAVITYVIEW_LICENSE_KEY') && ! empty( GRAVITYVIEW_LICENSE_KEY ) ),
'data-pending-text' => __('Verifying license…', 'gravityview'),
'default_value' => $default_settings['license_key'],
'class' => ( '' == $this->get_app_setting( 'license_key' ) ) ? 'activate code regular-text edd-license-key' : 'deactivate code regular-text edd-license-key',
Expand Down Expand Up @@ -990,8 +1002,11 @@ public function app_settings_fields() {
if( $disabled_attribute ) {
$field['disabled'] = $disabled_attribute;
}
}

if( empty( $field['disabled'] ) ) {
unset( $field['disabled'] );
}
}

$sections = array(
array(
Expand Down
1 change: 1 addition & 0 deletions readme.txt
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ Beautifully display your Gravity Forms entries. Learn more on [gravityview.co](h
= 1.22 =

* Changed:
* Fixed: When `GRAVITYVIEW_LICENSE_KEY` constant is defined, it will always be used, and the license field will be disabled
* Fixed: Inline Edit plugin not working when displaying a single entry
* Fixed: Featured Entries plugin not adding `gv-featured-entry` CSS selector to a single entry container
* Fixed: List View and Table View templates have more standardized CSS selectors for single & multiple contexts ([Learn more](http://docs.gravityview.co/article/63-css-guide))
Expand Down

0 comments on commit a1e7b88

Please sign in to comment.