From f859e64a57c624ff2daa2b21355f65a49fd4807d Mon Sep 17 00:00:00 2001
From: Jake Vanderwerf <get@jakevanderwerf.ca>
Date: Sat, 29 Aug 2026 03:09:12 +0000
Subject: [PATCH] =Some more tweaks. Mostly on the MenuBlock and adding the Meta.php to WooCommerce Products
---
inc/blocks/FeedBlock.php | 166 +++++++++++++++++++++++++-----------------------------
1 files changed, 77 insertions(+), 89 deletions(-)
diff --git a/inc/blocks/FeedBlock.php b/inc/blocks/FeedBlock.php
index 223c554..80d26c3 100644
--- a/inc/blocks/FeedBlock.php
+++ b/inc/blocks/FeedBlock.php
@@ -6,8 +6,6 @@
use JVBase\registrar\Registrar;
use JVBase\base\Site;
use JVBase\forms\TaxonomySelector;
-use JVBase\ui\CRUDSkeleton;
-use WP_Block;
use WP_Query;
if (!defined('ABSPATH')) {
@@ -32,13 +30,6 @@
public function __construct()
{
- // Initialize cache with connections
- $this->cache = Cache::for('feed_block', WEEK_IN_SECONDS);
- if (JVB_TESTING) {
- $this->cache->flush();
- }
- $this->cache->flush();
-
add_action('init', [$this, 'registerBlock']);
}
@@ -801,97 +792,94 @@
if (!$isTemplate && empty($value)) {
return '';
}
- switch ($fieldName) {
- case 'post_title':
- return sprintf(
- '<h3%s>%s</h3>',
- $data,
- $meta && !empty($value) ? $value : '',
- );
- case 'post_date':
- case 'post_modified':
- return sprintf(
- '<time%s%s>%s</time>',
- $data,
- $meta && !empty($value) ? date('c', strtotime($value)) : '',
- $meta && !empty($value) ? date('F j, Y', strtotime($value)) : '',
- );
- }
-
- return match ($fieldType) {
- 'date' => sprintf(
+ return match ($fieldName) {
+ 'post_title' => sprintf(
+ '<h3%s>%s</h3>',
+ $data,
+ $meta && !empty($value) ? $value : '',
+ ),
+ 'post_date', 'post_modified' => sprintf(
'<time%s%s>%s</time>',
$data,
$meta && !empty($value) ? date('c', strtotime($value)) : '',
$meta && !empty($value) ? date('F j, Y', strtotime($value)) : '',
),
- 'datetime' => sprintf(
- '<time%s%s>%s</time>',
- $data,
- $meta && !empty($value) ? date('c', strtotime($value)) : '',
- $meta && !empty($value) ? date('F j, Y at h:iA', strtotime($value)) : '',
- ),
- 'time' => sprintf(
- '<time%s%s>%s</time>',
- $data,
- $value,
- $value
- ),
- 'upload' => empty($value) ? sprintf(
- '<img%s width="300px" height="300px" loading="lazy" decoding="async">',
- $data
- ) :
- str_replace('<img', '<img' . $data, jvbFormatImage($value)),
- 'selector' => sprintf(
- '<ul%s class="terms %s">%s</ul>',
- $data,
- $config['taxonomy']??$config['post_type']??$config['role']??'',
- empty($value) ? sprintf('<li><a>%s</a></li>',
- $this->iconFor($config)
+ default => match ($fieldType) {
+ 'date' => sprintf(
+ '<time%s%s>%s</time>',
+ $data,
+ $meta && !empty($value) ? date('c', strtotime($value)) : '',
+ $meta && !empty($value) ? date('F j, Y', strtotime($value)) : '',
+ ),
+ 'datetime' => sprintf(
+ '<time%s%s>%s</time>',
+ $data,
+ $meta && !empty($value) ? date('c', strtotime($value)) : '',
+ $meta && !empty($value) ? date('F j, Y at h:iA', strtotime($value)) : '',
+ ),
+ 'time' => sprintf(
+ '<time%s%s>%s</time>',
+ $data,
+ $value,
+ $value
+ ),
+ 'upload' => empty($value) ? sprintf(
+ '<img%s width="300px" height="300px" loading="lazy" decoding="async">',
+ $data
) :
- implode('', array_filter(array_map(function ($ID) use ($config) {
- $type = $config['subtype'];
- $taxonomy = isset($config['taxonomy']) ? jvbCheckBase($config['taxonomy']) : '';
+ str_replace('<img', '<img' . $data, jvbFormatImage($value)),
+ 'selector' => sprintf(
+ '<ul%s class="terms %s">%s</ul>',
+ $data,
+ $config['taxonomy'] ?? $config['post_type'] ?? $config['role'] ?? '',
+ empty($value) ? sprintf('<li><a>%s</a></li>',
+ $this->iconFor($config)
+ ) :
+ implode('', array_filter(array_map(function ($ID) use ($config) {
+ $type = $config['subtype'];
+ $taxonomy = isset($config['taxonomy']) ? jvbCheckBase($config['taxonomy']) : '';
- $item = match ($type) {
- 'taxonomy' => get_term($ID, $taxonomy),
- 'user' => get_userdata($ID),
- 'post' => get_post($ID),
- default => false,
- };
+ $item = match ($type) {
+ 'taxonomy' => get_term($ID, $taxonomy),
+ 'user' => get_userdata($ID),
+ 'post' => get_post($ID),
+ default => false,
+ };
- if (!$item || is_wp_error($item)) {
- return '';
- }
+ if (!$item || is_wp_error($item)) {
+ return '';
+ }
- $icon = $this->iconFor($config);
+ $icon = $this->iconFor($config);
- $name = match ($type) {
- 'taxonomy' => $item->name,
- 'user' => $item->display_name,
- 'post' => $item->post_title,
- default => '',
- };
- $url = match ($type) {
- 'taxonomy' => get_term_link((int)$ID, $taxonomy),
- 'user' => get_the_permalink(get_user_meta($ID, BASE . 'userLink', true)),
- 'post' => get_the_permalink($ID),
- default => ''
- };
- return sprintf(
- '<li><a href="%s">%s%s</a></li>',
- $url,
- !empty($icon) ? jvbIcon($icon) : '',
- $name
- );
- }, explode(',', $value))))
- ),
- default => sprintf(
- '<p%s>%s</p>',
- $data,
- $value
- ),
+ $name = match ($type) {
+ 'taxonomy' => $item->name,
+ 'user' => $item->display_name,
+ 'post' => $item->post_title,
+ default => '',
+ };
+ $url = match ($type) {
+ 'taxonomy' => get_term_link((int)$ID, $taxonomy),
+ 'user' => get_the_permalink(get_user_meta($ID, BASE . 'userLink', true)),
+ 'post' => get_the_permalink($ID),
+ default => ''
+ };
+ return sprintf(
+ '<li><a href="%s">%s%s</a></li>',
+ $url,
+ !empty($icon) ? jvbIcon($icon) : '',
+ $name
+ );
+ }, explode(',', $value))))
+ ),
+ default => sprintf(
+ '<p%s>%s</p>',
+ $data,
+ $value
+ ),
+ },
};
+
}
protected function iconFor(array $fieldConfig):string
{
--
Gitblit v1.10.0