From c88689bac005d4502f7e8afdde0103a0cc0c58f6 Mon Sep 17 00:00:00 2001 From: POK Date: Wed, 4 Dec 2024 10:29:21 -0800 Subject: [PATCH] updates to taxonomy block --- build/taxonomy-archive-links/block.json | 24 ++++++ build/taxonomy-archive-links/index.asset.php | 2 +- build/taxonomy-archive-links/index.js | 2 +- build/taxonomy-archive-links/render.php | 55 +++++++++++-- build/taxonomy-archive-links/style-index.css | 2 +- carkeek-blocks.php | 2 +- .../class-carkeekblocks-custom-archive.php | 1 - readme.txt | 3 + src/taxonomy-archive-links/block.json | 24 ++++++ src/taxonomy-archive-links/inspector.js | 78 ++++++++++++++++++- src/taxonomy-archive-links/render.php | 55 +++++++++++-- src/taxonomy-archive-links/style.scss | 72 +++++++++++++++++ 12 files changed, 298 insertions(+), 22 deletions(-) diff --git a/build/taxonomy-archive-links/block.json b/build/taxonomy-archive-links/block.json index d4dcb6e..ff202fa 100644 --- a/build/taxonomy-archive-links/block.json +++ b/build/taxonomy-archive-links/block.json @@ -37,6 +37,10 @@ "type": "boolean", "default": false }, + "excludeChildTerms": { + "type": "boolean", + "default": false + }, "className": { "type": "string" }, @@ -62,6 +66,26 @@ "listLabel": { "type": "string", "default": "" + }, + "archiveType": { + "type": "string", + "default": "wordpress" + }, + "archivePage": { + "type": "string", + "default": "" + }, + "archiveFacet": { + "type": "string", + "default": "" + }, + "tileImageField": { + "type": "string", + "default": "" + }, + "tileImageStyle": { + "type": "string", + "default": "icon" } }, "supports": { diff --git a/build/taxonomy-archive-links/index.asset.php b/build/taxonomy-archive-links/index.asset.php index b327122..ca0622d 100644 --- a/build/taxonomy-archive-links/index.asset.php +++ b/build/taxonomy-archive-links/index.asset.php @@ -1 +1 @@ - array('react', 'wp-block-editor', 'wp-blocks', 'wp-components', 'wp-data', 'wp-i18n', 'wp-server-side-render'), 'version' => '668476cde0271b785599'); + array('react', 'wp-block-editor', 'wp-blocks', 'wp-components', 'wp-data', 'wp-i18n', 'wp-server-side-render'), 'version' => '28073c9e1afa613f42a7'); diff --git a/build/taxonomy-archive-links/index.js b/build/taxonomy-archive-links/index.js index 6c2365d..04e6620 100644 --- a/build/taxonomy-archive-links/index.js +++ b/build/taxonomy-archive-links/index.js @@ -1 +1 @@ -(()=>{"use strict";var e,t={857:(e,t,l)=>{const a=window.React,o={};o.layout=(0,a.createElement)("svg",{xmlns:"http://www.w3.org/2000/svg",width:"100",height:"100",x:"0",y:"0",viewBox:"0 0 100 100"},(0,a.createElement)("path",{d:"M66.046 50.783H33.953a1.344 1.344 0 010-2.688h32.092a1.344 1.344 0 01.001 2.688zM54.281 55.71h-8.563a1.344 1.344 0 010-2.688h8.563a1.344 1.344 0 010 2.688zM33.876 78.937H16.903a1.344 1.344 0 01-1.344-1.344V60.62c0-.742.602-1.344 1.344-1.344h16.974c.742 0 1.344.602 1.344 1.344v16.973a1.346 1.346 0 01-1.345 1.344zm-15.63-2.688h14.286V61.964H18.246v14.285zM58.486 78.937H41.512a1.344 1.344 0 01-1.344-1.344V60.62c0-.742.602-1.344 1.344-1.344h16.974c.742 0 1.344.602 1.344 1.344v16.973c0 .742-.602 1.344-1.344 1.344zm-15.63-2.688h14.286V61.964H42.856v14.285zM83.096 78.937H66.123a1.344 1.344 0 01-1.344-1.344V60.62c0-.742.602-1.344 1.344-1.344h16.973c.742 0 1.344.602 1.344 1.344v16.973c0 .742-.602 1.344-1.344 1.344zm-15.629-2.688h14.285V61.964H67.467v14.285z"}),(0,a.createElement)("g",null,(0,a.createElement)("path",{d:"M50 45.009a5.115 5.115 0 01-5.11-5.11 5.115 5.115 0 015.11-5.11 5.115 5.115 0 015.109 5.11A5.115 5.115 0 0150 45.009zm0-7.531a2.425 2.425 0 00-2.422 2.422c0 1.335 1.087 2.422 2.422 2.422s2.421-1.086 2.421-2.422A2.424 2.424 0 0050 37.478z"})),(0,a.createElement)("g",null,(0,a.createElement)("path",{d:"M93.656 15.452H6.344A1.34 1.34 0 005 16.796v66.408a1.34 1.34 0 001.344 1.344h87.312c.739 0 1.344-.598 1.344-1.344V16.796c0-.746-.605-1.344-1.344-1.344zM92.312 81.86H7.688V30.329h84.624V81.86zm0-54.219H7.688V18.14h84.624v9.501z"})),(0,a.createElement)("g",null,(0,a.createElement)("ellipse",{cx:"13.173",cy:"22.714",rx:"2.108",ry:"2.103"})),(0,a.createElement)("g",null,(0,a.createElement)("ellipse",{cx:"19.919",cy:"22.714",rx:"2.108",ry:"2.103"})),(0,a.createElement)("g",null,(0,a.createElement)("ellipse",{cx:"26.665",cy:"22.714",rx:"2.108",ry:"2.103"})));const r=o,n=window.wp.blockEditor,s=window.wp.i18n,c=window.wp.components,i=function(e){const{taxonomies:t,attributes:l,setAttributes:o}=e,{taxonomySelected:r,sortBy:i,order:m,relevantToPost:u,linkToCategory:p,displayAs:d,separator:y,showBullets:h,listLabel:b}=l;let g=[];if(t&&(g=t.map((e=>({value:e.slug,label:e.name})))),!r){const e={value:null,label:"Select a Taxonomy"};g.unshift(e)}const k=(0,a.createElement)(a.Fragment,null,t&&t.length>0?(0,a.createElement)(a.Fragment,null,(0,a.createElement)(c.SelectControl,{label:(0,s.__)("Select a Taxonomy","carkeek-blocks"),onChange:e=>o({taxonomySelected:e}),options:g,value:r,help:(0,s.__)("Select a taxonomy to display its terms","carkeek-blocks")})):(0,a.createElement)("div",{className:"ck-error"},(0,s.__)("There are no available taxonomies.","carkeek-blocks")));return(0,a.createElement)(n.InspectorControls,null,(0,a.createElement)(c.PanelBody,{title:(0,s.__)("Posts Settings","carkeek-blocks")},k,(0,a.createElement)(c.SelectControl,{label:(0,s.__)("Sort By","carkeek-blocks"),help:(0,s.__)("If it seems that your sorting selections aren't working, check for a taxonomy terms order plugin, if installed, you can manage the sort there.","carkeek-blocks"),onChange:e=>o({sortBy:e}),options:[{label:(0,s.__)("Title (alpha)"),value:"name"},{label:(0,s.__)("Menu Order"),value:"menu_order"}],value:i}),(0,a.createElement)(c.RadioControl,{label:(0,s.__)("Order"),selected:m,options:[{label:(0,s.__)("ASC"),value:"ASC"},{label:(0,s.__)("DESC"),value:"DESC"}],onChange:e=>o({order:e})}),(0,a.createElement)(c.ToggleControl,{label:"Limit to current post",checked:u,onChange:e=>o({relevantToPost:e})}),(0,a.createElement)(c.ToggleControl,{label:"Link items to category archive",checked:p,onChange:e=>o({linkToCategory:e})})),(0,a.createElement)(c.PanelBody,{title:(0,s.__)("Layout Style","carkeek-blocks")},(0,a.createElement)(c.TextControl,{label:"Label",value:b,onChange:e=>o({listLabel:e})}),(0,a.createElement)(c.SelectControl,{label:(0,s.__)("Display As","carkeek-blocks"),onChange:e=>o({displayAs:e}),options:[{label:(0,s.__)("Vertical List"),value:"list"},{label:(0,s.__)("Horizontal (inline) List"),value:"inline"}],value:d}),"inline"===d&&(0,a.createElement)(c.SelectControl,{label:(0,s.__)("Separator","carkeek-blocks"),onChange:e=>o({separator:e}),options:[{label:(0,s.__)("Comma (,)"),value:"comma"},{label:(0,s.__)("Bullet (•)"),value:"bullet"},{label:(0,s.__)("Pipe (|)"),value:"pipe"}],value:y}),"list"===d&&(0,a.createElement)(c.ToggleControl,{label:"Include bullets?",checked:h,onChange:e=>o({showBullets:e})})))},m=window.wp.serverSideRender;var u=l.n(m);const p=(0,window.wp.data.withSelect)(((e,t)=>{const{attributes:l}=t,{taxonomySelected:a}=l,{getEntityRecords:o,getTaxonomies:r}=e("core"),n=o("taxonomy",a,{per_page:-1});let s=r({per_page:-1});return{taxonomies:s,taxSelected:Array.isArray(s)&&1==s.length?s[0]:a,taxTerms:n}}))((function(e){const{attributes:t,name:l}=e,{taxonomySelected:o}=t,m=(0,n.useBlockProps)();if(!o){const t=(0,s.__)("Select a Taxonomy Type from the Block Settings");return(0,a.createElement)("div",{...m},(0,a.createElement)(i,{...e}),(0,a.createElement)(c.Placeholder,{icon:r.layout,label:(0,s.__)("Taxonomy Terms")},t))}return(0,a.createElement)("div",{...m},(0,a.createElement)(i,{...e}),(0,a.createElement)(u(),{block:l,attributes:e.attributes}))})),d=JSON.parse('{"$schema":"https://schemas.wp.org/trunk/block.json","apiVersion":2,"name":"carkeek-blocks/taxonomy-terms","title":"Taxonomy Archive List","category":"widgets","description":"Place taxonomy terms list on a page","keywords":["taxonomy","terms","archive"],"version":"1.0.0","textdomain":"carkeek-blocks","editorScript":"file:./index.js","style":"file:./style-index.css","render":"file:./render.php","attributes":{"taxonomySelected":{"type":"string"},"level":{"type":"number"},"excludeTerms":{"type":"string"},"sortBy":{"type":"string","default":"name"},"order":{"type":"string","default":"ASC"},"relevantToPost":{"type":"boolean","default":false},"className":{"type":"string"},"linkToCategory":{"type":"boolean","default":true},"align":{"type":"string"},"displayAs":{"type":"string","default":"list"},"showBullets":{"type":"boolean","default":false},"separator":{"type":"string","default":"comma"},"listLabel":{"type":"string","default":""}},"supports":{"align":["wide","full","left","right","center"]}}');(0,window.wp.blocks.registerBlockType)(d,{icon:r.layout,edit:p,save:()=>null})}},l={};function a(e){var o=l[e];if(void 0!==o)return o.exports;var r=l[e]={exports:{}};return t[e](r,r.exports,a),r.exports}a.m=t,e=[],a.O=(t,l,o,r)=>{if(!l){var n=1/0;for(m=0;m=r)&&Object.keys(a.O).every((e=>a.O[e](l[c])))?l.splice(c--,1):(s=!1,r0&&e[m-1][2]>r;m--)e[m]=e[m-1];e[m]=[l,o,r]},a.n=e=>{var t=e&&e.__esModule?()=>e.default:()=>e;return a.d(t,{a:t}),t},a.d=(e,t)=>{for(var l in t)a.o(t,l)&&!a.o(e,l)&&Object.defineProperty(e,l,{enumerable:!0,get:t[l]})},a.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),(()=>{var e={9214:0,2706:0};a.O.j=t=>0===e[t];var t=(t,l)=>{var o,r,[n,s,c]=l,i=0;if(n.some((t=>0!==e[t]))){for(o in s)a.o(s,o)&&(a.m[o]=s[o]);if(c)var m=c(a)}for(t&&t(l);ia(857)));o=a.O(o)})(); \ No newline at end of file +(()=>{"use strict";var e,t={857:(e,t,l)=>{const a=window.React,r={};r.layout=(0,a.createElement)("svg",{xmlns:"http://www.w3.org/2000/svg",width:"100",height:"100",x:"0",y:"0",viewBox:"0 0 100 100"},(0,a.createElement)("path",{d:"M66.046 50.783H33.953a1.344 1.344 0 010-2.688h32.092a1.344 1.344 0 01.001 2.688zM54.281 55.71h-8.563a1.344 1.344 0 010-2.688h8.563a1.344 1.344 0 010 2.688zM33.876 78.937H16.903a1.344 1.344 0 01-1.344-1.344V60.62c0-.742.602-1.344 1.344-1.344h16.974c.742 0 1.344.602 1.344 1.344v16.973a1.346 1.346 0 01-1.345 1.344zm-15.63-2.688h14.286V61.964H18.246v14.285zM58.486 78.937H41.512a1.344 1.344 0 01-1.344-1.344V60.62c0-.742.602-1.344 1.344-1.344h16.974c.742 0 1.344.602 1.344 1.344v16.973c0 .742-.602 1.344-1.344 1.344zm-15.63-2.688h14.286V61.964H42.856v14.285zM83.096 78.937H66.123a1.344 1.344 0 01-1.344-1.344V60.62c0-.742.602-1.344 1.344-1.344h16.973c.742 0 1.344.602 1.344 1.344v16.973c0 .742-.602 1.344-1.344 1.344zm-15.629-2.688h14.285V61.964H67.467v14.285z"}),(0,a.createElement)("g",null,(0,a.createElement)("path",{d:"M50 45.009a5.115 5.115 0 01-5.11-5.11 5.115 5.115 0 015.11-5.11 5.115 5.115 0 015.109 5.11A5.115 5.115 0 0150 45.009zm0-7.531a2.425 2.425 0 00-2.422 2.422c0 1.335 1.087 2.422 2.422 2.422s2.421-1.086 2.421-2.422A2.424 2.424 0 0050 37.478z"})),(0,a.createElement)("g",null,(0,a.createElement)("path",{d:"M93.656 15.452H6.344A1.34 1.34 0 005 16.796v66.408a1.34 1.34 0 001.344 1.344h87.312c.739 0 1.344-.598 1.344-1.344V16.796c0-.746-.605-1.344-1.344-1.344zM92.312 81.86H7.688V30.329h84.624V81.86zm0-54.219H7.688V18.14h84.624v9.501z"})),(0,a.createElement)("g",null,(0,a.createElement)("ellipse",{cx:"13.173",cy:"22.714",rx:"2.108",ry:"2.103"})),(0,a.createElement)("g",null,(0,a.createElement)("ellipse",{cx:"19.919",cy:"22.714",rx:"2.108",ry:"2.103"})),(0,a.createElement)("g",null,(0,a.createElement)("ellipse",{cx:"26.665",cy:"22.714",rx:"2.108",ry:"2.103"})));const o=r,n=window.wp.blockEditor,c=window.wp.i18n,s=window.wp.components,i=function(e){const{taxonomies:t,attributes:l,setAttributes:r}=e,{taxonomySelected:o,sortBy:i,order:m,relevantToPost:u,linkToCategory:d,displayAs:p,separator:g,showBullets:h,listLabel:y,archiveType:v,archivePage:b,archiveFacet:k,tileImageField:_,tileImageStyle:f,excludeChildTerms:x}=l;let E=[];if(t&&(E=t.map((e=>({value:e.slug,label:e.name})))),!o){const e={value:null,label:"Select a Taxonomy"};E.unshift(e)}const C=(0,a.createElement)(a.Fragment,null,t&&t.length>0?(0,a.createElement)(a.Fragment,null,(0,a.createElement)(s.SelectControl,{label:(0,c.__)("Select a Taxonomy","carkeek-blocks"),onChange:e=>r({taxonomySelected:e}),options:E,value:o,help:(0,c.__)("Select a taxonomy to display its terms","carkeek-blocks")})):(0,a.createElement)("div",{className:"ck-error"},(0,c.__)("There are no available taxonomies.","carkeek-blocks")));return(0,a.createElement)(n.InspectorControls,null,(0,a.createElement)(s.PanelBody,{title:(0,c.__)("Posts Settings","carkeek-blocks")},C,(0,a.createElement)(s.SelectControl,{label:(0,c.__)("Sort By","carkeek-blocks"),help:(0,c.__)("If it seems that your sorting selections aren't working, check for a taxonomy terms order plugin, if installed, you can manage the sort there.","carkeek-blocks"),onChange:e=>r({sortBy:e}),options:[{label:(0,c.__)("Title (alpha)"),value:"name"},{label:(0,c.__)("Menu Order"),value:"menu_order"}],value:i}),(0,a.createElement)(s.RadioControl,{label:(0,c.__)("Order"),selected:m,options:[{label:(0,c.__)("ASC"),value:"ASC"},{label:(0,c.__)("DESC"),value:"DESC"}],onChange:e=>r({order:e})}),(0,a.createElement)(s.ToggleControl,{label:"Limit to current post",checked:u,onChange:e=>r({relevantToPost:e})}),(0,a.createElement)(s.ToggleControl,{label:"Link items to category archive",checked:d,onChange:e=>r({linkToCategory:e})}),(0,a.createElement)(s.ToggleControl,{label:"Exclude Child Terms",checked:x,onChange:e=>r({excludeChildTerms:e})})),(0,a.createElement)(s.PanelBody,{title:(0,c.__)("Layout Style","carkeek-blocks")},(0,a.createElement)(s.TextControl,{label:"Label",value:y,onChange:e=>r({listLabel:e})}),(0,a.createElement)(s.SelectControl,{label:(0,c.__)("Display As","carkeek-blocks"),onChange:e=>r({displayAs:e}),options:[{label:(0,c.__)("Vertical List"),value:"list"},{label:(0,c.__)("Horizontal (inline) List"),value:"inline"},{label:(0,c.__)("Link Tile"),value:"tile"}],value:p}),"inline"===p&&(0,a.createElement)(s.SelectControl,{label:(0,c.__)("Separator","carkeek-blocks"),onChange:e=>r({separator:e}),options:[{label:(0,c.__)("Comma (,)"),value:"comma"},{label:(0,c.__)("Bullet (•)"),value:"bullet"},{label:(0,c.__)("Pipe (|)"),value:"pipe"}],value:g}),"list"===p&&(0,a.createElement)(s.ToggleControl,{label:"Include bullets?",checked:h,onChange:e=>r({showBullets:e})})),"tile"===p&&(0,a.createElement)(s.PanelBody,{title:(0,c.__)("Tile Settings","carkeek-blocks")},(0,a.createElement)(s.TextControl,{label:"Image Field",value:_,onChange:e=>r({tileImageField:e})}),(0,a.createElement)(s.SelectControl,{label:(0,c.__)("Image Style","carkeek-blocks"),onChange:e=>r({tileImageStyle:e}),options:[{label:(0,c.__)("Icon"),value:"icon"},{label:(0,c.__)("Cover"),value:"cover"}],value:f})),d&&(0,a.createElement)(s.PanelBody,{title:(0,c.__)("Archive Settings","carkeek-blocks")},(0,a.createElement)(s.SelectControl,{label:(0,c.__)("Archive Type","carkeek-blocks"),onChange:e=>r({archiveType:e}),options:[{label:(0,c.__)("WordPress"),value:"wordpress"},{label:(0,c.__)("FacetWP"),value:"facetwp"}],value:v}),"facetwp"===v&&(0,a.createElement)(a.Fragment,null,(0,a.createElement)(s.TextControl,{label:"Archive URL",value:b,onChange:e=>r({archivePage:e})}),(0,a.createElement)(s.TextControl,{label:"Taxonomy Facet",value:k,onChange:e=>r({archiveFacet:e})}))))},m=window.wp.serverSideRender;var u=l.n(m);const d=(0,window.wp.data.withSelect)(((e,t)=>{const{attributes:l}=t,{taxonomySelected:a}=l,{getEntityRecords:r,getTaxonomies:o}=e("core"),n=r("taxonomy",a,{per_page:-1});let c=o({per_page:-1});return{taxonomies:c,taxSelected:Array.isArray(c)&&1==c.length?c[0]:a,taxTerms:n}}))((function(e){const{attributes:t,name:l}=e,{taxonomySelected:r}=t,m=(0,n.useBlockProps)();if(!r){const t=(0,c.__)("Select a Taxonomy Type from the Block Settings");return(0,a.createElement)("div",{...m},(0,a.createElement)(i,{...e}),(0,a.createElement)(s.Placeholder,{icon:o.layout,label:(0,c.__)("Taxonomy Terms")},t))}return(0,a.createElement)("div",{...m},(0,a.createElement)(i,{...e}),(0,a.createElement)(u(),{block:l,attributes:e.attributes}))})),p=JSON.parse('{"$schema":"https://schemas.wp.org/trunk/block.json","apiVersion":2,"name":"carkeek-blocks/taxonomy-terms","title":"Taxonomy Archive List","category":"widgets","description":"Place taxonomy terms list on a page","keywords":["taxonomy","terms","archive"],"version":"1.0.0","textdomain":"carkeek-blocks","editorScript":"file:./index.js","style":"file:./style-index.css","render":"file:./render.php","attributes":{"taxonomySelected":{"type":"string"},"level":{"type":"number"},"excludeTerms":{"type":"string"},"sortBy":{"type":"string","default":"name"},"order":{"type":"string","default":"ASC"},"relevantToPost":{"type":"boolean","default":false},"excludeChildTerms":{"type":"boolean","default":false},"className":{"type":"string"},"linkToCategory":{"type":"boolean","default":true},"align":{"type":"string"},"displayAs":{"type":"string","default":"list"},"showBullets":{"type":"boolean","default":false},"separator":{"type":"string","default":"comma"},"listLabel":{"type":"string","default":""},"archiveType":{"type":"string","default":"wordpress"},"archivePage":{"type":"string","default":""},"archiveFacet":{"type":"string","default":""},"tileImageField":{"type":"string","default":""},"tileImageStyle":{"type":"string","default":"icon"}},"supports":{"align":["wide","full","left","right","center"]}}');(0,window.wp.blocks.registerBlockType)(p,{icon:o.layout,edit:d,save:()=>null})}},l={};function a(e){var r=l[e];if(void 0!==r)return r.exports;var o=l[e]={exports:{}};return t[e](o,o.exports,a),o.exports}a.m=t,e=[],a.O=(t,l,r,o)=>{if(!l){var n=1/0;for(m=0;m=o)&&Object.keys(a.O).every((e=>a.O[e](l[s])))?l.splice(s--,1):(c=!1,o0&&e[m-1][2]>o;m--)e[m]=e[m-1];e[m]=[l,r,o]},a.n=e=>{var t=e&&e.__esModule?()=>e.default:()=>e;return a.d(t,{a:t}),t},a.d=(e,t)=>{for(var l in t)a.o(t,l)&&!a.o(e,l)&&Object.defineProperty(e,l,{enumerable:!0,get:t[l]})},a.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),(()=>{var e={9214:0,2706:0};a.O.j=t=>0===e[t];var t=(t,l)=>{var r,o,[n,c,s]=l,i=0;if(n.some((t=>0!==e[t]))){for(r in c)a.o(c,r)&&(a.m[r]=c[r]);if(s)var m=s(a)}for(t&&t(l);ia(857)));r=a.O(r)})(); \ No newline at end of file diff --git a/build/taxonomy-archive-links/render.php b/build/taxonomy-archive-links/render.php index 3b954b4..9274ac1 100644 --- a/build/taxonomy-archive-links/render.php +++ b/build/taxonomy-archive-links/render.php @@ -7,9 +7,14 @@ global $post; $term_list = ''; -$list_style = $attributes['showBullets'] == true ? '' : 'no-bullets '; -$list_style .= $attributes['displayAs'] == 'inline' ? 'list-inline ' : ''; -$list_style .= 'separator-' . $attributes['separator']; +if ( $attributes['displayAs'] == 'tile' ) { + $list_style = 'tile-list no-bullets'; +} else { + $list_style = $attributes['showBullets'] == true ? '' : 'no-bullets '; + $list_style .= $attributes['displayAs'] == 'inline' ? 'list-inline ' : ''; + $list_style .= 'separator-' . $attributes['separator']; +} + $aria_title = $attributes['listLabel'] ? $attributes['listLabel'] : 'Taxonomy List for ' . $attributes['taxonomySelected']; if ( true == $attributes['relevantToPost'] ) { $terms = get_the_terms( $post->ID, $attributes['taxonomySelected'] ); @@ -19,19 +24,53 @@ 'orderby' => $attributes['sortBy'], 'order' => $attributes['order'], ); + if ( $attributes['excludeChildTerms'] ) { + $args['parent'] = 0; + } $terms = get_terms( $args ); } + if ( ! empty( $terms ) && ! is_wp_error( $terms ) ) { $term_list = '
    '; foreach ( $terms as $term ) { - $term_link_url = apply_filters( 'ck_tax_archive_term_link', get_term_link( $term ), $term, $post ); - $term_link_text = apply_filters( 'ck_tax_archive_term_text', $term->name, $term, $post ); + $term_link_url = ''; + $term_link_text = $term->name; if ( true == $attributes['linkToCategory'] ) { - $term_link = '' . $term_link_text . ''; + if ( 'wordpress' == $attributes['archiveType'] ) { + $term_link_url = get_term_link( $term ); + } else if ( 'facetwp' == $attributes['archiveType'] ) { + $term_link_url = add_query_arg( + array( + $attributes['archiveFacet'] => $term->slug, + ), + $attributes['archivePage']); + } + } + $term_content = ''; + $term_icon = ''; + $tile_hover = ''; + if ( $attributes['displayAs'] == 'tile' ) { + $img_field = $attributes['tileImageField']; + if ( ! empty( $img_field ) ) { + $term_image = get_field( $img_field, $term ); + $img_style = $attributes['tileImageStyle']; + if ( ! empty( $term_image ) ) { + $term_icon = wp_get_attachment_image( $term_image, array('600', '600'), "", array( "class" => $img_style ) ); + } + } + $tile_hover = '
    ' . esc_html( $term->description ) . '
    '; + } + + $term_link_url = apply_filters( 'ck_tax_archive_term_link', $term_link_url, $term, $post ); + $term_link_text = apply_filters( 'ck_tax_archive_term_text', $term->name, $term, $post ); + if ( empty( $term_link_url ) ) { + $term_content .= esc_html( $term_link_text ); } else { - $term_link = $term_link_text; + $term_content .= '' . $term_icon . esc_html( $term_link_text ) . $tile_hover . ''; } - $term_list .= '
  • ' . $term_link . '
  • '; + + //$term_content .= $tile_hover; + $term_list .= '
  • ' . $term_content . '
  • '; } $term_list .= '
'; } diff --git a/build/taxonomy-archive-links/style-index.css b/build/taxonomy-archive-links/style-index.css index 893a569..8e5382e 100644 --- a/build/taxonomy-archive-links/style-index.css +++ b/build/taxonomy-archive-links/style-index.css @@ -1 +1 @@ -.wp-block-carkeek-blocks-taxonomy-terms.aligncenter{text-align:center}.wp-block-carkeek-blocks-taxonomy-terms ul.no-bullets{list-style:none;margin:0;padding:0}.wp-block-carkeek-blocks-taxonomy-terms ul.list-inline li{display:inline-block}.wp-block-carkeek-blocks-taxonomy-terms ul.list-inline li:last-child{margin-right:0}.wp-block-carkeek-blocks-taxonomy-terms ul.list-inline li:last-child:after{content:""!important}.wp-block-carkeek-blocks-taxonomy-terms ul.list-inline.separator-comma li:after{content:",";display:inline-block;padding-right:5px}.wp-block-carkeek-blocks-taxonomy-terms ul.list-inline.separator-bullet li:after{content:"•";display:inline-block;padding-left:5px;padding-right:5px}.wp-block-carkeek-blocks-taxonomy-terms ul.list-inline.separator-pipe li:after{content:"|";display:inline-block;padding-left:5px;padding-right:5px} +:root{--ck-blocks-tax-link-border:1px solid #c6c6c6;--ck-blocks-tax-link-border-radius:0;--ck-blocks-tax-link-gap:1.5rem;--ck-blocks-tax-link-padding:2.5rem 1.5rem;--ck-blocks-tax-link-text-color:var(--wp--preset--color--primary,#000);--ck-blocks-tax-link-background-color:var(--wp--preset--color--white,#fff);--ck-blocks-tax-link-hover-text-color:var(--wp--preset--color--white,#fff);--ck-blocks-tax-link-hover-background-color:var(--wp--preset--color--primary,#000);--ck-blocks-tax-link-icon-width:100px;--ck-blocks-tax-link-icon-height:72px;--ck-blocks-tax-link-aspect-ratio:1.223}.wp-block-carkeek-blocks-taxonomy-terms.aligncenter{text-align:center}.wp-block-carkeek-blocks-taxonomy-terms ul.no-bullets{list-style:none;margin:0;padding:0}.wp-block-carkeek-blocks-taxonomy-terms ul.list-inline li{display:inline-block}.wp-block-carkeek-blocks-taxonomy-terms ul.list-inline li:last-child{margin-right:0}.wp-block-carkeek-blocks-taxonomy-terms ul.list-inline li:last-child:after{content:""!important}.wp-block-carkeek-blocks-taxonomy-terms ul.list-inline.separator-comma li:after{content:",";display:inline-block;padding-right:5px}.wp-block-carkeek-blocks-taxonomy-terms ul.list-inline.separator-bullet li:after{content:"•";display:inline-block;padding-left:5px;padding-right:5px}.wp-block-carkeek-blocks-taxonomy-terms ul.list-inline.separator-pipe li:after{content:"|";display:inline-block;padding-left:5px;padding-right:5px}.wp-block-carkeek-blocks-taxonomy-terms ul.tile-list{display:grid;gap:var(--ck-blocks-tax-link-gap);grid-template-columns:repeat(3,1fr)}.wp-block-carkeek-blocks-taxonomy-terms ul.tile-list li{background-color:var(--ck-blocks-tax-link-background-color);border:var(--ck-blocks-tax-link-border);border-radius:var(--ck-blocks-tax-link-border-radius)}.wp-block-carkeek-blocks-taxonomy-terms ul.tile-list li a{align-items:center;aspect-ratio:var(--ck-blocks-tax-link-aspect-ratio);color:var(--ck-blocks-tax-link-text-color);display:flex;flex-direction:column;gap:1rem;overflow:hidden;padding:var(--ck-blocks-tax-link-padding);position:relative;text-align:center}.wp-block-carkeek-blocks-taxonomy-terms ul.tile-list li img.icon{height:var(--ck-blocks-tax-link-icon-height);margin-left:auto;margin-right:auto;-o-object-fit:contain;object-fit:contain;width:var(--ck-blocks-tax-link-icon-width)}.wp-block-carkeek-blocks-taxonomy-terms ul.tile-list li img.cover{bottom:0;left:0;-o-object-fit:cover;object-fit:cover;position:absolute;right:0;top:0}.wp-block-carkeek-blocks-taxonomy-terms ul.tile-list li .tile-hover{align-items:center;background-color:var(--ck-blocks-tax-link-hover-background-color);color:var(--ck-blocks-tax-link-hover-text-color);display:flex;flex-direction:column;height:100%;justify-content:center;padding:var(--ck-blocks-tax-link-padding);position:absolute;top:100%;transition:top .3s;width:100%}.wp-block-carkeek-blocks-taxonomy-terms ul.tile-list li:hover .tile-hover{top:0} diff --git a/carkeek-blocks.php b/carkeek-blocks.php index b952688..c872c6f 100644 --- a/carkeek-blocks.php +++ b/carkeek-blocks.php @@ -8,7 +8,7 @@ * Primary Branch: main * Description: Series of blocks designed to work with this site's custom Theme * Author: Patty O'Hara - * Version: 3.2.36 + * Version: 3.2.37 * Author URI https://carkeekstudios.com/ * Text Domain: carkeek-blocks */ diff --git a/includes/class-carkeekblocks-custom-archive.php b/includes/class-carkeekblocks-custom-archive.php index 13d2f9a..51d140d 100644 --- a/includes/class-carkeekblocks-custom-archive.php +++ b/includes/class-carkeekblocks-custom-archive.php @@ -458,7 +458,6 @@ function( $t ) { $query = new WP_Query( $args ); } - $posts = ''; if ( true == $related && true == $attributes['fillTheSlots'] && -1 !== $attributes['numberOfPosts'] ) { diff --git a/readme.txt b/readme.txt index 57d5083..aa51cfa 100644 --- a/readme.txt +++ b/readme.txt @@ -44,6 +44,9 @@ directory take precedence. For example, `/assets/screenshot-1.png` would win ove 2. This is the second screen shot == Changelog == += 3.2.37 = +* Release 3.2.37 = 12/04/24 + * Made some updates to the taxonomy block to support a link tile style taxonomy layout = 3.2.36 = * Release 3.2.35 = 10/25/24 * Added a expand/collapse button block. diff --git a/src/taxonomy-archive-links/block.json b/src/taxonomy-archive-links/block.json index ec9c073..7adabc6 100644 --- a/src/taxonomy-archive-links/block.json +++ b/src/taxonomy-archive-links/block.json @@ -33,6 +33,10 @@ "type": "boolean", "default": false }, + "excludeChildTerms": { + "type": "boolean", + "default": false + }, "className": { "type": "string" }, @@ -58,6 +62,26 @@ "listLabel": { "type": "string", "default": "" + }, + "archiveType": { + "type": "string", + "default": "wordpress" + }, + "archivePage": { + "type": "string", + "default": "" + }, + "archiveFacet": { + "type": "string", + "default": "" + }, + "tileImageField": { + "type": "string", + "default": "" + }, + "tileImageStyle": { + "type": "string", + "default": "icon" } }, "supports": { diff --git a/src/taxonomy-archive-links/inspector.js b/src/taxonomy-archive-links/inspector.js index fb0ef1a..dec282c 100644 --- a/src/taxonomy-archive-links/inspector.js +++ b/src/taxonomy-archive-links/inspector.js @@ -24,7 +24,14 @@ function postsInspector( props ){ displayAs, separator, showBullets, - listLabel + listLabel, + archiveType, + archivePage, + archiveFacet, + tileImageField, + tileImageStyle, + excludeChildTerms + } = attributes; @@ -105,6 +112,13 @@ function postsInspector( props ){ onChange={value => setAttributes({ linkToCategory: value }) } + /> + + setAttributes({ excludeChildTerms: value }) + } /> @@ -125,6 +139,7 @@ function postsInspector( props ){ options={[ { label: __("Vertical List"), value: "list"}, { label: __("Horizontal (inline) List"), value: "inline"}, + { label: __("Link Tile"), value: "tile"}, ]} value={displayAs} /> @@ -153,8 +168,69 @@ function postsInspector( props ){ } /> } + + { displayAs === 'tile' && + + + setAttributes({ tileImageField: value }) + } + /> + + setAttributes({ + tileImageStyle: value + }) + } + options={[ + { label: __("Icon"), value: "icon"}, + { label: __("Cover"), value: "cover"}, + ]} + value={tileImageStyle} + /> + } + { linkToCategory && + + + setAttributes({ + archiveType: value + }) + } + options={[ + { label: __("WordPress"), value: "wordpress"}, + { label: __("FacetWP"), value: "facetwp"}, + ]} + value={archiveType} + /> + { archiveType === 'facetwp' && + <> + + setAttributes({ archivePage: value }) + } + /> + + setAttributes({ archiveFacet: value }) + } + /> + + } + + + } + diff --git a/src/taxonomy-archive-links/render.php b/src/taxonomy-archive-links/render.php index 3b954b4..9274ac1 100644 --- a/src/taxonomy-archive-links/render.php +++ b/src/taxonomy-archive-links/render.php @@ -7,9 +7,14 @@ global $post; $term_list = ''; -$list_style = $attributes['showBullets'] == true ? '' : 'no-bullets '; -$list_style .= $attributes['displayAs'] == 'inline' ? 'list-inline ' : ''; -$list_style .= 'separator-' . $attributes['separator']; +if ( $attributes['displayAs'] == 'tile' ) { + $list_style = 'tile-list no-bullets'; +} else { + $list_style = $attributes['showBullets'] == true ? '' : 'no-bullets '; + $list_style .= $attributes['displayAs'] == 'inline' ? 'list-inline ' : ''; + $list_style .= 'separator-' . $attributes['separator']; +} + $aria_title = $attributes['listLabel'] ? $attributes['listLabel'] : 'Taxonomy List for ' . $attributes['taxonomySelected']; if ( true == $attributes['relevantToPost'] ) { $terms = get_the_terms( $post->ID, $attributes['taxonomySelected'] ); @@ -19,19 +24,53 @@ 'orderby' => $attributes['sortBy'], 'order' => $attributes['order'], ); + if ( $attributes['excludeChildTerms'] ) { + $args['parent'] = 0; + } $terms = get_terms( $args ); } + if ( ! empty( $terms ) && ! is_wp_error( $terms ) ) { $term_list = '
    '; foreach ( $terms as $term ) { - $term_link_url = apply_filters( 'ck_tax_archive_term_link', get_term_link( $term ), $term, $post ); - $term_link_text = apply_filters( 'ck_tax_archive_term_text', $term->name, $term, $post ); + $term_link_url = ''; + $term_link_text = $term->name; if ( true == $attributes['linkToCategory'] ) { - $term_link = '' . $term_link_text . ''; + if ( 'wordpress' == $attributes['archiveType'] ) { + $term_link_url = get_term_link( $term ); + } else if ( 'facetwp' == $attributes['archiveType'] ) { + $term_link_url = add_query_arg( + array( + $attributes['archiveFacet'] => $term->slug, + ), + $attributes['archivePage']); + } + } + $term_content = ''; + $term_icon = ''; + $tile_hover = ''; + if ( $attributes['displayAs'] == 'tile' ) { + $img_field = $attributes['tileImageField']; + if ( ! empty( $img_field ) ) { + $term_image = get_field( $img_field, $term ); + $img_style = $attributes['tileImageStyle']; + if ( ! empty( $term_image ) ) { + $term_icon = wp_get_attachment_image( $term_image, array('600', '600'), "", array( "class" => $img_style ) ); + } + } + $tile_hover = '
    ' . esc_html( $term->description ) . '
    '; + } + + $term_link_url = apply_filters( 'ck_tax_archive_term_link', $term_link_url, $term, $post ); + $term_link_text = apply_filters( 'ck_tax_archive_term_text', $term->name, $term, $post ); + if ( empty( $term_link_url ) ) { + $term_content .= esc_html( $term_link_text ); } else { - $term_link = $term_link_text; + $term_content .= '' . $term_icon . esc_html( $term_link_text ) . $tile_hover . ''; } - $term_list .= '
  • ' . $term_link . '
  • '; + + //$term_content .= $tile_hover; + $term_list .= '
  • ' . $term_content . '
  • '; } $term_list .= '
'; } diff --git a/src/taxonomy-archive-links/style.scss b/src/taxonomy-archive-links/style.scss index 0629b12..4f5f2c6 100644 --- a/src/taxonomy-archive-links/style.scss +++ b/src/taxonomy-archive-links/style.scss @@ -1,3 +1,17 @@ +:root { + --ck-blocks-tax-link-border: 1px solid #C6C6C6; + --ck-blocks-tax-link-border-radius: 0; + --ck-blocks-tax-link-gap: 1.5rem; + --ck-blocks-tax-link-padding: 2.5rem 1.5rem; + --ck-blocks-tax-link-text-color: var(--wp--preset--color--primary, #000); + --ck-blocks-tax-link-background-color: var(--wp--preset--color--white, #fff); + --ck-blocks-tax-link-hover-text-color: var(--wp--preset--color--white, #fff); + --ck-blocks-tax-link-hover-background-color: var(--wp--preset--color--primary, #000); + --ck-blocks-tax-link-icon-width: 100px; + --ck-blocks-tax-link-icon-height: 72px; + --ck-blocks-tax-link-aspect-ratio: 1.223; +} + .wp-block-carkeek-blocks-taxonomy-terms { &.aligncenter { @@ -50,3 +64,61 @@ } } } + +.wp-block-carkeek-blocks-taxonomy-terms ul.tile-list { + display: grid; + grid-template-columns: repeat(3, 1fr); + gap: var(--ck-blocks-tax-link-gap); + + & li { + border: var(--ck-blocks-tax-link-border); + border-radius: var(--ck-blocks-tax-link-border-radius); + background-color: var(--ck-blocks-tax-link-background-color); + & a { + color: var(--ck-blocks-tax-link-text-color); + padding: var(--ck-blocks-tax-link-padding); + display: flex; + flex-direction: column; + align-items: center; + text-align: center; + gap: 1rem; + position: relative; + overflow: hidden; + aspect-ratio: var(--ck-blocks-tax-link-aspect-ratio); + + + } + & img.icon { + width: var(--ck-blocks-tax-link-icon-width); + height: var(--ck-blocks-tax-link-icon-height); + object-fit: contain; + margin-left: auto; + margin-right: auto; + } + & img.cover { + position: absolute; + top: 0; + left: 0; + right: 0; + bottom: 0; + object-fit: cover; + } + & .tile-hover { + background-color: var(--ck-blocks-tax-link-hover-background-color); + color: var(--ck-blocks-tax-link-hover-text-color); + padding: var(--ck-blocks-tax-link-padding); + position: absolute; + top: 100%; + transition: top 0.3s; + height: 100%; + width: 100%; + display: flex; + flex-direction: column; + justify-content: center; + align-items: center; + } + &:hover .tile-hover { + top: 0; + } + } +}