Jake Vanderwerf
10 days ago 97e7c319d656a5f05489ca996e249e7359303d4d
inc/blocks/CustomBlocks.php
@@ -24,7 +24,7 @@
   protected static ?int $currentQueryId = null;
   protected static array $counters = [];
   protected static ?WP_Query $originalQuery = null;
   protected array $ignore = ['align','alt','area','aspectRatio','backgroundColor','borderColor','buttonText','buttonPosition','buttonUseIcon','categories','className','columns','contentPosition','customOverlayColor','dimRatio','displayAsDropdown','displayAuthor','displayFeaturedImage','displayPostContent','displayPostContentRadio','displayPostDate','excerptLength','featuredImageAlign','fontSize','gradient','hasFixedLayout','hasParallax','height','iconColor','iconColorValue','iconColorValue','iconBackgroundColor','iconBackgroundColorValue','id','imageFill','isDark','isLink','isObjectPosition','isRepeated','isSearchFieldHidden','isStackedOnMobile','isUserOverlayColor','kind','label','largestFontSize','layout','lightbox','linkDestination','linkTo','level','mediaId','mediaLink','mediaPosition','mediaSizeSlug','mediaType','mediaWidth','metadata','minHeight','minHeightUnit','opacity','opensInNewTab','order','orderBy','ordered','overlayColor','overlayMenu','placeholder','postLayout','postsToShow','query', 'queryId','ref','rel','scale','shouldSyncIcon','showContent','showEmpty','showHierarchy','showLabel','showLabels','showOnlyTopLevel','showPostCounts','showTagCounts','size','sizeSlug','slug','smallestFontSize','tagName','taxonomy','term','textAlign','textColor','theme','title','type','url','useFeaturedImage','verticalAlignment','width','widthUnit',];
   protected array $ignore = ['align','alt','area','aspectRatio','backgroundColor','borderColor','buttonText','buttonPosition','buttonUseIcon','categories','className','columns','contentPosition','customOverlayColor','datetime','dimRatio','displayAsDropdown','displayAuthor','displayFeaturedImage','displayPostContent','displayPostContentRadio','displayPostDate','excerptLength','featuredImageAlign','fontSize','gradient','hasFixedLayout','hasParallax','height','iconColor','iconColorValue','iconColorValue','iconBackgroundColor','iconBackgroundColorValue','id','imageFill','isDark','isLink','isObjectPosition','isRepeated','isSearchFieldHidden','isStackedOnMobile','isUserOverlayColor','kind','label','largestFontSize','layout','lightbox','linkDestination','linkTo','level','mediaId','mediaLink','mediaPosition','mediaSizeSlug','mediaType','mediaWidth','metadata','minHeight','minHeightUnit','opacity','opensInNewTab','order','orderBy','ordered','overlayColor','overlayMenu','placeholder','postLayout','postsToShow','query', 'queryId','ref','rel','scale','shouldSyncIcon','showContent','showEmpty','showHierarchy','showLabel','showLabels','showOnlyTopLevel','showPostCounts','showTagCounts','size','sizeSlug','slug','smallestFontSize','tagName','taxonomy','term','textAlign','textColor','theme','title','type','url','useFeaturedImage','verticalAlignment','width','widthUnit',];
   //For custom style output for nested links, etc
   protected static array $pendingStyles = [];
@@ -88,6 +88,27 @@
                'label' => __('With Logo', 'jvb')
            ]
        );
        register_block_style(
            'core/gallery',
            [
                'name'  =>'hexagon',
                'label' => __('Hexagonal', 'jvb')
            ]
        );
        register_block_style(
            'core/gallery',
            [
                'name'  =>'diamond',
                'label' => __('Diamond', 'jvb')
            ]
        );
        register_block_style(
            'core/gallery',
            [
                'name'  =>'cut',
                'label' => __('Cut Corners', 'jvb')
            ]
        );
    }
   protected function checkMethods(?string $content, array $block, ?WP_Block $parent = null, bool $isPrerender = false):?string
   {
@@ -102,7 +123,7 @@
      } else if (method_exists($this, $method)) {
         $content = $this->$method($block, $content, $parent);
         return $isPrerender ? $this->maybeOutputCustomStyles().$content : $content;
      } elseif (!empty($blockName) && JVB_TESTING) {
      } elseif (JVB_TESTING && !empty($blockName)) {
         if (!in_array($block['blockName'], $this->getIgnore($isPrerender))) {
            jvbDump('No method found for '.print_r($block['blockName'], true));
         }
@@ -113,7 +134,13 @@
      {
         //Ignore for both
         $base = [
            'core/null'
            'core/null',
            'core/list-item',
            'core/post-content',
            'jvb/drawer-menu',
            'jvb/summary',
            'jvb/feed',
            'jvb/forms',
         ];
         if ($isPrerender) {
            $base = array_merge($base, [
@@ -231,7 +258,7 @@
    public function prerender_core_columns(array $block, ?string $content, ?WP_Block $parent):?string
    {
      jvbDump($block, 'columns');
//    jvbDump($block, 'columns');
      $attrs = $block['attrs']??[];
      $tagName = array_key_exists('tagName', $attrs) ? $attrs['tagName'] : 'section';
@@ -654,7 +681,7 @@
    public function prerender_core_paragraph(array $block, ?string $content, ?WP_Block $parent):?string
    {
      jvbDump($block, 'paragraph');
//    jvbDump($block, 'paragraph');
//    jvbDump($parent, 'Parent');
      $inside = $this->inside($block);
        return empty($inside) ? '' : sprintf(
@@ -1359,7 +1386,10 @@
      $inner = '';
      if (!static::$currentLoop) {
         jvbDump('No loop stored');
         if (JVB_TESTING) {
            jvbDump('No loop stored');
         }
         return $content;
      }
      if (static::$currentLoop->have_posts()) {
@@ -1799,7 +1829,7 @@
   public function prerender_core_query_title(array $block, ?string $content, ?WP_Block $parent):?string
   {
      jvbDump($block, 'query title');
//    jvbDump($block, 'query title');
      $attr = $block['attrs'];
      $name = '';
      $showPrefix = $attr['showPrefix']??false;
@@ -1952,7 +1982,7 @@
    //core_archives
   public function render_core_archives(array $block, string $content):string
   {
      jvbDump($block, 'archives');
//    jvbDump($block, 'archives');
      $attrs = $block['attrs']??[];
      $isDropdown = $this->checkAttrs('displayAsDropdown', $attrs);
@@ -2214,7 +2244,6 @@
      }
      $inside = [];
      foreach($pages->posts as $page) {
         jvbDump($page);
         $inside[] = sprintf(
            '<li><a href="%s">%s</a>',
            get_the_permalink($page->ID),
@@ -3209,7 +3238,10 @@
                     $styles['color'] = $this->getColor($v['text']);
                  }
                  if (isset($v['gradient'])) {
                     jvbDump($v, 'Gradient');
                     if (JVB_TESTING) {
                        jvbDump($v, 'Gradient');
                     }
                  }
                  break;
@@ -3279,7 +3311,9 @@
                     if ($sk === 'minHeight') {
                        $styles['min-height'] = $sv;
                     } else {
                        jvbDump('No config set for dimension '.$sk.': '.print_r($sv, true));
                        if (JVB_TESTING) {
                           jvbDump('No config set for dimension '.$sk.': '.print_r($sv, true));
                        }
                     }
                  }
@@ -3340,7 +3374,7 @@
               unset($border['style']);
               unset($border['color']);
               if (!empty($border)) {
                  jvbDump($border,'[getBorderStyle] Leftover styles:');
                  jvbDump($border, '[getBorderStyle] Leftover styles:');
               }
            }
@@ -3413,6 +3447,7 @@
                     break;
                  case 'textAlign':
                     $styles['text-align'] = $value;
                     break;
                  default:
                     if (JVB_TESTING) {
                        jvbDump($value,'[getTypographyStyle] No property set for '.$property.': ');
@@ -3443,8 +3478,11 @@
                  }, $selectors);
                  $fullSelector = implode(',', $fullSelector);
                  jvbDump($state, 'state');
                  jvbDump($rules, 'rules');
                  if (JVB_TESTING) {
                     jvbDump($state, 'state');
                     jvbDump($rules, 'rules');
                  }
                  if (isset($rules['color']['text']) || isset($rules['text'])) {
                     $css['color'] = $this->getColor($rules['color']['text'] ?? $rules['text']);