Skip to content

Commit aa6b3b3

Browse files
committed
code review
1 parent 46733f4 commit aa6b3b3

1 file changed

Lines changed: 7 additions & 5 deletions

File tree

src/TouchPoint-WP/Taxonomies.php

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -73,13 +73,13 @@ protected static function getLabels(string $singular, string $plural): array
7373
*
7474
* @return void
7575
*/
76-
public static function insertTermsForArrayBasedTaxonomy(array $list, string $taxonomy, bool $forceIdUpdate)
76+
public static function insertTermsForArrayBasedTaxonomy(array $list, string $taxonomy, bool $forceIdUpdate): void
7777
{
7878
$existingIds = [];
79+
$idUpdate = $forceIdUpdate;
7980
foreach ($list as $slug => $name) {
8081
// In addition to making sure term exists, make sure it has the correct meta id, too.
8182
$term = self::termExists($name, $taxonomy);
82-
$idUpdate = $forceIdUpdate;
8383
if ( ! $term) {
8484
$term = self::insertTerm(
8585
$name,
@@ -93,14 +93,16 @@ public static function insertTermsForArrayBasedTaxonomy(array $list, string $tax
9393
new TouchPointWP_WPError($term);
9494
$term = null;
9595
}
96-
if ($idUpdate) {
97-
TouchPointWP::queueFlushRewriteRules();
98-
}
96+
$idUpdate = true;
97+
9998
}
10099
if ( ! ! $term) {
101100
$existingIds[] = $term['term_id'];
102101
}
103102
}
103+
if ($idUpdate) {
104+
TouchPointWP::queueFlushRewriteRules();
105+
}
104106

105107
// Delete any terms that are no longer current.
106108
$terms = get_terms(['taxonomy' => $taxonomy, 'hide_empty' => false, 'exclude' => $existingIds]);

0 commit comments

Comments
 (0)