From ac444cba221832c012c0435fdc8339fe9f37febb Mon Sep 17 00:00:00 2001
From: Jake Vanderwerf <get@jakevanderwerf.ca>
Date: Mon, 11 May 2026 18:35:04 +0000
Subject: [PATCH] =Some changes to the CRUD.js editing, timeline post configuration
---
inc/registrar/Registrar.php | 27 +++++++++++++++++++++++++--
1 files changed, 25 insertions(+), 2 deletions(-)
diff --git a/inc/registrar/Registrar.php b/inc/registrar/Registrar.php
index 83c36bd..593a8c6 100644
--- a/inc/registrar/Registrar.php
+++ b/inc/registrar/Registrar.php
@@ -48,11 +48,13 @@
public ?string $rewrite_taxonomy = null;
+ public bool $add_image_column = false;
+
protected static array $allFlags = [
//Shared Flags
'favouritable', 'karma', 'show_feed', 'show_directory', 'approve_new', 'has_responses', 'invitable',
//Post Flags
- 'hide_single', 'redirect_to_author', 'is_calendar', 'single_image', 'is_timeline', 'is_gallery', 'is_faq', 'is_glossary', 'rewrite_taxonomy',
+ 'hide_single', 'redirect_to_author', 'is_calendar', 'single_image', 'is_timeline', 'is_gallery', 'is_faq', 'is_glossary', 'rewrite_taxonomy', 'add_image_column',
//Taxonomy Flags
'is_content', 'is_ownable', 'verify_entry', 'track_changes', 'associate_user_content',
//User Flags
@@ -686,6 +688,10 @@
if ($this->registrar) {
$this->registrar->register();
}
+ if ($this->add_image_column) {
+ add_filter("manage_{$this->based}_posts_columns", [$this, 'addImageColumn']);
+ add_action("manage_{$this->based}_posts_custom_column", [$this, 'showImageColumn'], 10, 2);
+ }
} elseif ($this->type === 'term') {
if ($this->is_content) {
if ($this->verify_entry) {
@@ -962,6 +968,23 @@
}
public function getUserSubtype():string|false
{
- return $this->user_subtype?:false;
+ return $this->user_subtype??false;
+ }
+
+ public function addImageColumn(array $columns):array
+ {
+ $keys = array_keys($columns);
+ $index = array_search('cb', $keys);
+ if ($index !== false) {
+ $pos = $index+1;
+ $columns = array_slice($columns, 0, $pos, true) + ['jvb_featured_image' => 'Image'] + array_slice($columns, $pos, null, true);
+ }
+ return $columns;
+ }
+ public function showImageColumn(string $column, int $postID):void
+ {
+ if ($column === 'jvb_featured_image') {
+ echo get_the_post_thumbnail($postID, 'tiny');
+ }
}
}
--
Gitblit v1.10.0