From 42fa8304ddb811b0f725f245130f70c0f5e86a6c Mon Sep 17 00:00:00 2001
From: Jake Vanderwerf <get@jakevanderwerf.ca>
Date: Tue, 04 Nov 2025 06:12:02 +0000
Subject: [PATCH] =Refactored LoginManager to be more extensible and configurable, as well as an AjaxRateLimiter
---
inc/helpers/ui.php | 58 ++++++++++++++++++++++++++++++++++++++++++++++++++--------
1 files changed, 50 insertions(+), 8 deletions(-)
diff --git a/inc/helpers/ui.php b/inc/helpers/ui.php
index 7026729..a9e310d 100644
--- a/inc/helpers/ui.php
+++ b/inc/helpers/ui.php
@@ -1,5 +1,7 @@
<?php
+use JVBase\utility\Features;
+
if (!defined('ABSPATH')) {
exit;
}
@@ -9,11 +11,12 @@
function jvbClientQueue():void
{
- if (!jvbSiteHasDashboard() || !is_user_logged_in()) {
+ if (!Features::forSite()->has('dashboard') || !is_user_logged_in()) {
return;
}
+
?>
- <aside id="queue" class="col start btw" aria-expanded="false" hidden>
+ <aside id="queue" class="left col start btw" aria-expanded="false" hidden>
<div class="status-actions row start nowrap">
<div class="refresh row btw">
<span class="countdown row" title="Will refresh again...">5</span>
@@ -60,6 +63,7 @@
</aside>
<button class="qtoggle row" title="Show Queue" aria-controls="queue" hidden>
<?= jvbIcon('save') ?>
+ <span class="screen-reader-text"></span>
<span class="indicator"></span>
<span class="count row"></span>
</button>
@@ -106,7 +110,7 @@
ob_start();
?>
<li>
- <a href="<?=get_home_url(2, '/dash/')?>" title="Behind the Scenes">
+ <a href="<?=get_home_url(null, '/dash/')?>" title="Behind the Scenes">
<?= jvbIcon('dashboard', ['title' => 'Behind the Scenes'])?>
<span class="screen-reader-text">Go Behind the Scenes</span>
</a>
@@ -119,7 +123,7 @@
</span>
</button>
<ul class="notifications-preview submenu">
- <li id="view-all"><a href="<?=get_home_url(2, '/dash/notifications/')?>" class="view-all">View All Notifications</a></li>
+ <li id="view-all"><a href="<?=get_home_url(null, '/dash/notifications/')?>" class="view-all">View All Notifications</a></li>
</ul>
<template class="notificationItem">
<li class="notification-preview">
@@ -149,6 +153,7 @@
function jvbHelpMenu():string
{
$out = get_option(BASE.'help_menu');
+
if ($out === false) {
$open = '<li><a href="';
$mid = '">';
@@ -168,7 +173,7 @@
'fields' => 'ids'
));
if ($page->have_posts()) {
- $end = ($t == 'About') ? '<li><a href="'.get_home_url(2, '/directory/partners/').'" title="View our Partners">Partners</a></li>' : '';
+ $end = ($t == 'About') ? '<li><a href="'.get_home_url(null, '/directory/partners/').'" title="View our Partners">Partners</a></li>' : '';
$links .= $open.get_the_permalink($page->posts[0]).'" title="'.$t.$mid.$t.$close.$end;
}
wp_reset_postdata();
@@ -324,6 +329,7 @@
return ob_get_clean();
}
+add_action('wp_footer', 'jvbLoadingScreen');
function jvbLoadingScreen():string
{
return '<dialog class="loading">
@@ -364,7 +370,12 @@
$header = '<nav class="tabs row start" role="tablist">';
$content = '';
$i = 0;
+
foreach ($tabs as $slug => $config) {
+ if (!array_key_exists('content', $config) || empty($config['content'])) {
+ error_log('No content for tab: '.$slug);
+ continue;
+ }
//Header
$active = ($i === 0) ? ' active' : '';
$selected = ($i === 0) ? 'true' : 'false';
@@ -386,7 +397,17 @@
$content .= '>
<h2>'.$config['title'].'</h2>';
if ( $config['description']) {
- $content .= apply_filters('the_content', $config['description']);
+ if (!is_array($config['description'])) {
+ $content .= apply_filters('the_content', $config['description']);
+ } else {
+// foreach ($config['description'] as $desc) {
+// $content .= apply_filters('the_content', $desc);
+// }
+ $content .= implode('',array_map(function ($paragraph) {
+ return apply_filters('the_content', $paragraph);
+ }, $config['description']));
+ }
+
}
$content .= $config['content'].'
@@ -403,10 +424,11 @@
return $out;
}
-function jvbRenderProgressBar(string $inside ='')
+function jvbRenderProgressBar(string $inside ='', $top = false)
{
+ $top = $top ? ' abs top' : '';
?>
- <div class="progress">
+ <div class="progress<?=$top?>">
<div class="bar">
<div class="fill"></div>
</div>
@@ -417,3 +439,23 @@
<?php
}
+function jvbFormStatus(string $message = '') {
+ return '<div class="restore-form col" hidden>
+ <h3>Looks like we left things hanging...</h3>
+ <p>We\'ve filled in the fields with what you put last time.</p>
+ <div class="actions">
+ <button type="button" data-action="clear-form">
+ '.jvbIcon('arrows-clockwise').'
+ <span>Start Over</span>
+ </button>
+ <button type="button" data-action="dismiss-restore">
+ '.jvbIcon('close').'
+ <span>Dismiss</span>
+ </button>
+ </div>
+ </div>
+ <div class="fstatus row" hidden>
+ <div class="spinner"></div>
+ <p class="message">'.$message.'</p>
+ </div>';
+}
--
Gitblit v1.10.0