Skip to content

Commit 546598a

Browse files
committed
Remove new editor logic
1 parent 1f382a2 commit 546598a

File tree

2 files changed

+7
-153
lines changed

2 files changed

+7
-153
lines changed

packages/block-library/src/term-template/edit.js

Lines changed: 7 additions & 65 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,6 @@
33
*/
44
import clsx from 'clsx';
55

6-
/**
7-
* Internal dependencies
8-
*/
9-
import { useCurrentTerm } from './use-current-term';
10-
116
/**
127
* WordPress dependencies
138
*/
@@ -87,17 +82,13 @@ export default function TermTemplateEdit( {
8782
showNested = false,
8883
perPage,
8984
include,
90-
inherit = false,
9185
} = {},
9286
},
9387
__unstableLayoutClassNames,
9488
} ) {
9589
const { type: layoutType, columnCount = 3 } = layout || {};
9690
const [ activeBlockContextId, setActiveBlockContextId ] = useState();
9791

98-
// Extract current term from template slug when inheriting.
99-
const currentTerm = useCurrentTerm( inherit );
100-
10192
const queryArgs = {
10293
hide_empty: hideEmpty,
10394
order,
@@ -108,24 +99,9 @@ export default function TermTemplateEdit( {
10899
per_page: perPage || -1,
109100
};
110101

111-
// Handle inherit logic.
112-
if ( inherit && currentTerm ) {
113-
// When inheriting, use the current term's taxonomy.
114-
queryArgs.taxonomy = currentTerm.taxonomy;
115-
116-
// For hierarchical taxonomies, show children of the current term.
117-
// If showNested is true, use child_of to include nested terms.
118-
// Otherwise, use parent to show only direct children.
119-
if ( showNested ) {
120-
// For nested terms, we need to fetch all terms and filter client-side
121-
// since the REST API doesn't support child_of like WP_Term_Query does.
122-
// Don't set parent - we'll filter the results after fetching.
123-
} else {
124-
queryArgs.parent = currentTerm.id;
125-
}
126-
} else if ( ! showNested && ! include?.length ) {
127-
// Nested terms are returned by default from REST API as long as parent is not set.
128-
// Set parent to 0 to show only top-level terms.
102+
// Nested terms are returned by default from REST API as long as parent is not set.
103+
// If we want to show nested terms, we must not set parent at all.
104+
if ( ! showNested && ! include?.length ) {
129105
queryArgs.parent = 0;
130106
}
131107

@@ -136,46 +112,12 @@ export default function TermTemplateEdit( {
136112
queryArgs.order = 'asc';
137113
}
138114

139-
// Use the taxonomy from queryArgs if it was set (for inherit), otherwise use the context taxonomy.
140-
const currentTaxonomy = queryArgs.taxonomy || taxonomy;
141-
142-
const { records: allTerms } = useEntityRecords(
115+
const { records: terms } = useEntityRecords(
143116
'taxonomy',
144-
currentTaxonomy,
117+
taxonomy,
145118
queryArgs
146119
);
147120

148-
// Filter terms for nested functionality.
149-
const terms = useMemo( () => {
150-
if ( ! allTerms || ! inherit || ! currentTerm ) {
151-
return allTerms;
152-
}
153-
154-
if ( showNested ) {
155-
// For nested terms, filter to show all descendants of the current term.
156-
const isDescendant = ( term ) => {
157-
// Check if this term is a descendant of the current term.
158-
const findParent = ( termId ) => {
159-
const foundTerm = allTerms.find( ( t ) => t.id === termId );
160-
return foundTerm ? foundTerm.parent : 0;
161-
};
162-
163-
let currentParent = term.parent;
164-
while ( currentParent !== 0 ) {
165-
if ( currentParent === currentTerm.id ) {
166-
return true;
167-
}
168-
currentParent = findParent( currentParent );
169-
}
170-
return false;
171-
};
172-
173-
return allTerms.filter( isDescendant );
174-
}
175-
176-
return allTerms;
177-
}, [ allTerms, inherit, currentTerm, showNested ] );
178-
179121
const blocks = useSelect(
180122
( select ) => select( blockEditorStore ).getBlocks( clientId ),
181123
[ clientId ]
@@ -186,12 +128,12 @@ export default function TermTemplateEdit( {
186128
const blockContexts = useMemo(
187129
() =>
188130
terms?.map( ( term ) => ( {
189-
taxonomy: currentTaxonomy,
131+
taxonomy,
190132
termId: term.id,
191133
classList: `term-${ term.id }`,
192134
termData: term,
193135
} ) ),
194-
[ terms, currentTaxonomy ]
136+
[ terms, taxonomy ]
195137
);
196138

197139
if ( ! terms ) {

packages/block-library/src/term-template/use-current-term.js

Lines changed: 0 additions & 88 deletions
This file was deleted.

0 commit comments

Comments
 (0)