index.js
1 year ago
useAuthors.js
3 years ago
useBlockStyles.js
1 year ago
useDebounceState.js
4 years ago
useDeviceAttributes.js
2 years ago
useDeviceType.js
1 year ago
useInnerBlocksCount.js
4 years ago
useQueryReducer.js
1 year ago
useRecordsReducer.js
3 years ago
useSelectedBlockElements.js
2 years ago
useStyleIndicator.js
2 years ago
useTaxonomies.js
1 year ago
useTaxonomyRecords.js
3 years ago
useTaxonomies.js
23 lines
| 1 | import { useSelect } from '@wordpress/data'; |
| 2 | import { store as coreStore } from '@wordpress/core-data'; |
| 3 | |
| 4 | export function useTaxonomies( postType ) { |
| 5 | return useSelect( ( select ) => { |
| 6 | const { getTaxonomies } = select( coreStore ); |
| 7 | |
| 8 | const args = { per_page: -1 }; |
| 9 | |
| 10 | /** |
| 11 | * Certain post types are excluded from this behavior since they are "pattern-like" and might display in a different |
| 12 | * content type than the one being edited. |
| 13 | */ |
| 14 | const excludedPostTypes = [ 'gp_elements', 'wp_block' ]; |
| 15 | |
| 16 | if ( postType && ! excludedPostTypes.includes( postType ) ) { |
| 17 | args.types = postType; |
| 18 | } |
| 19 | |
| 20 | return getTaxonomies( args ) || []; |
| 21 | }, [ postType ] ); |
| 22 | } |
| 23 |