Jake Vanderwerf
5 days ago a9b3b28d001941921aa70d37fdc87c758a163a44
inc/registrar/config/seo/Schema.php
@@ -93,49 +93,8 @@
      add_action('wp_head', [$this, 'outputSchema'], 1);
      add_filter('the_seo_framework_schema_graph_data', [$this, 'filterTSFSchema'], 10, 2);
      add_filter('the_seo_framework_title_from_custom_field', [$this, 'filterTSFOGTitle'], 10, 2);
      $this->maybeExcludeSingles();
   }
      protected function maybeExcludeSingles(): void
      {
         $exclude = $this->cache->remember(
            'excludeSingles',
            function () {
               $exclude = [];
               $registrar = Registrar::getInstance($this->slug);
               if ($registrar && $registrar->hasFeature('hide_single')) {
                  $exclude = $this->excludeSingle();
               }
               if ($registrar && $registrar->hasFeature('is_timeline')) {
                  $exclude = array_merge($exclude, $this->excludeTimeline());
               }
               return $exclude;
            }
         );
         if (!empty($exclude)) {
            add_filter('the_seo_framework_sitemap_exclude_ids', $exclude);
         }
      }
      protected function excludeSingle():array
      {
         return get_posts([
            'post_type'    => jvbCheckBase($this->slug),
            'posts_per_page'=> -1,
            'fields'    => 'ids',
            'post_status'  => 'publish',
         ]);
      }
      protected function excludeTimeline():array
      {
         return get_posts([
            'post_type'    => jvbCheckBase($this->slug),
            'posts_per_page'=> -1,
            'fields'    => 'ids',
            'post_status'  => 'publish',
            'post_parent__not_in'   => [0], // Only get posts with a parent
         ]);
      }
   public function filterTSFSchema(array $graph, ?array $args):array
   {
      $based = jvbCheckBase($this->slug);
@@ -277,7 +236,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'
@@ -317,6 +276,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);
@@ -333,7 +299,10 @@
            }
            $config = $this->getConfig();
            $class = JVB()->schemaHelper()::classFromConfig($config, $meta);
            $class->delete('about');
            if ($class) {
               $class->delete('about');
            }
            switch ($type) {
               case 'post':
@@ -477,6 +446,7 @@
            'type'   => 'JVBase\inc\managers\SEO\render\Thing\CreativeWork\Comment\Answer',
            'text'   => wp_strip_all_tags(str_replace("\n", '', $meta->get('post_content'))),
         ],
         'answerCount'  => 1,
      ];
      $question = SchemaHelper::classFromConfig($question);
      $page->setMainEntity($question);