Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
~ Tweak: load list course categories.
- Loading branch information
Showing
2 changed files
with
139 additions
and
170 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
<?php | ||
|
||
/** | ||
* Class ListCourseCategories | ||
* | ||
* Handle lit course categories | ||
* | ||
* @package LearnPress/Classes | ||
* @version 1.0.0 | ||
* @since 4.2.6.5 | ||
*/ | ||
|
||
namespace LearnPress\Models; | ||
|
||
use Throwable; | ||
|
||
class ListCourseCategories { | ||
/** | ||
* Get all course categories | ||
* | ||
* @param array $arg_query_terms | ||
* | ||
* @return array [ term_id => term_name ] | ||
*/ | ||
public static function get_all_categories_id_name( array $arg_query_terms = [] ): array { | ||
$terms = []; | ||
|
||
try { | ||
$arg_query_terms_default = [ | ||
'taxonomy' => LP_COURSE_CATEGORY_TAX, | ||
'fields' => 'id=>name', | ||
'parent' => 0, | ||
]; | ||
|
||
$arg_query_terms = array_merge( $arg_query_terms_default, $arg_query_terms ); | ||
|
||
$terms = get_terms( $arg_query_terms ); | ||
} catch ( Throwable $e ) { | ||
error_log( __METHOD__ . ': ' . $e->getMessage() ); | ||
} | ||
|
||
return $terms; | ||
} | ||
} |
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