| @@ -1,63 +1,68 @@ | ||
| 1 | 1 | <?php |
| 2 | 2 | namespace WPDeveloper\BetterDocs\Editors\Elementor; |
| 3 | + | |
| 3 | 4 | use WPDeveloper\BetterDocs\Core\Query; |
| 4 | 5 | |
| 5 | 6 | if ( ! defined( 'ABSPATH' ) ) { |
| 6 | - exit; // Exit if accessed directly | |
| 7 | + exit; // Exit if accessed directly | |
| 7 | 8 | } |
| 8 | 9 | |
| 9 | 10 | use WPDeveloper\BetterDocs\Utils\Base; |
| 10 | 11 | |
| 11 | 12 | class Helper extends Base { |
| 12 | - /** | |
| 13 | - * Summary of query | |
| 14 | - * @var Query | |
| 15 | - */ | |
| 16 | - private $query; | |
| 13 | + /** | |
| 14 | + * Summary of query | |
| 15 | + * @var Query | |
| 16 | + */ | |
| 17 | + private $query; | |
| 17 | 18 | |
| 18 | - public function __construct( Query $query ) { | |
| 19 | - $this->query = $query; | |
| 20 | - } | |
| 19 | + public function __construct( Query $query ) { | |
| 20 | + $this->query = $query; | |
| 21 | + } | |
| 21 | 22 | |
| 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 | - ]; | |
| 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 | + ]; | |
| 35 | 36 | |
| 36 | - return $orderby; | |
| 37 | - } | |
| 37 | + return $orderby; | |
| 38 | + } | |
| 38 | 39 | |
| 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 | - ] ); | |
| 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 | + ); | |
| 50 | 53 | |
| 51 | - if ( ! empty( $terms ) && ! is_wp_error( $terms ) ) { | |
| 52 | - foreach ( $terms as $term ) { | |
| 53 | - $options[$term->{$key}] = $term->name; | |
| 54 | - } | |
| 55 | - } | |
| 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 | + } | |
| 56 | 61 | |
| 57 | - return $options; | |
| 58 | - } | |
| 62 | + return $options; | |
| 63 | + } | |
| 59 | 64 | |
| 60 | - public function get_faq_terms() { | |
| 61 | - return $this->query->get_faq_terms(); | |
| 62 | - } | |
| 65 | + public function get_faq_terms() { | |
| 66 | + return $this->query->get_faq_terms(); | |
| 67 | + } | |
| 63 | 68 | } |