| 1 |
<?php |
| 2 |
|
| 3 |
namespace WPDeveloper\BetterDocs\Shortcodes; |
| 4 |
|
| 5 |
use WPDeveloper\BetterDocs\Core\Shortcode; |
| 6 |
|
| 7 |
class CategoryList extends Shortcode { |
| 8 |
public function get_name() { |
| 9 |
return 'betterdocs_category_list'; |
| 10 |
} |
| 11 |
|
| 12 |
public function get_style_depends() { |
| 13 |
return [ 'betterdocs-category-grid-list' ]; |
| 14 |
} |
| 15 |
|
| 16 |
public function get_script_depends() { |
| 17 |
return [ 'betterdocs-category-grid' ]; |
| 18 |
} |
| 19 |
|
| 20 |
/** |
| 21 |
* Summary of default_attributes |
| 22 |
* @return array |
| 23 |
*/ |
| 24 |
public function default_attributes() { |
| 25 |
return [ |
| 26 |
'post_type' => 'docs', |
| 27 |
'category' => 'doc_category', |
| 28 |
'orderby' => $this->settings->get( 'alphabetically_order_post' ), |
| 29 |
'order' => $this->settings->get( 'docs_order' ), |
| 30 |
'masonry' => '', |
| 31 |
'column' => '', |
| 32 |
'posts_per_page' => -1, |
| 33 |
'nested_subcategory' => '', |
| 34 |
'terms' => '', |
| 35 |
'terms_orderby' => '', |
| 36 |
'terms_order' => '', |
| 37 |
'kb_slug' => '', |
| 38 |
'multiple_knowledge_base' => false, |
| 39 |
'title_tag' => 'h2', |
| 40 |
'layout_type' => '', |
| 41 |
'list_icon_url' => '', |
| 42 |
'sidebar_layout' => '', |
| 43 |
'list_icon_name' => '', |
| 44 |
'lazy_load' => false |
| 45 |
]; |
| 46 |
} |
| 47 |
|
| 48 |
public function view_params() { |
| 49 |
$terms_query = $this->query->terms_query( |
| 50 |
[ |
| 51 |
'multiple_kb' => ( $this->attributes['multiple_knowledge_base'] && ! empty( $this->attributes['kb_slug'] ) ) ? true : false, |
| 52 |
'kb_slug' => $this->attributes['kb_slug'], |
| 53 |
'terms' => $this->attributes['terms'], |
| 54 |
'order' => $this->attributes['terms_order'], |
| 55 |
'orderby' => $this->attributes['terms_orderby'], |
| 56 |
'nested_subcategory' => (bool) $this->attributes['nested_subcategory'] |
| 57 |
] |
| 58 |
); |
| 59 |
|
| 60 |
$docs_query = [ |
| 61 |
'orderby' => $this->attributes['orderby'], |
| 62 |
'order' => $this->attributes['order'], |
| 63 |
'posts_per_page' => $this->attributes['posts_per_page'] |
| 64 |
]; |
| 65 |
|
| 66 |
return [ |
| 67 |
'wrapper_attr' => [ 'class' => [ 'betterdocs-category-list-wrapper' ] ], |
| 68 |
'inner_wrapper_attr' => [ 'class' => [ 'betterdocs-category-list-inner-wrapper' ] ], |
| 69 |
'is_edit_mode' => false, |
| 70 |
'widget' => $this, |
| 71 |
'layout' => 'default', |
| 72 |
|
| 73 |
'default_multiple_kb' => false, |
| 74 |
'terms_query_args' => $terms_query, |
| 75 |
'docs_query_args' => $docs_query, |
| 76 |
'widget_type' => 'category-grid', |
| 77 |
|
| 78 |
'show_header' => true, |
| 79 |
'show_list' => true, |
| 80 |
'list_icon' => true, |
| 81 |
|
| 82 |
'show_button' => false, |
| 83 |
|
| 84 |
'show_count' => false, |
| 85 |
'count_prefix' => '', |
| 86 |
'count_suffix_singular' => '', |
| 87 |
'count_suffix' => '', |
| 88 |
'show_title' => true, |
| 89 |
'show_icon' => false, |
| 90 |
'layout_type' => $this->attributes['layout_type'], |
| 91 |
'list_icon_url' => $this->attributes['list_icon_url'], |
| 92 |
'sidebar_layout' => $this->attributes['sidebar_layout'], |
| 93 |
'list_icon_name' => $this->attributes['list_icon_name'], |
| 94 |
'title_tag' => $this->attributes['title_tag'], |
| 95 |
'lazy_load' => ! empty( $this->attributes['lazy_load'] ) |
| 96 |
]; |
| 97 |
} |
| 98 |
|
| 99 |
public function render( $atts, $content = null ) { |
| 100 |
$this->views( 'layouts/base' ); |
| 101 |
} |
| 102 |
} |
| 103 |
|