| @@ -1,18 +1,75 @@ | ||
| 1 | 1 | <aside id="betterdocs-sidebar-right" class="betterdocs-sidebar betterdocs-full-sidebar-right right-sidebar-toc-wrap"> |
| 2 | - <div data-simplebar class="layout3-toc-container right-sidebar-toc-container"> | |
| 3 | - <?php | |
| 4 | - $hierarchy = betterdocs()->settings->get( 'toc_hierarchy' ); | |
| 5 | - $list_number = betterdocs()->settings->get( 'toc_list_number' ); | |
| 6 | - $supported_tag = betterdocs()->settings->get( 'supported_heading_tag' ); | |
| 7 | - $htags = $supported_tag ? implode( ',', $supported_tag ) : ''; | |
| 2 | + <div data-simplebar class="layout3-toc-container right-sidebar-toc-container"> | |
| 3 | + <?php | |
| 4 | +// phpcs:disable WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedVariableFound -- view template receives variables via extract(); prefixing is impractical. | |
| 5 | +if ( ! defined( 'ABSPATH' ) ) { | |
| 6 | + exit; | |
| 7 | +} | |
| 8 | +// Check if post is password protected and user hasn't provided correct password | |
| 9 | + if ( post_password_required() ) { | |
| 10 | + // Don't show ToC sidebar for password-protected posts until password is provided | |
| 11 | + echo '<div class="betterdocs-toc-password-protected">'; | |
| 12 | + echo '<p>' . esc_html__( 'Table of Contents is available after entering the correct password.', 'betterdocs' ) . '</p>'; | |
| 13 | + echo '</div>'; | |
| 14 | + } else { | |
| 15 | + $hierarchy = betterdocs()->settings->get( 'toc_hierarchy' ); | |
| 16 | + $list_number = betterdocs()->settings->get( 'toc_list_number' ); | |
| 17 | + $supported_tag = betterdocs()->settings->get( 'supported_heading_tag' ); | |
| 18 | + $htags = $supported_tag ? implode( ',', $supported_tag ) : ''; | |
| 8 | 19 | |
| 9 | - $attributes = betterdocs()->template_helper->get_html_attributes( [ | |
| 10 | - 'htags' => "{$htags}", | |
| 11 | - 'hierarchy' => "{$hierarchy}", | |
| 12 | - 'list_number' => "{$list_number}" | |
| 13 | - ] ); | |
| 20 | + $attributes = betterdocs()->template_helper->get_html_attributes( | |
| 21 | + [ | |
| 22 | + 'htags' => "{$htags}", | |
| 23 | + 'hierarchy' => "{$hierarchy}", | |
| 24 | + 'list_number' => "{$list_number}", | |
| 25 | + 'collapsible_on_mobile' => false | |
| 26 | + ] | |
| 27 | + ); | |
| 14 | 28 | |
| 15 | - echo do_shortcode( "[betterdocs_toc " . $attributes . "]" ); | |
| 16 | - ?> | |
| 17 | - </div> | |
| 29 | + echo do_shortcode( '[betterdocs_toc ' . $attributes . ']' ); | |
| 30 | + | |
| 31 | + if ( isset( $social_share ) && $social_share ) { | |
| 32 | + echo betterdocs()->views->get( 'templates/parts/social-2' ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped | |
| 33 | + } | |
| 34 | + | |
| 35 | + if ( isset( $feedback ) && $feedback ) { | |
| 36 | + $reaction_text = betterdocs()->customizer->defaults->get( 'betterdocs_post_reactions_text_2' ); | |
| 37 | + $reaction_text_tag = betterdocs()->customizer->defaults->get( 'betterdocs_reactions_title_tag' ); | |
| 38 | + // Collect reaction values and icons | |
| 39 | + $reactions_data = [ | |
| 40 | + 'happy' => 'betterdocs_post_reactions_happy', | |
| 41 | + 'happy_icon' => 'betterdocs_post_reactions_happy_icon', | |
| 42 | + 'normal' => 'betterdocs_post_reactions_normal', | |
| 43 | + 'normal_icon' => 'betterdocs_post_reactions_normal_icon', | |
| 44 | + 'sad' => 'betterdocs_post_reactions_sad', | |
| 45 | + 'sad_icon' => 'betterdocs_post_reactions_sad_icon' | |
| 46 | + ]; | |
| 47 | + | |
| 48 | + foreach ( $reactions_data as $key => $theme_mod ) { | |
| 49 | + $value = betterdocs()->customizer->defaults->get( $theme_mod ); | |
| 50 | + if ( $value ) { | |
| 51 | + $args[ $key ] = $value; | |
| 52 | + } else { | |
| 53 | + $args[ $key ] = false; | |
| 54 | + } | |
| 55 | + } | |
| 56 | + | |
| 57 | + // Build the attribute string for the shortcode | |
| 58 | + $attr = ''; | |
| 59 | + foreach ( $args as $key => $value ) { | |
| 60 | + $attr .= sprintf( ' %s="%s"', esc_attr( $key ), esc_attr( $value ) ); | |
| 61 | + } | |
| 62 | + echo do_shortcode( '[betterdocs_article_reactions text="' . $reaction_text . '" text_tag="' . $reaction_text_tag . '" layout="layout-3"' . $attr . ']' ); | |
| 63 | + } | |
| 64 | + } // End password protection check | |
| 65 | + ?> | |
| 66 | + </div> | |
| 67 | + <?php | |
| 68 | + /** | |
| 69 | + * Fires inside the right (ToC) sidebar, after the ToC container. Extension | |
| 70 | + * point for add-ons that render a sticky side panel next to the ToC (e.g. | |
| 71 | + * BetterDocs Pro's API-docs code-sample panel). | |
| 72 | + */ | |
| 73 | + do_action( 'betterdocs_after_toc_sidebar' ); | |
| 74 | + ?> | |
| 18 | 75 | </aside> |