From 48721c85ebcfa973ee81719d2467ca80e4253dc9 Mon Sep 17 00:00:00 2001
From: Jake Vanderwerf <get@jakevanderwerf.ca>
Date: Fri, 01 May 2026 17:30:03 +0000
Subject: [PATCH] =Edmonton Ink hard test begins! Real testing of the managers and reset routes will commence. So far, just ensuring our classes are all loaded correctly: Site() and its sub-classes Membership, Login, etc. Care should be taken to load conditionally on 'init', as we finish defining most settings by 'plugins_loaded' at priority 5
---
inc/registrar/Fields.php | 108 ++++++++++++++++++++++++++++++++++++++++++++---------
1 files changed, 89 insertions(+), 19 deletions(-)
diff --git a/inc/registrar/Fields.php b/inc/registrar/Fields.php
index 7386cd7..ada4615 100644
--- a/inc/registrar/Fields.php
+++ b/inc/registrar/Fields.php
@@ -121,7 +121,7 @@
'label' => 'Description',
]
];
- if ($this->registrar->args()['hierarchical']??false && $this->registrar->args()['hierarchical'] === true){
+ if ($this->registrar->args()['hierarchical']??false){
$fields['parent'] = [
'type' => 'taxonomy',
'isReference' => true,
@@ -166,8 +166,9 @@
public function modifyField(string $name, string $property, mixed $value):void
{
+ $property = 'set'.implode('',array_map('ucfirst',explode('_', $property)));
$field = $this->fields[$name];
- $field->$property = $value;
+ $field->$property($value);
}
public function getFields():array
@@ -177,32 +178,29 @@
public function addCommon(string $name):self
{
- match ($name) {
- 'wiki' => $this->addWikiField(),
- 'links' => $this->addLinksField(),
- 'contact' => $this->addContactField(),
- 'reviews', 'review' => $this->addReviewField(),
- 'alternate_name' => $this->addAlternateName(),
- 'keywords' => $this->addKeywords(),
- default => error_log('[Field]addCommon: No configuration found for '.$name.'.')
- };
+ $method = 'add'.implode('',array_map('ucfirst',explode('_', $name))).'Field';
+ if (method_exists($this, $method)) {
+ $this->$method();
+ } else {
+ error_log('[Field]addCommon: No configuration found for '.$name.'.');
+ }
return $this;
}
- protected function addWikiField():void
+ protected function addWikiField(?string $label = null):void
{
$this->addField(
'wiki',
[
'type' => 'url',
- 'label' => 'Wikipedia Page',
+ 'label' => $label ?: 'Wikipedia Page',
'description' => 'For the schema',
'quickEdit' => true,
]
);
}
- protected function addLinksField():void
+ protected function addLinksField(?string $label = null):void
{
$this->addField(
'links',
@@ -210,7 +208,7 @@
'type' => 'repeater',
'quickEdit' => true,
'add_label' => 'title',
- 'label' => 'Online Links',
+ 'label' => $label ?:'Online Links',
'description' => 'These are listed publicly on the website',
'fields' => [
'url' => [
@@ -225,6 +223,7 @@
'type' => 'text',
'label' => 'Tracker',
'description' => 'If you are set up to track link referrals, add what comes after the ? here.',
+ 'default' => 'ref=edmonton_ink'
],
],
'section' => 'contact'
@@ -266,14 +265,14 @@
);
}
- protected function addReviewField():void
+ protected function addReviewField(?string $label = null):void
{
$this->addField(
'reviews',
[
'type' => 'repeater',
'add_label' => 'name',
- 'label' => 'Reviews',
+ 'label' => $label ?: 'Reviews',
'fields' => [
'name' => [
'type' => 'text',
@@ -316,7 +315,7 @@
);
}
- protected function addAlternateName():void
+ protected function addAlternateNameField():void
{
$this->addField(
'alternate_name',
@@ -333,7 +332,7 @@
]
);
}
- protected function addKeywords():void
+ protected function addKeywordsField():void
{
$this->addField(
'keywords',
@@ -352,4 +351,75 @@
]
);
}
+
+ protected function addOutsidePhotoField():void
+ {
+ $this->addField(
+ 'outside_photo',
+ [
+ 'type' => 'image',
+ 'limit' => 1,
+ 'label' => __('Outside Photo', 'jvb')
+ ]
+ );
+ }
+
+ protected function addSloganField():void
+ {
+ $this->addField(
+ 'slogan',
+ [
+ 'type' => 'text',
+ 'label' => __('Tagline or Slogan', 'jvb')
+ ]
+ );
+ }
+
+ protected function addPaymentField():void
+ {
+ $this->addField(
+ 'payment_accepted',
+ [
+ 'type' => 'set',
+ 'label' => __('Payment Accepted', 'jvb'),
+ 'options' => [
+ 'Cash' => 'Cash',
+ 'Credit Card' => 'Credit Card',
+ 'Debit' => 'Debit',
+ 'Google Pay' => 'Google Pay',
+ 'Apple Pay' => 'Apple Pay',
+ 'PayPal' => 'PayPal',
+ 'Interac' => 'Interac',
+ 'AMEX' => 'AMEX',
+ ],
+ ]
+ );
+ }
+
+ protected function addAmenitiesField():void
+ {
+ $this->addField(
+ 'amenities',
+ [
+ 'type' => 'set',
+ 'label' => __('Amenities', 'jvb'),
+ 'options' => [
+ 'Wheelchair Accessible' => 'Wheelchair Accessible',
+ 'Free Parking' => 'Free Parking',
+ 'Private Rooms' => 'Private Rooms',
+ 'Air Conditioning' => 'Air Conditioning',
+ 'WiFi' => 'WiFi',
+ 'Gender Neutral Restroom' => 'Gender Neutral Restroom',
+ 'LGBTQ+ Friendly' => 'LGBTQ+ Friendly',
+ 'Sterilization Room' => 'Sterilization Room',
+ 'Refreshments Available' => 'Refreshments Available',
+ 'Street Level Access' => 'Street Level Access',
+ 'Single Use Needles' => 'Single Use Needles',
+ 'Consultation Room' => 'Consultation Room',
+ 'Aftercare Products Available' => 'Aftercare Products Available',
+ 'Walk-Ins Welcome' => 'Walk-Ins Welcome',
+ ]
+ ]
+ );
+ }
}
--
Gitblit v1.10.0