5 Commits

Author SHA1 Message Date
ranger e51b087545 release: 3.3.2 → 3.3.3 — verification bump to test the "Check now" flow end-to-end
Pure version increment with no functional changes. Lets David's
Local install (currently on v3.3.2) hit the "Check now" button in
Settings → Updates and verify the panel correctly reports a real
version delta — should render "v3.3.3 available — Download .zip"
with a working download link to the source archive on Gitea.

After the test passes, `git pull` brings the local install to
v3.3.3 and the same panel should flip back to "You are up to date
(v3.3.3)".

VERSION
- wp-notes.php header 3.3.2 → 3.3.3
- WP_NOTES_VERSION constant 3.3.2 → 3.3.3
- About page version-history leads with v3.3.3 as latest (with a
  cheeky "if you can see this line, you successfully pulled the
  test release" note); v3.3.2 demoted to previous entry.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-25 09:47:25 +01:00
ranger 1c93c82ef5 fix: update checker — fall back to /tags when no formal Gitea Release exists (v3.3.2)
The v3.3.0 update checker only queried Gitea's /releases/latest
endpoint, which requires a formal Release object (created via the
Gitea web UI with optional notes + zip assets attached). A plain
"git tag v3.3.x && git push --tags" from the terminal does NOT
create that Release object — so the checker kept returning "No
releases tagged on the Gitea repo yet" even when tags existed.

wp_notes_fetch_latest_release() now falls back to the
/tags?limit=1 endpoint when /releases/latest returns 404 (or any
non-200). It synthesises a release-like payload from the newest
tag — tag_name, html_url pointing at the tag view, tag message as
the body, empty assets[] so the existing download-URL logic falls
through to Gitea's source-archive URL pattern (/archive/<tag>.zip).

Net effect: the "Check now" button now finds the latest version
whether David creates formal Gitea Releases OR just pushes tags
with "git push --tags". No workflow change required.

Discovered while diagnosing why "Check now" wasn't seeing today's
v3.1.0/v3.2.0/v3.3.0/v3.3.1 tags (just pushed in this session)
— the tags were there, the formal Release objects were not.

KNOWN LIMITATION (not a bug — flagged)
The Gitea repo ranger/a-wp-notes-v3 is currently private. Anonymous
API requests get a 404 (Gitea's standard behaviour for private
repos). The updater code is correct but can't actually reach the
API on a private repo without authentication. Fix: change the
repo visibility to public on Gitea — appropriate anyway for a
GPL-licensed plugin headed for the WordPress.org marketplace.

VERSION BUMP
- wp-notes.php header 3.3.1 → 3.3.2
- WP_NOTES_VERSION constant 3.3.1 → 3.3.2
- About page version-history leads with v3.3.2; v3.3.1 demoted

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-25 09:29:33 +01:00
ranger 3667b7a154 release: 3.3.0 → 3.3.1 — drop "WP" prefix, plugin is now just "Logbook"
David's call after a short discussion about WordPress.org marketplace
considerations. WP.org's trademark policy historically discourages
plugins implying official endorsement via a "WP" prefix and has been
known to request rename during submission review. Dropping it now
makes the name cleaner AND sidesteps that future hurdle if/when the
plugin lands on the marketplace.

CHANGES
All user-facing brand mentions: WP Logbook → Logbook across:
- Plugin header (Plugin Name + docblock)
- Admin menu top-level
- Admin sidebar submenu label still "My Log" (already prefix-free)
- Admin bar count menu
- Dashboard widget title
- Settings page H1
- Main page H1
- About page intro card + "What Logbook does" card heading
- Email feedback subject + body intro
- Legacy feedback.php subject lines
- error_log() prefix [WP Logbook] → [Logbook]
- Updater panel description text
- styles.php docblock

VERSION
- wp-notes.php header Version: 3.3.0 → 3.3.1
- WP_NOTES_VERSION constant: 3.3.0 → 3.3.1
- About page version-history card gets new top entry for v3.3.1
  with green "latest" pill; v3.3.0 demoted to previous entry
- CHANGELOG header line tracks the full naming lineage now:
  A-WP-Notes (≤v3.1.0) → WP Logbook (v3.2.0-v3.3.0) → Logbook
  (v3.3.1+)

NOTABLY NOT CHANGED
- Historical CHANGELOG entries for v3.2.0 still say "WP Logbook" —
  that was the correct name at the time, rewriting would be
  revisionist.
- Same zero-migration commitment: internal function names,
  constants, DB option keys, user_meta keys, file paths, plugin
  slug 'wp-notes', and text domain 'a-wp-notes' all unchanged.
- Pure user-facing string change. No data migration, no behaviour
  change. Existing installs see "Logbook" appear on next page
  refresh.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-25 09:13:51 +01:00
ranger 5c8f1716a3 release: 3.2.0 → 3.3.0 — self-hosted update checker (Gitea API)
WP Logbook is hosted on the author's own Gitea instance
(git.davidtkeane.com), not on WordPress.org, so WP's built-in update
flow doesn't see new releases. This release adds a Settings →
Updates panel that polls Gitea's Releases API and reports whether
a newer version is available.

CHANGES
- inc/wp-notes-updater.php: full rewrite of the previous broken stub
  (it had a hard require on a non-existent vendor path and was never
  included from the main plugin file anyway).
- wp_notes_fetch_latest_release() hits
  /api/v1/repos/<owner>/<repo>/releases/latest, parses, normalises.
  Prefers a .zip asset attached to the release; falls back to
  Gitea's source-archive zip URL.
- wp_notes_update_status() compares against WP_NOTES_VERSION and
  returns 'available' | 'up-to-date' | 'unknown' (the last when no
  release has been tagged yet — graceful first-run UX since the
  repo currently has zero tags).
- New AJAX endpoint wp_notes_check_updates, capability-gated
  (manage_options) + nonce-protected. Force-refreshes the cache.
- Settings page now renders the Updates panel via
  wp_notes_render_updates_panel() — current status text, "Check
  now" button, View on Gitea / View all releases quick links,
  manual-install instructions, and a Download .zip button + View
  release notes link when an update is detected.
- wp-notes.php require_once chain now includes the updater file.

CACHING
- Successful fetches: 12h site transient.
- Negative responses (404 = no releases yet): 1h so a freshly-
  tagged release shows up quickly.

INSTALLATION FLOW (intentionally manual)
The panel does NOT auto-install. Manual path printed in the panel:
download .zip → deactivate → upload via Plugins → Add New → Upload
→ reactivate. Notes live in wp_options so they survive the upgrade.

ALSO IN 3.3.0
- Section heading rename carried from the previous unreleased
  block: "Add New Note" → "New Log Entry"; "Notes Todo List:" →
  "Log entries". Row-level "note" labels intentionally unchanged.

VERSION BUMP
- wp-notes.php header 3.2.0 → 3.3.0
- WP_NOTES_VERSION constant 3.2.0 → 3.3.0
- About page version history leads with v3.3.0 as latest, demotes
  v3.2.0 to previous entry

NOTES FOR FUTURE-CLAUDE
- Gitea repo currently has ZERO release tags. First run will show
  "No releases tagged on the Gitea repo yet." Tag v3.2.0 / v3.3.0
  on Gitea and the checker will start reporting versions.
- Repo coordinates live in three constants at the top of
  inc/wp-notes-updater.php (WP_NOTES_GITEA_HOST, _OWNER, _REPO).
  Override via define() in wp-config.php if the repo ever moves.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-25 09:09:40 +01:00
ranger eeaf8a0f87 ux: rename section headings on My Log page to match the logbook framing
The H1 says "WP Logbook" and the sidebar says "My Log" since the
v3.2.0 rebrand, but two section headings on the My Log page still
read "Add New Note" and "Notes Todo List:" — slightly jarring next
to the new identity.

CHANGES
- "Add New Note" (create form postbox) → "New Log Entry"
- "Notes Todo List:" (above active + completed lists) → "Log entries"

NOT CHANGED — intentionally
Row-level labels stay as "note" because that's the unit-of-work term
in the existing data model and the per-row UI:
- "Add Note" submit button
- "Mark as Done"
- "No active/completed notes found" empty-state notices
- Email subjects ("WP Logbook feedback…" stays, doesn't say note)

The headings are brand-y; the row-level strings are functional.
Different rename scope on purpose — minimises churn while still
making the page read consistently with its new name.

No version bump — too small to justify another release, lives in
[Unreleased] until the next phase bundles with it.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-25 08:34:17 +01:00
7 changed files with 470 additions and 74 deletions
+151 -1
View File
@@ -1,6 +1,6 @@
# Changelog # Changelog
All notable changes to **WP Logbook** (formerly **A-WP-Notes** through v3.1.0) are documented here. All notable changes to **Logbook** (formerly **A-WP-Notes** through v3.1.0, then **WP Logbook** in v3.2.0v3.3.0) are documented here.
Format: [Keep a Changelog 1.1.0](https://keepachangelog.com/en/1.1.0/) — versioning: [SemVer](https://semver.org/). Format: [Keep a Changelog 1.1.0](https://keepachangelog.com/en/1.1.0/) — versioning: [SemVer](https://semver.org/).
--- ---
@@ -9,6 +9,156 @@ Format: [Keep a Changelog 1.1.0](https://keepachangelog.com/en/1.1.0/) — versi
--- ---
## [3.3.3] — 2026-05-25
**Verification bump.** Pure version increment to test the end-to-end
"Check now" flow against the now-publicly-hosted Gitea repo. No
functional changes. David's Local install (running v3.3.2) should
now see *"v3.3.3 available — Download .zip"* in the Settings →
Updates panel once "Check now" is clicked, confirming the update
mechanism works against a real version delta. After the test, he
can `git pull` to land on v3.3.3 and watch the same panel flip back
to *"You are up to date (v3.3.3)"*.
---
## [3.3.2] — 2026-05-25
### Fixed — update checker now works with tag-only workflows
The v3.3.0 update checker only queried Gitea's `/releases/latest`
endpoint, which requires a **formal Release object** (created via
the Gitea web UI with optional notes + zip assets). A plain
`git tag v3.3.x && git push --tags` from the terminal doesn't
create that Release object — so the checker kept returning *"No
releases tagged on the Gitea repo yet"* even when tags clearly
existed.
`wp_notes_fetch_latest_release()` now falls back to the
`/tags?limit=1` endpoint when `/releases/latest` returns 404 (or
any non-200). It synthesises a release-like payload from the
newest tag — `tag_name`, an `html_url` pointing at the tag view,
the tag message as the body, and an empty `assets[]` array so the
existing download-URL logic falls through to Gitea's source-archive
URL pattern (`/archive/<tag>.zip`).
**Net effect:** the "Check now" button now finds the latest version
whether David creates formal Gitea Releases OR just pushes tags
with `git push --tags`. No workflow change required.
### Known limitation (not a bug — flagged for awareness)
The Gitea repo `ranger/a-wp-notes-v3` is currently **private**.
Anonymous API requests get a 404 (Gitea's standard behaviour to
avoid leaking the existence of private repos). The updater code is
correct, but it can't actually reach the API on a private repo
without authentication. **Fix:** change the repo visibility to
public on Gitea (Settings → Visibility) — appropriate anyway for a
GPL-licensed plugin headed for the WordPress.org marketplace.
---
## [3.3.1] — 2026-05-25
**Naming: dropped the `WP` prefix. The plugin is now just `Logbook`.**
David's call after a short discussion about WordPress.org marketplace
considerations — WP.org's trademark policy historically discourages
plugins implying official endorsement via a `WP` prefix and has been
known to request a rename during submission review. Dropping it now
makes the name cleaner *and* sidesteps that future hurdle if/when
the plugin lands on the marketplace.
### Changed
- All user-facing brand mentions: `WP Logbook``Logbook` across
plugin header, admin menu, admin bar, dashboard widget, settings
H1, main page H1, About page intro, About page card heading,
feedback email subjects/body, error_log prefix, updater panel
copy, and styles docblock.
- About page version-history card gets a new top entry for v3.3.1
with the green "latest" pill; v3.3.0 demoted to the previous slot.
- CHANGELOG header line updated to track the full naming lineage:
*A-WP-Notes (≤v3.1.0) → WP Logbook (v3.2.0v3.3.0) → Logbook
(v3.3.1+)*.
### Notably NOT changed
- Historical CHANGELOG entries for v3.2.0 (the original "WP
Logbook" rebrand) still say "WP Logbook" — that was the correct
name at the time and rewriting it would be revisionist.
- Same zero-migration commitment as the v3.2.0 rebrand: internal
function names, constants, DB option keys, user_meta keys, file
paths, plugin slug, and text domain all unchanged. Pure
user-facing string change.
---
## [3.3.0] — 2026-05-25
**New feature: self-hosted update checker.** WP Logbook is hosted on
the author's own Gitea instance (`git.davidtkeane.com`), not on
WordPress.org, so WordPress's built-in update flow doesn't see new
releases. This release adds a small **Updates** panel to the
Settings page that polls the Gitea Releases API and tells you when
there's a newer version waiting.
### Added
- **`inc/wp-notes-updater.php`** — full rewrite of the previous
broken stub (which had a hard `require` on a non-existent vendor
path and was never included from the main plugin file anyway).
- **Settings → Updates panel** at the bottom of `Settings → WP
Logbook → Settings`. Shows the current status on load (cached),
with a **Check now** button that force-refreshes against the
Gitea API.
- **`wp_notes_fetch_latest_release()`** — hits
`/api/v1/repos/<owner>/<repo>/releases/latest` on Gitea, parses
the response, normalises into `{version, html_url,
download_url, body, published_at}`. Prefers a `.zip` asset
attached to the release; falls back to Gitea's source-archive
URL (`/archive/<tag>.zip`).
- **`wp_notes_update_status()`** — version-compares against
`WP_NOTES_VERSION` and returns one of `available`,
`up-to-date`, or `unknown` (the last when no release has been
tagged yet — graceful first-time UX).
- **AJAX endpoint `wp_notes_check_updates`** — capability gated
(`manage_options`) + nonce protected. Deletes the cache and
re-fetches.
- **Quick links** in the panel: *View on Gitea* and *View all
releases* — both open the Gitea web UI in a new tab.
### Cached
- Successful release fetches: **12 hours** in a site transient.
- Negative responses (e.g. HTTP 404 = no releases tagged yet):
**1 hour** so a freshly-tagged release shows up quickly.
### Installation flow (manual on purpose)
The panel does NOT auto-install. Manual path (printed in the
panel itself): *download the .zip → deactivate plugin → upload via
Plugins → Add New → Upload → reactivate*. Notes live in
`wp_options` so they survive the upgrade.
### Notes for future-Claude / future-David
- The Gitea repo currently has **zero release tags** — so the very
first run of this checker will show *"No releases tagged on the
Gitea repo yet."* That's by design. Tag the v3.2.0 / v3.3.0 / v4
releases on Gitea as we ship them and the checker will start
reporting versions on its own.
- The Gitea repo coordinates live in three constants at the top of
`inc/wp-notes-updater.php` (`WP_NOTES_GITEA_HOST`, `_OWNER`,
`_REPO`). Override-able via `define()` in `wp-config.php` if the
repo ever moves.
### Also in this release — heading rename carried over from the unreleased block
### Changed — Section headings on My Log page renamed to match the logbook framing
- `Add New Note` → **`New Log Entry`** on the create form postbox.
- `Notes Todo List:` → **`Log entries`** above the active/completed
lists.
- Row-level labels intentionally **unchanged** — buttons like *Add
Note* / *Mark as Done* / empty-state *No active notes found* still
say "note" because that's the unit-of-work term in the existing
data model and UI. The headings are brand-y; the row-level strings
are functional. Two different concerns, different rename scope.
---
## [3.2.0] — 2026-05-25 ## [3.2.0] — 2026-05-25
**Plugin rebrand: `A-WP-Notes` → `WP Logbook`.** Bundles the rename **Plugin rebrand: `A-WP-Notes` → `WP Logbook`.** Bundles the rename
+2 -2
View File
@@ -40,10 +40,10 @@ function wp_notes_admin_bar_menu($wp_admin_bar) {
$notes = get_option('wp_notes', array()); $notes = get_option('wp_notes', array());
$count = count($notes); $count = count($notes);
// Main WP Logbook menu item // Main Logbook menu item
$wp_admin_bar->add_node(array( $wp_admin_bar->add_node(array(
'id' => 'wp-notes', 'id' => 'wp-notes',
'title' => sprintf('WP Logbook <span class="count">%d</span>', $count), 'title' => sprintf('Logbook <span class="count">%d</span>', $count),
'href' => admin_url('admin.php?page=wp-notes'), 'href' => admin_url('admin.php?page=wp-notes'),
)); ));
+24 -8
View File
@@ -2,7 +2,7 @@
// wp-notes-about.php // wp-notes-about.php
/** /**
* Function to display the "About" page for WP Logbook plugin. * Function to display the "About" page for Logbook plugin.
*/ */
function wp_notes_about_page() { function wp_notes_about_page() {
?> ?>
@@ -53,11 +53,11 @@ function wp_notes_about_page() {
<div class="wp-notes-about-intro"> <div class="wp-notes-about-intro">
<div class="wp-notes-about-intro__img"> <div class="wp-notes-about-intro__img">
<img src="<?php echo esc_url(WP_NOTES_URL); ?>assets/wp-notes-banner.jpg" <img src="<?php echo esc_url(WP_NOTES_URL); ?>assets/wp-notes-banner.jpg"
alt="WP Logbook banner"> alt="Logbook banner">
</div> </div>
<div class="wp-notes-about-intro__body"> <div class="wp-notes-about-intro__body">
<h2>WP Logbook <span style="color:#646970; font-weight:400;">v<?php echo esc_html(WP_NOTES_VERSION); ?></span></h2> <h2>Logbook <span style="color:#646970; font-weight:400;">v<?php echo esc_html(WP_NOTES_VERSION); ?></span></h2>
<p>WP Logbook is a lightweight task &amp; logbook plugin for WordPress. Log your daily work, mark tasks as done, and keep a tidy record right inside the dashboard &mdash; perfect for freelancers showing clients what's been delivered.</p> <p>Logbook is a lightweight task &amp; logbook plugin for WordPress. Log your daily work, mark tasks as done, and keep a tidy record right inside the dashboard &mdash; perfect for freelancers showing clients what's been delivered.</p>
<p style="margin-bottom:0;"> <p style="margin-bottom:0;">
<a href="<?php echo esc_url(admin_url('admin.php?page=wp-notes')); ?>" class="button button-primary">Go to My Log →</a> <a href="<?php echo esc_url(admin_url('admin.php?page=wp-notes')); ?>" class="button button-primary">Go to My Log →</a>
</p> </p>
@@ -101,10 +101,10 @@ function wp_notes_about_page() {
} }
</style> </style>
<!-- What WP Logbook does --> <!-- What Logbook does -->
<div class="wp-notes-about-card"> <div class="wp-notes-about-card">
<h2>What WP Logbook does</h2> <h2>What Logbook does</h2>
<p>WP Logbook is a lightweight task &amp; logbook plugin that lives entirely inside the WordPress admin. Type a note, format it with colour / size / font / emoji, mark it done when the work is finished, restore it later if you need to revisit. Everything is stored in the site's own database &mdash; nothing leaves your server.</p> <p>Logbook is a lightweight task &amp; logbook plugin that lives entirely inside the WordPress admin. Type a note, format it with colour / size / font / emoji, mark it done when the work is finished, restore it later if you need to revisit. Everything is stored in the site's own database &mdash; nothing leaves your server.</p>
<p>I built it for my own client work as a transparent &ldquo;here's what I did this week&rdquo; logbook, so customers can see clearly what they're paying for. It turned out to be just as useful for any small team or single user who wants notes attached to the WordPress dashboard rather than a separate app.</p> <p>I built it for my own client work as a transparent &ldquo;here's what I did this week&rdquo; logbook, so customers can see clearly what they're paying for. It turned out to be just as useful for any small team or single user who wants notes attached to the WordPress dashboard rather than a separate app.</p>
</div> </div>
@@ -125,7 +125,23 @@ function wp_notes_about_page() {
<h2>Version history</h2> <h2>Version history</h2>
<ul> <ul>
<li> <li>
<span class="ver">v3.2.0</span> &mdash; 25 May 2026 <span class="latest">latest</span><br> <span class="ver">v3.3.3</span> &mdash; 25 May 2026 <span class="latest">latest</span><br>
Pure version bump to verify the end-to-end &ldquo;Check now&rdquo; flow against a publicly-hosted Gitea repo. No functional changes. If you can see this line, you successfully pulled the test release.
</li>
<li>
<span class="ver">v3.3.2</span> &mdash; 25 May 2026<br>
Update checker now falls back to Gitea's <code>/tags</code> endpoint when no formal Release object exists for the latest tag. Means a plain <code>git tag &amp;&amp; git push --tags</code> is enough to make the &ldquo;Check now&rdquo; button report a new version &mdash; no need to manually create a Release in the Gitea web UI.
</li>
<li>
<span class="ver">v3.3.1</span> &mdash; 25 May 2026<br>
Dropped the <code>WP</code> prefix &mdash; the plugin is now just <strong>Logbook</strong>. Cleaner name, also clears a potential WordPress.org trademark-policy hurdle if/when the plugin ever lands on the marketplace.
</li>
<li>
<span class="ver">v3.3.0</span> &mdash; 25 May 2026<br>
Self-hosted update checker. Settings &rarr; Updates panel polls the Gitea repo via its JSON API, compares against the running version, and shows a download link when a new release is tagged. Includes &ldquo;View on Gitea&rdquo; and &ldquo;View all releases&rdquo; quick links. No auto-install &mdash; manual download keeps things safe.
</li>
<li>
<span class="ver">v3.2.0</span> &mdash; 25 May 2026<br>
Renamed to <strong>WP Logbook</strong> to match what the plugin is actually becoming &mdash; a work logbook for freelancers and students, not just a notes pad. Menu submenu renamed <em>My Notes</em> &rarr; <em>My Log</em>. Internal storage and slugs unchanged, no data migration. Renamed to <strong>WP Logbook</strong> to match what the plugin is actually becoming &mdash; a work logbook for freelancers and students, not just a notes pad. Menu submenu renamed <em>My Notes</em> &rarr; <em>My Log</em>. Internal storage and slugs unchanged, no data migration.
</li> </li>
<li> <li>
+3 -3
View File
@@ -1,6 +1,6 @@
<?php <?php
/** /**
* Feedback Form for WP Logbook Plugin * Feedback Form for Logbook Plugin
* *
* This file contains the HTML and AJAX handling for the feedback form. * This file contains the HTML and AJAX handling for the feedback form.
*/ */
@@ -95,7 +95,7 @@ function wp_notes_submit_feedback() {
// Example: Send feedback via email // Example: Send feedback via email
$to = 'david@icanhelp.ie'; $to = 'david@icanhelp.ie';
$subject = 'WP Logbook Feedback'; $subject = 'Logbook Feedback';
$body = "Name: $name\nEmail: $email\nMessage: $message"; $body = "Name: $name\nEmail: $email\nMessage: $message";
$headers = array('Content-Type: text/plain; charset=UTF-8'); $headers = array('Content-Type: text/plain; charset=UTF-8');
@@ -148,7 +148,7 @@ function wp_notes_submit_help() {
// Example: Send help request via email // Example: Send help request via email
$to = 'david@icanhelp.ie'; $to = 'david@icanhelp.ie';
$subject = 'WP Logbook Help Request'; $subject = 'Logbook Help Request';
$body = "Name: $name\nEmail: $email\nMessage: $message"; $body = "Name: $name\nEmail: $email\nMessage: $message";
$headers = array('Content-Type: text/plain; charset=UTF-8'); $headers = array('Content-Type: text/plain; charset=UTF-8');
+1 -1
View File
@@ -6,7 +6,7 @@ if (!defined('ABSPATH')) {
} }
/** /**
* Add required styles for WP Logbook * Add required styles for Logbook
*/ */
function wp_notes_admin_styles() { function wp_notes_admin_styles() {
?> ?>
+260 -39
View File
@@ -1,51 +1,272 @@
<?php <?php
// Add this to your main plugin file /**
require plugin_dir_path(__FILE__) . 'vendor/plugin-update-checker/plugin-update-checker.php'; * Logbook — self-hosted update checker against the Gitea repo.
*
* Polls the Gitea Releases API for the latest tagged release and
* compares its tag (e.g. "v3.3.0") against WP_NOTES_VERSION.
* Renders the result on the Settings page. NO auto-install — users
* download manually from Gitea. Safer for a self-hosted plugin and
* less surprising for admins.
*
* Result cached for 12h in a site transient so we don't hammer the
* Gitea host on every settings load. A manual "Check now" button
* force-refreshes the cache.
*/
// Include update checker - Assuming the 'vendor' directory is at the plugin root if ( ! defined( 'ABSPATH' ) ) { exit; }
// WP_NOTES_PATH is defined in your main plugin file (wp-notes.php)
// and points to the plugin's root directory.
require WP_NOTES_PATH . 'vendor/plugin-update-checker/plugin-update-checker.php';
function wp_notes_setup_updater() { // Gitea repo coordinates — change here if the repo ever moves.
if (!class_exists('YahnisElsts\PluginUpdateChecker\v5\PucFactory')) { if ( ! defined( 'WP_NOTES_GITEA_HOST' ) ) { define( 'WP_NOTES_GITEA_HOST', 'https://git.davidtkeane.com' ); }
return; if ( ! defined( 'WP_NOTES_GITEA_OWNER' ) ) { define( 'WP_NOTES_GITEA_OWNER', 'ranger' ); }
if ( ! defined( 'WP_NOTES_GITEA_REPO' ) ) { define( 'WP_NOTES_GITEA_REPO', 'a-wp-notes-v3' ); }
/**
* Convenience: full web URL of the repo / its releases page.
*/
function wp_notes_gitea_repo_url() {
return WP_NOTES_GITEA_HOST . '/' . WP_NOTES_GITEA_OWNER . '/' . WP_NOTES_GITEA_REPO;
}
function wp_notes_gitea_releases_url() {
return wp_notes_gitea_repo_url() . '/releases';
}
/**
* Hit Gitea's /api/v1/repos/<owner>/<repo>/releases/latest endpoint
* and return a normalised array, or null on irrecoverable error.
*
* Cached for 12h. Negative responses (404 = no releases yet) cached
* for 1h so a freshly-tagged release shows up quickly.
*
* @param bool $force_refresh skip the transient cache.
* @return array|null { version, html_url, download_url, body, published_at, error_code? }
*/
function wp_notes_fetch_latest_release( $force_refresh = false ) {
$cache_key = 'wp_notes_gitea_latest';
if ( ! $force_refresh ) {
$cached = get_site_transient( $cache_key );
if ( is_array( $cached ) ) { return $cached; }
} }
$myUpdateChecker = YahnisElsts\PluginUpdateChecker\v5\PucFactory::buildUpdateChecker(
'https://github.com/your-username/wp-notes/', // Change this to your GitHub repository $base_api = WP_NOTES_GITEA_HOST . '/api/v1/repos/' . WP_NOTES_GITEA_OWNER . '/' . WP_NOTES_GITEA_REPO;
__FILE__,
'wp-notes' // Try /releases/latest first — that's the canonical endpoint when David
// has published a formal Gitea Release via the web UI (with notes + zip
// assets attached).
$response = wp_remote_get( $base_api . '/releases/latest', array( 'timeout' => 8 ) );
if ( is_wp_error( $response ) ) {
return null;
}
$code = (int) wp_remote_retrieve_response_code( $response );
$body = ( $code === 200 ) ? json_decode( wp_remote_retrieve_body( $response ), true ) : null;
// Fallback: if no formal Release exists (typical for tag-only workflows
// where you `git tag v3.3.1 && git push --tags` without using the web
// UI), hit /tags instead and synthesise a release-like payload from the
// newest tag. Gitea's /tags endpoint sorts by creation order, so [0] is
// the most recent.
if ( $code !== 200 || ! is_array( $body ) || empty( $body['tag_name'] ) ) {
$tags_response = wp_remote_get( $base_api . '/tags?limit=1', array( 'timeout' => 8 ) );
if ( ! is_wp_error( $tags_response )
&& (int) wp_remote_retrieve_response_code( $tags_response ) === 200 ) {
$tags = json_decode( wp_remote_retrieve_body( $tags_response ), true );
if ( is_array( $tags ) && ! empty( $tags[0]['name'] ) ) {
$body = array(
'tag_name' => $tags[0]['name'],
'html_url' => wp_notes_gitea_repo_url() . '/src/tag/' . rawurlencode( $tags[0]['name'] ),
'body' => isset( $tags[0]['message'] ) ? $tags[0]['message'] : '',
'published_at' => isset( $tags[0]['commit']['created'] ) ? $tags[0]['commit']['created'] : null,
'assets' => array(),
);
$code = 200;
}
}
}
// Still nothing usable? Surface a friendly status and short-cache.
if ( $code !== 200 || ! is_array( $body ) || empty( $body['tag_name'] ) ) {
$info = array(
'version' => null,
'html_url' => wp_notes_gitea_releases_url(),
'download_url' => null,
'body' => '',
'published_at' => null,
'error_code' => $code,
);
set_site_transient( $cache_key, $info, HOUR_IN_SECONDS );
return $info;
}
// "v3.3.0" → "3.3.0" so version_compare() against WP_NOTES_VERSION works cleanly.
$version = ltrim( (string) $body['tag_name'], 'vV' );
// Prefer an explicit .zip asset attached to the release; fall back to
// Gitea's source-archive zip URL pattern.
$download_url = null;
if ( ! empty( $body['assets'] ) && is_array( $body['assets'] ) ) {
foreach ( $body['assets'] as $asset ) {
if ( isset( $asset['name'], $asset['browser_download_url'] )
&& substr( strtolower( $asset['name'] ), -4 ) === '.zip' ) {
$download_url = $asset['browser_download_url'];
break;
}
}
}
if ( ! $download_url ) {
$download_url = wp_notes_gitea_repo_url() . '/archive/' . rawurlencode( $body['tag_name'] ) . '.zip';
}
$info = array(
'version' => $version,
'html_url' => isset( $body['html_url'] ) ? esc_url_raw( $body['html_url'] ) : '',
'download_url' => esc_url_raw( $download_url ),
'body' => isset( $body['body'] ) ? wp_strip_all_tags( $body['body'] ) : '',
'published_at' => isset( $body['published_at'] ) ? $body['published_at'] : null,
); );
// Optional: Set the branch that contains the stable release set_site_transient( $cache_key, $info, 12 * HOUR_IN_SECONDS );
$myUpdateChecker->setBranch('main'); return $info;
} }
add_action('init', 'wp_notes_setup_updater');
// Add update checking functionality /**
function wp_notes_check_for_updates() { * Compare a fetched release against WP_NOTES_VERSION and return a
// Check if the 'check_update' GET parameter is set and the user has the capability to manage plugin options. * status payload suitable for the Settings UI.
if (isset($_GET['check_update']) && $_GET['check_update'] === '1' && current_user_can('manage_a_wp_notes_options')) { *
// Verify the nonce. The nonce name 'a_wp_notes_check_update_nonce' and action 'a_wp_notes_check_update_action' * @return array { status: 'available'|'up-to-date'|'unknown', current, latest?, message, ... }
// should match what's generated in admin-bar.php. */
if (!isset($_GET['a_wp_notes_check_update_nonce']) || !wp_verify_nonce(sanitize_key($_GET['a_wp_notes_check_update_nonce']), 'a_wp_notes_check_update_action')) { function wp_notes_update_status( $force_refresh = false ) {
wp_die('Nonce verification failed!', 'Error', array('response' => 403)); $current = defined( 'WP_NOTES_VERSION' ) ? WP_NOTES_VERSION : '0.0.0';
$latest = wp_notes_fetch_latest_release( $force_refresh );
if ( ! $latest || empty( $latest['version'] ) ) {
$msg = 'No releases tagged on the Gitea repo yet. Once a release is published, this check will start returning a version.';
if ( $latest && ! empty( $latest['error_code'] ) && (int) $latest['error_code'] !== 404 ) {
$msg = 'Could not reach Gitea (HTTP ' . (int) $latest['error_code'] . '). Try again in a few minutes.';
} }
// Trigger a manual update check return array(
wp_clean_plugins_cache(); 'status' => 'unknown',
wp_update_plugins(); 'current' => $current,
'message' => $msg,
add_settings_error( 'repo_url' => wp_notes_gitea_repo_url(),
'wp_notes',
'update_check',
'Update check completed.',
'updated'
); );
} }
}
add_action('admin_init', 'wp_notes_check_for_updates');
// Note: For the PucFactory::buildUpdateChecker, the second argument `__FILE__` currently refers to if ( version_compare( $latest['version'], $current, '>' ) ) {
// `wp-notes-updater.php`. For the library to work correctly, this should typically be the path return array(
// to your main plugin file (e.g., `WP_PLUGIN_DIR . '/a-wp-notes/a-wp-notes.php'`). 'status' => 'available',
// This is a setup detail for the update checker rather than a direct security fix from this review. 'current' => $current,
'latest' => $latest['version'],
'html_url' => $latest['html_url'],
'download_url' => $latest['download_url'],
'published_at' => $latest['published_at'],
'body' => $latest['body'],
'message' => sprintf( 'A new version (v%s) is available — you are on v%s.', $latest['version'], $current ),
);
}
return array(
'status' => 'up-to-date',
'current' => $current,
'latest' => $latest['version'],
'message' => sprintf( 'You are up to date (v%s).', $current ),
'repo_url' => wp_notes_gitea_repo_url(),
);
}
/**
* AJAX: force a fresh check, return the status payload.
*/
add_action( 'wp_ajax_wp_notes_check_updates', 'wp_notes_ajax_check_updates' );
function wp_notes_ajax_check_updates() {
if ( ! current_user_can( 'manage_options' ) ) {
wp_send_json_error( 'Insufficient permissions.', 403 );
}
check_ajax_referer( 'wp_notes_check_updates', 'nonce' );
delete_site_transient( 'wp_notes_gitea_latest' );
wp_send_json_success( wp_notes_update_status( true ) );
}
/**
* Render the "Updates" panel on the Settings page. Called from the
* settings render function via wp_notes_settings_page().
*/
function wp_notes_render_updates_panel() {
$status = wp_notes_update_status( false ); // use the cached value on initial load
$nonce = wp_create_nonce( 'wp_notes_check_updates' );
$repo_url = wp_notes_gitea_repo_url();
$rel_url = wp_notes_gitea_releases_url();
?>
<div class="wp-notes-updates" style="max-width:720px; margin-top:24px; padding:18px 20px; background:#fff; border:1px solid #ccd0d4; border-radius:4px;">
<h2 style="margin-top:0;">Updates</h2>
<p style="margin:0 0 12px;">
Logbook is self-hosted on Gitea. Click <strong>Check now</strong> to ask the repo whether there's a newer release than the one you're running.
</p>
<p id="wp-notes-update-status" style="margin:0 0 12px;">
<strong>Status:</strong>
<span id="wp-notes-update-status-text"><?php echo esc_html( $status['message'] ); ?></span>
<?php if ( $status['status'] === 'available' && ! empty( $status['download_url'] ) ) : ?>
<br>
<a href="<?php echo esc_url( $status['download_url'] ); ?>" class="button button-primary" style="margin-top:8px;">
Download v<?php echo esc_html( $status['latest'] ); ?> (.zip)
</a>
<?php if ( ! empty( $status['html_url'] ) ) : ?>
<a href="<?php echo esc_url( $status['html_url'] ); ?>" target="_blank" rel="noopener" style="margin-left:8px;">View release notes →</a>
<?php endif; ?>
<?php endif; ?>
</p>
<p style="margin:0 0 4px;">
<button type="button" id="wp-notes-check-updates-btn" class="button" data-nonce="<?php echo esc_attr( $nonce ); ?>">
↻ Check now
</button>
<a href="<?php echo esc_url( $repo_url ); ?>" target="_blank" rel="noopener" class="button" style="margin-left:6px;">View on Gitea</a>
<a href="<?php echo esc_url( $rel_url ); ?>" target="_blank" rel="noopener" class="button" style="margin-left:6px;">View all releases</a>
</p>
<p style="margin:10px 0 0; color:#646970; font-size:12px;">
Manual update path: download the .zip, deactivate the plugin in WordPress, upload via Plugins → Add New → Upload, reactivate. Your notes are stored in <code>wp_options</code> and survive the upgrade.
</p>
</div>
<script>
(function () {
var btn = document.getElementById('wp-notes-check-updates-btn');
var statusText = document.getElementById('wp-notes-update-status-text');
if (!btn || !statusText) { return; }
btn.addEventListener('click', function () {
var nonce = btn.getAttribute('data-nonce');
btn.disabled = true;
var orig = btn.textContent;
btn.textContent = '↻ Checking…';
statusText.textContent = 'Asking Gitea…';
var fd = new FormData();
fd.append('action', 'wp_notes_check_updates');
fd.append('nonce', nonce);
fetch(ajaxurl, { method: 'POST', credentials: 'same-origin', body: fd })
.then(function (r) { return r.json(); })
.then(function (res) {
if (!res || !res.success) {
statusText.textContent = (res && res.data) ? String(res.data) : 'Check failed.';
} else {
statusText.textContent = res.data.message || 'Check complete.';
if (res.data.status === 'available' && res.data.download_url) {
// Soft reload so the download / release-notes links render with the fresh data.
setTimeout(function () { window.location.reload(); }, 400);
}
}
})
.catch(function () { statusText.textContent = 'Network error — try again in a moment.'; })
.finally(function () {
btn.disabled = false;
btn.textContent = orig;
});
});
})();
</script>
<?php
}
+29 -20
View File
@@ -1,11 +1,11 @@
<?php <?php
/** /**
* WP Logbook — WordPress work-logbook plugin * Logbook — WordPress work-logbook plugin
* *
* Plugin Name: WP Logbook * Plugin Name: Logbook
* Plugin URI: https://icanhelp.ie/wp-notes * Plugin URI: https://icanhelp.ie/wp-notes
* Description: A lightweight task &amp; 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. * Description: A lightweight task &amp; 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.2.0 * Version: 3.3.3
* Requires at least: 5.0 * Requires at least: 5.0
* Requires PHP: 7.2 * Requires PHP: 7.2
* Author: IR240474 * Author: IR240474
@@ -33,7 +33,7 @@ if (!isset($wp_notes_init)) {
$wp_notes_init = true; $wp_notes_init = true;
// Plugin Constants // Plugin Constants
if (!defined('WP_NOTES_VERSION')) define('WP_NOTES_VERSION', '3.2.0'); if (!defined('WP_NOTES_VERSION')) define('WP_NOTES_VERSION', '3.3.3');
if (!defined('WP_NOTES_FILE')) define('WP_NOTES_FILE', __FILE__); 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_PATH')) define('WP_NOTES_PATH', plugin_dir_path(__FILE__));
if (!defined('WP_NOTES_URL')) define('WP_NOTES_URL', plugin_dir_url(__FILE__)); if (!defined('WP_NOTES_URL')) define('WP_NOTES_URL', plugin_dir_url(__FILE__));
@@ -44,7 +44,7 @@ if (!isset($wp_notes_init)) {
if (!function_exists('wp_notes_log_error')) { if (!function_exists('wp_notes_log_error')) {
function wp_notes_log_error($message) { function wp_notes_log_error($message) {
if (defined('WP_DEBUG') && WP_DEBUG === true) { if (defined('WP_DEBUG') && WP_DEBUG === true) {
error_log('[WP Logbook] ' . $message); error_log('[Logbook] ' . $message);
} }
} }
} }
@@ -162,14 +162,15 @@ if (defined('WP_NOTES_PATH')) {
require_once WP_NOTES_PATH . 'inc/wp-notes-feedback.php'; require_once WP_NOTES_PATH . 'inc/wp-notes-feedback.php';
require_once WP_NOTES_PATH . 'inc/wp-notes-display.php'; require_once WP_NOTES_PATH . 'inc/wp-notes-display.php';
require_once WP_NOTES_PATH . 'inc/wp-notes-styles.php'; require_once WP_NOTES_PATH . 'inc/wp-notes-styles.php';
require_once WP_NOTES_PATH . 'inc/wp-notes-updater.php';
} }
// Admin Menu // Admin Menu
function wp_notes_admin_menu() { function wp_notes_admin_menu() {
add_menu_page( add_menu_page(
'WP Logbook', 'Logbook',
'WP Logbook', 'Logbook',
'manage_options', 'manage_options',
'wp-notes', 'wp-notes',
'wp_notes_page_callback', 'wp_notes_page_callback',
@@ -178,7 +179,7 @@ function wp_notes_admin_menu() {
); );
// "My Log" — the main landing submenu. Same slug as the parent // "My Log" — the main landing submenu. Same slug as the parent
// menu so clicking either WP Logbook or My Log lands on the same // menu so clicking either Logbook or My Log lands on the same
// central dashboard (the parent's wp_notes_page_callback already // central dashboard (the parent's wp_notes_page_callback already
// renders form + active list + completed list). // renders form + active list + completed list).
// //
@@ -217,7 +218,7 @@ function wp_notes_admin_menu() {
'wp_notes_import_export_page' 'wp_notes_import_export_page'
); );
// About submenu — the WP Logbook brand is already carried by the // About submenu — the Logbook brand is already carried by the
// parent menu, so the submenu can be plain-spoken. // parent menu, so the submenu can be plain-spoken.
add_submenu_page( add_submenu_page(
'wp-notes', 'wp-notes',
@@ -290,7 +291,7 @@ function wp_notes_settings_page() {
settings_errors('wp_notes_settings'); settings_errors('wp_notes_settings');
?> ?>
<div class="wrap"> <div class="wrap">
<h1>WP Logbook Settings</h1> <h1>Logbook Settings</h1>
<form method="post" action="options.php"> <form method="post" action="options.php">
<?php <?php
settings_fields('wp_notes_settings'); settings_fields('wp_notes_settings');
@@ -298,13 +299,21 @@ function wp_notes_settings_page() {
submit_button(); submit_button();
?> ?>
</form> </form>
<?php
// Updates panel — checks the Gitea repo for a newer release.
// Defined in inc/wp-notes-updater.php.
if ( function_exists( 'wp_notes_render_updates_panel' ) ) {
wp_notes_render_updates_panel();
}
?>
</div> </div>
<?php <?php
} }
// Settings section callback // Settings section callback
function wp_notes_section_callback() { function wp_notes_section_callback() {
echo '<p>Configure default settings for WP Logbook.</p>'; echo '<p>Configure default settings for Logbook.</p>';
} }
// Font setting callback // Font setting callback
@@ -696,8 +705,8 @@ function wp_notes_ajax_submit_feedback() {
]; ];
$topics_pretty = array_map(function ($t) use ($topic_labels) { return $topic_labels[$t] ?? $t; }, $topics); $topics_pretty = array_map(function ($t) use ($topic_labels) { return $topic_labels[$t] ?? $t; }, $topics);
$subject = sprintf('[%s] WP Logbook feedback from %s', $site, $user->display_name ?: $user->user_login); $subject = sprintf('[%s] Logbook feedback from %s', $site, $user->display_name ?: $user->user_login);
$body = "Feedback received via WP Logbook → About page\n"; $body = "Feedback received via Logbook → About page\n";
$body .= str_repeat('-', 48) . "\n\n"; $body .= str_repeat('-', 48) . "\n\n";
$body .= 'From: ' . ($user->display_name ?: $user->user_login) . ' <' . $user->user_email . ">\n"; $body .= 'From: ' . ($user->display_name ?: $user->user_login) . ' <' . $user->user_email . ">\n";
$body .= 'Site: ' . home_url() . "\n"; $body .= 'Site: ' . home_url() . "\n";
@@ -811,7 +820,7 @@ function wp_notes_save_edit() {
} }
/** /**
* Main WP Logbook page — central hub for note management * Main Logbook page — central hub for note management
*/ */
function wp_notes_page_callback() { function wp_notes_page_callback() {
if (!current_user_can('edit_posts')) { if (!current_user_can('edit_posts')) {
@@ -831,7 +840,7 @@ function wp_notes_page_callback() {
?> ?>
<div class="wrap"> <div class="wrap">
<!-- Header Section with WordPress Admin Styling --> <!-- Header Section with WordPress Admin Styling -->
<h1 class="wp-heading-inline">WP Logbook</h1> <h1 class="wp-heading-inline">Logbook</h1>
<span class="page-title-action">v<?php echo esc_html(WP_NOTES_VERSION); ?></span> <span class="page-title-action">v<?php echo esc_html(WP_NOTES_VERSION); ?></span>
<hr class="wp-header-end"> <hr class="wp-header-end">
@@ -843,7 +852,7 @@ function wp_notes_page_callback() {
<!-- Note Creation Form with WordPress Admin Styling --> <!-- Note Creation Form with WordPress Admin Styling -->
<div class="postbox"> <div class="postbox">
<div class="postbox-header"> <div class="postbox-header">
<h2 class="hndle">Add New Note</h2> <h2 class="hndle">New Log Entry</h2>
</div> </div>
<div class="inside"> <div class="inside">
<form method="post" class="wp-notes-form"> <form method="post" class="wp-notes-form">
@@ -995,7 +1004,7 @@ function wp_notes_page_callback() {
</style> </style>
<!-- Notes List --> <!-- Notes List -->
<h2>Notes Todo List:</h2> <h2>Log entries</h2>
<!-- Active Notes List --> <!-- Active Notes List -->
<div class="wp-notes-active" id="active-notes"> <div class="wp-notes-active" id="active-notes">
<?php wp_notes_display_notes('active'); ?> <?php wp_notes_display_notes('active'); ?>
@@ -1387,7 +1396,7 @@ function wp_notes_dashboard_widget() {
function wp_notes_add_dashboard_widgets() { function wp_notes_add_dashboard_widgets() {
wp_add_dashboard_widget( wp_add_dashboard_widget(
'wp_notes_dashboard_widget', 'wp_notes_dashboard_widget',
'WP Logbook', 'Logbook',
'wp_notes_dashboard_widget' 'wp_notes_dashboard_widget'
); );
} }
@@ -1398,7 +1407,7 @@ function wp_notes_register_cpt() {
$labels = array( $labels = array(
'name' => __('Notes', 'a-wp-notes'), 'name' => __('Notes', 'a-wp-notes'),
'singular_name' => __('Note', 'a-wp-notes'), 'singular_name' => __('Note', 'a-wp-notes'),
'menu_name' => __('WP Logbook', 'a-wp-notes'), 'menu_name' => __('Logbook', 'a-wp-notes'),
'add_new' => __('Add New', 'a-wp-notes'), 'add_new' => __('Add New', 'a-wp-notes'),
'add_new_item' => __('Add New Note', 'a-wp-notes'), 'add_new_item' => __('Add New Note', 'a-wp-notes'),
'edit_item' => __('Edit Note', 'a-wp-notes'), 'edit_item' => __('Edit Note', 'a-wp-notes'),
@@ -1631,7 +1640,7 @@ function wp_notes_migration_notice() {
?> ?>
<div class="notice notice-info is-dismissible"> <div class="notice notice-info is-dismissible">
<p> <p>
<?php _e('WP Logbook needs to migrate your existing notes to the new storage system.', 'a-wp-notes'); ?> <?php _e('Logbook needs to migrate your existing notes to the new storage system.', 'a-wp-notes'); ?>
<a href="<?php echo esc_url(admin_url('admin.php?page=wp-notes-settings&action=migrate')); ?>" class="button button-primary"> <a href="<?php echo esc_url(admin_url('admin.php?page=wp-notes-settings&action=migrate')); ?>" class="button button-primary">
<?php _e('Start Migration', 'a-wp-notes'); ?> <?php _e('Start Migration', 'a-wp-notes'); ?>
</a> </a>