pressbooks aldine theme the theme used for the front page or default book
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

67 lines
2.0 KiB

<?php
/**
* The template for displaying the catalog page
*
* Template Name: Catalog
*
* @link https://developer.wordpress.org/themes/basics/template-hierarchy/
*
* @package Aldine
*/
use function Aldine\Helpers\get_catalog_data;
use function Aldine\Helpers\get_catalog_licenses;
use function Aldine\Helpers\get_available_subjects;
use function Aldine\Helpers\get_available_licenses;
$current_page = ( get_query_var( 'paged' ) ) ? get_query_var( 'paged' ) : 1;
$orderby = ( get_query_var( 'orderby' ) ) ? get_query_var( 'orderby' ) : 'title';
$subject = ( get_query_var( 'subject' ) ) ? get_query_var( 'subject' ) : '';
$license = ( get_query_var( 'license' ) ) ? get_query_var( 'license' ) : '';
$catalog_data = get_catalog_data( $current_page, 9, $orderby, $license, $subject );
$previous_page = ( $current_page > 1 ) ? $current_page - 1 : 0;
$next_page = $current_page + 1;
$licenses = get_catalog_licenses();
$available_licenses = get_available_licenses( $catalog_data );
$subjects = ( defined( 'PB_PLUGIN_VERSION' ) ) ? \Pressbooks\Metadata\get_thema_subjects() : [];
$available_subjects = get_available_subjects( $catalog_data );
7 years ago
if ( ! empty( $catalog_data['books'] ) ) :
7 years ago
get_header(); ?>
<div id="primary" class="content-area">
<main id="main" class="site-main">
<?php include( locate_template( 'partials/content-page-catalog.php' ) ); ?>
</main><!-- #main -->
</div><!-- #primary -->
<?php
get_sidebar();
get_footer();
else :
global $wp_query;
$wp_query->set_404();
status_header( 404 );
get_header();
?>
<div id="primary" class="content-area">
<main id="main" class="site-main">
<article class="page">
<header class="entry-header">
7 years ago
<h1 class="entry-title"><?php _e( 'No Books Found', 'pressbooks-aldine' ); ?></h1>
</header>
<div class="entry-content" style="text-align:center;">
7 years ago
<p><?php _e( 'No books have been added to the catalog.', 'pressbooks-aldine' ); ?></p>
</div>
</article>
</main>
</div>
<?php
get_footer();
exit();
endif;