protected function createFrontMatter($book_contents, $metadata)
{
$front_matter_printf = '<div class="front-matter %s" id="%s">';
$front_matter_printf .= '<div class="front-matter-title-wrap"><h3 class="front-matter-number">%s</h3><h1 class="front-matter-title">%s</h1></div>';
$front_matter_printf .= '<div class="ugc front-matter-ugc">%s</div>%s';
$front_matter_printf .= '</div>';
$vars = array('post_title' => '', 'stylesheet' => $this->stylesheet, 'post_content' => '', 'append_front_matter_content' => '', 'isbn' => @$metadata['pb_ebook_isbn'], 'lang' => $this->lang);
$i = $this->frontMatterPos;
foreach ($book_contents['front-matter'] as $front_matter) {
if (!$front_matter['export']) {
continue;
// Skip
}
$front_matter_id = $front_matter['ID'];
$subclass = \Pressbooks\Taxonomy::getFrontMatterType($front_matter_id);
if ('dedication' == $subclass || 'epigraph' == $subclass || 'title-page' == $subclass || 'before-title' == $subclass) {
continue;
// Skip
}
if ('introduction' == $subclass) {
$this->hasIntroduction = true;
}
$slug = $front_matter['post_name'];
$title = get_post_meta($front_matter_id, 'pb_show_title', true) ? $front_matter['post_title'] : '';
$content = $this->kneadHtml($front_matter['post_content'], 'front-matter', $i);
$append_front_matter_content = $this->kneadHtml(apply_filters('pb_append_front_matter_content', '', $front_matter_id), 'front-matter');
$short_title = trim(get_post_meta($front_matter_id, 'pb_short_title', true));
$subtitle = trim(get_post_meta($front_matter_id, 'pb_subtitle', true));
$author = trim(get_post_meta($front_matter_id, 'pb_section_author', true));
if (\Pressbooks\Modules\Export\Export::isParsingSubsections() == true) {
$sections = \Pressbooks\Book::getSubsections($front_matter_id);
if ($sections) {
$content = \Pressbooks\Book::tagSubsections($content, $front_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'] = $front_matter['post_title'];
$vars['post_content'] = sprintf($front_matter_printf, $subclass, $slug, $i, Sanitize\decode($title), $content, $var['append_front_matter_content'] = $append_front_matter_content, '');
$file_id = 'front-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' => $front_matter['ID'], 'post_title' => $front_matter['post_title'], 'filename' => $filename);
++$i;
}
$this->frontMatterPos = $i;
}