Skip to content

Commit 82602cc

Browse files
feat: move license key section
1 parent c78e6fa commit 82602cc

File tree

3 files changed

+73
-1
lines changed

3 files changed

+73
-1
lines changed

css/settings.css

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2466,3 +2466,31 @@ li.draggable-item .components-panel__body-toggle.components-button{
24662466
.fz-prompt-button button.components-button {
24672467
height: 28px;
24682468
}
2469+
.fz-license-section button#check_ti_license:disabled {
2470+
opacity: 0.5;
2471+
pointer-events: none;
2472+
}
2473+
.fz-license-section button#check_ti_license .dashicons-update {
2474+
display: none;
2475+
}
2476+
.fz-license-section button#check_ti_license.fz-checking .dashicons-update {
2477+
-webkit-animation:spin 2s linear infinite;
2478+
-moz-animation:spin 2s linear infinite;
2479+
animation:spin 2s linear infinite;
2480+
display: inline-block;
2481+
}
2482+
.fz-license-section .help-text:has(.dashicons-dismiss) {
2483+
color: #F00;
2484+
}
2485+
.fz-license-section .help-text:has(.dashicons-yes) {
2486+
color: #6eb77a;
2487+
}
2488+
@-webkit-keyframes spin {
2489+
100% { -webkit-transform: rotate(360deg); }
2490+
}
2491+
@keyframes spin {
2492+
100% {
2493+
-webkit-transform: rotate(360deg);
2494+
transform:rotate(360deg);
2495+
}
2496+
}

includes/layouts/settings.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,7 @@ class="<?php echo $_tab === $active_tab ? esc_attr( 'active' ) : ''; ?>"><?php e
114114
case 'general':
115115
?>
116116
<div class="fz-form-wrap">
117+
<?php do_action( 'feedzy_general_setting_before' ); ?>
117118
<div class="form-block">
118119
<div class="fz-form-group">
119120
<label for="feed-post-default-thumbnail" class="form-label"><?php echo esc_html_e( 'Fallback image for imported posts', 'feedzy-rss-feeds' ); ?></label>

js/feedzy-setting.js

Lines changed: 44 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ jQuery( function( $ ) {
6464
$( ':input' ).change(function () {
6565
unsaved = true;
6666
});
67-
$( '#feedzy-settings-submit, #check_wordai_api, #check_spinnerchief_api, #check_aws_api, #check_openai_api, #check_openrouter_api' ).on( 'click', function() {
67+
$( '#feedzy-settings-submit, #check_wordai_api, #check_spinnerchief_api, #check_aws_api, #check_openai_api, #check_openrouter_api, #check_ti_license' ).on( 'click', function() {
6868
unsaved = false;
6969
} );
7070
window.addEventListener( 'beforeunload', function( e ) {
@@ -78,5 +78,48 @@ jQuery( function( $ ) {
7878
$( document ).on( 'change', '#fz-event-execution', function() {
7979
$( '#fz-execution-offset' ).val( new Date().getTimezoneOffset() / 60 );
8080
} );
81+
82+
// License key.
83+
jQuery('.fz-license-section #license_key').on( 'input', function() {
84+
var licenseKey = jQuery(this).val();
85+
if ( licenseKey !== '' ) {
86+
jQuery( '#check_ti_license' ).removeAttr( 'disabled' );
87+
} else {
88+
jQuery( '#check_ti_license' ).attr( 'disabled', true );
89+
}
90+
jQuery('.fz-license-section input[name="license_key"]').val( licenseKey );
91+
} );
92+
93+
jQuery('.fz-license-section #check_ti_license').on('click', function (e) {
94+
e.preventDefault();
95+
var _this = jQuery(this);
96+
_this
97+
.attr('disabled', true)
98+
.addClass( 'fz-checking' );
99+
100+
_this
101+
.parents( '.fz-license-section' )
102+
.find( '.feedzy-api-error' )
103+
.remove();
104+
105+
const LicenseData = _this
106+
.parent( '.fz-input-group-btn' )
107+
.find( 'input' )
108+
.serialize();
109+
110+
jQuery.post( ajaxurl, LicenseData,
111+
function (response) {
112+
if ( ! response.success ) {
113+
jQuery( '<p class="feedzy-api-error">' + response.message + '</p>' ).insertAfter( jQuery( '.fz-license-section' ).find( '.help-text' ) );
114+
_this
115+
.removeAttr('disabled')
116+
.removeClass( 'fz-checking' );
117+
} else {
118+
window.location.reload();
119+
}
120+
},
121+
'json'
122+
);
123+
});
81124
snackbarNotice();
82125
});

0 commit comments

Comments
 (0)