Skip to content
Open
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
36 changes: 36 additions & 0 deletions dt-apps/dt-home/includes/class-home-apps.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,10 @@ public function on_init() {
// This is where we can safely apply filters after all classes are loaded
$this->load_magic_link_apps();
$this->load_home_apps();

// Register filter hooks for external code
add_filter( 'dt_home_screen_apps', [ $this, 'filter_home_screen_apps' ] );
add_filter( 'dt_home_screen_links', [ $this, 'filter_home_screen_links' ] );
}

/**
Expand Down Expand Up @@ -797,6 +801,38 @@ public function get_apps_for_user( $user_id = 0 ) {
return $roles_permissions->filter_apps_by_permissions( $apps, $user_id );
}

/**
* Filter callback for dt_home_screen_apps
*
* Returns only apps of type 'app' when external code calls apply_filters('dt_home_screen_apps', []).
*
* @param array $default_value Default value passed to apply_filters
* @return array Filtered apps of type 'app'
*/
public function filter_home_screen_apps( $default_value ) {
$apps = $this->get_apps_for_frontend();
$filtered = array_filter( $apps, function( $app ) {
return isset( $app['type'] ) && strtolower( trim( $app['type'] ) ) === 'app';
});
return $filtered;
}

/**
* Filter callback for dt_home_screen_links
*
* Returns only apps of type 'link' when external code calls apply_filters('dt_home_screen_links', []).
*
* @param array $default_value Default value passed to apply_filters
* @return array Filtered apps of type 'link'
*/
public function filter_home_screen_links( $default_value ) {
$apps = $this->get_apps_for_frontend();
$filtered = array_filter( $apps, function( $app ) {
return isset( $app['type'] ) && strtolower( trim( $app['type'] ) ) === 'link';
});
return $filtered;
}

/**
* Validate app data
*/
Expand Down
15 changes: 15 additions & 0 deletions dt-apps/dt-home/includes/class-home-training.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,9 @@ public static function instance() {
public function __construct() {
// Initialize with default videos if none exist
$this->initialize_default_videos();

// Register filter hook for external code
add_filter( 'dt_home_screen_training_videos', [ $this, 'filter_home_screen_training_videos' ] );
}

/**
Expand Down Expand Up @@ -302,6 +305,18 @@ public function get_videos_for_frontend() {
return $videos;
}

/**
* Filter callback for dt_home_screen_training_videos
*
* Returns all training videos when external code calls apply_filters('dt_home_screen_training_videos', []).
*
* @param array $default_value Default value passed to apply_filters
* @return array All training videos
*/
public function filter_home_screen_training_videos( $default_value ) {
return $this->get_videos_for_frontend();
}

/**
* Get YouTube thumbnail URL
*/
Expand Down
Loading