0c20833fe5
The plugin's identity has shifted over the day's work — from a notes
pad to a work-logbook with time tracking, earnings, and a Wallet
tile on the v4 roadmap. "WP Notes" undersold what it had become and
collided semantically with WordPress's notes-as-memos connotation;
"WP Logbook" matches both the freelancer use case ("logbook for
clients") and the student use case ("logbook for teachers"), and
matches the exact word the plugin's own About-page intro had been
using all day.
USER-FACING CHANGES
- Plugin Name header: A-WP-Notes → WP Logbook
- Description header rewritten to reflect the work-logbook framing
- Admin menu top-level: WP Notes → WP Logbook
- Admin sidebar submenu: My Notes → My Log (matches new parent —
reads cleanly as "WP Logbook → My Log")
- Admin bar count menu: WP Notes (N) → WP Logbook (N)
- Dashboard widget title: WP Notes → WP Logbook
- Settings page H1: WP Notes Settings → WP Logbook Settings
- Main page H1: WP Notes → WP Logbook
- About page: every brand mention updated; "Go to WP Notes →" CTA
now reads "Go to My Log →" to match the new submenu
- About page version history now leads with v3.2.0 (this release)
as latest, demotes v3.1.0 to the previous entry
- CPT menu_name label: WP Notes → WP Logbook (cosmetic only — CPT
hidden from admin UI since the duplicate-form fix in v3.1.0)
- Migration notice text updated
- Email-feedback subject + body intro updated
- Legacy feedback.php subjects (WP Notes Feedback / Help Request)
→ WP Logbook variants
- error_log() prefix [WP Notes] → [WP Logbook]
ZERO-MIGRATION COMMITMENT — these stay unchanged
- All wp_notes_* function names
- All WP_NOTES_* constants
- All DB option keys (wp_notes, wp_done_notes, wp_notes_settings,
wp_notes_migration_completed, wp_notes_version,
wp_notes_dismissed_empty_active|completed)
- All user_meta keys
- Admin page slug 'wp-notes' (preserves bookmarks, admin-bar
#new-note anchor, and the legacy ?page=wp-notes-create redirect)
- Plugin text domain 'a-wp-notes'
- File and directory names (wp-notes.php, inc/wp-notes-*.php,
assets/wp-notes-banner.jpg)
- Gitea repo name (ranger/a-wp-notes-v3) — David can rename on the
Gitea side separately if he wants
The rename is purely user-facing strings. Existing installs see the
new name appear after a plugin file refresh, with zero behaviour
change. No re-activation needed.
VERSION BUMP
- wp-notes.php header Version: 3.1.0 → 3.2.0
- WP_NOTES_VERSION constant: 3.1.0 → 3.2.0
- CHANGELOG: new [3.2.0] section that bundles the rename with the
post-3.1.0 unreleased work (About-page rewrite, feedback form)
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
161 lines
5.8 KiB
PHP
161 lines
5.8 KiB
PHP
<?php
|
|
/**
|
|
* Feedback Form for WP Logbook Plugin
|
|
*
|
|
* This file contains the HTML and AJAX handling for the feedback form.
|
|
*/
|
|
|
|
// Enqueue Feedback Form Script
|
|
function wp_notes_enqueue_feedback_script() {
|
|
wp_enqueue_script('wp-notes-feedback', WP_NOTES_URL . 'js/wp-notes-feedback.js', array('jquery'), null, true);
|
|
wp_localize_script('wp-notes-feedback', 'wp_notes_feedback_vars', array(
|
|
'ajax_url' => admin_url('admin-ajax.php'),
|
|
'nonce' => wp_create_nonce('wp_notes_feedback_nonce')
|
|
));
|
|
}
|
|
add_action('admin_enqueue_scripts', 'wp_notes_enqueue_feedback_script');
|
|
|
|
// Feedback Form HTML
|
|
function wp_notes_feedback_form() {
|
|
?>
|
|
<div id="feedback-form-improve" style="display: none;">
|
|
<h2>Leave Feedback</h2>
|
|
<form id="wp-notes-feedback-form" method="post">
|
|
<label for="feedback_name">Your Name:</label><br>
|
|
<input type="text" id="feedback_name" name="feedback_name" required><br><br>
|
|
|
|
<label for="feedback_email">Your Email:</label><br>
|
|
<input type="email" id="feedback_email" name="feedback_email" required><br><br>
|
|
|
|
<label for="feedback_message">Your Feedback:</label><br>
|
|
<textarea id="feedback_message" name="feedback_message" rows="5" required></textarea><br><br>
|
|
|
|
<input type="submit" value="Submit Feedback" class="button button-primary">
|
|
</form>
|
|
</div>
|
|
|
|
<div id="feedback-form-help" style="display: none;">
|
|
<h2>Need Help?</h2>
|
|
<form id="wp-notes-help-form" method="post">
|
|
<label for="help_name">Your Name:</label><br>
|
|
<input type="text" id="help_name" name="help_name" required><br><br>
|
|
|
|
<label for="help_email">Your Email:</label><br>
|
|
<input type="email" id="help_email" name="help_email" required><br><br>
|
|
|
|
<label for="help_message">Your Message:</label><br>
|
|
<textarea id="help_message" name="help_message" rows="5" required></textarea><br><br>
|
|
|
|
<input type="submit" value="Submit Help Request" class="button button-primary">
|
|
</form>
|
|
</div>
|
|
<?php
|
|
}
|
|
|
|
// Handle Feedback Form Submission
|
|
function wp_notes_submit_feedback() {
|
|
// 1. Nonce Check (already good)
|
|
if (!check_ajax_referer('wp_notes_feedback_nonce', 'nonce', false)) {
|
|
wp_send_json_error('Invalid nonce.');
|
|
return;
|
|
}
|
|
|
|
// 2. Capability Check (e.g., any logged-in user can submit feedback)
|
|
if (!current_user_can('read')) { // 'read' is a basic capability for any logged-in user
|
|
wp_send_json_error('You do not have permission to submit feedback.', 403);
|
|
return;
|
|
}
|
|
|
|
// Validate required fields
|
|
$required_fields = ['feedback_name', 'feedback_email', 'feedback_message'];
|
|
foreach ($required_fields as $field) {
|
|
if (!isset($_POST[$field]) || empty($_POST[$field])) {
|
|
wp_send_json_error("Missing required field: $field");
|
|
return;
|
|
}
|
|
}
|
|
|
|
// 3. Sanitize and validate data (already good)
|
|
$name = sanitize_text_field($_POST['feedback_name']);
|
|
$email = sanitize_email($_POST['feedback_email']);
|
|
$message = sanitize_textarea_field($_POST['feedback_message']);
|
|
|
|
// Save feedback to database or send via email
|
|
$feedback = array(
|
|
'name' => $name,
|
|
'email' => $email,
|
|
'message' => $message,
|
|
'timestamp' => current_time('mysql')
|
|
);
|
|
|
|
// Example: Save feedback to an option
|
|
$feedbacks = get_option('wp_notes_feedbacks', array());
|
|
$feedbacks[] = $feedback;
|
|
update_option('wp_notes_feedbacks', $feedbacks);
|
|
|
|
// Example: Send feedback via email
|
|
$to = 'david@icanhelp.ie';
|
|
$subject = 'WP Logbook Feedback';
|
|
$body = "Name: $name\nEmail: $email\nMessage: $message";
|
|
$headers = array('Content-Type: text/plain; charset=UTF-8');
|
|
|
|
wp_mail($to, $subject, $body, $headers);
|
|
|
|
wp_send_json_success('Feedback submitted successfully.');
|
|
}
|
|
add_action('wp_ajax_wp_notes_submit_feedback', 'wp_notes_submit_feedback');
|
|
|
|
// Handle Help Form Submission
|
|
function wp_notes_submit_help() {
|
|
// 1. Nonce Check (already good)
|
|
if (!check_ajax_referer('wp_notes_feedback_nonce', 'nonce', false)) {
|
|
wp_send_json_error('Invalid nonce.');
|
|
return;
|
|
}
|
|
|
|
// 2. Capability Check (e.g., any logged-in user can request help)
|
|
if (!current_user_can('read')) { // 'read' is a basic capability for any logged-in user
|
|
wp_send_json_error('You do not have permission to submit a help request.', 403);
|
|
return;
|
|
}
|
|
|
|
// Validate required fields
|
|
$required_fields = ['help_name', 'help_email', 'help_message'];
|
|
foreach ($required_fields as $field) {
|
|
if (!isset($_POST[$field]) || empty($_POST[$field])) {
|
|
wp_send_json_error("Missing required field: $field");
|
|
return;
|
|
}
|
|
}
|
|
|
|
// 3. Sanitize and validate data (already good)
|
|
$name = sanitize_text_field($_POST['help_name']);
|
|
$email = sanitize_email($_POST['help_email']);
|
|
$message = sanitize_textarea_field($_POST['help_message']);
|
|
|
|
// Save help request to database or send via email
|
|
$help_request = array(
|
|
'name' => $name,
|
|
'email' => $email,
|
|
'message' => $message,
|
|
'timestamp' => current_time('mysql')
|
|
);
|
|
|
|
// Example: Save help request to an option
|
|
$help_requests = get_option('wp_notes_help_requests', array());
|
|
$help_requests[] = $help_request;
|
|
update_option('wp_notes_help_requests', $help_requests);
|
|
|
|
// Example: Send help request via email
|
|
$to = 'david@icanhelp.ie';
|
|
$subject = 'WP Logbook Help Request';
|
|
$body = "Name: $name\nEmail: $email\nMessage: $message";
|
|
$headers = array('Content-Type: text/plain; charset=UTF-8');
|
|
|
|
wp_mail($to, $subject, $body, $headers);
|
|
|
|
wp_send_json_success('Help request submitted successfully.');
|
|
}
|
|
add_action('wp_ajax_wp_notes_submit_help', 'wp_notes_submit_help');
|
|
|
|
?>
|