Restore to commit 74e578279624c6045ca440a3459ebfa1f8d54191

This commit is contained in:
southseact-3d
2026-02-07 20:32:41 +00:00
commit ed67b7741b
252 changed files with 99814 additions and 0 deletions

View File

@@ -0,0 +1,985 @@
/**
* PC Changelog Manager - Public Styles
*
* @package PCChangelogManager
*/
/* ========================================
CSS Variables
======================================== */
:root {
/* Primary Colors */
--pc-clm-primary: #2271b1;
--pc-clm-primary-hover: #135e96;
--pc-clm-primary-light: #e8f4fd;
/* Semantic Colors */
--pc-clm-success: #000000;
--pc-clm-success-light: #ffffff;
--pc-clm-warning: #dba617;
--pc-clm-warning-light: #fef3cd;
--pc-clm-error: #000000;
--pc-clm-error-light: #ffffff;
--pc-clm-info: #000000;
--pc-clm-info-light: #ffffff;
/* Category Colors */
--pc-clm-category-new-features: #000000;
--pc-clm-category-bug-fixes: #333333;
--pc-clm-category-improvements: #666666;
--pc-clm-category-security: #dba617;
--pc-clm-category-deprecated: #888888;
--pc-clm-category-removed: #aaaaaa;
/* Typography */
--pc-clm-font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen-Sans, Ubuntu, Cantarell, 'Helvetica Neue', sans-serif;
--pc-clm-font-size-base: 16px;
--pc-clm-font-size-sm: 14px;
--pc-clm-font-size-lg: 18px;
--pc-clm-font-size-xl: 24px;
--pc-clm-font-size-2xl: 32px;
/* Spacing */
--pc-clm-spacing-xs: 4px;
--pc-clm-spacing-sm: 8px;
--pc-clm-spacing-md: 16px;
--pc-clm-spacing-lg: 24px;
--pc-clm-spacing-xl: 32px;
--pc-clm-spacing-2xl: 48px;
/* Border Radius */
--pc-clm-radius-sm: 4px;
--pc-clm-radius-md: 8px;
--pc-clm-radius-lg: 12px;
/* Shadows */
--pc-clm-shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
--pc-clm-shadow-md: 0 4px 6px rgba(0, 0, 0, 0.07);
--pc-clm-shadow-lg: 0 10px 15px rgba(0, 0, 0, 0.1);
/* Transitions */
--pc-clm-transition-fast: 150ms ease;
--pc-clm-transition-base: 250ms ease;
--pc-clm-transition-slow: 350ms ease;
}
.pc-clm-archive-container {
font-family: var(--pc-clm-font-family);
font-size: var(--pc-clm-font-size-base);
line-height: 1.6;
color: #000000;
padding: 0;
max-width: 100%;
margin: 0 auto;
}
.pc-clm-single-entry {
font-family: var(--pc-clm-font-family);
font-size: var(--pc-clm-font-size-base);
line-height: 1.6;
color: #000000;
background-color: #ffffff;
padding: var(--pc-clm-spacing-lg);
border-radius: var(--pc-clm-radius-md);
border: 2px solid #000000;
max-width: 900px;
margin: 20px auto;
}
.pc-clm-archive-header {
text-align: left;
margin-bottom: 40px;
padding-bottom: 20px;
border-bottom: 2px solid #000000;
}
.pc-clm-archive-title {
font-size: var(--pc-clm-font-size-2xl);
font-weight: 800;
margin: 0 0 12px 0;
color: #000000;
letter-spacing: -0.02em;
}
.pc-clm-archive-header .archive-description {
font-size: var(--pc-clm-font-size-lg);
color: #000000;
margin: 0;
background: transparent;
}
/* ========================================
Archive Content
======================================== */
.pc-clm-archive-content {
margin-bottom: 32px;
min-height: 100px;
}
.pc-clm-archive-content:empty {
display: none;
}
/* ========================================
Changelog Entry
======================================== */
.pc-clm-entry {
position: relative;
margin-bottom: var(--pc-clm-spacing-md);
background-color: #ffffff;
border-radius: var(--pc-clm-radius-md);
border: 2px solid #000000;
border-left: 4px solid #000000;
transition: all var(--pc-clm-transition-base);
overflow: hidden;
max-width: 100%;
}
.pc-clm-entry-wrapper {
padding: var(--pc-clm-spacing-lg);
background-color: #ffffff;
}
.pc-clm-entry {
position: relative;
margin-bottom: var(--pc-clm-spacing-md);
background-color: #ffffff;
border-radius: var(--pc-clm-radius-md);
border: 2px solid #000000;
border-left: 4px solid #000000;
transition: all var(--pc-clm-transition-base);
overflow: hidden;
}
.pc-clm-archive-container .pc-clm-entry {
max-width: 100%;
}
.pc-clm-entry:hover {
border-color: #000000;
box-shadow: var(--pc-clm-shadow-lg);
transform: translateY(-2px);
}
.pc-clm-entry-wrapper:hover {
box-shadow: var(--pc-clm-shadow-lg);
transform: translateY(-2px);
}
.pc-clm-entry-inner {
padding: var(--pc-clm-spacing-lg);
background-color: #ffffff;
border-radius: var(--pc-clm-radius-md);
}
.pc-clm-entry.pc-clm-category-new-features { border-left-color: var(--pc-clm-category-new-features); }
.pc-clm-entry.pc-clm-category-bug-fixes { border-left-color: var(--pc-clm-category-bug-fixes); }
.pc-clm-entry.pc-clm-category-improvements { border-left-color: var(--pc-clm-category-improvements); }
.pc-clm-entry.pc-clm-category-security { border-left-color: var(--pc-clm-category-security); }
.pc-clm-entry.pc-clm-category-deprecated { border-left-color: var(--pc-clm-category-deprecated); }
.pc-clm-entry.pc-clm-category-removed { border-left-color: var(--pc-clm-category-removed); }
.pc-clm-entry:last-child {
margin-bottom: 0;
}
.pc-clm-entry-content-wrapper {
background-color: #ffffff;
padding: 12px;
border-radius: var(--pc-clm-radius-md);
margin-top: 8px;
}
.pc-clm-entry-content {
background-color: #ffffff;
padding: 12px;
}
.pc-clm-single-entry .pc-clm-entry-content {
background-color: transparent;
padding: 0;
margin-top: 16px;
}
.pc-clm-single-entry .pc-clm-entry-title {
font-size: 28px;
font-weight: 700;
margin-bottom: 16px;
}
.pc-clm-entry-title {
font-size: var(--pc-clm-font-size-lg);
font-weight: 700;
margin: 0 0 var(--pc-clm-spacing-xs) 0;
line-height: 1.3;
}
.pc-clm-entry-title a {
color: #000000;
text-decoration: none;
}
.pc-clm-entry-title a:hover {
color: #666666;
}
.pc-clm-entry-meta {
display: flex;
flex-wrap: wrap;
align-items: center;
gap: 12px;
margin-bottom: var(--pc-clm-spacing-sm);
}
/* Version Badge */
.pc-clm-version-badge {
display: inline-block;
padding: 2px 8px;
font-size: 12px;
font-weight: 700;
font-family: 'SFMono-Regular', Consolas, 'Liberation Mono', Menlo, monospace;
color: #ffffff;
background-color: #000000;
border-radius: var(--pc-clm-radius-sm);
}
/* Release Date */
.pc-clm-release-date,
.pc-clm-date {
font-size: 13px;
color: #000000;
font-weight: 600;
}
/* Category Badge */
.pc-clm-category-badge {
display: inline-block;
padding: 2px 10px;
font-size: 11px;
font-weight: 700;
text-transform: uppercase;
letter-spacing: 0.03em;
border-radius: 20px;
background-color: #f5f5f5;
color: #000000;
border: 1px solid #000000;
}
.pc-clm-category-badge.pc-clm-category-new-features { background-color: #f5f5f5; color: #000000; border-color: #000000; }
.pc-clm-category-badge.pc-clm-category-bug-fixes { background-color: #e0e0e0; color: #333333; border-color: #333333; }
.pc-clm-category-badge.pc-clm-category-improvements { background-color: #d0d0d0; color: #666666; border-color: #666666; }
.pc-clm-category-badge.pc-clm-category-security { background-color: #ffffff; color: #dba617; border-color: #dba617; }
/* ========================================
Entry Content
======================================== */
.pc-clm-entry-content {
font-size: 15px;
line-height: 1.6;
color: #000000;
font-weight: 500;
background-color: #ffffff;
padding: 12px;
}
.pc-clm-entry-content p {
margin: 0 0 var(--pc-clm-spacing-sm) 0;
}
.pc-clm-entry-content p:last-child {
margin-bottom: 0;
}
.pc-clm-entry-content ul,
.pc-clm-entry-content ol {
margin: 0 0 var(--pc-clm-spacing-md) 0;
padding-left: 20px;
}
.pc-clm-entry-content li {
margin-bottom: 4px;
}
/* ========================================
Entry Header
======================================== */
.pc-clm-entry-header {
display: flex;
justify-content: space-between;
align-items: flex-start;
margin-bottom: var(--pc-clm-spacing-sm);
gap: var(--pc-clm-spacing-md);
}
.pc-clm-entry-meta {
flex: 1;
display: flex;
flex-wrap: wrap;
align-items: center;
gap: 12px;
margin-bottom: 0;
}
/* ========================================
Upvote Section
======================================== */
.pc-clm-upvote-section {
display: flex;
flex-direction: column;
align-items: center;
gap: 4px;
flex-shrink: 0;
}
.pc-clm-upvote-btn {
display: flex;
align-items: center;
gap: 4px;
padding: 8px 12px;
background-color: #ffffff;
border: 2px solid #000000;
border-radius: 20px;
color: #000000;
font-size: 12px;
font-weight: 700;
cursor: pointer;
transition: all var(--pc-clm-transition-fast);
outline: none;
position: relative;
min-width: 70px;
justify-content: center;
}
.pc-clm-upvote-btn:not(:disabled):hover {
background-color: #000000;
border-color: #000000;
color: #ffffff;
transform: translateY(-2px);
box-shadow: var(--pc-clm-shadow-md);
}
.pc-clm-upvote-btn:not(:disabled):active {
transform: translateY(0);
box-shadow: none;
}
.pc-clm-upvote-btn.voted {
background-color: #000000;
border-color: #000000;
color: #ffffff;
}
.pc-clm-upvote-btn.loading {
opacity: 0.7;
}
.pc-clm-upvote-btn.loading .pc-clm-upvote-icon {
animation: pulse 1s ease-in-out infinite;
}
.pc-clm-upvote-icon svg {
width: 16px;
height: 16px;
transition: transform var(--pc-clm-transition-fast);
}
.pc-clm-upvote-btn:hover .pc-clm-upvote-icon svg {
transform: scale(1.1);
}
.pc-clm-upvote-count {
font-weight: 700;
min-width: 16px;
text-align: center;
}
.pc-clm-upvote-label {
font-size: 10px;
color: #000000;
text-transform: uppercase;
letter-spacing: 0.03em;
font-weight: 600;
white-space: nowrap;
}
.pc-clm-upvote-btn.voted + .pc-clm-upvote-label {
color: #000000;
font-weight: 700;
}
/* Loading animation */
@keyframes pulse {
0%, 100% {
opacity: 1;
}
50% {
opacity: 0.5;
}
}
/* ========================================
Entry Footer
======================================== */
.pc-clm-entry-footer {
margin-top: 12px;
padding-top: 12px;
border-top: 1px solid #f0f0f0;
}
.pc-clm-read-more {
display: inline-flex;
align-items: center;
gap: 4px;
font-size: 13px;
font-weight: 600;
color: #000000;
text-decoration: none;
transition: color 0.15s ease;
}
.pc-clm-read-more:hover {
color: #666666;
}
.pc-clm-read-more .dashicons {
font-size: 14px;
width: 14px;
height: 14px;
}
.pc-clm-read-more:hover .dashicons {
transform: translateX(2px);
}
/* ========================================
No Entries State
======================================== */
.pc-clm-no-entries,
.pc-clm-widget-empty {
text-align: center;
padding: 48px 20px;
color: #000000;
background-color: #ffffff;
border-radius: 6px;
border: 2px solid #000000;
font-weight: 600;
margin: 20px 0;
}
.pc-clm-no-entries p,
.pc-clm-widget-empty p {
margin: 0;
}
/* ========================================
Shortcode Styles
======================================== */
.pc-clm-shortcode-wrapper {
font-family: var(--pc-clm-font-family);
}
.pc-clm-shortcode-title {
font-size: var(--pc-clm-font-size-xl);
font-weight: 700;
margin: 0 0 var(--pc-clm-spacing-lg) 0;
color: #000000;
}
/* ========================================
Widget Styles
======================================== */
.pc-clm-widget-list {
list-style: none;
margin: 0;
padding: 0;
}
.pc-clm-widget-entry {
padding: var(--pc-clm-spacing-md) 0;
border-bottom: 1px solid #000000;
}
.pc-clm-widget-entry:last-child {
border-bottom: none;
padding-bottom: 0;
}
.pc-clm-widget-entry-header {
display: flex;
align-items: center;
gap: var(--pc-clm-spacing-sm);
margin-bottom: var(--pc-clm-spacing-xs);
}
.pc-clm-widget-version {
font-family: 'Menlo', 'Monaco', 'Consolas', monospace;
font-size: 12px;
font-weight: 600;
color: #000000;
}
.pc-clm-widget-date {
font-size: 12px;
color: #000000;
}
.pc-clm-widget-entry-title {
font-size: var(--pc-clm-font-size-sm);
font-weight: 600;
color: #000000;
text-decoration: none;
transition: color var(--pc-clm-transition-fast);
display: block;
line-height: 1.4;
}
.pc-clm-widget-entry-title:hover {
color: #000000;
}
.pc-clm-widget-category {
display: inline-block;
margin-top: var(--pc-clm-spacing-xs);
font-size: 10px;
font-weight: 700;
text-transform: uppercase;
letter-spacing: 0.3px;
padding: 2px 6px;
border-radius: 3px;
background-color: #000000;
color: #ffffff;
}
/* ========================================
Pagination
======================================== */
.pc-clm-archive-container .pagination {
display: flex;
justify-content: center;
align-items: center;
gap: 8px;
margin-top: 40px;
padding-top: 24px;
border-top: 2px solid #000000;
}
.pc-clm-archive-container .page-numbers {
display: inline-flex;
align-items: center;
justify-content: center;
min-width: 36px;
height: 36px;
padding: 0 8px;
font-size: 14px;
font-weight: 600;
color: #000000;
background-color: #ffffff;
border: 2px solid #000000;
border-radius: 4px;
text-decoration: none;
transition: all 0.15s ease;
}
.pc-clm-archive-container .page-numbers:hover {
background-color: #000000;
border-color: #000000;
color: #ffffff;
}
.pc-clm-archive-container .page-numbers.current {
background-color: #000000;
border-color: #000000;
color: #ffffff;
}
.pc-clm-archive-container .page-numbers.dots {
border: none;
background: none;
color: #000000;
}
.pc-clm-archive-container .prev,
.pc-clm-archive-container .next {
min-width: auto;
padding: 0 16px;
}
/* ========================================
Dark Mode Support
======================================== */
@media (prefers-color-scheme: dark) {
.pc-clm-archive-container {
color: #000000;
background-color: #ffffff;
}
.pc-clm-archive-header {
border-bottom-color: #000000;
}
.pc-clm-archive-title {
color: #000000;
}
.pc-clm-archive-header .archive-description {
color: #000000;
}
.pc-clm-entry {
background-color: #ffffff;
border-color: #000000;
}
.pc-clm-entry:hover {
box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}
.pc-clm-entry-title a {
color: #000000;
}
.pc-clm-entry-title a:hover {
color: #000000;
}
.pc-clm-entry-content {
color: #000000;
}
.pc-clm-read-more {
color: #000000;
}
.pc-clm-read-more:hover {
color: #000000;
}
.pc-clm-no-entries,
.pc-clm-widget-empty {
background-color: #ffffff;
border-color: #000000;
color: #000000;
}
.pc-clm-archive-container .page-numbers {
background-color: #ffffff;
border-color: #000000;
color: #000000;
}
.pc-clm-archive-container .page-numbers:hover {
background-color: #000000;
color: #ffffff;
}
.pc-clm-archive-container .pagination {
border-top-color: #000000;
}
.pc-clm-version-badge {
background-color: #000000;
color: #ffffff;
}
.pc-clm-release-date,
.pc-clm-date {
color: #000000;
}
.pc-clm-widget-entry {
border-bottom-color: #000000;
}
.pc-clm-widget-entry-title {
color: #000000;
}
.pc-clm-widget-entry-title:hover {
color: #000000;
}
.pc-clm-category-new-features {
background-color: #000000;
color: #ffffff;
}
.pc-clm-category-bug-fixes {
background-color: #333333;
color: #ffffff;
}
.pc-clm-category-improvements {
background-color: #666666;
color: #ffffff;
}
.pc-clm-category-security {
background-color: #dba617;
color: #000000;
}
.pc-clm-category-deprecated {
background-color: #888888;
color: #ffffff;
}
.pc-clm-category-removed {
background-color: #aaaaaa;
color: #ffffff;
}
/* Upvote section dark mode */
.pc-clm-upvote-btn {
background-color: #ffffff;
border-color: #000000;
color: #000000;
}
.pc-clm-upvote-btn:not(:disabled):hover {
background-color: #000000;
border-color: #000000;
color: #ffffff;
}
}
.pc-clm-upvote-btn.voted {
background-color: #000000;
border-color: #000000;
color: #ffffff;
}
.pc-clm-upvote-label {
color: #000000;
}
.pc-clm-upvote-btn.voted + .pc-clm-upvote-label {
color: #000000;
}
/* Notifications dark mode */
.pc-clm-notification {
background-color: #ffffff;
border: 2px solid #000000;
color: #000000;
}
}
/* ========================================
Responsive Design
======================================== */
@media screen and (max-width: 768px) {
.pc-clm-archive-container {
padding: 0 12px;
}
.pc-clm-archive-header {
margin-bottom: 20px;
padding: 20px 0;
}
.pc-clm-archive-title {
font-size: 22px;
}
.pc-clm-entry {
padding: 16px;
}
.pc-clm-entry-title {
font-size: 17px;
}
.pc-clm-entry-meta {
gap: 6px;
}
.pc-clm-version-badge {
padding: 3px 8px;
font-size: 12px;
}
.pc-clm-category-badge {
padding: 3px 8px;
font-size: 10px;
}
.pc-clm-entry-header {
flex-direction: column;
align-items: stretch;
gap: var(--pc-clm-spacing-sm);
}
.pc-clm-upvote-section {
align-self: flex-end;
}
}
@media screen and (max-width: 480px) {
.pc-clm-archive-container {
padding: 0 8px;
}
.pc-clm-archive-title {
font-size: 20px;
}
.pc-clm-entry {
padding: 14px;
}
.pc-clm-entry-title {
font-size: 16px;
}
.pc-clm-entry-meta {
flex-direction: column;
align-items: flex-start;
gap: 6px;
}
.pc-clm-version-badge,
.pc-clm-release-date {
display: inline-block;
}
.pc-clm-upvote-section {
align-self: flex-end;
margin-top: var(--pc-clm-spacing-sm);
}
.pc-clm-upvote-btn {
min-width: 70px;
padding: 8px 12px;
}
}
/* ========================================
Accessibility
======================================== */
@media (prefers-reduced-motion: reduce) {
.pc-clm-entry {
transition: none;
}
.pc-clm-entry:hover {
transform: none;
}
.pc-clm-read-more .dashicons {
transition: none;
}
.pc-clm-read-more:hover .dashicons {
transform: none;
}
}
@media (prefers-contrast: high) {
.pc-clm-entry {
border-width: 2px;
}
.pc-clm-version-badge {
border: 1px solid currentColor;
}
.pc-clm-category-badge {
border: 1px solid currentColor;
}
}
/* ========================================
Notifications
======================================== */
.pc-clm-notification {
position: fixed;
top: 20px;
right: 20px;
padding: 12px 16px;
background-color: #fff;
border-radius: var(--pc-clm-radius-md);
border-left: 4px solid;
box-shadow: var(--pc-clm-shadow-lg);
font-size: 14px;
font-weight: 500;
z-index: 10000;
transform: translateX(100%);
opacity: 0;
transition: all var(--pc-clm-transition-base);
max-width: 300px;
}
.pc-clm-notification.show {
transform: translateX(0);
opacity: 1;
}
.pc-clm-notification-success {
border-left-color: var(--pc-clm-success);
color: var(--pc-clm-success);
}
.pc-clm-notification-error {
border-left-color: var(--pc-clm-error);
color: var(--pc-clm-error);
}
.pc-clm-notification-info {
border-left-color: var(--pc-clm-info);
color: var(--pc-clm-info);
}
/* Focus visible for keyboard navigation */
.pc-clm-entry-title a:focus-visible,
.pc-clm-read-more:focus-visible,
.pc-clm-upvote-btn:focus-visible {
outline: 2px solid var(--pc-clm-primary);
outline-offset: 2px;
}
/* ========================================
Print Styles
======================================== */
@media print {
.pc-clm-archive-container {
max-width: 100%;
padding: 0;
}
.pc-clm-entry {
box-shadow: none;
border: 1px solid #ccc;
page-break-inside: avoid;
}
.pc-clm-entry:hover {
transform: none;
box-shadow: none;
}
.pc-clm-read-more {
display: none;
}
.pc-clm-category-badge {
border: 1px solid #000;
}
}

View File

@@ -0,0 +1,115 @@
/**
* PC Changelog Manager - Public JavaScript
*
* @package PCChangelogManager
*/
(function($) {
'use strict';
$(document).ready(function() {
// Handle upvote button clicks
$(document).on('click', '.pc-clm-upvote-btn', function(e) {
e.preventDefault();
var $button = $(this);
var postId = $button.data('post-id');
var $count = $button.find('.pc-clm-upvote-count');
var $label = $button.siblings('.pc-clm-upvote-label');
var originalCount = parseInt($count.text());
// Prevent multiple clicks
if ($button.prop('disabled')) {
return;
}
$button.prop('disabled', true);
// Show loading state
$button.addClass('loading');
// Make AJAX request
$.ajax({
url: pc_clm_ajax.ajax_url,
type: 'POST',
data: {
action: 'pc_clm_upvote',
post_id: postId,
nonce: pc_clm_ajax.nonce
},
success: function(response) {
if (response.success) {
// Update the count
$count.text(response.data.vote_count);
// Update label
var labelText = response.data.vote_count === 1 ? 'upvote' : 'upvotes';
$label.text(labelText);
// Mark as voted
$button.addClass('voted');
$button.prop('disabled', true);
// Show success message (optional)
showNotification(response.data.message, 'success');
} else {
// Show error message
showNotification(response.data.message, 'error');
// Re-enable button if not already voted
if (!response.data.voted) {
$button.prop('disabled', false);
}
}
},
error: function(xhr, status, error) {
console.error('Upvote error:', error);
showNotification('An error occurred. Please try again.', 'error');
$button.prop('disabled', false);
},
complete: function() {
$button.removeClass('loading');
}
});
});
// Helper function to show notifications
function showNotification(message, type) {
var $notification = $('<div class="pc-clm-notification pc-clm-notification-' + type + '">' + message + '</div>');
// Add to page
$('body').append($notification);
// Show with animation
setTimeout(function() {
$notification.addClass('show');
}, 100);
// Auto hide after 3 seconds
setTimeout(function() {
$notification.removeClass('show');
setTimeout(function() {
$notification.remove();
}, 300);
}, 3000);
}
// Handle keyboard accessibility for upvote buttons
$(document).on('keydown', '.pc-clm-upvote-btn', function(e) {
if (e.key === 'Enter' || e.key === ' ') {
e.preventDefault();
$(this).click();
}
});
// Add hover effects for upvote buttons
$('.pc-clm-upvote-btn:not(.voted)').hover(
function() {
$(this).addClass('hover');
},
function() {
$(this).removeClass('hover');
}
);
});
})(jQuery);

View File

@@ -0,0 +1,133 @@
<?php
/**
* Changelog Archive Template
*
* @package PCChangelogManager
*/
// Prevent direct access to file.
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
// Let theme handle header/footer
get_header();
?>
<div class="site-content" role="main">
<div class="pc-clm-archive-container">
<header class="pc-clm-archive-header">
<h1 class="pc-clm-archive-title">
<?php
$archive_title = post_type_archive_title( '', false );
if ( $archive_title ) {
echo esc_html( $archive_title );
} else {
esc_html_e( 'Changelog', 'pc-changelog-manager-abc123' );
}
?>
</h1>
<?php if ( $description = get_the_archive_description() ) : ?>
<div class="pc-clm-archive-description"><?php echo $description; ?></div>
<?php endif; ?>
</header>
<div class="pc-clm-archive-content">
<?php
$post_type = new PC_CLM_Post_Type();
if ( have_posts() ) :
while ( have_posts() ) :
the_post();
$post_id = get_the_ID();
$version = $post_type->get_meta( $post_id, 'version_number' );
$release_date = $post_type->get_meta( $post_id, 'release_date' );
$category = $post_type->get_meta( $post_id, 'category' );
$categories = $post_type->get_categories();
$category_name = isset( $categories[ $category ] ) ? $categories[ $category ] : $category;
$upvote_count = (int) get_post_meta( $post_id, '_pc_clm_upvotes', true );
$has_voted = false;
$ip_address = $_SERVER['REMOTE_ADDR'];
$user_id = get_current_user_id();
$voted_key = $user_id ? "pc_clm_voted_user_{$user_id}" : "pc_clm_voted_ip_{$ip_address}";
$voted_posts = get_transient( $voted_key );
if ( $voted_posts && in_array( $post_id, $voted_posts ) ) {
$has_voted = true;
}
$entry_classes = array( 'pc-clm-entry' );
if ( $category ) {
$entry_classes[] = 'pc-clm-category-' . $category;
}
?>
<article id="post-<?php the_ID(); ?>" <?php post_class( $entry_classes ); ?>>
<div class="pc-clm-entry-wrapper">
<div class="pc-clm-entry-header">
<div class="pc-clm-entry-meta">
<?php if ( $version ) : ?>
<span class="pc-clm-version-badge"><?php echo esc_html( $version ); ?></span>
<?php endif; ?>
<?php if ( $release_date ) : ?>
<span class="pc-clm-release-date"><?php echo esc_html( date_i18n( get_option( 'date_format' ), strtotime( $release_date ) ) ); ?></span>
<?php endif; ?>
<?php if ( $category ) : ?>
<span class="pc-clm-category-badge pc-clm-category-<?php echo esc_attr( $category ); ?>"><?php echo esc_html( $category_name ); ?></span>
<?php endif; ?>
</div>
<div class="pc-clm-upvote-section">
<button class="pc-clm-upvote-btn <?php echo $has_voted ? 'voted' : ''; ?>"
data-post-id="<?php echo esc_attr( $post_id ); ?>"
<?php echo $has_voted ? 'disabled' : ''; ?>>
<span class="pc-clm-upvote-icon">
<svg width="16" height="16" viewBox="0 0 24 24" fill="currentColor">
<path d="M12 2l2.4 7.4h7.6l-6 4.6 2.3 7.4-6.3-4.6-6.3 4.6 2.3-7.4-6-4.6h7.6z"/>
</svg>
</span>
<span class="pc-clm-upvote-count"><?php echo esc_html( $upvote_count ); ?></span>
</button>
<span class="pc-clm-upvote-label"><?php echo esc_html( _n( 'upvote', 'upvotes', $upvote_count, 'pc-changelog-manager-abc123' ) ); ?></span>
</div>
</div>
<div class="pc-clm-entry-content-wrapper">
<h3 class="pc-clm-entry-title">
<a href="<?php the_permalink(); ?>"><?php the_title(); ?></a>
</h3>
<div class="pc-clm-entry-content">
<?php the_excerpt(); ?>
</div>
</div>
</div>
</article>
<?php
endwhile;
the_posts_pagination(
array(
'prev_text' => __( 'Previous', 'pc-changelog-manager-abc123' ),
'next_text' => __( 'Next', 'pc-changelog-manager-abc123' ),
'before_page_number' => '<span class="meta-nav screen-reader-text">' . __( 'Page', 'pc-changelog-manager-abc123' ) . ' </span>',
)
);
else :
?>
<div class="pc-clm-no-entries">
<p><?php esc_html_e( 'No changelog entries found.', 'pc-changelog-manager-abc123' ); ?></p>
</div>
<?php
endif;
?>
</div>
</div>
</div>
<?php get_footer(); ?>

View File

@@ -0,0 +1,99 @@
<?php
/**
* Single Changelog Template
*
* @package PCChangelogManager
*/
// Prevent direct access to file.
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
// Let theme handle header/footer
get_header();
?>
<div class="site-content" role="main">
<?php
while ( have_posts() ) :
the_post();
$post_id = get_the_ID();
$post_type = new PC_CLM_Post_Type();
$version = $post_type->get_meta( $post_id, 'version_number' );
$release_date = $post_type->get_meta( $post_id, 'release_date' );
$category = $post_type->get_meta( $post_id, 'category' );
$categories = $post_type->get_categories();
$category_name = isset( $categories[ $category ] ) ? $categories[ $category ] : $category;
$upvote_count = (int) get_post_meta( $post_id, '_pc_clm_upvotes', true );
$has_voted = false;
$ip_address = $_SERVER['REMOTE_ADDR'];
$user_id = get_current_user_id();
$voted_key = $user_id ? "pc_clm_voted_user_{$user_id}" : "pc_clm_voted_ip_{$ip_address}";
$voted_posts = get_transient( $voted_key );
if ( $voted_posts && in_array( $post_id, $voted_posts ) ) {
$has_voted = true;
}
$entry_classes = array( 'pc-clm-entry', 'pc-clm-single-entry' );
if ( $category ) {
$entry_classes[] = 'pc-clm-category-' . $category;
}
?>
<article id="post-<?php the_ID(); ?>" <?php post_class( $entry_classes ); ?>>
<div class="pc-clm-entry-wrapper">
<div class="pc-clm-entry-header">
<div class="pc-clm-entry-meta">
<?php if ( $version ) : ?>
<span class="pc-clm-version-badge"><?php echo esc_html( $version ); ?></span>
<?php endif; ?>
<?php if ( $release_date ) : ?>
<span class="pc-clm-release-date"><?php echo esc_html( date_i18n( get_option( 'date_format' ), strtotime( $release_date ) ) ); ?></span>
<?php endif; ?>
<?php if ( $category ) : ?>
<span class="pc-clm-category-badge pc-clm-category-<?php echo esc_attr( $category ); ?>"><?php echo esc_html( $category_name ); ?></span>
<?php endif; ?>
</div>
<div class="pc-clm-upvote-section">
<button class="pc-clm-upvote-btn <?php echo $has_voted ? 'voted' : ''; ?>"
data-post-id="<?php echo esc_attr( $post_id ); ?>"
<?php echo $has_voted ? 'disabled' : ''; ?>>
<span class="pc-clm-upvote-icon">
<svg width="16" height="16" viewBox="0 0 24 24" fill="currentColor">
<path d="M12 2l2.4 7.4h7.6l-6 4.6 2.3 7.4-6.3-4.6-6.3 4.6 2.3-7.4-6-4.6h7.6z"/>
</svg>
</span>
<span class="pc-clm-upvote-count"><?php echo esc_html( $upvote_count ); ?></span>
</button>
<span class="pc-clm-upvote-label"><?php echo esc_html( _n( 'upvote', 'upvotes', $upvote_count, 'pc-changelog-manager-abc123' ) ); ?></span>
</div>
</div>
<div class="pc-clm-entry-content-wrapper">
<h1 class="pc-clm-entry-title">
<?php the_title(); ?>
</h1>
<div class="pc-clm-entry-content">
<?php the_content(); ?>
</div>
</div>
</div>
</article>
<?php
if ( comments_open() || get_comments_number() ) {
comments_template();
}
endwhile;
?>
</div>
<?php get_footer(); ?>

View File

@@ -0,0 +1,180 @@
<?php
/**
* Changelog Widget
*
* @package PCChangelogManager
*/
// Prevent direct access to the file.
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
/**
* Changelog Widget class.
*/
class PC_CLM_Widget extends WP_Widget {
/**
* Constructor.
*/
public function __construct() {
parent::__construct(
'pc_clm_changelog_widget',
__( 'Changelog', 'pc-changelog-manager-abc123' ),
array(
'description' => __( 'Display recent changelog entries.', 'pc-changelog-manager-abc123' ),
'customize_selective_refresh' => true,
)
);
}
/**
* Output the widget content.
*
* @param array $args Display arguments.
* @param array $instance Widget instance.
*/
public function widget( $args, $instance ) {
// Enqueue styles.
if ( file_exists( PC_CLM_PLUGIN_DIR . 'public/css/public-style.css' ) ) {
wp_enqueue_style( 'pc-clm-public-style', PC_CLM_PLUGIN_URL . 'public/css/public-style.css', array(), PC_CLM_VERSION );
}
$title = ! empty( $instance['title'] ) ? $instance['title'] : __( 'Changelog', 'pc-changelog-manager-abc123' );
$limit = ! empty( $instance['limit'] ) ? intval( $instance['limit'] ) : 5;
$show_date = ! empty( $instance['show_date'] ) ? $instance['show_date'] : 'yes';
$show_category = ! empty( $instance['show_category'] ) ? $instance['show_category'] : 'yes';
echo wp_kses_post( $args['before_widget'] );
if ( $title ) {
echo wp_kses_post( $args['before_title'] . apply_filters( 'widget_title', $title ) . $args['after_title'] );
}
// Query changelog entries.
$query_args = array(
'post_type' => 'pc_changelog',
'post_status' => 'publish',
'posts_per_page' => $limit,
'orderby' => 'date',
'order' => 'DESC',
);
$query = new WP_Query( $query_args );
if ( $query->have_posts() ) {
?>
<ul class="pc-clm-widget-list">
<?php
while ( $query->have_posts() ) :
$query->the_post();
$post_id = get_the_ID();
$version = get_post_meta( $post_id, '_pc_clm_version_number', true );
$release_date = get_post_meta( $post_id, '_pc_clm_release_date', true );
$category = get_post_meta( $post_id, '_pc_clm_category', true );
$categories = array(
'new-features' => __( 'New Features', 'pc-changelog-manager-abc123' ),
'bug-fixes' => __( 'Bug Fixes', 'pc-changelog-manager-abc123' ),
'improvements' => __( 'Improvements', 'pc-changelog-manager-abc123' ),
'security' => __( 'Security', 'pc-changelog-manager-abc123' ),
'deprecated' => __( 'Deprecated', 'pc-changelog-manager-abc123' ),
'removed' => __( 'Removed', 'pc-changelog-manager-abc123' ),
);
?>
<li class="pc-clm-widget-entry">
<div class="pc-clm-widget-entry-header">
<?php if ( $version ) : ?>
<span class="pc-clm-widget-version"><?php echo esc_html( $version ); ?></span>
<?php endif; ?>
<?php if ( 'yes' === $show_date && $release_date ) : ?>
<span class="pc-clm-widget-date"><?php echo esc_html( date_i18n( 'M j, Y', strtotime( $release_date ) ) ); ?></span>
<?php endif; ?>
</div>
<a href="<?php the_permalink(); ?>" class="pc-clm-widget-entry-title">
<?php the_title(); ?>
</a>
<?php if ( 'yes' === $show_category && $category && isset( $categories[ $category ] ) ) : ?>
<span class="pc-clm-widget-category pc-clm-category-<?php echo esc_attr( $category ); ?>">
<?php echo esc_html( $categories[ $category ] ); ?>
</span>
<?php endif; ?>
</li>
<?php
endwhile;
?>
</ul>
<?php
wp_reset_postdata();
} else {
?>
<p class="pc-clm-widget-empty"><?php esc_html_e( 'No changelog entries found.', 'pc-changelog-manager-abc123' ); ?></p>
<?php
}
echo wp_kses_post( $args['after_widget'] );
}
/**
* Output the widget form in the admin.
*
* @param array $instance Current instance.
*/
public function form( $instance ) {
$title = ! empty( $instance['title'] ) ? $instance['title'] : __( 'Changelog', 'pc-changelog-manager-abc123' );
$limit = ! empty( $instance['limit'] ) ? intval( $instance['limit'] ) : 5;
$show_date = ! empty( $instance['show_date'] ) ? $instance['show_date'] : 'yes';
$show_category = ! empty( $instance['show_category'] ) ? $instance['show_category'] : 'yes';
?>
<p>
<label for="<?php echo esc_attr( $this->get_field_id( 'title' ) ); ?>">
<?php esc_html_e( 'Title:', 'pc-changelog-manager-abc123' ); ?>
</label>
<input class="widefat" id="<?php echo esc_attr( $this->get_field_id( 'title' ) ); ?>" name="<?php echo esc_attr( $this->get_field_name( 'title' ) ); ?>" type="text" value="<?php echo esc_attr( $title ); ?>" />
</p>
<p>
<label for="<?php echo esc_attr( $this->get_field_id( 'limit' ) ); ?>">
<?php esc_html_e( 'Number of entries to show:', 'pc-changelog-manager-abc123' ); ?>
</label>
<input class="tiny-text" id="<?php echo esc_attr( $this->get_field_id( 'limit' ) ); ?>" name="<?php echo esc_attr( $this->get_field_name( 'limit' ) ); ?>" type="number" min="1" max="20" value="<?php echo esc_attr( $limit ); ?>" />
</p>
<p>
<input class="checkbox" id="<?php echo esc_attr( $this->get_field_id( 'show_date' ) ); ?>" name="<?php echo esc_attr( $this->get_field_name( 'show_date' ) ); ?>" type="checkbox" value="yes" <?php checked( $show_date, 'yes' ); ?> />
<label for="<?php echo esc_attr( $this->get_field_id( 'show_date' ) ); ?>">
<?php esc_html_e( 'Show release date', 'pc-changelog-manager-abc123' ); ?>
</label>
</p>
<p>
<input class="checkbox" id="<?php echo esc_attr( $this->get_field_id( 'show_category' ) ); ?>" name="<?php echo esc_attr( $this->get_field_name( 'show_category' ) ); ?>" type="checkbox" value="yes" <?php checked( $show_category, 'yes' ); ?> />
<label for="<?php echo esc_attr( $this->get_field_id( 'show_category' ) ); ?>">
<?php esc_html_e( 'Show category', 'pc-changelog-manager-abc123' ); ?>
</label>
</p>
<?php
}
/**
* Save widget settings.
*
* @param array $new_instance New instance.
* @param array $old_instance Old instance.
* @return array
*/
public function update( $new_instance, $old_instance ) {
$instance = array();
$instance['title'] = ! empty( $new_instance['title'] ) ? sanitize_text_field( $new_instance['title'] ) : '';
$instance['limit'] = ! empty( $new_instance['limit'] ) ? intval( $new_instance['limit'] ) : 5;
$instance['show_date'] = ! empty( $new_instance['show_date'] ) ? 'yes' : 'no';
$instance['show_category'] = ! empty( $new_instance['show_category'] ) ? 'yes' : 'no';
return $instance;
}
}