?> <?php edit_post_link(__('Edit', 'pressbooks'), '<span class="edit-link">', '</span>'); ?> <?php // add part title to chapters if ('chapter' == get_post_type($post->ID)) { $part_title = get_post_field('post_title', $post->post_parent); if (!is_wp_error($part_title)) { echo "<small class='alignright'>" . $part_title . "</small>"; } } ?> <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)); ?> >
<?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 ) ); } ?>