Skip to content

Commit b62d5e6

Browse files
sigorillascottgonzalez
authored andcommitted
learn.jquery.com: Properly highlight nested categories
Closes gh-344
1 parent e14f33e commit b62d5e6

File tree

2 files changed

+9
-6
lines changed

2 files changed

+9
-6
lines changed

themes/learn.jquery.com/sidebar.php

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
<ul>
1313
<?php $chapters = learn_chapter_listing(); ?>
1414
<?php while ( $chapters->have_posts() ) : $chapters->the_post(); ?>
15-
<?php $is_active = ($active_post->ID == $chapters->post->ID) || ($active_post->post_parent == $chapters->post->ID); ?>
15+
<?php $is_active = ($active_post->ID == $chapters->post->ID); ?>
1616
<li <?php if ($is_active) { echo "class='active'"; } ?>>
1717
<a href="<?php the_permalink(); ?>">
1818
<?php if ( get_post_meta( $post->ID, "icon" ) ) : ?>
@@ -32,9 +32,12 @@
3232
<ul class="sub-chapter">
3333
<?php while ( $sub_chapters->have_posts() ) : $sub_chapters->the_post(); ?>
3434
<?php if ( has_children( $post ) ) { ?>
35-
<li><a href="<?php the_permalink(); ?>">
36-
<?php the_title(); ?>
37-
</a></li>
35+
<?php $is_active = ($active_post->ID == $sub_chapters->post->ID) || ($active_post->post_parent == $sub_chapters->post->ID); ?>
36+
<li <?php if ($is_active) { echo "class='active'"; } ?>>
37+
<a href="<?php the_permalink(); ?>">
38+
<?php the_title(); ?>
39+
</a>
40+
</li>
3841
<?php } ?>
3942
<?php endwhile; wp_reset_postdata(); ?>
4043
</ul>

themes/learn.jquery.com/style.css

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,13 +82,13 @@ a {
8282

8383
}
8484

85-
#sidebar #chapter-listing li.active a {
85+
#sidebar #chapter-listing li.active > a {
8686
background: #212121;
8787
color: #fff;
8888
text-shadow: none;
8989
}
9090

91-
#sidebar #chapter-listing li.active a i.icon-tasks {
91+
#sidebar #chapter-listing li.active > a i {
9292
color: #fff;
9393
}
9494

0 commit comments

Comments
 (0)