From 4089ba01e0881c89a72332e13bc3a80b6bddec2a Mon Sep 17 00:00:00 2001
From: Jake Vanderwerf <get@jakevanderwerf.ca>
Date: Mon, 29 Jun 2026 22:15:55 +0000
Subject: [PATCH] =DashboardManager overhaul. A bit easier to modify the output of pages. Still have to get the account pages to work as expected, as well as verify the integrations and others are working - but registrar/content pages work as expected. Also fixed up the table generation in CRUD.js and CRUDSkeleton.php
---
inc/ui/CRUDSkeleton.php | 155 ++++++++++++++++++++++++++-------------------------
1 files changed, 80 insertions(+), 75 deletions(-)
diff --git a/inc/ui/CRUDSkeleton.php b/inc/ui/CRUDSkeleton.php
index eb3ef35..b231217 100644
--- a/inc/ui/CRUDSkeleton.php
+++ b/inc/ui/CRUDSkeleton.php
@@ -600,7 +600,7 @@
$dataIgnore = $this->useCRUDjs ? '' : ' data-ignore';
?>
<section class="items-list <?= esc_attr($this->dataType) ?> crud" data-content="<?= esc_attr($this->dataType) ?>" data-singular="<?=$this->singular?>" data-plural="<?=$this->plural?>" data-view="<?= $this->defaultView?>"<?=$dataIgnore?>>
- <div class="wrap">
+ <div id="item-wrap">
<?php
$this->renderControlsAndFilters();
@@ -869,6 +869,7 @@
$form = ob_get_clean();
echo jvbNewModal(
'date-range',
+ 'date-range',
'Filter Results by Date:',
$form
);
@@ -1217,7 +1218,6 @@
?>
<template class="contentTable">
<form class="table"
-<!-- data-save="content"-->
data-content="<?= esc_attr($this->dataType) ?>"
data-form-id="content-table-<?= esc_attr($this->dataType) ?>"
<?= $permissions?>>
@@ -1255,9 +1255,9 @@
<?= $this->renderItemSelect() ?>
</td>
<?php
- if (array_key_exists('status', $this->fields)){
+ if (array_key_exists('post_status', $this->fields)){
?>
- <td class="status" data-field="post_status">
+ <td class="post_status" data-field="post_status" data-field-type="radio">
<?= $this->renderStatusRadios() ?>
</td>
<?php
@@ -1271,7 +1271,7 @@
'radio'
];
foreach ($this->fields as $name => $config):
- if (array_key_exists('hidden', $config) || $name === 'status'){
+ if ((array_key_exists('hidden', $config) && $config['hidden'] === true) || $name === 'post_status'){
continue;
}
$makeThisDetailed = (in_array($config['type'], $makeDetails));
@@ -1311,7 +1311,6 @@
?>
<template class="contentTable">
<form class="table"
-<!-- data-save="content"-->
data-content="<?= esc_attr($this->dataType) ?>"
data-form-id="content-table-<?= esc_attr($this->dataType) ?>">
<?= jvbFormStatus() ?>
@@ -1384,7 +1383,7 @@
</td>
<?php
foreach ($this->fields as $name => $config) {
- if(array_key_exists('hidden', $config) || $name === 'post_status') {
+ if((array_key_exists('hidden', $config) && $config['hidden'] === true) || $name === 'post_status') {
continue;
}
if (!in_array($name, $this->timelineUniqueFields)) {
@@ -1411,64 +1410,59 @@
* Render table header
*/
protected function renderTableHeader(): string {
- ob_start();
-
- ?>
- <tr>
+ $out = '<tr>
<th scope="col" class="select-header">
<input type="checkbox" id="select-all" name="select-all">
<label for="select-all">All</label>
- </th>
- <?php if (array_key_exists('status', $this->fields)) { ?>
- <th scope="col" class="status-header">Status</th>
- <?php } ?>
- <?php foreach ($this->fields as $name => $config):
- if (array_key_exists('hidden', $config) || $name === 'status'){
- continue;
- }
- ?>
- <th scope="col" class="show-<?= esc_attr($name) ?>"<?= (in_array($name, $this->stuck)) ? ' data-stuck':''?>>
- <?= esc_html($config['label']) ?>
- </th>
- <?php endforeach;
- if (!empty($this->itemActions)) {
- ?>
- <th scope="col" class="show-actions">
- Actions
- </th>
- <?php
- }
- ?>
+ </th>';
- </tr>
- <?php
- return ob_get_clean();
+ if (array_key_exists('post_status', $this->fields)){
+ $out .= '<th scope="col" class="status-header">Status</th>';
+ }
+
+ foreach ($this->fields as $name => $config) {
+ if ($name === 'post_status' || (array_key_exists('hidden', $config) && $config['hidden'] === true)) {
+ continue;
+ }
+ $out .= sprintf(
+ '<th scope="col" class="show-%s"%s>%s</th>',
+ esc_attr($name),
+ in_array($name, $this->stuck) ? ' data-stuck' : '',
+ esc_html($config['label'])
+ );
+ }
+
+ if (!empty($this->itemActions)) {
+ $out .= '<th scope="col" class="show-actions">Actions</th>';
+ }
+ $out .= '</tr>';
+
+ return $out;
}
protected function renderTimelineTableHeader(): string {
- ob_start();
-
- ?>
- <tr>
+ $out = '<tr>
<th scope="col" class="select-header">
<input type="checkbox" id="select-all" name="select-all">
<label for="select-all">All</label>
</th>
<th scope="col" class="show-post_status">
Status
- </th>
- <?php foreach ($this->fields as $name => $config):
- if (array_key_exists('hidden', $config) || $name === 'post_status'){
- continue;
- }
- ?>
- <th scope="col" class="show-<?= esc_attr($name) ?>"<?= (in_array($name, $this->stuck)) ? ' data-stuck':''?>>
- <?= esc_html($config['label']) ?>
- </th>
- <?php endforeach; ?>
- </tr>
- <?php
- return ob_get_clean();
+ </th>';
+
+ foreach ($this->fields as $name => $config) {
+ if ($name === 'post_status' || (array_key_exists('hidden', $config) && $config['hidden'] === true)) {
+ continue;
+ }
+ $out .= sprintf(
+ '<th scope="col" class="show-%s"%s>%s</th>th>',
+ esc_attr($name),
+ in_array($name, $this->stuck) ? ' data-stuck':'',
+ esc_html($config['label'])
+ );
+ }
+ $out .= '</tr>';
+ return $out;
}
/**
@@ -1496,29 +1490,35 @@
return ob_get_clean();
}
- protected function renderStatusRadios(): string {
- ob_start();
- ?>
- <div class="radio-options status-options row" data-field="post_status" data-field-type="radio">
- <?php foreach ($this->statuses as $status):
- if ($status === 'all') continue;
- if (!array_key_exists($status, $this->allowedStatuses)) continue;
- $config = $this->allowedStatuses[$status];
- ?>
+ protected function renderStatusRadios(): string
+ {
+ $out = '<div class="radio-options status-options row">';
+ foreach ($this->statuses as $status) {
+ if ($status === 'all' || !array_key_exists($status, $this->allowedStatuses)) continue;
+ $config = $this->allowedStatuses[$status];
- <input type="radio"
+ $out .= sprintf(
+ '<input type="radio"
name="post_status"
- id="status-<?= esc_attr($status) ?>"
- value="<?= esc_attr($status) ?>">
- <label for="status-<?= esc_attr($status) ?>">
- <?= jvbDashIcon($config['icon']) ?>
- <span class="screen-reader-text"><?= esc_html($config['label']) ?></span>
- </label>
- <?php endforeach; ?>
- <span class="validation-message" hidden role="alert"></span>
- </div>
- <?php
- return ob_get_clean();
+ id="post_status-%s"
+ class="btn"
+ value="%s">
+ <label for="post_status-%s" title="%s">
+ %s
+ <span class="screen-reader-text">%s</span>
+ </label>',
+ esc_attr($status),
+ esc_attr($status),
+ esc_attr($status),
+ esc_html($config['label']),
+ jvbDashIcon($config['icon']),
+ esc_html($config['label'])
+ );
+ }
+ $out .= '<span class="validation-message" hidden role="alert"></span>
+ </div>';
+
+ return $out;
}
@@ -1564,6 +1564,7 @@
{
echo jvbNewModal(
'create',
+ 'create',
'Creating <span class="count"></span> New '.$this->singular,
str_replace('edit-form"', 'create-form" data-noautosave', $this->editForm())
);
@@ -1572,8 +1573,9 @@
protected function editForm():string
{
ob_start();
+/* <form class="edit-form" data-save="content" data-form-id="edit-<?=$this->dataType?>" data-autosave<?= ($this->isTimeline) ? ' data-timeline' : ''*/
?>
-<!-- <form class="edit-form" data-save="content" data-form-id="edit---><?php //=$this->dataType?><!--" data-autosave--><?php //= ($this->isTimeline) ? ' data-timeline' : ''?><!-->-->
+
<form class="edit-form" data-form-id="edit-<?=$this->dataType?>" data-autosave<?= ($this->isTimeline) ? ' data-timeline' : ''?>>
<?= jvbFormStatus() ?>
<input type="hidden" name="form-id" value="<?=uniqid('new-')?>" />
@@ -1690,6 +1692,7 @@
{
echo jvbNewModal(
'edit',
+ 'edit',
'Edit your '.$this->singular,
$this->editForm()
);
@@ -1699,8 +1702,9 @@
{
if (empty($this->bulkActions)) return;
ob_start();
+/* <form class="bulk-edit-form" data-save="content" data-form-id="bulk-edit-<?=$this->dataType?>">*/
?>
-<!-- <form class="bulk-edit-form" data-save="content" data-form-id="bulk-edit---><?php //=$this->dataType?><!--">-->
+
<form class="bulk-edit-form" data-form-id="bulk-edit-<?=$this->dataType?>">
<?= jvbFormStatus() ?>
<div class="selected"></div>
@@ -1741,6 +1745,7 @@
$form = ob_get_clean();
echo jvbNewModal(
'bulkEdit',
+ 'bulkEdit',
'Bulk Edit <span class="selected"></span> '.$this->plural,
$form
);
--
Gitblit v1.10.0