117eaddaa0
Reviewer flagged inc/about.php line 19 — an inline <style> block — asking us to use wp_enqueue_style instead. Per their hint that the team may not list every instance of an issue, fixed the entire CSS inline-styling pattern across the plugin: - inc/about.php: <style> block (lines 19-59) → moved to buddy.css - inc/about.php: <span style="color:#646970; font-weight:400;"> → .buddy-about-intro__version class - inc/about.php: <p style="margin-bottom:0;"> → .buddy-about-intro__cta - inc/settings.php: <form style="..."> → .buddy-settings-form class - inc/settings.php: <h2 style="margin-top:0;"> → scoped under form class - inc/admin-page.php: <p style="max-width:720px;"> → .buddy-admin-description utility class The only remaining inline style is in inc/dashboard-widget.php at the stat-bar width — that is a runtime-computed %d value, legitimately inline. The buddy.css file was already enqueued on the About / Settings / Admin / Dashboard pages via the existing buddy_enqueue_admin_assets function, so no new enqueue logic was needed. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
71 lines
3.2 KiB
PHP
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 buddy-admin-description">
|
|
<?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
|
|
}
|