Jake Vanderwerf
2026-02-17 a24a06002081ad71a78ffeff9072725ba39cf121
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
<?php
namespace JVBase\managers\SEO\schemas;
 
if (!defined('ABSPATH')) {
    exit;
}
 
/**
 * Value object representing a schema entity to be resolved.
 *
 * Like Operation.php holds the data for a queue item,
 * this holds the data for a schema entity being built.
 */
final class SchemaDefinition
{
    /** @var string Schema.org type (e.g., 'TattooParlor', 'VisualArtwork') */
    public string $schemaType = '';
 
    /** @var string|null JSON-LD @id (e.g., 'https://site.com/#organization') */
    public ?string $id = null;
 
    /** @var int|null WordPress object ID (post ID, term ID, user ID) */
    public ?int $objectId = null;
 
    /** @var string|null Object type: post, term, user, archive */
    public ?string $objectType = null;
 
    /** @var string|null Content type slug from constants (tattoo, artist, shop) */
    public ?string $contentType = null;
 
    /** @var array Saved SEO config from ConfigManager */
    public array $config = [];
 
    /** @var array Additional context (archive type, parent term, etc.) */
    public array $context = [];
 
    /**
     * Create from the current SchemaOutputManager context
     */
    public static function fromContext(
        string $schemaType,
        array $config,
        ?string $id = null,
        ?array $wpContext = null
    ): self {
        $def = new self();
        $def->schemaType = $schemaType;
        $def->config = $config;
        $def->id = $id;
 
        if ($wpContext) {
            $def->objectId = $wpContext['objectId'] ?? null;
            $def->objectType = $wpContext['objectType'] ?? null;
            $def->contentType = $wpContext['type'] ?? null;
        }
 
        return $def;
    }
}