From 0afb2c0046b55c123eafb4ab9ee77efa68d12463 Mon Sep 17 00:00:00 2001
From: Jake Vanderwerf <get@jakevanderwerf.ca>
Date: Sat, 06 Jun 2026 17:15:31 +0000
Subject: [PATCH] =Starting the Favourites.js setup, converting previous Northeh stuff to new Registrar, fixing up Square.php integration to match
---
inc/managers/DirectoryManager.php | 31 ++++++++++++++++++++-----------
1 files changed, 20 insertions(+), 11 deletions(-)
diff --git a/inc/managers/DirectoryManager.php b/inc/managers/DirectoryManager.php
index c81010d..4645f97 100644
--- a/inc/managers/DirectoryManager.php
+++ b/inc/managers/DirectoryManager.php
@@ -38,7 +38,7 @@
jvb_register_do_once('buildDirectories', [$this, 'activate']);
add_action('init', [$this, 'registerDirectories']);
- add_filter('render_block', [$this, 'renderBlock'], 998, 3);
+ add_filter('pre_render_block', [$this, 'renderBlock'], 20, 3);
}
public function registerDirectories():void
@@ -85,6 +85,7 @@
public function getDirectories():array
{
$directories = get_option(BASE.'directories');
+
if (!$directories) {
$directories = [];
//content
@@ -134,7 +135,7 @@
$title = $config['title'];
//Bail early if we've already created the page
$existing = new WP_Query([
- 'post_type' => BASE.'dash',
+ 'post_type' => BASE.'directory',
'name' => sanitize_title($title),
'posts_per_page' => 1,
]);
@@ -228,7 +229,6 @@
// ];
// }
// }
-
if (!empty($created)) {
update_option(BASE.'directory_ids', $created);
}
@@ -240,6 +240,7 @@
protected function buildDirectoryList():array
{
$saved = get_option(BASE.'directory_list', []);
+
if (empty($saved)) {
$all = new WP_Query([
'post_type' => BASE.'directory',
@@ -324,7 +325,7 @@
string $name = '',
string $url = '',
string $ID = '',
- $extra = false
+ ?array $extra = null
):array {
if ($name == '') {
$name = get_the_title();
@@ -437,12 +438,20 @@
return $this->cache->remember(
$cacheKey,
function() use ($slug, $type, $registrar, $config, $paged) {
- $out = '<h1>' . $this->directoryTitle($registrar) . '</h1>';
+
+ $out = '<h1>' . $config['title'] . '</h1>';
$out .= '<div class="description">';
foreach ($config['description'] ?? [] as $p) {
$out .= '<p>' . $p . '</p>';
}
$out .= '</div>';
+ $link = match($registrar->getType()) {
+ 'post' => get_post_type_archive_link($registrar->getBased()),
+ 'term' => false,
+ 'user' => get_post_type_archive_link($registrar->getProfile()->getBased()),
+ default => false,
+ };
+ $out .= $link ? '<ul class="buttons"><li><a href="'.$link.'">See All</a></li></ul>' : '';
$out .= $this->renderIndex($slug);
$list = [];
@@ -465,7 +474,7 @@
$get = new WP_Query($args);
- $hasExtra = $registrar->hasFeature('directory_extra');
+ $hasExtra = !empty($config['directory_extra']??[]);
if ($get->have_posts()) {
while ( $get->have_posts() ) {
$get->the_post();
@@ -672,12 +681,13 @@
foreach ($items as $item) {
$extra = '';
if (!empty($item['extra'])) {
- $extra = '<span>';
+ $extra = '<ul class="term-list row">';
foreach ($item['extra'] as $ext) {
+ $icon = Registrar::getInstance($ext['type'])->getIcon();
$umamiType = ($ext['type'] === BASE.'shop') ? 'click_shop' : 'click_taxonomy';
- $extra .= '<a href="'.$ext['url'].'"'.$umami->trackContentClick($item['id'],$umamiType, ['source_type' => 'directory']).'>'.$ext['name'].'</a>';
+ $extra .= '<li><a href="'.$ext['url'].'"'.$umami->trackContentClick($item['id'],$umamiType, ['source_type' => 'directory']).'>'.jvbIcon($icon).$ext['name'].'</a></li>';
}
- $extra .= '</span>';
+ $extra .= '</ul>';
}
$item_html = apply_filters('jvb_directory_render_item', '', $item, $type, $extra);
@@ -697,7 +707,7 @@
return $out;
}
- public function renderBlock(string $content, array $block, WP_Block $instance)
+ public function renderBlock(?string $content, array $block, ?WP_Block $instance)
{
if (!is_post_type_archive(BASE.'directory') && !is_singular(BASE.'directory')) {
return $content;
@@ -706,7 +716,6 @@
return $content;
}
- error_log('Still working on directory manager...');
// For archive page
if (is_post_type_archive(BASE.'directory') && $block['blockName'] === 'core/group') {
return ($block['attrs']['tagName']??'' === 'main') ? '<main>'.$this->renderArchive().'</main>' : $content;
--
Gitblit v1.10.0