Jake Vanderwerf
9 days ago ed57c386db34d8693ca75311972d0929ebe5f488
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
   {
@@ -113,7 +134,16 @@
      {
         //Ignore for both
         $base = [
            'core/null'
            'core/null',
            'core/list-item',
            'core/post-content',
            'jvb/drawer-menu',
            'jvb/summary',
            'jvb/feed',
            'jvb/forms',
            'jvb/gmbreviews',
            'jvb/timeline',
            'jvb/video',
         ];
         if ($isPrerender) {
            $base = array_merge($base, [
@@ -140,13 +170,20 @@
    public function render(string $content, array $block):string
    {
      if ($block['blockName'] === 'jvb/feed') {
         // Enqueue the feed block script (it will automatically load dependencies)
         $this->localize_feedblock();
      switch ($block['blockName']) {
         case 'jvb/feed':
            $this->localize_feedblock();
            break;
         case 'jvb/forms':
            wp_enqueue_style('jvb-form');
            break;
         case 'jvb/timeline':
            wp_enqueue_script('jvb-gallery');
            add_action('wp_footer', 'jvbRenderGallery');
            break;
      }
      if ($block['blockName'] === 'jvb/forms') {
         wp_enqueue_style('jvb-form');
      }
      return $this->checkMethods($content, $block);
    }
@@ -731,7 +768,11 @@
         '<table%s',
         $this->getClassesAndStyles($attrs)
      ), $table);
      $caption = str_replace(strtok($parts[1], '>'), '<figcaption', $parts[1]);
      $caption = '';
      if (array_key_exists(1, $parts)) {
         $caption = str_replace(strtok($parts[1], '>'), '<figcaption', $parts[1]);
      }
      return sprintf(
         '<figure%s>%s%s</figure>',
@@ -1375,6 +1416,7 @@
            );
         }
      }
      return sprintf(
         '<ul%s>%s</ul>',
         $this->getClassesAndStyles($block['attrs']??[], ['loop']),
@@ -1496,7 +1538,9 @@
      protected function buildQueryArgs(array $attrs): array
      {
         $queryID = $attrs['queryId'] ?? null;
         $args = [];
         $args = [
            'post_status'  => 'publish',
         ];
         foreach (($attrs['query'] ?? []) as $key => $value) {
            if (empty($value)) continue;
            switch ($key) {
@@ -2784,8 +2828,9 @@
         $type = 'row';
         $isRow = true;
         //Determine type
         if ((array_key_exists('type', $value) && !in_array($value['type'], ['flex', 'grid'])) ||
         if ((array_key_exists('type', $value) && !in_array($value['type'], ['flex', 'grid', 'default'])) ||
            (array_key_exists('orientation', $value) && $value['orientation'] === 'vertical')) {
            $type = 'col';
            $isRow = false;
@@ -3420,6 +3465,7 @@
                     break;
                  case 'textAlign':
                     $styles['text-align'] = $value;
                     break;
                  default:
                     if (JVB_TESTING) {
                        jvbDump($value,'[getTypographyStyle] No property set for '.$property.': ');