public function getFilterableCategories($moduleId): array
    {
        $categories = array();
        $showAllCategories = get_field('mod_event_categories_show', $moduleId);

        $moduleCategories = get_field('mod_event_categories_list', $moduleId);
        if ($showAllCategories === false && !empty($moduleCategories) && is_array($moduleCategories)) {
            $categories = $moduleCategories;
            foreach ($categories as $key => &$category) {
                $category = get_term($category, 'event_categories');
                // If category is missing, remove it from the list
                if (!$category) {
                    unset($categories[$key]);
                }
            }
        } else {
            $categories = get_terms(
                'event_categories',
                array(
                    'hide_empty' => false,
                )
            );
        }

        $categories = \EventManagerIntegration\Helper\Translations::filterTermsByLanguage($categories);

        foreach ($categories as &$category) {
            $category = array(
                'id' => $category->term_id,
                'title' => $category->name,
                'checked' => false,
            );
        }

        return $categories;
    }
public function getFilterableCategories($moduleId): array
    {
        $categories = array();
        $showAllCategories = get_field('mod_event_categories_show', $moduleId);

        $moduleCategories = get_field('mod_event_categories_list', $moduleId);
        if ($showAllCategories === false && !empty($moduleCategories) && is_array($moduleCategories)) {
            $categories = $moduleCategories;
            foreach ($categories as $key => &$category) {
                $category = get_term($category, 'event_categories');
                // If category is missing, remove it from the list
                if (!$category) {
                    unset($categories[$key]);
                }
            }
        } else {
            $categories = get_terms(
                'event_categories',
                array(
                    'hide_empty' => false,
                )
            );
        }

        $categories = \EventManagerIntegration\Helper\Translations::filterTermsByLanguage($categories);

        foreach ($categories as &$category) {
            $category = array(
                'id' => $category->term_id,
                'title' => $category->name,
                'checked' => false,
            );
        }

        return $categories;
    }
public function getFilterableCategories ( $ moduleId ) : array { $ categories = array ( ) ; $ showAllCategories = get_field ( 'mod_event_categories_show' , $ moduleId ) ; $ moduleCategories = get_field ( 'mod_event_categories_list' , $ moduleId ) ; if ( $ showAllCategories === false && ! empty ( $ moduleCategories ) && is_array ( $ moduleCategories ) ) { $ categories = $ moduleCategories ; foreach ( $ categories as $ key => & $ category ) { $ category = get_term ( $ category , 'event_categories' ) ; // If category is missing, remove it from the list if ( ! $ category ) { unset ( $ categories [ $ key ] ) ; } } } else { $ categories = get_terms ( 'event_categories' , array ( 'hide_empty' => false , ) ) ; } $ categories = \ EventManagerIntegration \ Helper \ Translations :: filterTermsByLanguage ( $ categories ) ; foreach ( $ categories as & $ category ) { $ category = array ( 'id' => $ category -> term_id , 'title' => $ category -> name , 'checked' => false , ) ; } return $ categories ; }
Return categories available for filtering
@param int $moduleId The module ID
@return array|null
Return categories available for filtering