protected function createTitle($book_contents, $metadata)
{
// Look for custom title-page
$content = '';
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 ('title-page' != $subclass) {
continue;
// Skip
}
$content = $this->kneadHtml($front_matter['post_content'], 'front-matter');
break;
}
// HTML
$html = '<div id="title-page">';
if ($content) {
$html .= $content;
} else {
$html .= sprintf('<h1 class="title">%s</h1>', get_bloginfo('name'));
$html .= sprintf('<h2 class="subtitle">%s</h2>', @$metadata['pb_subtitle']);
$html .= sprintf('<h3 class="author">%s</h3>', @$metadata['pb_author']);
$html .= sprintf('<h4 class="author">%s</h4>', @$metadata['pb_contributing_authors']);
if (current_theme_supports('pressbooks_publisher_logo')) {
$html .= sprintf('<div class="publisher-logo"><img src="%s" /></div>', get_theme_support('pressbooks_publisher_logo')[0]['logo_uri']);
// TODO: Support custom publisher logo.
}
$html .= sprintf('<h4 class="publisher">%s</h4>', @$metadata['pb_publisher']);
$html .= sprintf('<h5 class="publisher-city">%s</h5>', @$metadata['pb_publisher_city']);
}
$html .= "</div>\n";
// Create file, insert into manifest
$vars = array('post_title' => __('Title Page', 'pressbooks'), 'stylesheet' => $this->stylesheet, 'post_content' => $html, 'isbn' => @$metadata['pb_ebook_isbn'], 'lang' => $this->lang);
$file_id = 'title-page';
$filename = "{$file_id}.{$this->filext}";
file_put_contents($this->tmpDir . "/OEBPS/{$filename}", $this->loadTemplate($this->dir . '/templates/epub201/html.php', $vars));
$this->manifest[$file_id] = array('ID' => -1, 'post_title' => $vars['post_title'], 'filename' => $filename);
}