Browse Source

Extensive cleanup and refactoring.

pull/40/head
Ned Zimmerman 8 years ago
parent
commit
6ad90c677e
  1. 60
      app/activation.php
  2. 158
      app/admin.php
  3. 54
      app/controllers/App.php
  4. 79
      app/filters.php
  5. 202
      app/helpers.php
  6. 38
      app/intervention.php
  7. 199
      app/setup.php
  8. 2
      assets/scripts/customizer.js
  9. 6
      dist/mix-manifest.json
  10. 14600
      dist/scripts/aldine.js
  11. 10356
      dist/scripts/customizer.js
  12. 3052
      dist/styles/aldine.css
  13. 74
      footer.php
  14. 8
      functions.php
  15. 134
      inc/customizer/namespace.php
  16. 26
      inc/filters/namespace.php
  17. 110
      inc/helpers/namespace.php
  18. 22
      page.php
  19. 45
      partials/contact-form.php
  20. 59
      partials/content-front-page.php
  21. 14
      resources/views/404.blade.php
  22. 47
      resources/views/front-page.blade.php
  23. 18
      resources/views/index.blade.php
  24. 21
      resources/views/layouts/app.blade.php
  25. 10
      resources/views/page.blade.php
  26. 17
      resources/views/partials/book.blade.php
  27. 38
      resources/views/partials/comments.blade.php
  28. 22
      resources/views/partials/contact-form.blade.php
  29. 2
      resources/views/partials/content-page.blade.php
  30. 11
      resources/views/partials/content-search.blade.php
  31. 13
      resources/views/partials/content-single.blade.php
  32. 9
      resources/views/partials/content.blade.php
  33. 6
      resources/views/partials/entry-meta.blade.php
  34. 50
      resources/views/partials/footer.blade.php
  35. 6
      resources/views/partials/head.blade.php
  36. 7
      resources/views/partials/page-block.blade.php
  37. 1
      resources/views/partials/sidebar.blade.php
  38. 11
      resources/views/partials/uio-script.blade.php
  39. 9
      resources/views/partials/uio.blade.php
  40. 18
      resources/views/search.blade.php
  41. 7
      resources/views/single.blade.php
  42. 12
      resources/views/template-custom.blade.php
  43. 0
      views/page-catalog.blade.php
  44. 0
      views/partials/header.blade.php
  45. 0
      views/partials/page-header.blade.php
  46. 0
      views/partials/svg.blade.php

60
app/activation.php

@ -1,60 +0,0 @@
<?php
namespace Aldine;
add_action('admin_init', function () {
if (! get_option('pb_aldine_activated')) {
$extra = new \ParsedownExtra();
$about = $extra->text(file_get_contents(get_stylesheet_directory() . '/docs/about.md'));
$help = $extra->text(file_get_contents(get_stylesheet_directory() . '/docs/help.md'));
$default_pages = [
'about' => [
'post_title' => __('About', 'aldine'),
'post_content' => apply_filters('pb_root_about_page_content', $about)
],
'help' => [
'post_title' => __('Help', 'aldine'),
'post_content' => apply_filters('pb_root_help_page_content', $help)
],
'catalog' => [
'post_title' => __('Catalog', 'aldine'),
'post_content' => ''
],
'home' => [
'post_title' => __('Home', 'aldine'),
'post_content' => ''
],
];
// Add our pages
$pages = [];
foreach ($default_pages as $slug => $page) {
$check = get_page_by_path($slug);
if (empty($check)) {
$pages[$slug] = wp_insert_post(array_merge($page, ['post_type' => 'page', 'post_status' => 'publish']));
} else {
$pages[$slug] = $check->ID;
}
}
// Set front page to Home
update_option('show_on_front', 'page');
update_option('page_on_front', $pages['home']);
// Remove content generated by wp_install_defaults
if (! wp_delete_post(1, true)) {
return;
}
if (! wp_delete_post(2, true)) {
return;
}
if (! wp_delete_comment(1, true)) {
return;
}
// Add "pb_aldine_activated" option to enable check above
add_option('pb_aldine_activated', 1);
}
});

158
app/admin.php

@ -1,158 +0,0 @@
<?php
namespace Aldine;
/**
* Theme customizer
*/
add_action('customize_register', function (\WP_Customize_Manager $wp_customize) {
// Add postMessage support
$wp_customize->get_setting('blogname')->transport = 'postMessage';
$wp_customize->selective_refresh->add_partial('blogname', [
'selector' => '.branding h1 a',
'render_callback' => function () {
bloginfo('name');
}
]);
// Add settings
foreach ([
[
'slug' => 'primary',
'hex' => '#b01109',
'label' => __('Primary Color', 'aldine'),
'description' => __('Primary color, used for links and other primary elements.', 'aldine'),
],
[
'slug' => 'accent',
'hex' => '#015d75',
'label' => __('Accent Color', 'aldine'),
'description' => __('Accent color, used for flourishes and secondary elements.', 'aldine'),
],
[
'slug' => 'primary_fg',
'hex' => '#ffffff',
'label' => __('Primary Foreground Color', 'aldine'),
'description' => __('Used for text on a primary background.', 'aldine'),
],
[
'slug' => 'accent_fg',
'hex' => '#ffffff',
'label' => __('Accent Foreground Color', 'aldine'),
'description' => __('Used for text on an accent color background.', 'aldine'),
],
] as $color) {
$wp_customize->add_setting("pb_network_color_{$color['slug']}", [
'type' => 'option',
'default' => $color['hex'],
]);
$wp_customize->add_control(new \WP_Customize_Color_Control(
$wp_customize,
"pb_network_color_{$color['slug']}",
[
'label' => $color['label'],
'section' => 'colors',
'description' => $color['description'],
'settings' => "pb_network_color_{$color['slug']}",
]
));
}
$wp_customize->add_section('pb_network_social', [
'title' => __('Social Media', 'aldine'),
'priority' => 30,
]);
$wp_customize->add_setting('pb_network_facebook', [
'type' => 'option',
'sanitize_callback' => 'esc_url_raw',
]);
$wp_customize->add_control('pb_network_facebook', [
'label' => __('Facebook', 'aldine'),
'section' => 'pb_network_social',
'settings' => 'pb_network_facebook',
]);
$wp_customize->add_setting('pb_network_twitter', [
'type' => 'option',
'sanitize_callback' => 'esc_url_raw',
]);
$wp_customize->add_control('pb_network_twitter', [
'label' => __('Twitter', 'aldine'),
'section' => 'pb_network_social',
'settings' => 'pb_network_twitter',
]);
if (function_exists('pb_meets_minimum_requirements') && pb_meets_minimum_requirements()) {
$wp_customize->add_section('pb_front_page_catalog', [
'title' => __('Front Page Catalog', 'aldine'),
'priority' => 25,
]);
$wp_customize->add_setting('pb_front_page_catalog', [
'type' => 'option',
]);
$wp_customize->add_control('pb_front_page_catalog', [
'label' => __('Show Front Page Catalog', 'aldine'),
'section' => 'pb_front_page_catalog',
'settings' => 'pb_front_page_catalog',
'type' => 'checkbox'
]);
$wp_customize->add_setting('pb_front_page_catalog_title', [
'type' => 'option',
'sanitize_callback' => 'sanitize_text_field'
]);
$wp_customize->add_control('pb_front_page_catalog_title', [
'label' => __('Front Page Catalog Title', 'aldine'),
'section' => 'pb_front_page_catalog',
'settings' => 'pb_front_page_catalog_title',
]);
}
$wp_customize->add_section('pb_network_contact_form', [
'title' => __('Contact Form', 'aldine'),
'priority' => 25,
]);
$wp_customize->add_setting('pb_network_contact_form', [
'type' => 'option',
]);
$wp_customize->add_control('pb_network_contact_form', [
'label' => __('Show Contact Form', 'aldine'),
'section' => 'pb_network_contact_form',
'settings' => 'pb_network_contact_form',
'type' => 'checkbox'
]);
$wp_customize->add_setting('pb_network_contact_form_title', [
'type' => 'option',
'sanitize_callback' => 'sanitize_text_field'
]);
$wp_customize->add_control('pb_network_contact_form_title', [
'label' => __('Contact Form Title', 'aldine'),
'section' => 'pb_network_contact_form',
'settings' => 'pb_network_contact_form_title',
]);
});
/**
* Customizer JS
*/
add_action('customize_preview_init', function () {
wp_enqueue_script('aldine/customizer.js', asset_path('scripts/customizer.js'), ['customize-preview'], null, true);
wp_localize_script('aldine/customizer.js', 'SAGE_DIST_PATH', get_theme_file_uri() . '/dist/');
});
add_action('customize_controls_enqueue_scripts', function () {
$handle = 'wcag-validate-customizer-color-contrast';
$src = get_theme_file_uri() .
'/lib/customizer-validate-wcag-color-contrast/customizer-validate-wcag-color-contrast.js';
$deps = [ 'customize-controls' ];
wp_enqueue_script($handle, $src, $deps);
$exports = [
'validate_color_contrast' => [
'pb_network_color_primary_fg' => [ 'pb_network_color_primary' ],
'pb_network_color_accent_fg' => [ 'pb_network_color_accent' ],
],
];
wp_scripts()->add_data(
$handle,
'data',
sprintf('var _validateWCAGColorContrastExports = %s;', wp_json_encode($exports))
);
});

54
app/controllers/App.php

@ -16,20 +16,7 @@ class App extends Controller
}
}
public function siteName()
{
return get_bloginfo('name');
}
public function networkFacebook()
{
return get_option('pb_network_facebook');
}
public function networkTwitter()
{
return get_option('pb_network_twitter');
}
public static function networkFooter($index)
{
@ -68,15 +55,7 @@ class App extends Controller
return get_the_title();
}
public function contactFormTitle()
{
$title = get_option('pb_network_contact_form_title');
if ($title) {
return $title;
}
return __('Contact Us', 'aldine');
}
public function currentPage()
{
@ -123,37 +102,4 @@ class App extends Controller
return $page + 1;
}
public static function catalogData($page = 1, $per_page = 10, $orderby = 'title', $license = '', $subject = '')
{
if (function_exists('pb_meets_minimum_requirements') && pb_meets_minimum_requirements()) {
$request = new \WP_REST_Request('GET', '/pressbooks/v2/books');
$request->set_query_params([
'page' => $page,
'per_page' => $per_page,
]);
$response = rest_do_request($request);
$pages = $response->headers['X-WP-TotalPages'];
$data = rest_get_server()->response_to_data($response, true);
$books = [];
foreach ($data as $key => $book) {
$book['title'] = $book['metadata']['name'];
$book['date-published'] = (isset($book['metadata']['datePublished'])) ?
$book['metadata']['datePublished'] :
'';
$book['subject'] = (isset($book['metadata']['about'][0]))
? $book['metadata']['about'][0]['identifier']
: '';
$books[] = $book;
}
if ($orderby === 'latest') {
$books = wp_list_sort($books, $orderby, 'desc');
} else {
$books = wp_list_sort($books, $orderby);
}
return ['pages' => $pages, 'books' => $books];
} else {
return ['pages' => 0, 'books' => []];
}
}
}

79
app/filters.php

@ -1,79 +0,0 @@
<?php
namespace Aldine;
/**
* Add <body> classes
*/
add_filter('body_class', function (array $classes) {
/** Add page slug if it doesn't exist */
if (is_single() || is_page() && !is_front_page()) {
if (!in_array(basename(get_permalink()), $classes)) {
$classes[] = basename(get_permalink());
}
}
/** Clean up class names for custom templates */
$classes = array_map(function ($class) {
return preg_replace(['/-blade(-php)?$/', '/^page-template-views/'], '', $class);
}, $classes);
return array_filter($classes);
});
/**
* Add "… Continued" to the excerpt
*/
add_filter('excerpt_more', function () {
return ' &hellip; <a href="' . get_permalink() . '">' . __('Continued', 'aldine') . '</a>';
});
/**
* Template Hierarchy should search for .blade.php files
*/
collect([
'index', '404', 'archive', 'author', 'category', 'tag', 'taxonomy', 'date', 'home',
'frontpage', 'page', 'paged', 'search', 'single', 'singular', 'attachment'
])->map(function ($type) {
add_filter("{$type}_template_hierarchy", __NAMESPACE__.'\\filter_templates');
});
/**
* Render page using Blade
*/
add_filter('template_include', function ($template) {
$data = collect(get_body_class())->reduce(function ($data, $class) use ($template) {
return apply_filters("sage/template/{$class}/data", $data, $template);
}, []);
if ($template) {
echo template($template, $data);
return get_stylesheet_directory().'/index.php';
}
return $template;
}, PHP_INT_MAX);
/**
* Tell WordPress how to find the compiled path of comments.blade.php
*/
add_filter('comments_template', function ($comments_template) {
$comments_template = str_replace(
[get_stylesheet_directory(), get_template_directory()],
'',
$comments_template
);
return template_path(locate_template(["views/{$comments_template}", $comments_template]) ?: $comments_template);
});
/**
* Fix Controller path
*/
add_filter('sober/controller/path', function () {
return get_template_directory() . '/app/controllers';
});
/**
* Remove Admin Bar callback
*/
add_action('admin_bar_init', function () {
remove_action('wp_head', '_admin_bar_bump_cb');
});

202
app/helpers.php

@ -1,202 +0,0 @@
<?php
namespace Aldine;
use Roots\Sage\Container;
/**
* Get the sage container.
*
* @param string $abstract
* @param array $parameters
* @param Container $container
* @return Container|mixed
*/
function sage($abstract = null, $parameters = [], Container $container = null)
{
$container = $container ?: Container::getInstance();
if (!$abstract) {
return $container;
}
return $container->bound($abstract)
? $container->makeWith($abstract, $parameters)
: $container->makeWith("sage.{$abstract}", $parameters);
}
/**
* Get / set the specified configuration value.
*
* If an array is passed as the key, we will assume you want to set an array of values.
*
* @param array|string $key
* @param mixed $default
* @return mixed|\Roots\Sage\Config
* @copyright Taylor Otwell
* @link https://github.com/laravel/framework/blob/c0970285/src/Illuminate/Foundation/helpers.php#L254-L265
*/
function config($key = null, $default = null)
{
if (is_null($key)) {
return sage('config');
}
if (is_array($key)) {
return sage('config')->set($key);
}
return sage('config')->get($key, $default);
}
/**
* @param string $file
* @param array $data
* @return string
*/
function template($file, $data = [])
{
if (remove_action('wp_head', 'wp_enqueue_scripts', 1)) {
wp_enqueue_scripts();
}
return sage('blade')->render($file, $data);
}
/**
* Retrieve path to a compiled blade view
* @param $file
* @param array $data
* @return string
*/
function template_path($file, $data = [])
{
return sage('blade')->compiledPath($file, $data);
}
/**
* @param $asset
* @return string
*/
function asset_path($asset)
{
return fix_path(sage('assets')->getUri('/' . $asset));
}
/**
* @param $asset
* @return string
*/
function asset_dir($asset)
{
return fix_path(sage('assets')->get('/' . $asset));
}
/**
* @param string|string[] $templates Possible template files
* @return array
*/
function filter_templates($templates)
{
$paths = apply_filters('sage/filter_templates/paths', [
'views',
'resources/views'
]);
$paths_pattern = "#^(" . implode('|', $paths) . ")/#";
return collect($templates)
->map(function ($template) use ($paths_pattern) {
/** Remove .blade.php/.blade/.php from template names */
$template = preg_replace('#\.(blade\.?)?(php)?$#', '', ltrim($template));
/** Remove partial $paths from the beginning of template names */
if (strpos($template, '/')) {
$template = preg_replace($paths_pattern, '', $template);
}
return $template;
})
->flatMap(function ($template) use ($paths) {
return collect($paths)
->flatMap(function ($path) use ($template) {
return [
"{$path}/{$template}.blade.php",
"{$path}/{$template}.php",
"{$template}.blade.php",
"{$template}.php",
];
});
})
->filter()
->unique()
->all();
}
/**
* @param string|string[] $templates Relative path to possible template files
* @return string Location of the template
*/
function locate_template($templates)
{
return \locate_template(filter_templates($templates));
}
/**
*
* Catch a contact form submission.
*
* @return false | array
*/
function contact_form_submission()
{
if (isset($_POST['submitted'])) {
$output = [];
$name = (isset($_POST['visitor_name'])) ? $_POST['visitor_name'] : false;
$email = (isset($_POST['visitor_email'])) ? $_POST['visitor_email'] : false;
$institution = (isset($_POST['visitor_institution'])) ? $_POST['visitor_institution'] : false;
$message = (isset($_POST['message'])) ? $_POST['message'] : false;
if (!$name) {
$output['message'] = __('Name is required.', 'aldine');
$output['status'] = 'error';
$output['field'] = 'visitor_name';
} elseif (!$email) {
$output['message'] = __('Email is required.', 'aldine');
$output['status'] = 'error';
$output['field'] = 'visitor_email';
} elseif (!filter_var($email, FILTER_VALIDATE_EMAIL)) {
$output['message'] = __('Email is invalid.', 'aldine');
$output['status'] = 'error';
$output['field'] = 'visitor_email';
} elseif (!$institution) {
$output['message'] = __('Institution is required.', 'aldine');
$output['status'] = 'error';
$output['field'] = 'visitor_institution';
} elseif (!$message) {
$output['message'] = __('Message is required.', 'aldine');
$output['status'] = 'error';
$output['field'] = 'message';
} else {
$sent = wp_mail(
get_option('admin_email'),
sprintf(__('Contact Form Submission from %s', 'aldine'), $name),
sprintf(
"From: %1\$s <%2\$s>\n%3\$s",
$name,
$email,
strip_tags($message)
),
"From: ${email}\r\nReply-To: ${email}\r\n"
);
if ($sent) {
$output['message'] = __('Your message was sent!', 'aldine');
$output['status'] = 'success';
} else {
$output['message'] = __('Your message could not be sent.', 'aldine');
$output['status'] = 'error';
}
}
return $output;
}
return false;
}
function fix_path($path)
{
return str_replace('/dist//', '/dist/', $path);
}

38
app/intervention.php

@ -1,38 +0,0 @@
<?php
namespace Aldine;
use function \Sober\Intervention\intervention;
if (function_exists('\Sober\Intervention\intervention')) {
intervention('remove-customizer-items', 'static-front-page', 'all');
intervention('remove-emoji');
intervention('remove-howdy', __('Hello,', 'aldine'));
intervention('remove-dashboard-items', ['activity', 'quick-draft']);
intervention('remove-menu-items', [
'posts',
'tools',
'setting-writing',
'setting-reading',
'setting-permalink'
], 'all');
intervention('remove-widgets', [
'pages',
'calendar',
'archives',
'links',
'media-audio',
'meta',
'search',
'categories',
'recent-posts',
'recent-comments',
'rss',
'tag-cloud',
'custom-menu',
'custom-html',
'media-video',
'akismet',
], 'all');
intervention('remove-toolbar-frontend', 'all');
}

199
app/setup.php

@ -1,199 +0,0 @@
<?php
namespace Aldine;
use Roots\Sage\Container;
use Roots\Sage\Assets\JsonManifest;
use Roots\Sage\Template\Blade;
use Roots\Sage\Template\BladeProvider;
/**
* Theme assets
*/
add_action('wp_enqueue_scripts', function () {
$webfonts = 'https://fonts.googleapis.com/css?family=Karla:400,400i,700|Spectral:400,400i,600';
wp_enqueue_style('aldine/webfonts', $webfonts, false, null);
wp_enqueue_style('aldine/main.css', asset_path('styles/main.css'), false, null);
wp_enqueue_script('aldine/main.js', asset_path('scripts/main.js'), ['jquery'], null, true);
wp_localize_script('aldine/main.js', 'SAGE_DIST_PATH', get_theme_file_uri() . '/dist/');
}, 100);
/**
* Theme setup
*/
add_action('after_setup_theme', function () {
/**
* Enable plugins to manage the document title
* @link https://developer.wordpress.org/reference/functions/add_theme_support/#title-tag
*/
add_theme_support('title-tag');
/**
* Register navigation menus
* @link https://developer.wordpress.org/reference/functions/register_nav_menus/
*/
register_nav_menus([
'network-footer-menu' => __('Network Footer Menu', 'aldine')
]);
/**
* Enable custom headers
* @link https://developer.wordpress.org/themes/functionality/custom-headers/
*/
add_theme_support('custom-header', [
'default-image' => asset_path('images/header.jpg'),
'width' => 1920,
'height' => 884,
'default-text-color' => '#000',
]);
/**
* Enable custom logos
* @link https://developer.wordpress.org/themes/functionality/custom-logo/
*/
add_theme_support('custom-logo', [
'height' => 40,
'width' => 265,
'flex-width' => true,
'flex-height' => true,
]);
/**
* Enable post thumbnails
* @link https://developer.wordpress.org/themes/functionality/featured-images-post-thumbnails/
*/
add_theme_support('post-thumbnails');
/**
* Enable HTML5 markup support
* @link https://developer.wordpress.org/reference/functions/add_theme_support/#html5
*/
add_theme_support('html5', ['caption', 'comment-form', 'comment-list', 'gallery', 'search-form']);
/**
* Enable selective refresh for widgets in customizer
* @link https://developer.wordpress.org/themes/advanced-topics/customizer-api/#theme-support-in-sidebars
*/
add_theme_support('customize-selective-refresh-widgets');
/**
* Use main stylesheet for visual editor
* @see resources/assets/styles/layouts/_tinymce.scss
*/
add_editor_style(asset_path('styles/main.css'));
}, 20);
/**
* Register sidebars
*/
add_action('widgets_init', function () {
$config = [
'before_widget' => '<section class="widget %1$s %2$s">',
'after_widget' => '</section>',
'before_title' => '<h2>',
'after_title' => '</h2>'
];
register_sidebar([
'name' => __('Front Page Content', 'aldine'),
'description' => __(
'Add content for your network&rsquo;s front page here. Currently, only text widgets are supported.',
'aldine'
),
'id' => 'front-page-block',
'before_widget' => '<section class="block %1$s %2$s">',
'after_widget' => '</section>',
'before_title' => '<h2>',
'after_title' => '</h2>'
]);
register_sidebar([
'name' => __('Network Footer Block 1', 'aldine'),
'description' => __(
'Add content for your network&rsquo;s customizeable footer here.
Currently, only text and image widgets are supported.
Content in this widget area will appear in the first row (on mobile) or the first column (on desktops).',
'aldine'
),
'id' => 'network-footer-block-1'
] + $config);
register_sidebar([
'name' => __('Network Footer Block 2', 'aldine'),
'description' => __(
'Add content for your network&rsquo;s customizeable footer here.
Currently, only text and image widgets are supported.
Content in this widget area will appear in the second row (on mobile) or the middle column (on desktop).',
'aldine'
),
'id' => 'network-footer-block-2'
] + $config);
});
/**
* Updates the `$post` variable on each iteration of the loop.
* Note: updated value is only available for subsequently loaded views, such as partials
*/
add_action('the_post', function ($post) {
sage('blade')->share('post', $post);
});
/**
* Setup Sage options
*/
add_action('after_setup_theme', function () {
/**
* Add JsonManifest to Sage container
*/
sage()->singleton('sage.assets', function () {
return new JsonManifest(config('assets.manifest'), config('assets.uri'));
});
/**
* Add Blade to Sage container
*/
sage()->singleton('sage.blade', function (\Illuminate\Container\Container $app) {
$cachePath = config('view.compiled');
if (!file_exists($cachePath)) {
wp_mkdir_p($cachePath);
}
(new BladeProvider($app))->register();
return new Blade($app['view']);
});
/**
* Create @asset() Blade directive
*/
sage('blade')->compiler()->directive('asset', function ($asset) {
return "<?= " . __NAMESPACE__ . "\\asset_path({$asset}); ?>";
});
});
add_action('wp_head', function () {
$primary = get_option('pb_network_color_primary');
$accent = get_option('pb_network_color_accent');
$primary_fg = get_option('pb_network_color_primary_fg');
$accent_fg = get_option('pb_network_color_accent_fg');
$header_text = get_header_textcolor();
if ($primary || $accent || $primary_fg || $accent_fg || $header_text) { ?>
<style type="text/css">:root {
<?php if ($primary) { ?>
--primary: <?= $primary ?>;
<?php }
if ($accent) { ?>
--accent: <?= $accent ?>;
<?php }
if ($primary_fg) { ?>
--primary-fg: <?= $primary_fg ?>;
<?php }
if ($accent_fg) { ?>
--accent-fg: <?= $accent_fg ?>;
<?php }
if ($header_text) { ?>
--header-text: <?= $header_text ?>;
<?php } ?>
}</style>
<?php }
});
add_action('wp_head', function () {
$response = contact_form_submission();
sage('blade')->share('contact_form_response', $response);
});

2
assets/scripts/customizer.js

@ -1,5 +1,5 @@
import $ from 'jquery';
wp.customize( 'blogname', value => {
value.bind( to => $( '.brand' ).text( to ) );
value.bind( to => $( '.brand a' ).text( to ) );
} );

6
dist/mix-manifest.json vendored

@ -1,5 +1,5 @@
{
"/scripts/aldine.js": "/scripts/aldine.js?id=8a707791c89c90b8f4c6",
"/styles/aldine.css": "/styles/aldine.css?id=8021de4bdd5014faae77",
"/scripts/customizer.js": "/scripts/customizer.js?id=9be871217cf240694b73"
"/scripts/aldine.js": "/scripts/aldine.js",
"/styles/aldine.css": "/styles/aldine.css",
"/scripts/customizer.js": "/scripts/customizer.js"
}

14600
dist/scripts/aldine.js vendored

File diff suppressed because one or more lines are too long

10356
dist/scripts/customizer.js vendored

File diff suppressed because one or more lines are too long

3052
dist/styles/aldine.css vendored

File diff suppressed because one or more lines are too long

74
footer.php

@ -8,25 +8,71 @@
*
* @package Aldine
*/
?>
<?php
$network_facebook = get_option( 'pb_network_facebook' );
$network_twitter = get_option( 'pb_network_twitter' );
$pb_network_contact_form = get_option( 'pb_network_contact_form' );
?>
</div><!-- #content -->
<footer id="colophon" class="site-footer">
<div class="site-info">
<a href="<?php echo esc_url( __( 'https://wordpress.org/', 'pressbooks-aldine' ) ); ?>"><?php
/* translators: %s: CMS name, i.e. WordPress. */
printf( esc_html__( 'Proudly powered by %s', 'pressbooks-aldine' ), 'WordPress' );
?></a>
<span class="sep"> | </span>
<?php
/* translators: 1: Theme name, 2: Theme author. */
printf( esc_html__( 'Theme: %1$s by %2$s.', 'pressbooks-aldine' ), 'pressbooks-aldine', '<a href="https://pressbooks.org">Pressbooks (Book Oven Inc.)</a>' );
?>
</div><!-- .site-info -->
</footer><!-- #colophon -->
</div><!-- #page -->
<footer class="footer<?php echo is_front_page() ? ' footer--home' : ' footer--inside' ?>">
<div class="footer__inner">
<?php if ( $pb_network_contact_form ) :
include( locate_template( 'partials/contact-form.php' ) );
endif; ?>
<section class="footer__network">
<div class="footer__network__block">
<?php dynamic_sidebar( 'network-footer-block-1' ); ?>
</div>
<div class="footer__network__block">
<?php dynamic_sidebar( 'network-footer-block-2' ); ?>
<div class="social-media">
<?php if ( $network_facebook ) { ?>
<a class="link near-black hover-silver dib h2 w2 mr3" href="<?php echo $network_facebook; ?>" title="<?php printf( __( '%s on Facebook', 'aldine' ), get_bloginfo( 'name', 'display' ) ); ?>">
<svg fill="currentColor" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16" fill-rule="evenodd" clip-rule="evenodd" stroke-linejoin="round" stroke-miterlimit="1.414"><path d="M15.117 0H.883C.395 0 0 .395 0 .883v14.234c0 .488.395.883.883.883h7.663V9.804H6.46V7.39h2.086V5.607c0-2.066 1.262-3.19 3.106-3.19.883 0 1.642.064 1.863.094v2.16h-1.28c-1 0-1.195.476-1.195 1.176v1.54h2.39l-.31 2.416h-2.08V16h4.077c.488 0 .883-.395.883-.883V.883C16 .395 15.605 0 15.117 0" fill-rule="nonzero"/></svg>
</a>
<?php } ?>
<?php if ( $network_twitter ) { ?>
<a class="link near-black hover-silver dib h2 w2 mr3" href="<?php echo $network_twitter; ?>" title="<?php printf( __( '%s on Twitter', 'aldine' ), get_bloginfo( 'name', 'display' ) ); ?>">
<svg fill="currentColor" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16" fill-rule="evenodd" clip-rule="evenodd" stroke-linejoin="round" stroke-miterlimit="1.414"><path d="M16 3.038c-.59.26-1.22.437-1.885.517.677-.407 1.198-1.05 1.443-1.816-.634.375-1.337.648-2.085.795-.598-.638-1.45-1.036-2.396-1.036-1.812 0-3.282 1.468-3.282 3.28 0 .258.03.51.085.75C5.152 5.39 2.733 4.084 1.114 2.1.83 2.583.67 3.147.67 3.75c0 1.14.58 2.143 1.46 2.732-.538-.017-1.045-.165-1.487-.41v.04c0 1.59 1.13 2.918 2.633 3.22-.276.074-.566.114-.865.114-.21 0-.416-.02-.617-.058.418 1.304 1.63 2.253 3.067 2.28-1.124.88-2.54 1.404-4.077 1.404-.265 0-.526-.015-.783-.045 1.453.93 3.178 1.474 5.032 1.474 6.038 0 9.34-5 9.34-9.338 0-.143-.004-.284-.01-.425.64-.463 1.198-1.04 1.638-1.7z" fill-rule="nonzero"/></svg>
</a>
<?php } ?>
</div>
</div>
<div class="network-footer__block network-footer__menu">
<?php wp_nav_menu( 'network-footer-menu' ); ?>
</div>
</section>
<section class="footer__pressbooks">
<a class="footer__pressbooks__icon" href="https://pressbooks.com" title="Pressbooks">
<svg class="icon--svg">
<use xlink:href="#icon-pressbooks" />
</svg>
</a>
<div class="footer__pressbooks__links">
<h1 class="footer__pressbooks__links__title"><a href="https://pressbooks.com"><?php printf( __( 'Powered by %s', 'pressbooks-book' ), '<span class="pressbooks">Pressbooks</span>' ); ?></a></h1>
<ul class="footer__pressbooks__links__list">
<li><a href="https://pressbooks.org"><?php _e( 'Open Source', 'pressbooks-book' ); ?></a> |</li>
<li><a href="https://pressbooks.com/for-academia"><?php _e( 'Open Textbooks', 'pressbooks-book' ); ?></a> |</li>
<li><a href="https://pressbooks.com"><?php _e( 'Open Book Publishing', 'pressbooks-book' ); ?></a> |</li>
<li><a href="https://pressbooks.com/about"><?php _e( 'Learn More', 'pressbooks-book' ); ?></a> </li>
</ul>
</div>
<div class="footer__pressbooks__social">
<a class="icon icon-facebook" href="https://facebook.com/pressbooks2" title="<?php _e( 'Pressbooks on Facebook', 'pressbooks-book' ); ?>"> </a>
<a class="icon icon-twitter" href="https://twitter.com/intent/follow?screen_name=pressbooks" title="<?php _e( 'Pressbooks on Twitter', 'pressbooks-book' ); ?>"> </a>
</div>
</section>
</div><!-- .container -->
</footer><!-- .footer -->
<?php get_template_part( 'content', 'accessibility-toolbar' ); ?>
<?php wp_footer(); ?>

8
functions.php

@ -39,11 +39,9 @@ require get_template_directory() . '/inc/intervention.php';
add_action( 'admin_init', '\\Aldine\\Activation\\create_default_content' );
add_action( 'admin_bar_init', '\\Aldine\\Actions\\remove_admin_bar_callback' );
add_action( 'customize_register', '\\Aldine\\Customizer\\customize_register' );
add_action( 'customize_preview_init', '\\Aldine\\Customizer\\customize_preview_js' );
add_action( 'wp_head', '\\Aldine\\Actions\\output_custom_colors' );
add_filter( 'body_class', '\\Aldine\\Filters\\body_classes' );
add_filter( 'excerpt_more', '\\Aldine\\Filters\\excerpt_more' );
if ( ! function_exists( 'pressbooks_aldine_setup' ) ) :
/**
@ -193,6 +191,8 @@ function pressbooks_aldine_scripts() {
wp_enqueue_style( 'aldine/style', $assets->getPath( 'styles/aldine.css' ), false, null );
wp_enqueue_style( 'aldine/webfonts', 'https://fonts.googleapis.com/css?family=Karla:400,400i,700|Spectral:400,400i,600', false, null );
wp_enqueue_script( 'aldine/script', $assets->getPath( 'scripts/aldine.js' ), [ 'jquery' ], null, true );
wp_register_script( 'aldine/customizer', $assets->getPath( 'scripts/customizer.js' ), [ 'customize-preview' ], false, null );
}
add_action( 'wp_enqueue_scripts', 'pressbooks_aldine_scripts' );
add_action( 'customize_register', '\\Aldine\\Customizer\\customize_register' );
add_action( 'customize_preview_init', '\\Aldine\\Customizer\\customize_preview_js' );

134
inc/customizer/namespace.php

@ -7,12 +7,14 @@
namespace Aldine\Customizer;
use PressbooksMix\Assets;
/**
* Add postMessage support for site title and description for the Theme Customizer.
*
* @param WP_Customize_Manager $wp_customize Theme Customizer object.
*/
function customize_register( $wp_customize ) {
function customize_register( \WP_Customize_Manager $wp_customize ) {
$wp_customize->get_setting( 'blogname' )->transport = 'postMessage';
$wp_customize->get_setting( 'blogdescription' )->transport = 'postMessage';
$wp_customize->get_setting( 'header_textcolor' )->transport = 'postMessage';
@ -27,6 +29,118 @@ function customize_register( $wp_customize ) {
'render_callback' => __NAMESPACE__ . '\\customize_partial_blogdescription',
] );
}
foreach ( [
[
'slug' => 'primary',
'hex' => '#b01109',
'label' => __( 'Primary Color', 'aldine' ),
'description' => __( 'Primary color, used for links and other primary elements.', 'aldine' ),
],
[
'slug' => 'accent',
'hex' => '#015d75',
'label' => __( 'Accent Color', 'aldine' ),
'description' => __( 'Accent color, used for flourishes and secondary elements.', 'aldine' ),
],
[
'slug' => 'primary_fg',
'hex' => '#ffffff',
'label' => __( 'Primary Foreground Color', 'aldine' ),
'description' => __( 'Used for text on a primary background.', 'aldine' ),
],
[
'slug' => 'accent_fg',
'hex' => '#ffffff',
'label' => __( 'Accent Foreground Color', 'aldine' ),
'description' => __( 'Used for text on an accent color background.', 'aldine' ),
],
] as $color ) {
$wp_customize->add_setting("pb_network_color_{$color['slug']}", [
'type' => 'option',
'default' => $color['hex'],
]);
$wp_customize->add_control(new \WP_Customize_Color_Control(
$wp_customize,
"pb_network_color_{$color['slug']}",
[
'label' => $color['label'],
'section' => 'colors',
'description' => $color['description'],
'settings' => "pb_network_color_{$color['slug']}",
]
));
}
$wp_customize->add_section('pb_network_social', [
'title' => __( 'Social Media', 'aldine' ),
'priority' => 30,
]);
$wp_customize->add_setting('pb_network_facebook', [
'type' => 'option',
'sanitize_callback' => 'esc_url_raw',
]);
$wp_customize->add_control('pb_network_facebook', [
'label' => __( 'Facebook', 'aldine' ),
'section' => 'pb_network_social',
'settings' => 'pb_network_facebook',
]);
$wp_customize->add_setting('pb_network_twitter', [
'type' => 'option',
'sanitize_callback' => 'esc_url_raw',
]);
$wp_customize->add_control('pb_network_twitter', [
'label' => __( 'Twitter', 'aldine' ),
'section' => 'pb_network_social',
'settings' => 'pb_network_twitter',
]);
if ( function_exists( 'pb_meets_minimum_requirements' ) && pb_meets_minimum_requirements() ) {
$wp_customize->add_section('pb_front_page_catalog', [
'title' => __( 'Front Page Catalog', 'aldine' ),
'priority' => 25,
]);
$wp_customize->add_setting('pb_front_page_catalog', [
'type' => 'option',
]);
$wp_customize->add_control('pb_front_page_catalog', [
'label' => __( 'Show Front Page Catalog', 'aldine' ),
'section' => 'pb_front_page_catalog',
'settings' => 'pb_front_page_catalog',
'type' => 'checkbox',
]);
$wp_customize->add_setting('pb_front_page_catalog_title', [
'type' => 'option',
'sanitize_callback' => 'sanitize_text_field',
]);
$wp_customize->add_control('pb_front_page_catalog_title', [
'label' => __( 'Front Page Catalog Title', 'aldine' ),
'section' => 'pb_front_page_catalog',
'settings' => 'pb_front_page_catalog_title',
]);
}
$wp_customize->add_section('pb_network_contact_form', [
'title' => __( 'Contact Form', 'aldine' ),
'priority' => 25,
]);
$wp_customize->add_setting('pb_network_contact_form', [
'type' => 'option',
]);
$wp_customize->add_control('pb_network_contact_form', [
'label' => __( 'Show Contact Form', 'aldine' ),
'section' => 'pb_network_contact_form',
'settings' => 'pb_network_contact_form',
'type' => 'checkbox',
]);
$wp_customize->add_setting('pb_network_contact_form_title', [
'type' => 'option',
'sanitize_callback' => 'sanitize_text_field',
]);
$wp_customize->add_control('pb_network_contact_form_title', [
'label' => __( 'Contact Form Title', 'aldine' ),
'section' => 'pb_network_contact_form',
'settings' => 'pb_network_contact_form_title',
]);
}
/**
@ -51,5 +165,21 @@ function customize_partial_blogdescription() {
* Binds JS handlers to make Theme Customizer preview reload changes asynchronously.
*/
function customize_preview_js() {
wp_enqueue_script( 'aldine/customizer' );
$assets = new Assets( 'pressbooks-aldine', 'theme' );
$assets->setSrcDirectory( 'assets' )->setDistDirectory( 'dist' );
wp_enqueue_script( 'aldine/customizer', $assets->getPath( 'scripts/customizer.js' ), [ 'customize-preview' ], false, null );
wp_enqueue_script( 'wcag-validate-customizer-color-contrast', get_template_directory_uri() . '/lib/customizer-validate-wcag-color-contrast/customizer-validate-wcag-color-contrast.js', [ 'customize-controls' ] );
$exports = [
'validate_color_contrast' => [
'pb_network_color_primary_fg' => [ 'pb_network_color_primary' ],
'pb_network_color_accent_fg' => [ 'pb_network_color_accent' ],
],
];
wp_scripts()->add_data(
'wcag-validate-customizer-color-contrast',
'data',
sprintf( 'var _validateWCAGColorContrastExports = %s;', wp_json_encode( $exports ) )
);
}

26
inc/filters/namespace.php

@ -10,14 +10,30 @@ namespace Aldine\Filters;
/**
* Adds custom classes to the array of body classes.
*
* @see https://github.com/roots/sage/blob/master/app/filters.php
*
* @param array $classes Classes for the body element.
* @return array
*/
function body_classes( $classes ) {
// Adds a class of hfeed to non-singular pages.
if ( ! is_singular() ) {
$classes[] = 'hfeed';
function body_classes( array $classes ) {
/** Add page slug if it doesn't exist */
if ( is_single() || is_page() && ! is_front_page() ) {
if ( ! in_array( basename( get_permalink() ), $classes, true ) ) {
$classes[] = basename( get_permalink() );
}
}
return $classes;
/** Clean up class names for custom templates */
$classes = array_map( function ( $class ) {
return preg_replace( [ '/-php$/', '/^page-template-/' ], '', $class );
}, $classes);
return array_filter( $classes );
}
/**
* Customize excerpt.
*/
function excerpt_more() {
return ' &hellip; <a href="' . get_permalink() . '">' . __( 'Continued', 'aldine' ) . '</a>';
}

110
inc/helpers/namespace.php

@ -6,3 +6,113 @@
*/
namespace Aldine\Helpers;
/**
* Get catalog data.
*
* @param int $page
* @param int $per_page
* @param string $orderby
* @param string $license
* @param string $subject
*/
function get_catalog_data( $page = 1, $per_page = 10, $orderby = 'title', $license = '', $subject = '' ) {
if ( function_exists( 'pb_meets_minimum_requirements' ) && pb_meets_minimum_requirements() ) {
$request = new \WP_REST_Request( 'GET', '/pressbooks/v2/books' );
$request->set_query_params([
'page' => $page,
'per_page' => $per_page,
]);
$response = rest_do_request( $request );
$pages = $response->headers['X-WP-TotalPages'];
$data = rest_get_server()->response_to_data( $response, true );
$books = [];
foreach ( $data as $key => $book ) {
$book['title'] = $book['metadata']['name'];
$book['date-published'] = ( isset( $book['metadata']['datePublished'] ) ) ?
$book['metadata']['datePublished'] :
'';
$book['subject'] = ( isset( $book['metadata']['about'][0] ) )
? $book['metadata']['about'][0]['identifier']
: '';
$books[] = $book;
}
if ( $orderby === 'latest' ) {
$books = wp_list_sort( $books, $orderby, 'desc' );
} else {
$books = wp_list_sort( $books, $orderby );
}
return [ 'pages' => $pages, 'books' => $books ];
} else {
return [ 'pages' => 0, 'books' => [] ];
}
}
/**
*
* Handler for contact form submissions.
*
* @return false | array
*/
function handle_contact_form_submission() {
if ( ! isset( $_POST['pb_root_contact_form_nonce'] ) || ! wp_verify_nonce( $_POST['pb_root_contact_form_nonce'], 'pb_root_contact_form' ) ) {
return; // Security check failed.
}
if ( isset( $_POST['submitted'] ) ) {
$output = [];
$name = ( isset( $_POST['visitor_name'] ) ) ? $_POST['visitor_name'] : '';
$email = ( isset( $_POST['visitor_email'] ) ) ? $_POST['visitor_email'] : '';
$institution = ( isset( $_POST['visitor_institution'] ) ) ? $_POST['visitor_institution'] : '';
$message = ( isset( $_POST['message'] ) ) ? $_POST['message'] : '';
$output['values'] = [
'visitor_name' => esc_attr( $name ),
'visitor_email' => sanitize_email( $email ),
'visitor_institution' => esc_attr( $institution ),
'message' => esc_textarea( $message ),
];
if ( empty( $name ) ) {
$output['message'] = __( 'Name is required.', 'aldine' );
$output['status'] = 'error';
$output['field'] = 'visitor_name';
} elseif ( empty( $email ) ) {
$output['message'] = __( 'Email is required.', 'aldine' );
$output['status'] = 'error';
$output['field'] = 'visitor_email';
} elseif ( ! filter_var( $email, FILTER_VALIDATE_EMAIL ) ) {
$output['message'] = __( 'Email is invalid.', 'aldine' );
$output['status'] = 'error';
$output['field'] = 'visitor_email';
} elseif ( empty( $institution ) ) {
$output['message'] = __( 'Institution is required.', 'aldine' );
$output['status'] = 'error';
$output['field'] = 'visitor_institution';
} elseif ( empty( $message ) ) {
$output['message'] = __( 'Message is required.', 'aldine' );
$output['status'] = 'error';
$output['field'] = 'message';
} else {
$sent = wp_mail(
get_option( 'admin_email' ),
sprintf( __( 'Contact Form Submission from %s', 'aldine' ), $name ),
sprintf(
"From: %1\$s <%2\$s>\nInstitution: %3\$s\n\n%4\$s",
stripslashes( $name ),
$email,
stripslashes( $institution ),
strip_tags( $message )
),
"From: ${email}\r\nReply-To: ${email}\r\n"
);
if ( $sent ) {
$output['message'] = __( 'Your message was sent!', 'aldine' );
$output['status'] = 'success';
} else {
$output['message'] = __( 'Your message could not be sent.', 'aldine' );
$output['status'] = 'error';
}
}
return $output;
}
return;
}

22
page.php

@ -17,17 +17,23 @@ get_header(); ?>
<div id="primary" class="content-area">
<main id="main" class="site-main">
<?php
while ( have_posts() ) : the_post();
<?php if ( is_front_page() ) :
get_template_part( 'template-parts/content', 'page' );
get_template_part( 'partials/content', 'front-page' );
// If comments are open or we have at least one comment, load up the comment template.
if ( comments_open() || get_comments_number() ) :
comments_template();
endif;
else :
endwhile; // End of the loop.
while ( have_posts() ) : the_post();
get_template_part( 'partials/content', 'page' );
// If comments are open or we have at least one comment, load up the comment template.
if ( comments_open() || get_comments_number() ) :
comments_template();
endif;
endwhile; // End of the loop.
endif;
?>
</main><!-- #main -->

45
partials/contact-form.php

@ -1 +1,46 @@
<?php
/**
* Template part for displaying the contact form
*
* @package Aldine
*/
?>
<?php
$contact_form_title = get_option( 'pb_network_contact_form_title', __( 'Contact Us', 'aldine' ) );
$contact_form_response = \Aldine\Helpers\handle_contact_form_submission();
?>
<section class="contact" id="contact">
<h2><?php echo $contact_form_title; ?></h2>
<form class="form" action="<?php echo network_home_url( '/#contact' ); ?>" method="post">
<?php if ( $contact_form_response ) : ?>
<p class="form__notice form__notice--<?php echo $contact_form_response['status']; ?>"><?php echo $contact_form_response['message']; ?></p>
<?php endif; ?>
<?php wp_nonce_field( 'pb_root_contact_form', 'pb_root_contact_form_nonce' ); ?>
<input type="hidden" name="submitted" value="1">
<p class="form__row<?php if ( isset( $contact_form_response['field'] ) && $contact_form_response['field'] === 'visitor_name' ) : ?> form__row--error<?php endif; ?>">
<label class="clip" for="visitor_name"><?php _e( 'Your name*', 'aldine' ); ?></label>
<input type="text" placeholder="<?php _e( 'Your name*', 'aldine' ); ?>" name="visitor_name" value="<?php if ( $contact_form_response['status'] === 'error' ) :
echo $contact_form_response['values']['visitor_name'];
endif; ?>" required></p>
<p class="form__row<?php if ( isset( $contact_form_response['field'] ) && $contact_form_response['field'] === 'visitor_email' ) : ?> form__row--error<?php endif; ?>">
<label class="clip" for="visitor_email"><?php _e( 'Your email*', 'aldine' ); ?></label>
<input type="email" placeholder="<?php _e( 'Your email*', 'aldine' ); ?>" name="visitor_email" value="<?php if ( $contact_form_response['status'] === 'error' ) :
echo $contact_form_response['values']['visitor_email'];
endif; ?>" required></p>
<p class="form__row<?php if ( isset( $contact_form_response['field'] ) && $contact_form_response['field'] === 'visitor_institution' ) : ?> form__row--error<?php endif; ?>">
<label class="clip" for="visitor_institution"><?php _e( 'Your institution*', 'aldine' ); ?></label>
<input type="text" placeholder="<?php _e( 'Your institution*', 'aldine' ); ?>" name="visitor_institution" value="<?php if ( $contact_form_response['status'] === 'error' ) :
echo $contact_form_response['values']['visitor_institution'];
endif; ?>" required></p>
<p class="form__row<?php if ( isset( $contact_form_response['field'] ) && $contact_form_response['field'] === 'message' ) : ?> form__row--error<?php endif; ?>">
<label class="clip" for="message"><?php _e( 'Your message here*', 'aldine' ); ?></label>
<textarea type="text" placeholder="<?php _e( 'Your message here*', 'aldine' ); ?>" name="message" required><?php if ( $contact_form_response['status'] === 'error' ) :
echo $contact_form_response['values']['message'];
endif; ?></textarea></p>
<p class="form__row"><input class="button button--small button--outline" type="submit" value="<?php _e( 'Send', 'aldine' ); ?>" /></p>
</form>
</section>

59
partials/content-front-page.php

@ -0,0 +1,59 @@
<?php
/**
* Template part for displaying the front page
*
* @link https://developer.wordpress.org/themes/basics/template-hierarchy/
*
* @package Aldine
*/
?>
<?php
use function Aldine\Helpers\get_catalog_data;
$block_count = 1;
$front_page_catalog = get_option( 'pb_front_page_catalog' );
$latest_books_title = get_option( 'pb_front_page_catalog_title', __( 'Our Latest Titles', 'aldine' ) );
$page = ( get_query_var( 'page' ) ) ? get_query_var( 'page' ) : 1;
$catalog_data = get_catalog_data( $page, 3 );
$previous_page = ( $page > 1 ) ? $page - 1 : 0;
$next_page = $page + 1;
?>
<section class="blocks blocks-<?php echo $block_count; ?> w-100">
<?php if ( is_active_sidebar( 'front-page-block' ) ) :
dynamic_sidebar( 'front-page-block' );
else : ?>
<div class="block flex flex-column items-center justify-center p-0 w-100">
<div class="inside tc">
<h3 class="tc ttu"><?php _e( 'About Pressbooks', 'aldine' ) ?></h3>
<p><?php _e( 'Pressbooks is easy-to-use book writing software that lets you create a book in all the formats you need to publish.', 'aldine' ); ?></p>
<a class="button" href="<?php echo network_home_url( '/about/' ); ?>"><?php _e( 'Learn More', 'aldine' ) ?></a>
</div>
</div>
<?php endif; ?>
<?php if ( get_option( 'pb_front_page_catalog' ) ) : ?>
<div id="latest-titles" class="latest-books">
<h3><?php echo $latest_books_title; ?></h3>
<div class="track">
<div class="books" data-total-pages="{{ $catalog_data["pages"] }}" <?php if ( $next_page <= $catalog_data['pages'] ) : ?>data-next-page="{{ $next_page }}"<?php endif; ?>>
<?php foreach ( $catalog_data['books'] as $book ) :
include( locate_template( 'partials/book.php' ) );
endforeach; ?>
</div>
<?php if ( $previous_page ) : ?>
<a class="previous" data-page="<?php echo $previous_page; ?>" href="<?php echo network_home_url( "/page/$previous_page/#latest-titles" ); ?>"></a>
<?php endif; ?>
<?php if ( $next_page <= $catalog_data['pages'] ) : ?>
<a class="next" data-page="<?php echo $next_page; ?>" href="<?php echo network_home_url( "/page/$next_page/#latest-titles" ); ?>"></a>
<?php endif; ?>
</div>
<div class="catalog-link">
<a class="button button--outline button--wide" href="<?php echo network_home_url( '/catalog/' ); ?>"><?php _e( 'View Complete Catalog', 'aldine' ); ?></a>
</div>
</div>
<?php endif; ?>
</section>

14
resources/views/404.blade.php

@ -1,14 +0,0 @@
@extends('layouts.app')
@section('content')
@include('partials.page-header')
@if (!have_posts())
<div class="alert alert-warning">
{{ __('Sorry, but the page you were trying to view does not exist.', 'aldine') }}
</div>
{!! get_search_form(false) !!}
@endif
{!! get_the_posts_navigation() !!}
@endsection

47
resources/views/front-page.blade.php

@ -1,47 +0,0 @@
@extends('layouts.app')
@section('content')
<section class="blocks blocks-{{ $block_count }} w-100">
@if(is_active_sidebar('front-page-block'))
@php(dynamic_sidebar('front-page-block'))
@else
@component('partials.page-block')
@slot('title')
{{ __('About Pressbooks', 'aldine') }}
@endslot
<p>{{ __('Pressbooks is easy-to-use book writing software that lets you create a book in all the formats you need to publish.', 'aldine')}}</p>
@slot('button_title')
{{ __('Learn More', 'aldine') }}
@endslot
@slot('button_url')
{{ network_home_url('/about/') }}
@endslot
@endcomponent
@endif
@if(get_option('pb_front_page_catalog'))
<div id="latest-titles" class="latest-books">
<h3>{{ $latest_books_title }}</h3>
<div class="track">
<div class="books" data-total-pages="{{ $catalog_data['pages'] }}" @if($next_page <= $catalog_data['pages'])data-next-page="{{ $next_page }}"@endif>
@foreach($catalog_data['books'] as $book)
@include('partials.book', ['book' => $book])
@endforeach
</div>
@if($previous_page)
<a class="previous" data-page="{{ $previous_page }}" href="{{ network_home_url("/page/$previous_page/#latest-titles") }}">
@php(include get_theme_file_path() . '/dist/' . Aldine\asset_dir('images/left-arrow.svg'))
</a>
@endif
@if($next_page <= $catalog_data['pages'])
<a class="next" data-page="{{ $next_page }}" href="{{ network_home_url("/page/$next_page/#latest-titles") }}">
@php(include get_theme_file_path() . '/dist/' . Aldine\asset_dir('images/right-arrow.svg'))
</a>
@endif
</div>
<div class="catalog-link">
<a class="button button--outline button--wide" href="{{ network_home_url('/catalog/') }}">{{ __('View Complete Catalog', 'aldine') }}</a>
</div>
</div>
@endif
</section>
@endsection

18
resources/views/index.blade.php

@ -1,18 +0,0 @@
@extends('layouts.app')
@section('content')
@include('partials.page-header')
@if (!have_posts())
<div class="alert alert-warning">
{{ __('Sorry, no results were found.', 'sage') }}
</div>
{!! get_search_form(false) !!}
@endif
@while (have_posts()) @php(the_post())
@include('partials.content-'.get_post_type())
@endwhile
{!! get_the_posts_navigation() !!}
@endsection

21
resources/views/layouts/app.blade.php

@ -1,21 +0,0 @@
<!doctype html>
<html @php(language_attributes())>
@include('partials.head')
<body @php(body_class('no-js'))>
@include('partials.svg')
{{-- @include('partials.uio') --}}
@php(do_action('get_header'))
@include('partials.header')
<div class="wrap container" role="document">
<div class="content">
<main class="main">
@yield('content')
</main>
</div>
</div>
@php(do_action('get_footer'))
@include('partials.footer')
@php(wp_footer())
{{-- @include('partials.uio-script') --}}
</body>
</html>

10
resources/views/page.blade.php

@ -1,10 +0,0 @@
@extends('layouts.app')
@section('content')
@while(have_posts()) @php(the_post())
<section class="page-content">
@include('partials.page-header')
@include('partials.content-page')
</section>
@endwhile
@endsection

17
resources/views/partials/book.blade.php

@ -1,17 +0,0 @@
<div class="book"
data-date-published="{{ str_replace('-', '', @$book['metadata']['datePublished']) }}"
data-license="{{ (new \Pressbooks\Licensing())->getLicenseFromUrl($book['metadata']['license']['url']) }}"
data-subject="{{ substr(@$book['subject'], 0, 2) }}"
>
@if(isset($book['metadata']['keywords']))
<p class="book__subject">
<a href="{{ network_home_url('/catalog/#') . substr($book['subject'], 0, 2) }}">{{ \Pressbooks\Metadata\get_subject_from_thema($book['subject']) }}</a>
</p>
@endif
<p class="book__title">
<a href="{{ $book['link'] }}">{{ $book['metadata']['name'] }}</a>
</p>
<p class="book__read-more">
<a href="{{ $book['link'] }}">{{ __('About this book &rarr;', 'aldine') }}</a>
</p>
</div>

38
resources/views/partials/comments.blade.php

@ -1,38 +0,0 @@
@php
if (post_password_required()) {
return;
}
@endphp
<section id="comments" class="comments">
@if (have_comments())
<h2>
{!! sprintf(_nx('One response to &ldquo;%2$s&rdquo;', '%1$s responses to &ldquo;%2$s&rdquo;', get_comments_number(), 'comments title', 'aldine'), number_format_i18n(get_comments_number()), '<span>' . get_the_title() . '</span>') !!}
</h2>
<ol class="comment-list">
{!! wp_list_comments(['style' => 'ol', 'short_ping' => true]) !!}
</ol>
@if (get_comment_pages_count() > 1 && get_option('page_comments'))
<nav>
<ul class="pager">
@if (get_previous_comments_link())
<li class="previous">@php(previous_comments_link(__('&larr; Older comments', 'aldine')))</li>
@endif
@if (get_next_comments_link())
<li class="next">@php(next_comments_link(__('Newer comments &rarr;', 'aldine')))</li>
@endif
</ul>
</nav>
@endif
@endif
@if (!comments_open() && get_comments_number() != '0' && post_type_supports(get_post_type(), 'comments'))
<div class="alert alert-warning">
{{ __('Comments are closed.', 'aldine') }}
</div>
@endif
@php(comment_form())
</section>

22
resources/views/partials/contact-form.blade.php

@ -1,22 +0,0 @@
<section class="contact" id="contact">
<h2>{{ $contact_form_title }}</h2>
<form class="form" action="{{ network_home_url('/#contact') }}" method="post">
@if($contact_form_response)
<p class="form__notice form__notice--{{ $contact_form_response['status'] }}">{{ $contact_form_response['message'] }}</p>
@endif
<input type="hidden" name="submitted" value="1">
<p class="form__row @if(@$contact_form_response['field'] === 'visitor_name'){{ 'form__row--error' }}@endif">
<label class="clip" for="visitor_name">{{ __('Your name*', 'aldine' ) }}</label>
<input type="text" placeholder="{{ __('Your name*', 'aldine' ) }}" name="visitor_name" value="@if($contact_form_response['status'] === 'error'){{ @esc_attr($_POST['visitor_name']) }}@endif"></p>
<p class="form__row @if(@$contact_form_response['field'] === 'visitor_email'){{ 'form__row--error' }}@endif">
<label class="clip" for="visitor_email">{{ __('Your email*', 'aldine' ) }}</label>
<input type="email" placeholder="{{ __('Your email*', 'aldine' ) }}" name="visitor_email" value="@if($contact_form_response['status'] === 'error'){{ @esc_attr($_POST['visitor_email']) }}@endif"></p>
<p class="form__row @if(@$contact_form_response['field'] === 'visitor_institution'){{ 'form__row--error' }}@endif">
<label class="clip" for="visitor_institution">{{ __('Your institution*', 'aldine' ) }}</label>
<input type="text" placeholder="{{ __('Your institution*', 'aldine' ) }}" name="visitor_institution" value="@if($contact_form_response['status'] === 'error'){{ @esc_attr($_POST['visitor_institution']) }}@endif"></p>
<p class="form__row @if(@$contact_form_response['field'] === 'message'){{ 'form__row--error' }}@endif">
<label class="clip" for="message">{{ __('Your message here', 'aldine' ) }}</label>
<textarea type="text" placeholder="{{ __('Your message here', 'aldine' ) }}" name="message">@if($contact_form_response['status'] === 'error'){{ @esc_textarea($_POST['message']) }}@endif</textarea></p>
<p class="form__row"><input class="button button--small button--outline" type="submit" value="{{ __('Send', 'aldine' ) }}" /></p>
</form>
</section>

2
resources/views/partials/content-page.blade.php

@ -1,2 +0,0 @@
@php(the_content())
{!! wp_link_pages(['echo' => 0, 'before' => '<nav class="page-nav"><p>' . __('Pages:', 'aldine'), 'after' => '</p></nav>']) !!}

11
resources/views/partials/content-search.blade.php

@ -1,11 +0,0 @@
<article @php(post_class())>
<header>
<h2 class="entry-title"><a href="{{ get_permalink() }}">{{ get_the_title() }}</a></h2>
@if (get_post_type() === 'post')
@include('partials/entry-meta')
@endif
</header>
<div class="entry-summary">
@php(the_excerpt())
</div>
</article>

13
resources/views/partials/content-single.blade.php

@ -1,13 +0,0 @@
<article @php(post_class())>
<header>
<h1 class="entry-title">{{ get_the_title() }}</h1>
@include('partials/entry-meta')
</header>
<div class="entry-content">
@php(the_content())
</div>
<footer>
{!! wp_link_pages(['echo' => 0, 'before' => '<nav class="page-nav"><p>' . __('Pages:', 'aldine'), 'after' => '</p></nav>']) !!}
</footer>
@php(comments_template('/partials/comments.blade.php'))
</article>

9
resources/views/partials/content.blade.php

@ -1,9 +0,0 @@
<article @php(post_class())>
<header>
<h2 class="entry-title"><a href="{{ get_permalink() }}">{{ get_the_title() }}</a></h2>
@include('partials/entry-meta')
</header>
<div class="entry-summary">
@php(the_excerpt())
</div>
</article>

6
resources/views/partials/entry-meta.blade.php

@ -1,6 +0,0 @@
<time class="updated" datetime="{{ get_post_time('c', true) }}">{{ get_the_date() }}</time>
<p class="byline author vcard">
{{ __('By', 'aldine') }} <a href="{{ get_author_posts_url(get_the_author_meta('ID')) }}" rel="author" class="fn">
{{ get_the_author() }}
</a>
</p>

50
resources/views/partials/footer.blade.php

@ -1,50 +0,0 @@
<footer class="footer">
<div class="footer__inner container">
@if(get_option('pb_network_contact_form'))
@include('partials.contact-form')
@endif
<section class="network-footer" style="display: none;">
<div class="network-footer__block network-footer__block--{{ App::networkFooter(1) }}">
@php(dynamic_sidebar('network-footer-block-1'))
</div>
<div class="network-footer__block network-footer__block--{{ App::networkFooter(2) }}">
@php(dynamic_sidebar('network-footer-block-2'))
<div class="social-media">
@if($network_facebook)
<a class="link near-black hover-silver dib h2 w2 mr3" href="{{ $network_facebook }}" title="{{ sprintf(__('%s on Facebook', 'aldine'), get_bloginfo('name', 'display')) }}">
<svg fill="currentColor" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16" fill-rule="evenodd" clip-rule="evenodd" stroke-linejoin="round" stroke-miterlimit="1.414"><path d="M15.117 0H.883C.395 0 0 .395 0 .883v14.234c0 .488.395.883.883.883h7.663V9.804H6.46V7.39h2.086V5.607c0-2.066 1.262-3.19 3.106-3.19.883 0 1.642.064 1.863.094v2.16h-1.28c-1 0-1.195.476-1.195 1.176v1.54h2.39l-.31 2.416h-2.08V16h4.077c.488 0 .883-.395.883-.883V.883C16 .395 15.605 0 15.117 0" fill-rule="nonzero"/></svg>
</a>
@endif
@if($network_twitter)
<a class="link near-black hover-silver dib h2 w2 mr3" href="{{ $network_twitter }}" title="{{ sprintf(__('%s on Twitter', 'aldine'), get_bloginfo('name', 'display')) }}">
<svg fill="currentColor" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16" fill-rule="evenodd" clip-rule="evenodd" stroke-linejoin="round" stroke-miterlimit="1.414"><path d="M16 3.038c-.59.26-1.22.437-1.885.517.677-.407 1.198-1.05 1.443-1.816-.634.375-1.337.648-2.085.795-.598-.638-1.45-1.036-2.396-1.036-1.812 0-3.282 1.468-3.282 3.28 0 .258.03.51.085.75C5.152 5.39 2.733 4.084 1.114 2.1.83 2.583.67 3.147.67 3.75c0 1.14.58 2.143 1.46 2.732-.538-.017-1.045-.165-1.487-.41v.04c0 1.59 1.13 2.918 2.633 3.22-.276.074-.566.114-.865.114-.21 0-.416-.02-.617-.058.418 1.304 1.63 2.253 3.067 2.28-1.124.88-2.54 1.404-4.077 1.404-.265 0-.526-.015-.783-.045 1.453.93 3.178 1.474 5.032 1.474 6.038 0 9.34-5 9.34-9.338 0-.143-.004-.284-.01-.425.64-.463 1.198-1.04 1.638-1.7z" fill-rule="nonzero"/></svg>
</a>
@endif
</div>
</div>
<div class="network-footer__block network-footer__menu">
@php(wp_nav_menu('network-footer-menu'))
</div>
</section>
<section class="footer__pressbooks">
<a class="footer__pressbooks__icon" href="https://pressbooks.com" title="Pressbooks">
<svg class="icon--svg">
<use xlink:href="#icon-pressbooks" />
</svg>
</a>
<div class="footer__pressbooks__links">
<h1 class="footer__pressbooks__links__title"><a href="https://pressbooks.com">{!! sprintf( __( 'Powered by %s', 'pressbooks-book' ), '<span class="pressbooks">Pressbooks</span>' ) !!}</a></h1>
<ul class="footer__pressbooks__links__list">
<li><a href="https://pressbooks.org">{{ __('Open Source', 'aldine') }}</a> |</li>
<li><a href="https://pressbooks.com/for-academia">{{ __('Open Textbooks', 'aldine') }}</a> |</li>
<li><a href="https://pressbooks.com">{{ __('Open Book Publishing', 'aldine') }}</a> |</li>
<li><a href="https://pressbooks.com/about">{{ __('Learn More', 'aldine') }}</a> </li>
</ul>
</div>
<div class="footer__pressbooks__social">
<a class="icon icon-facebook" href="https://facebook.com/pressbooks2" title="{{ __('Pressbooks on Facebook', 'aldine') }}"> </a>
<a class="icon icon-twitter" href="https://twitter.com/intent/follow?screen_name=pressbooks" title="{{ __('Pressbooks on Twitter', 'aldine') }}"> </a>
</div>
</section>
</div>
</footer>

6
resources/views/partials/head.blade.php

@ -1,6 +0,0 @@
<head>
<meta charset="utf-8">
<meta http-equiv="x-ua-compatible" content="ie=edge">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
@php(wp_head())
</head>

7
resources/views/partials/page-block.blade.php

@ -1,7 +0,0 @@
<div class="block flex flex-column items-center justify-center p-0 w-100">
<div class="inside tc">
<h3 class="tc ttu">{{ $title }}</h3>
{{ $slot }}
<a class="button" href="{{ $button_url }}">{{ $button_title }}</a>
</div>
</div>

1
resources/views/partials/sidebar.blade.php

@ -1 +0,0 @@
@php(dynamic_sidebar('sidebar-primary'))

11
resources/views/partials/uio-script.blade.php

@ -1,11 +0,0 @@
<script type="text/javascript">
$(document).ready(function () {
fluid.uiOptions.prefsEditor(".flc-prefsEditor-separatedPanel", {
tocTemplate: "/app/themes/pressbooks-aldine/lib/infusion/src/components/tableOfContents/html/TableOfContents.html",
terms: {
templatePrefix: "/app/themes/pressbooks-aldine/lib/infusion/src/framework/preferences/html",
messagePrefix: "/app/themes/pressbooks-aldine/lib/infusion/src/framework/preferences/messages"
}
});
})
</script>

9
resources/views/partials/uio.blade.php

@ -1,9 +0,0 @@
<div class="flc-prefsEditor-separatedPanel fl-prefsEditor-separatedPanel">
<div class="flc-slidingPanel-panel flc-prefsEditor-iframe"></div>
<div class="fl-panelBar">
<span class="fl-prefsEditor-buttons">
<button id="reset" class="flc-prefsEditor-reset fl-prefsEditor-reset"><span class="fl-icon-undo"></span>{{ __('Reset', 'aldine') }}</button>
<button id="show-hide" class="flc-slidingPanel-toggleButton fl-prefsEditor-showHide">{{ __('Show/Hide', 'aldine') }}</button>
</span>
</div>
</div>

18
resources/views/search.blade.php

@ -1,18 +0,0 @@
@extends('layouts.app')
@section('content')
@include('partials.page-header')
@if (!have_posts())
<div class="alert alert-warning">
{{ __('Sorry, no results were found.', 'aldine') }}
</div>
{!! get_search_form(false) !!}
@endif
@while(have_posts()) @php(the_post())
@include('partials.content-search')
@endwhile
{!! get_the_posts_navigation() !!}
@endsection

7
resources/views/single.blade.php

@ -1,7 +0,0 @@
@extends('layouts.app')
@section('content')
@while(have_posts()) @php(the_post())
@include('partials.content-single-'.get_post_type())
@endwhile
@endsection

12
resources/views/template-custom.blade.php

@ -1,12 +0,0 @@
{{--
Template Name: Custom Template
--}}
@extends('layouts.app')
@section('content')
@while(have_posts()) @php(the_post())
@include('partials.page-header')
@include('partials.content-page')
@endwhile
@endsection

0
resources/views/page-catalog.blade.php → views/page-catalog.blade.php

0
resources/views/partials/header.blade.php → views/partials/header.blade.php

0
resources/views/partials/page-header.blade.php → views/partials/page-header.blade.php

0
resources/views/partials/svg.blade.php → views/partials/svg.blade.php

Before

Width:  |  Height:  |  Size: 1.3 KiB

After

Width:  |  Height:  |  Size: 1.3 KiB

Loading…
Cancel
Save