fix: preserve active tab after saving settings
The _wp_http_referer hidden field didn't include the tab parameter, so WordPress redirected to the default (API Keys) tab after every save. Now the JS syncs the referer with the active tab on both tab switch and page load. Bumped to v0.2.6 to bust JS cache. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -36,6 +36,14 @@
|
|||||||
url.searchParams.set('tab', tab);
|
url.searchParams.set('tab', tab);
|
||||||
window.history.replaceState({}, '', url);
|
window.history.replaceState({}, '', url);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Update the _wp_http_referer so WordPress redirects back to this tab after save.
|
||||||
|
var $referer = $('#ab-settings-form input[name="_wp_http_referer"]');
|
||||||
|
if ($referer.length) {
|
||||||
|
var refUrl = new URL($referer.val(), window.location.origin);
|
||||||
|
refUrl.searchParams.set('tab', tab);
|
||||||
|
$referer.val(refUrl.pathname + refUrl.search);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -55,6 +63,18 @@
|
|||||||
$notice.fadeOut(400, function () { $(this).remove(); });
|
$notice.fadeOut(400, function () { $(this).remove(); });
|
||||||
}, 6000);
|
}, 6000);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// On load, sync _wp_http_referer with the current tab so the first
|
||||||
|
// save without switching tabs still returns to the right place.
|
||||||
|
var currentTab = new URL(window.location).searchParams.get('tab');
|
||||||
|
if (currentTab) {
|
||||||
|
var $referer = $('#ab-settings-form input[name="_wp_http_referer"]');
|
||||||
|
if ($referer.length) {
|
||||||
|
var refUrl = new URL($referer.val(), window.location.origin);
|
||||||
|
refUrl.searchParams.set('tab', currentTab);
|
||||||
|
$referer.val(refUrl.pathname + refUrl.search);
|
||||||
|
}
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ declare(strict_types=1);
|
|||||||
* Plugin Name: PRAutoBlogger
|
* Plugin Name: PRAutoBlogger
|
||||||
* Plugin URI: https://peptiderepo.com/prautoblogger
|
* Plugin URI: https://peptiderepo.com/prautoblogger
|
||||||
* Description: Monitors social media for trending topics, generates SEO-friendly blog posts using AI, and publishes them on a daily schedule with full cost tracking and self-improvement metrics.
|
* Description: Monitors social media for trending topics, generates SEO-friendly blog posts using AI, and publishes them on a daily schedule with full cost tracking and self-improvement metrics.
|
||||||
* Version: 0.2.5
|
* Version: 0.2.6
|
||||||
* Requires at least: 6.0
|
* Requires at least: 6.0
|
||||||
* Requires PHP: 7.4
|
* Requires PHP: 7.4
|
||||||
* Author: PeptideRepo
|
* Author: PeptideRepo
|
||||||
@@ -35,7 +35,7 @@ if ( ! defined( 'ABSPATH' ) ) {
|
|||||||
| and limits without magic strings.
|
| and limits without magic strings.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
define( 'PRAUTOBLOGGER_VERSION', '0.2.5' );
|
define( 'PRAUTOBLOGGER_VERSION', '0.2.6' );
|
||||||
define( 'PRAUTOBLOGGER_DB_VERSION', '1.1.0' );
|
define( 'PRAUTOBLOGGER_DB_VERSION', '1.1.0' );
|
||||||
define( 'PRAUTOBLOGGER_PLUGIN_FILE', __FILE__ );
|
define( 'PRAUTOBLOGGER_PLUGIN_FILE', __FILE__ );
|
||||||
define( 'PRAUTOBLOGGER_PLUGIN_DIR', plugin_dir_path( __FILE__ ) );
|
define( 'PRAUTOBLOGGER_PLUGIN_DIR', plugin_dir_path( __FILE__ ) );
|
||||||
|
|||||||
Reference in New Issue
Block a user