| @@ -1,65 +1,81 @@ | ||
| 1 | 1 | <?php |
| 2 | - if ( ( isset( $force ) && $force == null ) || ! isset( $force ) ) { | |
| 3 | - if( ! betterdocs()->settings->get( 'enable_sidebar_cat_list' ) ) { | |
| 4 | - return; | |
| 5 | - } | |
| 6 | - } | |
| 2 | +// phpcs:disable WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedVariableFound -- view template receives variables via extract(); prefixing is impractical. | |
| 7 | 3 | |
| 8 | - $wrapper_attributes = [ | |
| 9 | - 'class' => ['betterdocs-sidebar betterdocs-sidebar-layout-1'], | |
| 10 | - 'id' => 'betterdocs-sidebar' | |
| 11 | - ]; | |
| 4 | +if ( ! defined( 'ABSPATH' ) ) { | |
| 5 | + exit; | |
| 6 | +} | |
| 7 | +if ( ( isset( $force ) && $force == null ) || ! isset( $force ) ) { | |
| 8 | + if ( ! betterdocs()->settings->get( 'enable_sidebar_cat_list' ) && isset( $layout_type ) && $layout_type == 'template' ) { | |
| 9 | + return; | |
| 10 | + } | |
| 11 | +} | |
| 12 | 12 | |
| 13 | - /** | |
| 14 | - * @var array $wrapper_attr_array | |
| 15 | - */ | |
| 16 | - if ( isset( $wrapper_attr_array ) && ! empty( $wrapper_attr_array ) && is_array( $wrapper_attr_array ) ) { | |
| 17 | - $wrapper_attributes = betterdocs()->views->merge( $wrapper_attr_array, $wrapper_attributes ); | |
| 18 | - } | |
| 13 | + $wrapper_attributes = [ | |
| 14 | + 'class' => [ 'betterdocs-sidebar betterdocs-sidebar-layout-1' ], | |
| 15 | + 'id' => 'betterdocs-sidebar' | |
| 16 | + ]; | |
| 19 | 17 | |
| 20 | - $wrapper_attributes = betterdocs()->template_helper->get_html_attributes( $wrapper_attributes ); | |
| 21 | -?> | |
| 18 | + /** | |
| 19 | + * @var array $wrapper_attr_array | |
| 20 | + */ | |
| 21 | + if ( isset( $wrapper_attr_array ) && ! empty( $wrapper_attr_array ) && is_array( $wrapper_attr_array ) ) { | |
| 22 | + $wrapper_attributes = betterdocs()->views->merge( $wrapper_attr_array, $wrapper_attributes ); | |
| 23 | + } | |
| 24 | + | |
| 25 | + $wrapper_attributes = betterdocs()->template_helper->get_html_attributes( $wrapper_attributes ); | |
| 26 | + ?> | |
| 22 | 27 | <aside |
| 23 | - <?php echo $wrapper_attributes; ?>> | |
| 24 | - <div class="betterdocs-sidebar-content betterdocs-category-sidebar"> | |
| 25 | - <?php | |
| 26 | - $terms_orderby = betterdocs()->settings->get( 'terms_orderby' ); | |
| 27 | - $terms_order = betterdocs()->settings->get( 'terms_order' ); | |
| 28 | + <?php echo $wrapper_attributes; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?>> | |
| 29 | + <div class="betterdocs-sidebar-content betterdocs-category-sidebar"> | |
| 30 | + <?php | |
| 31 | + $terms_orderby = betterdocs()->settings->get( 'terms_orderby' ); | |
| 32 | + $terms_order = betterdocs()->settings->get( 'terms_order' ); | |
| 28 | 33 | |
| 29 | - if ( betterdocs()->settings->get( 'alphabetically_order_term' ) ) { | |
| 30 | - $terms_orderby = 'name'; | |
| 31 | - } | |
| 34 | + if ( betterdocs()->settings->get( 'alphabetically_order_term' ) ) { | |
| 35 | + $terms_orderby = 'name'; | |
| 36 | + } | |
| 32 | 37 | |
| 33 | - $title_tag = betterdocs()->customizer->defaults->get( 'betterdocs_sidebar_title_tag' ); | |
| 38 | + $title_tag = betterdocs()->customizer->defaults->get( 'betterdocs_sidebar_title_tag' ); | |
| 34 | 39 | |
| 35 | - $_shortcode_attr = [ | |
| 36 | - 'terms_order' => $terms_order, | |
| 37 | - 'terms_orderby' => $terms_orderby, | |
| 38 | - 'sidebar_list' => true, | |
| 39 | - 'posts_per_page' => -1, | |
| 40 | - 'title_tag' => betterdocs()->template_helper->is_valid_tag( $title_tag ) | |
| 41 | - ]; | |
| 42 | - if ( isset( $shortcode_attr ) ) { | |
| 43 | - $_shortcode_attr = array_merge( $_shortcode_attr, $shortcode_attr ); | |
| 44 | - } | |
| 40 | + $_shortcode_attr = [ | |
| 41 | + 'terms_order' => $terms_order, | |
| 42 | + 'terms_orderby' => $terms_orderby, | |
| 43 | + 'sidebar_list' => true, | |
| 44 | + 'posts_per_page' => -1, | |
| 45 | + 'title_tag' => betterdocs()->template_helper->is_valid_tag( $title_tag ), | |
| 46 | + 'layout_type' => isset( $layout_type ) ? $layout_type : '', | |
| 47 | + 'lazy_load' => ! empty( betterdocs()->settings->get( 'archive_lazy_load_descendants' ) ), | |
| 48 | + ]; | |
| 45 | 49 | |
| 46 | - $attributes = betterdocs()->template_helper->shortcode_atts( | |
| 47 | - $_shortcode_attr, | |
| 48 | - 'betterdocs_category_grid', | |
| 49 | - 'sidebar-1', | |
| 50 | - $terms_orderby, | |
| 51 | - $terms_order | |
| 52 | - ); | |
| 50 | + if ( isset( $layout_type ) && $layout_type == 'template' ) { | |
| 51 | + $_shortcode_attr['list_icon_url'] = ! empty( betterdocs()->customizer->defaults->get( 'betterdocs_sidbebar_item_list_icon' ) ) ? betterdocs()->customizer->defaults->get( 'betterdocs_sidbebar_item_list_icon' ) : ( ! empty( betterdocs()->settings->get( 'docs_list_icon' ) ) ? betterdocs()->settings->get( 'docs_list_icon' )['url'] : '' ); | |
| 52 | + } | |
| 53 | 53 | |
| 54 | - echo do_shortcode( '[betterdocs_category_grid ' . $attributes . ']' ); | |
| 55 | - ?> | |
| 56 | - </div> | |
| 54 | + if ( isset( $layout_type ) && $layout_type == 'block' ) { | |
| 55 | + $_shortcode_attr['list_icon_url'] = ''; | |
| 56 | + } | |
| 57 | 57 | |
| 58 | - <?php | |
| 59 | - if ( is_single() ) { | |
| 60 | - if ( betterdocs()->settings->get( 'enable_toc' ) && betterdocs()->settings->get( 'enable_sticky_toc' ) ) { | |
| 61 | - betterdocs()->views->get( 'templates/parts/sticky-toc' ); | |
| 62 | - } | |
| 63 | - } | |
| 64 | - ?> | |
| 58 | + if ( isset( $shortcode_attr ) ) { | |
| 59 | + $_shortcode_attr = array_merge( $_shortcode_attr, $shortcode_attr ); | |
| 60 | + } | |
| 61 | + | |
| 62 | + $attributes = betterdocs()->template_helper->shortcode_atts( | |
| 63 | + $_shortcode_attr, | |
| 64 | + 'betterdocs_category_grid', | |
| 65 | + 'sidebar-1', | |
| 66 | + $terms_orderby, | |
| 67 | + $terms_order | |
| 68 | + ); | |
| 69 | + | |
| 70 | + echo do_shortcode( '[betterdocs_category_grid ' . $attributes . ']' ); | |
| 71 | + ?> | |
| 72 | + </div> | |
| 73 | + | |
| 74 | + <?php | |
| 75 | + if ( is_single() ) { | |
| 76 | + if ( betterdocs()->settings->get( 'enable_toc' ) && betterdocs()->settings->get( 'enable_sticky_toc' ) ) { | |
| 77 | + betterdocs()->views->get( 'templates/parts/sticky-toc' ); | |
| 78 | + } | |
| 79 | + } | |
| 80 | + ?> | |
| 65 | 81 | </aside> |