Skip to content

Commit

Permalink
Bug #18, add top_link flag to simple_menu shortcode plugin [iet:7…
Browse files Browse the repository at this point in the history
…491556]
  • Loading branch information
nfreear committed Dec 21, 2016
1 parent bc5f4ed commit d795f08
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions simple_menu.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ public function shortcode_simplemenu( $attr ) {
'sub' => NULL,
'content' => false,
'comments'=> false,
'top_link'=> true,
], $attr ) );

$menu_obj = wp_get_nav_menu_object( $menu ); //232 ); //'Help' ); //'Main' );
Expand All @@ -60,7 +61,7 @@ public function shortcode_simplemenu( $attr ) {
$classes = self::SHORTCODE . " menu-$menu sub-$sub";

if ( $content ) {
return $this->display_content( $sub_menu, $parent_id, $classes, $comments );
return $this->display_content( $sub_menu, $parent_id, $classes, $comments, $top_link );
}
return $this->display_menu( $sub_menu, $parent_id, $classes );
}
Expand Down Expand Up @@ -88,7 +89,7 @@ protected function display_menu( $sub_menu, $menu_id, $classes ) {
}


protected function display_content( $sub_menu, $menu_id, $classes, $show_comments = false ) {
protected function display_content( $sub_menu, $menu_id, $classes, $show_comments = false, $with_top_link = false ) {
ob_start();

?><div class="<?php echo $classes ?>" id="sm-menu-<?php echo $menu_id ?>">
Expand All @@ -99,6 +100,9 @@ protected function display_content( $sub_menu, $menu_id, $classes, $show_comment
<h2 class="item-title"><?php echo $it->title ?></h3>
<?php echo apply_filters('the_content', get_post_field( 'post_content', $it->object_id )) ?>
<?php self::display_comments( $it->object_id, $show_comments ) ?>
<?php if ( $with_top_link ): ?>
<a href="#site-main" class="tttt-to-top">Return to top of page</a>
<?php endif; ?>
</div>
<?php endforeach ?>
</div><?php
Expand Down

0 comments on commit d795f08

Please sign in to comment.