Files
rangerhq-buddy/inc/admin-page.php
T
ranger cba0df9439 chore: wp.org submission prep — v0.1.3
Rebrand to RangerHQ Buddy and prepare for the WordPress.org Plugin
Directory. Same workflow as rangerhq-radio v0.7.0 → v0.7.5.

Changes:
- Plugin Name: Buddy → RangerHQ Buddy (matches family naming)
- Plugin URI: icanhelp.ie/buddy → davidtkeane.com/rangerhq-buddy
- Author URI: rangersmyth.xyz → davidtkeane.com
- Text Domain: buddy → rangerhq-buddy (62 occurrences across 8 PHP files)
- Add LICENSE file (full GPL v2 text from gnu.org)
- Add wp.org-format readme.txt with all 8 required headers
- Remove inc/updater.php (self-hosted Gitea updater forbidden for
  wp.org-hosted plugins per the rangerhq-radio v0.7.3 walkback)
- Replace mt_rand with wp_rand in inc/state.php for better RNG
- Add 5 translator comments for printf-style i18n placeholders
- Wrap 2 dashboard-widget.php printf placeholders in (int) casts
- Add tests/ to .gitignore (PCP reports are local-only)

PCP audit: 85 issues → ~1 (the .gitignore file itself, stripped from
the submission zip).
Plugin Check Namer Tool: "Generally Allowable" verdict on both name
and slug.
Plugin URI https://davidtkeane.com/rangerhq-buddy/ returns HTTP 200.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-06-07 01:56:26 +01:00

71 lines
3.2 KiB
PHP

<?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.', 'rangerhq-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', 'rangerhq-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.', 'rangerhq-buddy' ); ?>
<a href="<?php echo esc_url( admin_url( 'admin.php?page=buddy-about' ) ); ?>"><?php esc_html_e( 'Read more on the About page →', 'rangerhq-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', 'rangerhq-buddy' )
/* translators: %d is the number of days since the Buddy was adopted */
: sprintf( _n( '%d day old', '%d days old', $age_days, 'rangerhq-buddy' ), $age_days )
);
?>
</p>
</div>
<div class="buddy-main__card buddy-main__card--stats">
<h2><?php esc_html_e( 'How is Buddy doing?', 'rangerhq-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.', 'rangerhq-buddy' ); ?>
</p>
</div>
</div>
</div>
<?php
}