| 1 |
<?php |
| 2 |
|
| 3 |
/** |
| 4 |
* Class ListCourseCategories |
| 5 |
* |
| 6 |
* Handle lit course categories |
| 7 |
* |
| 8 |
* @package LearnPress/Classes |
| 9 |
* @version 1.0.0 |
| 10 |
* @since 4.2.6.5 |
| 11 |
*/ |
| 12 |
|
| 13 |
namespace LearnPress\Models; |
| 14 |
|
| 15 |
use Throwable; |
| 16 |
|
| 17 |
class ListCourseCategories { |
| 18 |
/** |
| 19 |
* Get all course categories |
| 20 |
* |
| 21 |
* @param array $arg_query_terms |
| 22 |
* |
| 23 |
* @return array [ term_id => term_name ] |
| 24 |
*/ |
| 25 |
public static function get_all_categories_id_name( array $arg_query_terms = [] ): array { |
| 26 |
$terms = []; |
| 27 |
|
| 28 |
try { |
| 29 |
$arg_query_terms_default = [ |
| 30 |
'taxonomy' => LP_COURSE_CATEGORY_TAX, |
| 31 |
'fields' => 'id=>name', |
| 32 |
'parent' => 0, |
| 33 |
'orderby' => 'term_order', |
| 34 |
'order' => 'ASC', |
| 35 |
]; |
| 36 |
|
| 37 |
$arg_query_terms = array_merge( $arg_query_terms_default, $arg_query_terms ); |
| 38 |
|
| 39 |
$terms = get_terms( $arg_query_terms ); |
| 40 |
} catch ( Throwable $e ) { |
| 41 |
error_log( __METHOD__ . ': ' . $e->getMessage() ); |
| 42 |
} |
| 43 |
|
| 44 |
return $terms; |
| 45 |
} |
| 46 |
} |
| 47 |
|