<?php the_title('<h1 class="entry-title">', '</h1>'); ?> <div class="difficulty"> <?php do_action('display_difficulty_rating', $post->ID); ?> </div> <div id="post-<?php the_ID(); ?> " <?php post_class(pb_get_section_type($post)); ?> > <div class="entry-content"> <?php the_content(); if (get_post_type($post->ID) === 'part') { echo get_post_meta($post->ID, 'pb_part_content', true); } ?> </div> </div> <?php
/** * Get "real" chapter number * * @param $post_name * * @return int */ function pb_get_chapter_number($post_name) { $options = get_option('pressbooks_theme_options_global'); if (!@$options['chapter_numbers']) { return 0; } $lookup = \PressBooks\Book::getBookStructure(); $lookup = $lookup['__export_lookup']; if ('chapter' != @$lookup[$post_name]) { return 0; } $i = 0; foreach ($lookup as $key => $val) { if ('chapter' == $val) { $chapter = get_posts(array('name' => $key, 'post_type' => 'chapter', 'post_status' => 'publish', 'numberposts' => 1)); if (isset($chapter[0])) { $type = pb_get_section_type($chapter[0]); if ($type !== 'numberless') { ++$i; } } else { return 0; } if ($key == $post_name) { break; } } } if ($type == 'numberless') { $i = 0; } return $i; }
} ?> <li><h4><!-- Back-matter --></h4></li> <li> <ul> <?php foreach ($book['back-matter'] as $bm) { ?> <?php if ($bm['post_status'] != 'publish') { continue; } // Skip ?> <li class="back-matter <?php echo pb_get_section_type(get_post($bm['ID'])); ?> "><a href="<?php echo get_permalink($bm['ID']); ?> "><?php echo pb_strip_br($bm['post_title']); ?> </a> <?php $sections = pb_get_sections($bm['ID']); if ($sections && pb_should_parse_sections()) { $s = 1; ?> <ul class="sections"> <?php
<?php if ($fm['post_status'] != 'publish') continue; // Skip ?> <li class="front-matter <?php echo pb_get_section_type( get_post($fm['ID']) ) ?>"><a href="<?php echo get_permalink($fm['ID']); ?>"><?php echo $fm['post_title']; ?></a></li> <?php endforeach; ?> </ul> </li> <?php foreach ($book['part'] as $part) : ?> <li><h4><?php if ( count( $book['part'] ) > 1 ) echo $part['post_title']; ?></h4><ul> <?php foreach ($part['chapters'] as $chapter) : ?> <?php if ($chapter['post_status'] != 'publish') continue; // Skip ?> <li class="chapter <?php echo pb_get_section_type( get_post($chapter['ID']) ) ?>"><a href="<?php echo get_permalink($chapter['ID']); ?>"><?php echo $chapter['post_title']; ?></a></li> <?php endforeach; ?> </ul></li> <?php endforeach; ?> <li> <ul> <?php foreach ($book['back-matter'] as $bm) : ?> <?php if ($bm['post_status'] != 'publish') continue; // Skip ?> <li class="back-matter <?php echo pb_get_section_type( get_post($bm['ID']) ) ?>"><a href="<?php echo get_permalink($bm['ID']); ?>"><?php echo $bm['post_title']; ?></a></li> <?php endforeach; ?> </ul> </li> </ul> </div><!-- #post-## --> <?php else: ?> <?php pb_private(); ?> <?php endif; ?> <?php get_footer(); ?>
<?php if ( have_posts() ) while ( have_posts() ) : the_post(); ?> <?php get_header(); ?> <?php if (get_option('blog_public') == '1' || (get_option('blog_public') == '0' && current_user_can_for_blog($blog_id, 'read'))): ?> <?php edit_post_link( __( 'Edit', 'pressbooks' ), '<span class="edit-link">', '</span>' ); ?> <h2 class="entry-title"><?php if ( $chapter_number = pb_get_chapter_number( $post->post_name ) ) echo "<span>$chapter_number</span> "; the_title(); ?></h2> <?php pb_get_links(); ?> <div id="post-<?php the_ID(); ?>" <?php post_class( pb_get_section_type( $post ) ); ?>> <div class="entry-content"> <?php if ($subtitle = get_post_meta($post->ID, 'pb_subtitle', true)): ?> <h2 class="chapter_subtitle"><?php echo $subtitle; ?></h2> <?php endif;?> <?php if ($chap_author = get_post_meta($post->ID, 'pb_section_author', true)): ?> <h2 class="chapter_author"><?php echo $chap_author; ?></h2> <?php endif; ?> <?php if ( get_post_type( $post->ID ) !== 'part' ) { $content = apply_filters ( 'the_content', get_the_content() ); $s = 1; while ( strpos( $content, '<h1>' ) !== false ) { $content = preg_replace('/<h1>/', '<h1 id="section-' . $s++ . '">', $content, 1); } echo $content; } else { echo apply_filters( 'the_content', get_post_meta( $post->ID, 'pb_part_content', true ) ); } ?>