Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions classes/models/FrmAddon.php
Original file line number Diff line number Diff line change
Expand Up @@ -1174,6 +1174,26 @@ private function activate_license( $license ) {

$this->update_last_checked( (bool) $is_valid );

if ( $is_valid ) {
// Setting the license active clears the license caches, so the new license details are available here.
$response = $this->add_activation_response_data( $response );
}

return $response;
}

/**
* Add extra details to the response for a license that just activated.
* Pro overrides this to include the license type, so the license message
* can be updated without reloading the page.
*
* @since x.x
*
* @param array $response The activation response.
*
* @return array
*/
protected function add_activation_response_data( $response ) {
return $response;
}

Expand Down
2 changes: 1 addition & 1 deletion js/formidable_admin.js

Large diffs are not rendered by default.

30 changes: 30 additions & 0 deletions js/src/admin/admin.js
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,7 @@ window.FrmFormsConnect = window.FrmFormsConnect || ( function( document, window,

if ( msg.success === true ) {
app.showAuthorized( true );
app.showLicenseType( msg );
app.showInlineSuccess();

/**
Expand Down Expand Up @@ -157,6 +158,35 @@ window.FrmFormsConnect = window.FrmFormsConnect || ( function( document, window,
}
},

/**
* Update the license type message with the license that was just activated.
* The message is printed before the license is known, so it would otherwise
* keep showing the Lite copy until the page is reloaded.
*
* @since x.x
*
* @param {Object} msg The response from the authorize request.
* @return {void}
*/
showLicenseType( msg ) {
if ( ! msg.license_type_info ) {
return;
}

document.querySelectorAll( '.frm_license_type_info' ).forEach( function( element ) {
element.textContent = msg.license_type_info;
} );

if ( msg.license_type !== 'Elite' ) {
return;
}

// There is nothing left to upgrade to.
document.querySelectorAll( '.frm_license_upgrade_cta' ).forEach( function( element ) {
element.remove();
} );
},

/**
* Use the data-success element to replace the element content.
*/
Expand Down
Loading