soflyy / breakdance-bugs

Bug reports from Breakdance users.
38 stars 6 forks source link

Postloop Filter Order #1058

Open marius-robotdance opened 2 months ago

marius-robotdance commented 2 months ago

At the moment it is not possible to sort the Taxonomyfilter of a PostLoop manually (or via menu_order / terms). Cause Breakdance sort the filters of a PostLoop by the postorder.

Instead Breakdance should use the standard get_terms function of WordPress.

Have a look at this code Snippet in the PostLoop ssr.pho referenced to the filter-bar.php:

function setupIsotopeFilterBar($data) { $rawSettings = array_filter((array) ($data['settings'] ?? [])); /* @var string $defaultType / $defaultType = $data['defaultType'] ?? 'category'; /* @var string $defaultAll / $defaultAll = $data['defaultAll'] ?? __('All', 'breakdance');

$settings = array_merge([
    'enable' => false,
    'type' => $defaultType,
    'all_filter' => false,
    'all_label' => $defaultAll
], $rawSettings);

$terms = [];
$activeTerm = 0;

if ($settings['enable']) {
    $terms = getTermsOnCurrentPage($data['query'], $settings['type']);
    $activeTerm = \Breakdance\WpQueryControl\getActiveTerm($settings['all_filter'], $terms);
}

return array_merge($settings, [
    'design' => $data['design'],
    'terms' => $terms,
    'activeTerm' => $activeTerm
]);

}

Breakdance should simply use:

function setupIsotopeFilterBar($data) { { return array_merge($settings, [ 'design' => $data['design'], 'terms' => get_terms([ 'taxonomy' => $settings['type'], 'hide_empty' => true, ]), 'activeTerm' => $activeTerm ]); }