Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

497 fix delete terms case sensitiv issue #502

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 8 additions & 9 deletions include/Core/Terms/Modules/DeleteTermsByNameModule.php
Original file line number Diff line number Diff line change
Expand Up @@ -118,17 +118,16 @@ protected function get_terms_that_are_equal_to( $value, $options ) {
* @return int[] Term ids.
*/
protected function get_terms_that_are_not_equal_to( $value, $options ) {
$name_like_args = array(
'name__like' => $value,
'taxonomy' => $options['taxonomy'],
);
$term_ids = array();
$terms = $this->get_all_terms( $options['taxonomy'] );

$query = array(
'taxonomy' => $options['taxonomy'],
'exclude' => $this->query_terms( $name_like_args ),
);
foreach ( $terms as $term ) {
if ( $term->name != $value ) {
$term_ids[] = $term->term_id;
}
}

return $this->query_terms( $query );
return $term_ids;
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,25 @@ public function provide_data_to_test_that_terms_can_be_deleted_by_name() {
'Term A',
),
),

array(
array(
'post_type' => 'post',
'taxonomy' => 'custom_taxonomy',
'terms' => array(
'Term A',
'Term sample B',
'Term Sample C',
),
),
array(
'search_term' => 'Term sample C',
'operator' => 'not_equal_to',
),
3,
array(),
),

array(
array(
'post_type' => 'post',
Expand Down