Changeset 2740344
- Timestamp:
- 06/10/2022 09:20:00 AM (2 years ago)
- Location:
- taxonomy-terms-list-block/trunk
- Files:
-
- 3 added
- 11 edited
Legend:
- Unmodified
- Added
- Removed
-
taxonomy-terms-list-block/trunk/block.json
r2676883 r2740344 25 25 "type": "string", 26 26 "default": "" 27 28 29 30 27 31 } 28 32 }, … … 32 36 "html": false, 33 37 "align": ["wide", "full"], 38 39 40 41 42 43 44 45 34 46 "typography": { 35 47 "lineHeight": true, … … 38 50 }, 39 51 "editorScript": "file:./build/index.js", 52 40 53 "style": "wp-block-taxonomy-terms-list-block" 41 54 } -
taxonomy-terms-list-block/trunk/build/index.asset.php
r2737323 r2740344 1 <?php return array('dependencies' => array('wp-block-editor', 'wp-blocks', 'wp-components', 'wp-core-data', 'wp-data', 'wp-element', 'wp-i18n', 'wp-server-side-render'), 'version' => ' 2696d2b4a1e85b060b015bcfb73080e6');1 <?php return array('dependencies' => array('wp-block-editor', 'wp-blocks', 'wp-components', 'wp-core-data', 'wp-data', 'wp-element', 'wp-i18n', 'wp-server-side-render'), 'version' => ''); -
taxonomy-terms-list-block/trunk/build/index.js
r2737323 r2740344 1 !function(){var e={184:function(e,t){var o;!function(){"use strict";var n={}.hasOwnProperty;function r(){for(var e=[],t=0;t<arguments.length;t++){var o=arguments[t];if(o){var l=typeof o;if("string"===l||"number"===l)e.push(o);else if(Array.isArray(o)){if(o.length){var a=r.apply(null,o);a&&e.push(a)}}else if("object"===l)if(o.toString===Object.prototype.toString)for(var s in o)n.call(o,s)&&o[s]&&e.push(s);else e.push(o.toString())}}return e.join(" ")}e.exports?(r.default=r,e.exports=r):void 0===(o=function(){return r}.apply(t,[]))||(e.exports=o)}()}},t={};function o(n){var r=t[n];if(void 0!==r)return r.exports;var l=t[n]={exports:{}};return e[n](l,l.exports,o),l.exports}o.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return o.d(t,{a:t}),t},o.d=function(e,t){for(var n in t)o.o(t,n)&&!o.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:t[n]})},o.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},function(){"use strict";var e=window.wp.blocks,t=window.wp.element,n=window.wp.data,r=window.wp.coreData,l=window.wp.serverSideRender,a=o.n(l),s=window.wp.blockEditor,i=o(184),c=o.n(i),u=window.wp.components,p=window.wp.i18n,m=e=>{let{selected:o,onChange:n,taxonomies:r}=e;return(0,t.createElement)(u.SelectControl,{label:"Display terms from this taxonomy",value:o,options:[{label:(0,p.__)("-- Select a taxonomy --","taxonomyblock"),value:""},...r.map((e=>{let{name:t,slug:o}=e;return{label:t,value:o}}))],onChange:n})},y=e=>{let{taxonomies:o,attributes:n,setAttributes:r}=e;const{term:l,textAlign:a,separator:i,title:c}=n;return(0,t.createElement)(t.Fragment,null,(0,t.createElement)(s.InspectorControls,null,(0,t.createElement)(u.PanelBody,null,(0,t.createElement)(m,{taxonomies:o,selected:l,onChange:e=>{r({term:e})}})),(0,t.createElement)(u.PanelBody,null,(0,t.createElement)(u.TextControl,{autoComplete:"off",label:(0,p.__)("Separator","taxonomyblock"),value:i||"",onChange:e=>{r({separator:e})},help:(0,p.__)("Enter character(s) used to separate terms.","taxonomyblock")}),(0,t.createElement)(u.TextControl,{autoComplete:"off",label:(0,p.__)("Title","taxonomyblock"),value:c||"",onChange:e=>{r({title:e})},help:(0,p.__)("Title prefixed to the list of elements.","taxonomyblock")}))),(0,t.createElement)(s.BlockControls,null,(0,t.createElement)(s.AlignmentToolbar,{value:a,onChange:e=>{r({textAlign:e})}})))};(0,e.registerBlockType)("taxonomy-terms-list/block",{edit:e=>{let{attributes:o,context:l,setAttributes:i}=e;const{term:m,textAlign:d}=o,{postId:b,postType:f}=l,x=(0,n.useSelect)((e=>(e("core").getTaxonomies()||[]).filter((e=>{var t;return null==e||null===(t=e.visibility)||void 0===t?void 0:t.publicly_queryable})))),g=x.filter((e=>{let{types:t}=e;return t.indexOf(f)>-1})),h=0===g.length?x:g,v=(0,n.useSelect)((e=>{var t;if(!m)return{};const{getTaxonomy:o}=e(r.store),n=o(m);return null!=n&&null!==(t=n.visibility)&&void 0!==t&&t.publicly_queryable?n:{}}),[m]),{postTerms:w,isLoading:T}=function(e){let{postId:t,postType:o,term:n}=e;const{rest_base:l}=n,[a]=(0,r.useEntityProp)("postType",o,l,t);return{postTerms:a,isLoading:void 0===a}}({postId:b,postType:f,term:v}),E=g.some((e=>{let{slug:t}=e;return t===m}));console.log({postTypeHasTaxonomy:E,term:m,postTypeTaxonomies:g}),(0,t.useEffect)((()=>{null!==w&&i({lastUpdate:(new Date).getTime()})}),[w]);const _=b&&f,k=(0,s.useBlockProps)({className:c()({[`has-text-align-${d}`]:d,[`taxonomy-block-${m}`]:m})});return(0,t.createElement)("div",k,_&&(0,t.createElement)(y,{taxonomies:h,attributes:o,setAttributes:i}),T&&m&&E&&(0,t.createElement)(u.Spinner,null),m&&!E&&(0,t.createElement)(u.Placeholder,{instructions:(0,p.__)("Taxonomy Terms List: This post hasn't got the %s taxonomy associated. This may happen inside the block editor context depending on the page you are trying to edit. The taxonomy terms list here will be replaced for an actual list in the website.","taxonomyblock")}),m&&!T&&E&&(0,t.createElement)(a(),{attributes:o,block:"taxonomy-terms-list/block",urlQueryArgs:{previewPostTerms:w}}),!m&&(0,t.createElement)(u.Placeholder,{instructions:(0,p.__)("Please, select a taxonomy in the block options","taxonomyblock")}))}})}()}(); 1 (()=>{var e={184:(e,t)=>{var o;!function(){"use strict";var n={}.hasOwnProperty;function r(){for(var e=[],t=0;t<arguments.length;t++){var o=arguments[t];if(o){var l=typeof o;if("string"===l||"number"===l)e.push(o);else if(Array.isArray(o)){if(o.length){var a=r.apply(null,o);a&&e.push(a)}}else if("object"===l)if(o.toString===Object.prototype.toString)for(var s in o)n.call(o,s)&&o[s]&&e.push(s);else e.push(o.toString())}}return e.join(" ")}e.exports?(r.default=r,e.exports=r):void 0===(o=function(){return r}.apply(t,[]))||(e.exports=o)}()}},t={};function o(n){var r=t[n];if(void 0!==r)return r.exports;var l=t[n]={exports:{}};return e[n](l,l.exports,o),l.exports}o.n=e=>{var t=e&&e.__esModule?()=>e.default:()=>e;return o.d(t,{a:t}),t},o.d=(e,t)=>{for(var n in t)o.o(t,n)&&!o.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:t[n]})},o.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),(()=>{"use strict";const e=window.wp.blocks,t=window.wp.element,n=window.wp.data,r=window.wp.coreData,l=window.wp.serverSideRender;var a=o.n(l);const s=window.wp.blockEditor;var i=o(184),c=o.n(i);const p=window.wp.components,m=window.wp.i18n,u=e=>{let{selected:o,onChange:n,taxonomies:r}=e;return(0,t.createElement)(p.SelectControl,{label:"Display terms from this taxonomy",value:o,options:[{label:(0,m.__)("-- Select a taxonomy --","taxonomyblock"),value:""},...r.map((e=>{let{name:t,slug:o}=e;return{label:t,value:o}}))],onChange:n})},y=e=>{let{taxonomies:o,attributes:n,setAttributes:r}=e;const{term:l,textAlign:a,separator:i,title:c}=n;return(0,t.createElement)(t.Fragment,null,(0,t.createElement)(s.InspectorControls,null,(0,t.createElement)(p.PanelBody,null,(0,t.createElement)(u,{taxonomies:o,selected:l,onChange:e=>{r({term:e})}})),(0,t.createElement)(p.PanelBody,null,(0,t.createElement)(p.TextControl,{autoComplete:"off",label:(0,m.__)("Separator","taxonomyblock"),value:i||"",onChange:e=>{r({separator:e})},help:(0,m.__)("Enter character(s) used to separate terms.","taxonomyblock")}),(0,t.createElement)(p.TextControl,{autoComplete:"off",label:(0,m.__)("Title","taxonomyblock"),value:c||"",onChange:e=>{r({title:e})},help:(0,m.__)("Title prefixed to the list of elements.","taxonomyblock")}))),(0,t.createElement)(s.BlockControls,null,(0,t.createElement)(s.AlignmentToolbar,{value:a,onChange:e=>{r({textAlign:e})}})))};(0,e.registerBlockType)("taxonomy-terms-list/block",{edit:e=>{let{attributes:o,context:l,setAttributes:i}=e;const{term:u,textAlign:b}=o,{postId:d,postType:x}=l,g=(0,n.useSelect)((e=>(e("core").getTaxonomies()||[]).filter((e=>e?.visibility?.publicly_queryable)))),f=g.filter((e=>{let{types:t}=e;return t.indexOf(x)>-1})),h=0===f.length?g:f,w=(0,n.useSelect)((e=>{if(!u)return{};const{getTaxonomy:t}=e(r.store),o=t(u);return o?.visibility?.publicly_queryable?o:{}}),[u]),{postTerms:v,isLoading:T}=function(e){let{postId:t,postType:o,term:n}=e;const{rest_base:l}=n,[a]=(0,r.useEntityProp)("postType",o,l,t);return{postTerms:a,isLoading:void 0===a}}({postId:d,postType:x,term:w}),_=f.some((e=>{let{slug:t}=e;return t===u}));(0,t.useEffect)((()=>{null!==v&&i({lastUpdate:(new Date).getTime()})}),[v]);const E=d&&x,k=(0,s.useBlockProps)({className:c()({[`has-text-align-${b}`]:b,[`taxonomy-block-${u}`]:u})});return(0,t.createElement)("div",k,E&&(0,t.createElement)(y,{taxonomies:h,attributes:o,setAttributes:i}),T&&u&&_&&(0,t.createElement)(p.Placeholder,{icon:"tag",label:(0,m.__)("Loading terms…","taxonomyblock")}),u&&!_&&!T&&(0,t.createElement)(p.Placeholder,{icon:"tag",label:"Taxonomy Terms List",instructions:(0,m.sprintf)(// translators: %s: Taxonomy name 2 (0,m.__)("This post hasn't got the %s taxonomy associated. This may happen inside the block editor context depending on the page you are trying to edit. The taxonomy terms list will be replaced for an actual list in the website.","taxonomyblock"),u)}),u&&!T&&_&&(0,t.createElement)(a(),{attributes:o,block:"taxonomy-terms-list/block",urlQueryArgs:{previewPostTerms:v}}),!u&&(0,t.createElement)(p.Placeholder,{icon:"tag",label:"Taxonomy Terms List",instructions:(0,m.__)("Please, select a taxonomy in the block options","taxonomyblock")}))}})})()})(); -
taxonomy-terms-list-block/trunk/inc/block.php
r2676883 r2740344 64 64 $separator = empty( $attributes['separator'] ) ? ' ' : $attributes['separator']; 65 65 66 $wrapper_attributes = get_block_wrapper_attributes( [ 'class' => $classes ] );66 $wrapper_attributes = ; 67 67 68 68 $links = []; -
taxonomy-terms-list-block/trunk/languages/taxonomy-terms-list-block.pot
r2737323 r2740344 3 3 msgid "" 4 4 msgstr "" 5 "Project-Id-Version: Taxonomy Terms List Block 1. 0.2\n"5 "Project-Id-Version: Taxonomy Terms List Block 1.\n" 6 6 "Report-Msgid-Bugs-To: https://wordpress.org/support/plugin/html\n" 7 7 "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n" … … 10 10 "Content-Type: text/plain; charset=UTF-8\n" 11 11 "Content-Transfer-Encoding: 8bit\n" 12 "POT-Creation-Date: 2022-06- 04T11:33:56+00:00\n"12 "POT-Creation-Date: 2022-06-+00:00\n" 13 13 "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" 14 14 "X-Generator: WP-CLI 2.5.0\n" … … 39 39 msgstr "" 40 40 41 #: src/components/Edit.js:7 442 msgid " Taxonomy Terms List: This post hasn't got the %s taxonomy associated. This may happen inside the block editor context depending on the page you are trying to edit. The taxonomy terms list here will be replaced for an actual list in the website."41 #: src/components/Edit.js:7 42 msgid "" 43 43 msgstr "" 44 44 45 #: src/components/Edit.js:91 45 #. translators: %s: Taxonomy name 46 #: src/components/Edit.js:81 47 msgid "This post hasn't got the %s taxonomy associated. This may happen inside the block editor context depending on the page you are trying to edit. The taxonomy terms list will be replaced for an actual list in the website." 48 msgstr "" 49 50 #: src/components/Edit.js:102 46 51 msgid "Please, select a taxonomy in the block options" 47 52 msgstr "" -
taxonomy-terms-list-block/trunk/readme.txt
r2737323 r2740344 4 4 Requires at least: 5.8 5 5 Tested up to: 5.9 6 Stable tag: 1. 0.26 Stable tag: 1. 7 7 License: GPLv2 or later 8 8 … … 24 24 == Changelog == 25 25 26 27 28 29 30 26 31 = 1.0.2 = 27 32 Fix: Taxonomy terms previsualization was not working in the block editor. -
taxonomy-terms-list-block/trunk/src/components/Edit.js
r2737323 r2740344 7 7 import classnames from 'classnames'; 8 8 import Settings from './Settings'; 9 import { Placeholder , Spinner} from '@wordpress/components';9 import { Placeholder } from '@wordpress/components'; 10 10 import { __, sprintf } from '@wordpress/i18n'; 11 11 import { store as coreStore } from '@wordpress/core-data'; … … 43 43 }); 44 44 45 console.log({ postTypeHasTaxonomy, term, postTypeTaxonomies });46 47 45 useEffect(() => { 48 46 if (postTerms === null) { … … 69 67 /> 70 68 )} 71 {isLoading && term && postTypeHasTaxonomy && <Spinner />} 72 {term && !postTypeHasTaxonomy && ( 69 {isLoading && term && postTypeHasTaxonomy && ( 73 70 <Placeholder 74 instructions={__( 75 "Taxonomy Terms List: This post hasn't got the %s taxonomy associated. This may happen inside the block editor context depending on the page you are trying to edit. The taxonomy terms list here will be replaced for an actual list in the website.", 76 'taxonomyblock' 71 icon="tag" 72 label={__('Loading terms…', 'taxonomyblock')} 73 /> 74 )} 75 {term && !postTypeHasTaxonomy && !isLoading && ( 76 <Placeholder 77 icon="tag" 78 label="Taxonomy Terms List" 79 instructions={sprintf( 80 // translators: %s: Taxonomy name 81 __( 82 "This post hasn't got the %s taxonomy associated. This may happen inside the block editor context depending on the page you are trying to edit. The taxonomy terms list will be replaced for an actual list in the website.", 83 'taxonomyblock' 84 ), 85 term 77 86 )} 78 87 /> … … 89 98 {!term && ( 90 99 <Placeholder 100 101 91 102 instructions={__( 92 103 'Please, select a taxonomy in the block options', -
taxonomy-terms-list-block/trunk/src/components/Settings.js
r2676883 r2740344 17 17 taxonomies={taxonomies} 18 18 selected={term} 19 onChange={( term) => {20 setAttributes({ term });19 onChange={() => { 20 setAttributes({ term }); 21 21 }} 22 22 /> -
taxonomy-terms-list-block/trunk/src/hooks/use-taxonomies.js
r2737323 r2740344 4 4 import { useSelect } from '@wordpress/data'; 5 5 6 export default function useTaxonomies( postType) {6 export default function useTaxonomies() { 7 7 return useSelect((select) => { 8 8 return (select('core').getTaxonomies() || []).filter( -
taxonomy-terms-list-block/trunk/src/index.js
r2676883 r2740344 1 1 2 import { registerBlockType } from '@wordpress/blocks'; 2 3 import Edit from './components/Edit'; -
taxonomy-terms-list-block/trunk/taxonomy-block.php
r2737323 r2740344 4 4 * Description: Displays a list of a post terms for a selected taxonomy. 5 5 * Plugin URI: https://wordpress.org/plugins/taxonomy-terms-list-block 6 * Version: 1. 0.26 * Version: 1. 7 7 * Author: igmoweb 8 8 * Author URI: http://igmoweb.com
Note: See TracChangeset
for help on using the changeset viewer.