diff --git a/assets/js/admin.js b/assets/js/admin.js index 5e8e247..5ca8e42 100755 --- a/assets/js/admin.js +++ b/assets/js/admin.js @@ -36,6 +36,14 @@ url.searchParams.set('tab', tab); 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(); }); }, 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); + } + } }); /* diff --git a/prautoblogger.php b/prautoblogger.php index 5aca883..5c6de94 100644 --- a/prautoblogger.php +++ b/prautoblogger.php @@ -8,7 +8,7 @@ declare(strict_types=1); * Plugin Name: 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. - * Version: 0.2.5 + * Version: 0.2.6 * Requires at least: 6.0 * Requires PHP: 7.4 * Author: PeptideRepo @@ -35,7 +35,7 @@ if ( ! defined( 'ABSPATH' ) ) { | 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_PLUGIN_FILE', __FILE__ ); define( 'PRAUTOBLOGGER_PLUGIN_DIR', plugin_dir_path( __FILE__ ) );