930e605b2d
Single-pass UX cleanup of the main WP Notes admin page. Functionality
unchanged; the page is shorter, has one H1, and stops contradicting
itself.
CHANGES
- Single H1 on the page (was five different H1s).
- Welcome/about content collapsed from THREE on-page surfaces (top
dismissible notice + nested toggle + Show/Close button row) to one
single description line linking to the dedicated About page where
the long copy already lives.
- Two duplicate "Toggle Welcome Section" buttons with the SAME label
but different targets — both removed.
- Embedded "What's New v3.0.0" changelog block deleted: it was
hard-coded to v3.0.0 while the plugin reports v3.0.2. The real
history is in CHANGELOG.md.
- "Buy me a coffee" button moved from page header to page footer —
promo shouldn't be the first thing under the page title.
- Invalid HTML cleaned up (li outside ul, p wrapping div/ul) by way
of removing the welcome blob that contained it.
- Dead bulk-action UI removed: per-row checkboxes and "Select all"
header in both wp_notes_display_notes() and wp_notes_list_table()
rendered but nothing acted on the selection. Removed with inline
comments marking the spot for when real bulk-actions land. Edit
form colspan adjusted to match the new column count.
- ~80 lines of inline style+script for the about-box dismissal
removed (localStorage tracking, show/hide handlers, two style
blocks). WordPress's notice notice-info is-dismissible + user-meta
is the right path if a banner needs to return.
- toggleSection() JS helper removed (no toggles remain).
- Small CSS additions to inc/wp-notes-styles.php for the header
banner and footer-support link.
ALSO FIXED
- PHP 8.2 deprecation: ${size}px → {$size}px in the dashboard
list-table render. ${var} interpolation is deprecated since 8.2
and will hard-error in 9.0.
NET DIFF: wp-notes.php -213 lines, total -111 lines across 4 files
(plus a new CHANGELOG entry). Storage model unchanged.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
118 lines
5.8 KiB
PHP
118 lines
5.8 KiB
PHP
<?php
|
|
// inc/wp-notes-display.php
|
|
|
|
if (!defined('ABSPATH')) {
|
|
exit;
|
|
}
|
|
|
|
/**
|
|
* Display notes list with consistent styling and functionality
|
|
*
|
|
* @param string $type Either 'active' or 'completed'
|
|
* @return void
|
|
*/
|
|
function wp_notes_display_notes($type = 'active') {
|
|
// Get notes and validate user permissions
|
|
if (!current_user_can('edit_posts')) {
|
|
return;
|
|
}
|
|
|
|
$notes = ($type === 'active') ? get_option('wp_notes', array()) : get_option('wp_done_notes', array());
|
|
$page_anchor = ($type === 'active') ? '#active-notes' : '#completed-notes';
|
|
$section_title = ($type === 'active') ? 'Active Notes' : 'Completed Notes';
|
|
|
|
if (empty($notes)) {
|
|
echo '<div class="wp-notes-empty notice notice-info">';
|
|
echo '<p>' . esc_html__('No ' . ($type === 'active' ? 'active' : 'completed') . ' notes found.', 'a-wp-notes') . '</p>';
|
|
echo '</div>';
|
|
return;
|
|
}
|
|
|
|
// Section header with status count
|
|
$status_class = ($type === 'active') ? 'status-active' : 'status-completed';
|
|
echo '<div class="wp-notes-section">';
|
|
echo '<h2 class="wp-notes-section-title">';
|
|
echo '<span class="' . $status_class . '">' . esc_html($section_title) . '</span>';
|
|
echo '<span class="note-count">(' . count($notes) . ')</span>';
|
|
echo '</h2>';
|
|
|
|
echo '<div class="wp-notes-list" id="' . esc_attr($type . '-notes') . '">';
|
|
echo '<table class="wp-list-table widefat fixed striped has-hover">';
|
|
echo '<thead><tr>';
|
|
/* No checkbox column — bulk actions are not wired up. Re-add this <th>
|
|
and the matching <td> below when bulk select/delete/done is built. */
|
|
echo '<th scope="col" class="manage-column column-primary">' . esc_html__('Note', 'a-wp-notes') . '</th>';
|
|
echo '<th scope="col" class="manage-column">' . esc_html__('Author', 'a-wp-notes') . '</th>';
|
|
echo '<th scope="col" class="manage-column">' . esc_html__('Created', 'a-wp-notes') . '</th>';
|
|
if ($type === 'completed') {
|
|
echo '<th scope="col" class="manage-column">' . esc_html__('Completed By', 'a-wp-notes') . '</th>';
|
|
echo '<th scope="col" class="manage-column">' . esc_html__('Completed On', 'a-wp-notes') . '</th>';
|
|
}
|
|
echo '<th scope="col" class="manage-column">' . esc_html__('Actions', 'a-wp-notes') . '</th>';
|
|
echo '</tr></thead><tbody>';
|
|
|
|
foreach ($notes as $key => $note) {
|
|
$text = esc_html($note['text']);
|
|
$color = esc_attr($note['color'] ?? '#000000');
|
|
$size = esc_attr($note['size'] ?? '14');
|
|
$font = esc_attr($note['font'] ?? 'Arial');
|
|
$timestamp = esc_html($note['timestamp'] ?? current_time('mysql'));
|
|
$author = esc_html($note['author_name'] ?? 'Unknown');
|
|
|
|
echo '<tr>';
|
|
echo '<td style="color: ' . $color . '; font-size: ' . $size . 'px; font-family: ' . $font . ';">' . $text . '</td>';
|
|
echo '<td>' . $author . '</td>';
|
|
echo '<td>' . $timestamp . '</td>';
|
|
|
|
if ($type === 'completed') {
|
|
echo '<td>' . esc_html($note['completed_by'] ?? 'Unknown') . '</td>';
|
|
echo '<td>' . esc_html($note['completed_on'] ?? 'Unknown') . '</td>';
|
|
}
|
|
|
|
echo '<td class="actions">';
|
|
if ($type === 'active') {
|
|
echo '<button type="button" class="button edit-note" data-note-id="' . esc_attr($key) . '">' .
|
|
esc_html__('Edit', 'a-wp-notes') . '</button> ';
|
|
echo '<form method="post" style="display:inline;">';
|
|
echo '<input type="hidden" name="note_id" value="' . esc_attr($key) . '">';
|
|
echo '<button type="submit" name="mark_done" class="button">' .
|
|
esc_html__('Mark as Done', 'a-wp-notes') . '</button>';
|
|
echo '</form>';
|
|
} else {
|
|
echo '<form method="post" style="display:inline;">';
|
|
echo '<input type="hidden" name="note_id" value="' . esc_attr($key) . '">';
|
|
echo '<button type="submit" name="restore_note" class="button">' .
|
|
esc_html__('Restore', 'a-wp-notes') . '</button>';
|
|
echo '</form>';
|
|
}
|
|
echo '</td></tr>';
|
|
|
|
// Edit form (for active notes only)
|
|
if ($type === 'active') {
|
|
/* Active rows have 4 columns: Note, Author, Created, Actions
|
|
(no longer a checkbox column). Edit form spans all 4. */
|
|
echo '<tr id="edit-note-' . esc_attr($key) . '" style="display:none;"><td colspan="4">';
|
|
echo '<form class="edit-note-form" data-note-id="' . esc_attr($key) . '">';
|
|
wp_nonce_field('wp_notes_nonce', '_wpnonce');
|
|
echo '<input type="hidden" name="note_id" value="' . esc_attr($key) . '">';
|
|
echo '<textarea name="new_text" class="large-text">' . esc_textarea($text) . '</textarea><br>';
|
|
echo '<div class="formatting-options">';
|
|
echo '<input type="color" name="edit_color" value="' . esc_attr($color) . '">';
|
|
echo '<input type="number" name="edit_size" value="' . esc_attr($size) . '" min="8" max="72">';
|
|
echo '<select name="edit_font">';
|
|
echo '<option value="Arial" ' . selected('Arial', $font, false) . '>Arial</option>';
|
|
echo '<option value="Helvetica" ' . selected('Helvetica', $font, false) . '>Helvetica</option>';
|
|
echo '<option value="Times New Roman" ' . selected('Times New Roman', $font, false) . '>Times New Roman</option>';
|
|
echo '<option value="Verdana" ' . selected('Verdana', $font, false) . '>Verdana</option>';
|
|
echo '</select>';
|
|
echo '</div>';
|
|
echo '<button type="submit" class="button button-primary">' . esc_html__('Save', 'a-wp-notes') . '</button>';
|
|
echo '<button type="button" class="button cancel-edit">' . esc_html__('Cancel', 'a-wp-notes') . '</button>';
|
|
echo '</form>';
|
|
echo '</td></tr>';
|
|
}
|
|
}
|
|
|
|
echo '</tbody></table></div>';
|
|
}
|