Jake Vanderwerf
2026-04-15 c4aa5cdb5e90ad4b420e22772797d16980232a2b
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
<?php
namespace JVBase\managers\SEO\render\Traits\_Properties;
 
use JVBase\managers\SEO\render\Thing\Intangible\StructuredValue\PropertyValue;
use JVBase\managers\SEO\render\Traits\_Helpers\arrayHelper;
 
if (!defined('ABSPATH')) {
    exit;
}
trait additionalPropertyTrait {
    use arrayHelper;
    /**
     * @var PropertyValue|array A property-value pair representing an additional characteristic of the entity, e.g. a product feature or another characteristic for which there is no matching property in schema.org.
     *
     * Note: Publishers should be aware that applications designed to use specific schema.org properties (e.g. https://schema.org/width, https://schema.org/color, https://schema.org/gtin13, ...) will typically expect such data to be provided using those properties, rather than using the generic property/value mechanism.
     */
    protected PropertyValue|array $additionalProperty;
 
    public function getAdditionalProperty():PropertyValue|array|null
    {
        return $this->additionalProperty??null;
    }
    public function setAdditionalProperty(PropertyValue|array $additionalProperty):void
    {
        if (is_array($additionalProperty)) {
            if (!is_numeric(array_key_first($additionalProperty))) {
                $additionalProperty = [$additionalProperty];
            }
            $additionalProperty = array_map(function($property) {
                if (!array_key_exists('type', $property)) {
                    $property['type'] = 'JVBase\managers\SEO\render\Thing\Intangible\StructuredValue\PropertyValue';
                }
                return $property;
            }, $additionalProperty);
            $additionalProperty = $this->classArray('additionalProperty', $additionalProperty, 'JVBase\managers\SEO\render\Thing\Intangible\StructuredValue\PropertyValue');
 
            $additionalProperty = array_filter($additionalProperty, function ($property) {
                return property_exists($property, 'value') && !empty($property->value);
            });
        }
        $this->additionalProperty = $additionalProperty;
    }
 
    public function getAdditionalPropertyFieldConfig():array
    {
        return [
            'type'  => 'repeater',
            'label' => 'Additional Properties',
            'hint'  => 'If you need to define another property that does not exist anywhere on this page, add it here.',
            'fields'    => [
                'name'  => [
                    'type'  => 'text',
                    'label' => 'Name'
                ],
                'propertyID'    => [
                    'type'  => 'text',
                    'label' => 'Property ID',
                    'hint'  => 'A commonly used identifier for the characteristic represented by the property, e.g. a manufacturer or a standard code for a property. propertyID can be (1) a prefixed string, mainly meant to be used with standards for product properties; (2) a site-specific, non-prefixed string (e.g. the primary key of the property or the vendor-specific ID of the property), or (3) a URL indicating the type of the property, either pointing to an external vocabulary, or a Web resource that describes the property (e.g. a glossary entry). Standards bodies should promote a standard prefix for the identifiers of properties from their standards.'
                ],
                'value' => [
                    'type'  => 'textarea',
                    'label' => 'Value'
                ]
            ]
        ];
    }
}