Skip to content
Merged
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: 15 additions & 2 deletions dt-apps/dt-home/includes/class-home-apps.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ private function initialize_default_apps() {
* Called on init hook to handle filter timing
*/
public function on_init() {
// This is where we can safely apply filters after all classes are loaded
// This is where we can safely load apps after all classes are loaded
$this->load_magic_link_apps();
$this->load_home_apps();
}
Expand Down Expand Up @@ -701,8 +701,11 @@ private function determine_app_type( $app ) {

/**
* Get apps for frontend display
*
* @param string|null $type Optional. Filter by app type: 'app', 'link', or null for all apps.
* @return array Array of apps for frontend display
*/
public function get_apps_for_frontend() {
public function get_apps_for_frontend( $type = null ) {
$apps = $this->get_enabled_apps();

// Enrich coded magic-link app urls.
Expand Down Expand Up @@ -763,6 +766,16 @@ public function get_apps_for_frontend() {
$enriched_apps[] = $app;
}

// If type is specified, filter by type
if ( $type !== null ) {
$type_normalized = strtolower( trim( $type ) );
if ( $type_normalized === 'app' || $type_normalized === 'link' ) {
$enriched_apps = array_filter( $enriched_apps, function( $app ) use ( $type_normalized ) {
return isset( $app['type'] ) && strtolower( trim( $app['type'] ) ) === $type_normalized;
});
}
}

// Sort by order
usort( $enriched_apps, function( $a, $b ) {
return $a['order'] <=> $b['order'];
Expand Down
Loading