Jake Vanderwerf
2026-04-15 c4aa5cdb5e90ad4b420e22772797d16980232a2b
inc/registrar/config/seo/Resolver.php
@@ -16,6 +16,13 @@
   public static function resolve(string $template, ?Meta $meta): string
   {
      if (!$meta) {
         if (is_singular()){
            $meta = Meta::forPost(get_the_ID());
         }else if (is_tax()) {
            $meta = Meta::forTerm(get_queried_object()->term_id);
         }
      }
      self::$meta = $meta;
      return preg_replace_callback(
         '/\{\{([^}]+)}}/',
@@ -45,6 +52,9 @@
         error_log('[SEO]Meta Resolver. Could not find meta configuration for variable: '.$variable);
         return '';
      }
      if ($variable === 'post_content') {
         return self::resolvePostContent($variable, $meta);
      }
      return match($config['type']) {
         'upload', 'image', 'gallery' => self::resolveImage($variable, $meta),
         'selector', 'taxonomy', 'user', 'post' => self::resolveObject($variable, $meta),
@@ -69,6 +79,8 @@
         }
      }
      error_log('resolveRelation: '.print_r($path, true));
      $ID = $meta->get($relation);
      if (!$ID || $ID === '') {
         return '';
@@ -78,14 +90,16 @@
      if (!$config) {
         return '';
      }
      $type = false;
      if ($config['type'] === 'taxonomy' || array_key_exists('taxonomy', $config)) {
         $type = 'taxonomy';
      } elseif ($config['type'] === 'user'){
         $type = 'term';
      } elseif ($config['type'] === 'user' || array_key_exists('user', $config)){
         $type = 'user';
      } elseif ($config['type'] === 'post'){
      } elseif ($config['type'] === 'post' || array_key_exists('post', $config)){
         $type = 'post';
      }
      if (!$type) {
         error_log('[SEO]Meta Resolver. Could not find type for relation: '.$relation.': '.$field);
         return '';
@@ -95,6 +109,9 @@
      return self::resolve($field, $newMeta);
   }
   protected static function resolvePostContent(string $variable, ?Meta $meta):string{
      return wp_strip_all_tags(str_replace("\n", '', $meta->get('post_content')));
   }
   protected static function resolveImage(string $variable, ?Meta $meta, bool $returnID = false): string
   {
      $imgID = $meta->get($variable);
@@ -133,7 +150,11 @@
         return $checkType;
      }
      error_log('[SEO]Resolver - No method found for '.$property.' with value: '.print_r($value, true).'. Defaulting to base Resolver');
      $ignore = ['description', 'name'];
      if (!in_array($property, $ignore)) {
         error_log('[SEO]Resolver - No method found for '.$property.' with value: '.print_r($value, true).'. Defaulting to base Resolver');
      }
      return self::resolve($value, $meta);
   }