v3.3.0
This commit is contained in:
parent
7b3c00cacc
commit
0ec665db60
2 changed files with 415 additions and 337 deletions
|
|
@ -14,61 +14,19 @@
|
|||
margin: 20px 0;
|
||||
}
|
||||
|
||||
/* ===========================
|
||||
Tabs Navigation
|
||||
=========================== */
|
||||
.noindex-seo-tabs {
|
||||
display: flex;
|
||||
gap: 10px;
|
||||
margin-bottom: 30px;
|
||||
border-bottom: 2px solid #c3c4c7;
|
||||
flex-wrap: wrap;
|
||||
/* Tab navigation uses the native WordPress nav-tab classes. */
|
||||
.noindex-seo-admin-wrap .nav-tab-wrapper {
|
||||
margin-bottom: 20px;
|
||||
}
|
||||
|
||||
.noindex-seo-tab {
|
||||
padding: 12px 24px;
|
||||
background: transparent;
|
||||
border: none;
|
||||
color: #646970;
|
||||
font-size: 15px;
|
||||
font-weight: 500;
|
||||
cursor: pointer;
|
||||
border-bottom: 3px solid transparent;
|
||||
transition: color 0.3s ease;
|
||||
position: relative;
|
||||
top: 2px;
|
||||
/* Section titles inside a tab panel. Vertical separation between
|
||||
sections comes from the content blocks' own bottom margins. */
|
||||
.noindex-seo-section-title {
|
||||
margin: 0 0 12px 0;
|
||||
}
|
||||
|
||||
.noindex-seo-tab:hover,
|
||||
.noindex-seo-tab.active {
|
||||
color: var(--wp-admin-theme-color, #2271b1);
|
||||
}
|
||||
|
||||
.noindex-seo-tab.active {
|
||||
border-bottom-color: var(--wp-admin-theme-color, #2271b1);
|
||||
}
|
||||
|
||||
/* ===========================
|
||||
Tab Content
|
||||
=========================== */
|
||||
.noindex-seo-tab-content {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.noindex-seo-tab-content.active {
|
||||
display: block;
|
||||
animation: noindexSeoFadeIn 0.3s ease;
|
||||
}
|
||||
|
||||
@keyframes noindexSeoFadeIn {
|
||||
from {
|
||||
opacity: 0;
|
||||
transform: translateY(10px);
|
||||
}
|
||||
to {
|
||||
opacity: 1;
|
||||
transform: translateY(0);
|
||||
}
|
||||
.noindex-seo-section-title + .description {
|
||||
margin: 0 0 12px 0;
|
||||
}
|
||||
|
||||
/* ===========================
|
||||
|
|
@ -365,11 +323,6 @@ input:checked + .noindex-seo-slider:before {
|
|||
margin: 0 0 20px 0;
|
||||
}
|
||||
|
||||
.noindex-seo-apply-note {
|
||||
margin-inline-start: 8px;
|
||||
vertical-align: middle;
|
||||
}
|
||||
|
||||
/* ===========================
|
||||
General Config Section
|
||||
=========================== */
|
||||
|
|
@ -758,15 +711,6 @@ input:checked + .noindex-seo-slider:before {
|
|||
grid-template-columns: 1fr;
|
||||
}
|
||||
|
||||
.noindex-seo-tabs {
|
||||
overflow-x: auto;
|
||||
-webkit-overflow-scrolling: touch;
|
||||
}
|
||||
|
||||
.noindex-seo-tab {
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.noindex-seo-stats {
|
||||
grid-template-columns: 1fr;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -13,43 +13,10 @@
|
|||
* Initialize the admin panel
|
||||
*/
|
||||
function init() {
|
||||
initTabs();
|
||||
initCollapsibleCards();
|
||||
initSearch();
|
||||
initStats();
|
||||
initTooltips();
|
||||
initMethodDependentFields();
|
||||
}
|
||||
|
||||
/**
|
||||
* Initialize tabs functionality
|
||||
*/
|
||||
function initTabs() {
|
||||
$( '.noindex-seo-tab' ).on(
|
||||
'click',
|
||||
function (e) {
|
||||
e.preventDefault();
|
||||
|
||||
const tabId = $( this ).data( 'tab' );
|
||||
|
||||
// Update active tab.
|
||||
$( '.noindex-seo-tab' ).removeClass( 'active' );
|
||||
$( this ).addClass( 'active' );
|
||||
|
||||
// Update active content.
|
||||
$( '.noindex-seo-tab-content' ).removeClass( 'active' );
|
||||
$( '#' + tabId ).addClass( 'active' );
|
||||
|
||||
// Save last active tab to localStorage.
|
||||
localStorage.setItem( 'noindexSeoActiveTab', tabId );
|
||||
}
|
||||
);
|
||||
|
||||
// Restore last active tab.
|
||||
const lastTab = localStorage.getItem( 'noindexSeoActiveTab' );
|
||||
if (lastTab && $( '#' + lastTab ).length) {
|
||||
$( '.noindex-seo-tab[data-tab="' + lastTab + '"]' ).click();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -163,63 +130,6 @@
|
|||
// Can be enhanced with a tooltip library if needed.
|
||||
}
|
||||
|
||||
/**
|
||||
* Initialize method-dependent field states
|
||||
* Some fields only work with HTTP headers, not HTML meta tags
|
||||
*/
|
||||
function initMethodDependentFields() {
|
||||
const methodSelect = $( '#noindex_seo_config_method' );
|
||||
|
||||
if (methodSelect.length === 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Update field states based on selected implementation method
|
||||
*/
|
||||
function updateFieldStates() {
|
||||
const method = methodSelect.val();
|
||||
const isHeaderEnabled = (method === 'header' || method === 'both');
|
||||
|
||||
// Contexts that ONLY work with HTTP headers (non-HTML content).
|
||||
const headerOnlyContexts = [
|
||||
'attachment', // Attachment pages (may contain PDFs, images, etc.).
|
||||
'feed', // RSS/Atom feeds (XML, not HTML).
|
||||
'comment_feed' // Comment feeds (XML, not HTML).
|
||||
];
|
||||
|
||||
headerOnlyContexts.forEach(
|
||||
function (context) {
|
||||
// Find all directive checkboxes for this context.
|
||||
const directiveCheckboxes = $( 'input[name$="_seo_' + context + '"]' );
|
||||
const option = directiveCheckboxes.first().closest( '.noindex-seo-option' );
|
||||
|
||||
if ( ! isHeaderEnabled) {
|
||||
// Disable all directives for this context.
|
||||
directiveCheckboxes.prop( 'disabled', true );
|
||||
directiveCheckboxes.prop( 'checked', false );
|
||||
option.addClass( 'disabled' );
|
||||
option.attr( 'title', 'This option only works with HTTP Headers implementation method' );
|
||||
} else {
|
||||
// Enable all directives for this context.
|
||||
directiveCheckboxes.prop( 'disabled', false );
|
||||
option.removeClass( 'disabled' );
|
||||
option.removeAttr( 'title' );
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
// Update stats after changing field states.
|
||||
updateStats();
|
||||
}
|
||||
|
||||
// Listen for method changes.
|
||||
methodSelect.on( 'change', updateFieldStates );
|
||||
|
||||
// Execute on page load.
|
||||
updateFieldStates();
|
||||
}
|
||||
|
||||
/**
|
||||
* Expand all cards
|
||||
*/
|
||||
|
|
@ -325,9 +235,15 @@
|
|||
if (urlParams.get( 'updated' ) === 'true') {
|
||||
showSuccessMessage( noindexSeoAdmin.successMessage || 'Settings saved successfully!' );
|
||||
|
||||
// Remove the parameter from URL without reload.
|
||||
const newUrl = window.location.pathname + window.location.hash;
|
||||
window.history.replaceState( {}, document.title, newUrl );
|
||||
// Remove only the success flag, keeping the page and tab
|
||||
// parameters intact (tabs are URL-based since 3.3.0).
|
||||
urlParams.delete( 'updated' );
|
||||
const remaining = urlParams.toString();
|
||||
window.history.replaceState(
|
||||
{},
|
||||
document.title,
|
||||
window.location.pathname + ( remaining ? '?' + remaining : '' )
|
||||
);
|
||||
}
|
||||
}
|
||||
);
|
||||
|
|
|
|||
Loading…
Reference in a new issue