| 1 |
<?php |
| 2 |
namespace WPDeveloper\BetterDocs\Editors\Elementor; |
| 3 |
use WPDeveloper\BetterDocs\Core\Query; |
| 4 |
|
| 5 |
if ( ! defined( 'ABSPATH' ) ) { |
| 6 |
exit; // Exit if accessed directly |
| 7 |
} |
| 8 |
|
| 9 |
use WPDeveloper\BetterDocs\Utils\Base; |
| 10 |
|
| 11 |
class Helper extends Base { |
| 12 |
/** |
| 13 |
* Summary of query |
| 14 |
* @var Query |
| 15 |
*/ |
| 16 |
private $query; |
| 17 |
|
| 18 |
public function __construct( Query $query ) { |
| 19 |
$this->query = $query; |
| 20 |
} |
| 21 |
|
| 22 |
public function orderby_options() { |
| 23 |
$orderby = [ |
| 24 |
'ID' => 'Docs ID', |
| 25 |
'author' => 'Docs Author', |
| 26 |
'title' => 'Title', |
| 27 |
'date' => 'Date', |
| 28 |
'modified' => 'Last Modified Date', |
| 29 |
'parent' => 'Parent Id', |
| 30 |
'rand' => 'Random', |
| 31 |
'comment_count' => 'Comment Count', |
| 32 |
'menu_order' => 'Menu Order', |
| 33 |
'betterdocs_order' => 'BetterDocs Order' |
| 34 |
]; |
| 35 |
|
| 36 |
return $orderby; |
| 37 |
} |
| 38 |
|
| 39 |
/** |
| 40 |
* Get Post Categories |
| 41 |
* |
| 42 |
* @return array |
| 43 |
*/ |
| 44 |
public function get_terms( $taxonomy = 'category', $key = 'term_id' ) { |
| 45 |
$options = []; |
| 46 |
$terms = get_terms( [ |
| 47 |
'taxonomy' => $taxonomy, |
| 48 |
'hide_empty' => true |
| 49 |
] ); |
| 50 |
|
| 51 |
if ( ! empty( $terms ) && ! is_wp_error( $terms ) ) { |
| 52 |
foreach ( $terms as $term ) { |
| 53 |
$options[$term->{$key}] = $term->name; |
| 54 |
} |
| 55 |
} |
| 56 |
|
| 57 |
return $options; |
| 58 |
} |
| 59 |
|
| 60 |
public function get_faq_terms() { |
| 61 |
return $this->query->get_faq_terms(); |
| 62 |
} |
| 63 |
} |
| 64 |
|