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:
@@ -0,0 +1,69 @@
|
||||
<?php
|
||||
/**
|
||||
* Buddy main admin page — renders the bigger view at WP Admin → Buddy
|
||||
* → My Buddy. Same data as the dashboard widget but with more room
|
||||
* for Phase B (interactions), Phase D (species picker), etc. to slot
|
||||
* in cleanly later.
|
||||
*
|
||||
* Discipline anchored from Logbook v3 lessons: one H1 per page, no
|
||||
* nested toggles, no duplicate sections. Each card owns one concern.
|
||||
*/
|
||||
|
||||
if ( ! defined( 'ABSPATH' ) ) { exit; }
|
||||
|
||||
/**
|
||||
* Top-level "Buddy → My Buddy" page renderer. Hooked via
|
||||
* add_menu_page() in buddy.php.
|
||||
*/
|
||||
function buddy_render_main_page() {
|
||||
if ( ! current_user_can( 'read' ) ) {
|
||||
wp_die( esc_html__( 'You do not have permission to view Buddy.', 'buddy' ) );
|
||||
}
|
||||
|
||||
$state = buddy_get_state();
|
||||
$mood = buddy_overall_mood( $state );
|
||||
$tone = buddy_mood_label( $mood );
|
||||
?>
|
||||
<div class="wrap">
|
||||
<h1 class="wp-heading-inline">🐾 <?php esc_html_e( 'Buddy', 'buddy' ); ?></h1>
|
||||
<span class="page-title-action">v<?php echo esc_html( BUDDY_VERSION ); ?></span>
|
||||
<hr class="wp-header-end">
|
||||
|
||||
<p class="description" style="max-width: 720px;">
|
||||
<?php esc_html_e( 'Your dashboard pet. Keep its stats up — eventually they will reflect how well you take care of your WordPress site.', 'buddy' ); ?>
|
||||
<a href="<?php echo esc_url( admin_url( 'admin.php?page=buddy-about' ) ); ?>"><?php esc_html_e( 'Read more on the About page →', 'buddy' ); ?></a>
|
||||
</p>
|
||||
|
||||
<div class="buddy-main">
|
||||
<div class="buddy-main__card buddy-main__card--pet">
|
||||
<?php buddy_render_sprite( $state['species'], $tone['tone'], 'lg' ); ?>
|
||||
<h2 class="buddy-main__name">
|
||||
<?php echo esc_html( $state['name'] ); ?>
|
||||
<span class="buddy-main__mood buddy-main__mood--<?php echo esc_attr( $tone['tone'] ); ?>">
|
||||
<?php echo esc_html( $tone['label'] ); ?>
|
||||
</span>
|
||||
</h2>
|
||||
<p class="buddy-main__age">
|
||||
<?php
|
||||
$age_seconds = max( 0, time() - (int) $state['born_at'] );
|
||||
$age_days = (int) floor( $age_seconds / DAY_IN_SECONDS );
|
||||
echo esc_html(
|
||||
$age_days < 1
|
||||
? __( 'Adopted today', 'buddy' )
|
||||
: sprintf( _n( '%d day old', '%d days old', $age_days, 'buddy' ), $age_days )
|
||||
);
|
||||
?>
|
||||
</p>
|
||||
</div>
|
||||
|
||||
<div class="buddy-main__card buddy-main__card--stats">
|
||||
<h2><?php esc_html_e( 'How is Buddy doing?', 'buddy' ); ?></h2>
|
||||
<?php buddy_render_stats_bars( $state ); ?>
|
||||
<p class="buddy-main__note">
|
||||
<?php esc_html_e( 'Coming soon: feed, play, clean, and sleep actions to keep Buddy thriving. Also: stats will react to your WordPress site\'s health.', 'buddy' ); ?>
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<?php
|
||||
}
|
||||
Reference in New Issue
Block a user