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.

53 lines
1.3 KiB

7 years ago
<?php
namespace Aldine;
7 years ago
use Sober\Controller\Controller;
class FrontPage extends Controller
7 years ago
{
public function blockCount()
{
7 years ago
global $_wp_sidebars_widgets;
7 years ago
if (empty($_wp_sidebars_widgets)) {
$_wp_sidebars_widgets = get_option('sidebars_widgets', []);
}
7 years ago
$sidebars_widgets_count = $_wp_sidebars_widgets;
if (isset($sidebars_widgets_count['front-page-block'])) {
return count($sidebars_widgets_count['front-page-block']);
}
return 1;
}
public function totalPages()
{
$books = wp_remote_get(network_home_url('/wp-json/pressbooks/v2/books?per_page=3'));
return $books['headers']['x-wp-totalpages'];
}
public function currentPage()
{
return get_query_var('page', 1);
}
public function previousPage()
{
return (get_query_var('page', 1) > 1) ? get_query_var('page') - 1 : 0;
}
public function nextPage()
{
return (get_query_var('page', 1) < FrontPage::totalPages()) ? get_query_var('page', 1) + 1 : 0;
}
public function latestBooksTitle()
{
$title = get_option('pb_front_page_catalog_title');
if ($title) {
return $title;
}
return __('Our Latest Titles', 'aldine');
}
7 years ago
}