Jake Vanderwerf
8 days ago 3b83905603d44b1a08f8b2b36a605808ce686ad6
inc/registrar/config/seo/Schema.php
@@ -23,6 +23,7 @@
   protected array $properties = [];
   protected array $referenceProperties = [];
   protected array $extras = [];
   protected array $defaultReference = [
      'name'   => '{{post_title}}',
      'url' => '{{post_permalink}}',
@@ -67,6 +68,8 @@
         }
         $this->defaultArchive['description'] = '{{registrar.'.$slug.'.description}}';
      }
      $this->extras = apply_filters(BASE.ucfirst($slug).'Extras', []);
      $this->initFilters();
      $this->registerHooks();
   }
@@ -274,7 +277,7 @@
               $class->setIsPartOf(get_home_url().'/#website');
               $itemList = new render\Thing\Intangible\ItemList\ItemList();
               $items = new WP_Query([
                  'post_type'    => jvbCheckBase($this->slug),
                  'post_type'    => $registrar->getBased(),
                  'posts_per_page'=> 25,
                  'post_status'  => 'publish',
                  'fields'    => 'ids'
@@ -295,6 +298,7 @@
               $class->setMainEntity($itemList);
               $schema = $class->outputSchema();
               if (JVB_TESTING) {
//                error_log('Generated archive schema: '.print_r($schema, true));
               }
@@ -313,6 +317,13 @@
      $cached = $this->referenceCache->remember(
         $ID,
         function () use ($ID, $type) {
            $postType = get_post_type($ID);
            $function = BASE.'build_singular_'.jvbNoBase($postType).'_schema_reference';
            if (function_exists($function)) {
               return $function($ID);
            }
            switch ($type) {
               case 'post':
                  $meta = Meta::forPost($ID);
@@ -329,7 +340,10 @@
            }
            $config = $this->getConfig();
            $class = JVB()->schemaHelper()::classFromConfig($config, $meta);
            $class->delete('about');
            if ($class) {
               $class->delete('about');
            }
            switch ($type) {
               case 'post':
@@ -659,4 +673,20 @@
      $page->setMainEntity($termset);
      return $page->outputSchema();
   }
   public function extra():array
   {
      if (empty($this->extras)) {
         return [];
      }
      $out = [];
      foreach ($this->extras as $config) {
         $schema = SchemaHelper::classFromConfig($config);
         $output = $schema->outputSchema();
         if (!empty($output)) {
            $out[] = $output;
         }
      }
      return $out;
   }
}