From 747d741293e064a979d7bf6c143ef969ea6d7629 Mon Sep 17 00:00:00 2001
From: Jake Vanderwerf <get@jakevanderwerf.ca>
Date: Sun, 24 May 2026 20:49:44 +0000
Subject: [PATCH] =GMBReview block minor tweaks. Refactored ReferralManager.php and ReferralRoutes.php to utilize the manager for all logic, and CustomTable for table interactions.
---
inc/registrar/Registrar.php | 93 +++++++++++++++++++++++++++++++++++++++++-----
1 files changed, 83 insertions(+), 10 deletions(-)
diff --git a/inc/registrar/Registrar.php b/inc/registrar/Registrar.php
index 727e3b3..81c78da 100644
--- a/inc/registrar/Registrar.php
+++ b/inc/registrar/Registrar.php
@@ -1,7 +1,8 @@
<?php
namespace JVBase\registrar;
-use JVBase\forms\TaxonomySelector;
+
+use JVBase\base\Site;
use JVBase\inc\registrar\helpers\HideSingle;
use JVBase\managers\Cache;
use JVBase\managers\CRUD;
@@ -20,8 +21,6 @@
use JVBase\registrar\helpers\MakeTimelineType;
use JVBase\registrar\helpers\MakeTrackChanges;
use JVBase\registrar\helpers\MakeVerification;
-use JVBase\utility\Features;
-use WP_Post;
use WP_Query;
if (!defined('ABSPATH')) {
@@ -33,6 +32,7 @@
protected string $type;
protected string $singular;
protected string $plural;
+ protected string $profile;
protected string $description ='';
protected Fields $fields;
protected array $sections = [];
@@ -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
@@ -140,12 +142,12 @@
/**
* @var bool Whether users/content need to request the owner for admission
*/
- protected bool $verify_entry;
+ protected bool $verify_entry = false;
protected ?MakeVerification $verifyEntryHandler = null;
/**
* @var bool Whether we should track post movements from term to term (ie. artists in tattoo shops)
*/
- protected bool $track_changes;
+ protected bool $track_changes = false;
protected ?MakeTrackChanges $trackChangesHandler = null;
/**
@@ -188,6 +190,16 @@
* @var array slugs of other user roles this role can manage
*/
protected array $manage_others = [];
+ /**
+ * @var string The slug of the taxonomy that defines different access points
+ * Example, for edmonton.ink, we have artist_type, and $this->>can_create would be:
+ * [
+ * 'piercer' => ['piercings', 'artwork', 'events'],
+ * 'tattoo_artist'=> ['tattoos', 'artwork', 'events'],
+ * 'artist' => ['artwork']
+ * ]
+ */
+ protected string $user_subtype;
/** Configs **/
protected Breadcrumbs $breadcrumbs;
@@ -220,7 +232,7 @@
// $this->initClasses();
$this->setFields();
- add_action('init', [$this, 'register'], 0);
+ add_action('init', [$this, 'register'], 2);
add_filter('jvbDashboardPage', [$this, 'renderDashPage'], 10, 3);
}
@@ -371,7 +383,8 @@
}
public function setIntegration(string $integration):self
{
- if (!Features::forSite()->has($integration)){
+
+ if (!Site::hasIntegration($integration)){
error_log('Integration not available for '.$this->slug.': '.$integration);
return $this;
}
@@ -382,7 +395,7 @@
public function getIntegrationFields(string $integration):AddIntegrationFields|false
{
- if (!Features::forSite()->has($integration)){
+ if (!Site::has($integration)){
error_log('Integration not available for '.$this->slug.': '.$integration);
return false;
}
@@ -399,6 +412,14 @@
public function hasIntegration(string $integration) {
return in_array($integration, $this->integrationConfigs);
}
+ public function hasAnyIntegrations(array $integrations = []):bool
+ {
+ if (empty($integrations)) {
+ $integrations = array_keys($this->integrationConfigs);
+ return !empty($integrations);
+ }
+ return !empty(array_intersect($integrations, array_keys($this->integrationConfigs)));
+ }
public function setUploadTitle(string $title):self
{
$this->upload_title = $title;
@@ -667,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) {
@@ -683,7 +708,7 @@
}
if ($this->karma) {
- $this->karmaManager = KarmaManager::for($this->slug);
+ $this->karmaManager = KarmaManager::for($this->slug, $this->type);
}
}
public static function getInstance(string $slug):Registrar|false
@@ -911,7 +936,55 @@
* FLAGGED FEATURES
*****************************************************************/
+ public function profile(?string $slug = null, ?string $singular = null, ?string $plural = null):self
+ {
+ if (!$slug) {
+ $slug = $this->slug.'_profile';
+ }
+ if (!$singular) {
+ $singular = $this->singular;
+ }
+ if (!$plural) {
+ $plural = $this->plural;
+ }
+ $this->profile_link = true;
+ $this->profile = $slug;
+ return Registrar::forPost($slug, $singular, $plural);
+ }
+ public function getProfile():self|false
+ {
+ if (!$this->profile_link) {
+ return false;
+ }
+ return self::getInstance($this->profile);
+ }
+ public function setUserSubtype(string $type):self
+ {
+ $this->user_subtype = sanitize_text_field($type);
+ return $this;
+ }
+ public function getUserSubtype():string|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