protected function createBackMatter($book_contents, $metadata)
{
$back_matter_printf = '<div class="back-matter %s" id="%s">';
$back_matter_printf .= '<div class="back-matter-title-wrap"><h3 class="back-matter-number">%s</h3><h1 class="back-matter-title">%s</h1></div>';
$back_matter_printf .= '<div class="ugc back-matter-ugc">%s</div>%s';
$back_matter_printf .= '</div>';
$vars = array('post_title' => '', 'stylesheet' => $this->stylesheet, 'post_content' => '', 'append_back_matter_content' => '', 'isbn' => @$metadata['pb_ebook_isbn'], 'lang' => $this->lang);
$i = 1;
foreach ($book_contents['back-matter'] as $back_matter) {
if (!$back_matter['export']) {
continue;
// Skip
}
$back_matter_id = $back_matter['ID'];
$subclass = \Pressbooks\Taxonomy::getBackMatterType($back_matter_id);
$slug = $back_matter['post_name'];
$title = get_post_meta($back_matter_id, 'pb_show_title', true) ? $back_matter['post_title'] : '';
$content = $this->kneadHtml($back_matter['post_content'], 'back-matter', $i);
$append_back_matter_content = $this->kneadHtml(apply_filters('pb_append_back_matter_content', '', $back_matter_id), 'back-matter');
$short_title = trim(get_post_meta($back_matter_id, 'pb_short_title', true));
$subtitle = trim(get_post_meta($back_matter_id, 'pb_subtitle', true));
$author = trim(get_post_meta($back_matter_id, 'pb_section_author', true));
if (\Pressbooks\Modules\Export\Export::isParsingSubsections() == true) {
$sections = \Pressbooks\Book::getSubsections($back_matter_id);
if ($sections) {
$content = \Pressbooks\Book::tagSubsections($content, $back_matter_id);
}
}
if ($author) {
$content = '<h2 class="chapter-author">' . Sanitize\decode($author) . '</h2>' . $content;
}
if ($subtitle) {
$content = '<h2 class="chapter-subtitle">' . Sanitize\decode($subtitle) . '</h2>' . $content;
}
if ($short_title) {
$content = '<h6 class="short-title">' . Sanitize\decode($short_title) . '</h6>' . $content;
}
$vars['post_title'] = $back_matter['post_title'];
$vars['post_content'] = sprintf($back_matter_printf, $subclass, $slug, $i, Sanitize\decode($title), $content, $var['append_back_matter_content'] = $append_back_matter_content, '');
$file_id = 'back-matter-' . sprintf('%03s', $i);
$filename = "{$file_id}-{$slug}.{$this->filext}";
file_put_contents($this->tmpDir . "/OEBPS/{$filename}", $this->loadTemplate($this->dir . '/templates/epub201/html.php', $vars));
$this->manifest[$file_id] = array('ID' => $back_matter['ID'], 'post_title' => $back_matter['post_title'], 'filename' => $filename);
++$i;
}
}