fix: Restore button now sends you to Active tab where the note lives (v3.4.1)

After v3.4.0 introduced the Active/Completed tab strip, clicking
Restore on a completed note appeared to do nothing — the restored
note never showed up. David: "the complete log does not return
to active."

Root cause: the Restore handler in wp_notes_page_callback() was
the only action handler without a wp_redirect() + exit; after its
update_option() calls. Every other handler (new note, mark-as-done
single, mark-as-done bulk) had one. So Restore relied on the page
falling through and re-rendering, which used to work when both
Active and Completed sections rendered on the same page (user
could glance up to see the restored note in the Active section).

v3.4.0's single-pane tab render exposed the latent bug: after
Restore, the URL still says ?tab=completed, so only Completed
re-renders (minus the now-restored note), and the restored note
is invisible on Active.

Fix: add the missing redirect to admin.php?page=wp-notes (defaults
to Active tab) after the restore completes. The restored note now
appears in its new home immediately.

Patch bump — bug fix only, no API or behavioural changes beyond
the fix itself. Other handlers, storage model, tab structure, and
CSS are unchanged.
This commit is contained in:
2026-05-26 09:07:27 +01:00
parent c5d8a34296
commit 431c31a95b
2 changed files with 38 additions and 4 deletions
+16 -4
View File
@@ -5,7 +5,7 @@
* Plugin Name: Logbook
* Plugin URI: https://icanhelp.ie/wp-notes
* Description: A lightweight task & logbook plugin for WordPress. Log your daily work, mark tasks done, and keep a tidy record inside the dashboard. Perfect for freelancers showing clients what's been delivered and students proving work to teachers.
* Version: 3.4.0
* Version: 3.4.1
* Requires at least: 5.0
* Requires PHP: 7.2
* Author: IR240474
@@ -33,7 +33,7 @@ if (!isset($wp_notes_init)) {
$wp_notes_init = true;
// Plugin Constants
if (!defined('WP_NOTES_VERSION')) define('WP_NOTES_VERSION', '3.4.0');
if (!defined('WP_NOTES_VERSION')) define('WP_NOTES_VERSION', '3.4.1');
if (!defined('WP_NOTES_FILE')) define('WP_NOTES_FILE', __FILE__);
if (!defined('WP_NOTES_PATH')) define('WP_NOTES_PATH', plugin_dir_path(__FILE__));
if (!defined('WP_NOTES_URL')) define('WP_NOTES_URL', plugin_dir_url(__FILE__));
@@ -1342,7 +1342,7 @@ function wp_notes_handle_actions() {
$done_notes = get_option('wp_done_notes', array());
$current_user = wp_get_current_user();
$new_done_notes = array();
foreach ($done_notes as $key => $note) {
if (in_array($key, $_POST['done_ids'])) {
$note['last_modified'] = current_time('mysql');
@@ -1352,9 +1352,21 @@ function wp_notes_handle_actions() {
$new_done_notes[] = $note;
}
}
update_option('wp_notes', $notes);
update_option('wp_done_notes', $new_done_notes);
// v3.4.1 fix: redirect to the Active tab so the restored note is
// visible in its new home. Without this redirect, the page falls
// through and re-renders with the URL's current ?tab=completed,
// so the user sees Completed (minus the now-restored note) and
// can't see the restored note on Active. The other action
// handlers above (new note, mark-as-done single, mark-as-done
// bulk) all redirect; restore was the odd one out. Pre-v3.4.0
// this was masked because both sections rendered on the same
// page — the v3.4.0 single-pane tab render exposed it.
wp_redirect(admin_url('admin.php?page=wp-notes'));
exit;
}
// Handle edit note action