chore: initial commit — Buddy v0.1.0 (Phase A complete)

Buddy is born. First commit of a new standalone WordPress plugin —
the spiritual successor to the tamagotchi that once lived inside
A-WP-Notes v1.1.5 (gracefully retired). Rebuilt from scratch with
all the v3-discipline lessons baked in from day one.

PHASE A — pet exists
- Dashboard widget at WP Admin → Dashboard showing SVG character +
  name + mood label + four stats bars.
- Dedicated admin page at WP Admin → Buddy → My Buddy (bigger view).
- About page with side-by-side intro + plain-prose cards (Logbook
  About-page pattern carried forward).
- Settings page with name-rename form + Updates panel.
- Per-user state in user_meta key buddy_state (each WP admin gets
  their own pet, no shared state).
- Inline SVG sprite renderer with three mood tones (happy/neutral/
  sad) and three sizes (sm/md/lg). CSS keyframe animations: bobbing
  + periodic blinking. Zero image files.
- Self-hosted update checker wired up from commit 1, ported from
  Logbook v3.3.5: /releases/latest with /tags?limit=1 fallback,
  12h success cache / 1h negative cache. UI on Settings page.
- dashicons-pets admin-menu icon — literal paw-print, brand match.

ARCHITECTURE LOCKED FROM COMMIT 1
- Single-word brand name "Buddy" — no WP prefix, no future rebrand.
- Public GPL v2+ Gitea repo (ranger/a-buddy).
- Constants prefix BUDDY_*, function prefix buddy_*, text domain
  buddy. Clean naming throughout — none of Logbook's wp-notes-*
  historical-artifact baggage.
- Single H1 per admin page, no nested toggle boxes, no duplicate
  sections — Tier-1 discipline carried forward from Logbook.
- All assets local (inline SVG, plain CSS), no third-party CDN,
  no Gravatar-style external pings.

NOT IN THIS RELEASE (planned)
- Phase B — Feed/Play/Clean/Sleep interactions + cooldown timers.
- Phase C — WP-cron decay + "Buddy is hungry" dismissible notices
  (port the persistent-dismissal pattern from Logbook).
- Phase D — Multiple species (dog, dragon, sprite), per-species
  personality phrases.
- Phase E — Site-health hook: pet stats react to wp_get_site_health()
  results. The killer feature.
- Phase F — Pro tier (€2.99 lifetime) with custom skins + multi-pet.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-05-25 10:23:57 +01:00
commit 48e97862a6
12 changed files with 1135 additions and 0 deletions
+70
View File
@@ -0,0 +1,70 @@
<?php
/**
* Buddy sprite rendering — pure inline SVG, no image files, no GIFs,
* no sprite sheets. CSS animations live alongside in buddy.css.
*
* Phase A: one species ("default") — a small round yellow chibi
* character with eyes and a smile. Phase D will branch this into
* dog / dragon / sprite / etc.
*
* Mood tone changes the expression: 'happy' = open smile, 'neutral'
* = flat mouth, 'sad' = downturned. Eyes blink via CSS keyframes
* regardless of tone (it's always alive).
*/
if ( ! defined( 'ABSPATH' ) ) { exit; }
/**
* Echo the inline SVG for a buddy character.
*
* @param string $species Currently only 'default'.
* @param string $tone 'happy' | 'neutral' | 'sad'
* @param string $size 'sm' (64px), 'md' (96px), 'lg' (160px). Just sets a class.
*/
function buddy_render_sprite( $species = 'default', $tone = 'happy', $size = 'md' ) {
$species = sanitize_key( $species );
$tone = in_array( $tone, array( 'happy', 'neutral', 'sad' ), true ) ? $tone : 'happy';
$size = in_array( $size, array( 'sm', 'md', 'lg' ), true ) ? $size : 'md';
// Mouth path varies by tone.
$mouth = array(
'happy' => 'M 42 60 Q 50 70 58 60', // smile
'neutral' => 'M 42 64 L 58 64', // flat
'sad' => 'M 42 66 Q 50 58 58 66', // frown
);
$mouth_d = $mouth[ $tone ];
// Body fill: subtle shift by tone.
$body_fill = ( $tone === 'sad' ) ? '#d8b04a' : '#f4c64e';
?>
<svg class="buddy-sprite buddy-sprite--<?php echo esc_attr( $size ); ?> buddy-sprite--<?php echo esc_attr( $tone ); ?>"
viewBox="0 0 100 100"
xmlns="http://www.w3.org/2000/svg"
role="img"
aria-label="<?php echo esc_attr( sprintf( __( 'Buddy is %s', 'buddy' ), $tone ) ); ?>">
<!-- body -->
<circle cx="50" cy="55" r="32" fill="<?php echo esc_attr( $body_fill ); ?>" stroke="#c9941d" stroke-width="2" />
<!-- left eye -->
<g class="buddy-sprite__eye buddy-sprite__eye--left">
<circle cx="40" cy="46" r="5" fill="#2c3338" />
<circle cx="41.2" cy="45" r="1.5" fill="#fff" />
</g>
<!-- right eye -->
<g class="buddy-sprite__eye buddy-sprite__eye--right">
<circle cx="60" cy="46" r="5" fill="#2c3338" />
<circle cx="61.2" cy="45" r="1.5" fill="#fff" />
</g>
<!-- mouth -->
<path d="<?php echo esc_attr( $mouth_d ); ?>"
stroke="#2c3338" stroke-width="2" fill="none" stroke-linecap="round" />
<!-- cheeks (only when happy or neutral) -->
<?php if ( $tone !== 'sad' ) : ?>
<circle cx="33" cy="58" r="3" fill="#f4866a" opacity="0.55" />
<circle cx="67" cy="58" r="3" fill="#f4866a" opacity="0.55" />
<?php endif; ?>
<!-- tiny feet -->
<ellipse cx="42" cy="88" rx="6" ry="3" fill="#c9941d" />
<ellipse cx="58" cy="88" rx="6" ry="3" fill="#c9941d" />
</svg>
<?php
}