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