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>
78 lines
2.8 KiB
PHP
78 lines
2.8 KiB
PHP
<?php
|
|
/**
|
|
* Buddy settings page — placeholder shell for Phase A. Settings will
|
|
* grow in later phases:
|
|
* Phase B: cooldown timers
|
|
* Phase C: decay tick interval
|
|
* Phase D: species picker (currently only one available)
|
|
* Phase E: site-health integration toggle
|
|
*
|
|
* For v0.1.0 this page exists to (a) host the Updates panel from the
|
|
* Logbook-style update checker, and (b) let the user rename their
|
|
* Buddy.
|
|
*/
|
|
|
|
if ( ! defined( 'ABSPATH' ) ) { exit; }
|
|
|
|
/**
|
|
* Handle the rename form POST. Capability-gated to anyone who can
|
|
* read (every WP user) since each user owns their own Buddy.
|
|
*/
|
|
add_action( 'admin_init', 'buddy_handle_rename_post' );
|
|
function buddy_handle_rename_post() {
|
|
if ( empty( $_POST['buddy_rename_submit'] ) ) { return; }
|
|
if ( ! current_user_can( 'read' ) ) { return; }
|
|
if ( ! isset( $_POST['buddy_rename_nonce'] )
|
|
|| ! wp_verify_nonce( sanitize_key( wp_unslash( $_POST['buddy_rename_nonce'] ) ), 'buddy_rename' ) ) {
|
|
return;
|
|
}
|
|
$new_name = isset( $_POST['buddy_name'] ) ? sanitize_text_field( wp_unslash( $_POST['buddy_name'] ) ) : '';
|
|
if ( $new_name === '' || mb_strlen( $new_name ) > 32 ) { return; }
|
|
buddy_update_state( array( 'name' => $new_name ) );
|
|
|
|
add_action( 'admin_notices', function () {
|
|
printf(
|
|
'<div class="notice notice-success is-dismissible"><p>%s</p></div>',
|
|
esc_html__( 'Buddy renamed.', 'rangerhq-buddy' )
|
|
);
|
|
} );
|
|
}
|
|
|
|
function buddy_render_settings_page() {
|
|
if ( ! current_user_can( 'read' ) ) {
|
|
wp_die( esc_html__( 'You do not have permission to view this page.', 'rangerhq-buddy' ) );
|
|
}
|
|
$state = buddy_get_state();
|
|
?>
|
|
<div class="wrap">
|
|
<h1><?php esc_html_e( 'Buddy Settings', 'rangerhq-buddy' ); ?></h1>
|
|
|
|
<form method="post" class="buddy-settings-form">
|
|
<?php wp_nonce_field( 'buddy_rename', 'buddy_rename_nonce' ); ?>
|
|
<h2><?php esc_html_e( 'Name', 'rangerhq-buddy' ); ?></h2>
|
|
<p>
|
|
<label for="buddy_name"><?php esc_html_e( 'What is your Buddy called?', 'rangerhq-buddy' ); ?></label><br>
|
|
<input type="text"
|
|
name="buddy_name"
|
|
id="buddy_name"
|
|
value="<?php echo esc_attr( $state['name'] ); ?>"
|
|
maxlength="32"
|
|
class="regular-text">
|
|
</p>
|
|
<p>
|
|
<button type="submit" name="buddy_rename_submit" class="button button-primary">
|
|
<?php esc_html_e( 'Save name', 'rangerhq-buddy' ); ?>
|
|
</button>
|
|
</p>
|
|
</form>
|
|
|
|
<?php
|
|
// Updates panel — defined in inc/updater.php.
|
|
if ( function_exists( 'buddy_render_updates_panel' ) ) {
|
|
buddy_render_updates_panel();
|
|
}
|
|
?>
|
|
</div>
|
|
<?php
|
|
}
|