Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- function shortcode_docs_nav() {
- ob_start();
- global $post;
- // Required version
- $category = get_query_var( 'documentation_category' );
- $category_term = get_term_by( 'slug', $category, 'documentation_category' );
- if ( ! empty( $category_term ) ) {
- if ( 15 == $category_term->parent || 37 == $category_term->term_id ) {
- // Show Personal license required for Integrations + Webhooks
- echo do_shortcode( '[elementor-template id="37591"]' );
- } elseif ( 29 == $category_term->parent ) {
- // Show Plus license required for Addons
- echo do_shortcode( '[elementor-template id="37599"]' );
- }
- }
- // On this page
- $depth = 4;
- $pattern = '/<h[2-' . $depth . ']*[^>]*>.*?<\/h[2-' . $depth . ']>/';
- $whocares = preg_match_all( $pattern, $post->post_content, $winners );
- foreach ( $winners[0] as $i => $winner ) {
- $winners[0][ $i ] = str_replace( '<h4>', '<h4><a href="#' . sanitize_title( $winner ) . '">', $winners[0][ $i ] );
- $winners[0][ $i ] = str_replace( '</h4>', '</a></h4>', $winners[0][ $i ] );
- $winners[0][ $i ] = str_replace( '<h3>', '<h3><a href="#' . sanitize_title( $winner ) . '">', $winners[0][ $i ] );
- $winners[0][ $i ] = str_replace( '</h3>', '</a></h3>', $winners[0][ $i ] );
- }
- //reformat the results to be more usable
- $heads = implode( "\n", $winners[0] );
- $heads = preg_replace( '/<h([1-' . $depth . '])>/', '<li class="toc$1">', $heads );
- $heads = preg_replace( '/<\/h[1-' . $depth . ']>/', '</li>', $heads );
- ?>
- <div id="nav-sidebar" class="sidebar line-top">
- <hr style="border-bottom: 4px solid #0b328e;" />
- <h3>On this page</h3>
- <ul><?php echo $heads; ?></ul>
- </div>
- <?php
- return ob_get_clean();
- }
- add_shortcode( 'wpf_docs_nav', 'shortcode_docs_nav' );
Add Comment
Please, Sign In to add comment