-
Notifications
You must be signed in to change notification settings - Fork 34
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
PLANET-6652: Add p4_action type to search
Add p4_action type to search filters and template
- Loading branch information
Showing
5 changed files
with
126 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace P4\MasterTheme\Search\Filters; | ||
|
||
use P4\MasterTheme\ActionPage; | ||
|
||
/** | ||
* Action types used for search (Petition, Event, etc.). | ||
*/ | ||
class ActionTypes { | ||
/** | ||
* Get all content types. | ||
* | ||
* @return array<WP_Post_Type> | ||
*/ | ||
public static function get_all(): array { | ||
return get_terms( | ||
[ | ||
'taxonomy' => ActionPage::TAXONOMY, | ||
'hide_empty' => false, | ||
] | ||
); | ||
} | ||
|
||
/** | ||
* @return array{int, array{term_id: int, name: string, results: int}} | ||
*/ | ||
public static function get_filters(): array { | ||
$types = self::get_all(); | ||
$filters = []; | ||
|
||
foreach ( $types as $type ) { | ||
$filters[ $type->term_id ] = [ | ||
'term_id' => $type->term_id, | ||
'name' => $type->name, | ||
'results' => 0, | ||
]; | ||
} | ||
|
||
return $filters; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters